Snap for 7246408 from 91b4a58111 to sc-release
Change-Id: I3a50cd1dc7605b1cf59e27fc9ebf0e953a56b98e
This commit is contained in:
27
res/drawable/circle.xml
Normal file
27
res/drawable/circle.xml
Normal file
@@ -0,0 +1,27 @@
|
||||
<?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.
|
||||
-->
|
||||
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportWidth="24"
|
||||
android:viewportHeight="24">
|
||||
|
||||
<path
|
||||
android:fillColor="#FFFFFF"
|
||||
android:pathData="M 12 0 C 18.627416998 0 24 5.37258300203 24 12 C 24 18.627416998 18.627416998 24 12 24 C 5.37258300203 24 0 18.627416998 0 12 C 0 5.37258300203 5.37258300203 0 12 0 Z" />
|
||||
</vector>
|
||||
121
res/drawable/ic_files_go_round.xml
Normal file
121
res/drawable/ic_files_go_round.xml
Normal file
@@ -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.
|
||||
-->
|
||||
<vector
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:aapt="http://schemas.android.com/aapt"
|
||||
android:width="32dp"
|
||||
android:height="32dp"
|
||||
android:viewportWidth="192"
|
||||
android:viewportHeight="192">
|
||||
<path
|
||||
android:pathData="M96,96m-88,0a88,88 0,1 1,176 0a88,88 0,1 1,-176 0"
|
||||
android:fillColor="#FFFFFF"/>
|
||||
<path
|
||||
android:pathData="M96,183c-48.43,0 -87.72,-39.13 -87.99,-87.5C8.01,95.67 8,95.83 8,96c0,48.6 39.4,88 88,88s88,-39.4 88,-88c0,-0.17 -0.01,-0.33 -0.01,-0.5C183.72,143.87 144.43,183 96,183z"
|
||||
android:fillColor="#263238"
|
||||
android:fillAlpha="0.2"/>
|
||||
<path
|
||||
android:pathData="M96,9c48.43,0 87.72,39.13 87.99,87.5c0,-0.17 0.01,-0.33 0.01,-0.5c0,-48.6 -39.4,-88 -88,-88S8,47.4 8,96c0,0.17 0.01,0.33 0.01,0.5C8.28,48.13 47.57,9 96,9z"
|
||||
android:fillColor="#FFFFFF"
|
||||
android:fillAlpha="0.2"/>
|
||||
<path
|
||||
android:pathData="M85.09,59.18H44.18c-4.52,0 -8.18,3.66 -8.18,8.18v40.91v2.05v-0.35c0,-1.08 0.43,-2.13 1.2,-2.89L85.09,59.18z"
|
||||
android:fillColor="#0F9D58"/>
|
||||
<path
|
||||
android:pathData="M85.09,59.18H44.18c-4.52,0 -8.18,3.66 -8.18,8.18v40.91v2.05v-0.35c0,-1.08 0.43,-2.13 1.2,-2.89L85.09,59.18z">
|
||||
<aapt:attr name="android:fillColor">
|
||||
<gradient
|
||||
android:startY="110.3181"
|
||||
android:startX="60.5458"
|
||||
android:endY="59.182"
|
||||
android:endX="60.5458"
|
||||
android:type="linear">
|
||||
<item android:offset="0" android:color="#33263238"/>
|
||||
<item android:offset="1" android:color="#00263238"/>
|
||||
</gradient>
|
||||
</aapt:attr>
|
||||
</path>
|
||||
<path
|
||||
android:pathData="M37.2,106.39c-0.77,0.77 -1.2,1.81 -1.2,2.89v0.35v0.33c0,-1.08 0.43,-2.13 1.2,-2.89l47.89,-47.89h-0.68L37.2,106.39z"
|
||||
android:fillColor="#263238"
|
||||
android:fillAlpha="0.2"/>
|
||||
<path
|
||||
android:pathData="M44.18,59.86h39.55l0.68,-0.68H44.18c-4.52,0 -8.18,3.66 -8.18,8.18v0.68C36,63.53 39.66,59.86 44.18,59.86z"
|
||||
android:fillColor="#FFFFFF"
|
||||
android:fillAlpha="0.2"/>
|
||||
<path
|
||||
android:pathData="M147.82,143.73H44.18c-4.52,0 -8.18,-3.66 -8.18,-8.18v-25.58c0,-1.08 0.43,-2.13 1.2,-2.89l57.6,-57.6c0.77,-0.77 1.81,-1.2 2.89,-1.2h50.12c4.52,0 8.18,3.66 8.18,8.18v79.09C156,140.06 152.34,143.73 147.82,143.73z"
|
||||
android:fillColor="#4285F4"/>
|
||||
<path
|
||||
android:pathData="M156,135.55l0,-29.32L98.05,48.27l-0.31,0c-1.11,0 -2.17,0.45 -2.94,1.25L37.2,107.07c-0.77,0.77 -1.2,1.81 -1.2,2.89v0.35l33.41,33.41l78.41,0C152.34,143.73 156,140.06 156,135.55z">
|
||||
<aapt:attr name="android:fillColor">
|
||||
<gradient
|
||||
android:startY="78.2732"
|
||||
android:startX="66.0008"
|
||||
android:endY="153.6034"
|
||||
android:endX="141.331"
|
||||
android:type="linear">
|
||||
<item android:offset="0" android:color="#281A237E"/>
|
||||
<item android:offset="1" android:color="#051A237E"/>
|
||||
</gradient>
|
||||
</aapt:attr>
|
||||
</path>
|
||||
<path
|
||||
android:pathData="M147.82,143.05H44.18c-4.52,0 -8.18,-3.66 -8.18,-8.18v0.68c0,4.52 3.66,8.18 8.18,8.18h103.64c4.52,0 8.18,-3.66 8.18,-8.18v-0.68C156,139.38 152.34,143.05 147.82,143.05z"
|
||||
android:fillColor="#1A237E"
|
||||
android:fillAlpha="0.2"/>
|
||||
<path
|
||||
android:pathData="M147.82,48.27H98.05c-0.6,0 -1.14,0.27 -1.51,0.68h51.29c4.52,0 8.18,3.66 8.18,8.18v-0.68C156,51.94 152.34,48.27 147.82,48.27z"
|
||||
android:fillColor="#FFFFFF"
|
||||
android:fillAlpha="0.2"/>
|
||||
<path
|
||||
android:pathData="M94.8,49.47l-57.6,57.6c-0.77,0.77 -1.2,1.81 -1.2,2.89v0.35v0c0,-1.13 0.92,-2.05 2.05,-2.05h49.77c4.52,0 8.18,-3.66 8.18,-8.18l0,-49.77c0,-1.13 0.92,-2.05 2.05,-2.05l0,0l-0.35,0C96.61,48.27 95.57,48.7 94.8,49.47z"
|
||||
android:fillColor="#DB4437"/>
|
||||
<path
|
||||
android:pathData="M97.69,48.27c-0.27,0 -0.54,0.03 -0.8,0.08C97.15,48.3 97.42,48.27 97.69,48.27l0.35,0c-1.34,0 -2.55,0.72 -3.21,1.85c0.43,-0.42 0.95,-0.73 1.5,-0.93c0.37,-0.55 0.99,-0.92 1.7,-0.92L97.69,48.27z"
|
||||
android:strokeAlpha="0.2"
|
||||
android:fillColor="#3E2723"
|
||||
android:fillAlpha="0.2"/>
|
||||
<path
|
||||
android:pathData="M96,99.41c0,4.52 -3.66,8.18 -8.18,8.18H38.05c-0.85,0 -1.57,0.51 -1.88,1.25c-0.1,0.36 -0.16,0.74 -0.16,1.13v0.35c0,-1.13 0.92,-2.05 2.05,-2.05h49.77c4.52,0 8.18,-3.66 8.18,-8.18"
|
||||
android:fillColor="#3E2723"
|
||||
android:fillAlpha="0.2"/>
|
||||
<path
|
||||
android:pathData="M36,110.32L36,110.32c0,-1.62 1.05,-3.06 2.6,-3.55L74.95,95.2c3.79,-1.21 6.77,-4.18 7.97,-7.97l11.57,-36.35c0.49,-1.55 1.93,-2.6 3.55,-2.6l0,0h-0.35c-1.08,0 -2.13,0.43 -2.89,1.2l-57.6,57.6c-0.77,0.77 -1.2,1.81 -1.2,2.89L36,110.32z"
|
||||
android:fillColor="#F4B400"/>
|
||||
<path
|
||||
android:pathData="M94.84,49.44c-0.14,0.24 -0.26,0.48 -0.35,0.75L82.92,86.54c-1.21,3.79 -4.18,6.77 -7.97,7.97L38.6,106.08c-0.27,0.09 -0.52,0.21 -0.76,0.35l-0.64,0.64c-0.77,0.77 -1.2,1.81 -1.2,2.89l0,0.35c0,-1.62 1.05,-3.06 2.6,-3.55L74.95,95.2c3.79,-1.21 6.77,-4.18 7.97,-7.97l11.57,-36.35c0.49,-1.55 1.93,-2.6 3.55,-2.6h-0.35C96.63,48.27 95.6,48.69 94.84,49.44z"
|
||||
android:fillColor="#BF360C"
|
||||
android:fillAlpha="0.3"/>
|
||||
<path
|
||||
android:pathData="M39,105.95l55.36,-55.36l0.13,-0.4c0.09,-0.27 0.21,-0.52 0.35,-0.75c-0.01,0.01 -0.03,0.02 -0.04,0.03l-56.96,56.96c0.24,-0.14 0.49,-0.27 0.76,-0.35L39,105.95z"
|
||||
android:strokeAlpha="0.2"
|
||||
android:fillColor="#FFFFFF"
|
||||
android:fillAlpha="0.2"/>
|
||||
<path
|
||||
android:pathData="M36,109.97v25.58c0,4.52 3.66,8.18 8.18,8.18h103.64c4.52,0 8.18,-3.66 8.18,-8.18V56.45c0,-4.52 -3.66,-8.18 -8.18,-8.18H97.69c-1.08,0 -2.13,0.43 -2.89,1.2l-9.71,9.71H44.18c-4.52,0 -8.18,3.66 -8.18,8.18v40.91L36,109.97">
|
||||
<aapt:attr name="android:fillColor">
|
||||
<gradient
|
||||
android:gradientRadius="115.3882"
|
||||
android:centerX="72.364"
|
||||
android:centerY="59.4093"
|
||||
android:type="radial">
|
||||
<item android:offset="0.0029046" android:color="#19FFFFFF"/>
|
||||
<item android:offset="1" android:color="#00FFFFFF"/>
|
||||
</gradient>
|
||||
</aapt:attr>
|
||||
</path>
|
||||
</vector>
|
||||
@@ -48,13 +48,13 @@
|
||||
android:src="@drawable/ic_enterprise" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/headerText"
|
||||
android:id="@+id/suc_layout_title"
|
||||
style="@style/SudGlifHeaderTitle"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/sud_layout_description"
|
||||
android:id="@+id/sud_layout_subtitle"
|
||||
style="@style/SudDescription.Glif"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
|
||||
@@ -48,14 +48,14 @@
|
||||
android:src="@drawable/ic_lock" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/headerText"
|
||||
android:id="@+id/suc_layout_title"
|
||||
style="@style/SudGlifHeaderTitle"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content" />
|
||||
|
||||
<TextView
|
||||
style="@style/SudDescription.Glif"
|
||||
android:id="@+id/sud_layout_description"
|
||||
android:id="@+id/sud_layout_subtitle"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="?attr/sudMarginStart"
|
||||
|
||||
@@ -26,7 +26,8 @@
|
||||
android:layout_width="24dp"
|
||||
android:layout_height="24dp"/>
|
||||
|
||||
<LinearLayout
|
||||
<RelativeLayout
|
||||
android:id="@+id/app_details"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_toRightOf="@id/app_icon"
|
||||
@@ -44,16 +45,18 @@
|
||||
<TextView
|
||||
android:id="@+id/number_of_uris"
|
||||
style="@style/AppAuthenticationPolicyNumberOfUrisText"
|
||||
android:layout_below="@id/app_name"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:visibility="gone"/>
|
||||
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/uris"
|
||||
android:layout_below="@id/app_name"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"/>
|
||||
|
||||
</LinearLayout>
|
||||
</RelativeLayout>
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/expand"
|
||||
|
||||
@@ -42,13 +42,13 @@
|
||||
android:src="@drawable/ic_enterprise" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/headerText"
|
||||
android:id="@+id/suc_layout_title"
|
||||
style="@style/SudGlifHeaderTitle"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/sud_layout_description"
|
||||
android:id="@+id/sud_layout_subtitle"
|
||||
style="@style/SudDescription.Glif"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
|
||||
@@ -41,14 +41,14 @@
|
||||
android:src="@drawable/ic_lock" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/headerText"
|
||||
android:id="@+id/suc_layout_title"
|
||||
style="@style/SudGlifHeaderTitle"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content" />
|
||||
|
||||
<TextView
|
||||
style="@style/SudDescription.Glif"
|
||||
android:id="@+id/sud_layout_description"
|
||||
android:id="@+id/sud_layout_subtitle"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="?attr/sudMarginStart"
|
||||
|
||||
@@ -26,35 +26,32 @@
|
||||
android:layout_width="match_parent"
|
||||
android:background="@drawable/button_ripple_radius"
|
||||
android:paddingTop="12dp"
|
||||
android:orientation="horizontal"
|
||||
android:paddingBottom="12dp"
|
||||
android:paddingStart="16dp">
|
||||
<ImageView
|
||||
android:id="@+id/icon"
|
||||
android:layout_height="24dp"
|
||||
android:layout_width="24dp"
|
||||
android:layout_marginTop="12dp"
|
||||
android:layout_gravity="center_vertical|start"
|
||||
android:scaleType="centerInside"/>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingStart="32dp"
|
||||
android:orientation="vertical">
|
||||
<LinearLayout
|
||||
android:layout_width="wrap_content"
|
||||
<TextView
|
||||
android:id="@+id/label"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal">
|
||||
<ImageView
|
||||
android:id="@+id/icon"
|
||||
android:layout_height="24dp"
|
||||
android:layout_width="24dp"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:scaleType="centerInside"/>
|
||||
<TextView
|
||||
android:id="@+id/label"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:textAppearance="@*android:style/TextAppearance.DeviceDefault.Notification"
|
||||
android:paddingStart="8dp" />
|
||||
</LinearLayout>
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:textAppearance="@*android:style/TextAppearance.DeviceDefault.Notification"/>
|
||||
<TextView
|
||||
android:id="@+id/count"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_width="wrap_content"
|
||||
android:paddingStart="6dp"
|
||||
android:layout_gravity="start|center_vertical"
|
||||
android:textDirection="locale"
|
||||
android:paddingTop="8dp"
|
||||
|
||||
@@ -37,6 +37,7 @@
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_centerVertical="true"
|
||||
android:layout_marginStart="32dp"
|
||||
android:ellipsize="end"
|
||||
android:singleLine="true"
|
||||
android:textAppearance="@style/TextAppearance.NotificationHistory.Title"
|
||||
@@ -76,6 +77,7 @@
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="left|center_vertical"
|
||||
android:ellipsize="end"
|
||||
android:layout_marginStart="32dp"
|
||||
android:maxLines="3"
|
||||
android:paddingTop="3dp"
|
||||
android:textAppearance="@style/TextAppearance.NotificationHistory.Text"
|
||||
|
||||
@@ -37,15 +37,14 @@
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/icon"
|
||||
android:layout_height="@*android:dimen/status_bar_icon_size"
|
||||
android:layout_width="@*android:dimen/status_bar_icon_size"
|
||||
android:layout_height="24dp"
|
||||
android:layout_width="24dp"
|
||||
android:layout_centerVertical="true"
|
||||
android:layout_marginStart="0dp"
|
||||
android:layout_marginEnd="8dp"
|
||||
android:padding="4dp"
|
||||
android:contentDescription="@null"
|
||||
android:adjustViewBounds="true"
|
||||
android:tint="?android:attr/textColorPrimary"
|
||||
android:scaleType="fitCenter" />
|
||||
android:scaleType="centerInside" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/pkgname"
|
||||
@@ -98,6 +97,7 @@
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="32dp"
|
||||
android:orientation="vertical"
|
||||
android:layout_marginBottom="6dp"
|
||||
>
|
||||
|
||||
@@ -522,4 +522,7 @@
|
||||
|
||||
<!-- Media Uri to view documents & other storage category. -->
|
||||
<string name="config_documents_and_other_storage_category_uri" translatable="false">content://com.android.providers.media.documents/root/documents_root</string>
|
||||
|
||||
<!-- Whether to show Smart Storage toggle -->
|
||||
<bool name="config_show_smart_storage_toggle">true</bool>
|
||||
</resources>
|
||||
|
||||
@@ -933,6 +933,43 @@
|
||||
<string name="setup_fingerprint_enroll_skip_title">Skip fingerprint?</string>
|
||||
<!-- Body text of dialog shown when the user tries to skip setting up fingerprint after adding lock screen during initial setup [CHAR LIMIT=NONE] -->
|
||||
<string name="setup_fingerprint_enroll_skip_after_adding_lock_text">Fingerprint setup only takes a minute or two. If you skip this, you can add your fingerprint later in settings.</string>
|
||||
<!-- Title of dialog shown when the user tries to skip setting up a screen lock, warning them of potential consequences of not doing so [CHAR LIMIT=30]-->
|
||||
|
||||
<!-- Introduction detail message shown in fingerprint enrollment introduction screen in setup wizard. [CHAR LIMIT=NONE]-->
|
||||
<string name="security_settings_fingerprint_v2_enroll_introduction_message_setup">When you see this icon, use your fingerprint for authentication, like when you sign in to apps or approve a purchase</string>
|
||||
<!-- Introduction subtitle message shown in fingerprint enrollment introduction screen in setup wizard. [CHAR LIMIT=NONE]-->
|
||||
<string name="security_settings_fingerprint_v2_enroll_introduction_footer_title_1">Keep in mind</string>
|
||||
<!-- Introduction description message shown in fingerprint enrollment introduction screen in setup wizard. [CHAR LIMIT=NONE]-->
|
||||
<string name="security_settings_fingerprint_v2_enroll_introduction_footer_message_1">Using your fingerprint to unlock your phone may be less secure than a strong pattern or PIN</string>
|
||||
<!-- Introduction subtitle message shown in fingerprint enrollment introduction screen in setup wizard. [CHAR LIMIT=NONE]-->
|
||||
<string name="security_settings_fingerprint_v2_enroll_introduction_footer_title_2">How it works</string>
|
||||
<!-- Introduction description message shown in fingerprint enrollment introduction screen in setup wizard. [CHAR LIMIT=NONE]-->
|
||||
<string name="security_settings_fingerprint_v2_enroll_introduction_footer_message_2">Fingerprint Unlock creates a unique model of your fingerprint to recognize you during authentication. To create this fingerprint model during setup, you will take images of your fingerprint from different positions.</string>
|
||||
<!-- Introduction description message shown in fingerprint enrollment introduction screen in setup wizard. [CHAR LIMIT=NONE]-->
|
||||
<string name="security_settings_fingerprint_v2_enroll_introduction_footer_message_3">The phone will also use images from your interactions with Fingerprint Unlock to update your fingerprint model. Your fingerprint images and model are stored securely on your phone and never leave the phone. All processing occurs securely on your phone.</string>
|
||||
<!-- Introduction description message shown in fingerprint enrollment introduction screen in setup wizard. [CHAR LIMIT=NONE]-->
|
||||
<string name="security_settings_fingerprint_v2_enroll_introduction_footer_message_4">You can delete your fingerprint images and model, or turn off Fingerprint Unlock at any time in Settings. Fingerprint images and models are stored on the phone until you delete them.</string>
|
||||
<!-- Introduction detail message shown in fingerprint enrollment introduction to learn more about fingerprint [CHAR LIMIT=NONE]-->
|
||||
<string name="security_settings_fingerprint_v2_enroll_introduction_message_learn_more"></string>
|
||||
|
||||
<!-- Acquire message received during fingerprint enrollment to inform the user to change the position of their finger. [CHAR LIMIT=NONE]-->
|
||||
<string name="security_settings_fingerprint_v2_enroll_acquire_try_adjusting">Change the position of your finger slightly each time</string>
|
||||
<!-- Acquire message received during fingerprint enrollment to inform the user to cover the fingerprint sensor. [CHAR LIMIT=NONE]-->
|
||||
<string name="security_settings_fingerprint_v2_enroll_acquire_partially_detected">Cover the icon with the center of your fingerprint</string>
|
||||
<!-- Acquire message received during fingerprint enrollment to inform the user this fingerprint has already been added. [CHAR LIMIT=NONE]-->
|
||||
<string name="security_settings_fingerprint_v2_enroll_acquire_already_enrolled">This fingerprint has already been added</string>
|
||||
<!-- Acquire message received during fingerprint enrollment to inform the user to clean the screen near the fingerprint sensor. [CHAR LIMIT=NONE]-->
|
||||
<string name="security_settings_fingerprint_v2_enroll_acquire_clean_sensor">Clean your screen near the sensor and try again</string>
|
||||
<!-- Acquire message received during fingerprint enrollment to inform the user to lift their finger. [CHAR LIMIT=NONE]-->
|
||||
<string name="security_settings_fingerprint_v2_enroll_acquire_too_fast">Lift your finger after you feel a vibration</string>
|
||||
<!-- Acquire message received during fingerprint enrollment to inform the user to try better lighting. [CHAR LIMIT=NONE]-->
|
||||
<string name="security_settings_fingerprint_v2_enroll_acquire_too_bright">Move somewhere with gentler lighting and try again</string>
|
||||
<!-- Acquire message received during fingerprint enrollment to inform the user they've reached the maximum number of enrollments. [CHAR LIMIT=NONE]-->
|
||||
<string name="security_settings_fingerprint_v2_enroll_error_max_attempts">You\u2019ve reached the maximum number of attempts</string>
|
||||
|
||||
<!-- Message shown in fingerprint security settings home screen. [CHAR LIMIT=NONE]-->
|
||||
<string name="security_settings_fingerprint_v2_home_screen">Use your fingerprint to unlock your phone or for authentication, like when you sign in to apps or approve a purchase</string>
|
||||
|
||||
<!-- Title of dialog shown when the user tries to skip setting up a screen lock, warning them of potential consequences of not doing so [CHAR LIMIT=30]-->
|
||||
<string name="lock_screen_intro_skip_title">Skip screen lock?</string>
|
||||
<!-- Dialog text shown when the user tries to skip setting up a screen lock, warning them of potential consequences of not doing so, including loss of factory reset protection. (tablet) [CHAR LIMIT=NONE] -->
|
||||
@@ -1067,6 +1104,9 @@
|
||||
<!-- Message shown in a dialog which asks the user to confirm when a single fingerprint gets deleted. [CHAR LIMIT=NONE]-->
|
||||
<string name="fingerprint_delete_message">Do you want to delete this fingerprint?</string>
|
||||
|
||||
<!-- Message shown in a dialog which asks the user to confirm when a single fingerprint gets deleted. [CHAR LIMIT=NONE]-->
|
||||
<string name="fingerprint_v2_delete_message">This deletes the fingerprint images and model associated with \'<xliff:g id="fingerprint_id" example="Fingerprint 2">%1$s</xliff:g>\' that are stored on your device</string>
|
||||
|
||||
<!-- Message shown in a dialog which asks the user to confirm when the last fingerprint gets deleted by him. [CHAR LIMIT=NONE]-->
|
||||
<string name="fingerprint_last_delete_message">You won\'t be able to use your fingerprints to
|
||||
unlock your phone, authorize purchases, or sign in to apps with them</string>
|
||||
@@ -1728,7 +1768,7 @@
|
||||
<!-- Bluetooth settings. Text displayed when Bluetooth is off and device list is empty [CHAR LIMIT=50]-->
|
||||
<string name="bluetooth_empty_list_bluetooth_off">When Bluetooth is turned on, your device can communicate with other nearby Bluetooth devices.</string>
|
||||
<!-- Bluetooth settings. Text displayed when Bluetooth is off and bluetooth scanning is turned on [CHAR LIMIT=NONE] -->
|
||||
<string name="bluetooth_scanning_on_info_message">When Bluetooth is turned on, your device can communicate with other nearby Bluetooth devices.\n\nTo improve device experience, apps and services can still scan for nearby devices at any time, even when Bluetooth is off. This can be used, for example, to improve location-based features and services. you can change this in <annotation id="link">scanning settings</annotation>.</string>
|
||||
<string name="bluetooth_scanning_on_info_message">When Bluetooth is turned on, your device can communicate with other nearby Bluetooth devices.\n\nTo improve device experience, apps and services can still scan for nearby devices at any time, even when Bluetooth is off. This can be used, for example, to improve location-based features and services. you can change this in <annotation id="link">Bluetooth scanning settings</annotation>.</string>
|
||||
<!-- Message to describe "BLE scan always available feature" when Bluetooth is off. The
|
||||
place-holders "LINK_BEGIN" and "LINK_END" must NOT be translated. They mark a link to bring
|
||||
the user to "scanning settings" screen. -->
|
||||
@@ -1981,13 +2021,13 @@
|
||||
<!-- Message to describe "Wi-Fi scan always available feature" when Wi-Fi is off and Wi-Fi
|
||||
scanning is on. The place-holders "LINK_BEGIN" and "LINK_END" must NOT be translated. They
|
||||
mark a link to bring the user to "scanning settings" screen. -->
|
||||
<string name="wifi_scan_notify_text">To improve location accuracy, apps and services can still scan for Wi\u2011Fi networks at any time, even when Wi\u2011Fi is off. This can be used, for example, to improve location-based features and services. You can change this in <xliff:g id="link_begin">LINK_BEGIN</xliff:g>scanning settings<xliff:g id="link_end">LINK_END</xliff:g>.</string>
|
||||
<string name="wifi_scan_notify_text">To improve location accuracy, apps and services can still scan for Wi\u2011Fi networks at any time, even when Wi\u2011Fi is off. This can be used, for example, to improve location-based features and services. You can change this in <xliff:g id="link_begin">LINK_BEGIN</xliff:g>Wi\u2011Fi scanning settings<xliff:g id="link_end">LINK_END</xliff:g>.</string>
|
||||
<!-- Message to describe "Wi-Fi scan always available feature" when Wi-Fi is off and Wi-Fi
|
||||
scanning is also off. The place-holders "LINK_BEGIN" and "LINK_END" must NOT be translated.
|
||||
They mark a link to bring the user to "scanning settings" screen. -->
|
||||
<string name="wifi_scan_notify_text_scanning_off">To improve location accuracy,
|
||||
turn on Wi-Fi scanning in
|
||||
<xliff:g id="link_begin">LINK_BEGIN</xliff:g>scanning
|
||||
<xliff:g id="link_begin">LINK_BEGIN</xliff:g>Wi\u2011Fi scanning
|
||||
settings<xliff:g id="link_end">LINK_END</xliff:g>.</string>
|
||||
<!-- Wifi scan always mode checkbox text -->
|
||||
<string name="wifi_scan_notify_remember_choice">Don\u2019t show again</string>
|
||||
|
||||
@@ -38,7 +38,17 @@
|
||||
<PreferenceCategory
|
||||
android:key="location_advanced_settings"
|
||||
android:layout="@layout/preference_category_no_label"
|
||||
settings:initialExpandedChildrenCount="2">
|
||||
settings:initialExpandedChildrenCount="3">
|
||||
|
||||
<!-- This preference gets removed if there is no managed profile -->
|
||||
<com.android.settingslib.RestrictedSwitchPreference
|
||||
android:enabled="false"
|
||||
android:key="managed_profile_location_switch"
|
||||
android:selectable="true"
|
||||
android:title="@string/managed_profile_location_switch_title"
|
||||
settings:controller="com.android.settings.location.LocationForWorkPreferenceController"
|
||||
settings:forWork="true"
|
||||
settings:useAdminDisabledSummary="true"/>
|
||||
|
||||
<!-- This preference category gets removed if new_recent_location_ui is disabled -->
|
||||
<Preference
|
||||
@@ -57,23 +67,6 @@
|
||||
android:title="@string/location_services_screen_title"
|
||||
settings:controller="com.android.settings.location.LocationServicesPreferenceController"/>
|
||||
|
||||
<!-- This preference gets removed if there is no managed profile -->
|
||||
<com.android.settingslib.RestrictedSwitchPreference
|
||||
android:enabled="false"
|
||||
android:key="managed_profile_location_switch"
|
||||
android:selectable="true"
|
||||
android:title="@string/managed_profile_location_switch_title"
|
||||
settings:controller="com.android.settings.location.LocationForWorkPreferenceController"
|
||||
settings:forWork="true"
|
||||
settings:useAdminDisabledSummary="true"/>
|
||||
|
||||
<!-- This preference gets removed if there is no managed profile -->
|
||||
<PreferenceCategory
|
||||
android:key="location_services_managed_profile"
|
||||
android:title="@string/managed_profile_location_services"
|
||||
settings:forWork="true"
|
||||
settings:controller="com.android.settings.location.LocationInjectedServicesForWorkPreferenceController"/>
|
||||
|
||||
</PreferenceCategory>
|
||||
|
||||
<com.android.settingslib.widget.FooterPreference
|
||||
|
||||
@@ -22,11 +22,6 @@
|
||||
android:title="@string/smart_battery_manager_title"
|
||||
settings:searchable="false">
|
||||
|
||||
<com.android.settingslib.widget.MainSwitchPreference
|
||||
android:key="smart_battery"
|
||||
android:title="@string/adaptive_battery_main_switch_title"
|
||||
settings:controller="com.android.settings.fuelgauge.SmartBatteryPreferenceController"/>
|
||||
|
||||
<com.android.settings.widget.VideoPreference
|
||||
android:key="auto_awesome_battery"
|
||||
android:title="@string/summary_placeholder"
|
||||
@@ -34,6 +29,13 @@
|
||||
settings:preview="@drawable/auto_awesome_battery"
|
||||
settings:controller="com.android.settings.widget.VideoPreferenceController"/>
|
||||
|
||||
<SwitchPreference
|
||||
android:key="smart_battery"
|
||||
android:title="@string/smart_battery_title"
|
||||
android:summary="@string/smart_battery_summary"
|
||||
settings:controller="com.android.settings.fuelgauge.SmartBatteryPreferenceController"
|
||||
settings:allowDividerAbove="true"/>
|
||||
|
||||
<SwitchPreference
|
||||
android:key="auto_restriction"
|
||||
android:title="@string/battery_auto_restriction_title"
|
||||
|
||||
@@ -42,40 +42,55 @@
|
||||
android:key="free_up_space"
|
||||
android:order="4"
|
||||
android:title="@string/storage_free_up_space_title"
|
||||
android:summary="@string/storage_free_up_space_summary"/>
|
||||
android:summary="@string/storage_free_up_space_summary"
|
||||
settings:allowDividerAbove="true"
|
||||
android:icon="@drawable/ic_files_go_round"/>
|
||||
<!-- Preference order 100~200 are 'ONLY' for storage category preferences below. -->
|
||||
<Preference
|
||||
android:key="pref_public_storage"
|
||||
android:title="@string/storage_files"
|
||||
android:icon="@drawable/ic_folder_vd_theme_24"
|
||||
android:order="100"/>
|
||||
<com.android.settings.deviceinfo.StorageItemPreference
|
||||
android:key="pref_images"
|
||||
android:title="@string/storage_images"
|
||||
android:icon="@drawable/ic_photo_library"/>
|
||||
android:icon="@drawable/ic_photo_library"
|
||||
android:order="101"/>
|
||||
<com.android.settings.deviceinfo.StorageItemPreference
|
||||
android:key="pref_videos"
|
||||
android:title="@string/storage_videos"
|
||||
android:icon="@drawable/ic_local_movies"/>
|
||||
android:icon="@drawable/ic_local_movies"
|
||||
android:order="102"/>
|
||||
<com.android.settings.deviceinfo.StorageItemPreference
|
||||
android:key="pref_audios"
|
||||
android:title="@string/storage_audios"
|
||||
android:icon="@drawable/ic_media_stream"/>
|
||||
android:icon="@drawable/ic_media_stream"
|
||||
android:order="103"/>
|
||||
<com.android.settings.deviceinfo.StorageItemPreference
|
||||
android:key="pref_apps"
|
||||
android:title="@string/storage_apps"
|
||||
android:icon="@drawable/ic_storage_apps"/>
|
||||
android:icon="@drawable/ic_storage_apps"
|
||||
android:order="104"/>
|
||||
<com.android.settings.deviceinfo.StorageItemPreference
|
||||
android:key="pref_games"
|
||||
android:title="@string/storage_games"
|
||||
android:icon="@drawable/ic_videogame_vd_theme_24"/>
|
||||
android:icon="@drawable/ic_videogame_vd_theme_24"
|
||||
android:order="105"/>
|
||||
<com.android.settings.deviceinfo.StorageItemPreference
|
||||
android:key="pref_documents_and_other"
|
||||
android:title="@string/storage_documents_and_other"
|
||||
android:icon="@drawable/ic_folder_vd_theme_24"/>
|
||||
android:icon="@drawable/ic_folder_vd_theme_24"
|
||||
android:order="106"/>
|
||||
<com.android.settings.deviceinfo.StorageItemPreference
|
||||
android:key="pref_system"
|
||||
android:title="@string/storage_system"
|
||||
android:icon="@drawable/ic_system_update"/>
|
||||
android:icon="@drawable/ic_system_update"
|
||||
android:order="107"/>
|
||||
<com.android.settings.deviceinfo.StorageItemPreference
|
||||
android:key="pref_trash"
|
||||
android:title="@string/storage_trash"
|
||||
android:icon="@drawable/ic_trash_can"/>
|
||||
android:icon="@drawable/ic_trash_can"
|
||||
android:order="108"/>
|
||||
<!-- Preference order 100~200 are 'ONLY' for storage category preferences above. -->
|
||||
<PreferenceCategory
|
||||
android:key="pref_secondary_users"
|
||||
|
||||
@@ -86,6 +86,7 @@ public class AppLaunchSettings extends AppInfoBase implements
|
||||
|
||||
private ClearDefaultsPreference mClearDefaultsPreference;
|
||||
private MainSwitchPreference mMainSwitchPreference;
|
||||
private Preference mAddLinkPreference;
|
||||
private PreferenceCategory mMainPreferenceCategory;
|
||||
private PreferenceCategory mSelectedLinksPreferenceCategory;
|
||||
private PreferenceCategory mOtherDefaultsPreferenceCategory;
|
||||
@@ -155,6 +156,7 @@ public class AppLaunchSettings extends AppInfoBase implements
|
||||
}
|
||||
setDomainVerificationUserSelection(userState.getIdentifier(), domainSet, /* enabled= */
|
||||
false);
|
||||
mAddLinkPreference.setEnabled(isAddLinksNotEmpty());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@@ -209,8 +211,8 @@ public class AppLaunchSettings extends AppInfoBase implements
|
||||
initMainSwitchAndCategories();
|
||||
if (canUpdateMainSwitchAndCategories()) {
|
||||
initVerifiedLinksPreference();
|
||||
addSelectedLinksPreference();
|
||||
initAddLinkPreference();
|
||||
addSelectedLinksPreference();
|
||||
initFooter();
|
||||
}
|
||||
}
|
||||
@@ -293,7 +295,7 @@ public class AppLaunchSettings extends AppInfoBase implements
|
||||
}
|
||||
|
||||
/** Add selected links items */
|
||||
public void addSelectedLinksPreference() {
|
||||
void addSelectedLinksPreference() {
|
||||
if (getLinksNumber(DOMAIN_STATE_SELECTED) == 0) {
|
||||
return;
|
||||
}
|
||||
@@ -303,22 +305,25 @@ public class AppLaunchSettings extends AppInfoBase implements
|
||||
for (String host : selectedLinks) {
|
||||
generateCheckBoxPreference(mSelectedLinksPreferenceCategory, host);
|
||||
}
|
||||
mAddLinkPreference.setEnabled(isAddLinksNotEmpty());
|
||||
}
|
||||
|
||||
/** Initialize add link preference */
|
||||
private void initAddLinkPreference() {
|
||||
final Preference addLinkPreference = findPreference(ADD_LINK_PREF_KEY);
|
||||
if (addLinkPreference != null) {
|
||||
addLinkPreference.setEnabled(getLinksNumber(DOMAIN_STATE_NONE) > 0);
|
||||
addLinkPreference.setOnPreferenceClickListener(preference -> {
|
||||
final int stateNoneLinksNo = getLinksNumber(DOMAIN_STATE_NONE);
|
||||
IntentPickerUtils.logd("The number of the state none links: " + stateNoneLinksNo);
|
||||
if (stateNoneLinksNo > 0) {
|
||||
showProgressDialogFragment();
|
||||
}
|
||||
return true;
|
||||
});
|
||||
}
|
||||
mAddLinkPreference = findPreference(ADD_LINK_PREF_KEY);
|
||||
mAddLinkPreference.setEnabled(isAddLinksNotEmpty());
|
||||
mAddLinkPreference.setOnPreferenceClickListener(preference -> {
|
||||
final int stateNoneLinksNo = getLinksNumber(DOMAIN_STATE_NONE);
|
||||
IntentPickerUtils.logd("The number of the state none links: " + stateNoneLinksNo);
|
||||
if (stateNoneLinksNo > 0) {
|
||||
showProgressDialogFragment();
|
||||
}
|
||||
return true;
|
||||
});
|
||||
}
|
||||
|
||||
private boolean isAddLinksNotEmpty() {
|
||||
return getLinksNumber(DOMAIN_STATE_NONE) > 0;
|
||||
}
|
||||
|
||||
private void showProgressDialogFragment() {
|
||||
|
||||
@@ -23,7 +23,7 @@ import androidx.annotation.VisibleForTesting;
|
||||
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.core.SubSettingLauncher;
|
||||
import com.android.settings.location.LocationServices;
|
||||
import com.android.settings.location.BluetoothScanningFragment;
|
||||
import com.android.settings.overlay.FeatureFactory;
|
||||
import com.android.settings.utils.AnnotationSpan;
|
||||
import com.android.settings.widget.SwitchWidgetController;
|
||||
@@ -100,7 +100,7 @@ public class BluetoothSwitchPreferenceController
|
||||
public void onClick(View v) {
|
||||
// send users to scanning settings if they click on the link in the summary text
|
||||
new SubSettingLauncher(mContext)
|
||||
.setDestination(LocationServices.class.getName())
|
||||
.setDestination(BluetoothScanningFragment.class.getName())
|
||||
.setSourceMetricsCategory(SettingsEnums.BLUETOOTH_FRAGMENT)
|
||||
.launch();
|
||||
}
|
||||
@@ -117,4 +117,4 @@ public class BluetoothSwitchPreferenceController
|
||||
mFooterPreference.setTitle(R.string.bluetooth_empty_list_bluetooth_off);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@ import android.util.ArrayMap;
|
||||
|
||||
import com.android.settings.accounts.AccountDashboardFragment;
|
||||
import com.android.settings.applications.manageapplications.ManageApplications;
|
||||
import com.android.settings.location.LocationSettings;
|
||||
import com.android.settings.location.LocationServices;
|
||||
import com.android.settings.location.RecentLocationAccessSeeAllFragment;
|
||||
|
||||
import java.util.Map;
|
||||
@@ -42,9 +42,9 @@ public class ProfileFragmentBridge {
|
||||
ProfileSelectAccountFragment.class.getName());
|
||||
FRAGMENT_MAP.put(ManageApplications.class.getName(),
|
||||
ProfileSelectManageApplications.class.getName());
|
||||
FRAGMENT_MAP.put(LocationSettings.class.getName(),
|
||||
ProfileSelectLocationFragment.class.getName());
|
||||
FRAGMENT_MAP.put(RecentLocationAccessSeeAllFragment.class.getName(),
|
||||
ProfileSelectRecentLocationAccessFragment.class.getName());
|
||||
FRAGMENT_MAP.put(LocationServices.class.getName(),
|
||||
ProfileSelectLocationServicesFragment.class.getName());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,47 @@
|
||||
/*
|
||||
* 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.dashboard.profileselector;
|
||||
|
||||
import android.os.Bundle;
|
||||
|
||||
import androidx.fragment.app.Fragment;
|
||||
|
||||
import com.android.settings.location.LocationServices;
|
||||
import com.android.settings.location.LocationServicesForWork;
|
||||
|
||||
/**
|
||||
* Location Services page for personal/managed profile.
|
||||
*/
|
||||
public class ProfileSelectLocationServicesFragment extends ProfileSelectFragment {
|
||||
|
||||
@Override
|
||||
public Fragment[] getFragments() {
|
||||
final Bundle workOnly = new Bundle();
|
||||
workOnly.putInt(EXTRA_PROFILE, ProfileType.WORK);
|
||||
final Fragment workFragment = new LocationServicesForWork();
|
||||
workFragment.setArguments(workOnly);
|
||||
|
||||
final Bundle personalOnly = new Bundle();
|
||||
personalOnly.putInt(EXTRA_PROFILE, ProfileType.PERSONAL);
|
||||
final Fragment personalFragment = new LocationServices();
|
||||
personalFragment.setArguments(personalOnly);
|
||||
return new Fragment[]{
|
||||
personalFragment, // 0
|
||||
workFragment
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -71,14 +71,14 @@ public class RegionSearchPicker extends BaseTimeZonePicker {
|
||||
final FilteredCountryTimeZones countryTimeZones = mTimeZoneData.lookupCountryTimeZones(
|
||||
regionId);
|
||||
final Activity activity = getActivity();
|
||||
if (countryTimeZones == null || countryTimeZones.getTimeZoneIds().isEmpty()) {
|
||||
if (countryTimeZones == null || countryTimeZones.getPreferredTimeZoneIds().isEmpty()) {
|
||||
Log.e(TAG, "Region has no time zones: " + regionId);
|
||||
activity.setResult(Activity.RESULT_CANCELED);
|
||||
activity.finish();
|
||||
return;
|
||||
}
|
||||
|
||||
List<String> timeZoneIds = countryTimeZones.getTimeZoneIds();
|
||||
List<String> timeZoneIds = countryTimeZones.getPreferredTimeZoneIds();
|
||||
// Choose the time zone associated the region if there is only one time zone in that region
|
||||
if (timeZoneIds.size() == 1) {
|
||||
final Intent resultData = new Intent()
|
||||
|
||||
@@ -103,7 +103,7 @@ public class RegionZonePicker extends BaseTimeZoneInfoPicker {
|
||||
// It could be a timely operations if there are many time zones. A region in time zone data
|
||||
// contains a maximum of 29 time zones currently. It may change in the future, but it's
|
||||
// unlikely to be changed drastically.
|
||||
return getRegionTimeZoneInfo(filteredCountryTimeZones.getTimeZoneIds());
|
||||
return getRegionTimeZoneInfo(filteredCountryTimeZones.getPreferredTimeZoneIds());
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -214,10 +214,11 @@ public class TimeZoneSettings extends DashboardFragment {
|
||||
mTimeZoneData.lookupCountryTimeZones(regionId);
|
||||
|
||||
use(RegionZonePreferenceController.class).setTimeZoneInfo(tzInfo);
|
||||
// Only clickable when the region has more than 1 time zones or no time zone is selected.
|
||||
|
||||
// Only clickable when the region has more than 1 time zones or no time zone is selected.
|
||||
use(RegionZonePreferenceController.class).setClickable(tzInfo == null ||
|
||||
(countryTimeZones != null && countryTimeZones.getTimeZoneIds().size() > 1));
|
||||
(countryTimeZones != null
|
||||
&& countryTimeZones.getPreferredTimeZoneIds().size() > 1));
|
||||
use(TimeZoneInfoPreferenceController.class).setTimeZoneInfo(tzInfo);
|
||||
|
||||
updatePreferenceStates();
|
||||
@@ -244,7 +245,8 @@ public class TimeZoneSettings extends DashboardFragment {
|
||||
|
||||
FilteredCountryTimeZones countryTimeZones =
|
||||
timeZoneData.lookupCountryTimeZones(regionId);
|
||||
if (countryTimeZones == null || !countryTimeZones.getTimeZoneIds().contains(tzId)) {
|
||||
if (countryTimeZones == null
|
||||
|| !countryTimeZones.getPreferredTimeZoneIds().contains(tzId)) {
|
||||
Log.e(TAG, "Unknown time zone id is selected: " + tzId);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -16,11 +16,15 @@
|
||||
|
||||
package com.android.settings.datetime.timezone.model;
|
||||
|
||||
import android.util.ArraySet;
|
||||
|
||||
import com.android.i18n.timezone.CountryTimeZones;
|
||||
|
||||
import java.time.Instant;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* Wrap {@class CountryTimeZones} to filter time zone that are shown in the picker.
|
||||
@@ -39,31 +43,46 @@ public class FilteredCountryTimeZones {
|
||||
* a timestamp known to be in the recent past is used. This should be updated occasionally but
|
||||
* it doesn't have to be very often.
|
||||
*/
|
||||
private static final long MIN_USE_DATE_OF_TIMEZONE = 1546300800000L; // 1/1/2019 00:00 UTC
|
||||
private static final Instant MIN_USE_DATE_OF_TIMEZONE =
|
||||
Instant.ofEpochMilli(1546300800000L); // 1/1/2019 00:00 UTC
|
||||
|
||||
private final CountryTimeZones mCountryTimeZones;
|
||||
private final List<String> mTimeZoneIds;
|
||||
private final List<String> mPreferredTimeZoneIds;
|
||||
private final Set<String> mAlternativeTimeZoneIds;
|
||||
|
||||
public FilteredCountryTimeZones(CountryTimeZones countryTimeZones) {
|
||||
mCountryTimeZones = countryTimeZones;
|
||||
List<String> timeZoneIds = countryTimeZones.getTimeZoneMappings().stream()
|
||||
.filter(timeZoneMapping ->
|
||||
timeZoneMapping.isShownInPicker()
|
||||
&& (timeZoneMapping.getNotUsedAfter() == null
|
||||
|| timeZoneMapping.getNotUsedAfter() >= MIN_USE_DATE_OF_TIMEZONE))
|
||||
.map(timeZoneMapping -> timeZoneMapping.getTimeZoneId())
|
||||
.collect(Collectors.toList());
|
||||
mTimeZoneIds = Collections.unmodifiableList(timeZoneIds);
|
||||
List<String> timeZoneIds = new ArrayList<>();
|
||||
Set<String> alternativeTimeZoneIds = new ArraySet<>();
|
||||
for (CountryTimeZones.TimeZoneMapping timeZoneMapping :
|
||||
countryTimeZones.getTimeZoneMappings()) {
|
||||
if (timeZoneMapping.isShownInPickerAt(MIN_USE_DATE_OF_TIMEZONE)) {
|
||||
String timeZoneId = timeZoneMapping.getTimeZoneId();
|
||||
timeZoneIds.add(timeZoneId);
|
||||
alternativeTimeZoneIds.addAll(timeZoneMapping.getAlternativeIds());
|
||||
}
|
||||
}
|
||||
mPreferredTimeZoneIds = Collections.unmodifiableList(timeZoneIds);
|
||||
mAlternativeTimeZoneIds = Collections.unmodifiableSet(alternativeTimeZoneIds);
|
||||
}
|
||||
|
||||
public List<String> getTimeZoneIds() {
|
||||
return mTimeZoneIds;
|
||||
public List<String> getPreferredTimeZoneIds() {
|
||||
return mPreferredTimeZoneIds;
|
||||
}
|
||||
|
||||
public CountryTimeZones getCountryTimeZones() {
|
||||
return mCountryTimeZones;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether {@code timeZoneId} is currently used in the country or is an alternative
|
||||
* name of a currently used time zone.
|
||||
*/
|
||||
public boolean matches(String timeZoneId) {
|
||||
return mPreferredTimeZoneIds.contains(timeZoneId)
|
||||
|| mAlternativeTimeZoneIds.contains(timeZoneId);
|
||||
}
|
||||
|
||||
public String getRegionId() {
|
||||
return TimeZoneData.normalizeRegionId(mCountryTimeZones.getCountryIso());
|
||||
}
|
||||
|
||||
@@ -71,7 +71,7 @@ public class TimeZoneData {
|
||||
Set<String> regionIds = new ArraySet<>();
|
||||
for (CountryTimeZones countryTimeZone : countryTimeZones) {
|
||||
FilteredCountryTimeZones filteredZones = new FilteredCountryTimeZones(countryTimeZone);
|
||||
if (filteredZones.getTimeZoneIds().contains(tzId)) {
|
||||
if (filteredZones.matches(tzId)) {
|
||||
regionIds.add(filteredZones.getRegionId());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -58,7 +58,7 @@ public class DeviceNamePreferenceController extends BasePreferenceController
|
||||
public DeviceNamePreferenceController(Context context, String key) {
|
||||
super(context, key);
|
||||
|
||||
mWifiManager = context.getSystemService(WifiManager.class);
|
||||
mWifiManager = (WifiManager) context.getSystemService(Context.WIFI_SERVICE);
|
||||
mWifiDeviceNameTextValidator = new WifiDeviceNameTextValidator();
|
||||
mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
|
||||
|
||||
|
||||
@@ -248,15 +248,19 @@ public class StorageDashboardFragment extends DashboardFragment
|
||||
|
||||
mPreferenceController.setVolume(mSelectedStorageEntry.getVolumeInfo());
|
||||
|
||||
if (mSelectedStorageEntry.isPrivate() && mSelectedStorageEntry.isMounted()) {
|
||||
if (!mSelectedStorageEntry.isMounted()) {
|
||||
// Set null volume to hide category stats.
|
||||
mPreferenceController.setVolume(null);
|
||||
return;
|
||||
}
|
||||
if (mSelectedStorageEntry.isPrivate()) {
|
||||
// Stats data is only available on private volumes.
|
||||
getLoaderManager().restartLoader(STORAGE_JOB_ID, Bundle.EMPTY, this);
|
||||
getLoaderManager()
|
||||
.restartLoader(VOLUME_SIZE_JOB_ID, Bundle.EMPTY, new VolumeSizeCallbacks());
|
||||
getLoaderManager().restartLoader(ICON_JOB_ID, Bundle.EMPTY, new IconLoaderCallbacks());
|
||||
} else {
|
||||
// Set null volume to hide category stats.
|
||||
mPreferenceController.setVolume(null);
|
||||
mPreferenceController.setVolume(mSelectedStorageEntry.getVolumeInfo());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -121,7 +121,7 @@ public class StorageWizardMigrateConfirm extends StorageWizardBase {
|
||||
try {
|
||||
moveId = getPackageManager().movePrimaryStorage(mVolume);
|
||||
} catch (IllegalArgumentException e) {
|
||||
StorageManager sm = getSystemService(StorageManager.class);
|
||||
StorageManager sm = (StorageManager) getSystemService(STORAGE_SERVICE);
|
||||
|
||||
if (Objects.equals(mVolume.getFsUuid(), sm.getPrimaryStorageVolume().getUuid())) {
|
||||
final Intent intent = new Intent(this, StorageWizardReady.class);
|
||||
|
||||
@@ -146,8 +146,8 @@ public class MyDeviceInfoFragment extends DashboardFragment
|
||||
// TODO: There may be an avatar setting action we can use here.
|
||||
final int iconId = bundle.getInt("icon_id", 0);
|
||||
if (iconId == 0) {
|
||||
final UserManager userManager = getActivity().getSystemService(
|
||||
UserManager.class);
|
||||
final UserManager userManager = (UserManager) getActivity().getSystemService(
|
||||
Context.USER_SERVICE);
|
||||
final UserInfo info = Utils.getExistingUser(userManager,
|
||||
android.os.Process.myUserHandle());
|
||||
controller.setLabel(info.name);
|
||||
|
||||
@@ -49,7 +49,7 @@ public class FirmwareVersionDetailPreferenceController extends BasePreferenceCon
|
||||
|
||||
public FirmwareVersionDetailPreferenceController(Context context, String key) {
|
||||
super(context, key);
|
||||
mUserManager = mContext.getSystemService(UserManager.class);
|
||||
mUserManager = (UserManager) mContext.getSystemService(Context.USER_SERVICE);
|
||||
initializeAdminPermissions();
|
||||
}
|
||||
|
||||
|
||||
@@ -49,7 +49,7 @@ public class ImeiInfoPreferenceController extends BasePreferenceController {
|
||||
|
||||
public ImeiInfoPreferenceController(Context context, String key) {
|
||||
super(context, key);
|
||||
mTelephonyManager = context.getSystemService(TelephonyManager.class);
|
||||
mTelephonyManager = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
|
||||
mIsMultiSim = mTelephonyManager.getPhoneCount() > 1;
|
||||
}
|
||||
|
||||
|
||||
@@ -46,9 +46,9 @@ public class SimStatusPreferenceController extends
|
||||
public SimStatusPreferenceController(Context context, Fragment fragment) {
|
||||
super(context);
|
||||
|
||||
mTelephonyManager = context.getSystemService(TelephonyManager.class);
|
||||
mSubscriptionManager = context.getSystemService(
|
||||
SubscriptionManager.class);
|
||||
mTelephonyManager = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
|
||||
mSubscriptionManager = (SubscriptionManager) context.getSystemService(
|
||||
Context.TELEPHONY_SUBSCRIPTION_SERVICE);
|
||||
mFragment = fragment;
|
||||
}
|
||||
|
||||
|
||||
@@ -26,6 +26,7 @@ import androidx.annotation.VisibleForTesting;
|
||||
import androidx.fragment.app.FragmentManager;
|
||||
import androidx.preference.PreferenceScreen;
|
||||
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.core.BasePreferenceController;
|
||||
import com.android.settings.deletionhelper.ActivationWarningFragment;
|
||||
import com.android.settings.overlay.FeatureFactory;
|
||||
@@ -66,6 +67,9 @@ public class AutomaticStorageManagementSwitchPreferenceController extends
|
||||
|
||||
@Override
|
||||
public int getAvailabilityStatus() {
|
||||
if (!mContext.getResources().getBoolean(R.bool.config_show_smart_storage_toggle)) {
|
||||
return UNSUPPORTED_ON_DEVICE;
|
||||
}
|
||||
return !ActivityManager.isLowRamDeviceStatic() ? AVAILABLE : UNSUPPORTED_ON_DEVICE;
|
||||
}
|
||||
|
||||
@@ -108,4 +112,4 @@ public class AutomaticStorageManagementSwitchPreferenceController extends
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -236,6 +236,14 @@ public class StorageEntry implements Comparable<StorageEntry>, Parcelable {
|
||||
return mVolumeInfo == null ? false : mVolumeInfo.getType() == VolumeInfo.TYPE_PUBLIC;
|
||||
}
|
||||
|
||||
/**
|
||||
* Stub volume is a volume that is maintained by external party such as the ChromeOS processes
|
||||
* in ARC++.
|
||||
*/
|
||||
public boolean isStub() {
|
||||
return mVolumeInfo == null ? false : mVolumeInfo.getType() == VolumeInfo.TYPE_STUB;
|
||||
}
|
||||
|
||||
/** Returns description. */
|
||||
public String getDescription() {
|
||||
if (isVolumeInfo()) {
|
||||
|
||||
@@ -69,6 +69,8 @@ public class StorageItemPreferenceController extends AbstractPreferenceControlle
|
||||
|
||||
private static final String SYSTEM_FRAGMENT_TAG = "SystemInfo";
|
||||
|
||||
@VisibleForTesting
|
||||
static final String PUBLIC_STORAGE_KEY = "pref_public_storage";
|
||||
@VisibleForTesting
|
||||
static final String IMAGES_KEY = "pref_images";
|
||||
@VisibleForTesting
|
||||
@@ -103,9 +105,11 @@ public class StorageItemPreferenceController extends AbstractPreferenceControlle
|
||||
private long mUsedBytes;
|
||||
private long mTotalSize;
|
||||
|
||||
private List<StorageItemPreference> mStorageItemPreferences;
|
||||
private List<StorageItemPreference> mPrivateStorageItemPreferences;
|
||||
private PreferenceScreen mScreen;
|
||||
@VisibleForTesting
|
||||
Preference mPublicStoragePreference;
|
||||
@VisibleForTesting
|
||||
StorageItemPreference mImagesPreference;
|
||||
@VisibleForTesting
|
||||
StorageItemPreference mVideosPreference;
|
||||
@@ -167,6 +171,9 @@ public class StorageItemPreferenceController extends AbstractPreferenceControlle
|
||||
return false;
|
||||
}
|
||||
switch (preference.getKey()) {
|
||||
case PUBLIC_STORAGE_KEY:
|
||||
launchPublicStorageIntent();
|
||||
return true;
|
||||
case IMAGES_KEY:
|
||||
launchImagesIntent();
|
||||
return true;
|
||||
@@ -210,37 +217,45 @@ public class StorageItemPreferenceController extends AbstractPreferenceControlle
|
||||
public void setVolume(VolumeInfo volume) {
|
||||
mVolume = volume;
|
||||
|
||||
final boolean isValidVolume = isValidVolume();
|
||||
setCategoryPreferencesVisibility(isValidVolume);
|
||||
if (isValidVolume) {
|
||||
updateCategoryPreferencesOrder();
|
||||
}
|
||||
updateCategoryPreferencesVisibility();
|
||||
updatePrivateStorageCategoryPreferencesOrder();
|
||||
}
|
||||
|
||||
// Stats data is only available on private volumes.
|
||||
private boolean isValidVolume() {
|
||||
private boolean isValidPrivateVolume() {
|
||||
return mVolume != null
|
||||
&& mVolume.getType() == VolumeInfo.TYPE_PRIVATE
|
||||
&& (mVolume.getState() == VolumeInfo.STATE_MOUNTED
|
||||
|| mVolume.getState() == VolumeInfo.STATE_MOUNTED_READ_ONLY);
|
||||
}
|
||||
|
||||
private void setCategoryPreferencesVisibility(boolean visible) {
|
||||
private boolean isValidPublicVolume() {
|
||||
return mVolume != null
|
||||
&& (mVolume.getType() == VolumeInfo.TYPE_PUBLIC
|
||||
|| mVolume.getType() == VolumeInfo.TYPE_STUB)
|
||||
&& (mVolume.getState() == VolumeInfo.STATE_MOUNTED
|
||||
|| mVolume.getState() == VolumeInfo.STATE_MOUNTED_READ_ONLY);
|
||||
}
|
||||
|
||||
private void updateCategoryPreferencesVisibility() {
|
||||
if (mScreen == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
mImagesPreference.setVisible(visible);
|
||||
mVideosPreference.setVisible(visible);
|
||||
mAudiosPreference.setVisible(visible);
|
||||
mAppsPreference.setVisible(visible);
|
||||
mGamesPreference.setVisible(visible);
|
||||
mDocumentsAndOtherPreference.setVisible(visible);
|
||||
mSystemPreference.setVisible(visible);
|
||||
mPublicStoragePreference.setVisible(isValidPublicVolume());
|
||||
|
||||
final boolean privateStoragePreferencesVisible = isValidPrivateVolume();
|
||||
mImagesPreference.setVisible(privateStoragePreferencesVisible);
|
||||
mVideosPreference.setVisible(privateStoragePreferencesVisible);
|
||||
mAudiosPreference.setVisible(privateStoragePreferencesVisible);
|
||||
mAppsPreference.setVisible(privateStoragePreferencesVisible);
|
||||
mGamesPreference.setVisible(privateStoragePreferencesVisible);
|
||||
mDocumentsAndOtherPreference.setVisible(privateStoragePreferencesVisible);
|
||||
mSystemPreference.setVisible(privateStoragePreferencesVisible);
|
||||
// TODO(b/170918505): Shows trash category after trash category feature complete.
|
||||
mTrashPreference.setVisible(false);
|
||||
|
||||
if (visible) {
|
||||
if (privateStoragePreferencesVisible) {
|
||||
final VolumeInfo sharedVolume = mSvp.findEmulatedForPrivate(mVolume);
|
||||
// If we don't have a shared volume for our internal storage (or the shared volume isn't
|
||||
// mounted as readable for whatever reason), we should hide the File preference.
|
||||
@@ -250,22 +265,22 @@ public class StorageItemPreferenceController extends AbstractPreferenceControlle
|
||||
}
|
||||
}
|
||||
|
||||
private void updateCategoryPreferencesOrder() {
|
||||
if (mScreen == null) {
|
||||
private void updatePrivateStorageCategoryPreferencesOrder() {
|
||||
if (mScreen == null || !isValidPrivateVolume()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (mStorageItemPreferences == null) {
|
||||
mStorageItemPreferences = new ArrayList<>();
|
||||
if (mPrivateStorageItemPreferences == null) {
|
||||
mPrivateStorageItemPreferences = new ArrayList<>();
|
||||
|
||||
mStorageItemPreferences.add(mImagesPreference);
|
||||
mStorageItemPreferences.add(mVideosPreference);
|
||||
mStorageItemPreferences.add(mAudiosPreference);
|
||||
mStorageItemPreferences.add(mAppsPreference);
|
||||
mStorageItemPreferences.add(mGamesPreference);
|
||||
mStorageItemPreferences.add(mDocumentsAndOtherPreference);
|
||||
mStorageItemPreferences.add(mSystemPreference);
|
||||
mStorageItemPreferences.add(mTrashPreference);
|
||||
mPrivateStorageItemPreferences.add(mImagesPreference);
|
||||
mPrivateStorageItemPreferences.add(mVideosPreference);
|
||||
mPrivateStorageItemPreferences.add(mAudiosPreference);
|
||||
mPrivateStorageItemPreferences.add(mAppsPreference);
|
||||
mPrivateStorageItemPreferences.add(mGamesPreference);
|
||||
mPrivateStorageItemPreferences.add(mDocumentsAndOtherPreference);
|
||||
mPrivateStorageItemPreferences.add(mSystemPreference);
|
||||
mPrivateStorageItemPreferences.add(mTrashPreference);
|
||||
}
|
||||
mScreen.removePreference(mImagesPreference);
|
||||
mScreen.removePreference(mVideosPreference);
|
||||
@@ -277,10 +292,10 @@ public class StorageItemPreferenceController extends AbstractPreferenceControlle
|
||||
mScreen.removePreference(mTrashPreference);
|
||||
|
||||
// Sort display order by size.
|
||||
Collections.sort(mStorageItemPreferences,
|
||||
Collections.sort(mPrivateStorageItemPreferences,
|
||||
Comparator.comparingLong(StorageItemPreference::getStorageSize));
|
||||
int orderIndex = LAST_STORAGE_CATEGORY_PREFERENCE_ORDER;
|
||||
for (StorageItemPreference preference : mStorageItemPreferences) {
|
||||
for (StorageItemPreference preference : mPrivateStorageItemPreferences) {
|
||||
preference.setOrder(orderIndex--);
|
||||
mScreen.addPreference(preference);
|
||||
}
|
||||
@@ -292,6 +307,7 @@ public class StorageItemPreferenceController extends AbstractPreferenceControlle
|
||||
public void setUserId(UserHandle userHandle) {
|
||||
mUserId = userHandle.getIdentifier();
|
||||
|
||||
tintPreference(mPublicStoragePreference);
|
||||
tintPreference(mImagesPreference);
|
||||
tintPreference(mVideosPreference);
|
||||
tintPreference(mAudiosPreference);
|
||||
@@ -320,6 +336,7 @@ public class StorageItemPreferenceController extends AbstractPreferenceControlle
|
||||
@Override
|
||||
public void displayPreference(PreferenceScreen screen) {
|
||||
mScreen = screen;
|
||||
mPublicStoragePreference = screen.findPreference(PUBLIC_STORAGE_KEY);
|
||||
mImagesPreference = screen.findPreference(IMAGES_KEY);
|
||||
mVideosPreference = screen.findPreference(VIDEOS_KEY);
|
||||
mAudiosPreference = screen.findPreference(AUDIOS_KEY);
|
||||
@@ -329,11 +346,8 @@ public class StorageItemPreferenceController extends AbstractPreferenceControlle
|
||||
mSystemPreference = screen.findPreference(SYSTEM_KEY);
|
||||
mTrashPreference = screen.findPreference(TRASH_KEY);
|
||||
|
||||
final boolean isValidVolume = isValidVolume();
|
||||
setCategoryPreferencesVisibility(isValidVolume);
|
||||
if (isValidVolume) {
|
||||
updateCategoryPreferencesOrder();
|
||||
}
|
||||
updateCategoryPreferencesVisibility();
|
||||
updatePrivateStorageCategoryPreferencesOrder();
|
||||
}
|
||||
|
||||
public void onLoadFinished(SparseArray<StorageAsyncLoader.AppsStorageResult> result,
|
||||
@@ -371,7 +385,7 @@ public class StorageItemPreferenceController extends AbstractPreferenceControlle
|
||||
mSystemPreference.setStorageSize(systemSize, mTotalSize);
|
||||
}
|
||||
|
||||
updateCategoryPreferencesOrder();
|
||||
updatePrivateStorageCategoryPreferencesOrder();
|
||||
}
|
||||
|
||||
public void setUsedSize(long usedSizeBytes) {
|
||||
@@ -382,6 +396,13 @@ public class StorageItemPreferenceController extends AbstractPreferenceControlle
|
||||
mTotalSize = totalSizeBytes;
|
||||
}
|
||||
|
||||
private void launchPublicStorageIntent() {
|
||||
final Intent intent = mVolume.buildBrowseIntent();
|
||||
if (intent != null) {
|
||||
mContext.startActivity(intent);
|
||||
}
|
||||
}
|
||||
|
||||
// TODO(b/183078080): To simplify StorageItemPreferenceController, move launchxxxIntent to a
|
||||
// utility object.
|
||||
private void launchImagesIntent() {
|
||||
|
||||
@@ -52,6 +52,19 @@ import java.util.Locale;
|
||||
* and icon image.
|
||||
*/
|
||||
public class BatteryEntry {
|
||||
|
||||
public static final class NameAndIcon {
|
||||
public final String name;
|
||||
public final Drawable icon;
|
||||
public final int iconId;
|
||||
|
||||
public NameAndIcon(String name, Drawable icon, int iconId) {
|
||||
this.name = name;
|
||||
this.icon = icon;
|
||||
this.iconId = iconId;
|
||||
}
|
||||
}
|
||||
|
||||
public static final int MSG_UPDATE_NAME_ICON = 1;
|
||||
public static final int MSG_REPORT_FULLY_DRAWN = 2;
|
||||
|
||||
@@ -186,22 +199,16 @@ public class BatteryEntry {
|
||||
} else if (batteryConsumer instanceof SystemBatteryConsumer) {
|
||||
mConsumedPower = batteryConsumer.getConsumedPower()
|
||||
- ((SystemBatteryConsumer) batteryConsumer).getPowerConsumedByApps();
|
||||
final Pair<Integer, String> resourcePair = getResourcePairFromDrainType(
|
||||
final NameAndIcon nameAndIcon = getNameAndIconFromDrainType(
|
||||
context, ((SystemBatteryConsumer) batteryConsumer).getDrainType());
|
||||
iconId = resourcePair.first;
|
||||
name = resourcePair.second;
|
||||
iconId = nameAndIcon.iconId;
|
||||
name = nameAndIcon.name;
|
||||
} else if (batteryConsumer instanceof UserBatteryConsumer) {
|
||||
mConsumedPower = batteryConsumer.getConsumedPower();
|
||||
|
||||
UserInfo info = um.getUserInfo(((UserBatteryConsumer) batteryConsumer).getUserId());
|
||||
if (info != null) {
|
||||
icon = Utils.getUserIcon(context, um, info);
|
||||
name = Utils.getUserLabel(context, info);
|
||||
} else {
|
||||
icon = null;
|
||||
name = context.getResources().getString(
|
||||
R.string.running_process_item_removed_user_label);
|
||||
}
|
||||
final NameAndIcon nameAndIcon = getNameAndIconFromUserId(
|
||||
context, ((UserBatteryConsumer) batteryConsumer).getUserId());
|
||||
icon = nameAndIcon.icon;
|
||||
name = nameAndIcon.name;
|
||||
}
|
||||
|
||||
if (iconId != 0) {
|
||||
@@ -238,15 +245,9 @@ public class BatteryEntry {
|
||||
}
|
||||
|
||||
if (packages == null || packages.length == 0) {
|
||||
if (uid == 0) {
|
||||
name = mContext.getResources().getString(R.string.process_kernel_label);
|
||||
} else if ("mediaserver".equals(name)) {
|
||||
name = mContext.getResources().getString(R.string.process_mediaserver_label);
|
||||
} else if ("dex2oat".equals(name)) {
|
||||
name = mContext.getResources().getString(R.string.process_dex2oat_label);
|
||||
}
|
||||
iconId = R.drawable.ic_power_system;
|
||||
icon = mContext.getDrawable(iconId);
|
||||
final NameAndIcon nameAndIcon = getNameAndIconFromUid(mContext, name, uid);
|
||||
icon = nameAndIcon.icon;
|
||||
name = nameAndIcon.name;
|
||||
} else {
|
||||
icon = mContext.getPackageManager().getDefaultActivityIcon();
|
||||
}
|
||||
@@ -418,6 +419,13 @@ public class BatteryEntry {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the BatteryConsumer of the app described by this entry.
|
||||
*/
|
||||
public BatteryConsumer getBatteryConsumer() {
|
||||
return mBatteryConsumer;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns foreground foreground time (in milliseconds) that is attributed to this entry.
|
||||
*/
|
||||
@@ -462,10 +470,46 @@ public class BatteryEntry {
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets icon ID and name from system battery consumer drain type.
|
||||
* Gets name and icon resource from UserBatteryConsumer userId.
|
||||
*/
|
||||
public static Pair<Integer, String> getResourcePairFromDrainType(
|
||||
Context context, int drainType) {
|
||||
public static NameAndIcon getNameAndIconFromUserId(
|
||||
Context context, final int userId) {
|
||||
UserManager um = context.getSystemService(UserManager.class);
|
||||
UserInfo info = um.getUserInfo(userId);
|
||||
|
||||
Drawable icon = null;
|
||||
String name = null;
|
||||
if (info != null) {
|
||||
icon = Utils.getUserIcon(context, um, info);
|
||||
name = Utils.getUserLabel(context, info);
|
||||
} else {
|
||||
name = context.getResources().getString(
|
||||
R.string.running_process_item_removed_user_label);
|
||||
}
|
||||
return new NameAndIcon(name, icon, 0 /* iconId */);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets name and icon resource from UidBatteryConsumer uid.
|
||||
*/
|
||||
public static NameAndIcon getNameAndIconFromUid(
|
||||
Context context, String name, final int uid) {
|
||||
Drawable icon = context.getDrawable(R.drawable.ic_power_system);
|
||||
if (uid == 0) {
|
||||
name = context.getResources().getString(R.string.process_kernel_label);
|
||||
} else if ("mediaserver".equals(name)) {
|
||||
name = context.getResources().getString(R.string.process_mediaserver_label);
|
||||
} else if ("dex2oat".equals(name)) {
|
||||
name = context.getResources().getString(R.string.process_dex2oat_label);
|
||||
}
|
||||
return new NameAndIcon(name, icon, 0 /* iconId */);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets name annd icon resource from SystemBatteryConsumer drain type.
|
||||
*/
|
||||
public static NameAndIcon getNameAndIconFromDrainType(
|
||||
Context context, final int drainType) {
|
||||
String name = null;
|
||||
int iconId = 0;
|
||||
switch (drainType) {
|
||||
@@ -511,6 +555,6 @@ public class BatteryEntry {
|
||||
iconId = R.drawable.ic_power_system;
|
||||
break;
|
||||
}
|
||||
return new Pair<>(Integer.valueOf(iconId), name);
|
||||
return new NameAndIcon(name, null /* icon */, iconId);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,27 +20,23 @@ package com.android.settings.fuelgauge;
|
||||
import android.content.Context;
|
||||
import android.provider.Settings;
|
||||
import android.text.TextUtils;
|
||||
import android.widget.Switch;
|
||||
|
||||
import androidx.preference.Preference;
|
||||
import androidx.preference.PreferenceScreen;
|
||||
import androidx.preference.SwitchPreference;
|
||||
|
||||
import com.android.settings.core.BasePreferenceController;
|
||||
import com.android.settings.overlay.FeatureFactory;
|
||||
import com.android.settingslib.widget.MainSwitchPreference;
|
||||
import com.android.settingslib.widget.OnMainSwitchChangeListener;
|
||||
|
||||
/**
|
||||
* Controller to change and update the smart battery toggle
|
||||
*/
|
||||
public class SmartBatteryPreferenceController extends BasePreferenceController implements
|
||||
OnMainSwitchChangeListener {
|
||||
Preference.OnPreferenceChangeListener {
|
||||
|
||||
private static final String KEY_SMART_BATTERY = "smart_battery";
|
||||
private static final int ON = 1;
|
||||
private static final int OFF = 0;
|
||||
private PowerUsageFeatureProvider mPowerUsageFeatureProvider;
|
||||
private MainSwitchPreference mPreference;
|
||||
|
||||
public SmartBatteryPreferenceController(Context context) {
|
||||
super(context, KEY_SMART_BATTERY);
|
||||
@@ -70,19 +66,14 @@ public class SmartBatteryPreferenceController extends BasePreferenceController i
|
||||
super.updateState(preference);
|
||||
final boolean smartBatteryOn = Settings.Global.getInt(mContext.getContentResolver(),
|
||||
Settings.Global.ADAPTIVE_BATTERY_MANAGEMENT_ENABLED, ON) == ON;
|
||||
((MainSwitchPreference) preference).updateStatus(smartBatteryOn);
|
||||
((SwitchPreference) preference).setChecked(smartBatteryOn);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void displayPreference(PreferenceScreen screen) {
|
||||
super.displayPreference(screen);
|
||||
mPreference = (MainSwitchPreference) screen.findPreference(getPreferenceKey());
|
||||
mPreference.addOnSwitchChangeListener(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSwitchChanged(Switch switchView, boolean isChecked) {
|
||||
public boolean onPreferenceChange(Preference preference, Object newValue) {
|
||||
final boolean smartBatteryOn = (Boolean) newValue;
|
||||
Settings.Global.putInt(mContext.getContentResolver(),
|
||||
Settings.Global.ADAPTIVE_BATTERY_MANAGEMENT_ENABLED, isChecked ? ON : OFF);
|
||||
Settings.Global.ADAPTIVE_BATTERY_MANAGEMENT_ENABLED, smartBatteryOn ? ON : OFF);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -85,7 +85,6 @@ public class LocationSettings extends DashboardFragment {
|
||||
use(RecentLocationAccessPreferenceController.class).init(this);
|
||||
use(RecentLocationAccessSeeAllButtonPreferenceController.class).init(this);
|
||||
use(LocationForWorkPreferenceController.class).init(this);
|
||||
use(LocationInjectedServicesForWorkPreferenceController.class).init(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -43,7 +43,7 @@ public final class EthernetTetherPreferenceController extends TetherBasePreferen
|
||||
super(context, preferenceKey);
|
||||
mEthernetRegex = context.getString(
|
||||
com.android.internal.R.string.config_ethernet_iface_regex);
|
||||
mEthernetManager = context.getSystemService(EthernetManager.class);
|
||||
mEthernetManager = (EthernetManager) context.getSystemService(Context.ETHERNET_SERVICE);
|
||||
}
|
||||
|
||||
@OnLifecycleEvent(Lifecycle.Event.ON_START)
|
||||
|
||||
@@ -142,13 +142,13 @@ public class InternetUpdater implements AirplaneModeEnabler.OnAirplaneModeChange
|
||||
private NetworkCallback mNetworkCallback = new NetworkCallback() {
|
||||
public void onCapabilitiesChanged(@NonNull Network network,
|
||||
@NonNull NetworkCapabilities networkCapabilities) {
|
||||
checkNetworkCapabilities(networkCapabilities);
|
||||
updateInternetAvailable(networkCapabilities);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLost(@NonNull Network network) {
|
||||
mInternetAvailable = false;
|
||||
update();
|
||||
updateInternetType();
|
||||
}
|
||||
};
|
||||
|
||||
@@ -203,7 +203,7 @@ public class InternetUpdater implements AirplaneModeEnabler.OnAirplaneModeChange
|
||||
Network activeNetwork = mConnectivityManager.getActiveNetwork();
|
||||
if (activeNetwork == null) {
|
||||
mInternetAvailable = false;
|
||||
update();
|
||||
updateInternetType();
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -211,36 +211,34 @@ public class InternetUpdater implements AirplaneModeEnabler.OnAirplaneModeChange
|
||||
mConnectivityManager.getNetworkCapabilities(activeNetwork);
|
||||
if (activeNetworkCapabilities == null) {
|
||||
mInternetAvailable = false;
|
||||
update();
|
||||
updateInternetType();
|
||||
return;
|
||||
}
|
||||
|
||||
checkNetworkCapabilities(activeNetworkCapabilities);
|
||||
}
|
||||
|
||||
private void checkNetworkCapabilities(@NonNull NetworkCapabilities networkCapabilities) {
|
||||
if (!networkCapabilities.hasCapability(NetworkCapabilities.NET_CAPABILITY_INTERNET)) {
|
||||
mInternetAvailable = false;
|
||||
update();
|
||||
return;
|
||||
}
|
||||
|
||||
boolean internetAvailable = false;
|
||||
for (int transport : networkCapabilities.getTransportTypes()) {
|
||||
if (sTransportMap.containsKey(transport)) {
|
||||
mTransport = transport;
|
||||
internetAvailable = true;
|
||||
Log.i(TAG, "Detect an internet capability network with transport type: "
|
||||
+ mTransport);
|
||||
break;
|
||||
}
|
||||
}
|
||||
mInternetAvailable = internetAvailable;
|
||||
update();
|
||||
updateInternetAvailable(activeNetworkCapabilities);
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
void update() {
|
||||
void updateInternetAvailable(@NonNull NetworkCapabilities capabilities) {
|
||||
boolean internetAvailable = false;
|
||||
if (capabilities.hasCapability(NetworkCapabilities.NET_CAPABILITY_INTERNET)
|
||||
&& capabilities.hasCapability(NetworkCapabilities.NET_CAPABILITY_VALIDATED)) {
|
||||
for (int transport : capabilities.getTransportTypes()) {
|
||||
if (sTransportMap.containsKey(transport)) {
|
||||
mTransport = transport;
|
||||
internetAvailable = true;
|
||||
Log.i(TAG, "Detect an internet available network with transport type: "
|
||||
+ mTransport);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
mInternetAvailable = internetAvailable;
|
||||
updateInternetType();
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
void updateInternetType() {
|
||||
@InternetType int internetType = INTERNET_NETWORKS_AVAILABLE;
|
||||
if (mInternetAvailable) {
|
||||
internetType = sTransportMap.get(mTransport);
|
||||
|
||||
@@ -73,9 +73,9 @@ public class MobilePlanPreferenceController extends AbstractPreferenceController
|
||||
MobilePlanPreferenceHost host) {
|
||||
super(context);
|
||||
mHost = host;
|
||||
mCm = context.getSystemService(ConnectivityManager.class);
|
||||
mTm = context.getSystemService(TelephonyManager.class);
|
||||
mUserManager = context.getSystemService(UserManager.class);
|
||||
mCm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
|
||||
mTm = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
|
||||
mUserManager = (UserManager) context.getSystemService(Context.USER_SERVICE);
|
||||
mIsSecondaryUser = !mUserManager.isAdminUser();
|
||||
}
|
||||
|
||||
|
||||
@@ -31,7 +31,7 @@ public class NetworkResetRestrictionChecker {
|
||||
|
||||
public NetworkResetRestrictionChecker(Context context) {
|
||||
mContext = context;
|
||||
mUserManager = context.getSystemService(UserManager.class);
|
||||
mUserManager = (UserManager) context.getSystemService(Context.USER_SERVICE);
|
||||
}
|
||||
|
||||
@VisibleForTesting(otherwise = VisibleForTesting.PRIVATE)
|
||||
|
||||
@@ -140,6 +140,6 @@ public class NetworkScorerPicker extends InstrumentedPreferenceFragment implemen
|
||||
|
||||
@VisibleForTesting
|
||||
NetworkScoreManager createNetworkScorerManager(Context context) {
|
||||
return context.getSystemService(NetworkScoreManager.class);
|
||||
return (NetworkScoreManager) context.getSystemService(Context.NETWORK_SCORE_SERVICE);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -37,7 +37,7 @@ public class NetworkScorerPickerPreferenceController extends BasePreferenceContr
|
||||
public NetworkScorerPickerPreferenceController(Context context, String key) {
|
||||
super(context, key);
|
||||
mNetworkScoreManager =
|
||||
mContext.getSystemService(NetworkScoreManager.class);
|
||||
(NetworkScoreManager) mContext.getSystemService(Context.NETWORK_SCORE_SERVICE);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -21,6 +21,7 @@ import static android.app.slice.Slice.EXTRA_TOGGLE_STATE;
|
||||
|
||||
import static com.android.settings.slices.CustomSliceRegistry.PROVIDER_MODEL_SLICE_URI;
|
||||
|
||||
import android.annotation.ColorInt;
|
||||
import android.app.settings.SettingsEnums;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
@@ -30,6 +31,7 @@ import android.telephony.SubscriptionManager;
|
||||
import android.util.Log;
|
||||
|
||||
import androidx.annotation.VisibleForTesting;
|
||||
import androidx.core.graphics.drawable.IconCompat;
|
||||
import androidx.slice.Slice;
|
||||
import androidx.slice.builders.ListBuilder;
|
||||
|
||||
@@ -83,9 +85,10 @@ public class ProviderModelSlice extends WifiSlice {
|
||||
// Second section: Add a carrier item.
|
||||
// Third section: Add the Wi-Fi items which are not connected.
|
||||
// Fourth section: If device has connection problem, this row show the message for user.
|
||||
boolean hasEthernet = isEthernetConnected();
|
||||
@InternetUpdater.InternetType int internetType = getInternetType();
|
||||
final ListBuilder listBuilder = mHelper.createListBuilder(getUri());
|
||||
if (mHelper.isAirplaneModeEnabled() && !mWifiManager.isWifiEnabled() && !hasEthernet) {
|
||||
if (mHelper.isAirplaneModeEnabled() && !mWifiManager.isWifiEnabled()
|
||||
&& internetType != InternetUpdater.INTERNET_ETHERNET) {
|
||||
log("Airplane mode is enabled.");
|
||||
return listBuilder.build();
|
||||
}
|
||||
@@ -105,15 +108,17 @@ public class ProviderModelSlice extends WifiSlice {
|
||||
log("hasCarrier: " + hasCarrier);
|
||||
|
||||
// First section: Add a Ethernet or Wi-Fi item which state is connected.
|
||||
boolean isConnectedWifiAddedTop = false;
|
||||
final WifiSliceItem connectedWifiItem = mHelper.getConnectedWifiItem(wifiList);
|
||||
if (hasEthernet) {
|
||||
if (internetType == InternetUpdater.INTERNET_ETHERNET) {
|
||||
log("get Ethernet item which is connected");
|
||||
listBuilder.addRow(createEthernetRow());
|
||||
maxListSize--;
|
||||
} else {
|
||||
if (connectedWifiItem != null) {
|
||||
log("get Wi-Fi item which is connected");
|
||||
if (connectedWifiItem != null && internetType == InternetUpdater.INTERNET_WIFI) {
|
||||
log("get Wi-Fi item which is connected to internet");
|
||||
listBuilder.addRow(getWifiSliceItemRow(connectedWifiItem));
|
||||
isConnectedWifiAddedTop = true;
|
||||
maxListSize--;
|
||||
}
|
||||
}
|
||||
@@ -128,7 +133,7 @@ public class ProviderModelSlice extends WifiSlice {
|
||||
}
|
||||
|
||||
// Third section: Add the connected Wi-Fi item to Wi-Fi list if the Ethernet is connected.
|
||||
if (connectedWifiItem != null && hasEthernet) {
|
||||
if (connectedWifiItem != null && !isConnectedWifiAddedTop) {
|
||||
log("get Wi-Fi item which is connected");
|
||||
listBuilder.addRow(getWifiSliceItemRow(connectedWifiItem));
|
||||
maxListSize--;
|
||||
@@ -222,12 +227,12 @@ public class ProviderModelSlice extends WifiSlice {
|
||||
return SliceBackgroundWorker.getInstance(getUri());
|
||||
}
|
||||
|
||||
private boolean isEthernetConnected() {
|
||||
private @InternetUpdater.InternetType int getInternetType() {
|
||||
final NetworkProviderWorker worker = getWorker();
|
||||
if (worker == null) {
|
||||
return false;
|
||||
return InternetUpdater.INTERNET_NETWORKS_AVAILABLE;
|
||||
}
|
||||
return worker.isEthernetConnected();
|
||||
return worker.getInternetType();
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
@@ -243,6 +248,20 @@ public class ProviderModelSlice extends WifiSlice {
|
||||
.setSubtitle(mContext.getText(R.string.to_switch_networks_disconnect_ethernet));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected IconCompat getWifiSliceItemLevelIcon(WifiSliceItem wifiSliceItem) {
|
||||
if (wifiSliceItem.getConnectedState() == WifiEntry.CONNECTED_STATE_CONNECTED
|
||||
&& getInternetType() != InternetUpdater.INTERNET_WIFI) {
|
||||
final @ColorInt int tint = Utils.getColorAttrDefaultColor(mContext,
|
||||
android.R.attr.colorControlNormal);
|
||||
final Drawable drawable = mContext.getDrawable(
|
||||
Utils.getWifiIconResource(wifiSliceItem.getLevel()));
|
||||
drawable.setTint(tint);
|
||||
return Utils.createIconWithDrawable(drawable);
|
||||
}
|
||||
return super.getWifiSliceItemLevelIcon(wifiSliceItem);
|
||||
}
|
||||
|
||||
/**
|
||||
* Wrap the subscriptionManager call for test mocking.
|
||||
*/
|
||||
|
||||
@@ -128,10 +128,10 @@ public class TetherEnabler implements SwitchWidgetController.OnSwitchChangeListe
|
||||
mSwitchWidgetController = switchWidgetController;
|
||||
mDataSaverBackend = new DataSaverBackend(context);
|
||||
mConnectivityManager =
|
||||
context.getSystemService(ConnectivityManager.class);
|
||||
mTetheringManager = context.getSystemService(TetheringManager.class);
|
||||
mWifiManager = context.getSystemService(WifiManager.class);
|
||||
mUserManager = context.getSystemService(UserManager.class);
|
||||
(ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
|
||||
mTetheringManager = (TetheringManager) context.getSystemService(Context.TETHERING_SERVICE);
|
||||
mWifiManager = (WifiManager) context.getSystemService(Context.WIFI_SERVICE);
|
||||
mUserManager = (UserManager) context.getSystemService(Context.USER_SERVICE);
|
||||
mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
|
||||
mBluetoothPan = bluetoothPan;
|
||||
mEthernetRegex =
|
||||
|
||||
@@ -1291,8 +1291,8 @@ public class ApnEditor extends SettingsPreferenceFragment
|
||||
mReadOnlyApnTypes = null;
|
||||
mReadOnlyApnFields = null;
|
||||
|
||||
final CarrierConfigManager configManager =
|
||||
getSystemService(CarrierConfigManager.class);
|
||||
final CarrierConfigManager configManager = (CarrierConfigManager)
|
||||
getSystemService(Context.CARRIER_CONFIG_SERVICE);
|
||||
if (configManager != null) {
|
||||
final PersistableBundle b = configManager.getConfigForSubId(mSubId);
|
||||
if (b != null) {
|
||||
|
||||
@@ -209,8 +209,8 @@ public class ApnSettings extends RestrictedSettingsFragment
|
||||
mSubscriptionInfo = getSubscriptionInfo(mSubId);
|
||||
mTelephonyManager = activity.getSystemService(TelephonyManager.class);
|
||||
|
||||
final CarrierConfigManager configManager =
|
||||
getSystemService(CarrierConfigManager.class);
|
||||
final CarrierConfigManager configManager = (CarrierConfigManager)
|
||||
getSystemService(Context.CARRIER_CONFIG_SERVICE);
|
||||
final PersistableBundle b = configManager.getConfigForSubId(mSubId);
|
||||
mHideImsApn = b.getBoolean(CarrierConfigManager.KEY_HIDE_IMS_APN_BOOL);
|
||||
mAllowAddingApns = b.getBoolean(CarrierConfigManager.KEY_ALLOW_ADDING_APNS_BOOL);
|
||||
|
||||
@@ -202,7 +202,7 @@ public class MobileNetworkSettings extends AbstractMobileNetworkSettings {
|
||||
|
||||
super.onCreate(icicle);
|
||||
final Context context = getContext();
|
||||
mUserManager = context.getSystemService(UserManager.class);
|
||||
mUserManager = (UserManager) context.getSystemService(Context.USER_SERVICE);
|
||||
mTelephonyManager = context.getSystemService(TelephonyManager.class)
|
||||
.createForSubscriptionId(mSubId);
|
||||
|
||||
|
||||
@@ -288,9 +288,9 @@ public class NetworkProviderWorker extends WifiScanWorker implements
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true, if the ethernet network is connected.
|
||||
* Returns the internet type.
|
||||
*/
|
||||
public boolean isEthernetConnected() {
|
||||
return mInternetType == INTERNET_ETHERNET;
|
||||
public @InternetUpdater.InternetType int getInternetType() {
|
||||
return mInternetType;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -106,8 +106,8 @@ public class NetworkSelectSettings extends DashboardFragment {
|
||||
.createForSubscriptionId(mSubId);
|
||||
mNetworkScanHelper = new NetworkScanHelper(
|
||||
mTelephonyManager, mCallback, mNetworkScanExecutor);
|
||||
PersistableBundle bundle = (getContext().getSystemService(
|
||||
CarrierConfigManager.class)).getConfigForSubId(mSubId);
|
||||
PersistableBundle bundle = ((CarrierConfigManager) getContext().getSystemService(
|
||||
Context.CARRIER_CONFIG_SERVICE)).getConfigForSubId(mSubId);
|
||||
if (bundle != null) {
|
||||
mShow4GForLTE = bundle.getBoolean(
|
||||
CarrierConfigManager.KEY_SHOW_4G_FOR_LTE_DATA_ICON_BOOL);
|
||||
|
||||
@@ -212,8 +212,8 @@ public class RenameMobileNetworkDialogFragment extends InstrumentedDialogFragmen
|
||||
|
||||
@Override
|
||||
public View getView(int position, View convertView, ViewGroup parent) {
|
||||
final LayoutInflater inflater =
|
||||
mContext.getSystemService(LayoutInflater.class);
|
||||
final LayoutInflater inflater = (LayoutInflater)
|
||||
mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
||||
|
||||
if (convertView == null) {
|
||||
convertView = inflater.inflate(mItemResId, null);
|
||||
|
||||
@@ -72,7 +72,7 @@ public class RecentConversationsPreferenceController extends AbstractPreferenceC
|
||||
return true;
|
||||
}
|
||||
|
||||
Preference getClearAll(PreferenceGroup parent) {
|
||||
LayoutPreference getClearAll(PreferenceGroup parent) {
|
||||
LayoutPreference pref = new LayoutPreference(
|
||||
mContext, R.layout.conversations_clear_recents);
|
||||
pref.setOrder(1);
|
||||
@@ -80,10 +80,21 @@ public class RecentConversationsPreferenceController extends AbstractPreferenceC
|
||||
button.setOnClickListener(v -> {
|
||||
try {
|
||||
mPs.removeAllRecentConversations();
|
||||
// Removing recents is asynchronous, so we can't immediately reload the list from
|
||||
// the backend. Instead, proactively remove all of items that were marked as
|
||||
// clearable, so long as we didn't get an error
|
||||
|
||||
for (int i = parent.getPreferenceCount() - 1; i >= 0; i--) {
|
||||
Preference p = parent.getPreference(i);
|
||||
if (p instanceof RecentConversationPreference) {
|
||||
if (((RecentConversationPreference) p).hasClearListener()) {
|
||||
parent.removePreference(p);
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (RemoteException e) {
|
||||
Slog.w(TAG, "Could not clear recents", e);
|
||||
}
|
||||
updateState(parent);
|
||||
});
|
||||
return pref;
|
||||
}
|
||||
@@ -118,36 +129,45 @@ public class RecentConversationsPreferenceController extends AbstractPreferenceC
|
||||
protected void populateList(List<ConversationChannel> conversations,
|
||||
PreferenceGroup containerGroup) {
|
||||
containerGroup.removeAll();
|
||||
boolean hasClearable = false;
|
||||
if (conversations != null) {
|
||||
populateConversations(conversations, containerGroup);
|
||||
hasClearable = populateConversations(conversations, containerGroup);
|
||||
}
|
||||
|
||||
if (containerGroup.getPreferenceCount() == 0) {
|
||||
containerGroup.setVisible(false);
|
||||
} else {
|
||||
containerGroup.setVisible(true);
|
||||
Preference clearAll = getClearAll(containerGroup);
|
||||
if (clearAll != null) {
|
||||
containerGroup.addPreference(clearAll);
|
||||
if (hasClearable) {
|
||||
Preference clearAll = getClearAll(containerGroup);
|
||||
if (clearAll != null) {
|
||||
containerGroup.addPreference(clearAll);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected void populateConversations(List<ConversationChannel> conversations,
|
||||
protected boolean populateConversations(List<ConversationChannel> conversations,
|
||||
PreferenceGroup containerGroup) {
|
||||
int order = 100;
|
||||
boolean hasClearable = false;
|
||||
for (ConversationChannel conversation : conversations) {
|
||||
if (conversation.getParentNotificationChannel().getImportance() == IMPORTANCE_NONE
|
||||
|| (conversation.getParentNotificationChannelGroup() != null
|
||||
&& conversation.getParentNotificationChannelGroup().isBlocked())) {
|
||||
continue;
|
||||
}
|
||||
containerGroup.addPreference(
|
||||
createConversationPref(containerGroup, conversation, order++));
|
||||
RecentConversationPreference pref =
|
||||
createConversationPref(containerGroup, conversation, order++);
|
||||
containerGroup.addPreference(pref);
|
||||
if (pref.hasClearListener()) {
|
||||
hasClearable = true;
|
||||
}
|
||||
}
|
||||
return hasClearable;
|
||||
}
|
||||
|
||||
protected Preference createConversationPref(PreferenceGroup parent,
|
||||
protected RecentConversationPreference createConversationPref(PreferenceGroup parent,
|
||||
final ConversationChannel conversation, int order) {
|
||||
final String pkg = conversation.getShortcutInfo().getPackage();
|
||||
final int uid = conversation.getUid();
|
||||
|
||||
@@ -34,6 +34,7 @@ import android.content.pm.ApplicationInfo;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.content.res.Configuration;
|
||||
import android.graphics.PorterDuff;
|
||||
import android.graphics.PorterDuffColorFilter;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.os.UserHandle;
|
||||
import android.os.UserManager;
|
||||
@@ -110,6 +111,7 @@ public class NotificationSbnAdapter extends
|
||||
int position) {
|
||||
final StatusBarNotification sbn = mValues.get(position);
|
||||
if (sbn != null) {
|
||||
holder.setIconBackground(loadBackground(sbn));
|
||||
holder.setIcon(loadIcon(sbn));
|
||||
holder.setPackageLabel(loadPackageLabel(sbn.getPackageName()).toString());
|
||||
holder.setTitle(getTitleString(sbn.getNotification()));
|
||||
@@ -140,6 +142,19 @@ public class NotificationSbnAdapter extends
|
||||
}
|
||||
}
|
||||
|
||||
private Drawable loadBackground(StatusBarNotification sbn) {
|
||||
Drawable bg = mContext.getDrawable(R.drawable.circle);
|
||||
int color = sbn.getNotification().color;
|
||||
if (color == COLOR_DEFAULT) {
|
||||
color = Utils.getColorAttrDefaultColor(
|
||||
mContext, com.android.internal.R.attr.colorAccent);
|
||||
}
|
||||
color = ContrastColorUtil.resolveContrastColor(
|
||||
mContext, color, mBackgroundColor, mInNightMode);
|
||||
bg.setColorFilter(new PorterDuffColorFilter(color, PorterDuff.Mode.SRC_ATOP));
|
||||
return bg;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return mValues.size();
|
||||
@@ -229,7 +244,7 @@ public class NotificationSbnAdapter extends
|
||||
return null;
|
||||
}
|
||||
draw.mutate();
|
||||
draw.setColorFilter(getContrastedColor(sbn.getNotification()), PorterDuff.Mode.SRC_ATOP);
|
||||
draw.setColorFilter(mBackgroundColor, PorterDuff.Mode.SRC_ATOP);
|
||||
return draw;
|
||||
}
|
||||
|
||||
@@ -240,13 +255,4 @@ public class NotificationSbnAdapter extends
|
||||
}
|
||||
return userId;
|
||||
}
|
||||
|
||||
private int getContrastedColor(Notification n) {
|
||||
int rawColor = n.color;
|
||||
if (rawColor != COLOR_DEFAULT) {
|
||||
rawColor |= 0xFF000000; // no alpha for custom colors
|
||||
}
|
||||
return ContrastColorUtil.resolveContrastColor(
|
||||
mContext, rawColor, mBackgroundColor, mInNightMode);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -75,6 +75,10 @@ public class NotificationSbnViewHolder extends RecyclerView.ViewHolder {
|
||||
mIcon.setImageDrawable(icon);
|
||||
}
|
||||
|
||||
void setIconBackground(Drawable background) {
|
||||
mIcon.setBackground(background);
|
||||
}
|
||||
|
||||
void setPackageLabel(String pkg) {
|
||||
mPkgName.setText(pkg);
|
||||
}
|
||||
|
||||
@@ -32,6 +32,7 @@ import android.util.Pair;
|
||||
import android.util.TypedValue;
|
||||
import android.view.KeyEvent;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.Surface;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ScrollView;
|
||||
@@ -508,6 +509,12 @@ public class ChooseLockPattern extends SettingsActivity {
|
||||
Bundle savedInstanceState) {
|
||||
final GlifLayout layout = (GlifLayout) inflater.inflate(
|
||||
R.layout.choose_lock_pattern, container, false);
|
||||
switch(getContext().getDisplay().getRotation()) {
|
||||
case Surface.ROTATION_90:
|
||||
case Surface.ROTATION_270:
|
||||
layout.setLandscapeHeaderAreaVisible(false /* visible */);
|
||||
break;
|
||||
}
|
||||
layout.setHeaderText(getActivity().getTitle());
|
||||
if (getResources().getBoolean(R.bool.config_lock_pattern_minimal_ui)) {
|
||||
View iconView = layout.findViewById(R.id.sud_layout_icon);
|
||||
|
||||
@@ -28,6 +28,7 @@ import android.os.UserManager;
|
||||
import android.os.storage.StorageManager;
|
||||
import android.text.TextUtils;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.Surface;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.animation.AnimationUtils;
|
||||
@@ -45,6 +46,8 @@ import com.android.settingslib.animation.AppearAnimationCreator;
|
||||
import com.android.settingslib.animation.AppearAnimationUtils;
|
||||
import com.android.settingslib.animation.DisappearAnimationUtils;
|
||||
|
||||
import com.google.android.setupdesign.GlifLayout;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
@@ -90,8 +93,7 @@ public class ConfirmLockPattern extends ConfirmDeviceCredentialBaseActivity {
|
||||
private boolean mDisappearing = false;
|
||||
private CountDownTimer mCountdownTimer;
|
||||
|
||||
private TextView mHeaderTextView;
|
||||
private TextView mDetailsTextView;
|
||||
private GlifLayout mGlifLayout;
|
||||
|
||||
// caller-supplied text for various prompts
|
||||
private CharSequence mHeaderText;
|
||||
@@ -117,9 +119,14 @@ public class ConfirmLockPattern extends ConfirmDeviceCredentialBaseActivity {
|
||||
: R.layout.confirm_lock_pattern,
|
||||
container,
|
||||
false);
|
||||
mHeaderTextView = (TextView) view.findViewById(R.id.headerText);
|
||||
mGlifLayout = view.findViewById(R.id.setup_wizard_layout);
|
||||
switch(getContext().getDisplay().getRotation()) {
|
||||
case Surface.ROTATION_90:
|
||||
case Surface.ROTATION_270:
|
||||
mGlifLayout.setLandscapeHeaderAreaVisible(false /* visible */);
|
||||
break;
|
||||
}
|
||||
mLockPatternView = (LockPatternView) view.findViewById(R.id.lockPattern);
|
||||
mDetailsTextView = (TextView) view.findViewById(R.id.sud_layout_description);
|
||||
mErrorTextView = (TextView) view.findViewById(R.id.errorText);
|
||||
|
||||
mIsManagedProfile = UserManager.get(getActivity()).isManagedProfile(mEffectiveUserId);
|
||||
@@ -177,7 +184,7 @@ public class ConfirmLockPattern extends ConfirmDeviceCredentialBaseActivity {
|
||||
return (float)(numRows - row) / numRows;
|
||||
}
|
||||
});
|
||||
setAccessibilityTitle(mHeaderTextView.getText());
|
||||
setAccessibilityTitle(mGlifLayout.getHeaderText());
|
||||
|
||||
mCredentialCheckResultTracker = (CredentialCheckResultTracker) getFragmentManager()
|
||||
.findFragmentByTag(FRAGMENT_TAG_CHECK_LOCK_RESULT);
|
||||
@@ -242,13 +249,13 @@ public class ConfirmLockPattern extends ConfirmDeviceCredentialBaseActivity {
|
||||
@Override
|
||||
public void prepareEnterAnimation() {
|
||||
super.prepareEnterAnimation();
|
||||
mHeaderTextView.setAlpha(0f);
|
||||
mGlifLayout.getHeaderTextView().setAlpha(0f);
|
||||
mCancelButton.setAlpha(0f);
|
||||
if (mForgotButton != null) {
|
||||
mForgotButton.setAlpha(0f);
|
||||
}
|
||||
mLockPatternView.setAlpha(0f);
|
||||
mDetailsTextView.setAlpha(0f);
|
||||
mGlifLayout.getDescriptionTextView().setAlpha(0f);
|
||||
}
|
||||
|
||||
private int getDefaultDetails() {
|
||||
@@ -269,8 +276,9 @@ public class ConfirmLockPattern extends ConfirmDeviceCredentialBaseActivity {
|
||||
|
||||
private Object[][] getActiveViews() {
|
||||
ArrayList<ArrayList<Object>> result = new ArrayList<>();
|
||||
result.add(new ArrayList<>(Collections.singletonList(mHeaderTextView)));
|
||||
result.add(new ArrayList<>(Collections.singletonList(mDetailsTextView)));
|
||||
result.add(new ArrayList<>(Collections.singletonList(mGlifLayout.getHeaderTextView())));
|
||||
result.add(new ArrayList<>(
|
||||
Collections.singletonList(mGlifLayout.getDescriptionTextView())));
|
||||
if (mCancelButton.getVisibility() == View.VISIBLE) {
|
||||
result.add(new ArrayList<>(Collections.singletonList(mCancelButton)));
|
||||
}
|
||||
@@ -306,14 +314,14 @@ public class ConfirmLockPattern extends ConfirmDeviceCredentialBaseActivity {
|
||||
switch (stage) {
|
||||
case NeedToUnlock:
|
||||
if (mHeaderText != null) {
|
||||
mHeaderTextView.setText(mHeaderText);
|
||||
mGlifLayout.setHeaderText(mHeaderText);
|
||||
} else {
|
||||
mHeaderTextView.setText(getDefaultHeader());
|
||||
mGlifLayout.setHeaderText(getDefaultHeader());
|
||||
}
|
||||
if (mDetailsText != null) {
|
||||
mDetailsTextView.setText(mDetailsText);
|
||||
mGlifLayout.setDescriptionText(mDetailsText);
|
||||
} else {
|
||||
mDetailsTextView.setText(getDefaultDetails());
|
||||
mGlifLayout.setDescriptionText(getDefaultDetails());
|
||||
}
|
||||
mErrorTextView.setText("");
|
||||
updateErrorMessage(
|
||||
@@ -341,7 +349,7 @@ public class ConfirmLockPattern extends ConfirmDeviceCredentialBaseActivity {
|
||||
|
||||
// Always announce the header for accessibility. This is a no-op
|
||||
// when accessibility is disabled.
|
||||
mHeaderTextView.announceForAccessibility(mHeaderTextView.getText());
|
||||
mGlifLayout.getHeaderTextView().announceForAccessibility(mGlifLayout.getHeaderText());
|
||||
}
|
||||
|
||||
private int getDefaultHeader() {
|
||||
|
||||
@@ -25,6 +25,7 @@ import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.RelativeLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
@@ -61,6 +62,7 @@ public class CredentialManagementAppAdapter extends RecyclerView.Adapter<Recycle
|
||||
|
||||
private final boolean mIncludeHeader;
|
||||
private final boolean mIncludeExpander;
|
||||
private final boolean mIsLayoutRtl;
|
||||
|
||||
/**
|
||||
* View holder for the header in the request manage credentials screen.
|
||||
@@ -113,6 +115,15 @@ public class CredentialManagementAppAdapter extends RecyclerView.Adapter<Recycle
|
||||
mChildRecyclerView = view.findViewById(R.id.uris);
|
||||
mExpandedApps = new ArrayList<>();
|
||||
|
||||
if (mIsLayoutRtl) {
|
||||
RelativeLayout appDetails = view.findViewById(R.id.app_details);
|
||||
RelativeLayout.LayoutParams params =
|
||||
(RelativeLayout.LayoutParams) appDetails.getLayoutParams();
|
||||
params.addRule(RelativeLayout.LEFT_OF, R.id.app_icon);
|
||||
params.addRule(RelativeLayout.RIGHT_OF, R.id.expand);
|
||||
view.setLayoutParams(params);
|
||||
}
|
||||
|
||||
mExpanderIconView.setOnClickListener(view1 -> {
|
||||
final String appName = mSortedAppNames.get(getBindingAdapterPosition());
|
||||
if (mExpandedApps.contains(appName)) {
|
||||
@@ -195,6 +206,8 @@ public class CredentialManagementAppAdapter extends RecyclerView.Adapter<Recycle
|
||||
mViewPool = new RecyclerView.RecycledViewPool();
|
||||
mIncludeHeader = includeHeader;
|
||||
mIncludeExpander = includeExpander;
|
||||
mIsLayoutRtl = context.getResources().getConfiguration().getLayoutDirection()
|
||||
== View.LAYOUT_DIRECTION_RTL;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -104,8 +104,8 @@ public class SimSelectNotification extends BroadcastReceiver {
|
||||
subId = SubscriptionManager.getDefaultSmsSubscriptionId();
|
||||
}
|
||||
|
||||
SubscriptionManager subscriptionManager = (context.getSystemService(
|
||||
SubscriptionManager.class));
|
||||
SubscriptionManager subscriptionManager = ((SubscriptionManager) context.getSystemService(
|
||||
Context.TELEPHONY_SUBSCRIPTION_SERVICE));
|
||||
if (!subscriptionManager.isActiveSubscriptionId(subId)) {
|
||||
Log.w(TAG, "onEnableMmsDataRequest invalid sub ID " + subId);
|
||||
return;
|
||||
@@ -130,8 +130,8 @@ public class SimSelectNotification extends BroadcastReceiver {
|
||||
return;
|
||||
}
|
||||
|
||||
TelephonyManager tm = (context.getSystemService(
|
||||
TelephonyManager.class)).createForSubscriptionId(subId);
|
||||
TelephonyManager tm = ((TelephonyManager) context.getSystemService(
|
||||
Context.TELEPHONY_SERVICE)).createForSubscriptionId(subId);
|
||||
|
||||
if (tm.isDataEnabledForApn(TYPE_MMS)) {
|
||||
Log.w(TAG, "onEnableMmsDataRequest MMS data already enabled on sub ID " + subId);
|
||||
@@ -230,14 +230,14 @@ public class SimSelectNotification extends BroadcastReceiver {
|
||||
PendingIntent.FLAG_CANCEL_CURRENT | PendingIntent.FLAG_IMMUTABLE);
|
||||
builder.setContentIntent(resultPendingIntent);
|
||||
NotificationManager notificationManager =
|
||||
context.getSystemService(NotificationManager.class);
|
||||
(NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
|
||||
notificationManager.createNotificationChannel(notificationChannel);
|
||||
notificationManager.notify(SIM_SELECT_NOTIFICATION_ID, builder.build());
|
||||
}
|
||||
|
||||
public static void cancelSimSelectNotification(Context context) {
|
||||
NotificationManager notificationManager =
|
||||
context.getSystemService(NotificationManager.class);
|
||||
(NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
|
||||
notificationManager.cancel(SIM_SELECT_NOTIFICATION_ID);
|
||||
}
|
||||
|
||||
@@ -270,14 +270,14 @@ public class SimSelectNotification extends BroadcastReceiver {
|
||||
|
||||
// Notify the notification.
|
||||
NotificationManager notificationManager =
|
||||
context.getSystemService(NotificationManager.class);
|
||||
(NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
|
||||
notificationManager.createNotificationChannel(notificationChannel);
|
||||
notificationManager.notify(ENABLE_MMS_NOTIFICATION_ID, builder.build());
|
||||
}
|
||||
|
||||
private void cancelEnableMmsNotification(Context context) {
|
||||
NotificationManager notificationManager =
|
||||
context.getSystemService(NotificationManager.class);
|
||||
(NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
|
||||
notificationManager.cancel(ENABLE_MMS_NOTIFICATION_ID);
|
||||
}
|
||||
|
||||
|
||||
@@ -319,7 +319,7 @@ public class AppManagementFragment extends SettingsPreferenceFragment
|
||||
@VisibleForTesting
|
||||
static boolean appHasVpnPermission(Context context, @NonNull ApplicationInfo application) {
|
||||
final AppOpsManager service =
|
||||
context.getSystemService(AppOpsManager.class);
|
||||
(AppOpsManager) context.getSystemService(Context.APP_OPS_SERVICE);
|
||||
final List<AppOpsManager.PackageOps> ops = service.getOpsForPackage(application.uid,
|
||||
application.packageName, new int[]{OP_ACTIVATE_VPN, OP_ACTIVATE_PLATFORM_VPN});
|
||||
return !ArrayUtils.isEmpty(ops);
|
||||
|
||||
@@ -116,9 +116,9 @@ public class VpnSettings extends RestrictedSettingsFragment implements
|
||||
public void onActivityCreated(Bundle savedInstanceState) {
|
||||
super.onActivityCreated(savedInstanceState);
|
||||
|
||||
mUserManager = getSystemService(UserManager.class);
|
||||
mConnectivityManager = getSystemService(ConnectivityManager.class);
|
||||
mVpnManager = getSystemService(VpnManager.class);
|
||||
mUserManager = (UserManager) getSystemService(Context.USER_SERVICE);
|
||||
mConnectivityManager = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
|
||||
mVpnManager = (VpnManager) getSystemService(Context.VPN_MANAGEMENT_SERVICE);
|
||||
|
||||
mUnavailable = isUiRestricted();
|
||||
setHasOptionsMenu(!mUnavailable);
|
||||
@@ -511,7 +511,7 @@ public class VpnSettings extends RestrictedSettingsFragment implements
|
||||
}
|
||||
|
||||
// Fetch VPN-enabled apps from AppOps.
|
||||
AppOpsManager aom = context.getSystemService(AppOpsManager.class);
|
||||
AppOpsManager aom = (AppOpsManager) context.getSystemService(Context.APP_OPS_SERVICE);
|
||||
List<AppOpsManager.PackageOps> apps =
|
||||
aom.getPackagesForOps(new int[] {OP_ACTIVATE_VPN, OP_ACTIVATE_PLATFORM_VPN});
|
||||
if (apps != null) {
|
||||
|
||||
@@ -49,7 +49,7 @@ public class ChangeWifiStateDetails extends AppInfoWithHeader
|
||||
super.onCreate(savedInstanceState);
|
||||
final Context context = getActivity();
|
||||
mAppBridge = new AppStateChangeWifiStateBridge(context, mState, null);
|
||||
mAppOpsManager = context.getSystemService(AppOpsManager.class);
|
||||
mAppOpsManager = (AppOpsManager) context.getSystemService(Context.APP_OPS_SERVICE);
|
||||
|
||||
// find preferences
|
||||
addPreferencesFromResource(R.xml.change_wifi_state_details);
|
||||
|
||||
@@ -69,7 +69,7 @@ public class ConfigureWifiSettings extends DashboardFragment {
|
||||
|
||||
@Override
|
||||
protected List<AbstractPreferenceController> createPreferenceControllers(Context context) {
|
||||
final WifiManager wifiManager = getSystemService(WifiManager.class);
|
||||
final WifiManager wifiManager = (WifiManager) getSystemService(WIFI_SERVICE);
|
||||
final List<AbstractPreferenceController> controllers = new ArrayList<>();
|
||||
controllers.add(new WifiP2pPreferenceController(context, getSettingsLifecycle(),
|
||||
wifiManager));
|
||||
|
||||
@@ -51,7 +51,7 @@ public class UseOpenWifiPreferenceController extends TogglePreferenceController
|
||||
super(context, KEY_USE_OPEN_WIFI_AUTOMATICALLY);
|
||||
mContentResolver = context.getContentResolver();
|
||||
mNetworkScoreManager =
|
||||
context.getSystemService(NetworkScoreManager.class);
|
||||
(NetworkScoreManager) context.getSystemService(Context.NETWORK_SCORE_SERVICE);
|
||||
mSettingObserver = new SettingObserver();
|
||||
updateEnableUseWifiComponentName();
|
||||
checkForFeatureSupportedScorers();
|
||||
|
||||
@@ -64,7 +64,7 @@ public class WifiAPITest extends SettingsPreferenceFragment implements
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
mWifiManager = getSystemService(WifiManager.class);
|
||||
mWifiManager = (WifiManager) getSystemService(WIFI_SERVICE);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -38,7 +38,7 @@ public class WifiConfigInfo extends Activity {
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
mWifiManager = getSystemService(WifiManager.class);
|
||||
mWifiManager = (WifiManager) getSystemService(WIFI_SERVICE);
|
||||
setContentView(R.layout.wifi_config_info);
|
||||
mConfigList = (TextView) findViewById(R.id.config_list);
|
||||
}
|
||||
|
||||
@@ -75,7 +75,7 @@ public class WifiEnabler implements SwitchWidgetController.OnSwitchChangeListene
|
||||
public WifiEnabler(Context context, SwitchWidgetController switchWidget,
|
||||
MetricsFeatureProvider metricsFeatureProvider) {
|
||||
this(context, switchWidget, metricsFeatureProvider,
|
||||
context.getSystemService(ConnectivityManager.class));
|
||||
(ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE));
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
@@ -86,7 +86,7 @@ public class WifiEnabler implements SwitchWidgetController.OnSwitchChangeListene
|
||||
mSwitchWidget = switchWidget;
|
||||
mSwitchWidget.setListener(this);
|
||||
mMetricsFeatureProvider = metricsFeatureProvider;
|
||||
mWifiManager = context.getSystemService(WifiManager.class);
|
||||
mWifiManager = (WifiManager) context.getSystemService(Context.WIFI_SERVICE);
|
||||
mConnectivityManager = connectivityManager;
|
||||
|
||||
mIntentFilter = new IntentFilter(WifiManager.WIFI_STATE_CHANGED_ACTION);
|
||||
|
||||
@@ -107,7 +107,7 @@ public class WifiNoInternetDialog extends AlertActivity implements
|
||||
}
|
||||
};
|
||||
|
||||
mCM = getSystemService(ConnectivityManager.class);
|
||||
mCM = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
|
||||
mCM.registerNetworkCallback(request, mNetworkCallback);
|
||||
|
||||
final NetworkInfo ni = mCM.getNetworkInfo(mNetwork);
|
||||
|
||||
@@ -63,7 +63,7 @@ import com.android.settings.core.FeatureFlags;
|
||||
import com.android.settings.core.SubSettingLauncher;
|
||||
import com.android.settings.datausage.DataUsagePreference;
|
||||
import com.android.settings.datausage.DataUsageUtils;
|
||||
import com.android.settings.location.LocationServices;
|
||||
import com.android.settings.location.WifiScanningFragment;
|
||||
import com.android.settings.overlay.FeatureFactory;
|
||||
import com.android.settings.search.BaseSearchIndexProvider;
|
||||
import com.android.settings.widget.MainSwitchBarController;
|
||||
@@ -921,8 +921,8 @@ public class WifiSettings extends RestrictedSettingsFragment
|
||||
: getText(R.string.wifi_scan_notify_text_scanning_off);
|
||||
final LinkifyUtils.OnClickListener clickListener =
|
||||
() -> new SubSettingLauncher(getContext())
|
||||
.setDestination(LocationServices.class.getName())
|
||||
.setTitleRes(R.string.location_services_screen_title)
|
||||
.setDestination(WifiScanningFragment.class.getName())
|
||||
.setTitleRes(R.string.location_scanning_wifi_always_scanning_title)
|
||||
.setSourceMetricsCategory(getMetricsCategory())
|
||||
.launch();
|
||||
mStatusMessagePreference.setText(title, description, clickListener);
|
||||
|
||||
@@ -116,7 +116,7 @@ public class WifiStatusTest extends Activity {
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
mWifiManager = getSystemService(WifiManager.class);
|
||||
mWifiManager = (WifiManager) getSystemService(WIFI_SERVICE);
|
||||
|
||||
mWifiStateFilter = new IntentFilter(WifiManager.WIFI_STATE_CHANGED_ACTION);
|
||||
mWifiStateFilter.addAction(WifiManager.NETWORK_STATE_CHANGED_ACTION);
|
||||
|
||||
@@ -83,7 +83,7 @@ public class WifiUtils {
|
||||
final DevicePolicyManager dpm =
|
||||
(DevicePolicyManager) context.getSystemService(Context.DEVICE_POLICY_SERVICE);
|
||||
final PackageManager pm = context.getPackageManager();
|
||||
final UserManager um = context.getSystemService(UserManager.class);
|
||||
final UserManager um = (UserManager) context.getSystemService(Context.USER_SERVICE);
|
||||
|
||||
// Check if device has DPM capability. If it has and dpm is still null, then we
|
||||
// treat this case with suspicion and bail out.
|
||||
|
||||
@@ -73,7 +73,7 @@ public class WifiWakeupPreferenceController extends TogglePreferenceController i
|
||||
|
||||
public WifiWakeupPreferenceController(Context context) {
|
||||
super(context, KEY_ENABLE_WIFI_WAKEUP);
|
||||
mLocationManager = context.getSystemService(LocationManager.class);
|
||||
mLocationManager = (LocationManager) context.getSystemService(Service.LOCATION_SERVICE);
|
||||
mWifiManager = context.getSystemService(WifiManager.class);
|
||||
}
|
||||
|
||||
|
||||
@@ -128,8 +128,8 @@ public class WifiCallingSettingsForSub extends SettingsPreferenceFragment
|
||||
|
||||
boolean isWfcModeEditable = true;
|
||||
boolean isWfcRoamingModeEditable = false;
|
||||
final CarrierConfigManager configManager =
|
||||
activity.getSystemService(CarrierConfigManager.class);
|
||||
final CarrierConfigManager configManager = (CarrierConfigManager)
|
||||
activity.getSystemService(Context.CARRIER_CONFIG_SERVICE);
|
||||
if (configManager != null) {
|
||||
PersistableBundle b =
|
||||
configManager.getConfigForSubId(WifiCallingSettingsForSub.this.mSubId);
|
||||
@@ -343,8 +343,8 @@ public class WifiCallingSettingsForSub extends SettingsPreferenceFragment
|
||||
return;
|
||||
}
|
||||
|
||||
final CarrierConfigManager configManager =
|
||||
getSystemService(CarrierConfigManager.class);
|
||||
final CarrierConfigManager configManager = (CarrierConfigManager)
|
||||
getSystemService(Context.CARRIER_CONFIG_SERVICE);
|
||||
boolean isWifiOnlySupported = true;
|
||||
|
||||
if (configManager != null) {
|
||||
|
||||
@@ -42,7 +42,7 @@ public class AddDevicePreferenceController2 extends BasePreferenceController {
|
||||
public AddDevicePreferenceController2(Context context) {
|
||||
super(context, KEY_ADD_DEVICE);
|
||||
|
||||
mWifiManager = context.getSystemService(WifiManager.class);
|
||||
mWifiManager = (WifiManager) context.getSystemService(Context.WIFI_SERVICE);
|
||||
}
|
||||
|
||||
public void setWifiEntry(WifiEntry wifiEntry) {
|
||||
|
||||
@@ -143,8 +143,8 @@ public class WifiNetworkDetailsFragment2 extends DashboardFragment implements
|
||||
if (admin == null) {
|
||||
final DevicePolicyManager dpm = (DevicePolicyManager)
|
||||
getContext().getSystemService(Context.DEVICE_POLICY_SERVICE);
|
||||
final UserManager um =
|
||||
getContext().getSystemService(UserManager.class);
|
||||
final UserManager um = (UserManager)
|
||||
getContext().getSystemService(Context.USER_SERVICE);
|
||||
final int profileOwnerUserId = Utils.getManagedProfileId(
|
||||
um, UserHandle.myUserId());
|
||||
if (profileOwnerUserId != UserHandle.USER_NULL) {
|
||||
|
||||
@@ -45,7 +45,7 @@ public class WifiPrivacyPreferenceController2 extends BasePreferenceController i
|
||||
public WifiPrivacyPreferenceController2(Context context) {
|
||||
super(context, KEY_WIFI_PRIVACY);
|
||||
|
||||
mWifiManager = context.getSystemService(WifiManager.class);
|
||||
mWifiManager = (WifiManager) context.getSystemService(Context.WIFI_SERVICE);
|
||||
}
|
||||
|
||||
public void setWifiEntry(WifiEntry wifiEntry) {
|
||||
|
||||
@@ -373,8 +373,8 @@ public class WifiDppUtils {
|
||||
* device security or if lock screen is unlocked
|
||||
*/
|
||||
public static void showLockScreen(Context context, Runnable successRunnable) {
|
||||
final KeyguardManager keyguardManager = context.getSystemService(
|
||||
KeyguardManager.class);
|
||||
final KeyguardManager keyguardManager = (KeyguardManager) context.getSystemService(
|
||||
Context.KEYGUARD_SERVICE);
|
||||
|
||||
if (keyguardManager.isKeyguardSecure()) {
|
||||
final BiometricPrompt.AuthenticationCallback authenticationCallback =
|
||||
|
||||
@@ -71,7 +71,7 @@ public class WifiP2pPreferenceController extends AbstractPreferenceController
|
||||
super(context);
|
||||
mWifiManager = wifiManager;
|
||||
lifecycle.addObserver(this);
|
||||
mLocationManager = context.getSystemService(LocationManager.class);
|
||||
mLocationManager = (LocationManager) context.getSystemService(Service.LOCATION_SERVICE);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -200,7 +200,7 @@ public class WifiP2pSettings extends DashboardFragment
|
||||
public void onActivityCreated(Bundle savedInstanceState) {
|
||||
final Activity activity = getActivity();
|
||||
if (mWifiP2pManager == null) {
|
||||
mWifiP2pManager = getSystemService(WifiP2pManager.class);
|
||||
mWifiP2pManager = (WifiP2pManager) getSystemService(Context.WIFI_P2P_SERVICE);
|
||||
}
|
||||
|
||||
if (mWifiP2pManager != null) {
|
||||
|
||||
@@ -202,7 +202,7 @@ public class QrCamera extends Handler {
|
||||
}
|
||||
|
||||
final WindowManager winManager =
|
||||
mContext.get().getSystemService(WindowManager.class);
|
||||
(WindowManager) mContext.get().getSystemService(Context.WINDOW_SERVICE);
|
||||
final int rotation = winManager.getDefaultDisplay().getRotation();
|
||||
int degrees = 0;
|
||||
switch (rotation) {
|
||||
|
||||
@@ -164,7 +164,7 @@ public class WifiSlice implements CustomSliceable {
|
||||
return rowBuilder;
|
||||
}
|
||||
|
||||
private IconCompat getWifiSliceItemLevelIcon(WifiSliceItem wifiSliceItem) {
|
||||
protected IconCompat getWifiSliceItemLevelIcon(WifiSliceItem wifiSliceItem) {
|
||||
final @ColorInt int tint;
|
||||
if (wifiSliceItem.getConnectedState() == WifiEntry.CONNECTED_STATE_CONNECTED) {
|
||||
tint = Utils.getColorAccentDefaultColor(mContext);
|
||||
|
||||
@@ -255,7 +255,7 @@ public class TetherService extends Service {
|
||||
}
|
||||
|
||||
private void disableTethering(final int tetheringType) {
|
||||
final TetheringManager tm = getSystemService(TetheringManager.class);
|
||||
final TetheringManager tm = (TetheringManager) getSystemService(Context.TETHERING_SERVICE);
|
||||
tm.stopTethering(tetheringType);
|
||||
}
|
||||
|
||||
|
||||
@@ -63,7 +63,7 @@ public class WifiTetherPreferenceController extends AbstractPreferenceController
|
||||
boolean initSoftApManager) {
|
||||
super(context);
|
||||
mTetheringManager = context.getSystemService(TetheringManager.class);
|
||||
mWifiManager = context.getSystemService(WifiManager.class);
|
||||
mWifiManager = (WifiManager) context.getSystemService(Context.WIFI_SERVICE);
|
||||
mWifiRegexs = mTetheringManager.getTetherableWifiRegexs();
|
||||
mLifecycle = lifecycle;
|
||||
if (lifecycle != null) {
|
||||
|
||||
@@ -110,7 +110,7 @@ public class WifiTetherSettings extends RestrictedDashboardFragment
|
||||
@Override
|
||||
public void onAttach(Context context) {
|
||||
super.onAttach(context);
|
||||
mWifiManager = context.getSystemService(WifiManager.class);
|
||||
mWifiManager = (WifiManager) context.getSystemService(Context.WIFI_SERVICE);
|
||||
mTetherChangeReceiver = new TetherChangeReceiver();
|
||||
|
||||
mSSIDPreferenceController = use(WifiTetherSSIDPreferenceController.class);
|
||||
|
||||
@@ -73,8 +73,8 @@ public class WifiTetherSwitchBarController implements
|
||||
mSwitch = mSwitchBar.getSwitch();
|
||||
mDataSaverBackend = new DataSaverBackend(context);
|
||||
mConnectivityManager =
|
||||
context.getSystemService(ConnectivityManager.class);
|
||||
mWifiManager = context.getSystemService(WifiManager.class);
|
||||
(ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
|
||||
mWifiManager = (WifiManager) context.getSystemService(Context.WIFI_SERVICE);
|
||||
mSwitchBar.setChecked(mWifiManager.getWifiApState() == WifiManager.WIFI_AP_STATE_ENABLED);
|
||||
updateWifiSwitch();
|
||||
}
|
||||
|
||||
@@ -92,4 +92,23 @@ public class TimeZoneDataTest {
|
||||
.containsExactly("US", "GB");
|
||||
assertThat(timeZoneData.lookupCountryCodesForZoneId("Unknown/Secret_City2")).isEmpty();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void lookupCountryCodesForNonCanonicalZoneId_returnsCurrentZone() {
|
||||
TimeZoneData timeZoneData = new TimeZoneData(mCountryZonesFinder);
|
||||
|
||||
CountryTimeZones greenland = mock(CountryTimeZones.class);
|
||||
when(greenland.getCountryIso()).thenReturn("gl");
|
||||
when(greenland.getTimeZoneMappings()).thenReturn(Arrays.asList(
|
||||
TimeZoneMapping.createForTests(
|
||||
"America/Nuuk",
|
||||
true /* showInPicker */,
|
||||
null /* notUsedAfter */,
|
||||
Arrays.asList("America/Godthab"))));
|
||||
when(mCountryZonesFinder.lookupCountryTimeZonesForZoneId("America/Godthab"))
|
||||
.thenReturn(Arrays.asList(greenland));
|
||||
|
||||
assertThat(timeZoneData.lookupCountryCodesForZoneId("America/Godthab"))
|
||||
.containsExactly("GL");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -181,8 +181,8 @@ public class ImeiInfoPreferenceControllerTest {
|
||||
|
||||
mController.copy();
|
||||
|
||||
final ClipboardManager clipboard = mContext.getSystemService(
|
||||
ClipboardManager.class);
|
||||
final ClipboardManager clipboard = (ClipboardManager) mContext.getSystemService(
|
||||
CLIPBOARD_SERVICE);
|
||||
final CharSequence data = clipboard.getPrimaryClip().getItemAt(0).getText();
|
||||
assertThat(data.toString()).isEqualTo(meid);
|
||||
}
|
||||
|
||||
@@ -22,12 +22,14 @@ import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.ArgumentMatchers.eq;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.never;
|
||||
import static org.mockito.Mockito.spy;
|
||||
import static org.mockito.Mockito.times;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
import android.content.ContentResolver;
|
||||
import android.content.Context;
|
||||
import android.content.res.Resources;
|
||||
import android.os.SystemProperties;
|
||||
import android.provider.Settings;
|
||||
|
||||
@@ -38,6 +40,7 @@ import androidx.preference.PreferenceScreen;
|
||||
|
||||
import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
|
||||
import com.android.internal.os.RoSystemProperties;
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.core.BasePreferenceController;
|
||||
import com.android.settings.deletionhelper.ActivationWarningFragment;
|
||||
import com.android.settings.overlay.FeatureFactory;
|
||||
@@ -67,13 +70,16 @@ public class AutomaticStorageManagementSwitchPreferenceControllerTest {
|
||||
private FragmentManager mFragmentManager;
|
||||
|
||||
private Context mContext;
|
||||
private Resources mResources;
|
||||
private AutomaticStorageManagementSwitchPreferenceController mController;
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
MockitoAnnotations.initMocks(this);
|
||||
mContext = RuntimeEnvironment.application.getApplicationContext();
|
||||
mContext = spy(RuntimeEnvironment.application.getApplicationContext());
|
||||
FeatureFactory.getFactory(mContext);
|
||||
mResources = spy(mContext.getResources());
|
||||
when(mContext.getResources()).thenReturn(mResources);
|
||||
|
||||
mController = new AutomaticStorageManagementSwitchPreferenceController(mContext, "testkey");
|
||||
mController.setFragmentManager(mFragmentManager);
|
||||
@@ -81,14 +87,27 @@ public class AutomaticStorageManagementSwitchPreferenceControllerTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void isAvailable_shouldReturnTrue_forHighRamDevice() {
|
||||
public void getAvailabilityStatus_configFalse_shouldUnsupportedOnDevice() {
|
||||
when(mResources.getBoolean(R.bool.config_show_smart_storage_toggle)).thenReturn(false);
|
||||
|
||||
assertThat(mController.isAvailable()).isFalse();
|
||||
assertThat(mController.getAvailabilityStatus()).isEqualTo(
|
||||
BasePreferenceController.UNSUPPORTED_ON_DEVICE);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getAvailabilityStatus_forHighRamDevice_shouldAvailable() {
|
||||
when(mResources.getBoolean(R.bool.config_show_smart_storage_toggle)).thenReturn(true);
|
||||
|
||||
assertThat(mController.isAvailable()).isTrue();
|
||||
assertThat(mController.getAvailabilityStatus()).isEqualTo(
|
||||
BasePreferenceController.AVAILABLE);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void isAvailable_shouldAlwaysReturnFalse_forLowRamDevice() {
|
||||
public void getAvailabilityStatus_forLowRamDevice_shouldUnsupportedOnDevice() {
|
||||
when(mResources.getBoolean(R.bool.config_show_smart_storage_toggle)).thenReturn(true);
|
||||
|
||||
ReflectionHelpers.setStaticField(RoSystemProperties.class, "CONFIG_LOW_RAM", true);
|
||||
assertThat(mController.isAvailable()).isFalse();
|
||||
assertThat(mController.getAvailabilityStatus()).isEqualTo(
|
||||
|
||||
@@ -104,6 +104,8 @@ public class StorageItemPreferenceControllerTest {
|
||||
}
|
||||
|
||||
private PreferenceScreen getPreferenceScreen() {
|
||||
final StorageItemPreference publicStorage = spy(new StorageItemPreference(mContext));
|
||||
publicStorage.setIcon(R.drawable.ic_folder_vd_theme_24);
|
||||
final StorageItemPreference images = spy(new StorageItemPreference(mContext));
|
||||
images.setIcon(R.drawable.ic_photo_library);
|
||||
final StorageItemPreference videos = spy(new StorageItemPreference(mContext));
|
||||
@@ -122,6 +124,8 @@ public class StorageItemPreferenceControllerTest {
|
||||
trash.setIcon(R.drawable.ic_trash_can);
|
||||
|
||||
final PreferenceScreen screen = mock(PreferenceScreen.class);
|
||||
when(screen.findPreference(eq(StorageItemPreferenceController.PUBLIC_STORAGE_KEY)))
|
||||
.thenReturn(publicStorage);
|
||||
when(screen.findPreference(eq(StorageItemPreferenceController.IMAGES_KEY)))
|
||||
.thenReturn(images);
|
||||
when(screen.findPreference(eq(StorageItemPreferenceController.VIDEOS_KEY)))
|
||||
@@ -148,6 +152,24 @@ public class StorageItemPreferenceControllerTest {
|
||||
.isEqualTo(mContext.getString(R.string.memory_calculating_size));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void launchPublicStorageIntent_nonNullBrowseIntent_settingsIntent() {
|
||||
final String fakeBrowseAction = "FAKE_BROWSE_ACTION";
|
||||
final Intent fakeBrowseIntent = new Intent(fakeBrowseAction);
|
||||
// mContext is not the activity, add FLAG_ACTIVITY_NEW_TASK to avoid AndroidRuntimeException
|
||||
// during this test.
|
||||
fakeBrowseIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
when(mVolume.buildBrowseIntent()).thenReturn(fakeBrowseIntent);
|
||||
mPreference.setKey(StorageItemPreferenceController.PUBLIC_STORAGE_KEY);
|
||||
mController.handlePreferenceTreeClick(mPreference);
|
||||
|
||||
final ArgumentCaptor<Intent> argumentCaptor = ArgumentCaptor.forClass(Intent.class);
|
||||
verify(mContext).startActivity(argumentCaptor.capture());
|
||||
|
||||
final Intent intent = argumentCaptor.getValue();
|
||||
assertThat(intent.getAction()).isEqualTo(fakeBrowseAction);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void launchImagesIntent_resolveActionViewNull_settingsIntent() {
|
||||
mPreference.setKey(StorageItemPreferenceController.IMAGES_KEY);
|
||||
@@ -191,6 +213,7 @@ public class StorageItemPreferenceControllerTest {
|
||||
|
||||
mController.setVolume(null);
|
||||
|
||||
assertThat(mController.mPublicStoragePreference.isVisible()).isFalse();
|
||||
assertThat(mController.mImagesPreference.isVisible()).isFalse();
|
||||
assertThat(mController.mVideosPreference.isVisible()).isFalse();
|
||||
assertThat(mController.mAudiosPreference.isVisible()).isFalse();
|
||||
@@ -347,6 +370,7 @@ public class StorageItemPreferenceControllerTest {
|
||||
|
||||
mController.setUserId(new UserHandle(10));
|
||||
|
||||
verify(mController.mPublicStoragePreference, times(2)).setIcon(nullable(Drawable.class));
|
||||
verify(mController.mImagesPreference, times(2)).setIcon(nullable(Drawable.class));
|
||||
verify(mController.mVideosPreference, times(2)).setIcon(nullable(Drawable.class));
|
||||
verify(mController.mAudiosPreference, times(2)).setIcon(nullable(Drawable.class));
|
||||
@@ -418,4 +442,26 @@ public class StorageItemPreferenceControllerTest {
|
||||
|
||||
assertThat(mController.mDocumentsAndOtherPreference.isVisible()).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void setVolume_publicStorage_showFilePreference() {
|
||||
// This will hide it initially.
|
||||
mController.displayPreference(mPreferenceScreen);
|
||||
when(mVolume.getType()).thenReturn(VolumeInfo.TYPE_PUBLIC);
|
||||
when(mVolume.getState()).thenReturn(VolumeInfo.STATE_MOUNTED);
|
||||
when(mVolume.isMountedReadable()).thenReturn(true);
|
||||
|
||||
// And we bring it back.
|
||||
mController.setVolume(mVolume);
|
||||
|
||||
assertThat(mController.mPublicStoragePreference.isVisible()).isTrue();
|
||||
assertThat(mController.mImagesPreference.isVisible()).isFalse();
|
||||
assertThat(mController.mVideosPreference.isVisible()).isFalse();
|
||||
assertThat(mController.mAudiosPreference.isVisible()).isFalse();
|
||||
assertThat(mController.mAppsPreference.isVisible()).isFalse();
|
||||
assertThat(mController.mGamesPreference.isVisible()).isFalse();
|
||||
assertThat(mController.mDocumentsAndOtherPreference.isVisible()).isFalse();
|
||||
assertThat(mController.mSystemPreference.isVisible()).isFalse();
|
||||
assertThat(mController.mTrashPreference.isVisible()).isFalse();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,156 @@
|
||||
/*
|
||||
* 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.emergency;
|
||||
|
||||
import static com.android.settings.core.BasePreferenceController.AVAILABLE;
|
||||
import static com.android.settings.core.BasePreferenceController.UNSUPPORTED_ON_DEVICE;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.ActivityInfo;
|
||||
import android.content.pm.ApplicationInfo;
|
||||
import android.content.pm.ResolveInfo;
|
||||
|
||||
import androidx.test.core.app.ApplicationProvider;
|
||||
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.testutils.shadow.SettingsShadowResources;
|
||||
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.robolectric.RobolectricTestRunner;
|
||||
import org.robolectric.Shadows;
|
||||
import org.robolectric.annotation.Config;
|
||||
import org.robolectric.shadows.ShadowPackageManager;
|
||||
|
||||
@RunWith(RobolectricTestRunner.class)
|
||||
@Config(shadows = SettingsShadowResources.class)
|
||||
public class MoreSettingsPreferenceControllerTest {
|
||||
|
||||
private static final String TEST_PKG_NAME = "test_pkg";
|
||||
private static final String TEST_CLASS_NAME = "name";
|
||||
|
||||
private static final Intent SETTING_INTENT = new Intent(Intent.ACTION_MAIN)
|
||||
.setPackage(TEST_PKG_NAME);
|
||||
|
||||
private Context mContext;
|
||||
private ShadowPackageManager mPackageManager;
|
||||
private static final String PREF_KEY = "more_settings_button";
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
mContext = ApplicationProvider.getApplicationContext();
|
||||
mPackageManager = Shadows.shadowOf(mContext.getPackageManager());
|
||||
}
|
||||
|
||||
@After
|
||||
public void tearDown() {
|
||||
SettingsShadowResources.reset();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void constructor_hasPackageConfig_shouldSetIntent() {
|
||||
// Provide override package name and provide resolvable intent
|
||||
SettingsShadowResources.overrideResource(
|
||||
R.string.config_emergency_package_name,
|
||||
TEST_PKG_NAME);
|
||||
prepareCustomIntent();
|
||||
|
||||
MoreSettingsPreferenceController controller = new MoreSettingsPreferenceController(
|
||||
mContext, PREF_KEY);
|
||||
|
||||
assertThat(controller.mIntent).isNotNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getAvailabilityStatus_whenIntentSet_shouldReturnAvailable() {
|
||||
// Provide override package name and provide resolvable intent
|
||||
SettingsShadowResources.overrideResource(
|
||||
R.string.config_emergency_package_name,
|
||||
TEST_PKG_NAME);
|
||||
prepareCustomIntent();
|
||||
|
||||
MoreSettingsPreferenceController controller = new MoreSettingsPreferenceController(
|
||||
mContext, PREF_KEY);
|
||||
|
||||
assertThat(controller.getAvailabilityStatus()).isEqualTo(AVAILABLE);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getAvailabilityStatus_whenPackageConfigIsUnavailable_shouldReturnUnsupported() {
|
||||
// No package name is configured
|
||||
MoreSettingsPreferenceController controller = new MoreSettingsPreferenceController(
|
||||
mContext, PREF_KEY);
|
||||
|
||||
assertThat(controller.getAvailabilityStatus()).isEqualTo(UNSUPPORTED_ON_DEVICE);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getAvailabilityStatus_noSuitableIntent_shouldReturnUnsupportedDevice() {
|
||||
// Provide override package name but don't provide resolvable intent
|
||||
SettingsShadowResources.overrideResource(
|
||||
R.string.config_emergency_package_name,
|
||||
TEST_PKG_NAME);
|
||||
|
||||
MoreSettingsPreferenceController controller = new MoreSettingsPreferenceController(
|
||||
mContext, PREF_KEY);
|
||||
|
||||
assertThat(controller.mIntent).isNull();
|
||||
assertThat(controller.getAvailabilityStatus()).isEqualTo(UNSUPPORTED_ON_DEVICE);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getAvailabilityStatus_intentForANonSystemApp_shouldReturnUnsupportedDevice() {
|
||||
// Provide override package name and provide resolvable intent for a non system app.
|
||||
SettingsShadowResources.overrideResource(
|
||||
R.string.config_emergency_package_name,
|
||||
TEST_PKG_NAME);
|
||||
prepareCustomIntentForANonSystemApp();
|
||||
|
||||
MoreSettingsPreferenceController controller = new MoreSettingsPreferenceController(
|
||||
mContext, PREF_KEY);
|
||||
|
||||
assertThat(controller.mIntent).isNull();
|
||||
assertThat(controller.getAvailabilityStatus()).isEqualTo(UNSUPPORTED_ON_DEVICE);
|
||||
}
|
||||
|
||||
private void prepareCustomIntent() {
|
||||
final ResolveInfo info = new ResolveInfo();
|
||||
info.activityInfo = new ActivityInfo();
|
||||
info.activityInfo.packageName = TEST_PKG_NAME;
|
||||
info.activityInfo.name = TEST_CLASS_NAME;
|
||||
|
||||
// Resolve to a system app.
|
||||
info.activityInfo.applicationInfo = new ApplicationInfo();
|
||||
info.activityInfo.applicationInfo.flags = ApplicationInfo.FLAG_SYSTEM;
|
||||
mPackageManager.addResolveInfoForIntent(SETTING_INTENT, info);
|
||||
}
|
||||
|
||||
|
||||
private void prepareCustomIntentForANonSystemApp() {
|
||||
final ResolveInfo info = new ResolveInfo();
|
||||
info.activityInfo = new ActivityInfo();
|
||||
info.activityInfo.packageName = TEST_PKG_NAME;
|
||||
info.activityInfo.name = TEST_CLASS_NAME;
|
||||
|
||||
mPackageManager.addResolveInfoForIntent(SETTING_INTENT, info);
|
||||
}
|
||||
}
|
||||
@@ -21,9 +21,10 @@ import static com.google.common.truth.Truth.assertThat;
|
||||
import static org.mockito.Mockito.doReturn;
|
||||
|
||||
import android.content.ContentResolver;
|
||||
import android.content.Context;
|
||||
import android.provider.Settings;
|
||||
|
||||
import androidx.preference.SwitchPreference;
|
||||
|
||||
import com.android.settings.core.BasePreferenceController;
|
||||
import com.android.settings.testutils.FakeFeatureFactory;
|
||||
import com.android.settingslib.widget.MainSwitchPreference;
|
||||
@@ -42,50 +43,48 @@ public class SmartBatteryPreferenceControllerTest {
|
||||
private static final int OFF = 0;
|
||||
|
||||
private SmartBatteryPreferenceController mController;
|
||||
private SwitchPreference mPreference;
|
||||
private ContentResolver mContentResolver;
|
||||
private FakeFeatureFactory mFeatureFactory;
|
||||
private Context mContext;
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
MockitoAnnotations.initMocks(this);
|
||||
|
||||
mContext = RuntimeEnvironment.application;
|
||||
mFeatureFactory = FakeFeatureFactory.setupForTest();
|
||||
mContentResolver = RuntimeEnvironment.application.getContentResolver();
|
||||
mController = new SmartBatteryPreferenceController(RuntimeEnvironment.application);
|
||||
mPreference = new SwitchPreference(RuntimeEnvironment.application);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUpdateState_smartBatteryOn_preferenceChecked() {
|
||||
putSmartBatteryValue(ON);
|
||||
final MainSwitchPreference preference = new MainSwitchPreference(mContext);
|
||||
|
||||
mController.updateState(preference);
|
||||
mController.updateState(mPreference);
|
||||
|
||||
assertThat(preference.isChecked()).isTrue();
|
||||
assertThat(mPreference.isChecked()).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUpdateState_smartBatteryOff_preferenceUnchecked() {
|
||||
putSmartBatteryValue(OFF);
|
||||
final MainSwitchPreference preference = new MainSwitchPreference(mContext);
|
||||
|
||||
mController.updateState(preference);
|
||||
mController.updateState(mPreference);
|
||||
|
||||
assertThat(preference.isChecked()).isFalse();
|
||||
assertThat(mPreference.isChecked()).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUpdateState_checkPreference_smartBatteryOn() {
|
||||
mController.onSwitchChanged(null, true);
|
||||
mController.onPreferenceChange(mPreference, true);
|
||||
|
||||
assertThat(getSmartBatteryValue()).isEqualTo(ON);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUpdateState_unCheckPreference_smartBatteryOff() {
|
||||
mController.onSwitchChanged(null, false);
|
||||
mController.onPreferenceChange(mPreference, false);
|
||||
|
||||
assertThat(getSmartBatteryValue()).isEqualTo(OFF);
|
||||
}
|
||||
|
||||
@@ -57,7 +57,7 @@ public class BluetoothTetherPreferenceControllerTest {
|
||||
|
||||
mContext = spy(ApplicationProvider.getApplicationContext());
|
||||
mSwitchPreference = spy(SwitchPreference.class);
|
||||
when(mContext.getSystemService(TetheringManager.class)).thenReturn(mTetheringManager);
|
||||
when(mContext.getSystemService(Context.TETHERING_SERVICE)).thenReturn(mTetheringManager);
|
||||
when(mTetheringManager.getTetherableBluetoothRegexs()).thenReturn(new String[] {""});
|
||||
mController = new BluetoothTetherPreferenceController(mContext, "BLUETOOTH");
|
||||
mController.setTetherEnabler(mTetherEnabler);
|
||||
|
||||
@@ -62,9 +62,9 @@ public class EthernetTetherPreferenceControllerTest {
|
||||
public void setUp() {
|
||||
mContext = spy(ApplicationProvider.getApplicationContext());
|
||||
mPreference = spy(SwitchPreference.class);
|
||||
when(mContext.getSystemService(TetheringManager.class)).thenReturn(mTetheringManager);
|
||||
when(mContext.getSystemService(Context.TETHERING_SERVICE)).thenReturn(mTetheringManager);
|
||||
when(mTetheringManager.getTetherableIfaces()).thenReturn(new String[]{ETHERNET_REGEX});
|
||||
when(mContext.getSystemService(EthernetManager.class)).thenReturn(mEthernetManager);
|
||||
when(mContext.getSystemService(Context.ETHERNET_SERVICE)).thenReturn(mEthernetManager);
|
||||
mController = new EthernetTetherPreferenceController(mContext, "ethernet");
|
||||
mController.setTetherEnabler(mTetherEnabler);
|
||||
ReflectionHelpers.setField(mController, "mEthernetRegex", ETHERNET_REGEX);
|
||||
|
||||
@@ -44,6 +44,7 @@ import android.os.Bundle;
|
||||
import android.os.PowerManager;
|
||||
import android.os.UserManager;
|
||||
import android.provider.Settings;
|
||||
import android.util.FeatureFlagUtils;
|
||||
import android.view.ContextMenu;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
@@ -131,6 +132,7 @@ public class NetworkProviderSettingsTest {
|
||||
mNetworkProviderSettings.mResetInternetPreference = mResetInternetPreference;
|
||||
mNetworkProviderSettings.mAirplaneModeMsgPreference = mAirplaneModeMsgPreference;
|
||||
mNetworkProviderSettings.mAirplaneModeEnabler = mAirplaneModeEnabler;
|
||||
FeatureFlagUtils.setEnabled(mContext, FeatureFlagUtils.SETTINGS_PROVIDER_MODEL, false);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -45,14 +45,14 @@ public class NetworkResetRestrictionCheckerTest {
|
||||
@Before
|
||||
public void setUp() {
|
||||
MockitoAnnotations.initMocks(this);
|
||||
when(mContext.getSystemService(UserManager.class)).thenReturn(mUserManager);
|
||||
when(mContext.getSystemService(Context.USER_SERVICE)).thenReturn(mUserManager);
|
||||
mRestrictionChecker = spy(new NetworkResetRestrictionChecker(mContext));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testHasRestriction_notAdmin_shouldReturnTrue() {
|
||||
final Context context = mock(Context.class);
|
||||
when(context.getSystemService(UserManager.class)).thenReturn(mUserManager);
|
||||
when(context.getSystemService(Context.USER_SERVICE)).thenReturn(mUserManager);
|
||||
when(mUserManager.isAdminUser()).thenReturn(false);
|
||||
|
||||
assertThat(mRestrictionChecker.hasRestriction()).isTrue();
|
||||
|
||||
@@ -125,7 +125,7 @@ public class PrivateDnsPreferenceControllerTest {
|
||||
mContext = spy(RuntimeEnvironment.application);
|
||||
mContentResolver = mContext.getContentResolver();
|
||||
mShadowContentResolver = Shadow.extract(mContentResolver);
|
||||
when(mContext.getSystemService(ConnectivityManager.class))
|
||||
when(mContext.getSystemService(Context.CONNECTIVITY_SERVICE))
|
||||
.thenReturn(mConnectivityManager);
|
||||
doNothing().when(mConnectivityManager).registerDefaultNetworkCallback(
|
||||
mCallbackCaptor.capture(), nullable(Handler.class));
|
||||
|
||||
@@ -95,10 +95,10 @@ public class TetherEnablerTest {
|
||||
AtomicReference<BluetoothPan> panReference = spy(AtomicReference.class);
|
||||
mSwitchBar = spy(new SwitchBar(context));
|
||||
mSwitchWidgetController = spy(new SwitchBarController(mSwitchBar));
|
||||
when(context.getSystemService(WifiManager.class)).thenReturn(mWifiManager);
|
||||
when(context.getSystemService(ConnectivityManager.class)).thenReturn(
|
||||
when(context.getSystemService(Context.WIFI_SERVICE)).thenReturn(mWifiManager);
|
||||
when(context.getSystemService(Context.CONNECTIVITY_SERVICE)).thenReturn(
|
||||
mConnectivityManager);
|
||||
when(context.getSystemService(TetheringManager.class)).thenReturn(mTetheringManager);
|
||||
when(context.getSystemService(Context.TETHERING_SERVICE)).thenReturn(mTetheringManager);
|
||||
when(context.getSystemService(Context.NETWORK_POLICY_SERVICE)).thenReturn(
|
||||
mNetworkPolicyManager);
|
||||
when(mTetheringManager.getTetherableIfaces()).thenReturn(new String[0]);
|
||||
@@ -311,4 +311,4 @@ public class TetherEnablerTest {
|
||||
assertThat(TetherEnabler.isTethering(TETHERING_ETHERNET_ON, TETHERING_ETHERNET)).isTrue();
|
||||
assertThat(TetherEnabler.isTethering(~TETHERING_ETHERNET_ON, TETHERING_ETHERNET)).isFalse();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -55,7 +55,7 @@ public class UsbTetherPreferenceControllerTest {
|
||||
MockitoAnnotations.initMocks(this);
|
||||
|
||||
mContext = spy(ApplicationProvider.getApplicationContext());
|
||||
when(mContext.getSystemService(TetheringManager.class)).thenReturn(mTetheringManager);
|
||||
when(mContext.getSystemService(Context.TETHERING_SERVICE)).thenReturn(mTetheringManager);
|
||||
when(mTetheringManager.getTetherableUsbRegexs()).thenReturn(new String[]{""});
|
||||
mController = new UsbTetherPreferenceController(mContext, "USB");
|
||||
mController.setTetherEnabler(mTetherEnabler);
|
||||
|
||||
@@ -100,7 +100,7 @@ public class WifiTetherDisablePreferenceControllerTest {
|
||||
|
||||
mContext = spy(ApplicationProvider.getApplicationContext());
|
||||
mPreference = spy(SwitchPreference.class);
|
||||
when(mContext.getSystemService(TetheringManager.class)).thenReturn(mTetheringManager);
|
||||
when(mContext.getSystemService(Context.TETHERING_SERVICE)).thenReturn(mTetheringManager);
|
||||
when(mTetheringManager.getTetherableWifiRegexs()).thenReturn(new String[]{""});
|
||||
mController = new WifiTetherDisablePreferenceController(mContext, WIFI_TETHER_DISABLE_KEY);
|
||||
mController.setTetherEnabler(mTetherEnabler);
|
||||
|
||||
@@ -74,7 +74,7 @@ public class MobileDataSliceTest {
|
||||
MockitoAnnotations.initMocks(this);
|
||||
mContext = spy(RuntimeEnvironment.application);
|
||||
|
||||
doReturn(mTelephonyManager).when(mContext).getSystemService(TelephonyManager.class);
|
||||
doReturn(mTelephonyManager).when(mContext).getSystemService(Context.TELEPHONY_SERVICE);
|
||||
doReturn(mSubscriptionManager).when(mContext).getSystemService(SubscriptionManager.class);
|
||||
doReturn(mTelephonyManager).when(mTelephonyManager).createForSubscriptionId(SUB_ID);
|
||||
doReturn(mSubscriptionInfo).when(mSubscriptionManager).getActiveSubscriptionInfo(anyInt());
|
||||
|
||||
@@ -77,7 +77,7 @@ public class NetworkSelectSettingsTest {
|
||||
MockitoAnnotations.initMocks(this);
|
||||
|
||||
mContext = spy(RuntimeEnvironment.application);
|
||||
when(mContext.getSystemService(TelephonyManager.class)).thenReturn(mTelephonyManager);
|
||||
when(mContext.getSystemService(Context.TELEPHONY_SERVICE)).thenReturn(mTelephonyManager);
|
||||
when(mContext.getSystemService(SubscriptionManager.class)).thenReturn(mSubscriptionManager);
|
||||
when(mTelephonyManager.createForSubscriptionId(SUB_ID)).thenReturn(mTelephonyManager);
|
||||
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user