Loading services/core/java/com/android/server/pm/AppsFilter.java +91 −30 Original line number Original line Diff line number Diff line Loading @@ -84,6 +84,7 @@ public class AppsFilter implements Watchable, Snappable { // Logs all filtering instead of enforcing // Logs all filtering instead of enforcing private static final boolean DEBUG_ALLOW_ALL = false; private static final boolean DEBUG_ALLOW_ALL = false; private static final boolean DEBUG_LOGGING = false; private static final boolean DEBUG_LOGGING = false; private static final boolean DEBUG_TRACING = false; /** /** * This contains a list of app UIDs that are implicitly queryable because another app explicitly * This contains a list of app UIDs that are implicitly queryable because another app explicitly Loading Loading @@ -363,23 +364,31 @@ public class AppsFilter implements Watchable, Snappable { @Override @Override public boolean isGloballyEnabled() { public boolean isGloballyEnabled() { if (DEBUG_TRACING) { Trace.traceBegin(TRACE_TAG_PACKAGE_MANAGER, "isGloballyEnabled"); Trace.traceBegin(TRACE_TAG_PACKAGE_MANAGER, "isGloballyEnabled"); } try { try { return mFeatureEnabled; return mFeatureEnabled; } finally { } finally { if (DEBUG_TRACING) { Trace.traceEnd(TRACE_TAG_PACKAGE_MANAGER); Trace.traceEnd(TRACE_TAG_PACKAGE_MANAGER); } } } } } @Override @Override public boolean packageIsEnabled(AndroidPackage pkg) { public boolean packageIsEnabled(AndroidPackage pkg) { if (DEBUG_TRACING) { Trace.traceBegin(TRACE_TAG_PACKAGE_MANAGER, "packageIsEnabled"); Trace.traceBegin(TRACE_TAG_PACKAGE_MANAGER, "packageIsEnabled"); } try { try { return !mDisabledPackages.contains(pkg.getPackageName()); return !mDisabledPackages.contains(pkg.getPackageName()); } finally { } finally { if (DEBUG_TRACING) { Trace.traceEnd(TRACE_TAG_PACKAGE_MANAGER); Trace.traceEnd(TRACE_TAG_PACKAGE_MANAGER); } } } } } @Override @Override public boolean isLoggingEnabled(int uid) { public boolean isLoggingEnabled(int uid) { Loading Loading @@ -656,7 +665,9 @@ public class AppsFilter implements Watchable, Snappable { * @param isReplace if the package is being replaced and may need extra cleanup. * @param isReplace if the package is being replaced and may need extra cleanup. */ */ public void addPackage(PackageSetting newPkgSetting, boolean isReplace) { public void addPackage(PackageSetting newPkgSetting, boolean isReplace) { if (DEBUG_TRACING) { Trace.traceBegin(TRACE_TAG_PACKAGE_MANAGER, "filter.addPackage"); Trace.traceBegin(TRACE_TAG_PACKAGE_MANAGER, "filter.addPackage"); } try { try { if (isReplace) { if (isReplace) { // let's first remove any prior rules for this package // let's first remove any prior rules for this package Loading Loading @@ -689,9 +700,11 @@ public class AppsFilter implements Watchable, Snappable { }); }); } finally { } finally { onChanged(); onChanged(); if (DEBUG_TRACING) { Trace.traceEnd(TRACE_TAG_PACKAGE_MANAGER); Trace.traceEnd(TRACE_TAG_PACKAGE_MANAGER); } } } } } /** /** * @return Additional packages that may have had their viewing visibility changed and may need * @return Additional packages that may have had their viewing visibility changed and may need Loading Loading @@ -1173,7 +1186,9 @@ public class AppsFilter implements Watchable, Snappable { */ */ public boolean shouldFilterApplication(int callingUid, @Nullable SettingBase callingSetting, public boolean shouldFilterApplication(int callingUid, @Nullable SettingBase callingSetting, PackageSetting targetPkgSetting, int userId) { PackageSetting targetPkgSetting, int userId) { if (DEBUG_TRACING) { Trace.traceBegin(TRACE_TAG_PACKAGE_MANAGER, "shouldFilterApplication"); Trace.traceBegin(TRACE_TAG_PACKAGE_MANAGER, "shouldFilterApplication"); } try { try { int callingAppId = UserHandle.getAppId(callingUid); int callingAppId = UserHandle.getAppId(callingUid); if (callingAppId < Process.FIRST_APPLICATION_UID if (callingAppId < Process.FIRST_APPLICATION_UID Loading Loading @@ -1211,13 +1226,17 @@ public class AppsFilter implements Watchable, Snappable { } } return !DEBUG_ALLOW_ALL; return !DEBUG_ALLOW_ALL; } finally { } finally { if (DEBUG_TRACING) { Trace.traceEnd(TRACE_TAG_PACKAGE_MANAGER); Trace.traceEnd(TRACE_TAG_PACKAGE_MANAGER); } } } } } private boolean shouldFilterApplicationInternal(int callingUid, SettingBase callingSetting, private boolean shouldFilterApplicationInternal(int callingUid, SettingBase callingSetting, PackageSetting targetPkgSetting, int targetUserId) { PackageSetting targetPkgSetting, int targetUserId) { if (DEBUG_TRACING) { Trace.traceBegin(TRACE_TAG_PACKAGE_MANAGER, "shouldFilterApplicationInternal"); Trace.traceBegin(TRACE_TAG_PACKAGE_MANAGER, "shouldFilterApplicationInternal"); } try { try { final boolean featureEnabled = mFeatureConfig.isGloballyEnabled(); final boolean featureEnabled = mFeatureConfig.isGloballyEnabled(); if (!featureEnabled) { if (!featureEnabled) { Loading @@ -1232,7 +1251,9 @@ public class AppsFilter implements Watchable, Snappable { } } final PackageSetting callingPkgSetting; final PackageSetting callingPkgSetting; final ArraySet<PackageSetting> callingSharedPkgSettings; final ArraySet<PackageSetting> callingSharedPkgSettings; if (DEBUG_TRACING) { Trace.traceBegin(TRACE_TAG_PACKAGE_MANAGER, "callingSetting instanceof"); Trace.traceBegin(TRACE_TAG_PACKAGE_MANAGER, "callingSetting instanceof"); } if (callingSetting instanceof PackageSetting) { if (callingSetting instanceof PackageSetting) { if (((PackageSetting) callingSetting).sharedUser == null) { if (((PackageSetting) callingSetting).sharedUser == null) { callingPkgSetting = (PackageSetting) callingSetting; callingPkgSetting = (PackageSetting) callingSetting; Loading @@ -1246,7 +1267,9 @@ public class AppsFilter implements Watchable, Snappable { callingPkgSetting = null; callingPkgSetting = null; callingSharedPkgSettings = ((SharedUserSetting) callingSetting).packages; callingSharedPkgSettings = ((SharedUserSetting) callingSetting).packages; } } if (DEBUG_TRACING) { Trace.traceEnd(TRACE_TAG_PACKAGE_MANAGER); Trace.traceEnd(TRACE_TAG_PACKAGE_MANAGER); } if (callingPkgSetting != null) { if (callingPkgSetting != null) { if (callingPkgSetting.pkg != null if (callingPkgSetting.pkg != null Loading Loading @@ -1282,7 +1305,9 @@ public class AppsFilter implements Watchable, Snappable { return false; return false; } } final String targetName = targetPkg.getPackageName(); final String targetName = targetPkg.getPackageName(); if (DEBUG_TRACING) { Trace.traceBegin(TRACE_TAG_PACKAGE_MANAGER, "getAppId"); Trace.traceBegin(TRACE_TAG_PACKAGE_MANAGER, "getAppId"); } final int callingAppId; final int callingAppId; if (callingPkgSetting != null) { if (callingPkgSetting != null) { callingAppId = callingPkgSetting.appId; callingAppId = callingPkgSetting.appId; Loading @@ -1290,7 +1315,9 @@ public class AppsFilter implements Watchable, Snappable { callingAppId = callingSharedPkgSettings.valueAt(0).appId; // all should be the same callingAppId = callingSharedPkgSettings.valueAt(0).appId; // all should be the same } } final int targetAppId = targetPkgSetting.appId; final int targetAppId = targetPkgSetting.appId; if (DEBUG_TRACING) { Trace.traceEnd(TRACE_TAG_PACKAGE_MANAGER); Trace.traceEnd(TRACE_TAG_PACKAGE_MANAGER); } if (callingAppId == targetAppId) { if (callingAppId == targetAppId) { if (DEBUG_LOGGING) { if (DEBUG_LOGGING) { log(callingSetting, targetPkgSetting, "same app id"); log(callingSetting, targetPkgSetting, "same app id"); Loading @@ -1299,7 +1326,9 @@ public class AppsFilter implements Watchable, Snappable { } } try { try { if (DEBUG_TRACING) { Trace.traceBegin(TRACE_TAG_PACKAGE_MANAGER, "requestsQueryAllPackages"); Trace.traceBegin(TRACE_TAG_PACKAGE_MANAGER, "requestsQueryAllPackages"); } if (callingPkgSetting != null) { if (callingPkgSetting != null) { if (callingPkgSetting.pkg != null if (callingPkgSetting.pkg != null && requestsQueryAllPackages(callingPkgSetting.pkg)) { && requestsQueryAllPackages(callingPkgSetting.pkg)) { Loading @@ -1314,10 +1343,14 @@ public class AppsFilter implements Watchable, Snappable { } } } } } finally { } finally { if (DEBUG_TRACING) { Trace.traceEnd(TRACE_TAG_PACKAGE_MANAGER); Trace.traceEnd(TRACE_TAG_PACKAGE_MANAGER); } } } try { try { if (DEBUG_TRACING) { Trace.traceBegin(TRACE_TAG_PACKAGE_MANAGER, "mForceQueryable"); Trace.traceBegin(TRACE_TAG_PACKAGE_MANAGER, "mForceQueryable"); } if (mForceQueryable.contains(targetAppId)) { if (mForceQueryable.contains(targetAppId)) { if (DEBUG_LOGGING) { if (DEBUG_LOGGING) { log(callingSetting, targetPkgSetting, "force queryable"); log(callingSetting, targetPkgSetting, "force queryable"); Loading @@ -1325,10 +1358,14 @@ public class AppsFilter implements Watchable, Snappable { return false; return false; } } } finally { } finally { if (DEBUG_TRACING) { Trace.traceEnd(TRACE_TAG_PACKAGE_MANAGER); Trace.traceEnd(TRACE_TAG_PACKAGE_MANAGER); } } } try { try { if (DEBUG_TRACING) { Trace.traceBegin(TRACE_TAG_PACKAGE_MANAGER, "mQueriesViaPackage"); Trace.traceBegin(TRACE_TAG_PACKAGE_MANAGER, "mQueriesViaPackage"); } if (mQueriesViaPackage.contains(callingAppId, targetAppId)) { if (mQueriesViaPackage.contains(callingAppId, targetAppId)) { if (DEBUG_LOGGING) { if (DEBUG_LOGGING) { log(callingSetting, targetPkgSetting, "queries package"); log(callingSetting, targetPkgSetting, "queries package"); Loading @@ -1336,10 +1373,14 @@ public class AppsFilter implements Watchable, Snappable { return false; return false; } } } finally { } finally { if (DEBUG_TRACING) { Trace.traceEnd(TRACE_TAG_PACKAGE_MANAGER); Trace.traceEnd(TRACE_TAG_PACKAGE_MANAGER); } } } try { try { if (DEBUG_TRACING) { Trace.traceBegin(TRACE_TAG_PACKAGE_MANAGER, "mQueriesViaComponent"); Trace.traceBegin(TRACE_TAG_PACKAGE_MANAGER, "mQueriesViaComponent"); } if (mQueriesViaComponentRequireRecompute) { if (mQueriesViaComponentRequireRecompute) { mStateProvider.runWithState((settings, users) -> { mStateProvider.runWithState((settings, users) -> { recomputeComponentVisibility(settings); recomputeComponentVisibility(settings); Loading @@ -1352,11 +1393,15 @@ public class AppsFilter implements Watchable, Snappable { return false; return false; } } } finally { } finally { if (DEBUG_TRACING) { Trace.traceEnd(TRACE_TAG_PACKAGE_MANAGER); Trace.traceEnd(TRACE_TAG_PACKAGE_MANAGER); } } } try { try { if (DEBUG_TRACING) { Trace.traceBegin(TRACE_TAG_PACKAGE_MANAGER, "mImplicitlyQueryable"); Trace.traceBegin(TRACE_TAG_PACKAGE_MANAGER, "mImplicitlyQueryable"); } final int targetUid = UserHandle.getUid(targetUserId, targetAppId); final int targetUid = UserHandle.getUid(targetUserId, targetAppId); if (mImplicitlyQueryable.contains(callingUid, targetUid)) { if (mImplicitlyQueryable.contains(callingUid, targetUid)) { if (DEBUG_LOGGING) { if (DEBUG_LOGGING) { Loading @@ -1365,11 +1410,15 @@ public class AppsFilter implements Watchable, Snappable { return false; return false; } } } finally { } finally { if (DEBUG_TRACING) { Trace.traceEnd(TRACE_TAG_PACKAGE_MANAGER); Trace.traceEnd(TRACE_TAG_PACKAGE_MANAGER); } } } try { try { if (DEBUG_TRACING) { Trace.traceBegin(TRACE_TAG_PACKAGE_MANAGER, "mOverlayReferenceMapper"); Trace.traceBegin(TRACE_TAG_PACKAGE_MANAGER, "mOverlayReferenceMapper"); } if (callingSharedPkgSettings != null) { if (callingSharedPkgSettings != null) { int size = callingSharedPkgSettings.size(); int size = callingSharedPkgSettings.size(); for (int index = 0; index < size; index++) { for (int index = 0; index < size; index++) { Loading @@ -1392,11 +1441,15 @@ public class AppsFilter implements Watchable, Snappable { } } } } } finally { } finally { if (DEBUG_TRACING) { Trace.traceEnd(TRACE_TAG_PACKAGE_MANAGER); Trace.traceEnd(TRACE_TAG_PACKAGE_MANAGER); } } } try { try { if (DEBUG_TRACING) { Trace.traceBegin(TRACE_TAG_PACKAGE_MANAGER, "mQueryableViaUsesLibrary"); Trace.traceBegin(TRACE_TAG_PACKAGE_MANAGER, "mQueryableViaUsesLibrary"); } if (mQueryableViaUsesLibrary.contains(callingAppId, targetAppId)) { if (mQueryableViaUsesLibrary.contains(callingAppId, targetAppId)) { if (DEBUG_LOGGING) { if (DEBUG_LOGGING) { log(callingSetting, targetPkgSetting, "queryable for library users"); log(callingSetting, targetPkgSetting, "queryable for library users"); Loading @@ -1404,14 +1457,18 @@ public class AppsFilter implements Watchable, Snappable { return false; return false; } } } finally { } finally { if (DEBUG_TRACING) { Trace.traceEnd(TRACE_TAG_PACKAGE_MANAGER); Trace.traceEnd(TRACE_TAG_PACKAGE_MANAGER); } } } return true; return true; } finally { } finally { if (DEBUG_TRACING) { Trace.traceEnd(TRACE_TAG_PACKAGE_MANAGER); Trace.traceEnd(TRACE_TAG_PACKAGE_MANAGER); } } } } } private static boolean requestsQueryAllPackages(@NonNull AndroidPackage pkg) { private static boolean requestsQueryAllPackages(@NonNull AndroidPackage pkg) { Loading @@ -1425,7 +1482,9 @@ public class AppsFilter implements Watchable, Snappable { private static boolean pkgInstruments( private static boolean pkgInstruments( @NonNull AndroidPackage source, @NonNull AndroidPackage target) { @NonNull AndroidPackage source, @NonNull AndroidPackage target) { try { try { if (DEBUG_TRACING) { Trace.traceBegin(TRACE_TAG_PACKAGE_MANAGER, "pkgInstruments"); Trace.traceBegin(TRACE_TAG_PACKAGE_MANAGER, "pkgInstruments"); } final String packageName = target.getPackageName(); final String packageName = target.getPackageName(); final List<ParsedInstrumentation> inst = source.getInstrumentations(); final List<ParsedInstrumentation> inst = source.getInstrumentations(); for (int i = ArrayUtils.size(inst) - 1; i >= 0; i--) { for (int i = ArrayUtils.size(inst) - 1; i >= 0; i--) { Loading @@ -1435,9 +1494,11 @@ public class AppsFilter implements Watchable, Snappable { } } return false; return false; } finally { } finally { if (DEBUG_TRACING) { Trace.traceEnd(TRACE_TAG_PACKAGE_MANAGER); Trace.traceEnd(TRACE_TAG_PACKAGE_MANAGER); } } } } } private static void log(SettingBase callingSetting, PackageSetting targetPkgSetting, private static void log(SettingBase callingSetting, PackageSetting targetPkgSetting, String description) { String description) { Loading Loading
services/core/java/com/android/server/pm/AppsFilter.java +91 −30 Original line number Original line Diff line number Diff line Loading @@ -84,6 +84,7 @@ public class AppsFilter implements Watchable, Snappable { // Logs all filtering instead of enforcing // Logs all filtering instead of enforcing private static final boolean DEBUG_ALLOW_ALL = false; private static final boolean DEBUG_ALLOW_ALL = false; private static final boolean DEBUG_LOGGING = false; private static final boolean DEBUG_LOGGING = false; private static final boolean DEBUG_TRACING = false; /** /** * This contains a list of app UIDs that are implicitly queryable because another app explicitly * This contains a list of app UIDs that are implicitly queryable because another app explicitly Loading Loading @@ -363,23 +364,31 @@ public class AppsFilter implements Watchable, Snappable { @Override @Override public boolean isGloballyEnabled() { public boolean isGloballyEnabled() { if (DEBUG_TRACING) { Trace.traceBegin(TRACE_TAG_PACKAGE_MANAGER, "isGloballyEnabled"); Trace.traceBegin(TRACE_TAG_PACKAGE_MANAGER, "isGloballyEnabled"); } try { try { return mFeatureEnabled; return mFeatureEnabled; } finally { } finally { if (DEBUG_TRACING) { Trace.traceEnd(TRACE_TAG_PACKAGE_MANAGER); Trace.traceEnd(TRACE_TAG_PACKAGE_MANAGER); } } } } } @Override @Override public boolean packageIsEnabled(AndroidPackage pkg) { public boolean packageIsEnabled(AndroidPackage pkg) { if (DEBUG_TRACING) { Trace.traceBegin(TRACE_TAG_PACKAGE_MANAGER, "packageIsEnabled"); Trace.traceBegin(TRACE_TAG_PACKAGE_MANAGER, "packageIsEnabled"); } try { try { return !mDisabledPackages.contains(pkg.getPackageName()); return !mDisabledPackages.contains(pkg.getPackageName()); } finally { } finally { if (DEBUG_TRACING) { Trace.traceEnd(TRACE_TAG_PACKAGE_MANAGER); Trace.traceEnd(TRACE_TAG_PACKAGE_MANAGER); } } } } } @Override @Override public boolean isLoggingEnabled(int uid) { public boolean isLoggingEnabled(int uid) { Loading Loading @@ -656,7 +665,9 @@ public class AppsFilter implements Watchable, Snappable { * @param isReplace if the package is being replaced and may need extra cleanup. * @param isReplace if the package is being replaced and may need extra cleanup. */ */ public void addPackage(PackageSetting newPkgSetting, boolean isReplace) { public void addPackage(PackageSetting newPkgSetting, boolean isReplace) { if (DEBUG_TRACING) { Trace.traceBegin(TRACE_TAG_PACKAGE_MANAGER, "filter.addPackage"); Trace.traceBegin(TRACE_TAG_PACKAGE_MANAGER, "filter.addPackage"); } try { try { if (isReplace) { if (isReplace) { // let's first remove any prior rules for this package // let's first remove any prior rules for this package Loading Loading @@ -689,9 +700,11 @@ public class AppsFilter implements Watchable, Snappable { }); }); } finally { } finally { onChanged(); onChanged(); if (DEBUG_TRACING) { Trace.traceEnd(TRACE_TAG_PACKAGE_MANAGER); Trace.traceEnd(TRACE_TAG_PACKAGE_MANAGER); } } } } } /** /** * @return Additional packages that may have had their viewing visibility changed and may need * @return Additional packages that may have had their viewing visibility changed and may need Loading Loading @@ -1173,7 +1186,9 @@ public class AppsFilter implements Watchable, Snappable { */ */ public boolean shouldFilterApplication(int callingUid, @Nullable SettingBase callingSetting, public boolean shouldFilterApplication(int callingUid, @Nullable SettingBase callingSetting, PackageSetting targetPkgSetting, int userId) { PackageSetting targetPkgSetting, int userId) { if (DEBUG_TRACING) { Trace.traceBegin(TRACE_TAG_PACKAGE_MANAGER, "shouldFilterApplication"); Trace.traceBegin(TRACE_TAG_PACKAGE_MANAGER, "shouldFilterApplication"); } try { try { int callingAppId = UserHandle.getAppId(callingUid); int callingAppId = UserHandle.getAppId(callingUid); if (callingAppId < Process.FIRST_APPLICATION_UID if (callingAppId < Process.FIRST_APPLICATION_UID Loading Loading @@ -1211,13 +1226,17 @@ public class AppsFilter implements Watchable, Snappable { } } return !DEBUG_ALLOW_ALL; return !DEBUG_ALLOW_ALL; } finally { } finally { if (DEBUG_TRACING) { Trace.traceEnd(TRACE_TAG_PACKAGE_MANAGER); Trace.traceEnd(TRACE_TAG_PACKAGE_MANAGER); } } } } } private boolean shouldFilterApplicationInternal(int callingUid, SettingBase callingSetting, private boolean shouldFilterApplicationInternal(int callingUid, SettingBase callingSetting, PackageSetting targetPkgSetting, int targetUserId) { PackageSetting targetPkgSetting, int targetUserId) { if (DEBUG_TRACING) { Trace.traceBegin(TRACE_TAG_PACKAGE_MANAGER, "shouldFilterApplicationInternal"); Trace.traceBegin(TRACE_TAG_PACKAGE_MANAGER, "shouldFilterApplicationInternal"); } try { try { final boolean featureEnabled = mFeatureConfig.isGloballyEnabled(); final boolean featureEnabled = mFeatureConfig.isGloballyEnabled(); if (!featureEnabled) { if (!featureEnabled) { Loading @@ -1232,7 +1251,9 @@ public class AppsFilter implements Watchable, Snappable { } } final PackageSetting callingPkgSetting; final PackageSetting callingPkgSetting; final ArraySet<PackageSetting> callingSharedPkgSettings; final ArraySet<PackageSetting> callingSharedPkgSettings; if (DEBUG_TRACING) { Trace.traceBegin(TRACE_TAG_PACKAGE_MANAGER, "callingSetting instanceof"); Trace.traceBegin(TRACE_TAG_PACKAGE_MANAGER, "callingSetting instanceof"); } if (callingSetting instanceof PackageSetting) { if (callingSetting instanceof PackageSetting) { if (((PackageSetting) callingSetting).sharedUser == null) { if (((PackageSetting) callingSetting).sharedUser == null) { callingPkgSetting = (PackageSetting) callingSetting; callingPkgSetting = (PackageSetting) callingSetting; Loading @@ -1246,7 +1267,9 @@ public class AppsFilter implements Watchable, Snappable { callingPkgSetting = null; callingPkgSetting = null; callingSharedPkgSettings = ((SharedUserSetting) callingSetting).packages; callingSharedPkgSettings = ((SharedUserSetting) callingSetting).packages; } } if (DEBUG_TRACING) { Trace.traceEnd(TRACE_TAG_PACKAGE_MANAGER); Trace.traceEnd(TRACE_TAG_PACKAGE_MANAGER); } if (callingPkgSetting != null) { if (callingPkgSetting != null) { if (callingPkgSetting.pkg != null if (callingPkgSetting.pkg != null Loading Loading @@ -1282,7 +1305,9 @@ public class AppsFilter implements Watchable, Snappable { return false; return false; } } final String targetName = targetPkg.getPackageName(); final String targetName = targetPkg.getPackageName(); if (DEBUG_TRACING) { Trace.traceBegin(TRACE_TAG_PACKAGE_MANAGER, "getAppId"); Trace.traceBegin(TRACE_TAG_PACKAGE_MANAGER, "getAppId"); } final int callingAppId; final int callingAppId; if (callingPkgSetting != null) { if (callingPkgSetting != null) { callingAppId = callingPkgSetting.appId; callingAppId = callingPkgSetting.appId; Loading @@ -1290,7 +1315,9 @@ public class AppsFilter implements Watchable, Snappable { callingAppId = callingSharedPkgSettings.valueAt(0).appId; // all should be the same callingAppId = callingSharedPkgSettings.valueAt(0).appId; // all should be the same } } final int targetAppId = targetPkgSetting.appId; final int targetAppId = targetPkgSetting.appId; if (DEBUG_TRACING) { Trace.traceEnd(TRACE_TAG_PACKAGE_MANAGER); Trace.traceEnd(TRACE_TAG_PACKAGE_MANAGER); } if (callingAppId == targetAppId) { if (callingAppId == targetAppId) { if (DEBUG_LOGGING) { if (DEBUG_LOGGING) { log(callingSetting, targetPkgSetting, "same app id"); log(callingSetting, targetPkgSetting, "same app id"); Loading @@ -1299,7 +1326,9 @@ public class AppsFilter implements Watchable, Snappable { } } try { try { if (DEBUG_TRACING) { Trace.traceBegin(TRACE_TAG_PACKAGE_MANAGER, "requestsQueryAllPackages"); Trace.traceBegin(TRACE_TAG_PACKAGE_MANAGER, "requestsQueryAllPackages"); } if (callingPkgSetting != null) { if (callingPkgSetting != null) { if (callingPkgSetting.pkg != null if (callingPkgSetting.pkg != null && requestsQueryAllPackages(callingPkgSetting.pkg)) { && requestsQueryAllPackages(callingPkgSetting.pkg)) { Loading @@ -1314,10 +1343,14 @@ public class AppsFilter implements Watchable, Snappable { } } } } } finally { } finally { if (DEBUG_TRACING) { Trace.traceEnd(TRACE_TAG_PACKAGE_MANAGER); Trace.traceEnd(TRACE_TAG_PACKAGE_MANAGER); } } } try { try { if (DEBUG_TRACING) { Trace.traceBegin(TRACE_TAG_PACKAGE_MANAGER, "mForceQueryable"); Trace.traceBegin(TRACE_TAG_PACKAGE_MANAGER, "mForceQueryable"); } if (mForceQueryable.contains(targetAppId)) { if (mForceQueryable.contains(targetAppId)) { if (DEBUG_LOGGING) { if (DEBUG_LOGGING) { log(callingSetting, targetPkgSetting, "force queryable"); log(callingSetting, targetPkgSetting, "force queryable"); Loading @@ -1325,10 +1358,14 @@ public class AppsFilter implements Watchable, Snappable { return false; return false; } } } finally { } finally { if (DEBUG_TRACING) { Trace.traceEnd(TRACE_TAG_PACKAGE_MANAGER); Trace.traceEnd(TRACE_TAG_PACKAGE_MANAGER); } } } try { try { if (DEBUG_TRACING) { Trace.traceBegin(TRACE_TAG_PACKAGE_MANAGER, "mQueriesViaPackage"); Trace.traceBegin(TRACE_TAG_PACKAGE_MANAGER, "mQueriesViaPackage"); } if (mQueriesViaPackage.contains(callingAppId, targetAppId)) { if (mQueriesViaPackage.contains(callingAppId, targetAppId)) { if (DEBUG_LOGGING) { if (DEBUG_LOGGING) { log(callingSetting, targetPkgSetting, "queries package"); log(callingSetting, targetPkgSetting, "queries package"); Loading @@ -1336,10 +1373,14 @@ public class AppsFilter implements Watchable, Snappable { return false; return false; } } } finally { } finally { if (DEBUG_TRACING) { Trace.traceEnd(TRACE_TAG_PACKAGE_MANAGER); Trace.traceEnd(TRACE_TAG_PACKAGE_MANAGER); } } } try { try { if (DEBUG_TRACING) { Trace.traceBegin(TRACE_TAG_PACKAGE_MANAGER, "mQueriesViaComponent"); Trace.traceBegin(TRACE_TAG_PACKAGE_MANAGER, "mQueriesViaComponent"); } if (mQueriesViaComponentRequireRecompute) { if (mQueriesViaComponentRequireRecompute) { mStateProvider.runWithState((settings, users) -> { mStateProvider.runWithState((settings, users) -> { recomputeComponentVisibility(settings); recomputeComponentVisibility(settings); Loading @@ -1352,11 +1393,15 @@ public class AppsFilter implements Watchable, Snappable { return false; return false; } } } finally { } finally { if (DEBUG_TRACING) { Trace.traceEnd(TRACE_TAG_PACKAGE_MANAGER); Trace.traceEnd(TRACE_TAG_PACKAGE_MANAGER); } } } try { try { if (DEBUG_TRACING) { Trace.traceBegin(TRACE_TAG_PACKAGE_MANAGER, "mImplicitlyQueryable"); Trace.traceBegin(TRACE_TAG_PACKAGE_MANAGER, "mImplicitlyQueryable"); } final int targetUid = UserHandle.getUid(targetUserId, targetAppId); final int targetUid = UserHandle.getUid(targetUserId, targetAppId); if (mImplicitlyQueryable.contains(callingUid, targetUid)) { if (mImplicitlyQueryable.contains(callingUid, targetUid)) { if (DEBUG_LOGGING) { if (DEBUG_LOGGING) { Loading @@ -1365,11 +1410,15 @@ public class AppsFilter implements Watchable, Snappable { return false; return false; } } } finally { } finally { if (DEBUG_TRACING) { Trace.traceEnd(TRACE_TAG_PACKAGE_MANAGER); Trace.traceEnd(TRACE_TAG_PACKAGE_MANAGER); } } } try { try { if (DEBUG_TRACING) { Trace.traceBegin(TRACE_TAG_PACKAGE_MANAGER, "mOverlayReferenceMapper"); Trace.traceBegin(TRACE_TAG_PACKAGE_MANAGER, "mOverlayReferenceMapper"); } if (callingSharedPkgSettings != null) { if (callingSharedPkgSettings != null) { int size = callingSharedPkgSettings.size(); int size = callingSharedPkgSettings.size(); for (int index = 0; index < size; index++) { for (int index = 0; index < size; index++) { Loading @@ -1392,11 +1441,15 @@ public class AppsFilter implements Watchable, Snappable { } } } } } finally { } finally { if (DEBUG_TRACING) { Trace.traceEnd(TRACE_TAG_PACKAGE_MANAGER); Trace.traceEnd(TRACE_TAG_PACKAGE_MANAGER); } } } try { try { if (DEBUG_TRACING) { Trace.traceBegin(TRACE_TAG_PACKAGE_MANAGER, "mQueryableViaUsesLibrary"); Trace.traceBegin(TRACE_TAG_PACKAGE_MANAGER, "mQueryableViaUsesLibrary"); } if (mQueryableViaUsesLibrary.contains(callingAppId, targetAppId)) { if (mQueryableViaUsesLibrary.contains(callingAppId, targetAppId)) { if (DEBUG_LOGGING) { if (DEBUG_LOGGING) { log(callingSetting, targetPkgSetting, "queryable for library users"); log(callingSetting, targetPkgSetting, "queryable for library users"); Loading @@ -1404,14 +1457,18 @@ public class AppsFilter implements Watchable, Snappable { return false; return false; } } } finally { } finally { if (DEBUG_TRACING) { Trace.traceEnd(TRACE_TAG_PACKAGE_MANAGER); Trace.traceEnd(TRACE_TAG_PACKAGE_MANAGER); } } } return true; return true; } finally { } finally { if (DEBUG_TRACING) { Trace.traceEnd(TRACE_TAG_PACKAGE_MANAGER); Trace.traceEnd(TRACE_TAG_PACKAGE_MANAGER); } } } } } private static boolean requestsQueryAllPackages(@NonNull AndroidPackage pkg) { private static boolean requestsQueryAllPackages(@NonNull AndroidPackage pkg) { Loading @@ -1425,7 +1482,9 @@ public class AppsFilter implements Watchable, Snappable { private static boolean pkgInstruments( private static boolean pkgInstruments( @NonNull AndroidPackage source, @NonNull AndroidPackage target) { @NonNull AndroidPackage source, @NonNull AndroidPackage target) { try { try { if (DEBUG_TRACING) { Trace.traceBegin(TRACE_TAG_PACKAGE_MANAGER, "pkgInstruments"); Trace.traceBegin(TRACE_TAG_PACKAGE_MANAGER, "pkgInstruments"); } final String packageName = target.getPackageName(); final String packageName = target.getPackageName(); final List<ParsedInstrumentation> inst = source.getInstrumentations(); final List<ParsedInstrumentation> inst = source.getInstrumentations(); for (int i = ArrayUtils.size(inst) - 1; i >= 0; i--) { for (int i = ArrayUtils.size(inst) - 1; i >= 0; i--) { Loading @@ -1435,9 +1494,11 @@ public class AppsFilter implements Watchable, Snappable { } } return false; return false; } finally { } finally { if (DEBUG_TRACING) { Trace.traceEnd(TRACE_TAG_PACKAGE_MANAGER); Trace.traceEnd(TRACE_TAG_PACKAGE_MANAGER); } } } } } private static void log(SettingBase callingSetting, PackageSetting targetPkgSetting, private static void log(SettingBase callingSetting, PackageSetting targetPkgSetting, String description) { String description) { Loading