diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index 98789bdc86c..07bc06cf354 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -3314,7 +3314,7 @@
+ android:label="@string/cards_passes_sentence">
@@ -3323,6 +3323,26 @@
android:value="com.android.settings.gestures.GlobalActionsPanelSettings" />
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
diff --git a/res/layout/zen_mode_senders_image.xml b/res/layout/zen_mode_senders_image.xml
index bc7cdae2627..6456b34ac9e 100644
--- a/res/layout/zen_mode_senders_image.xml
+++ b/res/layout/zen_mode_senders_image.xml
@@ -21,5 +21,7 @@
+ android:layout_height="wrap_content"
+ android:layout_marginTop="@dimen/zen_senders_image_margin_vertical"
+ android:layout_marginBottom="@dimen/zen_senders_image_margin_vertical"/>
diff --git a/res/layout/zen_mode_senders_overlay_image.xml b/res/layout/zen_mode_senders_overlay_image.xml
index 6976df30d8f..39c1c20db71 100644
--- a/res/layout/zen_mode_senders_overlay_image.xml
+++ b/res/layout/zen_mode_senders_overlay_image.xml
@@ -20,6 +20,8 @@
android:id="@+id/zen_mode_settings_senders_overlay_view"
android:layout_centerInParent="true"
android:layout_width="wrap_content"
- android:layout_height="wrap_content">
+ android:layout_height="wrap_content"
+ android:layout_marginTop="@dimen/zen_conversations_image_margin_vertical"
+ android:layout_marginBottom="@dimen/zen_conversations_image_margin_vertical">
diff --git a/res/layout/zen_mode_settings_button.xml b/res/layout/zen_mode_settings_button.xml
index 72731cc6c2d..291e319c72b 100644
--- a/res/layout/zen_mode_settings_button.xml
+++ b/res/layout/zen_mode_settings_button.xml
@@ -19,37 +19,36 @@
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
- android:orientation="vertical"
- android:paddingVertical="@dimen/zen_mode_button_padding_vertical">
+ android:orientation="vertical">
+ android:layout_marginTop="@dimen/zen_mode_settings_button_margin_vertical"/>
+ android:layout_height="wrap_content"/>
+ android:layout_height="wrap_content"/>
\ No newline at end of file
diff --git a/res/values/dimens.xml b/res/values/dimens.xml
index c2539fa9fea..79d797ce94b 100755
--- a/res/values/dimens.xml
+++ b/res/values/dimens.xml
@@ -88,10 +88,15 @@
26dp
48dp
- 16dp
+ 36dp
+ 16dp
+ 24dp
+ 16dp
+ 24dp
+ 32dp
+ 50dp
7dp
17dp
- 56dp
8dp
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 6baea65c133..10aafc47904 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -7522,8 +7522,8 @@
work challenge, work, profile
work profile, managed profile, unify, unification, work, profile
gestures
-
- global actions
+ cards, passes
+ device controls, controls
pay, tap, payments
backup, back up
gesture
@@ -7956,7 +7956,7 @@
Schedules
- Set duration for Quick Settings
+ Duration for Quick Settings
When Do Not Disturb is on, sound and vibration will be muted, except for the items you allow above.
@@ -8879,7 +8879,7 @@
Conversations that can interrupt
All conversations
- Important conversations
+ Priority conversations
None
- 1 conversation
@@ -8900,7 +8900,7 @@
Calls that can interrupt
- To be sure allowed calls make sound, check whether your device is set to ring, vibrate, or silent.
+ To make sure allowed calls make sound, check that device is set to ring
For \u2018%1$s\u2019 incoming calls are blocked. You can adjust settings to allow your friends, family, or other contacts to reach you.
@@ -8917,11 +8917,11 @@
messages
- SMS, MMS, and messaging apps
+ Messages
Messages that can interrupt
- To be sure allowed messages make sound, check whether your device is set to ring, vibrate, or silent.
+ To make sure allowed messages make sound, check that device is set to ring
For \u2018%1$s\u2019 incoming messages are blocked. You can adjust settings to allow your friends, family, or other contacts to reach you.
@@ -8961,14 +8961,14 @@
Media sounds
- From videos, games, and other media
+ Sounds from videos, games, and other media
media
Touch sounds
- From your keyboard and other buttons
+ Sounds from the keyboard and other buttons
touch sounds
@@ -8980,7 +8980,7 @@
reminders
- Events
+ Calendar events
From upcoming calendar events
@@ -9062,7 +9062,7 @@
%1$s and %2$s
- If the same person calls a second time within a %d minute period
+ If the same person calls a second time within a %d-minute period
Custom
@@ -10725,13 +10725,6 @@
To check time, notifications, and other info, tap your screen.
-
- To show the global actions panel, press & hold Power button
-
- Show global actions
-
- Global actions
-
Swipe fingerprint for notifications
@@ -11854,11 +11847,11 @@
This choice is no longer valid. Try again.
-
- Quick controls
+
+ Device controls
-
- quick controls
+
+ device controls
Cards & passes
@@ -11875,11 +11868,11 @@
Show cards & passes
-
- Show quick controls
+
+ Show device controls
-
- Show cards, passes, and quick controls
+
+ Show cards, passes, and device controls
Don\u2019t show any content
@@ -11893,11 +11886,17 @@
Hide cards and controls when locked
-
- Show quick controls
+
+ Show device controls
-
- To access controls for connected devices, hold the Power button
+
+ Show cards & passes
+
+
+ To access controls for connected devices, hold the Power button
+
+
+ To access things like your payment methods and boarding passes, press and hold the Power button.
diff --git a/res/xml/development_settings.xml b/res/xml/development_settings.xml
index def0075ed7b..72855f0dc82 100644
--- a/res/xml/development_settings.xml
+++ b/res/xml/development_settings.xml
@@ -275,6 +275,11 @@
android:title="@string/wifi_scan_throttling"
android:summary="@string/wifi_scan_throttling_summary" />
+
+
+
+
+
+
+
+
+
+
+
diff --git a/res/xml/gestures.xml b/res/xml/gestures.xml
index c505fc95cba..0f407f43633 100644
--- a/res/xml/gestures.xml
+++ b/res/xml/gestures.xml
@@ -82,9 +82,8 @@
settings:controller="com.android.settings.gestures.PreventRingingParentPreferenceController" />
-
+ android:key="gesture_power_menu_summary"
+ android:title="@string/power_menu_setting_name"
+ android:fragment="com.android.settings.gestures.PowerMenuSettings"
+ settings:controller="com.android.settings.gestures.PowerMenuPreferenceController" />
diff --git a/res/xml/global_actions_panel_settings.xml b/res/xml/global_actions_panel_settings.xml
index 3b7bef3f57e..980c75681d9 100644
--- a/res/xml/global_actions_panel_settings.xml
+++ b/res/xml/global_actions_panel_settings.xml
@@ -18,7 +18,7 @@
+ android:title="@string/cards_passes_sentence">
diff --git a/res/xml/power_menu_settings.xml b/res/xml/power_menu_settings.xml
new file mode 100644
index 00000000000..453a7e6a1f8
--- /dev/null
+++ b/res/xml/power_menu_settings.xml
@@ -0,0 +1,34 @@
+
+
+
+
+
+
+
+
+
diff --git a/res/xml/zen_mode_settings.xml b/res/xml/zen_mode_settings.xml
index 9649207dbbb..6764e288d43 100644
--- a/res/xml/zen_mode_settings.xml
+++ b/res/xml/zen_mode_settings.xml
@@ -56,7 +56,6 @@
android:key="zen_mode_automation_settings"
android:title="@string/zen_category_schedule"
settings:allowDividerAbove="true"
- settings:allowDividerBelow="true"
android:fragment="com.android.settings.notification.zen.ZenModeAutomationSettings"/>
+ android:title="@string/zen_mode_alarms"/>
+ android:title="@string/zen_mode_reminders"/>
+ android:title="@string/zen_mode_events"/>
-
-
diff --git a/src/com/android/settings/Settings.java b/src/com/android/settings/Settings.java
index d25d7e9dd24..f5494faa8ee 100644
--- a/src/com/android/settings/Settings.java
+++ b/src/com/android/settings/Settings.java
@@ -218,6 +218,8 @@ public class Settings extends SettingsActivity {
public static class WifiCallingDisclaimerActivity extends SettingsActivity { /* empty */ }
public static class MobileNetworkListActivity extends SettingsActivity {}
public static class GlobalActionsPanelSettingsActivity extends SettingsActivity {}
+ public static class PowerMenuSettingsActivity extends SettingsActivity {}
+ public static class QuickControlsSettingsActivity extends SettingsActivity {}
/**
* Activity for BugReportHandlerPicker.
*/
diff --git a/src/com/android/settings/applications/specialaccess/interactacrossprofiles/InteractAcrossProfilesDetails.java b/src/com/android/settings/applications/specialaccess/interactacrossprofiles/InteractAcrossProfilesDetails.java
index af055f3392d..ad47c03a90b 100644
--- a/src/com/android/settings/applications/specialaccess/interactacrossprofiles/InteractAcrossProfilesDetails.java
+++ b/src/com/android/settings/applications/specialaccess/interactacrossprofiles/InteractAcrossProfilesDetails.java
@@ -17,11 +17,13 @@ package com.android.settings.applications.specialaccess.interactacrossprofiles;
import static android.content.pm.PackageManager.MATCH_DIRECT_BOOT_AWARE;
import static android.content.pm.PackageManager.MATCH_DIRECT_BOOT_UNAWARE;
+import static android.provider.Settings.ACTION_MANAGE_CROSS_PROFILE_ACCESS;
import android.Manifest;
import android.annotation.UserIdInt;
import android.app.ActionBar;
import android.app.AppOpsManager;
+import android.app.admin.DevicePolicyEventLogger;
import android.app.admin.DevicePolicyManager;
import android.app.settings.SettingsEnums;
import android.content.Context;
@@ -37,6 +39,7 @@ import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.os.UserHandle;
import android.os.UserManager;
+import android.stats.devicepolicy.DevicePolicyEnums;
import android.util.IconDrawableFactory;
import android.view.View;
import android.widget.ImageView;
@@ -60,6 +63,8 @@ public class InteractAcrossProfilesDetails extends AppInfoBase
"interact_across_profiles_settings_switch";
private static final String INTERACT_ACROSS_PROFILES_HEADER = "interact_across_profiles_header";
public static final String INSTALL_APP_BANNER_KEY = "install_app_banner";
+ public static final String EXTRA_SHOW_FRAGMENT_ARGS = ":settings:show_fragment_args";
+ public static final String INTENT_KEY = "intent";
private Context mContext;
private CrossProfileApps mCrossProfileApps;
@@ -108,6 +113,52 @@ public class InteractAcrossProfilesDetails extends AppInfoBase
}
addAppTitleAndIcons(mPersonalProfile, mWorkProfile);
styleActionBar();
+ logPageLaunchMetrics();
+ }
+
+ private void logPageLaunchMetrics() {
+ if (!mCrossProfileApps.canConfigureInteractAcrossProfiles(mPackageName)) {
+ logNonConfigurableAppMetrics();
+ }
+ Bundle bundle = getIntent().getBundleExtra(EXTRA_SHOW_FRAGMENT_ARGS);
+ if (bundle == null) {
+ logEvent(DevicePolicyEnums.CROSS_PROFILE_SETTINGS_PAGE_LAUNCHED_FROM_SETTINGS);
+ return;
+ }
+ Intent intent = (Intent) bundle.get(INTENT_KEY);
+ if (intent == null) {
+ logEvent(DevicePolicyEnums.CROSS_PROFILE_SETTINGS_PAGE_LAUNCHED_FROM_SETTINGS);
+ return;
+ }
+ if (ACTION_MANAGE_CROSS_PROFILE_ACCESS.equals(intent.getAction())) {
+ logEvent(DevicePolicyEnums.CROSS_PROFILE_SETTINGS_PAGE_LAUNCHED_FROM_APP);
+ }
+ }
+
+ private void logNonConfigurableAppMetrics() {
+ if (!isCrossProfilePackageWhitelisted(mPackageName)) {
+ logEvent(DevicePolicyEnums.CROSS_PROFILE_SETTINGS_PAGE_ADMIN_RESTRICTED);
+ return;
+ }
+ if (mInstallBanner == null) {
+ logEvent(DevicePolicyEnums.CROSS_PROFILE_SETTINGS_PAGE_MISSING_INSTALL_BANNER_INTENT);
+ }
+ if (!mInstalledInPersonal) {
+ logEvent(DevicePolicyEnums.CROSS_PROFILE_SETTINGS_PAGE_MISSING_PERSONAL_APP);
+ return;
+ }
+ if (!mInstalledInWork) {
+ logEvent(DevicePolicyEnums.CROSS_PROFILE_SETTINGS_PAGE_MISSING_WORK_APP);
+ }
+ }
+
+ private void logEvent(int eventId) {
+ DevicePolicyEventLogger.createEvent(eventId)
+ .setStrings(mPackageName)
+ .setInt(UserHandle.myUserId())
+ .setAdmin(RestrictedLockUtils.getProfileOrDeviceOwner(
+ mContext, mWorkProfile).component)
+ .write();
}
private void addAppTitleAndIcons(UserHandle personalProfile, UserHandle workProfile) {
@@ -187,6 +238,7 @@ public class InteractAcrossProfilesDetails extends AppInfoBase
private void handleSwitchPreferenceClick() {
if (isInteractAcrossProfilesEnabled()) {
+ logEvent(DevicePolicyEnums.CROSS_PROFILE_SETTINGS_PAGE_PERMISSION_REVOKED);
enableInteractAcrossProfiles(false);
refreshUi();
} else {
@@ -220,12 +272,15 @@ public class InteractAcrossProfilesDetails extends AppInfoBase
builder.setView(dialogView)
.setPositiveButton(R.string.allow, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
+ logEvent(DevicePolicyEnums.CROSS_PROFILE_SETTINGS_PAGE_USER_CONSENTED);
enableInteractAcrossProfiles(true);
refreshUi();
}
})
.setNegativeButton(R.string.deny, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
+ logEvent(
+ DevicePolicyEnums.CROSS_PROFILE_SETTINGS_PAGE_USER_DECLINED_CONSENT);
refreshUi();
}
})
@@ -277,13 +332,17 @@ public class InteractAcrossProfilesDetails extends AppInfoBase
private void handleInstallBannerClick() {
if (mInstallAppIntent == null) {
+ logEvent(
+ DevicePolicyEnums.CROSS_PROFILE_SETTINGS_PAGE_INSTALL_BANNER_NO_INTENT_CLICKED);
return;
}
if (!mInstalledInWork) {
+ logEvent(DevicePolicyEnums.CROSS_PROFILE_SETTINGS_PAGE_INSTALL_BANNER_CLICKED);
mContext.startActivityAsUser(mInstallAppIntent, mWorkProfile);
return;
}
if (!mInstalledInPersonal) {
+ logEvent(DevicePolicyEnums.CROSS_PROFILE_SETTINGS_PAGE_INSTALL_BANNER_CLICKED);
mContext.startActivityAsUser(mInstallAppIntent, mPersonalProfile);
}
}
@@ -333,8 +392,10 @@ public class InteractAcrossProfilesDetails extends AppInfoBase
mInstallBanner.setTitle(getString(
R.string.interact_across_profiles_install_personal_app_title,
mAppLabel));
- mInstallBanner.setSummary(
- R.string.interact_across_profiles_install_app_summary);
+ if (mInstallAppIntent != null) {
+ mInstallBanner.setSummary(
+ R.string.interact_across_profiles_install_app_summary);
+ }
mInstallBanner.setVisible(true);
return true;
}
@@ -342,8 +403,10 @@ public class InteractAcrossProfilesDetails extends AppInfoBase
mInstallBanner.setTitle(getString(
R.string.interact_across_profiles_install_work_app_title,
mAppLabel));
- mInstallBanner.setSummary(
- R.string.interact_across_profiles_install_app_summary);
+ if (mInstallAppIntent != null) {
+ mInstallBanner.setSummary(
+ R.string.interact_across_profiles_install_app_summary);
+ }
mInstallBanner.setVisible(true);
return true;
}
diff --git a/src/com/android/settings/core/gateway/SettingsGateway.java b/src/com/android/settings/core/gateway/SettingsGateway.java
index 8c49e580c06..fea32cf8512 100644
--- a/src/com/android/settings/core/gateway/SettingsGateway.java
+++ b/src/com/android/settings/core/gateway/SettingsGateway.java
@@ -88,12 +88,14 @@ import com.android.settings.fuelgauge.PowerUsageSummary;
import com.android.settings.fuelgauge.batterysaver.BatterySaverScheduleSettings;
import com.android.settings.fuelgauge.batterysaver.BatterySaverSettings;
import com.android.settings.gestures.AssistGestureSettings;
+import com.android.settings.gestures.DeviceControlsSettings;
import com.android.settings.gestures.DoubleTapPowerSettings;
import com.android.settings.gestures.DoubleTapScreenSettings;
import com.android.settings.gestures.DoubleTwistGestureSettings;
import com.android.settings.gestures.GestureNavigationSettingsFragment;
import com.android.settings.gestures.GlobalActionsPanelSettings;
import com.android.settings.gestures.PickupGestureSettings;
+import com.android.settings.gestures.PowerMenuSettings;
import com.android.settings.gestures.SwipeToNotificationSettings;
import com.android.settings.gestures.SystemNavigationGestureSettings;
import com.android.settings.inputmethod.AvailableVirtualKeyboardFragment;
@@ -294,7 +296,9 @@ public class SettingsGateway {
PreviouslyConnectedDeviceDashboardFragment.class.getName(),
BatterySaverScheduleSettings.class.getName(),
MobileNetworkListFragment.class.getName(),
+ PowerMenuSettings.class.getName(),
GlobalActionsPanelSettings.class.getName(),
+ DeviceControlsSettings.class.getName(),
DarkModeSettingsFragment.class.getName(),
BugReportHandlerPicker.class.getName(),
GestureNavigationSettingsFragment.class.getName(),
diff --git a/src/com/android/settings/datausage/DataUsageList.java b/src/com/android/settings/datausage/DataUsageList.java
index 8db32e9eb19..7f1a0d8252d 100644
--- a/src/com/android/settings/datausage/DataUsageList.java
+++ b/src/com/android/settings/datausage/DataUsageList.java
@@ -42,6 +42,8 @@ import android.telephony.SubscriptionManager;
import android.util.Log;
import android.util.SparseArray;
import android.view.View;
+import android.view.View.AccessibilityDelegate;
+import android.view.accessibility.AccessibilityEvent;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemSelectedListener;
import android.widget.ImageView;
@@ -180,6 +182,16 @@ public class DataUsageList extends DataUsageBaseFragment
mCycleSpinner.setSelection(position);
}
}, mCycleListener);
+ mCycleSpinner.setAccessibilityDelegate(new AccessibilityDelegate() {
+ @Override
+ public void sendAccessibilityEvent(View host, int eventType) {
+ if (eventType == AccessibilityEvent.TYPE_VIEW_SELECTED) {
+ // Ignore TYPE_VIEW_SELECTED or TalkBack will speak for it at onResume.
+ return;
+ }
+ super.sendAccessibilityEvent(host, eventType);
+ }
+ });
mLoadingViewController = new LoadingViewController(
getView().findViewById(R.id.loading_container), getListView());
diff --git a/src/com/android/settings/development/DevelopmentSettingsDashboardFragment.java b/src/com/android/settings/development/DevelopmentSettingsDashboardFragment.java
index 66b93e17b46..5bea006bffa 100644
--- a/src/com/android/settings/development/DevelopmentSettingsDashboardFragment.java
+++ b/src/com/android/settings/development/DevelopmentSettingsDashboardFragment.java
@@ -463,6 +463,7 @@ public class DevelopmentSettingsDashboardFragment extends RestrictedDashboardFra
controllers.add(new WifiDisplayCertificationPreferenceController(context));
controllers.add(new WifiVerboseLoggingPreferenceController(context));
controllers.add(new WifiScanThrottlingPreferenceController(context));
+ controllers.add(new WifiEnhancedMacRandomizationPreferenceController(context));
controllers.add(new MobileDataAlwaysOnPreferenceController(context));
controllers.add(new TetheringHardwareAccelPreferenceController(context));
controllers.add(new BluetoothDeviceNoNamePreferenceController(context));
diff --git a/src/com/android/settings/development/WifiEnhancedMacRandomizationPreferenceController.java b/src/com/android/settings/development/WifiEnhancedMacRandomizationPreferenceController.java
new file mode 100644
index 00000000000..af44f5b2020
--- /dev/null
+++ b/src/com/android/settings/development/WifiEnhancedMacRandomizationPreferenceController.java
@@ -0,0 +1,73 @@
+/*
+ * Copyright (C) 2020 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.settings.development;
+
+import android.content.Context;
+import android.provider.Settings;
+
+import androidx.preference.Preference;
+import androidx.preference.SwitchPreference;
+
+import com.android.settings.core.PreferenceControllerMixin;
+import com.android.settingslib.development.DeveloperOptionsPreferenceController;
+
+/**
+ * Developer option controller for enhanced MAC randomization.
+ */
+public class WifiEnhancedMacRandomizationPreferenceController
+ extends DeveloperOptionsPreferenceController
+ implements Preference.OnPreferenceChangeListener, PreferenceControllerMixin {
+ private static final String WIFI_ENHANCED_MAC_RANDOMIZATION_KEY =
+ "wifi_enhanced_mac_randomization";
+ private static final String ENHANCED_MAC_RANDOMIZATION_FEATURE_FLAG =
+ "enhanced_mac_randomization_force_enabled";
+
+ public WifiEnhancedMacRandomizationPreferenceController(Context context) {
+ super(context);
+ }
+
+ @Override
+ public String getPreferenceKey() {
+ return WIFI_ENHANCED_MAC_RANDOMIZATION_KEY;
+ }
+
+ @Override
+ public boolean onPreferenceChange(Preference preference, Object newValue) {
+ int isEnabledInt = ((Boolean) newValue) ? 1 : 0;
+ Settings.Global.putInt(mContext.getContentResolver(),
+ ENHANCED_MAC_RANDOMIZATION_FEATURE_FLAG, isEnabledInt);
+ return true;
+ }
+
+ @Override
+ public void updateState(Preference preference) {
+ boolean enabled = false;
+ if (Settings.Global.getInt(mContext.getContentResolver(),
+ ENHANCED_MAC_RANDOMIZATION_FEATURE_FLAG, 0) == 1) {
+ enabled = true;
+ }
+ ((SwitchPreference) mPreference).setChecked(enabled);
+ }
+
+ @Override
+ protected void onDeveloperOptionsSwitchDisabled() {
+ super.onDeveloperOptionsSwitchDisabled();
+ Settings.Global.putInt(mContext.getContentResolver(),
+ ENHANCED_MAC_RANDOMIZATION_FEATURE_FLAG, 0);
+ ((SwitchPreference) mPreference).setChecked(false);
+ }
+}
diff --git a/src/com/android/settings/gestures/DeviceControlsPreferenceController.java b/src/com/android/settings/gestures/DeviceControlsPreferenceController.java
new file mode 100644
index 00000000000..e588e86354d
--- /dev/null
+++ b/src/com/android/settings/gestures/DeviceControlsPreferenceController.java
@@ -0,0 +1,69 @@
+/*
+ * Copyright (C) 2020 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.settings.gestures;
+
+import android.content.Context;
+import android.provider.Settings;
+import android.text.TextUtils;
+
+import com.android.internal.annotations.VisibleForTesting;
+
+public class DeviceControlsPreferenceController extends GesturePreferenceController {
+ private static final String PREF_KEY_VIDEO = "device_controls_video";
+
+ @VisibleForTesting
+ protected static final String ENABLED_SETTING = Settings.Secure.CONTROLS_ENABLED;
+
+ @VisibleForTesting
+ protected static final String TOGGLE_KEY = "gesture_device_controls_switch";
+
+ public DeviceControlsPreferenceController(Context context, String key) {
+ super(context, key);
+ }
+
+ @Override
+ public int getAvailabilityStatus() {
+ return AVAILABLE;
+ }
+
+ @Override
+ public boolean setChecked(boolean isChecked) {
+ return Settings.Secure.putInt(mContext.getContentResolver(), ENABLED_SETTING,
+ isChecked ? 1 : 0);
+ }
+
+ @Override
+ protected String getVideoPrefKey() {
+ return PREF_KEY_VIDEO;
+ }
+
+ @Override
+ public boolean isSliceable() {
+ return TextUtils.equals(getPreferenceKey(), TOGGLE_KEY);
+ }
+
+ @Override
+ public boolean isPublicSlice() {
+ return true;
+ }
+
+ @Override
+ public boolean isChecked() {
+ int enabled = Settings.Secure.getInt(mContext.getContentResolver(), ENABLED_SETTING, 1);
+ return enabled == 1;
+ }
+}
diff --git a/src/com/android/settings/gestures/DeviceControlsSettings.java b/src/com/android/settings/gestures/DeviceControlsSettings.java
new file mode 100644
index 00000000000..df36717cb0b
--- /dev/null
+++ b/src/com/android/settings/gestures/DeviceControlsSettings.java
@@ -0,0 +1,48 @@
+/*
+ * Copyright (C) 2020 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.settings.gestures;
+
+import android.app.settings.SettingsEnums;
+
+import com.android.settings.R;
+import com.android.settings.dashboard.DashboardFragment;
+import com.android.settings.search.BaseSearchIndexProvider;
+import com.android.settingslib.search.SearchIndexable;
+
+@SearchIndexable
+public class DeviceControlsSettings extends DashboardFragment {
+
+ private static final String TAG = "QuickControlsSettings";
+
+ @Override
+ public int getMetricsCategory() {
+ return SettingsEnums.DEVICE_CONTROLS_SETTINGS;
+ }
+
+ @Override
+ protected String getLogTag() {
+ return TAG;
+ }
+
+ @Override
+ protected int getPreferenceScreenResId() {
+ return R.xml.device_controls_settings;
+ }
+
+ public static final BaseSearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
+ new BaseSearchIndexProvider(R.xml.device_controls_settings);
+}
diff --git a/src/com/android/settings/gestures/PowerMenuPreferenceController.java b/src/com/android/settings/gestures/PowerMenuPreferenceController.java
new file mode 100644
index 00000000000..e65d140dbdb
--- /dev/null
+++ b/src/com/android/settings/gestures/PowerMenuPreferenceController.java
@@ -0,0 +1,61 @@
+/*
+ * Copyright (C) 2020 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.settings.gestures;
+
+import android.content.Context;
+import android.provider.Settings;
+
+import com.android.settings.R;
+import com.android.settings.core.BasePreferenceController;
+
+public class PowerMenuPreferenceController extends BasePreferenceController {
+
+ private static final String KEY = "gesture_power_menu_summary";
+ private static final String CONTROLS_ENABLED_SETTING = Settings.Secure.CONTROLS_ENABLED;
+ private static final String CARDS_ENABLED_SETTING =
+ Settings.Secure.GLOBAL_ACTIONS_PANEL_ENABLED;
+ private static final String CARDS_AVAILABLE_SETTING =
+ Settings.Secure.GLOBAL_ACTIONS_PANEL_AVAILABLE;
+
+ public PowerMenuPreferenceController(Context context, String key) {
+ super(context, key);
+ }
+
+ @Override
+ public CharSequence getSummary() {
+ boolean controlsEnabled = Settings.Secure.getInt(mContext.getContentResolver(),
+ CONTROLS_ENABLED_SETTING, 1) == 1;
+ boolean cardsEnabled = Settings.Secure.getInt(mContext.getContentResolver(),
+ CARDS_ENABLED_SETTING, 0) == 1;
+ boolean cardsVisible = cardsEnabled && Settings.Secure.getInt(mContext.getContentResolver(),
+ CARDS_AVAILABLE_SETTING, 0) == 1;
+ if (controlsEnabled && cardsVisible) {
+ return mContext.getText(R.string.power_menu_cards_passes_device_controls);
+ } else if (controlsEnabled) {
+ return mContext.getText(R.string.power_menu_device_controls);
+ } else if (cardsVisible) {
+ return mContext.getText(R.string.power_menu_cards_passes);
+ } else {
+ return mContext.getText(R.string.power_menu_none);
+ }
+ }
+
+ @Override
+ public int getAvailabilityStatus() {
+ return AVAILABLE;
+ }
+}
diff --git a/src/com/android/settings/gestures/PowerMenuSettings.java b/src/com/android/settings/gestures/PowerMenuSettings.java
new file mode 100644
index 00000000000..3b4c5c31f74
--- /dev/null
+++ b/src/com/android/settings/gestures/PowerMenuSettings.java
@@ -0,0 +1,46 @@
+/*
+ * Copyright (C) 2020 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.settings.gestures;
+
+import android.app.settings.SettingsEnums;
+
+import com.android.settings.R;
+import com.android.settings.dashboard.DashboardFragment;
+import com.android.settings.search.BaseSearchIndexProvider;
+
+public class PowerMenuSettings extends DashboardFragment {
+
+ private static final String TAG = "PowerMenuSettings";
+
+ @Override
+ protected int getPreferenceScreenResId() {
+ return R.xml.power_menu_settings;
+ }
+
+ @Override
+ protected String getLogTag() {
+ return TAG;
+ }
+
+ @Override
+ public int getMetricsCategory() {
+ return SettingsEnums.POWER_MENU_SETTINGS;
+ }
+
+ public static final BaseSearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
+ new BaseSearchIndexProvider(R.xml.power_menu_settings);
+}
diff --git a/src/com/android/settings/network/telephony/EnabledNetworkModePreferenceController.java b/src/com/android/settings/network/telephony/EnabledNetworkModePreferenceController.java
index 948eecaa5c2..d2ff6e8e4ae 100644
--- a/src/com/android/settings/network/telephony/EnabledNetworkModePreferenceController.java
+++ b/src/com/android/settings/network/telephony/EnabledNetworkModePreferenceController.java
@@ -398,8 +398,13 @@ public class EnabledNetworkModePreferenceController extends
if (!mIsGlobalCdma) {
setSelectedEntry(
TelephonyManagerConstants.NETWORK_MODE_LTE_GSM_WCDMA);
- setSummary(
- mShow4gForLTE ? R.string.network_4G : R.string.network_lte);
+ if (is5gEntryDisplayed()) {
+ setSummary(mShow4gForLTE
+ ? R.string.network_4G_pure : R.string.network_lte_pure);
+ } else {
+ setSummary(mShow4gForLTE
+ ? R.string.network_4G : R.string.network_lte);
+ }
} else {
setSelectedEntry(
TelephonyManagerConstants.NETWORK_MODE_LTE_CDMA_EVDO_GSM_WCDMA);
@@ -542,6 +547,7 @@ public class EnabledNetworkModePreferenceController extends
mEntriesValue.add(value);
mIs5gEntryDisplayed = true;
} else {
+ mIs5gEntryDisplayed = false;
Log.d(LOG_TAG, "Hide 5G option. "
+ " supported5GRadioAccessFamily: " + mSupported5gRadioAccessFamily
+ " allowed5GNetworkType: " + mAllowed5gNetworkType
diff --git a/src/com/android/settings/notification/zen/ZenModeBackend.java b/src/com/android/settings/notification/zen/ZenModeBackend.java
index 9291d55a320..b9b27c400f7 100644
--- a/src/com/android/settings/notification/zen/ZenModeBackend.java
+++ b/src/com/android/settings/notification/zen/ZenModeBackend.java
@@ -322,7 +322,7 @@ public class ZenModeBackend {
return R.string.zen_mode_from_starred;
case ZenPolicy.PEOPLE_TYPE_NONE:
default:
- return R.string.zen_mode_from_none_calls;
+ return R.string.zen_mode_from_none;
}
}
@@ -492,8 +492,12 @@ public class ZenModeBackend {
}
String getContactsNumberSummary(Context context) {
+ final int numContacts = queryAllContactsData().getCount();
+ if (numContacts == 0) {
+ return context.getResources().getString(R.string.zen_mode_from_none);
+ }
return context.getResources().getString(R.string.zen_mode_contacts_senders_summary,
- queryAllContactsData().getCount());
+ numContacts);
}
private Cursor queryStarredContactsData() {
diff --git a/src/com/android/settings/notification/zen/ZenModeButtonPreferenceController.java b/src/com/android/settings/notification/zen/ZenModeButtonPreferenceController.java
index 8c1f3ec033c..e97cbba03f7 100644
--- a/src/com/android/settings/notification/zen/ZenModeButtonPreferenceController.java
+++ b/src/com/android/settings/notification/zen/ZenModeButtonPreferenceController.java
@@ -81,10 +81,10 @@ public class ZenModeButtonPreferenceController extends AbstractZenModePreference
});
}
- updateButtons(preference);
+ updatePreference(preference);
}
- private void updateButtons(Preference preference) {
+ private void updatePreference(Preference preference) {
switch (getZenMode()) {
case Settings.Global.ZEN_MODE_ALARMS:
case Settings.Global.ZEN_MODE_IMPORTANT_INTERRUPTIONS:
diff --git a/src/com/android/settings/notification/zen/ZenModeConversationsImagePreferenceController.java b/src/com/android/settings/notification/zen/ZenModeConversationsImagePreferenceController.java
index 2d1f15d07de..78c81341865 100644
--- a/src/com/android/settings/notification/zen/ZenModeConversationsImagePreferenceController.java
+++ b/src/com/android/settings/notification/zen/ZenModeConversationsImagePreferenceController.java
@@ -25,6 +25,7 @@ import android.content.pm.ParceledListSlice;
import android.graphics.drawable.Drawable;
import android.os.AsyncTask;
import android.service.notification.ConversationChannelWrapper;
+import android.view.View;
import android.view.ViewGroup;
import android.widget.FrameLayout;
import android.widget.ImageView;
@@ -60,7 +61,8 @@ public class ZenModeConversationsImagePreferenceController
mNotificationBackend = notificationBackend;
mIconSizePx =
mContext.getResources().getDimensionPixelSize(R.dimen.zen_conversations_icon_size);
- mIconOffsetPx = mIconSizePx * 3 / 4;
+ mIconOffsetPx = mContext.getResources()
+ .getDimensionPixelSize(R.dimen.zen_conversations_icon_offset);
}
@Override
@@ -97,6 +99,8 @@ public class ZenModeConversationsImagePreferenceController
R.string.zen_mode_from_important_conversations));
} else {
mViewGroup.setContentDescription(null);
+ mViewGroup.setVisibility(View.GONE);
+ return;
}
final int numDrawablesToShow = Math.min(MAX_CONVERSATIONS_SHOWN,
@@ -111,6 +115,8 @@ public class ZenModeConversationsImagePreferenceController
fl.setPadding((numDrawablesToShow - i - 1) * mIconOffsetPx, 0, 0, 0);
mViewGroup.addView(fl);
}
+
+ mViewGroup.setVisibility(numDrawablesToShow > 0 ? View.VISIBLE : View.GONE);
}
private void loadConversations() {
diff --git a/src/com/android/settings/notification/zen/ZenModePrioritySendersPreferenceController.java b/src/com/android/settings/notification/zen/ZenModePrioritySendersPreferenceController.java
index 226ce155af3..96ddec2f000 100644
--- a/src/com/android/settings/notification/zen/ZenModePrioritySendersPreferenceController.java
+++ b/src/com/android/settings/notification/zen/ZenModePrioritySendersPreferenceController.java
@@ -171,6 +171,10 @@ public class ZenModePrioritySendersPreferenceController
private RadioButtonPreferenceWithExtraWidget makeRadioPreference(String key, int titleId) {
RadioButtonPreferenceWithExtraWidget pref =
new RadioButtonPreferenceWithExtraWidget(mPreferenceCategory.getContext());
+ pref.setKey(key);
+ pref.setTitle(titleId);
+ pref.setOnClickListener(mRadioButtonClickListener);
+
View.OnClickListener widgetClickListener = getWidgetClickListener(key);
if (widgetClickListener != null) {
pref.setExtraWidgetOnClickListener(widgetClickListener);
@@ -179,9 +183,6 @@ public class ZenModePrioritySendersPreferenceController
pref.setExtraWidgetVisibility(EXTRA_WIDGET_VISIBILITY_GONE);
}
- pref.setKey(key);
- pref.setTitle(titleId);
- pref.setOnClickListener(mRadioButtonClickListener);
mPreferenceCategory.addPreference(pref);
mRadioButtonPreferences.add(pref);
return pref;
diff --git a/src/com/android/settings/notification/zen/ZenModeSettings.java b/src/com/android/settings/notification/zen/ZenModeSettings.java
index d67c3535e78..7f9a4312c06 100644
--- a/src/com/android/settings/notification/zen/ZenModeSettings.java
+++ b/src/com/android/settings/notification/zen/ZenModeSettings.java
@@ -156,7 +156,7 @@ public class ZenModeSettings extends ZenModeSettingsBase {
|| PRIORITY_CATEGORY_REPEAT_CALLERS == category, true);
int numCategories = enabledCategories.size();
if (numCategories == 0) {
- return mContext.getString(R.string.zen_mode_from_none_calls);
+ return mContext.getString(R.string.zen_mode_from_none);
} else if (numCategories == 1) {
return mContext.getString(R.string.zen_mode_calls_summary_one,
enabledCategories.get(0));
@@ -172,7 +172,7 @@ public class ZenModeSettings extends ZenModeSettingsBase {
category -> PRIORITY_CATEGORY_MESSAGES == category, false);
int numCategories = enabledCategories.size();
if (numCategories == 0) {
- return mContext.getString(R.string.zen_mode_from_none_messages);
+ return mContext.getString(R.string.zen_mode_from_none);
} else {
return enabledCategories.get(0);
}
diff --git a/src/com/android/settings/notification/zen/ZenModeSoundVibrationSettings.java b/src/com/android/settings/notification/zen/ZenModeSoundVibrationSettings.java
index c07ee773c85..61e84fcb2c7 100644
--- a/src/com/android/settings/notification/zen/ZenModeSoundVibrationSettings.java
+++ b/src/com/android/settings/notification/zen/ZenModeSoundVibrationSettings.java
@@ -49,8 +49,6 @@ public class ZenModeSoundVibrationSettings extends ZenModeSettingsBase implement
controllers.add(new ZenModeSystemPreferenceController(context, lifecycle));
controllers.add(new ZenModeRemindersPreferenceController(context, lifecycle));
controllers.add(new ZenModeEventsPreferenceController(context, lifecycle));
- controllers.add(new ZenModeBehaviorFooterPreferenceController(context, lifecycle,
- R.string.zen_sound_footer));
return controllers;
}
diff --git a/src/com/android/settings/vpn2/ConfigDialog.java b/src/com/android/settings/vpn2/ConfigDialog.java
index a0aac19794d..4e6cc893b8e 100644
--- a/src/com/android/settings/vpn2/ConfigDialog.java
+++ b/src/com/android/settings/vpn2/ConfigDialog.java
@@ -173,6 +173,7 @@ class ConfigDialog extends AlertDialog implements TextWatcher,
mProxySettings.setOnItemSelectedListener(this);
mProxyHost.addTextChangedListener(this);
mProxyPort.addTextChangedListener(this);
+ mIpsecIdentifier.addTextChangedListener(this);
mIpsecSecret.addTextChangedListener(this);
mIpsecUserCert.setOnItemSelectedListener(this);
mShowOptions.setOnClickListener(this);
diff --git a/src/com/android/settings/wifi/WifiConfigController.java b/src/com/android/settings/wifi/WifiConfigController.java
index 54026a5671c..66b9a230ba2 100644
--- a/src/com/android/settings/wifi/WifiConfigController.java
+++ b/src/com/android/settings/wifi/WifiConfigController.java
@@ -48,6 +48,7 @@ import android.view.KeyEvent;
import android.view.View;
import android.view.View.AccessibilityDelegate;
import android.view.ViewGroup;
+import android.view.accessibility.AccessibilityEvent;
import android.view.accessibility.AccessibilityNodeInfo;
import android.view.accessibility.AccessibilityNodeInfo.AccessibilityAction;
import android.view.inputmethod.EditorInfo;
@@ -1020,6 +1021,8 @@ public class WifiConfigController implements TextWatcher,
mEapUserCertSpinner.setOnItemSelectedListener(this);
mEapIdentityView = (TextView) mView.findViewById(R.id.identity);
mEapAnonymousView = (TextView) mView.findViewById(R.id.anonymous);
+
+ setAccessibilityDelegateForSecuritySpinners();
}
if (refreshEapMethods) {
@@ -1148,6 +1151,26 @@ public class WifiConfigController implements TextWatcher,
}
}
+ private void setAccessibilityDelegateForSecuritySpinners() {
+ final AccessibilityDelegate selectedEventBlocker = new AccessibilityDelegate() {
+ @Override
+ public void sendAccessibilityEvent(View host, int eventType) {
+ if (eventType == AccessibilityEvent.TYPE_VIEW_SELECTED) {
+ // Ignore TYPE_VIEW_SELECTED or there will be multiple Spinner selected
+ // information for WifiController#showSecurityFields.
+ return;
+ }
+ super.sendAccessibilityEvent(host, eventType);
+ }
+ };
+
+ mEapMethodSpinner.setAccessibilityDelegate(selectedEventBlocker);
+ mPhase2Spinner.setAccessibilityDelegate(selectedEventBlocker);
+ mEapCaCertSpinner.setAccessibilityDelegate(selectedEventBlocker);
+ mEapOcspSpinner.setAccessibilityDelegate(selectedEventBlocker);
+ mEapUserCertSpinner.setAccessibilityDelegate(selectedEventBlocker);
+ }
+
/**
* EAP-PWD valid fields include
* identity
diff --git a/src/com/android/settings/wifi/WifiConfigController2.java b/src/com/android/settings/wifi/WifiConfigController2.java
index 4df0dfdc84e..ce0516d6f4d 100644
--- a/src/com/android/settings/wifi/WifiConfigController2.java
+++ b/src/com/android/settings/wifi/WifiConfigController2.java
@@ -46,6 +46,7 @@ import android.view.KeyEvent;
import android.view.View;
import android.view.View.AccessibilityDelegate;
import android.view.ViewGroup;
+import android.view.accessibility.AccessibilityEvent;
import android.view.accessibility.AccessibilityNodeInfo;
import android.view.accessibility.AccessibilityNodeInfo.AccessibilityAction;
import android.view.inputmethod.EditorInfo;
@@ -1014,6 +1015,8 @@ public class WifiConfigController2 implements TextWatcher,
mEapUserCertSpinner.setOnItemSelectedListener(this);
mEapIdentityView = (TextView) mView.findViewById(R.id.identity);
mEapAnonymousView = (TextView) mView.findViewById(R.id.anonymous);
+
+ setAccessibilityDelegateForSecuritySpinners();
}
if (refreshEapMethods) {
@@ -1144,6 +1147,26 @@ public class WifiConfigController2 implements TextWatcher,
}
}
+ private void setAccessibilityDelegateForSecuritySpinners() {
+ final AccessibilityDelegate selectedEventBlocker = new AccessibilityDelegate() {
+ @Override
+ public void sendAccessibilityEvent(View host, int eventType) {
+ if (eventType == AccessibilityEvent.TYPE_VIEW_SELECTED) {
+ // Ignore TYPE_VIEW_SELECTED or there will be multiple Spinner selected
+ // information for WifiController2#showSecurityFields.
+ return;
+ }
+ super.sendAccessibilityEvent(host, eventType);
+ }
+ };
+
+ mEapMethodSpinner.setAccessibilityDelegate(selectedEventBlocker);
+ mPhase2Spinner.setAccessibilityDelegate(selectedEventBlocker);
+ mEapCaCertSpinner.setAccessibilityDelegate(selectedEventBlocker);
+ mEapOcspSpinner.setAccessibilityDelegate(selectedEventBlocker);
+ mEapUserCertSpinner.setAccessibilityDelegate(selectedEventBlocker);
+ }
+
/**
* EAP-PWD valid fields include
* identity
diff --git a/tests/robotests/src/com/android/settings/development/WifiEnhancedMacRandomizationPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/development/WifiEnhancedMacRandomizationPreferenceControllerTest.java
new file mode 100644
index 00000000000..4a45ce70387
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/development/WifiEnhancedMacRandomizationPreferenceControllerTest.java
@@ -0,0 +1,105 @@
+/*
+ * Copyright (C) 2020 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.settings.development;
+
+import static com.google.common.truth.Truth.assertThat;
+
+import static org.mockito.Mockito.when;
+
+import android.content.Context;
+import android.provider.Settings;
+
+import androidx.preference.PreferenceScreen;
+import androidx.preference.SwitchPreference;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+import org.robolectric.RobolectricTestRunner;
+import org.robolectric.RuntimeEnvironment;
+
+@RunWith(RobolectricTestRunner.class)
+public class WifiEnhancedMacRandomizationPreferenceControllerTest {
+ private static final String ENHANCED_MAC_RANDOMIZATION_FEATURE_FLAG =
+ "enhanced_mac_randomization_force_enabled";
+ @Mock
+ private SwitchPreference mPreference;
+ @Mock
+ private PreferenceScreen mPreferenceScreen;
+ private Context mContext;
+ private WifiEnhancedMacRandomizationPreferenceController mController;
+
+ @Before
+ public void setup() {
+ MockitoAnnotations.initMocks(this);
+ mContext = RuntimeEnvironment.application;
+ mController = new WifiEnhancedMacRandomizationPreferenceController(mContext);
+ when(mPreferenceScreen.findPreference(mController.getPreferenceKey()))
+ .thenReturn(mPreference);
+ mController.displayPreference(mPreferenceScreen);
+ }
+
+ @Test
+ public void onPreferenceChanged_enabled_shouldTurnOnEnhancedRandomization() {
+ mController.onPreferenceChange(mPreference, true /* new value */);
+
+ int mode = Settings.Global.getInt(mContext.getContentResolver(),
+ ENHANCED_MAC_RANDOMIZATION_FEATURE_FLAG, -1);
+ assertThat(mode).isEqualTo(1);
+ }
+
+ @Test
+ public void onPreferenceChanged_disabled_shouldTurnOffEnhancedRandomization() {
+ mController.onPreferenceChange(mPreference, false /* new value */);
+
+ int mode = Settings.Global.getInt(mContext.getContentResolver(),
+ ENHANCED_MAC_RANDOMIZATION_FEATURE_FLAG, -1);
+ assertThat(mode).isEqualTo(0);
+ }
+
+ @Test
+ public void updateState_preferenceShouldBeChecked() {
+ Settings.Global.putInt(mContext.getContentResolver(),
+ ENHANCED_MAC_RANDOMIZATION_FEATURE_FLAG, 1);
+ mController.updateState(mPreference);
+
+ assertThat(mPreference.isChecked()).isTrue();
+ }
+
+ @Test
+ public void updateState_preferenceShouldNotBeChecked() {
+ Settings.Global.putInt(mContext.getContentResolver(),
+ ENHANCED_MAC_RANDOMIZATION_FEATURE_FLAG, 0);
+ mController.updateState(mPreference);
+
+ assertThat(mPreference.isChecked()).isFalse();
+ }
+
+ @Test
+ public void onDeveloperOptionsDisabled_shouldDisablePreference() {
+ mController.onDeveloperOptionsSwitchDisabled();
+
+ int mode = Settings.Global.getInt(mContext.getContentResolver(),
+ ENHANCED_MAC_RANDOMIZATION_FEATURE_FLAG, -1);
+
+ assertThat(mode).isEqualTo(0);
+ assertThat(mPreference.isChecked()).isFalse();
+ assertThat(mPreference.isEnabled()).isFalse();
+ }
+}
diff --git a/tests/robotests/src/com/android/settings/gestures/DeviceControlsPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/gestures/DeviceControlsPreferenceControllerTest.java
new file mode 100644
index 00000000000..c31971a991b
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/gestures/DeviceControlsPreferenceControllerTest.java
@@ -0,0 +1,87 @@
+/*
+ * Copyright (C) 2020 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.settings.gestures;
+
+import static com.google.common.truth.Truth.assertThat;
+
+import android.content.Context;
+import android.provider.Settings;
+
+import com.android.settings.core.BasePreferenceController;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.robolectric.RobolectricTestRunner;
+import org.robolectric.RuntimeEnvironment;
+
+@RunWith(RobolectricTestRunner.class)
+public class DeviceControlsPreferenceControllerTest {
+
+ private Context mContext;
+ private DeviceControlsPreferenceController mController;
+
+ private static final String KEY_GESTURE_PANEL = "gesture_device_controls";
+ private static final String ENABLED_SETTING =
+ DeviceControlsPreferenceController.ENABLED_SETTING;
+
+ @Before
+ public void setUp() {
+ mContext = RuntimeEnvironment.application;
+ mController = new DeviceControlsPreferenceController(mContext, KEY_GESTURE_PANEL);
+ }
+
+ @Test
+ public void testIsChecked_panelEnabled() {
+ Settings.Secure.putInt(
+ mContext.getContentResolver(), ENABLED_SETTING, 1);
+ assertThat(mController.isChecked()).isTrue();
+ }
+
+ @Test
+ public void testIsChecked_panelDisabled() {
+ Settings.Secure.putInt(
+ mContext.getContentResolver(), ENABLED_SETTING, 0);
+ assertThat(mController.isChecked()).isFalse();
+ }
+
+ @Test
+ public void getAvailabilityStatus_panelAvailable() {
+ assertThat(mController.getAvailabilityStatus())
+ .isEqualTo(BasePreferenceController.AVAILABLE);
+ }
+
+ @Test
+ public void isSliceable_correctKey() {
+ final DeviceControlsPreferenceController controller =
+ new DeviceControlsPreferenceController(mContext,
+ DeviceControlsPreferenceController.TOGGLE_KEY);
+ assertThat(controller.isSliceable()).isTrue();
+ }
+
+ @Test
+ public void isSliceable_incorrectKey() {
+ final DeviceControlsPreferenceController controller =
+ new DeviceControlsPreferenceController(mContext, "bad_key");
+ assertThat(controller.isSliceable()).isFalse();
+ }
+
+ @Test
+ public void isPublicSlice_returnTrue() {
+ assertThat(mController.isPublicSlice()).isTrue();
+ }
+}
diff --git a/tests/robotests/src/com/android/settings/gestures/DeviceControlsSettingsTest.java b/tests/robotests/src/com/android/settings/gestures/DeviceControlsSettingsTest.java
new file mode 100644
index 00000000000..2ec0f1d1602
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/gestures/DeviceControlsSettingsTest.java
@@ -0,0 +1,50 @@
+/*
+ * Copyright (C) 2020 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.settings.gestures;
+
+import static com.google.common.truth.Truth.assertThat;
+
+import android.provider.SearchIndexableResource;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.robolectric.RobolectricTestRunner;
+import org.robolectric.RuntimeEnvironment;
+
+import java.util.List;
+
+@RunWith(RobolectricTestRunner.class)
+public class DeviceControlsSettingsTest {
+
+ private DeviceControlsSettings mSettings;
+
+ @Before
+ public void setUp() {
+ mSettings = new DeviceControlsSettings();
+ }
+
+ @Test
+ public void testSearchIndexProvider_shouldIndexResource() {
+ final List indexRes =
+ DeviceControlsSettings.SEARCH_INDEX_DATA_PROVIDER.getXmlResourcesToIndex(
+ RuntimeEnvironment.application, true /* enabled */);
+
+ assertThat(indexRes).isNotNull();
+ assertThat(indexRes.get(0).xmlResId).isEqualTo(mSettings.getPreferenceScreenResId());
+ }
+}
diff --git a/tests/robotests/src/com/android/settings/gestures/PowerMenuPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/gestures/PowerMenuPreferenceControllerTest.java
new file mode 100644
index 00000000000..e14293eb82a
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/gestures/PowerMenuPreferenceControllerTest.java
@@ -0,0 +1,136 @@
+/*
+ * Copyright (C) 2020 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.settings.gestures;
+
+import static com.google.common.truth.Truth.assertThat;
+
+import android.content.Context;
+import android.provider.Settings;
+
+import com.android.settings.R;
+import com.android.settings.core.BasePreferenceController;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.MockitoAnnotations;
+import org.robolectric.RobolectricTestRunner;
+import org.robolectric.RuntimeEnvironment;
+
+@RunWith(RobolectricTestRunner.class)
+public class PowerMenuPreferenceControllerTest {
+ private Context mContext;
+ private PowerMenuPreferenceController mController;
+
+ private static final String KEY_GESTURE_POWER_MENU = "gesture_power_menu";
+ private static final String CONTROLS_ENABLED = Settings.Secure.CONTROLS_ENABLED;
+ private static final String CARDS_ENABLED = Settings.Secure.GLOBAL_ACTIONS_PANEL_ENABLED;
+ private static final String CARDS_AVAILABLE = Settings.Secure.GLOBAL_ACTIONS_PANEL_AVAILABLE;
+
+ @Before
+ public void setUp() {
+ MockitoAnnotations.initMocks(this);
+ mContext = RuntimeEnvironment.application;
+ mController = new PowerMenuPreferenceController(mContext, KEY_GESTURE_POWER_MENU);
+ }
+
+ @Test
+ public void getAvailabilityStatus_available() {
+ assertThat(mController.getAvailabilityStatus()).isEqualTo(
+ BasePreferenceController.AVAILABLE);
+ }
+
+ @Test
+ public void getSummary_allDisabled() {
+ Settings.Secure.putInt(mContext.getContentResolver(), CONTROLS_ENABLED, 0);
+ Settings.Secure.putInt(mContext.getContentResolver(), CARDS_ENABLED, 0);
+ Settings.Secure.putInt(mContext.getContentResolver(), CARDS_AVAILABLE, 0);
+
+ assertThat(mController.getSummary())
+ .isEqualTo(mContext.getText(R.string.power_menu_none));
+ }
+
+ @Test
+ public void getSummary_onlyControlsEnabled() {
+ Settings.Secure.putInt(mContext.getContentResolver(), CONTROLS_ENABLED, 1);
+ Settings.Secure.putInt(mContext.getContentResolver(), CARDS_ENABLED, 0);
+ Settings.Secure.putInt(mContext.getContentResolver(), CARDS_AVAILABLE, 0);
+
+ assertThat(mController.getSummary())
+ .isEqualTo(mContext.getText(R.string.power_menu_device_controls));
+ }
+
+ @Test
+ public void getSummary_onlyCardsEnabled_notAvailable() {
+ Settings.Secure.putInt(mContext.getContentResolver(), CONTROLS_ENABLED, 0);
+ Settings.Secure.putInt(mContext.getContentResolver(), CARDS_ENABLED, 1);
+ Settings.Secure.putInt(mContext.getContentResolver(), CARDS_AVAILABLE, 0);
+
+ assertThat(mController.getSummary())
+ .isEqualTo(mContext.getText(R.string.power_menu_none));
+ }
+
+ @Test
+ public void getSummary_cardsAvailable_notEnabled() {
+ Settings.Secure.putInt(mContext.getContentResolver(), CONTROLS_ENABLED, 0);
+ Settings.Secure.putInt(mContext.getContentResolver(), CARDS_ENABLED, 0);
+ Settings.Secure.putInt(mContext.getContentResolver(), CARDS_AVAILABLE, 1);
+
+ assertThat(mController.getSummary())
+ .isEqualTo(mContext.getText(R.string.power_menu_none));
+ }
+
+ @Test
+ public void getSummary_allEnabled_cardsNotAvailable() {
+ Settings.Secure.putInt(mContext.getContentResolver(), CONTROLS_ENABLED, 1);
+ Settings.Secure.putInt(mContext.getContentResolver(), CARDS_ENABLED, 1);
+ Settings.Secure.putInt(mContext.getContentResolver(), CARDS_AVAILABLE, 0);
+
+ assertThat(mController.getSummary())
+ .isEqualTo(mContext.getText(R.string.power_menu_device_controls));
+ }
+
+ @Test
+ public void getSummary_controlsEnabled_cardsDisabledAvailable() {
+ Settings.Secure.putInt(mContext.getContentResolver(), CONTROLS_ENABLED, 1);
+ Settings.Secure.putInt(mContext.getContentResolver(), CARDS_ENABLED, 0);
+ Settings.Secure.putInt(mContext.getContentResolver(), CARDS_AVAILABLE, 1);
+
+ assertThat(mController.getSummary())
+ .isEqualTo(mContext.getText(R.string.power_menu_device_controls));
+ }
+
+ @Test
+ public void getSummary_controlsDisabled() {
+ Settings.Secure.putInt(mContext.getContentResolver(), CONTROLS_ENABLED, 0);
+ Settings.Secure.putInt(mContext.getContentResolver(), CARDS_ENABLED, 1);
+ Settings.Secure.putInt(mContext.getContentResolver(), CARDS_AVAILABLE, 1);
+
+ assertThat(mController.getSummary())
+ .isEqualTo(mContext.getText(R.string.power_menu_cards_passes));
+ }
+
+ @Test
+ public void getSummary_allEnabled() {
+ Settings.Secure.putInt(mContext.getContentResolver(), CONTROLS_ENABLED, 1);
+ Settings.Secure.putInt(mContext.getContentResolver(), CARDS_ENABLED, 1);
+ Settings.Secure.putInt(mContext.getContentResolver(), CARDS_AVAILABLE, 1);
+
+ assertThat(mController.getSummary())
+ .isEqualTo(mContext.getText(R.string.power_menu_cards_passes_device_controls));
+ }
+}
diff --git a/tests/robotests/src/com/android/settings/gestures/PowerMenuSettingsTest.java b/tests/robotests/src/com/android/settings/gestures/PowerMenuSettingsTest.java
new file mode 100644
index 00000000000..4448ee38e12
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/gestures/PowerMenuSettingsTest.java
@@ -0,0 +1,50 @@
+/*
+ * Copyright (C) 2020 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.settings.gestures;
+
+import static com.google.common.truth.Truth.assertThat;
+
+import android.provider.SearchIndexableResource;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.robolectric.RobolectricTestRunner;
+import org.robolectric.RuntimeEnvironment;
+
+import java.util.List;
+
+@RunWith(RobolectricTestRunner.class)
+public class PowerMenuSettingsTest {
+
+ private PowerMenuSettings mSettings;
+
+ @Before
+ public void setUp() {
+ mSettings = new PowerMenuSettings();
+ }
+
+ @Test
+ public void testSearchIndexProvider_shouldIndexResource() {
+ final List indexRes =
+ PowerMenuSettings.SEARCH_INDEX_DATA_PROVIDER.getXmlResourcesToIndex(
+ RuntimeEnvironment.application, true /* enabled */);
+
+ assertThat(indexRes).isNotNull();
+ assertThat(indexRes.get(0).xmlResId).isEqualTo(mSettings.getPreferenceScreenResId());
+ }
+}