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

BatterySaverMode.

Adds a binder call to the surface flinger to change the refresh rate
while the device is in BatterySaverMode.

Change-Id: I9b5fdcc279757ceb4b9917cb0445643b50133a04
This commit is contained in:
Ruchi Kandoi
2014-07-11 10:55:05 -07:00
parent 1c41116f03
commit 0fe32ae50b

View File

@@ -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.