1 /*
2  * Copyright (C) 2019 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.server.policy;
18 
19 import android.annotation.NonNull;
20 import android.annotation.Nullable;
21 import android.annotation.UserIdInt;
22 import android.content.Intent;
23 
24 /**
25  * Internal calls into {@link PermissionPolicyService}.
26  */
27 public abstract class PermissionPolicyInternal {
28 
29     /**
30      * Callback for initializing the permission policy service.
31      */
32     public interface OnInitializedCallback {
33 
34         /**
35          * Called when initialized for the given user.
36          *
37          * @param userId The initialized user.
38          */
onInitialized(@serIdInt int userId)39         void onInitialized(@UserIdInt int userId);
40     }
41 
42     /**
43      * Check whether an activity should be started.
44      *
45      * @param intent the {@link Intent} for the activity start
46      * @param callingUid the calling uid starting the activity
47      * @param callingPackage the calling package starting the activity
48      *
49      * @return whether the activity should be started
50      */
checkStartActivity(@onNull Intent intent, int callingUid, @Nullable String callingPackage)51     public abstract boolean checkStartActivity(@NonNull Intent intent, int callingUid,
52             @Nullable String callingPackage);
53 
54     /**
55      * @return Whether the policy is initialized for a user.
56      */
isInitialized(@serIdInt int userId)57     public abstract boolean isInitialized(@UserIdInt int userId);
58 
59     /**
60      * Set a callback for users being initialized. If the user is already
61      * initialized the callback will not be invoked.
62      *
63      * @param callback The callback to register.
64      */
setOnInitializedCallback(@onNull OnInitializedCallback callback)65     public abstract void setOnInitializedCallback(@NonNull OnInitializedCallback callback);
66 }
67