Loading services/core/java/com/android/server/pm/ApexManager.java +21 −2 Original line number Original line Diff line number Diff line Loading @@ -83,13 +83,17 @@ class ApexManager { ApexManager(Context context) { ApexManager(Context context) { mContext = context; if (!isApexSupported()) { mApexService = null; return; } try { try { mApexService = IApexService.Stub.asInterface( mApexService = IApexService.Stub.asInterface( ServiceManager.getServiceOrThrow("apexservice")); ServiceManager.getServiceOrThrow("apexservice")); } catch (ServiceNotFoundException e) { } catch (ServiceNotFoundException e) { throw new IllegalStateException("Required service apexservice not available"); throw new IllegalStateException("Required service apexservice not available"); } } mContext = context; } } static final int MATCH_ACTIVE_PACKAGE = 1 << 0; static final int MATCH_ACTIVE_PACKAGE = 1 << 0; Loading @@ -102,6 +106,7 @@ class ApexManager { @interface PackageInfoFlags{} @interface PackageInfoFlags{} void systemReady() { void systemReady() { if (!isApexSupported()) return; mContext.registerReceiver(new BroadcastReceiver() { mContext.registerReceiver(new BroadcastReceiver() { @Override @Override public void onReceive(Context context, Intent intent) { public void onReceive(Context context, Intent intent) { Loading Loading @@ -175,6 +180,7 @@ class ApexManager { * is not found. * is not found. */ */ @Nullable PackageInfo getPackageInfo(String packageName, @PackageInfoFlags int flags) { @Nullable PackageInfo getPackageInfo(String packageName, @PackageInfoFlags int flags) { if (!isApexSupported()) return null; populateAllPackagesCacheIfNeeded(); populateAllPackagesCacheIfNeeded(); boolean matchActive = (flags & MATCH_ACTIVE_PACKAGE) != 0; boolean matchActive = (flags & MATCH_ACTIVE_PACKAGE) != 0; boolean matchFactory = (flags & MATCH_FACTORY_PACKAGE) != 0; boolean matchFactory = (flags & MATCH_FACTORY_PACKAGE) != 0; Loading @@ -198,6 +204,7 @@ class ApexManager { // TODO(b/132324953): delete. // TODO(b/132324953): delete. @Deprecated @Deprecated @Nullable PackageInfo getPackageInfoForApexName(String apexName) { @Nullable PackageInfo getPackageInfoForApexName(String apexName) { if (!isApexSupported()) return null; populateAllPackagesCacheIfNeeded(); populateAllPackagesCacheIfNeeded(); return mApexNameToPackageInfoCache.get(apexName); return mApexNameToPackageInfoCache.get(apexName); } } Loading @@ -209,6 +216,7 @@ class ApexManager { * active package. * active package. */ */ List<PackageInfo> getActivePackages() { List<PackageInfo> getActivePackages() { if (!isApexSupported()) return Collections.emptyList(); populateAllPackagesCacheIfNeeded(); populateAllPackagesCacheIfNeeded(); return mAllPackagesCache return mAllPackagesCache .stream() .stream() Loading @@ -223,6 +231,7 @@ class ApexManager { * active pre-installed package. * active pre-installed package. */ */ List<PackageInfo> getFactoryPackages() { List<PackageInfo> getFactoryPackages() { if (!isApexSupported()) return Collections.emptyList(); populateAllPackagesCacheIfNeeded(); populateAllPackagesCacheIfNeeded(); return mAllPackagesCache return mAllPackagesCache .stream() .stream() Loading @@ -237,6 +246,7 @@ class ApexManager { * inactive package. * inactive package. */ */ List<PackageInfo> getInactivePackages() { List<PackageInfo> getInactivePackages() { if (!isApexSupported()) return Collections.emptyList(); populateAllPackagesCacheIfNeeded(); populateAllPackagesCacheIfNeeded(); return mAllPackagesCache return mAllPackagesCache .stream() .stream() Loading @@ -251,6 +261,7 @@ class ApexManager { * @return {@code true} if {@code packageName} is an apex package. * @return {@code true} if {@code packageName} is an apex package. */ */ boolean isApexPackage(String packageName) { boolean isApexPackage(String packageName) { if (!isApexSupported()) return false; populateAllPackagesCacheIfNeeded(); populateAllPackagesCacheIfNeeded(); for (PackageInfo packageInfo : mAllPackagesCache) { for (PackageInfo packageInfo : mAllPackagesCache) { if (packageInfo.packageName.equals(packageName)) { if (packageInfo.packageName.equals(packageName)) { Loading @@ -268,6 +279,7 @@ class ApexManager { * @return an ApexSessionInfo object, or null if the session is not known. * @return an ApexSessionInfo object, or null if the session is not known. */ */ @Nullable ApexSessionInfo getStagedSessionInfo(int sessionId) { @Nullable ApexSessionInfo getStagedSessionInfo(int sessionId) { if (!isApexSupported()) return null; try { try { ApexSessionInfo apexSessionInfo = mApexService.getStagedSessionInfo(sessionId); ApexSessionInfo apexSessionInfo = mApexService.getStagedSessionInfo(sessionId); if (apexSessionInfo.isUnknown) { if (apexSessionInfo.isUnknown) { Loading Loading @@ -298,6 +310,7 @@ class ApexManager { */ */ boolean submitStagedSession( boolean submitStagedSession( int sessionId, @NonNull int[] childSessionIds, @NonNull ApexInfoList apexInfoList) { int sessionId, @NonNull int[] childSessionIds, @NonNull ApexInfoList apexInfoList) { if (!isApexSupported()) return false; try { try { return mApexService.submitStagedSession(sessionId, childSessionIds, apexInfoList); return mApexService.submitStagedSession(sessionId, childSessionIds, apexInfoList); } catch (RemoteException re) { } catch (RemoteException re) { Loading @@ -314,6 +327,7 @@ class ApexManager { * @return true upon success, false if the session is unknown. * @return true upon success, false if the session is unknown. */ */ boolean markStagedSessionReady(int sessionId) { boolean markStagedSessionReady(int sessionId) { if (!isApexSupported()) return false; try { try { return mApexService.markStagedSessionReady(sessionId); return mApexService.markStagedSessionReady(sessionId); } catch (RemoteException re) { } catch (RemoteException re) { Loading @@ -331,6 +345,7 @@ class ApexManager { * successful. * successful. */ */ void markStagedSessionSuccessful(int sessionId) { void markStagedSessionSuccessful(int sessionId) { if (!isApexSupported()) return; try { try { mApexService.markStagedSessionSuccessful(sessionId); mApexService.markStagedSessionSuccessful(sessionId); } catch (RemoteException re) { } catch (RemoteException re) { Loading Loading @@ -358,6 +373,7 @@ class ApexManager { * @return {@code true} upon success, {@code false} if any remote exception occurs * @return {@code true} upon success, {@code false} if any remote exception occurs */ */ boolean abortActiveSession() { boolean abortActiveSession() { if (!isApexSupported()) return false; try { try { mApexService.abortActiveSession(); mApexService.abortActiveSession(); return true; return true; Loading @@ -376,6 +392,7 @@ class ApexManager { * @return {@code true} upon successful uninstall, {@code false} otherwise. * @return {@code true} upon successful uninstall, {@code false} otherwise. */ */ boolean uninstallApex(String apexPackagePath) { boolean uninstallApex(String apexPackagePath) { if (!isApexSupported()) return false; try { try { mApexService.unstagePackages(Collections.singletonList(apexPackagePath)); mApexService.unstagePackages(Collections.singletonList(apexPackagePath)); return true; return true; Loading Loading @@ -441,6 +458,7 @@ class ApexManager { * information about that specific package will be dumped. * information about that specific package will be dumped. */ */ void dump(PrintWriter pw, @Nullable String packageName) { void dump(PrintWriter pw, @Nullable String packageName) { if (!isApexSupported()) return; final IndentingPrintWriter ipw = new IndentingPrintWriter(pw, " ", 120); final IndentingPrintWriter ipw = new IndentingPrintWriter(pw, " ", 120); try { try { populateAllPackagesCacheIfNeeded(); populateAllPackagesCacheIfNeeded(); Loading Loading @@ -486,6 +504,7 @@ class ApexManager { } } public void onBootCompleted() { public void onBootCompleted() { if (!isApexSupported()) return; populateAllPackagesCacheIfNeeded(); populateAllPackagesCacheIfNeeded(); } } } } Loading
services/core/java/com/android/server/pm/ApexManager.java +21 −2 Original line number Original line Diff line number Diff line Loading @@ -83,13 +83,17 @@ class ApexManager { ApexManager(Context context) { ApexManager(Context context) { mContext = context; if (!isApexSupported()) { mApexService = null; return; } try { try { mApexService = IApexService.Stub.asInterface( mApexService = IApexService.Stub.asInterface( ServiceManager.getServiceOrThrow("apexservice")); ServiceManager.getServiceOrThrow("apexservice")); } catch (ServiceNotFoundException e) { } catch (ServiceNotFoundException e) { throw new IllegalStateException("Required service apexservice not available"); throw new IllegalStateException("Required service apexservice not available"); } } mContext = context; } } static final int MATCH_ACTIVE_PACKAGE = 1 << 0; static final int MATCH_ACTIVE_PACKAGE = 1 << 0; Loading @@ -102,6 +106,7 @@ class ApexManager { @interface PackageInfoFlags{} @interface PackageInfoFlags{} void systemReady() { void systemReady() { if (!isApexSupported()) return; mContext.registerReceiver(new BroadcastReceiver() { mContext.registerReceiver(new BroadcastReceiver() { @Override @Override public void onReceive(Context context, Intent intent) { public void onReceive(Context context, Intent intent) { Loading Loading @@ -175,6 +180,7 @@ class ApexManager { * is not found. * is not found. */ */ @Nullable PackageInfo getPackageInfo(String packageName, @PackageInfoFlags int flags) { @Nullable PackageInfo getPackageInfo(String packageName, @PackageInfoFlags int flags) { if (!isApexSupported()) return null; populateAllPackagesCacheIfNeeded(); populateAllPackagesCacheIfNeeded(); boolean matchActive = (flags & MATCH_ACTIVE_PACKAGE) != 0; boolean matchActive = (flags & MATCH_ACTIVE_PACKAGE) != 0; boolean matchFactory = (flags & MATCH_FACTORY_PACKAGE) != 0; boolean matchFactory = (flags & MATCH_FACTORY_PACKAGE) != 0; Loading @@ -198,6 +204,7 @@ class ApexManager { // TODO(b/132324953): delete. // TODO(b/132324953): delete. @Deprecated @Deprecated @Nullable PackageInfo getPackageInfoForApexName(String apexName) { @Nullable PackageInfo getPackageInfoForApexName(String apexName) { if (!isApexSupported()) return null; populateAllPackagesCacheIfNeeded(); populateAllPackagesCacheIfNeeded(); return mApexNameToPackageInfoCache.get(apexName); return mApexNameToPackageInfoCache.get(apexName); } } Loading @@ -209,6 +216,7 @@ class ApexManager { * active package. * active package. */ */ List<PackageInfo> getActivePackages() { List<PackageInfo> getActivePackages() { if (!isApexSupported()) return Collections.emptyList(); populateAllPackagesCacheIfNeeded(); populateAllPackagesCacheIfNeeded(); return mAllPackagesCache return mAllPackagesCache .stream() .stream() Loading @@ -223,6 +231,7 @@ class ApexManager { * active pre-installed package. * active pre-installed package. */ */ List<PackageInfo> getFactoryPackages() { List<PackageInfo> getFactoryPackages() { if (!isApexSupported()) return Collections.emptyList(); populateAllPackagesCacheIfNeeded(); populateAllPackagesCacheIfNeeded(); return mAllPackagesCache return mAllPackagesCache .stream() .stream() Loading @@ -237,6 +246,7 @@ class ApexManager { * inactive package. * inactive package. */ */ List<PackageInfo> getInactivePackages() { List<PackageInfo> getInactivePackages() { if (!isApexSupported()) return Collections.emptyList(); populateAllPackagesCacheIfNeeded(); populateAllPackagesCacheIfNeeded(); return mAllPackagesCache return mAllPackagesCache .stream() .stream() Loading @@ -251,6 +261,7 @@ class ApexManager { * @return {@code true} if {@code packageName} is an apex package. * @return {@code true} if {@code packageName} is an apex package. */ */ boolean isApexPackage(String packageName) { boolean isApexPackage(String packageName) { if (!isApexSupported()) return false; populateAllPackagesCacheIfNeeded(); populateAllPackagesCacheIfNeeded(); for (PackageInfo packageInfo : mAllPackagesCache) { for (PackageInfo packageInfo : mAllPackagesCache) { if (packageInfo.packageName.equals(packageName)) { if (packageInfo.packageName.equals(packageName)) { Loading @@ -268,6 +279,7 @@ class ApexManager { * @return an ApexSessionInfo object, or null if the session is not known. * @return an ApexSessionInfo object, or null if the session is not known. */ */ @Nullable ApexSessionInfo getStagedSessionInfo(int sessionId) { @Nullable ApexSessionInfo getStagedSessionInfo(int sessionId) { if (!isApexSupported()) return null; try { try { ApexSessionInfo apexSessionInfo = mApexService.getStagedSessionInfo(sessionId); ApexSessionInfo apexSessionInfo = mApexService.getStagedSessionInfo(sessionId); if (apexSessionInfo.isUnknown) { if (apexSessionInfo.isUnknown) { Loading Loading @@ -298,6 +310,7 @@ class ApexManager { */ */ boolean submitStagedSession( boolean submitStagedSession( int sessionId, @NonNull int[] childSessionIds, @NonNull ApexInfoList apexInfoList) { int sessionId, @NonNull int[] childSessionIds, @NonNull ApexInfoList apexInfoList) { if (!isApexSupported()) return false; try { try { return mApexService.submitStagedSession(sessionId, childSessionIds, apexInfoList); return mApexService.submitStagedSession(sessionId, childSessionIds, apexInfoList); } catch (RemoteException re) { } catch (RemoteException re) { Loading @@ -314,6 +327,7 @@ class ApexManager { * @return true upon success, false if the session is unknown. * @return true upon success, false if the session is unknown. */ */ boolean markStagedSessionReady(int sessionId) { boolean markStagedSessionReady(int sessionId) { if (!isApexSupported()) return false; try { try { return mApexService.markStagedSessionReady(sessionId); return mApexService.markStagedSessionReady(sessionId); } catch (RemoteException re) { } catch (RemoteException re) { Loading @@ -331,6 +345,7 @@ class ApexManager { * successful. * successful. */ */ void markStagedSessionSuccessful(int sessionId) { void markStagedSessionSuccessful(int sessionId) { if (!isApexSupported()) return; try { try { mApexService.markStagedSessionSuccessful(sessionId); mApexService.markStagedSessionSuccessful(sessionId); } catch (RemoteException re) { } catch (RemoteException re) { Loading Loading @@ -358,6 +373,7 @@ class ApexManager { * @return {@code true} upon success, {@code false} if any remote exception occurs * @return {@code true} upon success, {@code false} if any remote exception occurs */ */ boolean abortActiveSession() { boolean abortActiveSession() { if (!isApexSupported()) return false; try { try { mApexService.abortActiveSession(); mApexService.abortActiveSession(); return true; return true; Loading @@ -376,6 +392,7 @@ class ApexManager { * @return {@code true} upon successful uninstall, {@code false} otherwise. * @return {@code true} upon successful uninstall, {@code false} otherwise. */ */ boolean uninstallApex(String apexPackagePath) { boolean uninstallApex(String apexPackagePath) { if (!isApexSupported()) return false; try { try { mApexService.unstagePackages(Collections.singletonList(apexPackagePath)); mApexService.unstagePackages(Collections.singletonList(apexPackagePath)); return true; return true; Loading Loading @@ -441,6 +458,7 @@ class ApexManager { * information about that specific package will be dumped. * information about that specific package will be dumped. */ */ void dump(PrintWriter pw, @Nullable String packageName) { void dump(PrintWriter pw, @Nullable String packageName) { if (!isApexSupported()) return; final IndentingPrintWriter ipw = new IndentingPrintWriter(pw, " ", 120); final IndentingPrintWriter ipw = new IndentingPrintWriter(pw, " ", 120); try { try { populateAllPackagesCacheIfNeeded(); populateAllPackagesCacheIfNeeded(); Loading Loading @@ -486,6 +504,7 @@ class ApexManager { } } public void onBootCompleted() { public void onBootCompleted() { if (!isApexSupported()) return; populateAllPackagesCacheIfNeeded(); populateAllPackagesCacheIfNeeded(); } } } }