diff options
author | Guang Zhu <guangzhu@google.com> | 2012-10-22 11:50:38 -0700 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2012-10-22 11:50:39 -0700 |
commit | a023f4f6404027c3525af2cc48535a208e33b1d8 (patch) | |
tree | 05c19f102fbc03d20b45b4bacb00de45385fe1af /src | |
parent | 56a166e9e3cac96246bd724ceea96846fc9e41e1 (diff) | |
parent | 167ba2af93e25500e8d9499b3433f7b2c67fad58 (diff) | |
download | packages_apps_settings-a023f4f6404027c3525af2cc48535a208e33b1d8.zip packages_apps_settings-a023f4f6404027c3525af2cc48535a208e33b1d8.tar.gz packages_apps_settings-a023f4f6404027c3525af2cc48535a208e33b1d8.tar.bz2 |
Merge "Prevent sync state changes when user is a monkey" into jb-mr1-dev
Diffstat (limited to 'src')
-rw-r--r-- | src/com/android/settings/DataUsageSummary.java | 6 | ||||
-rw-r--r-- | src/com/android/settings/accounts/SyncSettings.java | 7 | ||||
-rw-r--r-- | src/com/android/settings/accounts/SyncStateCheckBoxPreference.java | 8 |
3 files changed, 18 insertions, 3 deletions
diff --git a/src/com/android/settings/DataUsageSummary.java b/src/com/android/settings/DataUsageSummary.java index 90c3460..8dc3d53 100644 --- a/src/com/android/settings/DataUsageSummary.java +++ b/src/com/android/settings/DataUsageSummary.java @@ -553,7 +553,11 @@ public class DataUsageSummary extends Fragment { return true; } case R.id.data_usage_menu_auto_sync: { - ConfirmAutoSyncChangeFragment.show(this, !item.isChecked()); + if (ActivityManager.isUserAMonkey()) { + Log.d("SyncState", "ignoring monkey's attempt to flip global sync state"); + } else { + ConfirmAutoSyncChangeFragment.show(this, !item.isChecked()); + } return true; } } diff --git a/src/com/android/settings/accounts/SyncSettings.java b/src/com/android/settings/accounts/SyncSettings.java index 20c296a..3248113 100644 --- a/src/com/android/settings/accounts/SyncSettings.java +++ b/src/com/android/settings/accounts/SyncSettings.java @@ -20,6 +20,7 @@ import android.accounts.Account; import android.accounts.AccountManager; import android.accounts.OnAccountsUpdateListener; import android.app.Activity; +import android.app.ActivityManager; import android.content.ContentResolver; import android.content.Intent; import android.graphics.drawable.Drawable; @@ -56,7 +57,11 @@ public class SyncSettings extends AccountPreferenceBase mAutoSyncPreference.setOnPreferenceChangeListener(new OnPreferenceChangeListener() { @Override public boolean onPreferenceChange(Preference preference, Object newValue) { - ContentResolver.setMasterSyncAutomatically((Boolean) newValue); + if (ActivityManager.isUserAMonkey()) { + Log.d("SyncSettings", "ignoring monkey's attempt to flip sync state"); + } else { + ContentResolver.setMasterSyncAutomatically((Boolean) newValue); + } return true; } }); diff --git a/src/com/android/settings/accounts/SyncStateCheckBoxPreference.java b/src/com/android/settings/accounts/SyncStateCheckBoxPreference.java index 13081dd..db746ee 100644 --- a/src/com/android/settings/accounts/SyncStateCheckBoxPreference.java +++ b/src/com/android/settings/accounts/SyncStateCheckBoxPreference.java @@ -17,9 +17,11 @@ package com.android.settings.accounts; import android.accounts.Account; +import android.app.ActivityManager; import android.content.Context; import android.preference.CheckBoxPreference; import android.util.AttributeSet; +import android.util.Log; import android.view.View; import android.widget.TextView; @@ -131,7 +133,11 @@ public class SyncStateCheckBoxPreference extends CheckBoxPreference { // When we're in one-time sync mode, we don't want a click to change the // checkbox state if (!mOneTimeSyncMode) { - super.onClick(); + if (ActivityManager.isUserAMonkey()) { + Log.d("SyncState", "ignoring monkey's attempt to flip sync state"); + } else { + super.onClick(); + } } } |