summaryrefslogtreecommitdiffstats
path: root/packages/SystemUI/src/com
diff options
context:
space:
mode:
authorJohn Spurlock <jspurlock@google.com>2014-11-19 20:33:40 -0500
committerJohn Spurlock <jspurlock@google.com>2014-11-19 21:07:04 -0500
commit18764bf55158ca668d94364fd07feb168497a0c2 (patch)
tree7af30c0140149a037310a57dfd4d200d5871132a /packages/SystemUI/src/com
parent70273e05b26f671dcec9ff1aa4bafabb5e407895 (diff)
downloadframeworks_base-18764bf55158ca668d94364fd07feb168497a0c2.zip
frameworks_base-18764bf55158ca668d94364fd07feb168497a0c2.tar.gz
frameworks_base-18764bf55158ca668d94364fd07feb168497a0c2.tar.bz2
QS: Inversion tile: Don't consider initial 0 setting trackable.
For usage tracking purposes, seeing a setting value of 1 is always considered trackable. However, only consider a setting value of 0 as trackable if we've observed a change (from 1). Avoids tracking a db update from null to 0 (via settings cmd or a restore). Bug: 18062541 Change-Id: Ic8413b1770040f9ef28041bbadb4e5fb62d1c014
Diffstat (limited to 'packages/SystemUI/src/com')
-rw-r--r--packages/SystemUI/src/com/android/systemui/qs/SecureSetting.java15
-rw-r--r--packages/SystemUI/src/com/android/systemui/qs/tiles/ColorInversionTile.java6
2 files changed, 15 insertions, 6 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/qs/SecureSetting.java b/packages/SystemUI/src/com/android/systemui/qs/SecureSetting.java
index 0ab6626..4f812bc 100644
--- a/packages/SystemUI/src/com/android/systemui/qs/SecureSetting.java
+++ b/packages/SystemUI/src/com/android/systemui/qs/SecureSetting.java
@@ -26,24 +26,26 @@ import com.android.systemui.statusbar.policy.Listenable;
/** Helper for managing a secure setting. **/
public abstract class SecureSetting extends ContentObserver implements Listenable {
+ private static final int DEFAULT = 0;
+
private final Context mContext;
private final String mSettingName;
private boolean mListening;
private int mUserId;
+ private int mObservedValue = DEFAULT;
- protected abstract void handleValueChanged(int value);
+ protected abstract void handleValueChanged(int value, boolean observedChange);
public SecureSetting(Context context, Handler handler, String settingName) {
super(handler);
mContext = context;
mSettingName = settingName;
mUserId = ActivityManager.getCurrentUser();
- setListening(true);
}
public int getValue() {
- return Secure.getIntForUser(mContext.getContentResolver(), mSettingName, 0, mUserId);
+ return Secure.getIntForUser(mContext.getContentResolver(), mSettingName, DEFAULT, mUserId);
}
public void setValue(int value) {
@@ -52,18 +54,23 @@ public abstract class SecureSetting extends ContentObserver implements Listenabl
@Override
public void setListening(boolean listening) {
+ if (listening == mListening) return;
mListening = listening;
if (listening) {
+ mObservedValue = getValue();
mContext.getContentResolver().registerContentObserver(
Secure.getUriFor(mSettingName), false, this, mUserId);
} else {
mContext.getContentResolver().unregisterContentObserver(this);
+ mObservedValue = DEFAULT;
}
}
@Override
public void onChange(boolean selfChange) {
- handleValueChanged(getValue());
+ final int value = getValue();
+ handleValueChanged(value, value != mObservedValue);
+ mObservedValue = value;
}
public void setUserId(int userId) {
diff --git a/packages/SystemUI/src/com/android/systemui/qs/tiles/ColorInversionTile.java b/packages/SystemUI/src/com/android/systemui/qs/tiles/ColorInversionTile.java
index b565afa..5963a45 100644
--- a/packages/SystemUI/src/com/android/systemui/qs/tiles/ColorInversionTile.java
+++ b/packages/SystemUI/src/com/android/systemui/qs/tiles/ColorInversionTile.java
@@ -41,8 +41,10 @@ public class ColorInversionTile extends QSTile<QSTile.BooleanState> {
mSetting = new SecureSetting(mContext, mHandler,
Secure.ACCESSIBILITY_DISPLAY_INVERSION_ENABLED) {
@Override
- protected void handleValueChanged(int value) {
- mUsageTracker.trackUsage();
+ protected void handleValueChanged(int value, boolean observedChange) {
+ if (value != 0 || observedChange) {
+ mUsageTracker.trackUsage();
+ }
if (mListening) {
handleRefreshState(value);
}