diff options
| author | 2013-06-27 10:15:19 -0400 | |
|---|---|---|
| committer | 2013-06-27 10:21:39 -0400 | |
| commit | 4db614dbed10e74285eaa6d0e56c3e79a4afecc0 (patch) | |
| tree | 6c8476d4235e96991dcc4588f97cffd6713ef886 | |
| parent | 86bebb4c78ffb1c2968f90841a65c07f81ba664b (diff) | |
Add sanity check inside ServiceMonitor's setting observer.
When registering for a specific setting key uri, the observer
can also be called back for "parent uri" updates. e.g.
adb shell content update --uri content://settings/secure will
trigger onChange with uri=content://settings/secure.
Add a quick setting value recheck, and avoid restarting if
the setting value change will have no impact.
Bug: 9595731
Change-Id: I4c71f6a4be3b655b31d2535e809bb42edd931cd6
| -rw-r--r-- | packages/SystemUI/src/com/android/systemui/statusbar/ServiceMonitor.java | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/ServiceMonitor.java b/packages/SystemUI/src/com/android/systemui/statusbar/ServiceMonitor.java index f763f0340999..aea9ec69e133 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/ServiceMonitor.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/ServiceMonitor.java @@ -98,6 +98,11 @@ public class ServiceMonitor { public void onChange(boolean selfChange, Uri uri) { if (mDebug) Log.d(mTag, "onChange selfChange=" + selfChange + " uri=" + uri); + ComponentName cn = getComponentNameFromSetting(); + if (cn == null && mServiceName == null || cn != null && cn.equals(mServiceName)) { + if (mDebug) Log.d(mTag, "skipping no-op restart"); + return; + } if (mBound) { mHandler.sendEmptyMessage(MSG_STOP_SERVICE); } @@ -178,6 +183,12 @@ public class ServiceMonitor { mHandler.sendEmptyMessage(MSG_START_SERVICE); } + private ComponentName getComponentNameFromSetting() { + String cn = Settings.Secure.getStringForUser(mContext.getContentResolver(), + mSettingKey, UserHandle.USER_CURRENT); + return cn == null ? null : ComponentName.unflattenFromString(cn); + } + // everything below is called on the handler private void packageIntent(Intent intent) { @@ -210,9 +221,7 @@ public class ServiceMonitor { } private void startService() { - String cn = Settings.Secure.getStringForUser(mContext.getContentResolver(), - mSettingKey, UserHandle.USER_CURRENT); - mServiceName = cn == null ? null : ComponentName.unflattenFromString(cn); + mServiceName = getComponentNameFromSetting(); if (mDebug) Log.d(mTag, "startService mServiceName=" + mServiceName); if (mServiceName == null) { mBound = false; |