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

Commit 6b879024 authored by Ruchi Kandoi's avatar Ruchi Kandoi Committed by Android (Google) Code Review
Browse files

Merge "PowerManager: Adds a call to reduce refresh rate while device is in...

Merge "PowerManager: Adds a call to reduce refresh rate while device is in BatterySaverMode." into lmp-dev
parents a859523b 0fe32ae5
Loading
Loading
Loading
Loading
+18 −0
Original line number Diff line number Diff line
@@ -58,6 +58,8 @@ import android.os.SystemProperties;
import android.os.SystemService;
import android.os.UserHandle;
import android.os.WorkSource;
import android.os.Parcel;
import android.os.ServiceManager;
import android.provider.Settings;
import android.service.dreams.DreamManagerInternal;
import android.util.EventLog;
@@ -659,6 +661,7 @@ public final class PowerManagerService extends com.android.server.SystemService
        if (mLowPowerModeEnabled != lowPowerModeEnabled) {
            mLowPowerModeEnabled = lowPowerModeEnabled;
            powerHintInternal(POWER_HINT_LOW_POWER_MODE, lowPowerModeEnabled ? 1 : 0);
            setSurfaceFlingerLowPowerMode(lowPowerModeEnabled ? 1 : 0);
            mLowPowerModeEnabled = lowPowerModeEnabled;
            BackgroundThread.getHandler().post(new Runnable() {
                @Override
@@ -2094,6 +2097,21 @@ public final class PowerManagerService extends com.android.server.SystemService
        nativeSendPowerHint(hintId, data);
    }

    private static void setSurfaceFlingerLowPowerMode(int enabled) {
        try {
            final IBinder flinger = ServiceManager.getService("SurfaceFlinger");
            if (flinger != null) {
                final Parcel data = Parcel.obtain();
                data.writeInterfaceToken("android.ui.ISurfaceComposer");
                data.writeInt(enabled);
                flinger.transact(1016, data, null, 0);
                data.recycle();
            }
        } catch (RemoteException ex) {
            Slog.e(TAG, "Failed to reduce refresh rate", ex);
        }
    }

    /**
     * Low-level function turn the device off immediately, without trying
     * to be clean.  Most people should use {@link ShutdownThread} for a clean shutdown.