Loading services/java/com/android/server/PowerManagerService.java +35 −4 Original line number Diff line number Diff line Loading @@ -65,6 +65,8 @@ import static android.provider.Settings.System.SCREEN_BRIGHTNESS_MODE; import static android.provider.Settings.System.SCREEN_BRIGHTNESS_MODE_AUTOMATIC; import static android.provider.Settings.System.SCREEN_OFF_TIMEOUT; import static android.provider.Settings.System.STAY_ON_WHILE_PLUGGED_IN; import static android.provider.Settings.System.WINDOW_ANIMATION_SCALE; import static android.provider.Settings.System.TRANSITION_ANIMATION_SCALE; import java.io.FileDescriptor; import java.io.IOException; Loading Loading @@ -243,6 +245,11 @@ class PowerManagerService extends IPowerManager.Stub boolean mUnplugTurnsOnScreen; private int mWarningSpewThrottleCount; private long mWarningSpewThrottleTime; private int mAnimationSetting = ANIM_SETTING_OFF; // Must match with the ISurfaceComposer constants in C++. private static final int ANIM_SETTING_ON = 0x01; private static final int ANIM_SETTING_OFF = 0x10; // Used when logging number and duration of touch-down cycles private long mTotalTouchDownTime; Loading @@ -256,7 +263,7 @@ class PowerManagerService extends IPowerManager.Stub private native void nativeInit(); private native void nativeSetPowerState(boolean screenOn, boolean screenBright); private native void nativeStartSurfaceFlingerAnimation(); private native void nativeStartSurfaceFlingerAnimation(int mode); /* static PrintStream mLog; Loading Loading @@ -426,6 +433,12 @@ class PowerManagerService extends IPowerManager.Stub return iVal != null ? iVal : defValue; } private float getFloat(String name, float defValue) { ContentValues values = mSettings.getValues(name); Float fVal = values != null ? values.getAsFloat(Settings.System.VALUE) : null; return fVal != null ? fVal : defValue; } public void update(Observable o, Object arg) { synchronized (mLocks) { // STAY_ON_WHILE_PLUGGED_IN, default to when plugged into AC Loading @@ -445,6 +458,17 @@ class PowerManagerService extends IPowerManager.Stub // recalculate everything setScreenOffTimeoutsLocked(); final float windowScale = getFloat(WINDOW_ANIMATION_SCALE, 1.0f); final float transitionScale = getFloat(TRANSITION_ANIMATION_SCALE, 1.0f); mAnimationSetting = 0; if (windowScale > 0.5f) { mAnimationSetting |= ANIM_SETTING_OFF; } if (transitionScale > 0.5f) { // Uncomment this if you want the screen-on animation. // mAnimationSetting |= ANIM_SETTING_ON; } } } } Loading Loading @@ -581,11 +605,13 @@ class PowerManagerService extends IPowerManager.Stub ContentResolver resolver = mContext.getContentResolver(); Cursor settingsCursor = resolver.query(Settings.System.CONTENT_URI, null, "(" + Settings.System.NAME + "=?) or (" + Settings.System.NAME + "=?) or (" + Settings.System.NAME + "=?) or (" + Settings.System.NAME + "=?) or (" + Settings.System.NAME + "=?) or (" + Settings.System.NAME + "=?)", new String[]{STAY_ON_WHILE_PLUGGED_IN, SCREEN_OFF_TIMEOUT, DIM_SCREEN, SCREEN_BRIGHTNESS_MODE}, SCREEN_BRIGHTNESS_MODE, WINDOW_ANIMATION_SCALE, TRANSITION_ANIMATION_SCALE}, null); mSettings = new ContentQueryMap(settingsCursor, Settings.System.NAME, true, mHandler); SettingsObserver settingsObserver = new SettingsObserver(); Loading Loading @@ -2023,7 +2049,12 @@ class PowerManagerService extends IPowerManager.Stub animate = jump && targetValue == Power.BRIGHTNESS_OFF; // we're turning off } if (animate) { nativeStartSurfaceFlingerAnimation(); // TODO: I think it's possible that if you sleep & wake multiple times // quickly for different reasons, mScreenOffReason for the first animation // might get stomped on as it starts the second animation. nativeStartSurfaceFlingerAnimation( mScreenOffReason == WindowManagerPolicy.OFF_BECAUSE_OF_PROX_SENSOR ? 0 : mAnimationSetting); } mScreenBrightness.jumpToTarget(); } Loading services/jni/com_android_server_PowerManagerService.cpp +3 −3 Original line number Diff line number Diff line Loading @@ -125,9 +125,9 @@ static void android_server_PowerManagerService_nativeSetPowerState(JNIEnv* env, } static void android_server_PowerManagerService_nativeStartSurfaceFlingerAnimation(JNIEnv* env, jobject obj) { jobject obj, jint mode) { sp<ISurfaceComposer> s(ComposerService::getComposerService()); s->turnElectronBeamOff(0); s->turnElectronBeamOff(mode); } // ---------------------------------------------------------------------------- Loading @@ -138,7 +138,7 @@ static JNINativeMethod gPowerManagerServiceMethods[] = { (void*) android_server_PowerManagerService_nativeInit }, { "nativeSetPowerState", "(ZZ)V", (void*) android_server_PowerManagerService_nativeSetPowerState }, { "nativeStartSurfaceFlingerAnimation", "()V", { "nativeStartSurfaceFlingerAnimation", "(I)V", (void*) android_server_PowerManagerService_nativeStartSurfaceFlingerAnimation }, }; Loading Loading
services/java/com/android/server/PowerManagerService.java +35 −4 Original line number Diff line number Diff line Loading @@ -65,6 +65,8 @@ import static android.provider.Settings.System.SCREEN_BRIGHTNESS_MODE; import static android.provider.Settings.System.SCREEN_BRIGHTNESS_MODE_AUTOMATIC; import static android.provider.Settings.System.SCREEN_OFF_TIMEOUT; import static android.provider.Settings.System.STAY_ON_WHILE_PLUGGED_IN; import static android.provider.Settings.System.WINDOW_ANIMATION_SCALE; import static android.provider.Settings.System.TRANSITION_ANIMATION_SCALE; import java.io.FileDescriptor; import java.io.IOException; Loading Loading @@ -243,6 +245,11 @@ class PowerManagerService extends IPowerManager.Stub boolean mUnplugTurnsOnScreen; private int mWarningSpewThrottleCount; private long mWarningSpewThrottleTime; private int mAnimationSetting = ANIM_SETTING_OFF; // Must match with the ISurfaceComposer constants in C++. private static final int ANIM_SETTING_ON = 0x01; private static final int ANIM_SETTING_OFF = 0x10; // Used when logging number and duration of touch-down cycles private long mTotalTouchDownTime; Loading @@ -256,7 +263,7 @@ class PowerManagerService extends IPowerManager.Stub private native void nativeInit(); private native void nativeSetPowerState(boolean screenOn, boolean screenBright); private native void nativeStartSurfaceFlingerAnimation(); private native void nativeStartSurfaceFlingerAnimation(int mode); /* static PrintStream mLog; Loading Loading @@ -426,6 +433,12 @@ class PowerManagerService extends IPowerManager.Stub return iVal != null ? iVal : defValue; } private float getFloat(String name, float defValue) { ContentValues values = mSettings.getValues(name); Float fVal = values != null ? values.getAsFloat(Settings.System.VALUE) : null; return fVal != null ? fVal : defValue; } public void update(Observable o, Object arg) { synchronized (mLocks) { // STAY_ON_WHILE_PLUGGED_IN, default to when plugged into AC Loading @@ -445,6 +458,17 @@ class PowerManagerService extends IPowerManager.Stub // recalculate everything setScreenOffTimeoutsLocked(); final float windowScale = getFloat(WINDOW_ANIMATION_SCALE, 1.0f); final float transitionScale = getFloat(TRANSITION_ANIMATION_SCALE, 1.0f); mAnimationSetting = 0; if (windowScale > 0.5f) { mAnimationSetting |= ANIM_SETTING_OFF; } if (transitionScale > 0.5f) { // Uncomment this if you want the screen-on animation. // mAnimationSetting |= ANIM_SETTING_ON; } } } } Loading Loading @@ -581,11 +605,13 @@ class PowerManagerService extends IPowerManager.Stub ContentResolver resolver = mContext.getContentResolver(); Cursor settingsCursor = resolver.query(Settings.System.CONTENT_URI, null, "(" + Settings.System.NAME + "=?) or (" + Settings.System.NAME + "=?) or (" + Settings.System.NAME + "=?) or (" + Settings.System.NAME + "=?) or (" + Settings.System.NAME + "=?) or (" + Settings.System.NAME + "=?)", new String[]{STAY_ON_WHILE_PLUGGED_IN, SCREEN_OFF_TIMEOUT, DIM_SCREEN, SCREEN_BRIGHTNESS_MODE}, SCREEN_BRIGHTNESS_MODE, WINDOW_ANIMATION_SCALE, TRANSITION_ANIMATION_SCALE}, null); mSettings = new ContentQueryMap(settingsCursor, Settings.System.NAME, true, mHandler); SettingsObserver settingsObserver = new SettingsObserver(); Loading Loading @@ -2023,7 +2049,12 @@ class PowerManagerService extends IPowerManager.Stub animate = jump && targetValue == Power.BRIGHTNESS_OFF; // we're turning off } if (animate) { nativeStartSurfaceFlingerAnimation(); // TODO: I think it's possible that if you sleep & wake multiple times // quickly for different reasons, mScreenOffReason for the first animation // might get stomped on as it starts the second animation. nativeStartSurfaceFlingerAnimation( mScreenOffReason == WindowManagerPolicy.OFF_BECAUSE_OF_PROX_SENSOR ? 0 : mAnimationSetting); } mScreenBrightness.jumpToTarget(); } Loading
services/jni/com_android_server_PowerManagerService.cpp +3 −3 Original line number Diff line number Diff line Loading @@ -125,9 +125,9 @@ static void android_server_PowerManagerService_nativeSetPowerState(JNIEnv* env, } static void android_server_PowerManagerService_nativeStartSurfaceFlingerAnimation(JNIEnv* env, jobject obj) { jobject obj, jint mode) { sp<ISurfaceComposer> s(ComposerService::getComposerService()); s->turnElectronBeamOff(0); s->turnElectronBeamOff(mode); } // ---------------------------------------------------------------------------- Loading @@ -138,7 +138,7 @@ static JNINativeMethod gPowerManagerServiceMethods[] = { (void*) android_server_PowerManagerService_nativeInit }, { "nativeSetPowerState", "(ZZ)V", (void*) android_server_PowerManagerService_nativeSetPowerState }, { "nativeStartSurfaceFlingerAnimation", "()V", { "nativeStartSurfaceFlingerAnimation", "(I)V", (void*) android_server_PowerManagerService_nativeStartSurfaceFlingerAnimation }, }; Loading