summaryrefslogtreecommitdiffstats
path: root/services
diff options
context:
space:
mode:
authorDanesh M <daneshm90@gmail.com>2016-03-11 20:20:46 -0800
committerGerrit Code Review <gerrit@cyanogenmod.org>2016-03-14 13:36:29 -0700
commit6b5c6f33523facb3baef64f335c5439df6d58544 (patch)
treea761b88b427ee37e6c8565f3bc85193fdffe544f /services
parent9552ddcf19f19ac3c938b27c0e5161d49a05c932 (diff)
downloadframeworks_base-6b5c6f33523facb3baef64f335c5439df6d58544.zip
frameworks_base-6b5c6f33523facb3baef64f335c5439df6d58544.tar.gz
frameworks_base-6b5c6f33523facb3baef64f335c5439df6d58544.tar.bz2
Move keyDisabled and gamma to service
This allows us to keep track of user changes, and update preferences. CYNGNOS-1166 Change-Id: I8809c346c748e39e5d64b9e56a2b7623a0d0131b
Diffstat (limited to 'services')
-rw-r--r--services/core/java/com/android/server/display/LiveDisplayController.java33
-rw-r--r--services/core/java/com/android/server/policy/PhoneWindowManager.java12
-rw-r--r--services/core/java/com/android/server/power/PowerManagerService.java13
3 files changed, 55 insertions, 3 deletions
diff --git a/services/core/java/com/android/server/display/LiveDisplayController.java b/services/core/java/com/android/server/display/LiveDisplayController.java
index 80a6da4..28f2432 100644
--- a/services/core/java/com/android/server/display/LiveDisplayController.java
+++ b/services/core/java/com/android/server/display/LiveDisplayController.java
@@ -52,11 +52,13 @@ import cyanogenmod.providers.CMSettings;
import cyanogenmod.util.ColorUtils;
import java.io.PrintWriter;
+import java.util.List;
public class LiveDisplayController {
private static final String TAG = "LiveDisplay";
+ private static final String DELIMITER = "|";
private static final long TWILIGHT_ADJUSTMENT_TIME = DateUtils.HOUR_IN_MILLIS * 1;
private static final int OFF_TEMPERATURE = 6500;
@@ -214,6 +216,30 @@ public class LiveDisplayController {
}
updateLiveDisplay(mCurrentLux);
+ updateGamma();
+ }
+
+ private void updateGamma() {
+ if (!mHardware.isSupported(CMHardwareManager.FEATURE_DISPLAY_GAMMA_CALIBRATION)) {
+ return;
+ }
+ ContentResolver contentResolver = mContext.getContentResolver();
+ for (int i = 0; i < mHardware.getNumGammaControls(); i++) {
+ List<String> gammaValue = CMSettings.Secure.getDelimitedStringAsList(
+ contentResolver, DELIMITER,
+ CMSettings.Secure.DISPLAY_GAMMA_CALIBRATION_PREFIX + i);
+ if (gammaValue != null) {
+ mHardware.setDisplayGammaCalibration(i, stringArrayToIntArray(gammaValue));
+ }
+ }
+ }
+
+ private int[] stringArrayToIntArray(List<String> value) {
+ int[] result = new int[value.size()];
+ for (int i = 0; i < value.size(); i++) {
+ result[i] = Integer.parseInt(value.get(i));
+ }
+ return result;
}
private final class SettingsObserver extends UserContentObserver {
@@ -245,6 +271,13 @@ public class LiveDisplayController {
cr.registerContentObserver(DISPLAY_LOW_POWER_URI, false, this, UserHandle.USER_ALL);
cr.registerContentObserver(DISPLAY_COLOR_ENHANCE_URI, false, this, UserHandle.USER_ALL);
cr.registerContentObserver(DISPLAY_COLOR_ADJUSTMENT_URI, false, this, UserHandle.USER_ALL);
+ if (mHardware.isSupported(CMHardwareManager.FEATURE_DISPLAY_GAMMA_CALIBRATION)) {
+ for (int i = 0; i < mHardware.getNumGammaControls(); i++) {
+ Uri gammaUri = CMSettings.Secure.getUriFor(
+ CMSettings.Secure.DISPLAY_GAMMA_CALIBRATION_PREFIX + i);
+ cr.registerContentObserver(gammaUri, false, this, UserHandle.USER_ALL);
+ }
+ }
observe();
} else {
cr.unregisterContentObserver(this);
diff --git a/services/core/java/com/android/server/policy/PhoneWindowManager.java b/services/core/java/com/android/server/policy/PhoneWindowManager.java
index cd99038..9cb969c 100644
--- a/services/core/java/com/android/server/policy/PhoneWindowManager.java
+++ b/services/core/java/com/android/server/policy/PhoneWindowManager.java
@@ -86,6 +86,8 @@ import android.telecom.TelecomManager;
import com.android.internal.os.DeviceKeyHandler;
import com.android.internal.util.cm.ActionUtils;
+
+import cyanogenmod.hardware.CMHardwareManager;
import cyanogenmod.providers.CMSettings;
import dalvik.system.DexClassLoader;
import android.util.DisplayMetrics;
@@ -746,6 +748,7 @@ public class PhoneWindowManager implements WindowManagerPolicy {
private boolean mHasPermanentMenuKey;
private boolean mClearedBecauseOfForceShow;
private boolean mTopWindowIsKeyguard;
+ private CMHardwareManager mCMHardware;
private class PolicyHandler extends Handler {
@Override
@@ -1611,7 +1614,6 @@ public class PhoneWindowManager implements WindowManagerPolicy {
mOrientationListener.setCurrentRotation(windowManager.getRotation());
} catch (RemoteException ex) { }
mSettingsObserver = new SettingsObserver(mHandler);
- mSettingsObserver.observe();
mShortcutManager = new ShortcutManager(context);
mUiMode = context.getResources().getInteger(
com.android.internal.R.integer.config_defaultUiModeType);
@@ -2124,6 +2126,9 @@ public class PhoneWindowManager implements WindowManagerPolicy {
CMSettings.Secure.DEV_FORCE_SHOW_NAVBAR, 0, UserHandle.USER_CURRENT) == 1;
if (devForceNavbar != mDevForceNavbar) {
mDevForceNavbar = devForceNavbar;
+ if (mCMHardware.isSupported(CMHardwareManager.FEATURE_KEY_DISABLE)) {
+ mCMHardware.set(CMHardwareManager.FEATURE_KEY_DISABLE, mDevForceNavbar);
+ }
}
mNavigationBarLeftInLandscape = CMSettings.System.getIntForUser(resolver,
@@ -6890,6 +6895,11 @@ public class PhoneWindowManager implements WindowManagerPolicy {
mKeyguardDelegate = new KeyguardServiceDelegate(mContext);
mKeyguardDelegate.onSystemReady();
+ mCMHardware = CMHardwareManager.getInstance(mContext);
+ // Ensure observe happens in systemReady() since we need
+ // CMHardwareService to be up and running
+ mSettingsObserver.observe();
+
readCameraLensCoverState();
updateUiMode();
boolean bindKeyguardNow;
diff --git a/services/core/java/com/android/server/power/PowerManagerService.java b/services/core/java/com/android/server/power/PowerManagerService.java
index 70fdfff..1fd1fbd 100644
--- a/services/core/java/com/android/server/power/PowerManagerService.java
+++ b/services/core/java/com/android/server/power/PowerManagerService.java
@@ -524,6 +524,7 @@ public final class PowerManagerService extends SystemService
private boolean mProximityWakeSupported;
android.os.PowerManager.WakeLock mProximityWakeLock;
SensorEventListener mProximityListener;
+ private boolean mForceNavbar;
private PerformanceManagerInternal mPerf;
@@ -698,6 +699,9 @@ public final class PowerManagerService extends SystemService
resolver.registerContentObserver(CMSettings.Global.getUriFor(
CMSettings.Global.WAKE_WHEN_PLUGGED_OR_UNPLUGGED),
false, mSettingsObserver, UserHandle.USER_ALL);
+ resolver.registerContentObserver(CMSettings.Secure.getUriFor(
+ CMSettings.Secure.DEV_FORCE_SHOW_NAVBAR),
+ false, mSettingsObserver, UserHandle.USER_ALL);
// Go.
readConfigurationLocked();
@@ -842,7 +846,8 @@ public final class PowerManagerService extends SystemService
mKeyboardBrightness = CMSettings.Secure.getIntForUser(resolver,
CMSettings.Secure.KEYBOARD_BRIGHTNESS, mKeyboardBrightnessSettingDefault,
UserHandle.USER_CURRENT);
-
+ mForceNavbar = CMSettings.Secure.getIntForUser(resolver,
+ CMSettings.Secure.DEV_FORCE_SHOW_NAVBAR, 0, UserHandle.USER_CURRENT) == 1;
mDirty |= DIRTY_SETTINGS;
}
@@ -1700,7 +1705,11 @@ public final class PowerManagerService extends SystemService
buttonBrightness = mButtonBrightnessOverrideFromWindowManager;
keyboardBrightness = mButtonBrightnessOverrideFromWindowManager;
} else {
- buttonBrightness = mButtonBrightness;
+ if (!mForceNavbar) {
+ buttonBrightness = mButtonBrightness;
+ } else {
+ buttonBrightness = 0;
+ }
keyboardBrightness = mKeyboardBrightness;
}