Link PACKAGE_USAGE_STATS with LOADER_USAGE_STATS

Bug: 148374455
Test: Manual
Test: Create three packages; 1) only request PACKAGE_USAGE_STATS, 2) only request LOADER_USAGE_STATS, 3) request both
Test: Go to Settings -> Apps & Notifications -> Special app access
Test: See that there is only a single entry for "Usage access"
Test: Under "Usage access", see all three test apps appear
Test: Disable access for each application and verify that only the appop for the declared permisson is flipped using
Test: adb shell cmd appops get <<PACKAGE_NAME>>
Change-Id: I7741a703fd4494832347e51e113adf974cc31d2b
This commit is contained in:
Todd Kennedy
2020-01-27 15:15:02 -08:00
parent f160cbed83
commit b6aaed1bfc
3 changed files with 46 additions and 7 deletions

View File

@@ -61,17 +61,27 @@ public abstract class AppStateAppOpsBridge extends AppStateBaseBridge {
this(context, appState, callback, appOpsOpCode, permissions,
AppGlobals.getPackageManager());
}
AppStateAppOpsBridge(Context context, ApplicationsState appState, Callback callback,
int[] appOpsOpCodes, String[] permissions) {
this(context, appState, callback, appOpsOpCodes, permissions,
AppGlobals.getPackageManager());
}
@VisibleForTesting
AppStateAppOpsBridge(Context context, ApplicationsState appState, Callback callback,
int appOpsOpCode, String[] permissions, IPackageManager packageManager) {
this(context, appState, callback, new int[] {appOpsOpCode}, permissions,
packageManager);
}
AppStateAppOpsBridge(Context context, ApplicationsState appState, Callback callback,
int[] appOpsOpCodes, String[] permissions, IPackageManager packageManager) {
super(appState, callback);
mContext = context;
mIPackageManager = packageManager;
mUserManager = UserManager.get(context);
mProfiles = mUserManager.getUserProfiles();
mAppOpsManager = (AppOpsManager) context.getSystemService(Context.APP_OPS_SERVICE);
mAppOpsOpCodes = new int[] {appOpsOpCode};
mAppOpsOpCodes = appOpsOpCodes;
mPermissions = permissions;
}