Loading services/core/java/com/android/server/pm/PackageManagerService.java +5 −5 Original line number Diff line number Diff line Loading @@ -8960,15 +8960,15 @@ public class PackageManagerService extends IPackageManager.Stub } /** * Enforces that only the system UID or shell's UID can call a method exposed * via Binder. * Enforces that only the system UID or root's UID or shell's UID can call * a method exposed via Binder. * * @param message used as message if SecurityException is thrown * @throws SecurityException if the caller is not system or shell */ private static void enforceSystemOrShell(String message) { private static void enforceSystemOrRootOrShell(String message) { final int uid = Binder.getCallingUid(); if (uid != Process.SYSTEM_UID && uid != Process.SHELL_UID) { if (uid != Process.SYSTEM_UID && uid != Process.ROOT_UID && uid != Process.SHELL_UID) { throw new SecurityException(message); } } Loading Loading @@ -9454,7 +9454,7 @@ public class PackageManagerService extends IPackageManager.Stub if (getInstantAppPackageName(Binder.getCallingUid()) != null) { return false; } enforceSystemOrShell("runBackgroundDexoptJob"); enforceSystemOrRootOrShell("runBackgroundDexoptJob"); final long identity = Binder.clearCallingIdentity(); try { return BackgroundDexOptService.runIdleOptimizationsNow(this, mContext, packageNames); services/core/java/com/android/server/pm/PackageManagerShellCommand.java +1 −0 Original line number Diff line number Diff line Loading @@ -1302,6 +1302,7 @@ class PackageManagerShellCommand extends ShellCommand { } boolean result = mInterface.runBackgroundDexoptJob(packageNames.isEmpty() ? null : packageNames); getOutPrintWriter().println(result ? "Success" : "Failure"); return result ? 0 : -1; } Loading tests/BackgroundDexOptServiceIntegrationTests/src/com/android/server/pm/BackgroundDexOptServiceIntegrationTests.java +6 −1 Original line number Diff line number Diff line Loading @@ -154,6 +154,8 @@ public final class BackgroundDexOptServiceIntegrationTests { stdout.append(new String(buf, 0, bytesRead)); } fis.close(); Log.i(TAG, "stdout"); Log.i(TAG, stdout.toString()); return stdout.toString(); } Loading Loading @@ -202,7 +204,10 @@ public final class BackgroundDexOptServiceIntegrationTests { // TODO(aeubanks): figure out how to get scheduled bg-dexopt to run private static void runBackgroundDexOpt() throws IOException { runShellCommand("cmd package bg-dexopt-job " + PACKAGE_NAME); String result = runShellCommand("cmd package bg-dexopt-job " + PACKAGE_NAME); if (!result.trim().equals("Success")) { throw new IllegalStateException("Expected command success, received >" + result + "<"); } } // Set the time ahead of the last use time of the test app in days. Loading Loading
services/core/java/com/android/server/pm/PackageManagerService.java +5 −5 Original line number Diff line number Diff line Loading @@ -8960,15 +8960,15 @@ public class PackageManagerService extends IPackageManager.Stub } /** * Enforces that only the system UID or shell's UID can call a method exposed * via Binder. * Enforces that only the system UID or root's UID or shell's UID can call * a method exposed via Binder. * * @param message used as message if SecurityException is thrown * @throws SecurityException if the caller is not system or shell */ private static void enforceSystemOrShell(String message) { private static void enforceSystemOrRootOrShell(String message) { final int uid = Binder.getCallingUid(); if (uid != Process.SYSTEM_UID && uid != Process.SHELL_UID) { if (uid != Process.SYSTEM_UID && uid != Process.ROOT_UID && uid != Process.SHELL_UID) { throw new SecurityException(message); } } Loading Loading @@ -9454,7 +9454,7 @@ public class PackageManagerService extends IPackageManager.Stub if (getInstantAppPackageName(Binder.getCallingUid()) != null) { return false; } enforceSystemOrShell("runBackgroundDexoptJob"); enforceSystemOrRootOrShell("runBackgroundDexoptJob"); final long identity = Binder.clearCallingIdentity(); try { return BackgroundDexOptService.runIdleOptimizationsNow(this, mContext, packageNames);
services/core/java/com/android/server/pm/PackageManagerShellCommand.java +1 −0 Original line number Diff line number Diff line Loading @@ -1302,6 +1302,7 @@ class PackageManagerShellCommand extends ShellCommand { } boolean result = mInterface.runBackgroundDexoptJob(packageNames.isEmpty() ? null : packageNames); getOutPrintWriter().println(result ? "Success" : "Failure"); return result ? 0 : -1; } Loading
tests/BackgroundDexOptServiceIntegrationTests/src/com/android/server/pm/BackgroundDexOptServiceIntegrationTests.java +6 −1 Original line number Diff line number Diff line Loading @@ -154,6 +154,8 @@ public final class BackgroundDexOptServiceIntegrationTests { stdout.append(new String(buf, 0, bytesRead)); } fis.close(); Log.i(TAG, "stdout"); Log.i(TAG, stdout.toString()); return stdout.toString(); } Loading Loading @@ -202,7 +204,10 @@ public final class BackgroundDexOptServiceIntegrationTests { // TODO(aeubanks): figure out how to get scheduled bg-dexopt to run private static void runBackgroundDexOpt() throws IOException { runShellCommand("cmd package bg-dexopt-job " + PACKAGE_NAME); String result = runShellCommand("cmd package bg-dexopt-job " + PACKAGE_NAME); if (!result.trim().equals("Success")) { throw new IllegalStateException("Expected command success, received >" + result + "<"); } } // Set the time ahead of the last use time of the test app in days. Loading