diff options
| author | 2022-12-30 17:39:32 +0800 | |
|---|---|---|
| committer | 2022-12-30 17:46:33 +0800 | |
| commit | af5f0c40f16c393491e9d548ac787d7a7a84a47c (patch) | |
| tree | 51c578ec98b3991c7b90cca0c03ce95194a5d9a7 | |
| parent | 383a053610486636b0b6fd4064195b2a3d5055eb (diff) | |
Improve the cache rebuild latency of AppsFilter on boot #3
Returns early if the app id of caller or target package is
the core app id.
Bug: 262515424
Test: atest CtsAppEnumerationTestCases
Change-Id: If27ddbd1c94955a1bacfe983998ea7b9ba0c7cd5
| -rw-r--r-- | services/core/java/com/android/server/pm/AppsFilterBase.java | 39 |
1 files changed, 18 insertions, 21 deletions
diff --git a/services/core/java/com/android/server/pm/AppsFilterBase.java b/services/core/java/com/android/server/pm/AppsFilterBase.java index 1021e07cf946..12f6a1816e3e 100644 --- a/services/core/java/com/android/server/pm/AppsFilterBase.java +++ b/services/core/java/com/android/server/pm/AppsFilterBase.java @@ -399,6 +399,24 @@ public abstract class AppsFilterBase implements AppsFilterSnapshot { Slog.wtf(TAG, "No setting found for non system uid " + callingUid); return true; } + + if (DEBUG_TRACING) { + Trace.traceBegin(TRACE_TAG_PACKAGE_MANAGER, "getAppId"); + } + final int callingAppId = UserHandle.getAppId(callingUid); + final int targetAppId = targetPkgSetting.getAppId(); + if (DEBUG_TRACING) { + Trace.traceEnd(TRACE_TAG_PACKAGE_MANAGER); + } + if (callingAppId == targetAppId + || callingAppId < Process.FIRST_APPLICATION_UID + || targetAppId < Process.FIRST_APPLICATION_UID) { + if (DEBUG_LOGGING) { + log(callingSetting, targetPkgSetting, "same app id or core app id"); + } + return false; + } + final PackageStateInternal callingPkgSetting; if (DEBUG_TRACING) { Trace.traceBegin(TRACE_TAG_PACKAGE_MANAGER, "callingSetting instanceof"); @@ -446,27 +464,6 @@ public abstract class AppsFilterBase implements AppsFilterSnapshot { } } - if (DEBUG_TRACING) { - Trace.traceBegin(TRACE_TAG_PACKAGE_MANAGER, "getAppId"); - } - final int callingAppId; - if (callingPkgSetting != null) { - callingAppId = callingPkgSetting.getAppId(); - } else { - // all should be the same - callingAppId = callingSharedPkgSettings.valueAt(0).getAppId(); - } - final int targetAppId = targetPkgSetting.getAppId(); - if (DEBUG_TRACING) { - Trace.traceEnd(TRACE_TAG_PACKAGE_MANAGER); - } - if (callingAppId == targetAppId) { - if (DEBUG_LOGGING) { - log(callingSetting, targetPkgSetting, "same app id"); - } - return false; - } - try { if (DEBUG_TRACING) { Trace.traceBegin(TRACE_TAG_PACKAGE_MANAGER, "requestsQueryAllPackages"); |