Merge "Fix Learn more link placement is wrong problem" into sc-dev
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index c4bf977..0a40c89 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -182,6 +182,7 @@
<activity android:name=".Settings$CreateShortcutActivity"
android:exported="true"
+ android:theme="@style/Theme.SubSettings"
android:label="@string/settings_shortcut">
<intent-filter>
<action android:name="android.intent.action.CREATE_SHORTCUT" />
@@ -3713,6 +3714,7 @@
android:name="Settings$GestureNavigationSettingsActivity"
android:label="@string/gesture_settings_activity_title"
android:exported="true"
+ android:theme="@style/Theme.SubSettings"
android:enabled="true">
<intent-filter android:priority="32">
<action android:name="android.intent.action.MAIN" />
diff --git a/color-check-baseline.xml b/color-check-baseline.xml
index b9f5009..bb414ad 100644
--- a/color-check-baseline.xml
+++ b/color-check-baseline.xml
@@ -1125,22 +1125,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="contextual_card_stroke_color">#1f000000</color>"
- errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
- <location
- file="res/values/colors.xml"
- line="106"
- 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="switchbar_switch_track_tint">#BFFFFFFF</color>"
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
<location
@@ -4293,22 +4277,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=" <item name="strokeColor">@color/contextual_card_stroke_color</item>"
- errorLine2=" ^">
- <location
- file="res/values/styles.xml"
- line="475"
- column="34"/>
- </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="android:trackTint">@color/switchbar_switch_track_tint</item>"
errorLine2=" ^">
<location
diff --git a/res/drawable/ic_password.xml b/res/drawable/ic_password.xml
index 1924f6e..341e544 100644
--- a/res/drawable/ic_password.xml
+++ b/res/drawable/ic_password.xml
@@ -20,15 +20,15 @@
android:viewportHeight="24.0"
android:viewportWidth="24.0">
<path
- android:fillColor="?attr/colorAccent"
+ android:fillColor="?android:attr/colorAccent"
android:pathData="M21.5,9.39l-1.63,0l0.81,-1.42l-0.86,-0.5l-0.82,1.42l-0.82,-1.42l-0.86,0.5l0.81,1.42l-1.63,0l0,1l1.63,0l-0.81,1.41l0.86,0.5l0.82,-1.41l0.82,1.41l0.86,-0.5l-0.81,-1.41l1.63,0z" />
<path
- android:fillColor="?attr/colorAccent"
+ android:fillColor="?android:attr/colorAccent"
android:pathData="M13.68,7.97l-0.86,-0.5l-0.82,1.42l-0.82,-1.42l-0.86,0.5l0.81,1.42l-1.63,0l0,1l1.63,0l-0.81,1.41l0.86,0.5l0.82,-1.41l0.82,1.41l0.86,-0.5l-0.81,-1.41l1.63,0l0,-1l-1.63,0z" />
<path
- android:fillColor="?attr/colorAccent"
+ android:fillColor="?android:attr/colorAccent"
android:pathData="M6.68,7.97l-0.86,-0.5l-0.82,1.42l-0.82,-1.42l-0.86,0.5l0.81,1.42l-1.63,0l0,1l1.63,0l-0.81,1.41l0.86,0.5l0.82,-1.41l0.82,1.41l0.86,-0.5l-0.81,-1.41l1.63,0l0,-1l-1.63,0z" />
<path
- android:fillColor="?attr/colorAccent"
+ android:fillColor="?android:attr/colorAccent"
android:pathData="M21,17.89H3c-0.28,0 -0.5,-0.22 -0.5,-0.5v-1c0,-0.28 0.22,-0.5 0.5,-0.5h18c0.28,0 0.5,0.22 0.5,0.5v1C21.5,17.66 21.28,17.89 21,17.89z" />
</vector>
diff --git a/res/drawable/ic_pattern.xml b/res/drawable/ic_pattern.xml
index 3320aea..788eaa7 100644
--- a/res/drawable/ic_pattern.xml
+++ b/res/drawable/ic_pattern.xml
@@ -20,18 +20,18 @@
android:viewportHeight="24.0"
android:viewportWidth="24.0">
<path
- android:fillColor="?attr/colorAccent"
+ android:fillColor="?android:attr/colorAccent"
android:pathData="M4,4m-2,0a2,2 0,1 1,4 0a2,2 0,1 1,-4 0" />
<path
- android:fillColor="?attr/colorAccent"
+ android:fillColor="?android:attr/colorAccent"
android:pathData="M4,12m-2,0a2,2 0,1 1,4 0a2,2 0,1 1,-4 0" />
<path
- android:fillColor="?attr/colorAccent"
+ android:fillColor="?android:attr/colorAccent"
android:pathData="M12,4m-2,0a2,2 0,1 1,4 0a2,2 0,1 1,-4 0" />
<path
- android:fillColor="?attr/colorAccent"
+ android:fillColor="?android:attr/colorAccent"
android:pathData="M20,12m-2,0a2,2 0,1 1,4 0a2,2 0,1 1,-4 0" />
<path
- android:fillColor="?attr/colorAccent"
+ android:fillColor="?android:attr/colorAccent"
android:pathData="M20,18c-0.93,0 -1.7,0.64 -1.93,1.5h-4.14c-0.22,-0.86 -1,-1.5 -1.93,-1.5s-1.7,0.64 -1.93,1.5H5.93c-0.05,-0.18 -0.12,-0.35 -0.21,-0.51l5.28,-5.28C11.29,13.89 11.63,14 12,14c1.1,0 2,-0.9 2,-2c0,-0.37 -0.11,-0.71 -0.28,-1.01l5.28,-5.28C19.29,5.89 19.63,6 20,6c1.1,0 2,-0.9 2,-2s-0.9,-2 -2,-2s-2,0.9 -2,2c0,0.37 0.11,0.71 0.28,1.01l-5.28,5.28C12.71,10.11 12.37,10 12,10c-1.1,0 -2,0.9 -2,2c0,0.37 0.11,0.71 0.28,1.01l-5.28,5.28C4.71,18.11 4.37,18 4,18c-1.1,0 -2,0.9 -2,2s0.9,2 2,2c0.93,0 1.7,-0.64 1.93,-1.5h4.14c0.22,0.86 1,1.5 1.93,1.5s1.7,-0.64 1.93,-1.5h4.14c0.22,0.86 1,1.5 1.93,1.5c1.1,0 2,-0.9 2,-2S21.1,18 20,18z" />
</vector>
diff --git a/res/drawable/ic_pin.xml b/res/drawable/ic_pin.xml
index d8c3ae3..682e934 100644
--- a/res/drawable/ic_pin.xml
+++ b/res/drawable/ic_pin.xml
@@ -20,6 +20,6 @@
android:viewportHeight="24.0"
android:viewportWidth="24.0">
<path
- android:fillColor="?attr/colorAccent"
+ android:fillColor="?android:attr/colorAccent"
android:pathData="M20,4L4,4A2,2 0,0 0,2 6L2,18a2,2 0,0 0,2 2L20,20a2,2 0,0 0,2 -2L22,6A2,2 0,0 0,20 4ZM7.1,15L5.9,15L5.9,10.2L4.7,10.2L4.7,9L7.1,9v6ZM13.2,11.4A1.2,1.2 0,0 1,12 12.6L10.8,12.6v1.2h2.4L13.2,15L9.6,15L9.6,12.6a1.2,1.2 0,0 1,1.2 -1.2L12,11.4L12,10.2L9.6,10.2L9.6,9L12,9a1.2,1.2 0,0 1,1.2 1.2v1.2ZM19.3,11.1a0.9,0.9 0,0 1,-0.9 0.9,0.9 0.9,0 0,1 0.9,0.9v0.9A1.2,1.2 0,0 1,18.1 15L15.7,15L15.7,13.8h2.4L18.1,12.6L16.9,12.6L16.9,11.4h1.2L18.1,10.2L15.7,10.2L15.7,9h2.4a1.2,1.2 0,0 1,1.2 1.2v0.9Z" />
</vector>
diff --git a/res/drawable/ic_upload.xml b/res/drawable/ic_upload.xml
new file mode 100644
index 0000000..f95ffd4
--- /dev/null
+++ b/res/drawable/ic_upload.xml
@@ -0,0 +1,25 @@
+<!--
+ ~ Copyright (C) 2021 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="24.0dp"
+ android:height="24.0dp"
+ android:tint="?android:attr/colorControlNormal"
+ android:viewportHeight="24.0"
+ android:viewportWidth="24.0">
+ <path
+ android:fillColor="#FF000000"
+ android:pathData="M18,15v3H6v-3H4v3c0,1.1,0.9,2,2,2h12c1.1,0,2-0.9,2-2v-3H18z M7,9l1.41,1.41L11,7.83V16h2V7.83l2.59,2.58L17,9l-5-5L7,9z" />
+</vector>
diff --git a/res/drawable/progress_horizontal.xml b/res/drawable/progress_horizontal.xml
deleted file mode 100644
index f2a4cc4..0000000
--- a/res/drawable/progress_horizontal.xml
+++ /dev/null
@@ -1,38 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2021 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.
--->
-
-<layer-list
- xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:androidprv="http://schemas.android.com/apk/prv/res/android">
-
- <item
- android:id="@android:id/background">
- <shape>
- <corners android:radius="8dp" />
- <solid android:color="?androidprv:attr/colorSurfaceVariant" />
- </shape>
- </item>
-
- <item
- android:id="@android:id/progress">
- <clip>
- <shape>
- <corners android:radius="8dp" />
- <solid android:color="?android:attr/textColorPrimary" />
- </shape>
- </clip>
- </item>
-</layer-list>
diff --git a/res/layout-land/request_manage_credentials.xml b/res/layout-land/request_manage_credentials.xml
new file mode 100644
index 0000000..0c7bded
--- /dev/null
+++ b/res/layout-land/request_manage_credentials.xml
@@ -0,0 +1,140 @@
+<?xml version="1.0" encoding="utf-8"?><!--
+ ~ Copyright (C) 2021 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.
+ -->
+<LinearLayout
+ xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:app="http://schemas.android.com/apk/res-auto"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:orientation="horizontal"
+ android:weightSum="2">
+
+ <LinearLayout
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_weight="1"
+ style="@style/RequestManageCredentialsHeaderLandscape">
+
+ <ScrollView
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:scrollbars="none">
+
+ <LinearLayout
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:orientation="vertical">
+
+ <ImageView
+ android:id="@+id/credential_management_app_icon"
+ android:layout_width="48dp"
+ android:layout_height="48dp"
+ android:contentDescription="@null" />
+
+ <TextView
+ android:id="@+id/credential_management_app_title"
+ style="@style/RequestManageCredentialsTitle"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content" />
+
+ <TextView
+ android:id="@+id/credential_management_app_description"
+ style="@style/RequestManageCredentialsDescription"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="@string/request_manage_credentials_description" />
+
+ </LinearLayout>
+
+ </ScrollView>
+
+ </LinearLayout>
+
+ <LinearLayout
+ android:layout_width="wrap_content"
+ android:layout_height="match_parent"
+ android:layout_weight="1">
+
+ <RelativeLayout
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:orientation="vertical">
+
+ <androidx.coordinatorlayout.widget.CoordinatorLayout
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:clipChildren="true">
+
+ <RelativeLayout
+ android:layout_width="match_parent"
+ android:layout_height="match_parent">
+
+ <androidx.recyclerview.widget.RecyclerView
+ android:id="@+id/apps_list"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent" />
+
+ <LinearLayout
+ android:id="@+id/button_panel"
+ style="@style/RequestManageCredentialsButtonPanel"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content">
+
+ <Button
+ android:id="@+id/dont_allow_button"
+ style="@style/RequestManageCredentialsDontAllowButton"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="@string/request_manage_credentials_dont_allow" />
+
+ <Space
+ android:layout_width="0dp"
+ android:layout_height="0dp"
+ android:layout_weight="1"
+ android:visibility="invisible" />
+
+ <Button
+ android:id="@+id/allow_button"
+ style="@style/RequestManageCredentialsAllowButton"
+ android:theme="@style/RoundedCornerButtonTheme"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="@string/request_manage_credentials_allow" />
+
+ </LinearLayout>
+
+ </RelativeLayout>
+
+ <com.google.android.material.floatingactionbutton.ExtendedFloatingActionButton
+ android:id="@+id/extended_fab"
+ style="@style/RequestManageCredentialsFab"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="@string/request_manage_credentials_more"
+ android:theme="@style/Theme.CollapsingToolbar.Settings"
+ app:backgroundTint="?android:attr/colorAccent"
+ app:elevation="3dp"
+ app:icon="@drawable/ic_arrow_downward"
+ app:iconTint="?android:attr/textColorPrimary"
+ app:layout_anchor="@id/apps_list"
+ app:layout_anchorGravity="bottom|center" />
+
+ </androidx.coordinatorlayout.widget.CoordinatorLayout>
+
+ </RelativeLayout>
+
+ </LinearLayout>
+
+</LinearLayout>
diff --git a/res/layout/card_preference_layout.xml b/res/layout/card_preference_layout.xml
index bcaeb86..90e3388 100644
--- a/res/layout/card_preference_layout.xml
+++ b/res/layout/card_preference_layout.xml
@@ -29,6 +29,6 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="-8dp"
- layout="@layout/preference_material" />
+ layout="@layout/settingslib_preference" />
</com.google.android.material.card.MaterialCardView>
</FrameLayout>
diff --git a/res/layout/face_enroll_education.xml b/res/layout/face_enroll_education.xml
index a8455da..53a584e 100644
--- a/res/layout/face_enroll_education.xml
+++ b/res/layout/face_enroll_education.xml
@@ -38,7 +38,7 @@
<FrameLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
- android:layout_marginVertical="12dp">
+ android:layout_marginTop="-32dp">
<com.google.android.setupdesign.view.IllustrationVideoView
android:id="@+id/illustration_default"
@@ -51,11 +51,13 @@
<com.airbnb.lottie.LottieAnimationView
android:id="@+id/illustration_lottie"
android:layout_width="match_parent"
- android:layout_height="340dp"
- android:scaleType="fitCenter"
- android:visibility="invisible"
+ android:layout_height="400dp"
+ android:layout_marginTop="-48dp"
+ android:scaleType="centerCrop"
+ android:visibility="gone"
app:lottie_autoPlay="true"
- app:lottie_loop="true" />
+ app:lottie_loop="true"
+ app:lottie_speed="1.5" />
<ImageView
android:id="@+id/illustration_accessibility"
diff --git a/res/layout/preference_animated_image.xml b/res/layout/preference_animated_image.xml
index e7d9b52..0ab8adf 100644
--- a/res/layout/preference_animated_image.xml
+++ b/res/layout/preference_animated_image.xml
@@ -31,4 +31,14 @@
android:focusable="false"
android:clickable="false"
android:adjustViewBounds="true"/>
+
+ <com.airbnb.lottie.LottieAnimationView
+ android:id="@+id/lottie_view"
+ android:layout_width="412dp"
+ android:layout_height="300dp"
+ android:layout_gravity="center"
+ android:background="@drawable/protection_background"
+ android:scaleType="fitCenter"
+ android:adjustViewBounds="true"
+ android:clipToOutline="true"/>
</FrameLayout>
\ No newline at end of file
diff --git a/res/layout/remove_account_button.xml b/res/layout/remove_account_button.xml
index 6b47c37..070ecc5 100644
--- a/res/layout/remove_account_button.xml
+++ b/res/layout/remove_account_button.xml
@@ -20,13 +20,14 @@
android:orientation="vertical">
<Button
- android:id="@+id/button"
- android:text="@string/remove_account_label"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_gravity="center_horizontal"
- android:layout_marginTop="20dip"
- android:layout_marginBottom="12dip"
- android:gravity="center" />
+ android:id="@+id/button"
+ android:text="@string/remove_account_label"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_gravity="center_horizontal"
+ android:layout_marginTop="20dp"
+ android:layout_marginBottom="12dp"
+ android:gravity="center"
+ style="@style/ActionPrimaryButton" />
</LinearLayout>
diff --git a/res/layout/request_manage_credentials.xml b/res/layout/request_manage_credentials.xml
index ee3751c..c8167b6 100644
--- a/res/layout/request_manage_credentials.xml
+++ b/res/layout/request_manage_credentials.xml
@@ -52,6 +52,7 @@
<Button
android:id="@+id/allow_button"
style="@style/RequestManageCredentialsAllowButton"
+ android:theme="@style/RoundedCornerButtonTheme"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/request_manage_credentials_allow"/>
@@ -70,8 +71,8 @@
app:layout_anchorGravity="bottom|center"
app:elevation="3dp"
app:icon="@drawable/ic_arrow_downward"
- app:iconTint="?android:attr/colorAccent"
- app:backgroundTint="?android:attr/colorPrimary"
+ app:iconTint="?android:attr/textColorPrimary"
+ app:backgroundTint="?android:attr/colorAccent"
android:theme="@style/Theme.CollapsingToolbar.Settings"/>
</androidx.coordinatorlayout.widget.CoordinatorLayout>
diff --git a/res/values/colors.xml b/res/values/colors.xml
index 0b26c13..db525d5 100644
--- a/res/values/colors.xml
+++ b/res/values/colors.xml
@@ -103,9 +103,7 @@
<color name="homepage_wallpaper_background">#E51AD1</color>
<color name="homepage_notification_background">#DD4C9D</color>
- <color name="contextual_card_stroke_color">#1f000000</color>
<color name="contextual_card_dismissal_background">@*android:color/material_grey_100</color>
- <color name="contextual_card_background">@*android:color/background_device_default_light</color>
<!-- End of dashboard/homepage icon background colors -->
<color name="switchbar_background_color">@*android:color/material_grey_600</color>
diff --git a/res/values/strings.xml b/res/values/strings.xml
index b99dfc7..90708da 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -856,8 +856,6 @@
<!-- Button text in face settings which lets the user enroll their face [CHAR LIMIT=40] -->
<string name="security_settings_face_settings_enroll">Set up Face Unlock</string>
<!-- Text shown in face settings explaining what your face can be used for. [CHAR LIMIT=NONE] -->
- <string name="security_settings_face_settings_top_intro">Use Face Unlock to unlock your device, sign in to apps, and confirm payments.</string>
- <!-- Text shown in face settings explaining what your face can be used for. [CHAR LIMIT=NONE] -->
<string name="security_settings_face_settings_footer">Use your face to unlock your phone or for authentication in apps, like when you sign in or approve a purchase.\n\nKeep in mind:\nYou can only have one face set up at a time. To add another face, delete the current one.\n\nLooking at the phone can unlock it when you don\u2019t intend to.\n\nYour phone can be unlocked by someone else if it\u2019s held up to your face.\n\nYour phone can be unlocked by someone who looks a lot like you, like an identical sibling.</string>
<!-- Text shown in face settings explaining what your face can be used for. Used when attention checking is not supported. [CHAR LIMIT=NONE] -->
<string name="security_settings_face_settings_footer_attention_not_supported">Use your face to unlock your phone or for authentication in apps, like when you sign in or approve a purchase.\n\nKeep in mind:\nYou can only have one face set up at a time. To add another face, delete the current one.\n\nLooking at the phone can unlock it when you don\u2019t intend to.\n\nYour phone can be unlocked by someone else if it\u2019s held up to your face, even if your eyes are closed.\n\nYour phone can be unlocked by someone who looks a lot like you, like an identical sibling.</string>
@@ -6791,9 +6789,9 @@
<string name="cert_not_installed">Certificate not installed</string>
<!-- Title of screen shown to the user when an app requests to manage the user's KeyChain credentials [CHAR LIMIT=NONE] -->
- <string name="request_manage_credentials_title">Allow <xliff:g id="app_name" example="Ping">%s</xliff:g> to install certificates on this device?</string>
+ <string name="request_manage_credentials_title">Allow <b><xliff:g id="app_name" example="Ping">^1</xliff:g></b> to install certificates on this device?</string>
<!-- Description of screen shown to the user when an app requests to manage the user's KeyChain credentials [CHAR LIMIT=NONE] -->
- <string name="request_manage_credentials_description">These certificates will identify you to the apps and URLs below</string>
+ <string name="request_manage_credentials_description">These certificates will verify you by sharing your device\u2019s unique ID with the apps and URLs below</string>
<!-- Label for button to not allow an app to manage the user's KeyChain credentials [CHAR_LIMIT=50] -->
<string name="request_manage_credentials_dont_allow">Don\u2019t allow</string>
<!-- Label for button to allow an app to manage the user's KeyChain credentials [CHAR_LIMIT=50] -->
@@ -6805,7 +6803,9 @@
<!-- Summary if there is no certificate management app [CHAR_LIMIT=NONE] -->
<string name="no_certificate_management_app">None</string>
<!-- Summary of preference if there is a certificate management app [CHAR LIMIT=NONE] -->
- <string name="certificate_management_app_description">Certificates installed by this app identify you to the apps and URLs below</string>
+ <string name="certificate_management_app_description">Certificates will verify you when you use the apps and URLs below</string>
+ <!-- Label for button to uninstall all certificates installed by the credential management app [CHAR LIMIT=30] -->
+ <string name="uninstall_certs_credential_management_app">Uninstall certificates</string>
<!-- Label for button to remove the credential management app [CHAR LIMIT=30] -->
<string name="remove_credential_management_app">Remove</string>
<!-- List item found in the credential management app's authentication policy [CHAR LIMIT=NONE] -->
diff --git a/res/values/styles.xml b/res/values/styles.xml
index 6021a7c..63ea86e 100644
--- a/res/values/styles.xml
+++ b/res/values/styles.xml
@@ -13,7 +13,8 @@
limitations under the License.
-->
-<resources>
+<resources
+ xmlns:androidprv="http://schemas.android.com/apk/prv/res/android">
<style name="Widget.ActionBar.Base"
parent="@android:style/Widget.DeviceDefault.Light.ActionBar.Solid"/>
@@ -404,12 +405,6 @@
<item name="android:progressDrawable">@drawable/ring_progress</item>
</style>
- <style name="HorizontalProgressBarStyle"
- parent="android:style/Widget.Material.ProgressBar.Horizontal">
- <item name="android:progressDrawable">@drawable/progress_horizontal</item>
- <item name="android:scaleY">0.5</item>
- </style>
-
<style name="ActionPrimaryButton" parent="android:Widget.DeviceDefault.Button.Colored">
<item name="android:theme">@style/RoundedCornerThemeOverlay</item>
</style>
@@ -417,6 +412,8 @@
<style name="RoundedCornerThemeOverlay">
<item name="android:buttonCornerRadius">24dp</item>
+ <item name="android:paddingStart">16dp</item>
+ <item name="android:paddingEnd">16dp</item>
</style>
<style name="LockPatternContainerStyle">
@@ -470,11 +467,9 @@
<item name="android:layout_marginBottom">@dimen/contextual_card_vertical_margin</item>
<item name="android:layout_marginStart">@dimen/contextual_card_side_margin</item>
<item name="android:layout_marginEnd">@dimen/contextual_card_side_margin</item>
- <item name="cardBackgroundColor">@color/contextual_card_background</item>
+ <item name="cardBackgroundColor">?androidprv:attr/colorSurface</item>
<item name="cardCornerRadius">@dimen/contextual_card_corner_radius</item>
<item name="cardElevation">0dp</item>
- <item name="strokeColor">@color/contextual_card_stroke_color</item>
- <item name="strokeWidth">1dp</item>
<item name="rippleColor">?android:attr/colorControlHighlight</item>
</style>
@@ -799,10 +794,19 @@
<item name="android:background">?android:colorBackground</item>
</style>
+ <style name="RoundedCornerButtonTheme">
+ <item name="android:buttonCornerRadius">50dp</item>
+ <item name="android:paddingStart">20dp</item>
+ <item name="android:paddingEnd">20dp</item>
+ <item name="android:paddingTop">18dp</item>
+ <item name="android:paddingBottom">18dp</item>
+ </style>
+
<style name="RequestManageCredentialsAllowButton" parent="@style/ActionPrimaryButton">
<item name="android:fontFamily">google-sans-medium</item>
<item name="android:textSize">14sp</item>
<item name="android:textAllCaps">false</item>
+ <item name="android:textColor">?android:attr/textColorPrimary</item>
</style>
<style name="RequestManageCredentialsDontAllowButton"
@@ -810,13 +814,13 @@
<item name="android:fontFamily">google-sans-medium</item>
<item name="android:textSize">14sp</item>
<item name="android:textAllCaps">false</item>
- <item name="android:textColor">?android:attr/colorAccent</item>
+ <item name="android:textColor">?android:attr/textColorPrimary</item>
</style>
<style name="RequestManageCredentialsFab">
<item name="android:textSize">14sp</item>
<item name="android:textAllCaps">false</item>
- <item name="android:textColor">?android:attr/colorAccent</item>
+ <item name="android:textColor">?android:attr/textColorPrimary</item>
<item name="android:layout_marginBottom">12dp</item>
</style>
@@ -828,6 +832,13 @@
<item name="android:orientation">vertical</item>
</style>
+ <style name="RequestManageCredentialsHeaderLandscape">
+ <item name="android:paddingStart">24dp</item>
+ <item name="android:paddingEnd">24dp</item>
+ <item name="android:paddingTop">24dp</item>
+ <item name="android:paddingBottom">24dp</item>
+ </style>
+
<style name="RequestManageCredentialsTitle">
<item name="android:layout_marginTop">24dp</item>
<item name="android:textSize">36sp</item>
@@ -838,6 +849,7 @@
<item name="android:layout_marginTop">24dp</item>
<item name="android:textSize">18sp</item>
<item name="android:textColor">?android:attr/textColorPrimary</item>
+ <item name="android:alpha">0.7</item>
</style>
<style name="AppAuthenticationPolicyItem">
diff --git a/res/values/themes.xml b/res/values/themes.xml
index df7d433..4c5cdb7 100644
--- a/res/values/themes.xml
+++ b/res/values/themes.xml
@@ -32,7 +32,6 @@
<item name="android:homeAsUpIndicator">@drawable/ic_arrow_back</item>
<item name="android:navigationBarColor">@android:color/transparent</item>
<item name="android:datePickerDialogTheme">@style/PickerDialogTheme.Settings</item>
- <item name="android:progressBarStyleHorizontal">@style/HorizontalProgressBarStyle</item>
<item name="fingerprint_layout_theme">@style/FingerprintLayoutTheme</item>
<item name="face_layout_theme">@style/FaceLayoutTheme</item>
diff --git a/res/xml/credential_management_app_fragment.xml b/res/xml/credential_management_app_fragment.xml
index d4b61ac..7a5403b 100644
--- a/res/xml/credential_management_app_fragment.xml
+++ b/res/xml/credential_management_app_fragment.xml
@@ -27,19 +27,11 @@
android:order="-10000"
settings:controller="com.android.settings.security.CredentialManagementAppHeaderController"/>
- <com.android.settingslib.widget.TopIntroPreference
- android:key="top_intro_request_manage_credentials"
- android:order="-9999"
- android:title="@string/request_manage_credentials_description"
- settings:searchable="false"/>
-
<!-- Buttons -->
<com.android.settingslib.widget.ActionButtonsPreference
android:key="buttons"
android:selectable="true"
android:order="-9998"
- settings:allowDividerAbove="true"
- settings:allowDividerBelow="true"
settings:controller="com.android.settings.security.CredentialManagementAppButtonsController"/>
<!-- Authentication Policy -->
@@ -47,7 +39,6 @@
android:key="authentication_policy"
android:layout="@layout/preference_category_no_label"
android:title="@string/summary_placeholder"
- settings:allowDividerAbove="true"
settings:controller="com.android.settings.security.CredentialManagementAppPolicyController"/>
</PreferenceScreen>
diff --git a/res/xml/security_settings_face.xml b/res/xml/security_settings_face.xml
index 6d7c0ba..4529a01 100644
--- a/res/xml/security_settings_face.xml
+++ b/res/xml/security_settings_face.xml
@@ -19,10 +19,6 @@
xmlns:settings="http://schemas.android.com/apk/res-auto"
android:title="@string/security_settings_face_preference_title">
- <com.android.settingslib.widget.TopIntroPreference
- android:title="@string/security_settings_face_settings_top_intro"
- settings:searchable="false"/>
-
<PreferenceCategory
android:key="security_settings_face_unlock_category"
android:title="@string/security_settings_face_settings_use_face_category"
diff --git a/res/xml/storage_category_fragment.xml b/res/xml/storage_category_fragment.xml
index fb62bee..08f3f27 100644
--- a/res/xml/storage_category_fragment.xml
+++ b/res/xml/storage_category_fragment.xml
@@ -19,7 +19,7 @@
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:settings="http://schemas.android.com/apk/res-auto"
android:title="@string/storage_settings">
- <Preference
+ <com.android.settings.widget.CardPreference
android:key="free_up_space"
android:order="4"
android:title="@string/storage_free_up_space_title"
diff --git a/res/xml/storage_dashboard_fragment.xml b/res/xml/storage_dashboard_fragment.xml
index fff3235..8edf4bf 100644
--- a/res/xml/storage_dashboard_fragment.xml
+++ b/res/xml/storage_dashboard_fragment.xml
@@ -38,7 +38,7 @@
android:icon="@drawable/ic_storage"
android:order="3"
settings:controller="com.android.settings.deviceinfo.storage.AutomaticStorageManagementSwitchPreferenceController"/>
- <Preference
+ <com.android.settings.widget.CardPreference
android:key="free_up_space"
android:order="4"
android:title="@string/storage_free_up_space_title"
diff --git a/src/com/android/settings/accessibility/AnimatedImagePreference.java b/src/com/android/settings/accessibility/AnimatedImagePreference.java
index 2ca13f3..c707e5c 100644
--- a/src/com/android/settings/accessibility/AnimatedImagePreference.java
+++ b/src/com/android/settings/accessibility/AnimatedImagePreference.java
@@ -17,9 +17,14 @@
package com.android.settings.accessibility;
import android.content.Context;
-import android.graphics.drawable.AnimatedImageDrawable;
+import android.graphics.drawable.Animatable;
+import android.graphics.drawable.Animatable2;
+import android.graphics.drawable.AnimationDrawable;
import android.graphics.drawable.Drawable;
import android.net.Uri;
+import android.util.Log;
+import android.view.View;
+import android.view.ViewGroup;
import android.widget.ImageView;
import androidx.preference.Preference;
@@ -27,15 +32,31 @@
import com.android.settings.R;
+import com.airbnb.lottie.LottieAnimationView;
+import com.airbnb.lottie.LottieDrawable;
+
+import java.io.FileNotFoundException;
+import java.io.InputStream;
+import java.util.Objects;
+
/**
* A custom {@link ImageView} preference for showing animated or static image, such as <a
* href="https://developers.google.com/speed/webp/">animated webp</a> and static png.
*/
public class AnimatedImagePreference extends Preference {
+ private static final String TAG = "AnimatedImagePreference";
private Uri mImageUri;
private int mMaxHeight = -1;
+ private final Animatable2.AnimationCallback mAnimationCallback =
+ new Animatable2.AnimationCallback() {
+ @Override
+ public void onAnimationEnd(Drawable drawable) {
+ ((Animatable2) drawable).start();
+ }
+ };
+
AnimatedImagePreference(Context context) {
super(context);
setLayoutResource(R.layout.preference_animated_image);
@@ -46,21 +67,27 @@
super.onBindViewHolder(holder);
final ImageView imageView = holder.itemView.findViewById(R.id.animated_img);
- if (imageView == null) {
+ final LottieAnimationView lottieView = holder.itemView.findViewById(R.id.lottie_view);
+ if (imageView == null || lottieView == null) {
return;
}
if (mImageUri != null) {
- imageView.setImageURI(mImageUri);
+ resetAnimations(imageView, lottieView);
+ hideAllChildViews(holder.itemView);
- final Drawable drawable = imageView.getDrawable();
- if (drawable instanceof AnimatedImageDrawable) {
- ((AnimatedImageDrawable) drawable).start();
+ imageView.setImageURI(mImageUri);
+ if (imageView.getDrawable() != null) {
+ startAnimationWith(imageView);
+ } else {
+ // The lottie image from the raw folder also returns null.
+ startLottieAnimationWith(lottieView);
}
}
if (mMaxHeight > -1) {
imageView.setMaxHeight(mMaxHeight);
+ lottieView.setMaxHeight(mMaxHeight);
}
}
@@ -87,4 +114,68 @@
notifyChanged();
}
}
+
+ private void startAnimationWith(ImageView imageView) {
+ startAnimation(imageView.getDrawable());
+
+ imageView.setVisibility(View.VISIBLE);
+ }
+
+ private void startLottieAnimationWith(LottieAnimationView lottieView) {
+ final InputStream inputStream = getInputStreamFromUri(mImageUri);
+ Objects.requireNonNull(inputStream, "Invalid resource.");
+ lottieView.setAnimation(inputStream, /* cacheKey= */ null);
+ lottieView.setRepeatCount(LottieDrawable.INFINITE);
+ lottieView.playAnimation();
+
+ lottieView.setVisibility(View.VISIBLE);
+ }
+
+ private void startAnimation(Drawable drawable) {
+ if (!(drawable instanceof Animatable)) {
+ return;
+ }
+
+ if (drawable instanceof Animatable2) {
+ ((Animatable2) drawable).registerAnimationCallback(mAnimationCallback);
+ } else if (drawable instanceof AnimationDrawable) {
+ ((AnimationDrawable) drawable).setOneShot(false);
+ }
+
+ ((Animatable) drawable).start();
+ }
+
+ private void resetAnimations(ImageView imageView, LottieAnimationView lottieView) {
+ resetAnimation(imageView.getDrawable());
+
+ lottieView.cancelAnimation();
+ }
+
+ private void resetAnimation(Drawable drawable) {
+ if (!(drawable instanceof Animatable)) {
+ return;
+ }
+
+ if (drawable instanceof Animatable2) {
+ ((Animatable2) drawable).clearAnimationCallbacks();
+ }
+
+ ((Animatable) drawable).stop();
+ }
+
+ private InputStream getInputStreamFromUri(Uri uri) {
+ try {
+ return getContext().getContentResolver().openInputStream(uri);
+ } catch (FileNotFoundException e) {
+ Log.w(TAG, "Cannot find content uri: " + uri, e);
+ return null;
+ }
+ }
+
+ private void hideAllChildViews(View itemView) {
+ final ViewGroup viewGroup = (ViewGroup) itemView;
+ for (int i = 0; i < viewGroup.getChildCount(); i++) {
+ viewGroup.getChildAt(i).setVisibility(View.GONE);
+ }
+ }
}
diff --git a/src/com/android/settings/applications/appinfo/AppBatteryPreferenceController.java b/src/com/android/settings/applications/appinfo/AppBatteryPreferenceController.java
index 79cae92..1f0777a 100644
--- a/src/com/android/settings/applications/appinfo/AppBatteryPreferenceController.java
+++ b/src/com/android/settings/applications/appinfo/AppBatteryPreferenceController.java
@@ -118,7 +118,8 @@
final UserManager userManager =
(UserManager) mContext.getSystemService(Context.USER_SERVICE);
final BatteryEntry entry = new BatteryEntry(mContext, /* handler */null, userManager,
- mUidBatteryConsumer, /* isHidden */ false, /* packages */ null, mPackageName);
+ mUidBatteryConsumer, /* isHidden */ false,
+ mUidBatteryConsumer.getUid(), /* packages */ null, mPackageName);
AdvancedPowerUsageDetail.startBatteryDetailPage(mParent.getActivity(), mParent,
entry, mBatteryPercent);
} else {
diff --git a/src/com/android/settings/biometrics/BiometricEnrollIntroduction.java b/src/com/android/settings/biometrics/BiometricEnrollIntroduction.java
index 09d8e71..de85067 100644
--- a/src/com/android/settings/biometrics/BiometricEnrollIntroduction.java
+++ b/src/com/android/settings/biometrics/BiometricEnrollIntroduction.java
@@ -39,6 +39,8 @@
import com.google.android.setupcompat.template.FooterButton;
import com.google.android.setupcompat.util.WizardManagerHelper;
import com.google.android.setupdesign.span.LinkSpan;
+import com.google.android.setupdesign.template.RequireScrollMixin;
+import com.google.android.setupdesign.template.RequireScrollMixin.OnRequireScrollStateChangedListener;
import com.google.android.setupdesign.util.DynamicColorPalette;
/**
@@ -180,6 +182,35 @@
launchConfirmLock(getConfirmLockTitleResId());
}
}
+
+ FooterButton primaryButton = getPrimaryFooterButton();
+ FooterButton secondaryButton = getSecondaryFooterButton();
+ if (primaryButton == null) {
+ Log.d(TAG, "getPrimaryFooterButton() was null");
+ return;
+ }
+
+ if (secondaryButton == null) {
+ Log.d(TAG, "getSecondaryFooterButton() was null");
+ return;
+ }
+
+ // Setup scroll mixin
+ final RequireScrollMixin requireScrollMixin = getLayout().getMixin(
+ RequireScrollMixin.class);
+ requireScrollMixin.requireScrollWithButton(this, primaryButton, getScrollCompletedText(),
+ this::onNextButtonClick);
+
+ secondaryButton.setVisibility(View.INVISIBLE);
+ requireScrollMixin.setOnRequireScrollStateChangedListener(
+ new OnRequireScrollStateChangedListener() {
+ @Override
+ public void onRequireScrollStateChanged(boolean scrollNeeded) {
+ if (!scrollNeeded && secondaryButton.getVisibility() == View.INVISIBLE) {
+ secondaryButton.setVisibility(View.VISIBLE);
+ }
+ }
+ });
}
@Override
@@ -335,4 +366,18 @@
}
return mIconColorFilter;
}
+
+ @Nullable
+ protected FooterButton getPrimaryFooterButton() {
+ return null;
+ }
+
+ @Nullable
+ protected FooterButton getSecondaryFooterButton() {
+ return null;
+ }
+
+ protected int getScrollCompletedText() {
+ return R.string.security_settings_face_enroll_introduction_more;
+ }
}
diff --git a/src/com/android/settings/biometrics/face/FaceEnrollIntroduction.java b/src/com/android/settings/biometrics/face/FaceEnrollIntroduction.java
index d564547..b29e284 100644
--- a/src/com/android/settings/biometrics/face/FaceEnrollIntroduction.java
+++ b/src/com/android/settings/biometrics/face/FaceEnrollIntroduction.java
@@ -38,7 +38,6 @@
import com.google.android.setupcompat.template.FooterButton;
import com.google.android.setupcompat.util.WizardManagerHelper;
import com.google.android.setupdesign.span.LinkSpan;
-import com.google.android.setupdesign.template.RequireScrollMixin;
import java.util.List;
@@ -81,32 +80,6 @@
mFaceFeatureProvider = FeatureFactory.getFactory(getApplicationContext())
.getFaceFeatureProvider();
- mFooterBarMixin = getLayout().getMixin(FooterBarMixin.class);
- mFooterBarMixin.setSecondaryButton(
- new FooterButton.Builder(this)
- .setText(R.string.security_settings_face_enroll_introduction_no_thanks)
- .setListener(this::onSkipButtonClick)
- .setButtonType(FooterButton.ButtonType.NEXT)
- .setTheme(R.style.SudGlifButton_Primary)
- .build(),
- true /* usePrimaryStyle */);
-
- FooterButton.Builder nextButtonBuilder = new FooterButton.Builder(this)
- .setText(R.string.security_settings_face_enroll_introduction_agree)
- .setButtonType(FooterButton.ButtonType.OPT_IN)
- .setTheme(R.style.SudGlifButton_Primary);
- if (maxFacesEnrolled()) {
- nextButtonBuilder.setListener(this::onNextButtonClick);
- mFooterBarMixin.setPrimaryButton(nextButtonBuilder.build());
- } else {
- final FooterButton agreeButton = nextButtonBuilder.build();
- mFooterBarMixin.setPrimaryButton(agreeButton);
- final RequireScrollMixin requireScrollMixin = getLayout().getMixin(
- RequireScrollMixin.class);
- requireScrollMixin.requireScrollWithButton(this, agreeButton,
- R.string.security_settings_face_enroll_introduction_more,
- this::onNextButtonClick);
- }
// This path is an entry point for SetNewPasswordController, e.g.
// adb shell am start -a android.app.action.SET_NEW_PASSWORD
@@ -232,4 +205,40 @@
public void onClick(LinkSpan span) {
// TODO(b/110906762)
}
+
+ @Override
+ protected FooterButton getPrimaryFooterButton() {
+ if (mFooterBarMixin == null) {
+ mFooterBarMixin = getLayout().getMixin(FooterBarMixin.class);
+ }
+
+ if (mFooterBarMixin.getPrimaryButton() == null) {
+ final FooterButton nextButtonBuilder = new FooterButton.Builder(this)
+ .setText(R.string.security_settings_face_enroll_introduction_agree)
+ .setButtonType(FooterButton.ButtonType.OPT_IN)
+ .setListener(this::onNextButtonClick)
+ .setTheme(R.style.SudGlifButton_Primary)
+ .build();
+ mFooterBarMixin.setPrimaryButton(nextButtonBuilder);
+ }
+ return mFooterBarMixin.getPrimaryButton();
+ }
+
+ @Override
+ protected FooterButton getSecondaryFooterButton() {
+ if (mFooterBarMixin == null) {
+ mFooterBarMixin = getLayout().getMixin(FooterBarMixin.class);
+ }
+
+ if (mFooterBarMixin.getSecondaryButton() == null) {
+ final FooterButton noThanksButton = new FooterButton.Builder(this)
+ .setText(R.string.security_settings_face_enroll_introduction_no_thanks)
+ .setListener(this::onSkipButtonClick)
+ .setButtonType(FooterButton.ButtonType.NEXT)
+ .setTheme(R.style.SudGlifButton_Primary)
+ .build();
+ mFooterBarMixin.setSecondaryButton(noThanksButton, true /* usePrimaryStyle */);
+ }
+ return mFooterBarMixin.getSecondaryButton();
+ }
}
diff --git a/src/com/android/settings/biometrics/fingerprint/FingerprintEnrollIntroduction.java b/src/com/android/settings/biometrics/fingerprint/FingerprintEnrollIntroduction.java
index 18b1116..8a070ab 100644
--- a/src/com/android/settings/biometrics/fingerprint/FingerprintEnrollIntroduction.java
+++ b/src/com/android/settings/biometrics/fingerprint/FingerprintEnrollIntroduction.java
@@ -38,7 +38,6 @@
import com.google.android.setupcompat.template.FooterBarMixin;
import com.google.android.setupcompat.template.FooterButton;
import com.google.android.setupdesign.span.LinkSpan;
-import com.google.android.setupdesign.template.RequireScrollMixin;
import java.util.List;
@@ -69,29 +68,6 @@
iconDelete.getDrawable().setColorFilter(getIconColorFilter());
iconInfo.getDrawable().setColorFilter(getIconColorFilter());
iconLink.getDrawable().setColorFilter(getIconColorFilter());
-
- mFooterBarMixin = getLayout().getMixin(FooterBarMixin.class);
- mFooterBarMixin.setSecondaryButton(
- new FooterButton.Builder(this)
- .setText(getNegativeButtonTextId())
- .setListener(this::onSkipButtonClick)
- .setButtonType(FooterButton.ButtonType.NEXT)
- .setTheme(R.style.SudGlifButton_Primary)
- .build(),
- true /* usePrimaryStyle */);
-
- final FooterButton nextButton = new FooterButton.Builder(this)
- .setText(R.string.security_settings_fingerprint_enroll_introduction_agree)
- .setListener(this::onNextButtonClick)
- .setButtonType(FooterButton.ButtonType.OPT_IN)
- .setTheme(R.style.SudGlifButton_Primary)
- .build();
-
- mFooterBarMixin.setPrimaryButton(nextButton);
- final RequireScrollMixin requireScrollMixin =
- getLayout().getMixin(RequireScrollMixin.class);
- requireScrollMixin.requireScrollWithButton(this, nextButton,
- R.string.security_settings_face_enroll_introduction_more, this::onNextButtonClick);
}
int getNegativeButtonTextId() {
@@ -216,4 +192,45 @@
}
}
}
+
+ @Override
+ protected FooterButton getPrimaryFooterButton() {
+ if (mFooterBarMixin == null) {
+ mFooterBarMixin = getLayout().getMixin(FooterBarMixin.class);
+ }
+
+ if (mFooterBarMixin.getPrimaryButton() == null) {
+ final FooterButton nextButtonBuilder = new FooterButton.Builder(this)
+ .setText(R.string.security_settings_fingerprint_enroll_introduction_agree)
+ .setListener(this::onNextButtonClick)
+ .setButtonType(FooterButton.ButtonType.OPT_IN)
+ .setTheme(R.style.SudGlifButton_Primary)
+ .build();
+ mFooterBarMixin.setPrimaryButton(nextButtonBuilder);
+ }
+ return mFooterBarMixin.getPrimaryButton();
+ }
+
+ @Override
+ protected FooterButton getSecondaryFooterButton() {
+ if (mFooterBarMixin == null) {
+ mFooterBarMixin = getLayout().getMixin(FooterBarMixin.class);
+ }
+
+ if (mFooterBarMixin.getSecondaryButton() == null) {
+ final FooterButton noThanksButton = new FooterButton.Builder(this)
+ .setText(getNegativeButtonTextId())
+ .setListener(this::onSkipButtonClick)
+ .setButtonType(FooterButton.ButtonType.NEXT)
+ .setTheme(R.style.SudGlifButton_Primary)
+ .build();
+ mFooterBarMixin.setSecondaryButton(noThanksButton, true /* usePrimaryStyle */);
+ }
+ return mFooterBarMixin.getSecondaryButton();
+ }
+
+ @Override
+ protected int getScrollCompletedText() {
+ return R.string.security_settings_face_enroll_introduction_more;
+ }
}
diff --git a/src/com/android/settings/core/SubSettingLauncher.java b/src/com/android/settings/core/SubSettingLauncher.java
index 893d592..0a6966f 100644
--- a/src/com/android/settings/core/SubSettingLauncher.java
+++ b/src/com/android/settings/core/SubSettingLauncher.java
@@ -28,6 +28,7 @@
import com.android.settings.SettingsActivity;
import com.android.settings.SubSettings;
+import com.android.settings.Utils;
import com.android.settingslib.core.instrumentation.MetricsFeatureProvider;
import com.android.settingslib.transition.SettingsTransitionHelper.TransitionType;
@@ -181,8 +182,10 @@
@VisibleForTesting
void launchAsUser(Intent intent, UserHandle userHandle) {
- intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
- intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK);
+ if (!Utils.isPageTransitionEnabled(mContext)) {
+ intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
+ intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK);
+ }
mContext.startActivityAsUser(intent, userHandle);
}
diff --git a/src/com/android/settings/display/SmartAutoRotatePreferenceController.java b/src/com/android/settings/display/SmartAutoRotatePreferenceController.java
index 8c25a05..f8d5f96 100644
--- a/src/com/android/settings/display/SmartAutoRotatePreferenceController.java
+++ b/src/com/android/settings/display/SmartAutoRotatePreferenceController.java
@@ -16,15 +16,25 @@
package com.android.settings.display;
+import static android.hardware.SensorPrivacyManager.Sensors.CAMERA;
import static android.provider.Settings.Secure.CAMERA_AUTOROTATE;
+import static com.android.settings.display.SmartAutoRotateController.hasSufficientPermission;
+import static com.android.settings.display.SmartAutoRotateController.isRotationResolverServiceAvailable;
+
+import android.content.BroadcastReceiver;
import android.content.Context;
+import android.content.Intent;
+import android.content.IntentFilter;
+import android.hardware.SensorPrivacyManager;
+import android.os.PowerManager;
import android.os.UserHandle;
import android.provider.Settings;
import androidx.preference.Preference;
import androidx.preference.PreferenceScreen;
+import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.view.RotationPolicy;
import com.android.settings.R;
import com.android.settings.core.BasePreferenceController;
@@ -41,8 +51,21 @@
private RotationPolicy.RotationPolicyListener mRotationPolicyListener;
private Preference mPreference;
+ private final SensorPrivacyManager mPrivacyManager;
+ private final PowerManager mPowerManager;
+ private final BroadcastReceiver mReceiver = new BroadcastReceiver() {
+ @Override
+ public void onReceive(Context context, Intent intent) {
+ refreshSummary(mPreference);
+ }
+ };
+
public SmartAutoRotatePreferenceController(Context context, String preferenceKey) {
super(context, preferenceKey);
+ mPrivacyManager = SensorPrivacyManager.getInstance(context);
+ mPrivacyManager
+ .addSensorPrivacyListener(CAMERA, (sensor, enabled) -> refreshSummary(mPreference));
+ mPowerManager = context.getSystemService(PowerManager.class);
}
@Override
@@ -59,6 +82,8 @@
@Override
public void onStart() {
+ mContext.registerReceiver(mReceiver,
+ new IntentFilter(PowerManager.ACTION_POWER_SAVE_MODE_CHANGED));
if (mRotationPolicyListener == null) {
mRotationPolicyListener = new RotationPolicy.RotationPolicyListener() {
@Override
@@ -75,12 +100,27 @@
@Override
public void onStop() {
+ mContext.unregisterReceiver(mReceiver);
if (mRotationPolicyListener != null) {
RotationPolicy.unregisterRotationPolicyListener(mContext,
mRotationPolicyListener);
}
}
+ /**
+ * Need this because all controller tests use Roboelectric. No easy way to mock this service,
+ * so we mock the call we need
+ */
+ @VisibleForTesting
+ boolean isCameraLocked() {
+ return mPrivacyManager.isSensorPrivacyEnabled(SensorPrivacyManager.Sensors.CAMERA);
+ }
+
+ @VisibleForTesting
+ boolean isPowerSaveMode() {
+ return mPowerManager.isPowerSaveMode();
+ }
+
@Override
public CharSequence getSummary() {
int activeStringId = R.string.auto_rotate_option_off;
@@ -89,7 +129,11 @@
mContext.getContentResolver(),
CAMERA_AUTOROTATE,
0, UserHandle.USER_CURRENT);
- activeStringId = cameraRotate == 1 ? R.string.auto_rotate_option_face_based
+ activeStringId = cameraRotate == 1 && isRotationResolverServiceAvailable(mContext)
+ && hasSufficientPermission(mContext)
+ && !isCameraLocked()
+ && !isPowerSaveMode()
+ ? R.string.auto_rotate_option_face_based
: R.string.auto_rotate_option_on;
}
return mContext.getString(activeStringId);
diff --git a/src/com/android/settings/fuelgauge/BatteryAppListPreferenceController.java b/src/com/android/settings/fuelgauge/BatteryAppListPreferenceController.java
index 891b6d6..1dc572d 100644
--- a/src/com/android/settings/fuelgauge/BatteryAppListPreferenceController.java
+++ b/src/com/android/settings/fuelgauge/BatteryAppListPreferenceController.java
@@ -55,6 +55,7 @@
import com.android.settingslib.utils.StringUtil;
import java.util.ArrayList;
+import java.util.Comparator;
import java.util.List;
/**
@@ -66,6 +67,7 @@
static final boolean USE_FAKE_DATA = false;
private static final int MAX_ITEMS_TO_LIST = USE_FAKE_DATA ? 30 : 20;
private static final int MIN_AVERAGE_POWER_THRESHOLD_MILLI_AMP = 10;
+ private static final String MEDIASERVER_PACKAGE_NAME = "mediaserver";
private final String mPreferenceKey;
@VisibleForTesting
@@ -303,27 +305,17 @@
final ArrayList<BatteryEntry> results = new ArrayList<>();
final List<UidBatteryConsumer> uidBatteryConsumers =
mBatteryUsageStats.getUidBatteryConsumers();
+
+ // Sort to have all apps with "real" UIDs first, followed by apps that are supposed
+ // to be combined with the real ones.
+ uidBatteryConsumers.sort(Comparator.comparingInt(
+ consumer -> consumer.getUid() == getRealUid(consumer) ? 0 : 1));
+
for (int i = 0, size = uidBatteryConsumers.size(); i < size; i++) {
final UidBatteryConsumer consumer = uidBatteryConsumers.get(i);
- int realUid = consumer.getUid();
+ final int uid = getRealUid(consumer);
- // Check if this UID is a shared GID. If so, we combine it with the OWNER's
- // actual app UID.
- if (isSharedGid(consumer.getUid())) {
- realUid = UserHandle.getUid(UserHandle.USER_SYSTEM,
- UserHandle.getAppIdFromSharedAppGid(consumer.getUid()));
- }
-
- // Check if this UID is a system UID (mediaserver, logd, nfc, drm, etc).
- if (isSystemUid(realUid)
- && !"mediaserver".equals(consumer.getPackageWithHighestDrain())) {
- // Use the system UID for all UIDs running in their own sandbox that
- // are not apps. We exclude mediaserver because we already are expected to
- // report that as a separate item.
- realUid = Process.SYSTEM_UID;
- }
-
- final String[] packages = mPackageManager.getPackagesForUid(consumer.getUid());
+ final String[] packages = mPackageManager.getPackagesForUid(uid);
if (mBatteryUtils.shouldHideUidBatteryConsumerUnconditionally(consumer, packages)) {
continue;
}
@@ -333,11 +325,11 @@
continue;
}
- final int index = batteryEntryList.indexOfKey(realUid);
+ final int index = batteryEntryList.indexOfKey(uid);
if (index < 0) {
// New entry.
- batteryEntryList.put(realUid, new BatteryEntry(mContext, mHandler, mUserManager,
- consumer, isHidden, packages, null, loadDataInBackground));
+ batteryEntryList.put(uid, new BatteryEntry(mContext, mHandler, mUserManager,
+ consumer, isHidden, uid, packages, null, loadDataInBackground));
} else {
// Combine BatterySippers if we already have one with this UID.
final BatteryEntry existingSipper = batteryEntryList.valueAt(index);
@@ -385,7 +377,8 @@
for (int i = 0, size = userBatteryConsumers.size(); i < size; i++) {
final UserBatteryConsumer consumer = userBatteryConsumers.get(i);
results.add(new BatteryEntry(mContext, mHandler, mUserManager,
- consumer, /* isHidden */ true, null, null, loadDataInBackground));
+ consumer, /* isHidden */ true, Process.INVALID_UID, null, null,
+ loadDataInBackground));
}
}
@@ -400,6 +393,27 @@
return results;
}
+ private int getRealUid(UidBatteryConsumer consumer) {
+ int realUid = consumer.getUid();
+
+ // Check if this UID is a shared GID. If so, we combine it with the OWNER's
+ // actual app UID.
+ if (isSharedGid(consumer.getUid())) {
+ realUid = UserHandle.getUid(UserHandle.USER_SYSTEM,
+ UserHandle.getAppIdFromSharedAppGid(consumer.getUid()));
+ }
+
+ // Check if this UID is a system UID (mediaserver, logd, nfc, drm, etc).
+ if (isSystemUid(realUid)
+ && !MEDIASERVER_PACKAGE_NAME.equals(consumer.getPackageWithHighestDrain())) {
+ // Use the system UID for all UIDs running in their own sandbox that
+ // are not apps. We exclude mediaserver because we already are expected to
+ // report that as a separate item.
+ realUid = Process.SYSTEM_UID;
+ }
+ return realUid;
+ }
+
@VisibleForTesting
void setUsageSummary(Preference preference, BatteryEntry entry) {
// Only show summary when usage time is longer than one minute
diff --git a/src/com/android/settings/fuelgauge/BatteryChartPreferenceController.java b/src/com/android/settings/fuelgauge/BatteryChartPreferenceController.java
index ffbd2d9..3c9cbaa 100644
--- a/src/com/android/settings/fuelgauge/BatteryChartPreferenceController.java
+++ b/src/com/android/settings/fuelgauge/BatteryChartPreferenceController.java
@@ -272,7 +272,7 @@
final Map<String, BatteryHistEntry> entryMap = batteryHistoryMap.get(timestamp);
if (entryMap == null || entryMap.isEmpty()) {
Log.e(TAG, "abnormal entry list in the timestamp:"
- + ConvertUtils.utcToLocalTime(timestamp));
+ + ConvertUtils.utcToLocalTime(mPrefContext, timestamp));
continue;
}
// Averages the battery level in each time slot to avoid corner conditions.
@@ -287,7 +287,7 @@
Log.d(TAG, String.format(
"setBatteryHistoryMap() size=%d\nkeys=%s\nlevels=%s",
batteryHistoryMap.size(),
- utcToLocalTime(mBatteryHistoryKeys),
+ utcToLocalTime(mPrefContext, mBatteryHistoryKeys),
Arrays.toString(mBatteryHistoryLevels)));
// Loads item icon and label in the background.
@@ -496,9 +496,9 @@
if (mTrapezoidIndex < 0) {
return null;
}
- final String fromHour = ConvertUtils.utcToLocalTimeHour(
+ final String fromHour = ConvertUtils.utcToLocalTimeHour(mPrefContext,
mBatteryHistoryKeys[mTrapezoidIndex * 2], mIs24HourFormat);
- final String toHour = ConvertUtils.utcToLocalTimeHour(
+ final String toHour = ConvertUtils.utcToLocalTimeHour(mPrefContext,
mBatteryHistoryKeys[(mTrapezoidIndex + 1) * 2], mIs24HourFormat);
return String.format("%s - %s", fromHour, toHour);
}
@@ -584,11 +584,11 @@
mHandler.post(() -> mPreferenceScreen.addPreference(mFooterPreference));
}
- private static String utcToLocalTime(long[] timestamps) {
+ private static String utcToLocalTime(Context context, long[] timestamps) {
final StringBuilder builder = new StringBuilder();
for (int index = 0; index < timestamps.length; index++) {
builder.append(String.format("%s| ",
- ConvertUtils.utcToLocalTime(timestamps[index])));
+ ConvertUtils.utcToLocalTime(context, timestamps[index])));
}
return builder.toString();
}
diff --git a/src/com/android/settings/fuelgauge/BatteryChartView.java b/src/com/android/settings/fuelgauge/BatteryChartView.java
index ed64177..b721f14 100644
--- a/src/com/android/settings/fuelgauge/BatteryChartView.java
+++ b/src/com/android/settings/fuelgauge/BatteryChartView.java
@@ -56,14 +56,8 @@
private static final List<String> ACCESSIBILITY_SERVICE_NAMES =
Arrays.asList("SwitchAccessService", "TalkBackService", "JustSpeakService");
- // For drawing the percentage information.
- private static final String[] PERCENTAGES = new String[] {
- formatPercentage(/*percentage=*/ 100, /*round=*/ true),
- formatPercentage(/*percentage=*/ 50, /*round=*/ true),
- formatPercentage(/*percentage=*/ 0, /*round=*/ true)};
-
private static final int DEFAULT_TRAPEZOID_COUNT = 12;
- private static final int DEFAULT_TIMESTAMP_COUNT = 4;
+ private static final int DEFAULT_TIMESTAMP_COUNT = 5;
private static final int DIVIDER_COLOR = Color.parseColor("#CDCCC5");
private static final long UPDATE_STATE_DELAYED_TIME = 500L;
@@ -82,6 +76,7 @@
private float mTrapezoidVOffset;
private float mTrapezoidHOffset;
private boolean mIsSlotsClickabled;
+ private String[] mPercentages = getPercentages();
@VisibleForTesting int mSelectedIndex;
@VisibleForTesting String[] mTimestamps;
@@ -96,7 +91,7 @@
new Rect[] {new Rect(), new Rect(), new Rect()};
// For drawing the timestamp information.
private final Rect[] mTimestampsBounds =
- new Rect[] {new Rect(), new Rect(), new Rect(), new Rect()};
+ new Rect[] {new Rect(), new Rect(), new Rect(), new Rect(), new Rect()};
@VisibleForTesting
Handler mHandler = new Handler();
@@ -107,6 +102,7 @@
private Paint mTextPaint;
private Paint mDividerPaint;
private Paint mTrapezoidPaint;
+
@VisibleForTesting
Paint mTrapezoidCurvePaint = null;
private TrapezoidSlot[] mTrapezoidSlots;
@@ -201,12 +197,13 @@
if (mTimestamps == null) {
mTimestamps = new String[DEFAULT_TIMESTAMP_COUNT];
}
- final long timeSlotOffset = DateUtils.HOUR_IN_MILLIS * 8;
+ final long timeSlotOffset = DateUtils.HOUR_IN_MILLIS * 6;
final boolean is24HourFormat = DateFormat.is24HourFormat(getContext());
for (int index = 0; index < DEFAULT_TIMESTAMP_COUNT; index++) {
mTimestamps[index] =
ConvertUtils.utcToLocalTimeHour(
- latestTimestamp - (3 - index) * timeSlotOffset,
+ getContext(),
+ latestTimestamp - (4 - index) * timeSlotOffset,
is24HourFormat);
}
requestLayout();
@@ -217,9 +214,9 @@
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
// Measures text bounds and updates indent configuration.
if (mTextPaint != null) {
- for (int index = 0; index < PERCENTAGES.length; index++) {
+ for (int index = 0; index < mPercentages.length; index++) {
mTextPaint.getTextBounds(
- PERCENTAGES[index], 0, PERCENTAGES[index].length(),
+ mPercentages[index], 0, mPercentages[index].length(),
mPercentageBounds[index]);
}
// Updates the indent configurations.
@@ -396,7 +393,7 @@
private void drawPercentage(Canvas canvas, int index, float offsetY) {
if (mTextPaint != null) {
canvas.drawText(
- PERCENTAGES[index],
+ mPercentages[index],
getWidth() - mPercentageBounds[index].width() - mPercentageBounds[index].left,
offsetY + mPercentageBounds[index].height() *.5f,
mTextPaint);
@@ -429,7 +426,7 @@
final float baselineX = mDividerWidth * .5f;
final float offsetX = mDividerWidth + unitWidth;
for (int index = 0; index < DEFAULT_TIMESTAMP_COUNT; index++) {
- xOffsets[index] = baselineX + index * offsetX * 4;
+ xOffsets[index] = baselineX + index * offsetX * 3;
}
drawTimestamp(canvas, xOffsets);
}
@@ -443,11 +440,11 @@
getTimestampY(0), mTextPaint);
// Draws the last timestamp info.
canvas.drawText(
- mTimestamps[3],
- xOffsets[3] - mTimestampsBounds[3].width() - mTimestampsBounds[3].left,
- getTimestampY(3), mTextPaint);
+ mTimestamps[4],
+ xOffsets[4] - mTimestampsBounds[4].width() - mTimestampsBounds[4].left,
+ getTimestampY(4), mTextPaint);
// Draws the rest of timestamp info since it is located in the center.
- for (int index = 1; index <= 2; index++) {
+ for (int index = 1; index <= 3; index++) {
canvas.drawText(
mTimestamps[index],
xOffsets[index] -
@@ -544,6 +541,13 @@
&& mLevels[trapezoidIndex + 1] != 0;
}
+ private static String[] getPercentages() {
+ return new String[] {
+ formatPercentage(/*percentage=*/ 100, /*round=*/ true),
+ formatPercentage(/*percentage=*/ 50, /*round=*/ true),
+ formatPercentage(/*percentage=*/ 0, /*round=*/ true)};
+ }
+
@VisibleForTesting
static boolean isAccessibilityEnabled(Context context) {
final AccessibilityManager accessibilityManager =
diff --git a/src/com/android/settings/fuelgauge/BatteryEntry.java b/src/com/android/settings/fuelgauge/BatteryEntry.java
index 78ab962..0478c8b 100644
--- a/src/com/android/settings/fuelgauge/BatteryEntry.java
+++ b/src/com/android/settings/fuelgauge/BatteryEntry.java
@@ -159,12 +159,15 @@
private final Context mContext;
private final BatteryConsumer mBatteryConsumer;
+ private final int mUid;
private final boolean mIsHidden;
@ConvertUtils.ConsumerType
private final int mConsumerType;
@BatteryConsumer.PowerComponent
private final int mPowerComponentId;
private long mUsageDurationMs;
+ private long mTimeInForegroundMs;
+ private long mTimeInBackgroundMs;
public String name;
public Drawable icon;
@@ -180,13 +183,13 @@
}
public BatteryEntry(Context context, Handler handler, UserManager um,
- @NonNull BatteryConsumer batteryConsumer, boolean isHidden, String[] packages,
+ @NonNull BatteryConsumer batteryConsumer, boolean isHidden, int uid, String[] packages,
String packageName) {
- this(context, handler, um, batteryConsumer, isHidden, packages, packageName, true);
+ this(context, handler, um, batteryConsumer, isHidden, uid, packages, packageName, true);
}
public BatteryEntry(Context context, Handler handler, UserManager um,
- @NonNull BatteryConsumer batteryConsumer, boolean isHidden, String[] packages,
+ @NonNull BatteryConsumer batteryConsumer, boolean isHidden, int uid, String[] packages,
String packageName, boolean loadDataInBackground) {
sHandler = handler;
mContext = context;
@@ -196,11 +199,11 @@
mPowerComponentId = -1;
if (batteryConsumer instanceof UidBatteryConsumer) {
+ mUid = uid;
mConsumerType = ConvertUtils.CONSUMER_TYPE_UID_BATTERY;
mConsumedPower = batteryConsumer.getConsumedPower();
UidBatteryConsumer uidBatteryConsumer = (UidBatteryConsumer) batteryConsumer;
- int uid = uidBatteryConsumer.getUid();
if (mDefaultPackageName == null) {
// Apps should only have one package
if (packages != null && packages.length == 1) {
@@ -222,7 +225,12 @@
}
}
getQuickNameIconForUid(uid, packages, loadDataInBackground);
+ mTimeInForegroundMs =
+ uidBatteryConsumer.getTimeInStateMs(UidBatteryConsumer.STATE_FOREGROUND);
+ mTimeInBackgroundMs =
+ uidBatteryConsumer.getTimeInStateMs(UidBatteryConsumer.STATE_BACKGROUND);
} else if (batteryConsumer instanceof UserBatteryConsumer) {
+ mUid = Process.INVALID_UID;
mConsumerType = ConvertUtils.CONSUMER_TYPE_USER_BATTERY;
mConsumedPower = batteryConsumer.getConsumedPower();
final NameAndIcon nameAndIcon = getNameAndIconFromUserId(
@@ -239,6 +247,7 @@
double appsPowerMah, long usageDurationMs) {
mContext = context;
mBatteryConsumer = null;
+ mUid = Process.INVALID_UID;
mIsHidden = false;
mPowerComponentId = powerComponentId;
mConsumedPower =
@@ -261,6 +270,7 @@
double devicePowerMah, double appsPowerMah) {
mContext = context;
mBatteryConsumer = null;
+ mUid = Process.INVALID_UID;
mIsHidden = false;
mPowerComponentId = powerComponentId;
@@ -438,7 +448,7 @@
*/
public String getKey() {
if (mBatteryConsumer instanceof UidBatteryConsumer) {
- return Integer.toString(((UidBatteryConsumer) mBatteryConsumer).getUid());
+ return Integer.toString(mUid);
} else if (mBatteryConsumer instanceof UserBatteryConsumer) {
return "U|" + ((UserBatteryConsumer) mBatteryConsumer).getUserId();
} else {
@@ -482,11 +492,7 @@
* Returns the UID of the app described by this entry.
*/
public int getUid() {
- if (mBatteryConsumer instanceof UidBatteryConsumer) {
- return ((UidBatteryConsumer) mBatteryConsumer).getUid();
- } else {
- return Process.INVALID_UID;
- }
+ return mUid;
}
/**
@@ -494,8 +500,7 @@
*/
public long getTimeInForegroundMs() {
if (mBatteryConsumer instanceof UidBatteryConsumer) {
- return ((UidBatteryConsumer) mBatteryConsumer).getTimeInStateMs(
- UidBatteryConsumer.STATE_FOREGROUND);
+ return mTimeInForegroundMs;
} else {
return mUsageDurationMs;
}
@@ -506,8 +511,7 @@
*/
public long getTimeInBackgroundMs() {
if (mBatteryConsumer instanceof UidBatteryConsumer) {
- return ((UidBatteryConsumer) mBatteryConsumer).getTimeInStateMs(
- UidBatteryConsumer.STATE_BACKGROUND);
+ return mTimeInBackgroundMs;
} else {
return 0;
}
@@ -526,9 +530,15 @@
*/
public void add(BatteryConsumer batteryConsumer) {
mConsumedPower += batteryConsumer.getConsumedPower();
- if (mDefaultPackageName == null && batteryConsumer instanceof UidBatteryConsumer) {
- mDefaultPackageName =
- ((UidBatteryConsumer) batteryConsumer).getPackageWithHighestDrain();
+ if (batteryConsumer instanceof UidBatteryConsumer) {
+ UidBatteryConsumer uidBatteryConsumer = (UidBatteryConsumer) batteryConsumer;
+ mTimeInForegroundMs += uidBatteryConsumer.getTimeInStateMs(
+ UidBatteryConsumer.STATE_FOREGROUND);
+ mTimeInBackgroundMs += uidBatteryConsumer.getTimeInStateMs(
+ UidBatteryConsumer.STATE_BACKGROUND);
+ if (mDefaultPackageName == null) {
+ mDefaultPackageName = uidBatteryConsumer.getPackageWithHighestDrain();
+ }
}
}
diff --git a/src/com/android/settings/fuelgauge/BatteryHistEntry.java b/src/com/android/settings/fuelgauge/BatteryHistEntry.java
index d83d814..4c8ecee 100644
--- a/src/com/android/settings/fuelgauge/BatteryHistEntry.java
+++ b/src/com/android/settings/fuelgauge/BatteryHistEntry.java
@@ -184,7 +184,8 @@
@Override
public String toString() {
- final String recordAtDateTime = ConvertUtils.utcToLocalTime(mTimestamp);
+ final String recordAtDateTime =
+ ConvertUtils.utcToLocalTime(/*context=*/ null, mTimestamp);
final StringBuilder builder = new StringBuilder()
.append("\nBatteryHistEntry{")
.append(String.format("\n\tpackage=%s|label=%s|uid=%d|userId=%d|isHidden=%b",
diff --git a/src/com/android/settings/fuelgauge/ConvertUtils.java b/src/com/android/settings/fuelgauge/ConvertUtils.java
index 1980564..01f510e 100644
--- a/src/com/android/settings/fuelgauge/ConvertUtils.java
+++ b/src/com/android/settings/fuelgauge/ConvertUtils.java
@@ -17,6 +17,7 @@
import android.content.ContentValues;
import android.content.Context;
import android.os.BatteryUsageStats;
+import android.os.LocaleList;
import android.os.UserHandle;
import android.text.format.DateUtils;
import android.util.Log;
@@ -133,8 +134,8 @@
}
/** Converts UTC timestamp to human readable local time string. */
- public static String utcToLocalTime(long timestamp) {
- final Locale currentLocale = Locale.getDefault();
+ public static String utcToLocalTime(Context context, long timestamp) {
+ final Locale currentLocale = getLocale(context);
final String currentZoneId = TimeZone.getDefault().getID();
if (!currentZoneId.equals(sZoneId)
|| !currentLocale.equals(sLocale)
@@ -148,8 +149,9 @@
}
/** Converts UTC timestamp to local time hour data. */
- public static String utcToLocalTimeHour(long timestamp, boolean is24HourFormat) {
- final Locale currentLocale = Locale.getDefault();
+ public static String utcToLocalTimeHour(
+ Context context, long timestamp, boolean is24HourFormat) {
+ final Locale currentLocale = getLocale(context);
final String currentZoneId = TimeZone.getDefault().getID();
if (!currentZoneId.equals(sZoneIdForHour)
|| !currentLocale.equals(sLocaleForHour)
@@ -159,7 +161,7 @@
sZoneIdForHour = currentZoneId;
sIs24HourFormat = is24HourFormat;
sSimpleDateFormatForHour = new SimpleDateFormat(
- sIs24HourFormat ? "HH" : "h aa", currentLocale);
+ sIs24HourFormat ? "HH" : "h", currentLocale);
}
return sSimpleDateFormatForHour.format(new Date(timestamp))
.toLowerCase(currentLocale);
@@ -356,4 +358,15 @@
? entry3 : null;
}
}
+
+ @VisibleForTesting
+ static Locale getLocale(Context context) {
+ if (context == null) {
+ return Locale.getDefault();
+ }
+ final LocaleList locales =
+ context.getResources().getConfiguration().getLocales();
+ return locales != null && !locales.isEmpty() ? locales.get(0)
+ : Locale.getDefault();
+ }
}
diff --git a/src/com/android/settings/location/LocationInjectedServiceBasePreferenceController.java b/src/com/android/settings/location/LocationInjectedServiceBasePreferenceController.java
new file mode 100644
index 0000000..3b593b9
--- /dev/null
+++ b/src/com/android/settings/location/LocationInjectedServiceBasePreferenceController.java
@@ -0,0 +1,121 @@
+/*
+ * Copyright (C) 2021 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.BroadcastReceiver;
+import android.content.Context;
+import android.content.Intent;
+import android.content.IntentFilter;
+import android.location.SettingInjectorService;
+import android.os.UserHandle;
+import android.util.Log;
+
+import androidx.annotation.VisibleForTesting;
+import androidx.lifecycle.Lifecycle;
+import androidx.lifecycle.OnLifecycleEvent;
+import androidx.preference.Preference;
+import androidx.preference.PreferenceScreen;
+
+import com.android.settings.Utils;
+import com.android.settings.dashboard.DashboardFragment;
+import com.android.settingslib.core.lifecycle.LifecycleObserver;
+
+import java.util.List;
+import java.util.Map;
+
+/**
+ * A abstract class which is responsible for creating the injected location services items.
+ * Developer needs to implement the {@link #injectLocationServices(PreferenceScreen)}.
+ */
+public abstract class LocationInjectedServiceBasePreferenceController
+ extends LocationBasePreferenceController implements LifecycleObserver{
+
+ private static final String TAG = "LocationPrefCtrl";
+ @VisibleForTesting
+ static final IntentFilter INTENT_FILTER_INJECTED_SETTING_CHANGED =
+ new IntentFilter(SettingInjectorService.ACTION_INJECTED_SETTING_CHANGED);
+
+ @VisibleForTesting
+ AppSettingsInjector mInjector;
+ /** Receives UPDATE_INTENT */
+ @VisibleForTesting
+ BroadcastReceiver mInjectedSettingsReceiver;
+
+ public LocationInjectedServiceBasePreferenceController(Context context, String key) {
+ super(context, key);
+ }
+
+ @Override
+ public void init(DashboardFragment fragment) {
+ super.init(fragment);
+ mInjector = new AppSettingsInjector(mContext, getMetricsCategory());
+ }
+
+ @Override
+ public void displayPreference(PreferenceScreen screen) {
+ super.displayPreference(screen);
+ injectLocationServices(screen);
+ }
+
+ /**
+ * Override this method to inject location services in preference screen.
+ * @param screen
+ */
+ protected abstract void injectLocationServices(PreferenceScreen screen);
+
+ @Override
+ public void onLocationModeChanged(int mode, boolean restricted) {
+ // As a safety measure, also reloads on location mode change to ensure the settings are
+ // up-to-date even if an affected app doesn't send the setting changed broadcast.
+ mInjector.reloadStatusMessages();
+ }
+
+ /** @OnLifecycleEvent(ON_RESUME) */
+ @OnLifecycleEvent(Lifecycle.Event.ON_RESUME)
+ public void onResume() {
+ if (mInjectedSettingsReceiver == null) {
+ mInjectedSettingsReceiver = new BroadcastReceiver() {
+ @Override
+ public void onReceive(Context context, Intent intent) {
+ if (Log.isLoggable(TAG, Log.DEBUG)) {
+ Log.d(TAG, "Received settings change intent: " + intent);
+ }
+ mInjector.reloadStatusMessages();
+ }
+ };
+ }
+ mContext.registerReceiver(
+ mInjectedSettingsReceiver, INTENT_FILTER_INJECTED_SETTING_CHANGED);
+ }
+
+ /** @OnLifecycleEvent(ON_PAUSE) */
+ @OnLifecycleEvent(Lifecycle.Event.ON_PAUSE)
+ public void onPause() {
+ mContext.unregisterReceiver(mInjectedSettingsReceiver);
+ }
+
+ protected Map<Integer, List<Preference>> getLocationServices() {
+ // If location access is locked down by device policy then we only show injected settings
+ // for the primary profile.
+ final int profileUserId = Utils.getManagedProfileId(mUserManager, UserHandle.myUserId());
+
+ return mInjector.getInjectedSettings(mFragment.getPreferenceManager().getContext(),
+ (profileUserId != UserHandle.USER_NULL
+ && mLocationEnabler.getShareLocationEnforcedAdmin(profileUserId) != null)
+ ? UserHandle.myUserId() : UserHandle.USER_CURRENT);
+ }
+}
diff --git a/src/com/android/settings/location/LocationInjectedServicesForWorkPreferenceController.java b/src/com/android/settings/location/LocationInjectedServicesForWorkPreferenceController.java
index 571b4a7..b7e6cf2 100644
--- a/src/com/android/settings/location/LocationInjectedServicesForWorkPreferenceController.java
+++ b/src/com/android/settings/location/LocationInjectedServicesForWorkPreferenceController.java
@@ -20,6 +20,8 @@
import android.os.UserHandle;
import androidx.preference.Preference;
+import androidx.preference.PreferenceCategory;
+import androidx.preference.PreferenceScreen;
import com.android.settings.widget.RestrictedAppPreference;
@@ -30,7 +32,7 @@
* Retrieve the Location Services used in work profile user.
*/
public class LocationInjectedServicesForWorkPreferenceController extends
- LocationInjectedServicesPreferenceController {
+ LocationInjectedServiceBasePreferenceController {
private static final String TAG = "LocationWorkPrefCtrl";
public LocationInjectedServicesForWorkPreferenceController(Context context, String key) {
@@ -38,10 +40,10 @@
}
@Override
- public void updateState(Preference preference) {
- mCategoryLocationServices.removeAll();
+ protected void injectLocationServices(PreferenceScreen screen) {
+ final PreferenceCategory categoryLocationServices =
+ screen.findPreference(getPreferenceKey());
final Map<Integer, List<Preference>> prefs = getLocationServices();
- boolean show = false;
for (Map.Entry<Integer, List<Preference>> entry : prefs.entrySet()) {
for (Preference pref : entry.getValue()) {
if (pref instanceof RestrictedAppPreference) {
@@ -49,11 +51,8 @@
}
}
if (entry.getKey() != UserHandle.myUserId()) {
- LocationSettings.addPreferencesSorted(entry.getValue(),
- mCategoryLocationServices);
- show = true;
+ LocationSettings.addPreferencesSorted(entry.getValue(), categoryLocationServices);
}
}
- mCategoryLocationServices.setVisible(show);
}
}
diff --git a/src/com/android/settings/location/LocationInjectedServicesPreferenceController.java b/src/com/android/settings/location/LocationInjectedServicesPreferenceController.java
index 8573307..d623bae 100644
--- a/src/com/android/settings/location/LocationInjectedServicesPreferenceController.java
+++ b/src/com/android/settings/location/LocationInjectedServicesPreferenceController.java
@@ -15,25 +15,14 @@
*/
package com.android.settings.location;
-import android.content.BroadcastReceiver;
import android.content.Context;
-import android.content.Intent;
-import android.content.IntentFilter;
-import android.location.SettingInjectorService;
import android.os.UserHandle;
-import android.util.Log;
-import androidx.annotation.VisibleForTesting;
import androidx.preference.Preference;
import androidx.preference.PreferenceCategory;
import androidx.preference.PreferenceScreen;
-import com.android.settings.Utils;
-import com.android.settings.dashboard.DashboardFragment;
import com.android.settings.widget.RestrictedAppPreference;
-import com.android.settingslib.core.lifecycle.LifecycleObserver;
-import com.android.settingslib.core.lifecycle.events.OnPause;
-import com.android.settingslib.core.lifecycle.events.OnResume;
import java.util.List;
import java.util.Map;
@@ -41,42 +30,20 @@
/**
* Preference controller for the injected Location Services.
*/
-public class LocationInjectedServicesPreferenceController extends LocationBasePreferenceController
- implements LifecycleObserver, OnResume, OnPause {
+public class LocationInjectedServicesPreferenceController
+ extends LocationInjectedServiceBasePreferenceController {
private static final String TAG = "LocationPrefCtrl";
- @VisibleForTesting
- static final IntentFilter INTENT_FILTER_INJECTED_SETTING_CHANGED =
- new IntentFilter(SettingInjectorService.ACTION_INJECTED_SETTING_CHANGED);
-
- protected PreferenceCategory mCategoryLocationServices;
- @VisibleForTesting
- AppSettingsInjector mInjector;
- /** Receives UPDATE_INTENT */
- @VisibleForTesting
- BroadcastReceiver mInjectedSettingsReceiver;
public LocationInjectedServicesPreferenceController(Context context, String key) {
super(context, key);
}
@Override
- public void init(DashboardFragment fragment) {
- super.init(fragment);
- mInjector = new AppSettingsInjector(mContext, getMetricsCategory());
- }
-
- @Override
- public void displayPreference(PreferenceScreen screen) {
- super.displayPreference(screen);
- mCategoryLocationServices = screen.findPreference(getPreferenceKey());
- }
-
- @Override
- public void updateState(Preference preference) {
- mCategoryLocationServices.removeAll();
+ protected void injectLocationServices(PreferenceScreen screen) {
+ final PreferenceCategory categoryLocationServices =
+ screen.findPreference(getPreferenceKey());
final Map<Integer, List<Preference>> prefs = getLocationServices();
- boolean show = false;
for (Map.Entry<Integer, List<Preference>> entry : prefs.entrySet()) {
for (Preference pref : entry.getValue()) {
if (pref instanceof RestrictedAppPreference) {
@@ -84,53 +51,11 @@
}
}
if (entry.getKey() == UserHandle.myUserId()) {
- if (mCategoryLocationServices != null) {
+ if (categoryLocationServices != null) {
LocationSettings.addPreferencesSorted(entry.getValue(),
- mCategoryLocationServices);
+ categoryLocationServices);
}
- show = true;
}
}
- mCategoryLocationServices.setVisible(show);
- }
-
- @Override
- public void onLocationModeChanged(int mode, boolean restricted) {
- // As a safety measure, also reloads on location mode change to ensure the settings are
- // up-to-date even if an affected app doesn't send the setting changed broadcast.
- mInjector.reloadStatusMessages();
- }
-
- @Override
- public void onResume() {
- if (mInjectedSettingsReceiver == null) {
- mInjectedSettingsReceiver = new BroadcastReceiver() {
- @Override
- public void onReceive(Context context, Intent intent) {
- if (Log.isLoggable(TAG, Log.DEBUG)) {
- Log.d(TAG, "Received settings change intent: " + intent);
- }
- mInjector.reloadStatusMessages();
- }
- };
- }
- mContext.registerReceiver(
- mInjectedSettingsReceiver, INTENT_FILTER_INJECTED_SETTING_CHANGED);
- }
-
- @Override
- public void onPause() {
- mContext.unregisterReceiver(mInjectedSettingsReceiver);
- }
-
- protected Map<Integer, List<Preference>> getLocationServices() {
- // If location access is locked down by device policy then we only show injected settings
- // for the primary profile.
- final int profileUserId = Utils.getManagedProfileId(mUserManager, UserHandle.myUserId());
-
- return mInjector.getInjectedSettings(mFragment.getPreferenceManager().getContext(),
- (profileUserId != UserHandle.USER_NULL
- && mLocationEnabler.getShareLocationEnforcedAdmin(profileUserId) != null)
- ? UserHandle.myUserId() : UserHandle.USER_CURRENT);
}
}
diff --git a/src/com/android/settings/network/ProviderModelSlice.java b/src/com/android/settings/network/ProviderModelSlice.java
index b778a05..cfaef53 100644
--- a/src/com/android/settings/network/ProviderModelSlice.java
+++ b/src/com/android/settings/network/ProviderModelSlice.java
@@ -46,6 +46,7 @@
import com.android.settings.network.telephony.NetworkProviderWorker;
import com.android.settings.slices.CustomSliceable;
import com.android.settings.slices.SliceBackgroundWorker;
+import com.android.settings.slices.SliceBroadcastReceiver;
import com.android.settings.slices.SliceBuilderUtils;
import com.android.settings.wifi.WifiUtils;
import com.android.settings.wifi.slice.WifiSlice;
@@ -163,6 +164,18 @@
return listBuilder.build();
}
+ @Override
+ public PendingIntent getBroadcastIntent(Context context) {
+ final Intent intent = new Intent(getUri().toString())
+ // The FLAG_RECEIVER_FOREGROUND flag is necessary to avoid the intent delay of
+ // the first sending after the device restarts
+ .addFlags(Intent.FLAG_RECEIVER_FOREGROUND)
+ .setData(getUri())
+ .setClass(context, SliceBroadcastReceiver.class);
+ return PendingIntent.getBroadcast(context, 0 /* requestCode */, intent,
+ PendingIntent.FLAG_UPDATE_CURRENT | PendingIntent.FLAG_MUTABLE);
+ }
+
/**
* Update the current carrier's mobile data status.
*/
diff --git a/src/com/android/settings/network/SubscriptionsPreferenceController.java b/src/com/android/settings/network/SubscriptionsPreferenceController.java
index 2d23f1f..8c7347b 100644
--- a/src/com/android/settings/network/SubscriptionsPreferenceController.java
+++ b/src/com/android/settings/network/SubscriptionsPreferenceController.java
@@ -29,6 +29,7 @@
import android.content.IntentFilter;
import android.graphics.drawable.Drawable;
import android.net.wifi.WifiManager;
+import android.os.UserManager;
import android.provider.Settings;
import android.telephony.ServiceState;
import android.telephony.SignalStrength;
@@ -38,6 +39,7 @@
import android.telephony.TelephonyManager;
import android.text.Html;
import android.util.ArraySet;
+import android.util.Log;
import androidx.annotation.VisibleForTesting;
import androidx.collection.ArrayMap;
@@ -55,7 +57,7 @@
import com.android.settings.network.telephony.MobileNetworkUtils;
import com.android.settings.network.telephony.SignalStrengthListener;
import com.android.settings.network.telephony.TelephonyDisplayInfoListener;
-import com.android.settings.widget.GearPreference;
+import com.android.settings.widget.MutableGearPreference;
import com.android.settings.wifi.WifiPickerTrackerHelper;
import com.android.settingslib.SignalIcon.MobileIconGroup;
import com.android.settingslib.core.AbstractPreferenceController;
@@ -115,7 +117,7 @@
// Map of subscription id to Preference
private Map<Integer, Preference> mSubscriptionPreferences;
private int mStartOrder;
- private GearPreference mSubsGearPref;
+ private MutableGearPreference mSubsGearPref;
private Config mConfig = null;
private SubsPrefCtrlInjector mSubsPrefCtrlInjector;
private TelephonyDisplayInfo mTelephonyDisplayInfo =
@@ -196,6 +198,7 @@
mSignalStrengthListener.pause();
mTelephonyDisplayInfoListener.pause();
unRegisterReceiver();
+ resetProviderPreferenceSummary();
}
@Override
@@ -238,15 +241,20 @@
}
if (mSubsGearPref == null) {
mPreferenceGroup.removeAll();
- mSubsGearPref = new GearPreference(mContext, null);
+ mSubsGearPref = new MutableGearPreference(mContext, null);
mSubsGearPref.setOnPreferenceClickListener(preference -> {
connectCarrierNetwork();
return true;
});
+
mSubsGearPref.setOnGearClickListener(p ->
startMobileNetworkActivity(mContext, subInfo.getSubscriptionId()));
}
+ if (!(mContext.getSystemService(UserManager.class)).isAdminUser()) {
+ mSubsGearPref.setGearEnabled(false);
+ }
+
mSubsGearPref.setTitle(SubscriptionUtil.getUniqueSubscriptionDisplayName(
subInfo, mContext));
mSubsGearPref.setOrder(mStartOrder);
@@ -275,6 +283,7 @@
String result = mSubsPrefCtrlInjector.getNetworkType(
mContext, mConfig, mTelephonyDisplayInfo, subId, isActiveCarrierNetwork);
if (mSubsPrefCtrlInjector.isActiveCellularNetwork(mContext) || isActiveCarrierNetwork) {
+ Log.i(TAG, "Active cellular network or active carrier network.");
result = mContext.getString(R.string.preference_summary_default_combination,
mContext.getString(R.string.mobile_data_connection_active), result);
} else if (!isDataInService) {
@@ -316,6 +325,13 @@
return icon;
}
+ private void resetProviderPreferenceSummary() {
+ if (mSubsGearPref == null) {
+ return;
+ }
+ mSubsGearPref.setSummary("");
+ }
+
private void updateForBase() {
final Map<Integer, Preference> existingPrefs = mSubscriptionPreferences;
mSubscriptionPreferences = new ArrayMap<>();
diff --git a/src/com/android/settings/network/telephony/NetworkProviderWifiCallingGroup.java b/src/com/android/settings/network/telephony/NetworkProviderWifiCallingGroup.java
index 3423ad8..b4ab2a0 100644
--- a/src/com/android/settings/network/telephony/NetworkProviderWifiCallingGroup.java
+++ b/src/com/android/settings/network/telephony/NetworkProviderWifiCallingGroup.java
@@ -47,6 +47,7 @@
import com.android.settingslib.core.AbstractPreferenceController;
import com.android.settingslib.core.lifecycle.Lifecycle;
+import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -86,7 +87,8 @@
}
private void setSubscriptionInfoList(Context context) {
- mSubInfoListForWfc = SubscriptionUtil.getActiveSubscriptions(mSubscriptionManager);
+ mSubInfoListForWfc = new ArrayList<>(
+ SubscriptionUtil.getActiveSubscriptions(mSubscriptionManager));
if (mSubInfoListForWfc != null) {
mSubInfoListForWfc.removeIf(info -> {
final int subId = info.getSubscriptionId();
diff --git a/src/com/android/settings/network/telephony/ToggleSubscriptionDialogActivity.java b/src/com/android/settings/network/telephony/ToggleSubscriptionDialogActivity.java
index 0064e6c..146b575 100644
--- a/src/com/android/settings/network/telephony/ToggleSubscriptionDialogActivity.java
+++ b/src/com/android/settings/network/telephony/ToggleSubscriptionDialogActivity.java
@@ -30,12 +30,14 @@
import com.android.internal.annotations.VisibleForTesting;
import com.android.settings.R;
import com.android.settings.SidecarFragment;
+import com.android.settings.core.SettingsBaseActivity;
import com.android.settings.network.EnableMultiSimSidecar;
import com.android.settings.network.SubscriptionUtil;
import com.android.settings.network.SwitchToEuiccSubscriptionSidecar;
import com.android.settings.network.SwitchToRemovableSlotSidecar;
import com.android.settings.network.UiccSlotUtil;
import com.android.settings.sim.SimActivationNotifier;
+import com.android.settingslib.transition.SettingsTransitionHelper;
import com.google.common.collect.ImmutableList;
@@ -68,6 +70,9 @@
Intent intent = new Intent(context, ToggleSubscriptionDialogActivity.class);
intent.putExtra(ARG_SUB_ID, subId);
intent.putExtra(ARG_enable, enable);
+ // suppress page transition as this is a dialog
+ intent.putExtra(SettingsBaseActivity.EXTRA_PAGE_TRANSITION_TYPE,
+ SettingsTransitionHelper.TransitionType.TRANSITION_NONE);
return intent;
}
diff --git a/src/com/android/settings/notification/app/RecentConversationsPreferenceController.java b/src/com/android/settings/notification/app/RecentConversationsPreferenceController.java
index 5b2cdb9..d715ce4 100644
--- a/src/com/android/settings/notification/app/RecentConversationsPreferenceController.java
+++ b/src/com/android/settings/notification/app/RecentConversationsPreferenceController.java
@@ -141,9 +141,9 @@
int order = 100;
boolean hasClearable = false;
for (ConversationChannel conversation : conversations) {
- if (conversation.getParentNotificationChannel().getImportance() == IMPORTANCE_NONE
- || (conversation.getParentNotificationChannelGroup() != null
- && conversation.getParentNotificationChannelGroup().isBlocked())) {
+ if (conversation.getNotificationChannel().getImportance() == IMPORTANCE_NONE
+ || (conversation.getNotificationChannelGroup() != null
+ && conversation.getNotificationChannelGroup().isBlocked())) {
continue;
}
RecentConversationPreference pref =
@@ -179,12 +179,12 @@
pref.setSummary(getSummary(conversation));
pref.setIcon(mBackend.getConversationDrawable(mContext, conversation.getShortcutInfo(),
pkg, uid, false));
- pref.setKey(conversation.getParentNotificationChannel().getId()
+ pref.setKey(conversation.getNotificationChannel().getId()
+ ":" + conversationId);
pref.setOnPreferenceClickListener(preference -> {
mBackend.createConversationNotificationChannel(
pkg, uid,
- conversation.getParentNotificationChannel(),
+ conversation.getNotificationChannel(),
conversationId);
getSubSettingLauncher(conversation, pref.getTitle()).launch();
return true;
@@ -194,11 +194,11 @@
}
CharSequence getSummary(ConversationChannel conversation) {
- return conversation.getParentNotificationChannelGroup() == null
- ? conversation.getParentNotificationChannel().getName()
+ return conversation.getNotificationChannelGroup() == null
+ ? conversation.getNotificationChannel().getName()
: mContext.getString(R.string.notification_conversation_summary,
- conversation.getParentNotificationChannel().getName(),
- conversation.getParentNotificationChannelGroup().getName());
+ conversation.getNotificationChannel().getName(),
+ conversation.getNotificationChannelGroup().getName());
}
CharSequence getTitle(ConversationChannel conversation) {
@@ -213,7 +213,7 @@
channelArgs.putString(AppInfoBase.ARG_PACKAGE_NAME,
conversation.getShortcutInfo().getPackage());
channelArgs.putString(Settings.EXTRA_CHANNEL_ID,
- conversation.getParentNotificationChannel().getId());
+ conversation.getNotificationChannel().getId());
channelArgs.putString(Settings.EXTRA_CONVERSATION_ID,
conversation.getShortcutInfo().getId());
@@ -235,8 +235,8 @@
o2.getShortcutInfo().getLabel());
if (labelComparison == 0) {
- return o1.getParentNotificationChannel().getId().compareTo(
- o2.getParentNotificationChannel().getId());
+ return o1.getNotificationChannel().getId().compareTo(
+ o2.getNotificationChannel().getId());
}
return labelComparison;
diff --git a/src/com/android/settings/security/CredentialManagementAppAdapter.java b/src/com/android/settings/security/CredentialManagementAppAdapter.java
index eb379d5..3f4eb2a 100644
--- a/src/com/android/settings/security/CredentialManagementAppAdapter.java
+++ b/src/com/android/settings/security/CredentialManagementAppAdapter.java
@@ -21,6 +21,7 @@
import android.content.pm.PackageManager;
import android.net.Uri;
import android.security.AppUriAuthenticationPolicy;
+import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
@@ -85,11 +86,13 @@
ApplicationInfo applicationInfo =
mPackageManager.getApplicationInfo(mCredentialManagerPackage, 0);
mAppIconView.setImageDrawable(mPackageManager.getApplicationIcon(applicationInfo));
- mTitleView.setText(mContext.getString(R.string.request_manage_credentials_title,
+ mTitleView.setText(TextUtils.expandTemplate(
+ mContext.getText(R.string.request_manage_credentials_title),
applicationInfo.loadLabel(mPackageManager)));
} catch (PackageManager.NameNotFoundException e) {
mAppIconView.setImageDrawable(null);
- mTitleView.setText(mContext.getString(R.string.request_manage_credentials_title,
+ mTitleView.setText(TextUtils.expandTemplate(
+ mContext.getText(R.string.request_manage_credentials_title),
mCredentialManagerPackage));
}
}
diff --git a/src/com/android/settings/security/CredentialManagementAppButtonsController.java b/src/com/android/settings/security/CredentialManagementAppButtonsController.java
index fe5e45b..b296f37 100644
--- a/src/com/android/settings/security/CredentialManagementAppButtonsController.java
+++ b/src/com/android/settings/security/CredentialManagementAppButtonsController.java
@@ -80,12 +80,29 @@
private void displayButtons(PreferenceScreen screen) {
if (mHasCredentialManagerPackage) {
((ActionButtonsPreference) screen.findPreference(getPreferenceKey()))
- .setButton1Text(R.string.remove_credential_management_app)
- .setButton1Icon(R.drawable.ic_undo_24)
- .setButton1OnClickListener(view -> removeCredentialManagementApp());
+ .setButton1Text(R.string.uninstall_certs_credential_management_app)
+ .setButton1Icon(R.drawable.ic_upload)
+ .setButton1OnClickListener(view -> uninstallCertificates())
+ .setButton2Text(R.string.remove_credential_management_app)
+ .setButton2Icon(R.drawable.ic_delete)
+ .setButton2OnClickListener(view -> removeCredentialManagementApp());
}
}
+ private void uninstallCertificates() {
+ mExecutor.execute(() -> {
+ try {
+ IKeyChainService service = KeyChain.bind(mContext).getService();
+ for (String existingAlias :
+ service.getCredentialManagementAppPolicy().getAliases()) {
+ service.removeKeyPair(existingAlias);
+ }
+ } catch (InterruptedException | RemoteException e) {
+ Log.e(TAG, "Unable to uninstall certificates");
+ }
+ });
+ }
+
private void removeCredentialManagementApp() {
mExecutor.execute(() -> {
try {
diff --git a/src/com/android/settings/security/CredentialManagementAppHeaderController.java b/src/com/android/settings/security/CredentialManagementAppHeaderController.java
index 7b5ffb2..9361fb9 100644
--- a/src/com/android/settings/security/CredentialManagementAppHeaderController.java
+++ b/src/com/android/settings/security/CredentialManagementAppHeaderController.java
@@ -83,7 +83,6 @@
TextView titleView = headerPref.findViewById(R.id.entity_header_title);
TextView summary1 = headerPref.findViewById(R.id.entity_header_summary);
TextView summary2 = headerPref.findViewById(R.id.entity_header_second_summary);
- summary1.setVisibility(View.GONE);
summary2.setVisibility(View.GONE);
try {
@@ -91,6 +90,7 @@
mPackageManager.getApplicationInfo(mCredentialManagerPackageName, 0);
appIconView.setImageDrawable(mPackageManager.getApplicationIcon(applicationInfo));
titleView.setText(applicationInfo.loadLabel(mPackageManager));
+ summary1.setText(R.string.certificate_management_app_description);
} catch (PackageManager.NameNotFoundException e) {
appIconView.setImageDrawable(null);
titleView.setText(mCredentialManagerPackageName);
diff --git a/src/com/android/settings/security/RequestManageCredentials.java b/src/com/android/settings/security/RequestManageCredentials.java
index eb7a7d8..cda97da 100644
--- a/src/com/android/settings/security/RequestManageCredentials.java
+++ b/src/com/android/settings/security/RequestManageCredentials.java
@@ -21,7 +21,10 @@
import android.app.admin.DevicePolicyEventLogger;
import android.app.admin.DevicePolicyManager;
import android.content.Context;
+import android.content.pm.ApplicationInfo;
+import android.content.pm.PackageManager;
import android.content.pm.UserInfo;
+import android.content.res.Configuration;
import android.net.Uri;
import android.os.Bundle;
import android.os.Handler;
@@ -37,7 +40,9 @@
import android.util.Log;
import android.view.View;
import android.widget.Button;
+import android.widget.ImageView;
import android.widget.LinearLayout;
+import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.annotation.VisibleForTesting;
@@ -83,6 +88,7 @@
private KeyChain.KeyChainConnection mKeyChainConnection;
private boolean mDisplayingButtonPanel = false;
+ private boolean mIsLandscapeMode = false;
@Override
public void onCreate(@Nullable Bundle savedInstanceState) {
@@ -114,6 +120,8 @@
.setStrings(mCredentialManagerPackage)
.write();
setContentView(R.layout.request_manage_credentials);
+ mIsLandscapeMode = getResources().getConfiguration().orientation
+ == Configuration.ORIENTATION_LANDSCAPE;
mKeyChainTread = new HandlerThread("KeyChainConnection");
mKeyChainTread.start();
@@ -134,6 +142,9 @@
getNumberOfAuthenticationPolicyUris(mAuthenticationPolicy))
.write();
+ if (mIsLandscapeMode) {
+ loadHeader();
+ }
loadRecyclerView();
loadButtons();
loadExtendedFloatingActionButton();
@@ -193,7 +204,7 @@
CredentialManagementAppAdapter recyclerViewAdapter = new CredentialManagementAppAdapter(
this, mCredentialManagerPackage, mAuthenticationPolicy.getAppAndUriMappings(),
- /* include header= */ true, /* include expander= */ false);
+ /* include header= */ !mIsLandscapeMode, /* include expander= */ false);
mRecyclerView.setAdapter(recyclerViewAdapter);
}
@@ -214,12 +225,33 @@
private void loadExtendedFloatingActionButton() {
mExtendedFab = findViewById(R.id.extended_fab);
mExtendedFab.setOnClickListener(v -> {
- mRecyclerView.scrollToPosition(mAuthenticationPolicy.getAppAndUriMappings().size());
+ final int position = mIsLandscapeMode
+ ? mAuthenticationPolicy.getAppAndUriMappings().size() - 1
+ : mAuthenticationPolicy.getAppAndUriMappings().size();
+ mRecyclerView.scrollToPosition(position);
mExtendedFab.hide();
showButtonPanel();
});
}
+ private void loadHeader() {
+ final ImageView mAppIconView = findViewById(R.id.credential_management_app_icon);
+ final TextView mTitleView = findViewById(R.id.credential_management_app_title);
+ try {
+ ApplicationInfo applicationInfo =
+ getPackageManager().getApplicationInfo(mCredentialManagerPackage, 0);
+ mAppIconView.setImageDrawable(getPackageManager().getApplicationIcon(applicationInfo));
+ mTitleView.setText(TextUtils.expandTemplate(
+ getText(R.string.request_manage_credentials_title),
+ applicationInfo.loadLabel(getPackageManager())));
+ } catch (PackageManager.NameNotFoundException e) {
+ mAppIconView.setImageDrawable(null);
+ mTitleView.setText(TextUtils.expandTemplate(
+ getText(R.string.request_manage_credentials_title),
+ mCredentialManagerPackage));
+ }
+ }
+
private void setOrUpdateCredentialManagementAppAndFinish() {
try {
mKeyChainConnection.getService().setCredentialManagementApp(
diff --git a/src/com/android/settings/widget/CardPreference.java b/src/com/android/settings/widget/CardPreference.java
index 20ea710..c041552 100644
--- a/src/com/android/settings/widget/CardPreference.java
+++ b/src/com/android/settings/widget/CardPreference.java
@@ -29,6 +29,7 @@
* Preference that wrapped by {@link MaterialCardView}, only support to set icon, title and summary
*/
public class CardPreference extends Preference {
+
public CardPreference(Context context) {
this(context, null /* attrs */);
}
diff --git a/src/com/android/settings/widget/GearPreference.java b/src/com/android/settings/widget/GearPreference.java
index 0a30100..82bc1f0 100644
--- a/src/com/android/settings/widget/GearPreference.java
+++ b/src/com/android/settings/widget/GearPreference.java
@@ -29,7 +29,8 @@
* A preference with a Gear on the side
*/
public class GearPreference extends RestrictedPreference implements View.OnClickListener {
-
+ // Default true for gear available even if the preference itself is disabled.
+ protected boolean mGearState = true;
private OnGearClickListener mOnGearClickListener;
public GearPreference(Context context, AttributeSet attrs) {
@@ -41,6 +42,16 @@
notifyChanged();
}
+ /** Sets state of gear button. */
+ public void setGearEnabled(boolean enabled) {
+ mGearState = enabled;
+ }
+
+ /** Gets state of gear button. */
+ public boolean isGearEnabled() {
+ return mGearState;
+ }
+
@Override
protected int getSecondTargetResId() {
return R.layout.preference_widget_gear;
@@ -62,7 +73,8 @@
gear.setVisibility(View.GONE);
gear.setOnClickListener(null);
}
- gear.setEnabled(true); // Make gear available even if the preference itself is disabled.
+ // Make gear available even if the preference itself is disabled.
+ gear.setEnabled(mGearState);
}
@Override
diff --git a/src/com/android/settings/widget/MutableGearPreference.java b/src/com/android/settings/widget/MutableGearPreference.java
new file mode 100644
index 0000000..b0804eb
--- /dev/null
+++ b/src/com/android/settings/widget/MutableGearPreference.java
@@ -0,0 +1,57 @@
+/*
+ * Copyright (C) 2021 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.widget;
+
+import android.content.Context;
+import android.util.AttributeSet;
+import android.widget.ImageView;
+
+import androidx.preference.PreferenceViewHolder;
+
+import com.android.settings.R;
+import com.android.settingslib.utils.ColorUtil;
+
+/** A preference with a Gear on the side and mutable Gear color. */
+public class MutableGearPreference extends GearPreference {
+ private static final int VALUE_ENABLED_ALPHA = 255;
+
+ private ImageView mGear;
+ private Context mContext;
+ private int mDisabledAlphaValue;
+
+ public MutableGearPreference(Context context, AttributeSet attrs) {
+ super(context, attrs);
+ mContext = context;
+ mDisabledAlphaValue = (int) (ColorUtil.getDisabledAlpha(context) * VALUE_ENABLED_ALPHA);
+ }
+
+ @Override
+ public void setGearEnabled(boolean enabled) {
+ if (mGear != null) {
+ mGear.setEnabled(enabled);
+ mGear.setImageAlpha(enabled ? VALUE_ENABLED_ALPHA : mDisabledAlphaValue);
+ }
+ mGearState = enabled;
+ }
+
+ @Override
+ public void onBindViewHolder(PreferenceViewHolder holder) {
+ super.onBindViewHolder(holder);
+ mGear = (ImageView) holder.findViewById(R.id.settings_button);
+ setGearEnabled(mGearState);
+ }
+}
diff --git a/tests/robotests/res/layout/main_clear.xml b/tests/robotests/res/layout/main_clear.xml
new file mode 100644
index 0000000..868d88f
--- /dev/null
+++ b/tests/robotests/res/layout/main_clear.xml
@@ -0,0 +1,136 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2021 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.
+-->
+
+<com.google.android.setupdesign.GlifLayout
+ xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:app="http://schemas.android.com/apk/res-auto"
+ android:id="@+id/setup_wizard_layout"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:theme="@style/GlifV3Theme.Footer"
+ android:orientation="vertical"
+ android:icon="@drawable/ic_delete_accent"
+ app:sucHeaderText="@string/main_clear_title">
+
+ <ScrollView
+ android:id="@+id/main_clear_scrollview"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:layout_marginStart="@dimen/reset_main_clear_margin_start"
+ android:layout_marginEnd="@dimen/reset_main_clear_margin_end">
+
+ <LinearLayout
+ android:id="@+id/main_clear_container"
+ style="@style/SudContentFrame"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:orientation="vertical">
+
+ <TextView
+ style="@style/TextAppearance.SudGlifItemSummary"
+ android:id="@+id/sud_layout_description"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:text="@string/main_clear_desc"/>
+ <TextView
+ android:id="@+id/also_erases_external"
+ style="@style/TextAppearance.SudGlifItemSummary"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:visibility="gone"
+ android:text="@string/main_clear_desc_also_erases_external"/>
+ <TextView
+ android:id="@+id/also_erases_esim"
+ style="@style/TextAppearance.SudGlifItemSummary"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:visibility="gone"
+ android:text="@string/main_clear_desc_also_erases_esim"/>
+ <TextView
+ android:id="@+id/accounts_label"
+ style="@style/TextAppearance.SudGlifItemSummary"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:visibility="gone"
+ android:text="@string/main_clear_accounts"/>
+ <LinearLayout
+ android:id="@+id/accounts"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:orientation="vertical"
+ android:visibility="gone">
+ <!-- Do not add any children here as they will be removed in the MainClear.java
+ code. A list of accounts will be inserted programmatically. -->
+ </LinearLayout>
+ <TextView
+ android:id="@+id/other_users_present"
+ style="@style/TextAppearance.SudGlifItemSummary"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:visibility="gone"
+ android:text="@string/main_clear_other_users_present"/>
+ <TextView
+ android:id="@+id/no_cancel_mobile_plan"
+ style="@style/TextAppearance.SudGlifItemSummary"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:visibility="gone"
+ android:text="@string/main_clear_desc_no_cancel_mobile_plan"/>
+ <TextView
+ android:id="@+id/erase_external_option_text"
+ style="@style/TextAppearance.SudGlifItemSummary"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:text="@string/main_clear_desc_erase_external_storage"/>
+ <LinearLayout
+ android:id="@+id/erase_external_container"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:orientation="horizontal"
+ android:focusable="true"
+ android:clickable="true">
+ <CheckBox
+ android:id="@+id/erase_external"
+ style="@style/SudCheckBox"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_gravity="center_vertical"
+ android:focusable="false"
+ android:clickable="false"
+ android:duplicateParentState="true"/>
+ <LinearLayout
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_gravity="center_vertical"
+ android:orientation="vertical">
+ <TextView
+ style="@style/TextAppearance.SudGlifItemTitle"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="@string/erase_external_storage"/>
+ <TextView
+ style="@style/TextAppearance.SudGlifItemSummary"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="@string/erase_external_storage_description"/>
+ </LinearLayout>
+ </LinearLayout>
+
+ <include layout="@layout/reset_esim_checkbox"/>
+
+ </LinearLayout>
+ </ScrollView>
+</com.google.android.setupdesign.GlifLayout>
diff --git a/tests/robotests/res/layout/main_clear_confirm.xml b/tests/robotests/res/layout/main_clear_confirm.xml
new file mode 100644
index 0000000..341e7bb
--- /dev/null
+++ b/tests/robotests/res/layout/main_clear_confirm.xml
@@ -0,0 +1,40 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2021 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.
+-->
+<com.google.android.setupdesign.GlifLayout
+ xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:app="http://schemas.android.com/apk/res-auto"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:theme="@style/SudThemeGlifV3.DayNight"
+ android:orientation="vertical"
+ android:id="@+id/setup_wizard_layout"
+ android:icon="@drawable/ic_delete_accent"
+ app:sucHeaderText="@string/main_clear_confirm_title">
+
+ <LinearLayout
+ style="@style/SudContentFrame"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:orientation="vertical">
+
+ <TextView
+ android:id="@+id/sud_layout_description"
+ style="@style/SudItemTitle.GlifDescription"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="@string/main_clear_final_desc"/>
+ </LinearLayout>
+</com.google.android.setupdesign.GlifLayout>
diff --git a/tests/robotests/src/com/android/settings/accessibility/AnimatedImagePreferenceTest.java b/tests/robotests/src/com/android/settings/accessibility/AnimatedImagePreferenceTest.java
index c3dd7b5..4bce0bb 100644
--- a/tests/robotests/src/com/android/settings/accessibility/AnimatedImagePreferenceTest.java
+++ b/tests/robotests/src/com/android/settings/accessibility/AnimatedImagePreferenceTest.java
@@ -18,13 +18,19 @@
import static com.google.common.truth.Truth.assertThat;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.verify;
+import android.content.ContentResolver;
import android.content.Context;
import android.graphics.drawable.AnimatedImageDrawable;
+import android.graphics.drawable.AnimatedVectorDrawable;
+import android.graphics.drawable.AnimationDrawable;
import android.net.Uri;
import android.view.LayoutInflater;
import android.view.View;
@@ -34,18 +40,22 @@
import com.android.settings.R;
+import com.airbnb.lottie.LottieAnimationView;
+
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
-import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import org.mockito.Spy;
import org.robolectric.RobolectricTestRunner;
import org.robolectric.RuntimeEnvironment;
+import java.io.InputStream;
+
/** Tests for {@link AnimatedImagePreference}. */
@RunWith(RobolectricTestRunner.class)
public class AnimatedImagePreferenceTest {
+ private final Context mContext = RuntimeEnvironment.application;
private Uri mImageUri;
private View mRootView;
private PreferenceViewHolder mViewHolder;
@@ -54,32 +64,53 @@
@Spy
private ImageView mImageView;
- @Mock
- private AnimatedImageDrawable mAnimatedImageDrawable;
-
@Before
public void init() {
MockitoAnnotations.initMocks(this);
- final Context context = RuntimeEnvironment.application;
- final LayoutInflater inflater = LayoutInflater.from(context);
+ final LayoutInflater inflater = LayoutInflater.from(mContext);
mRootView = spy(inflater.inflate(R.layout.preference_animated_image, /* root= */ null));
mViewHolder = spy(PreferenceViewHolder.createInstanceForTests(mRootView));
- mImageView = spy(new ImageView(context));
+ mImageView = spy(new ImageView(mContext));
- mAnimatedImagePreference = new AnimatedImagePreference(context);
+ mAnimatedImagePreference = new AnimatedImagePreference(mContext);
mImageUri = new Uri.Builder().build();
}
@Test
- public void readImageUri_animatedImage_startAnimation() {
+ public void playAnimation_animatedImageDrawable_success() {
+ final AnimatedImageDrawable drawable = mock(AnimatedImageDrawable.class);
doReturn(mImageView).when(mRootView).findViewById(R.id.animated_img);
- doReturn(mAnimatedImageDrawable).when(mImageView).getDrawable();
+ doReturn(drawable).when(mImageView).getDrawable();
mAnimatedImagePreference.setImageUri(mImageUri);
mAnimatedImagePreference.onBindViewHolder(mViewHolder);
- verify(mAnimatedImageDrawable).start();
+ verify(drawable).start();
+ }
+
+ @Test
+ public void playAnimation_animatedVectorDrawable_success() {
+ final AnimatedVectorDrawable drawable = mock(AnimatedVectorDrawable.class);
+ doReturn(mImageView).when(mRootView).findViewById(R.id.animated_img);
+ doReturn(drawable).when(mImageView).getDrawable();
+
+ mAnimatedImagePreference.setImageUri(mImageUri);
+ mAnimatedImagePreference.onBindViewHolder(mViewHolder);
+
+ verify(drawable).start();
+ }
+
+ @Test
+ public void playAnimation_animationDrawable_success() {
+ final AnimationDrawable drawable = mock(AnimationDrawable.class);
+ doReturn(mImageView).when(mRootView).findViewById(R.id.animated_img);
+ doReturn(drawable).when(mImageView).getDrawable();
+
+ mAnimatedImagePreference.setImageUri(mImageUri);
+ mAnimatedImagePreference.onBindViewHolder(mViewHolder);
+
+ verify(drawable).start();
}
@Test
@@ -102,4 +133,22 @@
assertThat(mImageView.getMaxHeight()).isEqualTo(maxHeight);
}
+
+ @Test
+ public void setImageUriAndRebindViewHolder_lottieImageFromRawFolder_setAnimation() {
+ final int fakeLottieResId = 111111;
+ final Uri lottieImageUri =
+ new Uri.Builder().scheme(ContentResolver.SCHEME_ANDROID_RESOURCE)
+ .authority(mContext.getPackageName())
+ .appendPath(String.valueOf(fakeLottieResId))
+ .build();
+ final LottieAnimationView lottieView = spy(new LottieAnimationView(mContext));
+ doReturn(mImageView).when(mRootView).findViewById(R.id.animated_img);
+ doReturn(lottieView).when(mRootView).findViewById(R.id.lottie_view);
+
+ mAnimatedImagePreference.setImageUri(lottieImageUri);
+ mAnimatedImagePreference.onBindViewHolder(mViewHolder);
+
+ verify(lottieView).setAnimation(any(InputStream.class), eq(null));
+ }
}
diff --git a/tests/robotests/src/com/android/settings/applications/specialaccess/interactacrossprofiles/InteractAcrossProfilesDetailsTest.java b/tests/robotests/src/com/android/settings/applications/specialaccess/interactacrossprofiles/InteractAcrossProfilesDetailsTest.java
index c5ea21f..edd85e4 100644
--- a/tests/robotests/src/com/android/settings/applications/specialaccess/interactacrossprofiles/InteractAcrossProfilesDetailsTest.java
+++ b/tests/robotests/src/com/android/settings/applications/specialaccess/interactacrossprofiles/InteractAcrossProfilesDetailsTest.java
@@ -20,11 +20,10 @@
import static org.robolectric.Shadows.shadowOf;
-import android.app.AppOpsManager;
import android.content.Context;
+import android.content.PermissionChecker;
import android.content.pm.CrossProfileApps;
import android.content.pm.PackageManager;
-import android.content.pm.PermissionInfo;
import android.content.pm.UserInfo;
import android.os.UserManager;
@@ -37,19 +36,18 @@
import org.junit.Test;
import org.junit.runner.RunWith;
import org.robolectric.RobolectricTestRunner;
+import org.robolectric.shadows.ShadowPermissionChecker;
@RunWith(RobolectricTestRunner.class)
public class InteractAcrossProfilesDetailsTest {
private static final int PERSONAL_PROFILE_ID = 0;
private static final int WORK_PROFILE_ID = 10;
- private static final int PACKAGE_UID = 0;
private static final String CROSS_PROFILE_PACKAGE_NAME = "crossProfilePackage";
public static final String INTERACT_ACROSS_PROFILES_PERMISSION =
"android.permission.INTERACT_ACROSS_PROFILES";
private final Context mContext = ApplicationProvider.getApplicationContext();
- private final AppOpsManager mAppOpsManager = mContext.getSystemService(AppOpsManager.class);
private final PackageManager mPackageManager = mContext.getPackageManager();
private final UserManager mUserManager = mContext.getSystemService(UserManager.class);
private final CrossProfileApps mCrossProfileApps = mContext.getSystemService(
@@ -68,10 +66,10 @@
WORK_PROFILE_ID, ImmutableList.of(CROSS_PROFILE_PACKAGE_NAME));
shadowOf(mCrossProfileApps).addCrossProfilePackage(
CROSS_PROFILE_PACKAGE_NAME);
- String appOp = AppOpsManager.permissionToOp(INTERACT_ACROSS_PROFILES_PERMISSION);
- shadowOf(mAppOpsManager).setMode(
- appOp, PACKAGE_UID, CROSS_PROFILE_PACKAGE_NAME, AppOpsManager.MODE_ALLOWED);
- shadowOf(mPackageManager).addPermissionInfo(createCrossProfilesPermissionInfo());
+ ShadowPermissionChecker.setResult(
+ CROSS_PROFILE_PACKAGE_NAME,
+ INTERACT_ACROSS_PROFILES_PERMISSION,
+ PermissionChecker.PERMISSION_GRANTED);
assertThat(InteractAcrossProfilesDetails.getPreferenceSummary(
mContext, CROSS_PROFILE_PACKAGE_NAME))
@@ -91,11 +89,10 @@
WORK_PROFILE_ID, ImmutableList.of(CROSS_PROFILE_PACKAGE_NAME));
shadowOf(mCrossProfileApps).addCrossProfilePackage(
CROSS_PROFILE_PACKAGE_NAME);
- String appOp = AppOpsManager.permissionToOp(INTERACT_ACROSS_PROFILES_PERMISSION);
- shadowOf(mAppOpsManager).setMode(
- appOp, PACKAGE_UID, CROSS_PROFILE_PACKAGE_NAME, AppOpsManager.MODE_IGNORED);
- shadowOf(mPackageManager).addPermissionInfo(createCrossProfilesPermissionInfo());
-
+ ShadowPermissionChecker.setResult(
+ CROSS_PROFILE_PACKAGE_NAME,
+ INTERACT_ACROSS_PROFILES_PERMISSION,
+ PermissionChecker.PERMISSION_SOFT_DENIED);
assertThat(InteractAcrossProfilesDetails.getPreferenceSummary(
mContext, CROSS_PROFILE_PACKAGE_NAME))
.isEqualTo(mContext.getString(
@@ -114,11 +111,4 @@
.isEqualTo(mContext.getString(
R.string.interact_across_profiles_summary_not_allowed));
}
-
- private PermissionInfo createCrossProfilesPermissionInfo() {
- PermissionInfo permissionInfo = new PermissionInfo();
- permissionInfo.name = INTERACT_ACROSS_PROFILES_PERMISSION;
- permissionInfo.protectionLevel = PermissionInfo.PROTECTION_FLAG_APPOP;
- return permissionInfo;
- }
}
diff --git a/tests/robotests/src/com/android/settings/applications/specialaccess/interactacrossprofiles/InteractAcrossProfilesSettingsTest.java b/tests/robotests/src/com/android/settings/applications/specialaccess/interactacrossprofiles/InteractAcrossProfilesSettingsTest.java
index bbbcd82..029fb28 100644
--- a/tests/robotests/src/com/android/settings/applications/specialaccess/interactacrossprofiles/InteractAcrossProfilesSettingsTest.java
+++ b/tests/robotests/src/com/android/settings/applications/specialaccess/interactacrossprofiles/InteractAcrossProfilesSettingsTest.java
@@ -21,7 +21,6 @@
import static org.junit.Assert.assertTrue;
import static org.robolectric.Shadows.shadowOf;
-import android.app.AppOpsManager;
import android.content.Context;
import android.content.PermissionChecker;
import android.content.pm.ApplicationInfo;
@@ -51,7 +50,6 @@
private static final int PERSONAL_PROFILE_ID = 0;
private static final int WORK_PROFILE_ID = 10;
private static final int WORK_UID = UserHandle.PER_USER_RANGE * WORK_PROFILE_ID;
- private static final int PACKAGE_UID = 0;
private static final String PERSONAL_CROSS_PROFILE_PACKAGE = "personalCrossProfilePackage";
private static final String PERSONAL_NON_CROSS_PROFILE_PACKAGE =
@@ -71,7 +69,6 @@
private final UserManager mUserManager = mContext.getSystemService(UserManager.class);
private final CrossProfileApps mCrossProfileApps =
mContext.getSystemService(CrossProfileApps.class);
- private final AppOpsManager mAppOpsManager = mContext.getSystemService(AppOpsManager.class);
@Test
public void collectConfigurableApps_fromPersonal_returnsCombinedPackages() {
@@ -84,8 +81,8 @@
PERSONAL_PROFILE_ID, PERSONAL_PROFILE_INSTALLED_PACKAGES);
shadowOf(mPackageManager).setInstalledPackagesForUserId(
WORK_PROFILE_ID, WORK_PROFILE_INSTALLED_PACKAGES);
- installCrossProfilePackage(PERSONAL_PROFILE_ID, PERSONAL_CROSS_PROFILE_PACKAGE);
- installCrossProfilePackage(WORK_PROFILE_ID, WORK_CROSS_PROFILE_PACKAGE);
+ installCrossProfilePackage(PERSONAL_CROSS_PROFILE_PACKAGE);
+ installCrossProfilePackage(WORK_CROSS_PROFILE_PACKAGE);
List<Pair<ApplicationInfo, UserHandle>> apps =
InteractAcrossProfilesSettings.collectConfigurableApps(
@@ -110,8 +107,8 @@
PERSONAL_PROFILE_ID, PERSONAL_PROFILE_INSTALLED_PACKAGES);
shadowOf(mPackageManager).setInstalledPackagesForUserId(
WORK_PROFILE_ID, WORK_PROFILE_INSTALLED_PACKAGES);
- installCrossProfilePackage(PERSONAL_PROFILE_ID, PERSONAL_CROSS_PROFILE_PACKAGE);
- installCrossProfilePackage(WORK_PROFILE_ID, WORK_CROSS_PROFILE_PACKAGE);
+ installCrossProfilePackage(PERSONAL_CROSS_PROFILE_PACKAGE);
+ installCrossProfilePackage(WORK_CROSS_PROFILE_PACKAGE);
List<Pair<ApplicationInfo, UserHandle>> apps =
InteractAcrossProfilesSettings.collectConfigurableApps(
@@ -130,7 +127,7 @@
PERSONAL_PROFILE_ID, "personal-profile"/* name */, 0/* flags */);
shadowOf(mPackageManager).setInstalledPackagesForUserId(
PERSONAL_PROFILE_ID, PERSONAL_PROFILE_INSTALLED_PACKAGES);
- installCrossProfilePackage(PERSONAL_PROFILE_ID, PERSONAL_CROSS_PROFILE_PACKAGE);
+ installCrossProfilePackage(PERSONAL_CROSS_PROFILE_PACKAGE);
List<Pair<ApplicationInfo, UserHandle>> apps =
InteractAcrossProfilesSettings.collectConfigurableApps(
@@ -150,10 +147,9 @@
PERSONAL_PROFILE_ID, PERSONAL_PROFILE_INSTALLED_PACKAGES);
shadowOf(mPackageManager).setInstalledPackagesForUserId(
WORK_PROFILE_ID, WORK_PROFILE_INSTALLED_PACKAGES);
- installCrossProfilePackage(PERSONAL_PROFILE_ID, PERSONAL_CROSS_PROFILE_PACKAGE);
- installCrossProfilePackage(WORK_PROFILE_ID, WORK_CROSS_PROFILE_PACKAGE);
+ installCrossProfilePackage(PERSONAL_CROSS_PROFILE_PACKAGE);
+ installCrossProfilePackage(WORK_CROSS_PROFILE_PACKAGE);
shadowOf(mCrossProfileApps).addCrossProfilePackage(PERSONAL_CROSS_PROFILE_PACKAGE);
- String appOp = AppOpsManager.permissionToOp(INTERACT_ACROSS_PROFILES_PERMISSION);
ShadowPermissionChecker.setResult(
PERSONAL_CROSS_PROFILE_PACKAGE,
INTERACT_ACROSS_PROFILES_PERMISSION,
@@ -169,7 +165,7 @@
assertThat(numOfApps).isEqualTo(1);
}
- private void installCrossProfilePackage(int profileId, String packageName) {
+ private void installCrossProfilePackage(String packageName) {
PackageInfo personalPackageInfo = shadowOf(mPackageManager).getInternalMutablePackageInfo(
packageName);
personalPackageInfo.requestedPermissions = new String[]{
diff --git a/tests/robotests/src/com/android/settings/display/SmartAutoRotatePreferenceControllerTest.java b/tests/robotests/src/com/android/settings/display/SmartAutoRotatePreferenceControllerTest.java
index cc3b20d..068de34 100644
--- a/tests/robotests/src/com/android/settings/display/SmartAutoRotatePreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/display/SmartAutoRotatePreferenceControllerTest.java
@@ -20,46 +20,65 @@
import static com.google.common.truth.Truth.assertThat;
+import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyInt;
import static org.mockito.ArgumentMatchers.anyString;
+import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.when;
+import android.Manifest;
import android.content.ContentResolver;
import android.content.Context;
import android.content.pm.PackageManager;
+import android.content.pm.ResolveInfo;
+import android.content.pm.ServiceInfo;
+import android.content.res.Resources;
import android.os.UserHandle;
import android.provider.Settings;
import com.android.settings.R;
import com.android.settings.core.BasePreferenceController;
import com.android.settings.testutils.FakeFeatureFactory;
+import com.android.settings.testutils.ResolveInfoBuilder;
+import com.android.settings.testutils.shadow.ShadowSensorPrivacyManager;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
-import org.mockito.Answers;
import org.mockito.Mock;
+import org.mockito.Mockito;
import org.mockito.MockitoAnnotations;
import org.robolectric.RobolectricTestRunner;
import org.robolectric.RuntimeEnvironment;
+import org.robolectric.annotation.Config;
@RunWith(RobolectricTestRunner.class)
+@Config(shadows = ShadowSensorPrivacyManager.class)
public class SmartAutoRotatePreferenceControllerTest {
- @Mock(answer = Answers.RETURNS_DEEP_STUBS)
- private Context mContext;
+ private static final String PACKAGE_NAME = "package_name";
@Mock
private PackageManager mPackageManager;
+ @Mock
+ private Resources mResources;
+ private Context mContext;
private ContentResolver mContentResolver;
private SmartAutoRotatePreferenceController mController;
@Before
public void setUp() {
MockitoAnnotations.initMocks(this);
+ mContext = Mockito.spy(RuntimeEnvironment.application);
FakeFeatureFactory.setupForTest();
mContentResolver = RuntimeEnvironment.application.getContentResolver();
+
when(mContext.getPackageManager()).thenReturn(mPackageManager);
+ when(mContext.getResources()).thenReturn(mResources);
when(mContext.getContentResolver()).thenReturn(mContentResolver);
+
+ doReturn(PACKAGE_NAME).when(mPackageManager).getRotationResolverPackageName();
+ doReturn(PackageManager.PERMISSION_GRANTED).when(mPackageManager).checkPermission(
+ Manifest.permission.CAMERA, PACKAGE_NAME);
when(mContext.getString(R.string.auto_rotate_option_off))
.thenReturn("Off");
when(mContext.getString(R.string.auto_rotate_option_on))
@@ -68,8 +87,14 @@
.thenReturn("On - Face-based");
disableCameraBasedRotation();
+ final ResolveInfo resolveInfo = new ResolveInfoBuilder(PACKAGE_NAME).build();
+ resolveInfo.serviceInfo = new ServiceInfo();
+ when(mPackageManager.resolveService(any(), anyInt())).thenReturn(resolveInfo);
- mController = new SmartAutoRotatePreferenceController(mContext, "smart_auto_rotate");
+ mController = Mockito.spy(
+ new SmartAutoRotatePreferenceController(mContext, "smart_auto_rotate"));
+ when(mController.isCameraLocked()).thenReturn(false);
+ when(mController.isPowerSaveMode()).thenReturn(false);
}
@Test
@@ -82,33 +107,37 @@
}
@Test
- public void updatePreference_settingsIsOff_shouldTurnOffToggle() {
+ public void getSummary_settingsIsOff_returnsOff() {
disableAutoRotation();
assertThat(mController.getSummary()).isEqualTo("Off");
}
@Test
- public void updatePreference_settingsIsOn_shouldTurnOnToggle() {
+ public void getSummary_settingsIsOn_returnsOn() {
enableAutoRotation();
assertThat(mController.getSummary()).isEqualTo("On");
}
@Test
- public void updatePreference_settingsIsCameraBased_shouldTurnOnToggle() {
+ public void getSummary_autoRotateOffSmartAutoRotateOn_returnsOff() {
+ enableCameraBasedRotation();
+ disableAutoRotation();
+
+ assertThat(mController.getSummary()).isEqualTo("Off");
+ }
+
+ @Test
+ public void updatePreference_smartAutoRotateOn_returnsFaceBased() {
enableCameraBasedRotation();
enableAutoRotation();
assertThat(mController.getSummary()).isEqualTo("On - Face-based");
-
- disableAutoRotation();
-
- assertThat(mController.getSummary()).isEqualTo("Off");
}
@Test
- public void updatePreference_settingsIsOff_noSmartAuto_shouldTurnOffToggle() {
+ public void getSummary_noSmartAuto_returnsOff() {
disableAutoRotation();
Settings.Secure.putStringForUser(mContentResolver,
CAMERA_AUTOROTATE, null, UserHandle.USER_CURRENT);
@@ -118,7 +147,7 @@
}
@Test
- public void updatePreference_settingsIsOn_noSmartAuto_shouldTurnOnToggle() {
+ public void getSummary_noSmartAuto_returnsOn() {
enableAutoRotation();
Settings.Secure.putStringForUser(mContentResolver,
CAMERA_AUTOROTATE, null, UserHandle.USER_CURRENT);
@@ -127,6 +156,34 @@
}
@Test
+ public void getSummary_noCameraPermission_returnsOn() {
+ enableAutoRotation();
+ enableCameraBasedRotation();
+ doReturn(PackageManager.PERMISSION_DENIED).when(mPackageManager).checkPermission(
+ Manifest.permission.CAMERA, PACKAGE_NAME);
+
+ assertThat(mController.getSummary()).isEqualTo("On");
+ }
+
+ @Test
+ public void getSummary_cameraDisabled_returnsOn() {
+ enableAutoRotation();
+ enableCameraBasedRotation();
+ when(mController.isCameraLocked()).thenReturn(true);
+
+ assertThat(mController.getSummary()).isEqualTo("On");
+ }
+
+ @Test
+ public void getSummary_powerSaveEnabled_returnsOn() {
+ enableAutoRotation();
+ enableCameraBasedRotation();
+ when(mController.isPowerSaveMode()).thenReturn(true);
+
+ assertThat(mController.getSummary()).isEqualTo("On");
+ }
+
+ @Test
public void testGetAvailabilityStatus() {
assertThat(mController.getAvailabilityStatus()).isEqualTo(BasePreferenceController
.UNSUPPORTED_ON_DEVICE);
@@ -158,14 +215,14 @@
private void enableAutoRotationPreference() {
when(mPackageManager.hasSystemFeature(anyString())).thenReturn(true);
- when(mContext.getResources().getBoolean(anyInt())).thenReturn(true);
+ when(mResources.getBoolean(anyInt())).thenReturn(true);
Settings.System.putInt(mContentResolver,
Settings.System.HIDE_ROTATION_LOCK_TOGGLE_FOR_ACCESSIBILITY, 0);
}
private void disableAutoRotationPreference() {
when(mPackageManager.hasSystemFeature(anyString())).thenReturn(true);
- when(mContext.getResources().getBoolean(anyInt())).thenReturn(true);
+ when(mResources.getBoolean(anyInt())).thenReturn(true);
Settings.System.putInt(mContentResolver,
Settings.System.HIDE_ROTATION_LOCK_TOGGLE_FOR_ACCESSIBILITY, 1);
}
diff --git a/tests/robotests/src/com/android/settings/fuelgauge/BatteryChartPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/fuelgauge/BatteryChartPreferenceControllerTest.java
index 7894c3f..ef76eee 100644
--- a/tests/robotests/src/com/android/settings/fuelgauge/BatteryChartPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/fuelgauge/BatteryChartPreferenceControllerTest.java
@@ -35,6 +35,7 @@
import android.content.res.Resources;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
+import android.os.LocaleList;
import android.text.format.DateUtils;
import android.util.Pair;
@@ -100,6 +101,8 @@
mFeatureFactory = FakeFeatureFactory.setupForTest();
mMetricsFeatureProvider = mFeatureFactory.metricsFeatureProvider;
mContext = spy(RuntimeEnvironment.application);
+ mContext.getResources().getConfiguration().setLocales(
+ new LocaleList(new Locale("en_US")));
mBatteryChartPreferenceController = createController();
mBatteryChartPreferenceController.mPrefContext = mContext;
mBatteryChartPreferenceController.mAppListPrefGroup = mAppListGroup;
@@ -573,14 +576,12 @@
// Verifies the title in the preference group.
verify(mBatteryChartPreferenceController.mAppListPrefGroup)
.setTitle(captor.capture());
- assertThat(captor.getValue())
- .isEqualTo("App usage for 4 pm - 7 am");
+ assertThat(captor.getValue()).isEqualTo("App usage for 4 - 7");
// Verifies the title in the expandable divider.
captor = ArgumentCaptor.forClass(String.class);
verify(mBatteryChartPreferenceController.mExpandDividerPreference)
.setTitle(captor.capture());
- assertThat(captor.getValue())
- .isEqualTo("System usage for 4 pm - 7 am");
+ assertThat(captor.getValue()).isEqualTo("System usage for 4 - 7");
}
@Test
@@ -716,7 +717,8 @@
private void setUpBatteryHistoryKeys() {
mBatteryChartPreferenceController.mBatteryHistoryKeys =
new long[] {1619196786769L, 0L, 1619247636826L};
- ConvertUtils.utcToLocalTimeHour(/*timestamp=*/ 0, /*is24HourFormat=*/ false);
+ ConvertUtils.utcToLocalTimeHour(
+ mContext, /*timestamp=*/ 0, /*is24HourFormat=*/ false);
// Simulates the locale in GMT.
ConvertUtils.sSimpleDateFormatForHour
.setTimeZone(TimeZone.getTimeZone("GMT"));
diff --git a/tests/robotests/src/com/android/settings/fuelgauge/BatteryChartViewTest.java b/tests/robotests/src/com/android/settings/fuelgauge/BatteryChartViewTest.java
index 3f94456..ec77f4c 100644
--- a/tests/robotests/src/com/android/settings/fuelgauge/BatteryChartViewTest.java
+++ b/tests/robotests/src/com/android/settings/fuelgauge/BatteryChartViewTest.java
@@ -27,6 +27,7 @@
import android.accessibilityservice.AccessibilityServiceInfo;
import android.content.Context;
+import android.os.LocaleList;
import android.view.accessibility.AccessibilityManager;
import com.android.settings.testutils.FakeFeatureFactory;
@@ -41,6 +42,7 @@
import java.util.Arrays;
import java.util.ArrayList;
+import java.util.Locale;
import java.util.TimeZone;
@RunWith(RobolectricTestRunner.class)
@@ -60,6 +62,8 @@
mFeatureFactory = FakeFeatureFactory.setupForTest();
mPowerUsageFeatureProvider = mFeatureFactory.powerUsageFeatureProvider;
mContext = spy(RuntimeEnvironment.application);
+ mContext.getResources().getConfiguration().setLocales(
+ new LocaleList(new Locale("en_US")));
mBatteryChartView = new BatteryChartView(mContext);
doReturn(mockAccessibilityManager).when(mContext)
.getSystemService(AccessibilityManager.class);
@@ -234,11 +238,11 @@
final long timestamp = 1619196786769L;
ConvertUtils.sSimpleDateFormatForHour = null;
// Invokes the method first to create the SimpleDateFormat.
- ConvertUtils.utcToLocalTimeHour(/*timestamp=*/ 0, /*is24HourFormat=*/ false);
+ ConvertUtils.utcToLocalTimeHour(
+ mContext, /*timestamp=*/ 0, /*is24HourFormat=*/ false);
ConvertUtils.sSimpleDateFormatForHour
.setTimeZone(TimeZone.getTimeZone("America/Los_Angeles"));
- final String[] expectedTimestamps =
- new String[] {"9 am", "5 pm", "1 am", "9 am"};
+ final String[] expectedTimestamps = new String[] {"00", "06", "12", "18", "00"};
mBatteryChartView.setLatestTimestamp(timestamp);
diff --git a/tests/robotests/src/com/android/settings/fuelgauge/BatteryEntryTest.java b/tests/robotests/src/com/android/settings/fuelgauge/BatteryEntryTest.java
index e0f8ba7..96f0ec7 100644
--- a/tests/robotests/src/com/android/settings/fuelgauge/BatteryEntryTest.java
+++ b/tests/robotests/src/com/android/settings/fuelgauge/BatteryEntryTest.java
@@ -93,7 +93,7 @@
when(consumer.getUid()).thenReturn(APP_UID);
when(consumer.getPackageWithHighestDrain()).thenReturn(highDrainPackage);
return new BatteryEntry(mMockContext, mockHandler, mockUserManager,
- consumer, false, packages, packageName);
+ consumer, false, APP_UID, packages, packageName);
}
private BatteryEntry createAggregateBatteryEntry(int powerComponentId) {
@@ -108,7 +108,7 @@
UserBatteryConsumer consumer = mock(UserBatteryConsumer.class);
when(consumer.getUserId()).thenReturn(userId);
return new BatteryEntry(mMockContext, mockHandler, mockUserManager,
- consumer, false, null, null);
+ consumer, false, 0, null, null);
}
@Test
@@ -169,12 +169,12 @@
@Test
public void getTimeInForegroundMs_app() {
- final BatteryEntry entry = new BatteryEntry(RuntimeEnvironment.application, mockHandler,
- mockUserManager, mUidBatteryConsumer, false, null, null);
-
when(mUidBatteryConsumer.getTimeInStateMs(UidBatteryConsumer.STATE_FOREGROUND))
.thenReturn(100L);
+ final BatteryEntry entry = new BatteryEntry(RuntimeEnvironment.application, mockHandler,
+ mockUserManager, mUidBatteryConsumer, false, 0, null, null);
+
assertThat(entry.getTimeInForegroundMs()).isEqualTo(100L);
}
@@ -188,12 +188,12 @@
@Test
public void getTimeInBackgroundMs_app() {
- final BatteryEntry entry = new BatteryEntry(RuntimeEnvironment.application, mockHandler,
- mockUserManager, mUidBatteryConsumer, false, null, null);
-
when(mUidBatteryConsumer.getTimeInStateMs(UidBatteryConsumer.STATE_BACKGROUND))
.thenReturn(100L);
+ final BatteryEntry entry = new BatteryEntry(RuntimeEnvironment.application, mockHandler,
+ mockUserManager, mUidBatteryConsumer, false, 0, null, null);
+
assertThat(entry.getTimeInBackgroundMs()).isEqualTo(100L);
}
diff --git a/tests/robotests/src/com/android/settings/fuelgauge/ConvertUtilsTest.java b/tests/robotests/src/com/android/settings/fuelgauge/ConvertUtilsTest.java
index efabe44..0b1a1e3 100644
--- a/tests/robotests/src/com/android/settings/fuelgauge/ConvertUtilsTest.java
+++ b/tests/robotests/src/com/android/settings/fuelgauge/ConvertUtilsTest.java
@@ -24,11 +24,13 @@
import android.content.Context;
import android.os.BatteryManager;
import android.os.BatteryUsageStats;
+import android.os.LocaleList;
import android.os.UserHandle;
import com.android.settings.testutils.FakeFeatureFactory;
import org.junit.Before;
+import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
@@ -315,6 +317,8 @@
.isEqualTo(entry.mConsumePower * ratio);
}
+ @Ignore
+ @Test
public void testUtcToLocalTime_returnExpectedResult() {
ConvertUtils.sZoneId = null;
ConvertUtils.sLocale = null;
@@ -322,48 +326,78 @@
final String expectedZoneId = "America/Los_Angeles";
ConvertUtils.sSimpleDateFormat = null;
// Invokes the method first to create the SimpleDateFormat.
- ConvertUtils.utcToLocalTime(/*timestamp=*/ 0);
+ ConvertUtils.utcToLocalTime(mContext, /*timestamp=*/ 0);
ConvertUtils.sSimpleDateFormat
.setTimeZone(TimeZone.getTimeZone(expectedZoneId));
+ mContext.getResources().getConfiguration().setLocales(
+ new LocaleList(new Locale("en_US")));
- assertThat(ConvertUtils.utcToLocalTime(timestamp))
- .isEqualTo("Apr 23,2021 09:53:06");
+ assertThat(ConvertUtils.utcToLocalTime(mContext, timestamp))
+ .isEqualTo("Apr 24,2021 00:53:06");
assertThat(ConvertUtils.sZoneId).isNotEqualTo(expectedZoneId);
- assertThat(ConvertUtils.sLocale).isEqualTo(Locale.getDefault());
+ assertThat(ConvertUtils.sLocale).isEqualTo(new Locale("en_US"));
}
+ @Ignore
+ @Test
public void testUtcToLocalTimeHour_12HourFormat_returnExpectedResult() {
ConvertUtils.sZoneIdForHour = null;
ConvertUtils.sLocaleForHour = null;
- final long timestamp = 1619196786769L;
+ final long timestamp = 1619000086769L;
final String expectedZoneId = "America/Los_Angeles";
ConvertUtils.sSimpleDateFormatForHour = null;
// Invokes the method first to create the SimpleDateFormat.
- ConvertUtils.utcToLocalTimeHour(/*timestamp=*/ 0, /*is24HourFormat=*/ false);
+ ConvertUtils.utcToLocalTimeHour(
+ mContext, /*timestamp=*/ 0, /*is24HourFormat=*/ false);
ConvertUtils.sSimpleDateFormatForHour
.setTimeZone(TimeZone.getTimeZone(expectedZoneId));
+ mContext.getResources().getConfiguration().setLocales(
+ new LocaleList(new Locale("en_US")));
assertThat(ConvertUtils.utcToLocalTimeHour(
- timestamp, /*is24HourFormat=*/ false)).isEqualTo("9 am");
+ mContext, timestamp, /*is24HourFormat=*/ false)).isEqualTo("6");
assertThat(ConvertUtils.sZoneIdForHour).isNotEqualTo(expectedZoneId);
- assertThat(ConvertUtils.sLocaleForHour).isEqualTo(Locale.getDefault());
+ assertThat(ConvertUtils.sLocaleForHour).isEqualTo(new Locale("en_US"));
}
+ @Ignore
+ @Test
public void testUtcToLocalTimeHour_24HourFormat_returnExpectedResult() {
ConvertUtils.sZoneIdForHour = null;
ConvertUtils.sLocaleForHour = null;
- final long timestamp = 1619196786769L;
+ final long timestamp = 1619000086769L;
final String expectedZoneId = "America/Los_Angeles";
ConvertUtils.sSimpleDateFormatForHour = null;
// Invokes the method first to create the SimpleDateFormat.
- ConvertUtils.utcToLocalTimeHour(/*timestamp=*/ 0, /*is24HourFormat=*/ true);
+ ConvertUtils.utcToLocalTimeHour(
+ mContext, /*timestamp=*/ 0, /*is24HourFormat=*/ false);
ConvertUtils.sSimpleDateFormatForHour
.setTimeZone(TimeZone.getTimeZone(expectedZoneId));
+ mContext.getResources().getConfiguration().setLocales(
+ new LocaleList(new Locale("en_US")));
assertThat(ConvertUtils.utcToLocalTimeHour(
- timestamp, /*is24HourFormat=*/ true)).isEqualTo("09");
+ mContext, timestamp, /*is24HourFormat=*/ true)).isEqualTo("18");
assertThat(ConvertUtils.sZoneIdForHour).isNotEqualTo(expectedZoneId);
- assertThat(ConvertUtils.sLocaleForHour).isEqualTo(Locale.getDefault());
+ assertThat(ConvertUtils.sLocaleForHour).isEqualTo(new Locale("en_US"));
+ }
+
+ @Test
+ public void getLocale_nullContext_returnDefaultLocale() {
+ assertThat(ConvertUtils.getLocale(/*context=*/ null))
+ .isEqualTo(Locale.getDefault());
+ }
+
+ @Test
+ public void getLocale_nullLocaleList_returnDefaultLocale() {
+ mContext.getResources().getConfiguration().setLocales(null);
+ assertThat(ConvertUtils.getLocale(mContext)).isEqualTo(Locale.getDefault());
+ }
+
+ @Test
+ public void getLocale_emptyLocaleList_returnDefaultLocale() {
+ mContext.getResources().getConfiguration().setLocales(new LocaleList());
+ assertThat(ConvertUtils.getLocale(mContext)).isEqualTo(Locale.getDefault());
}
private static BatteryHistEntry createBatteryHistEntry(
diff --git a/tests/robotests/src/com/android/settings/location/LocationInjectedServicesPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/location/LocationInjectedServicesPreferenceControllerTest.java
index 0370781..1a7a63c 100644
--- a/tests/robotests/src/com/android/settings/location/LocationInjectedServicesPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/location/LocationInjectedServicesPreferenceControllerTest.java
@@ -67,8 +67,6 @@
@Mock
private PreferenceCategory mCategoryPrimary;
@Mock
- private PreferenceCategory mCategoryManaged;
- @Mock
private PreferenceScreen mScreen;
@Mock
private AppSettingsInjector mSettingsInjector;
@@ -115,31 +113,6 @@
}
@Test
- public void updateState_shouldRemoveAllAndAddInjectedSettings() {
- final List<Preference> preferences = new ArrayList<>();
- final Map<Integer, List<Preference>> map = new ArrayMap<>();
- final Preference pref1 = new Preference(mContext);
- pref1.setTitle("Title1");
- final Preference pref2 = new Preference(mContext);
- pref2.setTitle("Title2");
- preferences.add(pref1);
- preferences.add(pref2);
- map.put(UserHandle.myUserId(), preferences);
- doReturn(map)
- .when(mSettingsInjector).getInjectedSettings(any(Context.class), anyInt());
- when(mFragment.getPreferenceManager().getContext()).thenReturn(mContext);
- ShadowUserManager.getShadow().setProfileIdsWithDisabled(new int[]{UserHandle.myUserId()});
-
- mController.displayPreference(mScreen);
-
- mController.updateState(mCategoryPrimary);
-
- verify(mCategoryPrimary).removeAll();
- verify(mCategoryPrimary).addPreference(pref1);
- verify(mCategoryPrimary).addPreference(pref2);
- }
-
- @Test
public void workProfileDisallowShareLocationOn_getParentUserLocationServicesOnly() {
final int fakeWorkProfileId = 123;
ShadowUserManager.getShadow().setProfileIdsWithDisabled(
@@ -158,7 +131,6 @@
when(mDevicePolicyManager.getDeviceOwnerComponentOnAnyUser()).thenReturn(componentName);
mController.displayPreference(mScreen);
- mController.updateState(mCategoryPrimary);
verify(mSettingsInjector).getInjectedSettings(
any(Context.class), eq(UserHandle.myUserId()));
}
@@ -178,7 +150,6 @@
enforcingUsers);
mController.displayPreference(mScreen);
- mController.updateState(mCategoryPrimary);
verify(mSettingsInjector).getInjectedSettings(
any(Context.class), eq(UserHandle.USER_CURRENT));
}
@@ -216,7 +187,6 @@
when(mDevicePolicyManager.getDeviceOwnerComponentOnAnyUser()).thenReturn(componentName);
mController.displayPreference(mScreen);
- mController.updateState(mCategoryPrimary);
assertThat(pref.isEnabled()).isFalse();
assertThat(pref.isDisabledByAdmin()).isTrue();
diff --git a/tests/robotests/src/com/android/settings/notification/app/RecentConversationsPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/notification/app/RecentConversationsPreferenceControllerTest.java
index 15bc598..f0ae7ab 100644
--- a/tests/robotests/src/com/android/settings/notification/app/RecentConversationsPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/notification/app/RecentConversationsPreferenceControllerTest.java
@@ -160,9 +160,9 @@
true);
assertThat(mController.getSummary(ccw).toString()).contains(
- ccw.getParentNotificationChannelGroup().getName());
+ ccw.getNotificationChannelGroup().getName());
assertThat(mController.getSummary(ccw).toString()).contains(
- ccw.getParentNotificationChannel().getName());
+ ccw.getNotificationChannel().getName());
}
@Test
@@ -175,7 +175,7 @@
true);
assertThat(mController.getSummary(ccw).toString()).isEqualTo(
- ccw.getParentNotificationChannel().getName());
+ ccw.getNotificationChannel().getName());
}
@Test
@@ -207,7 +207,7 @@
ccw.getShortcutInfo().getPackage());
assertThat(extras.getInt(AppInfoBase.ARG_PACKAGE_UID)).isEqualTo(ccw.getUid());
assertThat(extras.getString(Settings.EXTRA_CHANNEL_ID)).isEqualTo(
- ccw.getParentNotificationChannel().getId());
+ ccw.getNotificationChannel().getId());
assertThat(extras.getString(Settings.EXTRA_CONVERSATION_ID)).isEqualTo(
ccw.getShortcutInfo().getId());
}
@@ -230,7 +230,7 @@
// expected since it tries to launch an activity
}
verify(mBackend).createConversationNotificationChannel(
- si.getPackage(), ccw.getUid(), ccw.getParentNotificationChannel(), si.getId());
+ si.getPackage(), ccw.getUid(), ccw.getNotificationChannel(), si.getId());
}
@Test
diff --git a/tests/robotests/src/com/android/settings/widget/CardPreferenceTest.java b/tests/robotests/src/com/android/settings/widget/CardPreferenceTest.java
index 6d4a6bb..85ab609 100644
--- a/tests/robotests/src/com/android/settings/widget/CardPreferenceTest.java
+++ b/tests/robotests/src/com/android/settings/widget/CardPreferenceTest.java
@@ -45,5 +45,4 @@
public void getLayoutResource() {
assertThat(mCardPreference.getLayoutResource()).isEqualTo(R.layout.card_preference_layout);
}
-
}
diff --git a/tests/unit/src/com/android/settings/network/ProviderModelSliceTest.java b/tests/unit/src/com/android/settings/network/ProviderModelSliceTest.java
index fb17e34..a96e7cf 100644
--- a/tests/unit/src/com/android/settings/network/ProviderModelSliceTest.java
+++ b/tests/unit/src/com/android/settings/network/ProviderModelSliceTest.java
@@ -144,6 +144,16 @@
@Test
@UiThreadTest
+ public void getBroadcastIntent_shouldHaveFlagReceiverForeground() {
+ final PendingIntent pendingIntent = mMockProviderModelSlice.getBroadcastIntent(mContext);
+
+ final int flags = pendingIntent.getIntent().getFlags();
+ assertThat(flags & Intent.FLAG_RECEIVER_FOREGROUND)
+ .isEqualTo(Intent.FLAG_RECEIVER_FOREGROUND);
+ }
+
+ @Test
+ @UiThreadTest
public void getSlice_noWifiAndHasCarrierNoData_oneCarrier() {
mWifiList.clear();
mMockNetworkProviderWorker.updateSelfResults(null);
diff --git a/tests/unit/src/com/android/settings/network/SubscriptionsPreferenceControllerTest.java b/tests/unit/src/com/android/settings/network/SubscriptionsPreferenceControllerTest.java
index 0ef44ee..fc18ce7 100644
--- a/tests/unit/src/com/android/settings/network/SubscriptionsPreferenceControllerTest.java
+++ b/tests/unit/src/com/android/settings/network/SubscriptionsPreferenceControllerTest.java
@@ -40,6 +40,7 @@
import android.net.Network;
import android.net.NetworkCapabilities;
import android.os.Looper;
+import android.os.UserManager;
import android.provider.Settings;
import android.telephony.ServiceState;
import android.telephony.SignalStrength;
@@ -82,6 +83,8 @@
private static final String KEY = "preference_group";
@Mock
+ private UserManager mUserManager;
+ @Mock
private SubscriptionManager mSubscriptionManager;
@Mock
private ConnectivityManager mConnectivityManager;
@@ -121,10 +124,12 @@
when(mContext.getSystemService(SubscriptionManager.class)).thenReturn(mSubscriptionManager);
when(mContext.getSystemService(ConnectivityManager.class)).thenReturn(mConnectivityManager);
when(mContext.getSystemService(TelephonyManager.class)).thenReturn(mTelephonyManager);
+ when(mContext.getSystemService(UserManager.class)).thenReturn(mUserManager);
when(mTelephonyManager.createForSubscriptionId(anyInt())).thenReturn(mTelephonyManager);
when(mConnectivityManager.getActiveNetwork()).thenReturn(mActiveNetwork);
when(mConnectivityManager.getNetworkCapabilities(mActiveNetwork))
.thenReturn(mNetworkCapabilities);
+ when(mUserManager.isAdminUser()).thenReturn(true);
when(mLifecycleOwner.getLifecycle()).thenReturn(mLifecycleRegistry);
mPreferenceManager = new PreferenceManager(mContext);
diff --git a/tests/unit/src/com/android/settings/widget/GearPreferenceTest.java b/tests/unit/src/com/android/settings/widget/GearPreferenceTest.java
new file mode 100644
index 0000000..a47eade
--- /dev/null
+++ b/tests/unit/src/com/android/settings/widget/GearPreferenceTest.java
@@ -0,0 +1,84 @@
+/*
+ * Copyright (C) 2021 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.widget;
+
+import static com.google.common.truth.Truth.assertThat;
+
+import static org.mockito.Mockito.spy;
+import static org.mockito.Mockito.when;
+
+import android.content.Context;
+import android.view.LayoutInflater;
+import android.view.View;
+
+import androidx.preference.PreferenceViewHolder;
+import androidx.test.core.app.ApplicationProvider;
+import androidx.test.ext.junit.runners.AndroidJUnit4;
+
+import com.android.settings.testutils.ResourcesUtils;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+
+/** Unittest for GearPreference */
+@RunWith(AndroidJUnit4.class)
+public class GearPreferenceTest {
+ @Mock
+ private GearPreference.OnGearClickListener mOnGearClickListener;
+
+ private Context mContext = ApplicationProvider.getApplicationContext();
+ private GearPreference mGearPreference;
+ private PreferenceViewHolder mViewHolder;
+ private View mGearView;
+
+ @Before
+ public void setUp() {
+ MockitoAnnotations.initMocks(this);
+ mGearPreference =
+ new GearPreference(mContext, null);
+ int layoutId = ResourcesUtils.getResourcesId(mContext, "layout", "preference_widget_gear");
+ PreferenceViewHolder holder =
+ PreferenceViewHolder.createInstanceForTests(
+ LayoutInflater.from(ApplicationProvider.getApplicationContext())
+ .inflate(layoutId, null));
+ mViewHolder = spy(holder);
+ mGearView = new View(mContext, null);
+ int gearId = ResourcesUtils.getResourcesId(mContext, "id", "settings_button");
+ when(mViewHolder.findViewById(gearId)).thenReturn(mGearView);
+ }
+
+ @Test
+ public void onBindViewHolder_gearIsVisible() {
+ mGearPreference.setOnGearClickListener(mOnGearClickListener);
+
+ mGearPreference.onBindViewHolder(mViewHolder);
+
+ assertThat(mGearView.getVisibility()).isEqualTo(View.VISIBLE);
+ }
+
+ @Test
+ public void onBindViewHolder_gearIsGone() {
+ mGearPreference.setOnGearClickListener(null);
+
+ mGearPreference.onBindViewHolder(mViewHolder);
+
+ assertThat(mGearView.getVisibility()).isEqualTo(View.GONE);
+ }
+}
diff --git a/tests/unit/src/com/android/settings/widget/MutableGearPreferenceTest.java b/tests/unit/src/com/android/settings/widget/MutableGearPreferenceTest.java
new file mode 100644
index 0000000..44b1d38
--- /dev/null
+++ b/tests/unit/src/com/android/settings/widget/MutableGearPreferenceTest.java
@@ -0,0 +1,84 @@
+/*
+ * Copyright (C) 2021 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.widget;
+
+import static org.mockito.ArgumentMatchers.anyInt;
+import static org.mockito.Mockito.spy;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
+import android.content.Context;
+import android.util.TypedValue;
+import android.view.LayoutInflater;
+import android.widget.ImageView;
+
+import androidx.preference.PreferenceViewHolder;
+import androidx.test.core.app.ApplicationProvider;
+import androidx.test.ext.junit.runners.AndroidJUnit4;
+
+import com.android.settings.testutils.ResourcesUtils;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+
+/** Unittest for MutableGearPreference */
+@RunWith(AndroidJUnit4.class)
+public class MutableGearPreferenceTest {
+ @Mock
+ private MutableGearPreference.OnGearClickListener mOnGearClickListener;
+
+ private Context mContext = ApplicationProvider.getApplicationContext();
+ private MutableGearPreference mMutableGearPreference;
+ private PreferenceViewHolder mViewHolder;
+ private ImageView mGearView;
+
+ @Before
+ public void setUp() {
+ MockitoAnnotations.initMocks(this);
+ mMutableGearPreference =
+ new MutableGearPreference(mContext, null);
+ int layoutId =
+ ResourcesUtils.getResourcesId(mContext, "layout", "preference_widget_gear");
+ PreferenceViewHolder holder =
+ PreferenceViewHolder.createInstanceForTests(
+ LayoutInflater.from(ApplicationProvider.getApplicationContext())
+ .inflate(layoutId, null));
+ mViewHolder = spy(holder);
+ mGearView = spy(new ImageView(mContext, null));
+ int gearId = ResourcesUtils.getResourcesId(mContext, "id", "settings_button");
+ when(mViewHolder.findViewById(gearId)).thenReturn(mGearView);
+ }
+
+ @Test
+ public void onBindViewHolder_gearChangeAlpha() {
+ mMutableGearPreference.setGearEnabled(false);
+ mMutableGearPreference.setOnGearClickListener(mOnGearClickListener);
+
+ mMutableGearPreference.onBindViewHolder(mViewHolder);
+
+ verify(mGearView).setImageAlpha(anyInt());
+ }
+
+ private static int getDisabledAlphaValue(Context context) {
+ TypedValue value = new TypedValue();
+ context.getTheme().resolveAttribute(android.R.attr.disabledAlpha, value, true);
+ return (int) (value.getFloat() * 255);
+ }
+}