1 /*
2  * Copyright (C) 2023 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.role;
18 
19 import android.annotation.CallbackExecutor;
20 import android.annotation.NonNull;
21 import android.app.role.RoleManager;
22 import android.os.RemoteCallback;
23 
24 import java.util.List;
25 import java.util.concurrent.Executor;
26 import java.util.function.Consumer;
27 
28 public interface RoleController {
29     /**
30      * @see android.app.role.RoleControllerManager#grantDefaultRoles
31      */
grantDefaultRoles(@onNull @allbackExecutor Executor executor, @NonNull Consumer<Boolean> callback)32     void grantDefaultRoles(@NonNull @CallbackExecutor Executor executor,
33             @NonNull Consumer<Boolean> callback);
34 
35     /**
36      * @see android.app.role.RoleControllerManager#onAddRoleHolder
37      */
onAddRoleHolder(@onNull String roleName, @NonNull String packageName, @RoleManager.ManageHoldersFlags int flags, @NonNull RemoteCallback callback)38     void onAddRoleHolder(@NonNull String roleName, @NonNull String packageName,
39             @RoleManager.ManageHoldersFlags int flags, @NonNull RemoteCallback callback);
40 
41     /**
42      * @see android.app.role.RoleControllerManager#onRemoveRoleHolder
43      */
onRemoveRoleHolder(@onNull String roleName, @NonNull String packageName, @RoleManager.ManageHoldersFlags int flags, @NonNull RemoteCallback callback)44     void onRemoveRoleHolder(@NonNull String roleName, @NonNull String packageName,
45             @RoleManager.ManageHoldersFlags int flags, @NonNull RemoteCallback callback);
46 
47     /**
48      * @see android.app.role.RoleControllerManager#onClearRoleHolders
49      */
onClearRoleHolders(@onNull String roleName, @RoleManager.ManageHoldersFlags int flags, @NonNull RemoteCallback callback)50     void onClearRoleHolders(@NonNull String roleName,
51             @RoleManager.ManageHoldersFlags int flags, @NonNull RemoteCallback callback);
52 
53     /**
54      * @see android.app.role.RoleControllerManager#isRoleVisible
55      */
isRoleVisible(@onNull String roleName)56     boolean isRoleVisible(@NonNull String roleName);
57 
58     /**
59      * @see android.app.role.RoleControllerManager#isApplicationVisibleForRole
60      */
isApplicationVisibleForRole(@onNull String roleName, @NonNull String packageName)61     boolean isApplicationVisibleForRole(@NonNull String roleName, @NonNull String packageName);
62 
63     /**
64      * @see android.app.role.RoleControllerManager#getLegacyFallbackDisabledRoles
65      */
getLegacyFallbackDisabledRoles(@onNull @allbackExecutor Executor executor, @NonNull Consumer<List<String>> callback)66     void getLegacyFallbackDisabledRoles(@NonNull @CallbackExecutor Executor executor,
67             @NonNull Consumer<List<String>> callback);
68 }
69