1 /*
2  * Copyright (C) 2020 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.pm.permission;
18 
19 import android.annotation.AppIdInt;
20 import android.annotation.NonNull;
21 
22 import java.util.List;
23 import java.util.Map;
24 import java.util.Set;
25 
26 /**
27  * An interface for legacy code to read permission data in order to maintain compatibility.
28  */
29 //@SystemApi(client = SystemApi.Client.SYSTEM_SERVER)
30 public interface LegacyPermissionDataProvider {
31     /**
32      * Get all the legacy permissions currently registered in the system.
33      *
34      * @return the legacy permissions
35      */
36     @NonNull
getLegacyPermissions()37     List<LegacyPermission> getLegacyPermissions();
38 
39     /**
40      * Get all the package names requesting app op permissions.
41      *
42      * @return a map of app op permission names to package names requesting them
43      */
44     @NonNull
getAllAppOpPermissionPackages()45     Map<String, Set<String>> getAllAppOpPermissionPackages();
46 
47     /**
48      * Get the legacy permission state of an app ID, either a package or a shared user.
49      *
50      * @param appId the app ID
51      * @return the legacy permission state
52      */
53     @NonNull
getLegacyPermissionState(@ppIdInt int appId)54     LegacyPermissionState getLegacyPermissionState(@AppIdInt int appId);
55 
56     /**
57      * Get the GIDs computed from the permission state of a UID, either a package or a shared user.
58      *
59      * @param uid the UID
60      * @return the GIDs for the UID
61      */
62     @NonNull
getGidsForUid(int uid)63     int[] getGidsForUid(int uid);
64 
65     /**
66      * This method should be in PermissionManagerServiceInternal, however it is made available here
67      * as well to avoid serious performance regression in writePermissionSettings(), which seems to
68      * be a hot spot and we should delay calling this method until wre are actually writing the
69      * file, instead of every time an async write is requested.
70      *
71      * @see PermissionManagerServiceInternal#writeLegacyPermissionStateTEMP()
72      */
writeLegacyPermissionStateTEMP()73     void writeLegacyPermissionStateTEMP();
74 }
75