1 /*
2  * Copyright (C) 2022 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 package com.android.bedstead.permissions;
18 
19 /** Methods available to classes which maintain permission contexts. */
20 public interface PermissionsController {
21     /** Enter a permission context with the given permissions. */
withPermission(String... permissions)22     PermissionContext withPermission(String... permissions);
23     /** Enter a permission context with the given permissions only when on a matching version. */
withPermissionOnVersion(int sdkVersion, String... permissions)24     PermissionContext withPermissionOnVersion(int sdkVersion, String... permissions);
25     /** Enter a permission context with the given permissions only when on a matching version. */
withPermissionOnVersionAtLeast(int minSdkVersion, String... permissions)26     PermissionContext withPermissionOnVersionAtLeast(int minSdkVersion, String... permissions);
27     /** Enter a permission context with the given permissions only when on a matching version. */
withPermissionOnVersionAtMost(int maxSdkVersion, String... permissions)28     PermissionContext withPermissionOnVersionAtMost(int maxSdkVersion, String... permissions);
29     /** Enter a permission context with the given permissions only when on a matching version. */
withPermissionOnVersionBetween( int minSdkVersion, int maxSdkVersion, String... permissions)30     PermissionContext withPermissionOnVersionBetween(
31             int minSdkVersion, int maxSdkVersion, String... permissions);
32     /** Enter a permission context without the given permissions. */
withoutPermission(String... permissions)33     PermissionContext withoutPermission(String... permissions);
34 
35     /** Enter a permission context with the given app op. */
withAppOp(String... appOps)36     PermissionContext withAppOp(String... appOps);
37     /** Enter a permission context with the given app op only when on a matching version. */
withAppOpOnVersion(int sdkVersion, String... appOps)38     PermissionContext withAppOpOnVersion(int sdkVersion, String... appOps);
39     /** Enter a permission context with the given app op only when on a matching version. */
withAppOpOnVersionAtLeast(int minSdkVersion, String... appOps)40     PermissionContext withAppOpOnVersionAtLeast(int minSdkVersion, String... appOps);
41     /** Enter a permission context with the given app op only when on a matching version. */
withAppOpOnVersionAtMost(int maxSdkVersion, String... appOps)42     PermissionContext withAppOpOnVersionAtMost(int maxSdkVersion, String... appOps);
43     /** Enter a permission context with the given app op only when on a matching version. */
withAppOpOnVersionBetween( int minSdkVersion, int maxSdkVersion, String... appOps)44     PermissionContext withAppOpOnVersionBetween(
45             int minSdkVersion, int maxSdkVersion, String... appOps);
46     /** Enter a permission context without the given app op. */
withoutAppOp(String... appOps)47     PermissionContext withoutAppOp(String... appOps);
48 }
49 
50 
51 
52