Merge "Rewire BiometricEnrollActivity to setup pages"
diff --git a/res/layout/homepage_slice_tile.xml b/res/layout/homepage_slice_tile.xml
index 807c26b..e95129e 100644
--- a/res/layout/homepage_slice_tile.xml
+++ b/res/layout/homepage_slice_tile.xml
@@ -31,6 +31,7 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
+ android:animateLayoutChanges="true"
style="@style/SliceViewStyle"/>
<!--dismissal view-->
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 93ba354..48bee2d 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -2266,6 +2266,10 @@
<!-- Wifi saved access points. Used as a label under the shortcut icon that goes to Wifi saved access points. [CHAR LIMIT=20] -->
<string name="wifi_saved_access_points_label">Saved networks</string>
+ <!-- Tab title for showing subscribed WiFi access points. [CHAR LIMIT=20] -->
+ <string name="wifi_subscribed_access_points_tab">Subscriptions</string>
+ <!-- Tab title for showing saved WiFi access points. -->
+ <string name="wifi_saved_access_points_tab">@string/wifi_access_points</string>
<!-- Wifi Advanced settings. Used as a label under the shortcut icon that goes to Wifi advanced settings. [CHAR LIMIT=20] -->
<string name="wifi_advanced_settings_label">IP settings</string>
<!-- Error message for users that aren't allowed to see or modify WiFi advanced settings [CHAR LIMIT=NONE] -->
@@ -5583,6 +5587,12 @@
<!-- Battery saver: Title for battery saver schedule screen [CHAR_LIMIT=40] -->
<string name="battery_saver_schedule_settings_title">Set a schedule</string>
+ <!-- Battery Saver: Title for sticky battery saver preference [CHAR_LIMIT=60] -->
+ <string name="battery_saver_sticky_title">Keep battery saver on</string>
+
+ <!-- Battery Saver: Description for sticky battery saver preference [CHAR_LIMIT=NONE] -->
+ <string name="battery_saver_sticky_description">Battery saver will stay on even after device is fully charged</string>
+
<!-- Battery saver: Label for seekbar to change battery saver threshold [CHAR_LIMIT=40] -->
<string name="battery_saver_seekbar_title"><xliff:g id="percent">%1$s</xliff:g></string>
@@ -7147,6 +7157,9 @@
<string name="keywords_ring_vibration">haptics, vibrate, phone, call, sensitivity, ring</string>
<!-- List of synonyms for notification vibration setting (changes whether your phone vibrates when it shows a notification), used to match in settings search [CHAR LIMIT=NONE] -->
<string name="keywords_notification_vibration">haptics, vibrate, sensitivity</string>
+ <!-- Battery Saver: Search terms for sticky battery saver preference [CHAR_LIMIT=NONE] -->
+ <string name="keywords_battery_saver_sticky">battery saver, sticky, persist, power saver, battery</string>
+
<!-- NFC Wi-Fi pairing/setup strings-->
@@ -9795,8 +9808,11 @@
<!-- Title for settings suggestion for double twist for camera [CHAR LIMIT=60] -->
<string name="double_twist_for_camera_suggestion_title">Take selfies faster</string>
- <!-- Title text for swipe up to switch apps [CHAR LIMIT=60] -->
- <string name="swipe_up_to_switch_apps_title">Swipe up on Home button</string>
+ <!-- Title text for system navigation [CHAR LIMIT=60] [DO NOT TRANSLATE] -->
+ <string name="system_navigation_title" translatable="false">System navigation</string>
+
+ <!-- Title text for swipe up to switch apps [CHAR LIMIT=60] [DO NOT TRANSLATE] -->
+ <string name="swipe_up_to_switch_apps_title" translatable="false">2-button navigation</string>
<!-- Summary text for swipe up to switch apps [CHAR LIMIT=250] -->
<string name="swipe_up_to_switch_apps_summary">To switch apps, swipe up on the Home button. Swipe up again to see all apps. Works from any screen. You’ll no longer have an Overview button on the bottom right of your screen.</string>
<!-- Title for settings suggestion for swipe up to switch apps [CHAR LIMIT=60] -->
@@ -9804,6 +9820,16 @@
<!-- Summary for settings suggestion for swipe up to switch apps [CHAR LIMIT=60] -->
<string name="swipe_up_to_switch_apps_suggestion_summary">Turn on the new gesture to switch apps</string>
+ <!-- Title text for edge to edge navigation [CHAR LIMIT=60] [DO NOT TRANSLATE] -->
+ <string name="edge_to_edge_navigation_title" translatable="false">Fully gestural navigation</string>
+ <!-- Summary text for edge to edge navigation [CHAR LIMIT=None] [DO NOT TRANSLATE] -->
+ <string name="edge_to_edge_navigation_summary" translatable="false">To go Home, swipe up from the bottom of the screen. To go Back, swipe from either the left or right edge of the screen. To switch apps, start swiping up from the bottom of the screen and hold before releasing.</string>
+
+ <!-- Title text for 3-button navigation [CHAR LIMIT=60] [DO NOT TRANSLATE] -->
+ <string name="legacy_navigation_title" translatable="false">3-button navigation</string>
+ <!-- Summary text for 3-button navigation [CHAR LIMIT=250] [DO NOT TRANSLATE] -->
+ <string name="legacy_navigation_summary" translatable="false">Classic Android navigation mode where going Home, switching apps, and going Back are accessible via buttons.</string>
+
<!-- Preference and settings suggestion title text for ambient display double tap (phone) [CHAR LIMIT=60]-->
<string name="ambient_display_title" product="default">Double-tap to check phone</string>
<!-- Preference and settings suggestion title text for ambient display double tap (tablet) [CHAR LIMIT=60]-->
@@ -10713,4 +10739,12 @@
<!-- Message for forget passpoint dialog [CHAR LIMIT=none] -->
<string name="forget_passpoint_dialog_message">Your subscription with this provider may be cancelled. Recurring subscriptions will not be cancelled. For more information, check with your provider.</string>
+
+ <!-- Keywords for Content Capture feature [CHAR_LIMIT=32] -->
+ <string name="keywords_content_capture">content capture</string>
+ <!-- Title of the 'Content Capture' feature toggle in the Settings -> Privacy screen [CHAR LIMIT=none]-->
+ <string name="content_capture">Content Capture</string>
+ <!-- Description of the 'Content Capture' feature toggle in the Settings -> Privacy screen [CHAR LIMIT=NONE]-->
+ <string name="content_capture_summary">Allow Android to save information seen on your screen or heard in video or audio content. Android makes helpful suggestions based on your device activity.</string>
+
</resources>
diff --git a/res/xml/battery_saver_settings.xml b/res/xml/battery_saver_settings.xml
index 89f7eab..ae9d14d 100644
--- a/res/xml/battery_saver_settings.xml
+++ b/res/xml/battery_saver_settings.xml
@@ -26,6 +26,13 @@
android:title="@string/battery_saver_schedule_settings_title"
settings:controller="com.android.settings.fuelgauge.batterysaver.BatterySaverSchedulePreferenceController"/>
+ <SwitchPreference
+ android:key="battery_saver_sticky"
+ android:title="@string/battery_saver_sticky_title"
+ android:summary="@string/battery_saver_sticky_description"
+ settings:keywords="@string/keywords_battery_saver_sticky"
+ settings:controller="com.android.settings.fuelgauge.batterysaver.BatterySaverStickyPreferenceController"/>
+
<com.android.settings.widget.TwoStateButtonPreference
android:key="battery_saver"
android:title="@string/battery_saver"
diff --git a/res/xml/gestures.xml b/res/xml/gestures.xml
index b1250ec..f705630 100644
--- a/res/xml/gestures.xml
+++ b/res/xml/gestures.xml
@@ -52,10 +52,10 @@
settings:controller="com.android.settings.gestures.DoubleTwistPreferenceController" />
<Preference
- android:key="gesture_swipe_up_input_summary"
- android:title="@string/swipe_up_to_switch_apps_title"
- android:fragment="com.android.settings.gestures.SwipeUpGestureSettings"
- settings:controller="com.android.settings.gestures.SwipeUpPreferenceController" />
+ android:key="gesture_system_navigation_input_summary"
+ android:title="@string/system_navigation_title"
+ android:fragment="com.android.settings.gestures.SystemNavigationGestureSettings"
+ settings:controller="com.android.settings.gestures.SystemNavigationLegacyPreferenceController" />
<Preference
android:key="gesture_tap_screen_input_summary"
diff --git a/res/xml/language_and_input.xml b/res/xml/language_and_input.xml
index b04bdf8..e3690a9 100644
--- a/res/xml/language_and_input.xml
+++ b/res/xml/language_and_input.xml
@@ -94,7 +94,8 @@
<com.android.settings.widget.WorkOnlyCategory
android:key="language_and_input_for_work_category"
- android:title="@string/language_and_input_for_work_category_title">
+ android:title="@string/language_and_input_for_work_category_title"
+ settings:searchable="false">
<Preference
android:key="virtual_keyboards_for_work_pref"
diff --git a/res/xml/privacy_dashboard_settings.xml b/res/xml/privacy_dashboard_settings.xml
index 48034a84..d2d9e35 100644
--- a/res/xml/privacy_dashboard_settings.xml
+++ b/res/xml/privacy_dashboard_settings.xml
@@ -62,6 +62,13 @@
android:summary="@string/summary_placeholder"
settings:searchable="false"/>
+ <!-- Content Capture -->
+ <SwitchPreference
+ android:key="content_capture"
+ android:title="@string/content_capture"
+ android:summary="@string/content_capture_summary"
+ settings:controller="com.android.settings.privacy.EnableContentCapturePreferenceController"/>
+
<!-- Privacy Service -->
<PreferenceCategory
android:key="privacy_services"/>
diff --git a/res/xml/swipe_up_gesture_settings.xml b/res/xml/swipe_up_gesture_settings.xml
deleted file mode 100644
index cc1db16..0000000
--- a/res/xml/swipe_up_gesture_settings.xml
+++ /dev/null
@@ -1,37 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
- Copyright (C) 2018 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.
- -->
-
-<PreferenceScreen
- xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:app="http://schemas.android.com/apk/res-auto"
- android:key="gesture_swipe_up_screen"
- android:title="@string/swipe_up_to_switch_apps_title">
-
- <com.android.settings.widget.VideoPreference
- android:key="gesture_swipe_up_video"
- app:animation="@raw/gesture_swipe_up"
- app:preview="@drawable/gesture_swipe_up" />
-
- <SwitchPreference
- android:key="gesture_swipe_up"
- android:title="@string/swipe_up_to_switch_apps_title"
- android:summary="@string/swipe_up_to_switch_apps_summary"
- app:keywords="@string/keywords_gesture"
- app:controller="com.android.settings.gestures.SwipeUpPreferenceController"
- app:allowDividerAbove="true" />
-
-</PreferenceScreen>
\ No newline at end of file
diff --git a/res/xml/system_navigation_gesture_settings.xml b/res/xml/system_navigation_gesture_settings.xml
new file mode 100644
index 0000000..97aacb8
--- /dev/null
+++ b/res/xml/system_navigation_gesture_settings.xml
@@ -0,0 +1,51 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ Copyright (C) 2018 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.
+ -->
+
+<PreferenceScreen
+ xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:app="http://schemas.android.com/apk/res-auto"
+ android:key="gesture_system_navigation_screen"
+ android:title="@string/system_navigation_title">
+
+ <com.android.settings.widget.VideoPreference
+ android:key="gesture_swipe_up_video"
+ app:animation="@raw/gesture_swipe_up"
+ app:preview="@drawable/gesture_swipe_up" />
+
+ <com.android.settings.widget.RadioButtonPreference
+ android:key="gesture_edge_to_edge"
+ android:title="@string/edge_to_edge_navigation_title"
+ android:summary="@string/edge_to_edge_navigation_summary"
+ app:keywords="@string/keywords_gesture"
+ app:controller="com.android.settings.gestures.SystemNavigationEdgeToEdgePreferenceController"
+ app:allowDividerAbove="true" />
+
+ <com.android.settings.widget.RadioButtonPreference
+ android:key="gesture_swipe_up"
+ android:title="@string/swipe_up_to_switch_apps_title"
+ android:summary="@string/swipe_up_to_switch_apps_summary"
+ app:keywords="@string/keywords_gesture"
+ app:controller="com.android.settings.gestures.SystemNavigationSwipeUpPreferenceController" />
+
+ <com.android.settings.widget.RadioButtonPreference
+ android:key="gesture_legacy"
+ android:title="@string/legacy_navigation_title"
+ android:summary="@string/legacy_navigation_summary"
+ app:keywords="@string/keywords_gesture"
+ app:controller="com.android.settings.gestures.SystemNavigationLegacyPreferenceController" />
+
+</PreferenceScreen>
\ No newline at end of file
diff --git a/res/xml/wifi_display_saved_access_points.xml b/res/xml/wifi_display_saved_access_points.xml
index 98b4dec..b3a8d55 100644
--- a/res/xml/wifi_display_saved_access_points.xml
+++ b/res/xml/wifi_display_saved_access_points.xml
@@ -21,8 +21,13 @@
android:title="@string/wifi_saved_access_points_label">
<PreferenceCategory
+ android:key="subscribed_access_points_category"
+ android:title="@string/wifi_subscribed_access_points_tab"
+ settings:controller="com.android.settings.wifi.savedaccesspoints.SubscribedAccessPointsPreferenceController"/>
+
+ <PreferenceCategory
android:key="saved_access_points_category"
- android:layout="@layout/preference_category_no_label"
+ android:title="@string/wifi_saved_access_points_tab"
settings:controller="com.android.settings.wifi.savedaccesspoints.SavedAccessPointsPreferenceController"/>
</PreferenceScreen>
diff --git a/src/com/android/settings/core/gateway/SettingsGateway.java b/src/com/android/settings/core/gateway/SettingsGateway.java
index 7abd98d..147d0be 100644
--- a/src/com/android/settings/core/gateway/SettingsGateway.java
+++ b/src/com/android/settings/core/gateway/SettingsGateway.java
@@ -82,7 +82,7 @@
import com.android.settings.gestures.DoubleTwistGestureSettings;
import com.android.settings.gestures.PickupGestureSettings;
import com.android.settings.gestures.SwipeToNotificationSettings;
-import com.android.settings.gestures.SwipeUpGestureSettings;
+import com.android.settings.gestures.SystemNavigationGestureSettings;
import com.android.settings.inputmethod.AvailableVirtualKeyboardFragment;
import com.android.settings.inputmethod.KeyboardLayoutPickerFragment;
import com.android.settings.inputmethod.PhysicalKeyboardFragment;
@@ -201,7 +201,7 @@
DoubleTapScreenSettings.class.getName(),
PickupGestureSettings.class.getName(),
DoubleTwistGestureSettings.class.getName(),
- SwipeUpGestureSettings.class.getName(),
+ SystemNavigationGestureSettings.class.getName(),
CryptKeeperSettings.class.getName(),
DataUsageSummary.class.getName(),
DreamSettings.class.getName(),
diff --git a/src/com/android/settings/fuelgauge/batterysaver/BatterySaverStickyPreferenceController.java b/src/com/android/settings/fuelgauge/batterysaver/BatterySaverStickyPreferenceController.java
new file mode 100644
index 0000000..b14fec9
--- /dev/null
+++ b/src/com/android/settings/fuelgauge/batterysaver/BatterySaverStickyPreferenceController.java
@@ -0,0 +1,41 @@
+package com.android.settings.fuelgauge.batterysaver;
+
+import android.content.Context;
+import android.provider.Settings;
+import androidx.preference.Preference;
+import androidx.preference.SwitchPreference;
+import com.android.settings.core.BasePreferenceController;
+import com.android.settings.core.PreferenceControllerMixin;
+
+public class BatterySaverStickyPreferenceController extends BasePreferenceController implements
+ PreferenceControllerMixin, Preference.OnPreferenceChangeListener {
+
+ public static final String LOW_POWER_STICKY_AUTO_DISABLE_ENABLED =
+ "low_power_sticky_auto_disable_enabled";
+
+ public BatterySaverStickyPreferenceController(Context context, String preferenceKey) {
+ super(context, preferenceKey);
+ }
+
+ @Override
+ public void updateState(Preference preference) {
+ int setting = Settings.System.getInt(mContext.getContentResolver(),
+ LOW_POWER_STICKY_AUTO_DISABLE_ENABLED, 1);
+
+ ((SwitchPreference) preference).setChecked(setting == 0);
+ }
+
+ @Override
+ public boolean onPreferenceChange(Preference preference, Object newValue) {
+ boolean keepActive = (Boolean) newValue;
+ Settings.System.putInt(mContext.getContentResolver(),
+ LOW_POWER_STICKY_AUTO_DISABLE_ENABLED,
+ keepActive ? 0 : 1);
+ return true;
+ }
+
+ @Override
+ public int getAvailabilityStatus() {
+ return AVAILABLE;
+ }
+}
diff --git a/src/com/android/settings/fuelgauge/batterytip/AnomalyInfo.java b/src/com/android/settings/fuelgauge/batterytip/AnomalyInfo.java
index 063cfec..fc15706 100644
--- a/src/com/android/settings/fuelgauge/batterytip/AnomalyInfo.java
+++ b/src/com/android/settings/fuelgauge/batterytip/AnomalyInfo.java
@@ -20,7 +20,7 @@
import android.util.Log;
/**
- * Model class to parse and store anomaly info from westworld
+ * Model class to parse and store anomaly info from statsd.
*/
public class AnomalyInfo {
private static final String TAG = "AnomalyInfo";
@@ -38,4 +38,4 @@
autoRestriction = parser.getBoolean(KEY_AUTO_RESTRICTION, false);
}
-}
\ No newline at end of file
+}
diff --git a/src/com/android/settings/gestures/SwipeUpPreferenceController.java b/src/com/android/settings/gestures/SwipeUpPreferenceController.java
deleted file mode 100644
index 5e882c4..0000000
--- a/src/com/android/settings/gestures/SwipeUpPreferenceController.java
+++ /dev/null
@@ -1,97 +0,0 @@
-/*
- * Copyright (C) 2018 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.ComponentName;
-import android.content.Context;
-import android.content.Intent;
-import android.content.pm.PackageManager;
-import android.os.UserManager;
-import android.provider.Settings;
-import android.text.TextUtils;
-
-import com.android.internal.R;
-
-public class SwipeUpPreferenceController extends GesturePreferenceController {
-
- private final int ON = 1;
- private final int OFF = 0;
-
- private static final String ACTION_QUICKSTEP = "android.intent.action.QUICKSTEP_SERVICE";
- private static final String PREF_KEY_VIDEO = "gesture_swipe_up_video";
- private final UserManager mUserManager;
-
- public SwipeUpPreferenceController(Context context, String key) {
- super(context, key);
- mUserManager = (UserManager) context.getSystemService(Context.USER_SERVICE);
- }
-
- static boolean isGestureAvailable(Context context) {
- if (!context.getResources().getBoolean(R.bool.config_swipe_up_gesture_setting_available)) {
- return false;
- }
-
- final ComponentName recentsComponentName = ComponentName.unflattenFromString(
- context.getString(R.string.config_recentsComponentName));
- if (recentsComponentName == null) {
- return false;
- }
- final Intent quickStepIntent = new Intent(ACTION_QUICKSTEP)
- .setPackage(recentsComponentName.getPackageName());
- if (context.getPackageManager().resolveService(quickStepIntent,
- PackageManager.MATCH_SYSTEM_ONLY) == null) {
- return false;
- }
- return true;
- }
-
- @Override
- public int getAvailabilityStatus() {
- return isGestureAvailable(mContext) ? AVAILABLE : UNSUPPORTED_ON_DEVICE;
- }
-
- @Override
- public boolean isSliceable() {
- return TextUtils.equals(getPreferenceKey(), "gesture_swipe_up");
- }
-
- @Override
- protected String getVideoPrefKey() {
- return PREF_KEY_VIDEO;
- }
-
- @Override
- public boolean setChecked(boolean isChecked) {
- setSwipeUpPreference(mContext, mUserManager, isChecked ? ON : OFF);
- return true;
- }
-
- public static void setSwipeUpPreference(Context context, UserManager userManager,
- int enabled) {
- Settings.Secure.putInt(context.getContentResolver(),
- Settings.Secure.SWIPE_UP_TO_SWITCH_APPS_ENABLED, enabled);
- }
-
- @Override
- public boolean isChecked() {
- final int defaultValue = mContext.getResources()
- .getBoolean(R.bool.config_swipe_up_gesture_default) ? ON : OFF;
- final int swipeUpEnabled = Settings.Secure.getInt(mContext.getContentResolver(),
- Settings.Secure.SWIPE_UP_TO_SWITCH_APPS_ENABLED, defaultValue);
- return swipeUpEnabled != OFF;
- }
-}
diff --git a/src/com/android/settings/gestures/SystemNavigationEdgeToEdgePreferenceController.java b/src/com/android/settings/gestures/SystemNavigationEdgeToEdgePreferenceController.java
new file mode 100644
index 0000000..129cf90
--- /dev/null
+++ b/src/com/android/settings/gestures/SystemNavigationEdgeToEdgePreferenceController.java
@@ -0,0 +1,48 @@
+/*
+ * Copyright (C) 2019 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.text.TextUtils;
+
+import com.android.settings.widget.RadioButtonPreference;
+
+public class SystemNavigationEdgeToEdgePreferenceController extends
+ SystemNavigationPreferenceController {
+ static final String PREF_KEY_EDGE_TO_EDGE = "gesture_edge_to_edge";
+
+ public SystemNavigationEdgeToEdgePreferenceController(Context context, String key) {
+ super(context, key);
+ }
+
+ @Override
+ public boolean isSliceable() {
+ return TextUtils.equals(PREF_KEY_EDGE_TO_EDGE, getPreferenceKey());
+ }
+
+ @Override
+ public void onRadioButtonClicked(RadioButtonPreference preference) {
+ setSwipeUpEnabled(mContext, true);
+ setEdgeToEdgeGestureEnabled(mContext, true);
+ selectRadioButtonInGroup(PREF_KEY_EDGE_TO_EDGE, mPreferenceScreen);
+ }
+
+ @Override
+ public boolean isChecked() {
+ return isEdgeToEdgeEnabled(mContext);
+ }
+}
diff --git a/src/com/android/settings/gestures/SwipeUpGestureSettings.java b/src/com/android/settings/gestures/SystemNavigationGestureSettings.java
similarity index 85%
rename from src/com/android/settings/gestures/SwipeUpGestureSettings.java
rename to src/com/android/settings/gestures/SystemNavigationGestureSettings.java
index a125643..ea5454b 100644
--- a/src/com/android/settings/gestures/SwipeUpGestureSettings.java
+++ b/src/com/android/settings/gestures/SystemNavigationGestureSettings.java
@@ -32,12 +32,12 @@
import java.util.List;
@SearchIndexable
-public class SwipeUpGestureSettings extends DashboardFragment {
+public class SystemNavigationGestureSettings extends DashboardFragment {
- private static final String TAG = "SwipeUpGesture";
+ private static final String TAG = "SystemNavigationGesture";
public static final String PREF_KEY_SUGGESTION_COMPLETE =
- "pref_swipe_up_suggestion_complete";
+ "pref_system_navigation_suggestion_complete";
@Override
public void onAttach(Context context) {
@@ -60,7 +60,7 @@
@Override
protected int getPreferenceScreenResId() {
- return R.xml.swipe_up_gesture_settings;
+ return R.xml.system_navigation_gesture_settings;
}
public static final SearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
@@ -69,13 +69,13 @@
public List<SearchIndexableResource> getXmlResourcesToIndex(
Context context, boolean enabled) {
final SearchIndexableResource sir = new SearchIndexableResource(context);
- sir.xmlResId = R.xml.swipe_up_gesture_settings;
+ sir.xmlResId = R.xml.system_navigation_gesture_settings;
return Arrays.asList(sir);
}
@Override
protected boolean isPageSearchEnabled(Context context) {
- return SwipeUpPreferenceController.isGestureAvailable(context);
+ return SystemNavigationPreferenceController.isGestureAvailable(context);
}
};
}
diff --git a/src/com/android/settings/gestures/SystemNavigationLegacyPreferenceController.java b/src/com/android/settings/gestures/SystemNavigationLegacyPreferenceController.java
new file mode 100644
index 0000000..f9c95a8
--- /dev/null
+++ b/src/com/android/settings/gestures/SystemNavigationLegacyPreferenceController.java
@@ -0,0 +1,48 @@
+/*
+ * Copyright (C) 2019 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.text.TextUtils;
+
+import com.android.settings.widget.RadioButtonPreference;
+
+public class SystemNavigationLegacyPreferenceController extends
+ SystemNavigationPreferenceController {
+ static final String PREF_KEY_LEGACY = "gesture_legacy";
+
+ public SystemNavigationLegacyPreferenceController(Context context, String key) {
+ super(context, key);
+ }
+
+ @Override
+ public boolean isSliceable() {
+ return TextUtils.equals(PREF_KEY_LEGACY, getPreferenceKey());
+ }
+
+ @Override
+ public void onRadioButtonClicked(RadioButtonPreference preference) {
+ setEdgeToEdgeGestureEnabled(mContext, false);
+ setSwipeUpEnabled(mContext, false);
+ selectRadioButtonInGroup(PREF_KEY_LEGACY, mPreferenceScreen);
+ }
+
+ @Override
+ public boolean isChecked() {
+ return !isEdgeToEdgeEnabled(mContext) && !isSwipeUpEnabled(mContext);
+ }
+}
diff --git a/src/com/android/settings/gestures/SystemNavigationPreferenceController.java b/src/com/android/settings/gestures/SystemNavigationPreferenceController.java
new file mode 100644
index 0000000..a11754e
--- /dev/null
+++ b/src/com/android/settings/gestures/SystemNavigationPreferenceController.java
@@ -0,0 +1,207 @@
+/*
+ * Copyright (C) 2019 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 android.os.UserHandle.USER_SYSTEM;
+
+import android.content.ComponentName;
+import android.content.Context;
+import android.content.Intent;
+import android.content.om.IOverlayManager;
+import android.content.pm.PackageManager;
+import android.os.RemoteException;
+import android.os.ServiceManager;
+import android.provider.Settings;
+import android.text.TextUtils;
+import android.view.View;
+
+import androidx.preference.Preference;
+import androidx.preference.PreferenceScreen;
+
+import com.android.settings.R;
+import com.android.settings.widget.RadioButtonPreference;
+
+public abstract class SystemNavigationPreferenceController extends GesturePreferenceController
+ implements RadioButtonPreference.OnClickListener {
+
+ private static final int OFF = 0;
+ private static final int ON = 1;
+
+ private static final String HIDE_BACK_BUTTON = "quickstepcontroller_hideback";
+ private static final String HIDE_HOME_BUTTON = "quickstepcontroller_hidehome";
+ private static final String HIDE_NAVBAR_DIVIDER = "hide_navigationbar_divider";
+ private static final String SHOW_HANDLE = "quickstepcontroller_showhandle";
+ private static final String ENABLE_CLICK_THROUGH = "quickstepcontroller_clickthrough";
+ private static final String ENABLE_LAUNCHER_SWIPE_TO_HOME = "SWIPE_HOME";
+ private static final String ENABLE_COLOR_ADAPT_FOR_HANDLE = "navbar_color_adapt_enable";
+ private static final String ENABLE_ASSISTANT_GESTURE = "ENABLE_ASSISTANT_GESTURE";
+ private static final String PROTOTYPE_ENABLED = "prototype_enabled";
+
+ private static final int EDGE_SENSITIVITY_WIDTH = 32;
+ private static final String EDGE_SENSITIVITY_KEY = "quickstepcontroller_edge_width_sensitivity";
+
+ private static final String GESTURES_MATCH_MAP_OFF = "000000";
+ private static final String GESTURES_MATCH_MAP_ON = "071133";
+ private static final String GESTURES_MATCH_MAP_KEY = "quickstepcontroller_gesture_match_map";
+
+ private static final String OVERLAY_NAVBAR_TYPE_INSET =
+ "com.android.internal.experiment.navbar.type.inset";
+ private static final String OVERLAY_NAVBAR_TYPE_FLOATING =
+ "com.android.internal.experiment.navbar.type.floating";
+
+ private static final String ACTION_QUICKSTEP = "android.intent.action.QUICKSTEP_SERVICE";
+ private static final String PREF_KEY_VIDEO = "gesture_swipe_up_video";
+
+ private static final String[] RADIO_BUTTONS_IN_GROUP = {
+ SystemNavigationLegacyPreferenceController.PREF_KEY_LEGACY,
+ SystemNavigationSwipeUpPreferenceController.PREF_KEY_SWIPE_UP,
+ SystemNavigationEdgeToEdgePreferenceController.PREF_KEY_EDGE_TO_EDGE,
+ };
+
+ protected PreferenceScreen mPreferenceScreen;
+
+ public SystemNavigationPreferenceController(Context context, String key) {
+ super(context, key);
+ }
+
+ @Override
+ public int getAvailabilityStatus() {
+ return isGestureAvailable(mContext) ? AVAILABLE : UNSUPPORTED_ON_DEVICE;
+ }
+
+ @Override
+ public void displayPreference(PreferenceScreen screen) {
+ super.displayPreference(screen);
+ mPreferenceScreen = screen;
+
+ Preference preference = screen.findPreference(getPreferenceKey());
+ if (preference != null && preference instanceof RadioButtonPreference) {
+ RadioButtonPreference radioPreference = (RadioButtonPreference) preference;
+ radioPreference.setOnClickListener(this);
+ radioPreference.setAppendixVisibility(View.GONE);
+ }
+ }
+
+ @Override
+ public boolean setChecked(boolean isChecked) {
+ if (!isChecked || mPreferenceScreen == null) {
+ return false;
+ }
+ Preference preference = mPreferenceScreen.findPreference(getPreferenceKey());
+ if (preference != null && preference instanceof RadioButtonPreference) {
+ onRadioButtonClicked((RadioButtonPreference) preference);
+ }
+ return true;
+ }
+
+ @Override
+ public CharSequence getSummary() {
+ if (isEdgeToEdgeEnabled(mContext)) {
+ return mContext.getText(R.string.edge_to_edge_navigation_title);
+ } else if (isSwipeUpEnabled(mContext)) {
+ return mContext.getText(R.string.swipe_up_to_switch_apps_title);
+ } else {
+ return mContext.getText(R.string.legacy_navigation_title);
+ }
+ }
+
+ @Override
+ protected String getVideoPrefKey() {
+ return PREF_KEY_VIDEO;
+ }
+
+ static boolean isGestureAvailable(Context context) {
+ if (!context.getResources().getBoolean(
+ com.android.internal.R.bool.config_swipe_up_gesture_setting_available)) {
+ return false;
+ }
+
+ final ComponentName recentsComponentName = ComponentName.unflattenFromString(
+ context.getString(com.android.internal.R.string.config_recentsComponentName));
+ if (recentsComponentName == null) {
+ return false;
+ }
+ final Intent quickStepIntent = new Intent(ACTION_QUICKSTEP)
+ .setPackage(recentsComponentName.getPackageName());
+ if (context.getPackageManager().resolveService(quickStepIntent,
+ PackageManager.MATCH_SYSTEM_ONLY) == null) {
+ return false;
+ }
+ return true;
+ }
+
+ static void selectRadioButtonInGroup(String preferenceKey, PreferenceScreen screen) {
+ if (screen == null) {
+ return;
+ }
+ for (String key : RADIO_BUTTONS_IN_GROUP) {
+ ((RadioButtonPreference) screen.findPreference(key)).setChecked(
+ TextUtils.equals(key, preferenceKey));
+ }
+ }
+
+ static void setEdgeToEdgeGestureEnabled(Context context, boolean enable) {
+ // TODO(b/127366543): replace all of this with a single switch
+ setBooleanGlobalSetting(context, HIDE_BACK_BUTTON, enable);
+ setBooleanGlobalSetting(context, HIDE_HOME_BUTTON, enable);
+ setBooleanGlobalSetting(context, HIDE_NAVBAR_DIVIDER, enable);
+ setBooleanGlobalSetting(context, SHOW_HANDLE, enable);
+ setBooleanGlobalSetting(context, ENABLE_CLICK_THROUGH, enable);
+ setBooleanGlobalSetting(context, ENABLE_LAUNCHER_SWIPE_TO_HOME, enable);
+ setBooleanGlobalSetting(context, ENABLE_COLOR_ADAPT_FOR_HANDLE, enable);
+ setBooleanGlobalSetting(context, ENABLE_ASSISTANT_GESTURE, enable);
+ setBooleanGlobalSetting(context, PROTOTYPE_ENABLED, enable);
+ Settings.Global.putInt(context.getContentResolver(), EDGE_SENSITIVITY_KEY,
+ EDGE_SENSITIVITY_WIDTH);
+ Settings.Global.putString(context.getContentResolver(), GESTURES_MATCH_MAP_KEY,
+ enable ? GESTURES_MATCH_MAP_ON : GESTURES_MATCH_MAP_OFF);
+
+ IOverlayManager overlayManager = IOverlayManager.Stub
+ .asInterface(ServiceManager.getService(Context.OVERLAY_SERVICE));
+ if (overlayManager != null) {
+ try {
+ overlayManager.setEnabled(OVERLAY_NAVBAR_TYPE_FLOATING, false, USER_SYSTEM);
+ overlayManager.setEnabled(OVERLAY_NAVBAR_TYPE_INSET, enable, USER_SYSTEM);
+ } catch (RemoteException e) {
+ throw e.rethrowFromSystemServer();
+ }
+ }
+ }
+
+ static void setBooleanGlobalSetting(Context context, String name, boolean flag) {
+ Settings.Global.putInt(context.getContentResolver(), name, flag ? ON : OFF);
+ }
+
+ static void setSwipeUpEnabled(Context context, boolean enabled) {
+ Settings.Secure.putInt(context.getContentResolver(),
+ Settings.Secure.SWIPE_UP_TO_SWITCH_APPS_ENABLED, enabled ? ON : OFF);
+ }
+
+ static boolean isSwipeUpEnabled(Context context) {
+ if (isEdgeToEdgeEnabled(context)) {
+ return false;
+ }
+ final int defaultSwipeUpValue = context.getResources()
+ .getBoolean(com.android.internal.R.bool.config_swipe_up_gesture_default) ? ON : OFF;
+ return Settings.Secure.getInt(context.getContentResolver(),
+ Settings.Secure.SWIPE_UP_TO_SWITCH_APPS_ENABLED, defaultSwipeUpValue) == ON;
+ }
+
+ static boolean isEdgeToEdgeEnabled(Context context) {
+ return Settings.Global.getInt(context.getContentResolver(), PROTOTYPE_ENABLED, OFF) == ON;
+ }
+}
diff --git a/src/com/android/settings/gestures/SystemNavigationSwipeUpPreferenceController.java b/src/com/android/settings/gestures/SystemNavigationSwipeUpPreferenceController.java
new file mode 100644
index 0000000..25fafdb
--- /dev/null
+++ b/src/com/android/settings/gestures/SystemNavigationSwipeUpPreferenceController.java
@@ -0,0 +1,48 @@
+/*
+ * Copyright (C) 2019 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.text.TextUtils;
+
+import com.android.settings.widget.RadioButtonPreference;
+
+public class SystemNavigationSwipeUpPreferenceController extends
+ SystemNavigationPreferenceController {
+ static final String PREF_KEY_SWIPE_UP = "gesture_swipe_up";
+
+ public SystemNavigationSwipeUpPreferenceController(Context context, String key) {
+ super(context, key);
+ }
+
+ @Override
+ public boolean isSliceable() {
+ return TextUtils.equals(PREF_KEY_SWIPE_UP, getPreferenceKey());
+ }
+
+ @Override
+ public void onRadioButtonClicked(RadioButtonPreference preference) {
+ setEdgeToEdgeGestureEnabled(mContext, false);
+ setSwipeUpEnabled(mContext, true);
+ selectRadioButtonInGroup(PREF_KEY_SWIPE_UP, mPreferenceScreen);
+ }
+
+ @Override
+ public boolean isChecked() {
+ return isSwipeUpEnabled(mContext);
+ }
+}
diff --git a/src/com/android/settings/homepage/contextualcards/ContextualCardLoader.java b/src/com/android/settings/homepage/contextualcards/ContextualCardLoader.java
index ea6ac43..13564b5 100644
--- a/src/com/android/settings/homepage/contextualcards/ContextualCardLoader.java
+++ b/src/com/android/settings/homepage/contextualcards/ContextualCardLoader.java
@@ -26,7 +26,6 @@
import android.net.Uri;
import android.os.Handler;
import android.os.Looper;
-import android.text.format.DateUtils;
import android.util.Log;
import androidx.annotation.NonNull;
@@ -50,7 +49,6 @@
@VisibleForTesting
static final int DEFAULT_CARD_COUNT = 4;
static final int CARD_CONTENT_LOADER_ID = 1;
- static final long CARD_CONTENT_LOADER_TIMEOUT_MS = DateUtils.SECOND_IN_MILLIS;
private static final String TAG = "ContextualCardLoader";
private static final long ELIGIBILITY_CHECKER_TIMEOUT_MS = 250;
diff --git a/src/com/android/settings/homepage/contextualcards/ContextualCardManager.java b/src/com/android/settings/homepage/contextualcards/ContextualCardManager.java
index 3b8aacd..c829015 100644
--- a/src/com/android/settings/homepage/contextualcards/ContextualCardManager.java
+++ b/src/com/android/settings/homepage/contextualcards/ContextualCardManager.java
@@ -24,6 +24,8 @@
import android.content.Context;
import android.os.Bundle;
+import android.provider.Settings;
+import android.text.format.DateUtils;
import android.util.ArrayMap;
import android.util.Log;
import android.widget.BaseAdapter;
@@ -62,8 +64,12 @@
public class ContextualCardManager implements ContextualCardLoader.CardContentLoaderListener,
ContextualCardUpdateListener, LifecycleObserver, OnSaveInstanceState {
- private static final String KEY_CONTEXTUAL_CARDS = "key_contextual_cards";
+ @VisibleForTesting
+ static final long CARD_CONTENT_LOADER_TIMEOUT_MS = DateUtils.SECOND_IN_MILLIS;
+ @VisibleForTesting
+ static final String KEY_GLOBAL_CARD_LOADER_TIMEOUT = "global_card_loader_timeout_key";
+ private static final String KEY_CONTEXTUAL_CARDS = "key_contextual_cards";
private static final String TAG = "ContextualCardManager";
//The list for Settings Custom Card
@@ -201,7 +207,8 @@
}
//only log homepage display upon a fresh launch
- if (loadTime <= ContextualCardLoader.CARD_CONTENT_LOADER_TIMEOUT_MS) {
+ final long timeoutLimit = getCardLoaderTimeout(mContext);
+ if (loadTime <= timeoutLimit) {
onContextualCardUpdated(cards.stream()
.collect(groupingBy(ContextualCard::getCardType)));
}
@@ -239,6 +246,14 @@
return getCardsWithSuggestionViewType(result);
}
+ @VisibleForTesting
+ long getCardLoaderTimeout(Context context) {
+ // Return the timeout limit if Settings.Global has the KEY_GLOBAL_CARD_LOADER_TIMEOUT key,
+ // else return default timeout.
+ return Settings.Global.getLong(mContext.getContentResolver(),
+ KEY_GLOBAL_CARD_LOADER_TIMEOUT, CARD_CONTENT_LOADER_TIMEOUT_MS);
+ }
+
private List<ContextualCard> getCardsWithSuggestionViewType(List<ContextualCard> cards) {
// Shows as half cards if 2 suggestion type of cards are next to each other.
// Shows as full card if 1 suggestion type of card lives alone.
diff --git a/src/com/android/settings/homepage/contextualcards/slices/BluetoothDevicesSlice.java b/src/com/android/settings/homepage/contextualcards/slices/BluetoothDevicesSlice.java
index 95412a8..3320be0 100644
--- a/src/com/android/settings/homepage/contextualcards/slices/BluetoothDevicesSlice.java
+++ b/src/com/android/settings/homepage/contextualcards/slices/BluetoothDevicesSlice.java
@@ -179,14 +179,9 @@
final Collection<CachedBluetoothDevice> cachedDevices =
bluetoothManager.getCachedDeviceManager().getCachedDevicesCopy();
- /**
- * TODO(b/114807655): Contextual Home Page - Connected Device
- * It's under discussion for including available media devices and currently connected
- * devices from Bluetooth. Will update the devices list or remove TODO later.
- */
- // Get available media device list and sort them.
+ // Get all connected devices and sort them.
return cachedDevices.stream()
- .filter(device -> device.isConnected() && device.isConnectedA2dpDevice())
+ .filter(device -> device.getDevice().isConnected())
.sorted(COMPARATOR).collect(Collectors.toList());
}
@@ -217,7 +212,7 @@
return Utils.createIconWithDrawable(pair.first);
} else {
return IconCompat.createWithResource(mContext,
- com.android.internal.R.drawable.ic_settings_bluetooth);
+ com.android.internal.R.drawable.ic_settings_bluetooth);
}
}
@@ -226,18 +221,29 @@
final List<ListBuilder.RowBuilder> bluetoothRows = new ArrayList<>();
final List<CachedBluetoothDevice> bluetoothDevices = getConnectedBluetoothDevices();
for (CachedBluetoothDevice bluetoothDevice : bluetoothDevices) {
- bluetoothRows.add(new ListBuilder.RowBuilder()
+ final ListBuilder.RowBuilder rowBuilder = new ListBuilder.RowBuilder()
.setTitleItem(getBluetoothDeviceIcon(bluetoothDevice), ListBuilder.ICON_IMAGE)
.setTitle(bluetoothDevice.getName())
- .setSubtitle(bluetoothDevice.getConnectionSummary())
- .setPrimaryAction(buildBluetoothDeviceAction(bluetoothDevice))
- .addEndItem(buildBluetoothDetailDeepLinkAction(bluetoothDevice)));
+ .setSubtitle(bluetoothDevice.getConnectionSummary());
+
+ if (bluetoothDevice.isConnectedA2dpDevice()) {
+ // For available media devices, the primary action is to active audio stream and
+ // add setting icon to the end to link detail page.
+ rowBuilder.setPrimaryAction(buildMediaBluetoothAction(bluetoothDevice));
+ rowBuilder.addEndItem(buildBluetoothDetailDeepLinkAction(bluetoothDevice));
+ } else {
+ // For other devices, the primary action is to link detail page.
+ rowBuilder.setPrimaryAction(buildBluetoothDetailDeepLinkAction(bluetoothDevice));
+ }
+
+ bluetoothRows.add(rowBuilder);
}
return bluetoothRows;
}
- private SliceAction buildBluetoothDeviceAction(CachedBluetoothDevice bluetoothDevice) {
+ @VisibleForTesting
+ SliceAction buildMediaBluetoothAction(CachedBluetoothDevice bluetoothDevice) {
// Send broadcast to activate available media device.
final Intent intent = new Intent(getUri().toString())
.setClass(mContext, SliceBroadcastReceiver.class)
@@ -250,7 +256,8 @@
bluetoothDevice.getName());
}
- private SliceAction buildBluetoothDetailDeepLinkAction(CachedBluetoothDevice bluetoothDevice) {
+ @VisibleForTesting
+ SliceAction buildBluetoothDetailDeepLinkAction(CachedBluetoothDevice bluetoothDevice) {
return SliceAction.createDeeplink(
getBluetoothDetailIntent(bluetoothDevice),
IconCompat.createWithResource(mContext, R.drawable.ic_settings_24dp),
diff --git a/src/com/android/settings/homepage/contextualcards/slices/SliceFullCardRendererHelper.java b/src/com/android/settings/homepage/contextualcards/slices/SliceFullCardRendererHelper.java
index ef0a67d..ee63536 100644
--- a/src/com/android/settings/homepage/contextualcards/slices/SliceFullCardRendererHelper.java
+++ b/src/com/android/settings/homepage/contextualcards/slices/SliceFullCardRendererHelper.java
@@ -16,6 +16,7 @@
package com.android.settings.homepage.contextualcards.slices;
+import android.animation.LayoutTransition;
import android.content.Context;
import android.view.View;
@@ -94,6 +95,7 @@
public SliceViewHolder(View view) {
super(view);
sliceView = view.findViewById(R.id.slice_view);
+ sliceView.getLayoutTransition().enableTransitionType(LayoutTransition.CHANGING);
}
}
}
diff --git a/src/com/android/settings/notification/AppNotificationSettings.java b/src/com/android/settings/notification/AppNotificationSettings.java
index 5553dd7..9f5ece2 100644
--- a/src/com/android/settings/notification/AppNotificationSettings.java
+++ b/src/com/android/settings/notification/AppNotificationSettings.java
@@ -16,6 +16,8 @@
package com.android.settings.notification;
+import static android.view.WindowManager.LayoutParams.SYSTEM_FLAG_HIDE_NON_SYSTEM_OVERLAY_WINDOWS;
+
import android.app.NotificationChannel;
import android.app.NotificationChannelGroup;
import android.app.settings.SettingsEnums;
@@ -24,6 +26,8 @@
import android.os.Bundle;
import android.text.TextUtils;
import android.util.Log;
+import android.view.Window;
+import android.view.WindowManager;
import androidx.preference.Preference;
import androidx.preference.PreferenceCategory;
@@ -33,7 +37,6 @@
import com.android.internal.widget.LockPatternUtils;
import com.android.settings.R;
-import com.android.settings.widget.MasterCheckBoxPreference;
import com.android.settingslib.RestrictedSwitchPreference;
import com.android.settingslib.core.AbstractPreferenceController;
@@ -85,6 +88,8 @@
public void onResume() {
super.onResume();
+ getActivity().getWindow().addSystemFlags(SYSTEM_FLAG_HIDE_NON_SYSTEM_OVERLAY_WINDOWS);
+
if (mUid < 0 || TextUtils.isEmpty(mPkg) || mPkgInfo == null) {
Log.w(TAG, "Missing package or uid or packageinfo");
finish();
@@ -119,6 +124,15 @@
}
@Override
+ public void onPause() {
+ super.onPause();
+ final Window window = getActivity().getWindow();
+ final WindowManager.LayoutParams attrs = window.getAttributes();
+ attrs.privateFlags &= ~SYSTEM_FLAG_HIDE_NON_SYSTEM_OVERLAY_WINDOWS;
+ window.setAttributes(attrs);
+ }
+
+ @Override
protected String getLogTag() {
return TAG;
}
diff --git a/src/com/android/settings/privacy/EnableContentCapturePreferenceController.java b/src/com/android/settings/privacy/EnableContentCapturePreferenceController.java
new file mode 100644
index 0000000..b3ea9a7
--- /dev/null
+++ b/src/com/android/settings/privacy/EnableContentCapturePreferenceController.java
@@ -0,0 +1,58 @@
+/*
+ * Copyright (C) 2019 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.privacy;
+
+import android.content.Context;
+import android.os.IBinder;
+import android.os.ServiceManager;
+import android.os.UserHandle;
+import android.provider.Settings;
+import android.view.contentcapture.ContentCaptureManager;
+
+import com.android.settings.core.TogglePreferenceController;
+
+public class EnableContentCapturePreferenceController extends TogglePreferenceController {
+
+ private static final String KEY_SHOW_PASSWORD = "content_capture";
+ private static final int MY_USER_ID = UserHandle.myUserId();
+
+ public EnableContentCapturePreferenceController(Context context) {
+ super(context, KEY_SHOW_PASSWORD);
+ }
+
+ @Override
+ public boolean isChecked() {
+ boolean enabled = Settings.Secure.getIntForUser(mContext.getContentResolver(),
+ Settings.Secure.CONTENT_CAPTURE_ENABLED, 1, MY_USER_ID) == 1;
+ return enabled;
+ }
+
+ @Override
+ public boolean setChecked(boolean isChecked) {
+ Settings.Secure.putIntForUser(mContext.getContentResolver(),
+ Settings.Secure.CONTENT_CAPTURE_ENABLED, isChecked ? 1 : 0, MY_USER_ID);
+ return true;
+ }
+
+ @Override
+ public int getAvailabilityStatus() {
+ // We cannot look for ContentCaptureManager, because it's not available if the service
+ // didn't whitelist Settings
+ IBinder service = ServiceManager.checkService(Context.CONTENT_CAPTURE_MANAGER_SERVICE);
+ return service != null ? AVAILABLE : UNSUPPORTED_ON_DEVICE;
+ }
+}
diff --git a/src/com/android/settings/users/AddUserWhenLockedPreferenceController.java b/src/com/android/settings/users/AddUserWhenLockedPreferenceController.java
index c097d41..f931fa4 100644
--- a/src/com/android/settings/users/AddUserWhenLockedPreferenceController.java
+++ b/src/com/android/settings/users/AddUserWhenLockedPreferenceController.java
@@ -38,9 +38,13 @@
mUserCaps.updateAddUserCapabilities(mContext);
final RestrictedSwitchPreference restrictedSwitchPreference =
(RestrictedSwitchPreference) preference;
- restrictedSwitchPreference.setDisabledByAdmin(
- mUserCaps.disallowAddUser() ? mUserCaps.getEnforcedAdmin() : null);
- restrictedSwitchPreference.setVisible(mUserCaps.mUserSwitcherEnabled);
+ if (!isAvailable()) {
+ restrictedSwitchPreference.setVisible(false);
+ } else {
+ restrictedSwitchPreference.setDisabledByAdmin(
+ mUserCaps.disallowAddUser() ? mUserCaps.getEnforcedAdmin() : null);
+ restrictedSwitchPreference.setVisible(mUserCaps.mUserSwitcherEnabled);
+ }
}
@Override
diff --git a/src/com/android/settings/users/UserSettings.java b/src/com/android/settings/users/UserSettings.java
index 5a83f34..98263e2 100644
--- a/src/com/android/settings/users/UserSettings.java
+++ b/src/com/android/settings/users/UserSettings.java
@@ -289,10 +289,8 @@
}
final PreferenceScreen screen = getPreferenceScreen();
- if (mAddUserWhenLockedPreferenceController.isAvailable()) {
- mAddUserWhenLockedPreferenceController.updateState(screen.findPreference(
- mAddUserWhenLockedPreferenceController.getPreferenceKey()));
- }
+ mAddUserWhenLockedPreferenceController.updateState(screen.findPreference(
+ mAddUserWhenLockedPreferenceController.getPreferenceKey()));
if (mShouldUpdateUserList) {
updateUI();
diff --git a/src/com/android/settings/wifi/savedaccesspoints/SavedAccessPointsPreferenceController.java b/src/com/android/settings/wifi/savedaccesspoints/SavedAccessPointsPreferenceController.java
index 4155ef7..40e6e56 100644
--- a/src/com/android/settings/wifi/savedaccesspoints/SavedAccessPointsPreferenceController.java
+++ b/src/com/android/settings/wifi/savedaccesspoints/SavedAccessPointsPreferenceController.java
@@ -28,6 +28,7 @@
import com.android.settings.core.BasePreferenceController;
import com.android.settings.utils.PreferenceGroupChildrenCache;
+import com.android.settings.R;
import com.android.settingslib.core.lifecycle.LifecycleObserver;
import com.android.settingslib.core.lifecycle.events.OnStart;
import com.android.settingslib.utils.ThreadUtils;
@@ -122,6 +123,12 @@
final int accessPointsSize = accessPoints.size();
for (int i = 0; i < accessPointsSize; ++i) {
AccessPoint ap = accessPoints.get(i);
+
+ if (mHost != null && mHost.isSubscriptionsFeatureEnabled()
+ && ap.isPasspointConfig()) {
+ continue;
+ }
+
String key = ap.getKey();
AccessPointPreference preference =
(AccessPointPreference) mChildrenCache.getCachedPreference(key);
@@ -139,6 +146,15 @@
if (mPreferenceGroup.getPreferenceCount() < 1) {
Log.w(TAG, "Saved networks activity loaded, but there are no saved networks!");
+ mPreferenceGroup.setVisible(false);
+ } else {
+ mPreferenceGroup.setVisible(true);
+ }
+
+ if (mHost != null && !mHost.isSubscriptionsFeatureEnabled()) {
+ mPreferenceGroup.setVisible(true);
+ mPreferenceGroup.setTitle(null);
+ mPreferenceGroup.setLayoutResource(R.layout.preference_category_no_label);
}
}
}
diff --git a/src/com/android/settings/wifi/savedaccesspoints/SavedAccessPointsWifiSettings.java b/src/com/android/settings/wifi/savedaccesspoints/SavedAccessPointsWifiSettings.java
index 6a9e8a2..867c2f8 100644
--- a/src/com/android/settings/wifi/savedaccesspoints/SavedAccessPointsWifiSettings.java
+++ b/src/com/android/settings/wifi/savedaccesspoints/SavedAccessPointsWifiSettings.java
@@ -75,6 +75,8 @@
.getApplicationContext().getSystemService(Context.WIFI_SERVICE);
use(SavedAccessPointsPreferenceController.class)
.setHost(this);
+ use(SubscribedAccessPointsPreferenceController.class)
+ .setHost(this);
}
@Override
@@ -172,10 +174,15 @@
Log.e(TAG, "Failed to remove Passpoint configuration for "
+ mSelectedAccessPoint.getConfigName());
}
- use(SavedAccessPointsPreferenceController.class)
- .postRefreshSavedAccessPoints();
+ if (isSubscriptionsFeatureEnabled()) {
+ use(SubscribedAccessPointsPreferenceController.class)
+ .postRefreshSubscribedAccessPoints();
+ } else {
+ use(SavedAccessPointsPreferenceController.class)
+ .postRefreshSavedAccessPoints();
+ }
} else {
- // mForgetListener will call initPreferences upon completion
+ // both onSuccess/onFailure will call postRefreshSavedAccessPoints
mWifiManager.forget(mSelectedAccessPoint.getConfig().networkId,
use(SavedAccessPointsPreferenceController.class));
}
@@ -198,4 +205,9 @@
}
return false;
}
+
+ boolean isSubscriptionsFeatureEnabled() {
+ return FeatureFlagUtils.isEnabled(getContext(), FeatureFlags.MOBILE_NETWORK_V2)
+ && FeatureFlagPersistent.isEnabled(getContext(), FeatureFlags.NETWORK_INTERNET_V2);
+ }
}
diff --git a/src/com/android/settings/wifi/savedaccesspoints/SubscribedAccessPointsPreferenceController.java b/src/com/android/settings/wifi/savedaccesspoints/SubscribedAccessPointsPreferenceController.java
new file mode 100644
index 0000000..8d31c82
--- /dev/null
+++ b/src/com/android/settings/wifi/savedaccesspoints/SubscribedAccessPointsPreferenceController.java
@@ -0,0 +1,158 @@
+/*
+ * Copyright (C) 2019 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.wifi.savedaccesspoints;
+
+
+import android.content.Context;
+import android.net.wifi.WifiManager;
+import android.util.Log;
+
+import androidx.annotation.VisibleForTesting;
+import androidx.preference.Preference;
+import androidx.preference.PreferenceGroup;
+import androidx.preference.PreferenceScreen;
+
+import com.android.settings.core.BasePreferenceController;
+import com.android.settings.utils.PreferenceGroupChildrenCache;
+import com.android.settingslib.core.lifecycle.LifecycleObserver;
+import com.android.settingslib.core.lifecycle.events.OnStart;
+import com.android.settingslib.utils.ThreadUtils;
+import com.android.settingslib.wifi.AccessPoint;
+import com.android.settingslib.wifi.AccessPointPreference;
+import com.android.settingslib.wifi.AccessPointPreference.UserBadgeCache;
+import com.android.settingslib.wifi.WifiSavedConfigUtils;
+
+import java.util.Collections;
+import java.util.List;
+
+/**
+ * Controller that manages a PreferenceGroup, which contains a list of subscribed access points.
+ */
+// TODO(b/127206629): Code refactor to avoid duplicated coding after removed feature flag.
+public class SubscribedAccessPointsPreferenceController extends BasePreferenceController implements
+ LifecycleObserver, OnStart, Preference.OnPreferenceClickListener,
+ WifiManager.ActionListener {
+
+ private static final String TAG = "SubscribedAPPrefCtrl";
+
+ private final WifiManager mWifiManager;
+ private final PreferenceGroupChildrenCache mChildrenCache;
+ private final UserBadgeCache mUserBadgeCache;
+ private PreferenceGroup mPreferenceGroup;
+ private SavedAccessPointsWifiSettings mHost;
+
+ public SubscribedAccessPointsPreferenceController(Context context,
+ String preferenceKey) {
+ super(context, preferenceKey);
+ mUserBadgeCache = new AccessPointPreference.UserBadgeCache(context.getPackageManager());
+ mWifiManager = context.getSystemService(WifiManager.class);
+ mChildrenCache = new PreferenceGroupChildrenCache();
+ }
+
+ public SubscribedAccessPointsPreferenceController setHost(SavedAccessPointsWifiSettings host) {
+ mHost = host;
+ return this;
+ }
+
+ @Override
+ public int getAvailabilityStatus() {
+ return AVAILABLE;
+ }
+
+ @Override
+ public void displayPreference(PreferenceScreen screen) {
+ super.displayPreference(screen);
+ mPreferenceGroup = screen.findPreference(getPreferenceKey());
+ }
+
+ @Override
+ public void onStart() {
+ refreshSubscribedAccessPoints();
+ }
+
+ public void postRefreshSubscribedAccessPoints() {
+ ThreadUtils.postOnMainThread(() -> refreshSubscribedAccessPoints());
+ }
+
+ @Override
+ public boolean onPreferenceClick(Preference preference) {
+ if (mHost != null) {
+ mHost.showWifiDialog((AccessPointPreference) preference);
+ }
+ return false;
+ }
+
+ @Override
+ public void onSuccess() {
+ postRefreshSubscribedAccessPoints();
+ }
+
+ @Override
+ public void onFailure(int reason) {
+ postRefreshSubscribedAccessPoints();
+ }
+
+ @VisibleForTesting
+ void refreshSubscribedAccessPoints() {
+ if (mPreferenceGroup == null) {
+ Log.w(TAG, "PreferenceGroup is null, skipping.");
+ return;
+ }
+
+ if (mHost != null && !mHost.isSubscriptionsFeatureEnabled()) {
+ mPreferenceGroup.setVisible(false);
+ return;
+ }
+
+ final Context prefContext = mPreferenceGroup.getContext();
+
+ final List<AccessPoint> accessPoints =
+ WifiSavedConfigUtils.getAllConfigs(mContext, mWifiManager);
+ Collections.sort(accessPoints, SavedNetworkComparator.INSTANCE);
+ mChildrenCache.cacheRemoveAllPrefs(mPreferenceGroup);
+
+ final int accessPointsSize = accessPoints.size();
+ for (int i = 0; i < accessPointsSize; ++i) {
+ AccessPoint ap = accessPoints.get(i);
+ if (!ap.isPasspointConfig()) {
+ continue;
+ }
+
+ final String key = ap.getKey();
+ AccessPointPreference preference =
+ (AccessPointPreference) mChildrenCache.getCachedPreference(key);
+ if (preference == null) {
+ preference = new AccessPointPreference(ap, prefContext, mUserBadgeCache, true);
+ preference.setKey(key);
+ preference.setIcon(null);
+ preference.setOnPreferenceClickListener(this);
+ mPreferenceGroup.addPreference(preference);
+ }
+ preference.setOrder(i);
+ }
+
+ mChildrenCache.removeCachedPrefs(mPreferenceGroup);
+
+ if (mPreferenceGroup.getPreferenceCount() < 1) {
+ Log.w(TAG, "Subscribed networks activity loaded,"
+ + " but there are no subscribed networks!");
+ mPreferenceGroup.setVisible(false);
+ } else {
+ mPreferenceGroup.setVisible(true);
+ }
+ }
+}
diff --git a/src/com/android/settings/wifi/slice/WifiSlice.java b/src/com/android/settings/wifi/slice/WifiSlice.java
index 8d20f7f..a2debb8 100644
--- a/src/com/android/settings/wifi/slice/WifiSlice.java
+++ b/src/com/android/settings/wifi/slice/WifiSlice.java
@@ -198,7 +198,7 @@
private IconCompat getEndIcon(AccessPoint accessPoint) {
if (accessPoint.isActive()) {
- return IconCompat.createWithResource(mContext, R.drawable.ic_settings_accent);
+ return null;
} else if (accessPoint.getSecurity() != AccessPoint.SECURITY_NONE) {
return IconCompat.createWithResource(mContext, R.drawable.ic_friction_lock_closed);
} else if (accessPoint.isMetered()) {
diff --git a/tests/robotests/src/com/android/settings/fuelgauge/batterysaver/BatterySaverStickyPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/fuelgauge/batterysaver/BatterySaverStickyPreferenceControllerTest.java
new file mode 100644
index 0000000..a441864
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/fuelgauge/batterysaver/BatterySaverStickyPreferenceControllerTest.java
@@ -0,0 +1,63 @@
+/*
+ * Copyright (C) 2016 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.fuelgauge.batterysaver;
+
+import static com.android.settings.fuelgauge.batterysaver.BatterySaverStickyPreferenceController.LOW_POWER_STICKY_AUTO_DISABLE_ENABLED;
+import static com.google.common.truth.Truth.assertThat;
+
+import android.content.Context;
+import android.provider.Settings;
+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 BatterySaverStickyPreferenceControllerTest {
+
+ private static final String PREF_KEY = "battery_saver_sticky";
+
+ private Context mContext;
+ private BatterySaverStickyPreferenceController mController;
+
+ @Before
+ public void setup() {
+ mContext = RuntimeEnvironment.application;
+ mController = new BatterySaverStickyPreferenceController(mContext, PREF_KEY);
+ }
+
+ private int getAutoDisableSetting() {
+ return Settings.System.getInt(mContext.getContentResolver(),
+ LOW_POWER_STICKY_AUTO_DISABLE_ENABLED,
+ 1);
+ }
+
+ @Test
+ public void testOnPreferenceChange_turnOnKeepActive_autoDisableOff() {
+ mController.onPreferenceChange(null, true);
+ final int isOn = getAutoDisableSetting();
+ assertThat(isOn).isEqualTo(0);
+ }
+
+ @Test
+ public void testOnPreferenceChange_TurnOffKeepActive_autoDisableOff() {
+ mController.onPreferenceChange(null, false);
+ final int isOn = getAutoDisableSetting();
+ assertThat(isOn).isEqualTo(1);
+ }
+}
diff --git a/tests/robotests/src/com/android/settings/gestures/SwipeUpPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/gestures/SystemNavigationEdgeToEdgePreferenceControllerTest.java
similarity index 61%
copy from tests/robotests/src/com/android/settings/gestures/SwipeUpPreferenceControllerTest.java
copy to tests/robotests/src/com/android/settings/gestures/SystemNavigationEdgeToEdgePreferenceControllerTest.java
index e98bdc8..5e6cd55 100644
--- a/tests/robotests/src/com/android/settings/gestures/SwipeUpPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/gestures/SystemNavigationEdgeToEdgePreferenceControllerTest.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2018 The Android Open Source Project
+ * Copyright (C) 2019 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.
@@ -16,17 +16,31 @@
package com.android.settings.gestures;
+import static com.android.settings.gestures.SystemNavigationEdgeToEdgePreferenceController.PREF_KEY_EDGE_TO_EDGE;
+import static com.android.settings.gestures.SystemNavigationLegacyPreferenceController.PREF_KEY_LEGACY;
+import static com.android.settings.gestures.SystemNavigationSwipeUpPreferenceController.PREF_KEY_SWIPE_UP;
+
import static com.google.common.truth.Truth.assertThat;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.when;
+import static org.mockito.Mockito.verify;
+
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.pm.ApplicationInfo;
import android.content.pm.ResolveInfo;
import android.content.pm.ServiceInfo;
+import android.provider.Settings;
+
+import androidx.preference.Preference;
+import androidx.preference.PreferenceScreen;
import com.android.internal.R;
import com.android.settings.testutils.shadow.SettingsShadowResources;
+import com.android.settings.widget.RadioButtonPreference;
import org.junit.After;
import org.junit.Before;
@@ -40,14 +54,14 @@
@RunWith(RobolectricTestRunner.class)
@Config(shadows = SettingsShadowResources.class)
-public class SwipeUpPreferenceControllerTest {
+public class SystemNavigationEdgeToEdgePreferenceControllerTest {
private Context mContext;
private ShadowPackageManager mPackageManager;
- private SwipeUpPreferenceController mController;
+
+ private SystemNavigationEdgeToEdgePreferenceController mController;
private static final String ACTION_QUICKSTEP = "android.intent.action.QUICKSTEP_SERVICE";
- private static final String KEY_SWIPE_UP = "gesture_swipe_up";
@Before
public void setUp() {
@@ -56,8 +70,12 @@
SettingsShadowResources.overrideResource(R.bool.config_swipe_up_gesture_default, true);
mContext = RuntimeEnvironment.application;
+ Settings.Global.putInt(mContext.getContentResolver(), "prototype_enabled", 1);
+
mPackageManager = Shadows.shadowOf(mContext.getPackageManager());
- mController = new SwipeUpPreferenceController(mContext, KEY_SWIPE_UP);
+
+ mController = new SystemNavigationEdgeToEdgePreferenceController(mContext,
+ PREF_KEY_EDGE_TO_EDGE);
}
@After
@@ -80,7 +98,8 @@
info.serviceInfo.applicationInfo.flags = ApplicationInfo.FLAG_SYSTEM;
mPackageManager.addResolveInfoForIntent(quickStepIntent, info);
- assertThat(SwipeUpPreferenceController.isGestureAvailable(mContext)).isTrue();
+ assertThat(SystemNavigationEdgeToEdgePreferenceController.isGestureAvailable(mContext))
+ .isTrue();
}
@Test
@@ -94,12 +113,14 @@
.setPackage(recentsComponentName.getPackageName());
mPackageManager.addResolveInfoForIntent(quickStepIntent, new ResolveInfo());
- assertThat(SwipeUpPreferenceController.isGestureAvailable(mContext)).isFalse();
+ assertThat(SystemNavigationEdgeToEdgePreferenceController.isGestureAvailable(mContext))
+ .isFalse();
}
@Test
public void testIsGestureAvailable_noMatchingServiceExists_shouldReturnFalse() {
- assertThat(SwipeUpPreferenceController.isGestureAvailable(mContext)).isFalse();
+ assertThat(SystemNavigationEdgeToEdgePreferenceController.isGestureAvailable(mContext))
+ .isFalse();
}
@Test
@@ -109,35 +130,45 @@
@Test
public void testIsChecked_defaultIsFalse_shouldReturnFalse() {
- SettingsShadowResources.overrideResource(R.bool.config_swipe_up_gesture_default, false);
+ Settings.Global.putInt(mContext.getContentResolver(), "prototype_enabled", 0);
assertThat(mController.isChecked()).isFalse();
}
@Test
- public void testIsChecked_setCheckedTrue_shouldReturnTrue() {
+ public void testIsChecked_radioButtonClicked_shouldReturnTrue() {
// Set the setting to be enabled.
- mController.setChecked(true);
+ mController.onRadioButtonClicked(null);
assertThat(mController.isChecked()).isTrue();
}
@Test
- public void testIsChecked_setCheckedFalse_shouldReturnFalse() {
- // Set the setting to be disabled.
- mController.setChecked(false);
- assertThat(mController.isChecked()).isFalse();
+ public void testOnRadioButtonClicked_setsCorrectRadioButtonChecked() {
+ RadioButtonPreference radioLegacy = mock(RadioButtonPreference.class);
+ RadioButtonPreference radioSwipeUp = mock(RadioButtonPreference.class);
+ RadioButtonPreference radioEdgeToEdge = mock(RadioButtonPreference.class);
+ PreferenceScreen screen = mock(PreferenceScreen.class);
+
+ when(screen.findPreference(PREF_KEY_LEGACY)).thenReturn(radioLegacy);
+ when(screen.findPreference(PREF_KEY_SWIPE_UP)).thenReturn(radioSwipeUp);
+ when(screen.findPreference(PREF_KEY_EDGE_TO_EDGE)).thenReturn(radioEdgeToEdge);
+
+ mController.displayPreference(screen);
+ mController.onRadioButtonClicked(radioEdgeToEdge);
+
+ verify(radioLegacy, times(1)).setChecked(false);
+ verify(radioSwipeUp, times(1)).setChecked(false);
+ verify(radioEdgeToEdge, times(1)).setChecked(true);
}
@Test
public void isSliceableCorrectKey_returnsTrue() {
- final SwipeUpPreferenceController controller =
- new SwipeUpPreferenceController(mContext, "gesture_swipe_up");
- assertThat(controller.isSliceable()).isTrue();
+ assertThat(mController.isSliceable()).isTrue();
}
@Test
public void isSliceableIncorrectKey_returnsFalse() {
- final SwipeUpPreferenceController controller =
- new SwipeUpPreferenceController(mContext, "bad_key");
+ final SystemNavigationEdgeToEdgePreferenceController controller =
+ new SystemNavigationEdgeToEdgePreferenceController(mContext, "bad_key");
assertThat(controller.isSliceable()).isFalse();
}
}
diff --git a/tests/robotests/src/com/android/settings/gestures/SwipeUpPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/gestures/SystemNavigationLegacyPreferenceControllerTest.java
similarity index 63%
copy from tests/robotests/src/com/android/settings/gestures/SwipeUpPreferenceControllerTest.java
copy to tests/robotests/src/com/android/settings/gestures/SystemNavigationLegacyPreferenceControllerTest.java
index e98bdc8..fe0a061 100644
--- a/tests/robotests/src/com/android/settings/gestures/SwipeUpPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/gestures/SystemNavigationLegacyPreferenceControllerTest.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2018 The Android Open Source Project
+ * Copyright (C) 2019 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.
@@ -16,8 +16,17 @@
package com.android.settings.gestures;
+import static com.android.settings.gestures.SystemNavigationEdgeToEdgePreferenceController.PREF_KEY_EDGE_TO_EDGE;
+import static com.android.settings.gestures.SystemNavigationLegacyPreferenceController.PREF_KEY_LEGACY;
+import static com.android.settings.gestures.SystemNavigationSwipeUpPreferenceController.PREF_KEY_SWIPE_UP;
+
import static com.google.common.truth.Truth.assertThat;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.when;
+import static org.mockito.Mockito.verify;
+
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
@@ -25,8 +34,12 @@
import android.content.pm.ResolveInfo;
import android.content.pm.ServiceInfo;
+import androidx.preference.Preference;
+import androidx.preference.PreferenceScreen;
+
import com.android.internal.R;
import com.android.settings.testutils.shadow.SettingsShadowResources;
+import com.android.settings.widget.RadioButtonPreference;
import org.junit.After;
import org.junit.Before;
@@ -40,24 +53,25 @@
@RunWith(RobolectricTestRunner.class)
@Config(shadows = SettingsShadowResources.class)
-public class SwipeUpPreferenceControllerTest {
+public class SystemNavigationLegacyPreferenceControllerTest {
private Context mContext;
private ShadowPackageManager mPackageManager;
- private SwipeUpPreferenceController mController;
+
+ private SystemNavigationLegacyPreferenceController mController;
private static final String ACTION_QUICKSTEP = "android.intent.action.QUICKSTEP_SERVICE";
- private static final String KEY_SWIPE_UP = "gesture_swipe_up";
@Before
public void setUp() {
SettingsShadowResources.overrideResource(R.bool.config_swipe_up_gesture_setting_available,
true);
- SettingsShadowResources.overrideResource(R.bool.config_swipe_up_gesture_default, true);
+ SettingsShadowResources.overrideResource(R.bool.config_swipe_up_gesture_default, false);
mContext = RuntimeEnvironment.application;
mPackageManager = Shadows.shadowOf(mContext.getPackageManager());
- mController = new SwipeUpPreferenceController(mContext, KEY_SWIPE_UP);
+
+ mController = new SystemNavigationLegacyPreferenceController(mContext, PREF_KEY_LEGACY);
}
@After
@@ -80,7 +94,8 @@
info.serviceInfo.applicationInfo.flags = ApplicationInfo.FLAG_SYSTEM;
mPackageManager.addResolveInfoForIntent(quickStepIntent, info);
- assertThat(SwipeUpPreferenceController.isGestureAvailable(mContext)).isTrue();
+ assertThat(SystemNavigationLegacyPreferenceController.isGestureAvailable(mContext))
+ .isTrue();
}
@Test
@@ -94,12 +109,14 @@
.setPackage(recentsComponentName.getPackageName());
mPackageManager.addResolveInfoForIntent(quickStepIntent, new ResolveInfo());
- assertThat(SwipeUpPreferenceController.isGestureAvailable(mContext)).isFalse();
+ assertThat(
+ SystemNavigationLegacyPreferenceController.isGestureAvailable(mContext)).isFalse();
}
@Test
public void testIsGestureAvailable_noMatchingServiceExists_shouldReturnFalse() {
- assertThat(SwipeUpPreferenceController.isGestureAvailable(mContext)).isFalse();
+ assertThat(
+ SystemNavigationLegacyPreferenceController.isGestureAvailable(mContext)).isFalse();
}
@Test
@@ -109,35 +126,46 @@
@Test
public void testIsChecked_defaultIsFalse_shouldReturnFalse() {
- SettingsShadowResources.overrideResource(R.bool.config_swipe_up_gesture_default, false);
+ // Turn on the Swipe Up mode (2-buttons)
+ SettingsShadowResources.overrideResource(R.bool.config_swipe_up_gesture_default, true);
assertThat(mController.isChecked()).isFalse();
}
@Test
- public void testIsChecked_setCheckedTrue_shouldReturnTrue() {
+ public void testIsChecked_radioButtonClicked_shouldReturnTrue() {
// Set the setting to be enabled.
- mController.setChecked(true);
+ mController.onRadioButtonClicked(null);
assertThat(mController.isChecked()).isTrue();
}
@Test
- public void testIsChecked_setCheckedFalse_shouldReturnFalse() {
- // Set the setting to be disabled.
- mController.setChecked(false);
- assertThat(mController.isChecked()).isFalse();
+ public void testOnRadioButtonClicked_setsCorrectRadioButtonChecked() {
+ RadioButtonPreference radioLegacy = mock(RadioButtonPreference.class);
+ RadioButtonPreference radioSwipeUp = mock(RadioButtonPreference.class);
+ RadioButtonPreference radioEdgeToEdge = mock(RadioButtonPreference.class);
+ PreferenceScreen screen = mock(PreferenceScreen.class);
+
+ when(screen.findPreference(PREF_KEY_LEGACY)).thenReturn(radioLegacy);
+ when(screen.findPreference(PREF_KEY_SWIPE_UP)).thenReturn(radioSwipeUp);
+ when(screen.findPreference(PREF_KEY_EDGE_TO_EDGE)).thenReturn(radioEdgeToEdge);
+
+ mController.displayPreference(screen);
+ mController.onRadioButtonClicked(radioLegacy);
+
+ verify(radioLegacy, times(1)).setChecked(true);
+ verify(radioSwipeUp, times(1)).setChecked(false);
+ verify(radioEdgeToEdge, times(1)).setChecked(false);
}
@Test
public void isSliceableCorrectKey_returnsTrue() {
- final SwipeUpPreferenceController controller =
- new SwipeUpPreferenceController(mContext, "gesture_swipe_up");
- assertThat(controller.isSliceable()).isTrue();
+ assertThat(mController.isSliceable()).isTrue();
}
@Test
public void isSliceableIncorrectKey_returnsFalse() {
- final SwipeUpPreferenceController controller =
- new SwipeUpPreferenceController(mContext, "bad_key");
+ final SystemNavigationLegacyPreferenceController controller =
+ new SystemNavigationLegacyPreferenceController(mContext, "bad_key");
assertThat(controller.isSliceable()).isFalse();
}
}
diff --git a/tests/robotests/src/com/android/settings/gestures/SwipeUpPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/gestures/SystemNavigationSwipeUpPreferenceControllerTest.java
similarity index 63%
rename from tests/robotests/src/com/android/settings/gestures/SwipeUpPreferenceControllerTest.java
rename to tests/robotests/src/com/android/settings/gestures/SystemNavigationSwipeUpPreferenceControllerTest.java
index e98bdc8..97b4762 100644
--- a/tests/robotests/src/com/android/settings/gestures/SwipeUpPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/gestures/SystemNavigationSwipeUpPreferenceControllerTest.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2018 The Android Open Source Project
+ * Copyright (C) 2019 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.
@@ -16,8 +16,17 @@
package com.android.settings.gestures;
+import static com.android.settings.gestures.SystemNavigationEdgeToEdgePreferenceController.PREF_KEY_EDGE_TO_EDGE;
+import static com.android.settings.gestures.SystemNavigationLegacyPreferenceController.PREF_KEY_LEGACY;
+import static com.android.settings.gestures.SystemNavigationSwipeUpPreferenceController.PREF_KEY_SWIPE_UP;
+
import static com.google.common.truth.Truth.assertThat;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.when;
+import static org.mockito.Mockito.verify;
+
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
@@ -25,8 +34,12 @@
import android.content.pm.ResolveInfo;
import android.content.pm.ServiceInfo;
+import androidx.preference.Preference;
+import androidx.preference.PreferenceScreen;
+
import com.android.internal.R;
import com.android.settings.testutils.shadow.SettingsShadowResources;
+import com.android.settings.widget.RadioButtonPreference;
import org.junit.After;
import org.junit.Before;
@@ -40,14 +53,14 @@
@RunWith(RobolectricTestRunner.class)
@Config(shadows = SettingsShadowResources.class)
-public class SwipeUpPreferenceControllerTest {
+public class SystemNavigationSwipeUpPreferenceControllerTest {
private Context mContext;
private ShadowPackageManager mPackageManager;
- private SwipeUpPreferenceController mController;
+
+ private SystemNavigationSwipeUpPreferenceController mController;
private static final String ACTION_QUICKSTEP = "android.intent.action.QUICKSTEP_SERVICE";
- private static final String KEY_SWIPE_UP = "gesture_swipe_up";
@Before
public void setUp() {
@@ -57,7 +70,8 @@
mContext = RuntimeEnvironment.application;
mPackageManager = Shadows.shadowOf(mContext.getPackageManager());
- mController = new SwipeUpPreferenceController(mContext, KEY_SWIPE_UP);
+
+ mController = new SystemNavigationSwipeUpPreferenceController(mContext, PREF_KEY_SWIPE_UP);
}
@After
@@ -80,7 +94,8 @@
info.serviceInfo.applicationInfo.flags = ApplicationInfo.FLAG_SYSTEM;
mPackageManager.addResolveInfoForIntent(quickStepIntent, info);
- assertThat(SwipeUpPreferenceController.isGestureAvailable(mContext)).isTrue();
+ assertThat(SystemNavigationSwipeUpPreferenceController.isGestureAvailable(mContext))
+ .isTrue();
}
@Test
@@ -94,12 +109,14 @@
.setPackage(recentsComponentName.getPackageName());
mPackageManager.addResolveInfoForIntent(quickStepIntent, new ResolveInfo());
- assertThat(SwipeUpPreferenceController.isGestureAvailable(mContext)).isFalse();
+ assertThat(SystemNavigationSwipeUpPreferenceController.isGestureAvailable(mContext))
+ .isFalse();
}
@Test
public void testIsGestureAvailable_noMatchingServiceExists_shouldReturnFalse() {
- assertThat(SwipeUpPreferenceController.isGestureAvailable(mContext)).isFalse();
+ assertThat(SystemNavigationSwipeUpPreferenceController.isGestureAvailable(mContext))
+ .isFalse();
}
@Test
@@ -114,30 +131,40 @@
}
@Test
- public void testIsChecked_setCheckedTrue_shouldReturnTrue() {
+ public void testIsChecked_radioButtonClicked_shouldReturnTrue() {
// Set the setting to be enabled.
- mController.setChecked(true);
+ mController.onRadioButtonClicked(null);
assertThat(mController.isChecked()).isTrue();
}
@Test
- public void testIsChecked_setCheckedFalse_shouldReturnFalse() {
- // Set the setting to be disabled.
- mController.setChecked(false);
- assertThat(mController.isChecked()).isFalse();
+ public void testOnRadioButtonClicked_setsCorrectRadioButtonChecked() {
+ RadioButtonPreference radioLegacy = mock(RadioButtonPreference.class);
+ RadioButtonPreference radioSwipeUp = mock(RadioButtonPreference.class);
+ RadioButtonPreference radioEdgeToEdge = mock(RadioButtonPreference.class);
+ PreferenceScreen screen = mock(PreferenceScreen.class);
+
+ when(screen.findPreference(PREF_KEY_LEGACY)).thenReturn(radioLegacy);
+ when(screen.findPreference(PREF_KEY_SWIPE_UP)).thenReturn(radioSwipeUp);
+ when(screen.findPreference(PREF_KEY_EDGE_TO_EDGE)).thenReturn(radioEdgeToEdge);
+
+ mController.displayPreference(screen);
+ mController.onRadioButtonClicked(radioSwipeUp);
+
+ verify(radioLegacy, times(1)).setChecked(false);
+ verify(radioSwipeUp, times(1)).setChecked(true);
+ verify(radioEdgeToEdge, times(1)).setChecked(false);
}
@Test
public void isSliceableCorrectKey_returnsTrue() {
- final SwipeUpPreferenceController controller =
- new SwipeUpPreferenceController(mContext, "gesture_swipe_up");
- assertThat(controller.isSliceable()).isTrue();
+ assertThat(mController.isSliceable()).isTrue();
}
@Test
public void isSliceableIncorrectKey_returnsFalse() {
- final SwipeUpPreferenceController controller =
- new SwipeUpPreferenceController(mContext, "bad_key");
+ final SystemNavigationSwipeUpPreferenceController controller =
+ new SystemNavigationSwipeUpPreferenceController(mContext, "bad_key");
assertThat(controller.isSliceable()).isFalse();
}
}
diff --git a/tests/robotests/src/com/android/settings/homepage/contextualcards/ContextualCardManagerTest.java b/tests/robotests/src/com/android/settings/homepage/contextualcards/ContextualCardManagerTest.java
index 1a0539c..eb9a461 100644
--- a/tests/robotests/src/com/android/settings/homepage/contextualcards/ContextualCardManagerTest.java
+++ b/tests/robotests/src/com/android/settings/homepage/contextualcards/ContextualCardManagerTest.java
@@ -31,6 +31,7 @@
import android.content.Context;
import android.net.Uri;
+import android.provider.Settings;
import android.util.ArrayMap;
import com.android.settings.homepage.contextualcards.conditional.ConditionFooterContextualCard;
@@ -126,6 +127,24 @@
}
@Test
+ public void getCardLoaderTimeout_noConfiguredTimeout_shouldReturnDefaultTimeout() {
+ final long timeout = mManager.getCardLoaderTimeout(mContext);
+
+ assertThat(timeout).isEqualTo(ContextualCardManager.CARD_CONTENT_LOADER_TIMEOUT_MS);
+ }
+
+ @Test
+ public void getCardLoaderTimeout_hasConfiguredTimeout_shouldReturnConfiguredTimeout() {
+ final long configuredTimeout = 5000L;
+ Settings.Global.putLong(mContext.getContentResolver(),
+ ContextualCardManager.KEY_GLOBAL_CARD_LOADER_TIMEOUT, configuredTimeout);
+
+ final long timeout = mManager.getCardLoaderTimeout(mContext);
+
+ assertThat(timeout).isEqualTo(configuredTimeout);
+ }
+
+ @Test
public void onFinishCardLoading_fastLoad_shouldCallOnContextualCardUpdated() {
mManager.mStartTime = System.currentTimeMillis();
final ContextualCardManager manager = spy(mManager);
diff --git a/tests/robotests/src/com/android/settings/homepage/contextualcards/slices/BluetoothDevicesSliceTest.java b/tests/robotests/src/com/android/settings/homepage/contextualcards/slices/BluetoothDevicesSliceTest.java
index 77fc5d9..4a23c33 100644
--- a/tests/robotests/src/com/android/settings/homepage/contextualcards/slices/BluetoothDevicesSliceTest.java
+++ b/tests/robotests/src/com/android/settings/homepage/contextualcards/slices/BluetoothDevicesSliceTest.java
@@ -23,6 +23,7 @@
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.never;
import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
@@ -83,7 +84,7 @@
// Mock the icon and detail intent of Bluetooth.
mIcon = IconCompat.createWithResource(mContext,
- com.android.internal.R.drawable.ic_settings_bluetooth);
+ com.android.internal.R.drawable.ic_settings_bluetooth);
mDetailIntent = PendingIntent.getActivity(mContext, 0, new Intent("test action"), 0);
doReturn(mIcon).when(mBluetoothDevicesSlice).getBluetoothDeviceIcon(any());
doReturn(mDetailIntent).when(mBluetoothDevicesSlice).getBluetoothDetailIntent(any());
@@ -122,6 +123,27 @@
}
@Test
+ public void getSlice_hasMediaBluetoothDevice_shouldBuildMediaBluetoothAction() {
+ mockBluetoothDeviceList(1 /* deviceCount */);
+ doReturn(true).when(mBluetoothDeviceList.get(0)).isConnectedA2dpDevice();
+ doReturn(mBluetoothDeviceList).when(mBluetoothDevicesSlice).getConnectedBluetoothDevices();
+
+ mBluetoothDevicesSlice.getSlice();
+
+ verify(mBluetoothDevicesSlice).buildMediaBluetoothAction(any());
+ }
+
+ @Test
+ public void getSlice_noMediaBluetoothDevice_shouldNotBuildMediaBluetoothAction() {
+ mockBluetoothDeviceList(1 /* deviceCount */);
+ doReturn(mBluetoothDeviceList).when(mBluetoothDevicesSlice).getConnectedBluetoothDevices();
+
+ mBluetoothDevicesSlice.getSlice();
+
+ verify(mBluetoothDevicesSlice, never()).buildMediaBluetoothAction(any());
+ }
+
+ @Test
public void getSlice_noBluetoothDevices_shouldHaveNoBluetoothDevicesTitle() {
doReturn(mBluetoothDeviceList).when(mBluetoothDevicesSlice).getConnectedBluetoothDevices();
@@ -175,7 +197,6 @@
doReturn(BLUETOOTH_MOCK_TITLE).when(mCachedBluetoothDevice).getName();
doReturn(BLUETOOTH_MOCK_SUMMARY).when(mCachedBluetoothDevice).getConnectionSummary();
doReturn(BLUETOOTH_MOCK_ADDRESS).when(mCachedBluetoothDevice).getAddress();
- doReturn(true).when(mCachedBluetoothDevice).isConnectedA2dpDevice();
for (int i = 0; i < deviceCount; i++) {
mBluetoothDeviceList.add(mCachedBluetoothDevice);
}
diff --git a/tests/robotests/src/com/android/settings/notification/AppNotificationSettingsTest.java b/tests/robotests/src/com/android/settings/notification/AppNotificationSettingsTest.java
new file mode 100644
index 0000000..9555a56
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/notification/AppNotificationSettingsTest.java
@@ -0,0 +1,93 @@
+package com.android.settings.notification;
+
+import static android.view.WindowManager.LayoutParams.SYSTEM_FLAG_HIDE_NON_SYSTEM_OVERLAY_WINDOWS;
+
+import static org.junit.Assert.assertEquals;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.spy;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
+import android.view.Window;
+import android.view.WindowManager;
+
+import androidx.fragment.app.FragmentActivity;
+import androidx.fragment.app.FragmentManager;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.ArgumentCaptor;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+import org.robolectric.Robolectric;
+import org.robolectric.RobolectricTestRunner;
+import org.robolectric.annotation.Config;
+import org.robolectric.annotation.Implementation;
+import org.robolectric.annotation.Implements;
+
+@RunWith(RobolectricTestRunner.class)
+public class AppNotificationSettingsTest {
+
+ private WindowManager.LayoutParams mLayoutParams;
+ private AppNotificationSettings mFragment;
+ private FragmentActivity mActivity;
+ @Mock
+ private Window mWindow;
+
+ @Before
+ public void setUp() {
+ MockitoAnnotations.initMocks(this);
+ mLayoutParams = new WindowManager.LayoutParams();
+ mActivity = spy(Robolectric.setupActivity(FragmentActivity.class));
+ mFragment = spy(new AppNotificationSettings());
+ when(mFragment.getActivity()).thenReturn(mActivity);
+ when(mFragment.getFragmentManager()).thenReturn(mock(FragmentManager.class));
+ when(mActivity.getWindow()).thenReturn(mWindow);
+ when(mWindow.getAttributes()).thenReturn(mLayoutParams);
+ }
+
+ @Test
+ @Config(shadows = {ShadowNotificationSettingsBase.class})
+ public void onResume_shouldHideSystemOverlay() {
+ mFragment.onResume();
+
+ verify(mWindow).addSystemFlags(SYSTEM_FLAG_HIDE_NON_SYSTEM_OVERLAY_WINDOWS);
+ }
+
+ @Test
+ @Config(shadows = {ShadowNotificationSettingsBase.class})
+ public void onPause_shouldRemoveHideSystemOverlay() {
+ mFragment.onResume();
+
+ verify(mWindow).addSystemFlags(SYSTEM_FLAG_HIDE_NON_SYSTEM_OVERLAY_WINDOWS);
+
+ mFragment.onPause();
+
+ // There's no Window.clearPrivateFlags() method, so the Window.attributes are updated.
+ ArgumentCaptor<WindowManager.LayoutParams> paramCaptor = ArgumentCaptor.forClass(
+ WindowManager.LayoutParams.class);
+ verify(mWindow).setAttributes(paramCaptor.capture());
+ assertEquals(0,
+ paramCaptor.getValue().privateFlags
+ & SYSTEM_FLAG_HIDE_NON_SYSTEM_OVERLAY_WINDOWS);
+ }
+
+ @Implements(NotificationSettingsBase.class)
+ public static class ShadowNotificationSettingsBase {
+
+ protected void __constructor__() {
+ // Do nothing
+ }
+
+ @Implementation
+ protected void onResume() {
+ // No-op.
+ }
+
+ @Implementation
+ protected void onPause() {
+ // No-op.
+ }
+ }
+}
diff --git a/tests/robotests/src/com/android/settings/privacy/EnableContentCapturePreferenceControllerTest.java b/tests/robotests/src/com/android/settings/privacy/EnableContentCapturePreferenceControllerTest.java
new file mode 100644
index 0000000..a379858
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/privacy/EnableContentCapturePreferenceControllerTest.java
@@ -0,0 +1,103 @@
+/*
+ * Copyright (C) 2019 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.privacy;
+
+import static com.google.common.truth.Truth.assertThat;
+
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
+import android.content.ContentResolver;
+import android.content.Context;
+import android.provider.Settings;
+import android.provider.Settings.SettingNotFoundException;
+
+import androidx.preference.Preference;
+import androidx.preference.PreferenceScreen;
+
+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 EnableContentCapturePreferenceControllerTest {
+
+ @Mock
+ private PreferenceScreen mScreen;
+
+ private Context mContext;
+ private EnableContentCapturePreferenceController mController;
+ private Preference mPreference;
+
+ @Before
+ public void setUp() {
+ MockitoAnnotations.initMocks(this);
+ mContext = RuntimeEnvironment.application;
+ mController = new EnableContentCapturePreferenceController(mContext);
+ mPreference = new Preference(mContext);
+ mPreference.setKey(mController.getPreferenceKey());
+ }
+
+ @Test
+ public void isChecked_settingIsOff_false() throws Exception {
+ setProperty(0);
+
+ assertThat(mController.isChecked()).isFalse();
+ }
+
+ @Test
+ public void isChecked_settingIsOn_true() throws Exception {
+ setProperty(1);
+
+ assertThat(mController.isChecked()).isTrue();
+ }
+
+ @Test
+ public void changePref_turnOn_shouldChangeSettingTo1() throws Exception {
+ setProperty(0);
+
+ mController.onPreferenceChange(mPreference, true);
+
+ assertThat(mController.isChecked()).isTrue();
+ assertProperty(1);
+ }
+
+ @Test
+ public void changePref_turnOff_shouldChangeSettingTo0() throws Exception {
+ setProperty(1);
+
+ mController.onPreferenceChange(mPreference, false);
+
+ assertThat(mController.isChecked()).isFalse();
+ assertProperty(0);
+ }
+
+ private void setProperty(int newValue) throws SettingNotFoundException {
+ final ContentResolver contentResolver = mContext.getContentResolver();
+ Settings.Secure.putInt(contentResolver, Settings.Secure.CONTENT_CAPTURE_ENABLED, newValue);
+ }
+
+ private void assertProperty(int expectedValue) throws SettingNotFoundException {
+ final ContentResolver contentResolver = mContext.getContentResolver();
+ assertThat(Settings.Secure.getInt(contentResolver, Settings.Secure.CONTENT_CAPTURE_ENABLED))
+ .isEqualTo(expectedValue);
+ }
+}
diff --git a/tests/robotests/src/com/android/settings/testutils/shadow/ShadowWifiManager.java b/tests/robotests/src/com/android/settings/testutils/shadow/ShadowWifiManager.java
index b69af2e..30d4c21 100644
--- a/tests/robotests/src/com/android/settings/testutils/shadow/ShadowWifiManager.java
+++ b/tests/robotests/src/com/android/settings/testutils/shadow/ShadowWifiManager.java
@@ -27,12 +27,15 @@
import org.robolectric.annotation.Implements;
import org.robolectric.shadow.api.Shadow;
+import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
@Implements(value = WifiManager.class)
public class ShadowWifiManager extends org.robolectric.shadows.ShadowWifiManager {
+ private List<PasspointConfiguration> mPasspointConfiguration;
+
public WifiConfiguration savedWifiConfig;
private WifiConfiguration mSavedApConfig;
@@ -61,7 +64,15 @@
@Implementation
protected List<PasspointConfiguration> getPasspointConfigurations() {
- return Collections.emptyList();
+ return mPasspointConfiguration == null ? Collections.emptyList() : mPasspointConfiguration;
+ }
+
+ @Implementation
+ protected void addOrUpdatePasspointConfiguration(PasspointConfiguration config) {
+ if (mPasspointConfiguration == null) {
+ mPasspointConfiguration = new ArrayList<>();
+ }
+ mPasspointConfiguration.add(config);
}
@Implementation
diff --git a/tests/robotests/src/com/android/settings/users/AddUserWhenLockedPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/users/AddUserWhenLockedPreferenceControllerTest.java
index dd0260b..b27b636 100644
--- a/tests/robotests/src/com/android/settings/users/AddUserWhenLockedPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/users/AddUserWhenLockedPreferenceControllerTest.java
@@ -30,6 +30,7 @@
import com.android.settings.testutils.shadow.ShadowUserManager;
import com.android.settingslib.RestrictedSwitchPreference;
+import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -57,6 +58,12 @@
mContext = RuntimeEnvironment.application;
mUserManager = ShadowUserManager.getShadow();
mController = new AddUserWhenLockedPreferenceController(mContext, "fake_key");
+ mUserManager.setSupportsMultipleUsers(true);
+ }
+
+ @After
+ public void tearDown() {
+ ShadowUserManager.reset();
}
@Test
@@ -72,6 +79,30 @@
}
@Test
+ public void updateState_NotAdmin_shouldNotDisplayPreference() {
+ mUserManager.setIsAdminUser(false);
+ final RestrictedSwitchPreference preference = mock(RestrictedSwitchPreference.class);
+
+ mController.updateState(preference);
+
+ verify(preference).setVisible(false);
+ }
+
+ @Test
+ public void updateState_Admin_shouldDisplayPreference() {
+ mUserManager.setIsAdminUser(true);
+ mUserManager.setUserSwitcherEnabled(true);
+ mUserManager.setSupportsMultipleUsers(true);
+ final AddUserWhenLockedPreferenceController controller =
+ new AddUserWhenLockedPreferenceController(mContext, "fake_key");
+ final RestrictedSwitchPreference preference = mock(RestrictedSwitchPreference.class);
+
+ controller.updateState(preference);
+
+ verify(preference).setVisible(true);
+ }
+
+ @Test
public void updateState_preferenceSetCheckedWhenSettingIsOn() {
final RestrictedSwitchPreference preference = mock(RestrictedSwitchPreference.class);
Global.putInt(mContext.getContentResolver(), Global.ADD_USERS_WHEN_LOCKED, 1);
diff --git a/tests/robotests/src/com/android/settings/wifi/savedaccesspoints/SavedAccessPointsPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/wifi/savedaccesspoints/SavedAccessPointsPreferenceControllerTest.java
index 7f7ecc5..51944d8 100644
--- a/tests/robotests/src/com/android/settings/wifi/savedaccesspoints/SavedAccessPointsPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/wifi/savedaccesspoints/SavedAccessPointsPreferenceControllerTest.java
@@ -20,7 +20,9 @@
import static com.google.common.truth.Truth.assertThat;
+import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.doNothing;
+import static org.mockito.Mockito.never;
import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
@@ -32,6 +34,8 @@
import androidx.preference.PreferenceCategory;
import androidx.preference.PreferenceScreen;
+import com.android.settings.core.FeatureFlags;
+import com.android.settings.development.featureflags.FeatureFlagPersistent;
import com.android.settings.testutils.shadow.ShadowAccessPoint;
import com.android.settings.testutils.shadow.ShadowThreadUtils;
import com.android.settings.testutils.shadow.ShadowWifiManager;
@@ -58,6 +62,7 @@
private Context mContext;
private WifiManager mWifiManager;
+ private SavedAccessPointsWifiSettings mSettings;
private SavedAccessPointsPreferenceController mController;
@Before
@@ -65,7 +70,9 @@
MockitoAnnotations.initMocks(this);
mContext = RuntimeEnvironment.application;
mWifiManager = mContext.getSystemService(WifiManager.class);
+ mSettings = spy(new SavedAccessPointsWifiSettings());
mController = spy(new SavedAccessPointsPreferenceController(mContext, "test_key"));
+ mController.setHost(mSettings);
when(mPreferenceScreen.findPreference(mController.getPreferenceKey()))
.thenReturn(mPreferenceCategory);
@@ -115,7 +122,7 @@
@Test
@Config(shadows = ShadowAccessPoint.class)
- public void refreshSavedAccessPoints_shouldListAllAPs() {
+ public void refreshSavedAccessPoints_shouldListNonSubscribedAPs() {
final WifiConfiguration config = new WifiConfiguration();
config.SSID = "SSID";
config.BSSID = "BSSID";
@@ -132,4 +139,18 @@
final AccessPointPreference pref = captor.getValue();
assertThat(pref.getTitle()).isEqualTo(config.SSID);
}
+
+ @Test
+ @Config(shadows = ShadowAccessPoint.class)
+ public void refreshSavedAccessPoints_shouldNotListSubscribedAPs() {
+ FeatureFlagPersistent.setEnabled(mContext, FeatureFlags.NETWORK_INTERNET_V2, true);
+
+ mWifiManager.addOrUpdatePasspointConfiguration(
+ SubscribedAccessPointsPreferenceControllerTest.createMockPasspointConfiguration());
+
+ mController.displayPreference(mPreferenceScreen);
+ mController.refreshSavedAccessPoints();
+
+ verify(mPreferenceCategory, never()).addPreference(any(AccessPointPreference.class));
+ }
}
diff --git a/tests/robotests/src/com/android/settings/wifi/savedaccesspoints/SavedAccessPointsWifiSettingsTest.java b/tests/robotests/src/com/android/settings/wifi/savedaccesspoints/SavedAccessPointsWifiSettingsTest.java
index f76184c..6ede989 100644
--- a/tests/robotests/src/com/android/settings/wifi/savedaccesspoints/SavedAccessPointsWifiSettingsTest.java
+++ b/tests/robotests/src/com/android/settings/wifi/savedaccesspoints/SavedAccessPointsWifiSettingsTest.java
@@ -28,6 +28,8 @@
import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
import com.android.settings.R;
+import com.android.settings.core.FeatureFlags;
+import com.android.settings.development.featureflags.FeatureFlagPersistent;
import com.android.settings.wifi.WifiConfigController;
import com.android.settings.wifi.WifiDialog;
import com.android.settingslib.core.AbstractPreferenceController;
@@ -39,6 +41,7 @@
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import org.robolectric.RobolectricTestRunner;
+import org.robolectric.RuntimeEnvironment;
import org.robolectric.util.ReflectionHelpers;
@RunWith(RobolectricTestRunner.class)
@@ -55,6 +58,8 @@
@Mock
private AccessPoint mAccessPoint;
@Mock
+ private SubscribedAccessPointsPreferenceController mSubscribedApController;
+ @Mock
private SavedAccessPointsPreferenceController mSavedApController;
private TestFragment mSettings;
@@ -64,6 +69,8 @@
MockitoAnnotations.initMocks(this);
mSettings = spy(new TestFragment());
+ doReturn(mSubscribedApController).when(mSettings)
+ .use(SubscribedAccessPointsPreferenceController.class);
doReturn(mSavedApController).when(mSettings)
.use(SavedAccessPointsPreferenceController.class);
@@ -84,6 +91,18 @@
}
@Test
+ public void onForget_isPasspointConfig_shouldRefreshSubscribedAPList() {
+ FeatureFlagPersistent.setEnabled(RuntimeEnvironment.application,
+ FeatureFlags.NETWORK_INTERNET_V2, true);
+ when(mAccessPoint.isPasspointConfig()).thenReturn(true);
+ ReflectionHelpers.setField(mSettings, "mSelectedAccessPoint", mAccessPoint);
+
+ mSettings.onForget(null);
+
+ verify(mSubscribedApController).postRefreshSubscribedAccessPoints();
+ }
+
+ @Test
public void onForget_shouldInvokeForgetApi() {
ReflectionHelpers.setField(mSettings, "mSelectedAccessPoint", mAccessPoint);
when(mAccessPoint.getConfig()).thenReturn(mWifiConfiguration);
diff --git a/tests/robotests/src/com/android/settings/wifi/savedaccesspoints/SubscribedAccessPointsPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/wifi/savedaccesspoints/SubscribedAccessPointsPreferenceControllerTest.java
new file mode 100644
index 0000000..26933d8
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/wifi/savedaccesspoints/SubscribedAccessPointsPreferenceControllerTest.java
@@ -0,0 +1,170 @@
+/*
+ * Copyright (C) 2019 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.wifi.savedaccesspoints;
+
+import static com.android.settings.core.BasePreferenceController.AVAILABLE;
+
+import static com.google.common.truth.Truth.assertThat;
+
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.Mockito.doNothing;
+import static org.mockito.Mockito.never;
+import static org.mockito.Mockito.spy;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+import static org.robolectric.Shadows.shadowOf;
+
+import android.content.Context;
+import android.content.pm.FeatureInfo;
+import android.content.pm.PackageManager;
+import android.net.wifi.WifiConfiguration;
+
+import android.net.wifi.hotspot2.PasspointConfiguration;
+import android.net.wifi.hotspot2.pps.HomeSp;
+import android.net.wifi.WifiEnterpriseConfig;
+import android.net.wifi.WifiManager;
+import androidx.preference.PreferenceCategory;
+import androidx.preference.PreferenceScreen;
+
+import com.android.settings.core.FeatureFlags;
+import com.android.settings.development.featureflags.FeatureFlagPersistent;
+import com.android.settings.testutils.shadow.ShadowAccessPoint;
+import com.android.settings.testutils.shadow.ShadowThreadUtils;
+import com.android.settings.testutils.shadow.ShadowWifiManager;
+import com.android.settingslib.wifi.AccessPointPreference;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.ArgumentCaptor;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+import org.robolectric.RobolectricTestRunner;
+import org.robolectric.RuntimeEnvironment;
+import org.robolectric.annotation.Config;
+
+@RunWith(RobolectricTestRunner.class)
+@Config(shadows = {ShadowThreadUtils.class, ShadowWifiManager.class})
+public class SubscribedAccessPointsPreferenceControllerTest {
+
+ @Mock
+ private PreferenceScreen mPreferenceScreen;
+ @Mock
+ private PreferenceCategory mPreferenceCategory;
+
+ private Context mContext;
+ private WifiManager mWifiManager;
+ private SavedAccessPointsWifiSettings mSettings;
+ private SubscribedAccessPointsPreferenceController mController;
+
+ @Before
+ public void setUp() {
+ MockitoAnnotations.initMocks(this);
+ mContext = RuntimeEnvironment.application;
+ mWifiManager = mContext.getSystemService(WifiManager.class);
+ mSettings = spy(new SavedAccessPointsWifiSettings());
+ mController = spy(new SubscribedAccessPointsPreferenceController(mContext, "test_key"));
+ mController.setHost(mSettings);
+
+ when(mPreferenceScreen.findPreference(mController.getPreferenceKey()))
+ .thenReturn(mPreferenceCategory);
+ when(mPreferenceCategory.getContext()).thenReturn(mContext);
+
+ FeatureFlagPersistent.setEnabled(mContext, FeatureFlags.NETWORK_INTERNET_V2, true);
+ }
+
+ @Test
+ public void getAvailability_alwaysAvailable() {
+ assertThat(mController.getAvailabilityStatus()).isEqualTo(AVAILABLE);
+ }
+
+ @Test
+ public void onStart_shouldRefreshApList() {
+ doNothing().when(mController).refreshSubscribedAccessPoints();
+
+ mController.onStart();
+
+ verify(mController).refreshSubscribedAccessPoints();
+ }
+
+ @Test
+ public void postRefresh_shouldRefreshApList() {
+ doNothing().when(mController).refreshSubscribedAccessPoints();
+
+ mController.postRefreshSubscribedAccessPoints();
+
+ verify(mController).refreshSubscribedAccessPoints();
+ }
+
+ @Test
+ public void forget_onSuccess_shouldRefreshApList() {
+ doNothing().when(mController).refreshSubscribedAccessPoints();
+
+ mController.onSuccess();
+
+ verify(mController).refreshSubscribedAccessPoints();
+ }
+
+ @Test
+ public void forget_onFailure_shouldRefreshApList() {
+ doNothing().when(mController).refreshSubscribedAccessPoints();
+
+ mController.onFailure(0 /* reason */);
+
+ verify(mController).refreshSubscribedAccessPoints();
+ }
+
+ @Test
+ @Config(shadows = ShadowAccessPoint.class)
+ public void refreshSubscribedAccessPoints_shouldNotListNonSubscribedAPs() {
+ final WifiConfiguration config = new WifiConfiguration();
+ config.SSID = "SSID";
+ config.BSSID = "BSSID";
+ config.networkId = 2;
+ mWifiManager.addNetwork(config);
+
+ mController.displayPreference(mPreferenceScreen);
+ mController.refreshSubscribedAccessPoints();
+
+ verify(mPreferenceCategory, never()).addPreference(any(AccessPointPreference.class));
+ }
+
+ @Test
+ @Config(shadows = ShadowAccessPoint.class)
+ public void refreshSubscribedAccessPoints_shouldListSubscribedAPs() {
+ mWifiManager.addOrUpdatePasspointConfiguration(createMockPasspointConfiguration());
+
+ mController.displayPreference(mPreferenceScreen);
+ mController.refreshSubscribedAccessPoints();
+
+ final ArgumentCaptor<AccessPointPreference> captor =
+ ArgumentCaptor.forClass(AccessPointPreference.class);
+ verify(mPreferenceCategory).addPreference(captor.capture());
+
+ final AccessPointPreference pref = captor.getValue();
+ assertThat(pref.getTitle()).isEqualTo("TESTPASSPOINT");
+ }
+
+ public static PasspointConfiguration createMockPasspointConfiguration() {
+ final PasspointConfiguration config = new PasspointConfiguration();
+ final HomeSp homeSp = new HomeSp();
+ homeSp.setFqdn("FQDN");
+ homeSp.setFriendlyName("TESTPASSPOINT");
+ config.setHomeSp(homeSp);
+ return config;
+ }
+}