Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 803648a9 authored by Andreas Gampe's avatar Andreas Gampe Committed by Gerrit Code Review
Browse files

Merge changes I52110b84,I15d10a19,I5f52b832,Ifbaceb47

* changes:
  Remove spurious error logging from BackgroundDexOptService
  Migrate BackgroundDexOptServiceIntegrationTests to androidx.test
  Framework: Allow root to send bg-dexopt
  Fix BackgroundDexOptServiceIntegrationTests
parents 760e80c1 fb7cdc3f
Loading
Loading
Loading
Loading
+12 −3
Original line number Diff line number Diff line
@@ -254,9 +254,16 @@ public class BackgroundDexOptService extends JobService {
            @Override
            public void run() {
                int result = idleOptimization(pm, pkgs, BackgroundDexOptService.this);
                if (result != OPTIMIZE_ABORT_BY_JOB_SCHEDULER) {
                if (result == OPTIMIZE_PROCESSED) {
                    Log.i(TAG, "Idle optimizations completed.");
                } else if (result == OPTIMIZE_ABORT_NO_SPACE_LEFT) {
                    Log.w(TAG, "Idle optimizations aborted because of space constraints.");
                    // If we didn't abort we ran to completion (or stopped because of space).
                } else if (result == OPTIMIZE_ABORT_BY_JOB_SCHEDULER) {
                    Log.w(TAG, "Idle optimizations aborted by job scheduler.");
                } else {
                    Log.w(TAG, "Idle optimizations ended with unexpected code: " + result);
                }
                if (result != OPTIMIZE_ABORT_BY_JOB_SCHEDULER) {
                    // Abandon our timeslice and do not reschedule.
                    jobFinished(jobParams, /* reschedule */ false);
                }
@@ -339,6 +346,7 @@ public class BackgroundDexOptService extends JobService {
            long lowStorageThreshold, boolean isForPrimaryDex) {
        ArraySet<String> updatedPackages = new ArraySet<>();
        Set<String> unusedPackages = pm.getUnusedPackages(mDowngradeUnusedAppsThresholdInMillis);
        boolean hadSomeLowSpaceFailure = false;
        Log.d(TAG, "Unsused Packages " +  String.join(",", unusedPackages));
        // Only downgrade apps when space is low on device.
        // Threshold is selected above the lowStorageThreshold so that we can pro-actively clean
@@ -359,6 +367,7 @@ public class BackgroundDexOptService extends JobService {
            } else {
                if (abort_code == OPTIMIZE_ABORT_NO_SPACE_LEFT) {
                    // can't dexopt because of low space.
                    hadSomeLowSpaceFailure = true;
                    continue;
                }
                dex_opt_performed = optimizePackage(pm, pkg, isForPrimaryDex);
@@ -369,7 +378,7 @@ public class BackgroundDexOptService extends JobService {
        }

        notifyPinService(updatedPackages);
        return OPTIMIZE_PROCESSED;
        return hadSomeLowSpaceFailure ? OPTIMIZE_ABORT_NO_SPACE_LEFT : OPTIMIZE_PROCESSED;
    }


+21 −1
Original line number Diff line number Diff line
@@ -9004,6 +9004,20 @@ public class PackageManagerService extends IPackageManager.Stub
        }
    }
    /**
     * 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 enforceSystemOrRootOrShell(String message) {
        final int uid = Binder.getCallingUid();
        if (uid != Process.SYSTEM_UID && uid != Process.ROOT_UID && uid != Process.SHELL_UID) {
            throw new SecurityException(message);
        }
    }
    @Override
    public void performFstrimIfNeeded() {
        enforceSystemOrRoot("Only the system can request fstrim");
@@ -9498,7 +9512,13 @@ public class PackageManagerService extends IPackageManager.Stub
        if (getInstantAppPackageName(Binder.getCallingUid()) != null) {
            return false;
        }
        enforceSystemOrRootOrShell("runBackgroundDexoptJob");
        final long identity = Binder.clearCallingIdentity();
        try {
            return BackgroundDexOptService.runIdleOptimizationsNow(this, mContext, packageNames);
        } finally {
            Binder.restoreCallingIdentity(identity);
        }
    }
    private static List<SharedLibraryInfo> findSharedLibraries(PackageParser.Package p) {
+1 −0
Original line number Diff line number Diff line
@@ -1334,6 +1334,7 @@ class PackageManagerShellCommand extends ShellCommand {
        }
        boolean result = mInterface.runBackgroundDexoptJob(packageNames.isEmpty() ? null :
                packageNames);
        getOutPrintWriter().println(result ? "Success" : "Failure");
        return result ? 0 : -1;
    }

+1 −1
Original line number Diff line number Diff line
@@ -17,7 +17,7 @@
android_test {
    name: "BackgroundDexOptServiceIntegrationTests",
    srcs: ["src/**/*.java"],
    static_libs: ["android-support-test"],
    static_libs: ["androidx.test.rules"],
    platform_apis: true,
    test_suites: ["device-tests"],
    certificate: "platform",
+1 −1
Original line number Diff line number Diff line
@@ -34,7 +34,7 @@
    </application>

    <instrumentation
        android:name="android.support.test.runner.AndroidJUnitRunner"
        android:name="androidx.test.runner.AndroidJUnitRunner"
        android:targetPackage="com.android.frameworks.bgdexopttest"
        android:label="Integration test for BackgroundDexOptService" />
</manifest>
Loading