Snap for 7422643 from 084d9f864b to sc-v2-release
Change-Id: I667e7fd7a2143399a69d1327f64d9f426d6c5128
This commit is contained in:
File diff suppressed because it is too large
Load Diff
52
res/drawable/face_enroll_intro_illustration.xml
Normal file
52
res/drawable/face_enroll_intro_illustration.xml
Normal file
@@ -0,0 +1,52 @@
|
|||||||
|
<?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="412dp"
|
||||||
|
android:height="300dp"
|
||||||
|
android:viewportWidth="412"
|
||||||
|
android:viewportHeight="300">
|
||||||
|
<group>
|
||||||
|
<clip-path
|
||||||
|
android:pathData="M206,255.65A67.68,67.68 0,1 0,138.32 188,67.68 67.68,0 0,0 206,255.65Z"/>
|
||||||
|
<path
|
||||||
|
android:pathData="M237.58,172.63a4.51,4.51 0,1 1,-4.51 -4.51A4.51,4.51 0,0 1,237.58 172.63Z"
|
||||||
|
android:fillColor="@color/biometric_enroll_intro_color_icon"
|
||||||
|
android:fillType="evenOdd"/>
|
||||||
|
<path
|
||||||
|
android:pathData="M178.93,177.14a4.51,4.51 0,1 1,4.51 -4.51A4.51,4.51 0,0 1,178.93 177.14Z"
|
||||||
|
android:fillColor="@color/biometric_enroll_intro_color_icon"
|
||||||
|
android:fillType="evenOdd"/>
|
||||||
|
<path
|
||||||
|
android:pathData="M212.41,215.89a9.93,9.93 0,0 1,-16.34 -7.57v0l-3.6,0s0,0 0,0.06A13.53,13.53 0,0 0,206 221.85a12.81,12.81 0,0 0,1.39 -0.07,13.38 13.38,0 0,0 7.35,-3.13Z"
|
||||||
|
android:fillColor="@color/biometric_enroll_intro_color_icon"
|
||||||
|
android:fillType="evenOdd"/>
|
||||||
|
<path
|
||||||
|
android:pathData="M207.35,181.66v11.73h-7.22V197H211V181.66Z"
|
||||||
|
android:fillColor="@color/biometric_enroll_intro_color_icon"
|
||||||
|
android:fillType="evenOdd"/>
|
||||||
|
</group>
|
||||||
|
<path
|
||||||
|
android:pathData="M206,45.75a38,38 0,0 0,-14.87 3h0A38.16,38.16 0,0 0,167.79 84v19.21h7V84A31.17,31.17 0,0 1,193.86 55.2h0a31.24,31.24 0,0 1,38.43 11.93l5.88,-3.78A38.08,38.08 0,0 0,206 45.75Z"
|
||||||
|
android:fillColor="@color/biometric_enroll_intro_color_bar"/>
|
||||||
|
<path
|
||||||
|
android:pathData="M238.18,63.35l-5.89,3.78A31.11,31.11 0,0 1,237.21 84v42.55h7V84A38.11,38.11 0,0 0,238.18 63.35Z"
|
||||||
|
android:fillColor="@color/biometric_enroll_intro_color_bar"/>
|
||||||
|
<path
|
||||||
|
android:pathData="M271.77,254.25H140.23a14,14 0,0 1,-14 -14V138.51a14,14 0,0 1,14 -14H271.77a14,14 0,0 1,14 14V240.25A14,14 0,0 1,271.77 254.25ZM140.23,128.51a10,10 0,0 0,-10 10V240.25a10,10 0,0 0,10 10H271.77a10,10 0,0 0,10 -10V138.51a10,10 0,0 0,-10 -10Z"
|
||||||
|
android:fillColor="@color/biometric_enroll_intro_color_outline"/>
|
||||||
|
</vector>
|
||||||
@@ -21,33 +21,33 @@
|
|||||||
android:viewportHeight="210.0"
|
android:viewportHeight="210.0"
|
||||||
android:viewportWidth="210.0">
|
android:viewportWidth="210.0">
|
||||||
<path
|
<path
|
||||||
android:fillColor="#34A853"
|
android:fillColor="@color/biometric_enroll_intro_color_bar"
|
||||||
android:pathData="M73.79,58.17h-7V38.96c0,-15.39 9.16,-29.21 23.34,-35.21l2.73,6.45c-11.58,4.9 -19.06,16.19 -19.06,28.76V58.17z" />
|
android:pathData="M73.79,58.17h-7V38.96c0,-15.39 9.16,-29.21 23.34,-35.21l2.73,6.45c-11.58,4.9 -19.06,16.19 -19.06,28.76V58.17z" />
|
||||||
<path
|
<path
|
||||||
android:fillColor="#34A853"
|
android:fillColor="@color/biometric_enroll_intro_color_bar"
|
||||||
android:pathData="M131.29,22.13C125.51,13.12 115.68,7.75 105,7.75c-4.21,0 -8.3,0.82 -12.15,2.45l-2.73,-6.45c4.71,-1.99 9.72,-3 14.87,-3c13.08,0 25.11,6.58 32.18,17.6L131.29,22.13z" />
|
android:pathData="M131.29,22.13C125.51,13.12 115.68,7.75 105,7.75c-4.21,0 -8.3,0.82 -12.15,2.45l-2.73,-6.45c4.71,-1.99 9.72,-3 14.87,-3c13.08,0 25.11,6.58 32.18,17.6L131.29,22.13z" />
|
||||||
<path
|
<path
|
||||||
android:fillColor="#34A853"
|
android:fillColor="@color/biometric_enroll_intro_color_bar"
|
||||||
android:pathData="M143.21,62.11h-7V38.96c0,-5.99 -1.7,-11.81 -4.92,-16.83l5.89,-3.78c3.94,6.15 6.03,13.27 6.03,20.6V62.11z" />
|
android:pathData="M143.21,62.11h-7V38.96c0,-5.99 -1.7,-11.81 -4.92,-16.83l5.89,-3.78c3.94,6.15 6.03,13.27 6.03,20.6V62.11z" />
|
||||||
<path
|
<path
|
||||||
android:fillColor="#34A853"
|
android:fillColor="@color/biometric_enroll_intro_color_bar"
|
||||||
android:pathData="M136.21,62.11h7v19.4h-7z" />
|
android:pathData="M136.21,62.11h7v19.4h-7z" />
|
||||||
<path
|
<path
|
||||||
android:fillColor="#3E82F1"
|
android:fillColor="@color/biometric_enroll_intro_color_icon"
|
||||||
android:pathData="M125.03,118.78c-0.28,0 -0.55,-0.07 -0.79,-0.2c-6.61,-3.37 -12.33,-4.79 -19.19,-4.79c-6.82,0 -13.3,1.6 -19.19,4.79c-0.83,0.44 -1.86,0.14 -2.34,-0.68c-0.45,-0.82 -0.14,-1.87 0.69,-2.31c6.41,-3.43 13.44,-5.2 20.84,-5.2c7.34,0 13.75,1.6 20.77,5.17c0.86,0.44 1.17,1.46 0.72,2.28C126.24,118.44 125.65,118.78 125.03,118.78z" />
|
android:pathData="M125.03,118.78c-0.28,0 -0.55,-0.07 -0.79,-0.2c-6.61,-3.37 -12.33,-4.79 -19.19,-4.79c-6.82,0 -13.3,1.6 -19.19,4.79c-0.83,0.44 -1.86,0.14 -2.34,-0.68c-0.45,-0.82 -0.14,-1.87 0.69,-2.31c6.41,-3.43 13.44,-5.2 20.84,-5.2c7.34,0 13.75,1.6 20.77,5.17c0.86,0.44 1.17,1.46 0.72,2.28C126.24,118.44 125.65,118.78 125.03,118.78z" />
|
||||||
<path
|
<path
|
||||||
android:fillColor="#3E82F1"
|
android:fillColor="@color/biometric_enroll_intro_color_icon"
|
||||||
android:pathData="M75.73,136.63c-0.34,0 -0.69,-0.1 -1,-0.31c-0.79,-0.54 -0.96,-1.6 -0.41,-2.38c3.41,-4.76 7.75,-8.5 12.92,-11.12c10.82,-5.51 24.67,-5.54 35.52,-0.03c5.17,2.62 9.51,6.32 12.92,11.05c0.55,0.75 0.38,1.84 -0.41,2.38c-0.79,0.54 -1.86,0.37 -2.41,-0.41c-3.1,-4.28 -7.03,-7.65 -11.68,-10c-9.89,-5 -22.53,-5 -32.38,0.03c-4.69,2.38 -8.61,5.78 -11.71,10.06C76.8,136.39 76.28,136.63 75.73,136.63z" />
|
android:pathData="M75.73,136.63c-0.34,0 -0.69,-0.1 -1,-0.31c-0.79,-0.54 -0.96,-1.6 -0.41,-2.38c3.41,-4.76 7.75,-8.5 12.92,-11.12c10.82,-5.51 24.67,-5.54 35.52,-0.03c5.17,2.62 9.51,6.32 12.92,11.05c0.55,0.75 0.38,1.84 -0.41,2.38c-0.79,0.54 -1.86,0.37 -2.41,-0.41c-3.1,-4.28 -7.03,-7.65 -11.68,-10c-9.89,-5 -22.53,-5 -32.38,0.03c-4.69,2.38 -8.61,5.78 -11.71,10.06C76.8,136.39 76.28,136.63 75.73,136.63z" />
|
||||||
<path
|
<path
|
||||||
android:fillColor="#3E82F1"
|
android:fillColor="@color/biometric_enroll_intro_color_icon"
|
||||||
android:pathData="M97.27,177.67c-0.45,0 -0.9,-0.17 -1.21,-0.51c-3,-2.96 -4.62,-4.86 -6.92,-8.98c-2.38,-4.18 -3.62,-9.28 -3.62,-14.76c0,-10.1 8.75,-18.33 19.5,-18.33s19.5,8.23 19.5,18.33c0,0.95 -0.76,1.7 -1.72,1.7s-1.72,-0.75 -1.72,-1.7c0,-8.23 -7.2,-14.93 -16.05,-14.93s-16.05,6.7 -16.05,14.93c0,4.9 1.1,9.42 3.2,13.09c2.2,3.91 3.72,5.58 6.37,8.23c0.65,0.68 0.65,1.73 0,2.41C98.16,177.5 97.71,177.67 97.27,177.67z" />
|
android:pathData="M97.27,177.67c-0.45,0 -0.9,-0.17 -1.21,-0.51c-3,-2.96 -4.62,-4.86 -6.92,-8.98c-2.38,-4.18 -3.62,-9.28 -3.62,-14.76c0,-10.1 8.75,-18.33 19.5,-18.33s19.5,8.23 19.5,18.33c0,0.95 -0.76,1.7 -1.72,1.7s-1.72,-0.75 -1.72,-1.7c0,-8.23 -7.2,-14.93 -16.05,-14.93s-16.05,6.7 -16.05,14.93c0,4.9 1.1,9.42 3.2,13.09c2.2,3.91 3.72,5.58 6.37,8.23c0.65,0.68 0.65,1.73 0,2.41C98.16,177.5 97.71,177.67 97.27,177.67z" />
|
||||||
<path
|
<path
|
||||||
android:fillColor="#3E82F1"
|
android:fillColor="@color/biometric_enroll_intro_color_icon"
|
||||||
android:pathData="M121.97,171.38c-4.1,0 -7.72,-1.02 -10.68,-3.03c-5.13,-3.43 -8.2,-9.01 -8.2,-14.93c0,-0.95 0.76,-1.7 1.72,-1.7s1.72,0.75 1.72,1.7c0,4.79 2.48,9.32 6.68,12.1c2.45,1.63 5.31,2.41 8.75,2.41c0.83,0 2.2,-0.1 3.58,-0.34c0.93,-0.17 1.83,0.44 2,1.39c0.17,0.92 -0.45,1.8 -1.41,1.97C124.17,171.34 122.45,171.38 121.97,171.38z" />
|
android:pathData="M121.97,171.38c-4.1,0 -7.72,-1.02 -10.68,-3.03c-5.13,-3.43 -8.2,-9.01 -8.2,-14.93c0,-0.95 0.76,-1.7 1.72,-1.7s1.72,0.75 1.72,1.7c0,4.79 2.48,9.32 6.68,12.1c2.45,1.63 5.31,2.41 8.75,2.41c0.83,0 2.2,-0.1 3.58,-0.34c0.93,-0.17 1.83,0.44 2,1.39c0.17,0.92 -0.45,1.8 -1.41,1.97C124.17,171.34 122.45,171.38 121.97,171.38z" />
|
||||||
<path
|
<path
|
||||||
android:fillColor="#3E82F1"
|
android:fillColor="@color/biometric_enroll_intro_color_icon"
|
||||||
android:pathData="M115.04,178.38c-0.14,0 -0.31,-0.03 -0.45,-0.07c-5.48,-1.5 -9.06,-3.5 -12.82,-7.14c-4.82,-4.73 -7.48,-11.02 -7.48,-17.75c0,-5.51 4.75,-10 10.61,-10c5.86,0 10.61,4.49 10.61,10c0,3.64 3.2,6.6 7.17,6.6s7.17,-2.96 7.17,-6.6c0,-12.82 -11.2,-23.22 -24.98,-23.22c-9.78,0 -18.74,5.37 -22.77,13.7c-1.34,2.75 -2.03,5.98 -2.03,9.52c0,2.65 0.24,6.83 2.31,12.27c0.34,0.88 -0.1,1.87 -1,2.18c-0.9,0.34 -1.89,-0.14 -2.2,-0.99c-1.69,-4.45 -2.51,-8.87 -2.51,-13.46c0,-4.08 0.79,-7.79 2.34,-11.02c4.58,-9.49 14.75,-15.64 25.87,-15.64c15.68,0 28.42,11.93 28.42,26.62c0,5.51 -4.75,10 -10.61,10c-5.86,0 -10.61,-4.49 -10.61,-10c0,-3.64 -3.2,-6.6 -7.17,-6.6s-7.17,2.96 -7.17,6.6c0,5.81 2.27,11.25 6.44,15.33c3.27,3.2 6.41,4.96 11.27,6.29c0.93,0.24 1.45,1.19 1.21,2.07C116.49,177.87 115.77,178.38 115.04,178.38z" />
|
android:pathData="M115.04,178.38c-0.14,0 -0.31,-0.03 -0.45,-0.07c-5.48,-1.5 -9.06,-3.5 -12.82,-7.14c-4.82,-4.73 -7.48,-11.02 -7.48,-17.75c0,-5.51 4.75,-10 10.61,-10c5.86,0 10.61,4.49 10.61,10c0,3.64 3.2,6.6 7.17,6.6s7.17,-2.96 7.17,-6.6c0,-12.82 -11.2,-23.22 -24.98,-23.22c-9.78,0 -18.74,5.37 -22.77,13.7c-1.34,2.75 -2.03,5.98 -2.03,9.52c0,2.65 0.24,6.83 2.31,12.27c0.34,0.88 -0.1,1.87 -1,2.18c-0.9,0.34 -1.89,-0.14 -2.2,-0.99c-1.69,-4.45 -2.51,-8.87 -2.51,-13.46c0,-4.08 0.79,-7.79 2.34,-11.02c4.58,-9.49 14.75,-15.64 25.87,-15.64c15.68,0 28.42,11.93 28.42,26.62c0,5.51 -4.75,10 -10.61,10c-5.86,0 -10.61,-4.49 -10.61,-10c0,-3.64 -3.2,-6.6 -7.17,-6.6s-7.17,2.96 -7.17,6.6c0,5.81 2.27,11.25 6.44,15.33c3.27,3.2 6.41,4.96 11.27,6.29c0.93,0.24 1.45,1.19 1.21,2.07C116.49,177.87 115.77,178.38 115.04,178.38z" />
|
||||||
<path
|
<path
|
||||||
android:fillColor="#DADCE0"
|
android:fillColor="@color/biometric_enroll_intro_color_outline"
|
||||||
android:pathData="M170.77,209.25H39.23c-7.72,0 -14,-6.28 -14,-14V93.51c0,-7.72 6.28,-14 14,-14h131.54c7.72,0 14,6.28 14,14v101.74C184.77,202.97 178.49,209.25 170.77,209.25zM39.23,83.51c-5.51,0 -10,4.49 -10,10v101.74c0,5.51 4.49,10 10,10h131.54c5.51,0 10,-4.49 10,-10V93.51c0,-5.51 -4.49,-10 -10,-10H39.23z" />
|
android:pathData="M170.77,209.25H39.23c-7.72,0 -14,-6.28 -14,-14V93.51c0,-7.72 6.28,-14 14,-14h131.54c7.72,0 14,6.28 14,14v101.74C184.77,202.97 178.49,209.25 170.77,209.25zM39.23,83.51c-5.51,0 -10,4.49 -10,10v101.74c0,5.51 4.49,10 10,10h131.54c5.51,0 10,-4.49 10,-10V93.51c0,-5.51 -4.49,-10 -10,-10H39.23z" />
|
||||||
</vector>
|
</vector>
|
||||||
|
|||||||
@@ -110,12 +110,14 @@
|
|||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/cycle_left_time"
|
android:id="@+id/cycle_left_time"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content" />
|
android:layout_height="wrap_content"
|
||||||
|
android:textColor="?android:attr/textColorSecondary" />
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/carrier_and_update"
|
android:id="@+id/carrier_and_update"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content" />
|
android:layout_height="wrap_content"
|
||||||
|
android:textColor="?android:attr/textColorSecondary" />
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
|
|||||||
@@ -27,7 +27,7 @@
|
|||||||
<LinearLayout
|
<LinearLayout
|
||||||
style="@style/SudContentFrame"
|
style="@style/SudContentFrame"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="wrap_content"
|
||||||
android:clipChildren="false"
|
android:clipChildren="false"
|
||||||
android:clipToPadding="false"
|
android:clipToPadding="false"
|
||||||
android:orientation="vertical">
|
android:orientation="vertical">
|
||||||
@@ -42,24 +42,23 @@
|
|||||||
<FrameLayout
|
<FrameLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginBottom="12dp">
|
android:layout_marginTop="-24dp"
|
||||||
|
android:layout_marginBottom="4dp">
|
||||||
|
|
||||||
<com.google.android.setupdesign.view.IllustrationVideoView
|
<ImageView
|
||||||
android:id="@+id/illustration_normal"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
style="@style/SudContentIllustration"
|
style="@style/SudContentIllustration"
|
||||||
app:sudVideo="@raw/face_settings"/>
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:contentDescription="@null"
|
||||||
|
android:src="@drawable/face_enroll_intro_illustration"/>
|
||||||
|
|
||||||
</FrameLayout>
|
</FrameLayout>
|
||||||
|
|
||||||
<!-- Contains the buttons and extra information text at the bottom -->
|
<!-- Contains the extra information text at the bottom -->
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:orientation="vertical"
|
android:orientation="vertical">
|
||||||
android:layout_gravity="center_horizontal|bottom"
|
|
||||||
android:paddingTop="12dp">
|
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
|
|||||||
@@ -64,7 +64,8 @@
|
|||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:textAlignment="viewStart"
|
android:textAlignment="viewStart"
|
||||||
android:paddingTop="12dp"
|
android:paddingTop="12dp"
|
||||||
android:text="@string/security_settings_fingerprint_v2_enroll_introduction_footer_title_2" />
|
android:text="@string/security_settings_fingerprint_v2_enroll_introduction_footer_title_2"
|
||||||
|
android:textColor="?android:attr/textColorPrimary"/>
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
@@ -84,7 +85,8 @@
|
|||||||
<TextView
|
<TextView
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:text="@string/security_settings_fingerprint_v2_enroll_introduction_footer_message_2" />
|
android:text="@string/security_settings_fingerprint_v2_enroll_introduction_footer_message_2"
|
||||||
|
android:textColor="?android:attr/textColorPrimary"/>
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
@@ -105,7 +107,8 @@
|
|||||||
<TextView
|
<TextView
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:text="@string/security_settings_fingerprint_v2_enroll_introduction_footer_message_3" />
|
android:text="@string/security_settings_fingerprint_v2_enroll_introduction_footer_message_3"
|
||||||
|
android:textColor="?android:attr/textColorPrimary"/>
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
<!-- You're in control -->
|
<!-- You're in control -->
|
||||||
@@ -115,7 +118,8 @@
|
|||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:textAlignment="viewStart"
|
android:textAlignment="viewStart"
|
||||||
android:paddingTop="12dp"
|
android:paddingTop="12dp"
|
||||||
android:text="@string/security_settings_fingerprint_enroll_introduction_footer_title_1" />
|
android:text="@string/security_settings_fingerprint_enroll_introduction_footer_title_1"
|
||||||
|
android:textColor="?android:attr/textColorPrimary"/>
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
@@ -135,7 +139,8 @@
|
|||||||
<TextView
|
<TextView
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:text="@string/security_settings_fingerprint_v2_enroll_introduction_footer_message_4" />
|
android:text="@string/security_settings_fingerprint_v2_enroll_introduction_footer_message_4"
|
||||||
|
android:textColor="?android:attr/textColorPrimary"/>
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
@@ -147,7 +152,8 @@
|
|||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:textAlignment="viewStart"
|
android:textAlignment="viewStart"
|
||||||
android:paddingTop="12dp"
|
android:paddingTop="12dp"
|
||||||
android:text="@string/security_settings_fingerprint_enroll_introduction_footer_title_2" />
|
android:text="@string/security_settings_fingerprint_enroll_introduction_footer_title_2"
|
||||||
|
android:textColor="?android:attr/textColorPrimary"/>
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
@@ -167,7 +173,8 @@
|
|||||||
<TextView
|
<TextView
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:text="@string/security_settings_fingerprint_v2_enroll_introduction_footer_message_5" />
|
android:text="@string/security_settings_fingerprint_v2_enroll_introduction_footer_message_5"
|
||||||
|
android:textColor="?android:attr/textColorPrimary"/>
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
@@ -188,7 +195,8 @@
|
|||||||
<TextView
|
<TextView
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:text="@string/security_settings_fingerprint_v2_enroll_introduction_message_learn_more" />
|
android:text="@string/security_settings_fingerprint_v2_enroll_introduction_message_learn_more"
|
||||||
|
android:textColor="?android:attr/textColorPrimary"/>
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|||||||
@@ -56,7 +56,6 @@
|
|||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:gravity="center_vertical"
|
android:gravity="center_vertical"
|
||||||
android:layoutDirection="ltr"
|
|
||||||
android:paddingTop="8dp">
|
android:paddingTop="8dp">
|
||||||
|
|
||||||
<ImageView
|
<ImageView
|
||||||
|
|||||||
@@ -14,60 +14,50 @@
|
|||||||
limitations under the License.
|
limitations under the License.
|
||||||
-->
|
-->
|
||||||
|
|
||||||
<androidx.coordinatorlayout.widget.CoordinatorLayout
|
<FrameLayout
|
||||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:settings="http://schemas.android.com/apk/res-auto"
|
xmlns:settings="http://schemas.android.com/apk/res-auto"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent">
|
||||||
android:orientation="vertical">
|
|
||||||
|
|
||||||
<FrameLayout
|
<FrameLayout
|
||||||
|
android:id="@+id/pinned_header"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:elevation="2dp"/>
|
||||||
|
|
||||||
|
<FrameLayout
|
||||||
|
android:id="@+id/list_container"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
settings:layout_behavior="com.android.settings.widget.FloatingAppBarScrollingViewBehavior">
|
android:visibility="gone">
|
||||||
|
|
||||||
<FrameLayout
|
<androidx.recyclerview.widget.RecyclerView
|
||||||
android:id="@+id/list_container"
|
android:id="@+id/apps_list"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:visibility="gone">
|
android:clipToPadding="false"
|
||||||
|
android:scrollbars="none"
|
||||||
|
settings:fastScrollEnabled="true"
|
||||||
|
settings:fastScrollHorizontalThumbDrawable="@drawable/thumb_drawable"
|
||||||
|
settings:fastScrollHorizontalTrackDrawable="@drawable/line_drawable"
|
||||||
|
settings:fastScrollVerticalThumbDrawable="@drawable/thumb_drawable"
|
||||||
|
settings:fastScrollVerticalTrackDrawable="@drawable/line_drawable"/>
|
||||||
|
|
||||||
<androidx.recyclerview.widget.RecyclerView
|
<TextView
|
||||||
android:id="@+id/apps_list"
|
android:id="@android:id/empty"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:clipToPadding="false"
|
android:gravity="bottom|center_horizontal"
|
||||||
android:scrollbars="none"
|
android:layout_gravity="center"
|
||||||
settings:fastScrollEnabled="true"
|
android:text="@string/no_applications"
|
||||||
settings:fastScrollHorizontalThumbDrawable="@drawable/thumb_drawable"
|
android:textAppearance="?android:attr/textAppearanceLarge"
|
||||||
settings:fastScrollHorizontalTrackDrawable="@drawable/line_drawable"
|
android:visibility="invisible"/>
|
||||||
settings:fastScrollVerticalThumbDrawable="@drawable/thumb_drawable"
|
|
||||||
settings:fastScrollVerticalTrackDrawable="@drawable/line_drawable"/>
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:id="@android:id/empty"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="match_parent"
|
|
||||||
android:gravity="center"
|
|
||||||
android:layout_gravity="center"
|
|
||||||
android:text="@string/no_applications"
|
|
||||||
android:textAppearance="?android:attr/textAppearanceLarge"
|
|
||||||
android:visibility="invisible"/>
|
|
||||||
|
|
||||||
</FrameLayout>
|
|
||||||
|
|
||||||
<include layout="@layout/loading_container"/>
|
|
||||||
|
|
||||||
</FrameLayout>
|
</FrameLayout>
|
||||||
|
|
||||||
<com.google.android.material.appbar.AppBarLayout
|
<include layout="@layout/loading_container"/>
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content">
|
</FrameLayout>
|
||||||
<FrameLayout
|
|
||||||
android:id="@+id/pinned_header"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
settings:layout_scrollFlags="scroll|enterAlways"/>
|
|
||||||
</com.google.android.material.appbar.AppBarLayout>
|
|
||||||
|
|
||||||
</androidx.coordinatorlayout.widget.CoordinatorLayout>
|
|
||||||
|
|||||||
@@ -1,63 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<!-- Copyright (C) 2021 The Android Open Source Project
|
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
you may not use this file except in compliance with the License.
|
|
||||||
You may obtain a copy of the License at
|
|
||||||
|
|
||||||
http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
|
|
||||||
Unless required by applicable law or agreed to in writing, software
|
|
||||||
distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
See the License for the specific language governing permissions and
|
|
||||||
limitations under the License.
|
|
||||||
-->
|
|
||||||
|
|
||||||
<FrameLayout
|
|
||||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
|
||||||
xmlns:settings="http://schemas.android.com/apk/res-auto"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="match_parent">
|
|
||||||
|
|
||||||
<FrameLayout
|
|
||||||
android:id="@+id/pinned_header"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:elevation="2dp"/>
|
|
||||||
|
|
||||||
<FrameLayout
|
|
||||||
android:id="@+id/list_container"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="match_parent"
|
|
||||||
android:visibility="gone">
|
|
||||||
|
|
||||||
<androidx.recyclerview.widget.RecyclerView
|
|
||||||
android:id="@+id/apps_list"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="match_parent"
|
|
||||||
android:clipToPadding="false"
|
|
||||||
android:scrollbars="none"
|
|
||||||
settings:fastScrollEnabled="true"
|
|
||||||
settings:fastScrollHorizontalThumbDrawable="@drawable/thumb_drawable"
|
|
||||||
settings:fastScrollHorizontalTrackDrawable="@drawable/line_drawable"
|
|
||||||
settings:fastScrollVerticalThumbDrawable="@drawable/thumb_drawable"
|
|
||||||
settings:fastScrollVerticalTrackDrawable="@drawable/line_drawable"/>
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:id="@android:id/empty"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="match_parent"
|
|
||||||
android:gravity="bottom|center_horizontal"
|
|
||||||
android:layout_gravity="center"
|
|
||||||
android:text="@string/no_applications"
|
|
||||||
android:textAppearance="?android:attr/textAppearanceLarge"
|
|
||||||
android:visibility="invisible"/>
|
|
||||||
|
|
||||||
</FrameLayout>
|
|
||||||
|
|
||||||
<include layout="@layout/loading_container"/>
|
|
||||||
|
|
||||||
</FrameLayout>
|
|
||||||
|
|
||||||
|
|
||||||
@@ -14,14 +14,15 @@
|
|||||||
limitations under the License.
|
limitations under the License.
|
||||||
-->
|
-->
|
||||||
|
|
||||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
<LinearLayout
|
||||||
android:layout_width="match_parent"
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
android:layout_height="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:orientation="vertical">
|
android:layout_height="match_parent"
|
||||||
|
android:orientation="vertical">
|
||||||
|
|
||||||
<FrameLayout
|
<FrameLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent" >
|
android:layout_height="match_parent" >
|
||||||
|
|
||||||
<view class="com.android.settings.applications.RunningProcessesView"
|
<view class="com.android.settings.applications.RunningProcessesView"
|
||||||
android:id="@+id/running_processes"
|
android:id="@+id/running_processes"
|
||||||
|
|||||||
@@ -62,14 +62,18 @@
|
|||||||
android:ellipsize="end"
|
android:ellipsize="end"
|
||||||
android:maxLines="1"
|
android:maxLines="1"
|
||||||
android:textColor="?android:attr/textColorPrimary"
|
android:textColor="?android:attr/textColorPrimary"
|
||||||
android:textSize="20sp"/>
|
android:textSize="24sp"
|
||||||
|
android:fontFamily="sans-serif-reqular"/>
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/header_subtitle"
|
android:id="@+id/header_subtitle"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:ellipsize="end"
|
android:ellipsize="end"
|
||||||
android:maxLines="1"/>
|
android:maxLines="1"
|
||||||
|
android:textColor="?android:attr/textColorSecondary"
|
||||||
|
android:textSize="14sp"
|
||||||
|
android:fontFamily="sans-serif-reqular" />
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
|
|||||||
@@ -24,6 +24,7 @@
|
|||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_margin="8dp"
|
android:layout_margin="8dp"
|
||||||
|
android:importantForAccessibility="yes"
|
||||||
style="@style/ContextualCardStyle">
|
style="@style/ContextualCardStyle">
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
@@ -46,16 +47,16 @@
|
|||||||
android:layout_marginTop="12dp"
|
android:layout_marginTop="12dp"
|
||||||
android:layout_marginBottom="16dp"
|
android:layout_marginBottom="16dp"
|
||||||
android:text="@string/battery_missing_message"
|
android:text="@string/battery_missing_message"
|
||||||
android:textAppearance="?android:attr/textAppearanceSmall"
|
android:textAppearance="?android:attr/textAppearanceListItem" />
|
||||||
android:textColor="?android:attr/textColorSecondary" />
|
|
||||||
|
|
||||||
<TextView android:id="@+id/link_text"
|
<TextView android:id="@+id/link_text"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_gravity="end"
|
android:layout_gravity="end"
|
||||||
android:text="@string/battery_missing_link_message"
|
android:text="@string/battery_missing_link_message"
|
||||||
android:textAppearance="?android:attr/textAppearanceSmall"
|
android:textAppearance="?android:attr/textAppearanceListItemSecondary"
|
||||||
android:textColor="@*android:color/material_red_A700" />
|
android:textColor="@*android:color/material_red_A700"
|
||||||
|
android:contentDescription="@string/battery_missing_link_a11y_message" />
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
</com.google.android.material.card.MaterialCardView>
|
</com.google.android.material.card.MaterialCardView>
|
||||||
</FrameLayout>
|
</FrameLayout>
|
||||||
|
|||||||
@@ -20,7 +20,7 @@
|
|||||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:paddingStart="@dimen/preference_no_icon_padding_start"
|
android:paddingStart="?android:attr/listPreferredItemPaddingStart"
|
||||||
android:paddingEnd="?android:attr/listPreferredItemPaddingEnd"
|
android:paddingEnd="?android:attr/listPreferredItemPaddingEnd"
|
||||||
android:orientation="vertical">
|
android:orientation="vertical">
|
||||||
|
|
||||||
|
|||||||
@@ -31,5 +31,5 @@
|
|||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:layout_toStartOf="@id/widget_summary"
|
android:layout_toStartOf="@id/widget_summary"
|
||||||
layout="@layout/preference_app"/>
|
layout="@layout/running_services_app_item"/>
|
||||||
</RelativeLayout>
|
</RelativeLayout>
|
||||||
@@ -33,6 +33,7 @@
|
|||||||
android:paddingEnd="0dp"
|
android:paddingEnd="0dp"
|
||||||
android:drawSelectorOnTop="false"
|
android:drawSelectorOnTop="false"
|
||||||
android:scrollbarStyle="outsideOverlay"
|
android:scrollbarStyle="outsideOverlay"
|
||||||
|
android:nestedScrollingEnabled="true"
|
||||||
android:fastScrollEnabled="true"/>
|
android:fastScrollEnabled="true"/>
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@android:id/empty"
|
android:id="@android:id/empty"
|
||||||
|
|||||||
70
res/layout/running_services_app_item.xml
Normal file
70
res/layout/running_services_app_item.xml
Normal file
@@ -0,0 +1,70 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<!--
|
||||||
|
Copyright (C) 2020 The Android Open Source Project
|
||||||
|
|
||||||
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
you may not use this file except in compliance with the License.
|
||||||
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
-->
|
||||||
|
<LinearLayout
|
||||||
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:background="?android:attr/selectableItemBackground"
|
||||||
|
android:gravity="center_vertical"
|
||||||
|
android:minHeight="?android:attr/listPreferredItemHeightSmall"
|
||||||
|
android:paddingStart="?android:attr/listPreferredItemPaddingStart"
|
||||||
|
android:paddingEnd="?android:attr/listPreferredItemPaddingEnd">
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:id="@+id/icon_frame"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:gravity="start|center_vertical"
|
||||||
|
android:minWidth="@dimen/secondary_app_icon_size"
|
||||||
|
android:orientation="horizontal"
|
||||||
|
android:paddingEnd="16dp"
|
||||||
|
android:paddingTop="4dp"
|
||||||
|
android:paddingBottom="4dp">
|
||||||
|
<ImageView
|
||||||
|
android:id="@android:id/icon"
|
||||||
|
android:layout_width="@dimen/secondary_app_icon_size"
|
||||||
|
android:layout_height="@dimen/secondary_app_icon_size"/>
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:orientation="vertical"
|
||||||
|
android:paddingTop="16dp"
|
||||||
|
android:paddingBottom="16dp">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@android:id/title"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:ellipsize="marquee"
|
||||||
|
android:fadingEdge="horizontal"
|
||||||
|
android:maxLines="2"
|
||||||
|
android:textAppearance="?android:attr/textAppearanceListItem"/>
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@android:id/summary"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:textDirection="locale"
|
||||||
|
android:textAppearance="?android:attr/textAppearanceSmall"
|
||||||
|
android:textColor="?android:attr/textColorSecondary"/>
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
@@ -14,13 +14,15 @@
|
|||||||
limitations under the License.
|
limitations under the License.
|
||||||
-->
|
-->
|
||||||
|
|
||||||
<resources>
|
<resources
|
||||||
|
xmlns:androidprv="http://schemas.android.com/apk/prv/res/android">
|
||||||
<color name="switchbar_switch_track_tint">#82000000</color>
|
<color name="switchbar_switch_track_tint">#82000000</color>
|
||||||
<color name="switchbar_switch_thumb_tint">@android:color/black</color>
|
<color name="switchbar_switch_thumb_tint">@android:color/black</color>
|
||||||
<color name="homepage_accessibility_background">#783BE5</color>
|
<color name="homepage_accessibility_background">#783BE5</color>
|
||||||
<color name="homepage_support_background">#3F5FBD</color>
|
<color name="homepage_support_background">#3F5FBD</color>
|
||||||
<color name="homepage_card_dismissal_background">@*android:color/material_grey_900</color>
|
<color name="homepage_card_dismissal_background">@*android:color/material_grey_900</color>
|
||||||
<color name="contextual_card_background">@*android:color/material_grey_900</color>
|
<color name="contextual_card_background">@*android:color/material_grey_900</color>
|
||||||
|
<color name="search_bar_background">?androidprv:attr/colorSurfaceVariant</color>
|
||||||
<color name="notification_importance_selection_bg">@*android:color/material_grey_800</color>
|
<color name="notification_importance_selection_bg">@*android:color/material_grey_800</color>
|
||||||
<color name="notification_importance_button_selected">#AECBFA</color> <!-- material blue 200 -->
|
<color name="notification_importance_button_selected">#AECBFA</color> <!-- material blue 200 -->
|
||||||
<color name="notification_importance_button_unselected">#5F6368</color>
|
<color name="notification_importance_button_unselected">#5F6368</color>
|
||||||
@@ -41,5 +43,10 @@
|
|||||||
<color name="color_surface_header">@*android:color/surface_header_dark</color>
|
<color name="color_surface_header">@*android:color/surface_header_dark</color>
|
||||||
<!-- Dialog error color. -->
|
<!-- Dialog error color. -->
|
||||||
<color name="settings_dialog_colorError">#f28b82</color> <!-- Red 300 -->
|
<color name="settings_dialog_colorError">#f28b82</color> <!-- Red 300 -->
|
||||||
|
|
||||||
|
<!-- Face and fingerprint enrollment -->
|
||||||
|
<color name="biometric_enroll_intro_color_bar">#5bb974</color>
|
||||||
|
<color name="biometric_enroll_intro_color_icon">#669df6</color>
|
||||||
|
<color name="biometric_enroll_intro_color_outline">#5e5e5e</color>
|
||||||
</resources>
|
</resources>
|
||||||
|
|
||||||
|
|||||||
@@ -126,6 +126,11 @@
|
|||||||
<color name="face_anim_particle_color_4">#fffdd835</color> <!-- Material Yellow 600 -->
|
<color name="face_anim_particle_color_4">#fffdd835</color> <!-- Material Yellow 600 -->
|
||||||
<color name="face_anim_particle_error">#ff9e9e9e</color> <!-- Material Gray 500 -->
|
<color name="face_anim_particle_error">#ff9e9e9e</color> <!-- Material Gray 500 -->
|
||||||
|
|
||||||
|
<!-- Face and fingerprint enrollment -->
|
||||||
|
<color name="biometric_enroll_intro_color_bar">#1e8e3e</color>
|
||||||
|
<color name="biometric_enroll_intro_color_icon">#1a73e8</color>
|
||||||
|
<color name="biometric_enroll_intro_color_outline">#e3e3e3</color>
|
||||||
|
|
||||||
<!-- notification settings -->
|
<!-- notification settings -->
|
||||||
<color name="notification_block_color">#ffff0000</color>
|
<color name="notification_block_color">#ffff0000</color>
|
||||||
<color name="notification_silence_color">#FF32c1de</color>
|
<color name="notification_silence_color">#FF32c1de</color>
|
||||||
@@ -145,7 +150,7 @@
|
|||||||
<!-- End of QR code scanner colors -->
|
<!-- End of QR code scanner colors -->
|
||||||
|
|
||||||
<!-- Search bar background color -->
|
<!-- Search bar background color -->
|
||||||
<color name="search_bar_background">?androidprv:attr/colorSurface</color>
|
<color name="search_bar_background">?androidprv:attr/colorSurfaceHighlight</color>
|
||||||
|
|
||||||
<color name="face_intro_outline">#ffdadce0</color>
|
<color name="face_intro_outline">#ffdadce0</color>
|
||||||
|
|
||||||
|
|||||||
@@ -103,7 +103,7 @@
|
|||||||
<!-- Disclaimer for camera based rotate [CHAR_LIMIT=NONE] -->
|
<!-- Disclaimer for camera based rotate [CHAR_LIMIT=NONE] -->
|
||||||
<string name="smart_rotate_text_headline">
|
<string name="smart_rotate_text_headline">
|
||||||
Face Detection uses the front-facing camera to improve Auto-rotate accuracy. Images are never stored or sent to Google.<br><br>
|
Face Detection uses the front-facing camera to improve Auto-rotate accuracy. Images are never stored or sent to Google.<br><br>
|
||||||
<a href="<xliff:g example="http://www.google.com" id="url">http://support.google.com/mobile?p=telephony_rtt</xliff:g>">Learn more</a>
|
<a href="<xliff:g example="http://www.google.com" id="url">http://support.google.com/mobile?p=telephony_rtt</xliff:g>">Learn more about Auto-rotate screen</a>
|
||||||
</string>
|
</string>
|
||||||
<string name="font_size_preview_text_headline">Sample text</string>
|
<string name="font_size_preview_text_headline">Sample text</string>
|
||||||
<string name="font_size_preview_text_title"
|
<string name="font_size_preview_text_title"
|
||||||
@@ -695,9 +695,8 @@
|
|||||||
emergency responders when you call or text an emergency number.
|
emergency responders when you call or text an emergency number.
|
||||||
</string>
|
</string>
|
||||||
<!-- Location settings footer link to support page [CHAR LIMIT=NONE] -->
|
<!-- Location settings footer link to support page [CHAR LIMIT=NONE] -->
|
||||||
<string name="location_settings_footer_learn_more">
|
<string name="location_settings_footer_learn_more_link" translatable="false">
|
||||||
<a href="<xliff:g example="http://www.google.com"
|
https://support.google.com/android/answer/3467281
|
||||||
id="url"> https://support.google.com/android/answer/3467281</xliff:g>">Learn more</a>
|
|
||||||
</string>
|
</string>
|
||||||
<!-- Location settings footer link content description [CHAR LIMIT=NONE] -->
|
<!-- Location settings footer link content description [CHAR LIMIT=NONE] -->
|
||||||
<string name="location_settings_footer_learn_more_content_description">
|
<string name="location_settings_footer_learn_more_content_description">
|
||||||
@@ -5335,8 +5334,8 @@
|
|||||||
<string name="accessibility_shortcut_edit_dialog_summary_software_gesture_talkback">Swipe up from the bottom of the screen with 3 fingers.\n\nTo switch between features, swipe up with 3 fingers and hold.</string>
|
<string name="accessibility_shortcut_edit_dialog_summary_software_gesture_talkback">Swipe up from the bottom of the screen with 3 fingers.\n\nTo switch between features, swipe up with 3 fingers and hold.</string>
|
||||||
<!-- Summary for software shortcut in accessibility edit shortcut dialog when user had enabled the accessibility floating button mode (Floating over other apps). [CHAR LIMIT=NONE] -->
|
<!-- Summary for software shortcut in accessibility edit shortcut dialog when user had enabled the accessibility floating button mode (Floating over other apps). [CHAR LIMIT=NONE] -->
|
||||||
<string name="accessibility_shortcut_edit_dialog_summary_software_floating"><annotation id="link">Customize accessibility button</annotation></string>
|
<string name="accessibility_shortcut_edit_dialog_summary_software_floating"><annotation id="link">Customize accessibility button</annotation></string>
|
||||||
<!-- Summary for footer to show help link. [CHAR LIMIT=NONE] -->
|
<!-- Footer to show help link content description. [CHAR LIMIT=NONE] -->
|
||||||
<string name="footer_learn_more"><annotation id="link">Learn more</annotation></string>
|
<string name="footer_learn_more_content_description">Learn more about <xliff:g id="service" example="Select to Speak">%1$s</xliff:g></string>
|
||||||
<!-- Title for hardware shortcut in accessibility edit shortcut dialog. [CHAR LIMIT=NONE] -->
|
<!-- Title for hardware shortcut in accessibility edit shortcut dialog. [CHAR LIMIT=NONE] -->
|
||||||
<string name="accessibility_shortcut_edit_dialog_title_hardware">Hold volume keys</string>
|
<string name="accessibility_shortcut_edit_dialog_title_hardware">Hold volume keys</string>
|
||||||
<!-- Part of list to compose user's accessibility shortcut list. [CHAR LIMIT=NONE] -->
|
<!-- Part of list to compose user's accessibility shortcut list. [CHAR LIMIT=NONE] -->
|
||||||
@@ -6052,7 +6051,7 @@
|
|||||||
<!-- Activity title for battery usage history details [CHAR LIMIT=60] -->
|
<!-- Activity title for battery usage history details [CHAR LIMIT=60] -->
|
||||||
<string name="history_details_title">History details</string>
|
<string name="history_details_title">History details</string>
|
||||||
<!-- Preference title for advanced battery usage [CHAR LIMIT=40] -->
|
<!-- Preference title for advanced battery usage [CHAR LIMIT=40] -->
|
||||||
<string name="advanced_battery_preference_title">View battery usage</string>
|
<string name="advanced_battery_preference_title">Battery Usage</string>
|
||||||
<!-- Preference summary for advanced battery usage, for past 24 hours [CHAR LIMIT=40] -->
|
<!-- Preference summary for advanced battery usage, for past 24 hours [CHAR LIMIT=40] -->
|
||||||
<string name="advanced_battery_preference_summary_with_hours">View usage for past 24 hours</string>
|
<string name="advanced_battery_preference_summary_with_hours">View usage for past 24 hours</string>
|
||||||
<!-- Preference summary for advanced battery usage, from last full charge [CHAR LIMIT=40] -->
|
<!-- Preference summary for advanced battery usage, from last full charge [CHAR LIMIT=40] -->
|
||||||
@@ -6100,7 +6099,7 @@
|
|||||||
<!-- Title for the battery limited temporarily tip [CHAR LIMIT=NONE] -->
|
<!-- Title for the battery limited temporarily tip [CHAR LIMIT=NONE] -->
|
||||||
<string name="battery_tip_limited_temporarily_title">Charging temporarily limited</string>
|
<string name="battery_tip_limited_temporarily_title">Charging temporarily limited</string>
|
||||||
<!-- Summary for the battery limited temporarily tip [CHAR LIMIT=NONE] -->
|
<!-- Summary for the battery limited temporarily tip [CHAR LIMIT=NONE] -->
|
||||||
<string name="battery_tip_limited_temporarily_summary">Battery limited temporarily. Learn more.</string>
|
<string name="battery_tip_limited_temporarily_summary">To preserve your battery. Learn more.</string>
|
||||||
<!-- Message for battery tip dialog to show the status about the battery [CHAR LIMIT=NONE] -->
|
<!-- Message for battery tip dialog to show the status about the battery [CHAR LIMIT=NONE] -->
|
||||||
<string name="battery_tip_dialog_message" product="default">Your phone has been used more than usual. Your battery may run out sooner than expected.\n\nTop apps by battery usage:</string>
|
<string name="battery_tip_dialog_message" product="default">Your phone has been used more than usual. Your battery may run out sooner than expected.\n\nTop apps by battery usage:</string>
|
||||||
<!-- Message for battery tip dialog to show the status about the battery [CHAR LIMIT=NONE] -->
|
<!-- Message for battery tip dialog to show the status about the battery [CHAR LIMIT=NONE] -->
|
||||||
@@ -6201,9 +6200,11 @@
|
|||||||
<string name="battery_header_title_alternate"><xliff:g id="number" example="88">^1</xliff:g><small> <font size="20"><xliff:g id="unit" example="%">%</xliff:g></font></small></string>
|
<string name="battery_header_title_alternate"><xliff:g id="number" example="88">^1</xliff:g><small> <font size="20"><xliff:g id="unit" example="%">%</xliff:g></font></small></string>
|
||||||
|
|
||||||
<!-- Summary for top level battery tile if battery is not present. [CHAR LIMIT=NONE] -->
|
<!-- Summary for top level battery tile if battery is not present. [CHAR LIMIT=NONE] -->
|
||||||
<string name="battery_missing_message">Can’t update battery info</string>
|
<string name="battery_missing_message">Problem reading the battery meter.</string>
|
||||||
<!-- Help text if battery is not present. [CHAR LIMIT=NONE] -->
|
<!-- Help text if battery is not present. [CHAR LIMIT=NONE] -->
|
||||||
<string name="battery_missing_link_message"></string>
|
<string name="battery_missing_link_message"></string>
|
||||||
|
<!-- Accessibility description for battery missing link. [CHAR LIMIT=NONE] -->
|
||||||
|
<string name="battery_missing_link_a11y_message">Tap to learn more about this error</string>
|
||||||
|
|
||||||
<!-- Title for force stop dialog [CHAR LIMIT=30] -->
|
<!-- Title for force stop dialog [CHAR LIMIT=30] -->
|
||||||
<string name="dialog_stop_title">Stop app?</string>
|
<string name="dialog_stop_title">Stop app?</string>
|
||||||
@@ -8252,10 +8253,10 @@
|
|||||||
<string name="keywords_bluetooth_settings">connected, device, headphones, headset, speaker, wireless, pair, earbuds, music, media </string>
|
<string name="keywords_bluetooth_settings">connected, device, headphones, headset, speaker, wireless, pair, earbuds, music, media </string>
|
||||||
|
|
||||||
<!-- List of synonyms for the Wallpaper picker setting, used to match in settings search [CHAR LIMIT=NONE] -->
|
<!-- List of synonyms for the Wallpaper picker setting, used to match in settings search [CHAR LIMIT=NONE] -->
|
||||||
<string name="keywords_wallpaper">background, screen, lockscreen, theme</string>
|
<string name="keywords_wallpaper">background, theme, grid, customize, personalize</string>
|
||||||
|
|
||||||
<!-- List of synonyms for the Styles picker setting, used to match in settings search [CHAR LIMIT=NONE] -->
|
<!-- List of synonyms for the Styles picker setting, used to match in settings search [CHAR LIMIT=NONE] -->
|
||||||
<string name="keywords_styles">icon shape, accent color, font</string>
|
<string name="keywords_styles">icon, accent, color</string>
|
||||||
|
|
||||||
<!-- List of synonyms for the Default Assist and Voice input setting, used to match in settings search [CHAR LIMIT=NONE] -->
|
<!-- List of synonyms for the Default Assist and Voice input setting, used to match in settings search [CHAR LIMIT=NONE] -->
|
||||||
<string name="keywords_assist_input">default, assistant</string>
|
<string name="keywords_assist_input">default, assistant</string>
|
||||||
@@ -10473,13 +10474,13 @@
|
|||||||
Allowing <xliff:g id="app_name" example="Settings">%1$s</xliff:g> to always run in the background may reduce battery life.
|
Allowing <xliff:g id="app_name" example="Settings">%1$s</xliff:g> to always run in the background may reduce battery life.
|
||||||
\n\nYou can change this later from Settings > Apps & notifications.</string>
|
\n\nYou can change this later from Settings > Apps & notifications.</string>
|
||||||
<!-- Summary of power usage for an app [CHAR LIMIT=NONE] -->
|
<!-- Summary of power usage for an app [CHAR LIMIT=NONE] -->
|
||||||
<string name="battery_summary"><xliff:g id="percentage" example="2">%1$s</xliff:g> use since last full charge</string>
|
<string name="battery_summary"><xliff:g id="percentage" example="2">%1$s</xliff:g> use for past 24 hours</string>
|
||||||
|
|
||||||
<!-- Title of a group of settings that let you manage settings that affect battery life [CHAR LIMIT=60] -->
|
<!-- Title of a group of settings that let you manage settings that affect battery life [CHAR LIMIT=60] -->
|
||||||
<string name="battery_power_management">Power management</string>
|
<string name="battery_power_management">Power management</string>
|
||||||
|
|
||||||
<!-- Summary for app with no battery usage [CHAR LIMIT=NONE] -->
|
<!-- Summary for app with no battery usage [CHAR LIMIT=NONE] -->
|
||||||
<string name="no_battery_summary">No battery use since last full charge</string>
|
<string name="no_battery_summary">No battery use for past 24 hours</string>
|
||||||
|
|
||||||
<!-- Link to an apps notification settings [CHAR LIMIT=50] -->
|
<!-- Link to an apps notification settings [CHAR LIMIT=50] -->
|
||||||
<string name="app_notification_preferences">App settings</string>
|
<string name="app_notification_preferences">App settings</string>
|
||||||
@@ -12911,9 +12912,6 @@
|
|||||||
<!-- UI debug setting: Force enable "smart dark" UI rendering feature summary [CHAR LIMIT=NONE] -->
|
<!-- UI debug setting: Force enable "smart dark" UI rendering feature summary [CHAR LIMIT=NONE] -->
|
||||||
<string name="hwui_force_dark_summary">Overrides the force-dark feature to be always-on</string>
|
<string name="hwui_force_dark_summary">Overrides the force-dark feature to be always-on</string>
|
||||||
|
|
||||||
<!-- If blurs are supported on SurfaceFlinger. [CHAR LIMIT=60] -->
|
|
||||||
<string name="enable_blurs_on_windows_title">Window-level blurs</string>
|
|
||||||
|
|
||||||
<!-- Title for the top level Privacy Settings [CHAR LIMIT=30]-->
|
<!-- Title for the top level Privacy Settings [CHAR LIMIT=30]-->
|
||||||
<string name="privacy_dashboard_title">Privacy</string>
|
<string name="privacy_dashboard_title">Privacy</string>
|
||||||
<!-- Summary for the top level Privacy Settings [CHAR LIMIT=NONE]-->
|
<!-- Summary for the top level Privacy Settings [CHAR LIMIT=NONE]-->
|
||||||
|
|||||||
@@ -308,10 +308,11 @@
|
|||||||
<item name="android:textColor">?android:attr/textColorPrimary</item>
|
<item name="android:textColor">?android:attr/textColorPrimary</item>
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
<style name="TextAppearance.SearchBar"
|
<style name="TextAppearance.SearchBar">
|
||||||
parent="@*android:style/TextAppearance.DeviceDefault.Widget.Toolbar.Subtitle">
|
<item name="android:layout_gravity">center</item>
|
||||||
|
<item name="android:fontFamily">@*android:string/config_headlineFontFamily</item>
|
||||||
<item name="android:textSize">@dimen/search_bar_text_size</item>
|
<item name="android:textSize">@dimen/search_bar_text_size</item>
|
||||||
<item name="android:textColor">?android:attr/textColorTertiary</item>
|
<item name="android:textColor">?android:attr/textColorSecondary</item>
|
||||||
<item name="android:singleLine">true</item>
|
<item name="android:singleLine">true</item>
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
|
|||||||
@@ -27,10 +27,11 @@
|
|||||||
settings:preview="@drawable/aab_brightness"
|
settings:preview="@drawable/aab_brightness"
|
||||||
settings:controller="com.android.settings.widget.VideoPreferenceController"/>
|
settings:controller="com.android.settings.widget.VideoPreferenceController"/>
|
||||||
|
|
||||||
<com.android.settingslib.widget.MainSwitchPreference
|
<com.android.settings.widget.SettingsMainSwitchPreference
|
||||||
android:key="auto_brightness"
|
android:key="auto_brightness"
|
||||||
android:title="@string/adaptive_brightness_main_switch_title"
|
android:title="@string/adaptive_brightness_main_switch_title"
|
||||||
settings:keywords="@string/keywords_display_auto_brightness"
|
settings:keywords="@string/keywords_display_auto_brightness"
|
||||||
|
settings:userRestriction="no_config_brightness"
|
||||||
settings:controller="com.android.settings.display.AutoBrightnessDetailPreferenceController"/>
|
settings:controller="com.android.settings.display.AutoBrightnessDetailPreferenceController"/>
|
||||||
|
|
||||||
<com.android.settingslib.widget.FooterPreference
|
<com.android.settingslib.widget.FooterPreference
|
||||||
|
|||||||
@@ -20,6 +20,11 @@
|
|||||||
xmlns:settings="http://schemas.android.com/apk/res-auto"
|
xmlns:settings="http://schemas.android.com/apk/res-auto"
|
||||||
android:title="@string/accelerometer_title" >
|
android:title="@string/accelerometer_title" >
|
||||||
|
|
||||||
|
<SwitchPreference
|
||||||
|
android:key="auto_rotate_switch"
|
||||||
|
android:title="@string/auto_rotate_settings_primary_switch_title"
|
||||||
|
settings:controller="com.android.settings.display.AutoRotatePreferenceController"/>
|
||||||
|
|
||||||
<com.android.settingslib.widget.BannerMessagePreference
|
<com.android.settingslib.widget.BannerMessagePreference
|
||||||
android:key="face_rotate_permission"
|
android:key="face_rotate_permission"
|
||||||
android:title="@string/adaptive_sleep_title_no_permission"
|
android:title="@string/adaptive_sleep_title_no_permission"
|
||||||
|
|||||||
@@ -490,7 +490,7 @@
|
|||||||
|
|
||||||
<SwitchPreference
|
<SwitchPreference
|
||||||
android:key="enable_blurs_on_windows"
|
android:key="enable_blurs_on_windows"
|
||||||
android:title="@string/enable_blurs_on_windows_title"/>
|
android:title="@string/window_blurs"/>
|
||||||
|
|
||||||
<SwitchPreference
|
<SwitchPreference
|
||||||
android:key="force_msaa"
|
android:key="force_msaa"
|
||||||
|
|||||||
@@ -71,7 +71,6 @@
|
|||||||
<com.android.settingslib.widget.FooterPreference
|
<com.android.settingslib.widget.FooterPreference
|
||||||
android:title="@string/location_settings_footer_general"
|
android:title="@string/location_settings_footer_general"
|
||||||
android:key="location_footer"
|
android:key="location_footer"
|
||||||
android:selectable="false"
|
|
||||||
settings:searchable="false"
|
settings:searchable="false"
|
||||||
settings:controller="com.android.settings.location.LocationSettingsFooterPreferenceController"/>
|
settings:controller="com.android.settings.location.LocationSettingsFooterPreferenceController"/>
|
||||||
</PreferenceScreen>
|
</PreferenceScreen>
|
||||||
|
|||||||
@@ -64,7 +64,7 @@
|
|||||||
android:key="manage_mobile_plan"
|
android:key="manage_mobile_plan"
|
||||||
android:title="@string/manage_mobile_plan_title"
|
android:title="@string/manage_mobile_plan_title"
|
||||||
android:persistent="false"
|
android:persistent="false"
|
||||||
android:order="0"
|
android:order="19"
|
||||||
settings:userRestriction="no_config_mobile_networks"
|
settings:userRestriction="no_config_mobile_networks"
|
||||||
settings:useAdminDisabledSummary="true" />
|
settings:useAdminDisabledSummary="true" />
|
||||||
|
|
||||||
|
|||||||
@@ -64,7 +64,7 @@
|
|||||||
android:key="manage_mobile_plan"
|
android:key="manage_mobile_plan"
|
||||||
android:title="@string/manage_mobile_plan_title"
|
android:title="@string/manage_mobile_plan_title"
|
||||||
android:persistent="false"
|
android:persistent="false"
|
||||||
android:order="0"
|
android:order="19"
|
||||||
settings:userRestriction="no_config_mobile_networks"
|
settings:userRestriction="no_config_mobile_networks"
|
||||||
settings:useAdminDisabledSummary="true" />
|
settings:useAdminDisabledSummary="true" />
|
||||||
|
|
||||||
|
|||||||
@@ -21,13 +21,11 @@
|
|||||||
android:key="privacy_dashboard_page"
|
android:key="privacy_dashboard_page"
|
||||||
android:title="@string/privacy_dashboard_title">
|
android:title="@string/privacy_dashboard_title">
|
||||||
|
|
||||||
|
|
||||||
<!-- Work Policy info -->
|
<!-- Work Policy info -->
|
||||||
<Preference
|
<Preference
|
||||||
android:key="work_policy_info"
|
android:key="work_policy_info"
|
||||||
android:title="@string/work_policy_privacy_settings"
|
android:title="@string/work_policy_privacy_settings"
|
||||||
android:summary="@string/work_policy_privacy_settings_summary"
|
android:summary="@string/work_policy_privacy_settings_summary"
|
||||||
settings:allowDividerAbove="true"
|
|
||||||
settings:controller="com.android.settings.privacy.WorkPolicyInfoPreferenceController"/>
|
settings:controller="com.android.settings.privacy.WorkPolicyInfoPreferenceController"/>
|
||||||
|
|
||||||
<!-- Connected work and personal apps -->
|
<!-- Connected work and personal apps -->
|
||||||
@@ -42,7 +40,6 @@
|
|||||||
<Preference
|
<Preference
|
||||||
android:key="privacy_accessibility_usage"
|
android:key="privacy_accessibility_usage"
|
||||||
android:title="@string/accessibility_usage_title"
|
android:title="@string/accessibility_usage_title"
|
||||||
settings:allowDividerAbove="true"
|
|
||||||
settings:controller="com.android.settings.privacy.AccessibilityUsagePreferenceController">
|
settings:controller="com.android.settings.privacy.AccessibilityUsagePreferenceController">
|
||||||
<intent android:action="android.intent.action.REVIEW_ACCESSIBILITY_SERVICES"/>
|
<intent android:action="android.intent.action.REVIEW_ACCESSIBILITY_SERVICES"/>
|
||||||
</Preference>
|
</Preference>
|
||||||
@@ -52,7 +49,6 @@
|
|||||||
android:key="privacy_permissions_usage"
|
android:key="privacy_permissions_usage"
|
||||||
android:title="@string/permissions_usage_title"
|
android:title="@string/permissions_usage_title"
|
||||||
android:summary="@string/permissions_usage_summary"
|
android:summary="@string/permissions_usage_summary"
|
||||||
settings:allowDividerAbove="true"
|
|
||||||
settings:searchable="false"
|
settings:searchable="false"
|
||||||
settings:controller="com.android.settings.privacy.PrivacyHubPreferenceController">
|
settings:controller="com.android.settings.privacy.PrivacyHubPreferenceController">
|
||||||
<intent android:action="android.intent.action.REVIEW_PERMISSION_USAGE"/>
|
<intent android:action="android.intent.action.REVIEW_PERMISSION_USAGE"/>
|
||||||
|
|||||||
@@ -70,21 +70,17 @@
|
|||||||
settings:controller="com.android.settings.biometrics.face.FaceSettingsLockscreenBypassPreferenceController" />
|
settings:controller="com.android.settings.biometrics.face.FaceSettingsLockscreenBypassPreferenceController" />
|
||||||
</PreferenceCategory>
|
</PreferenceCategory>
|
||||||
|
|
||||||
<PreferenceCategory
|
<com.android.settingslib.widget.LayoutPreference
|
||||||
android:key="security_settings_face_button_category"
|
android:key="security_settings_face_delete_faces_container"
|
||||||
android:title="@string/security_settings_face_preference_title">
|
android:title="@string/security_settings_face_settings_remove_face_model"
|
||||||
<com.android.settingslib.widget.LayoutPreference
|
android:selectable="false"
|
||||||
android:key="security_settings_face_delete_faces_container"
|
android:layout="@layout/face_remove_button"/>
|
||||||
android:title="@string/security_settings_face_settings_remove_face_model"
|
|
||||||
android:selectable="false"
|
|
||||||
android:layout="@layout/face_remove_button"/>
|
|
||||||
|
|
||||||
<com.android.settingslib.widget.LayoutPreference
|
<com.android.settingslib.widget.LayoutPreference
|
||||||
android:key="security_settings_face_enroll_faces_container"
|
android:key="security_settings_face_enroll_faces_container"
|
||||||
android:title="@string/security_settings_face_settings_enroll"
|
android:title="@string/security_settings_face_settings_enroll"
|
||||||
android:selectable="false"
|
android:selectable="false"
|
||||||
android:layout="@layout/face_enroll_button"/>
|
android:layout="@layout/face_enroll_button"/>
|
||||||
</PreferenceCategory>
|
|
||||||
|
|
||||||
<com.android.settingslib.widget.FooterPreference
|
<com.android.settingslib.widget.FooterPreference
|
||||||
android:key="security_face_footer"
|
android:key="security_face_footer"
|
||||||
|
|||||||
@@ -26,13 +26,6 @@
|
|||||||
android:summary="@string/wifi_wakeup_summary"
|
android:summary="@string/wifi_wakeup_summary"
|
||||||
settings:controller="com.android.settings.wifi.WifiWakeupPreferenceController"/>
|
settings:controller="com.android.settings.wifi.WifiWakeupPreferenceController"/>
|
||||||
|
|
||||||
<SwitchPreference
|
|
||||||
android:key="use_open_wifi_automatically"
|
|
||||||
android:icon="@drawable/ic_open_wifi_autoconnect"
|
|
||||||
android:title="@string/use_open_wifi_automatically_title"
|
|
||||||
android:summary="@string/use_open_wifi_automatically_summary"
|
|
||||||
settings:controller="com.android.settings.wifi.UseOpenWifiPreferenceController"/>
|
|
||||||
|
|
||||||
<SwitchPreference
|
<SwitchPreference
|
||||||
android:key="notify_open_networks"
|
android:key="notify_open_networks"
|
||||||
android:title="@string/wifi_notify_open_networks"
|
android:title="@string/wifi_notify_open_networks"
|
||||||
|
|||||||
@@ -111,9 +111,9 @@ public class SettingsDumpService extends Service {
|
|||||||
for (SubscriptionInfo info : manager.getAvailableSubscriptionInfoList()) {
|
for (SubscriptionInfo info : manager.getAvailableSubscriptionInfoList()) {
|
||||||
telephonyManager = telephonyManager
|
telephonyManager = telephonyManager
|
||||||
.createForSubscriptionId(info.getSubscriptionId());
|
.createForSubscriptionId(info.getSubscriptionId());
|
||||||
NetworkTemplate mobileAll = NetworkTemplate.buildTemplateMobileAll(
|
NetworkTemplate carrier = NetworkTemplate.buildTemplateCarrierMetered(
|
||||||
telephonyManager.getSubscriberId());
|
telephonyManager.getSubscriberId());
|
||||||
final JSONObject usage = dumpDataUsage(mobileAll, controller);
|
final JSONObject usage = dumpDataUsage(carrier, controller);
|
||||||
usage.put("subId", info.getSubscriptionId());
|
usage.put("subId", info.getSubscriptionId());
|
||||||
array.put(usage);
|
array.put(usage);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,7 +26,6 @@ import android.content.pm.PackageManager;
|
|||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
import android.util.ArrayMap;
|
import android.util.ArrayMap;
|
||||||
import android.util.FeatureFlagUtils;
|
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
@@ -43,11 +42,8 @@ import androidx.preference.PreferenceScreen;
|
|||||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||||
import androidx.recyclerview.widget.RecyclerView;
|
import androidx.recyclerview.widget.RecyclerView;
|
||||||
|
|
||||||
import com.android.settings.core.FeatureFlags;
|
|
||||||
import com.android.settings.core.InstrumentedPreferenceFragment;
|
import com.android.settings.core.InstrumentedPreferenceFragment;
|
||||||
import com.android.settings.core.instrumentation.InstrumentedDialogFragment;
|
import com.android.settings.core.instrumentation.InstrumentedDialogFragment;
|
||||||
import com.android.settings.search.actionbar.SearchMenuController;
|
|
||||||
import com.android.settings.support.actionbar.HelpMenuController;
|
|
||||||
import com.android.settings.support.actionbar.HelpResourceProvider;
|
import com.android.settings.support.actionbar.HelpResourceProvider;
|
||||||
import com.android.settings.widget.HighlightablePreferenceGroupAdapter;
|
import com.android.settings.widget.HighlightablePreferenceGroupAdapter;
|
||||||
import com.android.settings.widget.LoadingViewController;
|
import com.android.settings.widget.LoadingViewController;
|
||||||
@@ -129,11 +125,6 @@ public abstract class SettingsPreferenceFragment extends InstrumentedPreferenceF
|
|||||||
@Override
|
@Override
|
||||||
public void onCreate(Bundle icicle) {
|
public void onCreate(Bundle icicle) {
|
||||||
super.onCreate(icicle);
|
super.onCreate(icicle);
|
||||||
// TODO(b/176883483): Remove both search and help menu if this feature rolled out
|
|
||||||
if (!FeatureFlagUtils.isEnabled(getContext(), FeatureFlags.SILKY_HOME)) {
|
|
||||||
SearchMenuController.init(this /* host */);
|
|
||||||
HelpMenuController.init(this /* host */);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (icicle != null) {
|
if (icicle != null) {
|
||||||
mPreferenceHighlighted = icicle.getBoolean(SAVE_HIGHLIGHTED_KEY);
|
mPreferenceHighlighted = icicle.getBoolean(SAVE_HIGHLIGHTED_KEY);
|
||||||
|
|||||||
@@ -110,7 +110,6 @@ import androidx.preference.PreferenceGroup;
|
|||||||
import com.android.internal.app.UnlaunchableAppActivity;
|
import com.android.internal.app.UnlaunchableAppActivity;
|
||||||
import com.android.internal.util.ArrayUtils;
|
import com.android.internal.util.ArrayUtils;
|
||||||
import com.android.internal.widget.LockPatternUtils;
|
import com.android.internal.widget.LockPatternUtils;
|
||||||
import com.android.settings.core.FeatureFlags;
|
|
||||||
import com.android.settings.dashboard.profileselector.ProfileFragmentBridge;
|
import com.android.settings.dashboard.profileselector.ProfileFragmentBridge;
|
||||||
import com.android.settings.dashboard.profileselector.ProfileSelectFragment;
|
import com.android.settings.dashboard.profileselector.ProfileSelectFragment;
|
||||||
import com.android.settings.password.ChooseLockSettingsHelper;
|
import com.android.settings.password.ChooseLockSettingsHelper;
|
||||||
@@ -1220,7 +1219,7 @@ public final class Utils extends com.android.settingslib.Utils {
|
|||||||
*/
|
*/
|
||||||
@ColorInt
|
@ColorInt
|
||||||
public static int getHomepageIconColor(Context context) {
|
public static int getHomepageIconColor(Context context) {
|
||||||
return getColorAttrDefaultColor(context, android.R.attr.textColorPrimary);
|
return getColorAttrDefaultColor(context, android.R.attr.textColorSecondary);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isProviderModelEnabled(Context context) {
|
public static boolean isProviderModelEnabled(Context context) {
|
||||||
@@ -1228,10 +1227,7 @@ public final class Utils extends com.android.settingslib.Utils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isPageTransitionEnabled(Context context) {
|
public static boolean isPageTransitionEnabled(Context context) {
|
||||||
final boolean isSilkyHome = FeatureFlagUtils.isEnabled(context, FeatureFlags.SILKY_HOME);
|
return Settings.Global.getInt(context.getContentResolver(),
|
||||||
final boolean isTransitionEnabled = Settings.Global.getInt(context.getContentResolver(),
|
|
||||||
SETTINGS_SHARED_AXIS_ENABLED, 0) == 1;
|
SETTINGS_SHARED_AXIS_ENABLED, 0) == 1;
|
||||||
|
|
||||||
return isSilkyHome && isTransitionEnabled;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,29 +17,19 @@
|
|||||||
package com.android.settings.accessibility;
|
package com.android.settings.accessibility;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
|
||||||
import android.text.SpannableStringBuilder;
|
|
||||||
import android.text.TextUtils;
|
|
||||||
import android.text.method.LinkMovementMethod;
|
import android.text.method.LinkMovementMethod;
|
||||||
import android.util.AttributeSet;
|
import android.util.AttributeSet;
|
||||||
import android.widget.LinearLayout;
|
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
import androidx.preference.PreferenceViewHolder;
|
import androidx.preference.PreferenceViewHolder;
|
||||||
|
|
||||||
import com.android.settings.R;
|
|
||||||
import com.android.settings.utils.AnnotationSpan;
|
|
||||||
import com.android.settingslib.HelpUtils;
|
|
||||||
import com.android.settingslib.widget.FooterPreference;
|
import com.android.settingslib.widget.FooterPreference;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A custom preference acting as footer of a page. It has a field for icon and text. It is added
|
* A custom preference acting as footer of a page. Disables the movement method by default.
|
||||||
* to screen as the last preference and groups of icon and text content in accessibility-focusable
|
|
||||||
* {@link android.view.accessibility.AccessibilityNodeInfo} for TalkBack to use.
|
|
||||||
*/
|
*/
|
||||||
public final class AccessibilityFooterPreference extends FooterPreference {
|
public final class AccessibilityFooterPreference extends FooterPreference {
|
||||||
|
|
||||||
private CharSequence mIconContentDescription;
|
|
||||||
private boolean mLinkEnabled;
|
private boolean mLinkEnabled;
|
||||||
|
|
||||||
public AccessibilityFooterPreference(Context context, AttributeSet attrs) {
|
public AccessibilityFooterPreference(Context context, AttributeSet attrs) {
|
||||||
@@ -65,33 +55,6 @@ public final class AccessibilityFooterPreference extends FooterPreference {
|
|||||||
} else {
|
} else {
|
||||||
title.setMovementMethod(/* movement= */ null);
|
title.setMovementMethod(/* movement= */ null);
|
||||||
}
|
}
|
||||||
|
|
||||||
final LinearLayout infoFrame = holder.itemView.findViewById(R.id.icon_frame);
|
|
||||||
if (!TextUtils.isEmpty(mIconContentDescription)) {
|
|
||||||
// Groups related content.
|
|
||||||
infoFrame.setContentDescription(mIconContentDescription);
|
|
||||||
title.setFocusable(false);
|
|
||||||
} else {
|
|
||||||
infoFrame.setContentDescription(null);
|
|
||||||
title.setFocusable(true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets the content description of the icon.
|
|
||||||
*/
|
|
||||||
public void setIconContentDescription(CharSequence iconContentDescription) {
|
|
||||||
if (!TextUtils.equals(iconContentDescription, mIconContentDescription)) {
|
|
||||||
mIconContentDescription = iconContentDescription;
|
|
||||||
notifyChanged();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the content description of the icon.
|
|
||||||
*/
|
|
||||||
public CharSequence getIconContentDescription() {
|
|
||||||
return mIconContentDescription;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -110,23 +73,4 @@ public final class AccessibilityFooterPreference extends FooterPreference {
|
|||||||
public boolean isLinkEnabled() {
|
public boolean isLinkEnabled() {
|
||||||
return mLinkEnabled;
|
return mLinkEnabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Appends {@link AnnotationSpan} with learn more link apart from the other text.
|
|
||||||
*
|
|
||||||
* @param helpLinkRes The Help Uri Resource key
|
|
||||||
*/
|
|
||||||
public void appendHelpLink(int helpLinkRes) {
|
|
||||||
final SpannableStringBuilder sb = new SpannableStringBuilder();
|
|
||||||
sb.append(getTitle()).append("\n\n").append(getLearnMoreLink(getContext(), helpLinkRes));
|
|
||||||
setTitle(sb);
|
|
||||||
}
|
|
||||||
|
|
||||||
private CharSequence getLearnMoreLink(Context context, int helpLinkRes) {
|
|
||||||
final Intent helpIntent = HelpUtils.getHelpIntent(
|
|
||||||
context, context.getString(helpLinkRes), context.getClass().getName());
|
|
||||||
final AnnotationSpan.LinkInfo linkInfo = new AnnotationSpan.LinkInfo(
|
|
||||||
context, AnnotationSpan.LinkInfo.DEFAULT_ANNOTATION, helpIntent);
|
|
||||||
return AnnotationSpan.linkify(context.getText(R.string.footer_learn_more), linkInfo);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,11 +17,13 @@
|
|||||||
package com.android.settings.accessibility;
|
package com.android.settings.accessibility;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
import android.content.Intent;
|
||||||
|
|
||||||
import androidx.preference.PreferenceScreen;
|
import androidx.preference.PreferenceScreen;
|
||||||
|
|
||||||
import com.android.settings.R;
|
import com.android.settings.R;
|
||||||
import com.android.settings.core.BasePreferenceController;
|
import com.android.settings.core.BasePreferenceController;
|
||||||
|
import com.android.settingslib.HelpUtils;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Base class for accessibility preference footer.
|
* Base class for accessibility preference footer.
|
||||||
@@ -59,13 +61,24 @@ public abstract class AccessibilityFooterPreferenceController extends BasePrefer
|
|||||||
protected abstract String getLabelName();
|
protected abstract String getLabelName();
|
||||||
|
|
||||||
private void updateFooterPreferences(AccessibilityFooterPreference footerPreference) {
|
private void updateFooterPreferences(AccessibilityFooterPreference footerPreference) {
|
||||||
final String iconContentDescription = mContext.getString(
|
final StringBuffer sb = new StringBuffer();
|
||||||
R.string.accessibility_introduction_title, getLabelName());
|
sb.append(mContext.getString(
|
||||||
footerPreference.setIconContentDescription(iconContentDescription);
|
R.string.accessibility_introduction_title, getLabelName()))
|
||||||
|
.append("\n\n")
|
||||||
|
.append(footerPreference.getTitle());
|
||||||
|
footerPreference.setContentDescription(sb);
|
||||||
|
|
||||||
if (getHelpResource() != 0) {
|
if (getHelpResource() != 0) {
|
||||||
footerPreference.appendHelpLink(getHelpResource());
|
footerPreference.setLearnMoreAction(view -> {
|
||||||
footerPreference.setLinkEnabled(true);
|
final Intent helpIntent = HelpUtils.getHelpIntent(
|
||||||
|
mContext, mContext.getString(getHelpResource()),
|
||||||
|
mContext.getClass().getName());
|
||||||
|
view.startActivityForResult(helpIntent, 0);
|
||||||
|
});
|
||||||
|
|
||||||
|
final String learnMoreContentDescription = mContext.getString(
|
||||||
|
R.string.footer_learn_more_content_description, getLabelName());
|
||||||
|
footerPreference.setLearnMoreContentDescription(learnMoreContentDescription);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -55,6 +55,7 @@ import com.android.settings.accessibility.AccessibilityUtil.UserShortcutType;
|
|||||||
import com.android.settings.utils.LocaleUtils;
|
import com.android.settings.utils.LocaleUtils;
|
||||||
import com.android.settings.widget.SettingsMainSwitchBar;
|
import com.android.settings.widget.SettingsMainSwitchBar;
|
||||||
import com.android.settings.widget.SettingsMainSwitchPreference;
|
import com.android.settings.widget.SettingsMainSwitchPreference;
|
||||||
|
import com.android.settingslib.HelpUtils;
|
||||||
import com.android.settingslib.accessibility.AccessibilityUtils;
|
import com.android.settingslib.accessibility.AccessibilityUtils;
|
||||||
import com.android.settingslib.widget.OnMainSwitchChangeListener;
|
import com.android.settingslib.widget.OnMainSwitchChangeListener;
|
||||||
|
|
||||||
@@ -520,14 +521,25 @@ public abstract class ToggleFeaturePreferenceFragment extends SettingsPreference
|
|||||||
new AccessibilityFooterPreference(screen.getContext());
|
new AccessibilityFooterPreference(screen.getContext());
|
||||||
htmlFooterPreference.setKey(KEY_HTML_DESCRIPTION_PREFERENCE);
|
htmlFooterPreference.setKey(KEY_HTML_DESCRIPTION_PREFERENCE);
|
||||||
htmlFooterPreference.setSummary(htmlDescription);
|
htmlFooterPreference.setSummary(htmlDescription);
|
||||||
|
htmlFooterPreference.setContentDescription(
|
||||||
|
generateFooterContentDescription(htmlDescription));
|
||||||
|
|
||||||
// Only framework tools support help link
|
// Only framework tools support help link
|
||||||
if (getHelpResource() != 0) {
|
if (getHelpResource() != 0) {
|
||||||
htmlFooterPreference.appendHelpLink(getHelpResource());
|
htmlFooterPreference.setLearnMoreAction(view -> {
|
||||||
|
final Intent helpIntent = HelpUtils.getHelpIntent(
|
||||||
|
getContext(), getContext().getString(getHelpResource()),
|
||||||
|
getContext().getClass().getName());
|
||||||
|
view.startActivityForResult(helpIntent, 0);
|
||||||
|
});
|
||||||
|
|
||||||
|
final String learnMoreContentDescription = getPrefContext().getString(
|
||||||
|
R.string.footer_learn_more_content_description, mPackageName);
|
||||||
|
htmlFooterPreference.setLearnMoreContentDescription(learnMoreContentDescription);
|
||||||
htmlFooterPreference.setLinkEnabled(true);
|
htmlFooterPreference.setLinkEnabled(true);
|
||||||
} else {
|
} else {
|
||||||
htmlFooterPreference.setLinkEnabled(false);
|
htmlFooterPreference.setLinkEnabled(false);
|
||||||
}
|
}
|
||||||
htmlFooterPreference.setIconContentDescription(iconContentDescription);
|
|
||||||
screen.addPreference(htmlFooterPreference);
|
screen.addPreference(htmlFooterPreference);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -559,14 +571,33 @@ public abstract class ToggleFeaturePreferenceFragment extends SettingsPreference
|
|||||||
final AccessibilityFooterPreference footerPreference =
|
final AccessibilityFooterPreference footerPreference =
|
||||||
new AccessibilityFooterPreference(screen.getContext());
|
new AccessibilityFooterPreference(screen.getContext());
|
||||||
footerPreference.setSummary(summary);
|
footerPreference.setSummary(summary);
|
||||||
footerPreference.setIconContentDescription(iconContentDescription);
|
footerPreference.setContentDescription(
|
||||||
|
generateFooterContentDescription(summary));
|
||||||
|
|
||||||
|
// Only framework tools support help link
|
||||||
if (getHelpResource() != 0) {
|
if (getHelpResource() != 0) {
|
||||||
footerPreference.appendHelpLink(getHelpResource());
|
footerPreference.setLearnMoreAction(view -> {
|
||||||
footerPreference.setLinkEnabled(true);
|
final Intent helpIntent = HelpUtils.getHelpIntent(
|
||||||
|
getContext(), getContext().getString(getHelpResource()),
|
||||||
|
getContext().getClass().getName());
|
||||||
|
view.startActivityForResult(helpIntent, 0);
|
||||||
|
});
|
||||||
|
|
||||||
|
final String learnMoreContentDescription = getPrefContext().getString(
|
||||||
|
R.string.footer_learn_more_content_description, mPackageName);
|
||||||
|
footerPreference.setLearnMoreContentDescription(learnMoreContentDescription);
|
||||||
}
|
}
|
||||||
screen.addPreference(footerPreference);
|
screen.addPreference(footerPreference);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private CharSequence generateFooterContentDescription(CharSequence footerContent) {
|
||||||
|
final StringBuffer sb = new StringBuffer();
|
||||||
|
sb.append(getPrefContext().getString(
|
||||||
|
R.string.accessibility_introduction_title, mPackageName))
|
||||||
|
.append("\n\n")
|
||||||
|
.append(footerContent);
|
||||||
|
return sb;
|
||||||
|
}
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
void setupEditShortcutDialog(Dialog dialog) {
|
void setupEditShortcutDialog(Dialog dialog) {
|
||||||
final View dialogSoftwareView = dialog.findViewById(R.id.software_shortcut);
|
final View dialogSoftwareView = dialog.findViewById(R.id.software_shortcut);
|
||||||
|
|||||||
@@ -36,7 +36,12 @@ public interface ExtraAppInfoFeatureProvider {
|
|||||||
void setPackageName(String packageName);
|
void setPackageName(String packageName);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* gets the summary name
|
* Checks if enabled
|
||||||
|
*/
|
||||||
|
boolean isEnabled(Context context);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the summary name
|
||||||
*/
|
*/
|
||||||
String getSummary(Context context);
|
String getSummary(Context context);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -38,6 +38,11 @@ public class ExtraAppInfoFeatureProviderImpl implements
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isEnabled(Context context) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getSummary(Context context) {
|
public String getSummary(Context context) {
|
||||||
return "";
|
return "";
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ import android.content.Context;
|
|||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
|
|
||||||
import androidx.preference.Preference;
|
import androidx.preference.Preference;
|
||||||
|
import androidx.preference.PreferenceScreen;
|
||||||
|
|
||||||
import com.android.settings.core.BasePreferenceController;
|
import com.android.settings.core.BasePreferenceController;
|
||||||
import com.android.settings.overlay.FeatureFactory;
|
import com.android.settings.overlay.FeatureFactory;
|
||||||
@@ -55,6 +56,16 @@ public class ExtraAppInfoPreferenceController extends BasePreferenceController {
|
|||||||
return mExtraAppInfoFeatureProvider.getSummary(mContext);
|
return mExtraAppInfoFeatureProvider.getSummary(mContext);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void displayPreference(PreferenceScreen screen) {
|
||||||
|
super.displayPreference(screen);
|
||||||
|
|
||||||
|
if (mExtraAppInfoFeatureProvider != null) {
|
||||||
|
final Preference preference = screen.findPreference(getPreferenceKey());
|
||||||
|
preference.setEnabled(mExtraAppInfoFeatureProvider.isEnabled(preference.getContext()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the local package name
|
* Set the local package name
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -55,7 +55,6 @@ import android.os.UserManager;
|
|||||||
import android.preference.PreferenceFrameLayout;
|
import android.preference.PreferenceFrameLayout;
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
import android.util.ArraySet;
|
import android.util.ArraySet;
|
||||||
import android.util.FeatureFlagUtils;
|
|
||||||
import android.util.IconDrawableFactory;
|
import android.util.IconDrawableFactory;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
@@ -112,7 +111,6 @@ import com.android.settings.applications.appinfo.ExternalSourcesDetails;
|
|||||||
import com.android.settings.applications.appinfo.ManageExternalStorageDetails;
|
import com.android.settings.applications.appinfo.ManageExternalStorageDetails;
|
||||||
import com.android.settings.applications.appinfo.MediaManagementAppsDetails;
|
import com.android.settings.applications.appinfo.MediaManagementAppsDetails;
|
||||||
import com.android.settings.applications.appinfo.WriteSettingsDetails;
|
import com.android.settings.applications.appinfo.WriteSettingsDetails;
|
||||||
import com.android.settings.core.FeatureFlags;
|
|
||||||
import com.android.settings.core.InstrumentedFragment;
|
import com.android.settings.core.InstrumentedFragment;
|
||||||
import com.android.settings.core.SubSettingLauncher;
|
import com.android.settings.core.SubSettingLauncher;
|
||||||
import com.android.settings.dashboard.profileselector.ProfileSelectFragment;
|
import com.android.settings.dashboard.profileselector.ProfileSelectFragment;
|
||||||
@@ -123,7 +121,6 @@ import com.android.settings.notification.app.AppNotificationSettings;
|
|||||||
import com.android.settings.widget.LoadingViewController;
|
import com.android.settings.widget.LoadingViewController;
|
||||||
import com.android.settings.wifi.AppStateChangeWifiStateBridge;
|
import com.android.settings.wifi.AppStateChangeWifiStateBridge;
|
||||||
import com.android.settings.wifi.ChangeWifiStateDetails;
|
import com.android.settings.wifi.ChangeWifiStateDetails;
|
||||||
import com.android.settingslib.HelpUtils;
|
|
||||||
import com.android.settingslib.applications.ApplicationsState;
|
import com.android.settingslib.applications.ApplicationsState;
|
||||||
import com.android.settingslib.applications.ApplicationsState.AppEntry;
|
import com.android.settingslib.applications.ApplicationsState.AppEntry;
|
||||||
import com.android.settingslib.applications.ApplicationsState.AppFilter;
|
import com.android.settingslib.applications.ApplicationsState.AppFilter;
|
||||||
@@ -397,11 +394,7 @@ public class ManageApplications extends InstrumentedFragment
|
|||||||
return mRootView;
|
return mRootView;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (FeatureFlagUtils.isEnabled(getContext(), FeatureFlags.SILKY_HOME)) {
|
mRootView = inflater.inflate(R.layout.manage_applications_apps, null);
|
||||||
mRootView = inflater.inflate(R.layout.manage_applications_apps_v2, null);
|
|
||||||
} else {
|
|
||||||
mRootView = inflater.inflate(R.layout.manage_applications_apps, null);
|
|
||||||
}
|
|
||||||
mLoadingContainer = mRootView.findViewById(R.id.loading_container);
|
mLoadingContainer = mRootView.findViewById(R.id.loading_container);
|
||||||
mListContainer = mRootView.findViewById(R.id.list_container);
|
mListContainer = mRootView.findViewById(R.id.list_container);
|
||||||
if (mListContainer != null) {
|
if (mListContainer != null) {
|
||||||
@@ -661,10 +654,6 @@ public class ManageApplications extends InstrumentedFragment
|
|||||||
if (activity == null) {
|
if (activity == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// TODO(b/176883483): Remove the help menu if this feature rolled out
|
|
||||||
if (!FeatureFlagUtils.isEnabled(getContext(), FeatureFlags.SILKY_HOME)) {
|
|
||||||
HelpUtils.prepareHelpMenuItem(activity, menu, getHelpResource(), getClass().getName());
|
|
||||||
}
|
|
||||||
mOptionsMenu = menu;
|
mOptionsMenu = menu;
|
||||||
inflater.inflate(R.menu.manage_apps, menu);
|
inflater.inflate(R.menu.manage_apps, menu);
|
||||||
|
|
||||||
|
|||||||
@@ -266,10 +266,12 @@ public class BiometricEnrollActivity extends InstrumentedActivity {
|
|||||||
faceManager.getSensorPropertiesInternal();
|
faceManager.getSensorPropertiesInternal();
|
||||||
|
|
||||||
// This would need to be updated for devices with multiple sensors of the same modality
|
// This would need to be updated for devices with multiple sensors of the same modality
|
||||||
mIsFaceEnrollable = faceManager.getEnrolledFaces(mUserId).size()
|
mIsFaceEnrollable = !faceProperties.isEmpty() &&
|
||||||
< faceProperties.get(0).maxEnrollmentsPerUser;
|
faceManager.getEnrolledFaces(mUserId).size()
|
||||||
mIsFingerprintEnrollable = fingerprintManager.getEnrolledFingerprints(mUserId).size()
|
< faceProperties.get(0).maxEnrollmentsPerUser;
|
||||||
< fpProperties.get(0).maxEnrollmentsPerUser;
|
mIsFingerprintEnrollable = !fpProperties.isEmpty() &&
|
||||||
|
fingerprintManager.getEnrolledFingerprints(mUserId).size()
|
||||||
|
< fpProperties.get(0).maxEnrollmentsPerUser;
|
||||||
|
|
||||||
if (!mConfirmingCredentials) {
|
if (!mConfirmingCredentials) {
|
||||||
mConfirmingCredentials = true;
|
mConfirmingCredentials = true;
|
||||||
|
|||||||
@@ -18,6 +18,8 @@ package com.android.settings.biometrics;
|
|||||||
|
|
||||||
import android.app.admin.DevicePolicyManager;
|
import android.app.admin.DevicePolicyManager;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
|
import android.content.res.ColorStateList;
|
||||||
|
import android.graphics.Color;
|
||||||
import android.graphics.PorterDuff;
|
import android.graphics.PorterDuff;
|
||||||
import android.graphics.PorterDuffColorFilter;
|
import android.graphics.PorterDuffColorFilter;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
@@ -25,14 +27,17 @@ import android.os.UserHandle;
|
|||||||
import android.os.UserManager;
|
import android.os.UserManager;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
|
import android.widget.LinearLayout;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
|
import androidx.annotation.ColorInt;
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import androidx.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
|
|
||||||
import com.android.internal.widget.LockPatternUtils;
|
import com.android.internal.widget.LockPatternUtils;
|
||||||
import com.android.settings.R;
|
import com.android.settings.R;
|
||||||
import com.android.settings.SetupWizardUtils;
|
import com.android.settings.SetupWizardUtils;
|
||||||
|
import com.android.settings.Utils;
|
||||||
import com.android.settings.password.ChooseLockGeneric;
|
import com.android.settings.password.ChooseLockGeneric;
|
||||||
import com.android.settings.password.ChooseLockSettingsHelper;
|
import com.android.settings.password.ChooseLockSettingsHelper;
|
||||||
|
|
||||||
@@ -182,6 +187,15 @@ public abstract class BiometricEnrollIntroduction extends BiometricEnrollBase
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onPostCreate(@Nullable Bundle savedInstanceState) {
|
||||||
|
super.onPostCreate(savedInstanceState);
|
||||||
|
final LinearLayout buttonContainer = mFooterBarMixin.getButtonContainer();
|
||||||
|
if (buttonContainer != null) {
|
||||||
|
buttonContainer.setBackgroundColor(getBackgroundColor());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onResume() {
|
protected void onResume() {
|
||||||
super.onResume();
|
super.onResume();
|
||||||
@@ -199,6 +213,12 @@ public abstract class BiometricEnrollIntroduction extends BiometricEnrollBase
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onAttachedToWindow() {
|
||||||
|
super.onAttachedToWindow();
|
||||||
|
getWindow().setStatusBarColor(getBackgroundColor());
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onSaveInstanceState(Bundle outState) {
|
protected void onSaveInstanceState(Bundle outState) {
|
||||||
super.onSaveInstanceState(outState);
|
super.onSaveInstanceState(outState);
|
||||||
@@ -335,4 +355,10 @@ public abstract class BiometricEnrollIntroduction extends BiometricEnrollBase
|
|||||||
}
|
}
|
||||||
return mIconColorFilter;
|
return mIconColorFilter;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ColorInt
|
||||||
|
private int getBackgroundColor() {
|
||||||
|
final ColorStateList stateList = Utils.getColorAttr(this, android.R.attr.windowBackground);
|
||||||
|
return stateList != null ? stateList.getDefaultColor() : Color.TRANSPARENT;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,6 +27,5 @@ public class FeatureFlags {
|
|||||||
public static final String CONTROLLER_ENHANCEMENT = "settings_controller_loading_enhancement";
|
public static final String CONTROLLER_ENHANCEMENT = "settings_controller_loading_enhancement";
|
||||||
public static final String CONDITIONAL_CARDS = "settings_conditionals";
|
public static final String CONDITIONAL_CARDS = "settings_conditionals";
|
||||||
public static final String TETHER_ALL_IN_ONE = "settings_tether_all_in_one";
|
public static final String TETHER_ALL_IN_ONE = "settings_tether_all_in_one";
|
||||||
public static final String SILKY_HOME = "settings_silky_home";
|
|
||||||
public static final String CONTEXTUAL_HOME = "settings_contextual_home";
|
public static final String CONTEXTUAL_HOME = "settings_contextual_home";
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -31,7 +31,6 @@ import android.os.Bundle;
|
|||||||
import android.os.UserHandle;
|
import android.os.UserHandle;
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
import android.util.ArraySet;
|
import android.util.ArraySet;
|
||||||
import android.util.FeatureFlagUtils;
|
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.MenuItem;
|
import android.view.MenuItem;
|
||||||
@@ -67,7 +66,7 @@ public class SettingsBaseActivity extends FragmentActivity {
|
|||||||
/**
|
/**
|
||||||
* What type of page transition should be apply.
|
* What type of page transition should be apply.
|
||||||
*/
|
*/
|
||||||
public static final String EXTRA_PAGE_TRANSITION_TYPE = "extra_page_transition_type";
|
public static final String EXTRA_PAGE_TRANSITION_TYPE = "page_transition_type";
|
||||||
|
|
||||||
protected static final boolean DEBUG_TIMING = false;
|
protected static final boolean DEBUG_TIMING = false;
|
||||||
private static final String TAG = "SettingsBaseActivity";
|
private static final String TAG = "SettingsBaseActivity";
|
||||||
@@ -116,8 +115,7 @@ public class SettingsBaseActivity extends FragmentActivity {
|
|||||||
ThemeHelper.trySetDynamicColor(this);
|
ThemeHelper.trySetDynamicColor(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (FeatureFlagUtils.isEnabled(this, FeatureFlags.SILKY_HOME)
|
if (isToolbarEnabled() && !isAnySetupWizard) {
|
||||||
&& isToolbarEnabled() && !isAnySetupWizard) {
|
|
||||||
super.setContentView(R.layout.collapsing_toolbar_base_layout);
|
super.setContentView(R.layout.collapsing_toolbar_base_layout);
|
||||||
mCollapsingToolbarLayout = findViewById(R.id.collapsing_toolbar);
|
mCollapsingToolbarLayout = findViewById(R.id.collapsing_toolbar);
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -17,22 +17,17 @@
|
|||||||
package com.android.settings.core;
|
package com.android.settings.core;
|
||||||
|
|
||||||
import android.annotation.StringRes;
|
import android.annotation.StringRes;
|
||||||
import android.app.Activity;
|
|
||||||
import android.app.ActivityOptions;
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.UserHandle;
|
import android.os.UserHandle;
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
import android.widget.Toolbar;
|
|
||||||
|
|
||||||
import androidx.annotation.VisibleForTesting;
|
import androidx.annotation.VisibleForTesting;
|
||||||
import androidx.fragment.app.Fragment;
|
import androidx.fragment.app.Fragment;
|
||||||
|
|
||||||
import com.android.settings.R;
|
|
||||||
import com.android.settings.SettingsActivity;
|
import com.android.settings.SettingsActivity;
|
||||||
import com.android.settings.SubSettings;
|
import com.android.settings.SubSettings;
|
||||||
import com.android.settings.Utils;
|
|
||||||
import com.android.settingslib.core.instrumentation.MetricsFeatureProvider;
|
import com.android.settingslib.core.instrumentation.MetricsFeatureProvider;
|
||||||
import com.android.settingslib.transition.SettingsTransitionHelper.TransitionType;
|
import com.android.settingslib.transition.SettingsTransitionHelper.TransitionType;
|
||||||
|
|
||||||
@@ -199,14 +194,6 @@ public class SubSettingLauncher {
|
|||||||
|
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
void launchForResult(Fragment listener, Intent intent, int requestCode) {
|
void launchForResult(Fragment listener, Intent intent, int requestCode) {
|
||||||
if (Utils.isPageTransitionEnabled(mContext)) {
|
|
||||||
final Activity activity = listener.getActivity();
|
|
||||||
final Toolbar toolbar = activity.findViewById(R.id.action_bar);
|
|
||||||
final Bundle bundle = ActivityOptions.makeSceneTransitionAnimation(activity, toolbar,
|
|
||||||
"shared_element_view").toBundle();
|
|
||||||
listener.startActivityForResult(intent, requestCode, bundle);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
listener.startActivityForResult(intent, requestCode);
|
listener.startActivityForResult(intent, requestCode);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -73,7 +73,7 @@ public class DataUsageLib {
|
|||||||
|
|
||||||
private static NetworkTemplate getMobileTemplateForSubId(
|
private static NetworkTemplate getMobileTemplateForSubId(
|
||||||
TelephonyManager telephonyManager, int subId) {
|
TelephonyManager telephonyManager, int subId) {
|
||||||
return NetworkTemplate.buildTemplateMobileAll(
|
return NetworkTemplate.buildTemplateCarrierMetered(
|
||||||
telephonyManager.getSubscriberId(subId));
|
telephonyManager.getSubscriberId(subId));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ import android.widget.Switch;
|
|||||||
|
|
||||||
import androidx.preference.PreferenceScreen;
|
import androidx.preference.PreferenceScreen;
|
||||||
|
|
||||||
import com.android.settingslib.widget.MainSwitchPreference;
|
import com.android.settings.widget.SettingsMainSwitchPreference;
|
||||||
import com.android.settingslib.widget.OnMainSwitchChangeListener;
|
import com.android.settingslib.widget.OnMainSwitchChangeListener;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -51,7 +51,7 @@ public class AutoBrightnessDetailPreferenceController extends
|
|||||||
public void displayPreference(PreferenceScreen screen) {
|
public void displayPreference(PreferenceScreen screen) {
|
||||||
super.displayPreference(screen);
|
super.displayPreference(screen);
|
||||||
|
|
||||||
MainSwitchPreference pref = (MainSwitchPreference) screen.findPreference(
|
SettingsMainSwitchPreference pref = (SettingsMainSwitchPreference) screen.findPreference(
|
||||||
getPreferenceKey());
|
getPreferenceKey());
|
||||||
pref.addOnSwitchChangeListener(this);
|
pref.addOnSwitchChangeListener(this);
|
||||||
pref.updateStatus(isChecked());
|
pref.updateStatus(isChecked());
|
||||||
|
|||||||
@@ -28,7 +28,6 @@ import com.android.settingslib.core.lifecycle.LifecycleObserver;
|
|||||||
import com.android.settingslib.core.lifecycle.events.OnPause;
|
import com.android.settingslib.core.lifecycle.events.OnPause;
|
||||||
import com.android.settingslib.core.lifecycle.events.OnResume;
|
import com.android.settingslib.core.lifecycle.events.OnResume;
|
||||||
|
|
||||||
// TODO b/180515542 this class is no longer needed on S+
|
|
||||||
public class AutoRotatePreferenceController extends TogglePreferenceController implements
|
public class AutoRotatePreferenceController extends TogglePreferenceController implements
|
||||||
PreferenceControllerMixin, Preference.OnPreferenceChangeListener, LifecycleObserver,
|
PreferenceControllerMixin, Preference.OnPreferenceChangeListener, LifecycleObserver,
|
||||||
OnResume, OnPause {
|
OnResume, OnPause {
|
||||||
|
|||||||
@@ -25,6 +25,7 @@ import android.view.LayoutInflater;
|
|||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
|
|
||||||
|
import androidx.annotation.VisibleForTesting;
|
||||||
import androidx.preference.Preference;
|
import androidx.preference.Preference;
|
||||||
|
|
||||||
import com.android.internal.view.RotationPolicy;
|
import com.android.internal.view.RotationPolicy;
|
||||||
@@ -48,6 +49,7 @@ public class SmartAutoRotatePreferenceFragment extends DashboardFragment {
|
|||||||
|
|
||||||
private RotationPolicy.RotationPolicyListener mRotationPolicyListener;
|
private RotationPolicy.RotationPolicyListener mRotationPolicyListener;
|
||||||
private AutoRotateSwitchBarController mSwitchBarController;
|
private AutoRotateSwitchBarController mSwitchBarController;
|
||||||
|
@VisibleForTesting static final String AUTO_ROTATE_SWITCH_PREFERENCE_ID = "auto_rotate_switch";
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected int getPreferenceScreenResId() {
|
protected int getPreferenceScreenResId() {
|
||||||
@@ -65,12 +67,7 @@ public class SmartAutoRotatePreferenceFragment extends DashboardFragment {
|
|||||||
Bundle savedInstanceState) {
|
Bundle savedInstanceState) {
|
||||||
final View view = super.onCreateView(inflater, container, savedInstanceState);
|
final View view = super.onCreateView(inflater, container, savedInstanceState);
|
||||||
final SettingsActivity activity = (SettingsActivity) getActivity();
|
final SettingsActivity activity = (SettingsActivity) getActivity();
|
||||||
final SettingsMainSwitchBar switchBar = activity.getSwitchBar();
|
createHeader(activity);
|
||||||
switchBar.setTitle(
|
|
||||||
getContext().getString(R.string.auto_rotate_settings_primary_switch_title));
|
|
||||||
switchBar.show();
|
|
||||||
mSwitchBarController = new AutoRotateSwitchBarController(activity, switchBar,
|
|
||||||
getSettingsLifecycle());
|
|
||||||
final Preference footerPreference = findPreference(FooterPreference.KEY_FOOTER);
|
final Preference footerPreference = findPreference(FooterPreference.KEY_FOOTER);
|
||||||
if (footerPreference != null) {
|
if (footerPreference != null) {
|
||||||
footerPreference.setTitle(Html.fromHtml(getString(R.string.smart_rotate_text_headline),
|
footerPreference.setTitle(Html.fromHtml(getString(R.string.smart_rotate_text_headline),
|
||||||
@@ -80,6 +77,19 @@ public class SmartAutoRotatePreferenceFragment extends DashboardFragment {
|
|||||||
return view;
|
return view;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@VisibleForTesting
|
||||||
|
void createHeader(SettingsActivity activity) {
|
||||||
|
if (isRotationResolverServiceAvailable(activity)) {
|
||||||
|
final SettingsMainSwitchBar switchBar = activity.getSwitchBar();
|
||||||
|
switchBar.setTitle(
|
||||||
|
getContext().getString(R.string.auto_rotate_settings_primary_switch_title));
|
||||||
|
switchBar.show();
|
||||||
|
mSwitchBarController = new AutoRotateSwitchBarController(activity, switchBar,
|
||||||
|
getSettingsLifecycle());
|
||||||
|
findPreference(AUTO_ROTATE_SWITCH_PREFERENCE_ID).setVisible(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onResume() {
|
public void onResume() {
|
||||||
super.onResume();
|
super.onResume();
|
||||||
@@ -87,7 +97,9 @@ public class SmartAutoRotatePreferenceFragment extends DashboardFragment {
|
|||||||
mRotationPolicyListener = new RotationPolicy.RotationPolicyListener() {
|
mRotationPolicyListener = new RotationPolicy.RotationPolicyListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onChange() {
|
public void onChange() {
|
||||||
mSwitchBarController.onChange();
|
if (mSwitchBarController != null) {
|
||||||
|
mSwitchBarController.onChange();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -46,30 +46,25 @@ import java.util.Objects;
|
|||||||
/**
|
/**
|
||||||
* Helper class for {@link ActionDisabledByAdminDialog} which sets up the dialog.
|
* Helper class for {@link ActionDisabledByAdminDialog} which sets up the dialog.
|
||||||
*/
|
*/
|
||||||
public class ActionDisabledByAdminDialogHelper {
|
public final class ActionDisabledByAdminDialogHelper {
|
||||||
|
|
||||||
private static final String TAG = ActionDisabledByAdminDialogHelper.class.getName();
|
private static final String TAG = ActionDisabledByAdminDialogHelper.class.getName();
|
||||||
@VisibleForTesting EnforcedAdmin mEnforcedAdmin;
|
@VisibleForTesting EnforcedAdmin mEnforcedAdmin;
|
||||||
private ViewGroup mDialogView;
|
private ViewGroup mDialogView;
|
||||||
private String mRestriction = null;
|
private String mRestriction;
|
||||||
private final Activity mActivity;
|
|
||||||
private final ActionDisabledByAdminController mActionDisabledByAdminController;
|
private final ActionDisabledByAdminController mActionDisabledByAdminController;
|
||||||
|
private final Activity mActivity;
|
||||||
|
|
||||||
public ActionDisabledByAdminDialogHelper(Activity activity) {
|
public ActionDisabledByAdminDialogHelper(Activity activity) {
|
||||||
mActivity = activity;
|
mActivity = activity;
|
||||||
mActionDisabledByAdminController =
|
mDialogView = (ViewGroup) LayoutInflater.from(mActivity).inflate(
|
||||||
ActionDisabledByAdminControllerFactory.createInstance(
|
R.layout.admin_support_details_dialog, null);
|
||||||
mActivity.getSystemService(DevicePolicyManager.class),
|
mActionDisabledByAdminController = ActionDisabledByAdminControllerFactory
|
||||||
new ActionDisabledLearnMoreButtonLauncherImpl(),
|
.createInstance(mActivity, new DeviceAdminStringProviderImpl(mActivity));
|
||||||
new DeviceAdminStringProviderImpl(mActivity));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private @UserIdInt int getEnforcementAdminUserId(@NonNull EnforcedAdmin admin) {
|
private @UserIdInt int getEnforcementAdminUserId(@NonNull EnforcedAdmin admin) {
|
||||||
if (admin.user == null) {
|
return admin.user == null ? UserHandle.USER_NULL : admin.user.getIdentifier();
|
||||||
return UserHandle.USER_NULL;
|
|
||||||
} else {
|
|
||||||
return admin.user.getIdentifier();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private @UserIdInt int getEnforcementAdminUserId() {
|
private @UserIdInt int getEnforcementAdminUserId() {
|
||||||
@@ -78,21 +73,24 @@ public class ActionDisabledByAdminDialogHelper {
|
|||||||
|
|
||||||
public AlertDialog.Builder prepareDialogBuilder(String restriction,
|
public AlertDialog.Builder prepareDialogBuilder(String restriction,
|
||||||
EnforcedAdmin enforcedAdmin) {
|
EnforcedAdmin enforcedAdmin) {
|
||||||
mEnforcedAdmin = enforcedAdmin;
|
AlertDialog.Builder builder = new AlertDialog.Builder(mActivity)
|
||||||
mRestriction = restriction;
|
.setPositiveButton(R.string.okay, null)
|
||||||
final AlertDialog.Builder builder = new AlertDialog.Builder(mActivity);
|
.setView(mDialogView);
|
||||||
mDialogView = (ViewGroup) LayoutInflater.from(mActivity).inflate(
|
prepareDialogBuilder(builder, restriction, enforcedAdmin);
|
||||||
R.layout.admin_support_details_dialog, null);
|
|
||||||
initializeDialogViews(mDialogView, mEnforcedAdmin, getEnforcementAdminUserId(),
|
|
||||||
mRestriction, mActionDisabledByAdminController);
|
|
||||||
builder.setPositiveButton(R.string.okay, null).setView(mDialogView);
|
|
||||||
maybeSetLearnMoreButton(builder);
|
|
||||||
return builder;
|
return builder;
|
||||||
}
|
}
|
||||||
|
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
void maybeSetLearnMoreButton(AlertDialog.Builder builder) {
|
void prepareDialogBuilder(AlertDialog.Builder builder, String restriction,
|
||||||
mActionDisabledByAdminController.setupLearnMoreButton(mActivity, builder);
|
EnforcedAdmin enforcedAdmin) {
|
||||||
|
mActionDisabledByAdminController.initialize(
|
||||||
|
new ActionDisabledLearnMoreButtonLauncherImpl(mActivity, builder));
|
||||||
|
|
||||||
|
mEnforcedAdmin = enforcedAdmin;
|
||||||
|
mRestriction = restriction;
|
||||||
|
initializeDialogViews(mDialogView, mEnforcedAdmin, getEnforcementAdminUserId(),
|
||||||
|
mRestriction);
|
||||||
|
mActionDisabledByAdminController.setupLearnMoreButton(mActivity);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void updateDialog(String restriction, EnforcedAdmin admin) {
|
public void updateDialog(String restriction, EnforcedAdmin admin) {
|
||||||
@@ -102,17 +100,17 @@ public class ActionDisabledByAdminDialogHelper {
|
|||||||
mEnforcedAdmin = admin;
|
mEnforcedAdmin = admin;
|
||||||
mRestriction = restriction;
|
mRestriction = restriction;
|
||||||
initializeDialogViews(mDialogView, mEnforcedAdmin, getEnforcementAdminUserId(),
|
initializeDialogViews(mDialogView, mEnforcedAdmin, getEnforcementAdminUserId(),
|
||||||
mRestriction, mActionDisabledByAdminController);
|
mRestriction);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void initializeDialogViews(View root, EnforcedAdmin enforcedAdmin, int userId,
|
private void initializeDialogViews(View root, EnforcedAdmin enforcedAdmin, int userId,
|
||||||
String restriction, ActionDisabledByAdminController controller) {
|
String restriction) {
|
||||||
ComponentName admin = enforcedAdmin.component;
|
ComponentName admin = enforcedAdmin.component;
|
||||||
if (admin == null) {
|
if (admin == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
controller.updateEnforcedAdmin(enforcedAdmin, userId);
|
mActionDisabledByAdminController.updateEnforcedAdmin(enforcedAdmin, userId);
|
||||||
setAdminSupportIcon(root, admin, userId);
|
setAdminSupportIcon(root, admin, userId);
|
||||||
|
|
||||||
if (isNotCurrentUserOrProfile(admin, userId)) {
|
if (isNotCurrentUserOrProfile(admin, userId)) {
|
||||||
@@ -151,8 +149,7 @@ public class ActionDisabledByAdminDialogHelper {
|
|||||||
if (titleView == null) {
|
if (titleView == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
titleView.setText(
|
titleView.setText(mActionDisabledByAdminController.getAdminSupportTitle(restriction));
|
||||||
mActionDisabledByAdminController.getAdminSupportTitle(restriction));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
|
|||||||
@@ -20,104 +20,67 @@ import static java.util.Objects.requireNonNull;
|
|||||||
|
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.app.admin.DevicePolicyManager;
|
import android.app.admin.DevicePolicyManager;
|
||||||
|
import android.content.ComponentName;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.net.Uri;
|
|
||||||
import android.os.UserHandle;
|
import android.os.UserHandle;
|
||||||
import android.os.UserManager;
|
|
||||||
|
|
||||||
import androidx.appcompat.app.AlertDialog;
|
import androidx.appcompat.app.AlertDialog;
|
||||||
|
|
||||||
import com.android.settings.R;
|
import com.android.settings.R;
|
||||||
import com.android.settings.Settings;
|
import com.android.settings.Settings;
|
||||||
import com.android.settings.applications.specialaccess.deviceadmin.DeviceAdminAdd;
|
import com.android.settings.applications.specialaccess.deviceadmin.DeviceAdminAdd;
|
||||||
import com.android.settingslib.RestrictedLockUtils.EnforcedAdmin;
|
|
||||||
import com.android.settingslib.enterprise.ActionDisabledLearnMoreButtonLauncher;
|
import com.android.settingslib.enterprise.ActionDisabledLearnMoreButtonLauncher;
|
||||||
|
|
||||||
import java.util.function.BiConsumer;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Helper class to set up the "Learn more" button in the action disabled dialog.
|
* Helper class to set up the "Learn more" button in the action disabled dialog.
|
||||||
*/
|
*/
|
||||||
public class ActionDisabledLearnMoreButtonLauncherImpl
|
public final class ActionDisabledLearnMoreButtonLauncherImpl
|
||||||
implements ActionDisabledLearnMoreButtonLauncher {
|
extends ActionDisabledLearnMoreButtonLauncher {
|
||||||
|
|
||||||
static final BiConsumer<Activity, EnforcedAdmin> SHOW_ADMIN_POLICIES =
|
private final Activity mActivity;
|
||||||
(activity, enforcedAdmin) -> {
|
private final AlertDialog.Builder mBuilder;
|
||||||
showAdminPolicies(enforcedAdmin, activity);
|
|
||||||
activity.finish();
|
|
||||||
};
|
|
||||||
|
|
||||||
static final BiConsumer<Activity, String> LAUNCH_HELP_PAGE = (activity, url) -> {
|
ActionDisabledLearnMoreButtonLauncherImpl(Activity activity, AlertDialog.Builder builder) {
|
||||||
launchLearnMoreHelpPage(activity, url);
|
mActivity = requireNonNull(activity, "activity cannot be null");
|
||||||
activity.finish();
|
mBuilder = requireNonNull(builder, "builder cannot be null");
|
||||||
};
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setupLearnMoreButtonToShowAdminPolicies(
|
|
||||||
Context context,
|
|
||||||
Object alertDialogBuilder,
|
|
||||||
int enforcementAdminUserId,
|
|
||||||
EnforcedAdmin enforcedAdmin) {
|
|
||||||
requireNonNull(context);
|
|
||||||
requireNonNull(alertDialogBuilder);
|
|
||||||
requireNonNull(enforcedAdmin);
|
|
||||||
// The "Learn more" button appears only if the restriction is enforced by an admin in the
|
|
||||||
// same profile group. Otherwise the admin package and its policies are not accessible to
|
|
||||||
// the current user.
|
|
||||||
final UserManager um = UserManager.get(context);
|
|
||||||
if (um.isSameProfileGroup(enforcementAdminUserId, um.getUserHandle())) {
|
|
||||||
setupLearnMoreButton((AlertDialog.Builder) alertDialogBuilder, () ->
|
|
||||||
SHOW_ADMIN_POLICIES.accept((Activity) context, enforcedAdmin));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setupLearnMoreButtonToLaunchHelpPage(
|
public void setLearnMoreButton(Runnable action) {
|
||||||
Context context,
|
requireNonNull(action, "action cannot be null");
|
||||||
Object alertDialogBuilder,
|
|
||||||
String url) {
|
mBuilder.setNeutralButton(R.string.learn_more, (dialog, which) -> action.run());
|
||||||
requireNonNull(context);
|
|
||||||
requireNonNull(alertDialogBuilder);
|
|
||||||
requireNonNull(url);
|
|
||||||
setupLearnMoreButton((AlertDialog.Builder) alertDialogBuilder,
|
|
||||||
() -> LAUNCH_HELP_PAGE.accept((Activity) context, url));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setupLearnMoreButton(AlertDialog.Builder builder, Runnable runnable) {
|
@Override
|
||||||
builder.setNeutralButton(R.string.learn_more, (dialog, which) -> {
|
protected void launchShowAdminPolicies(Context context, UserHandle user, ComponentName admin) {
|
||||||
runnable.run();
|
requireNonNull(context, "context cannot be null");
|
||||||
});
|
requireNonNull(user, "user cannot be null");
|
||||||
|
requireNonNull(admin, "admin cannot be null");
|
||||||
|
|
||||||
|
Intent intent = new Intent()
|
||||||
|
.setClass(mActivity, DeviceAdminAdd.class)
|
||||||
|
.putExtra(DevicePolicyManager.EXTRA_DEVICE_ADMIN, admin)
|
||||||
|
.putExtra(DeviceAdminAdd.EXTRA_CALLED_FROM_SUPPORT_DIALOG, true);
|
||||||
|
// DeviceAdminAdd class may need to run as managed profile.
|
||||||
|
mActivity.startActivityAsUser(intent, user);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void launchLearnMoreHelpPage(Activity activity, String url) {
|
@Override
|
||||||
activity.startActivityAsUser(createLearnMoreIntent(url), UserHandle.SYSTEM);
|
protected void launchShowAdminSettings(Context context) {
|
||||||
|
requireNonNull(context, "context cannot be null");
|
||||||
|
|
||||||
|
Intent intent = new Intent()
|
||||||
|
.setClass(mActivity, Settings.DeviceAdminSettingsActivity.class)
|
||||||
|
.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||||
|
// Activity merges both managed profile and parent users
|
||||||
|
// admins so show as same user as this activity.
|
||||||
|
mActivity.startActivity(intent);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Intent createLearnMoreIntent(String url) {
|
@Override
|
||||||
final Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
|
protected void finishSelf() {
|
||||||
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK
|
mActivity.finish();
|
||||||
| Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS);
|
|
||||||
return intent;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void showAdminPolicies(
|
|
||||||
EnforcedAdmin enforcedAdmin,
|
|
||||||
Activity activity) {
|
|
||||||
final Intent intent = new Intent();
|
|
||||||
if (enforcedAdmin.component != null) {
|
|
||||||
intent.setClass(activity, DeviceAdminAdd.class);
|
|
||||||
intent.putExtra(DevicePolicyManager.EXTRA_DEVICE_ADMIN,
|
|
||||||
enforcedAdmin.component);
|
|
||||||
intent.putExtra(DeviceAdminAdd.EXTRA_CALLED_FROM_SUPPORT_DIALOG, true);
|
|
||||||
// DeviceAdminAdd class may need to run as managed profile.
|
|
||||||
activity.startActivityAsUser(intent, enforcedAdmin.user);
|
|
||||||
} else {
|
|
||||||
intent.setClass(activity, Settings.DeviceAdminSettingsActivity.class);
|
|
||||||
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
|
||||||
// Activity merges both managed profile and parent users
|
|
||||||
// admins so show as same user as this activity.
|
|
||||||
activity.startActivity(intent);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -30,18 +30,14 @@ import android.content.om.OverlayInfo;
|
|||||||
import android.os.RemoteException;
|
import android.os.RemoteException;
|
||||||
import android.os.ServiceManager;
|
import android.os.ServiceManager;
|
||||||
import android.provider.Settings;
|
import android.provider.Settings;
|
||||||
import android.util.FeatureFlagUtils;
|
|
||||||
|
|
||||||
import androidx.annotation.VisibleForTesting;
|
import androidx.annotation.VisibleForTesting;
|
||||||
import androidx.preference.PreferenceScreen;
|
import androidx.preference.PreferenceScreen;
|
||||||
|
|
||||||
import com.android.settings.R;
|
import com.android.settings.R;
|
||||||
import com.android.settings.core.FeatureFlags;
|
|
||||||
import com.android.settings.dashboard.suggestions.SuggestionFeatureProvider;
|
import com.android.settings.dashboard.suggestions.SuggestionFeatureProvider;
|
||||||
import com.android.settings.overlay.FeatureFactory;
|
import com.android.settings.overlay.FeatureFactory;
|
||||||
import com.android.settings.search.BaseSearchIndexProvider;
|
import com.android.settings.search.BaseSearchIndexProvider;
|
||||||
import com.android.settings.search.actionbar.SearchMenuController;
|
|
||||||
import com.android.settings.support.actionbar.HelpMenuController;
|
|
||||||
import com.android.settings.support.actionbar.HelpResourceProvider;
|
import com.android.settings.support.actionbar.HelpResourceProvider;
|
||||||
import com.android.settings.utils.CandidateInfoExtra;
|
import com.android.settings.utils.CandidateInfoExtra;
|
||||||
import com.android.settings.widget.RadioButtonPickerFragment;
|
import com.android.settings.widget.RadioButtonPickerFragment;
|
||||||
@@ -76,11 +72,6 @@ public class SystemNavigationGestureSettings extends RadioButtonPickerFragment i
|
|||||||
@Override
|
@Override
|
||||||
public void onAttach(Context context) {
|
public void onAttach(Context context) {
|
||||||
super.onAttach(context);
|
super.onAttach(context);
|
||||||
// TODO(b/176883483): Remove both search and help menu if this feature rolled out
|
|
||||||
if (!FeatureFlagUtils.isEnabled(getContext(), FeatureFlags.SILKY_HOME)) {
|
|
||||||
SearchMenuController.init(this /* host */);
|
|
||||||
HelpMenuController.init(this /* host */);
|
|
||||||
}
|
|
||||||
|
|
||||||
SuggestionFeatureProvider suggestionFeatureProvider = FeatureFactory.getFactory(context)
|
SuggestionFeatureProvider suggestionFeatureProvider = FeatureFactory.getFactory(context)
|
||||||
.getSuggestionFeatureProvider(context);
|
.getSuggestionFeatureProvider(context);
|
||||||
|
|||||||
@@ -26,7 +26,6 @@ import android.database.Cursor;
|
|||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.provider.UserDictionary;
|
import android.provider.UserDictionary;
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
import android.util.FeatureFlagUtils;
|
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.Menu;
|
import android.view.Menu;
|
||||||
import android.view.MenuInflater;
|
import android.view.MenuInflater;
|
||||||
@@ -45,7 +44,6 @@ import androidx.loader.app.LoaderManager;
|
|||||||
import androidx.loader.content.Loader;
|
import androidx.loader.content.Loader;
|
||||||
|
|
||||||
import com.android.settings.R;
|
import com.android.settings.R;
|
||||||
import com.android.settings.core.FeatureFlags;
|
|
||||||
import com.android.settings.core.SubSettingLauncher;
|
import com.android.settings.core.SubSettingLauncher;
|
||||||
import com.android.settings.overlay.FeatureFactory;
|
import com.android.settings.overlay.FeatureFactory;
|
||||||
import com.android.settingslib.core.instrumentation.Instrumentable;
|
import com.android.settingslib.core.instrumentation.Instrumentable;
|
||||||
@@ -106,10 +104,7 @@ public class UserDictionarySettings extends ListFragment implements Instrumentab
|
|||||||
@Override
|
@Override
|
||||||
public View onCreateView(
|
public View onCreateView(
|
||||||
LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||||
// TODO(b/176883483): Remove the title after material component updated
|
getActivity().setTitle(R.string.user_dict_settings_title);
|
||||||
if (FeatureFlagUtils.isEnabled(getContext(), FeatureFlags.SILKY_HOME)) {
|
|
||||||
getActivity().setTitle(R.string.user_dict_settings_title);
|
|
||||||
}
|
|
||||||
// Show the language as a subtitle of the action bar
|
// Show the language as a subtitle of the action bar
|
||||||
final ActionBar actionBar = getActivity().getActionBar();
|
final ActionBar actionBar = getActivity().getActionBar();
|
||||||
if (actionBar != null) {
|
if (actionBar != null) {
|
||||||
|
|||||||
@@ -31,6 +31,7 @@ import androidx.preference.Preference;
|
|||||||
import androidx.preference.PreferenceScreen;
|
import androidx.preference.PreferenceScreen;
|
||||||
|
|
||||||
import com.android.settings.R;
|
import com.android.settings.R;
|
||||||
|
import com.android.settingslib.HelpUtils;
|
||||||
import com.android.settingslib.widget.FooterPreference;
|
import com.android.settingslib.widget.FooterPreference;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@@ -104,15 +105,22 @@ public class LocationSettingsFooterPreferenceController extends LocationBasePref
|
|||||||
+ footerString;
|
+ footerString;
|
||||||
}
|
}
|
||||||
if (mFooterPreference != null) {
|
if (mFooterPreference != null) {
|
||||||
mFooterPreference.setTitle(Html.fromHtml(footerString
|
mFooterPreference.setTitle(Html.fromHtml(footerString));
|
||||||
+ PARAGRAPH_SEPARATOR
|
mFooterPreference.setLearnMoreAction(v -> openLocationLearnMoreLink());
|
||||||
+ mContext.getString(
|
mFooterPreference.setLearnMoreContentDescription(mContext.getString(
|
||||||
R.string.location_settings_footer_learn_more)));
|
R.string.location_settings_footer_learn_more_content_description));
|
||||||
mFooterPreference.setContentDescription(Html.fromHtml(footerString + mContext.getString(
|
|
||||||
R.string.location_settings_footer_learn_more_content_description)));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void openLocationLearnMoreLink() {
|
||||||
|
mFragment.startActivityForResult(
|
||||||
|
HelpUtils.getHelpIntent(
|
||||||
|
mContext,
|
||||||
|
mContext.getString(R.string.location_settings_footer_learn_more_link),
|
||||||
|
/*backupContext=*/""),
|
||||||
|
/*requestCode=*/ 0);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Location footer preference group should always be displayed.
|
* Location footer preference group should always be displayed.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -105,13 +105,20 @@ public class NetworkOperatorPreference extends Preference {
|
|||||||
return mCellId.equals(CellInfoUtil.getCellIdentity(cellinfo));
|
return mCellId.equals(CellInfoUtil.getCellIdentity(cellinfo));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return true when this preference is for forbidden network
|
||||||
|
*/
|
||||||
|
public boolean isForbiddenNetwork() {
|
||||||
|
return ((mForbiddenPlmns != null) && mForbiddenPlmns.contains(getOperatorNumeric()));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Refresh the NetworkOperatorPreference by updating the title and the icon.
|
* Refresh the NetworkOperatorPreference by updating the title and the icon.
|
||||||
*/
|
*/
|
||||||
public void refresh() {
|
public void refresh() {
|
||||||
String networkTitle = getOperatorName();
|
String networkTitle = getOperatorName();
|
||||||
|
|
||||||
if ((mForbiddenPlmns != null) && mForbiddenPlmns.contains(getOperatorNumeric())) {
|
if (isForbiddenNetwork()) {
|
||||||
if (DBG) Log.d(TAG, "refresh forbidden network: " + networkTitle);
|
if (DBG) Log.d(TAG, "refresh forbidden network: " + networkTitle);
|
||||||
networkTitle += " "
|
networkTitle += " "
|
||||||
+ getContext().getResources().getString(R.string.forbidden_network);
|
+ getContext().getResources().getString(R.string.forbidden_network);
|
||||||
|
|||||||
@@ -414,19 +414,30 @@ public class NetworkSelectSettings extends DashboardFragment {
|
|||||||
if (networkList == null || networkList.size() == 0) {
|
if (networkList == null || networkList.size() == 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
// Due to the aggregation of cell between carriers, it's possible to get CellIdentity
|
||||||
|
// containing forbidden PLMN.
|
||||||
|
// Getting current network from ServiceState is no longer a good idea.
|
||||||
|
// Add an additional rule to avoid from showing forbidden PLMN to the user.
|
||||||
|
if (mForbiddenPlmns == null) {
|
||||||
|
updateForbiddenPlmns();
|
||||||
|
}
|
||||||
for (NetworkRegistrationInfo regInfo : networkList) {
|
for (NetworkRegistrationInfo regInfo : networkList) {
|
||||||
final CellIdentity cellIdentity = regInfo.getCellIdentity();
|
final CellIdentity cellIdentity = regInfo.getCellIdentity();
|
||||||
if (cellIdentity != null) {
|
if (cellIdentity == null) {
|
||||||
final NetworkOperatorPreference pref = new NetworkOperatorPreference(
|
continue;
|
||||||
getPrefContext(), cellIdentity, mForbiddenPlmns, mShow4GForLTE);
|
|
||||||
pref.setSummary(R.string.network_connected);
|
|
||||||
// Update the signal strength icon, since the default signalStrength value
|
|
||||||
// would be zero
|
|
||||||
// (it would be quite confusing why the connected network has no signal)
|
|
||||||
pref.setIcon(SignalStrength.NUM_SIGNAL_STRENGTH_BINS - 1);
|
|
||||||
mPreferenceCategory.addPreference(pref);
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
final NetworkOperatorPreference pref = new NetworkOperatorPreference(
|
||||||
|
getPrefContext(), cellIdentity, mForbiddenPlmns, mShow4GForLTE);
|
||||||
|
if (pref.isForbiddenNetwork()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
pref.setSummary(R.string.network_connected);
|
||||||
|
// Update the signal strength icon, since the default signalStrength value
|
||||||
|
// would be zero
|
||||||
|
// (it would be quite confusing why the connected network has no signal)
|
||||||
|
pref.setIcon(SignalStrength.NUM_SIGNAL_STRENGTH_BINS - 1);
|
||||||
|
mPreferenceCategory.addPreference(pref);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,6 +18,8 @@ package com.android.settings.security;
|
|||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.os.UserManager;
|
import android.os.UserManager;
|
||||||
|
import android.security.keystore.KeyProperties;
|
||||||
|
import android.security.keystore2.AndroidKeyStoreLoadStoreParameter;
|
||||||
|
|
||||||
import androidx.preference.PreferenceScreen;
|
import androidx.preference.PreferenceScreen;
|
||||||
|
|
||||||
@@ -35,6 +37,7 @@ public class ResetCredentialsPreferenceController extends RestrictedEncryptionPr
|
|||||||
private static final String KEY_RESET_CREDENTIALS = "credentials_reset";
|
private static final String KEY_RESET_CREDENTIALS = "credentials_reset";
|
||||||
|
|
||||||
private final KeyStore mKeyStore;
|
private final KeyStore mKeyStore;
|
||||||
|
private final KeyStore mWifiKeyStore;
|
||||||
|
|
||||||
private RestrictedPreference mPreference;
|
private RestrictedPreference mPreference;
|
||||||
|
|
||||||
@@ -45,8 +48,19 @@ public class ResetCredentialsPreferenceController extends RestrictedEncryptionPr
|
|||||||
keyStore = KeyStore.getInstance("AndroidKeyStore");
|
keyStore = KeyStore.getInstance("AndroidKeyStore");
|
||||||
keyStore.load(null);
|
keyStore.load(null);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
keyStore = null;
|
||||||
}
|
}
|
||||||
mKeyStore = keyStore;
|
mKeyStore = keyStore;
|
||||||
|
keyStore = null;
|
||||||
|
if (context.getUser().isSystem()) {
|
||||||
|
try {
|
||||||
|
keyStore = KeyStore.getInstance("AndroidKeyStore");
|
||||||
|
keyStore.load(new AndroidKeyStoreLoadStoreParameter(KeyProperties.NAMESPACE_WIFI));
|
||||||
|
} catch (Exception e) {
|
||||||
|
keyStore = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
mWifiKeyStore = keyStore;
|
||||||
if (lifecycle != null) {
|
if (lifecycle != null) {
|
||||||
lifecycle.addObserver(this);
|
lifecycle.addObserver(this);
|
||||||
}
|
}
|
||||||
@@ -68,9 +82,11 @@ public class ResetCredentialsPreferenceController extends RestrictedEncryptionPr
|
|||||||
if (mPreference != null && !mPreference.isDisabledByAdmin()) {
|
if (mPreference != null && !mPreference.isDisabledByAdmin()) {
|
||||||
boolean isEnabled = false;
|
boolean isEnabled = false;
|
||||||
try {
|
try {
|
||||||
if (mKeyStore != null) {
|
isEnabled = (mKeyStore != null
|
||||||
isEnabled = mKeyStore.aliases().hasMoreElements();
|
&& mKeyStore.aliases().hasMoreElements())
|
||||||
}
|
|| (mWifiKeyStore != null
|
||||||
|
&& mWifiKeyStore.aliases().hasMoreElements());
|
||||||
|
|
||||||
} catch (KeyStoreException e) {
|
} catch (KeyStoreException e) {
|
||||||
// If access to keystore fails, treat as disabled.
|
// If access to keystore fails, treat as disabled.
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -33,6 +33,7 @@ import com.android.internal.widget.LockPatternUtils;
|
|||||||
import com.android.settings.R;
|
import com.android.settings.R;
|
||||||
import com.android.settings.SettingsPreferenceFragment;
|
import com.android.settings.SettingsPreferenceFragment;
|
||||||
import com.android.settings.core.PreferenceControllerMixin;
|
import com.android.settings.core.PreferenceControllerMixin;
|
||||||
|
import com.android.settings.core.SettingsBaseActivity;
|
||||||
import com.android.settings.overlay.FeatureFactory;
|
import com.android.settings.overlay.FeatureFactory;
|
||||||
import com.android.settings.password.ChooseLockSettingsHelper;
|
import com.android.settings.password.ChooseLockSettingsHelper;
|
||||||
import com.android.settings.security.SecurityFeatureProvider;
|
import com.android.settings.security.SecurityFeatureProvider;
|
||||||
@@ -44,6 +45,7 @@ import com.android.settingslib.core.lifecycle.events.OnCreate;
|
|||||||
import com.android.settingslib.core.lifecycle.events.OnResume;
|
import com.android.settingslib.core.lifecycle.events.OnResume;
|
||||||
import com.android.settingslib.core.lifecycle.events.OnSaveInstanceState;
|
import com.android.settingslib.core.lifecycle.events.OnSaveInstanceState;
|
||||||
import com.android.settingslib.search.SearchIndexableRaw;
|
import com.android.settingslib.search.SearchIndexableRaw;
|
||||||
|
import com.android.settingslib.transition.SettingsTransitionHelper;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -128,6 +130,8 @@ public class TrustAgentListPreferenceController extends AbstractPreferenceContro
|
|||||||
.show();
|
.show();
|
||||||
|
|
||||||
mTrustAgentClickIntent = preference.getIntent();
|
mTrustAgentClickIntent = preference.getIntent();
|
||||||
|
mTrustAgentClickIntent.putExtra(SettingsBaseActivity.EXTRA_PAGE_TRANSITION_TYPE,
|
||||||
|
SettingsTransitionHelper.TransitionType.TRANSITION_SLIDE);
|
||||||
|
|
||||||
if (!confirmationLaunched && mTrustAgentClickIntent != null) {
|
if (!confirmationLaunched && mTrustAgentClickIntent != null) {
|
||||||
// If this returns false, it means no password confirmation is required.
|
// If this returns false, it means no password confirmation is required.
|
||||||
|
|||||||
@@ -16,6 +16,8 @@
|
|||||||
|
|
||||||
package com.android.settings.widget;
|
package com.android.settings.widget;
|
||||||
|
|
||||||
|
import static com.android.settingslib.RestrictedLockUtils.EnforcedAdmin;
|
||||||
|
|
||||||
import android.app.settings.SettingsEnums;
|
import android.app.settings.SettingsEnums;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.util.AttributeSet;
|
import android.util.AttributeSet;
|
||||||
@@ -47,7 +49,7 @@ public class SettingsMainSwitchBar extends MainSwitchBar {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private ImageView mRestrictedIcon;
|
private ImageView mRestrictedIcon;
|
||||||
private RestrictedLockUtils.EnforcedAdmin mEnforcedAdmin;
|
private EnforcedAdmin mEnforcedAdmin;
|
||||||
private boolean mDisabledByAdmin;
|
private boolean mDisabledByAdmin;
|
||||||
|
|
||||||
private final MetricsFeatureProvider mMetricsFeatureProvider;
|
private final MetricsFeatureProvider mMetricsFeatureProvider;
|
||||||
@@ -87,7 +89,7 @@ public class SettingsMainSwitchBar extends MainSwitchBar {
|
|||||||
* If admin is not null, disables the text and switch but keeps the view clickable (unless the
|
* If admin is not null, disables the text and switch but keeps the view clickable (unless the
|
||||||
* switch is disabled for other reasons). Otherwise, calls setEnabled.
|
* switch is disabled for other reasons). Otherwise, calls setEnabled.
|
||||||
*/
|
*/
|
||||||
public void setDisabledByAdmin(RestrictedLockUtils.EnforcedAdmin admin) {
|
public void setDisabledByAdmin(EnforcedAdmin admin) {
|
||||||
mEnforcedAdmin = admin;
|
mEnforcedAdmin = admin;
|
||||||
if (admin != null) {
|
if (admin != null) {
|
||||||
super.setEnabled(true);
|
super.setEnabled(true);
|
||||||
|
|||||||
@@ -16,10 +16,13 @@
|
|||||||
|
|
||||||
package com.android.settings.widget;
|
package com.android.settings.widget;
|
||||||
|
|
||||||
|
import static com.android.settingslib.RestrictedLockUtils.EnforcedAdmin;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.res.TypedArray;
|
import android.content.res.TypedArray;
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
import android.util.AttributeSet;
|
import android.util.AttributeSet;
|
||||||
|
import android.widget.Switch;
|
||||||
|
|
||||||
import androidx.core.content.res.TypedArrayUtils;
|
import androidx.core.content.res.TypedArrayUtils;
|
||||||
import androidx.preference.PreferenceViewHolder;
|
import androidx.preference.PreferenceViewHolder;
|
||||||
@@ -27,7 +30,7 @@ import androidx.preference.TwoStatePreference;
|
|||||||
|
|
||||||
import com.android.settings.R;
|
import com.android.settings.R;
|
||||||
import com.android.settings.widget.SettingsMainSwitchBar.OnBeforeCheckedChangeListener;
|
import com.android.settings.widget.SettingsMainSwitchBar.OnBeforeCheckedChangeListener;
|
||||||
import com.android.settingslib.RestrictedLockUtils;
|
import com.android.settingslib.RestrictedPreferenceHelper;
|
||||||
import com.android.settingslib.widget.OnMainSwitchChangeListener;
|
import com.android.settingslib.widget.OnMainSwitchChangeListener;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@@ -38,7 +41,9 @@ import java.util.List;
|
|||||||
* This component is used as the main switch of the page
|
* This component is used as the main switch of the page
|
||||||
* to enable or disable the prefereces on the page.
|
* to enable or disable the prefereces on the page.
|
||||||
*/
|
*/
|
||||||
public class SettingsMainSwitchPreference extends TwoStatePreference {
|
public class SettingsMainSwitchPreference extends TwoStatePreference implements
|
||||||
|
OnMainSwitchChangeListener {
|
||||||
|
|
||||||
private final List<OnBeforeCheckedChangeListener> mBeforeCheckedChangeListeners =
|
private final List<OnBeforeCheckedChangeListener> mBeforeCheckedChangeListeners =
|
||||||
new ArrayList<>();
|
new ArrayList<>();
|
||||||
private final List<OnMainSwitchChangeListener> mSwitchChangeListeners = new ArrayList<>();
|
private final List<OnMainSwitchChangeListener> mSwitchChangeListeners = new ArrayList<>();
|
||||||
@@ -46,8 +51,8 @@ public class SettingsMainSwitchPreference extends TwoStatePreference {
|
|||||||
private SettingsMainSwitchBar mMainSwitchBar;
|
private SettingsMainSwitchBar mMainSwitchBar;
|
||||||
private CharSequence mTitle;
|
private CharSequence mTitle;
|
||||||
private boolean mIsVisible;
|
private boolean mIsVisible;
|
||||||
|
private EnforcedAdmin mEnforcedAdmin;
|
||||||
private RestrictedLockUtils.EnforcedAdmin mEnforcedAdmin;
|
private RestrictedPreferenceHelper mRestrictedHelper;
|
||||||
|
|
||||||
public SettingsMainSwitchPreference(Context context) {
|
public SettingsMainSwitchPreference(Context context) {
|
||||||
super(context);
|
super(context);
|
||||||
@@ -78,8 +83,8 @@ public class SettingsMainSwitchPreference extends TwoStatePreference {
|
|||||||
holder.setDividerAllowedBelow(false);
|
holder.setDividerAllowedBelow(false);
|
||||||
|
|
||||||
mMainSwitchBar = (SettingsMainSwitchBar) holder.findViewById(R.id.main_switch_bar);
|
mMainSwitchBar = (SettingsMainSwitchBar) holder.findViewById(R.id.main_switch_bar);
|
||||||
|
|
||||||
mMainSwitchBar.show();
|
mMainSwitchBar.show();
|
||||||
|
mEnforcedAdmin = mRestrictedHelper.checkRestrictionEnforced();
|
||||||
updateStatus(isChecked());
|
updateStatus(isChecked());
|
||||||
registerListenerToSwitchBar();
|
registerListenerToSwitchBar();
|
||||||
|
|
||||||
@@ -90,6 +95,7 @@ public class SettingsMainSwitchPreference extends TwoStatePreference {
|
|||||||
|
|
||||||
private void init(Context context, AttributeSet attrs) {
|
private void init(Context context, AttributeSet attrs) {
|
||||||
setLayoutResource(R.layout.preference_widget_main_switch);
|
setLayoutResource(R.layout.preference_widget_main_switch);
|
||||||
|
mSwitchChangeListeners.add(this);
|
||||||
mIsVisible = true;
|
mIsVisible = true;
|
||||||
|
|
||||||
if (attrs != null) {
|
if (attrs != null) {
|
||||||
@@ -103,6 +109,8 @@ public class SettingsMainSwitchPreference extends TwoStatePreference {
|
|||||||
setTitle(title.toString());
|
setTitle(title.toString());
|
||||||
}
|
}
|
||||||
a.recycle();
|
a.recycle();
|
||||||
|
|
||||||
|
mRestrictedHelper = new RestrictedPreferenceHelper(context, this, attrs);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -129,13 +137,17 @@ public class SettingsMainSwitchPreference extends TwoStatePreference {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onSwitchChanged(Switch switchView, boolean isChecked) {
|
||||||
|
super.setChecked(isChecked);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Update the switch status of preference
|
* Update the switch status of preference
|
||||||
*/
|
*/
|
||||||
public void updateStatus(boolean checked) {
|
public void updateStatus(boolean checked) {
|
||||||
setChecked(checked);
|
setChecked(checked);
|
||||||
if (mMainSwitchBar != null) {
|
if (mMainSwitchBar != null) {
|
||||||
mMainSwitchBar.setChecked(checked);
|
|
||||||
mMainSwitchBar.setTitle(mTitle);
|
mMainSwitchBar.setTitle(mTitle);
|
||||||
mMainSwitchBar.setDisabledByAdmin(mEnforcedAdmin);
|
mMainSwitchBar.setDisabledByAdmin(mEnforcedAdmin);
|
||||||
mMainSwitchBar.show();
|
mMainSwitchBar.show();
|
||||||
@@ -230,7 +242,7 @@ public class SettingsMainSwitchPreference extends TwoStatePreference {
|
|||||||
* Otherwise, calls setEnabled which will enables the entire view including
|
* Otherwise, calls setEnabled which will enables the entire view including
|
||||||
* the text and switch.
|
* the text and switch.
|
||||||
*/
|
*/
|
||||||
public void setDisabledByAdmin(RestrictedLockUtils.EnforcedAdmin admin) {
|
public void setDisabledByAdmin(EnforcedAdmin admin) {
|
||||||
mEnforcedAdmin = admin;
|
mEnforcedAdmin = admin;
|
||||||
if (mMainSwitchBar != null) {
|
if (mMainSwitchBar != null) {
|
||||||
mMainSwitchBar.setDisabledByAdmin(mEnforcedAdmin);
|
mMainSwitchBar.setDisabledByAdmin(mEnforcedAdmin);
|
||||||
|
|||||||
@@ -42,7 +42,6 @@ public class ConfigureWifiSettings extends DashboardFragment {
|
|||||||
public static final int WIFI_WAKEUP_REQUEST_CODE = 600;
|
public static final int WIFI_WAKEUP_REQUEST_CODE = 600;
|
||||||
|
|
||||||
private WifiWakeupPreferenceController mWifiWakeupPreferenceController;
|
private WifiWakeupPreferenceController mWifiWakeupPreferenceController;
|
||||||
private UseOpenWifiPreferenceController mUseOpenWifiPreferenceController;
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCreate(Bundle icicle) {
|
public void onCreate(Bundle icicle) {
|
||||||
@@ -83,9 +82,6 @@ public class ConfigureWifiSettings extends DashboardFragment {
|
|||||||
|
|
||||||
mWifiWakeupPreferenceController = use(WifiWakeupPreferenceController.class);
|
mWifiWakeupPreferenceController = use(WifiWakeupPreferenceController.class);
|
||||||
mWifiWakeupPreferenceController.setFragment(this);
|
mWifiWakeupPreferenceController.setFragment(this);
|
||||||
|
|
||||||
mUseOpenWifiPreferenceController = use(UseOpenWifiPreferenceController.class);
|
|
||||||
mUseOpenWifiPreferenceController.setFragment(this);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -94,10 +90,6 @@ public class ConfigureWifiSettings extends DashboardFragment {
|
|||||||
mWifiWakeupPreferenceController.onActivityResult(requestCode, resultCode);
|
mWifiWakeupPreferenceController.onActivityResult(requestCode, resultCode);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (requestCode == UseOpenWifiPreferenceController.REQUEST_CODE_OPEN_WIFI_AUTOMATICALLY) {
|
|
||||||
mUseOpenWifiPreferenceController.onActivityResult(requestCode, resultCode);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
super.onActivityResult(requestCode, resultCode, data);
|
super.onActivityResult(requestCode, resultCode, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,192 +0,0 @@
|
|||||||
package com.android.settings.wifi;
|
|
||||||
|
|
||||||
import android.app.Activity;
|
|
||||||
import android.content.ComponentName;
|
|
||||||
import android.content.ContentResolver;
|
|
||||||
import android.content.Context;
|
|
||||||
import android.content.Intent;
|
|
||||||
import android.database.ContentObserver;
|
|
||||||
import android.net.NetworkScoreManager;
|
|
||||||
import android.net.NetworkScorerAppData;
|
|
||||||
import android.net.Uri;
|
|
||||||
import android.os.Handler;
|
|
||||||
import android.os.Looper;
|
|
||||||
import android.provider.Settings;
|
|
||||||
import android.text.TextUtils;
|
|
||||||
|
|
||||||
import androidx.fragment.app.Fragment;
|
|
||||||
import androidx.preference.Preference;
|
|
||||||
import androidx.preference.PreferenceScreen;
|
|
||||||
|
|
||||||
import com.android.settings.R;
|
|
||||||
import com.android.settings.core.PreferenceControllerMixin;
|
|
||||||
import com.android.settings.core.TogglePreferenceController;
|
|
||||||
import com.android.settingslib.core.lifecycle.LifecycleObserver;
|
|
||||||
import com.android.settingslib.core.lifecycle.events.OnPause;
|
|
||||||
import com.android.settingslib.core.lifecycle.events.OnResume;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* {@link TogglePreferenceController} that controls whether a user wants to enable the "use open
|
|
||||||
* networks automatically" feature provided by the current network recommendation provider.
|
|
||||||
*/
|
|
||||||
public class UseOpenWifiPreferenceController extends TogglePreferenceController
|
|
||||||
implements PreferenceControllerMixin, Preference.OnPreferenceChangeListener,
|
|
||||||
LifecycleObserver, OnResume, OnPause {
|
|
||||||
public static final int REQUEST_CODE_OPEN_WIFI_AUTOMATICALLY = 400;
|
|
||||||
|
|
||||||
private static final String KEY_USE_OPEN_WIFI_AUTOMATICALLY = "use_open_wifi_automatically";
|
|
||||||
|
|
||||||
private final ContentResolver mContentResolver;
|
|
||||||
private Fragment mFragment;
|
|
||||||
private final NetworkScoreManager mNetworkScoreManager;
|
|
||||||
private final SettingObserver mSettingObserver;
|
|
||||||
|
|
||||||
private Preference mPreference;
|
|
||||||
private ComponentName mEnableUseWifiComponentName;
|
|
||||||
private boolean mDoFeatureSupportedScorersExist;
|
|
||||||
|
|
||||||
public UseOpenWifiPreferenceController(Context context) {
|
|
||||||
super(context, KEY_USE_OPEN_WIFI_AUTOMATICALLY);
|
|
||||||
mContentResolver = context.getContentResolver();
|
|
||||||
mNetworkScoreManager =
|
|
||||||
(NetworkScoreManager) context.getSystemService(Context.NETWORK_SCORE_SERVICE);
|
|
||||||
mSettingObserver = new SettingObserver();
|
|
||||||
updateEnableUseWifiComponentName();
|
|
||||||
checkForFeatureSupportedScorers();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setFragment(Fragment hostFragment) {
|
|
||||||
mFragment = hostFragment;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void updateEnableUseWifiComponentName() {
|
|
||||||
NetworkScorerAppData appData = mNetworkScoreManager.getActiveScorer();
|
|
||||||
mEnableUseWifiComponentName =
|
|
||||||
appData == null ? null : appData.getEnableUseOpenWifiActivity();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void checkForFeatureSupportedScorers() {
|
|
||||||
if (mEnableUseWifiComponentName != null) {
|
|
||||||
mDoFeatureSupportedScorersExist = true;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
List<NetworkScorerAppData> scorers = mNetworkScoreManager.getAllValidScorers();
|
|
||||||
for (NetworkScorerAppData scorer : scorers) {
|
|
||||||
if (scorer.getEnableUseOpenWifiActivity() != null) {
|
|
||||||
mDoFeatureSupportedScorersExist = true;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
mDoFeatureSupportedScorersExist = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void displayPreference(PreferenceScreen screen) {
|
|
||||||
super.displayPreference(screen);
|
|
||||||
mPreference = screen.findPreference(getPreferenceKey());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onResume() {
|
|
||||||
mSettingObserver.register(mContentResolver);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onPause() {
|
|
||||||
mSettingObserver.unregister(mContentResolver);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getAvailabilityStatus() {
|
|
||||||
// It is possible that mEnableUseWifiComponentName is no longer enabled by
|
|
||||||
// USE_OPEN_WIFI_PACKAGE. So update this component to reflect correct availability.
|
|
||||||
updateEnableUseWifiComponentName();
|
|
||||||
checkForFeatureSupportedScorers();
|
|
||||||
return mDoFeatureSupportedScorersExist ? AVAILABLE : CONDITIONALLY_UNAVAILABLE;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void updateState(Preference preference) {
|
|
||||||
super.updateState(preference);
|
|
||||||
|
|
||||||
final boolean isScorerSet = mNetworkScoreManager.getActiveScorerPackage() != null;
|
|
||||||
final boolean doesActiveScorerSupportFeature = mEnableUseWifiComponentName != null;
|
|
||||||
|
|
||||||
preference.setEnabled(isScorerSet && doesActiveScorerSupportFeature);
|
|
||||||
if (!isScorerSet) {
|
|
||||||
preference.setSummary(R.string.use_open_wifi_automatically_summary_scoring_disabled);
|
|
||||||
} else if (!doesActiveScorerSupportFeature) {
|
|
||||||
preference.setSummary(
|
|
||||||
R.string.use_open_wifi_automatically_summary_scorer_unsupported_disabled);
|
|
||||||
} else {
|
|
||||||
preference.setSummary(R.string.use_open_wifi_automatically_summary);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isChecked() {
|
|
||||||
final String enabledUseOpenWifiPackage = Settings.Global.getString(mContentResolver,
|
|
||||||
Settings.Global.USE_OPEN_WIFI_PACKAGE);
|
|
||||||
final String currentUseOpenWifiPackage = mEnableUseWifiComponentName == null
|
|
||||||
? null : mEnableUseWifiComponentName.getPackageName();
|
|
||||||
return TextUtils.equals(enabledUseOpenWifiPackage, currentUseOpenWifiPackage);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean setChecked(boolean isChecked) {
|
|
||||||
if (isChecked) {
|
|
||||||
if (mFragment == null) {
|
|
||||||
throw new IllegalStateException("No fragment to start activity");
|
|
||||||
}
|
|
||||||
|
|
||||||
final Intent intent = new Intent(NetworkScoreManager.ACTION_CUSTOM_ENABLE);
|
|
||||||
intent.setComponent(mEnableUseWifiComponentName);
|
|
||||||
mFragment.startActivityForResult(intent, REQUEST_CODE_OPEN_WIFI_AUTOMATICALLY);
|
|
||||||
return false; // Updating state is done in onActivityResult.
|
|
||||||
} else {
|
|
||||||
Settings.Global.putString(mContentResolver, Settings.Global.USE_OPEN_WIFI_PACKAGE, "");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean onActivityResult(int requestCode, int resultCode) {
|
|
||||||
if (requestCode != REQUEST_CODE_OPEN_WIFI_AUTOMATICALLY) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (resultCode == Activity.RESULT_OK) {
|
|
||||||
Settings.Global.putString(mContentResolver, Settings.Global.USE_OPEN_WIFI_PACKAGE,
|
|
||||||
mEnableUseWifiComponentName.getPackageName());
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
class SettingObserver extends ContentObserver {
|
|
||||||
private final Uri NETWORK_RECOMMENDATIONS_ENABLED_URI =
|
|
||||||
Settings.Global.getUriFor(Settings.Global.NETWORK_RECOMMENDATIONS_ENABLED);
|
|
||||||
|
|
||||||
public SettingObserver() {
|
|
||||||
super(new Handler(Looper.getMainLooper()));
|
|
||||||
}
|
|
||||||
|
|
||||||
public void register(ContentResolver cr) {
|
|
||||||
cr.registerContentObserver(NETWORK_RECOMMENDATIONS_ENABLED_URI, false, this);
|
|
||||||
onChange(true /* selfChange */, NETWORK_RECOMMENDATIONS_ENABLED_URI);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void unregister(ContentResolver cr) {
|
|
||||||
cr.unregisterContentObserver(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onChange(boolean selfChange, Uri uri) {
|
|
||||||
super.onChange(selfChange, uri);
|
|
||||||
if (NETWORK_RECOMMENDATIONS_ENABLED_URI.equals(uri)) {
|
|
||||||
updateEnableUseWifiComponentName();
|
|
||||||
updateState(mPreference);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -22,7 +22,6 @@ import android.os.Bundle;
|
|||||||
import android.provider.Settings;
|
import android.provider.Settings;
|
||||||
import android.telephony.SubscriptionInfo;
|
import android.telephony.SubscriptionInfo;
|
||||||
import android.telephony.SubscriptionManager;
|
import android.telephony.SubscriptionManager;
|
||||||
import android.util.FeatureFlagUtils;
|
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
@@ -35,12 +34,10 @@ import androidx.fragment.app.FragmentPagerAdapter;
|
|||||||
|
|
||||||
import com.android.internal.util.CollectionUtils;
|
import com.android.internal.util.CollectionUtils;
|
||||||
import com.android.settings.R;
|
import com.android.settings.R;
|
||||||
import com.android.settings.core.FeatureFlags;
|
|
||||||
import com.android.settings.core.InstrumentedFragment;
|
import com.android.settings.core.InstrumentedFragment;
|
||||||
import com.android.settings.network.SubscriptionUtil;
|
import com.android.settings.network.SubscriptionUtil;
|
||||||
import com.android.settings.network.ims.WifiCallingQueryImsState;
|
import com.android.settings.network.ims.WifiCallingQueryImsState;
|
||||||
import com.android.settings.search.actionbar.SearchMenuController;
|
import com.android.settings.search.actionbar.SearchMenuController;
|
||||||
import com.android.settings.support.actionbar.HelpMenuController;
|
|
||||||
import com.android.settings.support.actionbar.HelpResourceProvider;
|
import com.android.settings.support.actionbar.HelpResourceProvider;
|
||||||
import com.android.settings.widget.RtlCompatibleViewPager;
|
import com.android.settings.widget.RtlCompatibleViewPager;
|
||||||
import com.android.settings.widget.SlidingTabLayout;
|
import com.android.settings.widget.SlidingTabLayout;
|
||||||
@@ -121,12 +118,6 @@ public class WifiCallingSettings extends InstrumentedFragment implements HelpRes
|
|||||||
@Override
|
@Override
|
||||||
public void onCreate(Bundle icicle) {
|
public void onCreate(Bundle icicle) {
|
||||||
super.onCreate(icicle);
|
super.onCreate(icicle);
|
||||||
// TODO(b/176883483): Remove the option menu if collapsing toolbar feature rolled out
|
|
||||||
if (!FeatureFlagUtils.isEnabled(getContext(), FeatureFlags.SILKY_HOME)) {
|
|
||||||
setHasOptionsMenu(true);
|
|
||||||
SearchMenuController.init(this /* host */);
|
|
||||||
HelpMenuController.init(this /* host */);
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO: besides in onCreate, we should also update subList when SIM / Sub status
|
// TODO: besides in onCreate, we should also update subList when SIM / Sub status
|
||||||
// changes.
|
// changes.
|
||||||
|
|||||||
@@ -75,7 +75,7 @@ public class WifiP2pSettings extends DashboardFragment
|
|||||||
|
|
||||||
private final IntentFilter mIntentFilter = new IntentFilter();
|
private final IntentFilter mIntentFilter = new IntentFilter();
|
||||||
@VisibleForTesting WifiP2pManager mWifiP2pManager;
|
@VisibleForTesting WifiP2pManager mWifiP2pManager;
|
||||||
private WifiP2pManager.Channel mChannel;
|
@VisibleForTesting WifiP2pManager.Channel mChannel;
|
||||||
@VisibleForTesting OnClickListener mRenameListener;
|
@VisibleForTesting OnClickListener mRenameListener;
|
||||||
@VisibleForTesting OnClickListener mDisconnectListener;
|
@VisibleForTesting OnClickListener mDisconnectListener;
|
||||||
@VisibleForTesting OnClickListener mCancelConnectListener;
|
@VisibleForTesting OnClickListener mCancelConnectListener;
|
||||||
@@ -144,7 +144,9 @@ public class WifiP2pSettings extends DashboardFragment
|
|||||||
// Requesting our own device info as an app holding the NETWORK_SETTINGS permission
|
// Requesting our own device info as an app holding the NETWORK_SETTINGS permission
|
||||||
// ensures that the MAC address will be available in the result.
|
// ensures that the MAC address will be available in the result.
|
||||||
if (DBG) Log.d(TAG, "This device changed. Requesting device info.");
|
if (DBG) Log.d(TAG, "This device changed. Requesting device info.");
|
||||||
mWifiP2pManager.requestDeviceInfo(mChannel, WifiP2pSettings.this);
|
if (mWifiP2pManager != null && mChannel != null) {
|
||||||
|
mWifiP2pManager.requestDeviceInfo(mChannel, WifiP2pSettings.this);
|
||||||
|
}
|
||||||
} else if (WifiP2pManager.WIFI_P2P_DISCOVERY_CHANGED_ACTION.equals(action)) {
|
} else if (WifiP2pManager.WIFI_P2P_DISCOVERY_CHANGED_ACTION.equals(action)) {
|
||||||
int discoveryState = intent.getIntExtra(WifiP2pManager.EXTRA_DISCOVERY_STATE,
|
int discoveryState = intent.getIntExtra(WifiP2pManager.EXTRA_DISCOVERY_STATE,
|
||||||
WifiP2pManager.WIFI_P2P_DISCOVERY_STOPPED);
|
WifiP2pManager.WIFI_P2P_DISCOVERY_STOPPED);
|
||||||
@@ -155,7 +157,7 @@ public class WifiP2pSettings extends DashboardFragment
|
|||||||
updateSearchMenu(false);
|
updateSearchMenu(false);
|
||||||
}
|
}
|
||||||
} else if (WifiP2pManager.ACTION_WIFI_P2P_PERSISTENT_GROUPS_CHANGED.equals(action)) {
|
} else if (WifiP2pManager.ACTION_WIFI_P2P_PERSISTENT_GROUPS_CHANGED.equals(action)) {
|
||||||
if (mWifiP2pManager != null) {
|
if (mWifiP2pManager != null && mChannel != null) {
|
||||||
mWifiP2pManager.requestPersistentGroupInfo(mChannel, WifiP2pSettings.this);
|
mWifiP2pManager.requestPersistentGroupInfo(mChannel, WifiP2pSettings.this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -204,9 +206,7 @@ public class WifiP2pSettings extends DashboardFragment
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (mWifiP2pManager != null) {
|
if (mWifiP2pManager != null) {
|
||||||
mChannel = mWifiP2pManager.initialize(activity.getApplicationContext(),
|
if (!initChannel()) {
|
||||||
getActivity().getMainLooper(), null);
|
|
||||||
if (mChannel == null) {
|
|
||||||
//Failure to set up connection
|
//Failure to set up connection
|
||||||
Log.e(TAG, "Failed to set up connection with wifi p2p service");
|
Log.e(TAG, "Failed to set up connection with wifi p2p service");
|
||||||
mWifiP2pManager = null;
|
mWifiP2pManager = null;
|
||||||
@@ -230,7 +230,7 @@ public class WifiP2pSettings extends DashboardFragment
|
|||||||
@Override
|
@Override
|
||||||
public void onClick(DialogInterface dialog, int which) {
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
if (which == DialogInterface.BUTTON_POSITIVE) {
|
if (which == DialogInterface.BUTTON_POSITIVE) {
|
||||||
if (mWifiP2pManager != null) {
|
if (mWifiP2pManager != null && mChannel != null) {
|
||||||
String name = mDeviceNameText.getText().toString();
|
String name = mDeviceNameText.getText().toString();
|
||||||
if (name != null) {
|
if (name != null) {
|
||||||
for (int i = 0; i < name.length(); i++) {
|
for (int i = 0; i < name.length(); i++) {
|
||||||
@@ -266,7 +266,7 @@ public class WifiP2pSettings extends DashboardFragment
|
|||||||
@Override
|
@Override
|
||||||
public void onClick(DialogInterface dialog, int which) {
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
if (which == DialogInterface.BUTTON_POSITIVE) {
|
if (which == DialogInterface.BUTTON_POSITIVE) {
|
||||||
if (mWifiP2pManager != null) {
|
if (mWifiP2pManager != null && mChannel != null) {
|
||||||
mWifiP2pManager.removeGroup(mChannel, new WifiP2pManager.ActionListener() {
|
mWifiP2pManager.removeGroup(mChannel, new WifiP2pManager.ActionListener() {
|
||||||
public void onSuccess() {
|
public void onSuccess() {
|
||||||
if (DBG) Log.d(TAG, " remove group success");
|
if (DBG) Log.d(TAG, " remove group success");
|
||||||
@@ -285,7 +285,7 @@ public class WifiP2pSettings extends DashboardFragment
|
|||||||
@Override
|
@Override
|
||||||
public void onClick(DialogInterface dialog, int which) {
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
if (which == DialogInterface.BUTTON_POSITIVE) {
|
if (which == DialogInterface.BUTTON_POSITIVE) {
|
||||||
if (mWifiP2pManager != null) {
|
if (mWifiP2pManager != null && mChannel != null) {
|
||||||
mWifiP2pManager.cancelConnect(mChannel,
|
mWifiP2pManager.cancelConnect(mChannel,
|
||||||
new WifiP2pManager.ActionListener() {
|
new WifiP2pManager.ActionListener() {
|
||||||
public void onSuccess() {
|
public void onSuccess() {
|
||||||
@@ -305,7 +305,7 @@ public class WifiP2pSettings extends DashboardFragment
|
|||||||
@Override
|
@Override
|
||||||
public void onClick(DialogInterface dialog, int which) {
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
if (which == DialogInterface.BUTTON_POSITIVE) {
|
if (which == DialogInterface.BUTTON_POSITIVE) {
|
||||||
if (mWifiP2pManager != null) {
|
if (mWifiP2pManager != null && mChannel != null) {
|
||||||
if (mSelectedGroup != null) {
|
if (mSelectedGroup != null) {
|
||||||
if (DBG) Log.d(TAG, " deleting group " + mSelectedGroup.getGroupName());
|
if (DBG) Log.d(TAG, " deleting group " + mSelectedGroup.getGroupName());
|
||||||
mWifiP2pManager.deletePersistentGroup(mChannel,
|
mWifiP2pManager.deletePersistentGroup(mChannel,
|
||||||
@@ -346,9 +346,9 @@ public class WifiP2pSettings extends DashboardFragment
|
|||||||
mIntentFilter.addAction(WifiP2pManager.WIFI_P2P_DISCOVERY_CHANGED_ACTION);
|
mIntentFilter.addAction(WifiP2pManager.WIFI_P2P_DISCOVERY_CHANGED_ACTION);
|
||||||
mIntentFilter.addAction(WifiP2pManager.ACTION_WIFI_P2P_PERSISTENT_GROUPS_CHANGED);
|
mIntentFilter.addAction(WifiP2pManager.ACTION_WIFI_P2P_PERSISTENT_GROUPS_CHANGED);
|
||||||
final PreferenceScreen preferenceScreen = getPreferenceScreen();
|
final PreferenceScreen preferenceScreen = getPreferenceScreen();
|
||||||
|
if (mWifiP2pManager != null && initChannel()) {
|
||||||
getActivity().registerReceiver(mReceiver, mIntentFilter);
|
// Register receiver after make sure channel exist
|
||||||
if (mWifiP2pManager != null) {
|
getActivity().registerReceiver(mReceiver, mIntentFilter);
|
||||||
mWifiP2pManager.requestPeers(mChannel, WifiP2pSettings.this);
|
mWifiP2pManager.requestPeers(mChannel, WifiP2pSettings.this);
|
||||||
mWifiP2pManager.requestDeviceInfo(mChannel, WifiP2pSettings.this);
|
mWifiP2pManager.requestDeviceInfo(mChannel, WifiP2pSettings.this);
|
||||||
mIsIgnoreInitConnectionInfoCallback = false;
|
mIsIgnoreInitConnectionInfoCallback = false;
|
||||||
@@ -373,8 +373,13 @@ public class WifiP2pSettings extends DashboardFragment
|
|||||||
@Override
|
@Override
|
||||||
public void onPause() {
|
public void onPause() {
|
||||||
super.onPause();
|
super.onPause();
|
||||||
if (mWifiP2pManager != null) {
|
if (mWifiP2pManager != null && mChannel != null) {
|
||||||
mWifiP2pManager.stopPeerDiscovery(mChannel, null);
|
mWifiP2pManager.stopPeerDiscovery(mChannel, null);
|
||||||
|
if (!mLastGroupFormed) {
|
||||||
|
// Close the channel when p2p doesn't connected.
|
||||||
|
mChannel.close();
|
||||||
|
mChannel = null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
getActivity().unregisterReceiver(mReceiver);
|
getActivity().unregisterReceiver(mReceiver);
|
||||||
}
|
}
|
||||||
@@ -447,19 +452,20 @@ public class WifiP2pSettings extends DashboardFragment
|
|||||||
config.wps.setup = WpsInfo.DISPLAY;
|
config.wps.setup = WpsInfo.DISPLAY;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (mWifiP2pManager != null && mChannel != null) {
|
||||||
mWifiP2pManager.connect(mChannel, config,
|
mWifiP2pManager.connect(mChannel, config,
|
||||||
new WifiP2pManager.ActionListener() {
|
new WifiP2pManager.ActionListener() {
|
||||||
public void onSuccess() {
|
public void onSuccess() {
|
||||||
if (DBG) Log.d(TAG, " connect success");
|
if (DBG) Log.d(TAG, " connect success");
|
||||||
}
|
}
|
||||||
public void onFailure(int reason) {
|
public void onFailure(int reason) {
|
||||||
Log.e(TAG, " connect fail " + reason);
|
Log.e(TAG, " connect fail " + reason);
|
||||||
Toast.makeText(getActivity(),
|
Toast.makeText(getActivity(),
|
||||||
R.string.wifi_p2p_failed_connect_message,
|
R.string.wifi_p2p_failed_connect_message,
|
||||||
Toast.LENGTH_SHORT).show();
|
Toast.LENGTH_SHORT).show();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else if (preference instanceof WifiP2pPersistentGroup) {
|
} else if (preference instanceof WifiP2pPersistentGroup) {
|
||||||
mSelectedGroup = (WifiP2pPersistentGroup) preference;
|
mSelectedGroup = (WifiP2pPersistentGroup) preference;
|
||||||
@@ -626,7 +632,7 @@ public class WifiP2pSettings extends DashboardFragment
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void startSearch() {
|
private void startSearch() {
|
||||||
if (mWifiP2pManager != null && !mWifiP2pSearching) {
|
if (mWifiP2pManager != null && mChannel != null && !mWifiP2pSearching) {
|
||||||
mWifiP2pManager.discoverPeers(mChannel, new WifiP2pManager.ActionListener() {
|
mWifiP2pManager.discoverPeers(mChannel, new WifiP2pManager.ActionListener() {
|
||||||
public void onSuccess() {
|
public void onSuccess() {
|
||||||
}
|
}
|
||||||
@@ -636,4 +642,19 @@ public class WifiP2pSettings extends DashboardFragment
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private boolean initChannel() {
|
||||||
|
if (mChannel != null) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (mWifiP2pManager != null) {
|
||||||
|
mChannel = mWifiP2pManager.initialize(getActivity().getApplicationContext(),
|
||||||
|
getActivity().getMainLooper(), null);
|
||||||
|
}
|
||||||
|
if (mChannel == null) {
|
||||||
|
Log.e(TAG, "Failed to set up connection with wifi p2p service");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,24 +19,26 @@ package com.android.settings.fuelgauge.batterysaver;
|
|||||||
import static com.google.common.truth.Truth.assertThat;
|
import static com.google.common.truth.Truth.assertThat;
|
||||||
import static com.google.common.truth.Truth.assert_;
|
import static com.google.common.truth.Truth.assert_;
|
||||||
|
|
||||||
|
import android.app.Activity;
|
||||||
import android.app.Instrumentation;
|
import android.app.Instrumentation;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.os.PowerManager;
|
import android.os.PowerManager;
|
||||||
import android.provider.Settings;
|
import android.provider.Settings;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.widget.Button;
|
|
||||||
|
|
||||||
|
import androidx.fragment.app.Fragment;
|
||||||
|
import androidx.fragment.app.FragmentActivity;
|
||||||
import androidx.test.core.app.ActivityScenario;
|
import androidx.test.core.app.ActivityScenario;
|
||||||
|
import androidx.test.core.app.ApplicationProvider;
|
||||||
import androidx.test.ext.junit.rules.ActivityScenarioRule;
|
import androidx.test.ext.junit.rules.ActivityScenarioRule;
|
||||||
import androidx.test.ext.junit.runners.AndroidJUnit4;
|
import androidx.test.ext.junit.runners.AndroidJUnit4;
|
||||||
import androidx.test.filters.SmallTest;
|
import androidx.test.filters.SmallTest;
|
||||||
import androidx.test.platform.app.InstrumentationRegistry;
|
import androidx.test.platform.app.InstrumentationRegistry;
|
||||||
|
|
||||||
import com.android.settings.R;
|
|
||||||
import com.android.settings.Settings.BatterySaverSettingsActivity;
|
import com.android.settings.Settings.BatterySaverSettingsActivity;
|
||||||
|
import com.android.settings.SettingsPreferenceFragment;
|
||||||
import com.android.settings.testutils.AdbUtils;
|
import com.android.settings.testutils.AdbUtils;
|
||||||
import com.android.settings.testutils.UiUtils;
|
|
||||||
|
|
||||||
import org.junit.After;
|
import org.junit.After;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
@@ -49,11 +51,10 @@ import org.junit.runner.RunWith;
|
|||||||
public class BatterySaverButtonPreferenceControllerComponentTest {
|
public class BatterySaverButtonPreferenceControllerComponentTest {
|
||||||
private static final String TAG =
|
private static final String TAG =
|
||||||
BatterySaverButtonPreferenceControllerComponentTest.class.getSimpleName();
|
BatterySaverButtonPreferenceControllerComponentTest.class.getSimpleName();
|
||||||
private Instrumentation mInstrumentation = InstrumentationRegistry.getInstrumentation();
|
private final Instrumentation mInstrumentation = InstrumentationRegistry.getInstrumentation();
|
||||||
private PowerManager mManager =
|
private final PowerManager mManager =
|
||||||
(PowerManager) mInstrumentation.getTargetContext().getSystemService(
|
(PowerManager) mInstrumentation.getTargetContext().getSystemService(
|
||||||
Context.POWER_SERVICE);
|
Context.POWER_SERVICE);
|
||||||
|
|
||||||
@Rule
|
@Rule
|
||||||
public ActivityScenarioRule<BatterySaverSettingsActivity> rule = new ActivityScenarioRule<>(
|
public ActivityScenarioRule<BatterySaverSettingsActivity> rule = new ActivityScenarioRule<>(
|
||||||
new Intent(
|
new Intent(
|
||||||
@@ -66,55 +67,28 @@ public class BatterySaverButtonPreferenceControllerComponentTest {
|
|||||||
mInstrumentation.getUiAutomation().executeShellCommand("settings get global low_power 0");
|
mInstrumentation.getUiAutomation().executeShellCommand("settings get global low_power 0");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private BatterySaverButtonPreferenceController get_battery_saver_controller(Activity activity) {
|
||||||
|
BatterySaverButtonPreferenceController controller =
|
||||||
|
new BatterySaverButtonPreferenceController(
|
||||||
|
ApplicationProvider.getApplicationContext(), "battery_saver");
|
||||||
|
Fragment f =
|
||||||
|
((FragmentActivity) activity).getSupportFragmentManager().getFragments().get(0);
|
||||||
|
controller.displayPreference(((SettingsPreferenceFragment) f).getPreferenceScreen());
|
||||||
|
return controller;
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void test_check_battery_saver_button() throws Exception {
|
public void test_check_battery_saver_button() throws Exception {
|
||||||
ActivityScenario scenario = rule.getScenario();
|
ActivityScenario scenario = rule.getScenario();
|
||||||
scenario.onActivity(activity -> {
|
scenario.onActivity(activity -> {
|
||||||
final Button button = activity.findViewById(R.id.state_on_button);
|
BatterySaverButtonPreferenceController controller =
|
||||||
UiUtils.waitUntilCondition(3000, () -> button.isEnabled());
|
get_battery_saver_controller(activity);
|
||||||
button.callOnClick();
|
controller.setChecked(true);
|
||||||
checkPowerSaverMode(true);
|
checkPowerSaverMode(true);
|
||||||
|
|
||||||
Button offButton = activity.findViewById(R.id.state_off_button);
|
controller.setChecked(false);
|
||||||
offButton.callOnClick();
|
|
||||||
checkPowerSaverMode(false);
|
checkPowerSaverMode(false);
|
||||||
});
|
});
|
||||||
|
|
||||||
//Ideally, we should be able to also create BatteryTipPreferenceController and verify that
|
|
||||||
//it is showing battery saver on. Unfortunately, that part of code is tightly coupled with
|
|
||||||
//UI, and it's not possible to retrieve that string without reaching very deep into the
|
|
||||||
//codes and become very tightly coupled with any future changes. That is not what component
|
|
||||||
//tests should do, so either we'll need to do this through UI with another ActivityScenario,
|
|
||||||
//or the code needs to be refactored to be less coupled with UI.
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void test_battery_saver_button_changes_when_framework_setting_change() throws Exception {
|
|
||||||
ActivityScenario scenario = rule.getScenario();
|
|
||||||
scenario.onActivity(activity -> {
|
|
||||||
Button buttonOn = activity.findViewById(R.id.state_on_button);
|
|
||||||
Button buttonOff = activity.findViewById(R.id.state_off_button);
|
|
||||||
assertThat(buttonOn.isVisibleToUser()).isEqualTo(true);
|
|
||||||
assertThat(buttonOff.isVisibleToUser()).isEqualTo(false);
|
|
||||||
});
|
|
||||||
|
|
||||||
mManager.setPowerSaveModeEnabled(true);
|
|
||||||
scenario.recreate();
|
|
||||||
scenario.onActivity(activity -> {
|
|
||||||
Button buttonOn = activity.findViewById(R.id.state_on_button);
|
|
||||||
Button buttonOff = activity.findViewById(R.id.state_off_button);
|
|
||||||
assertThat(buttonOn.isVisibleToUser()).isEqualTo(false);
|
|
||||||
assertThat(buttonOff.isVisibleToUser()).isEqualTo(true);
|
|
||||||
});
|
|
||||||
|
|
||||||
mManager.setPowerSaveModeEnabled(false);
|
|
||||||
scenario.recreate();
|
|
||||||
scenario.onActivity(activity -> {
|
|
||||||
Button buttonOn = activity.findViewById(R.id.state_on_button);
|
|
||||||
Button buttonOff = activity.findViewById(R.id.state_off_button);
|
|
||||||
assertThat(buttonOn.isVisibleToUser()).isEqualTo(true);
|
|
||||||
assertThat(buttonOff.isVisibleToUser()).isEqualTo(false);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@After
|
@After
|
||||||
@@ -140,4 +114,5 @@ public class BatterySaverButtonPreferenceControllerComponentTest {
|
|||||||
//Check through manager
|
//Check through manager
|
||||||
assertThat(mManager.isPowerSaveMode() == enabled).isTrue();
|
assertThat(mManager.isPowerSaveMode() == enabled).isTrue();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,67 +0,0 @@
|
|||||||
/*
|
|
||||||
* 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.accessibility;
|
|
||||||
|
|
||||||
import static com.google.common.truth.Truth.assertThat;
|
|
||||||
|
|
||||||
import android.content.Context;
|
|
||||||
|
|
||||||
import androidx.preference.PreferenceManager;
|
|
||||||
import androidx.preference.PreferenceScreen;
|
|
||||||
import androidx.test.core.app.ApplicationProvider;
|
|
||||||
|
|
||||||
import com.android.settings.R;
|
|
||||||
|
|
||||||
import org.junit.Before;
|
|
||||||
import org.junit.Test;
|
|
||||||
import org.junit.runner.RunWith;
|
|
||||||
import org.robolectric.RobolectricTestRunner;
|
|
||||||
|
|
||||||
/** Tests for {@link AccessibilityButtonFooterPreferenceController}. */
|
|
||||||
@RunWith(RobolectricTestRunner.class)
|
|
||||||
public class AccessibilityButtonFooterPreferenceControllerTest {
|
|
||||||
|
|
||||||
private static final String TEST_KEY = "test_key";
|
|
||||||
private static final String TEST_TITLE = "test_title";
|
|
||||||
private final Context mContext = ApplicationProvider.getApplicationContext();
|
|
||||||
private PreferenceScreen mScreen;
|
|
||||||
private AccessibilityButtonFooterPreferenceController mController;
|
|
||||||
|
|
||||||
@Before
|
|
||||||
public void setUp() {
|
|
||||||
final PreferenceManager preferenceManager = new PreferenceManager(mContext);
|
|
||||||
mScreen = preferenceManager.createPreferenceScreen(mContext);
|
|
||||||
final AccessibilityFooterPreference footerPreference =
|
|
||||||
new AccessibilityFooterPreference(mContext);
|
|
||||||
footerPreference.setKey(TEST_KEY);
|
|
||||||
footerPreference.setTitle(TEST_TITLE);
|
|
||||||
mScreen.addPreference(footerPreference);
|
|
||||||
mController = new AccessibilityButtonFooterPreferenceController(mContext, TEST_KEY);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void onPreferenceChange_shouldSetCorrectIconContentDescription() {
|
|
||||||
mController.displayPreference(mScreen);
|
|
||||||
|
|
||||||
final AccessibilityFooterPreference footerPreference = mScreen.findPreference(TEST_KEY);
|
|
||||||
final String packageName = mContext.getString(R.string.accessibility_button_title);
|
|
||||||
final String iconContentDescription = mContext.getString(
|
|
||||||
R.string.accessibility_introduction_title,
|
|
||||||
packageName);
|
|
||||||
assertThat(footerPreference.getIconContentDescription()).isEqualTo(iconContentDescription);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,69 +0,0 @@
|
|||||||
/*
|
|
||||||
* 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.accessibility;
|
|
||||||
|
|
||||||
import static com.google.common.truth.Truth.assertThat;
|
|
||||||
|
|
||||||
import android.content.Context;
|
|
||||||
|
|
||||||
import androidx.preference.PreferenceManager;
|
|
||||||
import androidx.preference.PreferenceScreen;
|
|
||||||
import androidx.test.core.app.ApplicationProvider;
|
|
||||||
|
|
||||||
import com.android.settings.R;
|
|
||||||
|
|
||||||
import org.junit.Before;
|
|
||||||
import org.junit.Test;
|
|
||||||
import org.junit.runner.RunWith;
|
|
||||||
import org.robolectric.RobolectricTestRunner;
|
|
||||||
|
|
||||||
/** Tests for {@link AccessibilityControlTimeoutFooterPreferenceController}. */
|
|
||||||
@RunWith(RobolectricTestRunner.class)
|
|
||||||
public class AccessibilityControlTimeoutFooterPreferenceControllerTest {
|
|
||||||
|
|
||||||
private static final String TEST_KEY = "test_key";
|
|
||||||
private static final String TEST_TITLE = "test_title";
|
|
||||||
private final Context mContext = ApplicationProvider.getApplicationContext();
|
|
||||||
private PreferenceScreen mScreen;
|
|
||||||
private AccessibilityControlTimeoutFooterPreferenceController mController;
|
|
||||||
|
|
||||||
@Before
|
|
||||||
public void setUp() {
|
|
||||||
final PreferenceManager preferenceManager = new PreferenceManager(mContext);
|
|
||||||
mScreen = preferenceManager.createPreferenceScreen(mContext);
|
|
||||||
final AccessibilityFooterPreference footerPreference =
|
|
||||||
new AccessibilityFooterPreference(mContext);
|
|
||||||
footerPreference.setKey(TEST_KEY);
|
|
||||||
footerPreference.setTitle(TEST_TITLE);
|
|
||||||
mScreen.addPreference(footerPreference);
|
|
||||||
mController = new AccessibilityControlTimeoutFooterPreferenceController(mContext, TEST_KEY);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void onPreferenceChange_shouldSetCorrectIconContentDescription() {
|
|
||||||
mController.displayPreference(mScreen);
|
|
||||||
|
|
||||||
final AccessibilityFooterPreference footerPreference =
|
|
||||||
mScreen.findPreference(TEST_KEY);
|
|
||||||
final String packageName =
|
|
||||||
mContext.getString(R.string.accessibility_setting_item_control_timeout_title);
|
|
||||||
final String iconContentDescription = mContext.getString(
|
|
||||||
R.string.accessibility_introduction_title,
|
|
||||||
packageName);
|
|
||||||
assertThat(footerPreference.getIconContentDescription()).isEqualTo(iconContentDescription);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -19,13 +19,12 @@ package com.android.settings.accessibility;
|
|||||||
import static com.google.common.truth.Truth.assertThat;
|
import static com.google.common.truth.Truth.assertThat;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
import android.text.method.MovementMethod;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.widget.LinearLayout;
|
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
import androidx.preference.PreferenceViewHolder;
|
import androidx.preference.PreferenceViewHolder;
|
||||||
import androidx.test.core.app.ApplicationProvider;
|
|
||||||
|
|
||||||
import com.android.settings.R;
|
import com.android.settings.R;
|
||||||
|
|
||||||
@@ -39,10 +38,6 @@ import org.robolectric.RuntimeEnvironment;
|
|||||||
@RunWith(RobolectricTestRunner.class)
|
@RunWith(RobolectricTestRunner.class)
|
||||||
public final class AccessibilityFooterPreferenceTest {
|
public final class AccessibilityFooterPreferenceTest {
|
||||||
|
|
||||||
private static final String DEFAULT_SUMMARY = "default summary";
|
|
||||||
private static final String DEFAULT_DESCRIPTION = "default description";
|
|
||||||
|
|
||||||
private Context mContext = ApplicationProvider.getApplicationContext();
|
|
||||||
private AccessibilityFooterPreference mAccessibilityFooterPreference;
|
private AccessibilityFooterPreference mAccessibilityFooterPreference;
|
||||||
private PreferenceViewHolder mPreferenceViewHolder;
|
private PreferenceViewHolder mPreferenceViewHolder;
|
||||||
|
|
||||||
@@ -58,41 +53,22 @@ public final class AccessibilityFooterPreferenceTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void onBindViewHolder_initTextConfig_parseTextAndFocusable() {
|
public void onBindViewHolder_LinkDisabledByDefault_notReturnLinkMovement() {
|
||||||
mAccessibilityFooterPreference.setSummary(DEFAULT_SUMMARY);
|
mAccessibilityFooterPreference.onBindViewHolder(mPreferenceViewHolder);
|
||||||
|
|
||||||
|
final TextView summaryView = (TextView) mPreferenceViewHolder.findViewById(
|
||||||
|
android.R.id.title);
|
||||||
|
assertThat(summaryView.getMovementMethod()).isNull();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void onBindViewHolder_setLinkEnabled_returnLinkMovement() {
|
||||||
|
mAccessibilityFooterPreference.setLinkEnabled(true);
|
||||||
|
|
||||||
mAccessibilityFooterPreference.onBindViewHolder(mPreferenceViewHolder);
|
mAccessibilityFooterPreference.onBindViewHolder(mPreferenceViewHolder);
|
||||||
|
|
||||||
final TextView summaryView = (TextView) mPreferenceViewHolder.findViewById(
|
final TextView summaryView = (TextView) mPreferenceViewHolder.findViewById(
|
||||||
android.R.id.title);
|
android.R.id.title);
|
||||||
assertThat(summaryView.getText().toString()).isEqualTo(DEFAULT_SUMMARY);
|
assertThat(summaryView.getMovementMethod()).isInstanceOf(MovementMethod.class);
|
||||||
assertThat(summaryView.isFocusable()).isEqualTo(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void onBindViewHolder_initTextConfigAndAccessibleIcon_groupContentForAccessible() {
|
|
||||||
mAccessibilityFooterPreference.setSummary(DEFAULT_SUMMARY);
|
|
||||||
mAccessibilityFooterPreference.setIconContentDescription(DEFAULT_DESCRIPTION);
|
|
||||||
|
|
||||||
mAccessibilityFooterPreference.onBindViewHolder(mPreferenceViewHolder);
|
|
||||||
|
|
||||||
final TextView summaryView = (TextView) mPreferenceViewHolder.findViewById(
|
|
||||||
android.R.id.title);
|
|
||||||
assertThat(summaryView.getText().toString()).isEqualTo(DEFAULT_SUMMARY);
|
|
||||||
assertThat(summaryView.isFocusable()).isEqualTo(false);
|
|
||||||
final LinearLayout infoFrame = (LinearLayout) mPreferenceViewHolder.findViewById(
|
|
||||||
R.id.icon_frame);
|
|
||||||
assertThat(infoFrame.getContentDescription()).isEqualTo(DEFAULT_DESCRIPTION);
|
|
||||||
assertThat(infoFrame.isFocusable()).isEqualTo(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void appendHelpLink_timeoutHelpUri_updateSummary() {
|
|
||||||
mAccessibilityFooterPreference.setSummary(DEFAULT_SUMMARY);
|
|
||||||
|
|
||||||
mAccessibilityFooterPreference.appendHelpLink(R.string.help_url_timeout);
|
|
||||||
|
|
||||||
final String title = mAccessibilityFooterPreference.getTitle().toString();
|
|
||||||
assertThat(title.contains(mContext.getString(R.string.footer_learn_more))).isTrue();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,67 +0,0 @@
|
|||||||
/*
|
|
||||||
* 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.accessibility;
|
|
||||||
|
|
||||||
import static com.google.common.truth.Truth.assertThat;
|
|
||||||
|
|
||||||
import android.content.Context;
|
|
||||||
|
|
||||||
import androidx.preference.PreferenceManager;
|
|
||||||
import androidx.preference.PreferenceScreen;
|
|
||||||
import androidx.test.core.app.ApplicationProvider;
|
|
||||||
|
|
||||||
import com.android.settings.R;
|
|
||||||
|
|
||||||
import org.junit.Before;
|
|
||||||
import org.junit.Test;
|
|
||||||
import org.junit.runner.RunWith;
|
|
||||||
import org.robolectric.RobolectricTestRunner;
|
|
||||||
|
|
||||||
/** Tests for {@link CaptionFooterPreferenceController}. */
|
|
||||||
@RunWith(RobolectricTestRunner.class)
|
|
||||||
public class CaptionFooterPreferenceControllerTest {
|
|
||||||
|
|
||||||
private static final String TEST_KEY = "test_key";
|
|
||||||
private static final String TEST_TITLE = "test_title";
|
|
||||||
private final Context mContext = ApplicationProvider.getApplicationContext();
|
|
||||||
private PreferenceScreen mScreen;
|
|
||||||
private CaptionFooterPreferenceController mController;
|
|
||||||
|
|
||||||
@Before
|
|
||||||
public void setUp() {
|
|
||||||
final PreferenceManager preferenceManager = new PreferenceManager(mContext);
|
|
||||||
mScreen = preferenceManager.createPreferenceScreen(mContext);
|
|
||||||
final AccessibilityFooterPreference footerPreference =
|
|
||||||
new AccessibilityFooterPreference(mContext);
|
|
||||||
footerPreference.setKey(TEST_KEY);
|
|
||||||
footerPreference.setTitle(TEST_TITLE);
|
|
||||||
mScreen.addPreference(footerPreference);
|
|
||||||
mController = new CaptionFooterPreferenceController(mContext, TEST_KEY);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void onPreferenceChange_shouldSetCorrectIconContentDescription() {
|
|
||||||
mController.displayPreference(mScreen);
|
|
||||||
|
|
||||||
final AccessibilityFooterPreference footerPreference = mScreen.findPreference(TEST_KEY);
|
|
||||||
final String packageName = mContext.getString(R.string.accessibility_captioning_title);
|
|
||||||
final String iconContentDescription = mContext.getString(
|
|
||||||
R.string.accessibility_introduction_title,
|
|
||||||
packageName);
|
|
||||||
assertThat(footerPreference.getIconContentDescription()).isEqualTo(iconContentDescription);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,68 +0,0 @@
|
|||||||
/*
|
|
||||||
* 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.accessibility;
|
|
||||||
|
|
||||||
import static com.google.common.truth.Truth.assertThat;
|
|
||||||
|
|
||||||
import android.content.Context;
|
|
||||||
|
|
||||||
import androidx.preference.PreferenceManager;
|
|
||||||
import androidx.preference.PreferenceScreen;
|
|
||||||
import androidx.test.core.app.ApplicationProvider;
|
|
||||||
|
|
||||||
import com.android.settings.R;
|
|
||||||
|
|
||||||
import org.junit.Before;
|
|
||||||
import org.junit.Test;
|
|
||||||
import org.junit.runner.RunWith;
|
|
||||||
import org.robolectric.RobolectricTestRunner;
|
|
||||||
|
|
||||||
/** Tests for {@link ToggleAutoclickFooterPreferenceController}. */
|
|
||||||
@RunWith(RobolectricTestRunner.class)
|
|
||||||
public class ToggleAutoclickFooterPreferenceControllerTest {
|
|
||||||
|
|
||||||
private static final String TEST_KEY = "test_key";
|
|
||||||
private static final String TEST_TITLE = "test_title";
|
|
||||||
private final Context mContext = ApplicationProvider.getApplicationContext();
|
|
||||||
private PreferenceScreen mScreen;
|
|
||||||
private ToggleAutoclickFooterPreferenceController mController;
|
|
||||||
|
|
||||||
@Before
|
|
||||||
public void setUp() {
|
|
||||||
final PreferenceManager preferenceManager = new PreferenceManager(mContext);
|
|
||||||
mScreen = preferenceManager.createPreferenceScreen(mContext);
|
|
||||||
final AccessibilityFooterPreference footerPreference =
|
|
||||||
new AccessibilityFooterPreference(mContext);
|
|
||||||
footerPreference.setKey(TEST_KEY);
|
|
||||||
footerPreference.setTitle(TEST_TITLE);
|
|
||||||
mScreen.addPreference(footerPreference);
|
|
||||||
mController = new ToggleAutoclickFooterPreferenceController(mContext, TEST_KEY);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void onPreferenceChange_shouldSetCorrectIconContentDescription() {
|
|
||||||
mController.displayPreference(mScreen);
|
|
||||||
|
|
||||||
final AccessibilityFooterPreference footerPreference = mScreen.findPreference(TEST_KEY);
|
|
||||||
final String packageName = mContext.getString(
|
|
||||||
R.string.accessibility_autoclick_preference_title);
|
|
||||||
final String iconContentDescription = mContext.getString(
|
|
||||||
R.string.accessibility_introduction_title,
|
|
||||||
packageName);
|
|
||||||
assertThat(footerPreference.getIconContentDescription()).isEqualTo(iconContentDescription);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -215,8 +215,6 @@ public class ToggleFeaturePreferenceFragmentTest {
|
|||||||
(AccessibilityFooterPreference) mFragment.getPreferenceScreen().getPreference(
|
(AccessibilityFooterPreference) mFragment.getPreferenceScreen().getPreference(
|
||||||
mFragment.getPreferenceScreen().getPreferenceCount() - 1);
|
mFragment.getPreferenceScreen().getPreferenceCount() - 1);
|
||||||
assertThat(accessibilityFooterPreference.getSummary()).isEqualTo(DEFAULT_SUMMARY);
|
assertThat(accessibilityFooterPreference.getSummary()).isEqualTo(DEFAULT_SUMMARY);
|
||||||
assertThat(accessibilityFooterPreference.getIconContentDescription()).isEqualTo(
|
|
||||||
DEFAULT_DESCRIPTION);
|
|
||||||
assertThat(accessibilityFooterPreference.isSelectable()).isEqualTo(true);
|
assertThat(accessibilityFooterPreference.isSelectable()).isEqualTo(true);
|
||||||
assertThat(accessibilityFooterPreference.getOrder()).isEqualTo(Integer.MAX_VALUE - 1);
|
assertThat(accessibilityFooterPreference.getOrder()).isEqualTo(Integer.MAX_VALUE - 1);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,54 @@
|
|||||||
|
/*
|
||||||
|
* 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.applications.appinfo;
|
||||||
|
|
||||||
|
import static com.google.common.truth.Truth.assertThat;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
|
||||||
|
import org.junit.Before;
|
||||||
|
import org.junit.Test;
|
||||||
|
import org.junit.runner.RunWith;
|
||||||
|
import org.robolectric.RobolectricTestRunner;
|
||||||
|
import org.robolectric.RuntimeEnvironment;
|
||||||
|
|
||||||
|
@RunWith(RobolectricTestRunner.class)
|
||||||
|
public class ExtraAppInfoFeatureProviderImplTest {
|
||||||
|
private Context mContext;
|
||||||
|
private ExtraAppInfoFeatureProviderImpl mController;
|
||||||
|
|
||||||
|
@Before
|
||||||
|
public void setUp() {
|
||||||
|
mContext = RuntimeEnvironment.application;
|
||||||
|
mController = new ExtraAppInfoFeatureProviderImpl();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void isSupported_notSupportedByDefault() {
|
||||||
|
assertThat(mController.isSupported(mContext)).isEqualTo(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void isEnabled_notEnabledByDefault() {
|
||||||
|
assertThat(mController.isEnabled(mContext)).isEqualTo(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void getSummary_emptyByDefault() {
|
||||||
|
assertThat(mController.getSummary(mContext)).isEqualTo("");
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -73,7 +73,7 @@ public class ApplicationViewHolderTest {
|
|||||||
public void setTitle_titleIsNotEmptyAndContentIsNotEmpty_shouldSetTitleAndContentDescription() {
|
public void setTitle_titleIsNotEmptyAndContentIsNotEmpty_shouldSetTitleAndContentDescription() {
|
||||||
mHolder.setTitle("title", "content");
|
mHolder.setTitle("title", "content");
|
||||||
|
|
||||||
assertThat(mHolder.mAppName).isEqualTo("title");
|
assertThat(mHolder.mAppName.getText()).isEqualTo("title");
|
||||||
assertThat(mHolder.mAppName.getContentDescription()).isEqualTo("content");
|
assertThat(mHolder.mAppName.getContentDescription()).isEqualTo("content");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -81,8 +81,8 @@ public class ApplicationViewHolderTest {
|
|||||||
public void setTitle_titleIsNotEmptyButContentIsEmpty_shouldSetTitle() {
|
public void setTitle_titleIsNotEmptyButContentIsEmpty_shouldSetTitle() {
|
||||||
mHolder.setTitle("title", "");
|
mHolder.setTitle("title", "");
|
||||||
|
|
||||||
assertThat(mHolder.mAppName).isEqualTo("title");
|
assertThat(mHolder.mAppName.getText()).isEqualTo("title");
|
||||||
assertThat(mHolder.mAppName.getContentDescription()).isEqualTo("title");
|
assertThat(mHolder.mAppName.getContentDescription()).isNull();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|||||||
@@ -23,11 +23,11 @@ import static org.robolectric.Shadows.shadowOf;
|
|||||||
|
|
||||||
import android.app.AppOpsManager;
|
import android.app.AppOpsManager;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
import android.content.PermissionChecker;
|
||||||
import android.content.pm.ApplicationInfo;
|
import android.content.pm.ApplicationInfo;
|
||||||
import android.content.pm.CrossProfileApps;
|
import android.content.pm.CrossProfileApps;
|
||||||
import android.content.pm.PackageInfo;
|
import android.content.pm.PackageInfo;
|
||||||
import android.content.pm.PackageManager;
|
import android.content.pm.PackageManager;
|
||||||
import android.content.pm.PermissionInfo;
|
|
||||||
import android.content.pm.UserInfo;
|
import android.content.pm.UserInfo;
|
||||||
import android.os.UserHandle;
|
import android.os.UserHandle;
|
||||||
import android.os.UserManager;
|
import android.os.UserManager;
|
||||||
@@ -40,6 +40,7 @@ import com.google.common.collect.ImmutableList;
|
|||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
import org.robolectric.RobolectricTestRunner;
|
import org.robolectric.RobolectricTestRunner;
|
||||||
|
import org.robolectric.shadows.ShadowPermissionChecker;
|
||||||
import org.robolectric.shadows.ShadowProcess;
|
import org.robolectric.shadows.ShadowProcess;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -153,11 +154,14 @@ public class InteractAcrossProfilesSettingsTest {
|
|||||||
installCrossProfilePackage(WORK_PROFILE_ID, WORK_CROSS_PROFILE_PACKAGE);
|
installCrossProfilePackage(WORK_PROFILE_ID, WORK_CROSS_PROFILE_PACKAGE);
|
||||||
shadowOf(mCrossProfileApps).addCrossProfilePackage(PERSONAL_CROSS_PROFILE_PACKAGE);
|
shadowOf(mCrossProfileApps).addCrossProfilePackage(PERSONAL_CROSS_PROFILE_PACKAGE);
|
||||||
String appOp = AppOpsManager.permissionToOp(INTERACT_ACROSS_PROFILES_PERMISSION);
|
String appOp = AppOpsManager.permissionToOp(INTERACT_ACROSS_PROFILES_PERMISSION);
|
||||||
shadowOf(mAppOpsManager).setMode(
|
ShadowPermissionChecker.setResult(
|
||||||
appOp, PACKAGE_UID, PERSONAL_CROSS_PROFILE_PACKAGE, AppOpsManager.MODE_ALLOWED);
|
PERSONAL_CROSS_PROFILE_PACKAGE,
|
||||||
shadowOf(mAppOpsManager).setMode(
|
INTERACT_ACROSS_PROFILES_PERMISSION,
|
||||||
appOp, PACKAGE_UID, PERSONAL_NON_CROSS_PROFILE_PACKAGE, AppOpsManager.MODE_IGNORED);
|
PermissionChecker.PERMISSION_GRANTED);
|
||||||
shadowOf(mPackageManager).addPermissionInfo(createCrossProfilesPermissionInfo());
|
ShadowPermissionChecker.setResult(
|
||||||
|
PERSONAL_NON_CROSS_PROFILE_PACKAGE,
|
||||||
|
INTERACT_ACROSS_PROFILES_PERMISSION,
|
||||||
|
PermissionChecker.PERMISSION_SOFT_DENIED);
|
||||||
|
|
||||||
int numOfApps = InteractAcrossProfilesSettings.getNumberOfEnabledApps(
|
int numOfApps = InteractAcrossProfilesSettings.getNumberOfEnabledApps(
|
||||||
mContext, mPackageManager, mUserManager, mCrossProfileApps);
|
mContext, mPackageManager, mUserManager, mCrossProfileApps);
|
||||||
@@ -171,11 +175,4 @@ public class InteractAcrossProfilesSettingsTest {
|
|||||||
personalPackageInfo.requestedPermissions = new String[]{
|
personalPackageInfo.requestedPermissions = new String[]{
|
||||||
INTERACT_ACROSS_PROFILES_PERMISSION};
|
INTERACT_ACROSS_PROFILES_PERMISSION};
|
||||||
}
|
}
|
||||||
|
|
||||||
private PermissionInfo createCrossProfilesPermissionInfo() {
|
|
||||||
PermissionInfo permissionInfo = new PermissionInfo();
|
|
||||||
permissionInfo.name = INTERACT_ACROSS_PROFILES_PERMISSION;
|
|
||||||
permissionInfo.protectionLevel = PermissionInfo.PROTECTION_FLAG_APPOP;
|
|
||||||
return permissionInfo;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -121,9 +121,6 @@ public class AdvancedBluetoothDetailsHeaderControllerTest {
|
|||||||
when(mBluetoothDevice.getMetadata(
|
when(mBluetoothDevice.getMetadata(
|
||||||
BluetoothDevice.METADATA_IS_UNTETHERED_HEADSET)).thenReturn(
|
BluetoothDevice.METADATA_IS_UNTETHERED_HEADSET)).thenReturn(
|
||||||
String.valueOf(false).getBytes());
|
String.valueOf(false).getBytes());
|
||||||
when(mBluetoothDevice.getMetadata(
|
|
||||||
BluetoothDevice.METADATA_MAIN_BATTERY)).thenReturn(
|
|
||||||
String.valueOf(BATTERY_LEVEL_MAIN).getBytes());
|
|
||||||
when(mCachedDevice.isConnected()).thenReturn(true);
|
when(mCachedDevice.isConnected()).thenReturn(true);
|
||||||
|
|
||||||
mController.refresh();
|
mController.refresh();
|
||||||
@@ -134,6 +131,7 @@ public class AdvancedBluetoothDetailsHeaderControllerTest {
|
|||||||
View.GONE);
|
View.GONE);
|
||||||
assertThat(mLayoutPreference.findViewById(R.id.layout_middle).getVisibility()).isEqualTo(
|
assertThat(mLayoutPreference.findViewById(R.id.layout_middle).getVisibility()).isEqualTo(
|
||||||
View.VISIBLE);
|
View.VISIBLE);
|
||||||
|
// TODO (b/188954766) : clarify settings design
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|||||||
@@ -50,7 +50,6 @@ import org.robolectric.RobolectricTestRunner;
|
|||||||
import org.robolectric.RuntimeEnvironment;
|
import org.robolectric.RuntimeEnvironment;
|
||||||
|
|
||||||
@RunWith(RobolectricTestRunner.class)
|
@RunWith(RobolectricTestRunner.class)
|
||||||
@Config(shadows = ShadowUtils.class)
|
|
||||||
public class SubSettingLauncherTest {
|
public class SubSettingLauncherTest {
|
||||||
|
|
||||||
@Mock
|
@Mock
|
||||||
@@ -117,7 +116,6 @@ public class SubSettingLauncherTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void launch_hasRequestListener_shouldStartActivityForResult() {
|
public void launch_hasRequestListener_shouldStartActivityForResult() {
|
||||||
ShadowUtils.setIsPageTransitionEnabled(true);
|
|
||||||
final int requestCode = 123123;
|
final int requestCode = 123123;
|
||||||
when(mFragment.getActivity()).thenReturn(mActivity);
|
when(mFragment.getActivity()).thenReturn(mActivity);
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,123 @@
|
|||||||
|
/*
|
||||||
|
* 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.display;
|
||||||
|
|
||||||
|
import static com.android.settings.display.SmartAutoRotatePreferenceFragment.AUTO_ROTATE_SWITCH_PREFERENCE_ID;
|
||||||
|
|
||||||
|
import static org.mockito.ArgumentMatchers.any;
|
||||||
|
import static org.mockito.ArgumentMatchers.anyInt;
|
||||||
|
import static org.mockito.Mockito.doReturn;
|
||||||
|
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.Manifest;
|
||||||
|
import android.content.ContentResolver;
|
||||||
|
import android.content.Context;
|
||||||
|
import android.content.pm.PackageManager;
|
||||||
|
import android.content.pm.ResolveInfo;
|
||||||
|
import android.content.pm.ServiceInfo;
|
||||||
|
import android.view.View;
|
||||||
|
|
||||||
|
import androidx.preference.Preference;
|
||||||
|
|
||||||
|
import com.android.settings.R;
|
||||||
|
import com.android.settings.SettingsActivity;
|
||||||
|
import com.android.settings.testutils.ResolveInfoBuilder;
|
||||||
|
import com.android.settings.widget.SettingsMainSwitchBar;
|
||||||
|
|
||||||
|
import org.junit.Before;
|
||||||
|
import org.junit.Test;
|
||||||
|
import org.junit.runner.RunWith;
|
||||||
|
import org.mockito.Mock;
|
||||||
|
import org.mockito.MockitoAnnotations;
|
||||||
|
import org.robolectric.RobolectricTestRunner;
|
||||||
|
import org.robolectric.RuntimeEnvironment;
|
||||||
|
|
||||||
|
@RunWith(RobolectricTestRunner.class)
|
||||||
|
public class SmartAutoRotatePreferenceFragmentTest {
|
||||||
|
|
||||||
|
private static final String PACKAGE_NAME = "package_name";
|
||||||
|
|
||||||
|
private SmartAutoRotatePreferenceFragment mFragment;
|
||||||
|
|
||||||
|
private SettingsMainSwitchBar mSwitchBar;
|
||||||
|
|
||||||
|
@Mock
|
||||||
|
private PackageManager mPackageManager;
|
||||||
|
|
||||||
|
@Mock
|
||||||
|
private View mView;
|
||||||
|
|
||||||
|
@Mock
|
||||||
|
private SettingsActivity mActivity;
|
||||||
|
|
||||||
|
@Mock
|
||||||
|
private Preference mRotateSwitchPreference;
|
||||||
|
|
||||||
|
@Before
|
||||||
|
public void setUp() {
|
||||||
|
MockitoAnnotations.initMocks(this);
|
||||||
|
|
||||||
|
final Context context = spy(RuntimeEnvironment.application);
|
||||||
|
ContentResolver mContentResolver = RuntimeEnvironment.application.getContentResolver();
|
||||||
|
when(context.getPackageManager()).thenReturn(mPackageManager);
|
||||||
|
when(context.getContentResolver()).thenReturn(mContentResolver);
|
||||||
|
doReturn(PACKAGE_NAME).when(mPackageManager).getRotationResolverPackageName();
|
||||||
|
doReturn(PackageManager.PERMISSION_GRANTED).when(mPackageManager).checkPermission(
|
||||||
|
Manifest.permission.CAMERA, PACKAGE_NAME);
|
||||||
|
|
||||||
|
final ResolveInfo resolveInfo = new ResolveInfoBuilder(PACKAGE_NAME).build();
|
||||||
|
resolveInfo.serviceInfo = new ServiceInfo();
|
||||||
|
when(mPackageManager.resolveService(any(), anyInt())).thenReturn(resolveInfo);
|
||||||
|
|
||||||
|
mFragment = spy(new SmartAutoRotatePreferenceFragment());
|
||||||
|
when(mActivity.getPackageManager()).thenReturn(mPackageManager);
|
||||||
|
when(mFragment.getActivity()).thenReturn(mActivity);
|
||||||
|
when(mFragment.getContext()).thenReturn(context);
|
||||||
|
doReturn(mView).when(mFragment).getView();
|
||||||
|
|
||||||
|
when(mFragment.findPreference(AUTO_ROTATE_SWITCH_PREFERENCE_ID)).thenReturn(
|
||||||
|
mRotateSwitchPreference);
|
||||||
|
|
||||||
|
mSwitchBar = spy(new SettingsMainSwitchBar(context));
|
||||||
|
when(mActivity.getSwitchBar()).thenReturn(mSwitchBar);
|
||||||
|
doReturn(mSwitchBar).when(mView).findViewById(R.id.switch_bar);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void createHeader_faceDetectionSupported_switchBarIsEnabled() {
|
||||||
|
mFragment.createHeader(mActivity);
|
||||||
|
|
||||||
|
verify(mSwitchBar, times(1)).show();
|
||||||
|
verify(mRotateSwitchPreference, times(1)).setVisible(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void createHeader_faceDetectionUnSupported_switchBarIsDisabled() {
|
||||||
|
doReturn(null).when(mPackageManager).getRotationResolverPackageName();
|
||||||
|
|
||||||
|
mFragment.createHeader(mActivity);
|
||||||
|
|
||||||
|
verify(mSwitchBar, never()).show();
|
||||||
|
verify(mRotateSwitchPreference, never()).setVisible(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -200,24 +200,21 @@ public class ActionDisabledByAdminDialogHelperTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testMaybeSetLearnMoreButton() {
|
public void testMaybeSetLearnMoreButton() {
|
||||||
final UserManager userManager = RuntimeEnvironment.application.getSystemService(
|
UserManager userManager = RuntimeEnvironment.application
|
||||||
UserManager.class);
|
.getSystemService(UserManager.class);
|
||||||
final ShadowUserManager userManagerShadow = Shadow.extract(userManager);
|
ShadowUserManager userManagerShadow = Shadow.extract(userManager);
|
||||||
mHelper.prepareDialogBuilder(
|
|
||||||
/* restriction= */ null, ENFORCED_ADMIN);
|
|
||||||
|
|
||||||
// Set up for shadow call.
|
// Set up for shadow call.
|
||||||
userManagerShadow.getSameProfileGroupIds().put(USER_ID, 0);
|
userManagerShadow.getSameProfileGroupIds().put(USER_ID, 0);
|
||||||
|
|
||||||
// Test that the button is shown when user IDs are in the same profile group
|
// Test that the button is shown when user IDs are in the same profile group
|
||||||
AlertDialog.Builder builder = mock(AlertDialog.Builder.class);
|
AlertDialog.Builder builder = mock(AlertDialog.Builder.class);
|
||||||
mHelper.maybeSetLearnMoreButton(builder);
|
mHelper.prepareDialogBuilder(builder, /* restriction= */ null, ENFORCED_ADMIN);
|
||||||
verify(builder).setNeutralButton(anyInt(), any());
|
verify(builder).setNeutralButton(anyInt(), any());
|
||||||
|
|
||||||
// Test that the button is not shown when user IDs are not in the same profile group
|
// Test that the button is not shown when user IDs are not in the same profile group
|
||||||
userManagerShadow.getSameProfileGroupIds().clear();
|
userManagerShadow.getSameProfileGroupIds().clear();
|
||||||
builder = mock(AlertDialog.Builder.class);
|
builder = mock(AlertDialog.Builder.class);
|
||||||
mHelper.maybeSetLearnMoreButton(builder);
|
mHelper.prepareDialogBuilder(builder, /* restriction= */ null, ENFORCED_ADMIN);
|
||||||
verify(builder, never()).setNeutralButton(anyInt(), any());
|
verify(builder, never()).setNeutralButton(anyInt(), any());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -49,6 +49,7 @@ import com.android.settings.testutils.FakeFeatureFactory;
|
|||||||
import com.android.settingslib.core.instrumentation.MetricsFeatureProvider;
|
import com.android.settingslib.core.instrumentation.MetricsFeatureProvider;
|
||||||
|
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
|
import org.junit.Ignore;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
import org.mockito.ArgumentCaptor;
|
import org.mockito.ArgumentCaptor;
|
||||||
@@ -118,6 +119,7 @@ public final class BatteryChartPreferenceControllerTest {
|
|||||||
createBatteryHistoryMap());
|
createBatteryHistoryMap());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Ignore
|
||||||
@Test
|
@Test
|
||||||
public void testOnResume_uiModeIsChanged_clearBatteryDiffEntryCache() {
|
public void testOnResume_uiModeIsChanged_clearBatteryDiffEntryCache() {
|
||||||
doReturn(mResources).when(mContext).getResources();
|
doReturn(mResources).when(mContext).getResources();
|
||||||
@@ -133,6 +135,7 @@ public final class BatteryChartPreferenceControllerTest {
|
|||||||
assertThat(BatteryDiffEntry.sResourceCache).isEmpty();
|
assertThat(BatteryDiffEntry.sResourceCache).isEmpty();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Ignore
|
||||||
@Test
|
@Test
|
||||||
public void testOnResume_uiModeIsNotChanged_notClearBatteryDiffEntryCache() {
|
public void testOnResume_uiModeIsNotChanged_notClearBatteryDiffEntryCache() {
|
||||||
doReturn(mResources).when(mContext).getResources();
|
doReturn(mResources).when(mContext).getResources();
|
||||||
|
|||||||
@@ -29,6 +29,7 @@ import android.os.UserHandle;
|
|||||||
import com.android.settings.testutils.FakeFeatureFactory;
|
import com.android.settings.testutils.FakeFeatureFactory;
|
||||||
|
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
|
import org.junit.Ignore;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
import org.mockito.Mock;
|
import org.mockito.Mock;
|
||||||
@@ -60,8 +61,6 @@ public final class ConvertUtilsTest {
|
|||||||
mContext = spy(RuntimeEnvironment.application);
|
mContext = spy(RuntimeEnvironment.application);
|
||||||
mFeatureFactory = FakeFeatureFactory.setupForTest();
|
mFeatureFactory = FakeFeatureFactory.setupForTest();
|
||||||
mPowerUsageFeatureProvider = mFeatureFactory.powerUsageFeatureProvider;
|
mPowerUsageFeatureProvider = mFeatureFactory.powerUsageFeatureProvider;
|
||||||
Locale.setDefault(new Locale("en_US"));
|
|
||||||
org.robolectric.shadows.ShadowSettings.set24HourTimeFormat(false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -317,6 +316,7 @@ public final class ConvertUtilsTest {
|
|||||||
.isEqualTo(entry.mConsumePower * ratio);
|
.isEqualTo(entry.mConsumePower * ratio);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Ignore
|
||||||
@Test
|
@Test
|
||||||
public void testUtcToLocalTime_returnExpectedResult() {
|
public void testUtcToLocalTime_returnExpectedResult() {
|
||||||
ConvertUtils.sZoneId = null;
|
ConvertUtils.sZoneId = null;
|
||||||
@@ -335,6 +335,7 @@ public final class ConvertUtilsTest {
|
|||||||
assertThat(ConvertUtils.sLocale).isEqualTo(Locale.getDefault());
|
assertThat(ConvertUtils.sLocale).isEqualTo(Locale.getDefault());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Ignore
|
||||||
@Test
|
@Test
|
||||||
public void testUtcToLocalTimeHour_12HourFormat_returnExpectedResult() {
|
public void testUtcToLocalTimeHour_12HourFormat_returnExpectedResult() {
|
||||||
ConvertUtils.sZoneIdForHour = null;
|
ConvertUtils.sZoneIdForHour = null;
|
||||||
@@ -353,6 +354,7 @@ public final class ConvertUtilsTest {
|
|||||||
assertThat(ConvertUtils.sLocaleForHour).isEqualTo(Locale.getDefault());
|
assertThat(ConvertUtils.sLocaleForHour).isEqualTo(Locale.getDefault());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Ignore
|
||||||
@Test
|
@Test
|
||||||
public void testUtcToLocalTimeHour_24HourFormat_returnExpectedResult() {
|
public void testUtcToLocalTimeHour_24HourFormat_returnExpectedResult() {
|
||||||
ConvertUtils.sZoneIdForHour = null;
|
ConvertUtils.sZoneIdForHour = null;
|
||||||
|
|||||||
@@ -45,7 +45,6 @@ import android.content.Context;
|
|||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.provider.Settings.Global;
|
import android.provider.Settings.Global;
|
||||||
import android.util.FeatureFlagUtils;
|
|
||||||
|
|
||||||
import androidx.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
import androidx.preference.Preference;
|
import androidx.preference.Preference;
|
||||||
@@ -54,7 +53,6 @@ import com.android.internal.widget.LockPatternUtils;
|
|||||||
import com.android.internal.widget.LockscreenCredential;
|
import com.android.internal.widget.LockscreenCredential;
|
||||||
import com.android.settings.R;
|
import com.android.settings.R;
|
||||||
import com.android.settings.biometrics.BiometricEnrollBase;
|
import com.android.settings.biometrics.BiometricEnrollBase;
|
||||||
import com.android.settings.core.FeatureFlags;
|
|
||||||
import com.android.settings.password.ChooseLockGeneric.ChooseLockGenericFragment;
|
import com.android.settings.password.ChooseLockGeneric.ChooseLockGenericFragment;
|
||||||
import com.android.settings.search.SearchFeatureProvider;
|
import com.android.settings.search.SearchFeatureProvider;
|
||||||
import com.android.settings.testutils.shadow.ShadowInteractionJankMonitor;
|
import com.android.settings.testutils.shadow.ShadowInteractionJankMonitor;
|
||||||
@@ -66,11 +64,11 @@ import com.android.settingslib.widget.FooterPreference;
|
|||||||
|
|
||||||
import org.junit.After;
|
import org.junit.After;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
|
import org.junit.Ignore;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
import org.robolectric.Robolectric;
|
import org.robolectric.Robolectric;
|
||||||
import org.robolectric.RobolectricTestRunner;
|
import org.robolectric.RobolectricTestRunner;
|
||||||
import org.robolectric.RuntimeEnvironment;
|
|
||||||
import org.robolectric.annotation.Config;
|
import org.robolectric.annotation.Config;
|
||||||
import org.robolectric.shadows.ShadowApplication;
|
import org.robolectric.shadows.ShadowApplication;
|
||||||
import org.robolectric.shadows.ShadowPersistentDataBlockManager;
|
import org.robolectric.shadows.ShadowPersistentDataBlockManager;
|
||||||
@@ -85,6 +83,7 @@ import org.robolectric.shadows.ShadowPersistentDataBlockManager;
|
|||||||
ShadowUtils.class,
|
ShadowUtils.class,
|
||||||
ShadowInteractionJankMonitor.class
|
ShadowInteractionJankMonitor.class
|
||||||
})
|
})
|
||||||
|
@Ignore("b/179136903: Tests failed with collapsing toolbar, plan to figure out root cause later.")
|
||||||
public class ChooseLockGenericTest {
|
public class ChooseLockGenericTest {
|
||||||
|
|
||||||
private ChooseLockGenericFragment mFragment;
|
private ChooseLockGenericFragment mFragment;
|
||||||
@@ -94,7 +93,6 @@ public class ChooseLockGenericTest {
|
|||||||
public void setUp() {
|
public void setUp() {
|
||||||
Global.putInt(application.getContentResolver(), Global.DEVICE_PROVISIONED, 1);
|
Global.putInt(application.getContentResolver(), Global.DEVICE_PROVISIONED, 1);
|
||||||
mFragment = new ChooseLockGenericFragment();
|
mFragment = new ChooseLockGenericFragment();
|
||||||
FeatureFlagUtils.setEnabled(RuntimeEnvironment.application, FeatureFlags.SILKY_HOME, false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@After
|
@After
|
||||||
|
|||||||
@@ -0,0 +1,63 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2021 The Android Open Source Project
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.android.settings.widget;
|
||||||
|
|
||||||
|
import static com.android.settingslib.RestrictedLockUtils.EnforcedAdmin;
|
||||||
|
|
||||||
|
import static com.google.common.truth.Truth.assertThat;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import android.view.View;
|
||||||
|
import android.widget.ImageView;
|
||||||
|
|
||||||
|
import org.junit.Before;
|
||||||
|
import org.junit.Test;
|
||||||
|
import org.junit.runner.RunWith;
|
||||||
|
import org.mockito.Mock;
|
||||||
|
import org.mockito.MockitoAnnotations;
|
||||||
|
import org.robolectric.RobolectricTestRunner;
|
||||||
|
import org.robolectric.RuntimeEnvironment;
|
||||||
|
import org.robolectric.util.ReflectionHelpers;
|
||||||
|
|
||||||
|
@RunWith(RobolectricTestRunner.class)
|
||||||
|
public class SettingsMainSwitchPreferenceTest {
|
||||||
|
|
||||||
|
@Mock
|
||||||
|
private EnforcedAdmin mEnforcedAdmin;
|
||||||
|
private SettingsMainSwitchPreference mPreference;
|
||||||
|
|
||||||
|
@Before
|
||||||
|
public void setUp() {
|
||||||
|
MockitoAnnotations.initMocks(this);
|
||||||
|
final Context context = RuntimeEnvironment.application;
|
||||||
|
final SettingsMainSwitchBar switchBar = new SettingsMainSwitchBar(context);
|
||||||
|
mPreference = new SettingsMainSwitchPreference(context);
|
||||||
|
ReflectionHelpers.setField(mPreference, "mEnforcedAdmin", mEnforcedAdmin);
|
||||||
|
ReflectionHelpers.setField(mPreference, "mMainSwitchBar", switchBar);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void updateStatus_isRestricted_restrictIconShouldDisplay() {
|
||||||
|
mPreference.updateStatus(true);
|
||||||
|
|
||||||
|
final SettingsMainSwitchBar switchBar = mPreference.getSwitchBar();
|
||||||
|
final ImageView restrictedIcon = switchBar.findViewById(
|
||||||
|
com.android.settingslib.widget.R.id.restricted_icon);
|
||||||
|
|
||||||
|
assertThat(restrictedIcon.getVisibility() == View.VISIBLE).isTrue();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,266 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (C) 2017 The Android Open Source Project
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package com.android.settings.wifi;
|
|
||||||
|
|
||||||
import static android.content.Context.NETWORK_SCORE_SERVICE;
|
|
||||||
import static android.provider.Settings.Global.USE_OPEN_WIFI_PACKAGE;
|
|
||||||
|
|
||||||
import static com.android.settings.wifi.UseOpenWifiPreferenceController
|
|
||||||
.REQUEST_CODE_OPEN_WIFI_AUTOMATICALLY;
|
|
||||||
|
|
||||||
import static com.google.common.truth.Truth.assertThat;
|
|
||||||
|
|
||||||
import static org.mockito.ArgumentMatchers.eq;
|
|
||||||
import static org.mockito.Mockito.mock;
|
|
||||||
import static org.mockito.Mockito.verify;
|
|
||||||
import static org.mockito.Mockito.when;
|
|
||||||
|
|
||||||
import android.annotation.NonNull;
|
|
||||||
import android.app.Activity;
|
|
||||||
import android.content.ComponentName;
|
|
||||||
import android.content.Context;
|
|
||||||
import android.content.Intent;
|
|
||||||
import android.net.NetworkScoreManager;
|
|
||||||
import android.net.NetworkScorerAppData;
|
|
||||||
import android.provider.Settings;
|
|
||||||
|
|
||||||
import androidx.fragment.app.Fragment;
|
|
||||||
import androidx.preference.SwitchPreference;
|
|
||||||
|
|
||||||
import com.android.settings.R;
|
|
||||||
|
|
||||||
import com.google.common.collect.Lists;
|
|
||||||
|
|
||||||
import org.junit.Before;
|
|
||||||
import org.junit.BeforeClass;
|
|
||||||
import org.junit.Test;
|
|
||||||
import org.junit.runner.RunWith;
|
|
||||||
import org.mockito.ArgumentCaptor;
|
|
||||||
import org.mockito.Captor;
|
|
||||||
import org.mockito.Mock;
|
|
||||||
import org.mockito.MockitoAnnotations;
|
|
||||||
import org.robolectric.RobolectricTestRunner;
|
|
||||||
import org.robolectric.RuntimeEnvironment;
|
|
||||||
import org.robolectric.shadows.ShadowApplication;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
@RunWith(RobolectricTestRunner.class)
|
|
||||||
public class UseOpenWifiPreferenceControllerTest {
|
|
||||||
|
|
||||||
private static ComponentName sEnableActivityComponent;
|
|
||||||
private static NetworkScorerAppData sAppData;
|
|
||||||
private static NetworkScorerAppData sAppDataNoActivity;
|
|
||||||
|
|
||||||
@BeforeClass
|
|
||||||
public static void beforeClass() {
|
|
||||||
sEnableActivityComponent = new ComponentName("package", "activityClass");
|
|
||||||
sAppData = new NetworkScorerAppData(0, null, null, sEnableActivityComponent, null);
|
|
||||||
sAppDataNoActivity = new NetworkScorerAppData(0, null, null, null, null);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Mock
|
|
||||||
private Fragment mFragment;
|
|
||||||
@Mock
|
|
||||||
private NetworkScoreManager mNetworkScoreManager;
|
|
||||||
@Captor
|
|
||||||
private ArgumentCaptor<Intent> mIntentCaptor;
|
|
||||||
private Context mContext;
|
|
||||||
private UseOpenWifiPreferenceController mController;
|
|
||||||
|
|
||||||
@Before
|
|
||||||
public void setUp() {
|
|
||||||
MockitoAnnotations.initMocks(this);
|
|
||||||
|
|
||||||
mContext = RuntimeEnvironment.application;
|
|
||||||
ShadowApplication.getInstance()
|
|
||||||
.setSystemService(NETWORK_SCORE_SERVICE, mNetworkScoreManager);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void createController() {
|
|
||||||
mController = new UseOpenWifiPreferenceController(mContext);
|
|
||||||
mController.setFragment(mFragment);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets the scorers.
|
|
||||||
*
|
|
||||||
* @param scorers list of scorers returned by {@link NetworkScoreManager#getAllValidScorers()}.
|
|
||||||
* First scorer in the list is the active scorer.
|
|
||||||
*/
|
|
||||||
private void setupScorers(@NonNull List<NetworkScorerAppData> scorers) {
|
|
||||||
when(mNetworkScoreManager.getActiveScorerPackage())
|
|
||||||
.thenReturn(sEnableActivityComponent.getPackageName());
|
|
||||||
when(mNetworkScoreManager.getAllValidScorers()).thenReturn(scorers);
|
|
||||||
when(mNetworkScoreManager.getActiveScorer()).thenReturn(scorers.get(0));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testIsAvailable_returnsFalseWhenNoScorerSet() {
|
|
||||||
createController();
|
|
||||||
|
|
||||||
assertThat(mController.isAvailable()).isFalse();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testIsAvailable_returnsFalseWhenScorersNotSupported() {
|
|
||||||
setupScorers(Lists.newArrayList(sAppDataNoActivity));
|
|
||||||
createController();
|
|
||||||
|
|
||||||
assertThat(mController.isAvailable()).isFalse();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testIsAvailable_returnsTrueIfActiveScorerSupported() {
|
|
||||||
setupScorers(Lists.newArrayList(sAppData, sAppDataNoActivity));
|
|
||||||
createController();
|
|
||||||
|
|
||||||
assertThat(mController.isAvailable()).isTrue();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testIsAvailable_returnsTrueIfNonActiveScorerSupported() {
|
|
||||||
setupScorers(Lists.newArrayList(sAppDataNoActivity, sAppData));
|
|
||||||
when(mNetworkScoreManager.getActiveScorer()).thenReturn(sAppDataNoActivity);
|
|
||||||
createController();
|
|
||||||
|
|
||||||
assertThat(mController.isAvailable()).isTrue();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void isAvailable_disableUseOpenWifiComponentBetweenCalls_returnsTrueThenReturnsFalse() {
|
|
||||||
setupScorers(Lists.newArrayList(sAppData));
|
|
||||||
createController();
|
|
||||||
|
|
||||||
assertThat(mController.isAvailable()).isTrue();
|
|
||||||
|
|
||||||
// Update NetworkScorerAppData so that it no longer has openWifiActivity.
|
|
||||||
setupScorers(Lists.newArrayList(sAppDataNoActivity));
|
|
||||||
|
|
||||||
assertThat(mController.isAvailable()).isFalse();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void setChecked_withTrue_enableShouldStartEnableActivity() {
|
|
||||||
setupScorers(Lists.newArrayList(sAppData, sAppDataNoActivity));
|
|
||||||
createController();
|
|
||||||
|
|
||||||
mController.setChecked(true);
|
|
||||||
|
|
||||||
verify(mFragment).startActivityForResult(mIntentCaptor.capture(),
|
|
||||||
eq(REQUEST_CODE_OPEN_WIFI_AUTOMATICALLY));
|
|
||||||
final Intent activityIntent = mIntentCaptor.getValue();
|
|
||||||
assertThat(activityIntent.getComponent()).isEqualTo(sEnableActivityComponent);
|
|
||||||
assertThat(activityIntent.getAction()).isEqualTo(NetworkScoreManager.ACTION_CUSTOM_ENABLE);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void setChecked_withFalse_disableShouldUpdateSetting() {
|
|
||||||
setupScorers(Lists.newArrayList(sAppData, sAppDataNoActivity));
|
|
||||||
Settings.Global.putString(mContext.getContentResolver(), USE_OPEN_WIFI_PACKAGE,
|
|
||||||
sEnableActivityComponent.getPackageName());
|
|
||||||
createController();
|
|
||||||
|
|
||||||
mController.setChecked(false);
|
|
||||||
|
|
||||||
assertThat(Settings.Global.getString(mContext.getContentResolver(), USE_OPEN_WIFI_PACKAGE))
|
|
||||||
.isEqualTo("");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void onActivityResult_nonmatchingRequestCode_shouldDoNothing() {
|
|
||||||
setupScorers(Lists.newArrayList(sAppData, sAppDataNoActivity));
|
|
||||||
createController();
|
|
||||||
|
|
||||||
assertThat(mController.onActivityResult(234 /* requestCode */, Activity.RESULT_OK))
|
|
||||||
.isEqualTo(false);
|
|
||||||
assertThat(Settings.Global.getString(mContext.getContentResolver(), USE_OPEN_WIFI_PACKAGE))
|
|
||||||
.isNull();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void onActivityResult_matchingRequestCode_nonOkResult_shouldDoNothing() {
|
|
||||||
setupScorers(Lists.newArrayList(sAppData, sAppDataNoActivity));
|
|
||||||
createController();
|
|
||||||
|
|
||||||
assertThat(mController
|
|
||||||
.onActivityResult(REQUEST_CODE_OPEN_WIFI_AUTOMATICALLY, Activity.RESULT_CANCELED))
|
|
||||||
.isEqualTo(true);
|
|
||||||
assertThat(Settings.Global.getString(mContext.getContentResolver(), USE_OPEN_WIFI_PACKAGE))
|
|
||||||
.isNull();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void onActivityResult_matchingRequestCode_okResult_updatesSetting() {
|
|
||||||
setupScorers(Lists.newArrayList(sAppData, sAppDataNoActivity));
|
|
||||||
createController();
|
|
||||||
|
|
||||||
assertThat(mController
|
|
||||||
.onActivityResult(REQUEST_CODE_OPEN_WIFI_AUTOMATICALLY, Activity.RESULT_OK))
|
|
||||||
.isEqualTo(true);
|
|
||||||
assertThat(Settings.Global.getString(mContext.getContentResolver(), USE_OPEN_WIFI_PACKAGE))
|
|
||||||
.isEqualTo(sEnableActivityComponent.getPackageName());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void updateState_noEnableActivity_preferenceDisabled_summaryChanged() {
|
|
||||||
setupScorers(Lists.newArrayList(sAppDataNoActivity));
|
|
||||||
createController();
|
|
||||||
|
|
||||||
final SwitchPreference preference = mock(SwitchPreference.class);
|
|
||||||
Settings.Global.putString(mContext.getContentResolver(), USE_OPEN_WIFI_PACKAGE,
|
|
||||||
sEnableActivityComponent.getPackageName());
|
|
||||||
|
|
||||||
mController.updateState(preference);
|
|
||||||
|
|
||||||
verify(preference).setChecked(false);
|
|
||||||
verify(preference).setSummary(
|
|
||||||
R.string.use_open_wifi_automatically_summary_scorer_unsupported_disabled);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void updateState_noScorer_preferenceDisabled_summaryChanged() {
|
|
||||||
when(mNetworkScoreManager.getAllValidScorers()).thenReturn(new ArrayList<>());
|
|
||||||
createController();
|
|
||||||
|
|
||||||
final SwitchPreference preference = mock(SwitchPreference.class);
|
|
||||||
Settings.Global.putString(mContext.getContentResolver(), USE_OPEN_WIFI_PACKAGE,
|
|
||||||
sEnableActivityComponent.getPackageName());
|
|
||||||
|
|
||||||
mController.updateState(preference);
|
|
||||||
|
|
||||||
verify(preference).setChecked(false);
|
|
||||||
verify(preference).setSummary(
|
|
||||||
R.string.use_open_wifi_automatically_summary_scoring_disabled);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void updateState_enableActivityExists_preferenceEnabled() {
|
|
||||||
setupScorers(Lists.newArrayList(sAppData, sAppDataNoActivity));
|
|
||||||
createController();
|
|
||||||
|
|
||||||
final SwitchPreference preference = mock(SwitchPreference.class);
|
|
||||||
Settings.Global.putString(mContext.getContentResolver(), USE_OPEN_WIFI_PACKAGE,
|
|
||||||
sEnableActivityComponent.getPackageName());
|
|
||||||
|
|
||||||
mController.updateState(preference);
|
|
||||||
|
|
||||||
verify(preference).setChecked(true);
|
|
||||||
verify(preference).setSummary(R.string.use_open_wifi_automatically_summary);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -322,6 +322,18 @@ public class WifiP2pSettingsTest {
|
|||||||
mFragment.onPause();
|
mFragment.onPause();
|
||||||
|
|
||||||
verify(mWifiP2pManager, times(1)).stopPeerDiscovery(any(), any());
|
verify(mWifiP2pManager, times(1)).stopPeerDiscovery(any(), any());
|
||||||
|
assertThat(mFragment.mChannel).isNull();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void peerDiscovery_whenOnResume_shouldInitChannelAgain() {
|
||||||
|
mFragment.onPause();
|
||||||
|
|
||||||
|
verify(mWifiP2pManager, times(1)).stopPeerDiscovery(any(), any());
|
||||||
|
assertThat(mFragment.mChannel).isNull();
|
||||||
|
|
||||||
|
mFragment.onResume();
|
||||||
|
assertThat(mFragment.mChannel).isNotNull();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -492,6 +504,7 @@ public class WifiP2pSettingsTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void onActivityCreate_withNullP2pManager_shouldGetP2pManagerAgain() {
|
public void onActivityCreate_withNullP2pManager_shouldGetP2pManagerAgain() {
|
||||||
|
mFragment.mChannel = null; // Reset channel to re-test onActivityCreated flow
|
||||||
mFragment.mWifiP2pManager = null;
|
mFragment.mWifiP2pManager = null;
|
||||||
|
|
||||||
mFragment.onActivityCreated(new Bundle());
|
mFragment.onActivityCreated(new Bundle());
|
||||||
@@ -502,7 +515,7 @@ public class WifiP2pSettingsTest {
|
|||||||
@Test
|
@Test
|
||||||
public void onActivityCreate_withNullChannel_shouldSetP2pManagerNull() {
|
public void onActivityCreate_withNullChannel_shouldSetP2pManagerNull() {
|
||||||
doReturn(null).when(mWifiP2pManager).initialize(any(), any(), any());
|
doReturn(null).when(mWifiP2pManager).initialize(any(), any(), any());
|
||||||
|
mFragment.mChannel = null; // Reset channel to re-test onActivityCreated flow
|
||||||
mFragment.onActivityCreated(new Bundle());
|
mFragment.onActivityCreated(new Bundle());
|
||||||
|
|
||||||
assertThat(mFragment.mWifiP2pManager).isNull();
|
assertThat(mFragment.mWifiP2pManager).isNull();
|
||||||
|
|||||||
@@ -24,86 +24,104 @@ import static com.google.common.truth.Truth.assertThat;
|
|||||||
|
|
||||||
import static org.mockito.ArgumentMatchers.eq;
|
import static org.mockito.ArgumentMatchers.eq;
|
||||||
import static org.mockito.Mockito.verify;
|
import static org.mockito.Mockito.verify;
|
||||||
|
import static org.mockito.Mockito.when;
|
||||||
|
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.content.ComponentName;
|
import android.content.ComponentName;
|
||||||
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.os.UserHandle;
|
import android.os.UserHandle;
|
||||||
|
import android.os.UserManager;
|
||||||
|
|
||||||
|
import androidx.appcompat.app.AlertDialog;
|
||||||
import androidx.test.runner.AndroidJUnit4;
|
import androidx.test.runner.AndroidJUnit4;
|
||||||
|
|
||||||
import com.android.settings.Settings;
|
import com.android.settings.Settings;
|
||||||
import com.android.settings.applications.specialaccess.deviceadmin.DeviceAdminAdd;
|
import com.android.settings.applications.specialaccess.deviceadmin.DeviceAdminAdd;
|
||||||
import com.android.settingslib.RestrictedLockUtils;
|
|
||||||
import com.android.settingslib.RestrictedLockUtils.EnforcedAdmin;
|
|
||||||
|
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
|
import org.junit.Rule;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
import org.mockito.ArgumentCaptor;
|
import org.mockito.ArgumentCaptor;
|
||||||
|
import org.mockito.Captor;
|
||||||
import org.mockito.Mock;
|
import org.mockito.Mock;
|
||||||
import org.mockito.MockitoAnnotations;
|
import org.mockito.junit.MockitoJUnit;
|
||||||
|
import org.mockito.junit.MockitoRule;
|
||||||
|
|
||||||
@RunWith(AndroidJUnit4.class)
|
@RunWith(AndroidJUnit4.class)
|
||||||
public class ActionDisabledLearnMoreButtonLauncherImplTest {
|
public class ActionDisabledLearnMoreButtonLauncherImplTest {
|
||||||
|
|
||||||
private static final int ENFORCED_ADMIN_USER_ID = 123;
|
private static final int ENFORCED_ADMIN_USER_ID = 123;
|
||||||
|
private static final UserHandle ENFORCED_ADMIN_USER = UserHandle.of(ENFORCED_ADMIN_USER_ID);
|
||||||
|
|
||||||
|
private static final int CONTEXT_USER_ID = -ENFORCED_ADMIN_USER_ID;
|
||||||
|
private static final UserHandle CONTEXT_USER = UserHandle.of(CONTEXT_USER_ID);
|
||||||
|
|
||||||
private static final ComponentName ADMIN_COMPONENT =
|
private static final ComponentName ADMIN_COMPONENT =
|
||||||
new ComponentName("some.package.name", "some.package.name.SomeClass");
|
new ComponentName("some.package.name", "some.package.name.SomeClass");
|
||||||
private static final String URL = "https://testexample.com";
|
private static final String URL = "https://testexample.com";
|
||||||
private static final Uri URI = Uri.parse(URL);
|
private static final Uri URI = Uri.parse(URL);
|
||||||
|
|
||||||
|
@Rule
|
||||||
|
public final MockitoRule mMockitoRule = MockitoJUnit.rule();
|
||||||
|
|
||||||
@Mock
|
@Mock
|
||||||
private Activity mActivity;
|
private Activity mActivity;
|
||||||
|
|
||||||
|
@Captor
|
||||||
|
private ArgumentCaptor<Intent> mIntentCaptor;
|
||||||
|
|
||||||
|
@Mock
|
||||||
|
private AlertDialog.Builder mBuilder;
|
||||||
|
|
||||||
|
private ActionDisabledLearnMoreButtonLauncherImpl mImpl;
|
||||||
|
|
||||||
|
@Mock
|
||||||
|
private UserManager mUserManager;
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void setUp() {
|
public void setUp() {
|
||||||
MockitoAnnotations.initMocks(this);
|
// Can't mock getSystemService(Class) directly because it's final
|
||||||
|
when(mActivity.getSystemServiceName(UserManager.class)).thenReturn(Context.USER_SERVICE);
|
||||||
|
when(mActivity.getSystemService(Context.USER_SERVICE)).thenReturn(mUserManager);
|
||||||
|
|
||||||
|
when(mActivity.getUserId()).thenReturn(CONTEXT_USER_ID);
|
||||||
|
when(mUserManager.getUserHandle()).thenReturn(CONTEXT_USER_ID);
|
||||||
|
|
||||||
|
mImpl = new ActionDisabledLearnMoreButtonLauncherImpl(mActivity, mBuilder);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void showAdminPolicies_noComponent_works() {
|
public void launchShowAdminSettings_works() {
|
||||||
final EnforcedAdmin enforcedAdmin = createEnforcedAdmin(/* component= */ null);
|
mImpl.launchShowAdminSettings(mActivity);
|
||||||
|
|
||||||
ActionDisabledLearnMoreButtonLauncherImpl.SHOW_ADMIN_POLICIES
|
verify(mActivity).startActivity(mIntentCaptor.capture());
|
||||||
.accept(mActivity, enforcedAdmin);
|
assertDeviceAdminSettingsActivity(mIntentCaptor.getValue());
|
||||||
|
}
|
||||||
|
|
||||||
final ArgumentCaptor<Intent> captor = ArgumentCaptor.forClass(Intent.class);
|
@Test
|
||||||
verify(mActivity).startActivity(captor.capture());
|
public void launchShowAdminPolicies_works() {
|
||||||
assertThat(captor.getValue().getComponent().getClassName())
|
mImpl.launchShowAdminPolicies(mActivity, ENFORCED_ADMIN_USER, ADMIN_COMPONENT);
|
||||||
|
|
||||||
|
verify(mActivity).startActivityAsUser(mIntentCaptor.capture(), eq(ENFORCED_ADMIN_USER));
|
||||||
|
assertDeviceAdminAddIntent(mIntentCaptor.getValue());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void showHelpPage_works() {
|
||||||
|
mImpl.showHelpPage(mActivity, URL);
|
||||||
|
|
||||||
|
verify(mActivity).startActivityAsUser(mIntentCaptor.capture(), eq(CONTEXT_USER));
|
||||||
|
assertActionViewIntent(mIntentCaptor.getValue());
|
||||||
|
}
|
||||||
|
|
||||||
|
private void assertDeviceAdminSettingsActivity(Intent intent) {
|
||||||
|
assertThat(intent.getComponent().getClassName())
|
||||||
.isEqualTo(Settings.DeviceAdminSettingsActivity.class.getName());
|
.isEqualTo(Settings.DeviceAdminSettingsActivity.class.getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
|
||||||
public void showAdminPolicies_withComponent_works() {
|
|
||||||
final EnforcedAdmin enforcedAdmin = createEnforcedAdmin(ADMIN_COMPONENT);
|
|
||||||
|
|
||||||
ActionDisabledLearnMoreButtonLauncherImpl.SHOW_ADMIN_POLICIES
|
|
||||||
.accept(mActivity, enforcedAdmin);
|
|
||||||
|
|
||||||
final ArgumentCaptor<Intent> captor = ArgumentCaptor.forClass(Intent.class);
|
|
||||||
verify(mActivity).startActivityAsUser(
|
|
||||||
captor.capture(),
|
|
||||||
eq(UserHandle.of(ENFORCED_ADMIN_USER_ID)));
|
|
||||||
assertDeviceAdminAddIntent(captor.getValue());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void launchHelpPage_works() {
|
|
||||||
ActionDisabledLearnMoreButtonLauncherImpl.LAUNCH_HELP_PAGE.accept(mActivity, URL);
|
|
||||||
|
|
||||||
final ArgumentCaptor<Intent> captor = ArgumentCaptor.forClass(Intent.class);
|
|
||||||
verify(mActivity).startActivityAsUser(captor.capture(), eq(UserHandle.SYSTEM));
|
|
||||||
assertActionViewIntent(captor.getValue());
|
|
||||||
}
|
|
||||||
|
|
||||||
private EnforcedAdmin createEnforcedAdmin(ComponentName component) {
|
|
||||||
return new RestrictedLockUtils.EnforcedAdmin(
|
|
||||||
component, UserHandle.of(ENFORCED_ADMIN_USER_ID));
|
|
||||||
}
|
|
||||||
|
|
||||||
private void assertDeviceAdminAddIntent(Intent intent) {
|
private void assertDeviceAdminAddIntent(Intent intent) {
|
||||||
assertThat(intent.getComponent().getClassName())
|
assertThat(intent.getComponent().getClassName())
|
||||||
.isEqualTo(DeviceAdminAdd.class.getName());
|
.isEqualTo(DeviceAdminAdd.class.getName());
|
||||||
|
|||||||
Reference in New Issue
Block a user