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

Commit b0078d86 authored by electimon's avatar electimon Committed by Daniel Jacob Chittoor
Browse files

treewide: Extend PowerExt's influence over critical areas



* Introduces implementations for
  FLING_BOOST, ACTIVITY_SWITCH, APP_ROTATE,
  PACKAGE_SWITCH, PROCESS_CREATE and PACKAGE_INSTALL.

Signed-off-by: default avatarelectimon <electimon@gmail.com>
Change-Id: Ib9182941f81d3a1c9a08b7c1339e865dc7906574
parent d3b8331d
Loading
Loading
Loading
Loading
+26 −1
Original line number Diff line number Diff line
@@ -389,7 +389,28 @@ public abstract class PowerManagerInternal {
     */
    public enum PowerExtBoosts {
        // Custom boosts list
        FLING_BOOST(BOOST_INTERACTION);
        // There already is INTERACTION boost when user touches the screen but if an OEM would like
        // to add additional actions for FLING only they can use this boost.
        FLING_BOOST(BOOST_INTERACTION),
        // Although there is already a LAUNCH mode boost when an app is launched, OEMs may wish to
        // boost resources for a period after to ensure the app is responsive while it is loading.
        // This has a duration of 2000ms.
        // There is no fallback.
        ACTIVITY_SWITCH,
        // Like before, this hint allows OEMs to boost resources for when a new package is launched
        // This is triggered for a duration of 4000ms.
        // There is no fallback.
        PACKAGE_SWITCH,
        // This hint allows OEMs to boost resources for when a new process thread is created,
        // a package Cold Launch with a duration of 4000ms.
        // There is no fallback.
        PROCESS_CREATE,
        // This hint allows OEMs to boost resources in case of package installation.
        // There is no fallback.
        PACKAGE_INSTALL,
        // This hint allows OEMs to boost resources when app rotation animation occurs.
        // There is no fallback.
        APP_ROTATE;
        // End boosts list

        // Fallback boost for given value
@@ -403,5 +424,9 @@ public abstract class PowerManagerInternal {
            return mFallback;
        }
        // End fallback boost

        PowerExtBoosts() {
            mFallback = -1;
        }
    }
}
+5 −0
Original line number Diff line number Diff line
@@ -94,6 +94,7 @@ import android.os.IBinder;
import android.os.Looper;
import android.os.Message;
import android.os.PowerManager;
import android.os.PowerManagerInternal.PowerExtBoosts;
import android.os.Process;
import android.os.RemoteCallbackList;
import android.os.RemoteException;
@@ -1664,6 +1665,10 @@ public final class ProcessList {
        mService.updateCpuStats();
        checkSlow(startUptime, "startProcess: done updating cpu stats");

        if (mService.mLocalPowerManager != null && hostingRecord.getType().contains("activity") == true) {
            mService.mLocalPowerManager.setPowerExtBoost(PowerExtBoosts.PROCESS_CREATE.name(), 4000);
        }

        try {
            final int userId = UserHandle.getUserId(app.uid);
            try {
+6 −0
Original line number Diff line number Diff line
@@ -123,6 +123,7 @@ import android.os.Build;
import android.os.Bundle;
import android.os.Environment;
import android.os.Message;
import android.os.PowerManagerInternal.PowerExtBoosts;
import android.os.Process;
import android.os.RemoteException;
import android.os.SystemProperties;
@@ -2653,6 +2654,11 @@ final class InstallPackageHelper {
        final boolean removedBeforeUpdate = (pkgSetting == null)
                || (pkgSetting.isSystem() && !pkgSetting.getPath().getPath().equals(
                res.mPkg.getPath()));
        // Disable boost early to prevent stuck boost.
        if (mPm.mPowerManagerInternal != null) {
            mPm.mPowerManagerInternal.setPowerExtMode(
                PowerExtBoosts.PACKAGE_INSTALL.name(), false);
        }
        if (succeeded && removedBeforeUpdate) {
            Slog.e(TAG, packageName + " was removed before handlePackagePostInstall "
                    + "could be executed");
+5 −0
Original line number Diff line number Diff line
@@ -59,6 +59,7 @@ import android.os.Handler;
import android.os.HandlerThread;
import android.os.Looper;
import android.os.Message;
import android.os.PowerManagerInternal.PowerExtBoosts;
import android.os.Process;
import android.os.RemoteCallbackList;
import android.os.RemoteException;
@@ -934,6 +935,10 @@ public class PackageInstallerService extends IPackageInstaller.Stub implements
    @Override
    public IPackageInstallerSession openSession(int sessionId) {
        try {
            if (mPm.mPowerManagerInternal != null) {
                mPm.mPowerManagerInternal.setPowerExtMode(
                    PowerExtBoosts.PACKAGE_INSTALL.name(), true);
            }
            return openSessionInternal(sessionId);
        } catch (IOException e) {
            throw ExceptionUtils.wrap(e);
+5 −1
Original line number Diff line number Diff line
@@ -132,6 +132,7 @@ import android.os.Message;
import android.os.Parcel;
import android.os.ParcelableException;
import android.os.PersistableBundle;
import android.os.PowerManagerInternal;
import android.os.Process;
import android.os.ReconcileSdkDataArgs;
import android.os.RemoteException;
@@ -195,6 +196,7 @@ import com.android.server.PackageWatchdog;
import com.android.server.ServiceThread;
import com.android.server.SystemConfig;
import com.android.server.Watchdog;
import com.android.server.am.ActivityManagerService.LocalService;
import com.android.server.apphibernation.AppHibernationManagerInternal;
import com.android.server.compat.CompatChange;
import com.android.server.compat.PlatformCompat;
@@ -955,6 +957,7 @@ public class PackageManagerService implements PackageSender, TestUtilityService
    private final SuspendPackageHelper mSuspendPackageHelper;
    private final DistractingPackageHelper mDistractingPackageHelper;
    private final StorageEventHelper mStorageEventHelper;
    final PowerManagerInternal mPowerManagerInternal;

    /**
     * Invalidate the package info cache, which includes updating the cached computer.
@@ -1703,7 +1706,7 @@ public class PackageManagerService implements PackageSender, TestUtilityService
        mSharedLibraries.setDeletePackageHelper(mDeletePackageHelper);

        mStorageEventHelper = testParams.storageEventHelper;

        mPowerManagerInternal = null;
        registerObservers(false);
        invalidatePackageInfoCache();
    }
@@ -1864,6 +1867,7 @@ public class PackageManagerService implements PackageSender, TestUtilityService
                mRemovePackageHelper);
        mDistractingPackageHelper = new DistractingPackageHelper(this, mInjector, mBroadcastHelper,
                mSuspendPackageHelper);
        mPowerManagerInternal = LocalServices.getService(PowerManagerInternal.class);

        synchronized (mLock) {
            // Create the computer as soon as the state objects have been installed.  The
Loading