Merge "Add UiBlocker for DashboardFragment"
diff --git a/Android.mk b/Android.mk
index c99e30c..e385b34 100644
--- a/Android.mk
+++ b/Android.mk
@@ -23,6 +23,7 @@
LOCAL_SRC_FILES := $(call all-java-files-under, src)
LOCAL_STATIC_ANDROID_LIBRARIES := \
+ androidx-constraintlayout_constraintlayout \
androidx.slice_slice-builders \
androidx.slice_slice-core \
androidx.slice_slice-view \
@@ -40,6 +41,7 @@
ims-common
LOCAL_STATIC_JAVA_LIBRARIES := \
+ androidx-constraintlayout_constraintlayout-solver \
androidx.lifecycle_lifecycle-runtime \
androidx.lifecycle_lifecycle-extensions \
guava \
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index 871f609..213e5a4 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -139,7 +139,11 @@
android:label="@string/network_settings_title"
android:theme="@style/Theme.Settings.Home"
android:launchMode="singleTask">
- <!-- TODO(b/114749736): add intent filter here and disable the one in telephony -->
+ <intent-filter android:priority="1">
+ <action android:name="android.settings.NETWORK_OPERATOR_SETTINGS" />
+ <action android:name="android.settings.DATA_ROAMING_SETTINGS" />
+ <category android:name="android.intent.category.DEFAULT" />
+ </intent-filter>
</activity>
<!-- Alias for launcher activity only, as this belongs to each profile. -->
@@ -1473,7 +1477,7 @@
<activity android:name=".SetupRedactionInterstitial"
android:enabled="false"
android:exported="true"
- android:theme="@style/SuwThemeGlif.DayNight"
+ android:theme="@style/SudThemeGlif.DayNight"
android:label="@string/lock_screen_notifications_interstitial_title"
android:icon="@drawable/ic_suggested_notifications">
<intent-filter>
@@ -2003,9 +2007,8 @@
</intent-filter>
</activity>
- <!-- TODO: Is this needed? -->
<activity android:name="BandMode"
- android:theme="@android:style/Theme.DeviceDefault.Light.Dialog.Alert"
+ android:label="@string/band_mode_title"
android:process="com.android.phone">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
@@ -3050,7 +3053,7 @@
<intent-filter>
<action android:name="android.settings.WIFI_DPP_CONFIGURATOR_QR_CODE_SCANNER"/>
<action android:name="android.settings.WIFI_DPP_CONFIGURATOR_QR_CODE_GENERATOR"/>
- <action android:name="android.settings.WIFI_DPP_CONFIGURATOR_CHOOSE_SAVED_WIFI_NETWORK"/>
+ <action android:name="android.settings.PROCESS_WIFI_DPP_QR_CODE"/>
<category android:name="android.intent.category.DEFAULT"/>
</intent-filter>
</activity>
diff --git a/color-check-baseline.xml b/color-check-baseline.xml
index fd0fc6c..7b0b28e 100644
--- a/color-check-baseline.xml
+++ b/color-check-baseline.xml
@@ -2,6 +2,18 @@
<issues format="4">
<issue
+ id="LintError"
+ severity="Error"
+ message="No `.class` files were found in project ".", so none of the classfile based checks could be run. Does the project need to be built first?"
+ category="Lint"
+ priority="10"
+ summary="Lint Failure"
+ explanation="This issue type represents a problem running lint itself. Examples include failure to find bytecode for source files (which means certain detectors could not be run), parsing errors in lint configuration files, etc.
These errors are not errors in your own code, but they are shown to make it clear that some checks were not completed.">
+ <location
+ file="."/>
+ </issue>
+
+ <issue
id="HardCodedColor"
severity="Error"
message="Avoid using hardcoded color"
@@ -233,6 +245,22 @@
priority="4"
summary="Using hardcoded color"
explanation="Hardcoded color values are bad because theme changes cannot be uniformly applied.Instead use the theme specific colors such as `?android:attr/textColorPrimary` in attributes.
This ensures that a theme change from a light to a dark theme can be uniformlyapplied across the app."
+ errorLine1=" <color name="homepage_status_bar_color">#cc000000</color>"
+ errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
+ <location
+ file="res/values-night/colors.xml"
+ line="25"
+ column="3"/>
+ </issue>
+
+ <issue
+ id="HardCodedColor"
+ severity="Error"
+ message="Avoid using hardcoded color"
+ category="Correctness"
+ priority="4"
+ summary="Using hardcoded color"
+ explanation="Hardcoded color values are bad because theme changes cannot be uniformly applied.Instead use the theme specific colors such as `?android:attr/textColorPrimary` in attributes.
This ensures that a theme change from a light to a dark theme can be uniformlyapplied across the app."
errorLine1=" <color name="crypt_keeper_clock_foreground">#ff666666</color>"
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
<location
@@ -1289,11 +1317,27 @@
priority="4"
summary="Using hardcoded color"
explanation="Hardcoded color values are bad because theme changes cannot be uniformly applied.Instead use the theme specific colors such as `?android:attr/textColorPrimary` in attributes.
This ensures that a theme change from a light to a dark theme can be uniformlyapplied across the app."
+ errorLine1=" <color name="homepage_status_bar_color">#ccFFFFFF</color>"
+ errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
+ <location
+ file="res/values/colors.xml"
+ line="133"
+ column="5"/>
+ </issue>
+
+ <issue
+ id="HardCodedColor"
+ severity="Error"
+ message="Avoid using hardcoded color"
+ category="Correctness"
+ priority="4"
+ summary="Using hardcoded color"
+ explanation="Hardcoded color values are bad because theme changes cannot be uniformly applied.Instead use the theme specific colors such as `?android:attr/textColorPrimary` in attributes.
This ensures that a theme change from a light to a dark theme can be uniformlyapplied across the app."
errorLine1=" <color name="qr_corner_line_color">#ffdadce0</color>"
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
<location
file="res/values/colors.xml"
- line="133"
+ line="136"
column="5"/>
</issue>
@@ -1309,7 +1353,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
<location
file="res/values/colors.xml"
- line="134"
+ line="137"
column="5"/>
</issue>
@@ -1325,7 +1369,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
<location
file="res/values/colors.xml"
- line="135"
+ line="138"
column="5"/>
</issue>
@@ -2477,7 +2521,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~~~~">
<location
file="res/values/strings.xml"
- line="5883"
+ line="5885"
column="36"/>
</issue>
@@ -2509,7 +2553,7 @@
errorLine2=" ^">
<location
file="res/values/styles.xml"
- line="415"
+ line="388"
column="44"/>
</issue>
@@ -2525,7 +2569,7 @@
errorLine2=" ^">
<location
file="res/values/styles.xml"
- line="421"
+ line="394"
column="44"/>
</issue>
@@ -2541,7 +2585,7 @@
errorLine2=" ^">
<location
file="res/values/styles.xml"
- line="422"
+ line="395"
column="44"/>
</issue>
@@ -2557,7 +2601,7 @@
errorLine2=" ^">
<location
file="res/values/styles.xml"
- line="457"
+ line="430"
column="34"/>
</issue>
diff --git a/res/drawable/ic_battery_saver_accent_24dp.xml b/res/drawable/ic_battery_saver_accent_24dp.xml
new file mode 100644
index 0000000..c8def54
--- /dev/null
+++ b/res/drawable/ic_battery_saver_accent_24dp.xml
@@ -0,0 +1,29 @@
+<!--
+ 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.
+ -->
+
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
+ android:width="24dp"
+ android:height="24dp"
+ android:viewportWidth="24.0"
+ android:viewportHeight="24.0"
+ android:tint="?android:attr/colorAccent">
+ <path
+ android:fillColor="#FF000000"
+ android:pathData="M15,14l-2,0l0,2l-2,0l0,-2l-2,0l0,-2l2,0l0,-2l2,0l0,2l2,0z"/>
+ <path
+ android:fillColor="#FF000000"
+ android:pathData="M16.2,22.5H7.8c-1.3,0 -2.3,-1 -2.3,-2.3V5.8c0,-1.3 1,-2.3 2.3,-2.3h0.7v-2h7v2h0.7c1.3,0 2.3,1.1 2.3,2.3v14.3C18.5,21.5 17.5,22.5 16.2,22.5zM7.8,5.5c-0.2,0 -0.3,0.2 -0.3,0.3v14.3c0,0.2 0.2,0.3 0.3,0.3h8.3c0.2,0 0.3,-0.1 0.3,-0.3V5.8c0,-0.2 -0.1,-0.3 -0.3,-0.3h-2.7v-2h-3v2H7.8z"/>
+</vector>
diff --git a/res/drawable/ic_fingerprint_list_icon.xml b/res/drawable/ic_fingerprint_list_icon.xml
index ce1ce5e..6a563aa 100644
--- a/res/drawable/ic_fingerprint_list_icon.xml
+++ b/res/drawable/ic_fingerprint_list_icon.xml
@@ -19,6 +19,6 @@
android:viewportWidth="24.0"
android:viewportHeight="24.0">
<path
- android:fillColor="?attr/suwListItemIconColor"
+ android:fillColor="?attr/sudListItemIconColor"
android:pathData="M17.81,4.47c-0.08,0 -0.16,-0.02 -0.23,-0.06C15.66,3.42 14,3 12.01,3c-1.98,0 -3.86,0.47 -5.57,1.41 -0.24,0.13 -0.54,0.04 -0.68,-0.2 -0.13,-0.24 -0.04,-0.55 0.2,-0.68C7.82,2.52 9.86,2 12.01,2c2.13,0 3.99,0.47 6.03,1.52 0.25,0.13 0.34,0.43 0.21,0.67 -0.09,0.18 -0.26,0.28 -0.44,0.28zM3.5,9.72c-0.1,0 -0.2,-0.03 -0.29,-0.09 -0.23,-0.16 -0.28,-0.47 -0.12,-0.7 0.99,-1.4 2.25,-2.5 3.75,-3.27C9.98,4.04 14,4.03 17.15,5.65c1.5,0.77 2.76,1.86 3.75,3.25 0.16,0.22 0.11,0.54 -0.12,0.7 -0.23,0.16 -0.54,0.11 -0.7,-0.12 -0.9,-1.26 -2.04,-2.25 -3.39,-2.94 -2.87,-1.47 -6.54,-1.47 -9.4,0.01 -1.36,0.7 -2.5,1.7 -3.4,2.96 -0.08,0.14 -0.23,0.21 -0.39,0.21zM9.75,21.79c-0.13,0 -0.26,-0.05 -0.35,-0.15 -0.87,-0.87 -1.34,-1.43 -2.01,-2.64 -0.69,-1.23 -1.05,-2.73 -1.05,-4.34 0,-2.97 2.54,-5.39 5.66,-5.39s5.66,2.42 5.66,5.39c0,0.28 -0.22,0.5 -0.5,0.5s-0.5,-0.22 -0.5,-0.5c0,-2.42 -2.09,-4.39 -4.66,-4.39 -2.57,0 -4.66,1.97 -4.66,4.39 0,1.44 0.32,2.77 0.93,3.85 0.64,1.15 1.08,1.64 1.85,2.42 0.19,0.2 0.19,0.51 0,0.71 -0.11,0.1 -0.24,0.15 -0.37,0.15zM16.92,19.94c-1.19,0 -2.24,-0.3 -3.1,-0.89 -1.49,-1.01 -2.38,-2.65 -2.38,-4.39 0,-0.28 0.22,-0.5 0.5,-0.5s0.5,0.22 0.5,0.5c0,1.41 0.72,2.74 1.94,3.56 0.71,0.48 1.54,0.71 2.54,0.71 0.24,0 0.64,-0.03 1.04,-0.1 0.27,-0.05 0.53,0.13 0.58,0.41 0.05,0.27 -0.13,0.53 -0.41,0.58 -0.57,0.11 -1.07,0.12 -1.21,0.12zM14.91,22c-0.04,0 -0.09,-0.01 -0.13,-0.02 -1.59,-0.44 -2.63,-1.03 -3.72,-2.1 -1.4,-1.39 -2.17,-3.24 -2.17,-5.22 0,-1.62 1.38,-2.94 3.08,-2.94 1.7,0 3.08,1.32 3.08,2.94 0,1.07 0.93,1.94 2.08,1.94s2.08,-0.87 2.08,-1.94c0,-3.77 -3.25,-6.83 -7.25,-6.83 -2.84,0 -5.44,1.58 -6.61,4.03 -0.39,0.81 -0.59,1.76 -0.59,2.8 0,0.78 0.07,2.01 0.67,3.61 0.1,0.26 -0.03,0.55 -0.29,0.64 -0.26,0.1 -0.55,-0.04 -0.64,-0.29 -0.49,-1.31 -0.73,-2.61 -0.73,-3.96 0,-1.2 0.23,-2.29 0.68,-3.24 1.33,-2.79 4.28,-4.6 7.51,-4.6 4.55,0 8.25,3.51 8.25,7.83 0,1.62 -1.38,2.94 -3.08,2.94s-3.08,-1.32 -3.08,-2.94c0,-1.07 -0.93,-1.94 -2.08,-1.94s-2.08,0.87 -2.08,1.94c0,1.71 0.66,3.31 1.87,4.51 0.95,0.94 1.86,1.46 3.27,1.85 0.27,0.07 0.42,0.35 0.35,0.61 -0.05,0.23 -0.26,0.38 -0.47,0.38z"/>
</vector>
diff --git a/res/drawable/ic_lock_list_icon.xml b/res/drawable/ic_lock_list_icon.xml
index 7a323f2..9660f9c 100644
--- a/res/drawable/ic_lock_list_icon.xml
+++ b/res/drawable/ic_lock_list_icon.xml
@@ -18,7 +18,7 @@
android:height="24.0dp"
android:viewportWidth="24.0"
android:viewportHeight="24.0"
- android:tint="?attr/suwListItemIconColor">
+ android:tint="?attr/sudListItemIconColor">
<path
android:fillColor="@android:color/white"
android:pathData="M18.0,8.0l-1.0,0.0L17.0,6.0c0.0,-2.76 -2.24,-5.0 -5.0,-5.0S7.0,3.24 7.0,6.0l0.0,2.0L6.0,8.0c-1.1,0.0 -2.0,0.9 -2.0,2.0l0.0,10.0c0.0,1.0 0.9,2.0 2.0,2.0l12.0,0.0c1.1,0.0 2.0,-0.9 2.0,-2.0L20.0,10.0c0.0,-1.1 -0.9,-2.0 -2.0,-2.0zm-6.0,9.0c-1.1,0.0 -2.0,-0.9 -2.0,-2.0s0.9,-2.0 2.0,-2.0 2.0,0.9 2.0,2.0 -0.9,2.0 -2.0,2.0zm3.1,-9.0L8.9,8.0L8.9,6.0c0.0,-1.71 1.39,-3.1 3.1,-3.1 1.71,0.0 3.1,1.39 3.1,3.1l0.0,2.0z"/>
diff --git a/res/drawable/ic_password.xml b/res/drawable/ic_password.xml
index 57591c2..7d5f471 100644
--- a/res/drawable/ic_password.xml
+++ b/res/drawable/ic_password.xml
@@ -20,15 +20,15 @@
android:viewportHeight="24.0"
android:viewportWidth="24.0">
<path
- android:fillColor="?attr/suwListItemIconColor"
+ android:fillColor="?attr/sudListItemIconColor"
android:pathData="M21.5,9.39l-1.63,0l0.81,-1.42l-0.86,-0.5l-0.82,1.42l-0.82,-1.42l-0.86,0.5l0.81,1.42l-1.63,0l0,1l1.63,0l-0.81,1.41l0.86,0.5l0.82,-1.41l0.82,1.41l0.86,-0.5l-0.81,-1.41l1.63,0z" />
<path
- android:fillColor="?attr/suwListItemIconColor"
+ android:fillColor="?attr/sudListItemIconColor"
android:pathData="M13.68,7.97l-0.86,-0.5l-0.82,1.42l-0.82,-1.42l-0.86,0.5l0.81,1.42l-1.63,0l0,1l1.63,0l-0.81,1.41l0.86,0.5l0.82,-1.41l0.82,1.41l0.86,-0.5l-0.81,-1.41l1.63,0l0,-1l-1.63,0z" />
<path
- android:fillColor="?attr/suwListItemIconColor"
+ android:fillColor="?attr/sudListItemIconColor"
android:pathData="M6.68,7.97l-0.86,-0.5l-0.82,1.42l-0.82,-1.42l-0.86,0.5l0.81,1.42l-1.63,0l0,1l1.63,0l-0.81,1.41l0.86,0.5l0.82,-1.41l0.82,1.41l0.86,-0.5l-0.81,-1.41l1.63,0l0,-1l-1.63,0z" />
<path
- android:fillColor="?attr/suwListItemIconColor"
+ android:fillColor="?attr/sudListItemIconColor"
android:pathData="M21,17.89H3c-0.28,0 -0.5,-0.22 -0.5,-0.5v-1c0,-0.28 0.22,-0.5 0.5,-0.5h18c0.28,0 0.5,0.22 0.5,0.5v1C21.5,17.66 21.28,17.89 21,17.89z" />
</vector>
diff --git a/res/drawable/ic_pattern.xml b/res/drawable/ic_pattern.xml
index 003111e..b41129f 100644
--- a/res/drawable/ic_pattern.xml
+++ b/res/drawable/ic_pattern.xml
@@ -20,18 +20,18 @@
android:viewportHeight="24.0"
android:viewportWidth="24.0">
<path
- android:fillColor="?attr/suwListItemIconColor"
+ android:fillColor="?attr/sudListItemIconColor"
android:pathData="M4,4m-2,0a2,2 0,1 1,4 0a2,2 0,1 1,-4 0" />
<path
- android:fillColor="?attr/suwListItemIconColor"
+ android:fillColor="?attr/sudListItemIconColor"
android:pathData="M4,12m-2,0a2,2 0,1 1,4 0a2,2 0,1 1,-4 0" />
<path
- android:fillColor="?attr/suwListItemIconColor"
+ android:fillColor="?attr/sudListItemIconColor"
android:pathData="M12,4m-2,0a2,2 0,1 1,4 0a2,2 0,1 1,-4 0" />
<path
- android:fillColor="?attr/suwListItemIconColor"
+ android:fillColor="?attr/sudListItemIconColor"
android:pathData="M20,12m-2,0a2,2 0,1 1,4 0a2,2 0,1 1,-4 0" />
<path
- android:fillColor="?attr/suwListItemIconColor"
+ android:fillColor="?attr/sudListItemIconColor"
android:pathData="M20,18c-0.93,0 -1.7,0.64 -1.93,1.5h-4.14c-0.22,-0.86 -1,-1.5 -1.93,-1.5s-1.7,0.64 -1.93,1.5H5.93c-0.05,-0.18 -0.12,-0.35 -0.21,-0.51l5.28,-5.28C11.29,13.89 11.63,14 12,14c1.1,0 2,-0.9 2,-2c0,-0.37 -0.11,-0.71 -0.28,-1.01l5.28,-5.28C19.29,5.89 19.63,6 20,6c1.1,0 2,-0.9 2,-2s-0.9,-2 -2,-2s-2,0.9 -2,2c0,0.37 0.11,0.71 0.28,1.01l-5.28,5.28C12.71,10.11 12.37,10 12,10c-1.1,0 -2,0.9 -2,2c0,0.37 0.11,0.71 0.28,1.01l-5.28,5.28C4.71,18.11 4.37,18 4,18c-1.1,0 -2,0.9 -2,2s0.9,2 2,2c0.93,0 1.7,-0.64 1.93,-1.5h4.14c0.22,0.86 1,1.5 1.93,1.5s1.7,-0.64 1.93,-1.5h4.14c0.22,0.86 1,1.5 1.93,1.5c1.1,0 2,-0.9 2,-2S21.1,18 20,18z" />
</vector>
diff --git a/res/drawable/ic_pin.xml b/res/drawable/ic_pin.xml
index 0176019..577e04f 100644
--- a/res/drawable/ic_pin.xml
+++ b/res/drawable/ic_pin.xml
@@ -20,6 +20,6 @@
android:viewportHeight="24.0"
android:viewportWidth="24.0">
<path
- android:fillColor="?attr/suwListItemIconColor"
+ android:fillColor="?attr/sudListItemIconColor"
android:pathData="M20,4L4,4A2,2 0,0 0,2 6L2,18a2,2 0,0 0,2 2L20,20a2,2 0,0 0,2 -2L22,6A2,2 0,0 0,20 4ZM7.1,15L5.9,15L5.9,10.2L4.7,10.2L4.7,9L7.1,9v6ZM13.2,11.4A1.2,1.2 0,0 1,12 12.6L10.8,12.6v1.2h2.4L13.2,15L9.6,15L9.6,12.6a1.2,1.2 0,0 1,1.2 -1.2L12,11.4L12,10.2L9.6,10.2L9.6,9L12,9a1.2,1.2 0,0 1,1.2 1.2v1.2ZM19.3,11.1a0.9,0.9 0,0 1,-0.9 0.9,0.9 0.9,0 0,1 0.9,0.9v0.9A1.2,1.2 0,0 1,18.1 15L15.7,15L15.7,13.8h2.4L18.1,12.6L16.9,12.6L16.9,11.4h1.2L18.1,10.2L15.7,10.2L15.7,9h2.4a1.2,1.2 0,0 1,1.2 1.2v0.9Z" />
</vector>
diff --git a/res/drawable/ic_skip.xml b/res/drawable/ic_skip.xml
index 4376215..9d8ae2b 100644
--- a/res/drawable/ic_skip.xml
+++ b/res/drawable/ic_skip.xml
@@ -21,6 +21,6 @@
android:viewportHeight="24"
android:autoMirrored="true">
<path
- android:fillColor="?attr/suwListItemIconColor"
+ android:fillColor="?attr/sudListItemIconColor"
android:pathData="M18.4,10.6C16.55,8.99 14.15,8 11.5,8c-4.65,0 -8.58,3.03 -9.96,7.22L3.9,16c1.05,-3.19 4.05,-5.5 7.6,-5.5 1.95,0 3.73,0.72 5.12,1.88L13,16h9V7l-3.6,3.6z"/>
</vector>
diff --git a/res/drawable/ic_suggested_notifications.xml b/res/drawable/ic_suggested_notifications.xml
index d15d13a..5bce000 100644
--- a/res/drawable/ic_suggested_notifications.xml
+++ b/res/drawable/ic_suggested_notifications.xml
@@ -19,9 +19,9 @@
android:viewportWidth="24.0"
android:viewportHeight="24.0">
<path
- android:fillColor="@color/suw_color_accent_light"
+ android:fillColor="@color/sud_color_accent_light"
android:pathData="M18,17v-6c0,-3.07 -1.63,-5.64 -4.5,-6.32V4c0,-0.83 -0.67,-1.5 -1.5,-1.5S10.5,3.17 10.5,4v0.68C7.64,5.36 6,7.92 6,11v6H4v2h10h0.38H20v-2H18zM16,17H8v-6c0,-2.48 1.51,-4.5 4,-4.5s4,2.02 4,4.5V17z"/>
<path
- android:fillColor="@color/suw_color_accent_light"
+ android:fillColor="@color/sud_color_accent_light"
android:pathData="M12,22c1.1,0 2,-0.9 2,-2h-4C10,21.1 10.9,22 12,22z"/>
</vector>
diff --git a/res/layout-land/choose_lock_pattern.xml b/res/layout-land/choose_lock_pattern.xml
index d2d436f..1cc4352 100644
--- a/res/layout-land/choose_lock_pattern.xml
+++ b/res/layout-land/choose_lock_pattern.xml
@@ -22,7 +22,7 @@
android:layout_height="match_parent"
android:icon="@drawable/ic_lock"
android:layout="@layout/sud_glif_blank_template"
- settings:suwHeaderText="@string/lock_settings_picker_title">
+ settings:sucHeaderText="@string/lock_settings_picker_title">
<com.android.internal.widget.LinearLayoutWithDefaultTouchRecepient
android:id="@+id/topLayout"
@@ -37,18 +37,18 @@
android:layout_width="0dip"
android:layout_height="match_parent"
android:layout_weight="1.0"
- android:layout_marginStart="?attr/suwMarginSides"
- android:layout_marginBottom="@dimen/suw_content_frame_padding_bottom"
+ android:layout_marginStart="?attr/sudMarginSides"
+ android:layout_marginBottom="@dimen/sud_content_frame_padding_bottom"
android:clipChildren="false"
android:clipToPadding="false"
android:orientation="vertical">
<ImageView
- android:id="@+id/suw_layout_icon"
- style="@style/SuwGlifIcon"
+ android:id="@+id/suc_layout_icon"
+ style="@style/SudGlifIcon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
- android:layout_gravity="?attr/suwGlifHeaderGravity"
+ android:layout_gravity="?attr/sudGlifHeaderGravity"
android:layout_marginStart="0dp"
android:layout_marginEnd="0dp"
android:src="@drawable/ic_lock"/>
@@ -65,8 +65,8 @@
android:orientation="vertical">
<TextView
- android:id="@+id/suw_layout_title"
- style="@style/SuwGlifHeaderTitle"
+ android:id="@+id/suc_layout_title"
+ style="@style/SudGlifHeaderTitle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="0dp"
@@ -74,7 +74,7 @@
<TextView
android:id="@+id/message"
- style="@style/SuwDescription.Glif"
+ style="@style/SudDescription.Glif"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:minLines="2" />
@@ -85,16 +85,16 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
- android:gravity="?attr/suwGlifHeaderGravity"
+ android:gravity="?attr/sudGlifHeaderGravity"
android:textSize="18sp"/>
<Button
android:id="@+id/screen_lock_options"
- style="@style/SuwGlifButton.Tertiary"
+ style="@style/SudGlifButton.Tertiary"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
- android:gravity="?attr/suwGlifHeaderGravity"
+ android:gravity="?attr/sudGlifHeaderGravity"
android:text="@string/setup_lock_settings_options_button_label"
android:visibility="gone" />
@@ -122,7 +122,7 @@
<!-- left : skip -->
<Button android:id="@+id/skip_button"
- style="@style/SuwGlifButton.Secondary"
+ style="@style/SudGlifButton.Secondary"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/skip_label"
diff --git a/res/layout-land/confirm_lock_pattern_normal.xml b/res/layout-land/confirm_lock_pattern_normal.xml
index 993a84e..21c9b1e 100644
--- a/res/layout-land/confirm_lock_pattern_normal.xml
+++ b/res/layout-land/confirm_lock_pattern_normal.xml
@@ -40,34 +40,34 @@
android:paddingBottom="24dp">
<ImageView
- android:id="@+id/suw_layout_icon"
- style="@style/SuwGlifIcon"
+ android:id="@+id/suc_layout_icon"
+ style="@style/SudGlifIcon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
- android:layout_gravity="?attr/suwGlifHeaderGravity"
+ android:layout_gravity="?attr/sudGlifHeaderGravity"
android:src="@drawable/ic_lock" />
<TextView
android:id="@+id/headerText"
- style="@style/SuwGlifHeaderTitle"
+ style="@style/SudGlifHeaderTitle"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<TextView
- style="@style/SuwDescription.Glif"
+ style="@style/SudDescription.Glif"
android:id="@+id/detailsText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
- android:layout_marginStart="?attr/suwMarginSides"
- android:layout_marginEnd="?attr/suwMarginSides" />
+ android:layout_marginStart="?attr/sudMarginSides"
+ android:layout_marginEnd="?attr/sudMarginSides" />
<Button
android:id="@+id/cancelButton"
style="@style/SetupWizardButton.Negative"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
- android:layout_marginStart="?attr/suwMarginSides"
- android:layout_marginEnd="?attr/suwMarginSides"
+ android:layout_marginStart="?attr/sudMarginSides"
+ android:layout_marginEnd="?attr/sudMarginSides"
android:text="@string/cancel" />
<Space
@@ -81,8 +81,8 @@
android:id="@+id/errorText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
- android:layout_marginStart="?attr/suwMarginSides"
- android:layout_marginEnd="?attr/suwMarginSides"
+ android:layout_marginStart="?attr/sudMarginSides"
+ android:layout_marginEnd="?attr/sudMarginSides"
android:layout_marginBottom="24dp"
android:gravity="center_vertical"/>
</LinearLayout>
diff --git a/res/layout-land/fingerprint_enroll_enrolling.xml b/res/layout-land/fingerprint_enroll_enrolling.xml
index e71725e..f96bdde 100644
--- a/res/layout-land/fingerprint_enroll_enrolling.xml
+++ b/res/layout-land/fingerprint_enroll_enrolling.xml
@@ -28,7 +28,7 @@
android:layout_height="match_parent"
android:fillViewport="true">
<LinearLayout
- style="@style/SuwContentFrame"
+ style="@style/SudContentFrame"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal"
@@ -42,25 +42,25 @@
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="match_parent"
- android:layout_marginStart="?attr/suwMarginSides"
- android:layout_marginBottom="@dimen/suw_content_frame_padding_bottom"
+ android:layout_marginStart="?attr/sudMarginSides"
+ android:layout_marginBottom="@dimen/sud_content_frame_padding_bottom"
android:clipChildren="false"
android:clipToPadding="false"
android:orientation="vertical">
<ImageView
- android:id="@+id/suw_layout_icon"
- style="@style/SuwGlifIcon"
+ android:id="@+id/suc_layout_icon"
+ style="@style/SudGlifIcon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
- android:layout_gravity="?attr/suwGlifHeaderGravity"
+ android:layout_gravity="?attr/sudGlifHeaderGravity"
android:layout_marginStart="0dp"
android:layout_marginEnd="0dp"
android:src="@drawable/ic_fingerprint_header" />
<TextView
- android:id="@+id/suw_layout_title"
- style="@style/SuwGlifHeaderTitle"
+ android:id="@+id/suc_layout_title"
+ style="@style/SudGlifHeaderTitle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="0dp"
@@ -71,14 +71,14 @@
android:layout_height="wrap_content">
<TextView
- style="@style/SuwDescription.Glif"
+ style="@style/SudDescription.Glif"
android:id="@+id/start_message"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/security_settings_fingerprint_enroll_start_message"/>
<TextView
- style="@style/SuwDescription.Glif"
+ style="@style/SudDescription.Glif"
android:id="@+id/repeat_message"
android:layout_width="match_parent"
android:layout_height="wrap_content"
@@ -94,7 +94,7 @@
<Button
android:id="@+id/skip_button"
- style="@style/SuwGlifButton.Secondary"
+ style="@style/SudGlifButton.Secondary"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/security_settings_fingerprint_enroll_enrolling_skip" />
diff --git a/res/layout-land/fingerprint_enroll_find_sensor.xml b/res/layout-land/fingerprint_enroll_find_sensor.xml
index 0decbf2..f4c97a3 100644
--- a/res/layout-land/fingerprint_enroll_find_sensor.xml
+++ b/res/layout-land/fingerprint_enroll_find_sensor.xml
@@ -34,8 +34,8 @@
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="match_parent"
- android:layout_marginStart="?attr/suwMarginSides"
- android:layout_marginBottom="@dimen/suw_content_frame_padding_bottom"
+ android:layout_marginStart="?attr/sudMarginSides"
+ android:layout_marginBottom="@dimen/sud_content_frame_padding_bottom"
android:clipChildren="false"
android:clipToPadding="false"
android:orientation="vertical">
@@ -55,25 +55,25 @@
android:clipToPadding="false">
<ImageView
- android:id="@+id/suw_layout_icon"
- style="@style/SuwGlifIcon"
+ android:id="@+id/suc_layout_icon"
+ style="@style/SudGlifIcon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
- android:layout_gravity="?attr/suwGlifHeaderGravity"
+ android:layout_gravity="?attr/sudGlifHeaderGravity"
android:layout_marginStart="0dp"
android:layout_marginEnd="0dp"
android:src="@drawable/ic_fingerprint_header" />
<TextView
- android:id="@+id/suw_layout_title"
- style="@style/SuwGlifHeaderTitle"
+ android:id="@+id/suc_layout_title"
+ style="@style/SudGlifHeaderTitle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="0dp"
android:layout_marginEnd="0dp" />
<TextView
- style="@style/SuwDescription.Glif"
+ style="@style/SudDescription.Glif"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/security_settings_fingerprint_enroll_find_sensor_message"/>
diff --git a/res/layout-land/fingerprint_enroll_finish.xml b/res/layout-land/fingerprint_enroll_finish.xml
index 53e430e..7d292c6 100644
--- a/res/layout-land/fingerprint_enroll_finish.xml
+++ b/res/layout-land/fingerprint_enroll_finish.xml
@@ -29,7 +29,7 @@
android:fillViewport="true">
<LinearLayout
- style="@style/SuwContentFrame"
+ style="@style/SudContentFrame"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal"
@@ -45,19 +45,19 @@
android:orientation="vertical">
<ImageView
- android:id="@+id/suw_layout_icon"
- style="@style/SuwGlifIcon"
+ android:id="@+id/suc_layout_icon"
+ style="@style/SudGlifIcon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
- android:layout_gravity="?attr/suwGlifHeaderGravity"
+ android:layout_gravity="?attr/sudGlifHeaderGravity"
android:layout_marginLeft="0dp"
android:layout_marginRight="0dp"
android:contentDescription="@null"
android:src="@drawable/ic_fingerprint_header"/>
<TextView
- android:id="@+id/suw_layout_title"
- style="@style/SuwGlifHeaderTitle"
+ android:id="@+id/suc_layout_title"
+ style="@style/SudGlifHeaderTitle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="0dp"
@@ -65,7 +65,7 @@
<TextView
android:id="@+id/message"
- style="@style/SuwDescription.Glif"
+ style="@style/SudDescription.Glif"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/security_settings_fingerprint_enroll_finish_message"/>
@@ -79,7 +79,7 @@
<ImageView
android:id="@+id/fingerprint_in_app_indicator"
- style="@style/SuwContentIllustration"
+ style="@style/SudContentIllustration"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:contentDescription="@android:string/fingerprint_icon_content_description"
diff --git a/res/layout-land/wifi_dpp_qrcode_scanner_fragment.xml b/res/layout-land/wifi_dpp_qrcode_scanner_fragment.xml
index 21df686..4eed0f6 100644
--- a/res/layout-land/wifi_dpp_qrcode_scanner_fragment.xml
+++ b/res/layout-land/wifi_dpp_qrcode_scanner_fragment.xml
@@ -19,29 +19,40 @@
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/root"
android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:orientation="vertical">
+ android:layout_height="match_parent">
- <include layout="@layout/wifi_dpp_fragment_header"/>
+ <ScrollView
+ android:layout_width="match_parent"
+ android:layout_height="match_parent">
- <com.android.settings.wifi.qrcode.QrPreviewLayout
- android:layout_width="@dimen/qrcode_preview_size"
- android:layout_height="@dimen/qrcode_preview_size"
- android:layout_gravity="center">
- <TextureView
- android:id="@+id/preview_view"
- android:layout_width="wrap_content"
- android:layout_height="match_parent"/>
- <com.android.settings.wifi.qrcode.QrDecorateView
- android:id="@+id/decorate_view"
- android:layout_width="wrap_content"
- android:layout_height="match_parent"/>
- </com.android.settings.wifi.qrcode.QrPreviewLayout>
+ <LinearLayout
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:orientation="vertical"
+ android:gravity="center_horizontal">
- <TextView android:id="@+id/error_message"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_gravity="center"/>
+ <include layout="@layout/wifi_dpp_fragment_header"/>
+
+ <com.android.settings.wifi.qrcode.QrPreviewLayout
+ android:layout_width="@dimen/qrcode_preview_size"
+ android:layout_height="@dimen/qrcode_preview_size">
+ <TextureView
+ android:id="@+id/preview_view"
+ android:layout_width="wrap_content"
+ android:layout_height="match_parent"/>
+ <com.android.settings.wifi.qrcode.QrDecorateView
+ android:id="@+id/decorate_view"
+ android:layout_width="wrap_content"
+ android:layout_height="match_parent"/>
+ </com.android.settings.wifi.qrcode.QrPreviewLayout>
+
+ <TextView android:id="@+id/error_message"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"/>
+
+ </LinearLayout>
+
+ </ScrollView>
</LinearLayout>
diff --git a/res/layout/band_mode.xml b/res/layout/band_mode.xml
index ddbc7ae..b43dd1d 100644
--- a/res/layout/band_mode.xml
+++ b/res/layout/band_mode.xml
@@ -19,7 +19,7 @@
android:padding="4dip"
android:gravity="center_horizontal"
android:layout_width="match_parent"
- android:layout_height="match_parent">
+ android:layout_height="wrap_content">
<ListView android:id="@+id/band"
android:layout_width="match_parent"
diff --git a/res/layout/battery_header.xml b/res/layout/battery_header.xml
index d6ecafa..b3b699a 100644
--- a/res/layout/battery_header.xml
+++ b/res/layout/battery_header.xml
@@ -22,15 +22,12 @@
android:layout_height="match_parent"
android:layout_gravity="center"
android:orientation="horizontal"
- android:paddingTop="24dp"
- android:paddingBottom="24dp"
style="@style/EntityHeader">
<LinearLayout
- android:layout_width="0dp"
+ android:layout_width="170dp"
android:layout_height="wrap_content"
- android:layout_weight="1"
- android:layout_marginStart="56dp"
+ android:layout_marginStart="72dp"
android:layout_marginEnd="8dp"
android:orientation="vertical">
@@ -39,8 +36,8 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="12dp"
- android:fontFamily="@*android:string/config_headlineFontFamily"
- android:textAppearance="@*android:style/TextAppearance.DeviceDefault.Display1"/>
+ android:textAppearance="@style/TextAppearance.EntityHeaderTitle"
+ android:textSize="36sp" />
<TextView
android:id="@+id/summary1"
@@ -49,19 +46,20 @@
android:layout_marginTop="8dp"
android:minLines="2"
android:textAppearance="@android:style/TextAppearance.DeviceDefault.Small"/>
+ android:textColor="?android:attr/textColorPrimary"/>
<TextView
android:id="@+id/summary2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textAppearance="@android:style/TextAppearance.DeviceDefault.Small"/>
-
+ android:textColor="?android:attr/textColorPrimary"/>
</LinearLayout>
<com.android.settings.fuelgauge.BatteryMeterView
android:id="@+id/battery_header_icon"
- android:layout_width="@dimen/battery_meter_width"
+ android:layout_width="match_parent"
android:layout_height="@dimen/battery_meter_height"
- android:layout_marginEnd="16dp"/>
+ android:layout_gravity="center"/>
</LinearLayout>
\ No newline at end of file
diff --git a/res/layout/choose_lock_password.xml b/res/layout/choose_lock_password.xml
index 1962ee0..68583b5 100644
--- a/res/layout/choose_lock_password.xml
+++ b/res/layout/choose_lock_password.xml
@@ -22,10 +22,10 @@
android:icon="@drawable/ic_lock"
android:importantForAutofill="noExcludeDescendants"
settings:sucFooter="@layout/choose_lock_password_footer"
- settings:suwHeaderText="@string/lockpassword_choose_your_screen_lock_header">
+ settings:sucHeaderText="@string/lockpassword_choose_your_screen_lock_header">
<LinearLayout
- style="@style/SuwContentFrame"
+ style="@style/SudContentFrame"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:clipChildren="false"
@@ -35,7 +35,7 @@
<TextView
android:id="@+id/message"
- style="@style/SuwDescription.Glif"
+ style="@style/SudDescription.Glif"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:minLines="2"/>
@@ -71,7 +71,7 @@
<Button
android:id="@+id/screen_lock_options"
- style="@style/SuwGlifButton.Tertiary"
+ style="@style/SudGlifButton.Tertiary"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/setup_lock_settings_options_button_label"
diff --git a/res/layout/choose_lock_password_footer.xml b/res/layout/choose_lock_password_footer.xml
index 0b7791c..58d80cf 100644
--- a/res/layout/choose_lock_password_footer.xml
+++ b/res/layout/choose_lock_password_footer.xml
@@ -17,13 +17,13 @@
<!-- TODO: Use aapt:attr when it is fixed (b/36809755) -->
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
- style="@style/SuwGlifButtonBar"
+ style="@style/SudGlifButtonBar"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<!-- left : skip -->
<Button android:id="@+id/skip_button"
- style="@style/SuwGlifButton.Secondary"
+ style="@style/SudGlifButton.Secondary"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/skip_label"
@@ -32,7 +32,7 @@
<!-- left : clear -->
<Button android:id="@+id/clear_button"
- style="@style/SuwGlifButton.Secondary"
+ style="@style/SudGlifButton.Secondary"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:visibility="gone"
@@ -45,7 +45,7 @@
<!-- right : continue -->
<Button android:id="@+id/next_button"
- style="@style/SuwGlifButton.Primary"
+ style="@style/SudGlifButton.Primary"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/next_label" />
diff --git a/res/layout/choose_lock_pattern_common.xml b/res/layout/choose_lock_pattern_common.xml
index 6d64b88..b31062e 100644
--- a/res/layout/choose_lock_pattern_common.xml
+++ b/res/layout/choose_lock_pattern_common.xml
@@ -24,7 +24,7 @@
android:icon="@drawable/ic_lock"
android:layout="@layout/sud_glif_blank_template"
settings:sucFooter="@layout/choose_lock_pattern_common_footer"
- settings:suwHeaderText="@string/lockpassword_choose_your_screen_lock_header">
+ settings:sucHeaderText="@string/lockpassword_choose_your_screen_lock_header">
<com.android.internal.widget.LinearLayoutWithDefaultTouchRecepient
android:id="@+id/topLayout"
@@ -35,21 +35,21 @@
android:orientation="vertical">
<LinearLayout
- style="@style/SuwGlifHeaderContainer"
+ style="@style/SudGlifHeaderContainer"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<ImageView
- android:id="@+id/suw_layout_icon"
- style="@style/SuwGlifIcon"
+ android:id="@+id/suc_layout_icon"
+ style="@style/SudGlifIcon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/ic_lock" />
<TextView
- android:id="@+id/suw_layout_title"
- style="@style/SuwGlifHeaderTitle"
+ android:id="@+id/suc_layout_title"
+ style="@style/SudGlifHeaderTitle"
android:accessibilityLiveRegion="polite"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
@@ -58,7 +58,7 @@
<!-- takes up all space above button bar at bottom -->
<LinearLayout
- style="@style/SuwContentFrame"
+ style="@style/SudContentFrame"
android:layout_width="match_parent"
android:layout_height="0dip"
android:layout_weight="1"
@@ -71,10 +71,10 @@
<TextView
android:id="@+id/message"
- style="@style/SuwDescription.Glif"
+ style="@style/SudDescription.Glif"
android:layout_width="match_parent"
android:layout_height="wrap_content"
- android:layout_marginHorizontal="?attr/suwMarginSides"
+ android:layout_marginHorizontal="?attr/sudMarginSides"
android:minLines="2" />
<TextView android:id="@+id/headerText"
@@ -82,7 +82,7 @@
android:layout_height="wrap_content"
android:minLines="2"
android:gravity="center"
- android:paddingHorizontal="?attr/suwMarginSides"
+ android:paddingHorizontal="?attr/sudMarginSides"
android:textSize="12sp" />
<com.google.android.setupdesign.view.FillContentLayout
@@ -111,7 +111,7 @@
<Button
android:id="@+id/screen_lock_options"
- style="@style/SuwGlifButton.Tertiary"
+ style="@style/SudGlifButton.Tertiary"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/setup_lock_settings_options_button_label"
diff --git a/res/layout/choose_lock_pattern_common_footer.xml b/res/layout/choose_lock_pattern_common_footer.xml
index b0397ea..b582854 100644
--- a/res/layout/choose_lock_pattern_common_footer.xml
+++ b/res/layout/choose_lock_pattern_common_footer.xml
@@ -18,13 +18,13 @@
<!-- TODO: Use aapt:attr when it is fixed (b/36809755) -->
<com.google.android.setupdesign.view.ButtonBarLayout
xmlns:android="http://schemas.android.com/apk/res/android"
- style="@style/SuwGlifButtonBar.Stackable"
+ style="@style/SudGlifButtonBar.Stackable"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<!-- left : skip -->
<Button android:id="@+id/skip_button"
- style="@style/SuwGlifButton.Secondary"
+ style="@style/SudGlifButton.Secondary"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/skip_label"
@@ -32,7 +32,7 @@
<!-- left : retry -->
<Button android:id="@+id/footerLeftButton"
- style="@style/SuwGlifButton.Secondary"
+ style="@style/SudGlifButton.Secondary"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/lockpattern_tutorial_cancel_label" />
@@ -44,7 +44,7 @@
<!-- right : confirm or ok -->
<Button android:id="@+id/footerRightButton"
- style="@style/SuwGlifButton.Primary"
+ style="@style/SudGlifButton.Primary"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/lockpattern_tutorial_continue_label" />
diff --git a/res/layout/confirm_lock_password_normal.xml b/res/layout/confirm_lock_password_normal.xml
index 44d96e0..7b04127 100644
--- a/res/layout/confirm_lock_password_normal.xml
+++ b/res/layout/confirm_lock_password_normal.xml
@@ -29,11 +29,11 @@
<TextView
android:id="@+id/detailsText"
- style="@style/SuwDescription.Glif"
+ style="@style/SudDescription.Glif"
android:layout_width="match_parent"
android:layout_height="wrap_content"
- android:layout_marginStart="?attr/suwMarginSides"
- android:layout_marginEnd="?attr/suwMarginSides" />
+ android:layout_marginStart="?attr/sudMarginSides"
+ android:layout_marginEnd="?attr/sudMarginSides" />
<Space
android:layout_width="match_parent"
@@ -72,11 +72,11 @@
<Button
android:id="@+id/cancelButton"
- style="@style/SuwGlifButton.Secondary"
+ style="@style/SudGlifButton.Secondary"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
- android:layout_marginStart="?attr/suwMarginSides"
- android:layout_marginEnd="?attr/suwMarginSides"
+ android:layout_marginStart="?attr/sudMarginSides"
+ android:layout_marginEnd="?attr/sudMarginSides"
android:layout_marginBottom="80dp"
android:layout_gravity="center_horizontal"
android:text="@string/cancel" />
diff --git a/res/layout/confirm_lock_pattern_normal_base.xml b/res/layout/confirm_lock_pattern_normal_base.xml
index 8cf8f87..a08d516 100644
--- a/res/layout/confirm_lock_pattern_normal_base.xml
+++ b/res/layout/confirm_lock_pattern_normal_base.xml
@@ -33,31 +33,31 @@
android:orientation="vertical">
<ImageView
- android:id="@+id/suw_layout_icon"
- style="@style/SuwGlifIcon"
+ android:id="@+id/suc_layout_icon"
+ style="@style/SudGlifIcon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
- android:layout_gravity="?attr/suwGlifHeaderGravity"
+ android:layout_gravity="?attr/sudGlifHeaderGravity"
android:src="@drawable/ic_lock" />
<TextView
android:id="@+id/headerText"
- style="@style/SuwGlifHeaderTitle"
+ style="@style/SudGlifHeaderTitle"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<TextView
- style="@style/SuwDescription.Glif"
+ style="@style/SudDescription.Glif"
android:id="@+id/detailsText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
- android:layout_marginStart="?attr/suwMarginSides"
- android:layout_marginEnd="?attr/suwMarginSides" />
+ android:layout_marginStart="?attr/sudMarginSides"
+ android:layout_marginEnd="?attr/sudMarginSides" />
</LinearLayout>
<LinearLayout
- style="@style/SuwContentFrame"
+ style="@style/SudContentFrame"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
@@ -86,17 +86,17 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
- android:layout_marginHorizontal="?attr/suwMarginSides"
+ android:layout_marginHorizontal="?attr/sudMarginSides"
android:layout_marginTop="12dp"
android:gravity="center_vertical"/>
<Button
android:id="@+id/cancelButton"
- style="@style/SuwGlifButton.Secondary"
+ style="@style/SudGlifButton.Secondary"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
- android:layout_marginStart="?attr/suwMarginSides"
- android:layout_marginEnd="?attr/suwMarginSides"
+ android:layout_marginStart="?attr/sudMarginSides"
+ android:layout_marginEnd="?attr/sudMarginSides"
android:layout_marginBottom="80dp"
android:text="@string/cancel" />
diff --git a/res/layout/encryption_interstitial.xml b/res/layout/encryption_interstitial.xml
index 5acc7b1..3e227cb1 100644
--- a/res/layout/encryption_interstitial.xml
+++ b/res/layout/encryption_interstitial.xml
@@ -23,7 +23,7 @@
android:icon="@drawable/ic_lock">
<LinearLayout
- style="@style/SuwContentFrame"
+ style="@style/SudContentFrame"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:clipChildren="false"
@@ -32,7 +32,7 @@
<TextView
android:id="@+id/encryption_message"
- style="@style/SuwDescription.Glif"
+ style="@style/SudDescription.Glif"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
diff --git a/res/layout/face_enroll_enrolling.xml b/res/layout/face_enroll_enrolling.xml
index 38a26a2..e7af493 100644
--- a/res/layout/face_enroll_enrolling.xml
+++ b/res/layout/face_enroll_enrolling.xml
@@ -24,7 +24,7 @@
style="?attr/face_layout_theme">
<LinearLayout
- style="@style/SuwContentFrame"
+ style="@style/SudContentFrame"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
diff --git a/res/layout/face_enroll_finish.xml b/res/layout/face_enroll_finish.xml
index df46098..62176a7 100644
--- a/res/layout/face_enroll_finish.xml
+++ b/res/layout/face_enroll_finish.xml
@@ -24,7 +24,7 @@
android:layout_height="match_parent">
<LinearLayout
- style="@style/SuwContentFrame"
+ style="@style/SudContentFrame"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
@@ -44,7 +44,7 @@
android:layout_weight="1">
<ImageView
- style="@style/SuwContentIllustration"
+ style="@style/SudContentIllustration"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:contentDescription="@null"
diff --git a/res/layout/face_enroll_introduction.xml b/res/layout/face_enroll_introduction.xml
index df3cf72..69b00fe 100644
--- a/res/layout/face_enroll_introduction.xml
+++ b/res/layout/face_enroll_introduction.xml
@@ -25,7 +25,7 @@
android:layout_height="match_parent">
<LinearLayout
- style="@style/SuwContentFrame"
+ style="@style/SudContentFrame"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:clipChildren="false"
@@ -34,14 +34,14 @@
<com.google.android.setupdesign.view.RichTextView
android:id="@+id/description_text"
- style="@style/SuwDescription.Glif"
+ style="@style/SudDescription.Glif"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/security_settings_face_enroll_introduction_message" />
<com.google.android.setupdesign.view.RichTextView
android:id="@+id/error_text"
- style="@style/SuwDescription.Glif"
+ style="@style/SudDescription.Glif"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
@@ -51,7 +51,7 @@
android:layout_weight="1">
<ImageView
- style="@style/SuwContentIllustration"
+ style="@style/SudContentIllustration"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:contentDescription="@null"
@@ -65,7 +65,7 @@
android:layout_gravity="center">
<Button
android:id="@+id/accessibility_button"
- style="@style/SuwGlifButton.Secondary"
+ style="@style/SudGlifButton.Secondary"
android:layout_gravity="center"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
diff --git a/res/layout/fingerprint_enroll_enrolling_base.xml b/res/layout/fingerprint_enroll_enrolling_base.xml
index 4439b08..3a476fa 100644
--- a/res/layout/fingerprint_enroll_enrolling_base.xml
+++ b/res/layout/fingerprint_enroll_enrolling_base.xml
@@ -24,7 +24,7 @@
style="?attr/fingerprint_layout_theme">
<LinearLayout
- style="@style/SuwContentFrame"
+ style="@style/SudContentFrame"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
@@ -38,7 +38,7 @@
android:layout_height="wrap_content">
<TextView
- style="@style/SuwDescription.Glif"
+ style="@style/SudDescription.Glif"
android:id="@+id/start_message"
android:layout_width="match_parent"
android:layout_height="wrap_content"
@@ -46,7 +46,7 @@
android:text="@string/security_settings_fingerprint_enroll_start_message"/>
<TextView
- style="@style/SuwDescription.Glif"
+ style="@style/SudDescription.Glif"
android:id="@+id/repeat_message"
android:layout_width="match_parent"
android:layout_height="wrap_content"
diff --git a/res/layout/fingerprint_enroll_find_sensor_base.xml b/res/layout/fingerprint_enroll_find_sensor_base.xml
index 56d3ea4..c03ac5a 100644
--- a/res/layout/fingerprint_enroll_find_sensor_base.xml
+++ b/res/layout/fingerprint_enroll_find_sensor_base.xml
@@ -31,7 +31,7 @@
android:clipChildren="false">
<LinearLayout
- style="@style/SuwContentFrame"
+ style="@style/SudContentFrame"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
@@ -39,10 +39,10 @@
android:clipChildren="false">
<TextView
- style="@style/SuwDescription.Glif"
+ style="@style/SudDescription.Glif"
android:layout_width="match_parent"
android:layout_height="wrap_content"
- android:layout_marginTop="@dimen/suw_description_glif_margin_top"
+ android:layout_marginTop="@dimen/sud_description_glif_margin_top"
android:text="@string/security_settings_fingerprint_enroll_find_sensor_message"/>
</LinearLayout>
diff --git a/res/layout/fingerprint_enroll_finish_base.xml b/res/layout/fingerprint_enroll_finish_base.xml
index 1849f51..2fa5da6 100644
--- a/res/layout/fingerprint_enroll_finish_base.xml
+++ b/res/layout/fingerprint_enroll_finish_base.xml
@@ -24,7 +24,7 @@
android:layout_height="match_parent">
<LinearLayout
- style="@style/SuwContentFrame"
+ style="@style/SudContentFrame"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
@@ -33,10 +33,10 @@
<TextView
android:id="@+id/message"
- style="@style/SuwDescription.Glif"
+ style="@style/SudDescription.Glif"
android:layout_width="match_parent"
android:layout_height="wrap_content"
- android:layout_marginTop="@dimen/suw_description_glif_margin_top"
+ android:layout_marginTop="@dimen/sud_description_glif_margin_top"
android:minLines="3"
android:text="@string/security_settings_fingerprint_enroll_finish_message"/>
@@ -57,7 +57,7 @@
<ImageView
android:id="@+id/fingerprint_in_app_indicator"
- style="@style/SuwContentIllustration"
+ style="@style/SudContentIllustration"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="7dp"
diff --git a/res/layout/fingerprint_enroll_introduction.xml b/res/layout/fingerprint_enroll_introduction.xml
index adb46e5..4ee7057 100644
--- a/res/layout/fingerprint_enroll_introduction.xml
+++ b/res/layout/fingerprint_enroll_introduction.xml
@@ -24,7 +24,7 @@
android:layout_height="match_parent">
<LinearLayout
- style="@style/SuwContentFrame"
+ style="@style/SudContentFrame"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:clipChildren="false"
@@ -33,14 +33,14 @@
<com.google.android.setupdesign.view.RichTextView
android:id="@+id/description_text"
- style="@style/SuwDescription.Glif"
+ style="@style/SudDescription.Glif"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/security_settings_fingerprint_enroll_introduction_message" />
<com.google.android.setupdesign.view.RichTextView
android:id="@+id/error_text"
- style="@style/SuwDescription.Glif"
+ style="@style/SudDescription.Glif"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
@@ -50,7 +50,7 @@
android:layout_weight="1">
<ImageView
- style="@style/SuwContentIllustration"
+ style="@style/SudContentIllustration"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:contentDescription="@null"
diff --git a/res/layout/homepage_dismissal_view.xml b/res/layout/homepage_dismissal_view.xml
index e60b375..7d1abf3 100644
--- a/res/layout/homepage_dismissal_view.xml
+++ b/res/layout/homepage_dismissal_view.xml
@@ -20,6 +20,7 @@
android:id="@+id/dismissal_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
+ android:background="@color/homepage_card_dismissal_background"
android:orientation="vertical">
<TextView
@@ -40,6 +41,7 @@
style="@style/ContextualCardDismissalButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
+ android:layout_marginBottom="@dimen/homepage_card_dismissal_margin_bottom"
android:text="@string/contextual_card_dismiss_keep"/>
<Button
@@ -47,6 +49,7 @@
style="@style/ContextualCardDismissalButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
+ android:layout_marginBottom="@dimen/homepage_card_dismissal_margin_bottom"
android:text="@string/contextual_card_dismiss_remove"/>
</LinearLayout>
diff --git a/res/layout/homepage_slice_half_tile.xml b/res/layout/homepage_slice_half_tile.xml
index 7de9eb6..46f3cda 100644
--- a/res/layout/homepage_slice_half_tile.xml
+++ b/res/layout/homepage_slice_half_tile.xml
@@ -24,12 +24,12 @@
<ViewFlipper
android:id="@+id/view_flipper"
android:layout_width="match_parent"
- android:layout_height="wrap_content">
+ android:layout_height="match_parent">
<LinearLayout
android:id="@+id/content"
android:layout_width="match_parent"
- android:layout_height="wrap_content"
+ android:layout_height="match_parent"
android:paddingStart="@dimen/homepage_card_padding_start"
android:paddingEnd="@dimen/homepage_card_padding_end"
android:paddingTop="@dimen/homepage_half_card_padding_top"
diff --git a/res/layout/homepage_slice_tile.xml b/res/layout/homepage_slice_tile.xml
index 9fa7d61..2b7c1b0 100644
--- a/res/layout/homepage_slice_tile.xml
+++ b/res/layout/homepage_slice_tile.xml
@@ -30,6 +30,7 @@
android:id="@+id/slice_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
+ android:layout_gravity="center_vertical"
android:paddingStart="@dimen/homepage_card_padding_start"
android:paddingEnd="@dimen/homepage_card_padding_end"/>
diff --git a/res/layout/manage_applications_apps.xml b/res/layout/manage_applications_apps.xml
index 765ced6..c2f58c3 100644
--- a/res/layout/manage_applications_apps.xml
+++ b/res/layout/manage_applications_apps.xml
@@ -14,60 +14,73 @@
limitations under the License.
-->
-<LinearLayout
+<androidx.coordinatorlayout.widget.CoordinatorLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:settings="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
- <FrameLayout
+ <androidx.core.widget.NestedScrollView
android:layout_width="match_parent"
- android:layout_height="0dp"
- android:layout_weight="1">
+ android:layout_height="match_parent"
+ android:fillViewport="true"
+ settings:layout_behavior="com.android.settings.widget.FloatingAppBarScrollingViewBehavior">
- <LinearLayout
- android:id="@+id/list_container"
+ <FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
- android:orientation="vertical"
- android:visibility="gone">
+ android:paddingTop="@dimen/app_bar_height">
- <FrameLayout
- android:id="@+id/pinned_header"
+ <LinearLayout
+ android:id="@+id/list_container"
android:layout_width="match_parent"
- android:layout_height="wrap_content" />
+ android:layout_height="match_parent"
+ android:orientation="vertical"
+ android:visibility="gone">
- <FrameLayout
- android:layout_width="match_parent"
- android:layout_height="0px"
- android:layout_weight="1">
-
- <androidx.recyclerview.widget.RecyclerView
- android:id="@+id/apps_list"
+ <FrameLayout
android:layout_width="match_parent"
- android:layout_height="match_parent"
- settings:fastScrollEnabled="true"
- settings:fastScrollHorizontalThumbDrawable="@drawable/thumb_drawable"
- settings:fastScrollHorizontalTrackDrawable="@drawable/line_drawable"
- settings:fastScrollVerticalThumbDrawable="@drawable/thumb_drawable"
- settings:fastScrollVerticalTrackDrawable="@drawable/line_drawable"/>
+ android:layout_height="match_parent">
- <TextView
- android:id="@android:id/empty"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:gravity="center"
- android:text="@string/no_applications"
- android:textAppearance="?android:attr/textAppearanceLarge"
- android:visibility="invisible" />
+ <androidx.recyclerview.widget.RecyclerView
+ android:id="@+id/apps_list"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ settings:fastScrollEnabled="true"
+ settings:fastScrollHorizontalThumbDrawable="@drawable/thumb_drawable"
+ settings:fastScrollHorizontalTrackDrawable="@drawable/line_drawable"
+ settings:fastScrollVerticalThumbDrawable="@drawable/thumb_drawable"
+ settings:fastScrollVerticalTrackDrawable="@drawable/line_drawable"/>
- </FrameLayout>
+ <TextView
+ android:id="@android:id/empty"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:gravity="center"
+ android:layout_gravity="center"
+ android:text="@string/no_applications"
+ android:textAppearance="?android:attr/textAppearanceLarge"
+ android:visibility="invisible"/>
- </LinearLayout>
+ </FrameLayout>
- <include layout="@layout/loading_container" />
+ </LinearLayout>
- </FrameLayout>
+ <include layout="@layout/loading_container"/>
-</LinearLayout>
+ </FrameLayout>
+
+ </androidx.core.widget.NestedScrollView>
+
+ <com.google.android.material.appbar.AppBarLayout
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content">
+ <FrameLayout
+ android:id="@+id/pinned_header"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ settings:layout_scrollFlags="scroll|enterAlways"/>
+ </com.google.android.material.appbar.AppBarLayout>
+
+</androidx.coordinatorlayout.widget.CoordinatorLayout>
diff --git a/res/layout/master_clear.xml b/res/layout/master_clear.xml
index 83b02ff..9c1dd80 100644
--- a/res/layout/master_clear.xml
+++ b/res/layout/master_clear.xml
@@ -21,9 +21,9 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
- android:theme="@style/SuwThemeGlifV3.DayNight"
+ android:theme="@style/SudThemeGlifV3.DayNight"
android:icon="@drawable/ic_delete_accent"
- app:suwHeaderText="@string/master_clear_title">
+ app:sucHeaderText="@string/master_clear_title">
<ScrollView
android:id="@+id/master_clear_scrollview"
@@ -34,33 +34,33 @@
<LinearLayout
android:id="@+id/master_clear_container"
- style="@style/SuwContentFrame"
+ style="@style/SudContentFrame"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
- style="@style/TextAppearance.SuwGlifItemSummary"
+ style="@style/TextAppearance.SudGlifItemSummary"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/master_clear_desc"/>
<TextView
android:id="@+id/also_erases_external"
- style="@style/TextAppearance.SuwGlifItemSummary"
+ style="@style/TextAppearance.SudGlifItemSummary"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:visibility="gone"
android:text="@string/master_clear_desc_also_erases_external"/>
<TextView
android:id="@+id/also_erases_esim"
- style="@style/TextAppearance.SuwGlifItemSummary"
+ style="@style/TextAppearance.SudGlifItemSummary"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:visibility="gone"
android:text="@string/master_clear_desc_also_erases_esim"/>
<TextView
android:id="@+id/accounts_label"
- style="@style/TextAppearance.SuwGlifItemSummary"
+ style="@style/TextAppearance.SudGlifItemSummary"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:visibility="gone"
@@ -76,21 +76,21 @@
</LinearLayout>
<TextView
android:id="@+id/other_users_present"
- style="@style/TextAppearance.SuwGlifItemSummary"
+ style="@style/TextAppearance.SudGlifItemSummary"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:visibility="gone"
android:text="@string/master_clear_other_users_present"/>
<TextView
android:id="@+id/no_cancel_mobile_plan"
- style="@style/TextAppearance.SuwGlifItemSummary"
+ style="@style/TextAppearance.SudGlifItemSummary"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:visibility="gone"
android:text="@string/master_clear_desc_no_cancel_mobile_plan"/>
<TextView
android:id="@+id/erase_external_option_text"
- style="@style/TextAppearance.SuwGlifItemSummary"
+ style="@style/TextAppearance.SudGlifItemSummary"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/master_clear_desc_erase_external_storage"/>
@@ -103,7 +103,7 @@
android:clickable="true">
<CheckBox
android:id="@+id/erase_external"
- style="@style/SuwCheckBox"
+ style="@style/SudCheckBox"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
@@ -116,12 +116,12 @@
android:layout_gravity="center_vertical"
android:orientation="vertical">
<TextView
- style="@style/TextAppearance.SuwGlifItemTitle"
+ style="@style/TextAppearance.SudGlifItemTitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/erase_external_storage"/>
<TextView
- style="@style/TextAppearance.SuwGlifItemSummary"
+ style="@style/TextAppearance.SudGlifItemSummary"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/erase_external_storage_description"/>
diff --git a/res/layout/master_clear_account.xml b/res/layout/master_clear_account.xml
index 0b522f2..f95a44f 100644
--- a/res/layout/master_clear_account.xml
+++ b/res/layout/master_clear_account.xml
@@ -20,7 +20,7 @@
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:orientation="horizontal"
- style="@style/SuwDescription.Glif" >
+ style="@style/SudDescription.Glif" >
<ImageView
android:id="@android:id/icon"
android:layout_width="56dp"
@@ -30,6 +30,6 @@
android:id="@android:id/title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
- style="@style/TextAppearance.SuwGlifItemSummary"/>
+ style="@style/TextAppearance.SudGlifItemSummary"/>
</LinearLayout>
diff --git a/res/layout/master_clear_confirm.xml b/res/layout/master_clear_confirm.xml
index 2acdfce..b4c0270 100644
--- a/res/layout/master_clear_confirm.xml
+++ b/res/layout/master_clear_confirm.xml
@@ -19,20 +19,20 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
- android:theme="@style/SuwThemeGlifV3.DayNight"
+ android:theme="@style/SudThemeGlifV3.DayNight"
android:id="@+id/setup_wizard_layout"
android:icon="@drawable/ic_delete_accent"
- app:suwHeaderText="@string/master_clear_confirm_title">
+ app:sucHeaderText="@string/master_clear_confirm_title">
<LinearLayout
- style="@style/SuwContentFrame"
+ style="@style/SudContentFrame"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:id="@+id/master_clear_confirm"
- style="@style/SuwItemTitle.GlifDescription"
+ style="@style/SudItemTitle.GlifDescription"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/master_clear_final_desc"/>
diff --git a/res/layout/password_requirement_item.xml b/res/layout/password_requirement_item.xml
index 8080f10..ff7e04c 100644
--- a/res/layout/password_requirement_item.xml
+++ b/res/layout/password_requirement_item.xml
@@ -18,5 +18,5 @@
android:id="@+id/description_text"
android:layout_width="match_parent"
android:layout_height="wrap_content"
- android:gravity="?attr/suwGlifHeaderGravity"
+ android:gravity="?attr/sudGlifHeaderGravity"
android:textSize="14sp"/>
diff --git a/res/layout/redaction_interstitial.xml b/res/layout/redaction_interstitial.xml
index ab7e0b3..f911572 100644
--- a/res/layout/redaction_interstitial.xml
+++ b/res/layout/redaction_interstitial.xml
@@ -22,10 +22,10 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
android:icon="@drawable/ic_suggested_notifications"
- settings:suwHeaderText="@string/lock_screen_notifications_interstitial_title">
+ settings:sucHeaderText="@string/lock_screen_notifications_interstitial_title">
<LinearLayout
- style="@style/SuwContentFrame"
+ style="@style/SudContentFrame"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:clipChildren="false"
@@ -34,7 +34,7 @@
<TextView
android:id="@+id/message"
- style="@style/SuwDescription.Glif"
+ style="@style/SudDescription.Glif"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/lock_screen_notifications_interstitial_message" />
@@ -48,7 +48,7 @@
<com.android.settings.RestrictedRadioButton
android:id="@+id/show_all"
- style="@style/SuwRadioButton"
+ style="@style/SudRadioButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="0dp"
@@ -57,7 +57,7 @@
<com.android.settings.RestrictedRadioButton
android:id="@+id/redact_sensitive"
- style="@style/SuwRadioButton"
+ style="@style/SudRadioButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="0dp"
@@ -66,7 +66,7 @@
<RadioButton
android:id="@+id/hide_all"
- style="@style/SuwRadioButton"
+ style="@style/SudRadioButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="0dp"
diff --git a/res/layout/reset_esim_checkbox.xml b/res/layout/reset_esim_checkbox.xml
index e2ae4bb..2195435 100644
--- a/res/layout/reset_esim_checkbox.xml
+++ b/res/layout/reset_esim_checkbox.xml
@@ -15,7 +15,7 @@
-->
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
- style="@style/SuwDescription"
+ style="@style/SudDescription"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
@@ -25,7 +25,7 @@
<CheckBox
android:id="@+id/erase_esim"
- style="@style/SuwCheckBox"
+ style="@style/SudCheckBox"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
@@ -42,12 +42,12 @@
<TextView
android:id="@+id/erase_esim_title"
- style="@style/TextAppearance.SuwGlifItemTitle"
+ style="@style/TextAppearance.SudGlifItemTitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<TextView
- style="@style/TextAppearance.SuwGlifItemSummary"
+ style="@style/TextAppearance.SudGlifItemSummary"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/reset_esim_desc"/>
diff --git a/res/layout/settings_homepage_container.xml b/res/layout/settings_homepage_container.xml
index 75d449f..1e5bdce 100644
--- a/res/layout/settings_homepage_container.xml
+++ b/res/layout/settings_homepage_container.xml
@@ -31,8 +31,9 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
- android:paddingTop="@dimen/app_bar_height"
- android:descendantFocusability="blocksDescendants">
+ android:descendantFocusability="blocksDescendants"
+ android:paddingTop="104dp">
+ <!-- height of status bar(24dp) + height of action bar(48dp) + top/bottom margins(16dp) -->
<FrameLayout
android:id="@+id/contextual_cards_content"
@@ -52,6 +53,13 @@
<com.google.android.material.appbar.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
+
+ <Space
+ android:layout_width="match_parent"
+ android:layout_height="@*android:dimen/status_bar_height"
+ android:background="@android:color/transparent"
+ app:layout_scrollFlags="scroll|enterAlways"/>
+
<include layout="@layout/search_bar"/>
</com.google.android.material.appbar.AppBarLayout>
</androidx.coordinatorlayout.widget.CoordinatorLayout>
diff --git a/res/layout/setup_choose_lock_generic_biometrics_header.xml b/res/layout/setup_choose_lock_generic_biometrics_header.xml
index ca808e8..daeeedd 100644
--- a/res/layout/setup_choose_lock_generic_biometrics_header.xml
+++ b/res/layout/setup_choose_lock_generic_biometrics_header.xml
@@ -16,11 +16,11 @@
-->
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
- style="@style/SuwDescription.Glif"
+ style="@style/SudDescription.Glif"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingStart="?android:attr/listPreferredItemPaddingStart"
android:paddingEnd="?android:attr/listPreferredItemPaddingEnd"
- android:paddingTop="@dimen/suw_description_glif_margin_top"
- android:paddingBottom="@dimen/suw_description_glif_margin_bottom_lists"
+ android:paddingTop="@dimen/sud_description_glif_margin_top"
+ android:paddingBottom="@dimen/sud_description_glif_margin_bottom_lists"
android:text="@string/lock_settings_picker_biometrics_added_security_message" />
diff --git a/res/layout/setup_choose_lock_generic_header.xml b/res/layout/setup_choose_lock_generic_header.xml
index 8875e1f..7ec16d2 100644
--- a/res/layout/setup_choose_lock_generic_header.xml
+++ b/res/layout/setup_choose_lock_generic_header.xml
@@ -16,11 +16,11 @@
-->
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
- style="@style/SuwDescription.Glif"
+ style="@style/SudDescription.Glif"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingStart="?android:attr/listPreferredItemPaddingStart"
android:paddingEnd="?android:attr/listPreferredItemPaddingEnd"
- android:paddingTop="@dimen/suw_description_glif_margin_top"
- android:paddingBottom="@dimen/suw_description_glif_margin_bottom_lists"
+ android:paddingTop="@dimen/sud_description_glif_margin_top"
+ android:paddingBottom="@dimen/sud_description_glif_margin_bottom_lists"
android:text="@string/setup_lock_settings_picker_message" />
diff --git a/res/layout/setup_screen_lock_fingerprint_details.xml b/res/layout/setup_screen_lock_fingerprint_details.xml
index 06ca778..fc4ed98 100644
--- a/res/layout/setup_screen_lock_fingerprint_details.xml
+++ b/res/layout/setup_screen_lock_fingerprint_details.xml
@@ -20,6 +20,6 @@
android:layout_height="wrap_content"
android:paddingTop="6dip"
android:paddingBottom="6dip"
- android:paddingStart="@dimen/suw_layout_margin_sides"
- android:paddingEnd="@dimen/suw_layout_margin_sides"
+ android:paddingStart="@dimen/sud_layout_margin_sides"
+ android:paddingEnd="@dimen/sud_layout_margin_sides"
android:text="@string/unlock_setup_wizard_fingerprint_details" />
diff --git a/res/layout/storage_internal_forget.xml b/res/layout/storage_internal_forget.xml
index 5ff232a..a2b646e 100644
--- a/res/layout/storage_internal_forget.xml
+++ b/res/layout/storage_internal_forget.xml
@@ -28,11 +28,11 @@
android:id="@+id/body"
android:layout_width="match_parent"
android:layout_height="wrap_content"
- android:paddingTop="@dimen/suw_description_margin_top"
- android:paddingBottom="@dimen/suw_description_margin_bottom"
- android:paddingStart="@dimen/suw_layout_margin_sides"
- android:paddingEnd="@dimen/suw_layout_margin_sides"
- android:lineSpacingExtra="@dimen/suw_description_line_spacing_extra"
+ android:paddingTop="@dimen/sud_description_margin_top"
+ android:paddingBottom="@dimen/sud_description_margin_bottom"
+ android:paddingStart="@dimen/sud_layout_margin_sides"
+ android:paddingEnd="@dimen/sud_layout_margin_sides"
+ android:lineSpacingExtra="@dimen/sud_description_line_spacing_extra"
android:textAppearance="@*android:style/TextAppearance.DeviceDefault.Body1"
android:textColor="?android:attr/textColorPrimary" />
</ScrollView>
diff --git a/res/layout/storage_internal_format.xml b/res/layout/storage_internal_format.xml
index 500592f..08434b0 100644
--- a/res/layout/storage_internal_format.xml
+++ b/res/layout/storage_internal_format.xml
@@ -28,11 +28,11 @@
android:id="@+id/body"
android:layout_width="match_parent"
android:layout_height="wrap_content"
- android:paddingTop="@dimen/suw_description_margin_top"
- android:paddingBottom="@dimen/suw_description_margin_bottom"
- android:paddingStart="@dimen/suw_layout_margin_sides"
- android:paddingEnd="@dimen/suw_layout_margin_sides"
- android:lineSpacingExtra="@dimen/suw_description_line_spacing_extra"
+ android:paddingTop="@dimen/sud_description_margin_top"
+ android:paddingBottom="@dimen/sud_description_margin_bottom"
+ android:paddingStart="@dimen/sud_layout_margin_sides"
+ android:paddingEnd="@dimen/sud_layout_margin_sides"
+ android:lineSpacingExtra="@dimen/sud_description_line_spacing_extra"
android:textAppearance="@*android:style/TextAppearance.DeviceDefault.Body1"
android:textColor="?android:attr/textColorPrimary" />
</ScrollView>
diff --git a/res/layout/storage_internal_unmount.xml b/res/layout/storage_internal_unmount.xml
index 2e394df..2ae489c 100644
--- a/res/layout/storage_internal_unmount.xml
+++ b/res/layout/storage_internal_unmount.xml
@@ -28,11 +28,11 @@
android:id="@+id/body"
android:layout_width="match_parent"
android:layout_height="wrap_content"
- android:paddingTop="@dimen/suw_description_margin_top"
- android:paddingBottom="@dimen/suw_description_margin_bottom"
- android:paddingStart="@dimen/suw_layout_margin_sides"
- android:paddingEnd="@dimen/suw_layout_margin_sides"
- android:lineSpacingExtra="@dimen/suw_description_line_spacing_extra"
+ android:paddingTop="@dimen/sud_description_margin_top"
+ android:paddingBottom="@dimen/sud_description_margin_bottom"
+ android:paddingStart="@dimen/sud_layout_margin_sides"
+ android:paddingEnd="@dimen/sud_layout_margin_sides"
+ android:lineSpacingExtra="@dimen/sud_description_line_spacing_extra"
android:textAppearance="@*android:style/TextAppearance.DeviceDefault.Body1"
android:textColor="?android:attr/textColorPrimary" />
</ScrollView>
diff --git a/res/layout/storage_wizard_checklist.xml b/res/layout/storage_wizard_checklist.xml
index 6f21bb8..842cbdb 100644
--- a/res/layout/storage_wizard_checklist.xml
+++ b/res/layout/storage_wizard_checklist.xml
@@ -22,36 +22,36 @@
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
- android:layout_marginTop="@dimen/suw_description_margin_top"
+ android:layout_marginTop="@dimen/sud_description_margin_top"
android:textColor="?android:attr/textColorPrimary"
android:text="@string/storage_wizard_migrate_v2_checklist" />
<TextView
android:id="@+id/storage_wizard_migrate_v2_checklist_media"
android:layout_width="match_parent"
android:layout_height="wrap_content"
- android:layout_marginTop="@dimen/suw_description_margin_top"
- android:layout_marginBottom="@dimen/suw_description_margin_bottom"
+ android:layout_marginTop="@dimen/sud_description_margin_top"
+ android:layout_marginBottom="@dimen/sud_description_margin_bottom"
android:textColor="?android:attr/textColorPrimary"
android:text="@string/storage_wizard_migrate_v2_checklist_media"
android:drawableStart="@drawable/ic_sd_card"
android:drawableTint="?android:attr/textColorSecondary"
- android:drawablePadding="@dimen/suw_description_margin_bottom" />
+ android:drawablePadding="@dimen/sud_description_margin_bottom" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
- android:layout_marginBottom="@dimen/suw_description_margin_bottom"
+ android:layout_marginBottom="@dimen/sud_description_margin_bottom"
android:textColor="?android:attr/textColorPrimary"
android:text="@string/storage_wizard_migrate_v2_checklist_apps"
android:drawableStart="@drawable/ic_apps_alt"
android:drawableTint="?android:attr/textColorSecondary"
- android:drawablePadding="@dimen/suw_description_margin_bottom" />
+ android:drawablePadding="@dimen/sud_description_margin_bottom" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
- android:layout_marginBottom="@dimen/suw_description_margin_bottom"
+ android:layout_marginBottom="@dimen/sud_description_margin_bottom"
android:textColor="?android:attr/textColorPrimary"
android:text="@string/storage_wizard_migrate_v2_checklist_battery"
android:drawableStart="@drawable/ic_battery_charging_full"
android:drawableTint="?android:attr/textColorSecondary"
- android:drawablePadding="@dimen/suw_description_margin_bottom" />
+ android:drawablePadding="@dimen/sud_description_margin_bottom" />
</LinearLayout>
diff --git a/res/layout/storage_wizard_generic.xml b/res/layout/storage_wizard_generic.xml
index 0e7c1fd..2b96101 100644
--- a/res/layout/storage_wizard_generic.xml
+++ b/res/layout/storage_wizard_generic.xml
@@ -22,7 +22,7 @@
android:layout_height="match_parent">
<LinearLayout
- style="@style/SuwContentFrame"
+ style="@style/SudContentFrame"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
@@ -31,8 +31,8 @@
android:id="@+id/storage_wizard_body"
android:layout_width="match_parent"
android:layout_height="wrap_content"
- android:layout_marginTop="@dimen/suw_description_margin_top"
- android:lineSpacingExtra="@dimen/suw_description_line_spacing_extra"
+ android:layout_marginTop="@dimen/sud_description_margin_top"
+ android:lineSpacingExtra="@dimen/sud_description_line_spacing_extra"
android:textColor="?android:attr/textColorPrimary" />
<FrameLayout
diff --git a/res/layout/storage_wizard_init.xml b/res/layout/storage_wizard_init.xml
index bca2676..d02e871 100644
--- a/res/layout/storage_wizard_init.xml
+++ b/res/layout/storage_wizard_init.xml
@@ -22,7 +22,7 @@
android:layout_height="match_parent">
<LinearLayout
- style="@style/SuwContentFrame"
+ style="@style/SudContentFrame"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
@@ -30,7 +30,7 @@
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
- android:layout_marginTop="@dimen/suw_description_margin_top"
+ android:layout_marginTop="@dimen/sud_description_margin_top"
android:orientation="horizontal"
android:gravity="center_vertical">
<ImageView
@@ -42,23 +42,23 @@
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
- android:layout_marginStart="@dimen/suw_glif_margin_sides"
+ android:layout_marginStart="@dimen/sud_glif_margin_sides"
android:orientation="vertical">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
- android:layout_marginBottom="@dimen/suw_description_margin_bottom"
+ android:layout_marginBottom="@dimen/sud_description_margin_bottom"
android:textAppearance="@*android:style/TextAppearance.DeviceDefault.Subhead"
android:text="@string/storage_wizard_init_v2_internal_title" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
- android:layout_marginBottom="@dimen/suw_description_margin_bottom"
+ android:layout_marginBottom="@dimen/sud_description_margin_bottom"
android:textColor="?android:attr/textColorSecondary"
android:text="@string/storage_wizard_init_v2_internal_summary" />
<Button
android:id="@+id/storage_wizard_init_internal"
- style="@style/SuwGlifButton.Primary"
+ style="@style/SudGlifButton.Primary"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/storage_wizard_init_v2_internal_action"
@@ -69,7 +69,7 @@
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
- android:layout_marginTop="@dimen/suw_description_margin_top"
+ android:layout_marginTop="@dimen/sud_description_margin_top"
android:orientation="horizontal"
android:gravity="center_vertical">
<View
@@ -97,7 +97,7 @@
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
- android:layout_marginTop="@dimen/suw_description_margin_top"
+ android:layout_marginTop="@dimen/sud_description_margin_top"
android:orientation="horizontal"
android:gravity="center_vertical">
<ImageView
@@ -109,23 +109,23 @@
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
- android:layout_marginStart="@dimen/suw_glif_margin_sides"
+ android:layout_marginStart="@dimen/sud_glif_margin_sides"
android:orientation="vertical">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
- android:layout_marginBottom="@dimen/suw_description_margin_bottom"
+ android:layout_marginBottom="@dimen/sud_description_margin_bottom"
android:textAppearance="@*android:style/TextAppearance.DeviceDefault.Subhead"
android:text="@string/storage_wizard_init_v2_external_title" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
- android:layout_marginBottom="@dimen/suw_description_margin_bottom"
+ android:layout_marginBottom="@dimen/sud_description_margin_bottom"
android:textColor="?android:attr/textColorSecondary"
android:text="@string/storage_wizard_init_v2_external_summary" />
<Button
android:id="@+id/storage_wizard_init_external"
- style="@style/SuwGlifButton.Primary"
+ style="@style/SudGlifButton.Primary"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/storage_wizard_init_v2_external_action"
diff --git a/res/layout/storage_wizard_progress.xml b/res/layout/storage_wizard_progress.xml
index a68750f..cf5bc43 100644
--- a/res/layout/storage_wizard_progress.xml
+++ b/res/layout/storage_wizard_progress.xml
@@ -22,7 +22,7 @@
android:layout_height="match_parent">
<LinearLayout
- style="@style/SuwContentFrame"
+ style="@style/SudContentFrame"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
@@ -31,22 +31,22 @@
android:id="@+id/storage_wizard_progress"
android:layout_width="match_parent"
android:layout_height="wrap_content"
- android:layout_marginTop="@dimen/suw_description_margin_top"
+ android:layout_marginTop="@dimen/sud_description_margin_top"
android:indeterminate="false"
style="?android:attr/progressBarStyleHorizontal" />
<TextView
android:id="@+id/storage_wizard_progress_summary"
android:layout_width="match_parent"
android:layout_height="wrap_content"
- android:lineSpacingExtra="@dimen/suw_description_line_spacing_extra"
+ android:lineSpacingExtra="@dimen/sud_description_line_spacing_extra"
android:textColor="?android:attr/textColorSecondary" />
<TextView
android:id="@+id/storage_wizard_body"
android:layout_width="match_parent"
android:layout_height="wrap_content"
- android:layout_marginTop="@dimen/suw_description_margin_top"
- android:lineSpacingExtra="@dimen/suw_description_line_spacing_extra"
+ android:layout_marginTop="@dimen/sud_description_margin_top"
+ android:lineSpacingExtra="@dimen/sud_description_line_spacing_extra"
android:textColor="?android:attr/textColorPrimary"
android:visibility="gone" />
diff --git a/res/layout/time_zone_search_item.xml b/res/layout/time_zone_search_item.xml
index bb75226..8d059a8 100644
--- a/res/layout/time_zone_search_item.xml
+++ b/res/layout/time_zone_search_item.xml
@@ -63,7 +63,7 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:singleLine="true"
- android:textAppearance="@style/Preference_TextAppearanceMaterialSubhead"
+ android:textAppearance="?android:attr/textAppearanceListItem"
android:ellipsize="marquee" />
<RelativeLayout
diff --git a/res/layout/wifi_dialog.xml b/res/layout/wifi_dialog.xml
index 2a395b6..df676fc 100644
--- a/res/layout/wifi_dialog.xml
+++ b/res/layout/wifi_dialog.xml
@@ -68,7 +68,7 @@
android:layout_centerVertical="true"
android:layout_margin="5dp"
android:background="@null"
- android:src="@drawable/ic_qrcode_24dp"
+ android:src="@drawable/ic_scan_24dp"
android:visibility="gone"
android:contentDescription="@string/wifi_add_network" />
</RelativeLayout>
@@ -303,7 +303,7 @@
android:layout_centerVertical="true"
android:layout_margin="5dp"
android:background="@null"
- android:src="@drawable/ic_qrcode_24dp"
+ android:src="@drawable/ic_scan_24dp"
android:visibility="gone"
android:contentDescription="@string/wifi_add_network" />
</RelativeLayout>
diff --git a/res/layout/wifi_dpp_activity.xml b/res/layout/wifi_dpp_activity.xml
index 48f2b65..cb82f66 100644
--- a/res/layout/wifi_dpp_activity.xml
+++ b/res/layout/wifi_dpp_activity.xml
@@ -15,7 +15,7 @@
limitations under the License.
-->
-<ScrollView
+<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/root"
android:layout_width="match_parent"
@@ -27,4 +27,4 @@
android:layout_width="match_parent"
android:layout_height="match_parent"/>
-</ScrollView>
+</LinearLayout>
diff --git a/res/layout/wifi_dpp_add_device_fragment.xml b/res/layout/wifi_dpp_add_device_fragment.xml
index 03add62..97f5764 100644
--- a/res/layout/wifi_dpp_add_device_fragment.xml
+++ b/res/layout/wifi_dpp_add_device_fragment.xml
@@ -15,34 +15,49 @@
limitations under the License.
-->
-<LinearLayout
+<androidx.constraintlayout.widget.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/root"
android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:orientation="vertical">
+ android:layout_height="match_parent">
- <include layout="@layout/wifi_dpp_fragment_header"/>
-
- <ProgressBar
- android:id="@+id/progress_bar"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:indeterminate="true"/>
-
- <ImageView
- android:id="@+id/wifi_ap_picture_view"
+ <ScrollView
android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:layout_gravity="center"/>
+ android:layout_height="match_parent">
- <TextView android:id="@+id/choose_different_network"
- android:layout_width="wrap_content"
+ <LinearLayout
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:gravity="center_horizontal"
+ android:orientation="vertical">
+
+ <include layout="@layout/wifi_dpp_fragment_header"/>
+
+ <ImageView
+ android:id="@+id/wifi_ap_picture_view"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ app:layout_constraintTop_toBottomOf="@+id/header"/>
+
+ <Button
+ android:id="@+id/choose_different_network"
+ style="@style/SudGlifButton.Secondary"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ app:layout_constraintTop_toBottomOf="@+id/wifi_ap_picture_view"
+ android:layout_marginTop="8dp"
+ android:text="@string/wifi_dpp_choose_different_network"/>
+
+ </LinearLayout>
+
+ </ScrollView>
+
+ <include
+ layout="@layout/wifi_dpp_fragment_footer"
+ android:layout_width="match_parent"
android:layout_height="wrap_content"
- android:layout_gravity="center"/>
+ app:layout_constraintBottom_toBottomOf="parent"/>
- <include layout="@layout/wifi_dpp_fragment_footer"
- android:gravity="center|bottom"/>
-
-</LinearLayout>
+</androidx.constraintlayout.widget.ConstraintLayout>
diff --git a/res/layout/wifi_dpp_choose_saved_wifi_network_fragment.xml b/res/layout/wifi_dpp_choose_saved_wifi_network_fragment.xml
index a65cf3e..c3fccd0 100644
--- a/res/layout/wifi_dpp_choose_saved_wifi_network_fragment.xml
+++ b/res/layout/wifi_dpp_choose_saved_wifi_network_fragment.xml
@@ -15,21 +15,39 @@
limitations under the License.
-->
-<LinearLayout
+<androidx.constraintlayout.widget.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/root"
android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:orientation="vertical">
+ android:layout_height="match_parent">
- <include layout="@layout/wifi_dpp_fragment_header"/>
-
- <ListView android:id="@+id/saved_wifi_network_list"
+ <ScrollView
android:layout_width="match_parent"
- android:layout_height="wrap_content"/>
+ android:layout_height="match_parent">
- <include layout="@layout/wifi_dpp_fragment_footer"
- android:gravity="center|bottom"/>
+ <LinearLayout
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:gravity="center_horizontal"
+ android:orientation="vertical">
-</LinearLayout>
+ <include layout="@layout/wifi_dpp_fragment_header"/>
+
+ <ListView android:id="@+id/saved_wifi_network_list"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ app:layout_constraintTop_toBottomOf="@+id/header"/>
+
+ </LinearLayout>
+
+ </ScrollView>
+
+ <include
+ layout="@layout/wifi_dpp_fragment_footer"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ app:layout_constraintBottom_toBottomOf="parent"/>
+
+</androidx.constraintlayout.widget.ConstraintLayout>
diff --git a/res/layout/wifi_dpp_fragment_footer.xml b/res/layout/wifi_dpp_fragment_footer.xml
index 98c6485..d29f16e 100644
--- a/res/layout/wifi_dpp_fragment_footer.xml
+++ b/res/layout/wifi_dpp_fragment_footer.xml
@@ -18,16 +18,15 @@
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:orientation="horizontal">
+ android:layout_height="wrap_content"
+ style="@style/SudGlifButtonBar">
<Button
android:id="@+id/button_left"
+ style="@style/SudGlifButton.Secondary"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
- android:layout_gravity="bottom|start"
- android:text="left"
- style="?android:attr/borderlessButtonStyle"/>
+ android:layout_gravity="start"/>
<Space
android:layout_width="0dp"
@@ -36,9 +35,9 @@
<Button
android:id="@+id/button_right"
+ style="@style/SudGlifButton.Primary"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
- android:layout_gravity="bottom|end"
- android:text="right"/>
+ android:layout_gravity="end"/>
</LinearLayout>
diff --git a/res/layout/wifi_dpp_qrcode_generator_fragment.xml b/res/layout/wifi_dpp_qrcode_generator_fragment.xml
index c7c258b..2617aea 100644
--- a/res/layout/wifi_dpp_qrcode_generator_fragment.xml
+++ b/res/layout/wifi_dpp_qrcode_generator_fragment.xml
@@ -22,14 +22,27 @@
android:layout_height="match_parent"
android:orientation="vertical">
- <include layout="@layout/wifi_dpp_fragment_header"/>
+ <ScrollView
+ android:layout_width="match_parent"
+ android:layout_height="match_parent">
- <ImageView
- android:id="@+id/qrcode_view"
- android:layout_width="@dimen/qrcode_size"
- android:layout_height="@dimen/qrcode_size"
- android:src="@android:color/transparent"
- android:layout_gravity="center"/>
+ <LinearLayout
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:gravity="center_horizontal"
+ android:orientation="vertical">
+
+ <include layout="@layout/wifi_dpp_fragment_header"/>
+
+ <ImageView
+ android:id="@+id/qrcode_view"
+ android:layout_width="@dimen/qrcode_size"
+ android:layout_height="@dimen/qrcode_size"
+ android:src="@android:color/transparent"/>
+
+ </LinearLayout>
+
+ </ScrollView>
</LinearLayout>
diff --git a/res/layout/wifi_dpp_qrcode_scanner_fragment.xml b/res/layout/wifi_dpp_qrcode_scanner_fragment.xml
index f09fc69..c5e416b 100644
--- a/res/layout/wifi_dpp_qrcode_scanner_fragment.xml
+++ b/res/layout/wifi_dpp_qrcode_scanner_fragment.xml
@@ -19,35 +19,45 @@
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/root"
android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:orientation="vertical">
+ android:layout_height="match_parent">
- <include layout="@layout/wifi_dpp_fragment_header"/>
-
- <com.android.settings.wifi.qrcode.QrPreviewLayout
+ <ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent">
- <TextureView
- android:id="@+id/preview_view"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:layout_gravity="center"/>
- <com.android.settings.wifi.qrcode.QrDecorateView
- android:id="@+id/decorate_view"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:layout_gravity="center"/>
- </com.android.settings.wifi.qrcode.QrPreviewLayout>
- <TextView
- android:id="@+id/error_message"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_gravity="center"
- android:layout_marginTop="8dp"
- android:text="@string/wifi_dpp_could_not_detect_valid_qr_code"
- android:visibility="invisible"
- android:textColor="?android:attr/colorError"/>
+ <LinearLayout
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:orientation="vertical"
+ android:gravity="center_horizontal">
+
+ <include layout="@layout/wifi_dpp_fragment_header"/>
+
+ <com.android.settings.wifi.qrcode.QrPreviewLayout
+ android:layout_width="match_parent"
+ android:layout_height="match_parent">
+ <TextureView
+ android:id="@+id/preview_view"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"/>
+ <com.android.settings.wifi.qrcode.QrDecorateView
+ android:id="@+id/decorate_view"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"/>
+ </com.android.settings.wifi.qrcode.QrPreviewLayout>
+
+ <TextView
+ android:id="@+id/error_message"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_marginTop="8dp"
+ android:text="@string/wifi_dpp_could_not_detect_valid_qr_code"
+ android:visibility="invisible"
+ android:textColor="?android:attr/colorError"/>
+
+ </LinearLayout>
+
+ </ScrollView>
</LinearLayout>
diff --git a/res/values-night/colors.xml b/res/values-night/colors.xml
index bc06f47..cdbeada 100644
--- a/res/values-night/colors.xml
+++ b/res/values-night/colors.xml
@@ -21,5 +21,8 @@
<color name="switchbar_switch_thumb_tint">@android:color/black</color>
<color name="homepage_accessibility_background">#783BE5</color>
<color name="homepage_support_background">#3F5FBD</color>
+ <!-- 80% black for status bar of homepage -->
+ <color name="homepage_status_bar_color">#cc000000</color>
+ <color name="homepage_card_dismissal_background">@*android:color/material_grey_800</color>
</resources>
diff --git a/res/values/attrs.xml b/res/values/attrs.xml
index a88d6f6..b2d5468 100644
--- a/res/values/attrs.xml
+++ b/res/values/attrs.xml
@@ -72,6 +72,8 @@
<attr name="platform_slice" format="boolean" />
<!-- Whether or not dynamic summary text from PreferenceController is allowed when creating slice object, by default it's false. -->
<attr name="allowDynamicSummaryInSlice" format="boolean" />
+ <!-- customized subtitle if it's an unavailable slice -->
+ <attr name="unavailableSliceSubtitle" format="string" />
</declare-styleable>
<declare-styleable name="PreferenceScreen">
diff --git a/res/values/colors.xml b/res/values/colors.xml
index 2103649..da01be0 100644
--- a/res/values/colors.xml
+++ b/res/values/colors.xml
@@ -30,7 +30,7 @@
<color name="title_color">@android:color/holo_blue_light</color>
<color name="setup_lock_pattern_view_regular_color_light">@color/lock_pattern_view_regular_color</color>
<color name="setup_lock_pattern_view_success_color_dark">#ff84ffff</color>
- <color name="setup_lock_pattern_view_success_color_light">@color/suw_color_accent_light</color>
+ <color name="setup_lock_pattern_view_success_color_light">@color/sud_color_accent_light</color>
<color name="setup_lock_pattern_view_error_color_dark">#fff44336</color>
<color name="setup_wizard_wifi_color_dark">#89ffffff</color>
<color name="setup_wizard_wifi_color_light">#89000000</color>
@@ -104,6 +104,7 @@
<color name="homepage_about_background">#9FA8DA</color>
<color name="homepage_privacy_background">#5E97F6</color>
<color name="homepage_card_stroke_color">#1f000000</color>
+ <color name="homepage_card_dismissal_background">@*android:color/material_grey_50</color>
<!-- End of dashboard/homepage icon background colors -->
<color name="switchbar_text_color">@android:color/white</color>
@@ -129,6 +130,9 @@
<!-- launcher icon color -->
<color name="icon_launcher_setting_color">@*android:color/accent_device_default_light</color>
+ <!-- 80% white for status bar of homepage -->
+ <color name="homepage_status_bar_color">#ccFFFFFF</color>
+
<!-- QR code scanner colors -->
<color name="qr_corner_line_color">#ffdadce0</color>
<color name="qr_focused_corner_line_color">#ff1a73e8</color>
diff --git a/res/values/config.xml b/res/values/config.xml
index 82e185c..1a504dd 100755
--- a/res/values/config.xml
+++ b/res/values/config.xml
@@ -171,4 +171,10 @@
<!-- ComponentName to launch a vendor-specific enrollment activity if available -->
<string name="config_face_enroll" translatable="false"></string>
+
+ <!-- Max allowed value for screen timeout, in milliseconds -->
+ <integer name="max_lock_after_timeout_ms">1800000</integer>
+
+ <!-- App intent -->
+ <string name="config_account_intent_uri" translatable="false"></string>
</resources>
diff --git a/res/values/dimens.xml b/res/values/dimens.xml
index 383f564..1a3d6ff 100755
--- a/res/values/dimens.xml
+++ b/res/values/dimens.xml
@@ -105,8 +105,6 @@
<dimen name="search_bar_avatar_size">32dp</dimen>
<dimen name="search_bar_avatar_start_margin">4dp</dimen>
<dimen name="search_bar_avatar_end_margin">16dp</dimen>
- <!-- appbar height is equal search bar height (48dp) plus search bar top and bottom margin -->
- <dimen name="app_bar_height">80dp</dimen>
<!-- Dimensions for Wifi Assistant Card -->
<dimen name="wifi_assistant_padding_top_bottom">16dp</dimen>
@@ -116,6 +114,8 @@
<dimen name="wifi_assistant_height">182dp</dimen>
<dimen name="wifi_assistant_image_top">32dp</dimen>
<dimen name="wifi_assistant_image_start">24dp</dimen>
+ <!-- appbar height is equal search bar height (48dp) plus search bar top and bottom margin -->
+ <dimen name="app_bar_height">80dp</dimen>
<!-- CryptKeeper top margin for password/pin screen -->
<dimen name="crypt_keeper_password_top_margin">88dip</dimen>
@@ -332,6 +332,7 @@
<dimen name="homepage_half_card_padding_top">12dp</dimen>
<dimen name="homepage_half_card_padding_bottom">16dp</dimen>
<dimen name="homepage_half_card_title_margin_top">12dp</dimen>
+ <dimen name="homepage_card_dismissal_margin_bottom">2dp</dimen>
<!-- Horizontal divider size and margin -->
<dimen name="horizontal_divider_margin_top">4dp</dimen>
@@ -355,7 +356,7 @@
<dimen name="homepage_condition_full_card_padding_bottom">12dp</dimen>
<dimen name="homepage_condition_header_padding_top">10dp</dimen>
<dimen name="homepage_condition_header_padding_bottom">10dp</dimen>
- <dimen name="homepage_condition_header_icons_margin_start">24dp</dimen>
+ <dimen name="homepage_condition_header_icons_margin_start">16dp</dimen>
<dimen name="homepage_condition_header_indicator_padding_top">4dp</dimen>
<dimen name="homepage_condition_header_indicator_padding_start">16dp</dimen>
<dimen name="homepage_condition_header_indicator_padding_end">16dp</dimen>
diff --git a/res/values/strings.xml b/res/values/strings.xml
index cbdedf0..9f5b562 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -927,10 +927,12 @@
<string name="security_settings_face_settings_require_attention">Eyes open to unlock</string>
<!-- Text shown on the details of a toggle which disables/enables face authentication, depending if the user's eyes are open. [CHAR LIMIT=70] -->
<string name="security_settings_face_settings_require_attention_details">When using face authentication, your eyes must be open</string>
+ <!-- When authenticating in apps, always require confirmation (e.g. confirm button) after a face is authenticated. [CHAR LIMIT=50] -->
+ <string name="security_settings_face_settings_require_confirmation">Always require confirmation</string>
+ <!-- When authenticating in apps, always require confirmation (e.g. confirm button) after a face is authenticated. [CHAR LIMIT=70] -->
+ <string name="security_settings_face_settings_require_confirmation_details">When authenticating in apps, always require confirmation</string>
<!-- Button text in face settings which removes the user's faces from the device [CHAR LIMIT=20] -->
<string name="security_settings_face_settings_remove_face_data">Remove face data</string>
- <!-- Text shown in face settings allowing the user to update/improve the enrolled face. This brings the user back to the enrollment flow. [CHAR LIMIT=30] -->
- <string name="security_settings_face_settings_improve_face">Improve your face data</string>
<!-- Text shown in face settings explaining what your face can be used for. [CHAR LIMIT=NONE] -->
<string name="security_settings_face_settings_footer">Your face can be used to unlock your device and access apps.
<annotation id="url">Learn more</annotation></string>
@@ -2077,13 +2079,13 @@
<!-- Label for the spinner to show Wifi MAC randomization [CHAR LIMIT=25] -->
<string name="wifi_privacy_settings">Privacy</string>
<!-- Title for the fragment to add a device into the wifi network [CHAR LIMIT=50] -->
- <string name="wifi_dpp_add_device_to_network">Add a device to this network</string>
+ <string name="wifi_dpp_add_device_to_network">Add a device</string>
<!-- Hint for the user to center another device's QR code in the below camera window [CHAR LIMIT=120] -->
- <string name="wifi_dpp_center_qr_code">Center the device\u2019s QR code below to add device to \u201c<xliff:g id="ssid" example="OfficeWifi">%1$s</xliff:g>\u201d</string>
+ <string name="wifi_dpp_center_qr_code">Center the QR code below to add the device to \u201c<xliff:g id="ssid" example="OfficeWifi">%1$s</xliff:g>\u201d</string>
<!-- Title for the fragment to scan QR code [CHAR LIMIT=50] -->
<string name="wifi_dpp_scan_qr_code">Scan QR code</string>
<!-- Hint for the user to center another device's QR code in the below camera window [CHAR LIMIT=NONE] -->
- <string name="wifi_dpp_scan_qr_code_join_network">Join \u201c<xliff:g id="ssid" example="OfficeWifi">%1$s</xliff:g>\u201d by scanning a QR code</string>
+ <string name="wifi_dpp_scan_qr_code_join_network">Center the QR code below to connect to \u201c<xliff:g id="ssid" example="OfficeWifi">%1$s</xliff:g>\u201d</string>
<!-- Hint for the user to center another device's QR code in the below camera window [CHAR LIMIT=NONE] -->
<string name="wifi_dpp_scan_qr_code_join_unknown_network">Join Wi\u2011Fi by scanning a QR code</string>
<!-- Title for the fragment to share Wi-Fi [CHAR LIMIT=50] -->
@@ -2091,7 +2093,25 @@
<!-- Hint for the user to use another device to scan QR code on screen to join Wi-Fi [CHAR LIMIT=NONE] -->
<string name="wifi_dpp_scan_qr_code_with_another_device">Scan this QR code with another device to join \u201c<xliff:g id="ssid" example="OfficeWifi">%1$s</xliff:g>\u201d</string>
<!-- Hint for QR code detection [CHAR LIMIT=NONE] -->
- <string name="wifi_dpp_could_not_detect_valid_qr_code">Could not detect valid QR code</string>
+ <string name="wifi_dpp_could_not_detect_valid_qr_code">Couldn\u2019t read QR code</string>
+ <!-- Title for the fragment choose network [CHAR LIMIT=50] -->
+ <string name="wifi_dpp_choose_network">Choose network</string>
+ <!-- Hint for the user to center another device's QR code in the below camera window [CHAR LIMIT=NONE] -->
+ <string name="wifi_dpp_choose_network_to_connect_device">To connect your device, choose a network</string>
+ <!-- Hint for the user to add the device to a Wi-Fi network [CHAR LIMIT=NONE] -->
+ <string name="wifi_dpp_add_device_to_wifi">Add this device to \u201c<xliff:g id="ssid" example="OfficeWifi">%1$s</xliff:g>\u201d?</string>
+ <!-- Title for the fragment to tell the user that Wi-Fi shared with device successfully [CHAR LIMIT=50] -->
+ <string name="wifi_dpp_wifi_shared_with_device">Wi\u2011Fi shared with device</string>
+ <!-- Button label to add another device to Wi-Fi [CHAR LIMIT=50] -->
+ <string name="wifi_dpp_add_another_device">Add another device</string>
+ <!-- Button label to choose different Wi-Fi network [CHAR LIMIT=80] -->
+ <string name="wifi_dpp_choose_different_network">Choose different network</string>
+ <!-- Hint for QR code detection [CHAR LIMIT=50] -->
+ <string name="wifi_dpp_could_not_add_device">Couldn\u2019t add device</string>
+ <!-- Title for the fragment to show that device found but naming known [CHAR LIMIT=50] -->
+ <string name="wifi_dpp_device_found">Device found</string>
+ <!-- Label for the try again button [CHAR LIMIT=20]-->
+ <string name="retry">Retry</string>
<!-- Label for the check box to share a network with other users on the same device -->
<string name="wifi_shared">Share with other device users</string>
<!-- Hint for unchanged fields -->
@@ -4208,13 +4228,9 @@
<!-- Manage applications. application installation location summary -->
<string name="app_install_location_summary">Change the preferred installation location for new apps</string>
<!-- [CHAR LIMIT=30] Manage applications, label for option to disable app -->
- <string name="app_disable_dlg_positive">Disable app</string>
+ <string name="app_disable_dlg_positive">Uninstall app</string>
<!-- [CHAR LIMIT=200] Manage applications, text for dialog when disabling apps -->
- <string name="app_disable_dlg_text">If you disable this app, Android and other apps may no longer function as intended.</string>
- <!-- [CHAR LIMIT=NONE] Manage applications, title for dialog when disabling updated apps -->
- <string name="app_special_disable_dlg_title">Delete data and disable app?</string>
- <!-- [CHAR LIMIT=NONE] Manage applications, text for dialog when disabling update apps -->
- <string name="app_special_disable_dlg_text">If you disable this app, Android and other apps may no longer function as intended. Your data will also be deleted.</string>
+ <string name="app_disable_dlg_text">If you uninstall this app, Android and other apps may no longer function as intended.</string>
<!-- [CHAR LIMIT=30] Manage applications, title for dialog when disabling notifications for an app -->
<string name="app_disable_notifications_dlg_title">Turn off notifications?</string>
<!-- Manage applications, individual application info screen, section heading for information about the app installer [CHAR_LIMIT=25] -->
@@ -4675,7 +4691,9 @@
<!-- Title for accessibility preference screen for configuring vibrations. -->
<string name="accessibility_vibration_settings_title">Vibration</string>
<!-- Title for accessibility preference for configuring notification vibrations. -->
- <string name="accessibility_notification_vibration_title">Ring & notification vibration</string>
+ <string name="accessibility_notification_vibration_title">Notification vibration</string>
+ <!-- Title for accessibility preference for configuring ring vibrations. [CHAR LIMIT=NONE] -->
+ <string name="accessibility_ring_vibration_title">Ring vibration</string>
<!-- Title for accessibility preference for configuring touch feedback vibrations. -->
<string name="accessibility_touch_vibration_title">Touch vibration</string>
<!-- Used in the acessibilty service settings to control turning on/off the service entirely -->
@@ -4745,8 +4763,8 @@
<item quantity="other">Very long delay (<xliff:g id="click_delay_label" example="200">%1$d</xliff:g> ms)</item>
</plurals>
- <!-- Summary for vibration settings preference when notification vibration and haptic feedback intensity are set. [CHAR LIMIT=32] -->
- <string name="accessibility_vibration_summary">Ring <xliff:g id="summary_ring" example="Medium">%1$s</xliff:g>, touch <xliff:g id="summary_touch" example="High">%2$s</xliff:g></string>
+ <!-- Summary for vibration settings preference when notification vibration and haptic feedback intensity are set. [CHAR LIMIT=50] -->
+ <string name="accessibility_vibration_summary">Ring <xliff:g id="summary_ring" example="Medium">%1$s</xliff:g>, notification <xliff:g id="summary_notification" example="Low">%2$s</xliff:g>, touch <xliff:g id="summary_touch" example="High">%3$s</xliff:g></string>
<!-- Summary for vibration settings preference when ring & notification are set to off-->
<string name="accessibility_vibration_summary_off">Ring & notification set to off</string>
@@ -5226,6 +5244,9 @@
<item quantity="other">%1$d apps restricted</item>
</plurals>
+ <!-- Title to display the battery percentage. [CHAR LIMIT=24] -->
+ <string name="battery_header_title_alternate"><xliff:g id="number" example="88">^1</xliff:g><small> <font size="20"><xliff:g id="unit" example="%">%</xliff:g></font></small></string>
+
<!-- Title for force stop dialog [CHAR LIMIT=30] -->
<string name="dialog_stop_title">Stop app?</string>
<!-- Message body for force stop dialog [CHAR LIMIT=NONE] -->
@@ -5813,9 +5834,6 @@
Used in SetupWizard for XLarge screen [CHAR LIMIT=20] -->
<string name="wifi_setup_detail">Network details</string>
- <!-- Do not translate. This is a stub which will be removed soon. -->
- <string name="time_zone_auto_stub" translatable="false">Select Time Zone</string>
-
<!-- Content description of the enabled sync icon for accessibility. [CHAR LIMIT=NONE] -->
<string name="accessibility_sync_enabled">Sync enabled</string>
<!-- Content description of the disabled sync icon for accessibility. [CHAR LIMIT=NONE] -->
@@ -7040,8 +7058,10 @@
<!-- List of synonyms for touch vibration setting (where you get a haptic response for touching things on the screen), used to match in settings search [CHAR LIMIT=NONE] -->
<string name="keywords_touch_vibration">haptics, vibrate, screen, sensitivity</string>
- <!-- List of synonyms for ring and notification vibration setting (changes whether your phone vibrates when it rings), used to match in settings search [CHAR LIMIT=NONE] -->
- <string name="keywords_ring_vibration">haptics, vibrate, phone, call, sensitivity</string>
+ <!-- List of synonyms for ring vibration setting (changes whether your phone vibrates when it rings), used to match in settings search [CHAR LIMIT=NONE] -->
+ <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>
<!-- NFC Wi-Fi pairing/setup strings-->
@@ -7127,8 +7147,8 @@
<!-- Sound: Other sounds: Title for the option enabling touch sounds for screen locking sounds. [CHAR LIMIT=30] -->
<string name="screen_locking_sounds_title">Screen locking sounds</string>
- <!-- Sound: Other sounds: Title for the option enabling charging sounds. [CHAR LIMIT=30] -->
- <string name="charging_sounds_title">Charging sounds</string>
+ <!-- Sound: Other sounds: Title for the option enabling charging sounds and vibration. [CHAR LIMIT=30] -->
+ <string name="charging_sounds_title">Charging sounds and vibration</string>
<!-- Sound: Other sounds: Title for the option enabling docking sounds. [CHAR LIMIT=30] -->
<string name="docking_sounds_title">Docking sounds</string>
@@ -9079,6 +9099,12 @@
<!-- Summary of condition that do not disturb is on [CHAR LIMIT=36] -->
<string name="condition_zen_summary">Impacts what you hear and see</string>
+ <!-- Title of condition that battery saver is on [CHAR LIMIT=30] -->
+ <string name="condition_battery_title">Battery Saver is on</string>
+
+ <!-- Summary of condition that battery saver is on [CHAR LIMIT=NONE] -->
+ <string name="condition_battery_summary">Features restricted</string>
+
<!-- Title of condition that cellular data is off [CHAR LIMIT=50] -->
<string name="condition_cellular_title">Mobile data is off</string>
@@ -9458,10 +9484,14 @@
<string name="notification_log_details_parcel">parcel size</string>
<!-- Notification log debug tool: notification ashmem size -->
<string name="notification_log_details_ashmem">ashmem</string>
+ <!-- Notification log debug tool: header: notification alert info -->
+ <string name="notification_log_details_alerted">notification alerted</string>
<!-- Notification log debug tool: header: notification sound info -->
<string name="notification_log_details_sound">sound</string>
<!-- Notification log debug tool: header: notification vibration info -->
<string name="notification_log_details_vibrate">vibrate</string>
+ <!-- Notification log debug tool: header: notification vibration info -->
+ <string name="notification_log_details_vibrate_pattern">pattern</string>
<!-- Notification log debug tool: the word 'default' -->
<string name="notification_log_details_default">default</string>
<!-- Notification log debug tool: the word 'none' -->
@@ -10039,12 +10069,24 @@
<!-- UI debug setting: ANGLE enabled app has been set [CHAR LIMIT=NONE] -->
<string name="angle_enabled_app_set">ANGLE enabled application: <xliff:g id="app_name" example="com.company.app">%1$s</xliff:g></string>
- <!-- UI debug setting: select an app to use updated graphics driver [CHAR LIMIT=100] -->
- <string name="updated_gfx_driver_dev_opt_in_app">Select app to use updated graphics driver</string>
- <!-- UI debug setting: no app selected to use updated GPU driver [CHAR LIMIT=100] -->
- <string name="updated_gfx_driver_dev_opt_in_app_not_set">No selected app to use updated graphics driver</string>
- <!-- UI debug setting: app selected to use updated graphics driver [CHAR LIMIT=NONE] -->
- <string name="updated_gfx_driver_dev_opt_in_app_set">Opt in application: <xliff:g id="app_name" example="com.company.app">%1$s</xliff:g></string>
+ <!-- Title for Game Update Package dashboard where developers can configure apps to use GUP or not [CHAR LIMIT=50] -->
+ <string name="gup_dashboard_title">Game Update Package Preferences</string>
+ <!-- Summary for Game Update Package dashboard [CHAR LIMIT=50] -->
+ <string name="gup_dashboard_summary">Modify Game Update Package settings</string>
+ <!-- Title for Game Update Package preference [CHAR LIMIT=50] -->
+ <string name="gup_app_preference_title">Select Graphics Driver</string>
+ <!-- The default value for Game Update Package preference [CHAR LIMIT=50] -->
+ <string name="gup_app_preference_default">Default</string>
+ <!-- The gup value for Game Update Package preference [CHAR LIMIT=50] -->
+ <string name="gup_app_preference_gup">Game Update Package</string>
+ <!-- The system value for Game Update Package preference [CHAR LIMIT=50] -->
+ <string name="gup_app_preference_system">System Graphics Driver</string>
+ <!-- All the values for Game Update Package preference [CHAR LIMIT=50] -->
+ <string-array name="gup_app_preference_values">
+ <item>@string/gup_app_preference_default</item>
+ <item>@string/gup_app_preference_gup</item>
+ <item>@string/gup_app_preference_system</item>
+ </string-array>
<!-- Slices Strings -->
@@ -10162,12 +10204,6 @@
<!-- Homepage bottom menu. Title for display personalized Settings [CHAR LIMIT=30] -->
<string name="homepage_personal_settings">Suggestions</string>
- <!-- Setting Checkbox title whether to enable CBRS data. [CHAR LIMIT=40] -->
- <string name="cbrs_data_switch">CBRS Data</string>
-
- <!-- Title of implications of enabling CBRS Data -->
- <string name="cbrs_data_switch_summary">CBRS Data</string>
-
<!-- Available networks screen, name of button when user wants to select network manually [CHAR LIMIT=60] -->
<string name="choose_network_title">Choose network</string>
<!-- Available networks screen, text when no networks connected [CHAR LIMIT=60] -->
@@ -10381,7 +10417,7 @@
<!-- Title for the top level Privacy Settings [CHAR LIMIT=30]-->
<string name="privacy_dashboard_title">Privacy</string>
<!-- Summary for the top level Privacy Settings [CHAR LIMIT=NONE]-->
- <string name="privacy_dashboard_summary">Permission, permission usage</string>
+ <string name="privacy_dashboard_summary">Permissions, activity controls, data shown on screen</string>
<!-- Label for button in contextual card for users to remove the card [CHAR LIMIT=30] -->
<string name="contextual_card_dismiss_remove">Remove</string>
diff --git a/res/values/styles.xml b/res/values/styles.xml
index 98b6283..1668b37 100644
--- a/res/values/styles.xml
+++ b/res/values/styles.xml
@@ -174,13 +174,13 @@
<item name="android:background">#ff000000</item>
</style>
- <style name="SetupWizardButton.Negative" parent="@style/SuwGlifButton.Secondary">
+ <style name="SetupWizardButton.Negative" parent="@style/SudGlifButton.Secondary">
<!-- Negative margin to offset for padding of the button itself. We want the label to be
aligned with the text above it -->
<item name="android:layout_marginStart">-16dp</item>
</style>
- <style name="SetupWizardButton.Positive" parent="@style/SuwGlifButton.Primary"/>
+ <style name="SetupWizardButton.Positive" parent="@style/SudGlifButton.Primary"/>
<style name="AccentColorHighlightBorderlessButton">
<item name="android:colorControlHighlight">?android:attr/colorAccent</item>
@@ -454,11 +454,13 @@
<style name="ConditionFullCardBorderlessButton"
parent="@style/ConditionCardBorderlessButton">
- <item name="android:textAlignment">viewEnd</item>
+ <item name="android:minWidth">24dp</item>
+ <item name="android:layout_marginStart">20dp</item>
</style>
<style name="ContextualCardDismissalButton"
parent="android:Widget.DeviceDefault.Button.Borderless.Colored">
+ <item name="android:minHeight">16dp</item>
<item name="android:textAllCaps">false</item>
</style>
diff --git a/res/values/themes.xml b/res/values/themes.xml
index 6041ef8..c7fafad 100644
--- a/res/values/themes.xml
+++ b/res/values/themes.xml
@@ -39,7 +39,7 @@
<item name="wifi_friction">@drawable/wifi_friction</item>
<item name="side_margin">@dimen/settings_side_margin</item>
- <item name="suwListItemIconColor">?android:attr/colorAccent</item>
+ <item name="sudListItemIconColor">?android:attr/colorAccent</item>
<!-- Redefine the ActionBar style for contentInsetStart -->
<item name="android:actionBarStyle">@style/Widget.ActionBar</item>
diff --git a/res/values/themes_suw.xml b/res/values/themes_suw.xml
index e0d25c9..9bb67cf 100644
--- a/res/values/themes_suw.xml
+++ b/res/values/themes_suw.xml
@@ -17,7 +17,7 @@
<!-- SUW related themes -->
<resources>
- <style name="GlifTheme" parent="SuwThemeGlif.DayNight">
+ <style name="GlifTheme" parent="SudThemeGlif.DayNight">
<!-- For all AndroidX Alert Dialogs -->
<item name="alertDialogTheme">@style/ThemeOverlay.AlertDialog</item>
<item name="android:windowBackground">?android:attr/colorBackground</item>
@@ -36,7 +36,7 @@
<item name="*android:lockPatternStyle">@style/LockPatternStyle.Setup</item>
</style>
- <style name="GlifTheme.Light" parent="SuwThemeGlif.Light">
+ <style name="GlifTheme.Light" parent="SudThemeGlif.Light">
<!-- For all AndroidX Alert Dialogs -->
<item name="alertDialogTheme">@style/ThemeOverlay.AlertDialog</item>
<item name="android:windowBackground">?android:attr/colorBackground</item>
@@ -55,7 +55,7 @@
<item name="*android:colorError">@color/glif_error_color</item>
</style>
- <style name="GlifV2Theme" parent="SuwThemeGlifV2.DayNight">
+ <style name="GlifV2Theme" parent="SudThemeGlifV2.DayNight">
<!-- For all AndroidX Alert Dialogs -->
<item name="alertDialogTheme">@style/GlifV2ThemeAlertDialog</item>
<item name="android:windowBackground">?android:attr/colorBackground</item>
@@ -74,7 +74,7 @@
<item name="*android:lockPatternStyle">@style/LockPatternStyle.Setup</item>
</style>
- <style name="GlifV2Theme.Light" parent="SuwThemeGlifV2.Light">
+ <style name="GlifV2Theme.Light" parent="SudThemeGlifV2.Light">
<!-- For all AndroidX Alert Dialogs -->
<item name="alertDialogTheme">@style/GlifV2ThemeAlertDialog.Light</item>
<item name="android:windowBackground">?android:attr/colorBackground</item>
@@ -93,7 +93,7 @@
<item name="*android:colorError">@color/glif_error_color</item>
</style>
- <style name="GlifV3Theme" parent="SuwThemeGlifV3.DayNight">
+ <style name="GlifV3Theme" parent="SudThemeGlifV3.DayNight">
<!-- For all AndroidX Alert Dialogs -->
<item name="alertDialogTheme">@style/GlifV2ThemeAlertDialog</item>
<item name="android:windowBackground">?android:attr/colorBackground</item>
@@ -112,7 +112,7 @@
<item name="*android:lockPatternStyle">@style/LockPatternStyle.Setup</item>
</style>
- <style name="GlifV3Theme.Light" parent="SuwThemeGlifV3.Light">
+ <style name="GlifV3Theme.Light" parent="SudThemeGlifV3.Light">
<!-- For all AndroidX Alert Dialogs -->
<item name="alertDialogTheme">@style/GlifV2ThemeAlertDialog.Light</item>
<item name="android:windowBackground">?android:attr/colorBackground</item>
diff --git a/res/xml/accessibility_ring_vibration_settings.xml b/res/xml/accessibility_ring_vibration_settings.xml
new file mode 100644
index 0000000..078f76c
--- /dev/null
+++ b/res/xml/accessibility_ring_vibration_settings.xml
@@ -0,0 +1,20 @@
+<?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"
+ android:title="@string/accessibility_ring_vibration_title" />
diff --git a/res/xml/accessibility_vibration_settings.xml b/res/xml/accessibility_vibration_settings.xml
index b2b3596..dc2b16a 100644
--- a/res/xml/accessibility_vibration_settings.xml
+++ b/res/xml/accessibility_vibration_settings.xml
@@ -22,10 +22,17 @@
android:title="@string/accessibility_vibration_settings_title">
<Preference
+ android:fragment="com.android.settings.accessibility.RingVibrationPreferenceFragment"
+ android:key="ring_vibration_preference_screen"
+ android:title="@string/accessibility_ring_vibration_title"
+ settings:keywords="@string/keywords_ring_vibration"
+ app:controller="com.android.settings.accessibility.RingVibrationIntensityPreferenceController" />
+
+ <Preference
android:fragment="com.android.settings.accessibility.NotificationVibrationPreferenceFragment"
android:key="notification_vibration_preference_screen"
android:title="@string/accessibility_notification_vibration_title"
- settings:keywords="@string/keywords_ring_vibration"
+ settings:keywords="@string/keywords_notification_vibration"
app:controller="com.android.settings.accessibility.NotificationVibrationIntensityPreferenceController" />
<Preference
diff --git a/res/xml/date_time_prefs.xml b/res/xml/date_time_prefs.xml
index edda1ba..e8af64c 100644
--- a/res/xml/date_time_prefs.xml
+++ b/res/xml/date_time_prefs.xml
@@ -58,7 +58,7 @@
<com.android.settingslib.RestrictedPreference
android:fragment="com.android.settings.datetime.timezone.TimeZoneSettings"
android:key="timezone"
- android:title="@string/date_time_set_timezone"
+ android:title="@string/date_time_set_timezone_title"
android:summary="@string/summary_placeholder"
settings:userRestriction="no_config_date_time" />
</PreferenceCategory>
diff --git a/res/xml/development_settings.xml b/res/xml/development_settings.xml
index be45cd0..4cdab33 100644
--- a/res/xml/development_settings.xml
+++ b/res/xml/development_settings.xml
@@ -191,6 +191,13 @@
android:title="@string/enable_gpu_debug_layers"
android:summary="@string/enable_gpu_debug_layers_summary" />
+ <Preference
+ android:key="gup_dashboard"
+ android:title="@string/gup_dashboard_title"
+ android:summary="@string/gup_dashboard_summary"
+ android:fragment="com.android.settings.development.gup.GupDashboard"
+ settings:searchable="false" />
+
</PreferenceCategory>
<PreferenceCategory
@@ -234,11 +241,6 @@
android:title="@string/usb_default_label"/>
<SwitchPreference
- android:key="cbrs_data_switch"
- android:title="@string/cbrs_data_switch"
- android:summary="@string/cbrs_data_switch" />
-
- <SwitchPreference
android:key="bluetooth_show_devices_without_names"
android:title="@string/bluetooth_show_devices_without_names"
android:summary="@string/bluetooth_show_devices_without_names_summary" />
@@ -424,10 +426,6 @@
android:summary="%s"
android:title="@string/simulate_color_space" />
- <Preference android:key="updated_gfx_driver_dev_opt_in_app"
- android:summary="@string/updated_gfx_driver_dev_opt_in_app_summary"
- android:title="@string/updated_gfx_driver_dev_opt_in_app" />
-
</PreferenceCategory>
<PreferenceCategory
diff --git a/res/xml/gup_settings.xml b/res/xml/gup_settings.xml
new file mode 100644
index 0000000..43ba39b
--- /dev/null
+++ b/res/xml/gup_settings.xml
@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ Copyright 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.
+ -->
+
+<PreferenceScreen
+ xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:settings="http://schemas.android.com/apk/res-auto"
+ android:key="gup_settings"
+ android:title="@string/gup_dashboard_title">
+
+ <PreferenceCategory
+ android:key="gup_category"
+ android:title="@string/gup_app_preference_title"
+ settings:controller="com.android.settings.development.gup.GupPreferenceController">
+ </PreferenceCategory>
+
+</PreferenceScreen>
diff --git a/res/xml/my_device_info.xml b/res/xml/my_device_info.xml
index 3960103..d669977 100644
--- a/res/xml/my_device_info.xml
+++ b/res/xml/my_device_info.xml
@@ -102,8 +102,7 @@
settings:keywords="@string/keywords_model_and_hardware"
android:summary="@string/summary_placeholder"
settings:allowDynamicSummaryInSlice="true"
- settings:controller=
- "com.android.settings.deviceinfo.DeviceModelPreferenceController"/>
+ settings:controller="com.android.settings.deviceinfo.DeviceModelPreferenceController"/>
<!-- IMEI -->
<Preference
@@ -111,7 +110,8 @@
android:order="22"
android:title="@string/status_imei"
settings:keywords="@string/keywords_imei_info"
- android:summary="@string/summary_placeholder"/>
+ android:summary="@string/summary_placeholder"
+ settings:controller="com.android.settings.deviceinfo.imei.ImeiInfoPreferenceController"/>
<!-- Android version -->
<Preference
diff --git a/res/xml/prevent_ringing_gesture_settings.xml b/res/xml/prevent_ringing_gesture_settings.xml
index 62f0223..4b0edc3 100644
--- a/res/xml/prevent_ringing_gesture_settings.xml
+++ b/res/xml/prevent_ringing_gesture_settings.xml
@@ -26,8 +26,11 @@
app:animation="@raw/gesture_prevent_ringing"
app:preview="@drawable/gesture_prevent_ringing" />
+ <com.android.settingslib.widget.LayoutPreference
+ android:key="gesture_prevent_ringing_switch"
+ android:layout="@layout/styled_switch_bar" />
+
<PreferenceCategory
android:key="gesture_prevent_ringing_category"
- android:title="@string/gesture_prevent_ringing_title">
- </PreferenceCategory>
+ android:title="@string/gesture_prevent_ringing_title" />
</PreferenceScreen>
\ No newline at end of file
diff --git a/res/xml/privacy_dashboard_settings.xml b/res/xml/privacy_dashboard_settings.xml
index 79e2e71..a580f5f 100644
--- a/res/xml/privacy_dashboard_settings.xml
+++ b/res/xml/privacy_dashboard_settings.xml
@@ -19,7 +19,8 @@
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:settings="http://schemas.android.com/apk/res-auto"
android:key="privacy_dashboard_page"
- android:title="@string/privacy_dashboard_title">
+ android:title="@string/privacy_dashboard_title"
+ settings:initialExpandedChildrenCount="3">
<!-- App permissions -->
<Preference
@@ -30,13 +31,6 @@
<intent android:action="android.intent.action.MANAGE_PERMISSIONS"/>
</Preference>
- <!-- On lock screen notifications -->
- <com.android.settings.RestrictedListPreference
- android:key="privacy_lock_screen_notifications"
- android:title="@string/lock_screen_notifications_title"
- android:summary="@string/summary_placeholder"
- settings:searchable="false"/>
-
<!-- Show passwords -->
<SwitchPreference
android:key="show_password"
@@ -44,6 +38,13 @@
android:summary="@string/show_password_summary"
settings:controller="com.android.settings.security.ShowPasswordPreferenceController"/>
+ <!-- On lock screen notifications -->
+ <com.android.settings.RestrictedListPreference
+ android:key="privacy_lock_screen_notifications"
+ android:title="@string/lock_screen_notifications_title"
+ android:summary="@string/summary_placeholder"
+ settings:searchable="false"/>
+
<!-- Privacy Service -->
<PreferenceCategory
android:key="privacy_services"/>
diff --git a/res/xml/security_settings_face.xml b/res/xml/security_settings_face.xml
index c202a6c..f5dde8b 100644
--- a/res/xml/security_settings_face.xml
+++ b/res/xml/security_settings_face.xml
@@ -47,13 +47,16 @@
<SwitchPreference
android:key="security_settings_face_require_attention"
android:title="@string/security_settings_face_settings_require_attention"
+ android:summary="@string/security_settings_face_settings_require_attention_details"
app:keywords="@string/keywords_face_unlock"
app:controller="com.android.settings.biometrics.face.FaceSettingsAttentionPreferenceController"/>
- <Preference
- android:key="security_settings_face_improve"
- android:title="@string/security_settings_face_settings_improve_face">
- </Preference>
+ <SwitchPreference
+ android:key="security_settings_face_require_confirmation"
+ android:title="@string/security_settings_face_settings_require_confirmation"
+ android:summary="@string/security_settings_face_settings_require_confirmation_details"
+ app:keywords="@string/keywords_face_unlock"
+ app:controller="com.android.settings.biometrics.face.FaceSettingsConfirmPreferenceController"/>
<com.android.settingslib.widget.LayoutPreference
android:key="security_settings_face_delete_faces_container"
diff --git a/src/com/android/settings/BandMode.java b/src/com/android/settings/BandMode.java
index 5be82f6..bae8860 100644
--- a/src/com/android/settings/BandMode.java
+++ b/src/com/android/settings/BandMode.java
@@ -73,13 +73,8 @@
super.onCreate(icicle);
requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
-
setContentView(R.layout.band_mode);
- setTitle(getString(R.string.band_mode_title));
- getWindow().setLayout(WindowManager.LayoutParams.MATCH_PARENT,
- WindowManager.LayoutParams.WRAP_CONTENT);
-
mPhone = PhoneFactory.getDefaultPhone();
mBandList = (ListView) findViewById(R.id.band);
diff --git a/src/com/android/settings/EncryptionInterstitial.java b/src/com/android/settings/EncryptionInterstitial.java
index 656b18c..6060892 100644
--- a/src/com/android/settings/EncryptionInterstitial.java
+++ b/src/com/android/settings/EncryptionInterstitial.java
@@ -156,7 +156,7 @@
.setText(R.string.encryption_interstitial_no)
.setListener(this::onNoButtonClicked)
.setButtonType(FooterButton.ButtonType.SKIP)
- .setTheme(R.style.SuwGlifButton_Secondary)
+ .setTheme(R.style.SudGlifButton_Secondary)
.build()
);
@@ -165,7 +165,7 @@
.setText(R.string.encryption_interstitial_yes)
.setListener(this::onYesButtonClicked)
.setButtonType(FooterButton.ButtonType.NEXT)
- .setTheme(R.style.SuwGlifButton_Primary)
+ .setTheme(R.style.SudGlifButton_Primary)
.build()
);
}
diff --git a/src/com/android/settings/MasterClear.java b/src/com/android/settings/MasterClear.java
index e4ce6443..c03d499 100644
--- a/src/com/android/settings/MasterClear.java
+++ b/src/com/android/settings/MasterClear.java
@@ -423,7 +423,7 @@
.setText(R.string.master_clear_button_text)
.setListener(mInitiateListener)
.setButtonType(ButtonType.OTHER)
- .setTheme(R.style.SuwGlifButton_Primary)
+ .setTheme(R.style.SudGlifButton_Primary)
.build()
);
mInitiateButton = buttonFooterMixin.getPrimaryButton();
diff --git a/src/com/android/settings/MasterClearConfirm.java b/src/com/android/settings/MasterClearConfirm.java
index 0750cb1..cbd4924 100644
--- a/src/com/android/settings/MasterClearConfirm.java
+++ b/src/com/android/settings/MasterClearConfirm.java
@@ -160,7 +160,7 @@
.setText(R.string.master_clear_button_text)
.setListener(mFinalClickListener)
.setButtonType(ButtonType.OTHER)
- .setTheme(R.style.SuwGlifButton_Primary)
+ .setTheme(R.style.SudGlifButton_Primary)
.build()
);
}
diff --git a/src/com/android/settings/accessibility/AccessibilitySettings.java b/src/com/android/settings/accessibility/AccessibilitySettings.java
index 76be66d..402fa61 100644
--- a/src/com/android/settings/accessibility/AccessibilitySettings.java
+++ b/src/com/android/settings/accessibility/AccessibilitySettings.java
@@ -810,15 +810,30 @@
final Context context = getContext();
final Vibrator vibrator = context.getSystemService(Vibrator.class);
- final int ringIntensity = Settings.System.getInt(context.getContentResolver(),
- Settings.System.NOTIFICATION_VIBRATION_INTENSITY,
- vibrator.getDefaultNotificationVibrationIntensity());
+ int ringIntensity = Settings.System.getInt(context.getContentResolver(),
+ Settings.System.RING_VIBRATION_INTENSITY,
+ vibrator.getDefaultRingVibrationIntensity());
+ if (Settings.System.getInt(context.getContentResolver(),
+ Settings.System.VIBRATE_WHEN_RINGING, 0) == 0) {
+ ringIntensity = Vibrator.VIBRATION_INTENSITY_OFF;
+ }
CharSequence ringIntensityString =
VibrationIntensityPreferenceController.getIntensityString(context, ringIntensity);
- final int touchIntensity = Settings.System.getInt(context.getContentResolver(),
+ int notificationIntensity = Settings.System.getInt(context.getContentResolver(),
+ Settings.System.NOTIFICATION_VIBRATION_INTENSITY,
+ vibrator.getDefaultNotificationVibrationIntensity());
+ CharSequence notificationIntensityString =
+ VibrationIntensityPreferenceController.getIntensityString(context,
+ notificationIntensity);
+
+ int touchIntensity = Settings.System.getInt(context.getContentResolver(),
Settings.System.HAPTIC_FEEDBACK_INTENSITY,
vibrator.getDefaultHapticFeedbackIntensity());
+ if (Settings.System.getInt(context.getContentResolver(),
+ Settings.System.HAPTIC_FEEDBACK_ENABLED, 0) == 0) {
+ touchIntensity = Vibrator.VIBRATION_INTENSITY_OFF;
+ }
CharSequence touchIntensityString =
VibrationIntensityPreferenceController.getIntensityString(context, touchIntensity);
@@ -826,12 +841,14 @@
mVibrationPreferenceScreen = findPreference(VIBRATION_PREFERENCE_SCREEN);
}
- if (ringIntensity == touchIntensity) {
+ if (ringIntensity == touchIntensity && ringIntensity == notificationIntensity) {
mVibrationPreferenceScreen.setSummary(ringIntensityString);
} else {
mVibrationPreferenceScreen.setSummary(
getString(R.string.accessibility_vibration_summary,
- ringIntensityString, touchIntensityString));
+ ringIntensityString,
+ notificationIntensityString,
+ touchIntensityString));
}
}
diff --git a/src/com/android/settings/accessibility/HapticFeedbackIntensityPreferenceController.java b/src/com/android/settings/accessibility/HapticFeedbackIntensityPreferenceController.java
index 343ebb1..a2142a2 100644
--- a/src/com/android/settings/accessibility/HapticFeedbackIntensityPreferenceController.java
+++ b/src/com/android/settings/accessibility/HapticFeedbackIntensityPreferenceController.java
@@ -28,7 +28,8 @@
static final String PREF_KEY = "touch_vibration_preference_screen";
public HapticFeedbackIntensityPreferenceController(Context context) {
- super(context, PREF_KEY, Settings.System.HAPTIC_FEEDBACK_INTENSITY);
+ super(context, PREF_KEY, Settings.System.HAPTIC_FEEDBACK_INTENSITY,
+ Settings.System.HAPTIC_FEEDBACK_ENABLED);
}
@Override
diff --git a/src/com/android/settings/accessibility/NotificationVibrationIntensityPreferenceController.java b/src/com/android/settings/accessibility/NotificationVibrationIntensityPreferenceController.java
index 4aff513..4ace4c6 100644
--- a/src/com/android/settings/accessibility/NotificationVibrationIntensityPreferenceController.java
+++ b/src/com/android/settings/accessibility/NotificationVibrationIntensityPreferenceController.java
@@ -28,7 +28,7 @@
static final String PREF_KEY = "notification_vibration_preference_screen";
public NotificationVibrationIntensityPreferenceController(Context context) {
- super(context, PREF_KEY, Settings.System.NOTIFICATION_VIBRATION_INTENSITY);
+ super(context, PREF_KEY, Settings.System.NOTIFICATION_VIBRATION_INTENSITY, "");
}
@Override
diff --git a/src/com/android/settings/accessibility/NotificationVibrationPreferenceFragment.java b/src/com/android/settings/accessibility/NotificationVibrationPreferenceFragment.java
index 6804abc..ba7d51d 100644
--- a/src/com/android/settings/accessibility/NotificationVibrationPreferenceFragment.java
+++ b/src/com/android/settings/accessibility/NotificationVibrationPreferenceFragment.java
@@ -45,6 +45,11 @@
}
@Override
+ protected String getVibrationEnabledSetting() {
+ return "";
+ }
+
+ @Override
protected int getPreviewVibrationAudioAttributesUsage() {
return AudioAttributes.USAGE_NOTIFICATION;
}
diff --git a/src/com/android/settings/accessibility/RingVibrationIntensityPreferenceController.java b/src/com/android/settings/accessibility/RingVibrationIntensityPreferenceController.java
new file mode 100644
index 0000000..818c414
--- /dev/null
+++ b/src/com/android/settings/accessibility/RingVibrationIntensityPreferenceController.java
@@ -0,0 +1,44 @@
+/*
+ * 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.accessibility;
+
+import android.content.Context;
+import android.provider.Settings;
+
+import androidx.annotation.VisibleForTesting;
+
+public class RingVibrationIntensityPreferenceController
+ extends VibrationIntensityPreferenceController {
+
+ @VisibleForTesting
+ static final String PREF_KEY = "ring_vibration_preference_screen";
+
+ public RingVibrationIntensityPreferenceController(Context context) {
+ super(context, PREF_KEY, Settings.System.RING_VIBRATION_INTENSITY,
+ Settings.System.VIBRATE_WHEN_RINGING);
+ }
+
+ @Override
+ public int getAvailabilityStatus() {
+ return AVAILABLE;
+ }
+
+ @Override
+ protected int getDefaultIntensity() {
+ return mVibrator.getDefaultRingVibrationIntensity();
+ }
+}
diff --git a/src/com/android/settings/accessibility/RingVibrationPreferenceFragment.java b/src/com/android/settings/accessibility/RingVibrationPreferenceFragment.java
new file mode 100644
index 0000000..df05231
--- /dev/null
+++ b/src/com/android/settings/accessibility/RingVibrationPreferenceFragment.java
@@ -0,0 +1,62 @@
+/*
+ * 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.accessibility;
+
+import android.media.AudioAttributes;
+import android.os.Vibrator;
+import android.provider.Settings;
+
+import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
+import com.android.settings.R;
+
+/**
+ * Fragment for picking accessibility shortcut service
+ */
+public class RingVibrationPreferenceFragment extends VibrationPreferenceFragment {
+ @Override
+ public int getMetricsCategory() {
+ return MetricsEvent.ACCESSIBILITY_VIBRATION_RING;
+ }
+
+ @Override
+ protected int getPreferenceScreenResId() {
+ return R.xml.accessibility_ring_vibration_settings;
+ }
+
+ /**
+ * Get the setting string of the vibration intensity setting this preference is dealing with.
+ */
+ @Override
+ protected String getVibrationIntensitySetting() {
+ return Settings.System.RING_VIBRATION_INTENSITY;
+ }
+
+ @Override
+ protected String getVibrationEnabledSetting() {
+ return Settings.System.VIBRATE_WHEN_RINGING;
+ }
+
+ @Override
+ protected int getPreviewVibrationAudioAttributesUsage() {
+ return AudioAttributes.USAGE_NOTIFICATION;
+ }
+
+ @Override
+ protected int getDefaultVibrationIntensity() {
+ Vibrator vibrator = getContext().getSystemService(Vibrator.class);
+ return vibrator.getDefaultRingVibrationIntensity();
+ }
+}
diff --git a/src/com/android/settings/accessibility/TouchVibrationPreferenceFragment.java b/src/com/android/settings/accessibility/TouchVibrationPreferenceFragment.java
index ba08a43..52fd069 100644
--- a/src/com/android/settings/accessibility/TouchVibrationPreferenceFragment.java
+++ b/src/com/android/settings/accessibility/TouchVibrationPreferenceFragment.java
@@ -45,6 +45,11 @@
}
@Override
+ protected String getVibrationEnabledSetting() {
+ return Settings.System.HAPTIC_FEEDBACK_ENABLED;
+ }
+
+ @Override
protected int getDefaultVibrationIntensity() {
Vibrator vibrator = getContext().getSystemService(Vibrator.class);
return vibrator.getDefaultHapticFeedbackIntensity();
@@ -54,13 +59,4 @@
protected int getPreviewVibrationAudioAttributesUsage() {
return AudioAttributes.USAGE_ASSISTANCE_SONIFICATION;
}
-
- @Override
- public void onVibrationIntensitySelected(int intensity) {
- // We want to keep HAPTIC_FEEDBACK_ENABLED consistent with this setting since some
- // applications check it directly before triggering their own haptic feedback.
- final boolean hapticFeedbackEnabled = !(intensity == Vibrator.VIBRATION_INTENSITY_OFF);
- Settings.System.putInt(getContext().getContentResolver(),
- Settings.System.HAPTIC_FEEDBACK_ENABLED, hapticFeedbackEnabled ? 1 : 0);
- }
}
diff --git a/src/com/android/settings/accessibility/VibrationIntensityPreferenceController.java b/src/com/android/settings/accessibility/VibrationIntensityPreferenceController.java
index d9b1d79..e52f92d 100644
--- a/src/com/android/settings/accessibility/VibrationIntensityPreferenceController.java
+++ b/src/com/android/settings/accessibility/VibrationIntensityPreferenceController.java
@@ -39,14 +39,16 @@
protected final Vibrator mVibrator;
private final SettingObserver mSettingsContentObserver;
private final String mSettingKey;
+ private final String mEnabledKey;
private Preference mPreference;
public VibrationIntensityPreferenceController(Context context, String prefkey,
- String settingKey) {
+ String settingKey, String enabledKey) {
super(context, prefkey);
mVibrator = mContext.getSystemService(Vibrator.class);
mSettingKey = settingKey;
+ mEnabledKey = enabledKey;
mSettingsContentObserver = new SettingObserver(settingKey) {
@Override
public void onChange(boolean selfChange, Uri uri) {
@@ -78,7 +80,9 @@
public CharSequence getSummary() {
final int intensity = Settings.System.getInt(mContext.getContentResolver(),
mSettingKey, getDefaultIntensity());
- return getIntensityString(mContext, intensity);
+ final boolean enabled = Settings.System.getInt(mContext.getContentResolver(),
+ mEnabledKey, 1) == 1;
+ return getIntensityString(mContext, enabled ? intensity : Vibrator.VIBRATION_INTENSITY_OFF);
}
public static CharSequence getIntensityString(Context context, int intensity) {
diff --git a/src/com/android/settings/accessibility/VibrationPreferenceFragment.java b/src/com/android/settings/accessibility/VibrationPreferenceFragment.java
index 1101611..648acad 100644
--- a/src/com/android/settings/accessibility/VibrationPreferenceFragment.java
+++ b/src/com/android/settings/accessibility/VibrationPreferenceFragment.java
@@ -26,6 +26,7 @@
import android.os.VibrationEffect;
import android.os.Vibrator;
import android.provider.Settings;
+import android.text.TextUtils;
import android.util.ArrayMap;
import android.util.Log;
@@ -117,6 +118,11 @@
protected abstract String getVibrationIntensitySetting();
/**
+ * Get the setting string of the vibration enabledness setting this preference is dealing with.
+ */
+ protected abstract String getVibrationEnabledSetting();
+
+ /**
* Get the default intensity for the desired setting.
*/
protected abstract int getDefaultVibrationIntensity();
@@ -154,8 +160,13 @@
@Override
protected String getDefaultKey() {
- final int vibrationIntensity = Settings.System.getInt(getContext().getContentResolver(),
+ int vibrationIntensity = Settings.System.getInt(getContext().getContentResolver(),
getVibrationIntensitySetting(), getDefaultVibrationIntensity());
+ final boolean vibrationEnabled = Settings.System.getInt(getContext().getContentResolver(),
+ getVibrationEnabledSetting(), 1) == 1;
+ if (!vibrationEnabled) {
+ vibrationIntensity = Vibrator.VIBRATION_INTENSITY_OFF;
+ }
for (VibrationIntensityCandidateInfo candidate : mCandidates.values()) {
final boolean matchesIntensity = candidate.getIntensity() == vibrationIntensity;
final boolean matchesOn = candidate.getKey().equals(KEY_INTENSITY_ON)
@@ -174,8 +185,11 @@
Log.e(TAG, "Tried to set unknown intensity (key=" + key + ")!");
return false;
}
- Settings.System.putInt(getContext().getContentResolver(),
- getVibrationIntensitySetting(), candidate.getIntensity());
+ if (candidate.getIntensity() != Vibrator.VIBRATION_INTENSITY_OFF ||
+ TextUtils.isEmpty(getVibrationEnabledSetting())) {
+ Settings.System.putInt(getContext().getContentResolver(),
+ getVibrationIntensitySetting(), candidate.getIntensity());
+ }
onVibrationIntensitySelected(candidate.getIntensity());
return true;
}
diff --git a/src/com/android/settings/accounts/AccountFeatureProvider.java b/src/com/android/settings/accounts/AccountFeatureProvider.java
index fd65095..ef14fa0 100644
--- a/src/com/android/settings/accounts/AccountFeatureProvider.java
+++ b/src/com/android/settings/accounts/AccountFeatureProvider.java
@@ -23,5 +23,4 @@
public interface AccountFeatureProvider {
String getAccountType();
Account[] getAccounts(Context context);
- Intent getAccountSettingsDeeplinkIntent();
}
diff --git a/src/com/android/settings/accounts/AccountFeatureProviderImpl.java b/src/com/android/settings/accounts/AccountFeatureProviderImpl.java
index 2e0f432..90b581b 100644
--- a/src/com/android/settings/accounts/AccountFeatureProviderImpl.java
+++ b/src/com/android/settings/accounts/AccountFeatureProviderImpl.java
@@ -2,7 +2,6 @@
import android.accounts.Account;
import android.content.Context;
-import android.content.Intent;
public class AccountFeatureProviderImpl implements AccountFeatureProvider {
@Override
@@ -14,9 +13,4 @@
public Account[] getAccounts(Context context) {
return new Account[0];
}
-
- @Override
- public Intent getAccountSettingsDeeplinkIntent() {
- return null;
- }
}
diff --git a/src/com/android/settings/accounts/AvatarViewMixin.java b/src/com/android/settings/accounts/AvatarViewMixin.java
index 35a3cbf..43531b3 100644
--- a/src/com/android/settings/accounts/AvatarViewMixin.java
+++ b/src/com/android/settings/accounts/AvatarViewMixin.java
@@ -40,6 +40,7 @@
import com.android.settings.overlay.FeatureFactory;
import com.android.settingslib.utils.ThreadUtils;
+import java.net.URISyntaxException;
import java.util.List;
/**
@@ -57,7 +58,6 @@
private static final String KEY_AVATAR_BITMAP = "account_avatar";
private static final String KEY_ACCOUNT_NAME = "account_name";
private static final String EXTRA_ACCOUNT_NAME = "extra.accountName";
- private static final int REQUEST_CODE = 1013;
private final Context mContext;
private final ImageView mAvatarView;
@@ -69,23 +69,32 @@
mContext = activity.getApplicationContext();
mAvatarView = avatarView;
mAvatarView.setOnClickListener(v -> {
- final Intent intent = FeatureFactory.getFactory(mContext)
- .getAccountFeatureProvider()
- .getAccountSettingsDeeplinkIntent();
-
- if (intent == null) {
+ Intent intent;
+ try {
+ final String uri = mContext.getResources().getString(
+ R.string.config_account_intent_uri);
+ intent = Intent.parseUri(uri, Intent.URI_INTENT_SCHEME);
+ } catch (URISyntaxException e) {
+ Log.w(TAG, "Error parsing avatar mixin intent, skipping", e);
return;
}
if (!TextUtils.isEmpty(mAccountName)) {
- //TODO(b/117509285) launch the new page of the MeCard
intent.putExtra(EXTRA_ACCOUNT_NAME, mAccountName);
}
+ final List<ResolveInfo> matchedIntents =
+ mContext.getPackageManager().queryIntentActivities(intent,
+ PackageManager.MATCH_SYSTEM_ONLY);
+ if (matchedIntents.isEmpty()) {
+ Log.w(TAG, "Cannot find any matching action VIEW_ACCOUNT intent.");
+ return;
+ }
+
// Here may have two different UI while start the activity.
// It will display adding account UI when device has no any account.
// It will display account information page when intent added the specified account.
- activity.startActivityForResult(intent, REQUEST_CODE);
+ activity.startActivity(intent);
});
mAvatarImage = new MutableLiveData<>();
diff --git a/src/com/android/settings/applications/defaultapps/RolesPreferenceController.java b/src/com/android/settings/applications/defaultapps/RolesPreferenceController.java
index 59166dd..c7cab15 100644
--- a/src/com/android/settings/applications/defaultapps/RolesPreferenceController.java
+++ b/src/com/android/settings/applications/defaultapps/RolesPreferenceController.java
@@ -16,31 +16,44 @@
package com.android.settings.applications.defaultapps;
+import android.app.role.RoleManager;
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageManager;
+import android.icu.text.ListFormatter;
import android.provider.Settings;
import android.text.TextUtils;
import androidx.preference.Preference;
import com.android.settings.core.BasePreferenceController;
+import com.android.settingslib.applications.AppUtils;
+
+import java.util.ArrayList;
+import java.util.List;
/**
* STOPSHIP(b/110557011): Remove once the new UI is ready.
*/
public class RolesPreferenceController extends BasePreferenceController {
- private Intent mIntent;
+ private final PackageManager mPackageManager;
+ private final RoleManager mRoleManager;
+
+ private final Intent mIntent;
public RolesPreferenceController(Context context, String preferenceKey) {
super(context, preferenceKey);
- PackageManager packageManager = context.getPackageManager();
- String packageName = packageManager.getPermissionControllerPackageName();
+ mPackageManager = context.getPackageManager();
+ mRoleManager = context.getSystemService(RoleManager.class);
+
+ final String packageName = mPackageManager.getPermissionControllerPackageName();
if (packageName != null) {
mIntent = new Intent(Settings.ACTION_MANAGE_DEFAULT_APPS_SETTINGS)
.setPackage(packageName);
+ } else {
+ mIntent = null;
}
}
@@ -59,4 +72,34 @@
}
return false;
}
+
+ @Override
+ public CharSequence getSummary() {
+ final List<CharSequence> defaultAppLabels = new ArrayList<>();
+ final CharSequence defaultBrowserLabel = getDefaultAppLabel(RoleManager.ROLE_BROWSER);
+ if(!TextUtils.isEmpty(defaultBrowserLabel)) {
+ defaultAppLabels.add(defaultBrowserLabel);
+ }
+ final CharSequence defaultPhoneLabel = getDefaultAppLabel(RoleManager.ROLE_DIALER);
+ if(!TextUtils.isEmpty(defaultPhoneLabel)) {
+ defaultAppLabels.add(defaultPhoneLabel);
+ }
+ final CharSequence defaultSmsLabel = getDefaultAppLabel(RoleManager.ROLE_SMS);
+ if(!TextUtils.isEmpty(defaultSmsLabel)) {
+ defaultAppLabels.add(defaultSmsLabel);
+ }
+ if (defaultAppLabels.isEmpty()) {
+ return null;
+ }
+ return ListFormatter.getInstance().format(defaultAppLabels);
+ }
+
+ private CharSequence getDefaultAppLabel(String roleName) {
+ final List<String> packageNames = mRoleManager.getRoleHolders(roleName);
+ if (packageNames.isEmpty()) {
+ return null;
+ }
+ final String packageName = packageNames.get(0);
+ return AppUtils.getApplicationLabel(mPackageManager, packageName);
+ }
}
diff --git a/src/com/android/settings/biometrics/BiometricEnrollIntroduction.java b/src/com/android/settings/biometrics/BiometricEnrollIntroduction.java
index 798c188..79e699d 100644
--- a/src/com/android/settings/biometrics/BiometricEnrollIntroduction.java
+++ b/src/com/android/settings/biometrics/BiometricEnrollIntroduction.java
@@ -217,7 +217,7 @@
updatePasswordQuality();
mToken = data.getByteArrayExtra(
ChooseLockSettingsHelper.EXTRA_KEY_CHALLENGE_TOKEN);
- overridePendingTransition(R.anim.suw_slide_next_in, R.anim.suw_slide_next_out);
+ overridePendingTransition(R.anim.sud_slide_next_in, R.anim.sud_slide_next_out);
return;
} else {
setResult(result, data);
@@ -226,13 +226,13 @@
} else if (requestCode == CONFIRM_REQUEST) {
if (resultCode == RESULT_OK && data != null) {
mToken = data.getByteArrayExtra(ChooseLockSettingsHelper.EXTRA_KEY_CHALLENGE_TOKEN);
- overridePendingTransition(R.anim.suw_slide_next_in, R.anim.suw_slide_next_out);
+ overridePendingTransition(R.anim.sud_slide_next_in, R.anim.sud_slide_next_out);
} else {
setResult(result, data);
finish();
}
} else if (requestCode == LEARN_MORE_REQUEST) {
- overridePendingTransition(R.anim.suw_slide_back_in, R.anim.suw_slide_back_out);
+ overridePendingTransition(R.anim.sud_slide_back_in, R.anim.sud_slide_back_out);
}
super.onActivityResult(requestCode, resultCode, data);
}
diff --git a/src/com/android/settings/biometrics/BiometricsEnrollEnrolling.java b/src/com/android/settings/biometrics/BiometricsEnrollEnrolling.java
index 7ad2d17..12ffc6b 100644
--- a/src/com/android/settings/biometrics/BiometricsEnrollEnrolling.java
+++ b/src/com/android/settings/biometrics/BiometricsEnrollEnrolling.java
@@ -111,7 +111,7 @@
intent.putExtra(Intent.EXTRA_USER_ID, mUserId);
}
startActivity(intent);
- overridePendingTransition(R.anim.suw_slide_next_in, R.anim.suw_slide_next_out);
+ overridePendingTransition(R.anim.sud_slide_next_in, R.anim.sud_slide_next_out);
finish();
}
diff --git a/src/com/android/settings/biometrics/face/FaceEnrollEnrolling.java b/src/com/android/settings/biometrics/face/FaceEnrollEnrolling.java
index ec75266..2323afc 100644
--- a/src/com/android/settings/biometrics/face/FaceEnrollEnrolling.java
+++ b/src/com/android/settings/biometrics/face/FaceEnrollEnrolling.java
@@ -97,7 +97,7 @@
.setText(R.string.security_settings_face_enroll_enrolling_skip)
.setListener(this::onSkipButtonClick)
.setButtonType(FooterButton.ButtonType.SKIP)
- .setTheme(R.style.SuwGlifButton_Secondary)
+ .setTheme(R.style.SudGlifButton_Secondary)
.build()
);
diff --git a/src/com/android/settings/biometrics/face/FaceEnrollFinish.java b/src/com/android/settings/biometrics/face/FaceEnrollFinish.java
index afd6f55..c347d0f 100644
--- a/src/com/android/settings/biometrics/face/FaceEnrollFinish.java
+++ b/src/com/android/settings/biometrics/face/FaceEnrollFinish.java
@@ -43,7 +43,7 @@
.setText(R.string.security_settings_face_enroll_done)
.setListener(this::onNextButtonClick)
.setButtonType(FooterButton.ButtonType.NEXT)
- .setTheme(R.style.SuwGlifButton_Primary)
+ .setTheme(R.style.SudGlifButton_Primary)
.build()
);
}
diff --git a/src/com/android/settings/biometrics/face/FaceEnrollIntroduction.java b/src/com/android/settings/biometrics/face/FaceEnrollIntroduction.java
index 9311810..ba5a85e 100644
--- a/src/com/android/settings/biometrics/face/FaceEnrollIntroduction.java
+++ b/src/com/android/settings/biometrics/face/FaceEnrollIntroduction.java
@@ -66,7 +66,7 @@
.setText(R.string.security_settings_face_enroll_introduction_cancel)
.setListener(this::onCancelButtonClick)
.setButtonType(FooterButton.ButtonType.SKIP)
- .setTheme(R.style.SuwGlifButton_Secondary)
+ .setTheme(R.style.SudGlifButton_Secondary)
.build()
);
@@ -75,7 +75,7 @@
.setText(R.string.wizard_next)
.setListener(this::onNextButtonClick)
.setButtonType(FooterButton.ButtonType.NEXT)
- .setTheme(R.style.SuwGlifButton_Primary)
+ .setTheme(R.style.SudGlifButton_Primary)
.build()
);
}
diff --git a/src/com/android/settings/biometrics/face/FaceSettings.java b/src/com/android/settings/biometrics/face/FaceSettings.java
index 8eabf00..84745d2 100644
--- a/src/com/android/settings/biometrics/face/FaceSettings.java
+++ b/src/com/android/settings/biometrics/face/FaceSettings.java
@@ -51,11 +51,10 @@
public class FaceSettings extends DashboardFragment {
private static final String TAG = "FaceSettings";
- private static final String KEY_LAUNCHED_CONFIRM = "key_launched_confirm";
+ private static final String KEY_TOKEN = "key_token";
private FaceManager mFaceManager;
private int mUserId;
- private boolean mLaunchedConfirm;
private byte[] mToken;
private FaceSettingsAttentionPreferenceController mAttentionController;
@@ -86,7 +85,7 @@
@Override
public void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState);
- outState.putBoolean(KEY_LAUNCHED_CONFIRM, mLaunchedConfirm);
+ outState.putByteArray(KEY_TOKEN, mToken);
}
@Override
@@ -98,10 +97,10 @@
Intent.EXTRA_USER_ID, UserHandle.myUserId());
if (savedInstanceState != null) {
- mLaunchedConfirm = savedInstanceState.getBoolean(KEY_LAUNCHED_CONFIRM, false);
+ mToken = savedInstanceState.getByteArray(KEY_TOKEN);
}
- if (!mLaunchedConfirm) {
+ if (mToken == null) {
final long challenge = mFaceManager.generateChallenge();
ChooseLockSettingsHelper helper = new ChooseLockSettingsHelper(getActivity(), this);
if (!helper.launchConfirmationActivity(CONFIRM_REQUEST,
@@ -114,6 +113,14 @@
}
@Override
+ public void onResume() {
+ super.onResume();
+ if (mToken != null) {
+ mAttentionController.setToken(mToken);
+ }
+ }
+
+ @Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (requestCode == CONFIRM_REQUEST) {
@@ -172,6 +179,7 @@
controllers.add(new FaceSettingsAttentionPreferenceController(context));
controllers.add(new FaceSettingsRemoveButtonPreferenceController(context));
controllers.add(new FaceSettingsFooterPreferenceController(context));
+ controllers.add(new FaceSettingsConfirmPreferenceController(context));
return controllers;
}
diff --git a/src/com/android/settings/biometrics/face/FaceSettingsConfirmPreferenceController.java b/src/com/android/settings/biometrics/face/FaceSettingsConfirmPreferenceController.java
new file mode 100644
index 0000000..08740cf
--- /dev/null
+++ b/src/com/android/settings/biometrics/face/FaceSettingsConfirmPreferenceController.java
@@ -0,0 +1,62 @@
+/*
+ * 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.biometrics.face;
+
+import static android.provider.Settings.Secure.FACE_UNLOCK_ALWAYS_REQUIRE_CONFIRMATION;
+
+import android.content.Context;
+import android.provider.Settings;
+
+import com.android.settings.core.TogglePreferenceController;
+
+/**
+ * Preference controller giving the user an option to always require confirmation.
+ */
+public class FaceSettingsConfirmPreferenceController extends TogglePreferenceController {
+
+ private static final String KEY = "security_settings_face_require_confirmation";
+
+ private static final int ON = 1;
+ private static final int OFF = 0;
+ private static final int DEFAULT = OFF;
+
+ public FaceSettingsConfirmPreferenceController(Context context) {
+ this(context, KEY);
+ }
+
+ public FaceSettingsConfirmPreferenceController(Context context,
+ String preferenceKey) {
+ super(context, preferenceKey);
+ }
+
+ @Override
+ public boolean isChecked() {
+ return Settings.Secure.getInt(mContext.getContentResolver(),
+ FACE_UNLOCK_ALWAYS_REQUIRE_CONFIRMATION, DEFAULT) == ON;
+ }
+
+ @Override
+ public boolean setChecked(boolean isChecked) {
+ return Settings.Secure.putInt(mContext.getContentResolver(),
+ FACE_UNLOCK_ALWAYS_REQUIRE_CONFIRMATION, isChecked ? ON : OFF);
+ }
+
+ @Override
+ public int getAvailabilityStatus() {
+ return AVAILABLE;
+ }
+}
diff --git a/src/com/android/settings/biometrics/fingerprint/FingerprintEnrollEnrolling.java b/src/com/android/settings/biometrics/fingerprint/FingerprintEnrollEnrolling.java
index 88e1c6a..4c1ca62 100644
--- a/src/com/android/settings/biometrics/fingerprint/FingerprintEnrollEnrolling.java
+++ b/src/com/android/settings/biometrics/fingerprint/FingerprintEnrollEnrolling.java
@@ -143,7 +143,7 @@
.setText(R.string.security_settings_fingerprint_enroll_enrolling_skip)
.setListener(this::onSkipButtonClick)
.setButtonType(FooterButton.ButtonType.SKIP)
- .setTheme(R.style.SuwGlifButton_Secondary)
+ .setTheme(R.style.SudGlifButton_Secondary)
.build()
);
diff --git a/src/com/android/settings/biometrics/fingerprint/FingerprintEnrollFindSensor.java b/src/com/android/settings/biometrics/fingerprint/FingerprintEnrollFindSensor.java
index 1b97d19..72e115b 100644
--- a/src/com/android/settings/biometrics/fingerprint/FingerprintEnrollFindSensor.java
+++ b/src/com/android/settings/biometrics/fingerprint/FingerprintEnrollFindSensor.java
@@ -53,7 +53,7 @@
.setText(R.string.skip_label)
.setListener(this::onSkipButtonClick)
.setButtonType(FooterButton.ButtonType.SKIP)
- .setTheme(R.style.SuwGlifButton_Secondary)
+ .setTheme(R.style.SudGlifButton_Secondary)
.build()
);
@@ -155,7 +155,7 @@
if (requestCode == CONFIRM_REQUEST) {
if (resultCode == RESULT_OK && data != null) {
mToken = data.getByteArrayExtra(ChooseLockSettingsHelper.EXTRA_KEY_CHALLENGE_TOKEN);
- overridePendingTransition(R.anim.suw_slide_next_in, R.anim.suw_slide_next_out);
+ overridePendingTransition(R.anim.sud_slide_next_in, R.anim.sud_slide_next_out);
getIntent().putExtra(ChooseLockSettingsHelper.EXTRA_KEY_CHALLENGE_TOKEN, mToken);
startLookingForFingerprint();
} else {
diff --git a/src/com/android/settings/biometrics/fingerprint/FingerprintEnrollFinish.java b/src/com/android/settings/biometrics/fingerprint/FingerprintEnrollFinish.java
index db7d92e..4cf3a46 100644
--- a/src/com/android/settings/biometrics/fingerprint/FingerprintEnrollFinish.java
+++ b/src/com/android/settings/biometrics/fingerprint/FingerprintEnrollFinish.java
@@ -47,7 +47,7 @@
new FooterButton.Builder(this)
.setText(R.string.fingerprint_enroll_button_add)
.setButtonType(FooterButton.ButtonType.SKIP)
- .setTheme(R.style.SuwGlifButton_Secondary)
+ .setTheme(R.style.SudGlifButton_Secondary)
.build()
);
@@ -56,7 +56,7 @@
.setText(R.string.security_settings_fingerprint_enroll_done)
.setListener(this::onNextButtonClick)
.setButtonType(FooterButton.ButtonType.NEXT)
- .setTheme(R.style.SuwGlifButton_Primary)
+ .setTheme(R.style.SudGlifButton_Primary)
.build()
);
}
diff --git a/src/com/android/settings/biometrics/fingerprint/FingerprintEnrollIntroduction.java b/src/com/android/settings/biometrics/fingerprint/FingerprintEnrollIntroduction.java
index 1ad11e3..f603e24 100644
--- a/src/com/android/settings/biometrics/fingerprint/FingerprintEnrollIntroduction.java
+++ b/src/com/android/settings/biometrics/fingerprint/FingerprintEnrollIntroduction.java
@@ -53,7 +53,7 @@
.setText(R.string.security_settings_face_enroll_introduction_cancel)
.setListener(this::onCancelButtonClick)
.setButtonType(FooterButton.ButtonType.SKIP)
- .setTheme(R.style.SuwGlifButton_Secondary)
+ .setTheme(R.style.SudGlifButton_Secondary)
.build()
);
@@ -62,7 +62,7 @@
.setText(R.string.wizard_next)
.setListener(this::onNextButtonClick)
.setButtonType(FooterButton.ButtonType.NEXT)
- .setTheme(R.style.SuwGlifButton_Primary)
+ .setTheme(R.style.SudGlifButton_Primary)
.build()
);
}
diff --git a/src/com/android/settings/bluetooth/BluetoothDeviceUpdater.java b/src/com/android/settings/bluetooth/BluetoothDeviceUpdater.java
index eab2a28..2ea3371 100644
--- a/src/com/android/settings/bluetooth/BluetoothDeviceUpdater.java
+++ b/src/com/android/settings/bluetooth/BluetoothDeviceUpdater.java
@@ -52,8 +52,6 @@
LocalBluetoothProfileManager.ServiceListener {
private static final String TAG = "BluetoothDeviceUpdater";
private static final boolean DBG = true;
- private static final String BLUETOOTH_SHOW_DEVICES_WITHOUT_NAMES_PROPERTY =
- "persist.bluetooth.showdeviceswithoutnames";
protected final DevicePreferenceCallback mDevicePreferenceCallback;
protected final Map<BluetoothDevice, Preference> mPreferenceMap;
@@ -62,8 +60,6 @@
@VisibleForTesting
protected LocalBluetoothManager mLocalManager;
- private final boolean mShowDeviceWithoutNames;
-
@VisibleForTesting
final GearPreference.OnGearClickListener mDeviceProfilesListener = pref -> {
launchDeviceDetails(pref);
@@ -79,8 +75,6 @@
DevicePreferenceCallback devicePreferenceCallback, LocalBluetoothManager localManager) {
mFragment = fragment;
mDevicePreferenceCallback = devicePreferenceCallback;
- mShowDeviceWithoutNames = SystemProperties.getBoolean(
- BLUETOOTH_SHOW_DEVICES_WITHOUT_NAMES_PROPERTY, false);
mPreferenceMap = new HashMap<>();
mLocalManager = localManager;
}
@@ -223,7 +217,7 @@
if (!mPreferenceMap.containsKey(device)) {
BluetoothDevicePreference btPreference =
new BluetoothDevicePreference(mPrefContext, cachedDevice,
- mShowDeviceWithoutNames);
+ true /* showDeviceWithoutNames */);
btPreference.setOnGearClickListener(mDeviceProfilesListener);
if (this instanceof Preference.OnPreferenceClickListener) {
btPreference.setOnPreferenceClickListener(
diff --git a/src/com/android/settings/core/PreferenceXmlParserUtils.java b/src/com/android/settings/core/PreferenceXmlParserUtils.java
index ce5c505..db6cd41 100644
--- a/src/com/android/settings/core/PreferenceXmlParserUtils.java
+++ b/src/com/android/settings/core/PreferenceXmlParserUtils.java
@@ -72,9 +72,11 @@
MetadataFlag.FLAG_NEED_PREF_SUMMARY,
MetadataFlag.FLAG_NEED_PREF_ICON,
MetadataFlag.FLAG_NEED_SEARCHABLE,
- MetadataFlag.FLAG_ALLOW_DYNAMIC_SUMMARY_IN_SLICE})
+ MetadataFlag.FLAG_ALLOW_DYNAMIC_SUMMARY_IN_SLICE,
+ MetadataFlag.FLAG_UNAVAILABLE_SLICE_SUBTITLE})
@Retention(RetentionPolicy.SOURCE)
public @interface MetadataFlag {
+
int FLAG_INCLUDE_PREF_SCREEN = 1;
int FLAG_NEED_KEY = 1 << 1;
int FLAG_NEED_PREF_TYPE = 1 << 2;
@@ -87,6 +89,7 @@
int FLAG_NEED_SEARCHABLE = 1 << 9;
int FLAG_ALLOW_DYNAMIC_SUMMARY_IN_SLICE = 1 << 10;
int FLAG_NEED_PREF_APPEND = 1 << 11;
+ int FLAG_UNAVAILABLE_SLICE_SUBTITLE = 1 << 12;
}
public static final String METADATA_PREF_TYPE = "type";
@@ -101,6 +104,8 @@
public static final String METADATA_ALLOW_DYNAMIC_SUMMARY_IN_SLICE =
"allow_dynamic_summary_in_slice";
public static final String METADATA_APPEND = "staticPreferenceLocation";
+ public static final String METADATA_UNAVAILABLE_SLICE_SUBTITLE =
+ "unavailable_slice_subtitle";
private static final String ENTRIES_SEPARATOR = "|";
@@ -249,6 +254,10 @@
preferenceMetadata.putBoolean(METADATA_APPEND,
isAppended(preferenceScreenAttributes));
}
+ if (hasFlag(flags, MetadataFlag.FLAG_UNAVAILABLE_SLICE_SUBTITLE)) {
+ preferenceMetadata.putString(METADATA_UNAVAILABLE_SLICE_SUBTITLE,
+ getUnavailableSliceSubtitle(preferenceAttributes));
+ }
metadata.add(preferenceMetadata);
preferenceAttributes.recycle();
@@ -344,6 +353,11 @@
private static boolean isAppended(TypedArray styledAttributes) {
return styledAttributes.getInt(R.styleable.PreferenceScreen_staticPreferenceLocation,
- PREPEND_VALUE) == APPEND_VALUE;
+ PREPEND_VALUE) == APPEND_VALUE;
}
-}
+
+ private static String getUnavailableSliceSubtitle(TypedArray styledAttributes) {
+ return styledAttributes.getString(
+ R.styleable.Preference_unavailableSliceSubtitle);
+ }
+}
\ No newline at end of file
diff --git a/src/com/android/settings/development/CbrsDataSwitchPreferenceController.java b/src/com/android/settings/development/CbrsDataSwitchPreferenceController.java
deleted file mode 100644
index d5c78e8..0000000
--- a/src/com/android/settings/development/CbrsDataSwitchPreferenceController.java
+++ /dev/null
@@ -1,66 +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.development;
-
-import android.content.Context;
-import android.util.Log;
-import android.telephony.TelephonyManager;
-
-import androidx.annotation.VisibleForTesting;
-import androidx.preference.SwitchPreference;
-import androidx.preference.Preference;
-
-import com.android.settings.core.PreferenceControllerMixin;
-import com.android.settingslib.development.DeveloperOptionsPreferenceController;
-
-public class CbrsDataSwitchPreferenceController extends DeveloperOptionsPreferenceController
- implements Preference.OnPreferenceChangeListener, PreferenceControllerMixin {
- private static final String CBRS_DATA_SWITCH_KEY = "cbrs_data_switch";
- private static final String TAG = "CbrsDataSwitchPreferenceController";
- private Context mContext;
-
- private TelephonyManager mTelephonyManager;
-
- public CbrsDataSwitchPreferenceController(Context context) {
- super(context);
- mContext = context;
- mTelephonyManager = mContext.getSystemService(TelephonyManager.class);
- }
-
- @Override
- public String getPreferenceKey() {
- return CBRS_DATA_SWITCH_KEY;
- }
-
- @Override
- public boolean isAvailable() {
- return mTelephonyManager != null;
- }
-
- @Override
- public boolean onPreferenceChange(Preference preference, Object newValue) {
- boolean state = (Boolean)newValue;
- return mTelephonyManager.setAlternativeNetworkState(state);
- }
-
- @Override
- public void updateState(Preference preference) {
- boolean state = mTelephonyManager.isAlternativeNetworkEnabled();
- ((SwitchPreference) mPreference).setChecked(state);
- }
-
-}
diff --git a/src/com/android/settings/development/DevelopmentOptionsActivityRequestCodes.java b/src/com/android/settings/development/DevelopmentOptionsActivityRequestCodes.java
index e65d2ad..564f2c3 100644
--- a/src/com/android/settings/development/DevelopmentOptionsActivityRequestCodes.java
+++ b/src/com/android/settings/development/DevelopmentOptionsActivityRequestCodes.java
@@ -31,6 +31,4 @@
int REQUEST_CODE_ANGLE_DRIVER_PKGS = 4;
int REQUEST_CODE_ANGLE_DRIVER_VALUES = 5;
-
- int REQUEST_CODE_UPDATED_GFX_DRIVER_DEV_OPT_IN_APP = 6;
}
diff --git a/src/com/android/settings/development/DevelopmentSettingsDashboardFragment.java b/src/com/android/settings/development/DevelopmentSettingsDashboardFragment.java
index aa9918c..2a9919a 100644
--- a/src/com/android/settings/development/DevelopmentSettingsDashboardFragment.java
+++ b/src/com/android/settings/development/DevelopmentSettingsDashboardFragment.java
@@ -423,7 +423,6 @@
controllers.add(new SelectDebugAppPreferenceController(context, fragment));
controllers.add(new WaitForDebuggerPreferenceController(context));
controllers.add(new EnableGpuDebugLayersPreferenceController(context));
- controllers.add(new UpdatedGfxDriverDevOptInPreferenceController(context, fragment));
controllers.add(new VerifyAppsOverUsbPreferenceController(context));
controllers.add(new LogdSizePreferenceController(context));
controllers.add(new LogPersistPreferenceController(context, fragment, lifecycle));
@@ -482,7 +481,6 @@
controllers.add(new SmsAccessRestrictionPreferenceController(context));
controllers.add(new ShortcutManagerThrottlingPreferenceController(context));
controllers.add(new EnableGnssRawMeasFullTrackingPreferenceController(context));
- controllers.add(new CbrsDataSwitchPreferenceController(context));
controllers.add(new DefaultLaunchPreferenceController(context, "running_apps"));
controllers.add(new DefaultLaunchPreferenceController(context, "demo_mode"));
controllers.add(new DefaultLaunchPreferenceController(context, "quick_settings_tiles"));
diff --git a/src/com/android/settings/development/UpdatedGfxDriverDevOptInPreferenceController.java b/src/com/android/settings/development/UpdatedGfxDriverDevOptInPreferenceController.java
deleted file mode 100644
index ad2131e..0000000
--- a/src/com/android/settings/development/UpdatedGfxDriverDevOptInPreferenceController.java
+++ /dev/null
@@ -1,124 +0,0 @@
-/*
- * Copyright 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.development;
-
-import static com.android.settings.development.DevelopmentOptionsActivityRequestCodes
- .REQUEST_CODE_UPDATED_GFX_DRIVER_DEV_OPT_IN_APP;
-
-import android.app.Activity;
-import android.content.Context;
-import android.content.Intent;
-import android.content.pm.ApplicationInfo;
-import android.content.pm.PackageManager;
-import android.provider.Settings;
-import androidx.annotation.VisibleForTesting;
-import androidx.preference.Preference;
-
-import com.android.settings.R;
-import com.android.settings.core.PreferenceControllerMixin;
-import com.android.settingslib.development.DeveloperOptionsPreferenceController;
-
-// TODO(b/119221883): Need to override isAvailable() to return false when updatable graphics driver is not supported.
-public class UpdatedGfxDriverDevOptInPreferenceController
- extends DeveloperOptionsPreferenceController
- implements PreferenceControllerMixin, OnActivityResultListener {
-
- private static final String UPDATED_GFX_DRIVER_DEV_OPT_IN_APP_KEY =
- "updated_gfx_driver_dev_opt_in_app";
-
- private final DevelopmentSettingsDashboardFragment mFragment;
- private final PackageManager mPackageManager;
-
- public UpdatedGfxDriverDevOptInPreferenceController(Context context,
- DevelopmentSettingsDashboardFragment fragment) {
- super(context);
- mFragment = fragment;
- mPackageManager = mContext.getPackageManager();
- }
-
- @Override
- public String getPreferenceKey() {
- return UPDATED_GFX_DRIVER_DEV_OPT_IN_APP_KEY;
- }
-
- @Override
- public boolean handlePreferenceTreeClick(Preference preference) {
- if (UPDATED_GFX_DRIVER_DEV_OPT_IN_APP_KEY.equals(preference.getKey())) {
- // pass it on to settings
- final Intent intent = getActivityStartIntent();
- mFragment.startActivityForResult(intent,
- REQUEST_CODE_UPDATED_GFX_DRIVER_DEV_OPT_IN_APP);
- return true;
- }
- return false;
- }
-
- @Override
- public void updateState(Preference preference) {
- updatePreferenceSummary();
- }
-
- @Override
- public boolean onActivityResult(int requestCode, int resultCode, Intent data) {
- if (requestCode != REQUEST_CODE_UPDATED_GFX_DRIVER_DEV_OPT_IN_APP
- || resultCode != Activity.RESULT_OK) {
- return false;
- }
- Settings.Global.putString(mContext.getContentResolver(),
- Settings.Global.UPDATED_GFX_DRIVER_DEV_OPT_IN_APP, data.getAction());
- updatePreferenceSummary();
- return true;
- }
-
- @Override
- protected void onDeveloperOptionsSwitchDisabled() {
- super.onDeveloperOptionsSwitchDisabled();
- mPreference.setSummary(mContext.getResources().getString(
- R.string.updated_gfx_driver_dev_opt_in_app_not_set));
- }
-
- @VisibleForTesting
- Intent getActivityStartIntent() {
- Intent intent = new Intent(mContext, AppPicker.class);
- intent.putExtra(AppPicker.EXTRA_NON_SYSTEM, true /* value */);
- return intent;
- }
-
- private void updatePreferenceSummary() {
- final String updatedGfxDriverDevOptInApp = Settings.Global.getString(
- mContext.getContentResolver(), Settings.Global.UPDATED_GFX_DRIVER_DEV_OPT_IN_APP);
- if (updatedGfxDriverDevOptInApp != null && !updatedGfxDriverDevOptInApp.isEmpty()) {
- mPreference.setSummary(mContext.getResources().getString(
- R.string.updated_gfx_driver_dev_opt_in_app_set,
- getAppLabel(updatedGfxDriverDevOptInApp)));
- } else {
- mPreference.setSummary(mContext.getResources().getString(
- R.string.updated_gfx_driver_dev_opt_in_app_not_set));
- }
- }
-
- private String getAppLabel(String applicationPackageName) {
- try {
- final ApplicationInfo ai = mPackageManager.getApplicationInfo(applicationPackageName,
- PackageManager.GET_DISABLED_COMPONENTS);
- final CharSequence lab = mPackageManager.getApplicationLabel(ai);
- return lab != null ? lab.toString() : applicationPackageName;
- } catch (PackageManager.NameNotFoundException e) {
- return applicationPackageName;
- }
- }
-}
diff --git a/src/com/android/settings/development/featureflags/FeatureFlagPersistent.java b/src/com/android/settings/development/featureflags/FeatureFlagPersistent.java
index d27af64..33de9c3 100644
--- a/src/com/android/settings/development/featureflags/FeatureFlagPersistent.java
+++ b/src/com/android/settings/development/featureflags/FeatureFlagPersistent.java
@@ -37,6 +37,7 @@
static {
PERSISTENT_FLAGS = new HashSet<>();
PERSISTENT_FLAGS.add(FeatureFlags.HEARING_AID_SETTINGS);
+ PERSISTENT_FLAGS.add(FeatureFlags.NETWORK_INTERNET_V2);
}
public static boolean isEnabled(Context context, String feature) {
diff --git a/src/com/android/settings/development/gup/GupDashboard.java b/src/com/android/settings/development/gup/GupDashboard.java
new file mode 100644
index 0000000..31f01dd
--- /dev/null
+++ b/src/com/android/settings/development/gup/GupDashboard.java
@@ -0,0 +1,76 @@
+/*
+ * Copyright 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.development.gup;
+
+import android.content.Context;
+import android.provider.SearchIndexableResource;
+
+import com.android.internal.logging.nano.MetricsProto;
+import com.android.settings.R;
+import com.android.settings.dashboard.DashboardFragment;
+import com.android.settings.search.BaseSearchIndexProvider;
+import com.android.settings.search.Indexable;
+import com.android.settingslib.core.AbstractPreferenceController;
+import com.android.settingslib.core.lifecycle.Lifecycle;
+import com.android.settingslib.development.DevelopmentSettingsEnabler;
+import com.android.settingslib.search.SearchIndexable;
+
+import java.util.ArrayList;
+import java.util.List;
+
+@SearchIndexable
+public class GupDashboard extends DashboardFragment {
+ private static final String TAG = "GupDashboard";
+
+ @Override
+ public int getMetricsCategory() {
+ return MetricsProto.MetricsEvent.SETTINGS_GUP_DASHBOARD;
+ }
+
+ @Override
+ protected String getLogTag() {
+ return TAG;
+ }
+
+ @Override
+ protected int getPreferenceScreenResId() {
+ return R.xml.gup_settings;
+ }
+
+ @Override
+ public int getHelpResource() {
+ return 0;
+ }
+
+ public static final Indexable.SearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
+ new BaseSearchIndexProvider() {
+ @Override
+ public List<SearchIndexableResource> getXmlResourcesToIndex(
+ Context context, boolean enabled) {
+ final List<SearchIndexableResource> result = new ArrayList<>();
+ final SearchIndexableResource sir = new SearchIndexableResource(context);
+ sir.xmlResId = R.xml.gup_settings;
+ result.add(sir);
+ return result;
+ }
+
+ @Override
+ protected boolean isPageSearchEnabled(Context context) {
+ return DevelopmentSettingsEnabler.isDevelopmentSettingsEnabled(context);
+ }
+ };
+}
diff --git a/src/com/android/settings/development/gup/GupPreferenceController.java b/src/com/android/settings/development/gup/GupPreferenceController.java
new file mode 100644
index 0000000..d4cd2f1
--- /dev/null
+++ b/src/com/android/settings/development/gup/GupPreferenceController.java
@@ -0,0 +1,205 @@
+/*
+ * Copyright 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.development.gup;
+
+import android.content.ContentResolver;
+import android.content.Context;
+import android.content.pm.ApplicationInfo;
+import android.content.pm.PackageManager;
+import android.content.res.Resources;
+import android.provider.Settings;
+
+import androidx.annotation.VisibleForTesting;
+import androidx.preference.ListPreference;
+import androidx.preference.Preference;
+import androidx.preference.PreferenceGroup;
+import androidx.preference.PreferenceScreen;
+
+import com.android.settings.R;
+import com.android.settings.core.BasePreferenceController;
+import com.android.settingslib.development.DevelopmentSettingsEnabler;
+
+import java.text.Collator;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+public class GupPreferenceController
+ extends BasePreferenceController implements Preference.OnPreferenceChangeListener {
+ private final CharSequence[] mEntryList;
+ private final String mPreferenceTitle;
+ private final String mPreferenceDefault;
+ private final String mPreferenceGup;
+ private final String mPreferenceSystem;
+
+ private final List<AppInfo> mAppInfos;
+ private final Set<String> mDevOptInApps;
+ private final Set<String> mDevOptOutApps;
+
+ public GupPreferenceController(Context context, String key) {
+ super(context, key);
+
+ final Resources resources = context.getResources();
+ mEntryList = resources.getStringArray(R.array.gup_app_preference_values);
+ mPreferenceTitle = resources.getString(R.string.gup_app_preference_title);
+ mPreferenceDefault = resources.getString(R.string.gup_app_preference_default);
+ mPreferenceGup = resources.getString(R.string.gup_app_preference_gup);
+ mPreferenceSystem = resources.getString(R.string.gup_app_preference_system);
+
+ // TODO: Move this task to background if there's potential ANR/Jank.
+ // Update the UI when all the app infos are ready.
+ mAppInfos = getAppInfos(context);
+
+ final ContentResolver contentResolver = context.getContentResolver();
+ mDevOptInApps =
+ getGlobalSettingsString(contentResolver, Settings.Global.GUP_DEV_OPT_IN_APPS);
+ mDevOptOutApps =
+ getGlobalSettingsString(contentResolver, Settings.Global.GUP_DEV_OPT_OUT_APPS);
+ }
+
+ @Override
+ public int getAvailabilityStatus() {
+ return DevelopmentSettingsEnabler.isDevelopmentSettingsEnabled(mContext)
+ ? AVAILABLE
+ : DISABLED_DEPENDENT_SETTING;
+ }
+
+ @Override
+ public void displayPreference(PreferenceScreen screen) {
+ super.displayPreference(screen);
+ final PreferenceGroup preferenceGroup =
+ (PreferenceGroup) screen.findPreference(getPreferenceKey());
+ if (preferenceGroup == null) {
+ return;
+ }
+
+ for (AppInfo appInfo : mAppInfos) {
+ preferenceGroup.addPreference(
+ createListPreference(appInfo.info.packageName, appInfo.label));
+ }
+ }
+
+ @Override
+ public boolean onPreferenceChange(Preference preference, Object newValue) {
+ final ListPreference listPref = (ListPreference) preference;
+ final String value = newValue.toString();
+ final String packageName = preference.getKey();
+
+ // When user choose a new preference, update both Sets for
+ // opt-in and opt-out apps. Then set the new summary text.
+ if (value.equals(mPreferenceSystem)) {
+ mDevOptInApps.remove(packageName);
+ mDevOptOutApps.add(packageName);
+ } else if (value.equals(mPreferenceGup)) {
+ mDevOptInApps.add(packageName);
+ mDevOptOutApps.remove(packageName);
+ } else {
+ mDevOptInApps.remove(packageName);
+ mDevOptOutApps.remove(packageName);
+ }
+ listPref.setValue(value);
+ listPref.setSummary(value);
+
+ // Push the updated Sets for opt-in and opt-out apps to
+ // corresponding Settings.Global.GUP_DEV_OPT_(IN|OUT)_APPS
+ Settings.Global.putString(mContext.getContentResolver(),
+ Settings.Global.GUP_DEV_OPT_IN_APPS, String.join(",", mDevOptInApps));
+ Settings.Global.putString(mContext.getContentResolver(),
+ Settings.Global.GUP_DEV_OPT_OUT_APPS, String.join(",", mDevOptOutApps));
+
+ return true;
+ }
+
+ // AppInfo class to achieve loading the application label only once
+ class AppInfo {
+ AppInfo(PackageManager packageManager, ApplicationInfo applicationInfo) {
+ info = applicationInfo;
+ label = packageManager.getApplicationLabel(applicationInfo).toString();
+ }
+ final ApplicationInfo info;
+ final String label;
+ }
+
+ // List of non-system packages that are installed for the current user.
+ private List<AppInfo> getAppInfos(Context context) {
+ final PackageManager packageManager = context.getPackageManager();
+ final List<ApplicationInfo> applicationInfos =
+ packageManager.getInstalledApplications(0 /* flags */);
+
+ final List<AppInfo> appInfos = new ArrayList<>();
+ for (ApplicationInfo applicationInfo : applicationInfos) {
+ if ((applicationInfo.flags & ApplicationInfo.FLAG_SYSTEM) == 0) {
+ appInfos.add(new AppInfo(packageManager, applicationInfo));
+ }
+ }
+
+ Collections.sort(appInfos, appInfoComparator);
+
+ return appInfos;
+ }
+
+ // Parse the raw comma separated package names into a String Set
+ private Set<String> getGlobalSettingsString(ContentResolver contentResolver, String name) {
+ final String settingsValue = Settings.Global.getString(contentResolver, name);
+ if (settingsValue == null) {
+ return new HashSet<>();
+ }
+
+ final Set<String> valueSet = new HashSet<>(Arrays.asList(settingsValue.split(",")));
+ valueSet.remove("");
+
+ return valueSet;
+ }
+
+ private final Comparator<AppInfo> appInfoComparator = new Comparator<AppInfo>() {
+ public final int compare(AppInfo a, AppInfo b) {
+ return Collator.getInstance().compare(a.label, b.label);
+ }
+ };
+
+ @VisibleForTesting
+ protected ListPreference createListPreference(String packageName, String appName) {
+ final ListPreference listPreference = new ListPreference(mContext);
+
+ listPreference.setKey(packageName);
+ listPreference.setTitle(appName);
+ listPreference.setDialogTitle(mPreferenceTitle);
+ listPreference.setEntries(mEntryList);
+ listPreference.setEntryValues(mEntryList);
+
+ // Initialize preference default and summary with the opt in/out choices
+ // from Settings.Global.GUP_DEV_OPT_(IN|OUT)_APPS
+ if (mDevOptOutApps.contains(packageName)) {
+ listPreference.setValue(mPreferenceSystem);
+ listPreference.setSummary(mPreferenceSystem);
+ } else if (mDevOptInApps.contains(packageName)) {
+ listPreference.setValue(mPreferenceGup);
+ listPreference.setSummary(mPreferenceGup);
+ } else {
+ listPreference.setValue(mPreferenceDefault);
+ listPreference.setSummary(mPreferenceDefault);
+ }
+
+ listPreference.setOnPreferenceChangeListener(this);
+
+ return listPreference;
+ }
+}
diff --git a/src/com/android/settings/deviceinfo/StorageWizardBase.java b/src/com/android/settings/deviceinfo/StorageWizardBase.java
index 4d6ded1..db0d0d0 100644
--- a/src/com/android/settings/deviceinfo/StorageWizardBase.java
+++ b/src/com/android/settings/deviceinfo/StorageWizardBase.java
@@ -100,7 +100,7 @@
.setText(R.string.wizard_back)
.setListener(this::onNavigateBack)
.setButtonType(FooterButton.ButtonType.OTHER)
- .setTheme(R.style.SuwGlifButton_Secondary)
+ .setTheme(R.style.SudGlifButton_Secondary)
.build()
);
mButtonFooterMixin.setPrimaryButton(
@@ -108,7 +108,7 @@
.setText(R.string.wizard_next)
.setListener(this::onNavigateNext)
.setButtonType(FooterButton.ButtonType.NEXT)
- .setTheme(R.style.SuwGlifButton_Primary)
+ .setTheme(R.style.SudGlifButton_Primary)
.build()
);
mBack = mButtonFooterMixin.getSecondaryButton();
diff --git a/src/com/android/settings/deviceinfo/aboutphone/MyDeviceInfoFragment.java b/src/com/android/settings/deviceinfo/aboutphone/MyDeviceInfoFragment.java
index 19b6975..e836d1f 100644
--- a/src/com/android/settings/deviceinfo/aboutphone/MyDeviceInfoFragment.java
+++ b/src/com/android/settings/deviceinfo/aboutphone/MyDeviceInfoFragment.java
@@ -79,8 +79,9 @@
@Override
public void onAttach(Context context) {
super.onAttach(context);
- use(FirmwareVersionPreferenceController.class).setHost(this /*parent*/);
+ use(FirmwareVersionPreferenceController.class).setHost(this /* parent */);
use(DeviceModelPreferenceController.class).setHost(this /* parent */);
+ use(ImeiInfoPreferenceController.class).setHost(this /* parent */);
mBuildNumberPreferenceController = use(BuildNumberPreferenceController.class);
mBuildNumberPreferenceController.setHost(this /* parent */);
}
@@ -121,7 +122,6 @@
}
controllers.add(deviceNamePreferenceController);
controllers.add(new SimStatusPreferenceController(context, fragment));
- controllers.add(new ImeiInfoPreferenceController(context, fragment));
controllers.add(new IpAddressPreferenceController(context, lifecycle));
controllers.add(new WifiMacAddressPreferenceController(context, lifecycle));
controllers.add(new BluetoothAddressPreferenceController(context, lifecycle));
@@ -197,7 +197,7 @@
@Override
public List<AbstractPreferenceController> createPreferenceControllers(
Context context) {
- return buildPreferenceControllers(context, null /*activity */,
+ return buildPreferenceControllers(context, null /* activity */,
null /* fragment */, null /* lifecycle */);
}
};
diff --git a/src/com/android/settings/deviceinfo/imei/ImeiInfoPreferenceController.java b/src/com/android/settings/deviceinfo/imei/ImeiInfoPreferenceController.java
index 66d68a6..96ff83c 100644
--- a/src/com/android/settings/deviceinfo/imei/ImeiInfoPreferenceController.java
+++ b/src/com/android/settings/deviceinfo/imei/ImeiInfoPreferenceController.java
@@ -19,6 +19,7 @@
import static android.telephony.TelephonyManager.PHONE_TYPE_CDMA;
import android.content.Context;
+import android.os.UserManager;
import android.telephony.TelephonyManager;
import androidx.annotation.VisibleForTesting;
@@ -27,8 +28,9 @@
import androidx.preference.PreferenceScreen;
import com.android.settings.R;
-import com.android.settings.core.PreferenceControllerMixin;
-import com.android.settingslib.deviceinfo.AbstractSimStatusImeiInfoPreferenceController;
+import com.android.settings.core.BasePreferenceController;
+import com.android.settings.slices.Copyable;
+import com.android.settingslib.Utils;
import java.util.ArrayList;
import java.util.List;
@@ -36,39 +38,30 @@
/**
* Controller that manages preference for single and multi sim devices.
*/
-public class ImeiInfoPreferenceController extends
- AbstractSimStatusImeiInfoPreferenceController implements PreferenceControllerMixin {
-
- private static final String KEY_IMEI_INFO = "imei_info";
+public class ImeiInfoPreferenceController extends BasePreferenceController implements Copyable {
private final boolean mIsMultiSim;
private final TelephonyManager mTelephonyManager;
private final List<Preference> mPreferenceList = new ArrayList<>();
- private final Fragment mFragment;
+ private Fragment mFragment;
- public ImeiInfoPreferenceController(Context context, Fragment fragment) {
- super(context);
-
- mFragment = fragment;
+ public ImeiInfoPreferenceController(Context context, String key) {
+ super(context, key);
mTelephonyManager = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
mIsMultiSim = mTelephonyManager.getPhoneCount() > 1;
}
- @Override
- public String getPreferenceKey() {
- return KEY_IMEI_INFO;
+ public void setHost(Fragment fragment) {
+ mFragment = fragment;
}
@Override
public void displayPreference(PreferenceScreen screen) {
super.displayPreference(screen);
final Preference preference = screen.findPreference(getPreferenceKey());
- if (!isAvailable() || preference == null || !preference.isVisible()) {
- return;
- }
mPreferenceList.add(preference);
- updatePreference(preference, 0 /* sim slot */);
+ updatePreference(preference, 0 /* simSlot */);
final int imeiPreferenceOrder = preference.getOrder();
// Add additional preferences for each sim in the device
@@ -76,7 +69,7 @@
simSlotNumber++) {
final Preference multiSimPreference = createNewPreference(screen.getContext());
multiSimPreference.setOrder(imeiPreferenceOrder + simSlotNumber);
- multiSimPreference.setKey(KEY_IMEI_INFO + simSlotNumber);
+ multiSimPreference.setKey(getPreferenceKey() + simSlotNumber);
screen.addPreference(multiSimPreference);
mPreferenceList.add(multiSimPreference);
updatePreference(multiSimPreference, simSlotNumber);
@@ -84,6 +77,13 @@
}
@Override
+ public CharSequence getSummary() {
+ final int phoneType = mTelephonyManager.getPhoneType();
+ return phoneType == PHONE_TYPE_CDMA ? mTelephonyManager.getMeid()
+ : mTelephonyManager.getImei();
+ }
+
+ @Override
public boolean handlePreferenceTreeClick(Preference preference) {
final int simSlot = mPreferenceList.indexOf(preference);
if (simSlot == -1) {
@@ -94,6 +94,22 @@
return true;
}
+ @Override
+ public int getAvailabilityStatus() {
+ return mContext.getSystemService(UserManager.class).isAdminUser()
+ && !Utils.isWifiOnly(mContext) ? AVAILABLE : UNSUPPORTED_ON_DEVICE;
+ }
+
+ @Override
+ public boolean isSliceable() {
+ return true;
+ }
+
+ @Override
+ public void copy() {
+ Copyable.setCopyContent(mContext, getSummary(), mContext.getText(R.string.status_imei));
+ }
+
private void updatePreference(Preference preference, int simSlot) {
final int phoneType = mTelephonyManager.getPhoneType();
if (phoneType == PHONE_TYPE_CDMA) {
diff --git a/src/com/android/settings/display/TimeoutListPreference.java b/src/com/android/settings/display/TimeoutListPreference.java
index f9a731d..5ed427f 100644
--- a/src/com/android/settings/display/TimeoutListPreference.java
+++ b/src/com/android/settings/display/TimeoutListPreference.java
@@ -26,6 +26,7 @@
import android.util.Log;
import android.view.View;
+import androidx.annotation.VisibleForTesting;
import androidx.appcompat.app.AlertDialog.Builder;
import com.android.settings.R;
@@ -33,18 +34,18 @@
import com.android.settingslib.RestrictedLockUtils;
import java.util.ArrayList;
+import java.util.List;
public class TimeoutListPreference extends RestrictedListPreference {
private static final String TAG = "TimeoutListPreference";
private EnforcedAdmin mAdmin;
- private final CharSequence[] mInitialEntries;
- private final CharSequence[] mInitialValues;
+ private CharSequence[] mInitialEntries;
+ private CharSequence[] mInitialValues;
public TimeoutListPreference(Context context, AttributeSet attrs) {
super(context, attrs);
- mInitialEntries = getEntries();
- mInitialValues = getEntryValues();
+ updateInitialValues();
}
@Override
@@ -65,13 +66,8 @@
if (mAdmin != null) {
View footerView = dialog.findViewById(R.id.admin_disabled_other_options);
footerView.findViewById(R.id.admin_more_details_link).setOnClickListener(
- new View.OnClickListener() {
- @Override
- public void onClick(View view) {
- RestrictedLockUtils.sendShowAdminSupportDetailsIntent(
- getContext(), mAdmin);
- }
- });
+ view -> RestrictedLockUtils.sendShowAdminSupportDetailsIntent(
+ getContext(), mAdmin));
}
}
@@ -89,8 +85,8 @@
maxTimeout = Long.MAX_VALUE;
}
- ArrayList<CharSequence> revisedEntries = new ArrayList<CharSequence>();
- ArrayList<CharSequence> revisedValues = new ArrayList<CharSequence>();
+ final ArrayList<CharSequence> revisedEntries = new ArrayList<>();
+ final ArrayList<CharSequence> revisedValues = new ArrayList<>();
for (int i = 0; i < mInitialValues.length; ++i) {
long timeout = Long.parseLong(mInitialValues[i].toString());
if (timeout <= maxTimeout) {
@@ -101,7 +97,7 @@
// If there are no possible options for the user, then set this preference as disabled
// by admin, otherwise remove the padlock in case it was set earlier.
- if (revisedValues.size() == 0) {
+ if (revisedValues.isEmpty()) {
setDisabledByAdmin(admin);
return;
} else {
@@ -117,7 +113,7 @@
setValue(String.valueOf(userPreference));
} else if (revisedValues.size() > 0
&& Long.parseLong(revisedValues.get(revisedValues.size() - 1).toString())
- == maxTimeout) {
+ == maxTimeout) {
// If the last one happens to be the same as the max timeout, select that
setValue(String.valueOf(maxTimeout));
} else {
@@ -128,4 +124,36 @@
}
}
}
+
+ @VisibleForTesting
+ void updateInitialValues() {
+ // Read default list of candidate values.
+ final CharSequence[] entries = getEntries();
+ final CharSequence[] values = getEntryValues();
+ // Filter out values based on config
+ final List<CharSequence> revisedEntries = new ArrayList<>();
+ final List<CharSequence> revisedValues = new ArrayList<>();
+ final long maxTimeout = getContext().getResources().getInteger(
+ R.integer.max_lock_after_timeout_ms);
+ if (entries == null || values == null) {
+ return;
+ }
+ Log.d(TAG, "max timeout: " + maxTimeout);
+ for (int i = 0; i < values.length; ++i) {
+ long timeout = Long.parseLong(values[i].toString());
+ if (timeout <= maxTimeout) {
+ Log.d(TAG, "keeping timeout: " + values[i]);
+ revisedEntries.add(entries[i]);
+ revisedValues.add(values[i]);
+ } else {
+ Log.d(TAG, "Dropping timeout: " + values[i]);
+ }
+ }
+
+ // Store final candidates in initial value lists.
+ mInitialEntries = revisedEntries.toArray(new CharSequence[0]);
+ setEntries(mInitialEntries);
+ mInitialValues = revisedValues.toArray(new CharSequence[0]);
+ setEntryValues(mInitialValues);
+ }
}
diff --git a/src/com/android/settings/display/TimeoutPreferenceController.java b/src/com/android/settings/display/TimeoutPreferenceController.java
index 60b7e24..c1c5069 100644
--- a/src/com/android/settings/display/TimeoutPreferenceController.java
+++ b/src/com/android/settings/display/TimeoutPreferenceController.java
@@ -13,8 +13,6 @@
*/
package com.android.settings.display;
-import static android.provider.Settings.System.SCREEN_OFF_TIMEOUT;
-
import android.app.admin.DevicePolicyManager;
import android.content.Context;
import android.os.UserHandle;
@@ -60,7 +58,7 @@
public void updateState(Preference preference) {
final TimeoutListPreference timeoutListPreference = (TimeoutListPreference) preference;
final long currentTimeout = Settings.System.getLong(mContext.getContentResolver(),
- SCREEN_OFF_TIMEOUT, FALLBACK_SCREEN_TIMEOUT_VALUE);
+ Settings.System.SCREEN_OFF_TIMEOUT, FALLBACK_SCREEN_TIMEOUT_VALUE);
timeoutListPreference.setValue(String.valueOf(currentTimeout));
final DevicePolicyManager dpm =
(DevicePolicyManager) mContext.getSystemService(Context.DEVICE_POLICY_SERVICE);
@@ -86,7 +84,8 @@
public boolean onPreferenceChange(Preference preference, Object newValue) {
try {
int value = Integer.parseInt((String) newValue);
- Settings.System.putInt(mContext.getContentResolver(), SCREEN_OFF_TIMEOUT, value);
+ Settings.System.putInt(mContext.getContentResolver(),
+ Settings.System.SCREEN_OFF_TIMEOUT, value);
updateTimeoutPreferenceDescription((TimeoutListPreference) preference, value);
} catch (NumberFormatException e) {
Log.e(TAG, "could not persist screen timeout setting", e);
@@ -94,7 +93,7 @@
return true;
}
- public static CharSequence getTimeoutDescription(
+ private static CharSequence getTimeoutDescription(
long currentTimeout, CharSequence[] entries, CharSequence[] values) {
if (currentTimeout < 0 || entries == null || values == null
|| values.length != entries.length) {
diff --git a/src/com/android/settings/fuelgauge/BatteryHeaderPreferenceController.java b/src/com/android/settings/fuelgauge/BatteryHeaderPreferenceController.java
index 48f4cc1..3064d4f 100644
--- a/src/com/android/settings/fuelgauge/BatteryHeaderPreferenceController.java
+++ b/src/com/android/settings/fuelgauge/BatteryHeaderPreferenceController.java
@@ -21,8 +21,10 @@
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
+import android.icu.text.NumberFormat;
import android.os.BatteryManager;
import android.os.PowerManager;
+import android.text.TextUtils;
import android.widget.TextView;
import androidx.annotation.VisibleForTesting;
@@ -83,7 +85,7 @@
@Override
public void displayPreference(PreferenceScreen screen) {
super.displayPreference(screen);
- mBatteryLayoutPref = (LayoutPreference) screen.findPreference(getPreferenceKey());
+ mBatteryLayoutPref = screen.findPreference(getPreferenceKey());
mBatteryMeterView = mBatteryLayoutPref
.findViewById(R.id.battery_header_icon);
mBatteryPercentText = mBatteryLayoutPref.findViewById(R.id.battery_percent);
@@ -107,7 +109,7 @@
}
public void updateHeaderPreference(BatteryInfo info) {
- mBatteryPercentText.setText(Utils.formatPercentage(info.batteryLevel));
+ mBatteryPercentText.setText(formatBatteryPercentageText(info.batteryLevel));
if (info.remainingLabel == null) {
mSummary1.setText(info.statusLabel);
} else {
@@ -133,6 +135,11 @@
mBatteryMeterView.setBatteryLevel(batteryLevel);
mBatteryMeterView.setCharging(!discharging);
mBatteryMeterView.setPowerSave(mPowerManager.isPowerSaveMode());
- mBatteryPercentText.setText(Utils.formatPercentage(batteryLevel));
+ mBatteryPercentText.setText(formatBatteryPercentageText(batteryLevel));
+ }
+
+ private CharSequence formatBatteryPercentageText(int batteryLevel) {
+ return TextUtils.expandTemplate(mContext.getText(R.string.battery_header_title_alternate),
+ NumberFormat.getIntegerInstance().format(batteryLevel));
}
}
diff --git a/src/com/android/settings/fuelgauge/batterysaver/BatterySaverScheduleSeekBarController.java b/src/com/android/settings/fuelgauge/batterysaver/BatterySaverScheduleSeekBarController.java
index 215f400..6c11576 100644
--- a/src/com/android/settings/fuelgauge/batterysaver/BatterySaverScheduleSeekBarController.java
+++ b/src/com/android/settings/fuelgauge/batterysaver/BatterySaverScheduleSeekBarController.java
@@ -54,9 +54,11 @@
mContext = context;
mSeekBarPreference = new SeekBarPreference(context);
mSeekBarPreference.setOnPreferenceChangeListener(this);
- mSeekBarPreference.setMax(BatterySaverScheduleSeekBarController.MAX_SEEKBAR_VALUE);
- mSeekBarPreference.setMin(BatterySaverScheduleSeekBarController.MIN_SEEKBAR_VALUE);
+ mSeekBarPreference.setContinuousUpdates(true);
+ mSeekBarPreference.setMax(MAX_SEEKBAR_VALUE);
+ mSeekBarPreference.setMin(MIN_SEEKBAR_VALUE);
mSeekBarPreference.setKey(KEY_BATTERY_SAVER_SEEK_BAR);
+ updateSeekBar();
}
@Override
@@ -83,11 +85,12 @@
if (threshold <= 0) {
mSeekBarPreference.setVisible(false);
} else {
+ final int currentSeekbarValue = Math.max(threshold / 5, MIN_SEEKBAR_VALUE);
mSeekBarPreference.setVisible(true);
- mSeekBarPreference.setProgress(MIN_SEEKBAR_VALUE);
+ mSeekBarPreference.setProgress(currentSeekbarValue);
mSeekBarPreference.setTitle(mContext.getString(
R.string.battery_saver_seekbar_title,
- Utils.formatPercentage(MIN_SEEKBAR_VALUE * 5)));
+ Utils.formatPercentage(currentSeekbarValue * 5)));
}
} else {
mSeekBarPreference.setVisible(false);
diff --git a/src/com/android/settings/fuelgauge/batterysaver/BatterySaverScheduleSettings.java b/src/com/android/settings/fuelgauge/batterysaver/BatterySaverScheduleSettings.java
index 6e9c711..bfd36f3 100644
--- a/src/com/android/settings/fuelgauge/batterysaver/BatterySaverScheduleSettings.java
+++ b/src/com/android/settings/fuelgauge/batterysaver/BatterySaverScheduleSettings.java
@@ -17,10 +17,14 @@
package com.android.settings.fuelgauge.batterysaver;
import android.content.Context;
+import android.graphics.Color;
+import android.graphics.drawable.ColorDrawable;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.text.TextUtils;
import android.view.View;
+import androidx.annotation.NonNull;
+import androidx.annotation.Nullable;
import androidx.preference.PreferenceScreen;
import com.android.settings.widget.RadioButtonPickerFragment;
import com.android.settings.R;
@@ -59,6 +63,13 @@
}
@Override
+ public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
+ super.onViewCreated(view, savedInstanceState);
+ setDivider(new ColorDrawable(Color.TRANSPARENT));
+ setDividerHeight(0);
+ }
+
+ @Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
}
diff --git a/src/com/android/settings/gestures/PreventRingingGesturePreferenceController.java b/src/com/android/settings/gestures/PreventRingingGesturePreferenceController.java
index cb9bf4f..8f037ce 100644
--- a/src/com/android/settings/gestures/PreventRingingGesturePreferenceController.java
+++ b/src/com/android/settings/gestures/PreventRingingGesturePreferenceController.java
@@ -46,7 +46,7 @@
OnResume, OnPause, OnCreate, PreferenceControllerMixin {
@VisibleForTesting static final String KEY_VIBRATE = "prevent_ringing_option_vibrate";
- @VisibleForTesting static final String KEY_NONE = "prevent_ringing_option_none";
+
@VisibleForTesting static final String KEY_MUTE = "prevent_ringing_option_mute";
private final String KEY_VIDEO_PAUSED = "key_video_paused";
@@ -57,9 +57,8 @@
private VideoPreference mVideoPreference;
private boolean mVideoPaused;
- private PreferenceCategory mPreferenceCategory;
+ @VisibleForTesting PreferenceCategory mPreferenceCategory;
@VisibleForTesting RadioButtonPreference mVibratePref;
- @VisibleForTesting RadioButtonPreference mNonePref;
@VisibleForTesting RadioButtonPreference mMutePref;
private SettingObserver mSettingObserver;
@@ -80,7 +79,6 @@
mPreferenceCategory = (PreferenceCategory) screen.findPreference(getPreferenceKey());
mVibratePref = makeRadioPreference(KEY_VIBRATE, R.string.prevent_ringing_option_vibrate);
mMutePref = makeRadioPreference(KEY_MUTE, R.string.prevent_ringing_option_mute);
- mNonePref = makeRadioPreference(KEY_NONE, R.string.prevent_ringing_option_none);
if (mPreferenceCategory != null) {
mSettingObserver = new SettingObserver(mPreferenceCategory);
@@ -124,19 +122,21 @@
public void updateState(Preference preference) {
int preventRingingSetting = Settings.Secure.getInt(mContext.getContentResolver(),
Settings.Secure.VOLUME_HUSH_GESTURE, Settings.Secure.VOLUME_HUSH_VIBRATE);
-
final boolean isVibrate = preventRingingSetting == Settings.Secure.VOLUME_HUSH_VIBRATE;
final boolean isMute = preventRingingSetting == Settings.Secure.VOLUME_HUSH_MUTE;
- final boolean isOff = preventRingingSetting == Settings.Secure.VOLUME_HUSH_OFF
- || (!isVibrate && !isMute);
if (mVibratePref != null && mVibratePref.isChecked() != isVibrate) {
mVibratePref.setChecked(isVibrate);
}
if (mMutePref != null && mMutePref.isChecked() != isMute) {
mMutePref.setChecked(isMute);
}
- if (mNonePref != null && mNonePref.isChecked() != isOff) {
- mNonePref.setChecked(isOff);
+
+ if (preventRingingSetting == Settings.Secure.VOLUME_HUSH_OFF) {
+ mVibratePref.setEnabled(false);
+ mMutePref.setEnabled(false);
+ } else {
+ mVibratePref.setEnabled(true);
+ mMutePref.setEnabled(true);
}
}
@@ -173,13 +173,12 @@
private int keyToSetting(String key) {
switch (key) {
- case KEY_NONE:
- return Settings.Secure.VOLUME_HUSH_OFF;
case KEY_MUTE:
return Settings.Secure.VOLUME_HUSH_MUTE;
case KEY_VIBRATE:
- default:
return Settings.Secure.VOLUME_HUSH_VIBRATE;
+ default:
+ return Settings.Secure.VOLUME_HUSH_OFF;
}
}
diff --git a/src/com/android/settings/gestures/PreventRingingGestureSettings.java b/src/com/android/settings/gestures/PreventRingingGestureSettings.java
index 3e8ae85..420a019 100644
--- a/src/com/android/settings/gestures/PreventRingingGestureSettings.java
+++ b/src/com/android/settings/gestures/PreventRingingGestureSettings.java
@@ -35,7 +35,6 @@
public class PreventRingingGestureSettings extends DashboardFragment {
private static final String TAG = "RingingGestureSettings";
- private static final String KEY_PREVENT_RINGING = "gesture_prevent_ringing";
@Override
public void onAttach(Context context) {
@@ -51,6 +50,7 @@
Lifecycle lifecycle) {
List<AbstractPreferenceController> controllers = new ArrayList<>();
controllers.add(new PreventRingingGesturePreferenceController(context, lifecycle));
+ controllers.add(new PreventRingingSwitchPreferenceController(context));
return controllers;
}
diff --git a/src/com/android/settings/gestures/PreventRingingSwitchPreferenceController.java b/src/com/android/settings/gestures/PreventRingingSwitchPreferenceController.java
new file mode 100644
index 0000000..b94cfff
--- /dev/null
+++ b/src/com/android/settings/gestures/PreventRingingSwitchPreferenceController.java
@@ -0,0 +1,125 @@
+/*
+ * 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.ContentResolver;
+import android.content.Context;
+import android.database.ContentObserver;
+import android.net.Uri;
+import android.os.Handler;
+import android.provider.Settings;
+import android.widget.Switch;
+
+import androidx.annotation.VisibleForTesting;
+import androidx.preference.Preference;
+import androidx.preference.PreferenceScreen;
+
+import com.android.settings.R;
+import com.android.settings.core.PreferenceControllerMixin;
+import com.android.settings.widget.SwitchBar;
+import com.android.settingslib.core.AbstractPreferenceController;
+import com.android.settingslib.widget.LayoutPreference;
+
+public class PreventRingingSwitchPreferenceController extends AbstractPreferenceController
+ implements PreferenceControllerMixin, SwitchBar.OnSwitchChangeListener {
+
+ private static final String KEY = "gesture_prevent_ringing_switch";
+ private final Context mContext;
+ private SettingObserver mSettingObserver;
+
+ @VisibleForTesting SwitchBar mSwitch;
+
+ public PreventRingingSwitchPreferenceController(Context context) {
+ super(context);
+ mContext = context;
+ }
+
+ @Override
+ public String getPreferenceKey() {
+ return KEY;
+ }
+
+ @Override
+ public void displayPreference(PreferenceScreen screen) {
+ super.displayPreference(screen);
+ if (isAvailable()) {
+ LayoutPreference pref = (LayoutPreference) screen.findPreference(getPreferenceKey());
+ if (pref != null) {
+ mSettingObserver = new SettingObserver(pref);
+ mSwitch = pref.findViewById(R.id.switch_bar);
+ if (mSwitch != null) {
+ mSwitch.addOnSwitchChangeListener(this);
+ mSwitch.show();
+ }
+ }
+ }
+ }
+
+ public void setChecked(boolean isChecked) {
+ if (mSwitch != null) {
+ mSwitch.setChecked(isChecked);
+ }
+ }
+
+ @Override
+ public void updateState(Preference preference) {
+ int preventRingingSetting = Settings.Secure.getInt(mContext.getContentResolver(),
+ Settings.Secure.VOLUME_HUSH_GESTURE, Settings.Secure.VOLUME_HUSH_VIBRATE);
+ setChecked(preventRingingSetting != Settings.Secure.VOLUME_HUSH_OFF);
+ }
+
+ @Override
+ public boolean isAvailable() {
+ return mContext.getResources().getBoolean(
+ com.android.internal.R.bool.config_volumeHushGestureEnabled);
+ }
+
+ @Override
+ public void onSwitchChanged(Switch switchView, boolean isChecked) {
+ Settings.Secure.putInt(mContext.getContentResolver(),
+ Settings.Secure.VOLUME_HUSH_GESTURE, isChecked ? Settings.Secure.VOLUME_HUSH_VIBRATE
+ : Settings.Secure.VOLUME_HUSH_OFF);
+ }
+
+ private class SettingObserver extends ContentObserver {
+ private final Uri VOLUME_HUSH_GESTURE = Settings.Secure.getUriFor(
+ Settings.Secure.VOLUME_HUSH_GESTURE);
+
+ private final Preference mPreference;
+
+ public SettingObserver(Preference preference) {
+ super(new Handler());
+ mPreference = preference;
+ }
+
+ public void register(ContentResolver cr) {
+ cr.registerContentObserver(VOLUME_HUSH_GESTURE, false, this);
+ }
+
+ public void unregister(ContentResolver cr) {
+ cr.unregisterContentObserver(this);
+ }
+
+ @Override
+ public void onChange(boolean selfChange, Uri uri) {
+ super.onChange(selfChange, uri);
+ if (uri == null || VOLUME_HUSH_GESTURE.equals(uri)) {
+ updateState(mPreference);
+ }
+ }
+ }
+}
diff --git a/src/com/android/settings/homepage/SettingsHomepageActivity.java b/src/com/android/settings/homepage/SettingsHomepageActivity.java
index d3f11a0..d40006f 100644
--- a/src/com/android/settings/homepage/SettingsHomepageActivity.java
+++ b/src/com/android/settings/homepage/SettingsHomepageActivity.java
@@ -19,6 +19,7 @@
import android.content.Intent;
import android.os.Bundle;
import android.util.FeatureFlagUtils;
+import android.view.View;
import android.widget.ImageView;
import android.widget.Toolbar;
@@ -47,6 +48,7 @@
return;
}
+ updateWindowProperties();
setContentView(R.layout.settings_homepage_container);
final Toolbar toolbar = findViewById(R.id.search_action_bar);
@@ -73,4 +75,15 @@
}
fragmentTransaction.commit();
}
+
+ private void updateWindowProperties() {
+ final View decorView = getWindow().getDecorView();
+ decorView.setSystemUiVisibility(
+ decorView.getSystemUiVisibility() |
+ View.SYSTEM_UI_FLAG_LAYOUT_STABLE |
+ View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
+ );
+
+ getWindow().setStatusBarColor(getResources().getColor(R.color.homepage_status_bar_color));
+ }
}
\ No newline at end of file
diff --git a/src/com/android/settings/homepage/contextualcards/ContextualCardLoader.java b/src/com/android/settings/homepage/contextualcards/ContextualCardLoader.java
index 88478e3..49e2a76 100644
--- a/src/com/android/settings/homepage/contextualcards/ContextualCardLoader.java
+++ b/src/com/android/settings/homepage/contextualcards/ContextualCardLoader.java
@@ -107,12 +107,12 @@
}
}
}
- return getFinalDisplayableCards(result);
+ return getDisplayableCards(result);
}
// Get final displayed cards and log what cards will be displayed/hidden
@VisibleForTesting
- List<ContextualCard> getFinalDisplayableCards(List<ContextualCard> candidates) {
+ List<ContextualCard> getDisplayableCards(List<ContextualCard> candidates) {
final List<ContextualCard> eligibleCards = filterEligibleCards(candidates);
final List<ContextualCard> visibleCards = new ArrayList<>();
final List<ContextualCard> hiddenCards = new ArrayList<>();
diff --git a/src/com/android/settings/homepage/contextualcards/ContextualCardLookupTable.java b/src/com/android/settings/homepage/contextualcards/ContextualCardLookupTable.java
index a4a8419..90974f6 100644
--- a/src/com/android/settings/homepage/contextualcards/ContextualCardLookupTable.java
+++ b/src/com/android/settings/homepage/contextualcards/ContextualCardLookupTable.java
@@ -84,7 +84,11 @@
LegacySuggestionContextualCardController.class,
LegacySuggestionContextualCardRenderer.class));
add(new ControllerRendererMapping(CardType.SLICE,
- SliceContextualCardRenderer.VIEW_TYPE,
+ SliceContextualCardRenderer.VIEW_TYPE_FULL_WIDTH,
+ SliceContextualCardController.class,
+ SliceContextualCardRenderer.class));
+ add(new ControllerRendererMapping(CardType.SLICE,
+ SliceContextualCardRenderer.VIEW_TYPE_HALF_WIDTH,
SliceContextualCardController.class,
SliceContextualCardRenderer.class));
add(new ControllerRendererMapping(CardType.CONDITIONAL_FOOTER,
diff --git a/src/com/android/settings/homepage/contextualcards/ContextualCardManager.java b/src/com/android/settings/homepage/contextualcards/ContextualCardManager.java
index 067de7c..12088f8 100644
--- a/src/com/android/settings/homepage/contextualcards/ContextualCardManager.java
+++ b/src/com/android/settings/homepage/contextualcards/ContextualCardManager.java
@@ -17,6 +17,7 @@
package com.android.settings.homepage.contextualcards;
import static com.android.settings.homepage.contextualcards.ContextualCardLoader.CARD_CONTENT_LOADER_ID;
+import static com.android.settings.intelligence.ContextualCardProto.ContextualCard.Category.SUGGESTION_VALUE;
import static java.util.stream.Collectors.groupingBy;
@@ -172,7 +173,8 @@
//replace with the new data
mContextualCards.clear();
- mContextualCards.addAll(sortCards(allCards));
+ final List<ContextualCard> sortedCards = sortCards(allCards);
+ mContextualCards.addAll(assignCardWidth(sortedCards));
loadCardControllers();
@@ -224,6 +226,24 @@
mListener = listener;
}
+ @VisibleForTesting
+ List<ContextualCard> assignCardWidth(List<ContextualCard> cards) {
+ final List<ContextualCard> result = new ArrayList<>(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.
+ for (int index = 1; index < result.size(); index++) {
+ final ContextualCard previous = result.get(index - 1);
+ final ContextualCard current = result.get(index);
+ if (current.getCategory() == SUGGESTION_VALUE
+ && previous.getCategory() == SUGGESTION_VALUE) {
+ result.set(index - 1, previous.mutate().setIsHalfWidth(true).build());
+ result.set(index, current.mutate().setIsHalfWidth(true).build());
+ index++;
+ }
+ }
+ return result;
+ }
+
private List<ContextualCard> getCardsToKeep(List<ContextualCard> cards) {
if (mSavedCards != null) {
//screen rotate
diff --git a/src/com/android/settings/homepage/contextualcards/conditional/BatterySaverConditionController.java b/src/com/android/settings/homepage/contextualcards/conditional/BatterySaverConditionController.java
new file mode 100644
index 0000000..bce7c5d
--- /dev/null
+++ b/src/com/android/settings/homepage/contextualcards/conditional/BatterySaverConditionController.java
@@ -0,0 +1,108 @@
+/*
+ * 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.homepage.contextualcards.conditional;
+
+import android.content.Context;
+import android.os.PowerManager;
+
+import com.android.internal.logging.nano.MetricsProto;
+import com.android.settings.R;
+import com.android.settings.core.SubSettingLauncher;
+import com.android.settings.fuelgauge.BatterySaverReceiver;
+import com.android.settings.fuelgauge.batterysaver.BatterySaverSettings;
+import com.android.settings.homepage.contextualcards.ContextualCard;
+import com.android.settingslib.fuelgauge.BatterySaverUtils;
+
+import java.util.Objects;
+
+public class BatterySaverConditionController implements ConditionalCardController,
+ BatterySaverReceiver.BatterySaverListener {
+ static final int ID = Objects.hash("BatterySaverConditionController");
+
+ private final Context mAppContext;
+ private final ConditionManager mConditionManager;
+ private final BatterySaverReceiver mReceiver;
+ private final PowerManager mPowerManager;
+
+ public BatterySaverConditionController(Context appContext, ConditionManager conditionManager) {
+ mAppContext = appContext;
+ mConditionManager = conditionManager;
+ mPowerManager = appContext.getSystemService(PowerManager.class);
+ mReceiver = new BatterySaverReceiver(appContext);
+ mReceiver.setBatterySaverListener(this);
+ }
+
+ @Override
+ public long getId() {
+ return ID;
+ }
+
+ @Override
+ public boolean isDisplayable() {
+ return mPowerManager.isPowerSaveMode();
+ }
+
+ @Override
+ public void onPrimaryClick(Context context) {
+ new SubSettingLauncher(context)
+ .setDestination(BatterySaverSettings.class.getName())
+ .setSourceMetricsCategory(MetricsProto.MetricsEvent.DASHBOARD_SUMMARY)
+ .setTitleRes(R.string.battery_saver)
+ .launch();
+ }
+
+ @Override
+ public void onActionClick() {
+ BatterySaverUtils.setPowerSaveMode(mAppContext, false,
+ /*needFirstTimeWarning*/ false);
+ }
+
+ @Override
+ public ContextualCard buildContextualCard() {
+ return new ConditionalContextualCard.Builder()
+ .setConditionId(ID)
+ .setMetricsConstant(MetricsProto.MetricsEvent.SETTINGS_CONDITION_BATTERY_SAVER)
+ .setActionText(mAppContext.getText(R.string.condition_turn_off))
+ .setName(mAppContext.getPackageName() + "/"
+ + mAppContext.getText(R.string.condition_battery_title))
+ .setTitleText(mAppContext.getText(R.string.condition_battery_title).toString())
+ .setSummaryText(mAppContext.getText(R.string.condition_battery_summary).toString())
+ .setIconDrawable(mAppContext.getDrawable(R.drawable.ic_battery_saver_accent_24dp))
+ .setIsHalfWidth(true)
+ .build();
+ }
+
+ @Override
+ public void startMonitoringStateChange() {
+ mReceiver.setListening(true);
+ }
+
+ @Override
+ public void stopMonitoringStateChange() {
+ mReceiver.setListening(false);
+ }
+
+ @Override
+ public void onPowerSaveModeChanged() {
+ mConditionManager.onConditionChanged();
+ }
+
+ @Override
+ public void onBatteryChanged(boolean pluggedIn) {
+
+ }
+}
diff --git a/src/com/android/settings/homepage/contextualcards/conditional/ConditionContextualCardController.java b/src/com/android/settings/homepage/contextualcards/conditional/ConditionContextualCardController.java
index 834ebbc..b477d52 100644
--- a/src/com/android/settings/homepage/contextualcards/conditional/ConditionContextualCardController.java
+++ b/src/com/android/settings/homepage/contextualcards/conditional/ConditionContextualCardController.java
@@ -40,7 +40,7 @@
*/
public class ConditionContextualCardController implements ContextualCardController,
ConditionListener, LifecycleObserver, OnStart, OnStop {
- public static final int EXPANDING_THRESHOLD = 2;
+ public static final int EXPANDING_THRESHOLD = 0;
private static final double UNSUPPORTED_RANKING = -99999.0;
private static final String TAG = "ConditionCtxCardCtrl";
diff --git a/src/com/android/settings/homepage/contextualcards/conditional/ConditionManager.java b/src/com/android/settings/homepage/contextualcards/conditional/ConditionManager.java
index 39f4903..c741b98 100644
--- a/src/com/android/settings/homepage/contextualcards/conditional/ConditionManager.java
+++ b/src/com/android/settings/homepage/contextualcards/conditional/ConditionManager.java
@@ -154,6 +154,7 @@
mCardControllers.add(new AirplaneModeConditionController(mAppContext, this /* manager */));
mCardControllers.add(
new BackgroundDataConditionController(mAppContext, this /* manager */));
+ mCardControllers.add(new BatterySaverConditionController(mAppContext, this /* manager */));
mCardControllers.add(new CellularDataConditionController(mAppContext, this /* manager */));
mCardControllers.add(new DndConditionCardController(mAppContext, this /* manager */));
mCardControllers.add(new HotspotConditionController(mAppContext, this /* manager */));
diff --git a/src/com/android/settings/homepage/contextualcards/deviceinfo/BatterySlice.java b/src/com/android/settings/homepage/contextualcards/deviceinfo/BatteryInfoSlice.java
similarity index 96%
rename from src/com/android/settings/homepage/contextualcards/deviceinfo/BatterySlice.java
rename to src/com/android/settings/homepage/contextualcards/deviceinfo/BatteryInfoSlice.java
index 5271e12..41095a4 100644
--- a/src/com/android/settings/homepage/contextualcards/deviceinfo/BatterySlice.java
+++ b/src/com/android/settings/homepage/contextualcards/deviceinfo/BatteryInfoSlice.java
@@ -42,15 +42,15 @@
/**
* Utility class to build a Battery Slice, and handle all associated actions.
*/
-public class BatterySlice implements CustomSliceable {
- private static final String TAG = "BatterySlice";
+public class BatteryInfoSlice implements CustomSliceable {
+ private static final String TAG = "BatteryInfoSlice";
private final Context mContext;
private BatteryInfo mBatteryInfo;
private boolean mIsBatteryInfoLoading;
- public BatterySlice(Context context) {
+ public BatteryInfoSlice(Context context) {
mContext = context;
}
diff --git a/src/com/android/settings/homepage/contextualcards/slices/BatteryFixSlice.java b/src/com/android/settings/homepage/contextualcards/slices/BatteryFixSlice.java
index ab1b4c9..c0cfb3f 100644
--- a/src/com/android/settings/homepage/contextualcards/slices/BatteryFixSlice.java
+++ b/src/com/android/settings/homepage/contextualcards/slices/BatteryFixSlice.java
@@ -25,7 +25,6 @@
import android.content.Intent;
import android.content.SharedPreferences;
import android.net.Uri;
-import android.util.Log;
import androidx.annotation.VisibleForTesting;
import androidx.annotation.WorkerThread;
@@ -49,6 +48,7 @@
import com.android.settings.slices.SliceBuilderUtils;
import com.android.settingslib.utils.ThreadUtils;
+import java.util.Arrays;
import java.util.List;
public class BatteryFixSlice implements CustomSliceable {
@@ -58,6 +58,11 @@
@VisibleForTesting
static final String KEY_CURRENT_TIPS_TYPE = "current_tip_type";
+ private static final List<Integer> UNIMPORTANT_BATTERY_TIPS = Arrays.asList(
+ BatteryTip.TipType.SUMMARY,
+ BatteryTip.TipType.BATTERY_SAVER
+ );
+
private static final String TAG = "BatteryFixSlice";
private final Context mContext;
@@ -78,12 +83,12 @@
.setAccentColor(-1);
// TipType.SUMMARY is battery good
- if (readBatteryTipAvailabilityCache(mContext) == BatteryTip.TipType.SUMMARY) {
+ if (UNIMPORTANT_BATTERY_TIPS.contains(readBatteryTipAvailabilityCache(mContext))) {
return buildBatteryGoodSlice(sliceBuilder, true);
}
- final List<BatteryTip> batteryTips = SliceBackgroundWorker.getInstance(mContext,
- this).getResults();
+ final SliceBackgroundWorker worker = SliceBackgroundWorker.getInstance(getUri());
+ final List<BatteryTip> batteryTips = worker != null ? worker.getResults() : null;
if (batteryTips == null) {
// Because we need wait slice background worker return data
@@ -91,19 +96,21 @@
}
for (BatteryTip batteryTip : batteryTips) {
- if (batteryTip.getState() != BatteryTip.StateType.INVISIBLE) {
- final IconCompat icon = IconCompat.createWithResource(mContext, batteryTip.getIconId());
- final SliceAction primaryAction = SliceAction.createDeeplink(getPrimaryAction(),
- icon,
- ListBuilder.ICON_IMAGE,
- batteryTip.getTitle(mContext));
- sliceBuilder.addRow(new RowBuilder()
- .setTitleItem(icon, ListBuilder.ICON_IMAGE)
- .setTitle(batteryTip.getTitle(mContext))
- .setSubtitle(batteryTip.getSummary(mContext))
- .setPrimaryAction(primaryAction));
- break;
+ if (batteryTip.getState() == BatteryTip.StateType.INVISIBLE) {
+ continue;
}
+ final IconCompat icon = IconCompat.createWithResource(mContext,
+ batteryTip.getIconId());
+ final SliceAction primaryAction = SliceAction.createDeeplink(getPrimaryAction(),
+ icon,
+ ListBuilder.ICON_IMAGE,
+ batteryTip.getTitle(mContext));
+ sliceBuilder.addRow(new RowBuilder()
+ .setTitleItem(icon, ListBuilder.ICON_IMAGE)
+ .setTitle(batteryTip.getTitle(mContext))
+ .setSubtitle(batteryTip.getSummary(mContext))
+ .setPrimaryAction(primaryAction));
+ break;
}
return sliceBuilder.build();
}
diff --git a/src/com/android/settings/homepage/contextualcards/slices/BluetoothDevicesSlice.java b/src/com/android/settings/homepage/contextualcards/slices/BluetoothDevicesSlice.java
index 6a75274..b2bec7f 100644
--- a/src/com/android/settings/homepage/contextualcards/slices/BluetoothDevicesSlice.java
+++ b/src/com/android/settings/homepage/contextualcards/slices/BluetoothDevicesSlice.java
@@ -273,7 +273,7 @@
private SliceAction buildBluetoothDetailDeepLinkAction(CachedBluetoothDevice bluetoothDevice) {
return SliceAction.createDeeplink(
getBluetoothDetailIntent(bluetoothDevice),
- IconCompat.createWithResource(mContext, R.drawable.ic_settings),
+ IconCompat.createWithResource(mContext, R.drawable.ic_settings_24dp),
ListBuilder.ICON_IMAGE,
bluetoothDevice.getName());
}
@@ -287,9 +287,7 @@
final CharSequence title = mContext.getText(R.string.bluetooth_pairing_pref_title);
final IconCompat icon = IconCompat.createWithResource(mContext, R.drawable.ic_menu_add);
final SliceAction sliceAction = SliceAction.createDeeplink(
- getPairNewDeviceIntent(),
- IconCompat.createWithResource(mContext, R.drawable.ic_settings),
- ListBuilder.ICON_IMAGE, title);
+ getPairNewDeviceIntent(), icon, ListBuilder.ICON_IMAGE, title);
return new ListBuilder.RowBuilder()
.setTitleItem(icon, ListBuilder.ICON_IMAGE)
diff --git a/src/com/android/settings/homepage/contextualcards/slices/SliceContextualCardRenderer.java b/src/com/android/settings/homepage/contextualcards/slices/SliceContextualCardRenderer.java
index 7ca6e9a..5a43f66 100644
--- a/src/com/android/settings/homepage/contextualcards/slices/SliceContextualCardRenderer.java
+++ b/src/com/android/settings/homepage/contextualcards/slices/SliceContextualCardRenderer.java
@@ -26,7 +26,6 @@
import android.widget.Button;
import android.widget.ViewFlipper;
-import androidx.annotation.NonNull;
import androidx.annotation.VisibleForTesting;
import androidx.lifecycle.Lifecycle;
import androidx.lifecycle.LifecycleObserver;
@@ -35,40 +34,40 @@
import androidx.lifecycle.OnLifecycleEvent;
import androidx.recyclerview.widget.RecyclerView;
import androidx.slice.Slice;
-import androidx.slice.SliceItem;
-import androidx.slice.widget.EventInfo;
import androidx.slice.widget.SliceLiveData;
-import androidx.slice.widget.SliceView;
import com.android.settings.R;
import com.android.settings.homepage.contextualcards.CardContentProvider;
import com.android.settings.homepage.contextualcards.ContextualCard;
-import com.android.settings.homepage.contextualcards.ContextualCardFeatureProvider;
import com.android.settings.homepage.contextualcards.ContextualCardRenderer;
import com.android.settings.homepage.contextualcards.ControllerRendererPool;
-import com.android.settings.overlay.FeatureFactory;
import java.util.Map;
import java.util.Set;
/**
- * Card renderer for {@link ContextualCard} built as slices.
+ * Card renderer for {@link ContextualCard} built as slice full card or slice half card.
*/
-public class SliceContextualCardRenderer implements ContextualCardRenderer,
- SliceView.OnSliceActionListener, LifecycleObserver {
- public static final int VIEW_TYPE = R.layout.homepage_slice_tile;
+public class SliceContextualCardRenderer implements ContextualCardRenderer, LifecycleObserver {
+ public static final int VIEW_TYPE_FULL_WIDTH = R.layout.homepage_slice_tile;
+ public static final int VIEW_TYPE_HALF_WIDTH = R.layout.homepage_slice_half_tile;
private static final String TAG = "SliceCardRenderer";
@VisibleForTesting
final Map<Uri, LiveData<Slice>> mSliceLiveDataMap;
@VisibleForTesting
- final Set<SliceViewHolder> mFlippedCardSet;
+ final Set<RecyclerView.ViewHolder> mFlippedCardSet;
private final Context mContext;
private final LifecycleOwner mLifecycleOwner;
private final ControllerRendererPool mControllerRendererPool;
private final Set<ContextualCard> mCardSet;
+ private final SliceFullCardRendererHelper mFullCardHelper;
+ private final SliceHalfCardRendererHelper mHalfCardHelper;
+
+ //TODO(b/121303357): Remove isHalfWidth field from SliceContextualCardRenderer class.
+ private boolean mIsHalfWidth;
public SliceContextualCardRenderer(Context context, LifecycleOwner lifecycleOwner,
ControllerRendererPool controllerRendererPool) {
@@ -79,21 +78,26 @@
mCardSet = new ArraySet<>();
mFlippedCardSet = new ArraySet<>();
mLifecycleOwner.getLifecycle().addObserver(this);
+ mFullCardHelper = new SliceFullCardRendererHelper(context);
+ mHalfCardHelper = new SliceHalfCardRendererHelper(context);
}
@Override
public int getViewType(boolean isHalfWidth) {
- return VIEW_TYPE;
+ mIsHalfWidth = isHalfWidth;
+ return isHalfWidth? VIEW_TYPE_HALF_WIDTH : VIEW_TYPE_FULL_WIDTH;
}
@Override
public RecyclerView.ViewHolder createViewHolder(View view) {
- return new SliceViewHolder(view);
+ if (mIsHalfWidth) {
+ return mHalfCardHelper.createViewHolder(view);
+ }
+ return mFullCardHelper.createViewHolder(view);
}
@Override
public void bindView(RecyclerView.ViewHolder holder, ContextualCard card) {
- final SliceViewHolder cardHolder = (SliceViewHolder) holder;
final Uri uri = card.getSliceUri();
//TODO(b/120629936): Take this out once blank card issue is fixed.
Log.d(TAG, "bindView - uri = " + uri);
@@ -103,10 +107,6 @@
return;
}
- cardHolder.sliceView.setScrollable(false);
- cardHolder.sliceView.setTag(uri);
- //TODO(b/114009676): We will soon have a field to decide what slice mode we should set.
- cardHolder.sliceView.setMode(SliceView.MODE_LARGE);
LiveData<Slice> sliceLiveData = mSliceLiveDataMap.get(uri);
if (sliceLiveData == null) {
@@ -125,82 +125,58 @@
//TODO(b/120629936): Take this out once blank card issue is fixed.
Log.d(TAG, "Slice callback - uri = " + slice.getUri());
}
- cardHolder.sliceView.setSlice(slice);
+ if (holder.getItemViewType() == VIEW_TYPE_HALF_WIDTH) {
+ mHalfCardHelper.bindView(holder, card, slice);
+ } else {
+ mFullCardHelper.bindView(holder, card, slice, mCardSet);
+ }
});
- // Set this listener so we can log the interaction users make on the slice
- cardHolder.sliceView.setOnSliceActionListener(this);
-
- // Customize slice view for Settings
- cardHolder.sliceView.showTitleItems(true);
- if (card.isLargeCard()) {
- cardHolder.sliceView.showHeaderDivider(true);
- cardHolder.sliceView.showActionDividers(true);
+ if (holder.getItemViewType() == VIEW_TYPE_HALF_WIDTH) {
+ initDismissalActions(holder, card, R.id.content);
+ } else {
+ initDismissalActions(holder, card, R.id.slice_view);
}
-
- initDismissalActions(cardHolder, card);
}
- private void initDismissalActions(SliceViewHolder cardHolder, ContextualCard card) {
- cardHolder.sliceView.setOnLongClickListener(v -> {
- cardHolder.viewFlipper.showNext();
- mFlippedCardSet.add(cardHolder);
+ private void initDismissalActions(RecyclerView.ViewHolder holder, ContextualCard card,
+ int initialViewId) {
+ // initialView is the first view in the ViewFlipper.
+ final View initialView = holder.itemView.findViewById(initialViewId);
+ initialView.setOnLongClickListener(v -> {
+ flipCardToDismissalView(holder);
+ mFlippedCardSet.add(holder);
return true;
});
- final Button btnKeep = cardHolder.itemView.findViewById(R.id.keep);
+ final Button btnKeep = holder.itemView.findViewById(R.id.keep);
btnKeep.setOnClickListener(v -> {
- cardHolder.resetCard();
- mFlippedCardSet.remove(cardHolder);
+ mFlippedCardSet.remove(holder);
+ resetCardView(holder);
});
- final Button btnRemove = cardHolder.itemView.findViewById(R.id.remove);
+ final Button btnRemove = holder.itemView.findViewById(R.id.remove);
btnRemove.setOnClickListener(v -> {
mControllerRendererPool.getController(mContext, card.getCardType()).onDismissed(card);
- cardHolder.resetCard();
- mFlippedCardSet.remove(cardHolder);
+ mFlippedCardSet.remove(holder);
+ resetCardView(holder);
mSliceLiveDataMap.get(card.getSliceUri()).removeObservers(mLifecycleOwner);
});
}
- @Override
- public void onSliceAction(@NonNull EventInfo eventInfo, @NonNull SliceItem sliceItem) {
- //TODO(b/79698338): Log user interaction
-
- // sliceItem.getSlice().getUri() is like
- // content://android.settings.slices/action/wifi/_gen/0/_gen/0
- // contextualCard.getSliceUri() is prefix of sliceItem.getSlice().getUri()
- for (ContextualCard card : mCardSet) {
- if (sliceItem.getSlice().getUri().toString().startsWith(
- card.getSliceUri().toString())) {
- ContextualCardFeatureProvider contexualCardFeatureProvider =
- FeatureFactory.getFactory(mContext)
- .getContextualCardFeatureProvider(mContext);
- contexualCardFeatureProvider.logContextualCardClick(card,
- eventInfo.rowIndex, eventInfo.actionType);
- break;
- }
- }
- }
-
@OnLifecycleEvent(Lifecycle.Event.ON_STOP)
public void onStop() {
- mFlippedCardSet.stream().forEach(holder -> holder.resetCard());
+ mFlippedCardSet.stream().forEach(holder -> resetCardView(holder));
mFlippedCardSet.clear();
}
- public static class SliceViewHolder extends RecyclerView.ViewHolder {
- public final SliceView sliceView;
- public final ViewFlipper viewFlipper;
+ private void resetCardView(RecyclerView.ViewHolder holder) {
+ final ViewFlipper viewFlipper = holder.itemView.findViewById(R.id.view_flipper);
+ viewFlipper.setDisplayedChild(0 /* whichChild */);
+ }
- public SliceViewHolder(View view) {
- super(view);
- sliceView = view.findViewById(R.id.slice_view);
- viewFlipper = view.findViewById(R.id.view_flipper);
- }
-
- public void resetCard() {
- viewFlipper.setDisplayedChild(0);
- }
+ private void flipCardToDismissalView(RecyclerView.ViewHolder holder) {
+ final ViewFlipper viewFlipper = holder.itemView.findViewById(R.id.view_flipper);
+ viewFlipper.showNext();
}
}
diff --git a/src/com/android/settings/homepage/contextualcards/slices/SliceFullCardRendererHelper.java b/src/com/android/settings/homepage/contextualcards/slices/SliceFullCardRendererHelper.java
new file mode 100644
index 0000000..ef0a67d
--- /dev/null
+++ b/src/com/android/settings/homepage/contextualcards/slices/SliceFullCardRendererHelper.java
@@ -0,0 +1,99 @@
+/*
+ * 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.homepage.contextualcards.slices;
+
+import android.content.Context;
+import android.view.View;
+
+import androidx.annotation.NonNull;
+import androidx.recyclerview.widget.RecyclerView;
+import androidx.slice.Slice;
+import androidx.slice.SliceItem;
+import androidx.slice.widget.EventInfo;
+import androidx.slice.widget.SliceView;
+
+import com.android.settings.R;
+import com.android.settings.homepage.contextualcards.ContextualCard;
+import com.android.settings.homepage.contextualcards.ContextualCardFeatureProvider;
+import com.android.settings.overlay.FeatureFactory;
+
+import java.util.Set;
+
+/**
+ * Card renderer helper for {@link ContextualCard} built as slice full card.
+ */
+class SliceFullCardRendererHelper implements SliceView.OnSliceActionListener {
+ private static final String TAG = "SliceFCRendererHelper";
+
+ private final Context mContext;
+
+ private Set<ContextualCard> mCardSet;
+
+ SliceFullCardRendererHelper(Context context) {
+ mContext = context;
+ }
+
+ RecyclerView.ViewHolder createViewHolder(View view) {
+ return new SliceViewHolder(view);
+ }
+
+ void bindView(RecyclerView.ViewHolder holder, ContextualCard card, Slice slice,
+ Set<ContextualCard> cardSet) {
+ final SliceViewHolder cardHolder = (SliceViewHolder) holder;
+ cardHolder.sliceView.setScrollable(false);
+ cardHolder.sliceView.setTag(card.getSliceUri());
+ //TODO(b/114009676): We will soon have a field to decide what slice mode we should set.
+ cardHolder.sliceView.setMode(SliceView.MODE_LARGE);
+ cardHolder.sliceView.setSlice(slice);
+ mCardSet = cardSet;
+ // Set this listener so we can log the interaction users make on the slice
+ cardHolder.sliceView.setOnSliceActionListener(this);
+
+ // Customize slice view for Settings
+ cardHolder.sliceView.showTitleItems(true);
+ if (card.isLargeCard()) {
+ cardHolder.sliceView.showHeaderDivider(true);
+ cardHolder.sliceView.showActionDividers(true);
+ }
+ }
+
+ @Override
+ public void onSliceAction(@NonNull EventInfo eventInfo, @NonNull SliceItem sliceItem) {
+ // sliceItem.getSlice().getUri() is like
+ // content://android.settings.slices/action/wifi/_gen/0/_gen/0
+ // contextualCard.getSliceUri() is prefix of sliceItem.getSlice().getUri()
+ final ContextualCardFeatureProvider contextualCardFeatureProvider =
+ FeatureFactory.getFactory(mContext).getContextualCardFeatureProvider(mContext);
+ for (ContextualCard card : mCardSet) {
+ if (sliceItem.getSlice().getUri().toString().startsWith(
+ card.getSliceUri().toString())) {
+ contextualCardFeatureProvider.logContextualCardClick(card, eventInfo.rowIndex,
+ eventInfo.actionType);
+ break;
+ }
+ }
+ }
+
+ static class SliceViewHolder extends RecyclerView.ViewHolder {
+ public final SliceView sliceView;
+
+ public SliceViewHolder(View view) {
+ super(view);
+ sliceView = view.findViewById(R.id.slice_view);
+ }
+ }
+}
diff --git a/src/com/android/settings/homepage/contextualcards/slices/SliceHalfCardRendererHelper.java b/src/com/android/settings/homepage/contextualcards/slices/SliceHalfCardRendererHelper.java
new file mode 100644
index 0000000..24d654d
--- /dev/null
+++ b/src/com/android/settings/homepage/contextualcards/slices/SliceHalfCardRendererHelper.java
@@ -0,0 +1,85 @@
+/*
+ * 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.homepage.contextualcards.slices;
+
+import android.app.PendingIntent;
+import android.content.Context;
+import android.util.Log;
+import android.view.View;
+import android.widget.ImageView;
+import android.widget.LinearLayout;
+import android.widget.TextView;
+
+import androidx.recyclerview.widget.RecyclerView;
+import androidx.slice.Slice;
+import androidx.slice.SliceMetadata;
+import androidx.slice.core.SliceAction;
+import androidx.slice.widget.EventInfo;
+
+import com.android.settings.R;
+import com.android.settings.homepage.contextualcards.ContextualCard;
+import com.android.settings.homepage.contextualcards.ContextualCardFeatureProvider;
+import com.android.settings.overlay.FeatureFactory;
+
+/**
+ * Card renderer helper for {@link ContextualCard} built as slice half card.
+ */
+class SliceHalfCardRendererHelper {
+ private static final String TAG = "SliceHCRendererHelper";
+
+ private final Context mContext;
+
+ SliceHalfCardRendererHelper(Context context) {
+ mContext = context;
+ }
+
+ RecyclerView.ViewHolder createViewHolder(View view) {
+ return new HalfCardViewHolder(view);
+ }
+
+ void bindView(RecyclerView.ViewHolder holder, ContextualCard card, Slice slice) {
+ final HalfCardViewHolder view = (HalfCardViewHolder) holder;
+ final SliceMetadata sliceMetadata = SliceMetadata.from(mContext, slice);
+ final SliceAction primaryAction = sliceMetadata.getPrimaryAction();
+ view.icon.setImageDrawable(primaryAction.getIcon().loadDrawable(mContext));
+ view.title.setText(primaryAction.getTitle());
+ view.content.setOnClickListener(v -> {
+ try {
+ primaryAction.getAction().send();
+ } catch (PendingIntent.CanceledException e) {
+ Log.w(TAG, "Failed to start intent " + primaryAction.getTitle());
+ }
+ final ContextualCardFeatureProvider contextualCardFeatureProvider =
+ FeatureFactory.getFactory(mContext).getContextualCardFeatureProvider(mContext);
+ contextualCardFeatureProvider.logContextualCardClick(card, 0 /* row */,
+ EventInfo.ACTION_TYPE_CONTENT);
+ });
+ }
+
+ static class HalfCardViewHolder extends RecyclerView.ViewHolder {
+ public final LinearLayout content;
+ public final ImageView icon;
+ public final TextView title;
+
+ public HalfCardViewHolder(View itemView) {
+ super(itemView);
+ content = itemView.findViewById(R.id.content);
+ icon = itemView.findViewById(android.R.id.icon);
+ title = itemView.findViewById(android.R.id.title);
+ }
+ }
+}
diff --git a/src/com/android/settings/location/AppLocationPermissionPreferenceController.java b/src/com/android/settings/location/AppLocationPermissionPreferenceController.java
index 5bfc584..1fd1986 100644
--- a/src/com/android/settings/location/AppLocationPermissionPreferenceController.java
+++ b/src/com/android/settings/location/AppLocationPermissionPreferenceController.java
@@ -6,9 +6,10 @@
import android.content.Context;
import android.location.LocationManager;
-import android.permission.RuntimePermissionPresenter;
+import android.permission.PermissionControllerManager;
import android.provider.Settings;
+import androidx.annotation.VisibleForTesting;
import androidx.preference.Preference;
import com.android.settings.R;
@@ -24,9 +25,11 @@
private static final String KEY_APP_LEVEL_PERMISSIONS = "app_level_permissions";
/** Total number of apps that has location permission. */
- private int mNumTotal = -1;
+ @VisibleForTesting
+ int mNumTotal = -1;
/** Total number of apps that has background location permission. */
- private int mNumBackground = -1;
+ @VisibleForTesting
+ int mNumBackground = -1;
private final LocationManager mLocationManager;
private Preference mPreference;
@@ -70,7 +73,9 @@
if (!mLocationManager.isLocationEnabled()) {
return;
}
- RuntimePermissionPresenter.getInstance(mContext).countPermissionApps(
+ PermissionControllerManager permController =
+ mContext.getSystemService(PermissionControllerManager.class);
+ permController.countPermissionApps(
Arrays.asList(ACCESS_FINE_LOCATION, ACCESS_COARSE_LOCATION), false, false,
(numApps) -> {
mNumTotal = numApps;
@@ -79,7 +84,7 @@
}
}, null);
- RuntimePermissionPresenter.getInstance(mContext).countPermissionApps(
+ permController.countPermissionApps(
Collections.singletonList(ACCESS_BACKGROUND_LOCATION), true, false,
(numApps) -> {
mNumBackground = numApps;
diff --git a/src/com/android/settings/location/TopLevelLocationPreferenceController.java b/src/com/android/settings/location/TopLevelLocationPreferenceController.java
index 455af21..6d7789f 100644
--- a/src/com/android/settings/location/TopLevelLocationPreferenceController.java
+++ b/src/com/android/settings/location/TopLevelLocationPreferenceController.java
@@ -8,7 +8,7 @@
import android.content.Intent;
import android.content.IntentFilter;
import android.location.LocationManager;
-import android.permission.RuntimePermissionPresenter;
+import android.permission.PermissionControllerManager;
import androidx.annotation.VisibleForTesting;
import androidx.preference.Preference;
@@ -70,7 +70,7 @@
if (!mLocationManager.isLocationEnabled()) {
return;
}
- RuntimePermissionPresenter.getInstance(mContext).countPermissionApps(
+ mContext.getSystemService(PermissionControllerManager.class).countPermissionApps(
Arrays.asList(ACCESS_FINE_LOCATION, ACCESS_COARSE_LOCATION), false, false,
(numApps) -> {
setLocationAppCount(numApps);
diff --git a/src/com/android/settings/network/NetworkDashboardFragment.java b/src/com/android/settings/network/NetworkDashboardFragment.java
index 7d94bba..c2b4a2b 100644
--- a/src/com/android/settings/network/NetworkDashboardFragment.java
+++ b/src/com/android/settings/network/NetworkDashboardFragment.java
@@ -21,7 +21,6 @@
import android.app.Dialog;
import android.content.Context;
import android.provider.SearchIndexableResource;
-import android.util.FeatureFlagUtils;
import android.util.Log;
import androidx.appcompat.app.AlertDialog;
@@ -31,6 +30,7 @@
import com.android.settings.R;
import com.android.settings.core.FeatureFlags;
import com.android.settings.dashboard.DashboardFragment;
+import com.android.settings.development.featureflags.FeatureFlagPersistent;
import com.android.settings.network.MobilePlanPreferenceController.MobilePlanPreferenceHost;
import com.android.settings.search.BaseSearchIndexProvider;
import com.android.settings.wifi.WifiMasterSwitchPreferenceController;
@@ -61,7 +61,7 @@
@Override
protected int getPreferenceScreenResId() {
- if (FeatureFlagUtils.isEnabled(getContext(), FeatureFlags.NETWORK_INTERNET_V2)) {
+ if (FeatureFlagPersistent.isEnabled(getContext(), FeatureFlags.NETWORK_INTERNET_V2)) {
return R.xml.network_and_internet_v2;
} else {
return R.xml.network_and_internet;
@@ -72,7 +72,7 @@
public void onAttach(Context context) {
super.onAttach(context);
- if (FeatureFlagUtils.isEnabled(context, FeatureFlags.NETWORK_INTERNET_V2)) {
+ if (FeatureFlagPersistent.isEnabled(context, FeatureFlags.NETWORK_INTERNET_V2)) {
use(MultiNetworkHeaderController.class).init(getSettingsLifecycle());
}
use(AirplaneModePreferenceController.class).setFragment(this);
diff --git a/src/com/android/settings/network/telephony/MobileDataDialogFragment.java b/src/com/android/settings/network/telephony/MobileDataDialogFragment.java
index be2da04..276d1fb 100644
--- a/src/com/android/settings/network/telephony/MobileDataDialogFragment.java
+++ b/src/com/android/settings/network/telephony/MobileDataDialogFragment.java
@@ -17,6 +17,7 @@
package com.android.settings.network.telephony;
import android.app.Dialog;
+import android.app.settings.SettingsEnums;
import android.content.Context;
import android.content.DialogInterface;
import android.os.Bundle;
@@ -109,8 +110,7 @@
@Override
public int getMetricsCategory() {
- //TODO(b/114749736): add metric id for this fragment
- return 0;
+ return SettingsEnums.MOBILE_DATA_DIALOG;
}
@Override
diff --git a/src/com/android/settings/network/telephony/MobileNetworkSettings.java b/src/com/android/settings/network/telephony/MobileNetworkSettings.java
index 623b6de..6e5dece 100644
--- a/src/com/android/settings/network/telephony/MobileNetworkSettings.java
+++ b/src/com/android/settings/network/telephony/MobileNetworkSettings.java
@@ -196,7 +196,6 @@
}
}
- //TODO(b/114749736): update search provider
public static final Indexable.SearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
new BaseSearchIndexProvider() {
@Override
diff --git a/src/com/android/settings/network/telephony/PreferredNetworkModePreferenceController.java b/src/com/android/settings/network/telephony/PreferredNetworkModePreferenceController.java
index f60f927..0326f42 100644
--- a/src/com/android/settings/network/telephony/PreferredNetworkModePreferenceController.java
+++ b/src/com/android/settings/network/telephony/PreferredNetworkModePreferenceController.java
@@ -116,8 +116,6 @@
}
private int getPreferredNetworkModeSummaryResId(int NetworkMode) {
- //TODO(b/114749736): refactor it to "Preferred network mode: <Mode>", instead of building
- // string for each type...
switch (NetworkMode) {
case TelephonyManager.NETWORK_MODE_TDSCDMA_GSM_WCDMA:
return R.string.preferred_network_mode_tdscdma_gsm_wcdma_summary;
diff --git a/src/com/android/settings/network/telephony/RoamingDialogFragment.java b/src/com/android/settings/network/telephony/RoamingDialogFragment.java
index 4c82686..c349c1a 100644
--- a/src/com/android/settings/network/telephony/RoamingDialogFragment.java
+++ b/src/com/android/settings/network/telephony/RoamingDialogFragment.java
@@ -17,6 +17,7 @@
import android.app.AlertDialog;
import android.app.Dialog;
+import android.app.settings.SettingsEnums;
import android.content.Context;
import android.content.DialogInterface;
import android.content.DialogInterface.OnClickListener;
@@ -78,8 +79,7 @@
@Override
public int getMetricsCategory() {
- //TODO(b/114749736): add category for roaming dialog
- return 0;
+ return SettingsEnums.MOBILE_ROAMING_DIALOG;
}
@Override
diff --git a/src/com/android/settings/network/telephony/WifiCallingPreferenceController.java b/src/com/android/settings/network/telephony/WifiCallingPreferenceController.java
index 48fb710..ec9a841 100644
--- a/src/com/android/settings/network/telephony/WifiCallingPreferenceController.java
+++ b/src/com/android/settings/network/telephony/WifiCallingPreferenceController.java
@@ -72,7 +72,7 @@
&& MobileNetworkUtils.isWifiCallingEnabled(mContext,
SubscriptionManager.getPhoneId(mSubId))
? AVAILABLE
- : CONDITIONALLY_UNAVAILABLE;
+ : UNSUPPORTED_ON_DEVICE;
}
@Override
diff --git a/src/com/android/settings/nfc/AndroidBeamPreferenceController.java b/src/com/android/settings/nfc/AndroidBeamPreferenceController.java
index 181faa5..b784dc5 100644
--- a/src/com/android/settings/nfc/AndroidBeamPreferenceController.java
+++ b/src/com/android/settings/nfc/AndroidBeamPreferenceController.java
@@ -16,6 +16,7 @@
package com.android.settings.nfc;
import android.content.Context;
+import android.content.pm.PackageManager;
import android.nfc.NfcAdapter;
import androidx.preference.PreferenceScreen;
@@ -54,6 +55,10 @@
@Override
@AvailabilityStatus
public int getAvailabilityStatus() {
+ PackageManager pm = mContext.getPackageManager();
+ if (!pm.hasSystemFeature(PackageManager.FEATURE_NFC_BEAM)) {
+ return UNSUPPORTED_ON_DEVICE;
+ }
return mNfcAdapter != null
? AVAILABLE
: UNSUPPORTED_ON_DEVICE;
diff --git a/src/com/android/settings/notification/NotificationStation.java b/src/com/android/settings/notification/NotificationStation.java
index d3ebc08..116980f 100644
--- a/src/com/android/settings/notification/NotificationStation.java
+++ b/src/com/android/settings/notification/NotificationStation.java
@@ -16,10 +16,13 @@
package com.android.settings.notification;
+import static android.app.NotificationManager.IMPORTANCE_UNSPECIFIED;
+
import android.app.Activity;
import android.app.ActivityManager;
import android.app.INotificationManager;
import android.app.Notification;
+import android.app.NotificationChannel;
import android.app.PendingIntent;
import android.content.ComponentName;
import android.content.Context;
@@ -354,28 +357,53 @@
getString(R.string.notification_log_details_group_summary)));
}
}
- sb.append("\n")
- .append(bold(getString(R.string.notification_log_details_sound)))
- .append(delim);
- if (0 != (n.defaults & Notification.DEFAULT_SOUND)) {
- sb.append(getString(R.string.notification_log_details_default));
- } else if (n.sound != null) {
- sb.append(n.sound.toString());
- } else {
- sb.append(getString(R.string.notification_log_details_none));
- }
- sb.append("\n")
- .append(bold(getString(R.string.notification_log_details_vibrate)))
- .append(delim);
- if (0 != (n.defaults & Notification.DEFAULT_VIBRATE)) {
- sb.append(getString(R.string.notification_log_details_default));
- } else if (n.vibrate != null) {
- for (int vi=0;vi<n.vibrate.length;vi++) {
- if (vi > 0) sb.append(',');
- sb.append(String.valueOf(n.vibrate[vi]));
+ if (info.active) {
+ // mRanking only applies to active notifications
+ if (mRanking != null && mRanking.getRanking(sbn.getKey(), rank)) {
+ if (rank.getLastAudiblyAlertedMillis() > 0) {
+ sb.append("\n")
+ .append(bold(getString(R.string.notification_log_details_alerted)));
+ }
}
- } else {
- sb.append(getString(R.string.notification_log_details_none));
+ }
+ try {
+ NotificationChannel channel = mNoMan.getNotificationChannelForPackage(
+ sbn.getPackageName(), sbn.getUid(), n.getChannelId(), false);
+ sb.append("\n")
+ .append(bold(getString(R.string.notification_log_details_sound)))
+ .append(delim);
+ if (channel.getImportance() == IMPORTANCE_UNSPECIFIED) {
+
+ if (0 != (n.defaults & Notification.DEFAULT_SOUND)) {
+ sb.append(getString(R.string.notification_log_details_default));
+ } else if (n.sound != null) {
+ sb.append(n.sound.toString());
+ } else {
+ sb.append(getString(R.string.notification_log_details_none));
+ }
+ } else {
+ sb.append(String.valueOf(channel.getSound()));
+ }
+ sb.append("\n")
+ .append(bold(getString(R.string.notification_log_details_vibrate)))
+ .append(delim);
+ if (channel.getImportance() == IMPORTANCE_UNSPECIFIED) {
+ if (0 != (n.defaults & Notification.DEFAULT_VIBRATE)) {
+ sb.append(getString(R.string.notification_log_details_default));
+ } else if (n.vibrate != null) {
+ sb.append(getString(R.string.notification_log_details_vibrate_pattern));
+ } else {
+ sb.append(getString(R.string.notification_log_details_none));
+ }
+ } else {
+ if (channel.getVibrationPattern() != null) {
+ sb.append(getString(R.string.notification_log_details_vibrate_pattern));
+ } else {
+ sb.append(getString(R.string.notification_log_details_none));
+ }
+ }
+ } catch (RemoteException e) {
+ Log.d(TAG, "cannot read channel info", e);
}
sb.append("\n")
.append(bold(getString(R.string.notification_log_details_visibility)))
diff --git a/src/com/android/settings/notification/RedactionInterstitial.java b/src/com/android/settings/notification/RedactionInterstitial.java
index b2f2d25..11861e0 100644
--- a/src/com/android/settings/notification/RedactionInterstitial.java
+++ b/src/com/android/settings/notification/RedactionInterstitial.java
@@ -139,7 +139,7 @@
.setText(R.string.app_notifications_dialog_done)
.setListener(this::onDoneButtonClicked)
.setButtonType(FooterButton.ButtonType.NEXT)
- .setTheme(R.style.SuwGlifButton_Primary)
+ .setTheme(R.style.SudGlifButton_Primary)
.build()
);
}
diff --git a/src/com/android/settings/password/ChooseLockPassword.java b/src/com/android/settings/password/ChooseLockPassword.java
index 32d4edf..35bc45e 100644
--- a/src/com/android/settings/password/ChooseLockPassword.java
+++ b/src/com/android/settings/password/ChooseLockPassword.java
@@ -408,9 +408,9 @@
ViewGroup container = view.findViewById(R.id.password_container);
container.setOpticalInsets(Insets.NONE);
- mSkipButton = (Button) view.findViewById(R.id.skip_button);
+ mSkipButton = view.findViewById(R.id.skip_button);
mSkipButton.setOnClickListener(this);
- mNextButton = (Button) view.findViewById(R.id.next_button);
+ mNextButton = view.findViewById(R.id.next_button);
mNextButton.setOnClickListener(this);
mClearButton = view.findViewById(R.id.clear_button);
mClearButton.setOnClickListener(this);
@@ -894,12 +894,13 @@
mPasswordRequirementAdapter.setRequirements(messages);
// Enable/Disable the next button accordingly.
setNextEnabled(errorCode == NO_ERROR);
+ mClearButton.setVisibility(View.GONE);
} else {
// Hide password requirement view when we are just asking user to confirm the pw.
mPasswordRestrictionView.setVisibility(View.GONE);
setHeaderText(getString(mUiStage.getHint(mIsAlphaMode, getStageType())));
setNextEnabled(canInput && length >= mPasswordMinLength);
- mClearButton.setEnabled(canInput && length > 0);
+ mClearButton.setVisibility(toVisibility(canInput && length > 0));
}
int message = mUiStage.getMessage(mIsAlphaMode, getStageType());
if (message != 0) {
@@ -909,13 +910,11 @@
mMessage.setVisibility(View.INVISIBLE);
}
- mClearButton.setVisibility(toVisibility(mUiStage != Stage.Introduction));
-
setNextText(mUiStage.buttonText);
mPasswordEntryInputDisabler.setInputEnabled(canInput);
}
- private int toVisibility(boolean visibleOrGone) {
+ protected int toVisibility(boolean visibleOrGone) {
return visibleOrGone ? View.VISIBLE : View.GONE;
}
diff --git a/src/com/android/settings/password/ChooseLockPattern.java b/src/com/android/settings/password/ChooseLockPattern.java
index 1c9e3ff..2738a26 100644
--- a/src/com/android/settings/password/ChooseLockPattern.java
+++ b/src/com/android/settings/password/ChooseLockPattern.java
@@ -476,7 +476,7 @@
R.layout.choose_lock_pattern, container, false);
layout.setHeaderText(getActivity().getTitle());
if (getResources().getBoolean(R.bool.config_lock_pattern_minimal_ui)) {
- View iconView = layout.findViewById(R.id.suw_layout_icon);
+ View iconView = layout.findViewById(R.id.suc_layout_icon);
if (iconView != null) {
iconView.setVisibility(View.GONE);
}
@@ -494,7 +494,7 @@
@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
- mTitleText = view.findViewById(R.id.suw_layout_title);
+ mTitleText = view.findViewById(R.id.suc_layout_title);
mHeaderText = (TextView) view.findViewById(R.id.headerText);
mDefaultHeaderColorList = mHeaderText.getTextColors();
mMessageText = view.findViewById(R.id.message);
diff --git a/src/com/android/settings/password/ConfirmLockPassword.java b/src/com/android/settings/password/ConfirmLockPassword.java
index 45b8129..b5bca15 100644
--- a/src/com/android/settings/password/ConfirmLockPassword.java
+++ b/src/com/android/settings/password/ConfirmLockPassword.java
@@ -135,7 +135,7 @@
mHeaderTextView = (TextView) view.findViewById(R.id.headerText);
if (mHeaderTextView == null) {
- mHeaderTextView = view.findViewById(R.id.suw_layout_title);
+ mHeaderTextView = view.findViewById(R.id.suc_layout_title);
}
mDetailsTextView = (TextView) view.findViewById(R.id.detailsText);
mErrorTextView = (TextView) view.findViewById(R.id.errorText);
diff --git a/src/com/android/settings/password/SetupChooseLockGeneric.java b/src/com/android/settings/password/SetupChooseLockGeneric.java
index 8cd40d5..a0f8bae 100644
--- a/src/com/android/settings/password/SetupChooseLockGeneric.java
+++ b/src/com/android/settings/password/SetupChooseLockGeneric.java
@@ -86,7 +86,7 @@
GlifPreferenceLayout layout = (GlifPreferenceLayout) view;
layout.setDividerItemDecoration(new SettingsDividerItemDecoration(getContext()));
layout.setDividerInset(getContext().getResources().getDimensionPixelSize(
- R.dimen.suw_items_glif_text_divider_inset));
+ R.dimen.sud_items_glif_text_divider_inset));
layout.setIcon(getContext().getDrawable(R.drawable.ic_lock));
diff --git a/src/com/android/settings/password/SetupChooseLockPassword.java b/src/com/android/settings/password/SetupChooseLockPassword.java
index 8454cc5..2c443c2 100644
--- a/src/com/android/settings/password/SetupChooseLockPassword.java
+++ b/src/com/android/settings/password/SetupChooseLockPassword.java
@@ -135,9 +135,13 @@
@Override
protected void updateUi() {
super.updateUi();
-
// Show the skip button during SUW but not during Settings > Biometric Enrollment
- mSkipButton.setVisibility(View.VISIBLE);
+ if (mUiStage == Stage.Introduction) {
+ mSkipButton.setVisibility(View.VISIBLE);
+ } else {
+ mSkipButton.setVisibility(View.GONE);
+ }
+
if (mOptionsButton != null) {
mOptionsButton.setVisibility(
mUiStage == Stage.Introduction ? View.VISIBLE : View.GONE);
diff --git a/src/com/android/settings/password/SetupChooseLockPattern.java b/src/com/android/settings/password/SetupChooseLockPattern.java
index b24936b..0a32468 100644
--- a/src/com/android/settings/password/SetupChooseLockPattern.java
+++ b/src/com/android/settings/password/SetupChooseLockPattern.java
@@ -59,6 +59,7 @@
@Nullable
private Button mOptionsButton;
+ private Button mSkipButton;
@Override
public View onCreateView(
@@ -71,9 +72,8 @@
.show(getChildFragmentManager(), null));
}
// Show the skip button during SUW but not during Settings > Biometric Enrollment
- Button skipButton = view.findViewById(R.id.skip_button);
- skipButton.setVisibility(View.VISIBLE);
- skipButton.setOnClickListener(v -> {
+ mSkipButton = view.findViewById(R.id.skip_button);
+ mSkipButton.setOnClickListener(v -> {
SetupSkipDialog dialog = SetupSkipDialog.newInstance(
getActivity().getIntent()
.getBooleanExtra(SetupSkipDialog.EXTRA_FRP_SUPPORTED, false));
@@ -100,6 +100,12 @@
stage == Stage.ChoiceTooShort || stage == Stage.FirstChoiceValid)
? View.VISIBLE : View.INVISIBLE);
}
+
+ if (stage.leftMode == LeftButtonMode.Gone && stage == Stage.Introduction) {
+ mSkipButton.setVisibility(View.VISIBLE);
+ } else {
+ mSkipButton.setVisibility(View.GONE);
+ }
}
@Override
diff --git a/src/com/android/settings/slices/CustomSliceManager.java b/src/com/android/settings/slices/CustomSliceManager.java
index bb47df2..24ee680 100644
--- a/src/com/android/settings/slices/CustomSliceManager.java
+++ b/src/com/android/settings/slices/CustomSliceManager.java
@@ -23,7 +23,7 @@
import androidx.annotation.VisibleForTesting;
import com.android.settings.flashlight.FlashlightSlice;
-import com.android.settings.homepage.contextualcards.deviceinfo.BatterySlice;
+import com.android.settings.homepage.contextualcards.deviceinfo.BatteryInfoSlice;
import com.android.settings.homepage.contextualcards.deviceinfo.DataUsageSlice;
import com.android.settings.homepage.contextualcards.deviceinfo.DeviceInfoSlice;
import com.android.settings.homepage.contextualcards.deviceinfo.EmergencyInfoSlice;
@@ -106,7 +106,7 @@
private void addSlices() {
mUriMap.put(CustomSliceRegistry.BATTERY_FIX_SLICE_URI, BatteryFixSlice.class);
- mUriMap.put(CustomSliceRegistry.BATTERY_INFO_SLICE_URI, BatterySlice.class);
+ mUriMap.put(CustomSliceRegistry.BATTERY_INFO_SLICE_URI, BatteryInfoSlice.class);
mUriMap.put(CustomSliceRegistry.BLUETOOTH_DEVICES_SLICE_URI, BluetoothDevicesSlice.class);
mUriMap.put(CustomSliceRegistry.CONTEXTUAL_WIFI_SLICE_URI, ContextualWifiSlice.class);
mUriMap.put(CustomSliceRegistry.DATA_USAGE_SLICE_URI, DataUsageSlice.class);
diff --git a/src/com/android/settings/slices/SliceBackgroundWorker.java b/src/com/android/settings/slices/SliceBackgroundWorker.java
index 8b68f05..284fd23 100644
--- a/src/com/android/settings/slices/SliceBackgroundWorker.java
+++ b/src/com/android/settings/slices/SliceBackgroundWorker.java
@@ -17,6 +17,7 @@
package com.android.settings.slices;
import android.annotation.MainThread;
+import android.annotation.Nullable;
import android.content.Context;
import android.net.Uri;
import android.util.ArrayMap;
@@ -58,20 +59,29 @@
mUri = uri;
}
- public Uri getUri() {
+ protected Uri getUri() {
return mUri;
}
/**
+ * Returns the singleton instance of the {@link SliceBackgroundWorker} for specified {@link Uri}
+ * if exists
+ */
+ @Nullable
+ public static SliceBackgroundWorker getInstance(Uri uri) {
+ return LIVE_WORKERS.get(uri);
+ }
+
+ /**
* Returns the singleton instance of the {@link SliceBackgroundWorker} for specified {@link
* CustomSliceable}
*/
- public static SliceBackgroundWorker getInstance(Context context, CustomSliceable sliceable) {
+ static SliceBackgroundWorker getInstance(Context context, CustomSliceable sliceable) {
final Uri uri = sliceable.getUri();
- final Class<? extends SliceBackgroundWorker> workerClass =
- sliceable.getBackgroundWorkerClass();
- SliceBackgroundWorker worker = LIVE_WORKERS.get(uri);
+ SliceBackgroundWorker worker = getInstance(uri);
if (worker == null) {
+ final Class<? extends SliceBackgroundWorker> workerClass =
+ sliceable.getBackgroundWorkerClass();
worker = createInstance(context, uri, workerClass);
LIVE_WORKERS.put(uri, worker);
}
diff --git a/src/com/android/settings/slices/SliceBuilderUtils.java b/src/com/android/settings/slices/SliceBuilderUtils.java
index b2b8310..925306e 100644
--- a/src/com/android/settings/slices/SliceBuilderUtils.java
+++ b/src/com/android/settings/slices/SliceBuilderUtils.java
@@ -425,7 +425,10 @@
final String title = data.getTitle();
final Set<String> keywords = buildSliceKeywords(data);
@ColorInt final int color = Utils.getColorAccentDefaultColor(context);
- final CharSequence summary = context.getText(R.string.disabled_dependent_setting_summary);
+
+ final String customSubtitle = data.getUnavailableSliceSubtitle();
+ final CharSequence subtitle = !TextUtils.isEmpty(customSubtitle) ? customSubtitle
+ : context.getText(R.string.disabled_dependent_setting_summary);
final IconCompat icon = getSafeIcon(context, data);
final SliceAction primaryAction = SliceAction.createDeeplink(
getContentPendingIntent(context, data),
@@ -436,7 +439,7 @@
.addRow(new RowBuilder()
.setTitle(title)
.setTitleItem(icon, ListBuilder.ICON_IMAGE)
- .setSubtitle(summary)
+ .setSubtitle(subtitle)
.setPrimaryAction(primaryAction))
.setKeywords(keywords)
.build();
diff --git a/src/com/android/settings/slices/SliceData.java b/src/com/android/settings/slices/SliceData.java
index 8705884..9d52d56 100644
--- a/src/com/android/settings/slices/SliceData.java
+++ b/src/com/android/settings/slices/SliceData.java
@@ -28,7 +28,6 @@
* Note that {@link #mKey} is treated as a primary key for this class and determines equality.
*/
public class SliceData {
-
/**
* Flags indicating the UI type of the Slice.
*/
@@ -76,6 +75,8 @@
private final boolean mIsDynamicSummaryAllowed;
+ private final String mUnavailableSliceSubtitle;
+
public String getKey() {
return mKey;
}
@@ -124,6 +125,10 @@
return mIsDynamicSummaryAllowed;
}
+ public String getUnavailableSliceSubtitle() {
+ return mUnavailableSliceSubtitle;
+ }
+
private SliceData(Builder builder) {
mKey = builder.mKey;
mTitle = builder.mTitle;
@@ -137,6 +142,7 @@
mSliceType = builder.mSliceType;
mIsPlatformDefined = builder.mIsPlatformDefined;
mIsDynamicSummaryAllowed = builder.mIsDynamicSummaryAllowed;
+ mUnavailableSliceSubtitle = builder.mUnavailableSliceSubtitle;
}
@Override
@@ -178,6 +184,8 @@
private boolean mIsDynamicSummaryAllowed;
+ private String mUnavailableSliceSubtitle;
+
public Builder setKey(String key) {
mKey = key;
return this;
@@ -238,6 +246,12 @@
return this;
}
+ public Builder setUnavailableSliceSubtitle(
+ String unavailableSliceSubtitle) {
+ mUnavailableSliceSubtitle = unavailableSliceSubtitle;
+ return this;
+ }
+
public SliceData build() {
if (TextUtils.isEmpty(mKey)) {
throw new InvalidSliceDataException("Key cannot be empty");
diff --git a/src/com/android/settings/slices/SliceDataConverter.java b/src/com/android/settings/slices/SliceDataConverter.java
index cb2980d..dcc8089 100644
--- a/src/com/android/settings/slices/SliceDataConverter.java
+++ b/src/com/android/settings/slices/SliceDataConverter.java
@@ -16,12 +16,12 @@
package com.android.settings.slices;
-import static com.android.settings.core.PreferenceXmlParserUtils
- .METADATA_ALLOW_DYNAMIC_SUMMARY_IN_SLICE;
+import static com.android.settings.core.PreferenceXmlParserUtils.METADATA_ALLOW_DYNAMIC_SUMMARY_IN_SLICE;
import static com.android.settings.core.PreferenceXmlParserUtils.METADATA_CONTROLLER;
import static com.android.settings.core.PreferenceXmlParserUtils.METADATA_ICON;
import static com.android.settings.core.PreferenceXmlParserUtils.METADATA_KEY;
import static com.android.settings.core.PreferenceXmlParserUtils.METADATA_PLATFORM_SLICE_FLAG;
+import static com.android.settings.core.PreferenceXmlParserUtils.METADATA_UNAVAILABLE_SLICE_SUBTITLE;
import static com.android.settings.core.PreferenceXmlParserUtils.METADATA_SUMMARY;
import static com.android.settings.core.PreferenceXmlParserUtils.METADATA_TITLE;
@@ -189,7 +189,8 @@
| MetadataFlag.FLAG_NEED_PREF_ICON
| MetadataFlag.FLAG_NEED_PREF_SUMMARY
| MetadataFlag.FLAG_NEED_PLATFORM_SLICE_FLAG
- | MetadataFlag.FLAG_ALLOW_DYNAMIC_SUMMARY_IN_SLICE);
+ | MetadataFlag.FLAG_ALLOW_DYNAMIC_SUMMARY_IN_SLICE
+ | MetadataFlag.FLAG_UNAVAILABLE_SLICE_SUBTITLE);
for (Bundle bundle : metadata) {
// TODO (b/67996923) Non-controller Slices should become intent-only slices.
@@ -208,6 +209,8 @@
final boolean isPlatformSlice = bundle.getBoolean(METADATA_PLATFORM_SLICE_FLAG);
final boolean isDynamicSummaryAllowed = bundle.getBoolean(
METADATA_ALLOW_DYNAMIC_SUMMARY_IN_SLICE);
+ final String unavailableSliceSubtitle = bundle.getString(
+ METADATA_UNAVAILABLE_SLICE_SUBTITLE);
final SliceData xmlSlice = new SliceData.Builder()
.setKey(key)
@@ -220,6 +223,7 @@
.setSliceType(sliceType)
.setPlatformDefined(isPlatformSlice)
.setDynamicSummaryAllowed(isDynamicSummaryAllowed)
+ .setUnavailableSliceSubtitle(unavailableSliceSubtitle)
.build();
final BasePreferenceController controller =
diff --git a/src/com/android/settings/slices/SlicePreference.java b/src/com/android/settings/slices/SlicePreference.java
index 98719f7..37a53f4 100644
--- a/src/com/android/settings/slices/SlicePreference.java
+++ b/src/com/android/settings/slices/SlicePreference.java
@@ -33,12 +33,17 @@
public SlicePreference(Context context, AttributeSet attrs) {
super(context, attrs, R.attr.slicePreferenceStyle);
- mSliceView = findViewById(R.id.slice_view);
+ init();
}
public SlicePreference(Context context, AttributeSet attrs, int defStyleAttr) {
- super(context, attrs, R.attr.slicePreferenceStyle);
+ super(context, attrs, defStyleAttr);
+ init();
+ }
+
+ private void init() {
mSliceView = findViewById(R.id.slice_view);
+ mSliceView.showTitleItems(true);
}
public void onSliceUpdated(Slice slice) {
diff --git a/src/com/android/settings/slices/SlicesDatabaseAccessor.java b/src/com/android/settings/slices/SlicesDatabaseAccessor.java
index c75f3ef..ae77dd2 100644
--- a/src/com/android/settings/slices/SlicesDatabaseAccessor.java
+++ b/src/com/android/settings/slices/SlicesDatabaseAccessor.java
@@ -50,6 +50,7 @@
IndexColumns.PLATFORM_SLICE,
IndexColumns.SLICE_TYPE,
IndexColumns.ALLOW_DYNAMIC_SUMMARY_IN_SLICE,
+ IndexColumns.UNAVAILABLE_SLICE_SUBTITLE,
};
// Cursor value for boolean true
@@ -167,6 +168,8 @@
cursor.getColumnIndex(IndexColumns.ALLOW_DYNAMIC_SUMMARY_IN_SLICE)) == TRUE;
int sliceType = cursor.getInt(
cursor.getColumnIndex(IndexColumns.SLICE_TYPE));
+ final String unavailableSliceSubtitle = cursor.getString(
+ cursor.getColumnIndex(IndexColumns.UNAVAILABLE_SLICE_SUBTITLE));
if (isIntentOnly) {
sliceType = SliceData.SliceType.INTENT;
@@ -185,6 +188,7 @@
.setPlatformDefined(isPlatformDefined)
.setSliceType(sliceType)
.setDynamicSummaryAllowed(isDynamicSummaryAllowed)
+ .setUnavailableSliceSubtitle(unavailableSliceSubtitle)
.build();
}
diff --git a/src/com/android/settings/slices/SlicesDatabaseHelper.java b/src/com/android/settings/slices/SlicesDatabaseHelper.java
index e463099..8dc86fb 100644
--- a/src/com/android/settings/slices/SlicesDatabaseHelper.java
+++ b/src/com/android/settings/slices/SlicesDatabaseHelper.java
@@ -36,7 +36,7 @@
private static final String DATABASE_NAME = "slices_index.db";
private static final String SHARED_PREFS_TAG = "slices_shared_prefs";
- private static final int DATABASE_VERSION = 3;
+ private static final int DATABASE_VERSION = 4;
public interface Tables {
String TABLE_SLICES_INDEX = "slices_index";
@@ -99,6 +99,11 @@
* preference controller.
*/
String ALLOW_DYNAMIC_SUMMARY_IN_SLICE = "allow_dynamic_summary_in_slice";
+
+ /**
+ * Customized subtitle if it's a unavailable slice
+ */
+ String UNAVAILABLE_SLICE_SUBTITLE = "unavailable_slice_subtitle";
}
private static final String CREATE_SLICES_TABLE =
@@ -125,6 +130,8 @@
IndexColumns.SLICE_TYPE +
", " +
IndexColumns.ALLOW_DYNAMIC_SUMMARY_IN_SLICE +
+ ", " +
+ IndexColumns.UNAVAILABLE_SLICE_SUBTITLE +
");";
private final Context mContext;
@@ -151,7 +158,7 @@
@Override
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
if (oldVersion < DATABASE_VERSION) {
- Log.d(TAG, "Reconstructing DB from " + oldVersion + "to " + newVersion);
+ Log.d(TAG, "Reconstructing DB from " + oldVersion + " to " + newVersion);
reconstruct(db);
}
}
diff --git a/src/com/android/settings/slices/SlicesIndexer.java b/src/com/android/settings/slices/SlicesIndexer.java
index 0c39429..ec2be29 100644
--- a/src/com/android/settings/slices/SlicesIndexer.java
+++ b/src/com/android/settings/slices/SlicesIndexer.java
@@ -113,6 +113,8 @@
values.put(IndexColumns.SLICE_TYPE, dataRow.getSliceType());
values.put(IndexColumns.ALLOW_DYNAMIC_SUMMARY_IN_SLICE,
dataRow.isDynamicSummaryAllowed());
+ values.put(IndexColumns.UNAVAILABLE_SLICE_SUBTITLE,
+ dataRow.getUnavailableSliceSubtitle());
database.replaceOrThrow(Tables.TABLE_SLICES_INDEX, null /* nullColumnHack */,
values);
diff --git a/src/com/android/settings/widget/UpdatableListPreferenceDialogFragment.java b/src/com/android/settings/widget/UpdatableListPreferenceDialogFragment.java
index 998434e..bd7f78a 100644
--- a/src/com/android/settings/widget/UpdatableListPreferenceDialogFragment.java
+++ b/src/com/android/settings/widget/UpdatableListPreferenceDialogFragment.java
@@ -84,8 +84,8 @@
@Override
public void onDialogClosed(boolean positiveResult) {
- final ListPreference preference = getListPreference();
if (positiveResult && mClickedDialogEntryIndex >= 0) {
+ final ListPreference preference = getListPreference();
final String value = mEntryValues[mClickedDialogEntryIndex].toString();
if (preference.callChangeListener(value)) {
preference.setValue(value);
@@ -144,7 +144,8 @@
return mMetricsCategory;
}
- private ListPreference getListPreference() {
+ @VisibleForTesting
+ ListPreference getListPreference() {
return (ListPreference) getPreference();
}
diff --git a/src/com/android/settings/widget/VideoPreference.java b/src/com/android/settings/widget/VideoPreference.java
index d5d4f5e..fd215d8 100644
--- a/src/com/android/settings/widget/VideoPreference.java
+++ b/src/com/android/settings/widget/VideoPreference.java
@@ -54,6 +54,7 @@
private float mAspectRadio = 1.0f;
private int mPreviewResource;
private boolean mViewVisible;
+ private Surface mSurface;
public VideoPreference(Context context, AttributeSet attrs) {
super(context, attrs);
@@ -68,17 +69,12 @@
.authority(context.getPackageName())
.appendPath(String.valueOf(animation))
.build();
- mMediaPlayer = MediaPlayer.create(mContext, mVideoPath);
+ mPreviewResource = attributes.getResourceId(
+ R.styleable.VideoPreference_preview, 0);
+ initMediaPlayer();
if (mMediaPlayer != null && mMediaPlayer.getDuration() > 0) {
setVisible(true);
setLayoutResource(R.layout.video_preference);
-
- mPreviewResource = attributes.getResourceId(
- R.styleable.VideoPreference_preview, 0);
-
- mMediaPlayer.setOnSeekCompleteListener(mp -> mVideoReady = true);
-
- mMediaPlayer.setOnPreparedListener(mediaPlayer -> mediaPlayer.setLooping(true));
mAnimationAvailable = true;
updateAspectRatio();
} else {
@@ -127,9 +123,8 @@
public void onSurfaceTextureAvailable(SurfaceTexture surfaceTexture, int width,
int height) {
if (mMediaPlayer != null) {
- mMediaPlayer.setSurface(new Surface(surfaceTexture));
- mVideoReady = false;
- mMediaPlayer.seekTo(0);
+ mSurface = new Surface(surfaceTexture);
+ mMediaPlayer.setSurface(mSurface);
}
}
@@ -168,26 +163,40 @@
@Override
public void onDetached() {
- if (mMediaPlayer != null) {
- mMediaPlayer.stop();
- mMediaPlayer.reset();
- mMediaPlayer.release();
- }
+ releaseMediaPlayer();
super.onDetached();
}
public void onViewVisible(boolean videoPaused) {
mViewVisible = true;
mVideoPaused = videoPaused;
- if (mVideoReady && mMediaPlayer != null && !mMediaPlayer.isPlaying()) {
- mMediaPlayer.seekTo(0);
- }
+ initMediaPlayer();
}
public void onViewInvisible() {
mViewVisible = false;
- if (mMediaPlayer != null && mMediaPlayer.isPlaying()) {
- mMediaPlayer.pause();
+ releaseMediaPlayer();
+ }
+
+ private void initMediaPlayer() {
+ if (mMediaPlayer == null) {
+ mMediaPlayer = MediaPlayer.create(mContext, mVideoPath);
+ mMediaPlayer.seekTo(0);
+ mMediaPlayer.setOnSeekCompleteListener(mp -> mVideoReady = true);
+ mMediaPlayer.setOnPreparedListener(mediaPlayer -> mediaPlayer.setLooping(true));
+ if (mSurface != null) {
+ mMediaPlayer.setSurface(mSurface);
+ }
+ }
+ }
+
+ private void releaseMediaPlayer() {
+ if (mMediaPlayer != null) {
+ mMediaPlayer.stop();
+ mMediaPlayer.reset();
+ mMediaPlayer.release();
+ mMediaPlayer = null;
+ mVideoReady = false;
}
}
@@ -197,7 +206,6 @@
@VisibleForTesting
void updateAspectRatio() {
- mAspectRadio = mMediaPlayer.getVideoWidth() / (float)mMediaPlayer.getVideoHeight();
+ mAspectRadio = mMediaPlayer.getVideoWidth() / (float) mMediaPlayer.getVideoHeight();
}
-
}
diff --git a/src/com/android/settings/wifi/NetworkRequestDialogFragment.java b/src/com/android/settings/wifi/NetworkRequestDialogFragment.java
index 7a1bdb4..06e36e5 100644
--- a/src/com/android/settings/wifi/NetworkRequestDialogFragment.java
+++ b/src/com/android/settings/wifi/NetworkRequestDialogFragment.java
@@ -16,7 +16,6 @@
package com.android.settings.wifi;
-import android.app.Activity;
import android.app.Dialog;
import android.content.Context;
import android.content.DialogInterface;
@@ -67,9 +66,15 @@
/** Message sent to us to stop scanning wifi and pop up timeout dialog. */
private static final int MESSAGE_STOP_SCAN_WIFI_LIST = 0;
+ /** Message sent to us to finish activity. */
+ private static final int MESSAGE_FINISH_ACTIVITY = 1;
+
/** Spec defines there should be 5 wifi ap on the list at most. */
private static final int MAX_NUMBER_LIST_ITEM = 5;
+ /** Holding time to let user be aware that selected wifi ap is connected */
+ private static final int DELAY_TIME_USER_AWARE_CONNECTED_MS = 1 * 1000;
+
/** Delayed time to stop scanning wifi. */
private static final int DELAY_TIME_STOP_SCAN_MS = 30 * 1000;
@@ -155,7 +160,9 @@
public void onCancel(@NonNull DialogInterface dialog) {
super.onCancel(dialog);
// Finishes the activity when user clicks back key or outside of the dialog.
- getActivity().finish();
+ if (getActivity() != null) {
+ getActivity().finish();
+ }
}
@Override
@@ -177,6 +184,8 @@
@Override
public void onDestroy() {
super.onDestroy();
+
+ mHandler.removeMessages(MESSAGE_FINISH_ACTIVITY);
if (mFilterWifiTracker != null) {
mFilterWifiTracker.onDestroy();
mFilterWifiTracker = null;
@@ -207,7 +216,10 @@
switch (msg.what) {
case MESSAGE_STOP_SCAN_WIFI_LIST:
removeMessages(MESSAGE_STOP_SCAN_WIFI_LIST);
- stopScanningAndPopErrorDialog(ERROR_DIALOG_TYPE.TIME_OUT);
+ stopScanningAndMaybePopErrorDialog(ERROR_DIALOG_TYPE.TIME_OUT);
+ break;
+ case MESSAGE_FINISH_ACTIVITY:
+ stopScanningAndMaybePopErrorDialog(/* ERROR_DIALOG_TYPE */ null);
break;
default:
// Do nothing.
@@ -216,18 +228,29 @@
}
};
- protected void stopScanningAndPopErrorDialog(ERROR_DIALOG_TYPE type) {
+ protected void stopScanningAndMaybePopErrorDialog(ERROR_DIALOG_TYPE type) {
// Dismisses current dialog.
- dismiss();
+ final Dialog dialog = getDialog();
+ if (dialog != null && dialog.isShowing()) {
+ dismiss();
+ }
- // Throws new timeout dialog.
- final NetworkRequestErrorDialogFragment fragment = NetworkRequestErrorDialogFragment
- .newInstance();
- final Bundle bundle = new Bundle();
- bundle.putSerializable(NetworkRequestErrorDialogFragment.DIALOG_TYPE, type);
- fragment.setArguments(bundle);
- fragment.show(getActivity().getSupportFragmentManager(),
- NetworkRequestDialogFragment.class.getSimpleName());
+ if (type == null) {
+ // If no error, finishes activity.
+ if (getActivity() != null) {
+ getActivity().finish();
+ }
+ } else {
+ // Throws error dialog.
+ final NetworkRequestErrorDialogFragment fragment = NetworkRequestErrorDialogFragment
+ .newInstance();
+ final Bundle bundle = new Bundle();
+ bundle.putSerializable(NetworkRequestErrorDialogFragment.DIALOG_TYPE, type);
+ fragment.setArguments(bundle);
+ fragment.show(getActivity().getSupportFragmentManager(),
+ NetworkRequestDialogFragment.class.getSimpleName());
+ }
+
}
@Override
@@ -284,7 +307,7 @@
@Override
public void onAbort() {
- stopScanningAndPopErrorDialog(ERROR_DIALOG_TYPE.ABORT);
+ stopScanningAndMaybePopErrorDialog(ERROR_DIALOG_TYPE.ABORT);
}
@Override
@@ -295,10 +318,13 @@
@Override
public void onMatch(List<ScanResult> scanResults) {
- mHandler.removeMessages(MESSAGE_STOP_SCAN_WIFI_LIST);
- renewAccessPointList(scanResults);
+ // Shouldn't need to renew cached list, since input result is empty.
+ if (scanResults != null && scanResults.size() > 0) {
+ mHandler.removeMessages(MESSAGE_STOP_SCAN_WIFI_LIST);
+ renewAccessPointList(scanResults);
- notifyAdapterRefresh();
+ notifyAdapterRefresh();
+ }
}
// Updates internal AccessPoint list from WifiTracker. scanResults are used to update key list
@@ -329,17 +355,24 @@
@Override
public void onUserSelectionConnectSuccess(WifiConfiguration wificonfiguration) {
- // Dismisses current dialog and finishes Activity, since connection is success.
- dismiss();
- final Activity activity = getActivity();
- if (activity != null) {
- activity.finish();
+ // Removes the progress icon.
+ final Dialog dialog = getDialog();
+ if (dialog != null) {
+ final View view = dialog.findViewById(R.id.network_request_title_progress);
+ if (view != null) {
+ view.setVisibility(View.GONE);
+ }
}
+
+ // Posts delay to finish self since connection is success.
+ mHandler.removeMessages(MESSAGE_STOP_SCAN_WIFI_LIST);
+ mHandler.sendEmptyMessageDelayed(MESSAGE_FINISH_ACTIVITY,
+ DELAY_TIME_USER_AWARE_CONNECTED_MS);
}
@Override
public void onUserSelectionConnectFailure(WifiConfiguration wificonfiguration) {
- stopScanningAndPopErrorDialog(ERROR_DIALOG_TYPE.ABORT);
+ stopScanningAndMaybePopErrorDialog(ERROR_DIALOG_TYPE.ABORT);
}
private final class FilterWifiTracker {
diff --git a/src/com/android/settings/wifi/WifiSettings.java b/src/com/android/settings/wifi/WifiSettings.java
index 95e912d..eddae06 100644
--- a/src/com/android/settings/wifi/WifiSettings.java
+++ b/src/com/android/settings/wifi/WifiSettings.java
@@ -240,7 +240,7 @@
mAddPreference.setIcon(R.drawable.ic_menu_add);
mAddPreference.setTitle(R.string.wifi_add_network);
if (WifiDppUtils.isSharingNetworkEnabled(getContext())) {
- mAddPreference.setButtonIcon(R.drawable.ic_qrcode_24dp);
+ mAddPreference.setButtonIcon(R.drawable.ic_scan_24dp);
mAddPreference.setButtonOnClickListener((View v) -> {
// Launch QR code scanner to join a network.
getContext().startActivity(
diff --git a/src/com/android/settings/wifi/dpp/WifiDppAddDeviceFragment.java b/src/com/android/settings/wifi/dpp/WifiDppAddDeviceFragment.java
index 90fb850..0821ec0 100644
--- a/src/com/android/settings/wifi/dpp/WifiDppAddDeviceFragment.java
+++ b/src/com/android/settings/wifi/dpp/WifiDppAddDeviceFragment.java
@@ -16,14 +16,19 @@
package com.android.settings.wifi.dpp;
+import android.app.ActionBar;
+import android.app.Activity;
+import android.content.Context;
+import android.net.wifi.WifiManager;
import android.os.Bundle;
+import android.text.TextUtils;
+import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.ProgressBar;
-import android.widget.TextView;
import com.android.internal.logging.nano.MetricsProto;
import com.android.settings.R;
@@ -33,18 +38,64 @@
* to the Wi-Fi network.
*/
public class WifiDppAddDeviceFragment extends WifiDppQrCodeBaseFragment {
- private ProgressBar mProgressBar;
+ private static final String TAG = "WifiDppAddDeviceFragment";
+
private ImageView mWifiApPictureView;
- private TextView mChooseDifferentNetwork;
+ private Button mChooseDifferentNetwork;
private Button mButtonLeft;
private Button mButtonRight;
+ private class DppStatusCallback extends android.net.wifi.DppStatusCallback {
+ @Override
+ public void onEnrolleeSuccess(int newNetworkId) {
+ // Do nothing
+ }
+
+ @Override
+ public void onConfiguratorSuccess(int code) {
+ // Update success UI.
+ mTitle.setText(R.string.wifi_dpp_wifi_shared_with_device);
+ mSummary.setVisibility(View.INVISIBLE);
+ mChooseDifferentNetwork.setVisibility(View.INVISIBLE);
+ mButtonLeft.setText(R.string.wifi_dpp_add_another_device);
+ mButtonLeft.setOnClickListener(v -> getFragmentManager().popBackStack());
+ mButtonRight.setText(R.string.done);
+ mButtonRight.setOnClickListener(v -> getActivity().finish());
+ }
+
+ @Override
+ public void onFailure(int code) {
+ Log.d(TAG, "DppStatusCallback.onFailure " + code);
+
+ // Update fail UI.
+ mTitle.setText(R.string.wifi_dpp_could_not_add_device);
+ mSummary.setVisibility(View.INVISIBLE);
+ mChooseDifferentNetwork.setVisibility(View.INVISIBLE);
+ mButtonRight.setText(R.string.retry);
+ }
+
+ @Override
+ public void onProgress(int code) {
+ // Do nothing
+ }
+ }
+
@Override
public int getMetricsCategory() {
return MetricsProto.MetricsEvent.SETTINGS_WIFI_DPP_CONFIGURATOR;
}
@Override
+ public void onActivityCreated(Bundle savedInstanceState) {
+ super.onActivityCreated(savedInstanceState);
+
+ final ActionBar actionBar = getActivity().getActionBar();
+ if (actionBar != null) {
+ actionBar.hide();
+ }
+ }
+
+ @Override
public final View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
return inflater.inflate(R.layout.wifi_dpp_add_device_fragment, container,
@@ -55,10 +106,70 @@
public void onViewCreated(View view, Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
- mProgressBar = view.findViewById(R.id.progress_bar);
+ final WifiQrCode wifiQrCode = ((WifiDppConfiguratorActivity) getActivity())
+ .getWifiDppQrCode();
+ final String information = wifiQrCode.getInformation();
+ if (TextUtils.isEmpty(information)) {
+ mTitle.setText(R.string.wifi_dpp_device_found);
+ } else {
+ mTitle.setText(information);
+ }
+
+ final WifiNetworkConfig wifiNetworkConfig = ((WifiDppConfiguratorActivity) getActivity())
+ .getWifiNetworkConfig();
+ if (!WifiNetworkConfig.isValidConfig(wifiNetworkConfig)) {
+ throw new IllegalStateException("Invalid Wi-Fi network for configuring");
+ }
+ mSummary.setText(getString(R.string.wifi_dpp_add_device_to_wifi,
+ wifiNetworkConfig.getSsid()));
+
mWifiApPictureView = view.findViewById(R.id.wifi_ap_picture_view);
+
mChooseDifferentNetwork = view.findViewById(R.id.choose_different_network);
+ mChooseDifferentNetwork.setOnClickListener(v ->
+ mClickChooseDifferentNetworkListener.onClickChooseDifferentNetwork());
+
mButtonLeft = view.findViewById(R.id.button_left);
+ mButtonLeft.setText(R.string.cancel);
+ mButtonLeft.setOnClickListener(v -> {
+ getActivity().setResult(Activity.RESULT_CANCELED);
+ getActivity().finish();
+ });
+
mButtonRight = view.findViewById(R.id.button_right);
+ mButtonRight.setText(R.string.wifi_dpp_share_wifi);
+ mButtonRight.setOnClickListener(v -> startWifiDppInitiator());
+ }
+
+ private void startWifiDppInitiator() {
+ final WifiQrCode wifiQrCode = ((WifiDppConfiguratorActivity) getActivity())
+ .getWifiDppQrCode();
+ final String qrCode = wifiQrCode.getQrCode();
+ final int networkId =
+ ((WifiDppConfiguratorActivity) getActivity()).getWifiNetworkConfig().getNetworkId();
+ final WifiManager wifiManager = getContext().getSystemService(WifiManager.class);
+
+ wifiManager.startDppAsConfiguratorInitiator(qrCode, networkId,
+ WifiManager.DPP_NETWORK_ROLE_STA, /* handler */ null, new DppStatusCallback());
+ }
+
+ // Container Activity must implement this interface
+ public interface OnClickChooseDifferentNetworkListener {
+ public void onClickChooseDifferentNetwork();
+ }
+ OnClickChooseDifferentNetworkListener mClickChooseDifferentNetworkListener;
+
+ @Override
+ public void onAttach(Context context) {
+ super.onAttach(context);
+
+ mClickChooseDifferentNetworkListener = (OnClickChooseDifferentNetworkListener) context;
+ }
+
+ @Override
+ public void onDetach() {
+ mClickChooseDifferentNetworkListener = null;
+
+ super.onDetach();
}
}
diff --git a/src/com/android/settings/wifi/dpp/WifiDppChooseSavedWifiNetworkFragment.java b/src/com/android/settings/wifi/dpp/WifiDppChooseSavedWifiNetworkFragment.java
index a3e6db3..8037e23 100644
--- a/src/com/android/settings/wifi/dpp/WifiDppChooseSavedWifiNetworkFragment.java
+++ b/src/com/android/settings/wifi/dpp/WifiDppChooseSavedWifiNetworkFragment.java
@@ -16,6 +16,8 @@
package com.android.settings.wifi.dpp;
+import android.app.ActionBar;
+import android.app.Activity;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
@@ -41,6 +43,16 @@
}
@Override
+ public void onActivityCreated(Bundle savedInstanceState) {
+ super.onActivityCreated(savedInstanceState);
+
+ final ActionBar actionBar = getActivity().getActionBar();
+ if (actionBar != null) {
+ actionBar.hide();
+ }
+ }
+
+ @Override
public final View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
return inflater.inflate(R.layout.wifi_dpp_choose_saved_wifi_network_fragment, container,
@@ -51,8 +63,18 @@
public void onViewCreated(View view, Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
- mSavedWifiNetworkList = view.findViewById(R.id.saved_wifi_network_list);
+ mTitle.setText(R.string.wifi_dpp_choose_network);
+ mSummary.setText(R.string.wifi_dpp_choose_network_to_connect_device);
+
mButtonLeft = view.findViewById(R.id.button_left);
+ mButtonLeft.setText(R.string.cancel);
+ mButtonLeft.setOnClickListener(v -> {
+ Activity activity = getActivity();
+ activity.setResult(Activity.RESULT_CANCELED);
+ activity.finish();
+ });
+
mButtonRight = view.findViewById(R.id.button_right);
+ mButtonRight.setVisibility(View.GONE);
}
}
diff --git a/src/com/android/settings/wifi/dpp/WifiDppConfiguratorActivity.java b/src/com/android/settings/wifi/dpp/WifiDppConfiguratorActivity.java
index e89ebaa..97ee71a 100644
--- a/src/com/android/settings/wifi/dpp/WifiDppConfiguratorActivity.java
+++ b/src/com/android/settings/wifi/dpp/WifiDppConfiguratorActivity.java
@@ -22,6 +22,7 @@
import android.os.Bundle;
import android.util.Log;
+import androidx.annotation.VisibleForTesting;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentTransaction;
@@ -44,33 +45,39 @@
* {@code WifiDppUtils.EXTRA_WIFI_PRE_SHARED_KEY}
* {@code WifiDppUtils.EXTRA_WIFI_HIDDEN_SSID}
*
- * For intent action {@code ACTION_CONFIGURATOR_CHOOSE_SAVED_WIFI_NETWORK}, specify Wi-Fi (DPP)
+ * For intent action {@code ACTION_PROCESS_WIFI_DPP_QR_CODE}, specify Wi-Fi (DPP)
* QR code in {@code WifiDppUtils.EXTRA_QR_CODE}
*/
public class WifiDppConfiguratorActivity extends InstrumentedActivity implements
WifiNetworkConfig.Retriever,
WifiDppQrCodeGeneratorFragment.OnQrCodeGeneratorFragmentAddButtonClickedListener,
WifiDppQrCodeScannerFragment.OnScanWifiDppSuccessListener,
- WifiDppQrCodeScannerFragment.OnScanZxingWifiFormatSuccessListener {
+ WifiDppQrCodeScannerFragment.OnScanZxingWifiFormatSuccessListener,
+ WifiDppAddDeviceFragment.OnClickChooseDifferentNetworkListener {
private static final String TAG = "WifiDppConfiguratorActivity";
public static final String ACTION_CONFIGURATOR_QR_CODE_SCANNER =
"android.settings.WIFI_DPP_CONFIGURATOR_QR_CODE_SCANNER";
public static final String ACTION_CONFIGURATOR_QR_CODE_GENERATOR =
"android.settings.WIFI_DPP_CONFIGURATOR_QR_CODE_GENERATOR";
- public static final String ACTION_CONFIGURATOR_CHOOSE_SAVED_WIFI_NETWORK =
- "android.settings.WIFI_DPP_CONFIGURATOR_CHOOSE_SAVED_WIFI_NETWORK";
+ public static final String ACTION_PROCESS_WIFI_DPP_QR_CODE =
+ "android.settings.PROCESS_WIFI_DPP_QR_CODE";
+
+ // Key for Bundle usage
+ private static final String KEY_QR_CODE = "key_qr_code";
+ private static final String KEY_WIFI_SECURITY = "key_wifi_security";
+ private static final String KEY_WIFI_SSID = "key_wifi_ssid";
+ private static final String KEY_WIFI_PRESHARED_KEY = "key_wifi_preshared_key";
+ private static final String KEY_WIFI_HIDDEN_SSID = "key_wifi_hidden_ssid";
+ private static final String KEY_WIFI_NETWORK_ID = "key_wifi_network_id";
private FragmentManager mFragmentManager;
/** The Wi-Fi network which will be configured */
private WifiNetworkConfig mWifiNetworkConfig;
- /** The public key from Wi-Fi DPP QR code */
- private String mPublicKey;
-
- /** The information from Wi-Fi DPP QR code */
- private String mInformation;
+ /** The Wi-Fi DPP QR code from intent ACTION_PROCESS_WIFI_DPP_QR_CODE */
+ private WifiQrCode mWifiDppQrCode;
@Override
public int getMetricsCategory() {
@@ -81,6 +88,21 @@
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
+ if (savedInstanceState != null) {
+ String qrCode = savedInstanceState.getString(KEY_QR_CODE);
+
+ mWifiDppQrCode = getValidWifiDppQrCodeOrNull(qrCode);
+
+ String security = savedInstanceState.getString(KEY_WIFI_SECURITY);
+ String ssid = savedInstanceState.getString(KEY_WIFI_SSID);
+ String preSharedKey = savedInstanceState.getString(KEY_WIFI_PRESHARED_KEY);
+ boolean hiddenSsid = savedInstanceState.getBoolean(KEY_WIFI_HIDDEN_SSID);
+ int networkId = savedInstanceState.getInt(KEY_WIFI_NETWORK_ID);
+
+ mWifiNetworkConfig = WifiNetworkConfig.getValidConfigOrNull(security, ssid,
+ preSharedKey, hiddenSsid, networkId);
+ }
+
setContentView(R.layout.wifi_dpp_activity);
mFragmentManager = getSupportFragmentManager();
@@ -115,8 +137,14 @@
showQrCodeGeneratorFragment();
}
break;
- case ACTION_CONFIGURATOR_CHOOSE_SAVED_WIFI_NETWORK:
- showChooseSavedWifiNetworkFragment(/* addToBackStack */ false);
+ case ACTION_PROCESS_WIFI_DPP_QR_CODE:
+ String qrCode = intent.getStringExtra(WifiDppUtils.EXTRA_QR_CODE);
+ mWifiDppQrCode = getValidWifiDppQrCodeOrNull(qrCode);
+ if (mWifiDppQrCode == null) {
+ cancelActivity = true;
+ } else {
+ showChooseSavedWifiNetworkFragment(/* addToBackStack */ false);
+ }
break;
default:
cancelActivity = true;
@@ -199,21 +227,32 @@
fragmentTransaction.commit();
}
+ private WifiQrCode getValidWifiDppQrCodeOrNull(String qrCode) {
+ WifiQrCode wifiQrCode;
+ try {
+ wifiQrCode = new WifiQrCode(qrCode);
+ } catch(IllegalArgumentException e) {
+ return null;
+ }
+
+ if (WifiQrCode.SCHEME_DPP.equals(wifiQrCode.getScheme())) {
+ return wifiQrCode;
+ }
+
+ return null;
+ }
+
@Override
public WifiNetworkConfig getWifiNetworkConfig() {
return mWifiNetworkConfig;
}
- public String getPublicKey() {
- return mPublicKey;
+ public WifiQrCode getWifiDppQrCode() {
+ return mWifiDppQrCode;
}
- public String getInformation() {
- return mInformation;
- }
-
- @Override
- public boolean setWifiNetworkConfig(WifiNetworkConfig config) {
+ @VisibleForTesting(otherwise = VisibleForTesting.PRIVATE)
+ protected boolean setWifiNetworkConfig(WifiNetworkConfig config) {
if(!WifiNetworkConfig.isValidConfig(config)) {
return false;
} else {
@@ -222,8 +261,22 @@
}
}
+ @VisibleForTesting(otherwise = VisibleForTesting.PRIVATE)
+ protected boolean setWifiDppQrCode(WifiQrCode wifiQrCode) {
+ if (wifiQrCode == null) {
+ return false;
+ }
+
+ if (!WifiQrCode.SCHEME_DPP.equals(wifiQrCode.getScheme())) {
+ return false;
+ }
+
+ mWifiDppQrCode = new WifiQrCode(wifiQrCode.getQrCode());
+ return true;
+ }
+
@Override
- public boolean onNavigateUp(){
+ public boolean onNavigateUp() {
Fragment fragment = mFragmentManager.findFragmentById(R.id.fragment_container);
if (fragment instanceof WifiDppQrCodeGeneratorFragment) {
setResult(Activity.RESULT_CANCELED);
@@ -242,20 +295,38 @@
}
@Override
- public void onScanWifiDppSuccess(String publicKey, String information) {
- mPublicKey = publicKey;
- mInformation = information;
- mWifiNetworkConfig = null;
+ public void onScanWifiDppSuccess(WifiQrCode wifiQrCode) {
+ mWifiDppQrCode = wifiQrCode;
showAddDeviceFragment(/* addToBackStack */ true);
}
@Override
public void onScanZxingWifiFormatSuccess(WifiNetworkConfig wifiNetworkConfig) {
- mPublicKey = null;
- mInformation = null;
- mWifiNetworkConfig = new WifiNetworkConfig(wifiNetworkConfig);
+ // Do nothing, it's impossible to be a configurator without a Wi-Fi DPP QR code
+ }
- showAddDeviceFragment(/* addToBackStack */ true);
+ @Override
+ public void onClickChooseDifferentNetwork() {
+ mWifiNetworkConfig = null;
+
+ showChooseSavedWifiNetworkFragment(/* addToBackStack */ true);
+ }
+
+ @Override
+ public void onSaveInstanceState(Bundle outState) {
+ if (mWifiDppQrCode != null) {
+ outState.putString(KEY_QR_CODE, mWifiDppQrCode.getQrCode());
+ }
+
+ if (mWifiNetworkConfig != null) {
+ outState.putString(KEY_WIFI_SECURITY, mWifiNetworkConfig.getSecurity());
+ outState.putString(KEY_WIFI_SSID, mWifiNetworkConfig.getSsid());
+ outState.putString(KEY_WIFI_PRESHARED_KEY, mWifiNetworkConfig.getPreSharedKey());
+ outState.putBoolean(KEY_WIFI_HIDDEN_SSID, mWifiNetworkConfig.getHiddenSsid());
+ outState.putInt(KEY_WIFI_NETWORK_ID, mWifiNetworkConfig.getNetworkId());
+ }
+
+ super.onSaveInstanceState(outState);
}
}
diff --git a/src/com/android/settings/wifi/dpp/WifiDppEnrolleeActivity.java b/src/com/android/settings/wifi/dpp/WifiDppEnrolleeActivity.java
index 584a819..3a1b6bc 100644
--- a/src/com/android/settings/wifi/dpp/WifiDppEnrolleeActivity.java
+++ b/src/com/android/settings/wifi/dpp/WifiDppEnrolleeActivity.java
@@ -16,6 +16,8 @@
package com.android.settings.wifi.dpp;
+import android.content.Context;
+import android.net.wifi.WifiConfiguration;
import android.provider.Settings;
import android.app.ActionBar;
import android.app.Activity;
@@ -32,6 +34,8 @@
import com.android.settings.core.InstrumentedActivity;
import com.android.settings.R;
+import java.util.List;
+
/**
* To provision "this" device with specified Wi-Fi network.
*
@@ -49,6 +53,39 @@
private FragmentManager mFragmentManager;
+ private class DppStatusCallback extends android.net.wifi.DppStatusCallback {
+ @Override
+ public void onEnrolleeSuccess(int newNetworkId) {
+ // Connect to the new network.
+ final WifiManager wifiManager = getSystemService(WifiManager.class);
+ final List<WifiConfiguration> wifiConfigs = wifiManager.getPrivilegedConfiguredNetworks();
+ for (WifiConfiguration wifiConfig : wifiConfigs) {
+ if (wifiConfig.networkId == newNetworkId) {
+ wifiManager.connect(wifiConfig, WifiDppEnrolleeActivity.this);
+ return;
+ }
+ }
+ Log.e(TAG, "Invalid networkId " + newNetworkId);
+ WifiDppEnrolleeActivity.this.onFailure(WifiManager.ERROR_AUTHENTICATING);
+ }
+
+ @Override
+ public void onConfiguratorSuccess(int code) {
+ // Do nothing
+ }
+
+ @Override
+ public void onFailure(int code) {
+ //TODO(b/122429170): Show DPP enrollee error state UI
+ Log.d(TAG, "DppStatusCallback.onFailure " + code);
+ }
+
+ @Override
+ public void onProgress(int code) {
+ // Do nothing
+ }
+ }
+
@Override
public int getMetricsCategory() {
return MetricsProto.MetricsEvent.SETTINGS_WIFI_DPP_ENROLLEE;
@@ -108,8 +145,10 @@
}
@Override
- public void onScanWifiDppSuccess(String publicKey, String information) {
- // TODO(b/1023597): starts DPP enrollee handshake here
+ public void onScanWifiDppSuccess(WifiQrCode wifiQrCode) {
+ final WifiManager wifiManager = (WifiManager) getSystemService(Context.WIFI_SERVICE);
+ wifiManager.startDppAsEnrolleeInitiator(wifiQrCode.getQrCode(), /* handler */ null,
+ new DppStatusCallback());
}
@Override
diff --git a/src/com/android/settings/wifi/dpp/WifiDppQrCodeScannerFragment.java b/src/com/android/settings/wifi/dpp/WifiDppQrCodeScannerFragment.java
index c7c1461..21534dc 100644
--- a/src/com/android/settings/wifi/dpp/WifiDppQrCodeScannerFragment.java
+++ b/src/com/android/settings/wifi/dpp/WifiDppQrCodeScannerFragment.java
@@ -62,9 +62,9 @@
private static final long SHOW_ERROR_MESSAGE_INTERVAL = 2000;
private static final long SHOW_SUCCESS_SQUARE_INTERVAL = 1000;
- // Keys for Bundle usage
- private static final String KEY_PUBLIC_KEY = "key_public_key";
- private static final String KEY_INFORMATION = "key_information";
+ // Key for Bundle usage
+ private static final String KEY_PUBLIC_URI = "key_public_uri";
+ private static final String KEY_IS_CONFIGURATOR_MODE = "key_is_configurator_mode";
private QrCamera mCamera;
private TextureView mTextureView;
@@ -72,7 +72,7 @@
private TextView mErrorMessage;
/** true if the fragment working for configurator, false enrollee*/
- private final boolean mIsConfiguratorMode;
+ private boolean mIsConfiguratorMode;
/** The SSID of the Wi-Fi network which the user specify to enroll */
private String mSsid;
@@ -81,6 +81,15 @@
private WifiQrCode mWifiQrCode;
@Override
+ public void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+
+ if (savedInstanceState != null) {
+ mIsConfiguratorMode = savedInstanceState.getBoolean(KEY_IS_CONFIGURATOR_MODE);
+ }
+ }
+
+ @Override
public int getMetricsCategory() {
if (mIsConfiguratorMode) {
return MetricsProto.MetricsEvent.SETTINGS_WIFI_DPP_CONFIGURATOR;
@@ -91,7 +100,7 @@
// Container Activity must implement this interface
public interface OnScanWifiDppSuccessListener {
- public void onScanWifiDppSuccess(String publicKey, String information);
+ public void onScanWifiDppSuccess(WifiQrCode wifiQrCode);
}
OnScanWifiDppSuccessListener mScanWifiDppSuccessListener;
@@ -99,7 +108,7 @@
public interface OnScanZxingWifiFormatSuccessListener {
public void onScanZxingWifiFormatSuccess(WifiNetworkConfig wifiNetworkConfig);
}
- OnScanZxingWifiFormatSuccessListener mScanScanZxingWifiFormatSuccessListener;
+ OnScanZxingWifiFormatSuccessListener mScanZxingWifiFormatSuccessListener;
/**
* Configurator container activity of the fragment should create instance with this constructor.
@@ -137,13 +146,13 @@
super.onAttach(context);
mScanWifiDppSuccessListener = (OnScanWifiDppSuccessListener) context;
- mScanScanZxingWifiFormatSuccessListener = (OnScanZxingWifiFormatSuccessListener) context;
+ mScanZxingWifiFormatSuccessListener = (OnScanZxingWifiFormatSuccessListener) context;
}
@Override
public void onDetach() {
mScanWifiDppSuccessListener = null;
- mScanScanZxingWifiFormatSuccessListener = null;
+ mScanZxingWifiFormatSuccessListener = null;
super.onDetach();
}
@@ -263,17 +272,17 @@
}
/**
- * This method is only called when QrCamera.ScannerCallback.isValid returns true;
+ * This method is only called when QrCamera.ScannerCallback.isValid returns true;
*/
@Override
public void handleSuccessfulResult(String qrCode) {
switch (mWifiQrCode.getScheme()) {
case WifiQrCode.SCHEME_DPP:
- handleWifiDpp(mWifiQrCode.getPublicKey(), mWifiQrCode.getInformation());
+ handleWifiDpp();
break;
case WifiQrCode.SCHEME_ZXING_WIFI_NETWORK_CONFIG:
- handleZxingWifiFormat(mWifiQrCode.getWifiNetworkConfig());
+ handleZxingWifiFormat();
break;
default:
@@ -281,26 +290,22 @@
}
}
- private void handleWifiDpp(String publicKey, String information) {
+ private void handleWifiDpp() {
destroyCamera();
mDecorateView.setFocused(true);
- final Bundle bundle = new Bundle();
- bundle.putString(KEY_PUBLIC_KEY, publicKey);
- bundle.putString(KEY_INFORMATION, information);
-
Message message = mHandler.obtainMessage(MESSAGE_SCAN_WIFI_DPP_SUCCESS);
- message.setData(bundle);
+ message.obj = new WifiQrCode(mWifiQrCode.getQrCode());
mHandler.sendMessageDelayed(message, SHOW_SUCCESS_SQUARE_INTERVAL);
}
- private void handleZxingWifiFormat(WifiNetworkConfig wifiNetworkConfig) {
+ private void handleZxingWifiFormat() {
destroyCamera();
mDecorateView.setFocused(true);
Message message = mHandler.obtainMessage(MESSAGE_SCAN_ZXING_WIFI_FORMAT_SUCCESS);
- message.obj = wifiNetworkConfig;
+ message.obj = new WifiQrCode(mWifiQrCode.getQrCode()).getWifiNetworkConfig();
mHandler.sendMessageDelayed(message, SHOW_SUCCESS_SQUARE_INTERVAL);
}
@@ -351,18 +356,14 @@
if (mScanWifiDppSuccessListener == null) {
return;
}
- final Bundle bundle = msg.getData();
- final String publicKey = bundle.getString(KEY_PUBLIC_KEY);
- final String information = bundle.getString(KEY_INFORMATION);
-
- mScanWifiDppSuccessListener.onScanWifiDppSuccess(publicKey, information);
+ mScanWifiDppSuccessListener.onScanWifiDppSuccess((WifiQrCode)msg.obj);
break;
case MESSAGE_SCAN_ZXING_WIFI_FORMAT_SUCCESS:
- if (mScanScanZxingWifiFormatSuccessListener == null) {
+ if (mScanZxingWifiFormatSuccessListener == null) {
return;
}
- mScanScanZxingWifiFormatSuccessListener.onScanZxingWifiFormatSuccess(
+ mScanZxingWifiFormatSuccessListener.onScanZxingWifiFormatSuccess(
(WifiNetworkConfig)msg.obj);
break;
@@ -371,4 +372,11 @@
}
}
};
+
+ @Override
+ public void onSaveInstanceState(Bundle outState) {
+ outState.putBoolean(KEY_IS_CONFIGURATOR_MODE, mIsConfiguratorMode);
+
+ super.onSaveInstanceState(outState);
+ }
}
diff --git a/src/com/android/settings/wifi/dpp/WifiDppUtils.java b/src/com/android/settings/wifi/dpp/WifiDppUtils.java
index 3a40e25..0205ec1 100644
--- a/src/com/android/settings/wifi/dpp/WifiDppUtils.java
+++ b/src/com/android/settings/wifi/dpp/WifiDppUtils.java
@@ -64,6 +64,9 @@
/** The data corresponding to {@code WifiConfiguration} hiddenSSID */
public static final String EXTRA_WIFI_HIDDEN_SSID = "hiddenSsid";
+ /** The data corresponding to {@code WifiConfiguration} networkId */
+ public static final String EXTRA_WIFI_NETWORK_ID = "networkId";
+
/** @see WifiQrCode */
public static final String EXTRA_QR_CODE = "qrCode";
@@ -164,6 +167,11 @@
if (!TextUtils.isEmpty(preSharedKey)) {
intent.putExtra(EXTRA_WIFI_PRE_SHARED_KEY, preSharedKey);
}
+ if (wifiConfig.networkId == WifiConfiguration.INVALID_NETWORK_ID) {
+ throw new IllegalArgumentException("Invalid network ID");
+ } else {
+ intent.putExtra(EXTRA_WIFI_NETWORK_ID, wifiConfig.networkId);
+ }
return intent;
}
diff --git a/src/com/android/settings/wifi/dpp/WifiNetworkConfig.java b/src/com/android/settings/wifi/dpp/WifiNetworkConfig.java
index c9bfbd6..915e90d 100644
--- a/src/com/android/settings/wifi/dpp/WifiNetworkConfig.java
+++ b/src/com/android/settings/wifi/dpp/WifiNetworkConfig.java
@@ -30,6 +30,7 @@
import android.util.Log;
import androidx.annotation.Keep;
+import androidx.annotation.VisibleForTesting;
/**
* Wraps the parameters of ZXing reader library's Wi-Fi Network config format.
@@ -46,13 +47,16 @@
private String mSsid;
private String mPreSharedKey;
private boolean mHiddenSsid;
+ private int mNetworkId;
- private WifiNetworkConfig(String security, String ssid, String preSharedKey,
- boolean hiddenSsid) {
+ @VisibleForTesting(otherwise = VisibleForTesting.PRIVATE)
+ protected WifiNetworkConfig(String security, String ssid, String preSharedKey,
+ boolean hiddenSsid, int networkId) {
mSecurity = security;
mSsid = ssid;
mPreSharedKey = preSharedKey;
mHiddenSsid = hiddenSsid;
+ mNetworkId = networkId;
}
public WifiNetworkConfig(WifiNetworkConfig config) {
@@ -60,6 +64,7 @@
mSsid = config.mSsid;
mPreSharedKey = config.mPreSharedKey;
mHiddenSsid = config.mHiddenSsid;
+ mNetworkId = config.mNetworkId;
}
/**
@@ -68,7 +73,6 @@
*/
public interface Retriever {
public WifiNetworkConfig getWifiNetworkConfig();
- public boolean setWifiNetworkConfig(WifiNetworkConfig config);
}
/**
@@ -82,17 +86,19 @@
String ssid = intent.getStringExtra(WifiDppUtils.EXTRA_WIFI_SSID);
String preSharedKey = intent.getStringExtra(WifiDppUtils.EXTRA_WIFI_PRE_SHARED_KEY);
boolean hiddenSsid = intent.getBooleanExtra(WifiDppUtils.EXTRA_WIFI_HIDDEN_SSID, false);
+ int networkId = intent.getIntExtra(WifiDppUtils.EXTRA_WIFI_NETWORK_ID,
+ WifiConfiguration.INVALID_NETWORK_ID);
- return getValidConfigOrNull(security, ssid, preSharedKey, hiddenSsid);
+ return getValidConfigOrNull(security, ssid, preSharedKey, hiddenSsid, networkId);
}
public static WifiNetworkConfig getValidConfigOrNull(String security, String ssid,
- String preSharedKey, boolean hiddenSsid) {
+ String preSharedKey, boolean hiddenSsid, int networkId) {
if (!isValidConfig(security, ssid, preSharedKey, hiddenSsid)) {
return null;
}
- return new WifiNetworkConfig(security, ssid, preSharedKey, hiddenSsid);
+ return new WifiNetworkConfig(security, ssid, preSharedKey, hiddenSsid, networkId);
}
public static boolean isValidConfig(WifiNetworkConfig config) {
@@ -184,6 +190,11 @@
return mHiddenSsid;
}
+ @Keep
+ public int getNetworkId() {
+ return mNetworkId;
+ }
+
public void connect(Context context, WifiManager.ActionListener listener) {
WifiConfiguration wifiConfiguration = getWifiConfigurationOrNull();
if (wifiConfiguration == null) {
@@ -208,6 +219,7 @@
final WifiConfiguration wifiConfiguration = new WifiConfiguration();
wifiConfiguration.SSID = addQuotationIfNeeded(mSsid);
wifiConfiguration.hiddenSSID = mHiddenSsid;
+ wifiConfiguration.networkId = mNetworkId;
if (TextUtils.isEmpty(mSecurity) || SECURITY_NO_PASSWORD.equals(mSecurity)) {
wifiConfiguration.allowedKeyManagement.set(KeyMgmt.NONE);
diff --git a/src/com/android/settings/wifi/dpp/WifiQrCode.java b/src/com/android/settings/wifi/dpp/WifiQrCode.java
index a8562bb..b60289f 100644
--- a/src/com/android/settings/wifi/dpp/WifiQrCode.java
+++ b/src/com/android/settings/wifi/dpp/WifiQrCode.java
@@ -17,9 +17,9 @@
package com.android.settings.wifi.dpp;
import android.content.Intent;
+import android.net.wifi.WifiConfiguration;
import android.text.TextUtils;
-import androidx.annotation.Keep;
import androidx.annotation.VisibleForTesting;
import java.util.Arrays;
@@ -48,7 +48,6 @@
* H true Optional. True if the network SSID is hidden.
*
*/
-@Keep
public class WifiQrCode {
public static final String SCHEME_DPP = "DPP";
public static final String SCHEME_ZXING_WIFI_NETWORK_CONFIG = "WIFI";
@@ -85,7 +84,6 @@
// Data from parsed ZXing reader library's Wi-Fi Network config format
private WifiNetworkConfig mWifiNetworkConfig;
- @Keep
public WifiQrCode(String qrCode) throws IllegalArgumentException {
if (TextUtils.isEmpty(qrCode)) {
throw new IllegalArgumentException("Empty QR code");
@@ -135,7 +133,7 @@
password = removeBackSlash(password);
mWifiNetworkConfig = WifiNetworkConfig.getValidConfigOrNull(security, ssid, password,
- hiddenSsid);
+ hiddenSsid, WifiConfiguration.INVALID_NETWORK_ID);
if (mWifiNetworkConfig == null) {
throw new IllegalArgumentException("Invalid format");
@@ -171,7 +169,6 @@
return null;
}
- @Keep
@VisibleForTesting(otherwise = VisibleForTesting.PRIVATE)
protected String removeBackSlash(String input) {
if (input == null) {
@@ -198,7 +195,6 @@
return sb.toString();
}
- @Keep
public String getQrCode() {
return mQrCode;
}
@@ -209,25 +205,22 @@
* SCHEME_DPP for standard Wi-Fi device provision protocol; SCHEME_ZXING_WIFI_NETWORK_CONFIG
* for ZXing reader library' Wi-Fi Network config format
*/
- @Keep
public String getScheme() {
return mScheme;
}
/** Available when {@code getScheme()} returns SCHEME_DPP */
- @Keep
- public String getPublicKey() {
+ @VisibleForTesting(otherwise = VisibleForTesting.PRIVATE)
+ protected String getPublicKey() {
return mPublicKey;
}
/** May be available when {@code getScheme()} returns SCHEME_DPP */
- @Keep
public String getInformation() {
return mInformation;
}
/** Available when {@code getScheme()} returns SCHEME_ZXING_WIFI_NETWORK_CONFIG */
- @Keep
public WifiNetworkConfig getWifiNetworkConfig() {
if (mWifiNetworkConfig == null) {
return null;
diff --git a/src/com/android/settings/wifi/slice/WifiSlice.java b/src/com/android/settings/wifi/slice/WifiSlice.java
index 4d3a95a..35bb89f 100644
--- a/src/com/android/settings/wifi/slice/WifiSlice.java
+++ b/src/com/android/settings/wifi/slice/WifiSlice.java
@@ -105,8 +105,8 @@
return listBuilder.build();
}
- final List<AccessPoint> results =
- SliceBackgroundWorker.getInstance(mContext, this).getResults();
+ final SliceBackgroundWorker worker = SliceBackgroundWorker.getInstance(getUri());
+ final List<AccessPoint> results = worker != null ? worker.getResults() : null;
// Need a loading text when results are not ready.
boolean needLoadingRow = results == null;
diff --git a/src/com/android/settings/wifi/tether/WifiTetherSSIDPreferenceController.java b/src/com/android/settings/wifi/tether/WifiTetherSSIDPreferenceController.java
index fb2ce97..c0a3fa7 100644
--- a/src/com/android/settings/wifi/tether/WifiTetherSSIDPreferenceController.java
+++ b/src/com/android/settings/wifi/tether/WifiTetherSSIDPreferenceController.java
@@ -53,10 +53,8 @@
final WifiConfiguration config = mWifiManager.getWifiApConfiguration();
if (config != null) {
mSSID = config.SSID;
- Log.d(TAG, "Updating SSID in Preference, " + mSSID);
} else {
mSSID = DEFAULT_SSID;
- Log.d(TAG, "Updating to default SSID in Preference, " + mSSID);
}
((ValidatedEditTextPreference) mPreference).setValidator(this);
updateSsidDisplay((EditTextPreference) mPreference);
diff --git a/tests/robotests/Android.mk b/tests/robotests/Android.mk
index 01218cb..50133d9 100644
--- a/tests/robotests/Android.mk
+++ b/tests/robotests/Android.mk
@@ -25,6 +25,7 @@
$(SETTINGS_AOSP_PATH)/res
LOCAL_STATIC_ANDROID_LIBRARIES := \
+ androidx-constraintlayout_constraintlayout \
androidx.slice_slice-builders \
androidx.slice_slice-core \
androidx.slice_slice-view \
@@ -42,6 +43,7 @@
ims-common
LOCAL_STATIC_JAVA_LIBRARIES := \
+ androidx-constraintlayout_constraintlayout-solver \
androidx.lifecycle_lifecycle-runtime \
androidx.lifecycle_lifecycle-extensions \
guava \
diff --git a/tests/robotests/res/layout-mcc999/fingerprint_enroll_find_sensor.xml b/tests/robotests/res/layout-mcc999/fingerprint_enroll_find_sensor.xml
index 83eb781..595cfb4 100644
--- a/tests/robotests/res/layout-mcc999/fingerprint_enroll_find_sensor.xml
+++ b/tests/robotests/res/layout-mcc999/fingerprint_enroll_find_sensor.xml
@@ -46,7 +46,7 @@
</FrameLayout>
<LinearLayout
- style="@style/SuwContentFrame"
+ style="@style/SudContentFrame"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
@@ -54,10 +54,10 @@
android:clipChildren="false">
<TextView
- style="@style/SuwDescription.Glif"
+ style="@style/SudDescription.Glif"
android:layout_width="match_parent"
android:layout_height="wrap_content"
- android:layout_marginTop="@dimen/suw_description_glif_margin_top"
+ android:layout_marginTop="@dimen/sud_description_glif_margin_top"
android:text="@string/security_settings_fingerprint_enroll_find_sensor_message"/>
<View
@@ -66,7 +66,7 @@
android:layout_weight="1"/>
<Button
- style="@style/SuwGlifButton.Secondary"
+ style="@style/SudGlifButton.Secondary"
android:id="@+id/next_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
diff --git a/tests/robotests/res/values-mcc999/config.xml b/tests/robotests/res/values-mcc999/config.xml
index 101a6b8..59028d3 100644
--- a/tests/robotests/res/values-mcc999/config.xml
+++ b/tests/robotests/res/values-mcc999/config.xml
@@ -88,4 +88,7 @@
<!-- Email address for the homepage contextual cards feedback -->
<string name="config_contextual_card_feedback_email" translatable="false">test@test.test</string>
+
+ <!-- Max allowed value for screen timeout, in milliseconds -->
+ <integer name="max_lock_after_timeout_ms">1700000</integer>
</resources>
diff --git a/tests/robotests/res/xml-mcc999/location_settings.xml b/tests/robotests/res/xml-mcc999/location_settings.xml
index 91e4c41..a25f36d 100644
--- a/tests/robotests/res/xml-mcc999/location_settings.xml
+++ b/tests/robotests/res/xml-mcc999/location_settings.xml
@@ -27,6 +27,7 @@
settings:controller="com.android.settings.slices.FakePreferenceController"
settings:keywords="a, b, c"
settings:platform_slice="true"
- settings:allowDynamicSummaryInSlice="true"/>
+ settings:allowDynamicSummaryInSlice="true"
+ settings:unavailableSliceSubtitle="subtitleOfUnavailableSlice"/>
</PreferenceScreen>
\ No newline at end of file
diff --git a/tests/robotests/res/xml-mcc999/night_display_settings.xml b/tests/robotests/res/xml-mcc999/night_display_settings.xml
new file mode 100644
index 0000000..c23a2cf
--- /dev/null
+++ b/tests/robotests/res/xml-mcc999/night_display_settings.xml
@@ -0,0 +1,43 @@
+<?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:settings="http://schemas.android.com/apk/res-auto"
+ android:key="fake_title_key"
+ android:title="screen_title">
+
+ <Preference
+ android:key="key1"
+ android:title="title"
+ android:icon="@drawable/ic_android"
+ android:summary="summary"
+ settings:controller="com.android.settings.slices.FakePreferenceController"
+ settings:keywords="keyword"
+ settings:platform_slice="true"/>
+
+ <Preference
+ android:key="key2"
+ android:title="title"
+ android:icon="@drawable/ic_android"
+ android:summary="summary"
+ settings:controller="com.android.settings.slices.FakePreferenceController"
+ settings:keywords="keyword"
+ settings:platform_slice="true"
+ settings:unavailableSliceSubtitle="subtitleOfUnavailable"/>
+
+</PreferenceScreen>
\ No newline at end of file
diff --git a/tests/robotests/src/com/android/settings/accessibility/VibrationPreferenceFragmentTest.java b/tests/robotests/src/com/android/settings/accessibility/VibrationPreferenceFragmentTest.java
index 68d5e36..9f83f72 100644
--- a/tests/robotests/src/com/android/settings/accessibility/VibrationPreferenceFragmentTest.java
+++ b/tests/robotests/src/com/android/settings/accessibility/VibrationPreferenceFragmentTest.java
@@ -161,6 +161,11 @@
}
@Override
+ protected String getVibrationEnabledSetting() {
+ return "";
+ }
+
+ @Override
protected int getDefaultVibrationIntensity() {
return Vibrator.VIBRATION_INTENSITY_MEDIUM;
}
diff --git a/tests/robotests/src/com/android/settings/accounts/AvatarViewMixinTest.java b/tests/robotests/src/com/android/settings/accounts/AvatarViewMixinTest.java
index 7b4fb6f..6a2348c 100644
--- a/tests/robotests/src/com/android/settings/accounts/AvatarViewMixinTest.java
+++ b/tests/robotests/src/com/android/settings/accounts/AvatarViewMixinTest.java
@@ -30,6 +30,7 @@
import android.content.ContentProvider;
import android.content.ContentResolver;
import android.content.Context;
+import android.content.Intent;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageInfo;
import android.content.pm.ProviderInfo;
@@ -167,12 +168,22 @@
assertThat(bundle.getString("account_name")).isEqualTo(DUMMY_ACCOUNT);
}
+ @Test
+ public void onClickAvatar_withEmptyUri_startActivityShouldNotBeExecuted() {
+ final SettingsHomepageActivity activity = spy((SettingsHomepageActivity) mController.get());
+ final AvatarViewMixin avatarViewMixin = new AvatarViewMixin(activity, mImageView);
+
+ mImageView.performClick();
+
+ verify(activity, never()).startActivity(any(Intent.class));
+ }
+
@Implements(value = AccountFeatureProviderImpl.class)
public static class ShadowAccountFeatureProviderImpl {
@Implementation
protected Account[] getAccounts(Context context) {
- return new Account[] {new Account(DUMMY_ACCOUNT, DUMMY_DOMAIN)};
+ return new Account[]{new Account(DUMMY_ACCOUNT, DUMMY_DOMAIN)};
}
}
}
diff --git a/tests/robotests/src/com/android/settings/applications/defaultapps/RolesPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/applications/defaultapps/RolesPreferenceControllerTest.java
index 5bf2b7e..92468a0 100644
--- a/tests/robotests/src/com/android/settings/applications/defaultapps/RolesPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/applications/defaultapps/RolesPreferenceControllerTest.java
@@ -19,13 +19,17 @@
import static com.google.common.truth.Truth.assertThat;
import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.anyInt;
+import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
+import android.app.role.RoleManager;
import android.content.Context;
import android.content.Intent;
+import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager;
import android.provider.Settings;
@@ -41,32 +45,59 @@
import org.mockito.MockitoAnnotations;
import org.robolectric.RobolectricTestRunner;
+import java.util.Collections;
+
@RunWith(RobolectricTestRunner.class)
public class RolesPreferenceControllerTest {
private static final String PREFERENCE_KEY = "roles";
private static final String DIFFERENT_PREFERENCE_KEY = "different";
+
private static final String PERMISSION_CONTROLLER_PACKAGE_NAME =
"com.android.permissioncontroller";
+ private static final String BROWSER_PACKAGE_NAME = "com.example.browser1";
+ private static final String DIALER_PACKAGE_NAME = "com.example.dialer1";
+ private static final String SMS_PACKAGE_NAME = "com.example.sms1";
+
@Mock
private Context mContext;
@Mock
private PackageManager mPackageManager;
+ @Mock
+ private RoleManager mRoleManager;
+ @Mock
+ private ApplicationInfo mBrowserApplicationInfo;
+ @Mock
+ private ApplicationInfo mDialerApplicationInfo;
+ @Mock
+ private ApplicationInfo mSmsApplicationInfo;
@Before
- public void setUp() {
+ public void setUp() throws PackageManager.NameNotFoundException {
MockitoAnnotations.initMocks(this);
+
when(mContext.getPackageManager()).thenReturn(mPackageManager);
+ when(mContext.getSystemService(RoleManager.class)).thenReturn(mRoleManager);
+
+ when(mBrowserApplicationInfo.loadLabel(mPackageManager)).thenReturn("Browser1");
+ when(mPackageManager.getApplicationInfo(eq(BROWSER_PACKAGE_NAME), anyInt())).thenReturn(
+ mBrowserApplicationInfo);
+ when(mDialerApplicationInfo.loadLabel(mPackageManager)).thenReturn("Phone1");
+ when(mPackageManager.getApplicationInfo(eq(DIALER_PACKAGE_NAME), anyInt())).thenReturn(
+ mDialerApplicationInfo);
+ when(mSmsApplicationInfo.loadLabel(mPackageManager)).thenReturn("Sms1");
+ when(mPackageManager.getApplicationInfo(eq(SMS_PACKAGE_NAME), anyInt())).thenReturn(
+ mSmsApplicationInfo);
}
@Test
public void getAvailabilityStatus_noPermissionController_shouldReturnUnsupportedOnDevice() {
when(mPackageManager.getPermissionControllerPackageName()).thenReturn(null);
- RolesPreferenceController controller = new RolesPreferenceController(mContext,
+ RolesPreferenceController preferenceController = new RolesPreferenceController(mContext,
PREFERENCE_KEY);
- assertThat(controller.getAvailabilityStatus())
+ assertThat(preferenceController.getAvailabilityStatus())
.isEqualTo(BasePreferenceController.UNSUPPORTED_ON_DEVICE);
}
@@ -74,10 +105,10 @@
public void getAvailabilityStatus_hasPermissionController_shouldReturnAvailableUnsearchable() {
when(mPackageManager.getPermissionControllerPackageName())
.thenReturn(PERMISSION_CONTROLLER_PACKAGE_NAME);
- RolesPreferenceController controller = new RolesPreferenceController(mContext,
+ RolesPreferenceController preferenceController = new RolesPreferenceController(mContext,
PREFERENCE_KEY);
- assertThat(controller.getAvailabilityStatus())
+ assertThat(preferenceController.getAvailabilityStatus())
.isEqualTo(BasePreferenceController.AVAILABLE_UNSEARCHABLE);
}
@@ -85,34 +116,34 @@
public void handlePreferenceTreeClick_differentKey_shouldReturnFalse() {
when(mPackageManager.getPermissionControllerPackageName())
.thenReturn(PERMISSION_CONTROLLER_PACKAGE_NAME);
- RolesPreferenceController controller = new RolesPreferenceController(mContext,
+ RolesPreferenceController preferenceController = new RolesPreferenceController(mContext,
PREFERENCE_KEY);
Preference preference = mock(Preference.class);
when(preference.getKey()).thenReturn(DIFFERENT_PREFERENCE_KEY);
- assertThat(controller.handlePreferenceTreeClick(preference)).isFalse();
+ assertThat(preferenceController.handlePreferenceTreeClick(preference)).isFalse();
}
@Test
public void handlePreferenceTreeClick_sameKey_shouldReturnTrue() {
when(mPackageManager.getPermissionControllerPackageName())
.thenReturn(PERMISSION_CONTROLLER_PACKAGE_NAME);
- RolesPreferenceController controller = new RolesPreferenceController(mContext,
+ RolesPreferenceController preferenceController = new RolesPreferenceController(mContext,
PREFERENCE_KEY);
Preference preference = mock(Preference.class);
when(preference.getKey()).thenReturn(PREFERENCE_KEY);
- assertThat(controller.handlePreferenceTreeClick(preference)).isTrue();
+ assertThat(preferenceController.handlePreferenceTreeClick(preference)).isTrue();
}
@Test
public void handlePreferenceTreeClick_noPermissionController_shouldNotStartActivity() {
when(mPackageManager.getPermissionControllerPackageName()).thenReturn(null);
- RolesPreferenceController controller = new RolesPreferenceController(mContext,
+ RolesPreferenceController preferenceController = new RolesPreferenceController(mContext,
PREFERENCE_KEY);
Preference preference = mock(Preference.class);
when(preference.getKey()).thenReturn(PREFERENCE_KEY);
- controller.handlePreferenceTreeClick(preference);
+ preferenceController.handlePreferenceTreeClick(preference);
verify(mContext, never()).startActivity(any(Intent.class));
}
@@ -121,11 +152,11 @@
public void handlePreferenceTreeClick_hasPermissionController_shouldStartActivityWithIntent() {
when(mPackageManager.getPermissionControllerPackageName())
.thenReturn(PERMISSION_CONTROLLER_PACKAGE_NAME);
- RolesPreferenceController controller = new RolesPreferenceController(mContext,
+ RolesPreferenceController preferenceController = new RolesPreferenceController(mContext,
PREFERENCE_KEY);
Preference preference = mock(Preference.class);
when(preference.getKey()).thenReturn(PREFERENCE_KEY);
- controller.handlePreferenceTreeClick(preference);
+ preferenceController.handlePreferenceTreeClick(preference);
ArgumentCaptor<Intent> intent = ArgumentCaptor.forClass(Intent.class);
verify(mContext).startActivity(intent.capture());
@@ -133,4 +164,112 @@
.isEqualTo(Settings.ACTION_MANAGE_DEFAULT_APPS_SETTINGS);
assertThat(intent.getValue().getPackage()).isEqualTo(PERMISSION_CONTROLLER_PACKAGE_NAME);
}
+
+ @Test
+ public void getSummary_allAvailable_shouldReturnAll() {
+ when(mRoleManager.getRoleHolders(RoleManager.ROLE_BROWSER)).thenReturn(
+ Collections.singletonList(BROWSER_PACKAGE_NAME));
+ when(mRoleManager.getRoleHolders(RoleManager.ROLE_DIALER)).thenReturn(
+ Collections.singletonList(DIALER_PACKAGE_NAME));
+ when(mRoleManager.getRoleHolders(RoleManager.ROLE_SMS)).thenReturn(
+ Collections.singletonList(SMS_PACKAGE_NAME));
+ RolesPreferenceController preferenceController = new RolesPreferenceController(mContext,
+ PREFERENCE_KEY);
+
+ assertThat(preferenceController.getSummary()).isEqualTo("Browser1, Phone1, and Sms1");
+ }
+
+ @Test
+ public void getSummary_browserAndDialerAvailable_shouldReturnBrowserAndDialer() {
+ when(mRoleManager.getRoleHolders(RoleManager.ROLE_BROWSER)).thenReturn(
+ Collections.singletonList(BROWSER_PACKAGE_NAME));
+ when(mRoleManager.getRoleHolders(RoleManager.ROLE_DIALER)).thenReturn(
+ Collections.singletonList(DIALER_PACKAGE_NAME));
+ when(mRoleManager.getRoleHolders(RoleManager.ROLE_SMS)).thenReturn(Collections.emptyList());
+ RolesPreferenceController preferenceController = new RolesPreferenceController(mContext,
+ PREFERENCE_KEY);
+
+ assertThat(preferenceController.getSummary()).isEqualTo("Browser1 and Phone1");
+ }
+
+ @Test
+ public void getSummary_browserAndSmsAvailable_shouldReturnBrowserAndSms() {
+ when(mRoleManager.getRoleHolders(RoleManager.ROLE_BROWSER)).thenReturn(
+ Collections.singletonList(BROWSER_PACKAGE_NAME));
+ when(mRoleManager.getRoleHolders(RoleManager.ROLE_DIALER)).thenReturn(
+ Collections.emptyList());
+ when(mRoleManager.getRoleHolders(RoleManager.ROLE_SMS)).thenReturn(
+ Collections.singletonList(SMS_PACKAGE_NAME));
+ RolesPreferenceController preferenceController = new RolesPreferenceController(mContext,
+ PREFERENCE_KEY);
+
+ assertThat(preferenceController.getSummary()).isEqualTo("Browser1 and Sms1");
+ }
+
+ @Test
+ public void getSummary_dialerAndSmsAvailable_shouldReturnDialerAndSms() {
+ when(mRoleManager.getRoleHolders(RoleManager.ROLE_BROWSER)).thenReturn(
+ Collections.emptyList());
+ when(mRoleManager.getRoleHolders(RoleManager.ROLE_DIALER)).thenReturn(
+ Collections.singletonList(DIALER_PACKAGE_NAME));
+ when(mRoleManager.getRoleHolders(RoleManager.ROLE_SMS)).thenReturn(
+ Collections.singletonList(SMS_PACKAGE_NAME));
+ RolesPreferenceController preferenceController = new RolesPreferenceController(mContext,
+ PREFERENCE_KEY);
+
+ assertThat(preferenceController.getSummary()).isEqualTo("Phone1 and Sms1");
+ }
+
+ @Test
+ public void getSummary_browserAvailable_shouldReturnBrowser() {
+ when(mRoleManager.getRoleHolders(RoleManager.ROLE_BROWSER)).thenReturn(
+ Collections.singletonList(BROWSER_PACKAGE_NAME));
+ when(mRoleManager.getRoleHolders(RoleManager.ROLE_DIALER)).thenReturn(
+ Collections.emptyList());
+ when(mRoleManager.getRoleHolders(RoleManager.ROLE_SMS)).thenReturn(Collections.emptyList());
+ RolesPreferenceController preferenceController = new RolesPreferenceController(mContext,
+ PREFERENCE_KEY);
+
+ assertThat(preferenceController.getSummary()).isEqualTo("Browser1");
+ }
+
+ @Test
+ public void getSummary_dialerAvailable_shouldReturnDialer() {
+ when(mRoleManager.getRoleHolders(RoleManager.ROLE_BROWSER)).thenReturn(
+ Collections.emptyList());
+ when(mRoleManager.getRoleHolders(RoleManager.ROLE_DIALER)).thenReturn(
+ Collections.singletonList(DIALER_PACKAGE_NAME));
+ when(mRoleManager.getRoleHolders(RoleManager.ROLE_SMS)).thenReturn(Collections.emptyList());
+ RolesPreferenceController preferenceController = new RolesPreferenceController(mContext,
+ PREFERENCE_KEY);
+
+ assertThat(preferenceController.getSummary()).isEqualTo("Phone1");
+ }
+
+ @Test
+ public void getSummary_smsAvailable_shouldReturnSms() {
+ when(mRoleManager.getRoleHolders(RoleManager.ROLE_BROWSER)).thenReturn(
+ Collections.emptyList());
+ when(mRoleManager.getRoleHolders(RoleManager.ROLE_DIALER)).thenReturn(
+ Collections.emptyList());
+ when(mRoleManager.getRoleHolders(RoleManager.ROLE_SMS)).thenReturn(
+ Collections.singletonList(SMS_PACKAGE_NAME));
+ RolesPreferenceController preferenceController = new RolesPreferenceController(mContext,
+ PREFERENCE_KEY);
+
+ assertThat(preferenceController.getSummary()).isEqualTo("Sms1");
+ }
+
+ @Test
+ public void getSummary_noneAvailable_shouldReturnNull() {
+ when(mRoleManager.getRoleHolders(RoleManager.ROLE_BROWSER)).thenReturn(
+ Collections.emptyList());
+ when(mRoleManager.getRoleHolders(RoleManager.ROLE_DIALER)).thenReturn(
+ Collections.emptyList());
+ when(mRoleManager.getRoleHolders(RoleManager.ROLE_SMS)).thenReturn(Collections.emptyList());
+ RolesPreferenceController preferenceController = new RolesPreferenceController(mContext,
+ PREFERENCE_KEY);
+
+ assertThat(preferenceController.getSummary()).isNull();
+ }
}
diff --git a/tests/robotests/src/com/android/settings/core/PreferenceXmlParserUtilsTest.java b/tests/robotests/src/com/android/settings/core/PreferenceXmlParserUtilsTest.java
index 9627a48..b8051a1 100644
--- a/tests/robotests/src/com/android/settings/core/PreferenceXmlParserUtilsTest.java
+++ b/tests/robotests/src/com/android/settings/core/PreferenceXmlParserUtilsTest.java
@@ -16,12 +16,12 @@
package com.android.settings.core;
-import static com.android.settings.core.PreferenceXmlParserUtils
- .METADATA_ALLOW_DYNAMIC_SUMMARY_IN_SLICE;
+import static com.android.settings.core.PreferenceXmlParserUtils.METADATA_ALLOW_DYNAMIC_SUMMARY_IN_SLICE;
import static com.android.settings.core.PreferenceXmlParserUtils.METADATA_APPEND;
import static com.android.settings.core.PreferenceXmlParserUtils.METADATA_KEY;
import static com.android.settings.core.PreferenceXmlParserUtils.METADATA_KEYWORDS;
import static com.android.settings.core.PreferenceXmlParserUtils.METADATA_SEARCHABLE;
+import static com.android.settings.core.PreferenceXmlParserUtils.METADATA_UNAVAILABLE_SLICE_SUBTITLE;
import static com.google.common.truth.Truth.assertThat;
@@ -35,7 +35,6 @@
import com.android.settings.R;
import com.android.settings.core.PreferenceXmlParserUtils.MetadataFlag;
-import java.util.Objects;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -47,6 +46,7 @@
import java.io.IOException;
import java.util.List;
+import java.util.Objects;
/**
* These tests use a series of preferences that have specific attributes which are sometimes
@@ -320,7 +320,7 @@
@Test
@Config(qualifiers = "mcc999")
public void extractMetadata_requestAppendProperty_shouldDefaultToFalse()
- throws Exception {
+ throws Exception {
final List<Bundle> metadata = PreferenceXmlParserUtils.extractMetadata(mContext,
R.xml.display_settings,
MetadataFlag.FLAG_INCLUDE_PREF_SCREEN | MetadataFlag.FLAG_NEED_PREF_APPEND);
@@ -333,7 +333,7 @@
@Test
@Config(qualifiers = "mcc999")
public void extractMetadata_requestAppendProperty_shouldReturnCorrectValue()
- throws Exception {
+ throws Exception {
final List<Bundle> metadata = PreferenceXmlParserUtils.extractMetadata(mContext,
R.xml.battery_saver_schedule_settings,
MetadataFlag.FLAG_INCLUDE_PREF_SCREEN | MetadataFlag.FLAG_NEED_PREF_APPEND);
@@ -343,6 +343,46 @@
}
}
+ @Test
+ @Config(qualifiers = "mcc999")
+ public void extractMetadata_requestUnavailableSliceSubtitle_shouldDefaultNull()
+ throws Exception {
+ final List<Bundle> metadata = PreferenceXmlParserUtils.extractMetadata(mContext,
+ R.xml.night_display_settings,
+ MetadataFlag.FLAG_NEED_KEY | MetadataFlag.FLAG_UNAVAILABLE_SLICE_SUBTITLE);
+
+ boolean bundleWithKey1Found = false;
+ for (Bundle bundle : metadata) {
+ if (bundle.getString(METADATA_KEY).equals("key1")) {
+ assertThat(bundle.getString(METADATA_UNAVAILABLE_SLICE_SUBTITLE)).isNull();
+ bundleWithKey1Found = true;
+ break;
+ }
+ }
+ assertThat(bundleWithKey1Found).isTrue();
+ }
+
+ @Test
+ @Config(qualifiers = "mcc999")
+ public void extractMetadata_requestUnavailableSliceSubtitle_shouldReturnAttributeValue()
+ throws Exception {
+ final String expectedSubtitle = "subtitleOfUnavailable";
+ final List<Bundle> metadata = PreferenceXmlParserUtils.extractMetadata(mContext,
+ R.xml.night_display_settings,
+ MetadataFlag.FLAG_NEED_KEY | MetadataFlag.FLAG_UNAVAILABLE_SLICE_SUBTITLE);
+
+ boolean bundleWithKey2Found = false;
+ for (Bundle bundle : metadata) {
+ if (bundle.getString(METADATA_KEY).equals("key2")) {
+ assertThat(bundle.getString(METADATA_UNAVAILABLE_SLICE_SUBTITLE)).isEqualTo(
+ expectedSubtitle);
+ bundleWithKey2Found = true;
+ break;
+ }
+ }
+ assertThat(bundleWithKey2Found).isTrue();
+ }
+
/**
* @param resId the ID for the XML preference
* @return an XML resource parser that points to the start tag
diff --git a/tests/robotests/src/com/android/settings/development/CbrsDataSwitchPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/development/CbrsDataSwitchPreferenceControllerTest.java
deleted file mode 100644
index d955a6e..0000000
--- a/tests/robotests/src/com/android/settings/development/CbrsDataSwitchPreferenceControllerTest.java
+++ /dev/null
@@ -1,87 +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.development;
-
-import static org.mockito.Mockito.when;
-import static com.google.common.truth.Truth.assertThat;
-
-import android.content.Context;
-import android.telephony.TelephonyManager;
-
-import androidx.preference.PreferenceScreen;
-import androidx.preference.SwitchPreference;
-
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.mockito.Mock;
-import org.mockito.MockitoAnnotations;
-import org.robolectric.RobolectricTestRunner;
-import org.robolectric.RuntimeEnvironment;
-
-@RunWith(RobolectricTestRunner.class)
-public final class CbrsDataSwitchPreferenceControllerTest {
-
- @Mock
- private PreferenceScreen mPreferenceScreen;
- private Context mContext;
- private TelephonyManager mTelephonyManager;
- private SwitchPreference mPreference;
- private CbrsDataSwitchPreferenceController mController;
-
- @Before
- public void setUp() {
- MockitoAnnotations.initMocks(this);
- mContext = RuntimeEnvironment.application;
- mController = new CbrsDataSwitchPreferenceController(mContext);
- mPreference = new SwitchPreference(mContext);
- when(mPreferenceScreen.findPreference(mController.getPreferenceKey()))
- .thenReturn(mPreference);
- mTelephonyManager = mContext.getSystemService(TelephonyManager.class);
- mController.displayPreference(mPreferenceScreen);
- }
-
- @Test
- public void onPreferenceChanged_settingEnabled_shouldEnableANAS() {
- mController.onPreferenceChange(mPreference, true);
-
- assertThat(mTelephonyManager.isAlternativeNetworkEnabled()).isTrue();
- }
-
- @Test
- public void onPreferenceChanged_settingDisabled_shouldDisableANAS() {
- mController.onPreferenceChange(mPreference, false);
-
- assertThat(mTelephonyManager.isAlternativeNetworkEnabled()).isFalse();
- }
-
- @Test
- public void updateState_settingEnabled_shouldEnablePreference() {
- mTelephonyManager.setAlternativeNetworkState(true);
- mController.updateState(mPreference);
-
- assertThat(mPreference.isChecked()).isTrue();
- }
-
- @Test
- public void updateState_settingDisabled_shouldDisablePreference() {
- mTelephonyManager.setAlternativeNetworkState(false);
- mController.updateState(mPreference);
-
- assertThat(mPreference.isChecked()).isFalse();
- }
-}
diff --git a/tests/robotests/src/com/android/settings/development/UpdatedGfxDriverDevOptInPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/development/UpdatedGfxDriverDevOptInPreferenceControllerTest.java
deleted file mode 100644
index e92f1a5..0000000
--- a/tests/robotests/src/com/android/settings/development/UpdatedGfxDriverDevOptInPreferenceControllerTest.java
+++ /dev/null
@@ -1,129 +0,0 @@
-/*
- * Copyright 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.development;
-
-import static com.android.settings.development.DevelopmentOptionsActivityRequestCodes.REQUEST_CODE_UPDATED_GFX_DRIVER_DEV_OPT_IN_APP;
-import static com.google.common.truth.Truth.assertThat;
-import static org.mockito.Mockito.doReturn;
-import static org.mockito.Mockito.spy;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.when;
-
-import android.app.Activity;
-import android.content.ContentResolver;
-import android.content.Context;
-import android.content.Intent;
-import android.content.pm.PackageManager;
-import android.provider.Settings;
-
-import androidx.preference.Preference;
-import androidx.preference.PreferenceScreen;
-
-import com.android.settings.R;
-
-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 UpdatedGfxDriverDevOptInPreferenceControllerTest {
-
- @Mock
- private PreferenceScreen mPreferenceScreen;
- @Mock
- private DevelopmentSettingsDashboardFragment mFragment;
-
- private Context mContext;
- private Preference mPreference;
- private UpdatedGfxDriverDevOptInPreferenceController mController;
-
- @Before
- public void setup() {
- MockitoAnnotations.initMocks(this);
- mContext = RuntimeEnvironment.application;
- mController = spy(new UpdatedGfxDriverDevOptInPreferenceController(mContext, mFragment));
- mPreference = new Preference(mContext);
- mPreference.setKey(mController.getPreferenceKey());
-
- when(mPreferenceScreen.findPreference(mController.getPreferenceKey()))
- .thenReturn(mPreference);
- mController.displayPreference(mPreferenceScreen);
- }
-
- @Test
- public void handlePreferenceTreeClick_preferenceClicked_launchActivity() {
- final Intent activityStartIntent = new Intent(mContext, AppPicker.class);
- doReturn(activityStartIntent).when(mController).getActivityStartIntent();
- mController.handlePreferenceTreeClick(mPreference);
-
- verify(mFragment).startActivityForResult(activityStartIntent,
- REQUEST_CODE_UPDATED_GFX_DRIVER_DEV_OPT_IN_APP);
- }
-
- @Test
- public void updateState_foobarAppSelected_shouldUpdateSummaryWithUpdatedDriverDevOptInAppLabel() {
- final String selectedApp = "foobar";
- final ContentResolver contentResolver = mContext.getContentResolver();
- Settings.Global.putString(contentResolver,
- Settings.Global.UPDATED_GFX_DRIVER_DEV_OPT_IN_APP, selectedApp);
- mController.updateState(mPreference);
-
- assertThat(mPreference.getSummary()).isEqualTo(mContext.getString(R.string.updated_gfx_driver_dev_opt_in_app_set, selectedApp));
- }
-
- @Test
- public void updateState_noAppSelected_shouldUpdateSummaryWithNoAppSelected() {
- final String selectedApp = null;
- final ContentResolver contentResolver = mContext.getContentResolver();
- Settings.Global.putString(contentResolver,
- Settings.Global.UPDATED_GFX_DRIVER_DEV_OPT_IN_APP, selectedApp);
- mController.updateState(mPreference);
-
- assertThat(mPreference.getSummary()).isEqualTo(mContext.getString(R.string.updated_gfx_driver_dev_opt_in_app_not_set));
- }
-
- @Test
- public void onActivityResult_foobarAppSelected_shouldUpdateSummaryWithUpdatedDriverDevOptInLabel() {
- Intent activityResultIntent = new Intent(mContext, AppPicker.class);
- final String appLabel = "foobar";
- activityResultIntent.setAction(appLabel);
- final boolean result = mController
- .onActivityResult(REQUEST_CODE_UPDATED_GFX_DRIVER_DEV_OPT_IN_APP, Activity.RESULT_OK,
- activityResultIntent);
-
- assertThat(result).isTrue();
- assertThat(mPreference.getSummary()).isEqualTo(mContext.getString(R.string.updated_gfx_driver_dev_opt_in_app_set, appLabel));
- }
-
- @Test
- public void onActivityResult_badRequestCode_shouldReturnFalse() {
- assertThat(mController.onActivityResult(
- -1 /* requestCode */, -1 /* resultCode */, null /* intent */)).isFalse();
- }
-
- @Test
- public void onDeveloperOptionsSwitchDisabled_shouldDisablePreference() {
- mController.onDeveloperOptionsSwitchDisabled();
-
- assertThat(mPreference.isEnabled()).isFalse();
- assertThat(mPreference.getSummary()).isEqualTo(mContext.getString(R.string.updated_gfx_driver_dev_opt_in_app_not_set));
- }
-}
diff --git a/tests/robotests/src/com/android/settings/development/gup/GupDashboardTest.java b/tests/robotests/src/com/android/settings/development/gup/GupDashboardTest.java
new file mode 100644
index 0000000..17278ef
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/development/gup/GupDashboardTest.java
@@ -0,0 +1,54 @@
+/*
+ * Copyright 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.development.gup;
+
+import static com.google.common.truth.Truth.assertThat;
+
+import com.android.internal.logging.nano.MetricsProto;
+import com.android.settings.R;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.robolectric.RobolectricTestRunner;
+
+@RunWith(RobolectricTestRunner.class)
+public class GupDashboardTest {
+ private GupDashboard mDashboard;
+
+ @Before
+ public void setUp() {
+ mDashboard = new GupDashboard();
+ }
+
+ @Test
+ public void getHelpResource_shouldReturn0() {
+ assertThat(mDashboard.getHelpResource()).isEqualTo(0);
+ }
+
+ @Test
+ public void getMetricesCategory_shouldReturnGupDashboard() {
+ assertThat(mDashboard.getMetricsCategory())
+ .isEqualTo(MetricsProto.MetricsEvent.SETTINGS_GUP_DASHBOARD);
+ }
+
+ @Test
+ public void getPreferenceScreen_shouldReturnGupSettings() {
+ assertThat(mDashboard.getPreferenceScreenResId())
+ .isEqualTo(R.xml.gup_settings);
+ }
+}
diff --git a/tests/robotests/src/com/android/settings/development/gup/GupPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/development/gup/GupPreferenceControllerTest.java
new file mode 100644
index 0000000..d5e7a85
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/development/gup/GupPreferenceControllerTest.java
@@ -0,0 +1,237 @@
+/*
+ * Copyright 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.development.gup;
+
+import static com.android.settings.core.BasePreferenceController.AVAILABLE;
+import static com.android.settings.core.BasePreferenceController.DISABLED_DEPENDENT_SETTING;
+import static com.android.settings.testutils.ApplicationTestUtils.buildInfo;
+import static com.google.common.truth.Truth.assertThat;
+
+import static org.mockito.Mockito.spy;
+import static org.mockito.Mockito.when;
+
+import android.content.ContentResolver;
+import android.content.Context;
+import android.content.pm.ApplicationInfo;
+import android.content.pm.PackageManager;
+import android.provider.Settings;
+
+import androidx.preference.ListPreference;
+import androidx.preference.PreferenceCategory;
+import androidx.preference.PreferenceGroup;
+import androidx.preference.PreferenceManager;
+import androidx.preference.PreferenceScreen;
+
+import com.android.settings.R;
+
+import java.util.Arrays;
+
+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 GupPreferenceControllerTest {
+ private static final int DEFAULT = 0;
+ private static final int GUP = 1;
+ private static final int SYSTEM = 2;
+ private static final String TEST_APP_NAME = "testApp";
+ private static final String TEST_PKG_NAME = "testPkg";
+
+ // Pre-installed Apps in the Mock PackageManager
+ private static final String APP_1 = "app1";
+ private static final String APP_2 = "app2";
+ private static final String APP_3 = "app3";
+
+ @Mock
+ private PackageManager mPackageManager;
+ @Mock
+ private PreferenceScreen mScreen;
+
+ private Context mContext;
+ private PreferenceGroup mGroup;
+ private PreferenceManager mPreferenceManager;
+ private ContentResolver mResolver;
+ private GupPreferenceController mController;
+ private CharSequence[] mValueList;
+ private String mDialogTitle;
+
+ @Before
+ public void setUp() {
+ MockitoAnnotations.initMocks(this);
+ mContext = spy(RuntimeEnvironment.application);
+ mResolver = mContext.getContentResolver();
+ mValueList = mContext.getResources().getStringArray(R.array.gup_app_preference_values);
+ mDialogTitle = mContext.getResources().getString(R.string.gup_app_preference_title);
+ }
+
+ @Test
+ public void getAvailability_developmentSettingsEnabled_available() {
+ loadDefaultConfig();
+ Settings.Global.putInt(mResolver, Settings.Global.DEVELOPMENT_SETTINGS_ENABLED, 1);
+
+ assertThat(mController.getAvailabilityStatus()).isEqualTo(AVAILABLE);
+ }
+
+ @Test
+ public void getAvailability_developmentSettingsDisabled_disabledDependentSetting() {
+ loadDefaultConfig();
+ Settings.Global.putInt(mResolver, Settings.Global.DEVELOPMENT_SETTINGS_ENABLED, 0);
+
+ assertThat(mController.getAvailabilityStatus()).isEqualTo(DISABLED_DEPENDENT_SETTING);
+ }
+
+ @Test
+ public void displayPreference_shouldAddTwoPreferencesAndSortAscendingly() {
+ mockPackageManager();
+ loadDefaultConfig();
+
+ // Only non-system app has preference
+ assertThat(mGroup.getPreferenceCount()).isEqualTo(2);
+ assertThat(mGroup.getPreference(0).getKey()).isEqualTo(APP_1);
+ assertThat(mGroup.getPreference(1).getKey()).isEqualTo(APP_3);
+ }
+
+ @Test
+ public void createPreference_configDefault_shouldSetDefaultAttributes() {
+ loadDefaultConfig();
+ final ListPreference preference =
+ mController.createListPreference(TEST_PKG_NAME, TEST_APP_NAME);
+
+ assertThat(preference.getKey()).isEqualTo(TEST_PKG_NAME);
+ assertThat(preference.getTitle()).isEqualTo(TEST_APP_NAME);
+ assertThat(preference.getDialogTitle()).isEqualTo(mDialogTitle);
+ assertThat(preference.getEntries()).isEqualTo(mValueList);
+ assertThat(preference.getEntryValues()).isEqualTo(mValueList);
+ assertThat(preference.getEntry()).isEqualTo(mValueList[DEFAULT]);
+ assertThat(preference.getValue()).isEqualTo(mValueList[DEFAULT]);
+ assertThat(preference.getSummary()).isEqualTo(mValueList[DEFAULT]);
+ }
+
+ @Test
+ public void createPreference_configGup_shouldSetGupAttributes() {
+ loadConfig(TEST_PKG_NAME, "");
+ final ListPreference preference =
+ mController.createListPreference(TEST_PKG_NAME, TEST_APP_NAME);
+
+ assertThat(preference.getKey()).isEqualTo(TEST_PKG_NAME);
+ assertThat(preference.getTitle()).isEqualTo(TEST_APP_NAME);
+ assertThat(preference.getDialogTitle()).isEqualTo(mDialogTitle);
+ assertThat(preference.getEntries()).isEqualTo(mValueList);
+ assertThat(preference.getEntryValues()).isEqualTo(mValueList);
+ assertThat(preference.getEntry()).isEqualTo(mValueList[GUP]);
+ assertThat(preference.getValue()).isEqualTo(mValueList[GUP]);
+ assertThat(preference.getSummary()).isEqualTo(mValueList[GUP]);
+ }
+
+ @Test
+ public void createPreference_configSystem_shouldSetSystemAttributes() {
+ loadConfig("", TEST_PKG_NAME);
+ final ListPreference preference =
+ mController.createListPreference(TEST_PKG_NAME, TEST_APP_NAME);
+
+ assertThat(preference.getKey()).isEqualTo(TEST_PKG_NAME);
+ assertThat(preference.getTitle()).isEqualTo(TEST_APP_NAME);
+ assertThat(preference.getDialogTitle()).isEqualTo(mDialogTitle);
+ assertThat(preference.getEntries()).isEqualTo(mValueList);
+ assertThat(preference.getEntryValues()).isEqualTo(mValueList);
+ assertThat(preference.getEntry()).isEqualTo(mValueList[SYSTEM]);
+ assertThat(preference.getValue()).isEqualTo(mValueList[SYSTEM]);
+ assertThat(preference.getSummary()).isEqualTo(mValueList[SYSTEM]);
+ }
+
+ @Test
+ public void onPreferenceChange_selectDefault_shouldUpdateAttributesAndSettingsGlobal() {
+ loadDefaultConfig();
+ final ListPreference preference =
+ mController.createListPreference(TEST_PKG_NAME, TEST_APP_NAME);
+ mController.onPreferenceChange(preference, mValueList[DEFAULT]);
+
+ assertThat(preference.getEntry()).isEqualTo(mValueList[DEFAULT]);
+ assertThat(preference.getValue()).isEqualTo(mValueList[DEFAULT]);
+ assertThat(preference.getSummary()).isEqualTo(mValueList[DEFAULT]);
+ assertThat(Settings.Global.getString(mResolver, Settings.Global.GUP_DEV_OPT_IN_APPS))
+ .isEqualTo("");
+ assertThat(Settings.Global.getString(mResolver, Settings.Global.GUP_DEV_OPT_OUT_APPS))
+ .isEqualTo("");
+ }
+
+ @Test
+ public void onPreferenceChange_selectGup_shouldUpdateAttributesAndSettingsGlobal() {
+ loadDefaultConfig();
+ final ListPreference preference =
+ mController.createListPreference(TEST_PKG_NAME, TEST_APP_NAME);
+ mController.onPreferenceChange(preference, mValueList[GUP]);
+
+ assertThat(preference.getEntry()).isEqualTo(mValueList[GUP]);
+ assertThat(preference.getValue()).isEqualTo(mValueList[GUP]);
+ assertThat(preference.getSummary()).isEqualTo(mValueList[GUP]);
+ assertThat(Settings.Global.getString(mResolver, Settings.Global.GUP_DEV_OPT_IN_APPS))
+ .isEqualTo(TEST_PKG_NAME);
+ assertThat(Settings.Global.getString(mResolver, Settings.Global.GUP_DEV_OPT_OUT_APPS))
+ .isEqualTo("");
+ }
+
+ @Test
+ public void onPreferenceChange_selectSystem_shouldUpdateAttributesAndSettingsGlobal() {
+ loadDefaultConfig();
+ final ListPreference preference =
+ mController.createListPreference(TEST_PKG_NAME, TEST_APP_NAME);
+ mController.onPreferenceChange(preference, mValueList[SYSTEM]);
+
+ assertThat(preference.getEntry()).isEqualTo(mValueList[SYSTEM]);
+ assertThat(preference.getValue()).isEqualTo(mValueList[SYSTEM]);
+ assertThat(preference.getSummary()).isEqualTo(mValueList[SYSTEM]);
+ assertThat(Settings.Global.getString(mResolver, Settings.Global.GUP_DEV_OPT_IN_APPS))
+ .isEqualTo("");
+ assertThat(Settings.Global.getString(mResolver, Settings.Global.GUP_DEV_OPT_OUT_APPS))
+ .isEqualTo(TEST_PKG_NAME);
+ }
+
+ private void mockPackageManager() {
+ final int uid = mContext.getUserId();
+ final ApplicationInfo app1 = buildInfo(uid, APP_1, 0 /* flags */, 0 /* targetSdkVersion */);
+ final ApplicationInfo app2 =
+ buildInfo(uid, APP_2, ApplicationInfo.FLAG_SYSTEM, 0 /* targetSdkVersion */);
+ final ApplicationInfo app3 = buildInfo(uid, APP_3, 0 /* flags */, 0 /* targetSdkVersion */);
+
+ when(mPackageManager.getInstalledApplications(0 /* flags */))
+ .thenReturn(Arrays.asList(app3, app2, app1));
+ when(mPackageManager.getApplicationLabel(app1)).thenReturn(APP_1);
+ when(mPackageManager.getApplicationLabel(app2)).thenReturn(APP_2);
+ when(mPackageManager.getApplicationLabel(app3)).thenReturn(APP_3);
+ when(mContext.getPackageManager()).thenReturn(mPackageManager);
+ }
+
+ private void loadDefaultConfig() { loadConfig("", ""); }
+
+ private void loadConfig(String optIn, String optOut) {
+ Settings.Global.putString(mResolver, Settings.Global.GUP_DEV_OPT_IN_APPS, optIn);
+ Settings.Global.putString(mResolver, Settings.Global.GUP_DEV_OPT_OUT_APPS, optOut);
+
+ mController = new GupPreferenceController(mContext, "testKey");
+ mGroup = spy(new PreferenceCategory(mContext));
+ final PreferenceManager preferenceManager = new PreferenceManager(mContext);
+ when(mGroup.getPreferenceManager()).thenReturn(preferenceManager);
+ when(mScreen.findPreference(mController.getPreferenceKey())).thenReturn(mGroup);
+ mController.displayPreference(mScreen);
+ }
+}
diff --git a/tests/robotests/src/com/android/settings/deviceinfo/imei/ImeiInfoPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/deviceinfo/imei/ImeiInfoPreferenceControllerTest.java
index e56baa1..69bc494 100644
--- a/tests/robotests/src/com/android/settings/deviceinfo/imei/ImeiInfoPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/deviceinfo/imei/ImeiInfoPreferenceControllerTest.java
@@ -16,9 +16,14 @@
package com.android.settings.deviceinfo.imei;
+import static android.content.Context.CLIPBOARD_SERVICE;
import static android.telephony.TelephonyManager.PHONE_TYPE_CDMA;
import static android.telephony.TelephonyManager.PHONE_TYPE_GSM;
+import static com.android.settings.core.BasePreferenceController.AVAILABLE;
+
+import static com.google.common.truth.Truth.assertThat;
+
import static org.mockito.ArgumentMatchers.anyInt;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.mock;
@@ -26,6 +31,7 @@
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
+import android.content.ClipboardManager;
import android.content.Context;
import android.os.UserManager;
import android.telephony.TelephonyManager;
@@ -71,8 +77,9 @@
MockitoAnnotations.initMocks(this);
mContext = spy(RuntimeEnvironment.application);
doReturn(mUserManager).when(mContext).getSystemService(UserManager.class);
- mController = spy(new ImeiInfoPreferenceController(mContext, mFragment));
- doReturn(true).when(mController).isAvailable();
+ mController = spy(new ImeiInfoPreferenceController(mContext, "imei_info"));
+ mController.setHost(mFragment);
+ doReturn(AVAILABLE).when(mController).getAvailabilityStatus();
when(mScreen.getContext()).thenReturn(mContext);
doReturn(mSecondSimPreference).when(mController).createNewPreference(mContext);
ReflectionHelpers.setField(mController, "mTelephonyManager", mTelephonyManager);
@@ -156,7 +163,7 @@
@Test
public void handlePreferenceTreeClick_shouldStartDialogFragment() {
when(mFragment.getChildFragmentManager())
- .thenReturn(mock(FragmentManager.class, Answers.RETURNS_DEEP_STUBS));
+ .thenReturn(mock(FragmentManager.class, Answers.RETURNS_DEEP_STUBS));
when(mPreference.getTitle()).thenReturn("SomeTitle");
mController.displayPreference(mScreen);
@@ -164,4 +171,19 @@
verify(mFragment).getChildFragmentManager();
}
+
+ @Test
+ public void copy_shouldCopyImeiToClipboard() {
+ ReflectionHelpers.setField(mController, "mIsMultiSim", false);
+ final String meid = "125132215123";
+ when(mTelephonyManager.getPhoneType()).thenReturn(PHONE_TYPE_CDMA);
+ when(mTelephonyManager.getMeid()).thenReturn(meid);
+
+ mController.copy();
+
+ final ClipboardManager clipboard = (ClipboardManager) mContext.getSystemService(
+ CLIPBOARD_SERVICE);
+ final CharSequence data = clipboard.getPrimaryClip().getItemAt(0).getText();
+ assertThat(data.toString()).isEqualTo(meid);
+ }
}
diff --git a/tests/robotests/src/com/android/settings/display/TimeoutListPreferenceTest.java b/tests/robotests/src/com/android/settings/display/TimeoutListPreferenceTest.java
index 55fcdac..7b67f0f 100644
--- a/tests/robotests/src/com/android/settings/display/TimeoutListPreferenceTest.java
+++ b/tests/robotests/src/com/android/settings/display/TimeoutListPreferenceTest.java
@@ -17,11 +17,11 @@
import static com.google.common.truth.Truth.assertThat;
-import static org.mockito.Mockito.mock;
import static org.robolectric.RuntimeEnvironment.application;
import android.util.AttributeSet;
+import com.android.settings.R;
import com.android.settings.testutils.shadow.ShadowUserManager;
import com.android.settingslib.RestrictedLockUtils;
@@ -69,4 +69,23 @@
// should set to largest allowed value, which is 5 minute
assertThat(mPreference.getValue()).isEqualTo("300000");
}
+
+ @Test
+ @Config(qualifiers = "mcc999")
+ public void newInstance_hasLowTimeoutConfig_shouldRemoveLongTimeouts() {
+ final AttributeSet attributeSet = Robolectric.buildAttributeSet().build();
+ final TimeoutListPreference pref = new TimeoutListPreference(application, attributeSet);
+ final long maxTimeout = application.getResources().getInteger(
+ R.integer.max_lock_after_timeout_ms);
+ pref.setEntries(R.array.screen_timeout_entries);
+ pref.setEntryValues(R.array.screen_timeout_values);
+
+ pref.updateInitialValues();
+
+ final CharSequence[] values = pref.getEntryValues();
+ for (CharSequence value : values) {
+ long timeout = Long.parseLong(value.toString());
+ assertThat(timeout).isAtMost(maxTimeout);
+ }
+ }
}
diff --git a/tests/robotests/src/com/android/settings/fuelgauge/BatteryHeaderPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/fuelgauge/BatteryHeaderPreferenceControllerTest.java
index b22821b..5be7274 100644
--- a/tests/robotests/src/com/android/settings/fuelgauge/BatteryHeaderPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/fuelgauge/BatteryHeaderPreferenceControllerTest.java
@@ -140,8 +140,9 @@
assertThat(((BatteryMeterView) mBatteryLayoutPref.findViewById(
R.id.battery_header_icon)).getBatteryLevel()).isEqualTo(BATTERY_LEVEL);
- assertThat(((TextView) mBatteryLayoutPref.findViewById(R.id.battery_percent)).getText())
- .isEqualTo("60%");
+ assertThat(((TextView) mBatteryLayoutPref.findViewById(R.id.battery_percent))
+ .getText().toString())
+ .isEqualTo("60 %");
}
@Test
@@ -195,7 +196,7 @@
assertThat(mBatteryMeterView.getBatteryLevel()).isEqualTo(BATTERY_LEVEL);
assertThat(mBatteryMeterView.getCharging()).isTrue();
- assertThat(mBatteryPercentText.getText()).isEqualTo("60%");
+ assertThat(mBatteryPercentText.getText().toString()).isEqualTo("60 %");
assertThat(mSummary.getText()).isEqualTo(BATTERY_STATUS);
assertThat(mSummary2.getText()).isEqualTo(BATTERY_STATUS);
}
diff --git a/tests/robotests/src/com/android/settings/gestures/PreventRingingGesturePreferenceControllerTest.java b/tests/robotests/src/com/android/settings/gestures/PreventRingingGesturePreferenceControllerTest.java
index 84fef5d..956d8bf 100644
--- a/tests/robotests/src/com/android/settings/gestures/PreventRingingGesturePreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/gestures/PreventRingingGesturePreferenceControllerTest.java
@@ -18,44 +18,47 @@
import static com.google.common.truth.Truth.assertThat;
-import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.when;
-import static org.mockito.MockitoAnnotations.initMocks;
import android.content.Context;
import android.content.res.Resources;
-import android.preference.PreferenceCategory;
import android.provider.Settings;
-import androidx.preference.PreferenceScreen;
+import androidx.preference.Preference;
+import androidx.preference.PreferenceCategory;
import com.android.settings.widget.RadioButtonPreference;
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 PreventRingingGesturePreferenceControllerTest {
-
private Context mContext;
private Resources mResources;
private PreventRingingGesturePreferenceController mController;
+ @Mock
+ private Preference mPreference;
+
@Before
public void setUp() {
+ MockitoAnnotations.initMocks(this);
mContext = spy(RuntimeEnvironment.application);
mResources = mock(Resources.class);
when(mContext.getResources()).thenReturn(mResources);
when(mResources.getBoolean(com.android.internal.R.bool.config_volumeHushGestureEnabled))
.thenReturn(true);
mController = new PreventRingingGesturePreferenceController(mContext, null);
+ mController.mPreferenceCategory = new PreferenceCategory(mContext);
mController.mVibratePref = new RadioButtonPreference(mContext);
- mController.mNonePref = new RadioButtonPreference(mContext);
mController.mMutePref = new RadioButtonPreference(mContext);
}
@@ -79,9 +82,10 @@
public void testUpdateState_mute() {
Settings.Secure.putInt(mContext.getContentResolver(), Settings.Secure.VOLUME_HUSH_GESTURE,
Settings.Secure.VOLUME_HUSH_MUTE);
- mController.updateState(null);
+ mController.updateState(mPreference);
+ assertThat(mController.mVibratePref.isEnabled()).isTrue();
+ assertThat(mController.mMutePref.isEnabled()).isTrue();
assertThat(mController.mVibratePref.isChecked()).isFalse();
- assertThat(mController.mNonePref.isChecked()).isFalse();
assertThat(mController.mMutePref.isChecked()).isTrue();
}
@@ -89,9 +93,21 @@
public void testUpdateState_vibrate() {
Settings.Secure.putInt(mContext.getContentResolver(), Settings.Secure.VOLUME_HUSH_GESTURE,
Settings.Secure.VOLUME_HUSH_VIBRATE);
- mController.updateState(null);
+ mController.updateState(mPreference);
+ assertThat(mController.mVibratePref.isEnabled()).isTrue();
+ assertThat(mController.mMutePref.isEnabled()).isTrue();
assertThat(mController.mVibratePref.isChecked()).isTrue();
- assertThat(mController.mNonePref.isChecked()).isFalse();
+ assertThat(mController.mMutePref.isChecked()).isFalse();
+ }
+
+ @Test
+ public void testUpdateState_off() {
+ Settings.Secure.putInt(mContext.getContentResolver(), Settings.Secure.VOLUME_HUSH_GESTURE,
+ Settings.Secure.VOLUME_HUSH_OFF);
+ mController.updateState(mPreference);
+ assertThat(mController.mVibratePref.isEnabled()).isFalse();
+ assertThat(mController.mMutePref.isEnabled()).isFalse();
+ assertThat(mController.mVibratePref.isChecked()).isFalse();
assertThat(mController.mMutePref.isChecked()).isFalse();
}
@@ -99,9 +115,8 @@
public void testUpdateState_other() {
Settings.Secure.putInt(mContext.getContentResolver(), Settings.Secure.VOLUME_HUSH_GESTURE,
7);
- mController.updateState(null);
+ mController.updateState(mPreference);
assertThat(mController.mVibratePref.isChecked()).isFalse();
- assertThat(mController.mNonePref.isChecked()).isTrue();
assertThat(mController.mMutePref.isChecked()).isFalse();
}
@@ -132,19 +147,4 @@
Settings.Secure.getInt(mContext.getContentResolver(),
Settings.Secure.VOLUME_HUSH_GESTURE, Settings.Secure.VOLUME_HUSH_OFF));
}
-
- @Test
- public void testRadioButtonClicked_off() {
- RadioButtonPreference rbPref = new RadioButtonPreference(mContext);
- rbPref.setKey(PreventRingingGesturePreferenceController.KEY_NONE);
-
- Settings.Secure.putInt(mContext.getContentResolver(), Settings.Secure.VOLUME_HUSH_GESTURE,
- Settings.Secure.VOLUME_HUSH_MUTE);
-
- mController.onRadioButtonClicked(rbPref);
-
- assertThat(Settings.Secure.VOLUME_HUSH_OFF).isEqualTo(
- Settings.Secure.getInt(mContext.getContentResolver(),
- Settings.Secure.VOLUME_HUSH_GESTURE, Settings.Secure.VOLUME_HUSH_VIBRATE));
- }
}
diff --git a/tests/robotests/src/com/android/settings/gestures/PreventRingingSwitchPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/gestures/PreventRingingSwitchPreferenceControllerTest.java
new file mode 100644
index 0000000..5f221f5
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/gestures/PreventRingingSwitchPreferenceControllerTest.java
@@ -0,0 +1,98 @@
+/*
+ * 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 com.google.common.truth.Truth.assertThat;
+
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.spy;
+import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
+import android.content.Context;
+import android.content.res.Resources;
+import android.provider.Settings;
+
+import androidx.preference.Preference;
+
+import com.android.settings.widget.SwitchBar;
+
+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 PreventRingingSwitchPreferenceControllerTest {
+ private Context mContext;
+ private Resources mResources;
+ private PreventRingingSwitchPreferenceController mController;
+ private Preference mPreference = mock(Preference.class);
+
+ @Before
+ public void setUp() {
+ mContext = spy(RuntimeEnvironment.application);
+ mResources = mock(Resources.class);
+ when(mContext.getResources()).thenReturn(mResources);
+ when(mResources.getBoolean(com.android.internal.R.bool.config_volumeHushGestureEnabled))
+ .thenReturn(true);
+ mController = new PreventRingingSwitchPreferenceController(mContext);
+ mController.mSwitch = mock(SwitchBar.class);
+ }
+
+ @Test
+ public void testIsAvailable_configIsTrue_shouldReturnTrue() {
+ when(mResources.getBoolean(
+ com.android.internal.R.bool.config_volumeHushGestureEnabled)).thenReturn(true);
+
+ assertThat(mController.isAvailable()).isTrue();
+ }
+
+ @Test
+ public void testIsAvailable_configIsFalse_shouldReturnFalse() {
+ when(mResources.getBoolean(
+ com.android.internal.R.bool.config_volumeHushGestureEnabled)).thenReturn(false);
+
+ assertThat(mController.isAvailable()).isFalse();
+ }
+
+ @Test
+ public void testOn_updateState_hushOff() {
+ Settings.Secure.putInt(mContext.getContentResolver(), Settings.Secure.VOLUME_HUSH_GESTURE,
+ Settings.Secure.VOLUME_HUSH_OFF);
+ mController.updateState(mPreference);
+ verify(mController.mSwitch, times(1)).setChecked(false);
+ }
+
+ @Test
+ public void testOn_updateState_hushVibrate() {
+ Settings.Secure.putInt(mContext.getContentResolver(), Settings.Secure.VOLUME_HUSH_GESTURE,
+ Settings.Secure.VOLUME_HUSH_VIBRATE);
+ mController.updateState(mPreference);
+ verify(mController.mSwitch, times(1)).setChecked(true);
+ }
+
+ @Test
+ public void testOn_updateState_hushMute() {
+ Settings.Secure.putInt(mContext.getContentResolver(), Settings.Secure.VOLUME_HUSH_GESTURE,
+ Settings.Secure.VOLUME_HUSH_MUTE);
+ mController.updateState(mPreference);
+ verify(mController.mSwitch, times(1)).setChecked(true);
+ }
+}
diff --git a/tests/robotests/src/com/android/settings/homepage/contextualcards/ContextualCardLoaderTest.java b/tests/robotests/src/com/android/settings/homepage/contextualcards/ContextualCardLoaderTest.java
index c62a6bb..c47fa38 100644
--- a/tests/robotests/src/com/android/settings/homepage/contextualcards/ContextualCardLoaderTest.java
+++ b/tests/robotests/src/com/android/settings/homepage/contextualcards/ContextualCardLoaderTest.java
@@ -29,16 +29,16 @@
import com.android.settings.slices.CustomSliceRegistry;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.stream.Collectors;
-
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.robolectric.RobolectricTestRunner;
import org.robolectric.RuntimeEnvironment;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.stream.Collectors;
+
@RunWith(RobolectricTestRunner.class)
public class ContextualCardLoaderTest {
@@ -82,29 +82,29 @@
}
@Test
- public void getFinalDisplayableCards_twoEligibleCards_shouldShowAll() {
+ public void getDisplayableCards_twoEligibleCards_shouldShowAll() {
final List<ContextualCard> cards = getContextualCardList().stream().limit(2)
.collect(Collectors.toList());
doReturn(cards).when(mContextualCardLoader).filterEligibleCards(any(List.class));
- final List<ContextualCard> result = mContextualCardLoader.getFinalDisplayableCards(cards);
+ final List<ContextualCard> result = mContextualCardLoader.getDisplayableCards(cards);
assertThat(result).hasSize(cards.size());
}
@Test
- public void getFinalDisplayableCards_fiveEligibleCardsNoLarge_shouldShowDefaultCardCount() {
+ public void getDisplayableCards_fiveEligibleCardsNoLarge_shouldShowDefaultCardCount() {
final List<ContextualCard> fiveCards = getContextualCardListWithNoLargeCard();
doReturn(fiveCards).when(mContextualCardLoader).filterEligibleCards(any(List.class));
- final List<ContextualCard> result = mContextualCardLoader.getFinalDisplayableCards(
+ final List<ContextualCard> result = mContextualCardLoader.getDisplayableCards(
fiveCards);
assertThat(result).hasSize(DEFAULT_CARD_COUNT);
}
@Test
- public void getFinalDisplayableCards_threeEligibleCardsOneLarge_shouldShowThreeCards() {
+ public void getDisplayableCards_threeEligibleCardsOneLarge_shouldShowThreeCards() {
final List<ContextualCard> cards = getContextualCardList().stream().limit(2)
.collect(Collectors.toList());
cards.add(new ContextualCard.Builder()
@@ -115,18 +115,18 @@
.build());
doReturn(cards).when(mContextualCardLoader).filterEligibleCards(any(List.class));
- final List<ContextualCard> result = mContextualCardLoader.getFinalDisplayableCards(cards);
+ final List<ContextualCard> result = mContextualCardLoader.getDisplayableCards(cards);
assertThat(result).hasSize(3);
}
@Test
- public void getFinalDisplayableCards_threeEligibleCardsTwoLarge_shouldShowTwoCards() {
+ public void getDisplayableCards_threeEligibleCardsTwoLarge_shouldShowTwoCards() {
final List<ContextualCard> threeCards = getContextualCardList().stream().limit(3)
.collect(Collectors.toList());
doReturn(threeCards).when(mContextualCardLoader).filterEligibleCards(any(List.class));
- final List<ContextualCard> result = mContextualCardLoader.getFinalDisplayableCards(
+ final List<ContextualCard> result = mContextualCardLoader.getDisplayableCards(
threeCards);
assertThat(result).hasSize(2);
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 c405ffc..3fc8e06 100644
--- a/tests/robotests/src/com/android/settings/homepage/contextualcards/ContextualCardManagerTest.java
+++ b/tests/robotests/src/com/android/settings/homepage/contextualcards/ContextualCardManagerTest.java
@@ -32,6 +32,8 @@
import com.android.settings.homepage.contextualcards.conditional.ConditionFooterContextualCard;
import com.android.settings.homepage.contextualcards.conditional.ConditionHeaderContextualCard;
import com.android.settings.homepage.contextualcards.conditional.ConditionalContextualCard;
+import com.android.settings.intelligence.ContextualCardProto;
+import com.android.settings.slices.CustomSliceRegistry;
import org.junit.Before;
import org.junit.Test;
@@ -203,6 +205,134 @@
assertThat(actualCards).containsExactlyElementsIn(expectedCards);
}
+
+ @Test
+ public void assignCardWidth_noSuggestionCards_shouldNotHaveHalfCards() {
+ final List<Integer> categories = Arrays.asList(
+ ContextualCardProto.ContextualCard.Category.IMPORTANT_VALUE,
+ ContextualCardProto.ContextualCard.Category.IMPORTANT_VALUE,
+ ContextualCardProto.ContextualCard.Category.IMPORTANT_VALUE,
+ ContextualCardProto.ContextualCard.Category.IMPORTANT_VALUE,
+ ContextualCardProto.ContextualCard.Category.IMPORTANT_VALUE
+ );
+ final List<ContextualCard> noSuggestionCards = buildCategoriedCards(getContextualCardList(),
+ categories);
+
+ final List<ContextualCard> result = mManager.assignCardWidth(noSuggestionCards);
+
+ assertThat(result).hasSize(5);
+ for (ContextualCard card : result) {
+ assertThat(card.isHalfWidth()).isFalse();
+ }
+ }
+
+ @Test
+ public void assignCardWidth_oneSuggestionCards_shouldNotHaveHalfCards() {
+ final List<Integer> categories = Arrays.asList(
+ ContextualCardProto.ContextualCard.Category.IMPORTANT_VALUE,
+ ContextualCardProto.ContextualCard.Category.IMPORTANT_VALUE,
+ ContextualCardProto.ContextualCard.Category.IMPORTANT_VALUE,
+ ContextualCardProto.ContextualCard.Category.IMPORTANT_VALUE,
+ ContextualCardProto.ContextualCard.Category.SUGGESTION_VALUE
+ );
+ final List<ContextualCard> oneSuggestionCards = buildCategoriedCards(
+ getContextualCardList(), categories);
+
+ final List<ContextualCard> result = mManager.assignCardWidth(oneSuggestionCards);
+
+ assertThat(result).hasSize(5);
+ for (ContextualCard card : result) {
+ assertThat(card.isHalfWidth()).isFalse();
+ }
+ }
+
+ @Test
+ public void assignCardWidth_twoConsecutiveSuggestionCards_shouldHaveTwoHalfCards() {
+ final List<Integer> categories = Arrays.asList(
+ ContextualCardProto.ContextualCard.Category.IMPORTANT_VALUE,
+ ContextualCardProto.ContextualCard.Category.IMPORTANT_VALUE,
+ ContextualCardProto.ContextualCard.Category.SUGGESTION_VALUE,
+ ContextualCardProto.ContextualCard.Category.SUGGESTION_VALUE,
+ ContextualCardProto.ContextualCard.Category.IMPORTANT_VALUE
+ );
+ final List<ContextualCard> twoConsecutiveSuggestionCards = buildCategoriedCards(
+ getContextualCardList(), categories);
+ final List<Boolean> expectedValues = Arrays.asList(false, false, true, true, false);
+
+ final List<ContextualCard> result = mManager.assignCardWidth(
+ twoConsecutiveSuggestionCards);
+
+ assertThat(result).hasSize(5);
+ for (int i = 0; i < result.size(); i++) {
+ assertThat(result.get(i).isHalfWidth()).isEqualTo(expectedValues.get(i));
+ }
+ }
+
+ @Test
+ public void assignCardWidth_twoNonConsecutiveSuggestionCards_shouldNotHaveHalfCards() {
+ final List<Integer> categories = Arrays.asList(
+ ContextualCardProto.ContextualCard.Category.SUGGESTION_VALUE,
+ ContextualCardProto.ContextualCard.Category.IMPORTANT_VALUE,
+ ContextualCardProto.ContextualCard.Category.IMPORTANT_VALUE,
+ ContextualCardProto.ContextualCard.Category.IMPORTANT_VALUE,
+ ContextualCardProto.ContextualCard.Category.SUGGESTION_VALUE
+ );
+ final List<ContextualCard> twoNonConsecutiveSuggestionCards = buildCategoriedCards(
+ getContextualCardList(), categories);
+
+ final List<ContextualCard> result = mManager.assignCardWidth(
+ twoNonConsecutiveSuggestionCards);
+
+ assertThat(result).hasSize(5);
+ for (ContextualCard card : result) {
+ assertThat(card.isHalfWidth()).isFalse();
+ }
+ }
+
+ @Test
+ public void assignCardWidth_threeConsecutiveSuggestionCards_shouldHaveTwoHalfCards() {
+ final List<Integer> categories = Arrays.asList(
+ ContextualCardProto.ContextualCard.Category.IMPORTANT_VALUE,
+ ContextualCardProto.ContextualCard.Category.SUGGESTION_VALUE,
+ ContextualCardProto.ContextualCard.Category.SUGGESTION_VALUE,
+ ContextualCardProto.ContextualCard.Category.SUGGESTION_VALUE,
+ ContextualCardProto.ContextualCard.Category.IMPORTANT_VALUE
+ );
+ final List<ContextualCard> threeConsecutiveSuggestionCards = buildCategoriedCards(
+ getContextualCardList(), categories);
+ final List<Boolean> expectedValues = Arrays.asList(false, true, true, false, false);
+
+ final List<ContextualCard> result = mManager.assignCardWidth(
+ threeConsecutiveSuggestionCards);
+
+ assertThat(result).hasSize(5);
+ for (int i = 0; i < result.size(); i++) {
+ assertThat(result.get(i).isHalfWidth()).isEqualTo(expectedValues.get(i));
+ }
+ }
+
+ @Test
+ public void assignCardWidth_fourConsecutiveSuggestionCards_shouldHaveFourHalfCards() {
+ final List<Integer> categories = Arrays.asList(
+ ContextualCardProto.ContextualCard.Category.IMPORTANT_VALUE,
+ ContextualCardProto.ContextualCard.Category.SUGGESTION_VALUE,
+ ContextualCardProto.ContextualCard.Category.SUGGESTION_VALUE,
+ ContextualCardProto.ContextualCard.Category.SUGGESTION_VALUE,
+ ContextualCardProto.ContextualCard.Category.SUGGESTION_VALUE
+ );
+ final List<ContextualCard> fourConsecutiveSuggestionCards = buildCategoriedCards(
+ getContextualCardList(), categories);
+ final List<Boolean> expectedValues = Arrays.asList(false, true, true, true, true);
+
+ final List<ContextualCard> result = mManager.assignCardWidth(
+ fourConsecutiveSuggestionCards);
+
+ assertThat(result).hasSize(5);
+ for (int i = 0; i < result.size(); i++) {
+ assertThat(result.get(i).isHalfWidth()).isEqualTo(expectedValues.get(i));
+ }
+ }
+
private ContextualCard buildContextualCard(String sliceUri) {
return new ContextualCard.Builder()
.setName(TEST_SLICE_NAME)
@@ -210,4 +340,45 @@
.setSliceUri(Uri.parse(sliceUri))
.build();
}
+
+ private List<ContextualCard> buildCategoriedCards(List<ContextualCard> cards,
+ List<Integer> categories) {
+ final List<ContextualCard> result = new ArrayList<>();
+ for (int i = 0; i < cards.size(); i++) {
+ result.add(cards.get(i).mutate().setCategory(categories.get(i)).build());
+ }
+ return result;
+ }
+
+ private List<ContextualCard> getContextualCardList() {
+ final List<ContextualCard> cards = new ArrayList<>();
+ cards.add(new ContextualCard.Builder()
+ .setName("test_wifi")
+ .setCardType(ContextualCard.CardType.SLICE)
+ .setSliceUri(CustomSliceRegistry.CONTEXTUAL_WIFI_SLICE_URI)
+ .build());
+ cards.add(new ContextualCard.Builder()
+ .setName("test_flashlight")
+ .setCardType(ContextualCard.CardType.SLICE)
+ .setSliceUri(
+ Uri.parse("content://com.android.settings.test.slices/action/flashlight"))
+ .build());
+ cards.add(new ContextualCard.Builder()
+ .setName("test_connected")
+ .setCardType(ContextualCard.CardType.SLICE)
+ .setSliceUri(CustomSliceRegistry.BLUETOOTH_DEVICES_SLICE_URI)
+ .build());
+ cards.add(new ContextualCard.Builder()
+ .setName("test_gesture")
+ .setCardType(ContextualCard.CardType.SLICE)
+ .setSliceUri(Uri.parse(
+ "content://com.android.settings.test.slices/action/gesture_pick_up"))
+ .build());
+ cards.add(new ContextualCard.Builder()
+ .setName("test_battery")
+ .setCardType(ContextualCard.CardType.SLICE)
+ .setSliceUri(CustomSliceRegistry.BATTERY_INFO_SLICE_URI)
+ .build());
+ return cards;
+ }
}
diff --git a/tests/robotests/src/com/android/settings/homepage/contextualcards/conditional/BatterySaverConditionControllerTest.java b/tests/robotests/src/com/android/settings/homepage/contextualcards/conditional/BatterySaverConditionControllerTest.java
new file mode 100644
index 0000000..e4ca6c0
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/homepage/contextualcards/conditional/BatterySaverConditionControllerTest.java
@@ -0,0 +1,86 @@
+/*
+ * 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.homepage.contextualcards.conditional;
+
+import static com.google.common.truth.Truth.assertThat;
+
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.Mockito.spy;
+import static org.mockito.Mockito.verify;
+
+import android.content.Context;
+import android.content.IntentFilter;
+import android.os.PowerManager;
+
+import com.android.settings.fuelgauge.BatterySaverReceiver;
+
+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;
+import org.robolectric.Shadows;
+import org.robolectric.shadows.ShadowPowerManager;
+
+@RunWith(RobolectricTestRunner.class)
+public class BatterySaverConditionControllerTest {
+ @Mock
+ private ConditionManager mConditionManager;
+
+ private ShadowPowerManager mPowerManager;
+ private Context mContext;
+ private BatterySaverConditionController mController;
+
+ @Before
+ public void setUp() {
+ MockitoAnnotations.initMocks(this);
+ mContext = spy(RuntimeEnvironment.application);
+ mPowerManager = Shadows.shadowOf(mContext.getSystemService(PowerManager.class));
+ mController = new BatterySaverConditionController(mContext, mConditionManager);
+ }
+
+ @Test
+ public void startMonitor_shouldRegisterReceiver() {
+ mController.startMonitoringStateChange();
+
+ verify(mContext).registerReceiver(any(BatterySaverReceiver.class), any(IntentFilter.class));
+ }
+
+ @Test
+ public void stopMonitor_shouldUnregisterReceiver() {
+ mController.startMonitoringStateChange();
+ mController.stopMonitoringStateChange();
+
+ verify(mContext).unregisterReceiver(any(BatterySaverReceiver.class));
+ }
+
+ @Test
+ public void isDisplayable_PowerSaverOn_true() {
+ mPowerManager.setIsPowerSaveMode(true);
+
+ assertThat(mController.isDisplayable()).isTrue();
+ }
+
+ @Test
+ public void isDisplayable_PowerSaverOff_false() {
+ mPowerManager.setIsPowerSaveMode(false);
+
+ assertThat(mController.isDisplayable()).isFalse();
+ }
+}
diff --git a/tests/robotests/src/com/android/settings/homepage/contextualcards/conditional/ConditionContextualCardControllerTest.java b/tests/robotests/src/com/android/settings/homepage/contextualcards/conditional/ConditionContextualCardControllerTest.java
index 566ca07..4553f7c 100644
--- a/tests/robotests/src/com/android/settings/homepage/contextualcards/conditional/ConditionContextualCardControllerTest.java
+++ b/tests/robotests/src/com/android/settings/homepage/contextualcards/conditional/ConditionContextualCardControllerTest.java
@@ -112,7 +112,8 @@
}
@Test
- public void getConditionalCards_hasOneConditionCard_shouldGetOneFullWidthCard() {
+ public void getConditionalCards_hasOneConditionCardAndExpanded_shouldGetOneFullWidthCard() {
+ mController.setIsExpanded(true);
final Map<Integer, List<ContextualCard>> conditionalCards =
mController.buildConditionalCardsWithFooterOrHeader(generateConditionCards(1));
@@ -120,11 +121,24 @@
assertThat(conditionalCards.get(CardType.CONDITIONAL)).hasSize(1);
assertThat(conditionalCards.get(CardType.CONDITIONAL).get(0).isHalfWidth()).isFalse();
assertThat(conditionalCards.get(CardType.CONDITIONAL_HEADER)).isEmpty();
+ assertThat(conditionalCards.get(CardType.CONDITIONAL_FOOTER)).isNotEmpty();
+ }
+
+ @Test
+ public void getConditionalCards_hasOneConditionCardAndCollapsed_shouldGetConditionalHeader() {
+ mController.setIsExpanded(false);
+ final Map<Integer, List<ContextualCard>> conditionalCards =
+ mController.buildConditionalCardsWithFooterOrHeader(generateConditionCards(1));
+
+ assertThat(conditionalCards).hasSize(3);
+ assertThat(conditionalCards.get(CardType.CONDITIONAL)).isEmpty();
+ assertThat(conditionalCards.get(CardType.CONDITIONAL_HEADER)).isNotEmpty();
assertThat(conditionalCards.get(CardType.CONDITIONAL_FOOTER)).isEmpty();
}
@Test
- public void getConditionalCards_hasTwoConditionCards_shouldGetTwoHalfWidthCards() {
+ public void getConditionalCards_hasTwoConditionCardsAndExpanded_shouldGetTwoHalfWidthCards() {
+ mController.setIsExpanded(true);
final Map<Integer, List<ContextualCard>> conditionalCards =
mController.buildConditionalCardsWithFooterOrHeader(generateConditionCards(2));
@@ -134,6 +148,18 @@
assertThat(card.isHalfWidth()).isTrue();
}
assertThat(conditionalCards.get(CardType.CONDITIONAL_HEADER)).isEmpty();
+ assertThat(conditionalCards.get(CardType.CONDITIONAL_FOOTER)).isNotEmpty();
+ }
+
+ @Test
+ public void getConditionalCards_hasTwoConditionCardsAndCollapsed_shouldGetConditionalHeader() {
+ mController.setIsExpanded(false);
+ final Map<Integer, List<ContextualCard>> conditionalCards =
+ mController.buildConditionalCardsWithFooterOrHeader(generateConditionCards(2));
+
+ assertThat(conditionalCards).hasSize(3);
+ assertThat(conditionalCards.get(CardType.CONDITIONAL)).isEmpty();
+ assertThat(conditionalCards.get(CardType.CONDITIONAL_HEADER)).isNotEmpty();
assertThat(conditionalCards.get(CardType.CONDITIONAL_FOOTER)).isEmpty();
}
diff --git a/tests/robotests/src/com/android/settings/homepage/contextualcards/deviceinfo/BatterySliceTest.java b/tests/robotests/src/com/android/settings/homepage/contextualcards/deviceinfo/BatteryInfoSliceTest.java
similarity index 84%
rename from tests/robotests/src/com/android/settings/homepage/contextualcards/deviceinfo/BatterySliceTest.java
rename to tests/robotests/src/com/android/settings/homepage/contextualcards/deviceinfo/BatteryInfoSliceTest.java
index 289a57d..ff276d6 100644
--- a/tests/robotests/src/com/android/settings/homepage/contextualcards/deviceinfo/BatterySliceTest.java
+++ b/tests/robotests/src/com/android/settings/homepage/contextualcards/deviceinfo/BatteryInfoSliceTest.java
@@ -40,10 +40,10 @@
import org.robolectric.RuntimeEnvironment;
@RunWith(RobolectricTestRunner.class)
-public class BatterySliceTest {
+public class BatteryInfoSliceTest {
private Context mContext;
- private BatterySlice mBatterySlice;
+ private BatteryInfoSlice mBatteryInfoSlice;
@Before
public void setUp() {
@@ -52,16 +52,16 @@
// Set-up specs for SliceMetadata.
SliceProvider.setSpecs(SliceLiveData.SUPPORTED_SPECS);
- mBatterySlice = spy(new BatterySlice(mContext));
+ mBatteryInfoSlice = spy(new BatteryInfoSlice(mContext));
}
@Test
public void getSlice_shouldBeCorrectSliceContent() {
- doNothing().when(mBatterySlice).loadBatteryInfo();
- doReturn("10%").when(mBatterySlice).getBatteryPercentString();
- doReturn("test").when(mBatterySlice).getSummary();
+ doNothing().when(mBatteryInfoSlice).loadBatteryInfo();
+ doReturn("10%").when(mBatteryInfoSlice).getBatteryPercentString();
+ doReturn("test").when(mBatteryInfoSlice).getSummary();
- final Slice slice = mBatterySlice.getSlice();
+ final Slice slice = mBatteryInfoSlice.getSlice();
final SliceMetadata metadata = SliceMetadata.from(mContext, slice);
assertThat(metadata.getTitle()).isEqualTo(
diff --git a/tests/robotests/src/com/android/settings/homepage/contextualcards/slices/BatteryFixSliceTest.java b/tests/robotests/src/com/android/settings/homepage/contextualcards/slices/BatteryFixSliceTest.java
index ff08c6a..1c299cb 100644
--- a/tests/robotests/src/com/android/settings/homepage/contextualcards/slices/BatteryFixSliceTest.java
+++ b/tests/robotests/src/com/android/settings/homepage/contextualcards/slices/BatteryFixSliceTest.java
@@ -26,6 +26,8 @@
import android.content.Context;
import android.content.SharedPreferences;
+import androidx.slice.Slice;
+import androidx.slice.SliceMetadata;
import androidx.slice.SliceProvider;
import androidx.slice.widget.SliceLiveData;
@@ -55,11 +57,13 @@
public class BatteryFixSliceTest {
private Context mContext;
+ private BatteryFixSlice mSlice;
@Before
public void setUp() {
MockitoAnnotations.initMocks(this);
mContext = RuntimeEnvironment.application;
+ mSlice = new BatteryFixSlice(mContext);
// Set-up specs for SliceMetadata.
SliceProvider.setSpecs(SliceLiveData.SUPPORTED_SPECS);
@@ -71,7 +75,7 @@
}
@Test
- public void readBatteryTipfromPref_readCorrectValue() {
+ public void readBatteryTipFromPref_readCorrectValue() {
int target = 111;
final SharedPreferences.Editor editor = mContext.getSharedPreferences(PREFS,
MODE_PRIVATE).edit();
@@ -90,7 +94,7 @@
public void updateBatteryTipAvailabilityCache_writeCorrectValue() {
final List<BatteryTip> tips = new ArrayList<>();
tips.add(new LowBatteryTip(BatteryTip.StateType.INVISIBLE, false, ""));
- tips.add(new EarlyWarningTip(BatteryTip.StateType.HANDLED, false));
+ tips.add(new EarlyWarningTip(BatteryTip.StateType.NEW, false));
ShadowBatteryTipLoader.setBatteryTips(tips);
BatteryFixSlice.updateBatteryTipAvailabilityCache(mContext);
@@ -99,6 +103,23 @@
BatteryTip.TipType.BATTERY_SAVER);
}
+ @Test
+ @Config(shadows = {
+ ShadowBatteryStatsHelperLoader.class,
+ ShadowBatteryTipLoader.class
+ })
+ public void getSlice_unimportantSlice_shouldSkip() {
+ final List<BatteryTip> tips = new ArrayList<>();
+ tips.add(new LowBatteryTip(BatteryTip.StateType.INVISIBLE, false, ""));
+ tips.add(new EarlyWarningTip(BatteryTip.StateType.NEW, false));
+ ShadowBatteryTipLoader.setBatteryTips(tips);
+
+ BatteryFixSlice.updateBatteryTipAvailabilityCache(mContext);
+ final Slice slice = mSlice.getSlice();
+
+ assertThat(SliceMetadata.from(mContext, slice).isErrorSlice()).isTrue();
+ }
+
@Implements(BatteryStatsHelperLoader.class)
public static class ShadowBatteryStatsHelperLoader {
diff --git a/tests/robotests/src/com/android/settings/homepage/contextualcards/slices/SliceContextualCardRendererTest.java b/tests/robotests/src/com/android/settings/homepage/contextualcards/slices/SliceContextualCardRendererTest.java
index 0b87525..4d9a21d 100644
--- a/tests/robotests/src/com/android/settings/homepage/contextualcards/slices/SliceContextualCardRendererTest.java
+++ b/tests/robotests/src/com/android/settings/homepage/contextualcards/slices/SliceContextualCardRendererTest.java
@@ -79,17 +79,6 @@
}
@Test
- public void bindView_shouldSetScrollableToFalse() {
- RecyclerView.ViewHolder viewHolder = getSliceViewHolder();
-
- mRenderer.bindView(viewHolder, buildContextualCard(TEST_SLICE_URI));
-
- assertThat(
- ((SliceContextualCardRenderer.SliceViewHolder) viewHolder).sliceView.isScrollable
- ()).isFalse();
- }
-
- @Test
public void bindView_invalidScheme_sliceShouldBeNull() {
final Uri sliceUri = Uri.parse("contet://com.android.settings.slices/action/flashlight");
RecyclerView.ViewHolder viewHolder = getSliceViewHolder();
@@ -97,7 +86,7 @@
mRenderer.bindView(viewHolder, buildContextualCard(sliceUri));
assertThat(
- ((SliceContextualCardRenderer.SliceViewHolder) viewHolder).sliceView.getSlice())
+ ((SliceFullCardRendererHelper.SliceViewHolder) viewHolder).sliceView.getSlice())
.isNull();
}
diff --git a/tests/robotests/src/com/android/settings/homepage/contextualcards/slices/SliceFullCardRendererHelperTest.java b/tests/robotests/src/com/android/settings/homepage/contextualcards/slices/SliceFullCardRendererHelperTest.java
new file mode 100644
index 0000000..9172300d
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/homepage/contextualcards/slices/SliceFullCardRendererHelperTest.java
@@ -0,0 +1,151 @@
+/*
+ * 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.homepage.contextualcards.slices;
+
+import static com.android.settings.homepage.contextualcards.slices.SliceContextualCardRenderer.VIEW_TYPE_FULL_WIDTH;
+
+import static com.google.common.truth.Truth.assertThat;
+
+import android.app.Activity;
+import android.app.PendingIntent;
+import android.content.Intent;
+import android.net.Uri;
+import android.view.LayoutInflater;
+import android.view.View;
+
+import androidx.core.graphics.drawable.IconCompat;
+import androidx.recyclerview.widget.LinearLayoutManager;
+import androidx.recyclerview.widget.RecyclerView;
+import androidx.slice.Slice;
+import androidx.slice.SliceProvider;
+import androidx.slice.builders.ListBuilder;
+import androidx.slice.builders.SliceAction;
+import androidx.slice.widget.SliceLiveData;
+import androidx.slice.widget.SliceView;
+
+import com.android.settings.R;
+import com.android.settings.homepage.contextualcards.ContextualCard;
+import com.android.settings.homepage.contextualcards.slices.SliceFullCardRendererHelper.SliceViewHolder;
+import com.android.settings.intelligence.ContextualCardProto;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.robolectric.Robolectric;
+import org.robolectric.RobolectricTestRunner;
+
+import java.util.Collections;
+
+@RunWith(RobolectricTestRunner.class)
+public class SliceFullCardRendererHelperTest {
+
+ private static final Uri TEST_SLICE_URI = Uri.parse("content://test/test");
+
+ private Activity mActivity;
+ private SliceFullCardRendererHelper mHelper;
+
+ @Before
+ public void setUp() {
+ // Set-up specs for SliceMetadata.
+ SliceProvider.setSpecs(SliceLiveData.SUPPORTED_SPECS);
+ mActivity = Robolectric.buildActivity(Activity.class).create().get();
+ mActivity.setTheme(R.style.Theme_Settings_Home);
+ mHelper = new SliceFullCardRendererHelper(mActivity);
+ }
+
+ @Test
+ public void createViewHolder_shouldAlwaysReturnSliceViewHolder() {
+ final RecyclerView.ViewHolder viewHolder = getSliceViewHolder();
+
+ assertThat(viewHolder).isInstanceOf(SliceViewHolder.class);
+ }
+
+ @Test
+ public void bindView_shouldSetScrollableToFalse() {
+ final RecyclerView.ViewHolder viewHolder = getSliceViewHolder();
+
+ mHelper.bindView(viewHolder, buildContextualCard(), buildSlice(), Collections.emptySet());
+
+ assertThat(((SliceViewHolder) viewHolder).sliceView.isScrollable()).isFalse();
+ }
+
+ @Test
+ public void bindView_shouldSetTagToSliceUri() {
+ final RecyclerView.ViewHolder viewHolder = getSliceViewHolder();
+ final ContextualCard card = buildContextualCard();
+
+ mHelper.bindView(viewHolder, card, buildSlice(), Collections.emptySet());
+
+ assertThat(((SliceViewHolder) viewHolder).sliceView.getTag()).isEqualTo(card.getSliceUri());
+ }
+
+ @Test
+ public void bindView_shouldSetModeToLarge() {
+ final RecyclerView.ViewHolder viewHolder = getSliceViewHolder();
+
+ mHelper.bindView(viewHolder, buildContextualCard(), buildSlice(), Collections.emptySet());
+
+ assertThat(((SliceViewHolder) viewHolder).sliceView.getMode()).isEqualTo(
+ SliceView.MODE_LARGE);
+ }
+
+ @Test
+ public void bindView_shouldSetSlice() {
+ final RecyclerView.ViewHolder viewHolder = getSliceViewHolder();
+
+ mHelper.bindView(viewHolder, buildContextualCard(), buildSlice(), Collections.emptySet());
+
+ assertThat(((SliceViewHolder) viewHolder).sliceView.getSlice().getUri()).isEqualTo(
+ TEST_SLICE_URI);
+ }
+
+ private RecyclerView.ViewHolder getSliceViewHolder() {
+ final RecyclerView recyclerView = new RecyclerView(mActivity);
+ recyclerView.setLayoutManager(new LinearLayoutManager(mActivity));
+ final View view = LayoutInflater.from(mActivity).inflate(VIEW_TYPE_FULL_WIDTH, recyclerView,
+ false);
+ return mHelper.createViewHolder(view);
+ }
+
+ private ContextualCard buildContextualCard() {
+ return new ContextualCard.Builder()
+ .setName("test_name")
+ .setCategory(ContextualCardProto.ContextualCard.Category.SUGGESTION_VALUE)
+ .setCardType(ContextualCard.CardType.SLICE)
+ .setSliceUri(TEST_SLICE_URI)
+ .setIsHalfWidth(false /* isHalfWidth */)
+ .build();
+ }
+
+ private Slice buildSlice() {
+ final String title = "test_title";
+ final IconCompat icon = IconCompat.createWithResource(mActivity, R.drawable.empty_icon);
+ final PendingIntent pendingIntent = PendingIntent.getActivity(
+ mActivity,
+ title.hashCode() /* requestCode */,
+ new Intent("test action"),
+ 0 /* flags */);
+ final SliceAction action
+ = SliceAction.createDeeplink(pendingIntent, icon, ListBuilder.SMALL_IMAGE, title);
+ return new ListBuilder(mActivity, TEST_SLICE_URI, ListBuilder.INFINITY)
+ .addRow(new ListBuilder.RowBuilder()
+ .addEndItem(icon, ListBuilder.ICON_IMAGE)
+ .setTitle(title)
+ .setPrimaryAction(action))
+ .build();
+ }
+}
diff --git a/tests/robotests/src/com/android/settings/homepage/contextualcards/slices/SliceHalfCardRendererHelperTest.java b/tests/robotests/src/com/android/settings/homepage/contextualcards/slices/SliceHalfCardRendererHelperTest.java
new file mode 100644
index 0000000..c38697e
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/homepage/contextualcards/slices/SliceHalfCardRendererHelperTest.java
@@ -0,0 +1,119 @@
+/*
+ * 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.homepage.contextualcards.slices;
+
+import static com.android.settings.homepage.contextualcards.slices.SliceContextualCardRenderer.VIEW_TYPE_HALF_WIDTH;
+
+import static com.google.common.truth.Truth.assertThat;
+
+import android.app.Activity;
+import android.app.PendingIntent;
+import android.content.Intent;
+import android.net.Uri;
+import android.view.LayoutInflater;
+import android.view.View;
+
+import androidx.core.graphics.drawable.IconCompat;
+import androidx.recyclerview.widget.LinearLayoutManager;
+import androidx.recyclerview.widget.RecyclerView;
+import androidx.slice.Slice;
+import androidx.slice.SliceProvider;
+import androidx.slice.builders.ListBuilder;
+import androidx.slice.builders.SliceAction;
+import androidx.slice.widget.SliceLiveData;
+
+import com.android.settings.R;
+import com.android.settings.homepage.contextualcards.ContextualCard;
+import com.android.settings.homepage.contextualcards.slices.SliceHalfCardRendererHelper.HalfCardViewHolder;
+import com.android.settings.intelligence.ContextualCardProto;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.robolectric.Robolectric;
+import org.robolectric.RobolectricTestRunner;
+
+@RunWith(RobolectricTestRunner.class)
+public class SliceHalfCardRendererHelperTest {
+
+ private static final Uri TEST_SLICE_URI = Uri.parse("content://test/test");
+
+ private Activity mActivity;
+ private SliceHalfCardRendererHelper mHelper;
+
+ @Before
+ public void setUp() {
+ // Set-up specs for SliceMetadata.
+ SliceProvider.setSpecs(SliceLiveData.SUPPORTED_SPECS);
+ mActivity = Robolectric.buildActivity(Activity.class).create().get();
+ mActivity.setTheme(R.style.Theme_Settings_Home);
+ mHelper = new SliceHalfCardRendererHelper(mActivity);
+ }
+
+ @Test
+ public void createViewHolder_shouldAlwaysReturnCustomViewHolder() {
+ final RecyclerView.ViewHolder viewHolder = getHalfCardViewHolder();
+
+ assertThat(viewHolder).isInstanceOf(HalfCardViewHolder.class);
+ }
+
+ @Test
+ public void bindView_shouldSetTitle() {
+ final RecyclerView.ViewHolder viewHolder = getHalfCardViewHolder();
+
+ mHelper.bindView(viewHolder, buildContextualCard(), buildSlice());
+
+ assertThat(((HalfCardViewHolder) viewHolder).title.getText()).isEqualTo("test_title");
+ }
+
+ private RecyclerView.ViewHolder getHalfCardViewHolder() {
+ final RecyclerView recyclerView = new RecyclerView(mActivity);
+ recyclerView.setLayoutManager(new LinearLayoutManager(mActivity));
+ final View view = LayoutInflater.from(mActivity).inflate(VIEW_TYPE_HALF_WIDTH, recyclerView,
+ false);
+
+ return mHelper.createViewHolder(view);
+ }
+
+ private ContextualCard buildContextualCard() {
+ return new ContextualCard.Builder()
+ .setName("test_name")
+ .setCategory(ContextualCardProto.ContextualCard.Category.SUGGESTION_VALUE)
+ .setCardType(ContextualCard.CardType.SLICE)
+ .setSliceUri(TEST_SLICE_URI)
+ .setIsHalfWidth(false /* isHalfWidth */)
+ .build();
+ }
+
+ private Slice buildSlice() {
+ final String title = "test_title";
+ final IconCompat icon = IconCompat.createWithResource(mActivity, R.drawable.empty_icon);
+ final PendingIntent pendingIntent = PendingIntent.getActivity(
+ mActivity,
+ title.hashCode() /* requestCode */,
+ new Intent("test action"),
+ 0 /* flags */);
+ final SliceAction action
+ = SliceAction.createDeeplink(pendingIntent, icon, ListBuilder.SMALL_IMAGE, title);
+ return new ListBuilder(mActivity, TEST_SLICE_URI, ListBuilder.INFINITY)
+ .addRow(new ListBuilder.RowBuilder()
+ .addEndItem(icon, ListBuilder.ICON_IMAGE)
+ .setTitle(title)
+ .setPrimaryAction(action))
+ .build();
+ }
+}
diff --git a/tests/robotests/src/com/android/settings/location/AppLocationPermissionPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/location/AppLocationPermissionPreferenceControllerTest.java
index 6379e44..bddd5fe 100644
--- a/tests/robotests/src/com/android/settings/location/AppLocationPermissionPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/location/AppLocationPermissionPreferenceControllerTest.java
@@ -3,10 +3,12 @@
import static com.google.common.truth.Truth.assertThat;
import android.content.Context;
+import android.location.LocationManager;
import android.provider.Settings;
import androidx.lifecycle.LifecycleOwner;
+import com.android.settings.R;
import com.android.settingslib.core.lifecycle.Lifecycle;
import org.junit.Before;
@@ -27,6 +29,7 @@
private LifecycleOwner mLifecycleOwner;
private Lifecycle mLifecycle;
+ private LocationManager mLocationManager;
@Before
public void setUp() {
@@ -35,6 +38,7 @@
mLifecycleOwner = () -> mLifecycle;
mLifecycle = new Lifecycle(mLifecycleOwner);
mController = new AppLocationPermissionPreferenceController(mContext, mLifecycle);
+ mLocationManager = (LocationManager) mContext.getSystemService(Context.LOCATION_SERVICE);
}
@Test
@@ -52,4 +56,40 @@
assertThat(mController.isAvailable()).isTrue();
}
+
+ @Test
+ public void getSummary_whenLocationIsOff_shouldReturnStringForOff() {
+ mLocationManager.setLocationEnabledForUser(false, android.os.Process.myUserHandle());
+
+ assertThat(mController.getSummary()).isEqualTo(
+ mContext.getString(R.string.location_app_permission_summary_location_off));
+ }
+
+ @Test
+ public void getSummary_whenLocationIsOn_shouldReturnLoadingString() {
+ mLocationManager.setLocationEnabledForUser(true, android.os.Process.myUserHandle());
+
+ assertThat(mController.getSummary()).isEqualTo(
+ mContext.getString(R.string.location_settings_loading_app_permission_stats));
+ }
+
+ @Test
+ public void getSummary_whenLocationAppCountIsOne_shouldShowSingularString() {
+ mLocationManager.setLocationEnabledForUser(true, android.os.Process.myUserHandle());
+ mController.mNumBackground = 1;
+ mController.mNumTotal = 1;
+
+ assertThat(mController.getSummary()).isEqualTo(mContext.getResources().getQuantityString(
+ R.plurals.location_app_permission_summary_location_on, 1, 1, 1));
+ }
+
+ @Test
+ public void getSummary_whenLocationAppCountIsGreaterThanOne_shouldShowPluralString() {
+ mLocationManager.setLocationEnabledForUser(true, android.os.Process.myUserHandle());
+ mController.mNumBackground = 5;
+ mController.mNumTotal = 10;
+
+ assertThat(mController.getSummary()).isEqualTo(mContext.getResources().getQuantityString(
+ R.plurals.location_app_permission_summary_location_on, 5, 5, 10));
+ }
}
diff --git a/tests/robotests/src/com/android/settings/location/RecentLocationAccessPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/location/RecentLocationAccessPreferenceControllerTest.java
new file mode 100644
index 0000000..3b33558
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/location/RecentLocationAccessPreferenceControllerTest.java
@@ -0,0 +1,145 @@
+/*
+ * 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.location;
+
+import static com.google.common.truth.Truth.assertThat;
+
+import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.spy;
+import static org.mockito.Mockito.when;
+
+import android.content.Context;
+import android.graphics.drawable.Drawable;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.widget.ImageView;
+import android.widget.TextView;
+
+import androidx.preference.PreferenceScreen;
+
+import com.android.settings.R;
+import com.android.settingslib.location.RecentLocationAccesses;
+import com.android.settingslib.widget.LayoutPreference;
+
+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;
+
+import java.util.ArrayList;
+import java.util.List;
+
+@RunWith(RobolectricTestRunner.class)
+public class RecentLocationAccessPreferenceControllerTest {
+ @Mock
+ private LayoutPreference mLayoutPreference;
+ @Mock
+ private PreferenceScreen mScreen;
+ @Mock
+ private RecentLocationAccesses mRecentLocationApps;
+
+ private Context mContext;
+ private RecentLocationAccessPreferenceController mController;
+ private View mAppEntitiesHeaderView;
+
+ @Before
+ public void setUp() {
+ MockitoAnnotations.initMocks(this);
+ mContext = spy(RuntimeEnvironment.application);
+ mController = spy(
+ new RecentLocationAccessPreferenceController(mContext, mRecentLocationApps));
+ final String key = mController.getPreferenceKey();
+ mAppEntitiesHeaderView = LayoutInflater.from(mContext).inflate(
+ R.layout.app_entities_header, null /* root */);
+ when(mScreen.findPreference(key)).thenReturn(mLayoutPreference);
+ when(mLayoutPreference.getKey()).thenReturn(key);
+ when(mLayoutPreference.getContext()).thenReturn(mContext);
+ when(mLayoutPreference.findViewById(R.id.app_entities_header)).thenReturn(
+ mAppEntitiesHeaderView);
+ }
+
+ /** Verifies the title text, details text are correct, and the click listener is set. */
+ @Test
+ public void updateState_whenAppListIsEmpty_shouldDisplayTitleTextAndDetailsText() {
+ doReturn(new ArrayList<>()).when(mRecentLocationApps).getAppListSorted();
+ mController.displayPreference(mScreen);
+ mController.updateState(mLayoutPreference);
+
+ final TextView title = mAppEntitiesHeaderView.findViewById(R.id.header_title);
+ assertThat(title.getText()).isEqualTo(
+ mContext.getText(R.string.location_category_recent_location_access));
+ final TextView details = mAppEntitiesHeaderView.findViewById(R.id.header_details);
+ assertThat(details.getText()).isEqualTo(
+ mContext.getText(R.string.location_recent_location_access_view_details));
+ assertThat(details.hasOnClickListeners()).isTrue();
+ }
+
+ @Test
+ public void updateState_whenAppListMoreThanThree_shouldDisplayTopThreeApps() {
+ final List<RecentLocationAccesses.Access> accesses = createMockAccesses(6);
+ doReturn(accesses).when(mRecentLocationApps).getAppListSorted();
+ mController.displayPreference(mScreen);
+ mController.updateState(mLayoutPreference);
+
+ // The widget can display the top 3 apps from the list when there're more than 3.
+ final View app1View = mAppEntitiesHeaderView.findViewById(R.id.app1_view);
+ final ImageView appIconView1 = app1View.findViewById(R.id.app_icon);
+ final TextView appTitle1 = app1View.findViewById(R.id.app_title);
+ final TextView appSummary1 = app1View.findViewById(R.id.app_summary);
+
+ assertThat(app1View.getVisibility()).isEqualTo(View.VISIBLE);
+ assertThat(appIconView1.getDrawable()).isNotNull();
+ assertThat(appTitle1.getText()).isEqualTo("appTitle0");
+ assertThat(appSummary1.getText()).isEqualTo("appSummary0");
+
+ final View app2View = mAppEntitiesHeaderView.findViewById(R.id.app2_view);
+ final ImageView appIconView2 = app2View.findViewById(R.id.app_icon);
+ final TextView appTitle2 = app2View.findViewById(R.id.app_title);
+ final TextView appSummary2 = app2View.findViewById(R.id.app_summary);
+
+ assertThat(app2View.getVisibility()).isEqualTo(View.VISIBLE);
+ assertThat(appIconView2.getDrawable()).isNotNull();
+ assertThat(appTitle2.getText()).isEqualTo("appTitle1");
+ assertThat(appSummary2.getText()).isEqualTo("appSummary1");
+
+ final View app3View = mAppEntitiesHeaderView.findViewById(R.id.app3_view);
+ final ImageView appIconView3 = app3View.findViewById(R.id.app_icon);
+ final TextView appTitle3 = app3View.findViewById(R.id.app_title);
+ final TextView appSummary3 = app3View.findViewById(R.id.app_summary);
+
+ assertThat(app3View.getVisibility()).isEqualTo(View.VISIBLE);
+ assertThat(appIconView3.getDrawable()).isNotNull();
+ assertThat(appTitle3.getText()).isEqualTo("appTitle2");
+ assertThat(appSummary3.getText()).isEqualTo("appSummary2");
+ }
+
+ private List<RecentLocationAccesses.Access> createMockAccesses(int count) {
+ final List<RecentLocationAccesses.Access> accesses = new ArrayList<>();
+ for (int i = 0; i < count; i++) {
+ final Drawable icon = mock(Drawable.class);
+ // Add mock accesses
+ final RecentLocationAccesses.Access access = new RecentLocationAccesses.Access(
+ "packageName", android.os.Process.myUserHandle(), icon,
+ "appTitle" + i, "appSummary" + i, 1000 - i);
+ accesses.add(access);
+ }
+ return accesses;
+ }
+}
diff --git a/tests/robotests/src/com/android/settings/network/telephony/WifiCallingPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/network/telephony/WifiCallingPreferenceControllerTest.java
index 452e9b1..c0b1dab 100644
--- a/tests/robotests/src/com/android/settings/network/telephony/WifiCallingPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/network/telephony/WifiCallingPreferenceControllerTest.java
@@ -32,6 +32,7 @@
import com.android.ims.ImsConfig;
import com.android.ims.ImsManager;
+import com.android.settings.core.BasePreferenceController;
import org.junit.Before;
import org.junit.Test;
@@ -109,4 +110,12 @@
assertThat(mPreferenceCategory.isVisible()).isFalse();
}
+
+ @Test
+ public void getAvailabilityStatus_noWiFiCalling_shouldReturnUnsupported() {
+ mController.init(SubscriptionManager.INVALID_SUBSCRIPTION_ID);
+
+ assertThat(mController.getAvailabilityStatus()).isEqualTo(
+ BasePreferenceController.UNSUPPORTED_ON_DEVICE);
+ }
}
diff --git a/tests/robotests/src/com/android/settings/nfc/AndroidBeamPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/nfc/AndroidBeamPreferenceControllerTest.java
index 8ed9dcc..cd70d66 100644
--- a/tests/robotests/src/com/android/settings/nfc/AndroidBeamPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/nfc/AndroidBeamPreferenceControllerTest.java
@@ -22,6 +22,7 @@
import static org.mockito.Mockito.when;
import android.content.Context;
+import android.content.pm.PackageManager;
import android.nfc.NfcAdapter;
import android.nfc.NfcManager;
import android.os.UserHandle;
@@ -57,6 +58,8 @@
private UserManager mUserManager;
@Mock
private PreferenceScreen mScreen;
+ @Mock
+ private PackageManager mPackageManager;
private RestrictedPreference mAndroidBeamPreference;
private AndroidBeamPreferenceController mAndroidBeamController;
@@ -78,6 +81,8 @@
mAndroidBeamPreference = new RestrictedPreference(RuntimeEnvironment.application);
when(mScreen.findPreference(mAndroidBeamController.getPreferenceKey())).thenReturn(
mAndroidBeamPreference);
+ when(mContext.getPackageManager()).thenReturn(mPackageManager);
+ when(mPackageManager.hasSystemFeature(PackageManager.FEATURE_NFC_BEAM)).thenReturn(true);
Settings.Global.putString(mContext.getContentResolver(),
Settings.Global.AIRPLANE_MODE_TOGGLEABLE_RADIOS,
@@ -95,6 +100,13 @@
}
@Test
+ public void isAvailable_noNfcFeature_shouldReturnFalse() {
+ when(mNfcAdapter.isEnabled()).thenReturn(true);
+ when(mPackageManager.hasSystemFeature(PackageManager.FEATURE_NFC_BEAM)).thenReturn(false);
+ assertThat(mAndroidBeamController.isAvailable()).isFalse();
+ }
+
+ @Test
public void isAvailable_noNfcAdapter_shouldReturnFalse() {
ReflectionHelpers.setField(mAndroidBeamController, "mNfcAdapter", null);
assertThat(mAndroidBeamController.isAvailable()).isFalse();
diff --git a/tests/robotests/src/com/android/settings/password/ChooseLockPatternTest.java b/tests/robotests/src/com/android/settings/password/ChooseLockPatternTest.java
index a6a6355..6b1029c 100644
--- a/tests/robotests/src/com/android/settings/password/ChooseLockPatternTest.java
+++ b/tests/robotests/src/com/android/settings/password/ChooseLockPatternTest.java
@@ -107,7 +107,7 @@
ChooseLockPatternFragment fragment = (ChooseLockPatternFragment)
activity.getSupportFragmentManager().findFragmentById(R.id.main_content);
- View iconView = fragment.getView().findViewById(R.id.suw_layout_icon);
+ View iconView = fragment.getView().findViewById(R.id.suc_layout_icon);
assertThat(iconView.getVisibility()).isEqualTo(View.GONE);
}
diff --git a/tests/robotests/src/com/android/settings/password/SetupChooseLockPasswordTest.java b/tests/robotests/src/com/android/settings/password/SetupChooseLockPasswordTest.java
index 0a08319..bee66cc 100644
--- a/tests/robotests/src/com/android/settings/password/SetupChooseLockPasswordTest.java
+++ b/tests/robotests/src/com/android/settings/password/SetupChooseLockPasswordTest.java
@@ -29,10 +29,13 @@
import com.android.settings.R;
import com.android.settings.password.ChooseLockGeneric.ChooseLockGenericFragment;
+import com.android.settings.password.ChooseLockPassword.ChooseLockPasswordFragment.Stage;
import com.android.settings.password.ChooseLockPassword.IntentBuilder;
import com.android.settings.password.SetupChooseLockPassword.SetupChooseLockPasswordFragment;
import com.android.settings.testutils.shadow.SettingsShadowResources;
+import com.android.settings.testutils.shadow.ShadowAlertDialogCompat;
import com.android.settings.testutils.shadow.ShadowUtils;
+import com.android.settings.widget.ScrollToParentEditText;
import org.junit.After;
import org.junit.Before;
@@ -51,7 +54,7 @@
import java.util.List;
@RunWith(RobolectricTestRunner.class)
-@Config(shadows = {SettingsShadowResources.class, ShadowUtils.class})
+@Config(shadows = {SettingsShadowResources.class, ShadowUtils.class, ShadowAlertDialogCompat.class})
public class SetupChooseLockPasswordTest {
@Before
@@ -130,6 +133,42 @@
.isEqualTo("bar");
}
+ @Test
+ public void createActivity_skipButtonInIntroductionStage_shouldBeVisible() {
+ SetupChooseLockPassword activity = createSetupChooseLockPassword();
+
+ Button skipButton = activity.findViewById(R.id.skip_button);
+ assertThat(skipButton).isNotNull();
+ assertThat(skipButton.getVisibility()).isEqualTo(View.VISIBLE);
+
+ skipButton.performClick();
+ AlertDialog chooserDialog = ShadowAlertDialogCompat.getLatestAlertDialog();
+ assertThat(chooserDialog).isNotNull();
+ }
+
+ @Test
+ public void createActivity_inputPasswordInConfirmStage_clearButtonShouldBeVisible() {
+ SetupChooseLockPassword activity = createSetupChooseLockPassword();
+
+ SetupChooseLockPasswordFragment fragment =
+ (SetupChooseLockPasswordFragment) activity.getSupportFragmentManager()
+ .findFragmentById(R.id.main_content);
+
+ ScrollToParentEditText passwordEntry = activity.findViewById(R.id.password_entry);
+ passwordEntry.setText("");
+ fragment.updateStage(Stage.NeedToConfirm);
+
+ Button skipButton = activity.findViewById(R.id.skip_button);
+ Button clearButton = activity.findViewById(R.id.clear_button);
+ assertThat(skipButton.getVisibility()).isEqualTo(View.GONE);
+ assertThat(clearButton.getVisibility()).isEqualTo(View.GONE);
+
+ passwordEntry.setText("1234");
+ fragment.updateUi();
+ assertThat(skipButton.getVisibility()).isEqualTo(View.GONE);
+ assertThat(clearButton.getVisibility()).isEqualTo(View.VISIBLE);
+ }
+
private SetupChooseLockPassword createSetupChooseLockPassword() {
final Intent intent =
SetupChooseLockPassword.modifyIntentForSetup(
diff --git a/tests/robotests/src/com/android/settings/password/SetupChooseLockPatternTest.java b/tests/robotests/src/com/android/settings/password/SetupChooseLockPatternTest.java
index 649a1ba..6b6c60e 100644
--- a/tests/robotests/src/com/android/settings/password/SetupChooseLockPatternTest.java
+++ b/tests/robotests/src/com/android/settings/password/SetupChooseLockPatternTest.java
@@ -164,6 +164,20 @@
assertThat(findFragment(mActivity).mChosenPattern).isNull();
}
+ @Test
+ public void createActivity_enterPattern_clearButtonShouldBeVisible() {
+ ChooseLockPatternFragment fragment = findFragment(mActivity);
+
+ Button skipButton = mActivity.findViewById(R.id.skip_button);
+ Button clearButton = mActivity.findViewById(R.id.footerLeftButton);
+ assertThat(skipButton.getVisibility()).isEqualTo(View.VISIBLE);
+ assertThat(clearButton.getVisibility()).isEqualTo(View.GONE);
+
+ enterPattern();
+ assertThat(skipButton.getVisibility()).isEqualTo(View.GONE);
+ assertThat(clearButton.getVisibility()).isEqualTo(View.VISIBLE);
+ }
+
private ChooseLockPatternFragment findFragment(FragmentActivity activity) {
return (ChooseLockPatternFragment)
activity.getSupportFragmentManager().findFragmentById(R.id.main_content);
diff --git a/tests/robotests/src/com/android/settings/slices/SliceBuilderUtilsTest.java b/tests/robotests/src/com/android/settings/slices/SliceBuilderUtilsTest.java
index 2d893a6..c2d1e93 100644
--- a/tests/robotests/src/com/android/settings/slices/SliceBuilderUtilsTest.java
+++ b/tests/robotests/src/com/android/settings/slices/SliceBuilderUtilsTest.java
@@ -449,7 +449,7 @@
R.drawable.ic_settings).toIcon().getResId();
final SliceData data = getDummyData(FakeUnavailablePreferenceController.class,
SUMMARY, SliceData.SliceType.SWITCH, SCREEN_TITLE, 0 /* icon */,
- IS_DYNAMIC_SUMMARY_ALLOWED);
+ IS_DYNAMIC_SUMMARY_ALLOWED, null /* unavailableSliceSubtitle */);
Settings.Global.putInt(mContext.getContentResolver(),
FakeUnavailablePreferenceController.AVAILABILITY_KEY,
BasePreferenceController.DISABLED_DEPENDENT_SETTING);
@@ -518,33 +518,65 @@
assertThat(actualIconResource).isEqualTo(settingsIcon);
}
+ @Test
+ public void buildUnavailableSlice_customizeSubtitle_returnsSliceWithCustomizedSubtitle() {
+ final String subtitleOfUnavailableSlice = "subtitleOfUnavailableSlice";
+ final SliceData data = getDummyData(FakeUnavailablePreferenceController.class,
+ SUMMARY, SliceData.SliceType.SWITCH, SCREEN_TITLE, 0 /* icon */,
+ IS_DYNAMIC_SUMMARY_ALLOWED, subtitleOfUnavailableSlice);
+ Settings.Global.putInt(mContext.getContentResolver(),
+ FakeUnavailablePreferenceController.AVAILABILITY_KEY,
+ BasePreferenceController.DISABLED_DEPENDENT_SETTING);
+
+ final Slice slice = SliceBuilderUtils.buildSlice(mContext, data);
+
+ final SliceMetadata metadata = SliceMetadata.from(mContext, slice);
+ assertThat(metadata.getSubtitle()).isEqualTo(subtitleOfUnavailableSlice);
+ }
+
+ @Test
+ public void buildUnavailableSlice_notCustomizeSubtitle_returnsSliceWithDefaultSubtitle() {
+ final SliceData data = getDummyData(FakeUnavailablePreferenceController.class,
+ SliceData.SliceType.SWITCH);
+ Settings.Global.putInt(mContext.getContentResolver(),
+ FakeUnavailablePreferenceController.AVAILABILITY_KEY,
+ BasePreferenceController.DISABLED_DEPENDENT_SETTING);
+
+ final Slice slice = SliceBuilderUtils.buildSlice(mContext, data);
+
+ final SliceMetadata metadata = SliceMetadata.from(mContext, slice);
+ assertThat(metadata.getSubtitle()).isEqualTo(
+ mContext.getString(R.string.disabled_dependent_setting_summary));
+ }
+
private SliceData getDummyData() {
return getDummyData(TOGGLE_CONTROLLER, SUMMARY, SliceData.SliceType.SWITCH, SCREEN_TITLE,
- ICON, IS_DYNAMIC_SUMMARY_ALLOWED);
+ ICON, IS_DYNAMIC_SUMMARY_ALLOWED, null /* unavailableSliceSubtitle */);
}
private SliceData getDummyData(boolean isDynamicSummaryAllowed) {
return getDummyData(TOGGLE_CONTROLLER, SUMMARY, SliceData.SliceType.SWITCH, SCREEN_TITLE,
- ICON, isDynamicSummaryAllowed);
+ ICON, isDynamicSummaryAllowed, null /* unavailableSliceSubtitle */);
}
private SliceData getDummyData(Class prefController, int sliceType, int icon) {
- return getDummyData(TOGGLE_CONTROLLER, SUMMARY, SliceData.SliceType.SWITCH, SCREEN_TITLE,
- icon, IS_DYNAMIC_SUMMARY_ALLOWED);
+ return getDummyData(prefController, SUMMARY, sliceType, SCREEN_TITLE,
+ icon, IS_DYNAMIC_SUMMARY_ALLOWED, null /* unavailableSliceSubtitle */);
}
private SliceData getDummyData(String summary, String screenTitle) {
return getDummyData(TOGGLE_CONTROLLER, summary, SliceData.SliceType.SWITCH, screenTitle,
- ICON, IS_DYNAMIC_SUMMARY_ALLOWED);
+ ICON, IS_DYNAMIC_SUMMARY_ALLOWED, null /* unavailableSliceSubtitle */);
}
private SliceData getDummyData(Class prefController, int sliceType) {
return getDummyData(prefController, SUMMARY, sliceType, SCREEN_TITLE, ICON,
- IS_DYNAMIC_SUMMARY_ALLOWED);
+ IS_DYNAMIC_SUMMARY_ALLOWED, null /* unavailableSliceSubtitle */);
}
private SliceData getDummyData(Class prefController, String summary, int sliceType,
- String screenTitle, int icon, boolean isDynamicSummaryAllowed) {
+ String screenTitle, int icon, boolean isDynamicSummaryAllowed,
+ String unavailableSliceSubtitle) {
return new SliceData.Builder()
.setKey(KEY)
.setTitle(TITLE)
@@ -557,6 +589,7 @@
.setPreferenceControllerClassName(prefController.getName())
.setSliceType(sliceType)
.setDynamicSummaryAllowed(isDynamicSummaryAllowed)
+ .setUnavailableSliceSubtitle(unavailableSliceSubtitle)
.build();
}
}
diff --git a/tests/robotests/src/com/android/settings/slices/SliceDataConverterTest.java b/tests/robotests/src/com/android/settings/slices/SliceDataConverterTest.java
index b935e76..7c1319c 100644
--- a/tests/robotests/src/com/android/settings/slices/SliceDataConverterTest.java
+++ b/tests/robotests/src/com/android/settings/slices/SliceDataConverterTest.java
@@ -125,6 +125,8 @@
assertThat(fakeSlice.getSliceType()).isEqualTo(SliceData.SliceType.SLIDER);
assertThat(fakeSlice.isPlatformDefined()).isTrue(); // from XML
assertThat(fakeSlice.isDynamicSummaryAllowed()).isTrue(); // from XML
+ assertThat(fakeSlice.getUnavailableSliceSubtitle()).isEqualTo(
+ "subtitleOfUnavailableSlice"); // from XML
}
private void assertFakeA11ySlice(SliceData fakeSlice) {
diff --git a/tests/robotests/src/com/android/settings/slices/SliceDataTest.java b/tests/robotests/src/com/android/settings/slices/SliceDataTest.java
index 579af1f..b6c7af5 100644
--- a/tests/robotests/src/com/android/settings/slices/SliceDataTest.java
+++ b/tests/robotests/src/com/android/settings/slices/SliceDataTest.java
@@ -39,6 +39,7 @@
private final int SLICE_TYPE = SliceData.SliceType.SWITCH;
private final boolean IS_PLATFORM_DEFINED = true;
private final boolean IS_DYNAMIC_SUMMARY_ALLOWED = true;
+ private final String UNAVAILABLE_SLICE_SUBTITLE = "subtitleOfUnavailableSlice";
@Test
public void testBuilder_buildsMatchingObject() {
@@ -54,7 +55,8 @@
.setPreferenceControllerClassName(PREF_CONTROLLER)
.setSliceType(SLICE_TYPE)
.setPlatformDefined(IS_PLATFORM_DEFINED)
- .setDynamicSummaryAllowed(IS_DYNAMIC_SUMMARY_ALLOWED);
+ .setDynamicSummaryAllowed(IS_DYNAMIC_SUMMARY_ALLOWED)
+ .setUnavailableSliceSubtitle(UNAVAILABLE_SLICE_SUBTITLE);
SliceData data = builder.build();
@@ -70,6 +72,7 @@
assertThat(data.getSliceType()).isEqualTo(SLICE_TYPE);
assertThat(data.isPlatformDefined()).isEqualTo(IS_PLATFORM_DEFINED);
assertThat(data.isDynamicSummaryAllowed()).isEqualTo(IS_DYNAMIC_SUMMARY_ALLOWED);
+ assertThat(data.getUnavailableSliceSubtitle()).isEqualTo(UNAVAILABLE_SLICE_SUBTITLE);
}
@Test(expected = SliceData.InvalidSliceDataException.class)
diff --git a/tests/robotests/src/com/android/settings/slices/SlicesDatabaseAccessorTest.java b/tests/robotests/src/com/android/settings/slices/SlicesDatabaseAccessorTest.java
index f4b68a5..a657ede 100644
--- a/tests/robotests/src/com/android/settings/slices/SlicesDatabaseAccessorTest.java
+++ b/tests/robotests/src/com/android/settings/slices/SlicesDatabaseAccessorTest.java
@@ -109,12 +109,14 @@
assertThat(data.getUri()).isNull();
assertThat(data.getPreferenceController()).isEqualTo(FAKE_CONTROLLER_NAME);
assertThat(data.isDynamicSummaryAllowed()).isFalse(); /* default value */
+ assertThat(data.getUnavailableSliceSubtitle()).isNull();
}
@Test
public void testGetSliceDataFromKey_allowDynamicSummary_validSliceReturned() {
String key = "key";
- insertSpecialCase(key, true /* isPlatformSlice */, true /* isDynamicSummaryAllowed */);
+ insertSpecialCase(key, true /* isPlatformSlice */, true /* isDynamicSummaryAllowed */,
+ null /* customizedUnavailableSliceSubtitle */);
SliceData data = mAccessor.getSliceDataFromKey(key);
@@ -133,7 +135,8 @@
@Test
public void testGetSliceDataFromKey_doNotAllowDynamicSummary_validSliceReturned() {
String key = "key";
- insertSpecialCase(key, true /* isPlatformSlice */, false /* isDynamicSummaryAllowed */);
+ insertSpecialCase(key, true /* isPlatformSlice */, false /* isDynamicSummaryAllowed */,
+ null /* customizedUnavailableSliceSubtitle */);
SliceData data = mAccessor.getSliceDataFromKey(key);
@@ -243,16 +246,58 @@
assertThat(keys).isNotEmpty();
}
+ @Test
+ public void testGetSliceDataFromKey_defaultUnavailableSlice_validSliceReturned() {
+ String key = "key";
+ insertSpecialCase(key, true /* isPlatformSlice */, true /* isDynamicSummaryAllowed */,
+ null /* customizedUnavailableSliceSubtitle */);
+
+ SliceData data = mAccessor.getSliceDataFromKey(key);
+
+ assertThat(data.getKey()).isEqualTo(key);
+ assertThat(data.getTitle()).isEqualTo(FAKE_TITLE);
+ assertThat(data.getSummary()).isEqualTo(FAKE_SUMMARY);
+ assertThat(data.getScreenTitle()).isEqualTo(FAKE_SCREEN_TITLE);
+ assertThat(data.getKeywords()).isEqualTo(FAKE_KEYWORDS);
+ assertThat(data.getIconResource()).isEqualTo(FAKE_ICON);
+ assertThat(data.getFragmentClassName()).isEqualTo(FAKE_FRAGMENT_NAME);
+ assertThat(data.getUri()).isNull();
+ assertThat(data.getPreferenceController()).isEqualTo(FAKE_CONTROLLER_NAME);
+ assertThat(data.getUnavailableSliceSubtitle()).isNull();
+ }
+
+ @Test
+ public void testGetSliceDataFromKey_customizeSubtitleOfUnavailableSlice_validSliceReturned() {
+ String key = "key";
+ String subtitle = "subtitle";
+ insertSpecialCase(key, true /* isPlatformSlice */, true /* isDynamicSummaryAllowed */,
+ subtitle);
+
+ SliceData data = mAccessor.getSliceDataFromKey(key);
+
+ assertThat(data.getKey()).isEqualTo(key);
+ assertThat(data.getTitle()).isEqualTo(FAKE_TITLE);
+ assertThat(data.getSummary()).isEqualTo(FAKE_SUMMARY);
+ assertThat(data.getScreenTitle()).isEqualTo(FAKE_SCREEN_TITLE);
+ assertThat(data.getKeywords()).isEqualTo(FAKE_KEYWORDS);
+ assertThat(data.getIconResource()).isEqualTo(FAKE_ICON);
+ assertThat(data.getFragmentClassName()).isEqualTo(FAKE_FRAGMENT_NAME);
+ assertThat(data.getUri()).isNull();
+ assertThat(data.getPreferenceController()).isEqualTo(FAKE_CONTROLLER_NAME);
+ assertThat(data.getUnavailableSliceSubtitle()).isEqualTo(subtitle);
+ }
+
private void insertSpecialCase(String key) {
insertSpecialCase(key, true);
}
private void insertSpecialCase(String key, boolean isPlatformSlice) {
- insertSpecialCase(key, isPlatformSlice, false /* isDynamicSummaryAllowed */);
+ insertSpecialCase(key, isPlatformSlice, false /* isDynamicSummaryAllowed */,
+ null /*customizedUnavailableSliceSubtitle*/);
}
private void insertSpecialCase(String key, boolean isPlatformSlice,
- boolean isDynamicSummaryAllowed) {
+ boolean isDynamicSummaryAllowed, String customizedUnavailableSliceSubtitle) {
ContentValues values = new ContentValues();
values.put(SlicesDatabaseHelper.IndexColumns.KEY, key);
values.put(SlicesDatabaseHelper.IndexColumns.TITLE, FAKE_TITLE);
@@ -266,6 +311,8 @@
values.put(SlicesDatabaseHelper.IndexColumns.ALLOW_DYNAMIC_SUMMARY_IN_SLICE,
isDynamicSummaryAllowed);
values.put(SlicesDatabaseHelper.IndexColumns.SLICE_TYPE, SliceData.SliceType.INTENT);
+ values.put(SlicesDatabaseHelper.IndexColumns.UNAVAILABLE_SLICE_SUBTITLE,
+ customizedUnavailableSliceSubtitle);
mDb.replaceOrThrow(SlicesDatabaseHelper.Tables.TABLE_SLICES_INDEX, null, values);
}
diff --git a/tests/robotests/src/com/android/settings/slices/SlicesDatabaseHelperTest.java b/tests/robotests/src/com/android/settings/slices/SlicesDatabaseHelperTest.java
index 2bc3443..0e92c05 100644
--- a/tests/robotests/src/com/android/settings/slices/SlicesDatabaseHelperTest.java
+++ b/tests/robotests/src/com/android/settings/slices/SlicesDatabaseHelperTest.java
@@ -74,6 +74,7 @@
IndexColumns.PLATFORM_SLICE,
IndexColumns.SLICE_TYPE,
IndexColumns.ALLOW_DYNAMIC_SUMMARY_IN_SLICE,
+ IndexColumns.UNAVAILABLE_SLICE_SUBTITLE,
};
assertThat(columnNames).isEqualTo(expectedNames);
diff --git a/tests/robotests/src/com/android/settings/slices/SlicesIndexerTest.java b/tests/robotests/src/com/android/settings/slices/SlicesIndexerTest.java
index 827c3f6..b63dfd9 100644
--- a/tests/robotests/src/com/android/settings/slices/SlicesIndexerTest.java
+++ b/tests/robotests/src/com/android/settings/slices/SlicesIndexerTest.java
@@ -55,6 +55,7 @@
private final boolean PLATFORM_DEFINED = true;
private final boolean IS_DYNAMIC_SUMMARY_ALLOWED = true;
private final int SLICE_TYPE = SliceData.SliceType.SLIDER;
+ private final String UNAVAILABLE_SLICE_SUBTITLE = "subtitleOfUnavailableSlice";
private Context mContext;
@@ -145,6 +146,9 @@
cursor.getColumnIndex(
IndexColumns.ALLOW_DYNAMIC_SUMMARY_IN_SLICE)))
.isEqualTo(1 /* true */);
+ assertThat(cursor.getString(
+ cursor.getColumnIndex(IndexColumns.UNAVAILABLE_SLICE_SUBTITLE)))
+ .isEqualTo(UNAVAILABLE_SLICE_SUBTITLE);
cursor.moveToNext();
}
} finally {
@@ -179,7 +183,8 @@
.setPreferenceControllerClassName(PREF_CONTROLLER)
.setPlatformDefined(PLATFORM_DEFINED)
.setSliceType(SLICE_TYPE)
- .setDynamicSummaryAllowed(IS_DYNAMIC_SUMMARY_ALLOWED);
+ .setDynamicSummaryAllowed(IS_DYNAMIC_SUMMARY_ALLOWED)
+ .setUnavailableSliceSubtitle(UNAVAILABLE_SLICE_SUBTITLE);
for (int i = 0; i < KEYS.length; i++) {
builder.setKey(KEYS[i]).setTitle(TITLES[i]);
diff --git a/tests/robotests/src/com/android/settings/widget/UpdatableListPreferenceDialogFragmentTest.java b/tests/robotests/src/com/android/settings/widget/UpdatableListPreferenceDialogFragmentTest.java
index 029de61..a2e9de7 100644
--- a/tests/robotests/src/com/android/settings/widget/UpdatableListPreferenceDialogFragmentTest.java
+++ b/tests/robotests/src/com/android/settings/widget/UpdatableListPreferenceDialogFragmentTest.java
@@ -18,7 +18,9 @@
import static com.google.common.truth.Truth.assertThat;
+import static org.mockito.Mockito.never;
import static org.mockito.Mockito.spy;
+import static org.mockito.Mockito.verify;
import android.content.Context;
import android.widget.ArrayAdapter;
@@ -31,6 +33,7 @@
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;
@@ -42,9 +45,10 @@
@Config(shadows = ShadowBluetoothUtils.class)
public class UpdatableListPreferenceDialogFragmentTest {
- private Context mContext;
- private UpdatableListPreferenceDialogFragment mUpdatableListPrefDlgFragment;
private static final String KEY = "Test_Key";
+ @Mock
+ private UpdatableListPreferenceDialogFragment mUpdatableListPrefDlgFragment;
+ private Context mContext;
private ArrayAdapter mAdapter;
private ArrayList<CharSequence> mEntries;
@@ -53,8 +57,8 @@
MockitoAnnotations.initMocks(this);
mContext = RuntimeEnvironment.application;
- mUpdatableListPrefDlgFragment = UpdatableListPreferenceDialogFragment
- .newInstance(KEY, MetricsProto.MetricsEvent.DIALOG_SWITCH_A2DP_DEVICES);
+ mUpdatableListPrefDlgFragment = spy(UpdatableListPreferenceDialogFragment
+ .newInstance(KEY, MetricsProto.MetricsEvent.DIALOG_SWITCH_A2DP_DEVICES));
mEntries = spy(new ArrayList<>());
mUpdatableListPrefDlgFragment.setEntries(mEntries);
mUpdatableListPrefDlgFragment.
@@ -87,4 +91,11 @@
assertThat(mUpdatableListPrefDlgFragment.getAdapter().getCount()).isEqualTo(2);
}
+
+ @Test
+ public void onDialogClosed_emptyPreference() {
+ mUpdatableListPrefDlgFragment.onDialogClosed(false);
+
+ verify(mUpdatableListPrefDlgFragment, never()).getListPreference();
+ }
}
\ No newline at end of file
diff --git a/tests/robotests/src/com/android/settings/widget/VideoPreferenceTest.java b/tests/robotests/src/com/android/settings/widget/VideoPreferenceTest.java
index 396b9df..4cd6be4 100644
--- a/tests/robotests/src/com/android/settings/widget/VideoPreferenceTest.java
+++ b/tests/robotests/src/com/android/settings/widget/VideoPreferenceTest.java
@@ -92,4 +92,13 @@
verify(mMediaPlayer, never()).start();
}
+
+ @Test
+ public void onViewInvisible_shouldReleaseMediaplayer() {
+ mVideoPreference.onViewVisible(false);
+
+ mVideoPreference.onViewInvisible();
+
+ verify(mMediaPlayer).release();
+ }
}
diff --git a/tests/robotests/src/com/android/settings/wifi/NetworkRequestDialogFragmentTest.java b/tests/robotests/src/com/android/settings/wifi/NetworkRequestDialogFragmentTest.java
index e64fae7..17516e9 100644
--- a/tests/robotests/src/com/android/settings/wifi/NetworkRequestDialogFragmentTest.java
+++ b/tests/robotests/src/com/android/settings/wifi/NetworkRequestDialogFragmentTest.java
@@ -111,14 +111,17 @@
ShadowLooper.getShadowMainLooper().runToEndOfTasks();
assertThat(fakeFragment.bCalledStopAndPop).isTrue();
+ assertThat(fakeFragment.errorType).isEqualTo(ERROR_DIALOG_TYPE.TIME_OUT);
}
class FakeNetworkRequestDialogFragment extends NetworkRequestDialogFragment {
boolean bCalledStopAndPop = false;
+ ERROR_DIALOG_TYPE errorType = null;
@Override
- public void stopScanningAndPopErrorDialog(ERROR_DIALOG_TYPE type) {
+ public void stopScanningAndMaybePopErrorDialog(ERROR_DIALOG_TYPE type) {
bCalledStopAndPop = true;
+ errorType = type;
}
}
@@ -150,22 +153,28 @@
@Test
public void updateAccessPointList_onUserSelectionConnectSuccess_shouldCloseTheDialog() {
- List<AccessPoint> accessPointList = createAccessPointList();
- when(networkRequestDialogFragment.getAccessPointList()).thenReturn(accessPointList);
- networkRequestDialogFragment.show(mActivity.getSupportFragmentManager(), null);
- AlertDialog alertDialog = ShadowAlertDialogCompat.getLatestAlertDialog();
- assertThat(alertDialog.isShowing()).isTrue();
+ // Assert
+ FakeNetworkRequestDialogFragment fakeFragment = new FakeNetworkRequestDialogFragment();
+ FakeNetworkRequestDialogFragment spyFakeFragment = spy(fakeFragment);
- // Test if config would update list.
+ List<AccessPoint> accessPointList = createAccessPointList();
+ when(spyFakeFragment.getAccessPointList()).thenReturn(accessPointList);
+
+ spyFakeFragment.show(mActivity.getSupportFragmentManager(), null);
+
+ // Action
WifiConfiguration config = new WifiConfiguration();
config.SSID = "Test AP 3";
- networkRequestDialogFragment.onUserSelectionConnectSuccess(config);
+ spyFakeFragment.onUserSelectionConnectSuccess(config);
- assertThat(alertDialog.isShowing()).isFalse();
+ // Check
+ ShadowLooper.getShadowMainLooper().runToEndOfTasks();
+ assertThat(fakeFragment.bCalledStopAndPop).isTrue();
+ assertThat(fakeFragment.errorType).isNull();
}
@Test
- public void updateAccessPointList_onUserSelectionConnectFailure_shouldCallTimeoutDialog() {
+ public void updateAccessPointList_onUserSelectionConnectFailure_shouldCallAbortDialog() {
FakeNetworkRequestDialogFragment fakeFragment = new FakeNetworkRequestDialogFragment();
FakeNetworkRequestDialogFragment spyFakeFragment = spy(fakeFragment);
List<AccessPoint> accessPointList = createAccessPointList();
@@ -181,6 +190,7 @@
fakeFragment.onUserSelectionConnectFailure(config);
assertThat(fakeFragment.bCalledStopAndPop).isTrue();
+ assertThat(fakeFragment.errorType).isEqualTo(ERROR_DIALOG_TYPE.ABORT);
}
@Test
diff --git a/tests/uitests/src/com/android/settings/ui/StorageWizardTest.java b/tests/uitests/src/com/android/settings/ui/StorageWizardTest.java
index d47cd0d..eefd1eb 100644
--- a/tests/uitests/src/com/android/settings/ui/StorageWizardTest.java
+++ b/tests/uitests/src/com/android/settings/ui/StorageWizardTest.java
@@ -86,7 +86,7 @@
InstrumentationRegistry.getContext().startActivity(buildInitIntent());
// Activity: pick option to use as internal
- waitFor(By.res(PACKAGE, "suw_layout_title").text(containsIgnoringCase("How will you use")));
+ waitFor(By.res(PACKAGE, "suc_layout_title").text(containsIgnoringCase("How will you use")));
waitFor(By.res(PACKAGE, "storage_wizard_init_internal")).click();
// Dialog: acknowledge that we're formatting the card
@@ -94,15 +94,15 @@
waitFor(By.clickable(true).text(containsIgnoringCase("Format"))).click();
// Activity: ack storage device is slow
- waitForLong(By.res(PACKAGE, "suw_layout_title").textContains("Slow"));
+ waitForLong(By.res(PACKAGE, "suc_layout_title").textContains("Slow"));
waitFor(By.res(PACKAGE, "storage_next_button")).click();
// Activity: choose to move content
- waitForLong(By.res(PACKAGE, "suw_layout_title").textContains("Move content"));
+ waitForLong(By.res(PACKAGE, "suc_layout_title").textContains("Move content"));
waitFor(By.res(PACKAGE, "storage_next_button")).click();
// Activity: yay, we're done!
- waitForLong(By.res(PACKAGE, "suw_layout_title").textContains("ready to use"));
+ waitForLong(By.res(PACKAGE, "suc_layout_title").textContains("ready to use"));
waitFor(By.res(PACKAGE, "storage_next_button")).click();
}
@@ -114,11 +114,11 @@
InstrumentationRegistry.getContext().startActivity(buildInitIntent());
// Activity: pick option to use as external
- waitFor(By.res(PACKAGE, "suw_layout_title").textContains("How will you use"));
+ waitFor(By.res(PACKAGE, "suc_layout_title").textContains("How will you use"));
waitFor(By.res(PACKAGE, "storage_wizard_init_external")).click();
// Activity: yay, we're done!
- waitFor(By.res(PACKAGE, "suw_layout_title").textContains("ready to use"));
+ waitFor(By.res(PACKAGE, "suc_layout_title").textContains("ready to use"));
waitFor(By.res(PACKAGE, "storage_next_button")).click();
}
diff --git a/tests/unit/src/com/android/settings/wifi/dpp/WifiDppConfiguratorActivityTest.java b/tests/unit/src/com/android/settings/wifi/dpp/WifiDppConfiguratorActivityTest.java
index 61033e9..215b7e2 100644
--- a/tests/unit/src/com/android/settings/wifi/dpp/WifiDppConfiguratorActivityTest.java
+++ b/tests/unit/src/com/android/settings/wifi/dpp/WifiDppConfiguratorActivityTest.java
@@ -19,6 +19,7 @@
import static com.google.common.truth.Truth.assertThat;
import android.content.Intent;
+import android.content.pm.ActivityInfo;
import androidx.test.rule.ActivityTestRule;
import androidx.test.runner.AndroidJUnit4;
@@ -29,6 +30,10 @@
@RunWith(AndroidJUnit4.class)
public class WifiDppConfiguratorActivityTest {
+ // Valid Wi-Fi DPP QR code & it's parameters
+ private static final String VALID_WIFI_DPP_QR_CODE = "DPP:I:SN=4774LH2b4044;M:010203040506;K:"
+ + "MDkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDIgADURzxmttZoIRIPWGoQMV00XHWCAQIhXruVWOz0NjlkIA=;;";
+
@Rule
public final ActivityTestRule<WifiDppConfiguratorActivity> mActivityRule =
new ActivityTestRule<>(WifiDppConfiguratorActivity.class);
@@ -38,6 +43,7 @@
Intent intent = new Intent(WifiDppConfiguratorActivity.ACTION_CONFIGURATOR_QR_CODE_SCANNER);
intent.putExtra(WifiDppUtils.EXTRA_WIFI_SECURITY, "WEP");
intent.putExtra(WifiDppUtils.EXTRA_WIFI_SSID, "GoogleGuest");
+ intent.putExtra(WifiDppUtils.EXTRA_WIFI_PRE_SHARED_KEY, "password");
mActivityRule.launchActivity(intent);
@@ -50,6 +56,7 @@
WifiDppConfiguratorActivity.ACTION_CONFIGURATOR_QR_CODE_GENERATOR);
intent.putExtra(WifiDppUtils.EXTRA_WIFI_SECURITY, "WEP");
intent.putExtra(WifiDppUtils.EXTRA_WIFI_SSID, "GoogleGuest");
+ intent.putExtra(WifiDppUtils.EXTRA_WIFI_PRE_SHARED_KEY, "password");
mActivityRule.launchActivity(intent);
@@ -59,7 +66,8 @@
@Test
public void launchActivity_chooseSavedWifiNetwork_shouldNotAutoFinish() {
Intent intent = new Intent(
- WifiDppConfiguratorActivity.ACTION_CONFIGURATOR_CHOOSE_SAVED_WIFI_NETWORK);
+ WifiDppConfiguratorActivity.ACTION_PROCESS_WIFI_DPP_QR_CODE);
+ intent.putExtra(WifiDppUtils.EXTRA_QR_CODE, VALID_WIFI_DPP_QR_CODE);
mActivityRule.launchActivity(intent);
@@ -96,4 +104,59 @@
assertThat(activity instanceof WifiDppQrCodeScannerFragment
.OnScanZxingWifiFormatSuccessListener).isEqualTo(true);
}
+
+ @Test
+ public void testActivity_shouldImplementsOnClickChooseDifferentNetworkCallback() {
+ WifiDppConfiguratorActivity activity = mActivityRule.getActivity();
+
+ assertThat(activity instanceof WifiDppAddDeviceFragment
+ .OnClickChooseDifferentNetworkListener).isEqualTo(true);
+ }
+
+ @Test
+ public void rotateScreen_shouldGetCorrectWifiDppQrCode() {
+ WifiQrCode wifiQrCode = new WifiQrCode(VALID_WIFI_DPP_QR_CODE);
+ Intent intent = new Intent(WifiDppConfiguratorActivity.ACTION_CONFIGURATOR_QR_CODE_SCANNER);
+ intent.putExtra(WifiDppUtils.EXTRA_WIFI_SECURITY, "WEP");
+ intent.putExtra(WifiDppUtils.EXTRA_WIFI_SSID, "GoogleGuest");
+ intent.putExtra(WifiDppUtils.EXTRA_WIFI_PRE_SHARED_KEY, "password");
+
+ // setWifiDppQrCode and check if getWifiDppQrCode correctly after rotation
+ mActivityRule.launchActivity(intent);
+ mActivityRule.getActivity().setWifiDppQrCode(wifiQrCode);
+ mActivityRule.getActivity().setRequestedOrientation(
+ ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
+ mActivityRule.getActivity().setRequestedOrientation(
+ ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
+ WifiQrCode restoredWifiDppQrCode = mActivityRule.getActivity().getWifiDppQrCode();
+
+ assertThat(restoredWifiDppQrCode).isNotNull();
+ assertThat(restoredWifiDppQrCode.getQrCode()).isEqualTo(VALID_WIFI_DPP_QR_CODE);
+ }
+
+ @Test
+ public void rotateScreen_shouldGetCorrectWifiNetworkConfig() {
+ WifiNetworkConfig wifiNetworkConfig = new WifiNetworkConfig("WPA", "WifiSsid", "password",
+ /* hiddenSsid */ false, /* networkId */ 0);
+ Intent intent = new Intent(
+ WifiDppConfiguratorActivity.ACTION_PROCESS_WIFI_DPP_QR_CODE);
+ intent.putExtra(WifiDppUtils.EXTRA_QR_CODE, VALID_WIFI_DPP_QR_CODE);
+
+ // setWifiNetworkConfig and check if getWifiNetworkConfig correctly after rotation
+ mActivityRule.launchActivity(intent);
+ mActivityRule.getActivity().setWifiNetworkConfig(wifiNetworkConfig);
+ mActivityRule.getActivity().setRequestedOrientation(
+ ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
+ mActivityRule.getActivity().setRequestedOrientation(
+ ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
+ WifiNetworkConfig restoredWifiNetworkConfig =
+ mActivityRule.getActivity().getWifiNetworkConfig();
+
+ assertThat(restoredWifiNetworkConfig).isNotNull();
+ assertThat(restoredWifiNetworkConfig.getSecurity()).isEqualTo("WPA");
+ assertThat(restoredWifiNetworkConfig.getSsid()).isEqualTo("WifiSsid");
+ assertThat(restoredWifiNetworkConfig.getPreSharedKey()).isEqualTo("password");
+ assertThat(restoredWifiNetworkConfig.getHiddenSsid()).isFalse();
+ assertThat(restoredWifiNetworkConfig.getNetworkId()).isEqualTo(0);
+ }
}