Merge "Restrict changing wi-fi networks" into oc-dr1-dev
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index 7e67962..da96c00 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -83,6 +83,7 @@
<uses-permission android:name="android.permission.MANAGE_NOTIFICATIONS"/>
<uses-permission android:name="android.permission.DELETE_PACKAGES"/>
<uses-permission android:name="android.permission.MANAGE_APP_OPS_RESTRICTIONS"/>
+ <uses-permission android:name="android.permission.NETWORK_SETTINGS" />
<application android:label="@string/settings_label"
android:icon="@drawable/ic_launcher_settings"
diff --git a/res/xml/app_and_notification.xml b/res/xml/app_and_notification.xml
index 47fc378..4a5ee1d 100644
--- a/res/xml/app_and_notification.xml
+++ b/res/xml/app_and_notification.xml
@@ -40,6 +40,11 @@
</Preference>
</PreferenceCategory>
+ <!-- Empty category to draw divider -->
+ <PreferenceCategory
+ android:key="all_app_info_divider"
+ android:order="-190"/>
+
<Preference
android:key="manage_perms"
android:title="@string/app_permissions"
diff --git a/res/xml/encryption_and_credential.xml b/res/xml/encryption_and_credential.xml
index be643b1..715ea14 100644
--- a/res/xml/encryption_and_credential.xml
+++ b/res/xml/encryption_and_credential.xml
@@ -24,25 +24,21 @@
android:order="100">
<com.android.settingslib.RestrictedPreference android:key="credential_storage_type"
- android:title="@string/credential_storage_type"
- android:persistent="false" />
+ android:title="@string/credential_storage_type" />
<Preference android:key="trusted_credentials"
android:title="@string/trusted_credentials"
android:summary="@string/trusted_credentials_summary"
- android:persistent="false"
android:fragment="com.android.settings.TrustedCredentialsSettings"/>
<com.android.settingslib.RestrictedPreference android:key="user_credentials"
android:title="@string/user_credentials"
android:summary="@string/user_credentials_summary"
- android:persistent="false"
android:fragment="com.android.settings.UserCredentialsSettings"/>
<com.android.settingslib.RestrictedPreference android:key="credentials_install"
android:title="@string/credentials_install"
- android:summary="@string/credentials_install_summary"
- android:persistent="false">
+ android:summary="@string/credentials_install_summary">
<intent android:action="android.credentials.INSTALL"
android:targetPackage="com.android.certinstaller"
@@ -52,8 +48,7 @@
<com.android.settingslib.RestrictedPreference android:key="credentials_reset"
android:title="@string/credentials_reset"
- android:summary="@string/credentials_reset_summary"
- android:persistent="false">
+ android:summary="@string/credentials_reset_summary">
<intent android:action="com.android.credentials.RESET"
android:targetPackage="com.android.settings"
diff --git a/res/xml/security_settings_encrypted.xml b/res/xml/security_settings_encrypted.xml
index 391f0fe..0d3fe76 100644
--- a/res/xml/security_settings_encrypted.xml
+++ b/res/xml/security_settings_encrypted.xml
@@ -18,12 +18,10 @@
android:title="@string/security_settings_title">
<PreferenceCategory
- android:key="security_category"
+ android:key="security_category_for_encrypted_device"
android:title="@string/crypt_keeper_settings_title">
<Preference
- android:enabled="false"
- android:shouldDisableView="false"
android:key="crypt_keeper_encrypt_title"
android:title="@string/crypt_keeper_encrypt_title"
android:summary="@string/crypt_keeper_encrypted_summary"/>
diff --git a/res/xml/security_settings_unencrypted.xml b/res/xml/security_settings_unencrypted.xml
index 7c51d25..27dbe96 100644
--- a/res/xml/security_settings_unencrypted.xml
+++ b/res/xml/security_settings_unencrypted.xml
@@ -18,14 +18,14 @@
android:title="@string/crypt_keeper_settings_title">
<PreferenceCategory
- android:key="security_category"
+ android:key="security_category_for_unencrypted_device"
android:title="@string/crypt_keeper_settings_title">
<Preference
android:key="encryption"
android:title="@string/crypt_keeper_encrypt_title"
android:fragment="com.android.settings.CryptKeeperSettings" />
-
+
</PreferenceCategory>
</PreferenceScreen>
diff --git a/src/com/android/settings/EncryptionAndCredential.java b/src/com/android/settings/EncryptionAndCredential.java
index 3cb2740..4892f7e 100644
--- a/src/com/android/settings/EncryptionAndCredential.java
+++ b/src/com/android/settings/EncryptionAndCredential.java
@@ -20,7 +20,6 @@
import android.app.admin.DevicePolicyManager;
import android.content.Context;
import android.content.Intent;
-import android.content.res.Resources;
import android.os.Bundle;
import android.os.UserHandle;
import android.os.UserManager;
@@ -34,7 +33,6 @@
import com.android.settings.dashboard.DashboardFragment;
import com.android.settings.search.BaseSearchIndexProvider;
import com.android.settings.search.Indexable;
-import com.android.settings.search.SearchIndexableRaw;
import com.android.settingslib.RestrictedLockUtils;
import com.android.settingslib.RestrictedPreference;
@@ -106,7 +104,6 @@
}
}
-
// Credential storage
mKeyStore = KeyStore.getInstance(); // needs to be initialized for onResume()
@@ -182,28 +179,22 @@
@Override
public List<SearchIndexableResource> getXmlResourcesToIndex(
Context context, boolean enabled) {
- final List<SearchIndexableResource> index = new ArrayList<SearchIndexableResource>();
+ final List<SearchIndexableResource> index = new ArrayList<>();
- final DevicePolicyManager dpm = (DevicePolicyManager)
- context.getSystemService(Context.DEVICE_POLICY_SERVICE);
- final UserManager um = UserManager.get(context);
-
- if (um.isAdminUser()) {
- switch (dpm.getStorageEncryptionStatus()) {
- case DevicePolicyManager.ENCRYPTION_STATUS_ACTIVE:
- // The device is currently encrypted.
- index.add(getSearchResource(context, R.xml.security_settings_encrypted));
- break;
- case DevicePolicyManager.ENCRYPTION_STATUS_INACTIVE:
- // This device supports encryption but isn't encrypted.
- index.add(getSearchResource(context, R.xml.security_settings_unencrypted));
- break;
- }
- }
+ // Add everything. We will suppress some of them in getNonIndexableKeys()
+ index.add(getSearchResource(context, R.xml.encryption_and_credential));
+ index.add(getSearchResource(context, R.xml.security_settings_encrypted));
+ index.add(getSearchResource(context, R.xml.security_settings_unencrypted));
return index;
}
+ @Override
+ protected boolean isPageSearchEnabled(Context context) {
+ final UserManager um = (UserManager) context.getSystemService(Context.USER_SERVICE);
+ return um.isAdminUser();
+ }
+
private SearchIndexableResource getSearchResource(Context context, int xmlResId) {
final SearchIndexableResource sir = new SearchIndexableResource(context);
sir.xmlResId = xmlResId;
@@ -211,54 +202,34 @@
}
@Override
- public List<SearchIndexableRaw> getRawDataToIndex(Context context, boolean enabled) {
- final List<SearchIndexableRaw> result = new ArrayList<SearchIndexableRaw>();
- final Resources res = context.getResources();
-
- final String screenTitle = res.getString(
- R.string.encryption_and_credential_settings_title);
-
- SearchIndexableRaw data = new SearchIndexableRaw(context);
- data.title = screenTitle;
- data.screenTitle = screenTitle;
- result.add(data);
-
- final UserManager um = UserManager.get(context);
- if (!um.isAdminUser()) {
- int resId = um.isLinkedUser() ?
- R.string.profile_info_settings_title : R.string.user_info_settings_title;
-
- data = new SearchIndexableRaw(context);
- data.title = res.getString(resId);
- data.screenTitle = screenTitle;
- result.add(data);
- }
-
- // Credential storage
- if (!um.hasUserRestriction(UserManager.DISALLOW_CONFIG_CREDENTIALS)) {
- KeyStore keyStore = KeyStore.getInstance();
-
- final int storageSummaryRes = keyStore.isHardwareBacked() ?
- R.string.credential_storage_type_hardware :
- R.string.credential_storage_type_software;
-
- data = new SearchIndexableRaw(context);
- data.title = res.getString(storageSummaryRes);
- data.screenTitle = screenTitle;
- result.add(data);
- }
-
- return result;
- }
-
- @Override
public List<String> getNonIndexableKeys(Context context) {
final List<String> keys = super.getNonIndexableKeys(context);
-
- final UserManager um = UserManager.get(context);
+ if (!isPageSearchEnabled(context)) {
+ return keys;
+ }
+ final UserManager um = (UserManager) context.getSystemService(Context.USER_SERVICE);
if (um.hasUserRestriction(UserManager.DISALLOW_CONFIG_CREDENTIALS)) {
keys.add(KEY_CREDENTIALS_MANAGER);
+ keys.add(KEY_RESET_CREDENTIALS);
+ keys.add(KEY_CREDENTIALS_INSTALL);
+ keys.add(KEY_CREDENTIAL_STORAGE_TYPE);
+ keys.add(KEY_USER_CREDENTIALS);
+ }
+
+ final DevicePolicyManager dpm = (DevicePolicyManager)
+ context.getSystemService(Context.DEVICE_POLICY_SERVICE);
+ switch (dpm.getStorageEncryptionStatus()) {
+ case DevicePolicyManager.ENCRYPTION_STATUS_ACTIVE:
+ // The device is currently encrypted. Disable security_settings_unencrypted
+ keys.addAll(getNonIndexableKeysFromXml(
+ context, R.xml.security_settings_unencrypted));
+ break;
+ default:
+ // This device supports encryption but isn't encrypted.
+ keys.addAll(getNonIndexableKeysFromXml(
+ context, R.xml.security_settings_encrypted));
+ break;
}
return keys;
diff --git a/src/com/android/settings/applications/AppAndNotificationDashboardFragment.java b/src/com/android/settings/applications/AppAndNotificationDashboardFragment.java
index df1430c..e0fc2b0 100644
--- a/src/com/android/settings/applications/AppAndNotificationDashboardFragment.java
+++ b/src/com/android/settings/applications/AppAndNotificationDashboardFragment.java
@@ -50,7 +50,7 @@
@Override
public void onAttach(Context context) {
super.onAttach(context);
- mProgressiveDisclosureMixin.setTileLimit(3);
+ mProgressiveDisclosureMixin.setTileLimit(4);
}
@Override
diff --git a/src/com/android/settings/applications/RecentAppsPreferenceController.java b/src/com/android/settings/applications/RecentAppsPreferenceController.java
index f540832..dd95605 100644
--- a/src/com/android/settings/applications/RecentAppsPreferenceController.java
+++ b/src/com/android/settings/applications/RecentAppsPreferenceController.java
@@ -62,6 +62,8 @@
private static final String TAG = "RecentAppsCtrl";
private static final String KEY_PREF_CATEGORY = "recent_apps_category";
@VisibleForTesting
+ static final String KEY_DIVIDER = "all_app_info_divider";
+ @VisibleForTesting
static final String KEY_SEE_ALL = "all_app_info";
private static final int SHOW_RECENT_APP_COUNT = 5;
private static final Set<String> SKIP_SYSTEM_PACKAGES = new ArraySet<>();
@@ -78,6 +80,7 @@
private PreferenceCategory mCategory;
private Preference mSeeAllPref;
+ private Preference mDivider;
private boolean mHasRecentApps;
static {
@@ -122,12 +125,14 @@
super.updateNonIndexableKeys(keys);
// Don't index category name into search. It's not actionable.
keys.add(KEY_PREF_CATEGORY);
+ keys.add(KEY_DIVIDER);
}
@Override
public void displayPreference(PreferenceScreen screen) {
mCategory = (PreferenceCategory) screen.findPreference(getPreferenceKey());
mSeeAllPref = screen.findPreference(KEY_SEE_ALL);
+ mDivider = screen.findPreference(KEY_DIVIDER);
super.displayPreference(screen);
refreshUi(mCategory.getContext());
}
@@ -181,6 +186,7 @@
private void displayOnlyAppInfo() {
mCategory.setTitle(null);
+ mDivider.setVisible(false);
mSeeAllPref.setTitle(R.string.applications_settings);
mSeeAllPref.setIcon(null);
int prefCount = mCategory.getPreferenceCount();
@@ -194,6 +200,7 @@
private void displayRecentApps(Context prefContext, List<UsageStats> recentApps) {
mCategory.setTitle(R.string.recent_app_category_title);
+ mDivider.setVisible(true);
mSeeAllPref.setSummary(null);
mSeeAllPref.setIcon(R.drawable.ic_chevron_right_24dp);
diff --git a/src/com/android/settings/display/AmbientDisplayAlwaysOnPreferenceController.java b/src/com/android/settings/display/AmbientDisplayAlwaysOnPreferenceController.java
index e062276..03bcc72 100644
--- a/src/com/android/settings/display/AmbientDisplayAlwaysOnPreferenceController.java
+++ b/src/com/android/settings/display/AmbientDisplayAlwaysOnPreferenceController.java
@@ -85,6 +85,7 @@
mContext.getString(R.string.ambient_display_screen_title));
return new InlineSwitchPayload(Settings.Secure.DOZE_ALWAYS_ON,
- ResultPayload.SettingsSource.SECURE, ON, intent, isAvailable());
+ ResultPayload.SettingsSource.SECURE, ON /* onValue */, intent, isAvailable(),
+ ON /* defaultValue */);
}
}
diff --git a/src/com/android/settings/display/AutoBrightnessPreferenceController.java b/src/com/android/settings/display/AutoBrightnessPreferenceController.java
index d4226e2..12f3a8b 100644
--- a/src/com/android/settings/display/AutoBrightnessPreferenceController.java
+++ b/src/com/android/settings/display/AutoBrightnessPreferenceController.java
@@ -36,6 +36,9 @@
private final String mAutoBrightnessKey;
+ private final String SYSTEM_KEY = SCREEN_BRIGHTNESS_MODE;
+ private final int DEFAULT_VALUE = SCREEN_BRIGHTNESS_MODE_MANUAL;
+
public AutoBrightnessPreferenceController(Context context, String key) {
super(context);
mAutoBrightnessKey = key;
@@ -55,15 +58,15 @@
@Override
public void updateState(Preference preference) {
int brightnessMode = Settings.System.getInt(mContext.getContentResolver(),
- SCREEN_BRIGHTNESS_MODE, SCREEN_BRIGHTNESS_MODE_MANUAL);
- ((SwitchPreference) preference).setChecked(brightnessMode != SCREEN_BRIGHTNESS_MODE_MANUAL);
+ SYSTEM_KEY, DEFAULT_VALUE);
+ ((SwitchPreference) preference).setChecked(brightnessMode != DEFAULT_VALUE);
}
@Override
public boolean onPreferenceChange(Preference preference, Object newValue) {
boolean auto = (Boolean) newValue;
- Settings.System.putInt(mContext.getContentResolver(), SCREEN_BRIGHTNESS_MODE,
- auto ? SCREEN_BRIGHTNESS_MODE_AUTOMATIC : SCREEN_BRIGHTNESS_MODE_MANUAL);
+ Settings.System.putInt(mContext.getContentResolver(), SYSTEM_KEY,
+ auto ? SCREEN_BRIGHTNESS_MODE_AUTOMATIC : DEFAULT_VALUE);
return true;
}
@@ -73,8 +76,8 @@
DisplaySettings.class.getName(), mAutoBrightnessKey,
mContext.getString(R.string.display_settings));
- return new InlineSwitchPayload(SCREEN_BRIGHTNESS_MODE,
+ return new InlineSwitchPayload(SYSTEM_KEY,
ResultPayload.SettingsSource.SYSTEM, SCREEN_BRIGHTNESS_MODE_AUTOMATIC, intent,
- isAvailable());
+ isAvailable(), DEFAULT_VALUE);
}
-}
+}
\ No newline at end of file
diff --git a/src/com/android/settings/fuelgauge/anomaly/AnomalyLoader.java b/src/com/android/settings/fuelgauge/anomaly/AnomalyLoader.java
index eb125ad..596eaf5 100644
--- a/src/com/android/settings/fuelgauge/anomaly/AnomalyLoader.java
+++ b/src/com/android/settings/fuelgauge/anomaly/AnomalyLoader.java
@@ -98,15 +98,7 @@
mUserManager.getUserProfiles());
}
- final List<Anomaly> anomalies = new ArrayList<>();
- for (@Anomaly.AnomalyType int type : Anomaly.ANOMALY_TYPE_LIST) {
- if (mPolicy.isAnomalyDetectorEnabled(type)) {
- anomalies.addAll(mAnomalyUtils.getAnomalyDetector(type).detectAnomalies(
- mBatteryStatsHelper, mPackageName));
- }
- }
-
- return anomalies;
+ return mAnomalyUtils.detectAnomalies(mBatteryStatsHelper, mPolicy, mPackageName);
}
@VisibleForTesting
diff --git a/src/com/android/settings/fuelgauge/anomaly/AnomalyUtils.java b/src/com/android/settings/fuelgauge/anomaly/AnomalyUtils.java
index 8ac9e6f..491a3b4 100644
--- a/src/com/android/settings/fuelgauge/anomaly/AnomalyUtils.java
+++ b/src/com/android/settings/fuelgauge/anomaly/AnomalyUtils.java
@@ -20,6 +20,7 @@
import android.os.Build;
import android.support.annotation.VisibleForTesting;
+import com.android.internal.os.BatteryStatsHelper;
import com.android.settings.fuelgauge.anomaly.action.AnomalyAction;
import com.android.settings.fuelgauge.anomaly.action.ForceStopAction;
import com.android.settings.fuelgauge.anomaly.action.LocationCheckAction;
@@ -29,6 +30,9 @@
import com.android.settings.fuelgauge.anomaly.checker.WakeLockAnomalyDetector;
import com.android.settings.fuelgauge.anomaly.checker.WakeupAlarmAnomalyDetector;
+import java.util.ArrayList;
+import java.util.List;
+
/**
* Utility class for anomaly detection
*/
@@ -91,4 +95,27 @@
return null;
}
}
+
+ /**
+ * Detect whether application with {@code targetPackageName} has anomaly. When
+ * {@code targetPackageName} is null, start detection among all the applications.
+ *
+ * @param batteryStatsHelper contains battery stats, used to detect anomaly
+ * @param policy contains configuration about anomaly check
+ * @param targetPackageName represents the app need to be detected
+ * @return the list of anomalies
+ */
+ public List<Anomaly> detectAnomalies(BatteryStatsHelper batteryStatsHelper,
+ AnomalyDetectionPolicy policy, String targetPackageName) {
+ final List<Anomaly> anomalies = new ArrayList<>();
+ for (@Anomaly.AnomalyType int type : Anomaly.ANOMALY_TYPE_LIST) {
+ if (policy.isAnomalyDetectorEnabled(type)) {
+ anomalies.addAll(getAnomalyDetector(type).detectAnomalies(
+ batteryStatsHelper, targetPackageName));
+ }
+ }
+
+ return anomalies;
+ }
+
}
diff --git a/src/com/android/settings/gestures/AssistGesturePreferenceController.java b/src/com/android/settings/gestures/AssistGesturePreferenceController.java
index da25ce1..b91f230 100644
--- a/src/com/android/settings/gestures/AssistGesturePreferenceController.java
+++ b/src/com/android/settings/gestures/AssistGesturePreferenceController.java
@@ -32,6 +32,8 @@
import com.android.settingslib.core.lifecycle.Lifecycle;
import com.android.settingslib.core.lifecycle.events.OnResume;
+import static android.provider.Settings.Secure.ASSIST_GESTURE_ENABLED;
+
public class AssistGesturePreferenceController extends GesturePreferenceController
implements OnResume {
@@ -41,6 +43,8 @@
private static final String PREF_KEY_VIDEO = "gesture_assist_video";
private final String mAssistGesturePrefKey;
+ private final String SECURE_KEY = ASSIST_GESTURE_ENABLED;
+
private final AssistGestureFeatureProvider mFeatureProvider;
private boolean mWasAvailable;
@@ -142,8 +146,7 @@
@Override
public boolean onPreferenceChange(Preference preference, Object newValue) {
final boolean enabled = (boolean) newValue;
- Settings.Secure.putInt(mContext.getContentResolver(),
- Settings.Secure.ASSIST_GESTURE_ENABLED, enabled ? ON : OFF);
+ Settings.Secure.putInt(mContext.getContentResolver(), SECURE_KEY, enabled ? ON : OFF);
updateState(preference);
return true;
}
@@ -161,7 +164,7 @@
@Override
protected boolean isSwitchPrefEnabled() {
final int assistGestureEnabled = Settings.Secure.getInt(mContext.getContentResolver(),
- Settings.Secure.ASSIST_GESTURE_ENABLED, 1);
+ SECURE_KEY, ON);
return assistGestureEnabled != 0;
}
@@ -171,7 +174,7 @@
AssistGestureSettings.class.getName(), mAssistGesturePrefKey,
mContext.getString(R.string.display_settings));
- return new InlineSwitchPayload(Settings.Secure.ASSIST_GESTURE_ENABLED,
- ResultPayload.SettingsSource.SECURE, ON, intent, isAvailable());
+ return new InlineSwitchPayload(SECURE_KEY, ResultPayload.SettingsSource.SECURE,
+ ON /* onValue */, intent, isAvailable(), ON /* defaultValue */);
}
}
diff --git a/src/com/android/settings/gestures/DoubleTapPowerPreferenceController.java b/src/com/android/settings/gestures/DoubleTapPowerPreferenceController.java
index 8d4116a..970b6a7 100644
--- a/src/com/android/settings/gestures/DoubleTapPowerPreferenceController.java
+++ b/src/com/android/settings/gestures/DoubleTapPowerPreferenceController.java
@@ -22,14 +22,14 @@
import android.provider.Settings;
import android.support.v7.preference.Preference;
-import com.android.settings.DisplaySettings;
import com.android.settings.R;
-import com.android.settings.overlay.FeatureFactory;
import com.android.settings.search.DatabaseIndexingUtils;
import com.android.settings.search.InlineSwitchPayload;
import com.android.settings.search.ResultPayload;
import com.android.settingslib.core.lifecycle.Lifecycle;
+import static android.provider.Settings.Secure.CAMERA_DOUBLE_TAP_POWER_GESTURE_DISABLED;
+
public class DoubleTapPowerPreferenceController extends GesturePreferenceController {
private final int ON = 0;
@@ -38,6 +38,8 @@
private static final String PREF_KEY_VIDEO = "gesture_double_tap_power_video";
private final String mDoubleTapPowerKey;
+ private final String SECURE_KEY = CAMERA_DOUBLE_TAP_POWER_GESTURE_DISABLED;
+
public DoubleTapPowerPreferenceController(Context context, Lifecycle lifecycle, String key) {
super(context, lifecycle);
mDoubleTapPowerKey = key;
@@ -71,15 +73,14 @@
@Override
public boolean onPreferenceChange(Preference preference, Object newValue) {
boolean enabled = (boolean) newValue;
- Settings.Secure.putInt(mContext.getContentResolver(),
- Settings.Secure.CAMERA_DOUBLE_TAP_POWER_GESTURE_DISABLED, enabled ? ON : OFF);
+ Settings.Secure.putInt(mContext.getContentResolver(), SECURE_KEY, enabled ? ON : OFF);
return true;
}
@Override
protected boolean isSwitchPrefEnabled() {
final int cameraDisabled = Settings.Secure.getInt(mContext.getContentResolver(),
- Settings.Secure.CAMERA_DOUBLE_TAP_POWER_GESTURE_DISABLED, 0);
+ SECURE_KEY, ON);
return cameraDisabled == 0;
}
@@ -89,7 +90,7 @@
DoubleTapPowerSettings.class.getName(), mDoubleTapPowerKey,
mContext.getString(R.string.display_settings));
- return new InlineSwitchPayload(Settings.Secure.CAMERA_DOUBLE_TAP_POWER_GESTURE_DISABLED,
- ResultPayload.SettingsSource.SECURE, ON, intent, isAvailable());
+ return new InlineSwitchPayload(SECURE_KEY, ResultPayload.SettingsSource.SECURE,
+ ON /* onValue */, intent, isAvailable(), ON /* defaultValue */);
}
}
diff --git a/src/com/android/settings/gestures/DoubleTapScreenPreferenceController.java b/src/com/android/settings/gestures/DoubleTapScreenPreferenceController.java
index 4de6e14..9ec06ae 100644
--- a/src/com/android/settings/gestures/DoubleTapScreenPreferenceController.java
+++ b/src/com/android/settings/gestures/DoubleTapScreenPreferenceController.java
@@ -25,12 +25,13 @@
import com.android.internal.hardware.AmbientDisplayConfiguration;
import com.android.settings.R;
-import com.android.settings.overlay.FeatureFactory;
import com.android.settings.search.DatabaseIndexingUtils;
import com.android.settings.search.InlineSwitchPayload;
import com.android.settings.search.ResultPayload;
import com.android.settingslib.core.lifecycle.Lifecycle;
+import static android.provider.Settings.Secure.DOZE_PULSE_ON_DOUBLE_TAP;
+
public class DoubleTapScreenPreferenceController extends GesturePreferenceController {
private final int ON = 1;
@@ -39,6 +40,8 @@
private static final String PREF_KEY_VIDEO = "gesture_double_tap_screen_video";
private final String mDoubleTapScreenPrefKey;
+ private final String SECURE_KEY = DOZE_PULSE_ON_DOUBLE_TAP;
+
private final AmbientDisplayConfiguration mAmbientConfig;
@UserIdInt
private final int mUserId;
@@ -70,8 +73,7 @@
@Override
public boolean onPreferenceChange(Preference preference, Object newValue) {
final boolean enabled = (boolean) newValue;
- Settings.Secure.putInt(mContext.getContentResolver(),
- Settings.Secure.DOZE_PULSE_ON_DOUBLE_TAP, enabled ? ON : OFF);
+ Settings.Secure.putInt(mContext.getContentResolver(), SECURE_KEY, enabled ? ON : OFF);
return true;
}
@@ -91,7 +93,7 @@
DoubleTapScreenSettings.class.getName(), mDoubleTapScreenPrefKey,
mContext.getString(R.string.display_settings));
- return new InlineSwitchPayload(Settings.Secure.DOZE_PULSE_ON_DOUBLE_TAP,
- ResultPayload.SettingsSource.SECURE, ON, intent, isAvailable());
+ return new InlineSwitchPayload(SECURE_KEY, ResultPayload.SettingsSource.SECURE,
+ ON /* onValue */, intent, isAvailable(), ON /* defaultValue */);
}
-}
+}
\ No newline at end of file
diff --git a/src/com/android/settings/gestures/PickupGesturePreferenceController.java b/src/com/android/settings/gestures/PickupGesturePreferenceController.java
index 9a4c846..e64c0cf 100644
--- a/src/com/android/settings/gestures/PickupGesturePreferenceController.java
+++ b/src/com/android/settings/gestures/PickupGesturePreferenceController.java
@@ -30,6 +30,8 @@
import com.android.settings.search.ResultPayload;
import com.android.settingslib.core.lifecycle.Lifecycle;
+import static android.provider.Settings.Secure.DOZE_PULSE_ON_PICK_UP;
+
public class PickupGesturePreferenceController extends GesturePreferenceController {
private final int ON = 1;
@@ -38,6 +40,8 @@
private static final String PREF_KEY_VIDEO = "gesture_pick_up_video";
private final String mPickUpPrefKey;
+ private final String SECURE_KEY = DOZE_PULSE_ON_PICK_UP;
+
private final AmbientDisplayConfiguration mAmbientConfig;
@UserIdInt
private final int mUserId;
@@ -80,7 +84,7 @@
public boolean onPreferenceChange(Preference preference, Object newValue) {
final boolean enabled = (boolean) newValue;
Settings.Secure.putInt(mContext.getContentResolver(),
- Settings.Secure.DOZE_PULSE_ON_PICK_UP, enabled ? ON : OFF);
+ SECURE_KEY, enabled ? ON : OFF);
return true;
}
@@ -95,7 +99,7 @@
PickupGestureSettings.class.getName(), mPickUpPrefKey,
mContext.getString(R.string.display_settings));
- return new InlineSwitchPayload(Settings.Secure.DOZE_PULSE_ON_PICK_UP,
- ResultPayload.SettingsSource.SECURE, ON, intent, isAvailable());
+ return new InlineSwitchPayload(SECURE_KEY, ResultPayload.SettingsSource.SECURE,
+ ON /* onValue */, intent, isAvailable(), ON /* defaultValue */);
}
}
diff --git a/src/com/android/settings/gestures/SwipeToNotificationPreferenceController.java b/src/com/android/settings/gestures/SwipeToNotificationPreferenceController.java
index 05c6461..bc6950e 100644
--- a/src/com/android/settings/gestures/SwipeToNotificationPreferenceController.java
+++ b/src/com/android/settings/gestures/SwipeToNotificationPreferenceController.java
@@ -29,6 +29,8 @@
import com.android.settings.search.ResultPayload;
import com.android.settingslib.core.lifecycle.Lifecycle;
+import static android.provider.Settings.Secure.SYSTEM_NAVIGATION_KEYS_ENABLED;
+
public class SwipeToNotificationPreferenceController extends GesturePreferenceController {
private final int ON = 1;
@@ -37,6 +39,8 @@
private static final String PREF_KEY_VIDEO = "gesture_swipe_down_fingerprint_video";
private final String mSwipeDownFingerPrefKey;
+ private final String SECURE_KEY = SYSTEM_NAVIGATION_KEYS_ENABLED;
+
public SwipeToNotificationPreferenceController(Context context, Lifecycle lifecycle,
String key) {
super(context, lifecycle);
@@ -71,16 +75,14 @@
@Override
public boolean onPreferenceChange(Preference preference, Object newValue) {
- Settings.Secure.putInt(mContext.getContentResolver(),
- Settings.Secure.SYSTEM_NAVIGATION_KEYS_ENABLED, (boolean) newValue ? ON : OFF);
+ Settings.Secure.putInt(mContext.getContentResolver(), SECURE_KEY,
+ (boolean) newValue ? ON : OFF);
return true;
}
@Override
protected boolean isSwitchPrefEnabled() {
- return Settings.Secure.getInt(mContext.getContentResolver(),
- Settings.Secure.SYSTEM_NAVIGATION_KEYS_ENABLED, 0)
- == 1;
+ return Settings.Secure.getInt(mContext.getContentResolver(), SECURE_KEY, OFF) == ON;
}
@Override
@@ -89,7 +91,7 @@
SwipeToNotificationSettings.class.getName(), mSwipeDownFingerPrefKey,
mContext.getString(R.string.display_settings));
- return new InlineSwitchPayload(Settings.Secure.SYSTEM_NAVIGATION_KEYS_ENABLED,
- ResultPayload.SettingsSource.SECURE, ON, intent, isAvailable());
+ return new InlineSwitchPayload(SECURE_KEY, ResultPayload.SettingsSource.SECURE,
+ ON /* onValue */, intent, isAvailable(), ON /* defaultValue */);
}
}
diff --git a/src/com/android/settings/location/LocationPreferenceController.java b/src/com/android/settings/location/LocationPreferenceController.java
index da7f299..bd7aea1 100644
--- a/src/com/android/settings/location/LocationPreferenceController.java
+++ b/src/com/android/settings/location/LocationPreferenceController.java
@@ -132,7 +132,6 @@
return new InlineListPayload(Secure.LOCATION_MODE,
ResultPayload.SettingsSource.SECURE, intent, isAvailable(),
- Secure.LOCATION_MODE_HIGH_ACCURACY + 1);
+ Secure.LOCATION_MODE_HIGH_ACCURACY + 1, Secure.LOCATION_MODE_OFF);
}
-
}
diff --git a/src/com/android/settings/network/AirplaneModePreferenceController.java b/src/com/android/settings/network/AirplaneModePreferenceController.java
index 8422ab4..05c428a 100644
--- a/src/com/android/settings/network/AirplaneModePreferenceController.java
+++ b/src/com/android/settings/network/AirplaneModePreferenceController.java
@@ -45,7 +45,6 @@
private final Fragment mFragment;
private final MetricsFeatureProvider mMetricsFeatureProvider;
- private final PackageManager mPackageManager;
private AirplaneModeEnabler mAirplaneModeEnabler;
private SwitchPreference mAirplaneModePreference;
@@ -53,7 +52,6 @@
public AirplaneModePreferenceController(Context context, Fragment hostFragment) {
super(context);
mFragment = hostFragment;
- mPackageManager = context.getPackageManager();
mMetricsFeatureProvider = FeatureFactory.getFactory(context).getMetricsFeatureProvider();
}
@@ -88,7 +86,11 @@
@Override
public boolean isAvailable() {
- return !mPackageManager.hasSystemFeature(PackageManager.FEATURE_TELEVISION);
+ return isAvailable(mContext);
+ }
+
+ public static boolean isAvailable(Context context) {
+ return !context.getPackageManager().hasSystemFeature(PackageManager.FEATURE_TELEVISION);
}
@Override
diff --git a/src/com/android/settings/network/MobileNetworkPreferenceController.java b/src/com/android/settings/network/MobileNetworkPreferenceController.java
index b91552e..bfe013b 100644
--- a/src/com/android/settings/network/MobileNetworkPreferenceController.java
+++ b/src/com/android/settings/network/MobileNetworkPreferenceController.java
@@ -39,18 +39,17 @@
private static final String KEY_MOBILE_NETWORK_SETTINGS = "mobile_network_settings";
- private final UserManager mUserManager;
private final boolean mIsSecondaryUser;
private final TelephonyManager mTelephonyManager;
private Preference mPreference;
- @VisibleForTesting(otherwise = VisibleForTesting.PRIVATE)
+ @VisibleForTesting
PhoneStateListener mPhoneStateListener;
public MobileNetworkPreferenceController(Context context) {
super(context);
- mUserManager = (UserManager) context.getSystemService(Context.USER_SERVICE);
+ UserManager userManager = (UserManager) context.getSystemService(Context.USER_SERVICE);
mTelephonyManager = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
- mIsSecondaryUser = !mUserManager.isAdminUser();
+ mIsSecondaryUser = !userManager.isAdminUser();
}
@Override
diff --git a/src/com/android/settings/search/BaseSearchIndexProvider.java b/src/com/android/settings/search/BaseSearchIndexProvider.java
index 11b4db1..239de15 100644
--- a/src/com/android/settings/search/BaseSearchIndexProvider.java
+++ b/src/com/android/settings/search/BaseSearchIndexProvider.java
@@ -16,10 +16,12 @@
package com.android.settings.search;
+import android.annotation.XmlRes;
import android.content.Context;
import android.content.res.XmlResourceParser;
import android.provider.SearchIndexableResource;
import android.support.annotation.CallSuper;
+import android.support.annotation.VisibleForTesting;
import android.text.TextUtils;
import android.util.AttributeSet;
import android.util.Log;
@@ -94,18 +96,25 @@
}
final List<String> nonIndexableKeys = new ArrayList<>();
for (SearchIndexableResource res : resources) {
- final XmlResourceParser parser = context.getResources().getXml(res.xmlResId);
- final AttributeSet attrs = Xml.asAttributeSet(parser);
- try {
- while (parser.next() != XmlPullParser.END_DOCUMENT) {
- final String key = XmlParserUtils.getDataKey(context, attrs);
- if (!TextUtils.isEmpty(key)) {
- nonIndexableKeys.add(key);
- }
+ nonIndexableKeys.addAll(getNonIndexableKeysFromXml(context, res.xmlResId));
+ }
+ return nonIndexableKeys;
+ }
+
+ @VisibleForTesting(otherwise = VisibleForTesting.PROTECTED)
+ public List<String> getNonIndexableKeysFromXml(Context context, @XmlRes int xmlResId) {
+ final List<String> nonIndexableKeys = new ArrayList<>();
+ final XmlResourceParser parser = context.getResources().getXml(xmlResId);
+ final AttributeSet attrs = Xml.asAttributeSet(parser);
+ try {
+ while (parser.next() != XmlPullParser.END_DOCUMENT) {
+ final String key = XmlParserUtils.getDataKey(context, attrs);
+ if (!TextUtils.isEmpty(key)) {
+ nonIndexableKeys.add(key);
}
- } catch (IOException | XmlPullParserException e) {
- Log.w(TAG, "Error parsing non-indexable from xml " + res.xmlResId);
}
+ } catch (IOException | XmlPullParserException e) {
+ Log.w(TAG, "Error parsing non-indexable from xml " + xmlResId);
}
return nonIndexableKeys;
}
diff --git a/src/com/android/settings/search/InlineListPayload.java b/src/com/android/settings/search/InlineListPayload.java
index 60113b9..c11c4a3 100644
--- a/src/com/android/settings/search/InlineListPayload.java
+++ b/src/com/android/settings/search/InlineListPayload.java
@@ -16,8 +16,8 @@
private int mNumOptions;
public InlineListPayload(String key, @PayloadType int payloadType, Intent intent,
- boolean isDeviceSupported, int numOptions) {
- super(key, payloadType, intent, isDeviceSupported);
+ boolean isDeviceSupported, int numOptions, int defaultValue) {
+ super(key, payloadType, intent, isDeviceSupported, defaultValue);
mNumOptions = numOptions;
}
diff --git a/src/com/android/settings/search/InlinePayload.java b/src/com/android/settings/search/InlinePayload.java
index 0807f62..03b8828 100644
--- a/src/com/android/settings/search/InlinePayload.java
+++ b/src/com/android/settings/search/InlinePayload.java
@@ -49,24 +49,31 @@
final boolean mIsDeviceSupported;
/**
+ * The default value for the setting.
+ */
+ final int mDefaultvalue;
+
+ /**
* @param key uniquely identifies the stored setting.
* @param source of the setting. Used to determine where to get and set the setting.
* @param intent to the setting page.
* @param isDeviceSupported is true when the setting is valid for the given device.
*/
public InlinePayload(String key, @SettingsSource int source, Intent intent,
- boolean isDeviceSupported) {
+ boolean isDeviceSupported, int defaultValue) {
super(intent);
mSettingKey = key;
mSettingSource = source;
mIsDeviceSupported = isDeviceSupported;
+ mDefaultvalue = defaultValue;
}
InlinePayload(Parcel parcel) {
- super((Intent) parcel.readParcelable(Intent.class.getClassLoader()));
+ super(parcel.readParcelable(Intent.class.getClassLoader()));
mSettingKey = parcel.readString();
mSettingSource = parcel.readInt();
mIsDeviceSupported = parcel.readInt() == TRUE;
+ mDefaultvalue = parcel.readInt();
}
@Override
@@ -75,6 +82,7 @@
dest.writeString(mSettingKey);
dest.writeInt(mSettingSource);
dest.writeInt(mIsDeviceSupported ? TRUE : FALSE);
+ dest.writeInt(mDefaultvalue);
}
@Override
@@ -108,24 +116,19 @@
switch(mSettingSource) {
case SettingsSource.SECURE:
settingsValue = Settings.Secure.getInt(context.getContentResolver(),
- mSettingKey, -1);
+ mSettingKey, mDefaultvalue);
break;
case SettingsSource.SYSTEM:
settingsValue = Settings.System.getInt(context.getContentResolver(),
- mSettingKey, -1);
+ mSettingKey, mDefaultvalue);
break;
case SettingsSource.GLOBAL:
settingsValue = Settings.Global.getInt(context.getContentResolver(),
- mSettingKey, -1);
+ mSettingKey, mDefaultvalue);
break;
}
- if (settingsValue == -1) {
- throw new IllegalStateException("Unable to find setting from uri: "
- + mSettingKey.toString());
- }
-
return standardizeInput(settingsValue);
}
diff --git a/src/com/android/settings/search/InlineSwitchPayload.java b/src/com/android/settings/search/InlineSwitchPayload.java
index 8916dde..bac0313 100644
--- a/src/com/android/settings/search/InlineSwitchPayload.java
+++ b/src/com/android/settings/search/InlineSwitchPayload.java
@@ -45,8 +45,8 @@
* @param isDeviceSupported is true when the setting is valid for the given device.
*/
public InlineSwitchPayload(String key, @SettingsSource int source,
- int onValue, Intent intent, boolean isDeviceSupported) {
- super(key, source, intent, isDeviceSupported);
+ int onValue, Intent intent, boolean isDeviceSupported, int defaultValue) {
+ super(key, source, intent, isDeviceSupported, defaultValue);
// If on is stored as TRUE then the switch is standard.
mIsStandard = onValue == TRUE;
}
diff --git a/src/com/android/settings/search/SearchIndexableResources.java b/src/com/android/settings/search/SearchIndexableResources.java
index 9b84bf1..31d39b5 100644
--- a/src/com/android/settings/search/SearchIndexableResources.java
+++ b/src/com/android/settings/search/SearchIndexableResources.java
@@ -171,8 +171,7 @@
addIndex(LocationSettings.class, R.xml.location_settings, R.drawable.ic_settings_location);
addIndex(ScanningSettings.class, R.xml.location_scanning, R.drawable.ic_settings_location);
addIndex(SecuritySettings.class, NO_DATA_RES_ID, R.drawable.ic_settings_security);
- addIndex(EncryptionAndCredential.class, R.xml.encryption_and_credential,
- R.drawable.ic_settings_security);
+ addIndex(EncryptionAndCredential.class, NO_DATA_RES_ID, R.drawable.ic_settings_security);
addIndex(ScreenPinningSettings.class, NO_DATA_RES_ID, R.drawable.ic_settings_security);
addIndex(UserAndAccountDashboardFragment.class, NO_DATA_RES_ID,
R.drawable.ic_settings_accounts);
diff --git a/tests/robotests/src/com/android/settings/EncryptionAndCredentialTest.java b/tests/robotests/src/com/android/settings/EncryptionAndCredentialTest.java
index bc88b1a..7a3875e 100644
--- a/tests/robotests/src/com/android/settings/EncryptionAndCredentialTest.java
+++ b/tests/robotests/src/com/android/settings/EncryptionAndCredentialTest.java
@@ -16,23 +16,110 @@
package com.android.settings;
+import static android.app.admin.DevicePolicyManager.ENCRYPTION_STATUS_ACTIVE;
+import static android.app.admin.DevicePolicyManager.ENCRYPTION_STATUS_INACTIVE;
+import static com.android.settings.EncryptionAndCredential.SEARCH_INDEX_DATA_PROVIDER;
+import static com.google.common.truth.Truth.assertThat;
+import static org.mockito.Mockito.when;
+
+import android.app.admin.DevicePolicyManager;
+import android.content.Context;
+import android.os.UserManager;
+import android.provider.SearchIndexableResource;
+
import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
+import com.android.settings.search.BaseSearchIndexProvider;
import com.android.settings.testutils.SettingsRobolectricTestRunner;
-import static com.google.common.truth.Truth.assertThat;
-
+import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
import org.robolectric.annotation.Config;
+import org.robolectric.shadows.ShadowApplication;
+
+import java.util.ArrayList;
+import java.util.List;
@RunWith(SettingsRobolectricTestRunner.class)
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
public class EncryptionAndCredentialTest {
+ @Mock
+ private UserManager mUserManager;
+ @Mock
+ private DevicePolicyManager mDevicePolicyManager;
+
+ private ShadowApplication mApplication;
+ private Context mContext;
+
+ @Before
+ public void setUp() {
+ MockitoAnnotations.initMocks(this);
+ mApplication = ShadowApplication.getInstance();
+ mApplication.setSystemService(Context.DEVICE_POLICY_SERVICE, mDevicePolicyManager);
+ mApplication.setSystemService(Context.USER_SERVICE, mUserManager);
+ mContext = mApplication.getApplicationContext();
+ }
+
@Test
public void getMetricsCategory_shouldReturnEncryptionAndCredential() {
EncryptionAndCredential fragment = new EncryptionAndCredential();
assertThat(fragment.getMetricsCategory()).isEqualTo(MetricsEvent.ENCRYPTION_AND_CREDENTIAL);
}
+ // Search provider tests
+ @Test
+ public void getXmlResourcesToIndex_shouldReturnAllXmls() {
+ final List<SearchIndexableResource> index =
+ SEARCH_INDEX_DATA_PROVIDER.getXmlResourcesToIndex(
+ mContext, true /* enabled */);
+
+ assertThat(index).hasSize(3);
+ }
+
+ @Test
+ public void getNonIndexableKeys_pageIsDisabled_shouldReturnAllKeysAsNonIndexable() {
+ when(mUserManager.isAdminUser()).thenReturn(false);
+
+ final List<SearchIndexableResource> index =
+ SEARCH_INDEX_DATA_PROVIDER.getXmlResourcesToIndex(mContext, true /* enabled */);
+ final List<String> expectedKeys = new ArrayList<>();
+ for (SearchIndexableResource res : index) {
+ expectedKeys.addAll(((BaseSearchIndexProvider) SEARCH_INDEX_DATA_PROVIDER)
+ .getNonIndexableKeysFromXml(mContext, res.xmlResId));
+ }
+ final List<String> keys = SEARCH_INDEX_DATA_PROVIDER.getNonIndexableKeys(mContext);
+
+ assertThat(keys).containsExactlyElementsIn(expectedKeys);
+ }
+
+ @Test
+ public void getNonIndexableKeys_deviceEncrypted_shouldReturnUnencryptedKeys() {
+ when(mUserManager.isAdminUser()).thenReturn(true);
+ when(mDevicePolicyManager.getStorageEncryptionStatus()).thenReturn(
+ ENCRYPTION_STATUS_ACTIVE);
+
+ final List<String> expectedKeys = new ArrayList<>();
+ expectedKeys.addAll(((BaseSearchIndexProvider) SEARCH_INDEX_DATA_PROVIDER)
+ .getNonIndexableKeysFromXml(mContext, R.xml.security_settings_unencrypted));
+ final List<String> keys = SEARCH_INDEX_DATA_PROVIDER.getNonIndexableKeys(mContext);
+
+ assertThat(keys).containsExactlyElementsIn(expectedKeys);
+ }
+
+ @Test
+ public void getNonIndexableKeys_deviceNotEncrypted_shouldReturnEncryptedKeys() {
+ when(mUserManager.isAdminUser()).thenReturn(true);
+ when(mDevicePolicyManager.getStorageEncryptionStatus())
+ .thenReturn(ENCRYPTION_STATUS_INACTIVE);
+
+ final List<String> expectedKeys = new ArrayList<>();
+ expectedKeys.addAll(((BaseSearchIndexProvider) SEARCH_INDEX_DATA_PROVIDER)
+ .getNonIndexableKeysFromXml(mContext, R.xml.security_settings_encrypted));
+ final List<String> keys = SEARCH_INDEX_DATA_PROVIDER.getNonIndexableKeys(mContext);
+
+ assertThat(keys).containsExactlyElementsIn(expectedKeys);
+ }
}
diff --git a/tests/robotests/src/com/android/settings/applications/RecentAppsPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/applications/RecentAppsPreferenceControllerTest.java
index c89fff8..4403991 100644
--- a/tests/robotests/src/com/android/settings/applications/RecentAppsPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/applications/RecentAppsPreferenceControllerTest.java
@@ -72,6 +72,8 @@
private PreferenceCategory mCategory;
@Mock
private Preference mSeeAllPref;
+ @Mock
+ private PreferenceCategory mDivider;
@Mock(answer = Answers.RETURNS_DEEP_STUBS)
private Context mMockContext;
@Mock
@@ -98,6 +100,8 @@
when(mScreen.findPreference(RecentAppsPreferenceController.KEY_SEE_ALL))
.thenReturn(mSeeAllPref);
+ when(mScreen.findPreference(RecentAppsPreferenceController.KEY_DIVIDER))
+ .thenReturn(mDivider);
when(mCategory.getContext()).thenReturn(mContext);
}
@@ -112,7 +116,8 @@
mController.updateNonIndexableKeys(nonIndexable);
- assertThat(nonIndexable).containsExactly(mController.getPreferenceKey());
+ assertThat(nonIndexable).containsAllOf(mController.getPreferenceKey(),
+ RecentAppsPreferenceController.KEY_DIVIDER);
}
@Test
@@ -140,6 +145,7 @@
verify(mCategory).setTitle(null);
verify(mSeeAllPref).setTitle(R.string.applications_settings);
verify(mSeeAllPref).setIcon(null);
+ verify(mDivider).setVisible(false);
}
@Test
@@ -186,6 +192,7 @@
verify(mSeeAllPref).setSummary(null);
verify(mSeeAllPref).setIcon(R.drawable.ic_chevron_right_24dp);
+ verify(mDivider).setVisible(true);
}
@Test
diff --git a/tests/robotests/src/com/android/settings/deviceinfo/storage/StorageSummaryDonutPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/deviceinfo/storage/StorageSummaryDonutPreferenceControllerTest.java
index d3c6a25..bd40240 100644
--- a/tests/robotests/src/com/android/settings/deviceinfo/storage/StorageSummaryDonutPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/deviceinfo/storage/StorageSummaryDonutPreferenceControllerTest.java
@@ -42,6 +42,7 @@
import com.android.settings.testutils.shadow.SettingsShadowResources;
import com.android.settingslib.deviceinfo.StorageVolumeProvider;
+import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -70,6 +71,8 @@
@Before
public void setUp() throws Exception {
+ SettingsShadowResources.overrideResource(
+ com.android.internal.R.string.config_headlineFontFamily, "");
mContext = spy(RuntimeEnvironment.application.getApplicationContext());
FakeFeatureFactory.setupForTest(mContext);
mFakeFeatureFactory = (FakeFeatureFactory) FakeFeatureFactory.getFactory(mContext);
@@ -84,6 +87,11 @@
mHolder = PreferenceViewHolder.createInstanceForTests(view);
}
+ @After
+ public void tearDown() {
+ SettingsShadowResources.reset();
+ }
+
@Test
public void testEmpty() throws Exception {
mController.updateBytes(0, 32 * GIGABYTE);
diff --git a/tests/robotests/src/com/android/settings/password/SetupChooseLockPasswordTest.java b/tests/robotests/src/com/android/settings/password/SetupChooseLockPasswordTest.java
index 3e9c39c..39a0fb6 100644
--- a/tests/robotests/src/com/android/settings/password/SetupChooseLockPasswordTest.java
+++ b/tests/robotests/src/com/android/settings/password/SetupChooseLockPasswordTest.java
@@ -38,6 +38,8 @@
import com.android.settings.testutils.shadow.ShadowEventLogWriter;
import com.android.settings.testutils.shadow.ShadowUtils;
+import org.junit.After;
+import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.robolectric.Robolectric;
@@ -66,6 +68,17 @@
})
public class SetupChooseLockPasswordTest {
+ @Before
+ public void setUp() throws Exception {
+ SettingsShadowResources.overrideResource(
+ com.android.internal.R.string.config_headlineFontFamily, "");
+ }
+
+ @After
+ public void tearDown() {
+ SettingsShadowResources.reset();
+ }
+
@Test
public void createActivity_shouldNotCrash() {
// Basic sanity test for activity created without crashing
diff --git a/tests/robotests/src/com/android/settings/search/CursorToSearchResultConverterTest.java b/tests/robotests/src/com/android/settings/search/CursorToSearchResultConverterTest.java
index 1aed11d..f7628ca 100644
--- a/tests/robotests/src/com/android/settings/search/CursorToSearchResultConverterTest.java
+++ b/tests/robotests/src/com/android/settings/search/CursorToSearchResultConverterTest.java
@@ -220,7 +220,7 @@
final Intent intent = new Intent();
intent.putExtra(intentKey, intentVal);
final InlineSwitchPayload payload = new InlineSwitchPayload(uri, source, 1 /* onValue */,
- intent, true /* isDeviceSupported */);
+ intent, true /* isDeviceSupported */, 0 /* defautValue */);
cursor.addRow(new Object[]{
KEY.hashCode(), // Doc ID
diff --git a/tests/robotests/src/com/android/settings/search/DatabaseRowTest.java b/tests/robotests/src/com/android/settings/search/DatabaseRowTest.java
index 60afff5..a0d3163 100644
--- a/tests/robotests/src/com/android/settings/search/DatabaseRowTest.java
+++ b/tests/robotests/src/com/android/settings/search/DatabaseRowTest.java
@@ -114,7 +114,7 @@
public void testRowWithInlinePayload_genericPayloadNotAdded() {
final String URI = "test uri";
final InlineSwitchPayload payload = new InlineSwitchPayload(URI, 0 /* mSettingSource */,
- 1 /* onValue */, null /* intent */, true /* isDeviceSupported */);
+ 1 /* onValue */, null /* intent */, true /* isDeviceSupported */, 1 /* default */);
mBuilder.setPayload(payload);
final DatabaseRow row = generateRow();
final InlineSwitchPayload unmarshalledPayload = ResultPayloadUtils
@@ -133,7 +133,7 @@
intent.setComponent(component);
final InlineSwitchPayload payload = new InlineSwitchPayload(URI, 0 /* mSettingSource */,
- 1 /* onValue */, intent, true /* isDeviceSupported */);
+ 1 /* onValue */, intent, true /* isDeviceSupported */, 1 /* default */);
mBuilder.setPayload(payload);
final DatabaseRow row = generateRow();
final InlineSwitchPayload unmarshalledPayload = ResultPayloadUtils
diff --git a/tests/robotests/src/com/android/settings/search/InlineListPayloadTest.java b/tests/robotests/src/com/android/settings/search/InlineListPayloadTest.java
index 60e24f9..bee8d93 100644
--- a/tests/robotests/src/com/android/settings/search/InlineListPayloadTest.java
+++ b/tests/robotests/src/com/android/settings/search/InlineListPayloadTest.java
@@ -37,7 +37,7 @@
intent.putExtra(intentKey, intentVal);
InlineListPayload payload = new InlineListPayload(uri, source,
- intent, true /* isAvailable */, 1);
+ intent, true /* isAvailable */, 1 /* numOptions */, 1 /* default */);
final Intent retainedIntent = payload.getIntent();
assertThat(payload.mSettingKey).isEqualTo(uri);
@@ -80,7 +80,7 @@
public void testInputStandardization_inputDoesntChange() {
InlineListPayload payload = new InlineListPayload(DUMMY_SETTING,
ResultPayload.SettingsSource.SYSTEM, null /* intent */, true /* isDeviceSupport */,
- 3 /* numOptions */);
+ 3 /* numOptions */, 0 /* default */);
int input = 2;
assertThat(payload.standardizeInput(input)).isEqualTo(input);
@@ -90,7 +90,7 @@
public void testSetSystem_negativeValue_throwsError() {
InlineListPayload payload = new InlineListPayload(DUMMY_SETTING,
ResultPayload.SettingsSource.SYSTEM, null /* intent */, true /* isDeviceSupport */,
- 3 /* numOptions */);
+ 3 /* numOptions */, 0 /* default */);
payload.setValue(mContext, -1);
}
@@ -100,7 +100,7 @@
int maxOptions = 4;
InlineListPayload payload = new InlineListPayload(DUMMY_SETTING,
ResultPayload.SettingsSource.SYSTEM, null /* intent */, true /* isDeviceSupport */,
- maxOptions /* numOptions */);
+ maxOptions /* numOptions */, 0 /* default */);
payload.setValue(mContext, maxOptions + 1);
}
diff --git a/tests/robotests/src/com/android/settings/search/InlinePayloadTest.java b/tests/robotests/src/com/android/settings/search/InlinePayloadTest.java
index b2a6211..1747cca 100644
--- a/tests/robotests/src/com/android/settings/search/InlinePayloadTest.java
+++ b/tests/robotests/src/com/android/settings/search/InlinePayloadTest.java
@@ -111,7 +111,7 @@
public ConcreteInlinePayload(String key, @SettingsSource int source, Intent intent,
boolean isDeviceSupported) {
- super(key, source, intent, isDeviceSupported);
+ super(key, source, intent, isDeviceSupported, 0 /* defaultValue */);
}
@Override
diff --git a/tests/robotests/src/com/android/settings/search/InlineSwitchPayloadTest.java b/tests/robotests/src/com/android/settings/search/InlineSwitchPayloadTest.java
index 2c16c13..b067ea6 100644
--- a/tests/robotests/src/com/android/settings/search/InlineSwitchPayloadTest.java
+++ b/tests/robotests/src/com/android/settings/search/InlineSwitchPayloadTest.java
@@ -61,7 +61,8 @@
final Intent intent = new Intent();
intent.putExtra(intentKey, intentVal);
- InlineSwitchPayload payload = new InlineSwitchPayload(uri, source, 1, intent, true);
+ InlineSwitchPayload payload = new InlineSwitchPayload(uri, source, 1, intent, true,
+ 1 /* default */);
final Intent retainedIntent = payload.getIntent();
assertThat(payload.mSettingKey).isEqualTo(uri);
assertThat(payload.getType()).isEqualTo(type);
@@ -86,6 +87,7 @@
parcel.writeInt(source);
parcel.writeInt(InlineSwitchPayload.TRUE);
parcel.writeInt(InlineSwitchPayload.TRUE);
+ parcel.writeInt(InlineSwitchPayload.TRUE);
parcel.setDataPosition(0);
InlineSwitchPayload payload = InlineSwitchPayload.CREATOR.createFromParcel(parcel);
@@ -103,7 +105,7 @@
public void testGetSystem_flippedSetting_returnsFlippedValue() {
// Stores 1s as 0s, and vis versa
InlineSwitchPayload payload = new InlineSwitchPayload(DUMMY_SETTING, SettingsSource.SYSTEM,
- FLIPPED_ON, null /* intent */, true);
+ FLIPPED_ON, null /* intent */, true, 1 /* default */);
int currentValue = 1;
Settings.System.putInt(mContext.getContentResolver(), DUMMY_SETTING, currentValue);
@@ -116,7 +118,7 @@
public void testSetSystem_flippedSetting_updatesToFlippedValue() {
// Stores 1s as 0s, and vis versa
InlineSwitchPayload payload = new InlineSwitchPayload(DUMMY_SETTING, SettingsSource.SYSTEM,
- FLIPPED_ON, null /* intent */, true);
+ FLIPPED_ON, null /* intent */, true, 1 /* default */);
int newValue = 1;
ContentResolver resolver = mContext.getContentResolver();
Settings.System.putInt(resolver, SCREEN_BRIGHTNESS_MODE, newValue);
@@ -130,7 +132,7 @@
@Test(expected = IllegalArgumentException.class)
public void testSetSystem_negativeValue_ThrowsError() {
InlineSwitchPayload payload = new InlineSwitchPayload(DUMMY_SETTING, SettingsSource.SYSTEM,
- STANDARD_ON, null /* intent */, true);
+ STANDARD_ON, null /* intent */, true, 1 /* default */);
payload.setValue(mContext, -1);
}
@@ -138,7 +140,7 @@
@Test(expected = IllegalArgumentException.class)
public void testSetSystem_highValue_ThrowsError() {
InlineSwitchPayload payload = new InlineSwitchPayload(DUMMY_SETTING, SettingsSource.SYSTEM,
- STANDARD_ON, null /* intent */, true);
+ STANDARD_ON, null /* intent */, true, 1 /* default */);
payload.setValue(mContext, 2);
}
diff --git a/tests/robotests/src/com/android/settings/search/InlineSwitchViewHolderTest.java b/tests/robotests/src/com/android/settings/search/InlineSwitchViewHolderTest.java
index 093909b..94ee335 100644
--- a/tests/robotests/src/com/android/settings/search/InlineSwitchViewHolderTest.java
+++ b/tests/robotests/src/com/android/settings/search/InlineSwitchViewHolderTest.java
@@ -107,7 +107,8 @@
.setSummary(SUMMARY)
.setRank(1)
.setPayload(new InlineSwitchPayload("" /* uri */, 0 /* mSettingSource */,
- 1 /* onValue */, null /* intent */, true /* isDeviceSupported */))
+ 1 /* onValue */, null /* intent */, true /* isDeviceSupported */,
+ 1 /* default */))
.addBreadcrumbs(new ArrayList<>())
.setIcon(mIcon)
.setPayload(mPayload)