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 android.permission; 18 19 import android.content.AttributionSourceState; 20 import android.content.pm.ParceledListSlice; 21 import android.content.pm.PermissionGroupInfo; 22 import android.content.pm.PermissionInfo; 23 import android.content.pm.permission.SplitPermissionInfoParcelable; 24 import android.os.UserHandle; 25 import android.permission.IOnPermissionsChangeListener; 26 import android.permission.PermissionManager.PermissionState; 27 28 /** 29 * Interface to communicate directly with the permission manager service. 30 * @see PermissionManager 31 * @hide 32 */ 33 interface IPermissionManager { getAllPermissionGroups(int flags)34 ParceledListSlice getAllPermissionGroups(int flags); 35 getPermissionGroupInfo(String groupName, int flags)36 PermissionGroupInfo getPermissionGroupInfo(String groupName, int flags); 37 getPermissionInfo(String permissionName, String packageName, int flags)38 PermissionInfo getPermissionInfo(String permissionName, String packageName, int flags); 39 queryPermissionsByGroup(String groupName, int flags)40 ParceledListSlice queryPermissionsByGroup(String groupName, int flags); 41 addPermission(in PermissionInfo permissionInfo, boolean async)42 boolean addPermission(in PermissionInfo permissionInfo, boolean async); 43 removePermission(String permissionName)44 void removePermission(String permissionName); 45 getPermissionFlags(String packageName, String permissionName, String persistentDeviceId, int userId)46 int getPermissionFlags(String packageName, String permissionName, String persistentDeviceId, 47 int userId); 48 updatePermissionFlags(String packageName, String permissionName, int flagMask, int flagValues, boolean checkAdjustPolicyFlagPermission, String persistentDeviceId, int userId)49 void updatePermissionFlags(String packageName, String permissionName, int flagMask, 50 int flagValues, boolean checkAdjustPolicyFlagPermission, String persistentDeviceId, 51 int userId); 52 updatePermissionFlagsForAllApps(int flagMask, int flagValues, int userId)53 void updatePermissionFlagsForAllApps(int flagMask, int flagValues, int userId); 54 addOnPermissionsChangeListener(in IOnPermissionsChangeListener listener)55 void addOnPermissionsChangeListener(in IOnPermissionsChangeListener listener); 56 removeOnPermissionsChangeListener(in IOnPermissionsChangeListener listener)57 void removeOnPermissionsChangeListener(in IOnPermissionsChangeListener listener); 58 getAllowlistedRestrictedPermissions(String packageName, int flags, int userId)59 List<String> getAllowlistedRestrictedPermissions(String packageName, 60 int flags, int userId); 61 addAllowlistedRestrictedPermission(String packageName, String permissionName, int flags, int userId)62 boolean addAllowlistedRestrictedPermission(String packageName, String permissionName, 63 int flags, int userId); 64 removeAllowlistedRestrictedPermission(String packageName, String permissionName, int flags, int userId)65 boolean removeAllowlistedRestrictedPermission(String packageName, String permissionName, 66 int flags, int userId); 67 grantRuntimePermission(String packageName, String permissionName, String persistentDeviceId, int userId)68 void grantRuntimePermission(String packageName, String permissionName, 69 String persistentDeviceId, int userId); 70 revokeRuntimePermission(String packageName, String permissionName, String persistentDeviceId, int userId, String reason)71 void revokeRuntimePermission(String packageName, String permissionName, 72 String persistentDeviceId, int userId, String reason); 73 revokePostNotificationPermissionWithoutKillForTest(String packageName, int userId)74 void revokePostNotificationPermissionWithoutKillForTest(String packageName, int userId); 75 shouldShowRequestPermissionRationale(String packageName, String permissionName, int deviceId, int userId)76 boolean shouldShowRequestPermissionRationale(String packageName, String permissionName, 77 int deviceId, int userId); 78 isPermissionRevokedByPolicy(String packageName, String permissionName, int deviceId, int userId)79 boolean isPermissionRevokedByPolicy(String packageName, String permissionName, int deviceId, 80 int userId); 81 getSplitPermissions()82 List<SplitPermissionInfoParcelable> getSplitPermissions(); 83 84 @EnforcePermission("MANAGE_ONE_TIME_PERMISSION_SESSIONS") startOneTimePermissionSession(String packageName, int deviceId, int userId, long timeout, long revokeAfterKilledDelay)85 void startOneTimePermissionSession(String packageName, int deviceId, int userId, long timeout, 86 long revokeAfterKilledDelay); 87 88 @EnforcePermission("MANAGE_ONE_TIME_PERMISSION_SESSIONS") stopOneTimePermissionSession(String packageName, int userId)89 void stopOneTimePermissionSession(String packageName, int userId); 90 getAutoRevokeExemptionRequestedPackages(int userId)91 List<String> getAutoRevokeExemptionRequestedPackages(int userId); 92 getAutoRevokeExemptionGrantedPackages(int userId)93 List<String> getAutoRevokeExemptionGrantedPackages(int userId); 94 setAutoRevokeExempted(String packageName, boolean exempted, int userId)95 boolean setAutoRevokeExempted(String packageName, boolean exempted, int userId); 96 isAutoRevokeExempted(String packageName, int userId)97 boolean isAutoRevokeExempted(String packageName, int userId); 98 registerAttributionSource(in AttributionSourceState source)99 IBinder registerAttributionSource(in AttributionSourceState source); 100 getRegisteredAttributionSourceCount(int uid)101 int getRegisteredAttributionSourceCount(int uid); 102 isRegisteredAttributionSource(in AttributionSourceState source)103 boolean isRegisteredAttributionSource(in AttributionSourceState source); 104 checkPermission(String packageName, String permissionName, String persistentDeviceId, int userId)105 int checkPermission(String packageName, String permissionName, String persistentDeviceId, 106 int userId); 107 checkUidPermission(int uid, String permissionName, int deviceId)108 int checkUidPermission(int uid, String permissionName, int deviceId); 109 getAllPermissionStates(String packageName, String persistentDeviceId, int userId)110 Map<String, PermissionState> getAllPermissionStates(String packageName, String persistentDeviceId, int userId); 111 } 112 113 /** 114 * Data class for the state of a permission requested by a package 115 * @hide 116 */ 117 parcelable PermissionManager.PermissionState; 118