Merge "Fix no reaction when tapping permission dialog button in shortcut service page" into qt-dev
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index 8e62c45..ee93b5e 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -164,7 +164,8 @@
</receiver>
<activity android:name=".SubSettings"
- android:parentActivityName="Settings" />
+ android:parentActivityName="Settings"
+ android:theme="@style/Theme.SubSettings"/>
<activity android:name=".Settings$CreateShortcutActivity"
android:label="@string/settings_shortcut">
@@ -1447,6 +1448,16 @@
<action android:name="android.settings.ACCESSIBILITY_SETTINGS_FOR_SUW" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
+ <meta-data android:name="com.android.settings.FRAGMENT_CLASS"
+ android:value="com.android.settings.accessibility.AccessibilitySettingsForSetupWizard" />
+ <meta-data android:name="com.android.settings.PRIMARY_PROFILE_CONTROLLED"
+ android:value="true" />
+ </activity>
+
+ <activity-alias
+ android:name=".FontSizeSettingsForSetupWizardActivity"
+ android:exported="true"
+ android:targetActivity=".accessibility.AccessibilitySettingsForSetupWizardActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="com.android.settings.suggested.category.DISPLAY_SETTINGS" />
@@ -1457,9 +1468,7 @@
android:value="true" />
<meta-data android:name="com.android.settings.FRAGMENT_CLASS"
android:value="com.android.settings.accessibility.AccessibilitySettingsForSetupWizard" />
- <meta-data android:name="com.android.settings.PRIMARY_PROFILE_CONTROLLED"
- android:value="true" />
- </activity>
+ </activity-alias>
<activity
android:name="Settings$AccessibilityDaltonizerSettingsActivity"
@@ -2705,10 +2714,8 @@
</intent-filter>
</activity>
- <activity
+ <receiver
android:name=".wifi.slice.ConnectToWifiHandler"
- android:theme="@android:style/Theme.NoDisplay"
- android:excludeFromRecents="true"
android:exported="false" />
<activity
diff --git a/color-check-baseline.xml b/color-check-baseline.xml
index 1031071..41cb12d 100644
--- a/color-check-baseline.xml
+++ b/color-check-baseline.xml
@@ -133,12 +133,12 @@
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="switchbar_switch_track_tint">#82000000</color>"
- errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
+ errorLine1=" <color name="switchbar_switch_track_tint">#82000000</color>"
+ errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
<location
file="res/values-night/colors.xml"
line="18"
- column="3"/>
+ column="5"/>
</issue>
<issue
@@ -165,12 +165,12 @@
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_accessibility_background">#783BE5</color>"
- errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
+ errorLine1=" <color name="homepage_accessibility_background">#783BE5</color>"
+ errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
<location
file="res/values-night/colors.xml"
line="20"
- column="3"/>
+ column="5"/>
</issue>
<issue
@@ -197,12 +197,12 @@
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_support_background">#3F5FBD</color>"
- errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
+ errorLine1=" <color name="homepage_support_background">#3F5FBD</color>"
+ errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
<location
file="res/values-night/colors.xml"
line="21"
- column="3"/>
+ column="5"/>
</issue>
<issue
@@ -245,22 +245,6 @@
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="23"
- 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="divider_color">#20ffffff</color>"
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
<location
@@ -277,11 +261,43 @@
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="notification_importance_button_selected">#AECBFA</color> <!-- material blue 200 -->"
+ errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
+ <location
+ file="res/values-night/colors.xml"
+ line="28"
+ 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="notification_importance_button_unselected">#5F6368</color>"
+ errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
+ <location
+ file="res/values-night/colors.xml"
+ line="29"
+ 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="setup_lock_pattern_view_success_color_dark">#ff84ffff</color>"
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
<location
file="res/values/colors.xml"
- line="27"
+ line="29"
column="5"/>
</issue>
@@ -297,7 +313,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
<location
file="res/values/colors.xml"
- line="29"
+ line="31"
column="5"/>
</issue>
@@ -309,27 +325,11 @@
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="notification_importance_button_selected">#AECBFA</color> <!-- material blue 200 -->"
- errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
- <location
- file="res/values-night/colors.xml"
- line="30"
- 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="setup_wizard_wifi_color_dark">#89ffffff</color>"
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
<location
file="res/values/colors.xml"
- line="30"
+ line="32"
column="5"/>
</issue>
@@ -341,27 +341,11 @@
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="notification_importance_button_unselected">#5F6368</color>"
- errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
- <location
- file="res/values-night/colors.xml"
- line="31"
- 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="setup_wizard_wifi_color_light">#89000000</color>"
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
<location
file="res/values/colors.xml"
- line="31"
+ line="33"
column="5"/>
</issue>
@@ -377,7 +361,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
<location
file="res/values/colors.xml"
- line="33"
+ line="35"
column="5"/>
</issue>
@@ -393,7 +377,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
<location
file="res/values/colors.xml"
- line="34"
+ line="36"
column="5"/>
</issue>
@@ -409,7 +393,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
<location
file="res/values/colors.xml"
- line="36"
+ line="38"
column="5"/>
</issue>
@@ -425,7 +409,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
<location
file="res/values/colors.xml"
- line="41"
+ line="43"
column="5"/>
</issue>
@@ -441,7 +425,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
<location
file="res/values/colors.xml"
- line="42"
+ line="44"
column="5"/>
</issue>
@@ -457,7 +441,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
<location
file="res/values/colors.xml"
- line="44"
+ line="46"
column="5"/>
</issue>
@@ -473,7 +457,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
<location
file="res/values/colors.xml"
- line="45"
+ line="47"
column="5"/>
</issue>
@@ -489,7 +473,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
<location
file="res/values/colors.xml"
- line="49"
+ line="51"
column="5"/>
</issue>
@@ -505,7 +489,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
<location
file="res/values/colors.xml"
- line="52"
+ line="54"
column="5"/>
</issue>
@@ -521,7 +505,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
<location
file="res/values/colors.xml"
- line="55"
+ line="57"
column="5"/>
</issue>
@@ -537,7 +521,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
<location
file="res/values/colors.xml"
- line="56"
+ line="58"
column="5"/>
</issue>
@@ -553,7 +537,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
<location
file="res/values/colors.xml"
- line="57"
+ line="59"
column="5"/>
</issue>
@@ -569,7 +553,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
<location
file="res/values/colors.xml"
- line="58"
+ line="60"
column="5"/>
</issue>
@@ -585,7 +569,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
<location
file="res/values/colors.xml"
- line="60"
+ line="62"
column="5"/>
</issue>
@@ -601,7 +585,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
<location
file="res/values/colors.xml"
- line="61"
+ line="63"
column="5"/>
</issue>
@@ -617,7 +601,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
<location
file="res/values/colors.xml"
- line="62"
+ line="64"
column="5"/>
</issue>
@@ -633,7 +617,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
<location
file="res/values/colors.xml"
- line="63"
+ line="65"
column="5"/>
</issue>
@@ -649,7 +633,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
<location
file="res/values/colors.xml"
- line="64"
+ line="66"
column="5"/>
</issue>
@@ -665,7 +649,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
<location
file="res/values/colors.xml"
- line="65"
+ line="67"
column="5"/>
</issue>
@@ -681,7 +665,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
<location
file="res/values/colors.xml"
- line="66"
+ line="68"
column="5"/>
</issue>
@@ -697,7 +681,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
<location
file="res/values/colors.xml"
- line="67"
+ line="69"
column="5"/>
</issue>
@@ -713,7 +697,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
<location
file="res/values/colors.xml"
- line="68"
+ line="70"
column="5"/>
</issue>
@@ -729,7 +713,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
<location
file="res/values/colors.xml"
- line="69"
+ line="71"
column="5"/>
</issue>
@@ -745,7 +729,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
<location
file="res/values/colors.xml"
- line="71"
+ line="73"
column="5"/>
</issue>
@@ -761,7 +745,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
<location
file="res/values/colors.xml"
- line="74"
+ line="76"
column="5"/>
</issue>
@@ -777,7 +761,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
<location
file="res/values/colors.xml"
- line="77"
+ line="79"
column="5"/>
</issue>
@@ -793,7 +777,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
<location
file="res/values/colors.xml"
- line="80"
+ line="82"
column="5"/>
</issue>
@@ -809,7 +793,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
<location
file="res/values/colors.xml"
- line="83"
+ line="85"
column="5"/>
</issue>
@@ -825,7 +809,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
<location
file="res/values/colors.xml"
- line="84"
+ line="86"
column="5"/>
</issue>
@@ -841,7 +825,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
<location
file="res/values/colors.xml"
- line="85"
+ line="87"
column="5"/>
</issue>
@@ -857,7 +841,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
<location
file="res/values/colors.xml"
- line="86"
+ line="88"
column="5"/>
</issue>
@@ -873,7 +857,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
<location
file="res/values/colors.xml"
- line="87"
+ line="89"
column="5"/>
</issue>
@@ -889,7 +873,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
<location
file="res/values/colors.xml"
- line="88"
+ line="90"
column="5"/>
</issue>
@@ -905,7 +889,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
<location
file="res/values/colors.xml"
- line="89"
+ line="91"
column="5"/>
</issue>
@@ -921,7 +905,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
<location
file="res/values/colors.xml"
- line="90"
+ line="92"
column="5"/>
</issue>
@@ -937,7 +921,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
<location
file="res/values/colors.xml"
- line="91"
+ line="93"
column="5"/>
</issue>
@@ -953,7 +937,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
<location
file="res/values/colors.xml"
- line="92"
+ line="94"
column="5"/>
</issue>
@@ -969,7 +953,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
<location
file="res/values/colors.xml"
- line="93"
+ line="95"
column="5"/>
</issue>
@@ -985,7 +969,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
<location
file="res/values/colors.xml"
- line="94"
+ line="96"
column="5"/>
</issue>
@@ -1001,7 +985,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
<location
file="res/values/colors.xml"
- line="95"
+ line="97"
column="5"/>
</issue>
@@ -1017,7 +1001,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
<location
file="res/values/colors.xml"
- line="96"
+ line="98"
column="5"/>
</issue>
@@ -1033,7 +1017,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
<location
file="res/values/colors.xml"
- line="97"
+ line="99"
column="5"/>
</issue>
@@ -1049,7 +1033,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
<location
file="res/values/colors.xml"
- line="98"
+ line="100"
column="5"/>
</issue>
@@ -1065,7 +1049,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
<location
file="res/values/colors.xml"
- line="100"
+ line="102"
column="5"/>
</issue>
@@ -1081,7 +1065,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
<location
file="res/values/colors.xml"
- line="106"
+ line="108"
column="5"/>
</issue>
@@ -1097,7 +1081,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
<location
file="res/values/colors.xml"
- line="111"
+ line="113"
column="5"/>
</issue>
@@ -1113,7 +1097,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
<location
file="res/values/colors.xml"
- line="112"
+ line="114"
column="5"/>
</issue>
@@ -1129,7 +1113,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
<location
file="res/values/colors.xml"
- line="113"
+ line="115"
column="5"/>
</issue>
@@ -1145,7 +1129,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
<location
file="res/values/colors.xml"
- line="114"
+ line="116"
column="5"/>
</issue>
@@ -1161,7 +1145,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
<location
file="res/values/colors.xml"
- line="115"
+ line="117"
column="5"/>
</issue>
@@ -1177,7 +1161,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
<location
file="res/values/colors.xml"
- line="116"
+ line="118"
column="5"/>
</issue>
@@ -1193,7 +1177,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
<location
file="res/values/colors.xml"
- line="119"
+ line="121"
column="5"/>
</issue>
@@ -1209,7 +1193,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
<location
file="res/values/colors.xml"
- line="120"
+ line="122"
column="5"/>
</issue>
@@ -1225,7 +1209,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
<location
file="res/values/colors.xml"
- line="121"
+ line="123"
column="5"/>
</issue>
@@ -1241,7 +1225,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
<location
file="res/values/colors.xml"
- line="122"
+ line="124"
column="5"/>
</issue>
@@ -1257,7 +1241,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
<location
file="res/values/colors.xml"
- line="123"
+ line="125"
column="5"/>
</issue>
@@ -1273,7 +1257,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
<location
file="res/values/colors.xml"
- line="126"
+ line="128"
column="5"/>
</issue>
@@ -1289,7 +1273,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
<location
file="res/values/colors.xml"
- line="127"
+ line="129"
column="5"/>
</issue>
@@ -1305,7 +1289,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
<location
file="res/values/colors.xml"
- line="128"
+ line="130"
column="5"/>
</issue>
@@ -1321,7 +1305,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
<location
file="res/values/colors.xml"
- line="129"
+ line="131"
column="5"/>
</issue>
@@ -1337,7 +1321,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
<location
file="res/values/colors.xml"
- line="130"
+ line="132"
column="5"/>
</issue>
@@ -1353,23 +1337,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
<location
file="res/values/colors.xml"
- line="131"
- 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="homepage_status_bar_color">#ccFFFFFF</color>"
- errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
- <location
- file="res/values/colors.xml"
- line="137"
+ line="133"
column="5"/>
</issue>
@@ -1385,7 +1353,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
<location
file="res/values/colors.xml"
- line="140"
+ line="139"
column="5"/>
</issue>
@@ -1401,7 +1369,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
<location
file="res/values/colors.xml"
- line="141"
+ line="140"
column="5"/>
</issue>
@@ -1417,7 +1385,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
<location
file="res/values/colors.xml"
- line="142"
+ line="141"
column="5"/>
</issue>
@@ -2617,7 +2585,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~~~~">
<location
file="res/values-en-rXC/strings.xml"
- line="2629"
+ line="2652"
column="169"/>
</issue>
@@ -2633,7 +2601,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~~~~">
<location
file="res/values-en-rAU/strings.xml"
- line="2632"
+ line="2653"
column="64"/>
</issue>
@@ -2649,7 +2617,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~~~~">
<location
file="res/values-en-rCA/strings.xml"
- line="2632"
+ line="2653"
column="64"/>
</issue>
@@ -2665,7 +2633,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~~~~">
<location
file="res/values-en-rGB/strings.xml"
- line="2632"
+ line="2653"
column="64"/>
</issue>
@@ -2681,7 +2649,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~~~~">
<location
file="res/values-en-rIN/strings.xml"
- line="2632"
+ line="2653"
column="64"/>
</issue>
@@ -2697,7 +2665,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~~~~">
<location
file="res/values/strings.xml"
- line="6134"
+ line="6186"
column="36"/>
</issue>
@@ -2793,7 +2761,7 @@
errorLine2=" ^">
<location
file="res/values/themes.xml"
- line="99"
+ line="103"
column="40"/>
</issue>
@@ -2809,7 +2777,7 @@
errorLine2=" ^">
<location
file="res/values/themes.xml"
- line="99"
+ line="103"
column="40"/>
</issue>
@@ -2825,7 +2793,7 @@
errorLine2=" ^">
<location
file="res/values/themes.xml"
- line="167"
+ line="171"
column="45"/>
</issue>
@@ -2841,7 +2809,7 @@
errorLine2=" ^">
<location
file="res/values/themes.xml"
- line="168"
+ line="172"
column="49"/>
</issue>
@@ -2857,7 +2825,7 @@
errorLine2=" ^">
<location
file="res/values/themes.xml"
- line="176"
+ line="180"
column="45"/>
</issue>
@@ -2873,7 +2841,7 @@
errorLine2=" ^">
<location
file="res/values/themes.xml"
- line="177"
+ line="181"
column="49"/>
</issue>
@@ -2885,6 +2853,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=" <item name="android:colorAccent">@color/material_blue_700</item>"
+ errorLine2=" ^">
+ <location
+ file="res/values/themes.xml"
+ line="249"
+ column="42"/>
+ </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=" <item name="wifi_signal_color">@color/setup_wizard_wifi_color_dark</item>"
errorLine2=" ^">
<location
diff --git a/res/drawable-nodpi/gesture_swipe_up.png b/res/drawable-nodpi/system_nav_2_button.png
similarity index 100%
rename from res/drawable-nodpi/gesture_swipe_up.png
rename to res/drawable-nodpi/system_nav_2_button.png
Binary files differ
diff --git a/res/drawable-nodpi/system_nav_3_button.png b/res/drawable-nodpi/system_nav_3_button.png
new file mode 100644
index 0000000..e78fc8b
--- /dev/null
+++ b/res/drawable-nodpi/system_nav_3_button.png
Binary files differ
diff --git a/res/drawable-nodpi/system_nav_fully_gestural.png b/res/drawable-nodpi/system_nav_fully_gestural.png
new file mode 100644
index 0000000..b301608
--- /dev/null
+++ b/res/drawable-nodpi/system_nav_fully_gestural.png
Binary files differ
diff --git a/res/drawable/ic_partial_system_update_current.xml b/res/drawable/ic_partial_system_update_current.xml
new file mode 100644
index 0000000..18be203
--- /dev/null
+++ b/res/drawable/ic_partial_system_update_current.xml
@@ -0,0 +1,24 @@
+<!--
+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.
+-->
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
+ android:width="24dp"
+ android:height="24dp"
+ android:viewportWidth="20.0"
+ android:viewportHeight="22.0">
+ <path
+ android:fillColor="#FF1E8E3E"
+ android:pathData="M15,17L5,17L5,14.33l1.59,1.58L8,14.5l-3,-3 -1,-1 -4,4 1.41,1.42L3,14.33L3,20a2.006,2.006 0,0 0,2 2L15,22a2.006,2.006 0,0 0,2 -2L17,13L15,13ZM15,20L5,20L5,19L15,19ZM5,5L15,5L15,7.67L13.41,6.09 12,7.5l4,4 4,-4L18.59,6.08 17,7.67L17,2a1.997,1.997 0,0 0,-2 -1.99L5,0A2.006,2.006 0,0 0,3 2v7L5,9ZM5,2L15,2L15,3L5,3Z"/>
+</vector>
diff --git a/res/drawable/ic_partial_system_update_stale.xml b/res/drawable/ic_partial_system_update_stale.xml
new file mode 100644
index 0000000..711be2c
--- /dev/null
+++ b/res/drawable/ic_partial_system_update_stale.xml
@@ -0,0 +1,24 @@
+<!--
+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.
+-->
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
+ android:width="24dp"
+ android:height="24dp"
+ android:viewportWidth="20.0"
+ android:viewportHeight="22.0">
+ <path
+ android:fillColor="#FFD93025"
+ android:pathData="M15,17L5,17L5,14.33l1.59,1.58L8,14.5l-3,-3 -1,-1 -4,4 1.41,1.42L3,14.33L3,20a2.006,2.006 0,0 0,2 2L15,22a2.006,2.006 0,0 0,2 -2L17,13L15,13ZM15,20L5,20L5,19L15,19ZM5,5L15,5L15,7.67L13.41,6.09 12,7.5l4,4 4,-4L18.59,6.08 17,7.67L17,2a1.997,1.997 0,0 0,-2 -1.99L5,0A2.006,2.006 0,0 0,3 2v7L5,9ZM5,2L15,2L15,3L5,3Z"/>
+</vector>
diff --git a/res/layout/captioning_preview.xml b/res/layout/captioning_preview.xml
index b90c3a5..d8d2e4f 100644
--- a/res/layout/captioning_preview.xml
+++ b/res/layout/captioning_preview.xml
@@ -15,41 +15,32 @@
limitations under the License.
-->
-<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+<FrameLayout
+ xmlns:android="http://schemas.android.com/apk/res/android"
+ android:id="@+id/preview_viewport"
+ android:clipToPadding="true"
+ android:clipChildren="true"
android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:orientation="vertical" >
+ android:layout_height="wrap_content">
+
+ <ImageView
+ android:layout_width="match_parent"
+ android:layout_height="@dimen/captioning_preview_height"
+ android:contentDescription="@null"
+ android:scaleType="centerCrop"
+ android:src="@drawable/caption_background"/>
<FrameLayout
- android:id="@+id/preview_viewport"
+ android:id="@+id/preview_window"
android:layout_width="match_parent"
- android:layout_height="@dimen/captioning_preview_height" >
+ android:layout_height="wrap_content"
+ android:layout_gravity="bottom|start"
+ android:padding="16dp">
- <ImageView
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:contentDescription="@null"
- android:scaleType="centerCrop"
- android:src="@drawable/caption_background" />
-
- <FrameLayout
- android:id="@+id/preview_window"
- android:layout_width="match_parent"
+ <com.android.internal.widget.SubtitleView
+ android:id="@+id/preview_text"
+ android:layout_width="wrap_content"
android:layout_height="wrap_content"
- android:layout_gravity="bottom|start"
- android:padding="16dp" >
-
- <com.android.internal.widget.SubtitleView
- android:id="@+id/preview_text"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="@string/captioning_preview_text" />
- </FrameLayout>
+ android:text="@string/captioning_preview_text"/>
</FrameLayout>
-
- <FrameLayout
- android:id="@+id/properties_fragment"
- android:layout_width="match_parent"
- android:layout_height="match_parent" />
-
-</LinearLayout>
+</FrameLayout>
diff --git a/res/layout/magnification_video_preference.xml b/res/layout/magnification_video_preference.xml
index fe7f26f..ff7089c 100644
--- a/res/layout/magnification_video_preference.xml
+++ b/res/layout/magnification_video_preference.xml
@@ -16,7 +16,9 @@
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
- android:layout_height="wrap_content">
+ android:layout_height="wrap_content"
+ android:clipChildren="true"
+ android:clipToPadding="true">
<ImageView
android:id="@+id/video_background"
diff --git a/res/layout/preference_list_fragment.xml b/res/layout/preference_list_fragment.xml
index 0fa5f9f..6dfc8a3 100644
--- a/res/layout/preference_list_fragment.xml
+++ b/res/layout/preference_list_fragment.xml
@@ -27,7 +27,9 @@
<FrameLayout android:id="@+id/pinned_header"
android:layout_width="match_parent"
android:layout_height="wrap_content"
- android:visibility="gone" />
+ android:background="?android:attr/windowBackground"
+ android:elevation="1dp"
+ android:visibility="gone"/>
<FrameLayout
android:id="@android:id/list_container"
diff --git a/res/layout/settings_base_layout.xml b/res/layout/settings_base_layout.xml
index 7216d76..f94d25d 100644
--- a/res/layout/settings_base_layout.xml
+++ b/res/layout/settings_base_layout.xml
@@ -19,6 +19,7 @@
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
+ android:fitsSystemWindows="true"
android:orientation="vertical">
<Toolbar
android:id="@+id/action_bar"
@@ -30,6 +31,5 @@
<FrameLayout
android:id="@+id/content_frame"
android:layout_width="match_parent"
- android:layout_height="fill_parent"
- android:background="?android:attr/windowBackground" />
+ android:layout_height="match_parent"/>
</LinearLayout>
diff --git a/res/layout/settings_main_prefs.xml b/res/layout/settings_main_prefs.xml
index c4c0af5..ea89006 100644
--- a/res/layout/settings_main_prefs.xml
+++ b/res/layout/settings_main_prefs.xml
@@ -22,23 +22,17 @@
android:layout_height="match_parent"
android:layout_width="match_parent">
- <LinearLayout
- android:orientation="vertical"
- android:layout_height="0px"
- android:layout_width="match_parent"
- android:layout_weight="1">
+ <com.android.settings.widget.SwitchBar
+ android:id="@+id/switch_bar"
+ android:layout_height="?android:attr/actionBarSize"
+ android:layout_width="match_parent"
+ android:theme="?attr/switchBarTheme"/>
- <com.android.settings.widget.SwitchBar android:id="@+id/switch_bar"
- android:layout_height="?android:attr/actionBarSize"
- android:layout_width="match_parent"
- android:theme="?attr/switchBarTheme" />
-
- <FrameLayout
- android:id="@+id/main_content"
- android:layout_width="match_parent"
- android:layout_height="match_parent" />
-
- </LinearLayout>
+ <FrameLayout
+ android:id="@+id/main_content"
+ android:layout_width="match_parent"
+ android:layout_height="0dp"
+ android:layout_weight="1"/>
<RelativeLayout android:id="@+id/button_bar"
android:layout_height="wrap_content"
@@ -51,7 +45,7 @@
android:layout_height="wrap_content"
android:layout_margin="5dip"
android:layout_alignParentStart="true"
- android:text="@*android:string/back_button_label" />
+ android:text="@*android:string/back_button_label"/>
<LinearLayout
android:orientation="horizontal"
@@ -64,13 +58,13 @@
android:layout_height="wrap_content"
android:layout_margin="5dip"
android:text="@*android:string/skip_button_label"
- android:visibility="gone" />
+ android:visibility="gone"/>
<Button android:id="@+id/next_button"
android:layout_width="150dip"
android:layout_height="wrap_content"
android:layout_margin="5dip"
- android:text="@*android:string/next_button_label" />
+ android:text="@*android:string/next_button_label"/>
</LinearLayout>
diff --git a/res/layout/wifi_dpp_qrcode_scanner_fragment.xml b/res/layout/wifi_dpp_qrcode_scanner_fragment.xml
index 9364071..1fc95e7 100644
--- a/res/layout/wifi_dpp_qrcode_scanner_fragment.xml
+++ b/res/layout/wifi_dpp_qrcode_scanner_fragment.xml
@@ -43,21 +43,18 @@
android:layout_marginBottom="8dp"
style="?android:attr/progressBarStyleHorizontal"/>
- <androidx.constraintlayout.widget.ConstraintLayout
- xmlns:app="http://schemas.android.com/apk/res-auto"
+ <FrameLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<TextureView
android:id="@+id/preview_view"
android:layout_width="match_parent"
- android:layout_height="0dp"
- app:layout_constraintDimensionRatio="1:1"/>
+ android:layout_height="@dimen/qrcode_preview_size"/>
<com.android.settings.wifi.qrcode.QrDecorateView
android:id="@+id/decorate_view"
android:layout_width="match_parent"
- android:layout_height="0dp"
- app:layout_constraintDimensionRatio="1:1"/>
- </androidx.constraintlayout.widget.ConstraintLayout>
+ android:layout_height="@dimen/qrcode_preview_size"/>
+ </FrameLayout>
<TextView
android:id="@+id/error_message"
diff --git a/res/raw/bubbles.mp4 b/res/raw/bubbles.mp4
deleted file mode 100644
index c68ea57..0000000
--- a/res/raw/bubbles.mp4
+++ /dev/null
Binary files differ
diff --git a/res/raw/gesture_swipe_up.mp4 b/res/raw/system_nav_2_button.mp4
similarity index 100%
rename from res/raw/gesture_swipe_up.mp4
rename to res/raw/system_nav_2_button.mp4
Binary files differ
diff --git a/res/raw/system_nav_3_button.mp4 b/res/raw/system_nav_3_button.mp4
new file mode 100644
index 0000000..86fb236
--- /dev/null
+++ b/res/raw/system_nav_3_button.mp4
Binary files differ
diff --git a/res/raw/system_nav_fully_gestural.mp4 b/res/raw/system_nav_fully_gestural.mp4
new file mode 100644
index 0000000..ae9c6d7
--- /dev/null
+++ b/res/raw/system_nav_fully_gestural.mp4
Binary files differ
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 1b24912..2f368e9 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -890,10 +890,14 @@
<string name="security_settings_face_preference_title">Face authentication</string>
<!-- Introduction title shown in face enrollment education screen [CHAR LIMIT=40] -->
<string name="security_settings_face_enroll_education_title">How to set up Face unlock</string>
- <!-- Introduction title shown in face enrollment education screen to show the face authentication feature, when face unlock is disabled by device admin [CHAR LIMIT=40] -->
+ <!-- Introduction title shown in face enrollment education screen for accessibility [CHAR LIMI=40]-->
+ <string name="security_settings_face_enroll_education_title_accessibility">Set up Face unlock</string>
+ <!-- Introduction title shown in face enrollment education screen to show the face authentication feature, when face unlock is disabled by device admin [CHAR LIMIT=60] -->
<string name="security_settings_face_enroll_education_title_unlock_disabled">Use your face to authenticate</string>
<!-- Introduction detail message shown in face education [CHAR LIMIT=NONE] -->
<string name="security_settings_face_enroll_education_message"></string>
+ <!-- Button that takes the user to the enrollment activity [CHAR LIMIT=20] -->
+ <string name="security_settings_face_enroll_education_start">Start</string>
<!-- Button shown which shows accessibility toggles for face enrollment when clicked. [CHAR LIMIT=32] -->
<string name="security_settings_face_enroll_introduction_accessibility">Use accessibility setup</string>
<!-- Additional details shown when the accessibility toggle is expanded. [CHAR LIMIT=NONE]-->
@@ -906,7 +910,7 @@
<string name="security_settings_face_enroll_introduction_cancel">Cancel</string>
<!-- Introduction title shown in face enrollment to introduce the face unlock feature [CHAR LIMIT=40] -->
<string name="security_settings_face_enroll_introduction_title">Unlock with your face</string>
- <!-- Introduction title shown in face enrollment to introduce the face authentication feature, when face unlock is disabled by device admin [CHAR LIMIT=40] -->
+ <!-- Introduction title shown in face enrollment to introduce the face authentication feature, when face unlock is disabled by device admin [CHAR LIMIT=60] -->
<string name="security_settings_face_enroll_introduction_title_unlock_disabled">Use your face to authenticate</string>
<!-- Introduction detail message shown in face enrollment dialog [CHAR LIMIT=NONE]-->
<string name="security_settings_face_enroll_introduction_message">Use your face to unlock your phone, authorize purchases, or sign in to apps.</string>
@@ -3847,6 +3851,13 @@
<!-- Ask user to connect to the internet [CHAR_ LIMIT=50]-->
<string name="mobile_connect_to_internet" translatable="true">Please connect to the internet</string>
+ <!-- Location settings screen, sub category for recent location requests [CHAR LIMIT=42] -->
+ <string name="location_category_recent_location_requests">Recent location requests</string>
+ <!-- Location settings screen, displayed when there're more than three recent location requests [CHAR LIMIT=30] -->
+ <string name="location_recent_location_requests_see_all">See all</string>
+ <!-- Location settings screen, sub category for location services [CHAR LIMIT=30] -->
+ <string name="location_category_location_services">Location services</string>
+
<!-- Security & location settings screen, section header for settings relating to location -->
<string name="location_title">My Location</string>
<!-- [CHAR LIMIT=30] Title for managed profile location switch -->
@@ -4806,7 +4817,7 @@
<!-- Title for the accessibility preference category of interaction control services and settings. [CHAR LIMIT=50] -->
<string name="interaction_control_category_title">Interaction controls</string>
<!-- Title for the accessibility preference category of services downloaded by the user. [CHAR LIMIT=50] -->
- <string name="user_installed_services_category_title">Downloaded services</string>
+ <string name="user_installed_services_category_title">Downloaded apps</string>
<!-- Title for the accessibility preference category of settings considered to be experimental, meaning they might be changed or removed in the future. [CHAR LIMIT=50] -->
<string name="experimental_category_title">Experimental</string>
<!-- Title for feature flags dashboard where developers can turn on experimental features [CHAR LIMIT=50] -->
@@ -4912,7 +4923,7 @@
<!-- Title for accessibility preference for configuring touch feedback vibrations. -->
<string name="accessibility_touch_vibration_title">Touch feedback</string>
<!-- Used in the acessibilty service settings to control turning on/off the service entirely -->
- <string name="accessibility_service_master_switch_title">Use service</string>
+ <string name="accessibility_service_master_switch_title">Use <xliff:g id="service" example="TalkBack">%1$s</xliff:g></string>
<!-- Used in the Color correction settings screen to control turning on/off the feature entirely -->
<string name="accessibility_daltonizer_master_switch_title">Use color correction</string>
<!-- Used in the Captions settings screen to control turning on/off the feature entirely -->
@@ -5138,7 +5149,7 @@
</string>
<!-- Title for the action perform in accessibility dialog. [CHAR LIMIT=NONE] -->
- <string name="accessibility_service_action_perform_title">View and platform actions</string>
+ <string name="accessibility_service_action_perform_title">View and perform actions</string>
<!-- Description for the action perform in accessibility dialog. [CHAR LIMIT=NONE] -->
<string name="accessibility_service_action_perform_description">It can track your interactions
@@ -7059,6 +7070,18 @@
<string name="mms_message_title">MMS messages</string>
<!-- Summary of multimedia messaging service settings. [CHAR LIMIT=100] -->
<string name="mms_message_summary">Send & receive when mobile data is off</string>
+
+ <!-- Title of a preference for whether to allow data during calls that is shown when mobile
+ data is turned off. This is needed for some multi-SIM scenarios, because the SIM that is
+ default for data might not be available during a phone call. [CHAR LIMIT=60] -->
+ <string name="data_during_calls_title">Data during calls</string>
+ <!-- Title of a preference for whether to allow data during calls that is shown when mobile
+ data is turned off. This is needed for some multi-SIM scenarios, because the SIM that is
+ default for data might not be available during a phone call. [CHAR LIMIT=NONE] -->
+ <string name="data_during_calls_summary">
+ Allow this SIM to be used for mobile data only during calls
+ </string>
+
<!-- Work SIM title. [CHAR LIMIT=50] -->
<string name="work_sim_title">Work SIM</string>
@@ -7891,8 +7914,8 @@
<!-- Configure Notifications: Title for the notification bubbles option. [CHAR LIMIT=60] -->
<string name="notification_bubbles_title">Bubbles</string>
- <!-- Configure Notifications: Summary for the notification bubbles option. [CHAR LIMIT=NONE] -->
- <string name="notification_bubbles_summary">Quickly access app content from anywhere using floating shortcuts</string>
+ <!-- Developer setting summary for bubbles [CHAR LIMIT=NONE] -->
+ <string name="notification_bubbles_developer_setting_summary">Some notifications can appear as bubbles on the screen</string>
<!-- Feature education for bubbles. [CHAR LIMIT=NONE] -->
<string name="bubbles_feature_education">Some notifications and other content can appear as bubbles on the screen. To open a bubble, tap it. To dismiss it, drag it down the screen.</string>
<!-- Title for the toggle shown on the app-level bubbles page [CHAR LIMIT=60] -->
@@ -10035,6 +10058,12 @@
<!-- [CHAR LIMIT=60] Name of setting that changes the UI to dark -->
<string name="dark_ui_mode">Dark Theme</string>
+ <!-- [CHAR LIMIT=60] Summary string on dark theme explaining why the toggle is disabled while the setting is still on-->
+ <string name="dark_ui_mode_disabled_summary_dark_theme_on">On / Temporarily disabled due to Battery Saver</string>
+
+ <!-- [CHAR LIMIT=60] Summary string on dark theme explaining why the toggle is disabled while the setting is off-->
+ <string name="dark_ui_mode_disabled_summary_dark_theme_off">Temporarily turned on due to Battery Saver</string>
+
<!-- [CHAR_LIMIT=NONE] Summary that is shown in the footer when dark mode is selected -->
<string name="dark_ui_settings_dark_summary">Supported apps will also switch to dark theme</string>
@@ -10134,11 +10163,11 @@
<!-- Title for settings suggestion for double twist for camera [CHAR LIMIT=60] -->
<string name="double_twist_for_camera_suggestion_title">Take selfies faster</string>
- <!-- Title text for system navigation [CHAR LIMIT=60] [DO NOT TRANSLATE] -->
- <string name="system_navigation_title" translatable="false">System navigation</string>
+ <!-- Title text for system navigation [CHAR LIMIT=60] -->
+ <string name="system_navigation_title">System navigation</string>
- <!-- Title text for swipe up to switch apps [CHAR LIMIT=60] [DO NOT TRANSLATE] -->
- <string name="swipe_up_to_switch_apps_title" translatable="false">2-button navigation</string>
+ <!-- Title text for swipe up to switch apps [CHAR LIMIT=60] -->
+ <string name="swipe_up_to_switch_apps_title">2-button navigation</string>
<!-- Summary text for swipe up to switch apps [CHAR LIMIT=250] -->
<string name="swipe_up_to_switch_apps_summary">To switch apps, swipe up on the Home button. Swipe up again to see all apps. Works from any screen. You’ll no longer have an Overview button on the bottom right of your screen.</string>
<!-- Title for settings suggestion for swipe up to switch apps [CHAR LIMIT=60] -->
@@ -10146,15 +10175,18 @@
<!-- Summary for settings suggestion for swipe up to switch apps [CHAR LIMIT=60] -->
<string name="swipe_up_to_switch_apps_suggestion_summary">Turn on the new gesture to switch apps</string>
- <!-- Title text for edge to edge navigation [CHAR LIMIT=60] [DO NOT TRANSLATE] -->
- <string name="edge_to_edge_navigation_title" translatable="false">Fully gestural navigation</string>
- <!-- Summary text for edge to edge navigation [CHAR LIMIT=None] [DO NOT TRANSLATE] -->
- <string name="edge_to_edge_navigation_summary" translatable="false">To go Home, swipe up from the bottom of the screen. To go Back, swipe from either the left or right edge of the screen. To switch apps, start swiping up from the bottom of the screen and hold before releasing.</string>
+ <!-- Title text for edge to edge navigation [CHAR LIMIT=60] -->
+ <string name="edge_to_edge_navigation_title">Gesture navigation</string>
+ <!-- Summary text for edge to edge navigation [CHAR LIMIT=NONE] -->
+ <string name="edge_to_edge_navigation_summary">To go Home, swipe up from the bottom of the screen. To go Back, swipe from either the left or right edge of the screen. To switch apps, start swiping up from the bottom of the screen and hold before releasing.</string>
- <!-- Title text for 3-button navigation [CHAR LIMIT=60] [DO NOT TRANSLATE] -->
- <string name="legacy_navigation_title" translatable="false">3-button navigation</string>
- <!-- Summary text for 3-button navigation [CHAR LIMIT=250] [DO NOT TRANSLATE] -->
- <string name="legacy_navigation_summary" translatable="false">Classic Android navigation mode where going Home, switching apps, and going Back are accessible via buttons.</string>
+ <!-- Title text for 3-button navigation [CHAR LIMIT=60] -->
+ <string name="legacy_navigation_title">3-button navigation</string>
+ <!-- Summary text for 3-button navigation [CHAR LIMIT=NONE] -->
+ <string name="legacy_navigation_summary">Classic Android navigation mode where going Home, switching apps, and going Back are accessible via buttons.</string>
+
+ <!-- Search keywords for System Navigation settings. [CHAR_LIMIT=NONE]-->
+ <string name="keywords_system_navigation">system navigation, 2 button navigation, 3 button navigation, gesture navigation</string>
<!-- Preference and settings suggestion title text for ambient display double tap (phone) [CHAR LIMIT=60]-->
<string name="ambient_display_title" product="default">Double-tap to check phone</string>
@@ -10542,9 +10574,9 @@
<!-- Note displayed when certain features are not available on low ram devices. [CHAR LIMIT=NONE] -->
<string name="disabled_low_ram_device">This feature is not available on this device</string>
- <!-- Note displayed when certain features are not available. [CHAR LIMIT=NONE] -->
+ <!-- Title of a message for an empty state screen. A user will see this message if they try to use a certain feature, but the feature was turned off so it won't slow down their phone. [CHAR LIMIT=NONE] -->
<string name="disabled_feature">Feature not available</string>
- <!-- Note displayed to explain that a feature is not available because it will slow down the phone. [CHAR LIMIT=NONE] -->
+ <!-- Part of a message for an empty state screen. A user will see this message if they try to use a certain feature, but the feature was turned off so it won't slow down their phone. [CHAR LIMIT=NONE] -->
<string name="disabled_feature_reason_slow_down_phone">This feature has been turned off because it slows down your phone</string>
<!-- UI debug setting: preference title - enforce full raw GNSS satellite measurements [CHAR LIMIT=60] -->
diff --git a/res/values/themes.xml b/res/values/themes.xml
index 4edd943..cc265ba 100644
--- a/res/values/themes.xml
+++ b/res/values/themes.xml
@@ -27,8 +27,11 @@
<style name="Theme.Settings" parent="Theme.SettingsBase">
<item name="preferenceTheme">@style/PreferenceTheme</item>
+ <item name="android:clipToPadding">false</item>
+ <item name="android:clipChildren">false</item>
<item name="android:listPreferredItemHeight">72dip</item>
<item name="android:homeAsUpIndicator">@drawable/ic_arrow_back</item>
+ <item name="android:navigationBarColor">@android:color/transparent</item>
<item name="fingerprint_layout_theme">@style/FingerprintLayoutTheme</item>
<item name="face_layout_theme">@style/FaceLayoutTheme</item>
@@ -88,6 +91,7 @@
</style>
<style name="ThemeOverlay.SwitchBar.Settings" parent="@*android:style/ThemeOverlay.DeviceDefault.ActionBar">
+ <item name="android:elevation">1dp</item>
<item name="switchBarMarginStart">@dimen/switchbar_subsettings_margin_start</item>
<item name="switchBarMarginEnd">@dimen/switchbar_subsettings_margin_end</item>
<item name="switchBarBackgroundColor">@color/switchbar_background_color</item>
@@ -231,4 +235,17 @@
<item name="android:textColorSecondary">@*android:color/secondary_text_light</item>
</style>
+ <!-- Light theme for those pages inherit SubSettings and launched during setup flow -->
+ <style name="LightTheme.SubSettings.SetupWizard" parent="@android:style/Theme.DeviceDefault.Light">
+ <item name="android:windowLightStatusBar">true</item>
+ <item name="android:statusBarColor">@android:color/white</item>
+ <item name="android:navigationBarColor">@android:color/white</item>
+ <item name="android:windowLightNavigationBar">true</item>
+ <item name="android:windowBackground">@android:color/white</item>
+ <item name="android:navigationBarDividerColor">@*android:color/navigation_bar_divider_device_default_settings</item>
+
+ <item name="android:colorPrimary">@android:color/white</item>
+ <item name="android:colorPrimaryDark">@android:color/white</item>
+ <item name="android:colorAccent">@color/material_blue_700</item>
+ </style>
</resources>
diff --git a/res/xml/bubble_notification_settings.xml b/res/xml/bubble_notification_settings.xml
deleted file mode 100644
index 7fba125..0000000
--- a/res/xml/bubble_notification_settings.xml
+++ /dev/null
@@ -1,41 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- 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.
--->
-
-<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:settings="http://schemas.android.com/apk/res-auto"
- android:title="@string/bubbles_app_toggle_title"
- android:key="bubble_notification_settings">
-
- <com.android.settings.widget.VideoPreference
- android:key="bubbles_illustration"
- android:title="@string/summary_placeholder"
- settings:animation="@raw/bubbles"
- settings:controller="com.android.settings.widget.VideoPreferenceController"
- android:persistent="false" />
-
- <!-- Notification bubbles -->
- <SwitchPreference
- android:key="global_notification_bubbles"
- android:title="@string/notification_bubbles_title"
- android:summary="@string/notification_bubbles_summary"
- settings:controller="com.android.settings.notification.BubbleNotificationPreferenceController"/>
-
- <com.android.settingslib.widget.FooterPreference
- android:key="notification_bubbles_footer"
- android:title="@string/bubbles_feature_education"
- android:selectable="false" />
-
-</PreferenceScreen>
diff --git a/res/xml/captioning_settings.xml b/res/xml/captioning_settings.xml
index 3129738..56e0e2d 100644
--- a/res/xml/captioning_settings.xml
+++ b/res/xml/captioning_settings.xml
@@ -21,6 +21,12 @@
android:key="captioning_preference_screen"
android:title="@string/accessibility_captioning_title" >
+ <com.android.settingslib.widget.LayoutPreference
+ android:key="caption_preview"
+ android:title="@string/summary_placeholder"
+ android:layout="@layout/captioning_preview"
+ settings:searchable="false"/>
+
<PreferenceCategory
android:key="standard"
android:title="@string/captioning_standard_options_title" >
diff --git a/res/xml/configure_notification_settings.xml b/res/xml/configure_notification_settings.xml
index af27869..687fe83 100644
--- a/res/xml/configure_notification_settings.xml
+++ b/res/xml/configure_notification_settings.xml
@@ -74,13 +74,6 @@
android:title="@string/notification_badging_title"
settings:controller="com.android.settings.notification.BadgingNotificationPreferenceController"/>
- <!-- Notification bubbles -->
- <Preference
- android:key="notification_bubbles"
- android:title="@string/notification_bubbles_title"
- settings:controller="com.android.settings.notification.BubbleSummaryNotificationPreferenceController"
- android:fragment="com.android.settings.notification.BubbleNotificationSettings"/>
-
<!-- Pulse notification light -->
<SwitchPreference
android:key="notification_pulse"
diff --git a/res/xml/development_settings.xml b/res/xml/development_settings.xml
index 908529e..c537f3f 100644
--- a/res/xml/development_settings.xml
+++ b/res/xml/development_settings.xml
@@ -560,6 +560,12 @@
android:key="device_identifier_access_restrictions"
android:title="@string/device_identifier_access_restrictions_title"
android:summary="@string/device_identifier_access_restrictions_summary" />
+
+ <SwitchPreference
+ android:key="notification_bubbles"
+ android:title="@string/notification_bubbles_title"
+ android:summary="@string/notification_bubbles_developer_setting_summary"/>
+
</PreferenceCategory>
<com.android.settings.development.autofill.AutofillPreferenceCategory
diff --git a/res/xml/gestures.xml b/res/xml/gestures.xml
index 5dcb1b0..ff3a6b5 100644
--- a/res/xml/gestures.xml
+++ b/res/xml/gestures.xml
@@ -49,7 +49,7 @@
android:key="gesture_system_navigation_input_summary"
android:title="@string/system_navigation_title"
android:fragment="com.android.settings.gestures.SystemNavigationGestureSettings"
- settings:controller="com.android.settings.gestures.SystemNavigationLegacyPreferenceController" />
+ settings:controller="com.android.settings.gestures.SystemNavigationPreferenceController" />
<Preference
android:key="gesture_tap_screen_input_summary"
diff --git a/res/xml/location_recent_requests_see_all.xml b/res/xml/location_recent_requests_see_all.xml
new file mode 100644
index 0000000..dfb8804
--- /dev/null
+++ b/res/xml/location_recent_requests_see_all.xml
@@ -0,0 +1,18 @@
+<?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/location_category_recent_location_requests"
+ android:key="recent_location_requests_see_all">
+ <PreferenceCategory
+ android:key="all_recent_location_requests"/>
+</PreferenceScreen>
diff --git a/res/xml/location_settings.xml b/res/xml/location_settings.xml
index 9ab80a7..136e6ab 100644
--- a/res/xml/location_settings.xml
+++ b/res/xml/location_settings.xml
@@ -20,11 +20,16 @@
android:title="@string/location_settings_title"
settings:keywords="@string/keywords_location">
- <com.android.settingslib.widget.LayoutPreference
- android:key="apps_dashboard"
- android:layout="@layout/app_entities_header"
- android:selectable="false"
- settings:allowDividerBelow="true" />
+ <PreferenceCategory
+ android:key="recent_location_requests"
+ android:title="@string/location_category_recent_location_requests"/>
+
+ <Preference
+ android:key="recent_location_requests_see_all_button"
+ android:title="@string/location_recent_location_requests_see_all"
+ android:icon="@drawable/ic_chevron_right_24dp"
+ android:fragment="com.android.settings.location.RecentLocationRequestSeeAllFragment"
+ settings:searchable="false"/>
<PreferenceCategory
android:key="location_advanced_settings"
diff --git a/res/xml/system_navigation_gesture_settings.xml b/res/xml/system_navigation_gesture_settings.xml
index 97aacb8..b1045fc 100644
--- a/res/xml/system_navigation_gesture_settings.xml
+++ b/res/xml/system_navigation_gesture_settings.xml
@@ -17,35 +17,7 @@
<PreferenceScreen
xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:app="http://schemas.android.com/apk/res-auto"
+ xmlns:settings="http://schemas.android.com/apk/res-auto"
android:key="gesture_system_navigation_screen"
- android:title="@string/system_navigation_title">
-
- <com.android.settings.widget.VideoPreference
- android:key="gesture_swipe_up_video"
- app:animation="@raw/gesture_swipe_up"
- app:preview="@drawable/gesture_swipe_up" />
-
- <com.android.settings.widget.RadioButtonPreference
- android:key="gesture_edge_to_edge"
- android:title="@string/edge_to_edge_navigation_title"
- android:summary="@string/edge_to_edge_navigation_summary"
- app:keywords="@string/keywords_gesture"
- app:controller="com.android.settings.gestures.SystemNavigationEdgeToEdgePreferenceController"
- app:allowDividerAbove="true" />
-
- <com.android.settings.widget.RadioButtonPreference
- android:key="gesture_swipe_up"
- android:title="@string/swipe_up_to_switch_apps_title"
- android:summary="@string/swipe_up_to_switch_apps_summary"
- app:keywords="@string/keywords_gesture"
- app:controller="com.android.settings.gestures.SystemNavigationSwipeUpPreferenceController" />
-
- <com.android.settings.widget.RadioButtonPreference
- android:key="gesture_legacy"
- android:title="@string/legacy_navigation_title"
- android:summary="@string/legacy_navigation_summary"
- app:keywords="@string/keywords_gesture"
- app:controller="com.android.settings.gestures.SystemNavigationLegacyPreferenceController" />
-
-</PreferenceScreen>
\ No newline at end of file
+ android:title="@string/system_navigation_title"
+ settings:keywords="@string/keywords_system_navigation"/>
diff --git a/src/com/android/settings/SettingsActivity.java b/src/com/android/settings/SettingsActivity.java
index 4ac4be4..3b01b32 100644
--- a/src/com/android/settings/SettingsActivity.java
+++ b/src/com/android/settings/SettingsActivity.java
@@ -35,7 +35,6 @@
import android.text.TextUtils;
import android.util.Log;
import android.view.View;
-import android.view.ViewGroup;
import android.widget.Button;
import androidx.annotation.Nullable;
@@ -51,7 +50,6 @@
import com.android.internal.util.ArrayUtils;
import com.android.settings.Settings.WifiSettingsActivity;
import com.android.settings.applications.manageapplications.ManageApplications;
-import com.android.settings.backup.BackupSettingsHelper;
import com.android.settings.backup.UserBackupSettingsActivity;
import com.android.settings.core.OnActivityResultListener;
import com.android.settings.core.SettingsBaseActivity;
@@ -67,6 +65,8 @@
import com.android.settingslib.development.DevelopmentSettingsEnabler;
import com.android.settingslib.drawer.DashboardCategory;
+import com.google.android.setupcompat.util.WizardManagerHelper;
+
import java.util.ArrayList;
import java.util.List;
@@ -166,8 +166,6 @@
private Button mNextButton;
- private ViewGroup mContent;
-
// Categories
private ArrayList<DashboardCategory> mCategories = new ArrayList<>();
@@ -243,15 +241,15 @@
intent.getBooleanExtra(EXTRA_SHOW_FRAGMENT_AS_SUBSETTING, false);
// If this is a sub settings, then apply the SubSettings Theme for the ActionBar content
- // insets
- if (isSubSettings) {
+ // insets.
+ // If this is in setup flow, don't apply theme. Because light theme needs to be applied
+ // in SettingsBaseActivity#onCreate().
+ if (isSubSettings && !WizardManagerHelper.isAnySetupWizard(getIntent())) {
setTheme(R.style.Theme_SubSettings);
}
setContentView(R.layout.settings_main_prefs);
- mContent = findViewById(R.id.main_content);
-
getSupportFragmentManager().addOnBackStackChangedListener(this);
if (savedState != null) {
diff --git a/src/com/android/settings/SetupWizardUtils.java b/src/com/android/settings/SetupWizardUtils.java
index 077d94c..bce6f3f 100644
--- a/src/com/android/settings/SetupWizardUtils.java
+++ b/src/com/android/settings/SetupWizardUtils.java
@@ -16,12 +16,18 @@
package com.android.settings;
+import static com.google.android.setupcompat.util.WizardManagerHelper.EXTRA_IS_FIRST_RUN;
+import static com.google.android.setupcompat.util.WizardManagerHelper.EXTRA_IS_SETUP_FLOW;
+
import android.content.Intent;
+import android.os.Bundle;
import android.sysprop.SetupWizardProperties;
import com.google.android.setupcompat.util.WizardManagerHelper;
import com.google.android.setupdesign.util.ThemeHelper;
+import java.util.Arrays;
+
public class SetupWizardUtils {
@@ -90,4 +96,14 @@
public static void copySetupExtras(Intent fromIntent, Intent toIntent) {
WizardManagerHelper.copyWizardManagerExtras(fromIntent, toIntent);
}
+
+ public static Bundle copyLifecycleExtra(Bundle srcBundle, Bundle dstBundle) {
+ for (String key :
+ Arrays.asList(
+ EXTRA_IS_FIRST_RUN,
+ EXTRA_IS_SETUP_FLOW)) {
+ dstBundle.putBoolean(key, srcBundle.getBoolean(key, false));
+ }
+ return dstBundle;
+ }
}
diff --git a/src/com/android/settings/accessibility/AccessibilitySettingsForSetupWizardActivity.java b/src/com/android/settings/accessibility/AccessibilitySettingsForSetupWizardActivity.java
index fc68d2c..0ed1644 100644
--- a/src/com/android/settings/accessibility/AccessibilitySettingsForSetupWizardActivity.java
+++ b/src/com/android/settings/accessibility/AccessibilitySettingsForSetupWizardActivity.java
@@ -16,23 +16,35 @@
package com.android.settings.accessibility;
+import android.content.ComponentName;
import android.os.Bundle;
+import android.util.Log;
import android.view.Menu;
import android.view.accessibility.AccessibilityEvent;
+import androidx.annotation.VisibleForTesting;
import androidx.preference.Preference;
import androidx.preference.PreferenceFragmentCompat;
import com.android.settings.SettingsActivity;
+import com.android.settings.SetupWizardUtils;
import com.android.settings.core.SubSettingLauncher;
+import com.android.settings.display.FontSizePreferenceFragmentForSetupWizard;
import com.android.settings.search.actionbar.SearchMenuController;
import com.android.settings.support.actionbar.HelpResourceProvider;
import com.android.settingslib.core.instrumentation.Instrumentable;
+import com.google.android.setupcompat.util.WizardManagerHelper;
+
public class AccessibilitySettingsForSetupWizardActivity extends SettingsActivity {
+ private static final String LOG_TAG = "A11ySettingsForSUW";
private static final String SAVE_KEY_TITLE = "activity_title";
+ @VisibleForTesting
+ static final String CLASS_NAME_FONT_SIZE_SETTINGS_FOR_SUW =
+ "com.android.settings.FontSizeSettingsForSetupWizardActivity";
+
@Override
protected void onSaveInstanceState(Bundle savedState) {
savedState.putCharSequence(SAVE_KEY_TITLE, getTitle());
@@ -79,4 +91,33 @@
.launch();
return true;
}
+
+ @Override
+ protected void onCreate(Bundle savedState) {
+ super.onCreate(savedState);
+
+ tryLaunchFontSizeSettings();
+ }
+
+ @VisibleForTesting
+ void tryLaunchFontSizeSettings() {
+ if (WizardManagerHelper.isAnySetupWizard(getIntent())
+ && new ComponentName(getPackageName(),
+ CLASS_NAME_FONT_SIZE_SETTINGS_FOR_SUW).equals(
+ getIntent().getComponent())) {
+ final Bundle args = new Bundle();
+ args.putInt(HelpResourceProvider.HELP_URI_RESOURCE_KEY, 0);
+ args.putBoolean(SearchMenuController.NEED_SEARCH_ICON_IN_ACTION_BAR, false);
+ final SubSettingLauncher subSettingLauncher = new SubSettingLauncher(this)
+ .setDestination(FontSizePreferenceFragmentForSetupWizard.class.getName())
+ .setArguments(args)
+ .setSourceMetricsCategory(Instrumentable.METRICS_CATEGORY_UNKNOWN)
+ .setExtras(SetupWizardUtils.copyLifecycleExtra(getIntent().getExtras(),
+ new Bundle()));
+
+ Log.d(LOG_TAG, "Launch font size settings");
+ subSettingLauncher.launch();
+ finish();
+ }
+ }
}
diff --git a/src/com/android/settings/accessibility/CaptionPropertiesFragment.java b/src/com/android/settings/accessibility/CaptionPropertiesFragment.java
index ae7e3fd..bddca9c 100644
--- a/src/com/android/settings/accessibility/CaptionPropertiesFragment.java
+++ b/src/com/android/settings/accessibility/CaptionPropertiesFragment.java
@@ -22,13 +22,8 @@
import android.content.res.Resources;
import android.graphics.Color;
import android.os.Bundle;
-import android.preference.PreferenceFrameLayout;
import android.provider.Settings;
-import android.view.LayoutInflater;
import android.view.View;
-import android.view.View.OnLayoutChangeListener;
-import android.view.ViewGroup;
-import android.view.ViewGroup.LayoutParams;
import android.view.accessibility.CaptioningManager;
import android.view.accessibility.CaptioningManager.CaptionStyle;
@@ -46,6 +41,7 @@
import com.android.settings.widget.ToggleSwitch;
import com.android.settings.widget.ToggleSwitch.OnBeforeCheckedChangeListener;
import com.android.settingslib.accessibility.AccessibilityUtils;
+import com.android.settingslib.widget.LayoutPreference;
import java.util.Locale;
@@ -54,6 +50,7 @@
*/
public class CaptionPropertiesFragment extends SettingsPreferenceFragment
implements OnPreferenceChangeListener, OnValueChangedListener {
+ private static final String PREF_CAPTION_PREVIEW = "caption_preview";
private static final String PREF_BACKGROUND_COLOR = "captioning_background_color";
private static final String PREF_BACKGROUND_OPACITY = "captioning_background_opacity";
private static final String PREF_FOREGROUND_COLOR = "captioning_foreground_color";
@@ -116,43 +113,6 @@
}
@Override
- public View onCreateView(
- LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
- final View rootView = inflater.inflate(R.layout.captioning_preview, container, false);
-
- // We have to do this now because PreferenceFrameLayout looks at it
- // only when the view is added.
- if (container instanceof PreferenceFrameLayout) {
- ((PreferenceFrameLayout.LayoutParams) rootView.getLayoutParams()).removeBorders = true;
- }
-
- final View content = super.onCreateView(inflater, container, savedInstanceState);
- ((ViewGroup) rootView.findViewById(R.id.properties_fragment)).addView(
- content, LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
-
- return rootView;
- }
-
- @Override
- public void onViewCreated(View view, Bundle savedInstanceState) {
- super.onViewCreated(view, savedInstanceState);
-
- final boolean enabled = mCaptioningManager.isEnabled();
- mPreviewText = (SubtitleView) view.findViewById(R.id.preview_text);
- mPreviewText.setVisibility(enabled ? View.VISIBLE : View.INVISIBLE);
-
- mPreviewWindow = view.findViewById(R.id.preview_window);
- mPreviewViewport = view.findViewById(R.id.preview_viewport);
- mPreviewViewport.addOnLayoutChangeListener(new OnLayoutChangeListener() {
- @Override
- public void onLayoutChange(View v, int left, int top, int right, int bottom,
- int oldLeft, int oldTop, int oldRight, int oldBottom) {
- refreshPreviewText();
- }
- });
- }
-
- @Override
public void onActivityCreated(Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
@@ -263,6 +223,19 @@
}
private void initializeAllPreferences() {
+ final LayoutPreference captionPreview = findPreference(PREF_CAPTION_PREVIEW);
+
+ final boolean enabled = mCaptioningManager.isEnabled();
+ mPreviewText = captionPreview.findViewById(R.id.preview_text);
+ mPreviewText.setVisibility(enabled ? View.VISIBLE : View.INVISIBLE);
+
+ mPreviewWindow = captionPreview.findViewById(R.id.preview_window);
+
+ mPreviewViewport = captionPreview.findViewById(R.id.preview_viewport);
+ mPreviewViewport.addOnLayoutChangeListener(
+ (v, left, top, right, bottom, oldLeft, oldTop, oldRight, oldBottom)
+ -> refreshPreviewText());
+
mLocale = (LocalePreference) findPreference(PREF_LOCALE);
mFontSize = (ListPreference) findPreference(PREF_FONT_SIZE);
@@ -370,9 +343,9 @@
/**
* Unpack the specified color value and update the preferences.
*
- * @param color color preference
+ * @param color color preference
* @param opacity opacity preference
- * @param value packed value
+ * @param value packed value
*/
private void parseColorOpacity(ColorPreference color, ColorPreference opacity, int value) {
final int colorValue;
diff --git a/src/com/android/settings/accessibility/ToggleAccessibilityServicePreferenceFragment.java b/src/com/android/settings/accessibility/ToggleAccessibilityServicePreferenceFragment.java
index b28d8b5..4fe6507 100644
--- a/src/com/android/settings/accessibility/ToggleAccessibilityServicePreferenceFragment.java
+++ b/src/com/android/settings/accessibility/ToggleAccessibilityServicePreferenceFragment.java
@@ -86,6 +86,16 @@
}
@Override
+ public void onViewCreated(View view, Bundle savedInstanceState) {
+ super.onViewCreated(view, savedInstanceState);
+ mSwitchBar.setLabelDelegate((boolean isChecked) -> {
+ final AccessibilityServiceInfo info = getAccessibilityServiceInfo();
+ return getString(R.string.accessibility_service_master_switch_title,
+ info.getResolveInfo().loadLabel(getPackageManager()));
+ });
+ }
+
+ @Override
public void onResume() {
mSettingsContentObserver.register(getContentResolver());
updateSwitchBarToggleSwitch();
@@ -120,7 +130,7 @@
return serviceInfo;
}
}
- return null;
+ throw new IllegalStateException("ServiceInfo is not found.");
}
@Override
@@ -128,18 +138,12 @@
switch (dialogId) {
case DIALOG_ID_ENABLE_WARNING: {
final AccessibilityServiceInfo info = getAccessibilityServiceInfo();
- if (info == null) {
- return null;
- }
mDialog = AccessibilityServiceWarning
.createCapabilitiesDialog(getActivity(), info, this);
break;
}
case DIALOG_ID_DISABLE_WARNING: {
AccessibilityServiceInfo info = getAccessibilityServiceInfo();
- if (info == null) {
- return null;
- }
mDialog = AccessibilityServiceWarning
.createDisableDialog(getActivity(), info, this);
break;
diff --git a/src/com/android/settings/applications/appinfo/AppDataUsagePreferenceController.java b/src/com/android/settings/applications/appinfo/AppDataUsagePreferenceController.java
index 7d9fdcf..4d19151 100644
--- a/src/com/android/settings/applications/appinfo/AppDataUsagePreferenceController.java
+++ b/src/com/android/settings/applications/appinfo/AppDataUsagePreferenceController.java
@@ -92,7 +92,6 @@
.addUid(mParent.getAppEntry().info.uid)
.setRetrieveDetail(false)
.setNetworkTemplate(template)
- .setSubscriberId(template.getSubscriberId())
.build();
}
diff --git a/src/com/android/settings/biometrics/face/FaceEnrollEducation.java b/src/com/android/settings/biometrics/face/FaceEnrollEducation.java
index 6e162dc..956ba49 100644
--- a/src/com/android/settings/biometrics/face/FaceEnrollEducation.java
+++ b/src/com/android/settings/biometrics/face/FaceEnrollEducation.java
@@ -30,8 +30,10 @@
import android.provider.Settings;
import android.text.TextUtils;
import android.view.View;
+import android.view.accessibility.AccessibilityManager;
import android.widget.Button;
import android.widget.CompoundButton;
+import android.widget.TextView;
import com.android.settings.R;
import com.android.settings.Utils;
@@ -48,8 +50,8 @@
private static final String TAG = "FaceEducation";
private static final int ON = 1;
private static final int OFF = 0;
- // 10 seconds.
- private static final long FACE_ENROLL_EDUCATION_DELAY = 16000;
+ // 8 seconds.
+ private static final long FACE_ENROLL_EDUCATION_DELAY = 8000;
private FaceManager mFaceManager;
private FaceEnrollAccessibilityToggle mSwitchDiversity;
@@ -58,19 +60,28 @@
private View mIllustrationAccessibility;
private Handler mHandler;
private Intent mResultIntent;
+ private TextView mDescriptionText;
private CompoundButton.OnCheckedChangeListener mSwitchDiversityListener =
new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
+ int titleRes = isChecked ?
+ R.string.security_settings_face_enroll_education_title_accessibility
+ : R.string.security_settings_face_enroll_education_title;
+ getLayout().setHeaderText(titleRes);
+ setTitle(titleRes);
+
if (isChecked) {
mIllustrationNormal.stop();
mIllustrationNormal.setVisibility(View.INVISIBLE);
mIllustrationAccessibility.setVisibility(View.VISIBLE);
+ mDescriptionText.setVisibility(View.INVISIBLE);
} else {
mIllustrationNormal.setVisibility(View.VISIBLE);
mIllustrationNormal.start();
mIllustrationAccessibility.setVisibility(View.INVISIBLE);
+ mDescriptionText.setVisibility(View.VISIBLE);
}
}
};
@@ -84,18 +95,10 @@
mHandler = new Handler();
mFaceManager = Utils.getFaceManagerOrNull(this);
- final Button accessibilityButton = findViewById(R.id.accessibility_button);
- accessibilityButton.setOnClickListener(view -> {
- mSwitchDiversity.setChecked(true);
- accessibilityButton.setVisibility(View.GONE);
- mSwitchDiversity.setVisibility(View.VISIBLE);
- });
-
- mSwitchDiversity = findViewById(R.id.toggle_diversity);
- mSwitchDiversity.setListener(mSwitchDiversityListener);
mIllustrationNormal = findViewById(R.id.illustration_normal);
mIllustrationAccessibility = findViewById(R.id.illustration_accessibility);
+ mDescriptionText = findViewById(R.id.sud_layout_description);
mFooterBarMixin = getLayout().getMixin(FooterBarMixin.class);
mFooterBarMixin.setSecondaryButton(
@@ -108,17 +111,23 @@
);
final FooterButton footerButton = new FooterButton.Builder(this)
- .setText(R.string.wizard_next)
+ .setText(R.string.security_settings_face_enroll_education_start)
.setListener(this::onNextButtonClick)
.setButtonType(FooterButton.ButtonType.NEXT)
.setTheme(R.style.SudGlifButton_Primary)
.build();
+ boolean accessibilityEnabled = false;
+ final AccessibilityManager accessibilityManager = getApplicationContext().getSystemService(
+ AccessibilityManager.class);
+ if (accessibilityManager != null) {
+ accessibilityEnabled = accessibilityManager.isEnabled();
+ }
mFooterBarMixin.setPrimaryButton(footerButton);
final Context context = getApplicationContext();
final boolean didDisplayEdu = Settings.Secure.getIntForUser(context.getContentResolver(),
FACE_UNLOCK_EDUCATION_INFO_DISPLAYED, OFF, mUserId) == ON;
- if (!didDisplayEdu) {
+ if (!didDisplayEdu && !accessibilityEnabled) {
Settings.Secure.putIntForUser(context.getContentResolver(),
FACE_UNLOCK_EDUCATION_INFO_DISPLAYED, ON, mUserId);
footerButton.setEnabled(false);
@@ -126,6 +135,21 @@
footerButton.setEnabled(true);
}, FACE_ENROLL_EDUCATION_DELAY);
}
+
+ final Button accessibilityButton = findViewById(R.id.accessibility_button);
+ accessibilityButton.setOnClickListener(view -> {
+ footerButton.setEnabled(true);
+ mSwitchDiversity.setChecked(true);
+ accessibilityButton.setVisibility(View.GONE);
+ mSwitchDiversity.setVisibility(View.VISIBLE);
+ });
+
+ mSwitchDiversity = findViewById(R.id.toggle_diversity);
+ mSwitchDiversity.setListener(mSwitchDiversityListener);
+
+ if (accessibilityEnabled) {
+ accessibilityButton.callOnClick();
+ }
}
@Override
diff --git a/src/com/android/settings/biometrics/face/FaceSettingsRemoveButtonPreferenceController.java b/src/com/android/settings/biometrics/face/FaceSettingsRemoveButtonPreferenceController.java
index 990e68d..d532a76 100644
--- a/src/com/android/settings/biometrics/face/FaceSettingsRemoveButtonPreferenceController.java
+++ b/src/com/android/settings/biometrics/face/FaceSettingsRemoveButtonPreferenceController.java
@@ -94,6 +94,7 @@
Log.e(TAG, "Unable to remove face: " + face.getBiometricId()
+ " error: " + errMsgId + " " + errString);
Toast.makeText(mContext, errString, Toast.LENGTH_SHORT).show();
+ mRemoving = false;
}
@Override
@@ -131,6 +132,7 @@
mFaceManager.remove(faces.get(0), mUserId, mRemovalCallback);
} else {
mButton.setEnabled(true);
+ mRemoving = false;
}
}
};
diff --git a/src/com/android/settings/core/SettingsBaseActivity.java b/src/com/android/settings/core/SettingsBaseActivity.java
index cd13654..5ff81d5 100644
--- a/src/com/android/settings/core/SettingsBaseActivity.java
+++ b/src/com/android/settings/core/SettingsBaseActivity.java
@@ -37,8 +37,11 @@
import androidx.fragment.app.FragmentActivity;
import com.android.settings.R;
+import com.android.settings.SubSettings;
import com.android.settings.dashboard.CategoryManager;
+import com.google.android.setupcompat.util.WizardManagerHelper;
+
import java.util.ArrayList;
import java.util.List;
@@ -65,6 +68,10 @@
if (!theme.getBoolean(android.R.styleable.Theme_windowNoTitle, false)) {
requestWindowFeature(Window.FEATURE_NO_TITLE);
}
+ // Apply SetupWizard light theme during setup flow. This is for SubSettings pages.
+ if (WizardManagerHelper.isAnySetupWizard(getIntent()) && this instanceof SubSettings) {
+ setTheme(R.style.LightTheme_SubSettings_SetupWizard);
+ }
super.setContentView(R.layout.settings_base_layout);
final Toolbar toolbar = findViewById(R.id.action_bar);
diff --git a/src/com/android/settings/core/SubSettingLauncher.java b/src/com/android/settings/core/SubSettingLauncher.java
index 39ecd78..5d9a528 100644
--- a/src/com/android/settings/core/SubSettingLauncher.java
+++ b/src/com/android/settings/core/SubSettingLauncher.java
@@ -19,6 +19,7 @@
import android.annotation.StringRes;
import android.content.Context;
import android.content.Intent;
+import android.os.Build;
import android.os.Bundle;
import android.os.UserHandle;
import android.text.TextUtils;
@@ -89,6 +90,11 @@
return this;
}
+ public SubSettingLauncher setExtras(Bundle extras) {
+ mLaunchRequest.extras = extras;
+ return this;
+ }
+
public SubSettingLauncher setSourceMetricsCategory(int sourceMetricsCategory) {
mLaunchRequest.sourceMetricsCategory = sourceMetricsCategory;
return this;
@@ -136,6 +142,7 @@
public Intent toIntent() {
final Intent intent = new Intent(Intent.ACTION_MAIN);
+ copyExtras(intent);
intent.setClass(mContext, SubSettings.class);
if (TextUtils.isEmpty(mLaunchRequest.destinationName)) {
throw new IllegalArgumentException("Destination fragment must be set");
@@ -180,6 +187,11 @@
listener.startActivityForResult(intent, requestCode);
}
+ private void copyExtras(Intent intent) {
+ if (mLaunchRequest.extras != null) {
+ intent.replaceExtras(mLaunchRequest.extras);
+ }
+ }
/**
* Simple container that has information about how to launch a subsetting.
*/
@@ -194,5 +206,6 @@
int mRequestCode;
UserHandle userHandle;
Bundle arguments;
+ Bundle extras;
}
}
diff --git a/src/com/android/settings/core/gateway/SettingsGateway.java b/src/com/android/settings/core/gateway/SettingsGateway.java
index f50d6ad..d073dbc 100644
--- a/src/com/android/settings/core/gateway/SettingsGateway.java
+++ b/src/com/android/settings/core/gateway/SettingsGateway.java
@@ -104,7 +104,6 @@
import com.android.settings.nfc.PaymentSettings;
import com.android.settings.notification.AppBubbleNotificationSettings;
import com.android.settings.notification.AppNotificationSettings;
-import com.android.settings.notification.BubbleNotificationSettings;
import com.android.settings.notification.ChannelGroupNotificationSettings;
import com.android.settings.notification.ChannelNotificationSettings;
import com.android.settings.notification.ConfigureNotificationSettings;
@@ -216,7 +215,6 @@
DreamSettings.class.getName(),
UserSettings.class.getName(),
NotificationAccessSettings.class.getName(),
- BubbleNotificationSettings.class.getName(),
AppBubbleNotificationSettings.class.getName(),
ZenAccessSettings.class.getName(),
ZenAccessDetails.class.getName(),
diff --git a/src/com/android/settings/datausage/AppDataUsage.java b/src/com/android/settings/datausage/AppDataUsage.java
index 8bab256..a86459e 100644
--- a/src/com/android/settings/datausage/AppDataUsage.java
+++ b/src/com/android/settings/datausage/AppDataUsage.java
@@ -393,8 +393,7 @@
final NetworkCycleDataForUidLoader.Builder builder
= NetworkCycleDataForUidLoader.builder(mContext);
builder.setRetrieveDetail(true)
- .setNetworkTemplate(mTemplate)
- .setSubscriberId(mTemplate.getSubscriberId());
+ .setNetworkTemplate(mTemplate);
if (mAppItem.category == AppItem.CATEGORY_USER) {
for (int i = 0; i < mAppItem.uids.size(); i++) {
builder.addUid(mAppItem.uids.keyAt(i));
diff --git a/src/com/android/settings/datausage/DataUsageList.java b/src/com/android/settings/datausage/DataUsageList.java
index 96a1e22..f477ba3 100644
--- a/src/com/android/settings/datausage/DataUsageList.java
+++ b/src/com/android/settings/datausage/DataUsageList.java
@@ -496,7 +496,6 @@
public Loader<List<NetworkCycleChartData>> onCreateLoader(int id, Bundle args) {
return NetworkCycleChartDataLoader.builder(getContext())
.setNetworkTemplate(mTemplate)
- .setSubscriberId(mTelephonyManager.getSubscriberId(mSubId))
.build();
}
@@ -523,8 +522,7 @@
return new NetworkStatsSummaryLoader.Builder(getContext())
.setStartTime(mChart.getInspectStart())
.setEndTime(mChart.getInspectEnd())
- .setNetworkType(mNetworkType)
- .setSubscriberId(mTelephonyManager.getSubscriberId(mSubId))
+ .setNetworkTemplate(mTemplate)
.build();
}
diff --git a/src/com/android/settings/development/BubbleGlobalPreferenceController.java b/src/com/android/settings/development/BubbleGlobalPreferenceController.java
new file mode 100644
index 0000000..86d7be1
--- /dev/null
+++ b/src/com/android/settings/development/BubbleGlobalPreferenceController.java
@@ -0,0 +1,75 @@
+/*
+ * 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.development;
+
+import static android.provider.Settings.Secure.NOTIFICATION_BUBBLES;
+
+import android.content.Context;
+import android.provider.Settings;
+
+import androidx.annotation.VisibleForTesting;
+import androidx.preference.Preference;
+import androidx.preference.SwitchPreference;
+
+import com.android.settings.core.PreferenceControllerMixin;
+import com.android.settingslib.development.DeveloperOptionsPreferenceController;
+
+public class BubbleGlobalPreferenceController extends DeveloperOptionsPreferenceController
+ implements Preference.OnPreferenceChangeListener, PreferenceControllerMixin {
+
+ @VisibleForTesting
+ static final int ON = 1;
+ @VisibleForTesting
+ static final int OFF = 0;
+
+ public BubbleGlobalPreferenceController(Context context) {
+ super(context);
+ }
+
+ @Override
+ public String getPreferenceKey() {
+ return NOTIFICATION_BUBBLES;
+ }
+
+ @Override
+ public boolean onPreferenceChange(Preference preference, Object newValue) {
+ writeSetting((boolean) newValue);
+ return true;
+ }
+
+ @Override
+ public void updateState(Preference preference) {
+ ((SwitchPreference) mPreference).setChecked(isEnabled());
+ }
+
+ @Override
+ protected void onDeveloperOptionsSwitchDisabled() {
+ super.onDeveloperOptionsSwitchDisabled();
+ writeSetting(false /* isEnabled */);
+ updateState(mPreference);
+ }
+
+ private boolean isEnabled() {
+ return Settings.Secure.getInt(mContext.getContentResolver(),
+ NOTIFICATION_BUBBLES, OFF) == ON;
+ }
+
+ private void writeSetting(boolean isEnabled) {
+ Settings.Secure.putInt(mContext.getContentResolver(),
+ NOTIFICATION_BUBBLES, isEnabled ? ON : OFF);
+ }
+}
diff --git a/src/com/android/settings/development/DevelopmentSettingsDashboardFragment.java b/src/com/android/settings/development/DevelopmentSettingsDashboardFragment.java
index 77b104b..9dcc222 100644
--- a/src/com/android/settings/development/DevelopmentSettingsDashboardFragment.java
+++ b/src/com/android/settings/development/DevelopmentSettingsDashboardFragment.java
@@ -482,6 +482,7 @@
controllers.add(new DesktopModePreferenceController(context));
controllers.add(new DeviceIdentifierAccessRestrictionsPreferenceController(context));
controllers.add(new ShortcutManagerThrottlingPreferenceController(context));
+ controllers.add(new BubbleGlobalPreferenceController(context));
controllers.add(new EnableGnssRawMeasFullTrackingPreferenceController(context));
controllers.add(new DefaultLaunchPreferenceController(context, "running_apps"));
controllers.add(new DefaultLaunchPreferenceController(context, "demo_mode"));
diff --git a/src/com/android/settings/deviceinfo/imei/ImeiInfoDialogController.java b/src/com/android/settings/deviceinfo/imei/ImeiInfoDialogController.java
index 4b2f50d..5c3772b 100644
--- a/src/com/android/settings/deviceinfo/imei/ImeiInfoDialogController.java
+++ b/src/com/android/settings/deviceinfo/imei/ImeiInfoDialogController.java
@@ -78,9 +78,12 @@
final Context context = dialog.getContext();
mSubscriptionInfo = context.getSystemService(SubscriptionManager.class)
.getActiveSubscriptionInfoForSimSlotIndex(slotId);
+ TelephonyManager tm = context.getSystemService(TelephonyManager.class);
if (mSubscriptionInfo != null) {
mTelephonyManager = context.getSystemService(TelephonyManager.class)
.createForSubscriptionId(mSubscriptionInfo.getSubscriptionId());
+ } else if(isValidSlotIndex(slotId, tm)) {
+ mTelephonyManager = tm;
} else {
mTelephonyManager = null;
}
@@ -104,6 +107,7 @@
private void updateDialogForCdmaPhone() {
final Resources res = mDialog.getContext().getResources();
mDialog.setText(ID_MEID_NUMBER_VALUE, getMeid());
+ // MIN needs to read from SIM. So if no SIM, we should not show MIN on UI
mDialog.setText(ID_MIN_NUMBER_VALUE, mSubscriptionInfo != null
? mTelephonyManager.getCdmaMin(mSubscriptionInfo.getSubscriptionId())
: "");
@@ -137,7 +141,8 @@
@VisibleForTesting
String getCdmaPrlVersion() {
- return mTelephonyManager.getCdmaPrlVersion();
+ // PRL needs to read from SIM. So if no SIM, return empty
+ return mSubscriptionInfo != null ? mTelephonyManager.getCdmaPrlVersion() : "";
}
@VisibleForTesting
@@ -150,4 +155,9 @@
String getMeid() {
return mTelephonyManager.getMeid(mSlotId);
}
+
+ @VisibleForTesting
+ private boolean isValidSlotIndex(int slotIndex, TelephonyManager telephonyManager) {
+ return slotIndex >= 0 && slotIndex < telephonyManager.getPhoneCount();
+ }
}
diff --git a/src/com/android/settings/display/DarkUIPreferenceController.java b/src/com/android/settings/display/DarkUIPreferenceController.java
index 9df2402..d3d30b5 100644
--- a/src/com/android/settings/display/DarkUIPreferenceController.java
+++ b/src/com/android/settings/display/DarkUIPreferenceController.java
@@ -17,27 +17,53 @@
package com.android.settings.display;
import android.app.UiModeManager;
+import android.content.BroadcastReceiver;
import android.content.Context;
+import android.content.Intent;
+import android.content.IntentFilter;
+import android.os.PowerManager;
import android.provider.Settings;
import androidx.annotation.VisibleForTesting;
import androidx.fragment.app.Fragment;
+import androidx.preference.Preference;
+import androidx.preference.PreferenceScreen;
+import androidx.preference.SwitchPreference;
+import com.android.settings.R;
import com.android.settings.core.TogglePreferenceController;
+import com.android.settingslib.core.lifecycle.LifecycleObserver;
+import com.android.settingslib.core.lifecycle.events.OnStart;
+import com.android.settingslib.core.lifecycle.events.OnStop;
-public class DarkUIPreferenceController extends TogglePreferenceController {
+public class DarkUIPreferenceController extends TogglePreferenceController implements
+ LifecycleObserver, OnStart, OnStop {
public static final String DARK_MODE_PREFS = "dark_mode_prefs";
public static final String PREF_DARK_MODE_DIALOG_SEEN = "dark_mode_dialog_seen";
public static final int DIALOG_SEEN = 1;
+
+ @VisibleForTesting
+ SwitchPreference mPreference;
+
private UiModeManager mUiModeManager;
+ private PowerManager mPowerManager;
private Context mContext;
+
private Fragment mFragment;
+ private BroadcastReceiver mReceiver = new BroadcastReceiver() {
+ @Override
+ public void onReceive(Context context, Intent intent) {
+ updateEnabledStateIfNeeded();
+ }
+ };
+
public DarkUIPreferenceController(Context context, String key) {
super(context, key);
mContext = context;
mUiModeManager = context.getSystemService(UiModeManager.class);
+ mPowerManager = context.getSystemService(PowerManager.class);
}
@Override
@@ -46,6 +72,18 @@
}
@Override
+ public void displayPreference(PreferenceScreen screen) {
+ super.displayPreference(screen);
+ mPreference = screen.findPreference(getPreferenceKey());
+ }
+
+ @Override
+ public void updateState(Preference preference) {
+ super.updateState(preference);
+ updateEnabledStateIfNeeded();
+ }
+
+ @Override
public boolean setChecked(boolean isChecked) {
final boolean dialogSeen =
Settings.Secure.getInt(mContext.getContentResolver(),
@@ -68,6 +106,29 @@
}
@VisibleForTesting
+ void updateEnabledStateIfNeeded() {
+ if (mPreference == null) {
+ return;
+ }
+ boolean isBatterySaver = isPowerSaveMode();
+ mPreference.setEnabled(!isBatterySaver);
+ if (isBatterySaver) {
+ int stringId = mUiModeManager.getNightMode() == UiModeManager.MODE_NIGHT_YES
+ ? R.string.dark_ui_mode_disabled_summary_dark_theme_on
+ : R.string.dark_ui_mode_disabled_summary_dark_theme_off;
+ mPreference.setSummary(mContext.getString(stringId));
+ } else {
+ mPreference.setSummary(null);
+ }
+ }
+
+ @VisibleForTesting
+ boolean isPowerSaveMode() {
+ return mPowerManager.isPowerSaveMode();
+ }
+
+
+ @VisibleForTesting
void setUiModeManager(UiModeManager uiModeManager) {
mUiModeManager = uiModeManager;
}
@@ -77,6 +138,17 @@
}
@Override
+ public void onStart() {
+ mContext.registerReceiver(mReceiver,
+ new IntentFilter(PowerManager.ACTION_POWER_SAVE_MODE_CHANGED));
+ }
+
+ @Override
+ public void onStop() {
+ mContext.unregisterReceiver(mReceiver);
+ }
+
+ @Override
public int getAvailabilityStatus() {
return AVAILABLE;
}
diff --git a/src/com/android/settings/display/PreviewPagerAdapter.java b/src/com/android/settings/display/PreviewPagerAdapter.java
index 5c43683..018be32 100644
--- a/src/com/android/settings/display/PreviewPagerAdapter.java
+++ b/src/com/android/settings/display/PreviewPagerAdapter.java
@@ -67,7 +67,8 @@
mPreviewFrames[p].setLayoutParams(new LinearLayout.LayoutParams(
LinearLayout.LayoutParams.MATCH_PARENT,
LinearLayout.LayoutParams.MATCH_PARENT));
-
+ mPreviewFrames[p].setClipToPadding(true);
+ mPreviewFrames[p].setClipChildren(true);
for (int j = 0; j < configurations.length; ++j) {
// Create a new configuration for the specified value. It won't
// have any theme set, so manually apply the current theme.
diff --git a/src/com/android/settings/gestures/SystemNavigationEdgeToEdgePreferenceController.java b/src/com/android/settings/gestures/SystemNavigationEdgeToEdgePreferenceController.java
deleted file mode 100644
index 0c5adc4..0000000
--- a/src/com/android/settings/gestures/SystemNavigationEdgeToEdgePreferenceController.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * Copyright (C) 2019 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.settings.gestures;
-
-import static android.view.WindowManagerPolicyConstants.NAV_BAR_MODE_GESTURAL_OVERLAY;
-
-import android.content.Context;
-import android.content.om.IOverlayManager;
-import android.os.ServiceManager;
-import android.text.TextUtils;
-
-import androidx.annotation.VisibleForTesting;
-
-import com.android.settings.widget.RadioButtonPreference;
-
-public class SystemNavigationEdgeToEdgePreferenceController extends
- SystemNavigationPreferenceController {
- static final String PREF_KEY_EDGE_TO_EDGE = "gesture_edge_to_edge";
-
- public SystemNavigationEdgeToEdgePreferenceController(Context context, String key) {
- this(context, IOverlayManager.Stub.asInterface(ServiceManager.getService(
- Context.OVERLAY_SERVICE)), key);
- }
-
- @VisibleForTesting
- public SystemNavigationEdgeToEdgePreferenceController(Context context,
- IOverlayManager overlayManager, String key) {
- super(context, overlayManager, key, NAV_BAR_MODE_GESTURAL_OVERLAY);
- }
-
- @Override
- public void onRadioButtonClicked(RadioButtonPreference preference) {
- setNavBarInteractionMode(mOverlayManager, NAV_BAR_MODE_GESTURAL_OVERLAY);
- selectRadioButtonInGroup(PREF_KEY_EDGE_TO_EDGE, mPreferenceScreen);
- }
-
- @Override
- public boolean isChecked() {
- return isEdgeToEdgeEnabled(mContext);
- }
-}
diff --git a/src/com/android/settings/gestures/SystemNavigationGestureSettings.java b/src/com/android/settings/gestures/SystemNavigationGestureSettings.java
index ea5454b..e17b870 100644
--- a/src/com/android/settings/gestures/SystemNavigationGestureSettings.java
+++ b/src/com/android/settings/gestures/SystemNavigationGestureSettings.java
@@ -16,29 +16,58 @@
package com.android.settings.gestures;
+import static android.os.UserHandle.USER_CURRENT;
+import static android.view.WindowManagerPolicyConstants.NAV_BAR_MODE_2BUTTON_OVERLAY;
+import static android.view.WindowManagerPolicyConstants.NAV_BAR_MODE_3BUTTON_OVERLAY;
+import static android.view.WindowManagerPolicyConstants.NAV_BAR_MODE_GESTURAL_OVERLAY;
+
import android.app.settings.SettingsEnums;
import android.content.Context;
import android.content.SharedPreferences;
+import android.content.om.IOverlayManager;
+import android.graphics.drawable.Drawable;
+import android.os.RemoteException;
+import android.os.ServiceManager;
import android.provider.SearchIndexableResource;
+import android.view.View;
+
+import androidx.annotation.VisibleForTesting;
+import androidx.preference.PreferenceScreen;
import com.android.settings.R;
-import com.android.settings.dashboard.DashboardFragment;
import com.android.settings.dashboard.suggestions.SuggestionFeatureProvider;
import com.android.settings.overlay.FeatureFactory;
import com.android.settings.search.BaseSearchIndexProvider;
+import com.android.settings.search.Indexable;
+import com.android.settings.widget.RadioButtonPickerFragment;
+import com.android.settings.widget.RadioButtonPreference;
+import com.android.settings.widget.VideoPreference;
import com.android.settingslib.search.SearchIndexable;
+import com.android.settingslib.widget.CandidateInfo;
+import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
@SearchIndexable
-public class SystemNavigationGestureSettings extends DashboardFragment {
+public class SystemNavigationGestureSettings extends RadioButtonPickerFragment {
private static final String TAG = "SystemNavigationGesture";
+ @VisibleForTesting
+ static final String KEY_SYSTEM_NAV_3BUTTONS = "system_nav_3buttons";
+ @VisibleForTesting
+ static final String KEY_SYSTEM_NAV_2BUTTONS = "system_nav_2buttons";
+ @VisibleForTesting
+ static final String KEY_SYSTEM_NAV_GESTURAL = "system_nav_gestural";
+
public static final String PREF_KEY_SUGGESTION_COMPLETE =
"pref_system_navigation_suggestion_complete";
+ private IOverlayManager mOverlayManager;
+
+ private VideoPreference mVideoPreference;
+
@Override
public void onAttach(Context context) {
super.onAttach(context);
@@ -46,6 +75,12 @@
.getSuggestionFeatureProvider(context);
SharedPreferences prefs = suggestionFeatureProvider.getSharedPrefs(context);
prefs.edit().putBoolean(PREF_KEY_SUGGESTION_COMPLETE, true).apply();
+
+ mOverlayManager = IOverlayManager.Stub.asInterface(
+ ServiceManager.getService(Context.OVERLAY_SERVICE));
+
+ mVideoPreference = new VideoPreference(context);
+ setIllustrationVideo(mVideoPreference, getDefaultKey());
}
@Override
@@ -54,16 +89,153 @@
}
@Override
- protected String getLogTag() {
- return TAG;
- }
-
- @Override
protected int getPreferenceScreenResId() {
return R.xml.system_navigation_gesture_settings;
}
- public static final SearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
+ @Override
+ protected void addStaticPreferences(PreferenceScreen screen) {
+ screen.addPreference(mVideoPreference);
+ }
+
+ @Override
+ protected List<? extends CandidateInfo> getCandidates() {
+ final Context c = getContext();
+ List<NavModeCandidateInfo> candidates = new ArrayList<>();
+
+ if (SystemNavigationPreferenceController.isOverlayPackageAvailable(c,
+ NAV_BAR_MODE_GESTURAL_OVERLAY)) {
+ candidates.add(new NavModeCandidateInfo(
+ c.getText(R.string.edge_to_edge_navigation_title),
+ c.getText(R.string.edge_to_edge_navigation_summary),
+ KEY_SYSTEM_NAV_GESTURAL, true /* enabled */));
+ }
+ if (SystemNavigationPreferenceController.isOverlayPackageAvailable(c,
+ NAV_BAR_MODE_2BUTTON_OVERLAY)) {
+ candidates.add(new NavModeCandidateInfo(
+ c.getText(R.string.swipe_up_to_switch_apps_title),
+ c.getText(R.string.swipe_up_to_switch_apps_summary),
+ KEY_SYSTEM_NAV_2BUTTONS, true /* enabled */));
+ }
+ if (SystemNavigationPreferenceController.isOverlayPackageAvailable(c,
+ NAV_BAR_MODE_3BUTTON_OVERLAY)) {
+ candidates.add(new NavModeCandidateInfo(
+ c.getText(R.string.legacy_navigation_title),
+ c.getText(R.string.legacy_navigation_summary),
+ KEY_SYSTEM_NAV_3BUTTONS, true /* enabled */));
+ }
+
+ return candidates;
+ }
+
+ @Override
+ protected String getDefaultKey() {
+ return getCurrentSystemNavigationMode(getContext());
+ }
+
+ @Override
+ protected boolean setDefaultKey(String key) {
+ setCurrentSystemNavigationMode(mOverlayManager, key);
+ setIllustrationVideo(mVideoPreference, key);
+ return true;
+ }
+
+ @VisibleForTesting
+ static String getCurrentSystemNavigationMode(Context context) {
+ if (SystemNavigationPreferenceController.isEdgeToEdgeEnabled(context)) {
+ return KEY_SYSTEM_NAV_GESTURAL;
+ } else if (SystemNavigationPreferenceController.isSwipeUpEnabled(context)) {
+ return KEY_SYSTEM_NAV_2BUTTONS;
+ } else {
+ return KEY_SYSTEM_NAV_3BUTTONS;
+ }
+ }
+
+ @VisibleForTesting
+ static void setCurrentSystemNavigationMode(IOverlayManager overlayManager, String key) {
+ switch (key) {
+ case KEY_SYSTEM_NAV_GESTURAL:
+ setNavBarInteractionMode(overlayManager, NAV_BAR_MODE_GESTURAL_OVERLAY);
+ break;
+ case KEY_SYSTEM_NAV_2BUTTONS:
+ setNavBarInteractionMode(overlayManager, NAV_BAR_MODE_2BUTTON_OVERLAY);
+ break;
+ case KEY_SYSTEM_NAV_3BUTTONS:
+ setNavBarInteractionMode(overlayManager, NAV_BAR_MODE_3BUTTON_OVERLAY);
+ break;
+ }
+ }
+
+ /**
+ * Enables the specified overlay package.
+ */
+ static void setNavBarInteractionMode(IOverlayManager overlayManager, String overlayPackage) {
+ try {
+ overlayManager.setEnabledExclusiveInCategory(overlayPackage, USER_CURRENT);
+ } catch (RemoteException e) {
+ throw e.rethrowFromSystemServer();
+ }
+ }
+
+ static void setIllustrationVideo(VideoPreference videoPref, String systemNavKey) {
+ videoPref.setVideo(0, 0);
+ switch (systemNavKey) {
+ case KEY_SYSTEM_NAV_GESTURAL:
+ videoPref.setVideo(R.raw.system_nav_fully_gestural,
+ R.drawable.system_nav_fully_gestural);
+ break;
+ case KEY_SYSTEM_NAV_2BUTTONS:
+ videoPref.setVideo(R.raw.system_nav_2_button, R.drawable.system_nav_2_button);
+ break;
+ case KEY_SYSTEM_NAV_3BUTTONS:
+ videoPref.setVideo(R.raw.system_nav_3_button, R.drawable.system_nav_3_button);
+ break;
+ }
+ }
+
+ @Override
+ public void bindPreferenceExtra(RadioButtonPreference pref,
+ String key, CandidateInfo info, String defaultKey, String systemDefaultKey) {
+ if (info instanceof NavModeCandidateInfo) {
+ pref.setSummary(((NavModeCandidateInfo) info).loadSummary());
+ pref.setAppendixVisibility(View.GONE);
+ }
+ }
+
+ static class NavModeCandidateInfo extends CandidateInfo {
+ private final CharSequence mLabel;
+ private final CharSequence mSummary;
+ private final String mKey;
+
+ NavModeCandidateInfo(CharSequence label, CharSequence summary, String key,
+ boolean enabled) {
+ super(enabled);
+ mLabel = label;
+ mSummary = summary;
+ mKey = key;
+ }
+
+ @Override
+ public CharSequence loadLabel() {
+ return mLabel;
+ }
+
+ public CharSequence loadSummary() {
+ return mSummary;
+ }
+
+ @Override
+ public Drawable loadIcon() {
+ return null;
+ }
+
+ @Override
+ public String getKey() {
+ return mKey;
+ }
+ }
+
+ public static final Indexable.SearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
new BaseSearchIndexProvider() {
@Override
public List<SearchIndexableResource> getXmlResourcesToIndex(
diff --git a/src/com/android/settings/gestures/SystemNavigationLegacyPreferenceController.java b/src/com/android/settings/gestures/SystemNavigationLegacyPreferenceController.java
deleted file mode 100644
index 7ac9a03..0000000
--- a/src/com/android/settings/gestures/SystemNavigationLegacyPreferenceController.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * Copyright (C) 2019 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.settings.gestures;
-
-import static android.view.WindowManagerPolicyConstants.NAV_BAR_MODE_3BUTTON_OVERLAY;
-
-import android.content.Context;
-import android.content.om.IOverlayManager;
-import android.os.ServiceManager;
-import android.text.TextUtils;
-
-import androidx.annotation.VisibleForTesting;
-
-import com.android.settings.widget.RadioButtonPreference;
-
-public class SystemNavigationLegacyPreferenceController extends
- SystemNavigationPreferenceController {
- static final String PREF_KEY_LEGACY = "gesture_legacy";
-
- public SystemNavigationLegacyPreferenceController(Context context, String key) {
- this(context, IOverlayManager.Stub.asInterface(ServiceManager.getService(
- Context.OVERLAY_SERVICE)), key);
- }
-
- @VisibleForTesting
- public SystemNavigationLegacyPreferenceController(Context context,
- IOverlayManager overlayManager, String key) {
- super(context, overlayManager, key, NAV_BAR_MODE_3BUTTON_OVERLAY);
- }
-
- @Override
- public void onRadioButtonClicked(RadioButtonPreference preference) {
- setNavBarInteractionMode(mOverlayManager, NAV_BAR_MODE_3BUTTON_OVERLAY);
- selectRadioButtonInGroup(PREF_KEY_LEGACY, mPreferenceScreen);
- }
-
- @Override
- public boolean isChecked() {
- return !isEdgeToEdgeEnabled(mContext) && !isSwipeUpEnabled(mContext);
- }
-}
diff --git a/src/com/android/settings/gestures/SystemNavigationPreferenceController.java b/src/com/android/settings/gestures/SystemNavigationPreferenceController.java
index 664e7bb..d0d8155 100644
--- a/src/com/android/settings/gestures/SystemNavigationPreferenceController.java
+++ b/src/com/android/settings/gestures/SystemNavigationPreferenceController.java
@@ -16,79 +16,29 @@
package com.android.settings.gestures;
-import static android.os.UserHandle.USER_CURRENT;
import static android.view.WindowManagerPolicyConstants.NAV_BAR_MODE_2BUTTON;
-import static android.view.WindowManagerPolicyConstants.NAV_BAR_MODE_2BUTTON_OVERLAY;
-import static android.view.WindowManagerPolicyConstants.NAV_BAR_MODE_3BUTTON_OVERLAY;
import static android.view.WindowManagerPolicyConstants.NAV_BAR_MODE_GESTURAL;
-import static android.view.WindowManagerPolicyConstants.NAV_BAR_MODE_GESTURAL_OVERLAY;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
-import android.content.om.IOverlayManager;
import android.content.pm.PackageManager;
-import android.os.RemoteException;
-import android.text.TextUtils;
-import android.view.View;
-
-import androidx.preference.Preference;
-import androidx.preference.PreferenceScreen;
import com.android.settings.R;
-import com.android.settings.widget.RadioButtonPreference;
+import com.android.settings.core.BasePreferenceController;
-public abstract class SystemNavigationPreferenceController extends GesturePreferenceController
- implements RadioButtonPreference.OnClickListener {
+public class SystemNavigationPreferenceController extends BasePreferenceController {
+ static final String PREF_KEY_SYSTEM_NAVIGATION = "gesture_system_navigation";
private static final String ACTION_QUICKSTEP = "android.intent.action.QUICKSTEP_SERVICE";
- private static final String PREF_KEY_VIDEO = "gesture_swipe_up_video";
- private static final String[] RADIO_BUTTONS_IN_GROUP = {
- SystemNavigationLegacyPreferenceController.PREF_KEY_LEGACY,
- SystemNavigationSwipeUpPreferenceController.PREF_KEY_SWIPE_UP,
- SystemNavigationEdgeToEdgePreferenceController.PREF_KEY_EDGE_TO_EDGE,
- };
-
- protected final IOverlayManager mOverlayManager;
- protected PreferenceScreen mPreferenceScreen;
- private final String mOverlayPackage;
-
- public SystemNavigationPreferenceController(Context context, IOverlayManager overlayManager,
- String key, String overlayPackage) {
+ public SystemNavigationPreferenceController(Context context, String key) {
super(context, key);
- mOverlayManager = overlayManager;
- mOverlayPackage = overlayPackage;
}
@Override
public int getAvailabilityStatus() {
- return isGestureAvailable(mContext, mOverlayPackage) ? AVAILABLE : UNSUPPORTED_ON_DEVICE;
- }
-
- @Override
- public void displayPreference(PreferenceScreen screen) {
- super.displayPreference(screen);
- mPreferenceScreen = screen;
-
- Preference preference = screen.findPreference(getPreferenceKey());
- if (preference != null && preference instanceof RadioButtonPreference) {
- RadioButtonPreference radioPreference = (RadioButtonPreference) preference;
- radioPreference.setOnClickListener(this);
- radioPreference.setAppendixVisibility(View.GONE);
- }
- }
-
- @Override
- public boolean setChecked(boolean isChecked) {
- if (!isChecked || mPreferenceScreen == null) {
- return false;
- }
- Preference preference = mPreferenceScreen.findPreference(getPreferenceKey());
- if (preference != null && preference instanceof RadioButtonPreference) {
- onRadioButtonClicked((RadioButtonPreference) preference);
- }
- return true;
+ return isGestureAvailable(mContext) ? AVAILABLE : UNSUPPORTED_ON_DEVICE;
}
@Override
@@ -102,17 +52,7 @@
}
}
- @Override
- protected String getVideoPrefKey() {
- return PREF_KEY_VIDEO;
- }
-
-
static boolean isGestureAvailable(Context context) {
- return isGestureAvailable(context, null /* overlayPackage */);
- }
-
- static boolean isGestureAvailable(Context context, String overlayPackage) {
// Skip if the swipe up settings are not available
if (!context.getResources().getBoolean(
com.android.internal.R.bool.config_swipe_up_gesture_setting_available)) {
@@ -127,44 +67,22 @@
}
// Skip if the overview proxy service exists
- final PackageManager pm = context.getPackageManager();
final Intent quickStepIntent = new Intent(ACTION_QUICKSTEP)
.setPackage(recentsComponentName.getPackageName());
- if (pm.resolveService(quickStepIntent, PackageManager.MATCH_SYSTEM_ONLY) == null) {
+ if (context.getPackageManager().resolveService(quickStepIntent,
+ PackageManager.MATCH_SYSTEM_ONLY) == null) {
return false;
}
- // Skip if the required overlay package is defined but doesn't exist
- if (overlayPackage != null) {
- try {
- return pm.getPackageInfo(overlayPackage, 0 /* flags */) != null;
- } catch (PackageManager.NameNotFoundException e) {
- // Not found, just return unavailable
- return false;
- }
- }
-
return true;
}
- static void selectRadioButtonInGroup(String preferenceKey, PreferenceScreen screen) {
- if (screen == null) {
- return;
- }
- for (String key : RADIO_BUTTONS_IN_GROUP) {
- ((RadioButtonPreference) screen.findPreference(key)).setChecked(
- TextUtils.equals(key, preferenceKey));
- }
- }
-
- /**
- * Enables the specified overlay package.
- */
- static void setNavBarInteractionMode(IOverlayManager overlayManager, String overlayPackage) {
+ static boolean isOverlayPackageAvailable(Context context, String overlayPackage) {
try {
- overlayManager.setEnabledExclusiveInCategory(overlayPackage, USER_CURRENT);
- } catch (RemoteException e) {
- throw e.rethrowFromSystemServer();
+ return context.getPackageManager().getPackageInfo(overlayPackage, 0) != null;
+ } catch (PackageManager.NameNotFoundException e) {
+ // Not found, just return unavailable
+ return false;
}
}
diff --git a/src/com/android/settings/gestures/SystemNavigationSwipeUpPreferenceController.java b/src/com/android/settings/gestures/SystemNavigationSwipeUpPreferenceController.java
deleted file mode 100644
index 592b231..0000000
--- a/src/com/android/settings/gestures/SystemNavigationSwipeUpPreferenceController.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * Copyright (C) 2019 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.settings.gestures;
-
-import static android.view.WindowManagerPolicyConstants.NAV_BAR_MODE_2BUTTON_OVERLAY;
-
-import android.content.Context;
-import android.content.om.IOverlayManager;
-import android.os.ServiceManager;
-import android.text.TextUtils;
-
-import androidx.annotation.VisibleForTesting;
-
-import com.android.settings.widget.RadioButtonPreference;
-
-public class SystemNavigationSwipeUpPreferenceController extends
- SystemNavigationPreferenceController {
- static final String PREF_KEY_SWIPE_UP = "gesture_swipe_up";
-
- public SystemNavigationSwipeUpPreferenceController(Context context, String key) {
- this(context, IOverlayManager.Stub.asInterface(ServiceManager.getService(
- Context.OVERLAY_SERVICE)), key);
- }
-
- @VisibleForTesting
- public SystemNavigationSwipeUpPreferenceController(Context context,
- IOverlayManager overlayManager, String key) {
- super(context, overlayManager, key, NAV_BAR_MODE_2BUTTON_OVERLAY);
- }
-
- @Override
- public void onRadioButtonClicked(RadioButtonPreference preference) {
- setNavBarInteractionMode(mOverlayManager, NAV_BAR_MODE_2BUTTON_OVERLAY);
- selectRadioButtonInGroup(PREF_KEY_SWIPE_UP, mPreferenceScreen);
- }
-
- @Override
- public boolean isChecked() {
- return isSwipeUpEnabled(mContext);
- }
-}
diff --git a/src/com/android/settings/homepage/SettingsHomepageActivity.java b/src/com/android/settings/homepage/SettingsHomepageActivity.java
index e767664..fa23101 100644
--- a/src/com/android/settings/homepage/SettingsHomepageActivity.java
+++ b/src/com/android/settings/homepage/SettingsHomepageActivity.java
@@ -27,16 +27,16 @@
import androidx.annotation.VisibleForTesting;
import androidx.fragment.app.Fragment;
+import androidx.fragment.app.FragmentActivity;
import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentTransaction;
import com.android.settings.R;
import com.android.settings.accounts.AvatarViewMixin;
-import com.android.settings.core.SettingsBaseActivity;
import com.android.settings.homepage.contextualcards.ContextualCardsFragment;
import com.android.settings.overlay.FeatureFactory;
-public class SettingsHomepageActivity extends SettingsBaseActivity {
+public class SettingsHomepageActivity extends FragmentActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
diff --git a/src/com/android/settings/homepage/contextualcards/ContextualCardsFragment.java b/src/com/android/settings/homepage/contextualcards/ContextualCardsFragment.java
index 0704ed8..92892b3 100644
--- a/src/com/android/settings/homepage/contextualcards/ContextualCardsFragment.java
+++ b/src/com/android/settings/homepage/contextualcards/ContextualCardsFragment.java
@@ -33,12 +33,11 @@
import com.android.settings.core.InstrumentedFragment;
import com.android.settings.homepage.contextualcards.slices.SwipeDismissalDelegate;
import com.android.settings.overlay.FeatureFactory;
+import com.android.settings.wifi.slice.ContextualWifiScanWorker;
public class ContextualCardsFragment extends InstrumentedFragment implements
FocusRecyclerView.FocusListener {
- private static final String TAG = "ContextualCardsFragment";
-
private FocusRecyclerView mCardsContainer;
private GridLayoutManager mLayoutManager;
private ContextualCardsAdapter mContextualCardsAdapter;
@@ -60,6 +59,7 @@
@Override
public void onStart() {
super.onStart();
+ ContextualWifiScanWorker.newVisibleUiSession();
mContextualCardManager.loadContextualCards(LoaderManager.getInstance(this));
}
diff --git a/src/com/android/settings/location/LocationSettings.java b/src/com/android/settings/location/LocationSettings.java
index 6871428..7142486 100644
--- a/src/com/android/settings/location/LocationSettings.java
+++ b/src/com/android/settings/location/LocationSettings.java
@@ -33,7 +33,7 @@
import com.android.settings.widget.SwitchBar;
import com.android.settingslib.core.AbstractPreferenceController;
import com.android.settingslib.core.lifecycle.Lifecycle;
-import com.android.settingslib.location.RecentLocationAccesses;
+import com.android.settingslib.location.RecentLocationApps;
import com.android.settingslib.search.SearchIndexable;
import java.util.ArrayList;
@@ -50,7 +50,7 @@
* <li>In switch bar: location master switch. Used to toggle location on and off.
* </li>
* </ul>
- * <li>Recent location requests: automatically populated by {@link RecentLocationAccesses}</li>
+ * <li>Recent location requests: automatically populated by {@link RecentLocationApps}</li>
* <li>Location services: multi-app settings provided from outside the Android framework. Each
* is injected by a system-partition app via the {@link SettingInjectorService} API.</li>
* </ul>
@@ -118,7 +118,7 @@
final List<AbstractPreferenceController> controllers = new ArrayList<>();
controllers.add(new AppLocationPermissionPreferenceController(context, lifecycle));
controllers.add(new LocationForWorkPreferenceController(context, lifecycle));
- controllers.add(new RecentLocationAccessPreferenceController(context));
+ controllers.add(new RecentLocationRequestPreferenceController(context, fragment, lifecycle));
controllers.add(new LocationScanningPreferenceController(context));
controllers.add(new LocationServicePreferenceController(context, fragment, lifecycle));
controllers.add(new LocationFooterPreferenceController(context, lifecycle));
diff --git a/src/com/android/settings/location/RecentLocationRequestPreferenceController.java b/src/com/android/settings/location/RecentLocationRequestPreferenceController.java
new file mode 100644
index 0000000..fb8c62c
--- /dev/null
+++ b/src/com/android/settings/location/RecentLocationRequestPreferenceController.java
@@ -0,0 +1,145 @@
+/*
+ * Copyright (C) 2017 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 android.content.Context;
+import android.os.Bundle;
+import android.os.UserHandle;
+
+import androidx.annotation.VisibleForTesting;
+import androidx.preference.Preference;
+import androidx.preference.PreferenceCategory;
+import androidx.preference.PreferenceScreen;
+
+import com.android.settings.R;
+import com.android.settings.applications.appinfo.AppInfoDashboardFragment;
+import com.android.settings.core.SubSettingLauncher;
+import com.android.settings.dashboard.DashboardFragment;
+import com.android.settingslib.core.lifecycle.Lifecycle;
+import com.android.settingslib.location.RecentLocationApps;
+import com.android.settingslib.widget.apppreference.AppPreference;
+
+import java.util.List;
+
+public class RecentLocationRequestPreferenceController extends LocationBasePreferenceController {
+ /** Key for preference category "Recent location requests" */
+ private static final String KEY_RECENT_LOCATION_REQUESTS = "recent_location_requests";
+ @VisibleForTesting
+ static final String KEY_SEE_ALL_BUTTON = "recent_location_requests_see_all_button";
+ private final LocationSettings mFragment;
+ private final RecentLocationApps mRecentLocationApps;
+ private PreferenceCategory mCategoryRecentLocationRequests;
+
+ /** Used in this class and {@link RecentLocationRequestSeeAllPreferenceController} */
+ static class PackageEntryClickedListener implements Preference.OnPreferenceClickListener {
+ private final DashboardFragment mFragment;
+ private final String mPackage;
+ private final UserHandle mUserHandle;
+
+ public PackageEntryClickedListener(DashboardFragment fragment, String packageName,
+ UserHandle userHandle) {
+ mFragment = fragment;
+ mPackage = packageName;
+ mUserHandle = userHandle;
+ }
+
+ @Override
+ public boolean onPreferenceClick(Preference preference) {
+ // start new fragment to display extended information
+ final Bundle args = new Bundle();
+ args.putString(AppInfoDashboardFragment.ARG_PACKAGE_NAME, mPackage);
+ new SubSettingLauncher(mFragment.getContext())
+ .setDestination(AppInfoDashboardFragment.class.getName())
+ .setArguments(args)
+ .setTitleRes(R.string.application_info_label)
+ .setUserHandle(mUserHandle)
+ .setSourceMetricsCategory(mFragment.getMetricsCategory())
+ .launch();
+ return true;
+ }
+ }
+
+ public RecentLocationRequestPreferenceController(Context context, LocationSettings fragment,
+ Lifecycle lifecycle) {
+ this(context, fragment, lifecycle, new RecentLocationApps(context));
+ }
+
+ @VisibleForTesting
+ RecentLocationRequestPreferenceController(Context context, LocationSettings fragment,
+ Lifecycle lifecycle, RecentLocationApps recentApps) {
+ super(context, lifecycle);
+ mFragment = fragment;
+ mRecentLocationApps = recentApps;
+ }
+
+ @Override
+ public String getPreferenceKey() {
+ return KEY_RECENT_LOCATION_REQUESTS;
+ }
+
+ @Override
+ public void displayPreference(PreferenceScreen screen) {
+ super.displayPreference(screen);
+ mCategoryRecentLocationRequests =
+ (PreferenceCategory) screen.findPreference(KEY_RECENT_LOCATION_REQUESTS);
+ }
+
+ @Override
+ public void updateState(Preference preference) {
+ mCategoryRecentLocationRequests.removeAll();
+ final Context prefContext = preference.getContext();
+ final List<RecentLocationApps.Request> recentLocationRequests =
+ mRecentLocationApps.getAppListSorted(false);
+ if (recentLocationRequests.size() > 3) {
+ // Display the top 3 preferences to container in original order.
+ for (int i = 0; i < 3; i++) {
+ mCategoryRecentLocationRequests.addPreference(
+ createAppPreference(prefContext, recentLocationRequests.get(i)));
+ }
+ } else if (recentLocationRequests.size() > 0) {
+ // Add preferences to container in original order (already sorted by recency).
+ for (RecentLocationApps.Request request : recentLocationRequests) {
+ mCategoryRecentLocationRequests.addPreference(
+ createAppPreference(prefContext, request));
+ }
+ } else {
+ // If there's no item to display, add a "No recent apps" item.
+ final Preference banner = createAppPreference(prefContext);
+ banner.setTitle(R.string.location_no_recent_apps);
+ banner.setSelectable(false);
+ mCategoryRecentLocationRequests.addPreference(banner);
+ }
+ }
+
+ @Override
+ public void onLocationModeChanged(int mode, boolean restricted) {
+ mCategoryRecentLocationRequests.setEnabled(mLocationEnabler.isEnabled(mode));
+ }
+
+ @VisibleForTesting
+ AppPreference createAppPreference(Context prefContext) {
+ return new AppPreference(prefContext);
+ }
+
+ @VisibleForTesting
+ AppPreference createAppPreference(Context prefContext, RecentLocationApps.Request request) {
+ final AppPreference pref = createAppPreference(prefContext);
+ pref.setSummary(request.contentDescription);
+ pref.setIcon(request.icon);
+ pref.setTitle(request.label);
+ pref.setOnPreferenceClickListener(new PackageEntryClickedListener(
+ mFragment, request.packageName, request.userHandle));
+ return pref;
+ }
+}
diff --git a/src/com/android/settings/location/RecentLocationRequestSeeAllFragment.java b/src/com/android/settings/location/RecentLocationRequestSeeAllFragment.java
new file mode 100644
index 0000000..9e4a77f
--- /dev/null
+++ b/src/com/android/settings/location/RecentLocationRequestSeeAllFragment.java
@@ -0,0 +1,135 @@
+/*
+ * 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.location;
+
+import android.content.Context;
+import android.provider.SearchIndexableResource;
+import android.view.Menu;
+import android.view.MenuInflater;
+import android.view.MenuItem;
+
+import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
+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.search.SearchIndexable;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+/** Dashboard Fragment to display all recent location requests, sorted by recency. */
+@SearchIndexable
+public class RecentLocationRequestSeeAllFragment extends DashboardFragment {
+ private static final String TAG = "RecentLocationReqAll";
+ public static final String PATH =
+ "com.android.settings.location.RecentLocationRequestSeeAllFragment";
+
+ private static final int MENU_SHOW_SYSTEM = Menu.FIRST + 1;
+ private static final int MENU_HIDE_SYSTEM = Menu.FIRST + 2;
+
+ private boolean mShowSystem = false;
+ private MenuItem mShowSystemMenu;
+ private MenuItem mHideSystemMenu;
+ private RecentLocationRequestSeeAllPreferenceController mController;
+
+ @Override
+ public int getMetricsCategory() {
+ return MetricsEvent.RECENT_LOCATION_REQUESTS_ALL;
+ }
+
+ @Override
+ protected int getPreferenceScreenResId() {
+ return R.xml.location_recent_requests_see_all;
+ }
+
+ @Override
+ protected String getLogTag() {
+ return TAG;
+ }
+
+ @Override
+ protected List<AbstractPreferenceController> createPreferenceControllers(Context context) {
+ return buildPreferenceControllers(context, getSettingsLifecycle(), this);
+ }
+
+ @Override
+ public boolean onOptionsItemSelected(MenuItem menuItem) {
+ switch (menuItem.getItemId()) {
+ case MENU_SHOW_SYSTEM:
+ case MENU_HIDE_SYSTEM:
+ mShowSystem = menuItem.getItemId() == MENU_SHOW_SYSTEM;
+ updateMenu();
+ if (mController != null) {
+ mController.setShowSystem(mShowSystem);
+ }
+ return true;
+ default:
+ return super.onOptionsItemSelected(menuItem);
+ }
+ }
+
+ private void updateMenu() {
+ mShowSystemMenu.setVisible(!mShowSystem);
+ mHideSystemMenu.setVisible(mShowSystem);
+ }
+
+ private static List<AbstractPreferenceController> buildPreferenceControllers(
+ Context context, Lifecycle lifecycle, RecentLocationRequestSeeAllFragment fragment) {
+ final List<AbstractPreferenceController> controllers = new ArrayList<>();
+ final RecentLocationRequestSeeAllPreferenceController controller =
+ new RecentLocationRequestSeeAllPreferenceController(context, lifecycle, fragment);
+ controllers.add(controller);
+ if (fragment != null) {
+ fragment.mController = controller;
+ }
+ return controllers;
+ }
+
+ /**
+ * For Search.
+ */
+ public static final Indexable.SearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
+ new BaseSearchIndexProvider() {
+ @Override
+ public List<SearchIndexableResource> getXmlResourcesToIndex(
+ Context context, boolean enabled) {
+ final SearchIndexableResource sir = new SearchIndexableResource(context);
+ sir.xmlResId = R.xml.location_recent_requests_see_all;
+ return Arrays.asList(sir);
+ }
+
+ @Override
+ public List<AbstractPreferenceController> getPreferenceControllers(Context
+ context) {
+ return buildPreferenceControllers(
+ context, /* lifecycle = */ null, /* fragment = */ null);
+ }
+ };
+
+ @Override
+ public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
+ super.onCreateOptionsMenu(menu, inflater);
+ mShowSystemMenu = menu.add(Menu.NONE, MENU_SHOW_SYSTEM, Menu.NONE,
+ R.string.menu_show_system);
+ mHideSystemMenu = menu.add(Menu.NONE, MENU_HIDE_SYSTEM, Menu.NONE,
+ R.string.menu_hide_system);
+ updateMenu();
+ }
+}
diff --git a/src/com/android/settings/location/RecentLocationRequestSeeAllPreferenceController.java b/src/com/android/settings/location/RecentLocationRequestSeeAllPreferenceController.java
new file mode 100644
index 0000000..3abccf7
--- /dev/null
+++ b/src/com/android/settings/location/RecentLocationRequestSeeAllPreferenceController.java
@@ -0,0 +1,116 @@
+/*
+ * 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.location;
+
+import android.content.Context;
+
+import androidx.annotation.VisibleForTesting;
+import androidx.preference.Preference;
+import androidx.preference.PreferenceCategory;
+import androidx.preference.PreferenceScreen;
+
+import com.android.settingslib.core.lifecycle.Lifecycle;
+import com.android.settingslib.location.RecentLocationApps;
+import com.android.settingslib.widget.apppreference.AppPreference;
+
+import java.util.List;
+
+import com.android.settings.R;
+
+/** Preference controller for preference category displaying all recent location requests. */
+public class RecentLocationRequestSeeAllPreferenceController
+ extends LocationBasePreferenceController {
+ /** Key for preference category "All recent location requests" */
+ private static final String KEY_ALL_RECENT_LOCATION_REQUESTS = "all_recent_location_requests";
+ private final RecentLocationRequestSeeAllFragment mFragment;
+ private PreferenceCategory mCategoryAllRecentLocationRequests;
+ private RecentLocationApps mRecentLocationApps;
+ private boolean mShowSystem = false;
+ private Preference mPreference;
+
+ public RecentLocationRequestSeeAllPreferenceController(
+ Context context, Lifecycle lifecycle, RecentLocationRequestSeeAllFragment fragment) {
+ this(context, lifecycle, fragment, new RecentLocationApps(context));
+ }
+
+ @VisibleForTesting
+ RecentLocationRequestSeeAllPreferenceController(
+ Context context,
+ Lifecycle lifecycle,
+ RecentLocationRequestSeeAllFragment fragment,
+ RecentLocationApps recentLocationApps) {
+ super(context, lifecycle);
+ mFragment = fragment;
+ mRecentLocationApps = recentLocationApps;
+ }
+
+ @Override
+ public String getPreferenceKey() {
+ return KEY_ALL_RECENT_LOCATION_REQUESTS;
+ }
+
+ @Override
+ public void onLocationModeChanged(int mode, boolean restricted) {
+ mCategoryAllRecentLocationRequests.setEnabled(mLocationEnabler.isEnabled(mode));
+ }
+
+ @Override
+ public void displayPreference(PreferenceScreen screen) {
+ super.displayPreference(screen);
+ mCategoryAllRecentLocationRequests =
+ (PreferenceCategory) screen.findPreference(KEY_ALL_RECENT_LOCATION_REQUESTS);
+ }
+
+ @Override
+ public void updateState(Preference preference) {
+ mCategoryAllRecentLocationRequests.removeAll();
+ mPreference = preference;
+ List<RecentLocationApps.Request> requests = mRecentLocationApps.getAppListSorted(
+ mShowSystem);
+ if (requests.isEmpty()) {
+ // If there's no item to display, add a "No recent apps" item.
+ final Preference banner = new AppPreference(mContext);
+ banner.setTitle(R.string.location_no_recent_apps);
+ banner.setSelectable(false);
+ mCategoryAllRecentLocationRequests.addPreference(banner);
+ } else {
+ for (RecentLocationApps.Request request : requests) {
+ Preference appPreference = createAppPreference(preference.getContext(), request);
+ mCategoryAllRecentLocationRequests.addPreference(appPreference);
+ }
+ }
+ }
+
+ @VisibleForTesting
+ AppPreference createAppPreference(
+ Context prefContext, RecentLocationApps.Request request) {
+ final AppPreference pref = new AppPreference(prefContext);
+ pref.setSummary(request.contentDescription);
+ pref.setIcon(request.icon);
+ pref.setTitle(request.label);
+ pref.setOnPreferenceClickListener(
+ new RecentLocationRequestPreferenceController.PackageEntryClickedListener(
+ mFragment, request.packageName, request.userHandle));
+ return pref;
+ }
+
+ public void setShowSystem(boolean showSystem) {
+ mShowSystem = showSystem;
+ if (mPreference != null) {
+ updateState(mPreference);
+ }
+ }
+}
diff --git a/src/com/android/settings/network/telephony/ApnPreferenceController.java b/src/com/android/settings/network/telephony/ApnPreferenceController.java
index 9fdb6ea..98c1f5b 100644
--- a/src/com/android/settings/network/telephony/ApnPreferenceController.java
+++ b/src/com/android/settings/network/telephony/ApnPreferenceController.java
@@ -65,8 +65,11 @@
final boolean isGsmApn = MobileNetworkUtils.isGsmOptions(mContext, subId)
&& carrierConfig != null
&& carrierConfig.getBoolean(CarrierConfigManager.KEY_APN_EXPAND_BOOL);
+ final boolean hideCarrierNetwork = carrierConfig == null
+ || carrierConfig.getBoolean(
+ CarrierConfigManager.KEY_HIDE_CARRIER_NETWORK_SETTINGS_BOOL);
- return isCdmaApn || isGsmApn
+ return !hideCarrierNetwork && (isCdmaApn || isGsmApn)
? AVAILABLE
: CONDITIONALLY_UNAVAILABLE;
}
diff --git a/src/com/android/settings/network/telephony/MobileNetworkUtils.java b/src/com/android/settings/network/telephony/MobileNetworkUtils.java
index 9b25338..0c099ca 100644
--- a/src/com/android/settings/network/telephony/MobileNetworkUtils.java
+++ b/src/com/android/settings/network/telephony/MobileNetworkUtils.java
@@ -355,6 +355,8 @@
|| carrierConfig == null
|| !carrierConfig.getBoolean(
CarrierConfigManager.KEY_OPERATOR_SELECTION_EXPAND_BOOL)
+ || carrierConfig.getBoolean(
+ CarrierConfigManager.KEY_HIDE_CARRIER_NETWORK_SETTINGS_BOOL)
|| (carrierConfig.getBoolean(CarrierConfigManager.KEY_CSP_ENABLED_BOOL)
&& !telephonyManager.isManualNetworkSelectionAllowed())) {
return false;
diff --git a/src/com/android/settings/network/telephony/gsm/AutoSelectPreferenceController.java b/src/com/android/settings/network/telephony/gsm/AutoSelectPreferenceController.java
index adfb1d8..56d0b2d 100644
--- a/src/com/android/settings/network/telephony/gsm/AutoSelectPreferenceController.java
+++ b/src/com/android/settings/network/telephony/gsm/AutoSelectPreferenceController.java
@@ -52,7 +52,6 @@
private static final long MINIMUM_DIALOG_TIME_MILLIS = TimeUnit.SECONDS.toMillis(1);
private final Handler mUiHandler;
- private int mSubId;
private TelephonyManager mTelephonyManager;
private boolean mOnlyAutoSelectInHome;
private List<OnNetworkSelectModeListener> mListeners;
diff --git a/src/com/android/settings/network/telephony/gsm/OpenNetworkSelectPagePreferenceController.java b/src/com/android/settings/network/telephony/gsm/OpenNetworkSelectPagePreferenceController.java
index 9ac0d12..46171bc 100644
--- a/src/com/android/settings/network/telephony/gsm/OpenNetworkSelectPagePreferenceController.java
+++ b/src/com/android/settings/network/telephony/gsm/OpenNetworkSelectPagePreferenceController.java
@@ -42,7 +42,6 @@
TelephonyBasePreferenceController implements
AutoSelectPreferenceController.OnNetworkSelectModeListener {
- private int mSubId;
private TelephonyManager mTelephonyManager;
private Preference mPreference;
diff --git a/src/com/android/settings/notification/BubbleNotificationPreferenceController.java b/src/com/android/settings/notification/BubbleNotificationPreferenceController.java
deleted file mode 100644
index 83e73e9..0000000
--- a/src/com/android/settings/notification/BubbleNotificationPreferenceController.java
+++ /dev/null
@@ -1,124 +0,0 @@
-/*
- * 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.notification;
-
-import static android.provider.Settings.Secure.NOTIFICATION_BUBBLES;
-import static android.provider.Settings.Secure.NOTIFICATION_BUBBLES;
-
-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.text.TextUtils;
-
-import com.android.settings.core.PreferenceControllerMixin;
-import com.android.settings.core.TogglePreferenceController;
-import com.android.settingslib.core.lifecycle.LifecycleObserver;
-import com.android.settingslib.core.lifecycle.events.OnPause;
-import com.android.settingslib.core.lifecycle.events.OnResume;
-
-import androidx.annotation.VisibleForTesting;
-import androidx.preference.Preference;
-import androidx.preference.PreferenceScreen;
-
-public class BubbleNotificationPreferenceController extends TogglePreferenceController
- implements PreferenceControllerMixin, Preference.OnPreferenceChangeListener,
- LifecycleObserver, OnResume, OnPause {
-
- private static final String TAG = "BubbleNotifPrefContr";
- @VisibleForTesting
- static final int ON = 1;
- @VisibleForTesting
- static final int OFF = 0;
-
- private SettingObserver mSettingObserver;
-
- public BubbleNotificationPreferenceController(Context context, String preferenceKey) {
- super(context, preferenceKey);
- }
-
- @Override
- public void displayPreference(PreferenceScreen screen) {
- super.displayPreference(screen);
- Preference preference = screen.findPreference(getPreferenceKey());
- if (preference != null) {
- mSettingObserver = new SettingObserver(preference);
- }
- }
-
- @Override
- public void onResume() {
- if (mSettingObserver != null) {
- mSettingObserver.register(mContext.getContentResolver(), true /* register */);
- }
- }
-
- @Override
- public void onPause() {
- if (mSettingObserver != null) {
- mSettingObserver.register(mContext.getContentResolver(), false /* register */);
- }
- }
-
- @Override
- public int getAvailabilityStatus() {
- return AVAILABLE;
- }
-
- @Override
- public boolean isChecked() {
- return Settings.Secure.getInt(mContext.getContentResolver(),
- NOTIFICATION_BUBBLES, ON) == ON;
- }
-
- @Override
- public boolean setChecked(boolean isChecked) {
- return Settings.Secure.putInt(mContext.getContentResolver(),
- NOTIFICATION_BUBBLES, isChecked ? ON : OFF);
- }
-
- class SettingObserver extends ContentObserver {
-
- private final Uri NOTIFICATION_BUBBLES_URI =
- Settings.Secure.getUriFor(NOTIFICATION_BUBBLES);
-
- private final Preference mPreference;
-
- public SettingObserver(Preference preference) {
- super(new Handler());
- mPreference = preference;
- }
-
- public void register(ContentResolver cr, boolean register) {
- if (register) {
- cr.registerContentObserver(NOTIFICATION_BUBBLES_URI, false, this);
- } else {
- cr.unregisterContentObserver(this);
- }
- }
-
- @Override
- public void onChange(boolean selfChange, Uri uri) {
- super.onChange(selfChange, uri);
- if (NOTIFICATION_BUBBLES_URI.equals(uri)) {
- updateState(mPreference);
- }
- }
- }
-}
diff --git a/src/com/android/settings/notification/BubbleNotificationSettings.java b/src/com/android/settings/notification/BubbleNotificationSettings.java
deleted file mode 100644
index 7044293..0000000
--- a/src/com/android/settings/notification/BubbleNotificationSettings.java
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- * 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.notification;
-
-import android.app.settings.SettingsEnums;
-import android.content.Context;
-import android.provider.SearchIndexableResource;
-
-import com.android.settings.R;
-import com.android.settings.core.OnActivityResultListener;
-import com.android.settings.dashboard.DashboardFragment;
-import com.android.settings.search.BaseSearchIndexProvider;
-import com.android.settingslib.search.SearchIndexable;
-
-import java.util.Arrays;
-import java.util.List;
-
-@SearchIndexable
-public class BubbleNotificationSettings extends DashboardFragment implements
- OnActivityResultListener {
- private static final String TAG = "BubbleNotiSettings";
-
- @Override
- public int getMetricsCategory() {
- return SettingsEnums.BUBBLE_SETTINGS;
- }
-
- @Override
- protected String getLogTag() {
- return TAG;
- }
-
- @Override
- protected int getPreferenceScreenResId() {
- return R.xml.bubble_notification_settings;
- }
-
- /**
- * For Search.
- */
- public static final SearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
- new BaseSearchIndexProvider() {
- @Override
- public List<SearchIndexableResource> getXmlResourcesToIndex(
- Context context, boolean enabled) {
- final SearchIndexableResource sir = new SearchIndexableResource(context);
- sir.xmlResId = R.xml.bubble_notification_settings;
- return Arrays.asList(sir);
- }
- };
-}
diff --git a/src/com/android/settings/notification/BubblePreferenceController.java b/src/com/android/settings/notification/BubblePreferenceController.java
index f373752..200c4b2 100644
--- a/src/com/android/settings/notification/BubblePreferenceController.java
+++ b/src/com/android/settings/notification/BubblePreferenceController.java
@@ -25,6 +25,7 @@
import com.android.settings.core.PreferenceControllerMixin;
import com.android.settingslib.RestrictedSwitchPreference;
+import androidx.annotation.VisibleForTesting;
import androidx.fragment.app.FragmentManager;
import androidx.preference.Preference;
@@ -33,8 +34,10 @@
private static final String TAG = "BubblePrefContr";
private static final String KEY = "bubble_pref";
- private static final int SYSTEM_WIDE_ON = 1;
- private static final int SYSTEM_WIDE_OFF = 0;
+ @VisibleForTesting
+ static final int SYSTEM_WIDE_ON = 1;
+ @VisibleForTesting
+ static final int SYSTEM_WIDE_OFF = 0;
private FragmentManager mFragmentManager;
@@ -58,18 +61,14 @@
if (!super.isAvailable()) {
return false;
}
- if (mAppRow == null && mChannel == null) {
+ if (!isGloballyEnabled()) {
return false;
}
if (mChannel != null) {
- if (Settings.Secure.getInt(mContext.getContentResolver(),
- NOTIFICATION_BUBBLES, SYSTEM_WIDE_ON) == SYSTEM_WIDE_OFF) {
- return false;
- }
if (isDefaultChannel()) {
return true;
} else {
- return mAppRow == null ? false : mAppRow.allowBubbles;
+ return mAppRow != null && mAppRow.allowBubbles;
}
}
return true;
@@ -80,12 +79,10 @@
RestrictedSwitchPreference pref = (RestrictedSwitchPreference) preference;
pref.setDisabledByAdmin(mAdmin);
if (mChannel != null) {
- pref.setChecked(mChannel.canBubble());
+ pref.setChecked(mChannel.canBubble() && isGloballyEnabled());
pref.setEnabled(!pref.isDisabledByAdmin());
} else {
- pref.setChecked(mAppRow.allowBubbles
- && Settings.Secure.getInt(mContext.getContentResolver(),
- NOTIFICATION_BUBBLES, SYSTEM_WIDE_ON) == SYSTEM_WIDE_ON);
+ pref.setChecked(mAppRow.allowBubbles && isGloballyEnabled());
pref.setSummary(mContext.getString(
R.string.bubbles_app_toggle_summary, mAppRow.label));
}
@@ -94,7 +91,7 @@
@Override
public boolean onPreferenceChange(Preference preference, Object newValue) {
- final boolean value = (Boolean) newValue;
+ final boolean value = (Boolean) newValue && isGloballyEnabled();
if (mChannel != null) {
mChannel.setAllowBubbles(value);
saveChannel();
@@ -103,9 +100,7 @@
RestrictedSwitchPreference pref = (RestrictedSwitchPreference) preference;
// if the global setting is off, toggling app level permission requires extra
// confirmation
- if (Settings.Secure.getInt(mContext.getContentResolver(),
- NOTIFICATION_BUBBLES, SYSTEM_WIDE_ON) == SYSTEM_WIDE_OFF
- && !pref.isChecked()) {
+ if (!isGloballyEnabled() && !pref.isChecked()) {
new BubbleWarningDialogFragment()
.setPkgInfo(mAppRow.pkg, mAppRow.uid)
.show(mFragmentManager, "dialog");
@@ -118,6 +113,11 @@
return true;
}
+ private boolean isGloballyEnabled() {
+ return Settings.Secure.getInt(mContext.getContentResolver(),
+ NOTIFICATION_BUBBLES, SYSTEM_WIDE_OFF) == SYSTEM_WIDE_ON;
+ }
+
// Used in app level prompt that confirms the user is ok with turning on bubbles
// globally. If they aren't, undo what
public static void revertBubblesApproval(Context mContext, String pkg, int uid) {
diff --git a/src/com/android/settings/notification/BubbleSummaryNotificationPreferenceController.java b/src/com/android/settings/notification/BubbleSummaryNotificationPreferenceController.java
deleted file mode 100644
index e26d9a8..0000000
--- a/src/com/android/settings/notification/BubbleSummaryNotificationPreferenceController.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * 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.notification;
-
-import static android.provider.Settings.Secure.NOTIFICATION_BUBBLES;
-
-import android.content.Context;
-import android.provider.Settings;
-
-import com.android.settings.R;
-import com.android.settings.core.BasePreferenceController;
-
-import androidx.annotation.VisibleForTesting;
-
-public class BubbleSummaryNotificationPreferenceController extends BasePreferenceController {
-
- @VisibleForTesting
- static final int ON = 1;
-
- public BubbleSummaryNotificationPreferenceController(Context context, String preferenceKey) {
- super(context, preferenceKey);
- }
-
- @Override
- public CharSequence getSummary() {
- return mContext.getString(
- areBubblesEnabled() ? R.string.switch_on_text : R.string.switch_off_text);
- }
-
- @Override
- public int getAvailabilityStatus() {
- return AVAILABLE;
- }
-
- private boolean areBubblesEnabled() {
- return Settings.Secure.getInt(mContext.getContentResolver(),
- NOTIFICATION_BUBBLES, ON) == ON;
- }
-}
diff --git a/src/com/android/settings/notification/BubbleSummaryPreferenceController.java b/src/com/android/settings/notification/BubbleSummaryPreferenceController.java
index 5f58f67..b1632c4 100644
--- a/src/com/android/settings/notification/BubbleSummaryPreferenceController.java
+++ b/src/com/android/settings/notification/BubbleSummaryPreferenceController.java
@@ -27,13 +27,16 @@
import com.android.settings.applications.AppInfoBase;
import com.android.settings.core.SubSettingLauncher;
+import androidx.annotation.VisibleForTesting;
import androidx.preference.Preference;
public class BubbleSummaryPreferenceController extends NotificationPreferenceController {
private static final String KEY = "bubble_link_pref";
- private static final int SYSTEM_WIDE_ON = 1;
- private static final int SYSTEM_WIDE_OFF = 0;
+ @VisibleForTesting
+ static final int SYSTEM_WIDE_ON = 1;
+ @VisibleForTesting
+ static final int SYSTEM_WIDE_OFF = 0;
public BubbleSummaryPreferenceController(Context context, NotificationBackend backend) {
super(context, backend);
@@ -53,17 +56,16 @@
return false;
}
if (mChannel != null) {
- if (Settings.Secure.getInt(mContext.getContentResolver(),
- NOTIFICATION_BUBBLES, SYSTEM_WIDE_ON) == SYSTEM_WIDE_OFF) {
+ if (!isGloballyEnabled()) {
return false;
}
if (isDefaultChannel()) {
return true;
} else {
- return mAppRow == null ? false : mAppRow.allowBubbles;
+ return mAppRow != null && mAppRow.allowBubbles;
}
}
- return true;
+ return isGloballyEnabled();
}
@Override
@@ -89,13 +91,16 @@
boolean canBubble = false;
if (mAppRow != null) {
if (mChannel != null) {
- canBubble |= mChannel.canBubble();
+ canBubble |= mChannel.canBubble() && isGloballyEnabled();
} else {
- canBubble |= mAppRow.allowBubbles
- && (Settings.Secure.getInt(mContext.getContentResolver(),
- NOTIFICATION_BUBBLES, SYSTEM_WIDE_ON) == SYSTEM_WIDE_ON);
+ canBubble |= mAppRow.allowBubbles && isGloballyEnabled();
}
}
return mContext.getString(canBubble ? R.string.switch_on_text : R.string.switch_off_text);
}
+
+ private boolean isGloballyEnabled() {
+ return Settings.Secure.getInt(mContext.getContentResolver(),
+ NOTIFICATION_BUBBLES, SYSTEM_WIDE_OFF) == SYSTEM_WIDE_ON;
+ }
}
diff --git a/src/com/android/settings/notification/RecentNotifyingAppsPreferenceController.java b/src/com/android/settings/notification/RecentNotifyingAppsPreferenceController.java
index 1fe7e7d..d5e1723 100644
--- a/src/com/android/settings/notification/RecentNotifyingAppsPreferenceController.java
+++ b/src/com/android/settings/notification/RecentNotifyingAppsPreferenceController.java
@@ -79,7 +79,6 @@
private final PackageManager mPm;
private final NotificationBackend mNotificationBackend;
private IUsageStatsManager mUsageStatsManager;
- private final int mUserId;
private final IconDrawableFactory mIconDrawableFactory;
private Calendar mCal;
@@ -104,7 +103,6 @@
ApplicationsState appState, Fragment host) {
super(context);
mIconDrawableFactory = IconDrawableFactory.newInstance(context);
- mUserId = UserHandle.myUserId();
mPm = context.getPackageManager();
mHost = host;
mApplicationsState = appState;
@@ -177,7 +175,6 @@
e.printStackTrace();
}
if (events != null) {
-
ArrayMap<String, NotifyingApp> aggregatedStats = new ArrayMap<>();
UsageEvents.Event event = new UsageEvents.Event();
@@ -205,7 +202,8 @@
}
}
- private static String getKey(int userId, String pkg) {
+ @VisibleForTesting
+ static String getKey(int userId, String pkg) {
return userId + "|" + pkg;
}
@@ -252,12 +250,13 @@
}
boolean rebindPref = true;
- NotificationAppPreference pref = appPreferences.remove(pkgName);
+ NotificationAppPreference pref = appPreferences.remove(getKey(app.getUserId(),
+ pkgName));
if (pref == null) {
pref = new NotificationAppPreference(prefContext);
rebindPref = false;
}
- pref.setKey(pkgName);
+ pref.setKey(getKey(app.getUserId(), pkgName));
pref.setTitle(appEntry.label);
pref.setIcon(mIconDrawableFactory.getBadgedIcon(appEntry.info));
pref.setIconSize(TwoTargetPreference.ICON_SIZE_SMALL);
@@ -267,11 +266,11 @@
Bundle args = new Bundle();
args.putString(AppInfoBase.ARG_PACKAGE_NAME, pkgName);
args.putInt(AppInfoBase.ARG_PACKAGE_UID, appEntry.info.uid);
-
pref.setIntent(new SubSettingLauncher(mHost.getActivity())
.setDestination(AppNotificationSettings.class.getName())
.setTitleRes(R.string.notifications_title)
.setArguments(args)
+ .setUserHandle(new UserHandle(UserHandle.getUserId(appEntry.info.uid)))
.setSourceMetricsCategory(
SettingsEnums.MANAGE_APPLICATIONS_NOTIFICATIONS)
.toIntent());
@@ -301,11 +300,11 @@
int count = 0;
for (NotifyingApp app : mApps) {
final ApplicationsState.AppEntry appEntry = mApplicationsState.getEntry(
- app.getPackage(), mUserId);
+ app.getPackage(), app.getUserId());
if (appEntry == null) {
continue;
}
- if (!shouldIncludePkgInRecents(app.getPackage())) {
+ if (!shouldIncludePkgInRecents(app.getPackage(), app.getUserId())) {
continue;
}
displayableApps.add(app);
@@ -321,14 +320,14 @@
/**
* Whether or not the app should be included in recent list.
*/
- private boolean shouldIncludePkgInRecents(String pkgName) {
+ private boolean shouldIncludePkgInRecents(String pkgName, int userId) {
final Intent launchIntent = new Intent().addCategory(Intent.CATEGORY_LAUNCHER)
.setPackage(pkgName);
if (mPm.resolveActivity(launchIntent, 0) == null) {
// Not visible on launcher -> likely not a user visible app, skip if non-instant.
final ApplicationsState.AppEntry appEntry =
- mApplicationsState.getEntry(pkgName, mUserId);
+ mApplicationsState.getEntry(pkgName, userId);
if (appEntry == null || appEntry.info == null || !AppUtils.isInstant(appEntry.info)) {
Log.d(TAG, "Not a user visible or instant app, skipping " + pkgName);
return false;
diff --git a/src/com/android/settings/panel/SettingsPanelActivity.java b/src/com/android/settings/panel/SettingsPanelActivity.java
index a2cb277..749a46e 100644
--- a/src/com/android/settings/panel/SettingsPanelActivity.java
+++ b/src/com/android/settings/panel/SettingsPanelActivity.java
@@ -18,13 +18,10 @@
import static com.android.settingslib.media.MediaOutputSliceConstants.EXTRA_PACKAGE_NAME;
-import android.app.settings.SettingsEnums;
import android.content.Intent;
import android.os.Bundle;
-import android.text.TextUtils;
import android.util.Log;
import android.view.Gravity;
-import android.view.MotionEvent;
import android.view.Window;
import android.view.WindowManager;
@@ -35,8 +32,6 @@
import com.android.internal.annotations.VisibleForTesting;
import com.android.settings.R;
-import com.android.settings.overlay.FeatureFactory;
-import com.android.settings.panel.PanelLoggingContract.PanelClosedKeys;
/**
* Dialog Activity to host Settings Slices.
@@ -66,17 +61,17 @@
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
- showOrUpdatePanel();
+ createOrUpdatePanel(true /* shouldForceCreation */);
}
@Override
protected void onNewIntent(Intent intent) {
super.onNewIntent(intent);
setIntent(intent);
- showOrUpdatePanel();
+ createOrUpdatePanel(false /* shouldForceCreation */);
}
- private void showOrUpdatePanel() {
+ private void createOrUpdatePanel(boolean shouldForceCreation) {
final Intent callingIntent = getIntent();
if (callingIntent == null) {
Log.e(TAG, "Null intent, closing Panel Activity");
@@ -95,7 +90,7 @@
final Fragment fragment = fragmentManager.findFragmentById(R.id.main_content);
// If fragment already exists, we will need to update panel with animation.
- if (fragment != null && fragment instanceof PanelFragment) {
+ if (!shouldForceCreation && fragment != null && fragment instanceof PanelFragment) {
final PanelFragment panelFragment = (PanelFragment) fragment;
panelFragment.setArguments(mBundle);
((PanelFragment) fragment).updatePanelWithAnimation();
diff --git a/src/com/android/settings/slices/SlicesFeatureProvider.java b/src/com/android/settings/slices/SlicesFeatureProvider.java
index ae94f29..b649eb2 100644
--- a/src/com/android/settings/slices/SlicesFeatureProvider.java
+++ b/src/com/android/settings/slices/SlicesFeatureProvider.java
@@ -18,9 +18,9 @@
/**
* Starts a new UI session for the purpose of using Slices.
*
- * A UI session is defined as an duration of time when user stays in a UI screen. Screen
- * rotation does not break the continuation of session, going to a sub-page and coming out does
- * not break the continuation either. Leaving the page and coming back breaks it.
+ * A UI session is defined as a duration of time when user stays in a UI screen. Screen rotation
+ * does not break the continuation of session, going to a sub-page and coming out does not break
+ * the continuation either. Leaving the page and coming back breaks it.
*/
void newUiSession();
diff --git a/src/com/android/settings/slices/SlicesFeatureProviderImpl.java b/src/com/android/settings/slices/SlicesFeatureProviderImpl.java
index 297f2c1..87d7401 100644
--- a/src/com/android/settings/slices/SlicesFeatureProviderImpl.java
+++ b/src/com/android/settings/slices/SlicesFeatureProviderImpl.java
@@ -24,8 +24,6 @@
import com.android.settings.wifi.calling.WifiCallingSliceHelper;
import com.android.settingslib.utils.ThreadUtils;
-import java.util.Random;
-
/**
* Manages Slices in Settings.
*/
diff --git a/src/com/android/settings/widget/SwitchBar.java b/src/com/android/settings/widget/SwitchBar.java
index f8743d1..3341304 100644
--- a/src/com/android/settings/widget/SwitchBar.java
+++ b/src/com/android/settings/widget/SwitchBar.java
@@ -61,6 +61,16 @@
void onSwitchChanged(Switch switchView, boolean isChecked);
}
+ public interface LabelDelegate {
+ /**
+ * Called to create label and set the title with Accessibility
+ * service name to the textView of switchBar.
+ *
+ * @param isChecked The checked state of switchView.
+ */
+ String createLabel(boolean isChecked);
+ }
+
private static final int[] XML_ATTRIBUTES = {
R.attr.switchBarMarginStart,
R.attr.switchBarMarginEnd,
@@ -90,6 +100,7 @@
private boolean mDisabledByAdmin;
private EnforcedAdmin mEnforcedAdmin = null;
private String mMetricsTag;
+ private LabelDelegate mLabelDelegate;
public SwitchBar(Context context) {
@@ -178,7 +189,11 @@
}
public void setTextViewLabelAndBackground(boolean isChecked) {
- mLabel = getResources().getString(isChecked ? mOnTextId : mOffTextId);
+ if(mLabelDelegate != null) {
+ mLabel = mLabelDelegate.createLabel(isChecked);
+ } else {
+ mLabel = getResources().getString(isChecked ? mOnTextId : mOffTextId);
+ }
setBackgroundColor(isChecked ? mBackgroundActivatedColor : mBackgroundColor);
updateText();
}
@@ -383,4 +398,9 @@
requestLayout();
}
+
+ public void setLabelDelegate(LabelDelegate labelDelegate) {
+ mLabelDelegate = labelDelegate;
+ setTextViewLabelAndBackground(isChecked());
+ }
}
diff --git a/src/com/android/settings/widget/UsageGraph.java b/src/com/android/settings/widget/UsageGraph.java
index 7cef66f..505dc58 100644
--- a/src/com/android/settings/widget/UsageGraph.java
+++ b/src/com/android/settings/widget/UsageGraph.java
@@ -288,7 +288,11 @@
canvas.drawPath(mPath, paint);
}
- private void drawFilledPath(Canvas canvas, SparseIntArray localPaths, Paint paint) {
+ @VisibleForTesting
+ void drawFilledPath(Canvas canvas, SparseIntArray localPaths, Paint paint) {
+ if (localPaths.size() == 0) {
+ return;
+ }
mPath.reset();
float lastStartX = localPaths.keyAt(0);
mPath.moveTo(localPaths.keyAt(0), localPaths.valueAt(0));
diff --git a/src/com/android/settings/wifi/WifiConfigController.java b/src/com/android/settings/wifi/WifiConfigController.java
index ba26f02..0be7c2b 100644
--- a/src/com/android/settings/wifi/WifiConfigController.java
+++ b/src/com/android/settings/wifi/WifiConfigController.java
@@ -582,9 +582,11 @@
}
/**
- * Special handling for WPA2/WPA3 in Transition mode: The key SECURITY_PSK_SAE_TRANSITION is
- * a pseudo key which results by the scan results, but never appears in the saved networks.
- * A saved network is either WPA3 for supporting devices or WPA2 for non-supporting devices.
+ * Special handling for WPA2/WPA3 and OWE in Transition mode: The key
+ * SECURITY_PSK_SAE_TRANSITION and SECURITY_OWE_TRANSITION are pseudo keys which result by the
+ * scan results, but never appears in the saved networks.
+ * A saved network is either WPA3 for supporting devices or WPA2 for non-supporting devices,
+ * or, OWE for supporting devices or Open for non-supporting devices.
*
* @param accessPointSecurity Access point current security type
* @return Converted security type (if required)
@@ -597,6 +599,14 @@
return AccessPoint.SECURITY_PSK;
}
}
+ if (accessPointSecurity == AccessPoint.SECURITY_OWE_TRANSITION) {
+ if (mWifiManager.isEnhancedOpenSupported()) {
+ return AccessPoint.SECURITY_OWE;
+ } else {
+ return AccessPoint.SECURITY_NONE;
+ }
+ }
+
return accessPointSecurity;
}
@@ -948,7 +958,8 @@
private void showSecurityFields() {
if (mAccessPointSecurity == AccessPoint.SECURITY_NONE ||
- mAccessPointSecurity == AccessPoint.SECURITY_OWE) {
+ mAccessPointSecurity == AccessPoint.SECURITY_OWE ||
+ mAccessPointSecurity == AccessPoint.SECURITY_OWE_TRANSITION) {
mView.findViewById(R.id.security_fields).setVisibility(View.GONE);
return;
}
diff --git a/src/com/android/settings/wifi/WifiSettings.java b/src/com/android/settings/wifi/WifiSettings.java
index 4d3f230..8c4bfa2 100644
--- a/src/com/android/settings/wifi/WifiSettings.java
+++ b/src/com/android/settings/wifi/WifiSettings.java
@@ -494,7 +494,9 @@
if (isSavedNetwork) {
connect(mSelectedAccessPoint.getConfig(), isSavedNetwork);
} else if ((mSelectedAccessPoint.getSecurity() == AccessPoint.SECURITY_NONE) ||
- (mSelectedAccessPoint.getSecurity() == AccessPoint.SECURITY_OWE)) {
+ (mSelectedAccessPoint.getSecurity() == AccessPoint.SECURITY_OWE) ||
+ (mSelectedAccessPoint.getSecurity()
+ == AccessPoint.SECURITY_OWE_TRANSITION)) {
/** Bypass dialog for unsecured networks */
mSelectedAccessPoint.generateOpenNetworkConfig();
connect(mSelectedAccessPoint.getConfig(), isSavedNetwork);
@@ -748,7 +750,8 @@
preference.setOrder(index);
if (mOpenSsid != null && mOpenSsid.equals(accessPoint.getSsidStr())
&& (accessPoint.getSecurity() != AccessPoint.SECURITY_NONE &&
- accessPoint.getSecurity() != AccessPoint.SECURITY_OWE)) {
+ accessPoint.getSecurity() != AccessPoint.SECURITY_OWE &&
+ accessPoint.getSecurity() != AccessPoint.SECURITY_OWE_TRANSITION)) {
if (!accessPoint.isSaved() || isDisabledByWrongPassword(accessPoint)) {
onPreferenceTreeClick(preference);
mOpenSsid = null;
diff --git a/src/com/android/settings/wifi/WifiUtils.java b/src/com/android/settings/wifi/WifiUtils.java
index 9b3c1b3..c4df567 100644
--- a/src/com/android/settings/wifi/WifiUtils.java
+++ b/src/com/android/settings/wifi/WifiUtils.java
@@ -268,7 +268,8 @@
if (accessPoint.isOsuProvider()) {
return CONNECT_TYPE_OSU_PROVISION;
} else if ((accessPoint.getSecurity() == AccessPoint.SECURITY_NONE) ||
- (accessPoint.getSecurity() == AccessPoint.SECURITY_OWE)) {
+ (accessPoint.getSecurity() == AccessPoint.SECURITY_OWE) ||
+ (accessPoint.getSecurity() == AccessPoint.SECURITY_OWE_TRANSITION)) {
return CONNECT_TYPE_OPEN_NETWORK;
} else if (accessPoint.isSaved() && config != null
&& config.getNetworkSelectionStatus() != null
diff --git a/src/com/android/settings/wifi/details/AddDevicePreferenceController.java b/src/com/android/settings/wifi/details/AddDevicePreferenceController.java
index eb7e226..f2b3d75 100644
--- a/src/com/android/settings/wifi/details/AddDevicePreferenceController.java
+++ b/src/com/android/settings/wifi/details/AddDevicePreferenceController.java
@@ -29,7 +29,7 @@
import com.android.settingslib.wifi.AccessPoint;
/**
- * {@link AbstractPreferenceController} that launches Wi-Fi Easy Connect configurator flow
+ * {@link BasePreferenceController} that launches Wi-Fi Easy Connect configurator flow
*/
public class AddDevicePreferenceController extends BasePreferenceController {
diff --git a/src/com/android/settings/wifi/qrcode/QrCamera.java b/src/com/android/settings/wifi/qrcode/QrCamera.java
index b7d41ba..6088fa5 100644
--- a/src/com/android/settings/wifi/qrcode/QrCamera.java
+++ b/src/com/android/settings/wifi/qrcode/QrCamera.java
@@ -313,9 +313,6 @@
private void setTransformationMatrix(Size viewSize) {
// Check aspect ratio, can only handle square view.
final int viewRatio = (int)getRatio(viewSize.getWidth(), viewSize.getHeight());
- if (viewRatio != 1) {
- throw new IllegalArgumentException("Preview area should be square");
- }
final boolean isPortrait = mContext.get().getResources().getConfiguration().orientation
== Configuration.ORIENTATION_PORTRAIT ? true : false;
diff --git a/src/com/android/settings/wifi/slice/ConnectToWifiHandler.java b/src/com/android/settings/wifi/slice/ConnectToWifiHandler.java
index f1b0b6f..5c92d81 100644
--- a/src/com/android/settings/wifi/slice/ConnectToWifiHandler.java
+++ b/src/com/android/settings/wifi/slice/ConnectToWifiHandler.java
@@ -16,7 +16,9 @@
package com.android.settings.wifi.slice;
-import android.app.Activity;
+import android.content.BroadcastReceiver;
+import android.content.Context;
+import android.content.Intent;
import android.net.ConnectivityManager;
import android.net.Network;
import android.net.wifi.WifiManager;
@@ -30,35 +32,36 @@
import com.android.settingslib.wifi.AccessPoint;
/**
- * This activity helps connect to the Wi-Fi network which is open or saved
+ * This receiver helps connect to Wi-Fi network
*/
-public class ConnectToWifiHandler extends Activity {
+public class ConnectToWifiHandler extends BroadcastReceiver {
@Override
- public void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
+ public void onReceive(Context context, Intent intent) {
+ if (context == null || intent == null) {
+ return;
+ }
- final Network network = getIntent().getParcelableExtra(ConnectivityManager.EXTRA_NETWORK);
- final Bundle accessPointState = getIntent().getBundleExtra(
+ final Network network = intent.getParcelableExtra(ConnectivityManager.EXTRA_NETWORK);
+ final Bundle accessPointState = intent.getBundleExtra(
WifiDialogActivity.KEY_ACCESS_POINT_STATE);
if (network != null) {
WifiScanWorker.clearClickedWifi();
- final ConnectivityManager cm = getSystemService(ConnectivityManager.class);
+ final ConnectivityManager cm = context.getSystemService(ConnectivityManager.class);
// start captive portal app to sign in to network
cm.startCaptivePortalApp(network);
} else if (accessPointState != null) {
- connect(new AccessPoint(this, accessPointState));
+ connect(context, new AccessPoint(context, accessPointState));
}
-
- finish();
}
@VisibleForTesting
- void connect(AccessPoint accessPoint) {
+ void connect(Context context, AccessPoint accessPoint) {
+ ContextualWifiScanWorker.saveSession();
WifiScanWorker.saveClickedWifi(accessPoint);
- final WifiConnectListener connectListener = new WifiConnectListener(this);
+ final WifiConnectListener connectListener = new WifiConnectListener(context);
switch (WifiUtils.getConnectingType(accessPoint)) {
case WifiUtils.CONNECT_TYPE_OSU_PROVISION:
accessPoint.startOsuProvisioning(connectListener);
@@ -68,7 +71,7 @@
accessPoint.generateOpenNetworkConfig();
case WifiUtils.CONNECT_TYPE_SAVED_NETWORK:
- final WifiManager wifiManager = getSystemService(WifiManager.class);
+ final WifiManager wifiManager = context.getSystemService(WifiManager.class);
wifiManager.connect(accessPoint.getConfig(), connectListener);
break;
}
diff --git a/src/com/android/settings/wifi/slice/ContextualWifiScanWorker.java b/src/com/android/settings/wifi/slice/ContextualWifiScanWorker.java
new file mode 100644
index 0000000..5e69b8a
--- /dev/null
+++ b/src/com/android/settings/wifi/slice/ContextualWifiScanWorker.java
@@ -0,0 +1,65 @@
+/*
+ * Copyright (C) 2019 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License
+ */
+
+package com.android.settings.wifi.slice;
+
+import android.content.Context;
+import android.net.Uri;
+import android.os.SystemClock;
+
+import com.android.settings.slices.SliceBackgroundWorker;
+
+/**
+ * {@link SliceBackgroundWorker} for Wi-Fi, used by {@link ContextualWifiSlice}.
+ */
+public class ContextualWifiScanWorker extends WifiScanWorker {
+
+ private static long sVisibleUiSessionToken;
+ private static long sActiveSession;
+
+ public ContextualWifiScanWorker(Context context, Uri uri) {
+ super(context, uri);
+ }
+
+ /**
+ * Starts a new visible UI session for the purpose of automatically starting captive portal.
+ *
+ * A visible UI session is defined as a duration of time when a UI screen is visible to user.
+ * Going to a sub-page and coming out breaks the continuation, leaving the page and coming back
+ * breaks it too.
+ */
+ public static void newVisibleUiSession() {
+ sVisibleUiSessionToken = SystemClock.elapsedRealtime();
+ }
+
+ static void saveSession() {
+ sActiveSession = sVisibleUiSessionToken;
+ }
+
+ @Override
+ protected void clearClickedWifiOnSliceUnpinned() {
+ // Do nothing for contextual Wi-Fi slice
+ }
+
+ @Override
+ protected boolean isSessionValid() {
+ if (sVisibleUiSessionToken != sActiveSession) {
+ clearClickedWifi();
+ return false;
+ }
+ return true;
+ }
+}
\ No newline at end of file
diff --git a/src/com/android/settings/wifi/slice/ContextualWifiSlice.java b/src/com/android/settings/wifi/slice/ContextualWifiSlice.java
index fefbf10..97b9241 100644
--- a/src/com/android/settings/wifi/slice/ContextualWifiSlice.java
+++ b/src/com/android/settings/wifi/slice/ContextualWifiSlice.java
@@ -90,4 +90,9 @@
&& !nc.hasCapability(NetworkCapabilities.NET_CAPABILITY_PARTIAL_CONNECTIVITY)
&& nc.hasCapability(NetworkCapabilities.NET_CAPABILITY_VALIDATED);
}
+
+ @Override
+ public Class getBackgroundWorkerClass() {
+ return ContextualWifiScanWorker.class;
+ }
}
diff --git a/src/com/android/settings/wifi/slice/WifiScanWorker.java b/src/com/android/settings/wifi/slice/WifiScanWorker.java
index 8697f00..a5bd74d 100644
--- a/src/com/android/settings/wifi/slice/WifiScanWorker.java
+++ b/src/com/android/settings/wifi/slice/WifiScanWorker.java
@@ -50,7 +50,7 @@
import java.util.List;
/**
- * {@link SliceBackgroundWorker} for Wi-Fi, used by WifiSlice.
+ * {@link SliceBackgroundWorker} for Wi-Fi, used by {@link WifiSlice}.
*/
public class WifiScanWorker extends SliceBackgroundWorker<AccessPoint> implements
WifiTracker.WifiListener {
@@ -84,7 +84,7 @@
protected void onSliceUnpinned() {
mWifiTracker.onStop();
unregisterNetworkCallback();
- clearClickedWifi();
+ clearClickedWifiOnSliceUnpinned();
}
@Override
@@ -157,6 +157,14 @@
return !TextUtils.isEmpty(ssid) && TextUtils.equals(ssid, sClickedWifiSsid);
}
+ protected void clearClickedWifiOnSliceUnpinned() {
+ clearClickedWifi();
+ }
+
+ protected boolean isSessionValid() {
+ return true;
+ }
+
public void registerNetworkCallback(Network wifiNetwork) {
if (wifiNetwork == null) {
return;
@@ -224,12 +232,13 @@
// Automatically start captive portal
if (!prevIsCaptivePortal && mIsCaptivePortal
- && isWifiClicked(mWifiTracker.getManager().getConnectionInfo())) {
+ && isWifiClicked(mWifiTracker.getManager().getConnectionInfo())
+ && isSessionValid()) {
final Intent intent = new Intent(mContext, ConnectToWifiHandler.class)
.putExtra(ConnectivityManager.EXTRA_NETWORK, network)
- .addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
- // Starting activity in the system process needs to specify a user
- mContext.startActivityAsUser(intent, UserHandle.CURRENT);
+ .addFlags(Intent.FLAG_RECEIVER_FOREGROUND);
+ // Sending a broadcast in the system process needs to specify a user
+ mContext.sendBroadcastAsUser(intent, UserHandle.CURRENT);
}
}
diff --git a/src/com/android/settings/wifi/slice/WifiSlice.java b/src/com/android/settings/wifi/slice/WifiSlice.java
index a687b93..e5c8de5 100644
--- a/src/com/android/settings/wifi/slice/WifiSlice.java
+++ b/src/com/android/settings/wifi/slice/WifiSlice.java
@@ -94,6 +94,7 @@
final boolean isWifiEnabled = isWifiEnabled();
ListBuilder listBuilder = getHeaderRow(isWifiEnabled);
if (!isWifiEnabled) {
+ WifiScanWorker.clearClickedWifi();
return listBuilder.build();
}
@@ -133,11 +134,21 @@
return listBuilder.build();
}
+ private void handleNetworkCallback(WifiScanWorker worker, boolean isFirstApActive) {
+ if (worker == null) {
+ return;
+ }
+ if (isFirstApActive) {
+ worker.registerNetworkCallback(mWifiManager.getCurrentNetwork());
+ } else {
+ worker.unregisterNetworkCallback();
+ }
+ }
+
private ListBuilder getHeaderRow(boolean isWifiEnabled) {
final IconCompat icon = IconCompat.createWithResource(mContext,
R.drawable.ic_settings_wireless);
final String title = mContext.getString(R.string.wifi_settings);
- final CharSequence summary = getSummary();
final PendingIntent toggleAction = getBroadcastIntent(mContext);
final PendingIntent primaryAction = getPrimaryAction();
final SliceAction primarySliceAction = SliceAction.createDeeplink(primaryAction, icon,
@@ -150,22 +161,10 @@
.setKeywords(getKeywords())
.addRow(new ListBuilder.RowBuilder()
.setTitle(title)
- .setSubtitle(summary)
.addEndItem(toggleSliceAction)
.setPrimaryAction(primarySliceAction));
}
- private void handleNetworkCallback(WifiScanWorker worker, boolean isFirstApActive) {
- if (worker == null) {
- return;
- }
- if (isFirstApActive) {
- worker.registerNetworkCallback(mWifiManager.getCurrentNetwork());
- } else {
- worker.unregisterNetworkCallback();
- }
- }
-
private ListBuilder.RowBuilder getAccessPointRow(AccessPoint accessPoint) {
final boolean isCaptivePortal = accessPoint.isActive() && isCaptivePortal();
final CharSequence title = accessPoint.getTitle();
@@ -175,9 +174,8 @@
.setTitleItem(levelIcon, ListBuilder.ICON_IMAGE)
.setTitle(title)
.setSubtitle(summary)
- .setPrimaryAction(SliceAction.createDeeplink(
- getAccessPointAction(accessPoint, isCaptivePortal), levelIcon,
- ListBuilder.ICON_IMAGE, title));
+ .setPrimaryAction(getAccessPointAction(accessPoint, isCaptivePortal, levelIcon,
+ title));
if (isCaptivePortal) {
rowBuilder.addEndItem(getCaptivePortalEndAction(accessPoint, title));
@@ -203,7 +201,7 @@
final Drawable d = mContext.getDrawable(
com.android.settingslib.Utils.getWifiIconResource(accessPoint.getLevel()));
- @ColorInt int color;
+ final @ColorInt int color;
if (accessPoint.isActive()) {
final NetworkInfo.State state = accessPoint.getNetworkInfo().getState();
if (state == NetworkInfo.State.CONNECTED) {
@@ -232,36 +230,54 @@
}
private SliceAction getCaptivePortalEndAction(AccessPoint accessPoint, CharSequence title) {
- return SliceAction.createDeeplink(
- getAccessPointAction(accessPoint, false /* isCaptivePortal */),
- IconCompat.createWithResource(mContext, R.drawable.ic_settings_accent),
- ListBuilder.ICON_IMAGE, title);
+ return getAccessPointAction(accessPoint, false /* isCaptivePortal */,
+ IconCompat.createWithResource(mContext, R.drawable.ic_settings_accent), title);
}
- private PendingIntent getAccessPointAction(AccessPoint accessPoint, boolean isCaptivePortal) {
+ private SliceAction getAccessPointAction(AccessPoint accessPoint, boolean isCaptivePortal,
+ IconCompat icon, CharSequence title) {
+ final int requestCode = accessPoint.hashCode();
+ if (isCaptivePortal) {
+ final Intent intent = new Intent(mContext, ConnectToWifiHandler.class)
+ .putExtra(ConnectivityManager.EXTRA_NETWORK, mWifiManager.getCurrentNetwork());
+ return getBroadcastAction(requestCode, intent, icon, title);
+ }
+
final Bundle extras = new Bundle();
accessPoint.saveWifiState(extras);
- Intent intent;
- if (isCaptivePortal) {
- intent = new Intent(mContext, ConnectToWifiHandler.class);
- intent.putExtra(ConnectivityManager.EXTRA_NETWORK, mWifiManager.getCurrentNetwork());
- } else if (accessPoint.isActive()) {
- intent = new SubSettingLauncher(mContext)
+ if (accessPoint.isActive()) {
+ final Intent intent = new SubSettingLauncher(mContext)
.setTitleRes(R.string.pref_title_network_details)
.setDestination(WifiNetworkDetailsFragment.class.getName())
.setArguments(extras)
.setSourceMetricsCategory(SettingsEnums.WIFI)
.toIntent();
+ return getActivityAction(requestCode, intent, icon, title);
} else if (WifiUtils.getConnectingType(accessPoint) != WifiUtils.CONNECT_TYPE_OTHERS) {
- intent = new Intent(mContext, ConnectToWifiHandler.class);
- intent.putExtra(WifiDialogActivity.KEY_ACCESS_POINT_STATE, extras);
+ final Intent intent = new Intent(mContext, ConnectToWifiHandler.class)
+ .putExtra(WifiDialogActivity.KEY_ACCESS_POINT_STATE, extras);
+ return getBroadcastAction(requestCode, intent, icon, title);
} else {
- intent = new Intent(mContext, WifiDialogActivity.class);
- intent.putExtra(WifiDialogActivity.KEY_ACCESS_POINT_STATE, extras);
+ final Intent intent = new Intent(mContext, WifiDialogActivity.class)
+ .putExtra(WifiDialogActivity.KEY_ACCESS_POINT_STATE, extras);
+ return getActivityAction(requestCode, intent, icon, title);
}
- return PendingIntent.getActivity(mContext, accessPoint.hashCode() /* requestCode */,
- intent, 0 /* flags */);
+ }
+
+ private SliceAction getActivityAction(int requestCode, Intent intent, IconCompat icon,
+ CharSequence title) {
+ final PendingIntent pi = PendingIntent.getActivity(mContext, requestCode, intent,
+ 0 /* flags */);
+ return SliceAction.createDeeplink(pi, icon, ListBuilder.ICON_IMAGE, title);
+ }
+
+ private SliceAction getBroadcastAction(int requestCode, Intent intent, IconCompat icon,
+ CharSequence title) {
+ intent.addFlags(Intent.FLAG_RECEIVER_FOREGROUND);
+ final PendingIntent pi = PendingIntent.getBroadcast(mContext, requestCode, intent,
+ PendingIntent.FLAG_UPDATE_CURRENT);
+ return SliceAction.create(pi, icon, ListBuilder.ICON_IMAGE, title);
}
private ListBuilder.RowBuilder getLoadingRow(CharSequence placeholder) {
@@ -277,7 +293,7 @@
.setSubtitle(title);
}
- protected boolean isCaptivePortal() {
+ private boolean isCaptivePortal() {
final NetworkCapabilities nc = mConnectivityManager.getNetworkCapabilities(
mWifiManager.getCurrentNetwork());
return WifiUtils.canSignIntoNetwork(nc);
@@ -320,20 +336,6 @@
}
}
- private CharSequence getSummary() {
- switch (mWifiManager.getWifiState()) {
- case WifiManager.WIFI_STATE_ENABLED:
- case WifiManager.WIFI_STATE_ENABLING:
- return mContext.getText(R.string.switch_on_text);
- case WifiManager.WIFI_STATE_DISABLED:
- case WifiManager.WIFI_STATE_DISABLING:
- return mContext.getText(R.string.switch_off_text);
- case WifiManager.WIFI_STATE_UNKNOWN:
- default:
- return null;
- }
- }
-
private PendingIntent getPrimaryAction() {
final Intent intent = getIntent();
return PendingIntent.getActivity(mContext, 0 /* requestCode */,
diff --git a/tests/robotests/src/com/android/settings/SetupWizardUtilsTest.java b/tests/robotests/src/com/android/settings/SetupWizardUtilsTest.java
index b965d78..5f4f31b 100644
--- a/tests/robotests/src/com/android/settings/SetupWizardUtilsTest.java
+++ b/tests/robotests/src/com/android/settings/SetupWizardUtilsTest.java
@@ -19,6 +19,7 @@
import static com.google.common.truth.Truth.assertThat;
import android.content.Intent;
+import android.os.Bundle;
import android.sysprop.SetupWizardProperties;
import com.google.android.setupcompat.util.WizardManagerHelper;
@@ -31,9 +32,6 @@
@RunWith(RobolectricTestRunner.class)
public class SetupWizardUtilsTest {
- private static final String EXTRA_IS_SETUP_FLOW = "isSetupFlow";
- private static final String EXTRA_IS_FIRST_RUN = "firstRun";
-
@Test
public void testCopySetupExtras() {
Intent fromIntent = new Intent();
@@ -46,6 +44,25 @@
assertThat(theme).isEqualTo(toIntent.getStringExtra(WizardManagerHelper.EXTRA_THEME));
assertThat(toIntent.getBooleanExtra(WizardManagerHelper.EXTRA_IS_SETUP_FLOW, false))
.isTrue();
+ assertThat(toIntent.getBooleanExtra(WizardManagerHelper.EXTRA_IS_FIRST_RUN, true))
+ .isFalse();
+ }
+
+ @Test
+ public void testCopyLifecycleExtra() {
+ Intent fromIntent = new Intent();
+ final String theme = "TEST_THEME";
+ fromIntent.putExtra(WizardManagerHelper.EXTRA_THEME, theme);
+ fromIntent.putExtra(WizardManagerHelper.EXTRA_IS_SETUP_FLOW, true);
+ Bundle dstBundle = new Bundle();
+ dstBundle = SetupWizardUtils.copyLifecycleExtra(fromIntent.getExtras(), dstBundle);
+
+ assertThat(dstBundle).isNotNull();
+ assertThat(dstBundle.getString(WizardManagerHelper.EXTRA_THEME)).isNull();
+ assertThat(dstBundle.getBoolean(WizardManagerHelper.EXTRA_IS_SETUP_FLOW))
+ .isTrue();
+ assertThat(dstBundle.getBoolean(WizardManagerHelper.EXTRA_IS_FIRST_RUN))
+ .isFalse();
}
@Test
@@ -87,7 +104,7 @@
private Intent createSetupWizardIntent() {
return new Intent()
- .putExtra(EXTRA_IS_SETUP_FLOW, true)
- .putExtra(EXTRA_IS_FIRST_RUN, true);
+ .putExtra(WizardManagerHelper.EXTRA_IS_SETUP_FLOW, true)
+ .putExtra(WizardManagerHelper.EXTRA_IS_FIRST_RUN, true);
}
}
diff --git a/tests/robotests/src/com/android/settings/accessibility/AccessibilitySettingsForSetupWizardActivityTest.java b/tests/robotests/src/com/android/settings/accessibility/AccessibilitySettingsForSetupWizardActivityTest.java
index a0a9de9..c3a630b 100644
--- a/tests/robotests/src/com/android/settings/accessibility/AccessibilitySettingsForSetupWizardActivityTest.java
+++ b/tests/robotests/src/com/android/settings/accessibility/AccessibilitySettingsForSetupWizardActivityTest.java
@@ -16,18 +16,27 @@
package com.android.settings.accessibility;
+import static com.android.settings.accessibility.AccessibilitySettingsForSetupWizardActivity.CLASS_NAME_FONT_SIZE_SETTINGS_FOR_SUW;
+
import static com.google.common.truth.Truth.assertThat;
+import android.content.ComponentName;
import android.content.Intent;
import androidx.test.filters.SmallTest;
import com.android.settings.R;
+import com.android.settings.SettingsActivity;
+import com.android.settings.display.FontSizePreferenceFragmentForSetupWizard;
+
+import com.google.android.setupcompat.util.WizardManagerHelper;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.robolectric.Robolectric;
import org.robolectric.RobolectricTestRunner;
+import org.robolectric.RuntimeEnvironment;
+import org.robolectric.Shadows;
@RunWith(RobolectricTestRunner.class)
@SmallTest
@@ -41,4 +50,37 @@
assertThat(activity.getThemeResId()).isEqualTo(R.style.GlifV3Theme_Light);
}
+
+ @Test
+ public void onCreate_hasFontSizeComponent_shouldGoToFontSizePreferenceDirectly() {
+ AccessibilitySettingsForSetupWizardActivity activity =
+ Robolectric.buildActivity(AccessibilitySettingsForSetupWizardActivity.class,
+ new Intent(Intent.ACTION_MAIN).setComponent(new ComponentName(
+ RuntimeEnvironment.application, CLASS_NAME_FONT_SIZE_SETTINGS_FOR_SUW)).
+ putExtra(WizardManagerHelper.EXTRA_IS_FIRST_RUN, true).
+ putExtra(WizardManagerHelper.EXTRA_IS_SETUP_FLOW, true)).get();
+
+ activity.tryLaunchFontSizeSettings();
+
+ final Intent launchIntent = Shadows.shadowOf(activity).getNextStartedActivity();
+ assertThat(launchIntent).isNotNull();
+ assertThat(launchIntent.getStringExtra(SettingsActivity.EXTRA_SHOW_FRAGMENT)).isEqualTo(
+ FontSizePreferenceFragmentForSetupWizard.class.getName());
+ assertThat(activity.isFinishing()).isTrue();
+ }
+
+ @Test
+ public void onCreate_noFontSizeComponent_shouldNotFinishCurrentActivity() {
+ AccessibilitySettingsForSetupWizardActivity activity =
+ Robolectric.buildActivity(AccessibilitySettingsForSetupWizardActivity.class,
+ new Intent(Intent.ACTION_MAIN).
+ putExtra(WizardManagerHelper.EXTRA_IS_FIRST_RUN, true).
+ putExtra(WizardManagerHelper.EXTRA_IS_SETUP_FLOW, true)).get();
+
+ activity.tryLaunchFontSizeSettings();
+
+ final Intent launchIntent = Shadows.shadowOf(activity).getNextStartedActivity();
+ assertThat(launchIntent).isNull();
+ assertThat(activity.isFinishing()).isFalse();
+ }
}
diff --git a/tests/robotests/src/com/android/settings/datausage/DataUsageSummaryTest.java b/tests/robotests/src/com/android/settings/datausage/DataUsageSummaryTest.java
index b9bfcc1..0672bd4 100644
--- a/tests/robotests/src/com/android/settings/datausage/DataUsageSummaryTest.java
+++ b/tests/robotests/src/com/android/settings/datausage/DataUsageSummaryTest.java
@@ -27,7 +27,6 @@
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.when;
import android.app.usage.NetworkStatsManager;
import android.content.Context;
@@ -46,15 +45,16 @@
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
-import org.mockito.Answers;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import org.robolectric.Robolectric;
import org.robolectric.RobolectricTestRunner;
import org.robolectric.RuntimeEnvironment;
+import org.robolectric.Shadows;
import org.robolectric.annotation.Config;
import org.robolectric.shadows.ShadowApplication;
import org.robolectric.shadows.ShadowSubscriptionManager;
+import org.robolectric.shadows.ShadowTelephonyManager;
@Config(shadows = {
ShadowUtils.class,
@@ -71,7 +71,6 @@
private NetworkPolicyManager mNetworkPolicyManager;
@Mock
private NetworkStatsManager mNetworkStatsManager;
- @Mock(answer = Answers.RETURNS_DEEP_STUBS)
private TelephonyManager mTelephonyManager;
private Context mContext;
private FragmentActivity mActivity;
@@ -90,8 +89,11 @@
shadowContext.setSystemService(Context.NETWORK_POLICY_SERVICE, mNetworkPolicyManager);
mContext = spy(RuntimeEnvironment.application);
- when(mContext.getSystemService(Context.TELEPHONY_SERVICE)).thenReturn(mTelephonyManager);
- when(mTelephonyManager.createForSubscriptionId(anyInt())).thenReturn(mTelephonyManager);
+ mTelephonyManager = mContext.getSystemService(TelephonyManager.class);
+ final ShadowTelephonyManager shadowTelephonyManager = Shadows.shadowOf(mTelephonyManager);
+ shadowTelephonyManager.setTelephonyManagerForSubscriptionId(
+ SubscriptionManager.INVALID_SUBSCRIPTION_ID, mTelephonyManager);
+ shadowTelephonyManager.setTelephonyManagerForSubscriptionId(1, mTelephonyManager);
mActivity = spy(Robolectric.buildActivity(FragmentActivity.class).get());
doReturn(mNetworkStatsManager).when(mActivity).getSystemService(NetworkStatsManager.class);
@@ -188,7 +190,7 @@
ShadowDataUsageUtils.IS_WIFI_SUPPORTED = true;
ShadowDataUsageUtils.HAS_SIM = false;
ShadowSubscriptionManager.setDefaultDataSubscriptionId(
- SubscriptionManager.INVALID_SUBSCRIPTION_ID);
+ SubscriptionManager.INVALID_SUBSCRIPTION_ID);
final DataUsageSummary dataUsageSummary = spy(new DataUsageSummary());
doReturn(mContext).when(dataUsageSummary).getContext();
diff --git a/tests/robotests/src/com/android/settings/development/BubbleGlobalPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/development/BubbleGlobalPreferenceControllerTest.java
new file mode 100644
index 0000000..11ca63f
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/development/BubbleGlobalPreferenceControllerTest.java
@@ -0,0 +1,111 @@
+/*
+ * 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.development;
+
+import static android.provider.Settings.Secure.NOTIFICATION_BUBBLES;
+
+import static com.android.settings.development.BubbleGlobalPreferenceController.OFF;
+import static com.android.settings.development.BubbleGlobalPreferenceController.ON;
+
+import static com.google.common.truth.Truth.assertThat;
+
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
+import android.content.Context;
+import android.provider.Settings;
+
+import androidx.preference.PreferenceScreen;
+import androidx.preference.SwitchPreference;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+import org.robolectric.RobolectricTestRunner;
+import org.robolectric.RuntimeEnvironment;
+
+@RunWith(RobolectricTestRunner.class)
+public class BubbleGlobalPreferenceControllerTest {
+ private Context mContext;
+
+ @Mock
+ private SwitchPreference mPreference;
+ @Mock
+ private PreferenceScreen mPreferenceScreen;
+
+ private BubbleGlobalPreferenceController mController;
+
+ @Before
+ public void setUp() {
+ MockitoAnnotations.initMocks(this);
+ mContext = RuntimeEnvironment.application;
+ mController = new BubbleGlobalPreferenceController(mContext);
+ when(mPreferenceScreen.findPreference(mController.getPreferenceKey()))
+ .thenReturn(mPreference);
+ mController.displayPreference(mPreferenceScreen);
+ }
+
+ @Test
+ public void onPreferenceChange_settingEnabled_allowBubbles_shouldBeOn() {
+ mController.onPreferenceChange(mPreference, true /* new value */);
+
+ assertThat(isSettingEnabled()).isTrue();
+ }
+
+ @Test
+ public void onPreferenceChange_settingDisabled_allowBubbles_shouldBeOff() {
+ mController.onPreferenceChange(mPreference, false /* new value */);
+
+ assertThat(isSettingEnabled()).isFalse();
+ }
+
+ @Test
+ public void updateState_settingEnabled_preferenceShouldBeChecked() {
+ Settings.Secure.putInt(mContext.getContentResolver(),
+ NOTIFICATION_BUBBLES, 1 /* enabled */);
+ mController.updateState(mPreference);
+
+ verify(mPreference).setChecked(true);
+ }
+
+ @Test
+ public void updateState_settingReset_defaultDisabled_preferenceShouldNotBeChecked() {
+ Settings.Secure.putInt(mContext.getContentResolver(),
+ NOTIFICATION_BUBBLES, 0 /* enabled */);
+ mController.updateState(mPreference);
+
+ verify(mPreference).setChecked(false);
+ }
+
+ @Test
+ public void onDeveloperOptionsSwitchDisabled_shouldDisable() {
+ mController.onDeveloperOptionsSwitchDisabled();
+
+ verify(mPreference).setChecked(false);
+ verify(mPreference).setEnabled(false);
+
+ assertThat(isSettingEnabled()).isFalse();
+ }
+
+ private boolean isSettingEnabled() {
+ return Settings.Secure.getInt(mContext.getContentResolver(), NOTIFICATION_BUBBLES,
+ OFF /* default off */) == ON;
+ }
+
+}
diff --git a/tests/robotests/src/com/android/settings/deviceinfo/imei/ImeiInfoDialogControllerTest.java b/tests/robotests/src/com/android/settings/deviceinfo/imei/ImeiInfoDialogControllerTest.java
index f38668c..7ad8d63 100644
--- a/tests/robotests/src/com/android/settings/deviceinfo/imei/ImeiInfoDialogControllerTest.java
+++ b/tests/robotests/src/com/android/settings/deviceinfo/imei/ImeiInfoDialogControllerTest.java
@@ -86,8 +86,8 @@
mController = spy(new ImeiInfoDialogController(mDialog, SLOT_ID));
- doReturn(PRL_VERSION).when(mController).getCdmaPrlVersion();
- doReturn(MEID_NUMBER).when(mController).getMeid();
+ when(mTelephonyManager.getCdmaPrlVersion()).thenReturn(PRL_VERSION);
+ when(mTelephonyManager.getMeid(anyInt())).thenReturn(MEID_NUMBER);
when(mTelephonyManager.getCdmaMin(anyInt())).thenReturn(MIN_NUMBER);
when(mTelephonyManager.getDeviceSoftwareVersion(anyInt())).thenReturn(IMEI_SV_NUMBER);
when(mTelephonyManager.getImei(anyInt())).thenReturn(IMEI_NUMBER);
@@ -98,6 +98,7 @@
mController = spy(new ImeiInfoDialogController(mDialog, SLOT_ID + 1));
mController.populateImeiInfo();
+
verify(mDialog, never()).setText(anyInt(), any());
}
@@ -129,17 +130,31 @@
}
@Test
- public void populateImeiInfo_cdmaSimDisabled_shouldRemoveImeiInfoAndSetMinToEmpty() {
+ public void populateImeiInfo_cdmaSimDisabled_shouldRemoveImeiInfoAndSetMinPrlToEmpty() {
ReflectionHelpers.setField(mController, "mSubscriptionInfo", null);
when(mTelephonyManager.getPhoneType()).thenReturn(TelephonyManager.PHONE_TYPE_CDMA);
mController.populateImeiInfo();
+ verify(mDialog).setText(ID_MEID_NUMBER_VALUE, MEID_NUMBER);
verify(mDialog).setText(ID_MIN_NUMBER_VALUE, "");
+ verify(mDialog).setText(ID_PRL_VERSION_VALUE, "");
verify(mDialog).removeViewFromScreen(ID_GSM_SETTINGS);
}
@Test
+ public void populateImeiInfo_gsmSimDisabled_shouldSetImeiAndRemoveCdmaSettings() {
+ ReflectionHelpers.setField(mController, "mSubscriptionInfo", null);
+ when(mTelephonyManager.getPhoneType()).thenReturn(TelephonyManager.PHONE_TYPE_GSM);
+
+ mController.populateImeiInfo();
+
+ verify(mDialog).setText(eq(ID_IMEI_VALUE), any());
+ verify(mDialog).setText(eq(ID_IMEI_SV_VALUE), any());
+ verify(mDialog).removeViewFromScreen(ID_CDMA_SETTINGS);
+ }
+
+ @Test
public void populateImeinfo_gsm_shouldSetImeiAndRemoveCdmaSettings() {
when(mTelephonyManager.getPhoneType()).thenReturn(TelephonyManager.PHONE_TYPE_GSM);
diff --git a/tests/robotests/src/com/android/settings/display/DarkUIPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/display/DarkUIPreferenceControllerTest.java
new file mode 100644
index 0000000..3659803
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/display/DarkUIPreferenceControllerTest.java
@@ -0,0 +1,78 @@
+/*
+ * 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.display;
+
+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.times;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
+import android.content.Context;
+import android.os.Handler;
+import android.os.IPowerManager;
+import android.os.PowerManager;
+
+import androidx.fragment.app.Fragment;
+import androidx.preference.PreferenceScreen;
+import androidx.preference.SwitchPreference;
+
+import org.junit.Assert;
+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 DarkUIPreferenceControllerTest {
+
+ private DarkUIPreferenceController mController;
+ private Context mContext;
+ @Mock
+ private Fragment mFragment;
+
+ @Before
+ public void setUp() {
+ MockitoAnnotations.initMocks(this);
+ mContext = spy(RuntimeEnvironment.application);
+ mController = spy(new DarkUIPreferenceController(mContext, "dark_ui_mode"));
+ mController.setParentFragment(mFragment);
+ mController.mPreference = new SwitchPreference(mContext);
+ mController.onStart();
+ }
+
+ @Test
+ public void batterySaverToggles_disabledStateUpdates() {
+ doReturn(true).when(mController).isPowerSaveMode();
+ mController.updateEnabledStateIfNeeded();
+ assertThat(mController.mPreference.isEnabled()).isFalse();
+
+ doReturn(false).when(mController).isPowerSaveMode();
+ mController.updateEnabledStateIfNeeded();
+ assertThat(mController.mPreference.isEnabled()).isTrue();
+
+ doReturn(true).when(mController).isPowerSaveMode();
+ mController.updateEnabledStateIfNeeded();
+ assertThat(mController.mPreference.isEnabled()).isFalse();
+ }
+}
diff --git a/tests/robotests/src/com/android/settings/gestures/SystemNavigationEdgeToEdgePreferenceControllerTest.java b/tests/robotests/src/com/android/settings/gestures/SystemNavigationEdgeToEdgePreferenceControllerTest.java
deleted file mode 100644
index 5c02101..0000000
--- a/tests/robotests/src/com/android/settings/gestures/SystemNavigationEdgeToEdgePreferenceControllerTest.java
+++ /dev/null
@@ -1,199 +0,0 @@
-/*
- * Copyright (C) 2019 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.settings.gestures;
-
-import static android.view.WindowManagerPolicyConstants.NAV_BAR_MODE_2BUTTON;
-import static android.view.WindowManagerPolicyConstants.NAV_BAR_MODE_3BUTTON;
-import static android.view.WindowManagerPolicyConstants.NAV_BAR_MODE_GESTURAL;
-
-import static com.android.settings.gestures.SystemNavigationEdgeToEdgePreferenceController.PREF_KEY_EDGE_TO_EDGE;
-import static com.android.settings.gestures.SystemNavigationLegacyPreferenceController.PREF_KEY_LEGACY;
-import static com.android.settings.gestures.SystemNavigationSwipeUpPreferenceController.PREF_KEY_SWIPE_UP;
-
-import static com.google.common.truth.Truth.assertThat;
-
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.times;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.when;
-
-import android.content.ComponentName;
-import android.content.Context;
-import android.content.Intent;
-import android.content.om.IOverlayManager;
-import android.content.pm.ApplicationInfo;
-import android.content.pm.ResolveInfo;
-import android.content.pm.ServiceInfo;
-
-import androidx.preference.PreferenceScreen;
-
-import com.android.internal.R;
-import com.android.settings.testutils.shadow.SettingsShadowResources;
-import com.android.settings.widget.RadioButtonPreference;
-
-import org.junit.After;
-import org.junit.Before;
-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.annotation.Config;
-import org.robolectric.shadows.ShadowPackageManager;
-
-@RunWith(RobolectricTestRunner.class)
-@Config(shadows = SettingsShadowResources.class)
-public class SystemNavigationEdgeToEdgePreferenceControllerTest {
-
- private Context mContext;
- private ShadowPackageManager mPackageManager;
-
- @Mock
- private IOverlayManager mOverlayManager;
-
- private SystemNavigationEdgeToEdgePreferenceController mController;
-
- private static final String ACTION_QUICKSTEP = "android.intent.action.QUICKSTEP_SERVICE";
-
- @Before
- public void setUp() {
- MockitoAnnotations.initMocks(this);
-
- SettingsShadowResources.overrideResource(R.bool.config_swipe_up_gesture_setting_available,
- true);
-
- mContext = RuntimeEnvironment.application;
- mPackageManager = Shadows.shadowOf(mContext.getPackageManager());
-
- mController = new SystemNavigationEdgeToEdgePreferenceController(mContext, mOverlayManager,
- PREF_KEY_EDGE_TO_EDGE);
- }
-
- @After
- public void tearDown() {
- SettingsShadowResources.reset();
- }
-
- @Test
- public void testIsGestureAvailable_matchingServiceExists_shouldReturnTrue() {
- final ComponentName recentsComponentName = ComponentName.unflattenFromString(
- mContext.getString(com.android.internal.R.string.config_recentsComponentName));
- final Intent quickStepIntent = new Intent(ACTION_QUICKSTEP)
- .setPackage(recentsComponentName.getPackageName());
- final ResolveInfo info = new ResolveInfo();
- info.serviceInfo = new ServiceInfo();
- info.resolvePackageName = recentsComponentName.getPackageName();
- info.serviceInfo.packageName = info.resolvePackageName;
- info.serviceInfo.name = recentsComponentName.getClassName();
- info.serviceInfo.applicationInfo = new ApplicationInfo();
- info.serviceInfo.applicationInfo.flags = ApplicationInfo.FLAG_SYSTEM;
- mPackageManager.addResolveInfoForIntent(quickStepIntent, info);
-
- assertThat(SystemNavigationEdgeToEdgePreferenceController.isGestureAvailable(mContext))
- .isTrue();
- }
-
- @Test
- public void testIsGestureAvailable_overlayDisabled_matchingServiceExists_shouldReturnFalse() {
- SettingsShadowResources.overrideResource(R.bool.config_swipe_up_gesture_setting_available,
- false);
-
- final ComponentName recentsComponentName = ComponentName.unflattenFromString(
- mContext.getString(com.android.internal.R.string.config_recentsComponentName));
- final Intent quickStepIntent = new Intent(ACTION_QUICKSTEP)
- .setPackage(recentsComponentName.getPackageName());
- mPackageManager.addResolveInfoForIntent(quickStepIntent, new ResolveInfo());
-
- assertThat(SystemNavigationEdgeToEdgePreferenceController.isGestureAvailable(mContext))
- .isFalse();
- }
-
- @Test
- public void testIsGestureAvailable_noMatchingServiceExists_shouldReturnFalse() {
- assertThat(SystemNavigationEdgeToEdgePreferenceController.isGestureAvailable(mContext))
- .isFalse();
- }
-
- @Test
- public void testIsGestureAvailable_noOverlayPackage_shouldReturnFalse() {
- assertThat(SystemNavigationEdgeToEdgePreferenceController.isGestureAvailable(mContext,
- "com.package.fake")).isFalse();
- }
-
- @Test
- public void testIsChecked_defaultIsEdgeToEdge_shouldReturnTrue() {
- SettingsShadowResources.overrideResource(R.integer.config_navBarInteractionMode,
- NAV_BAR_MODE_GESTURAL);
- assertThat(mController.isChecked()).isTrue();
- }
-
- @Test
- public void testIsChecked_defaultIsLegacy_shouldReturnFalse() {
- SettingsShadowResources.overrideResource(R.integer.config_navBarInteractionMode,
- NAV_BAR_MODE_3BUTTON);
- assertThat(mController.isChecked()).isFalse();
- }
-
- @Test
- public void testIsChecked_defaultIsSwipeUp_shouldReturnFalse() {
- SettingsShadowResources.overrideResource(R.integer.config_navBarInteractionMode,
- NAV_BAR_MODE_2BUTTON);
- assertThat(mController.isChecked()).isFalse();
- }
-
- @Test
- public void testIsChecked_radioButtonClicked_shouldReturnTrue() {
- SettingsShadowResources.overrideResource(R.integer.config_navBarInteractionMode,
- NAV_BAR_MODE_GESTURAL);
- // Set the setting to be enabled.
- mController.onRadioButtonClicked(null);
- assertThat(mController.isChecked()).isTrue();
- }
-
- @Test
- public void testOnRadioButtonClicked_setsCorrectRadioButtonChecked() {
- RadioButtonPreference radioLegacy = mock(RadioButtonPreference.class);
- RadioButtonPreference radioSwipeUp = mock(RadioButtonPreference.class);
- RadioButtonPreference radioEdgeToEdge = mock(RadioButtonPreference.class);
- PreferenceScreen screen = mock(PreferenceScreen.class);
-
- when(screen.findPreference(PREF_KEY_LEGACY)).thenReturn(radioLegacy);
- when(screen.findPreference(PREF_KEY_SWIPE_UP)).thenReturn(radioSwipeUp);
- when(screen.findPreference(PREF_KEY_EDGE_TO_EDGE)).thenReturn(radioEdgeToEdge);
-
- mController.displayPreference(screen);
- mController.onRadioButtonClicked(radioEdgeToEdge);
-
- verify(radioLegacy, times(1)).setChecked(false);
- verify(radioSwipeUp, times(1)).setChecked(false);
- verify(radioEdgeToEdge, times(1)).setChecked(true);
- }
-
- @Test
- public void isSliceable_returnsFalse() {
- assertThat(mController.isSliceable()).isFalse();
- }
-
- @Test
- public void isSliceableIncorrectKey_returnsFalse() {
- final SystemNavigationEdgeToEdgePreferenceController controller =
- new SystemNavigationEdgeToEdgePreferenceController(mContext, "bad_key");
- assertThat(controller.isSliceable()).isFalse();
- }
-}
diff --git a/tests/robotests/src/com/android/settings/gestures/SystemNavigationGestureSettingsTest.java b/tests/robotests/src/com/android/settings/gestures/SystemNavigationGestureSettingsTest.java
new file mode 100644
index 0000000..1f3a758
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/gestures/SystemNavigationGestureSettingsTest.java
@@ -0,0 +1,115 @@
+/*
+ * Copyright (C) 2019 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License
+ */
+
+package com.android.settings.gestures;
+
+import static android.os.UserHandle.USER_CURRENT;
+import static android.view.WindowManagerPolicyConstants.NAV_BAR_MODE_2BUTTON;
+import static android.view.WindowManagerPolicyConstants.NAV_BAR_MODE_2BUTTON_OVERLAY;
+import static android.view.WindowManagerPolicyConstants.NAV_BAR_MODE_3BUTTON;
+import static android.view.WindowManagerPolicyConstants.NAV_BAR_MODE_3BUTTON_OVERLAY;
+import static android.view.WindowManagerPolicyConstants.NAV_BAR_MODE_GESTURAL;
+import static android.view.WindowManagerPolicyConstants.NAV_BAR_MODE_GESTURAL_OVERLAY;
+
+import static com.android.settings.gestures.SystemNavigationGestureSettings.KEY_SYSTEM_NAV_2BUTTONS;
+import static com.android.settings.gestures.SystemNavigationGestureSettings.KEY_SYSTEM_NAV_3BUTTONS;
+import static com.android.settings.gestures.SystemNavigationGestureSettings.KEY_SYSTEM_NAV_GESTURAL;
+
+import static com.google.common.truth.Truth.assertThat;
+
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.verify;
+
+import android.content.Context;
+import android.content.om.IOverlayManager;
+import android.os.ServiceManager;
+import android.provider.SearchIndexableResource;
+import android.text.TextUtils;
+
+import com.android.internal.R;
+import com.android.settings.testutils.shadow.SettingsShadowResources;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.robolectric.RobolectricTestRunner;
+import org.robolectric.RuntimeEnvironment;
+import org.robolectric.annotation.Config;
+
+import java.util.List;
+
+@RunWith(RobolectricTestRunner.class)
+@Config(shadows = SettingsShadowResources.class)
+public class SystemNavigationGestureSettingsTest {
+
+ private Context mContext;
+
+ private IOverlayManager mOverlayManager;
+
+ private SystemNavigationGestureSettings mSettings;
+
+ @Before
+ public void setUp() {
+ mContext = RuntimeEnvironment.application;
+ mOverlayManager = mock(IOverlayManager.class);
+
+ mSettings = new SystemNavigationGestureSettings();
+ }
+
+ @Test
+ public void testSearchIndexProvider_shouldIndexResource() {
+ final List<SearchIndexableResource> indexRes =
+ SystemNavigationGestureSettings.SEARCH_INDEX_DATA_PROVIDER.getXmlResourcesToIndex(
+ RuntimeEnvironment.application, true /* enabled */);
+
+ assertThat(indexRes).isNotNull();
+ assertThat(indexRes.get(0).xmlResId).isEqualTo(mSettings.getPreferenceScreenResId());
+ }
+
+ @Test
+ public void testGetCurrentSystemNavigationMode() {
+ SettingsShadowResources.overrideResource(R.integer.config_navBarInteractionMode,
+ NAV_BAR_MODE_GESTURAL);
+ assertThat(TextUtils.equals(mSettings.getCurrentSystemNavigationMode(mContext),
+ KEY_SYSTEM_NAV_GESTURAL)).isTrue();
+
+ SettingsShadowResources.overrideResource(R.integer.config_navBarInteractionMode,
+ NAV_BAR_MODE_3BUTTON);
+ assertThat(TextUtils.equals(mSettings.getCurrentSystemNavigationMode(mContext),
+ KEY_SYSTEM_NAV_3BUTTONS)).isTrue();
+
+ SettingsShadowResources.overrideResource(R.integer.config_navBarInteractionMode,
+ NAV_BAR_MODE_2BUTTON);
+ assertThat(TextUtils.equals(mSettings.getCurrentSystemNavigationMode(mContext),
+ KEY_SYSTEM_NAV_2BUTTONS)).isTrue();
+ }
+
+ @Test
+ public void testSetCurrentSystemNavigationMode() throws Exception {
+ mSettings.setCurrentSystemNavigationMode(mOverlayManager, KEY_SYSTEM_NAV_GESTURAL);
+ verify(mOverlayManager, times(1)).setEnabledExclusiveInCategory(
+ NAV_BAR_MODE_GESTURAL_OVERLAY, USER_CURRENT);
+
+ mSettings.setCurrentSystemNavigationMode(mOverlayManager, KEY_SYSTEM_NAV_2BUTTONS);
+ verify(mOverlayManager, times(1)).setEnabledExclusiveInCategory(
+ NAV_BAR_MODE_2BUTTON_OVERLAY, USER_CURRENT);
+
+ mSettings.setCurrentSystemNavigationMode(mOverlayManager, KEY_SYSTEM_NAV_3BUTTONS);
+ verify(mOverlayManager, times(1)).setEnabledExclusiveInCategory(
+ NAV_BAR_MODE_3BUTTON_OVERLAY, USER_CURRENT);
+ }
+}
diff --git a/tests/robotests/src/com/android/settings/gestures/SystemNavigationLegacyPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/gestures/SystemNavigationLegacyPreferenceControllerTest.java
deleted file mode 100644
index ebb1eb0..0000000
--- a/tests/robotests/src/com/android/settings/gestures/SystemNavigationLegacyPreferenceControllerTest.java
+++ /dev/null
@@ -1,201 +0,0 @@
-/*
- * Copyright (C) 2019 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.settings.gestures;
-
-import static android.view.WindowManagerPolicyConstants.NAV_BAR_MODE_2BUTTON;
-import static android.view.WindowManagerPolicyConstants.NAV_BAR_MODE_3BUTTON;
-import static android.view.WindowManagerPolicyConstants.NAV_BAR_MODE_GESTURAL;
-
-import static com.android.settings.gestures.SystemNavigationEdgeToEdgePreferenceController.PREF_KEY_EDGE_TO_EDGE;
-import static com.android.settings.gestures.SystemNavigationLegacyPreferenceController.PREF_KEY_LEGACY;
-import static com.android.settings.gestures.SystemNavigationSwipeUpPreferenceController.PREF_KEY_SWIPE_UP;
-
-import static com.google.common.truth.Truth.assertThat;
-
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.times;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.when;
-
-import android.content.ComponentName;
-import android.content.Context;
-import android.content.Intent;
-import android.content.om.IOverlayManager;
-import android.content.pm.ApplicationInfo;
-import android.content.pm.ResolveInfo;
-import android.content.pm.ServiceInfo;
-
-import androidx.preference.PreferenceScreen;
-
-import com.android.internal.R;
-import com.android.settings.testutils.shadow.SettingsShadowResources;
-import com.android.settings.widget.RadioButtonPreference;
-
-import org.junit.After;
-import org.junit.Before;
-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.annotation.Config;
-import org.robolectric.shadows.ShadowPackageManager;
-
-@RunWith(RobolectricTestRunner.class)
-@Config(shadows = SettingsShadowResources.class)
-public class SystemNavigationLegacyPreferenceControllerTest {
-
- private Context mContext;
- private ShadowPackageManager mPackageManager;
-
- @Mock
- private IOverlayManager mOverlayManager;
-
- private SystemNavigationLegacyPreferenceController mController;
-
- private static final String ACTION_QUICKSTEP = "android.intent.action.QUICKSTEP_SERVICE";
-
- @Before
- public void setUp() {
- MockitoAnnotations.initMocks(this);
-
- SettingsShadowResources.overrideResource(R.bool.config_swipe_up_gesture_setting_available,
- true);
-
- mContext = RuntimeEnvironment.application;
- mPackageManager = Shadows.shadowOf(mContext.getPackageManager());
-
- mController = new SystemNavigationLegacyPreferenceController(mContext, mOverlayManager,
- PREF_KEY_LEGACY);
- }
-
- @After
- public void tearDown() {
- SettingsShadowResources.reset();
- }
-
- @Test
- public void testIsGestureAvailable_matchingServiceExists_shouldReturnTrue() {
- final ComponentName recentsComponentName = ComponentName.unflattenFromString(
- mContext.getString(com.android.internal.R.string.config_recentsComponentName));
- final Intent quickStepIntent = new Intent(ACTION_QUICKSTEP)
- .setPackage(recentsComponentName.getPackageName());
- final ResolveInfo info = new ResolveInfo();
- info.serviceInfo = new ServiceInfo();
- info.resolvePackageName = recentsComponentName.getPackageName();
- info.serviceInfo.packageName = info.resolvePackageName;
- info.serviceInfo.name = recentsComponentName.getClassName();
- info.serviceInfo.applicationInfo = new ApplicationInfo();
- info.serviceInfo.applicationInfo.flags = ApplicationInfo.FLAG_SYSTEM;
- mPackageManager.addResolveInfoForIntent(quickStepIntent, info);
-
- assertThat(SystemNavigationLegacyPreferenceController.isGestureAvailable(mContext))
- .isTrue();
- }
-
- @Test
- public void testIsGestureAvailable_overlayDisabled_matchingServiceExists_shouldReturnFalse() {
- SettingsShadowResources.overrideResource(R.bool.config_swipe_up_gesture_setting_available,
- false);
-
- final ComponentName recentsComponentName = ComponentName.unflattenFromString(
- mContext.getString(com.android.internal.R.string.config_recentsComponentName));
- final Intent quickStepIntent = new Intent(ACTION_QUICKSTEP)
- .setPackage(recentsComponentName.getPackageName());
- mPackageManager.addResolveInfoForIntent(quickStepIntent, new ResolveInfo());
-
- assertThat(
- SystemNavigationLegacyPreferenceController.isGestureAvailable(mContext)).isFalse();
- }
-
- @Test
- public void testIsGestureAvailable_noMatchingServiceExists_shouldReturnFalse() {
- assertThat(
- SystemNavigationLegacyPreferenceController.isGestureAvailable(mContext)).isFalse();
- }
-
- @Test
- public void testIsGestureAvailable_noOverlayPackage_shouldReturnFalse() {
- assertThat(SystemNavigationLegacyPreferenceController.isGestureAvailable(mContext,
- "com.package.fake")).isFalse();
- }
-
- @Test
- public void testIsChecked_defaultIsLegacy_shouldReturnTrue() {
- SettingsShadowResources.overrideResource(R.integer.config_navBarInteractionMode,
- NAV_BAR_MODE_3BUTTON);
- assertThat(mController.isChecked()).isTrue();
- }
-
- @Test
- public void testIsChecked_defaultIsSwipeUp_shouldReturnFalse() {
- // Turn on the Swipe Up mode (2-buttons)
- SettingsShadowResources.overrideResource(R.integer.config_navBarInteractionMode,
- NAV_BAR_MODE_2BUTTON);
- assertThat(mController.isChecked()).isFalse();
- }
-
- @Test
- public void testIsChecked_defaultIsEdgeToEdge_shouldReturnFalse() {
- // Turn on the Edge to Edge
- SettingsShadowResources.overrideResource(R.integer.config_navBarInteractionMode,
- NAV_BAR_MODE_GESTURAL);
- assertThat(mController.isChecked()).isFalse();
- }
-
- @Test
- public void testIsChecked_radioButtonClicked_shouldReturnTrue() {
- SettingsShadowResources.overrideResource(R.integer.config_navBarInteractionMode,
- NAV_BAR_MODE_3BUTTON);
- // Set the setting to be enabled.
- mController.onRadioButtonClicked(null);
- assertThat(mController.isChecked()).isTrue();
- }
-
- @Test
- public void testOnRadioButtonClicked_setsCorrectRadioButtonChecked() {
- RadioButtonPreference radioLegacy = mock(RadioButtonPreference.class);
- RadioButtonPreference radioSwipeUp = mock(RadioButtonPreference.class);
- RadioButtonPreference radioEdgeToEdge = mock(RadioButtonPreference.class);
- PreferenceScreen screen = mock(PreferenceScreen.class);
-
- when(screen.findPreference(PREF_KEY_LEGACY)).thenReturn(radioLegacy);
- when(screen.findPreference(PREF_KEY_SWIPE_UP)).thenReturn(radioSwipeUp);
- when(screen.findPreference(PREF_KEY_EDGE_TO_EDGE)).thenReturn(radioEdgeToEdge);
-
- mController.displayPreference(screen);
- mController.onRadioButtonClicked(radioLegacy);
-
- verify(radioLegacy, times(1)).setChecked(true);
- verify(radioSwipeUp, times(1)).setChecked(false);
- verify(radioEdgeToEdge, times(1)).setChecked(false);
- }
-
- @Test
- public void isSliceable_returnsFalse() {
- assertThat(mController.isSliceable()).isFalse();
- }
-
- @Test
- public void isSliceableIncorrectKey_returnsFalse() {
- final SystemNavigationLegacyPreferenceController controller =
- new SystemNavigationLegacyPreferenceController(mContext, "bad_key");
- assertThat(controller.isSliceable()).isFalse();
- }
-}
diff --git a/tests/robotests/src/com/android/settings/gestures/SystemNavigationPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/gestures/SystemNavigationPreferenceControllerTest.java
new file mode 100644
index 0000000..095c4d7
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/gestures/SystemNavigationPreferenceControllerTest.java
@@ -0,0 +1,169 @@
+/*
+ * Copyright (C) 2019 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License
+ */
+
+package com.android.settings.gestures;
+
+import static android.view.WindowManagerPolicyConstants.NAV_BAR_MODE_2BUTTON;
+import static android.view.WindowManagerPolicyConstants.NAV_BAR_MODE_3BUTTON;
+import static android.view.WindowManagerPolicyConstants.NAV_BAR_MODE_GESTURAL;
+
+import static com.android.settings.gestures.SystemNavigationPreferenceController.PREF_KEY_SYSTEM_NAVIGATION;
+
+import static com.google.common.truth.Truth.assertThat;
+
+import android.content.ComponentName;
+import android.content.Context;
+import android.content.Intent;
+import android.content.pm.ApplicationInfo;
+import android.content.pm.ResolveInfo;
+import android.content.pm.ServiceInfo;
+import android.text.TextUtils;
+
+import com.android.internal.R;
+import com.android.settings.testutils.shadow.SettingsShadowResources;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.MockitoAnnotations;
+import org.robolectric.RobolectricTestRunner;
+import org.robolectric.RuntimeEnvironment;
+import org.robolectric.Shadows;
+import org.robolectric.annotation.Config;
+import org.robolectric.shadows.ShadowPackageManager;
+
+@RunWith(RobolectricTestRunner.class)
+@Config(shadows = SettingsShadowResources.class)
+public class SystemNavigationPreferenceControllerTest {
+
+ private Context mContext;
+ private ShadowPackageManager mPackageManager;
+
+ private SystemNavigationPreferenceController mController;
+
+ private static final String ACTION_QUICKSTEP = "android.intent.action.QUICKSTEP_SERVICE";
+
+ @Before
+ public void setUp() {
+ MockitoAnnotations.initMocks(this);
+
+ SettingsShadowResources.overrideResource(R.bool.config_swipe_up_gesture_setting_available,
+ true);
+
+ mContext = RuntimeEnvironment.application;
+ mPackageManager = Shadows.shadowOf(mContext.getPackageManager());
+
+ mController = new SystemNavigationPreferenceController(mContext,
+ PREF_KEY_SYSTEM_NAVIGATION);
+ }
+
+ @After
+ public void tearDown() {
+ SettingsShadowResources.reset();
+ }
+
+ @Test
+ public void testIsGestureAvailable_matchingServiceExists_shouldReturnTrue() {
+ final ComponentName recentsComponentName = ComponentName.unflattenFromString(
+ mContext.getString(com.android.internal.R.string.config_recentsComponentName));
+ final Intent quickStepIntent = new Intent(ACTION_QUICKSTEP)
+ .setPackage(recentsComponentName.getPackageName());
+ final ResolveInfo info = new ResolveInfo();
+ info.serviceInfo = new ServiceInfo();
+ info.resolvePackageName = recentsComponentName.getPackageName();
+ info.serviceInfo.packageName = info.resolvePackageName;
+ info.serviceInfo.name = recentsComponentName.getClassName();
+ info.serviceInfo.applicationInfo = new ApplicationInfo();
+ info.serviceInfo.applicationInfo.flags = ApplicationInfo.FLAG_SYSTEM;
+ mPackageManager.addResolveInfoForIntent(quickStepIntent, info);
+
+ assertThat(SystemNavigationPreferenceController.isGestureAvailable(mContext)).isTrue();
+ }
+
+ @Test
+ public void testIsGestureAvailable_overlayDisabled_matchingServiceExists_shouldReturnFalse() {
+ SettingsShadowResources.overrideResource(R.bool.config_swipe_up_gesture_setting_available,
+ false);
+
+ final ComponentName recentsComponentName = ComponentName.unflattenFromString(
+ mContext.getString(com.android.internal.R.string.config_recentsComponentName));
+ final Intent quickStepIntent = new Intent(ACTION_QUICKSTEP)
+ .setPackage(recentsComponentName.getPackageName());
+ mPackageManager.addResolveInfoForIntent(quickStepIntent, new ResolveInfo());
+
+ assertThat(SystemNavigationPreferenceController.isGestureAvailable(mContext)).isFalse();
+ }
+
+ @Test
+ public void testIsGestureAvailable_noMatchingServiceExists_shouldReturnFalse() {
+ assertThat(SystemNavigationPreferenceController.isGestureAvailable(mContext)).isFalse();
+ }
+
+ @Test
+ public void testIsOverlayPackageAvailable_noOverlayPackage_shouldReturnFalse() {
+ assertThat(SystemNavigationPreferenceController.isOverlayPackageAvailable(mContext,
+ "com.package.fake")).isFalse();
+ }
+
+ @Test
+ public void testIsSwipeUpEnabled() {
+ SettingsShadowResources.overrideResource(R.integer.config_navBarInteractionMode,
+ NAV_BAR_MODE_2BUTTON);
+ assertThat(SystemNavigationPreferenceController.isSwipeUpEnabled(mContext)).isTrue();
+
+ SettingsShadowResources.overrideResource(R.integer.config_navBarInteractionMode,
+ NAV_BAR_MODE_3BUTTON);
+ assertThat(SystemNavigationPreferenceController.isSwipeUpEnabled(mContext)).isFalse();
+
+ SettingsShadowResources.overrideResource(R.integer.config_navBarInteractionMode,
+ NAV_BAR_MODE_GESTURAL);
+ assertThat(SystemNavigationPreferenceController.isSwipeUpEnabled(mContext)).isFalse();
+ }
+
+ @Test
+ public void testIsEdgeToEdgeEnabled() {
+ SettingsShadowResources.overrideResource(R.integer.config_navBarInteractionMode,
+ NAV_BAR_MODE_GESTURAL);
+ assertThat(SystemNavigationPreferenceController.isEdgeToEdgeEnabled(mContext)).isTrue();
+
+ SettingsShadowResources.overrideResource(R.integer.config_navBarInteractionMode,
+ NAV_BAR_MODE_3BUTTON);
+ assertThat(SystemNavigationPreferenceController.isEdgeToEdgeEnabled(mContext)).isFalse();
+
+ SettingsShadowResources.overrideResource(R.integer.config_navBarInteractionMode,
+ NAV_BAR_MODE_2BUTTON);
+ assertThat(SystemNavigationPreferenceController.isEdgeToEdgeEnabled(mContext)).isFalse();
+ }
+
+ @Test
+ public void testGetSummary() {
+ SettingsShadowResources.overrideResource(R.integer.config_navBarInteractionMode,
+ NAV_BAR_MODE_GESTURAL);
+ assertThat(TextUtils.equals(mController.getSummary(), mContext.getText(
+ com.android.settings.R.string.edge_to_edge_navigation_title))).isTrue();
+
+ SettingsShadowResources.overrideResource(R.integer.config_navBarInteractionMode,
+ NAV_BAR_MODE_3BUTTON);
+ assertThat(TextUtils.equals(mController.getSummary(),
+ mContext.getText(com.android.settings.R.string.legacy_navigation_title))).isTrue();
+
+ SettingsShadowResources.overrideResource(R.integer.config_navBarInteractionMode,
+ NAV_BAR_MODE_2BUTTON);
+ assertThat(TextUtils.equals(mController.getSummary(), mContext.getText(
+ com.android.settings.R.string.swipe_up_to_switch_apps_title))).isTrue();
+ }
+}
\ No newline at end of file
diff --git a/tests/robotests/src/com/android/settings/gestures/SystemNavigationSwipeUpPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/gestures/SystemNavigationSwipeUpPreferenceControllerTest.java
deleted file mode 100644
index f8a0b58..0000000
--- a/tests/robotests/src/com/android/settings/gestures/SystemNavigationSwipeUpPreferenceControllerTest.java
+++ /dev/null
@@ -1,199 +0,0 @@
-/*
- * Copyright (C) 2019 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.settings.gestures;
-
-import static android.view.WindowManagerPolicyConstants.NAV_BAR_MODE_2BUTTON;
-import static android.view.WindowManagerPolicyConstants.NAV_BAR_MODE_3BUTTON;
-import static android.view.WindowManagerPolicyConstants.NAV_BAR_MODE_GESTURAL;
-
-import static com.android.settings.gestures.SystemNavigationEdgeToEdgePreferenceController.PREF_KEY_EDGE_TO_EDGE;
-import static com.android.settings.gestures.SystemNavigationLegacyPreferenceController.PREF_KEY_LEGACY;
-import static com.android.settings.gestures.SystemNavigationSwipeUpPreferenceController.PREF_KEY_SWIPE_UP;
-
-import static com.google.common.truth.Truth.assertThat;
-
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.times;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.when;
-
-import android.content.ComponentName;
-import android.content.Context;
-import android.content.Intent;
-import android.content.om.IOverlayManager;
-import android.content.pm.ApplicationInfo;
-import android.content.pm.ResolveInfo;
-import android.content.pm.ServiceInfo;
-
-import androidx.preference.PreferenceScreen;
-
-import com.android.internal.R;
-import com.android.settings.testutils.shadow.SettingsShadowResources;
-import com.android.settings.widget.RadioButtonPreference;
-
-import org.junit.After;
-import org.junit.Before;
-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.annotation.Config;
-import org.robolectric.shadows.ShadowPackageManager;
-
-@RunWith(RobolectricTestRunner.class)
-@Config(shadows = SettingsShadowResources.class)
-public class SystemNavigationSwipeUpPreferenceControllerTest {
-
- private Context mContext;
- private ShadowPackageManager mPackageManager;
-
- @Mock
- private IOverlayManager mOverlayManager;
-
- private SystemNavigationSwipeUpPreferenceController mController;
-
- private static final String ACTION_QUICKSTEP = "android.intent.action.QUICKSTEP_SERVICE";
-
- @Before
- public void setUp() {
- MockitoAnnotations.initMocks(this);
-
- SettingsShadowResources.overrideResource(R.bool.config_swipe_up_gesture_setting_available,
- true);
-
- mContext = RuntimeEnvironment.application;
- mPackageManager = Shadows.shadowOf(mContext.getPackageManager());
-
- mController = new SystemNavigationSwipeUpPreferenceController(mContext, mOverlayManager,
- PREF_KEY_SWIPE_UP);
- }
-
- @After
- public void tearDown() {
- SettingsShadowResources.reset();
- }
-
- @Test
- public void testIsGestureAvailable_matchingServiceExists_shouldReturnTrue() {
- final ComponentName recentsComponentName = ComponentName.unflattenFromString(
- mContext.getString(com.android.internal.R.string.config_recentsComponentName));
- final Intent quickStepIntent = new Intent(ACTION_QUICKSTEP)
- .setPackage(recentsComponentName.getPackageName());
- final ResolveInfo info = new ResolveInfo();
- info.serviceInfo = new ServiceInfo();
- info.resolvePackageName = recentsComponentName.getPackageName();
- info.serviceInfo.packageName = info.resolvePackageName;
- info.serviceInfo.name = recentsComponentName.getClassName();
- info.serviceInfo.applicationInfo = new ApplicationInfo();
- info.serviceInfo.applicationInfo.flags = ApplicationInfo.FLAG_SYSTEM;
- mPackageManager.addResolveInfoForIntent(quickStepIntent, info);
-
- assertThat(SystemNavigationSwipeUpPreferenceController.isGestureAvailable(mContext))
- .isTrue();
- }
-
- @Test
- public void testIsGestureAvailable_overlayDisabled_matchingServiceExists_shouldReturnFalse() {
- SettingsShadowResources.overrideResource(R.bool.config_swipe_up_gesture_setting_available,
- false);
-
- final ComponentName recentsComponentName = ComponentName.unflattenFromString(
- mContext.getString(com.android.internal.R.string.config_recentsComponentName));
- final Intent quickStepIntent = new Intent(ACTION_QUICKSTEP)
- .setPackage(recentsComponentName.getPackageName());
- mPackageManager.addResolveInfoForIntent(quickStepIntent, new ResolveInfo());
-
- assertThat(SystemNavigationSwipeUpPreferenceController.isGestureAvailable(mContext))
- .isFalse();
- }
-
- @Test
- public void testIsGestureAvailable_noMatchingServiceExists_shouldReturnFalse() {
- assertThat(SystemNavigationSwipeUpPreferenceController.isGestureAvailable(mContext))
- .isFalse();
- }
-
- @Test
- public void testIsGestureAvailable_noOverlayPackage_shouldReturnFalse() {
- assertThat(SystemNavigationSwipeUpPreferenceController.isGestureAvailable(mContext,
- "com.package.fake")).isFalse();
- }
-
- @Test
- public void testIsChecked_defaultIsSwipeUp_shouldReturnTrue() {
- SettingsShadowResources.overrideResource(R.integer.config_navBarInteractionMode,
- NAV_BAR_MODE_2BUTTON);
- assertThat(mController.isChecked()).isTrue();
- }
-
- @Test
- public void testIsChecked_defaultIsLegacy_shouldReturnFalse() {
- SettingsShadowResources.overrideResource(R.integer.config_navBarInteractionMode,
- NAV_BAR_MODE_3BUTTON);
- assertThat(mController.isChecked()).isFalse();
- }
-
- @Test
- public void testIsChecked_defaultIsEdgeToEdge_shouldReturnFalse() {
- SettingsShadowResources.overrideResource(R.integer.config_navBarInteractionMode,
- NAV_BAR_MODE_GESTURAL);
- assertThat(mController.isChecked()).isFalse();
- }
-
- @Test
- public void testIsChecked_radioButtonClicked_shouldReturnTrue() {
- SettingsShadowResources.overrideResource(R.integer.config_navBarInteractionMode,
- NAV_BAR_MODE_2BUTTON);
- // Set the setting to be enabled.
- mController.onRadioButtonClicked(null);
- assertThat(mController.isChecked()).isTrue();
- }
-
- @Test
- public void testOnRadioButtonClicked_setsCorrectRadioButtonChecked() {
- RadioButtonPreference radioLegacy = mock(RadioButtonPreference.class);
- RadioButtonPreference radioSwipeUp = mock(RadioButtonPreference.class);
- RadioButtonPreference radioEdgeToEdge = mock(RadioButtonPreference.class);
- PreferenceScreen screen = mock(PreferenceScreen.class);
-
- when(screen.findPreference(PREF_KEY_LEGACY)).thenReturn(radioLegacy);
- when(screen.findPreference(PREF_KEY_SWIPE_UP)).thenReturn(radioSwipeUp);
- when(screen.findPreference(PREF_KEY_EDGE_TO_EDGE)).thenReturn(radioEdgeToEdge);
-
- mController.displayPreference(screen);
- mController.onRadioButtonClicked(radioSwipeUp);
-
- verify(radioLegacy, times(1)).setChecked(false);
- verify(radioSwipeUp, times(1)).setChecked(true);
- verify(radioEdgeToEdge, times(1)).setChecked(false);
- }
-
- @Test
- public void isSliceable_returnsFalse() {
- assertThat(mController.isSliceable()).isFalse();
- }
-
- @Test
- public void isSliceableIncorrectKey_returnsFalse() {
- final SystemNavigationSwipeUpPreferenceController controller =
- new SystemNavigationSwipeUpPreferenceController(mContext, "bad_key");
- assertThat(controller.isSliceable()).isFalse();
- }
-}
diff --git a/tests/robotests/src/com/android/settings/homepage/contextualcards/deviceinfo/DataUsageSliceTest.java b/tests/robotests/src/com/android/settings/homepage/contextualcards/deviceinfo/DataUsageSliceTest.java
index 588b7aa..b3aae03 100644
--- a/tests/robotests/src/com/android/settings/homepage/contextualcards/deviceinfo/DataUsageSliceTest.java
+++ b/tests/robotests/src/com/android/settings/homepage/contextualcards/deviceinfo/DataUsageSliceTest.java
@@ -17,13 +17,13 @@
package com.android.settings.homepage.contextualcards.deviceinfo;
import static com.google.common.truth.Truth.assertThat;
-
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.spy;
import android.content.Context;
-
+import android.telephony.SubscriptionManager;
+import android.telephony.TelephonyManager;
import androidx.core.graphics.drawable.IconCompat;
import androidx.slice.Slice;
import androidx.slice.SliceItem;
@@ -31,19 +31,18 @@
import androidx.slice.SliceProvider;
import androidx.slice.core.SliceAction;
import androidx.slice.widget.SliceLiveData;
-
import com.android.settings.R;
import com.android.settings.testutils.SliceTester;
import com.android.settings.testutils.shadow.ShadowDataUsageUtils;
-
+import java.util.List;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.robolectric.RobolectricTestRunner;
import org.robolectric.RuntimeEnvironment;
+import org.robolectric.Shadows;
import org.robolectric.annotation.Config;
-
-import java.util.List;
+import org.robolectric.shadows.ShadowTelephonyManager;
@RunWith(RobolectricTestRunner.class)
@Config(shadows = ShadowDataUsageUtils.class)
@@ -62,6 +61,11 @@
SliceProvider.setSpecs(SliceLiveData.SUPPORTED_SPECS);
mDataUsageSlice = spy(new DataUsageSlice(mContext));
+
+ final TelephonyManager telephonyManager = mContext.getSystemService(TelephonyManager.class);
+ final ShadowTelephonyManager shadowTelephonyManager = Shadows.shadowOf(telephonyManager);
+ shadowTelephonyManager.setTelephonyManagerForSubscriptionId(
+ SubscriptionManager.INVALID_SUBSCRIPTION_ID, telephonyManager);
}
@Test
diff --git a/tests/robotests/src/com/android/settings/network/telephony/ApnPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/network/telephony/ApnPreferenceControllerTest.java
index e2ac8ce..ce4c9a2 100644
--- a/tests/robotests/src/com/android/settings/network/telephony/ApnPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/network/telephony/ApnPreferenceControllerTest.java
@@ -123,6 +123,18 @@
assertThat(mController.getAvailabilityStatus()).isEqualTo(CONDITIONALLY_UNAVAILABLE);
}
+
+ @Test
+ public void getAvailabilityStatus_hideCarrierNetworkSettings_returnUnavailable() {
+ doReturn(PhoneConstants.PHONE_TYPE_GSM).when(mTelephonyManager).getPhoneType();
+ final PersistableBundle bundle = new PersistableBundle();
+ bundle.putBoolean(CarrierConfigManager.KEY_APN_EXPAND_BOOL, true);
+ bundle.putBoolean(CarrierConfigManager.KEY_HIDE_CARRIER_NETWORK_SETTINGS_BOOL, true);
+ doReturn(bundle).when(mCarrierConfigManager).getConfigForSubId(SUB_ID);
+
+ assertThat(mController.getAvailabilityStatus()).isEqualTo(CONDITIONALLY_UNAVAILABLE);
+ }
+
@Test
public void handPreferenceTreeClick_fireIntent() {
ArgumentCaptor<Intent> captor = ArgumentCaptor.forClass(Intent.class);
diff --git a/tests/robotests/src/com/android/settings/network/telephony/DataUsagePreferenceControllerTest.java b/tests/robotests/src/com/android/settings/network/telephony/DataUsagePreferenceControllerTest.java
index 5ffda81..7a097e7 100644
--- a/tests/robotests/src/com/android/settings/network/telephony/DataUsagePreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/network/telephony/DataUsagePreferenceControllerTest.java
@@ -17,7 +17,6 @@
package com.android.settings.network.telephony;
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;
@@ -30,12 +29,9 @@
import android.provider.Settings;
import android.telephony.SubscriptionManager;
import android.telephony.TelephonyManager;
-
import androidx.preference.SwitchPreference;
-
import com.android.settings.core.BasePreferenceController;
import com.android.settingslib.net.DataUsageController;
-
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -44,6 +40,8 @@
import org.mockito.MockitoAnnotations;
import org.robolectric.Robolectric;
import org.robolectric.RobolectricTestRunner;
+import org.robolectric.Shadows;
+import org.robolectric.shadows.ShadowTelephonyManager;
import org.robolectric.util.ReflectionHelpers;
@RunWith(RobolectricTestRunner.class)
@@ -51,8 +49,6 @@
private static final int SUB_ID = 2;
@Mock
- private TelephonyManager mTelephonyManager;
- @Mock
private NetworkStatsManager mNetworkStatsManager;
private DataUsagePreferenceController mController;
private SwitchPreference mPreference;
@@ -63,8 +59,13 @@
MockitoAnnotations.initMocks(this);
mContext = spy(Robolectric.setupActivity(Activity.class));
- doReturn(mTelephonyManager).when(mContext).getSystemService(Context.TELEPHONY_SERVICE);
- doReturn(mTelephonyManager).when(mTelephonyManager).createForSubscriptionId(SUB_ID);
+
+ final TelephonyManager telephonyManager = mContext.getSystemService(TelephonyManager.class);
+ final ShadowTelephonyManager shadowTelephonyManager = Shadows.shadowOf(telephonyManager);
+ shadowTelephonyManager.setTelephonyManagerForSubscriptionId(SUB_ID, telephonyManager);
+ shadowTelephonyManager.setTelephonyManagerForSubscriptionId(
+ SubscriptionManager.INVALID_SUBSCRIPTION_ID, telephonyManager);
+
doReturn(mNetworkStatsManager).when(mContext).getSystemService(NetworkStatsManager.class);
mPreference = new SwitchPreference(mContext);
diff --git a/tests/robotests/src/com/android/settings/network/telephony/MobileNetworkUtilsTest.java b/tests/robotests/src/com/android/settings/network/telephony/MobileNetworkUtilsTest.java
index 7dfe520..61599e6 100644
--- a/tests/robotests/src/com/android/settings/network/telephony/MobileNetworkUtilsTest.java
+++ b/tests/robotests/src/com/android/settings/network/telephony/MobileNetworkUtilsTest.java
@@ -198,4 +198,25 @@
assertThat(MobileNetworkUtils.getSearchableSubscriptionId(mContext))
.isEqualTo(SubscriptionManager.INVALID_SUBSCRIPTION_ID);
}
+
+ @Test
+ public void shouldDisplayNetworkSelectOptions_HideCarrierNetwork_returnFalse() {
+ mCarrierConfig.putBoolean(CarrierConfigManager.KEY_HIDE_CARRIER_NETWORK_SETTINGS_BOOL,
+ true);
+
+ assertThat(MobileNetworkUtils.shouldDisplayNetworkSelectOptions(mContext, SUB_ID_1))
+ .isFalse();
+ }
+
+ @Test
+ public void shouldDisplayNetworkSelectOptions_allCheckPass_returnTrue() {
+ mCarrierConfig.putBoolean(CarrierConfigManager.KEY_HIDE_CARRIER_NETWORK_SETTINGS_BOOL,
+ false);
+ mCarrierConfig.putBoolean(CarrierConfigManager.KEY_OPERATOR_SELECTION_EXPAND_BOOL, true);
+ mCarrierConfig.putBoolean(CarrierConfigManager.KEY_CSP_ENABLED_BOOL, false);
+ when(mTelephonyManager.getPhoneType()).thenReturn(PhoneConstants.PHONE_TYPE_GSM);
+
+ assertThat(MobileNetworkUtils.shouldDisplayNetworkSelectOptions(mContext, SUB_ID_1))
+ .isTrue();
+ }
}
diff --git a/tests/robotests/src/com/android/settings/notification/BubbleNotificationPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/notification/BubbleNotificationPreferenceControllerTest.java
deleted file mode 100644
index f3f51c5..0000000
--- a/tests/robotests/src/com/android/settings/notification/BubbleNotificationPreferenceControllerTest.java
+++ /dev/null
@@ -1,136 +0,0 @@
-/*
- * 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.notification;
-
-import static android.provider.Settings.Secure.NOTIFICATION_BUBBLES;
-
-import static com.android.settings.notification.BadgingNotificationPreferenceController.OFF;
-import static com.android.settings.notification.BadgingNotificationPreferenceController.ON;
-
-import static com.google.common.truth.Truth.assertThat;
-
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.when;
-
-import android.content.Context;
-import android.provider.Settings;
-
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.mockito.Answers;
-import org.mockito.Mock;
-import org.mockito.MockitoAnnotations;
-import org.robolectric.RobolectricTestRunner;
-import org.robolectric.RuntimeEnvironment;
-
-import androidx.preference.Preference;
-import androidx.preference.PreferenceScreen;
-import androidx.preference.TwoStatePreference;
-
-@RunWith(RobolectricTestRunner.class)
-public class BubbleNotificationPreferenceControllerTest {
-
- private Context mContext;
- @Mock(answer = Answers.RETURNS_DEEP_STUBS)
- private PreferenceScreen mScreen;
-
- private BubbleNotificationPreferenceController mController;
- private Preference mPreference;
-
- private static final String KEY_NOTIFICATION_BUBBLES = "notification_bubbles";
-
- @Before
- public void setUp() {
- MockitoAnnotations.initMocks(this);
- mContext = RuntimeEnvironment.application;
- mController = new BubbleNotificationPreferenceController(mContext,
- KEY_NOTIFICATION_BUBBLES);
- mPreference = new Preference(RuntimeEnvironment.application);
- mPreference.setKey(mController.getPreferenceKey());
- when(mScreen.findPreference(mPreference.getKey())).thenReturn(mPreference);
- }
-
- @Test
- public void display_shouldDisplay() {
- assertThat(mPreference.isVisible()).isTrue();
- }
-
- @Test
- public void updateState_preferenceSetCheckedWhenSettingIsOn() {
- final TwoStatePreference preference = mock(TwoStatePreference.class);
- Settings.Secure.putInt(mContext.getContentResolver(), NOTIFICATION_BUBBLES, ON);
-
- mController.updateState(preference);
-
- verify(preference).setChecked(true);
- }
-
- @Test
- public void updateState_preferenceSetUncheckedWhenSettingIsOff() {
- final TwoStatePreference preference = mock(TwoStatePreference.class);
- Settings.Secure.putInt(mContext.getContentResolver(), NOTIFICATION_BUBBLES, OFF);
- assertThat(Settings.Secure.getInt(mContext.getContentResolver(),
- NOTIFICATION_BUBBLES, ON)).isEqualTo(OFF);
-
- mController.updateState(preference);
-
- verify(preference).setChecked(false);
- }
-
- @Test
- public void isChecked_settingIsOff_shouldReturnFalse() {
- Settings.Secure.putInt(mContext.getContentResolver(), NOTIFICATION_BUBBLES, OFF);
-
- assertThat(mController.isChecked()).isFalse();
- }
-
- @Test
- public void isChecked_settingIsOn_shouldReturnTrue() {
- Settings.Secure.putInt(mContext.getContentResolver(), NOTIFICATION_BUBBLES, ON);
-
- assertThat(mController.isChecked()).isTrue();
- }
-
- @Test
- public void setChecked_setFalse_disablesSetting() {
- Settings.Secure.putInt(mContext.getContentResolver(), NOTIFICATION_BUBBLES, ON);
-
- mController.setChecked(false);
- int updatedValue = Settings.Secure.getInt(mContext.getContentResolver(),
- NOTIFICATION_BUBBLES, -1);
-
- assertThat(updatedValue).isEqualTo(OFF);
- }
-
- @Test
- public void setChecked_setTrue_enablesSetting() {
- Settings.Secure.putInt(mContext.getContentResolver(), NOTIFICATION_BUBBLES, OFF);
-
- mController.setChecked(true);
- int updatedValue = Settings.Secure.getInt(mContext.getContentResolver(),
- NOTIFICATION_BUBBLES, -1);
-
- assertThat(updatedValue).isEqualTo(ON);
- }
-
- @Test
- public void isSliceable_returnsFalse() {
- assertThat(mController.isSliceable()).isFalse();
- }
-}
diff --git a/tests/robotests/src/com/android/settings/notification/BubblePreferenceControllerTest.java b/tests/robotests/src/com/android/settings/notification/BubblePreferenceControllerTest.java
index ea66964..67324e9 100644
--- a/tests/robotests/src/com/android/settings/notification/BubblePreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/notification/BubblePreferenceControllerTest.java
@@ -22,6 +22,9 @@
import static android.app.NotificationManager.IMPORTANCE_NONE;
import static android.provider.Settings.Secure.NOTIFICATION_BUBBLES;
+import static com.android.settings.notification.BubblePreferenceController.SYSTEM_WIDE_OFF;
+import static com.android.settings.notification.BubblePreferenceController.SYSTEM_WIDE_ON;
+
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
@@ -96,6 +99,7 @@
@Test
public void testIsAvailable_notIfAppBlocked() {
+ Settings.Secure.putInt(mContext.getContentResolver(), NOTIFICATION_BUBBLES, SYSTEM_WIDE_ON);
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
appRow.banned = true;
mController.onResume(appRow, mock(NotificationChannel.class), null, null);
@@ -104,6 +108,7 @@
@Test
public void testIsAvailable_notIfChannelBlocked() {
+ Settings.Secure.putInt(mContext.getContentResolver(), NOTIFICATION_BUBBLES, SYSTEM_WIDE_ON);
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
NotificationChannel channel = mock(NotificationChannel.class);
when(channel.getImportance()).thenReturn(IMPORTANCE_NONE);
@@ -113,6 +118,7 @@
@Test
public void testIsAvailable_channel_notIfAppOff() {
+ Settings.Secure.putInt(mContext.getContentResolver(), NOTIFICATION_BUBBLES, SYSTEM_WIDE_ON);
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
appRow.allowBubbles = false;
NotificationChannel channel = mock(NotificationChannel.class);
@@ -123,12 +129,13 @@
}
@Test
- public void testIsAvailable_ifOffGlobally_app() {
+ public void testIsNotAvailable_ifOffGlobally_app() {
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
mController.onResume(appRow, null, null, null);
- Settings.Secure.putInt(mContext.getContentResolver(), NOTIFICATION_BUBBLES, 0);
+ Settings.Secure.putInt(mContext.getContentResolver(),
+ NOTIFICATION_BUBBLES, SYSTEM_WIDE_OFF);
- assertTrue(mController.isAvailable());
+ assertFalse(mController.isAvailable());
}
@Test
@@ -137,7 +144,8 @@
NotificationChannel channel = mock(NotificationChannel.class);
when(channel.getImportance()).thenReturn(IMPORTANCE_HIGH);
mController.onResume(appRow, channel, null, null);
- Settings.Secure.putInt(mContext.getContentResolver(), NOTIFICATION_BUBBLES, 0);
+ Settings.Secure.putInt(mContext.getContentResolver(),
+ NOTIFICATION_BUBBLES, SYSTEM_WIDE_OFF);
assertFalse(mController.isAvailable());
}
@@ -146,7 +154,7 @@
public void testIsAvailable_app() {
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
mController.onResume(appRow, null, null, null);
- Settings.Secure.putInt(mContext.getContentResolver(), NOTIFICATION_BUBBLES, 1);
+ Settings.Secure.putInt(mContext.getContentResolver(), NOTIFICATION_BUBBLES, SYSTEM_WIDE_ON);
assertTrue(mController.isAvailable());
}
@@ -159,7 +167,7 @@
when(channel.getImportance()).thenReturn(IMPORTANCE_HIGH);
when(channel.getId()).thenReturn(DEFAULT_CHANNEL_ID);
mController.onResume(appRow, channel, null, null);
- Settings.Secure.putInt(mContext.getContentResolver(), NOTIFICATION_BUBBLES, 1);
+ Settings.Secure.putInt(mContext.getContentResolver(), NOTIFICATION_BUBBLES, SYSTEM_WIDE_ON);
assertTrue(mController.isAvailable());
}
@@ -171,7 +179,7 @@
NotificationChannel channel = mock(NotificationChannel.class);
when(channel.getImportance()).thenReturn(IMPORTANCE_HIGH);
mController.onResume(appRow, channel, null, null);
- Settings.Secure.putInt(mContext.getContentResolver(), NOTIFICATION_BUBBLES, 1);
+ Settings.Secure.putInt(mContext.getContentResolver(), NOTIFICATION_BUBBLES, SYSTEM_WIDE_ON);
assertTrue(mController.isAvailable());
}
@@ -183,7 +191,7 @@
NotificationChannel channel = mock(NotificationChannel.class);
when(channel.getImportance()).thenReturn(IMPORTANCE_HIGH);
mController.onResume(appRow, channel, null, null);
- Settings.Secure.putInt(mContext.getContentResolver(), NOTIFICATION_BUBBLES, 1);
+ Settings.Secure.putInt(mContext.getContentResolver(), NOTIFICATION_BUBBLES, SYSTEM_WIDE_ON);
assertFalse(mController.isAvailable());
}
@@ -203,6 +211,7 @@
@Test
public void testUpdateState_channelNotBlockable() {
+ Settings.Secure.putInt(mContext.getContentResolver(), NOTIFICATION_BUBBLES, SYSTEM_WIDE_ON);
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
NotificationChannel channel = mock(NotificationChannel.class);
when(channel.isImportanceLockedByCriticalDeviceFunction()).thenReturn(true);
@@ -216,6 +225,7 @@
@Test
public void testUpdateState_channel() {
+ Settings.Secure.putInt(mContext.getContentResolver(), NOTIFICATION_BUBBLES, SYSTEM_WIDE_ON);
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
NotificationChannel channel = mock(NotificationChannel.class);
when(channel.canBubble()).thenReturn(true);
@@ -235,6 +245,7 @@
@Test
public void testUpdateState_app() {
+ Settings.Secure.putInt(mContext.getContentResolver(), NOTIFICATION_BUBBLES, SYSTEM_WIDE_ON);
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
appRow.label = "App!";
appRow.allowBubbles = true;
@@ -256,7 +267,8 @@
@Test
public void testUpdateState_app_offGlobally() {
- Settings.Secure.putInt(mContext.getContentResolver(), NOTIFICATION_BUBBLES, 0);
+ Settings.Secure.putInt(mContext.getContentResolver(),
+ NOTIFICATION_BUBBLES, SYSTEM_WIDE_OFF);
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
appRow.label = "App!";
appRow.allowBubbles = true;
@@ -269,6 +281,7 @@
@Test
public void testOnPreferenceChange_on_channel() {
+ Settings.Secure.putInt(mContext.getContentResolver(), NOTIFICATION_BUBBLES, SYSTEM_WIDE_ON);
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
appRow.allowBubbles = true;
NotificationChannel channel =
@@ -288,6 +301,7 @@
@Test
public void testOnPreferenceChange_off_channel() {
+ Settings.Secure.putInt(mContext.getContentResolver(), NOTIFICATION_BUBBLES, SYSTEM_WIDE_ON);
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
appRow.allowBubbles = true;
NotificationChannel channel =
@@ -307,6 +321,7 @@
@Test
public void testOnPreferenceChange_on_app() {
+ Settings.Secure.putInt(mContext.getContentResolver(), NOTIFICATION_BUBBLES, SYSTEM_WIDE_ON);
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
appRow.allowBubbles = false;
mController.onResume(appRow, null, null, null);
@@ -324,6 +339,7 @@
@Test
public void testOnPreferenceChange_off_app() {
+ Settings.Secure.putInt(mContext.getContentResolver(), NOTIFICATION_BUBBLES, SYSTEM_WIDE_ON);
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
appRow.allowBubbles = true;
mController.onResume(appRow, null, null, null);
@@ -341,7 +357,8 @@
@Test
public void testOnPreferenceChange_on_app_offGlobally() {
- Settings.Secure.putInt(mContext.getContentResolver(), NOTIFICATION_BUBBLES, 0);
+ Settings.Secure.putInt(mContext.getContentResolver(), NOTIFICATION_BUBBLES,
+ SYSTEM_WIDE_OFF);
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
appRow.allowBubbles = false;
mController.onResume(appRow, null, null, null);
diff --git a/tests/robotests/src/com/android/settings/notification/BubbleSummaryNotificationPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/notification/BubbleSummaryNotificationPreferenceControllerTest.java
deleted file mode 100644
index 4bdb2cc..0000000
--- a/tests/robotests/src/com/android/settings/notification/BubbleSummaryNotificationPreferenceControllerTest.java
+++ /dev/null
@@ -1,70 +0,0 @@
-/*
- * 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.notification;
-
-import static android.provider.Settings.Secure.NOTIFICATION_BUBBLES;
-
-import static com.android.settings.notification.BadgingNotificationPreferenceController.OFF;
-import static com.android.settings.notification.BadgingNotificationPreferenceController.ON;
-
-import static com.google.common.truth.Truth.assertThat;
-
-import android.content.Context;
-import android.provider.Settings;
-
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.robolectric.RobolectricTestRunner;
-import org.robolectric.RuntimeEnvironment;
-
-import androidx.preference.Preference;
-
-@RunWith(RobolectricTestRunner.class)
-public class BubbleSummaryNotificationPreferenceControllerTest {
-
- private Context mContext;
-
- private BubbleSummaryNotificationPreferenceController mController;
- private Preference mPreference;
-
- private static final String KEY_NOTIFICATION_BUBBLES = "notification_bubbles";
-
- @Before
- public void setUp() {
- mContext = RuntimeEnvironment.application;
- mController = new BubbleSummaryNotificationPreferenceController(mContext,
- KEY_NOTIFICATION_BUBBLES);
- mPreference = new Preference(RuntimeEnvironment.application);
- }
-
- @Test
- public void display_shouldDisplay() {
- assertThat(mPreference.isVisible()).isTrue();
- }
-
- @Test
- public void getSummary() {
- Settings.Secure.putInt(mContext.getContentResolver(), NOTIFICATION_BUBBLES, OFF);
-
- assertThat(mController.getSummary()).isEqualTo("Off");
-
- Settings.Secure.putInt(mContext.getContentResolver(), NOTIFICATION_BUBBLES, ON);
-
- assertThat(mController.getSummary()).isEqualTo("On");
- }
-}
diff --git a/tests/robotests/src/com/android/settings/notification/BubbleSummaryPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/notification/BubbleSummaryPreferenceControllerTest.java
index 0a0addc..04c8e4e 100644
--- a/tests/robotests/src/com/android/settings/notification/BubbleSummaryPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/notification/BubbleSummaryPreferenceControllerTest.java
@@ -22,6 +22,9 @@
import static android.app.NotificationManager.IMPORTANCE_NONE;
import static android.provider.Settings.Secure.NOTIFICATION_BUBBLES;
+import static com.android.settings.notification.BubbleSummaryPreferenceController.SYSTEM_WIDE_OFF;
+import static com.android.settings.notification.BubbleSummaryPreferenceController.SYSTEM_WIDE_ON;
+
import static junit.framework.TestCase.assertEquals;
import static org.junit.Assert.assertFalse;
@@ -95,7 +98,8 @@
NotificationChannel channel = mock(NotificationChannel.class);
when(channel.getImportance()).thenReturn(IMPORTANCE_HIGH);
mController.onResume(appRow, channel, null, null);
- Settings.Secure.putInt(mContext.getContentResolver(), NOTIFICATION_BUBBLES, 0);
+ Settings.Secure.putInt(mContext.getContentResolver(), NOTIFICATION_BUBBLES,
+ SYSTEM_WIDE_OFF);
assertFalse(mController.isAvailable());
}
@@ -104,18 +108,19 @@
public void testIsAvailable_app() {
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
mController.onResume(appRow, null, null, null);
- Settings.Secure.putInt(mContext.getContentResolver(), NOTIFICATION_BUBBLES, 1);
+ Settings.Secure.putInt(mContext.getContentResolver(), NOTIFICATION_BUBBLES, SYSTEM_WIDE_ON);
assertTrue(mController.isAvailable());
}
@Test
- public void testIsAvailable_app_globalOff() {
+ public void testIsNotAvailable_app_globalOff() {
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
mController.onResume(appRow, null, null, null);
- Settings.Secure.putInt(mContext.getContentResolver(), NOTIFICATION_BUBBLES, 0);
+ Settings.Secure.putInt(mContext.getContentResolver(), NOTIFICATION_BUBBLES,
+ SYSTEM_WIDE_OFF);
- assertTrue(mController.isAvailable());
+ assertFalse(mController.isAvailable());
}
@Test
@@ -126,7 +131,7 @@
when(channel.getImportance()).thenReturn(IMPORTANCE_HIGH);
when(channel.getId()).thenReturn(DEFAULT_CHANNEL_ID);
mController.onResume(appRow, channel, null, null);
- Settings.Secure.putInt(mContext.getContentResolver(), NOTIFICATION_BUBBLES, 1);
+ Settings.Secure.putInt(mContext.getContentResolver(), NOTIFICATION_BUBBLES, SYSTEM_WIDE_ON);
assertTrue(mController.isAvailable());
}
@@ -144,16 +149,18 @@
@Test
public void testGetSummary() {
+ Settings.Secure.putInt(mContext.getContentResolver(), NOTIFICATION_BUBBLES, SYSTEM_WIDE_ON);
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
appRow.allowBubbles = true;
mController.onResume(appRow, null, null, null);
assertEquals("On", mController.getSummary());
- Settings.Secure.putInt(mContext.getContentResolver(), NOTIFICATION_BUBBLES, 0);
+ Settings.Secure.putInt(mContext.getContentResolver(), NOTIFICATION_BUBBLES,
+ SYSTEM_WIDE_OFF);
assertEquals("Off", mController.getSummary());
- Settings.Secure.putInt(mContext.getContentResolver(), NOTIFICATION_BUBBLES, 1);
+ Settings.Secure.putInt(mContext.getContentResolver(), NOTIFICATION_BUBBLES, SYSTEM_WIDE_ON);
appRow.allowBubbles = false;
mController.onResume(appRow, null, null, null);
diff --git a/tests/robotests/src/com/android/settings/notification/RecentNotifyingAppsPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/notification/RecentNotifyingAppsPreferenceControllerTest.java
index d47d125..93bd8dc 100644
--- a/tests/robotests/src/com/android/settings/notification/RecentNotifyingAppsPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/notification/RecentNotifyingAppsPreferenceControllerTest.java
@@ -168,7 +168,6 @@
@Test
public void display_showRecents() throws Exception {
-
List<Event> events = new ArrayList<>();
Event app = new Event();
app.mEventType = Event.NOTIFICATION_INTERRUPTION;
@@ -262,8 +261,12 @@
ArgumentCaptor<Preference> prefCaptor = ArgumentCaptor.forClass(Preference.class);
verify(mCategory, times(2)).addPreference(prefCaptor.capture());
List<Preference> prefs = prefCaptor.getAllValues();
- assertThat(prefs.get(1).getKey()).isEqualTo(app.getPackageName());
- assertThat(prefs.get(0).getKey()).isEqualTo(app1.getPackageName());
+ assertThat(prefs.get(1).getKey()).isEqualTo(
+ RecentNotifyingAppsPreferenceController.getKey(UserHandle.myUserId(),
+ app.getPackageName()));
+ assertThat(prefs.get(0).getKey()).isEqualTo(
+ RecentNotifyingAppsPreferenceController.getKey(UserHandle.myUserId(),
+ app1.getPackageName()));
}
@Test
diff --git a/tests/robotests/src/com/android/settings/widget/UsageGraphTest.java b/tests/robotests/src/com/android/settings/widget/UsageGraphTest.java
index 7f09c3b..ebb496c 100644
--- a/tests/robotests/src/com/android/settings/widget/UsageGraphTest.java
+++ b/tests/robotests/src/com/android/settings/widget/UsageGraphTest.java
@@ -24,6 +24,8 @@
import android.content.Context;
import android.content.res.Resources;
+import android.graphics.Canvas;
+import android.graphics.Paint;
import android.util.SparseIntArray;
import com.android.settingslib.R;
@@ -177,4 +179,14 @@
assertThat(localPaths.keyAt(5)).isEqualTo(1001);
assertThat(localPaths.valueAt(5)).isEqualTo(-1);
}
+
+ @Test
+ public void drawFilledPath_emptyPath_shouldNotCrash() {
+ final Canvas canvas = new Canvas();
+ final SparseIntArray localPaths = new SparseIntArray();
+ final Paint paint = new Paint();
+
+ // Should not crash
+ mGraph.drawFilledPath(canvas, localPaths, paint);
+ }
}
diff --git a/tests/robotests/src/com/android/settings/wifi/slice/ConnectToWifiHandlerTest.java b/tests/robotests/src/com/android/settings/wifi/slice/ConnectToWifiHandlerTest.java
index cea8365..1eb7818 100644
--- a/tests/robotests/src/com/android/settings/wifi/slice/ConnectToWifiHandlerTest.java
+++ b/tests/robotests/src/com/android/settings/wifi/slice/ConnectToWifiHandlerTest.java
@@ -23,6 +23,7 @@
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
+import android.content.Context;
import android.net.wifi.WifiConfiguration;
import android.net.wifi.WifiConfiguration.NetworkSelectionStatus;
import android.net.wifi.WifiManager;
@@ -35,8 +36,8 @@
import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
-import org.robolectric.Robolectric;
import org.robolectric.RobolectricTestRunner;
+import org.robolectric.RuntimeEnvironment;
import org.robolectric.annotation.Config;
@RunWith(RobolectricTestRunner.class)
@@ -44,6 +45,7 @@
public class ConnectToWifiHandlerTest {
private static final String AP_SSID = "\"ap\"";
+ private Context mContext;
private ConnectToWifiHandler mHandler;
private WifiConfiguration mWifiConfig;
@Mock
@@ -53,7 +55,8 @@
public void setUp() {
MockitoAnnotations.initMocks(this);
- mHandler = Robolectric.setupActivity(ConnectToWifiHandler.class);
+ mContext = RuntimeEnvironment.application;
+ mHandler = new ConnectToWifiHandler();
mWifiConfig = new WifiConfiguration();
mWifiConfig.SSID = AP_SSID;
doReturn(mWifiConfig).when(mAccessPoint).getConfig();
@@ -64,7 +67,7 @@
when(mAccessPoint.isSaved()).thenReturn(false);
when(mAccessPoint.getSecurity()).thenReturn(AccessPoint.SECURITY_NONE);
- mHandler.connect(mAccessPoint);
+ mHandler.connect(mContext, mAccessPoint);
assertThat(ShadowWifiManager.get().savedWifiConfig.SSID).isEqualTo(AP_SSID);
}
@@ -74,7 +77,7 @@
when(mAccessPoint.isSaved()).thenReturn(false);
when(mAccessPoint.isOsuProvider()).thenReturn(true);
- mHandler.connect(mAccessPoint);
+ mHandler.connect(mContext, mAccessPoint);
verify(mAccessPoint).startOsuProvisioning(any(WifiManager.ActionListener.class));
}
@@ -85,7 +88,7 @@
when(mAccessPoint.isSaved()).thenReturn(false);
when(mAccessPoint.isPasspoint()).thenReturn(true);
- mHandler.connect(mAccessPoint);
+ mHandler.connect(mContext, mAccessPoint);
assertThat(ShadowWifiManager.get().savedWifiConfig.SSID).isEqualTo(AP_SSID);
}
@@ -98,7 +101,7 @@
status.setHasEverConnected(true);
mWifiConfig.setNetworkSelectionStatus(status);
- mHandler.connect(mAccessPoint);
+ mHandler.connect(mContext, mAccessPoint);
assertThat(ShadowWifiManager.get().savedWifiConfig.SSID).isEqualTo(AP_SSID);
}
@@ -108,7 +111,7 @@
when(mAccessPoint.isSaved()).thenReturn(false);
when(mAccessPoint.getSecurity()).thenReturn(AccessPoint.SECURITY_PSK);
- mHandler.connect(mAccessPoint);
+ mHandler.connect(mContext, mAccessPoint);
assertThat(ShadowWifiManager.get().savedWifiConfig).isNull();
}
diff --git a/tests/robotests/src/com/android/settings/wifi/slice/ContextualWifiScanWorkerTest.java b/tests/robotests/src/com/android/settings/wifi/slice/ContextualWifiScanWorkerTest.java
new file mode 100644
index 0000000..0e52520
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/wifi/slice/ContextualWifiScanWorkerTest.java
@@ -0,0 +1,105 @@
+/*
+ * Copyright (C) 2019 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License
+ */
+
+package com.android.settings.wifi.slice;
+
+import static com.android.settings.slices.CustomSliceRegistry.CONTEXTUAL_WIFI_SLICE_URI;
+
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.eq;
+import static org.mockito.Mockito.never;
+import static org.mockito.Mockito.spy;
+import static org.mockito.Mockito.verify;
+
+import android.content.Context;
+import android.content.Intent;
+import android.net.ConnectivityManager;
+import android.net.ConnectivityManager.NetworkCallback;
+import android.net.Network;
+import android.net.wifi.WifiManager;
+import android.os.UserHandle;
+
+import com.android.settings.testutils.shadow.ShadowWifiManager;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.robolectric.RobolectricTestRunner;
+import org.robolectric.RuntimeEnvironment;
+import org.robolectric.annotation.Config;
+
+@RunWith(RobolectricTestRunner.class)
+@Config(shadows = {
+ ShadowWifiManager.class,
+ WifiScanWorkerTest.ShadowWifiTracker.class,
+})
+public class ContextualWifiScanWorkerTest {
+
+ private Context mContext;
+ private WifiManager mWifiManager;
+ private ConnectivityManager mConnectivityManager;
+ private ContextualWifiScanWorker mWifiScanWorker;
+ private ConnectToWifiHandler mConnectToWifiHandler;
+
+ @Before
+ public void setUp() {
+ mContext = spy(RuntimeEnvironment.application);
+ mWifiManager = mContext.getSystemService(WifiManager.class);
+ mWifiManager.setWifiEnabled(true);
+
+ mConnectivityManager = mContext.getSystemService(ConnectivityManager.class);
+ mWifiScanWorker = new ContextualWifiScanWorker(mContext, CONTEXTUAL_WIFI_SLICE_URI);
+ mConnectToWifiHandler = new ConnectToWifiHandler();
+ }
+
+ @After
+ public void tearDown() {
+ mWifiScanWorker.clearClickedWifi();
+ }
+
+ @Test
+ public void NetworkCallback_onCapabilitiesChanged_sliceIsUnpinned_shouldSendBroadcast() {
+ final Intent intent = WifiScanWorkerTest.getIntentWithAccessPoint("ap1");
+ WifiScanWorkerTest.setConnectionInfoSSID("ap1");
+ final Network network = mConnectivityManager.getActiveNetwork();
+ mWifiScanWorker.registerNetworkCallback(network);
+ final NetworkCallback callback = mWifiScanWorker.mNetworkCallback;
+
+ mWifiScanWorker.onSlicePinned();
+ mConnectToWifiHandler.onReceive(mContext, intent);
+ mWifiScanWorker.onSliceUnpinned();
+ callback.onCapabilitiesChanged(network,
+ WifiSliceTest.makeCaptivePortalNetworkCapabilities());
+
+ verify(mContext).sendBroadcastAsUser(any(Intent.class), eq(UserHandle.CURRENT));
+ }
+
+ @Test
+ public void NetworkCallback_onCapabilitiesChanged_newSession_shouldNotSendBroadcast() {
+ final Intent intent = WifiScanWorkerTest.getIntentWithAccessPoint("ap1");
+ WifiScanWorkerTest.setConnectionInfoSSID("ap1");
+ final Network network = mConnectivityManager.getActiveNetwork();
+ mWifiScanWorker.registerNetworkCallback(network);
+
+ mConnectToWifiHandler.onReceive(mContext, intent);
+ ContextualWifiScanWorker.newVisibleUiSession();
+ mWifiScanWorker.mNetworkCallback.onCapabilitiesChanged(network,
+ WifiSliceTest.makeCaptivePortalNetworkCapabilities());
+
+ verify(mContext, never()).sendBroadcastAsUser(any(Intent.class), eq(UserHandle.CURRENT));
+ }
+}
diff --git a/tests/robotests/src/com/android/settings/wifi/slice/WifiScanWorkerTest.java b/tests/robotests/src/com/android/settings/wifi/slice/WifiScanWorkerTest.java
index b246e9a..1c84eb6 100644
--- a/tests/robotests/src/com/android/settings/wifi/slice/WifiScanWorkerTest.java
+++ b/tests/robotests/src/com/android/settings/wifi/slice/WifiScanWorkerTest.java
@@ -17,6 +17,7 @@
package com.android.settings.wifi.slice;
import static com.android.settings.slices.CustomSliceRegistry.WIFI_SLICE_URI;
+import static com.android.settings.wifi.WifiDialogActivity.KEY_ACCESS_POINT_STATE;
import static com.google.common.truth.Truth.assertThat;
@@ -42,9 +43,6 @@
import android.os.Bundle;
import android.os.UserHandle;
-import androidx.slice.SliceProvider;
-import androidx.slice.widget.SliceLiveData;
-
import com.android.settings.testutils.shadow.ShadowWifiManager;
import com.android.settingslib.wifi.AccessPoint;
import com.android.settingslib.wifi.WifiTracker;
@@ -57,7 +55,6 @@
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
-import org.robolectric.Robolectric;
import org.robolectric.RobolectricTestRunner;
import org.robolectric.RuntimeEnvironment;
import org.robolectric.annotation.Config;
@@ -85,14 +82,11 @@
mResolver = mock(ContentResolver.class);
doReturn(mResolver).when(mContext).getContentResolver();
mWifiManager = mContext.getSystemService(WifiManager.class);
-
- // Set-up specs for SliceMetadata.
- SliceProvider.setSpecs(SliceLiveData.SUPPORTED_SPECS);
mWifiManager.setWifiEnabled(true);
mConnectivityManager = mContext.getSystemService(ConnectivityManager.class);
mWifiScanWorker = new WifiScanWorker(mContext, WIFI_SLICE_URI);
- mConnectToWifiHandler = Robolectric.setupActivity(ConnectToWifiHandler.class);
+ mConnectToWifiHandler = new ConnectToWifiHandler();
}
@After
@@ -147,42 +141,36 @@
verify(mResolver).notifyChange(WIFI_SLICE_URI, null);
}
- private void setConnectionInfoSSID(String ssid) {
- final WifiInfo wifiInfo = new WifiInfo();
- wifiInfo.setSSID(WifiSsid.createFromAsciiEncoded(ssid));
- ShadowWifiManager.get().setConnectionInfo(wifiInfo);
- }
-
@Test
- public void NetworkCallback_onCapabilitiesChanged_isClickedWifi_shouldStartActivity() {
- final AccessPoint accessPoint = createAccessPoint("ap1");
+ public void NetworkCallback_onCapabilitiesChanged_isClickedWifi_shouldSendBroadcast() {
+ final Intent intent = getIntentWithAccessPoint("ap1");
setConnectionInfoSSID("ap1");
final Network network = mConnectivityManager.getActiveNetwork();
mWifiScanWorker.registerNetworkCallback(network);
- mConnectToWifiHandler.connect(accessPoint);
+ mConnectToWifiHandler.onReceive(mContext, intent);
mWifiScanWorker.mNetworkCallback.onCapabilitiesChanged(network,
WifiSliceTest.makeCaptivePortalNetworkCapabilities());
- verify(mContext).startActivityAsUser(any(Intent.class), eq(UserHandle.CURRENT));
+ verify(mContext).sendBroadcastAsUser(any(Intent.class), eq(UserHandle.CURRENT));
}
@Test
- public void NetworkCallback_onCapabilitiesChanged_isNotClickedWifi_shouldNotStartActivity() {
- final AccessPoint accessPoint = createAccessPoint("ap1");
+ public void NetworkCallback_onCapabilitiesChanged_isNotClickedWifi_shouldNotSendBroadcast() {
+ final Intent intent = getIntentWithAccessPoint("ap1");
setConnectionInfoSSID("ap2");
final Network network = mConnectivityManager.getActiveNetwork();
mWifiScanWorker.registerNetworkCallback(network);
- mConnectToWifiHandler.connect(accessPoint);
+ mConnectToWifiHandler.onReceive(mContext, intent);
mWifiScanWorker.mNetworkCallback.onCapabilitiesChanged(network,
WifiSliceTest.makeCaptivePortalNetworkCapabilities());
- verify(mContext, never()).startActivityAsUser(any(Intent.class), eq(UserHandle.CURRENT));
+ verify(mContext, never()).sendBroadcastAsUser(any(Intent.class), eq(UserHandle.CURRENT));
}
@Test
- public void NetworkCallback_onCapabilitiesChanged_neverClickWifi_shouldNotStartActivity() {
+ public void NetworkCallback_onCapabilitiesChanged_neverClickWifi_shouldNotSendBroadcast() {
setConnectionInfoSSID("ap1");
final Network network = mConnectivityManager.getActiveNetwork();
mWifiScanWorker.registerNetworkCallback(network);
@@ -190,24 +178,36 @@
mWifiScanWorker.mNetworkCallback.onCapabilitiesChanged(network,
WifiSliceTest.makeCaptivePortalNetworkCapabilities());
- verify(mContext, never()).startActivityAsUser(any(Intent.class), eq(UserHandle.CURRENT));
+ verify(mContext, never()).sendBroadcastAsUser(any(Intent.class), eq(UserHandle.CURRENT));
}
@Test
- public void NetworkCallback_onCapabilitiesChanged_sliceIsUnpinned_shouldNotStartActivity() {
- final AccessPoint accessPoint = createAccessPoint("ap1");
+ public void NetworkCallback_onCapabilitiesChanged_sliceIsUnpinned_shouldNotSendBroadcast() {
+ final Intent intent = getIntentWithAccessPoint("ap1");
setConnectionInfoSSID("ap1");
final Network network = mConnectivityManager.getActiveNetwork();
mWifiScanWorker.registerNetworkCallback(network);
final NetworkCallback callback = mWifiScanWorker.mNetworkCallback;
mWifiScanWorker.onSlicePinned();
- mConnectToWifiHandler.connect(accessPoint);
+ mConnectToWifiHandler.onReceive(mContext, intent);
mWifiScanWorker.onSliceUnpinned();
callback.onCapabilitiesChanged(network,
WifiSliceTest.makeCaptivePortalNetworkCapabilities());
- verify(mContext, never()).startActivityAsUser(any(Intent.class), eq(UserHandle.CURRENT));
+ verify(mContext, never()).sendBroadcastAsUser(any(Intent.class), eq(UserHandle.CURRENT));
+ }
+
+ static Intent getIntentWithAccessPoint(String ssid) {
+ final Bundle savedState = new Bundle();
+ savedState.putString("key_ssid", ssid);
+ return new Intent().putExtra(KEY_ACCESS_POINT_STATE, savedState);
+ }
+
+ static void setConnectionInfoSSID(String ssid) {
+ final WifiInfo wifiInfo = new WifiInfo();
+ wifiInfo.setSSID(WifiSsid.createFromAsciiEncoded(ssid));
+ ShadowWifiManager.get().setConnectionInfo(wifiInfo);
}
private AccessPoint createAccessPoint(String ssid, DetailedState detailedState) {
@@ -223,10 +223,6 @@
return createAccessPoint("ap", detailedState);
}
- private AccessPoint createAccessPoint(String ssid) {
- return createAccessPoint(ssid, DetailedState.DISCONNECTED);
- }
-
@Implements(WifiTracker.class)
public static class ShadowWifiTracker {
@Implementation
diff --git a/tests/robotests/src/com/android/settings/wifi/slice/WifiSliceTest.java b/tests/robotests/src/com/android/settings/wifi/slice/WifiSliceTest.java
index fabc50e..18ed006 100644
--- a/tests/robotests/src/com/android/settings/wifi/slice/WifiSliceTest.java
+++ b/tests/robotests/src/com/android/settings/wifi/slice/WifiSliceTest.java
@@ -238,20 +238,13 @@
setWorkerResults(createAccessPoint(AP1_NAME, true, true));
doReturn(makeCaptivePortalNetworkCapabilities()).when(mConnectivityManager)
.getNetworkCapabilities(any());
+ final IconCompat expectedIcon = IconCompat.createWithResource(mContext,
+ R.drawable.ic_settings_accent);
final Slice wifiSlice = mWifiSlice.getSlice();
final List<SliceItem> sliceItems = wifiSlice.getItems();
SliceTester.assertAnySliceItemContainsTitle(sliceItems, AP1_NAME);
- assertCaptivePortalItems(sliceItems);
- }
-
- private void assertCaptivePortalItems(List<SliceItem> sliceItems) {
- final String expectedSummary = mContext.getString(R.string.switch_on_text);
- SliceTester.assertAnySliceItemContainsSubtitle(sliceItems, expectedSummary);
-
- final IconCompat expectedIcon = IconCompat.createWithResource(mContext,
- R.drawable.ic_settings_accent);
SliceTester.assertAnySliceItemContainsIcon(sliceItems, expectedIcon);
}