PowerManagerService: Adds a VrStateListener to track Vr Mode state changes.

PowerManagerService sends VR_MODE hints to the powerHAL for device-specific
power tunings.

Bug: 27659731
Signed-off-by: Ruchi Kandoi <kandoiruchi@google.com>
Change-Id: I152d9b6adfbae5d3df8d131fdd16e33fb14b64d3
This commit is contained in:
Ruchi Kandoi
2016-03-14 17:09:17 -07:00
parent b6692a3ae6
commit 03a0428ed3

View File

@@ -70,6 +70,8 @@ import com.android.server.Watchdog;
import com.android.server.am.BatteryStatsService;
import com.android.server.lights.Light;
import com.android.server.lights.LightsManager;
import com.android.server.vr.VrManagerInternal;
import com.android.server.vr.VrStateListener;
import libcore.util.Objects;
import java.io.FileDescriptor;
@@ -155,6 +157,7 @@ public final class PowerManagerService extends SystemService
// Power hints defined in hardware/libhardware/include/hardware/power.h.
private static final int POWER_HINT_LOW_POWER = 5;
private static final int POWER_HINT_SUSTAINED_PERFORMANCE = 6;
private static final int POWER_HINT_VR_MODE = 7;
// Power features defined in hardware/libhardware/include/hardware/power.h.
private static final int POWER_FEATURE_DOUBLE_TAP_TO_WAKE = 1;
@@ -643,6 +646,7 @@ public final class PowerManagerService extends SystemService
resolver.registerContentObserver(Settings.Secure.getUriFor(
Secure.BRIGHTNESS_USE_TWILIGHT),
false, mSettingsObserver, UserHandle.USER_ALL);
getLocalService(VrManagerInternal.class).registerListener(mVrStateListener);
// Go.
readConfigurationLocked();
updateSettingsLocked();
@@ -2989,6 +2993,13 @@ public final class PowerManagerService extends SystemService
}
}
private final VrStateListener mVrStateListener = new VrStateListener() {
@Override
public void onVrStateChanged(boolean enabled) {
powerHintInternal(POWER_HINT_VR_MODE, enabled ? 1 : 0);
}
};
/**
* Handler for asynchronous operations performed by the power manager.
*/