Merge "[Wi-Fi] Support passport R1 expiration handling"
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index c48d51b..0a72b75 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -213,7 +213,7 @@
<activity
android:name=".Settings$ConnectedDeviceDashboardActivity"
android:label="@string/connected_devices_dashboard_title"
- android:icon="@drawable/ic_homepage_connected_device"
+ android:icon="@drawable/ic_devices_other"
android:parentActivityName="Settings">
<intent-filter android:priority="1">
<action android:name="android.settings.BLUETOOTH_SETTINGS" />
@@ -1342,6 +1342,11 @@
</intent-filter>
</activity>
+ <activity android:name=".security.InstallCaCertificateWarning"
+ android:theme="@style/GlifV3Theme.Light"
+ android:exported="false">
+ </activity>
+
<activity
android:name="Settings$DeviceAdminSettingsActivity"
android:label="@string/device_admin_settings_title"
@@ -2642,10 +2647,6 @@
android:grantUriPermissions="true"
android:exported="false"/>
- <activity android:name=".sim.SimPreferenceDialog"
- android:theme="@style/Theme.AlertDialog"
- android:excludeFromRecents="true" />
-
<activity
android:name=".wifi.RequestToggleWiFiActivity"
android:theme="@android:style/Theme.DeviceDefault.Light.Dialog.Alert"
@@ -2981,6 +2982,8 @@
<intent-filter>
<action android:name="android.service.quicksettings.action.QS_TILE" />
</intent-filter>
+ <meta-data android:name="android.service.quicksettings.BOOLEAN_TILE"
+ android:value="true"/>
</service>
<service
android:name=".development.qstile.DevelopmentTiles$GPUProfiling"
@@ -2991,6 +2994,8 @@
<intent-filter>
<action android:name="android.service.quicksettings.action.QS_TILE" />
</intent-filter>
+ <meta-data android:name="android.service.quicksettings.BOOLEAN_TILE"
+ android:value="true"/>
</service>
<service
android:name=".development.qstile.DevelopmentTiles$ForceRTL"
@@ -3001,6 +3006,8 @@
<intent-filter>
<action android:name="android.service.quicksettings.action.QS_TILE" />
</intent-filter>
+ <meta-data android:name="android.service.quicksettings.BOOLEAN_TILE"
+ android:value="true"/>
</service>
<service
android:name=".development.qstile.DevelopmentTiles$AnimationSpeed"
@@ -3011,6 +3018,8 @@
<intent-filter>
<action android:name="android.service.quicksettings.action.QS_TILE" />
</intent-filter>
+ <meta-data android:name="android.service.quicksettings.BOOLEAN_TILE"
+ android:value="true"/>
</service>
<service
@@ -3022,6 +3031,8 @@
<intent-filter>
<action android:name="android.service.quicksettings.action.QS_TILE" />
</intent-filter>
+ <meta-data android:name="android.service.quicksettings.BOOLEAN_TILE"
+ android:value="true"/>
</service>
<service
@@ -3033,6 +3044,8 @@
<intent-filter>
<action android:name="android.service.quicksettings.action.QS_TILE" />
</intent-filter>
+ <meta-data android:name="android.service.quicksettings.BOOLEAN_TILE"
+ android:value="true"/>
</service>
<activity
@@ -3088,6 +3101,8 @@
</intent-filter>
<meta-data android:name="com.android.settings.FRAGMENT_CLASS"
android:value="com.android.settings.bluetooth.BluetoothDeviceDetailsFragment" />
+ <meta-data android:name="com.android.settings.PRIMARY_PROFILE_CONTROLLED"
+ android:value="true" />
</activity>
<activity android:name=".panel.SettingsPanelActivity"
diff --git a/res/drawable-hdpi/dotted_line_480px.png b/res/drawable-hdpi/dotted_line_480px.png
deleted file mode 100644
index 4c25bae..0000000
--- a/res/drawable-hdpi/dotted_line_480px.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-hdpi/ic_warning_googred_48dp.png b/res/drawable-hdpi/ic_warning_googred_48dp.png
new file mode 100644
index 0000000..70381dd
--- /dev/null
+++ b/res/drawable-hdpi/ic_warning_googred_48dp.png
Binary files differ
diff --git a/res/drawable-mdpi/dotted_line_480px.png b/res/drawable-mdpi/dotted_line_480px.png
deleted file mode 100755
index a52ca43..0000000
--- a/res/drawable-mdpi/dotted_line_480px.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-xhdpi/dotted_line_480px.png b/res/drawable-xhdpi/dotted_line_480px.png
deleted file mode 100644
index 7a9d024..0000000
--- a/res/drawable-xhdpi/dotted_line_480px.png
+++ /dev/null
Binary files differ
diff --git a/res/layout/ca_certificate_warning_dialog.xml b/res/layout/ca_certificate_warning_dialog.xml
new file mode 100644
index 0000000..d863b08
--- /dev/null
+++ b/res/layout/ca_certificate_warning_dialog.xml
@@ -0,0 +1,56 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ ~ Copyright (C) 2019 The Android Open Source Project
+ ~
+ ~ Licensed under the Apache License, Version 2.0 (the "License");
+ ~ you may not use this file except in compliance with the License.
+ ~ You may obtain a copy of the License at
+ ~
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~
+ ~ Unless required by applicable law or agreed to in writing, software
+ ~ distributed under the License is distributed on an "AS IS" BASIS,
+ ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ ~ See the License for the specific language governing permissions and
+ ~ limitations under the License.
+ -->
+<com.google.android.setupdesign.GlifLayout
+ xmlns:android="http://schemas.android.com/apk/res/android"
+ android:id="@+id/setup_wizard_layout"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent">
+
+ <LinearLayout
+ style="@style/SudContentFrame"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:orientation="vertical"
+ android:gravity="center_horizontal">
+
+ <ImageView
+ android:id="@+id/sud_layout_icon"
+ style="@style/SudGlifIcon"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:gravity="center"
+ android:src="@drawable/ic_warning_googred_48dp"/>
+
+ <TextView
+ android:id="@+id/sud_layout_title"
+ style="@style/SudGlifHeaderTitle"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:gravity="center"
+ android:text="@string/ca_certificate_warning_title"/>
+
+ <TextView
+ android:id="@+id/sud_layout_description"
+ style="@style/SudDescription.Glif"
+ android:layout_marginTop="16dp"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:text="@string/ca_certificate_warning_description"/>
+
+ </LinearLayout>
+
+</com.google.android.setupdesign.GlifLayout>
\ No newline at end of file
diff --git a/res/layout/crypt_keeper_emergency_button.xml b/res/layout/crypt_keeper_emergency_button.xml
index 0b6f810..6efcf5a 100644
--- a/res/layout/crypt_keeper_emergency_button.xml
+++ b/res/layout/crypt_keeper_emergency_button.xml
@@ -24,8 +24,7 @@
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
- android:orientation="vertical"
- android:gravity="bottom">
+ android:orientation="vertical">
<Button
android:id="@+id/emergencyCallButton"
android:layout_width="wrap_content"
diff --git a/res/layout/multi_sim_dialog.xml b/res/layout/multi_sim_dialog.xml
deleted file mode 100644
index d0e7df8..0000000
--- a/res/layout/multi_sim_dialog.xml
+++ /dev/null
@@ -1,120 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2014 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.
--->
-
-<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content">
-
- <LinearLayout
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:orientation="vertical">
-
- <LinearLayout android:id="@+id/type"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:orientation="vertical">
-
- <TextView
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:layout_marginTop="@dimen/sim_dialog_margin_top"
- android:paddingStart="@dimen/sim_content_padding"
- android:text="@string/sim_editor_name" />
-
- <EditText android:id="@+id/sim_name"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:singleLine="true"
- android:paddingStart="@dimen/sim_content_padding"
- android:paddingBottom="@dimen/sim_dialog_margin_bottom"
- android:hint="@string/sim_name_hint"
- android:inputType="textNoSuggestions"
- android:maxLength="@integer/sim_name_length"
- android:textColor="@android:color/black"
- style="?android:attr/textAppearanceMedium" />
-
- </LinearLayout>
-
- <LinearLayout
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:orientation="vertical">
-
- <TextView
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:layout_marginTop="@dimen/sim_dialog_margin_top"
- android:paddingStart="@dimen/sim_content_padding"
- android:text="@string/color_title" />
-
- <Spinner
- android:id="@+id/spinner"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:paddingStart="@dimen/sim_content_padding" />
-
- </LinearLayout>
-
- <LinearLayout
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:orientation="vertical">
-
- <TextView
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:layout_marginTop="@dimen/sim_dialog_margin_top"
- android:paddingStart="@dimen/sim_content_padding"
- android:text="@string/sim_editor_carrier" />
-
- <TextView android:id="@+id/carrier"
- android:textColor="@android:color/black"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:paddingStart="@dimen/sim_content_padding"
- android:paddingBottom="@dimen/sim_dialog_margin_bottom"
- android:singleLine="true"
- style="?android:attr/textAppearanceMedium" />
-
- </LinearLayout>
-
- <LinearLayout
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:orientation="vertical">
-
- <TextView
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:layout_marginTop="@dimen/sim_dialog_margin_top"
- android:paddingStart="@dimen/sim_content_padding"
- android:text="@string/sim_editor_number" />
-
- <TextView android:id="@+id/number"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:paddingBottom="@dimen/sim_dialog_margin_bottom"
- android:paddingStart="@dimen/sim_content_padding"
- android:singleLine="true"
- android:textColor="@android:color/black"
- style="?android:attr/textAppearanceMedium" />
-
- </LinearLayout>
-
- </LinearLayout>
-
-</ScrollView>
diff --git a/res/layout/preference.xml b/res/layout/preference.xml
deleted file mode 100644
index 195671b..0000000
--- a/res/layout/preference.xml
+++ /dev/null
@@ -1,65 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2011 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:minHeight="?android:attr/listPreferredItemHeightSmall"
- android:gravity="center_vertical"
- android:paddingStart="?android:attr/listPreferredItemPaddingStart"
- android:paddingEnd="?android:attr/listPreferredItemPaddingEnd"
- android:background="?android:attr/selectableItemBackground">
-
- <RelativeLayout
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_weight="1"
- android:paddingTop="16dip"
- android:paddingBottom="16dip">
-
- <TextView
- android:id="@android:id/title"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:singleLine="true"
- android:textAppearance="@*android:style/TextAppearance.DeviceDefault.Subhead"
- android:textColor="?android:attr/textColorPrimary"
- android:ellipsize="marquee"
- android:fadingEdge="horizontal" />
-
- <TextView
- android:id="@android:id/summary"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_below="@android:id/title"
- android:layout_alignStart="@android:id/title"
- android:visibility="gone"
- android:textAlignment="viewStart"
- android:textAppearance="@*android:style/TextAppearance.DeviceDefault.Body1"
- android:textColor="?android:attr/textColorSecondary"
- android:maxLines="10" />
-
- </RelativeLayout>
-
- <LinearLayout
- android:id="@android:id/widget_frame"
- android:layout_width="wrap_content"
- android:layout_height="match_parent"
- android:minWidth="58dip"
- android:gravity="end|center_vertical"
- android:orientation="vertical" />
-
-</LinearLayout>
diff --git a/res/layout/preference_widget_two_summary.xml b/res/layout/preference_widget_two_summary.xml
new file mode 100644
index 0000000..3f951da
--- /dev/null
+++ b/res/layout/preference_widget_two_summary.xml
@@ -0,0 +1,38 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2019 The Android Open Source Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<LinearLayout
+ xmlns:android="http://schemas.android.com/apk/res/android"
+ android:orientation="vertical"
+ android:paddingTop="16dp"
+ android:paddingBottom="16dp"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent">
+ <TextView
+ android:id="@+id/widget_summary1"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:textAppearance="?android:attr/textAppearanceSmall"
+ android:textColor="?android:attr/textColorSecondary"/>
+
+ <TextView
+ android:id="@+id/widget_summary2"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_gravity="bottom"
+ android:textAppearance="?android:attr/textAppearanceSmall"
+ android:textColor="?android:attr/textColorSecondary"/>
+</LinearLayout>
diff --git a/res/layout/profile_select_tablayout.xml b/res/layout/profile_select_tablayout.xml
index afacaae..4712c1d 100644
--- a/res/layout/profile_select_tablayout.xml
+++ b/res/layout/profile_select_tablayout.xml
@@ -22,21 +22,27 @@
android:layout_height="match_parent"
android:orientation="vertical">
+ <com.google.android.material.tabs.TabLayout
+ android:background="@android:color/transparent"
+ android:id="@+id/tabs"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ app:tabMaxWidth="0dp"
+ app:tabGravity="fill"
+ app:tabMode="fixed"
+ app:tabIndicatorFullWidth="false"
+ app:tabIndicatorColor="@*android:color/accent_device_default"
+ app:tabSelectedTextColor="@*android:color/accent_device_default"
+ app:tabTextColor="?android:attr/textColorSecondary" />
+ <View
+ android:layout_width="match_parent"
+ android:layout_height="1dp"
+ android:background="?android:attr/listDivider"/>
+
<androidx.viewpager.widget.ViewPager
android:id="@+id/view_pager"
android:layout_width="match_parent"
android:layout_height="match_parent">
- <com.google.android.material.tabs.TabLayout
- android:background="@android:color/transparent"
- android:id="@+id/tabs"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- app:tabMaxWidth="0dp"
- app:tabGravity="fill"
- app:tabMode="fixed"
- app:tabIndicatorColor="@*android:color/accent_device_default"
- app:tabSelectedTextColor="@*android:color/accent_device_default"
- app:tabTextColor="?android:attr/textColorSecondary" />
</androidx.viewpager.widget.ViewPager>
</LinearLayout>
diff --git a/res/layout/running_processes_header.xml b/res/layout/running_processes_header.xml
index b2db025..384c0b6 100644
--- a/res/layout/running_processes_header.xml
+++ b/res/layout/running_processes_header.xml
@@ -55,38 +55,29 @@
android:scaleType="centerInside"
android:src="@color/running_processes_system_ram"
android:contentDescription="@null" />
- <LinearLayout
+ <RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
- android:layout_gravity="center"
- android:orientation="horizontal">
+ android:layout_gravity="center">
<TextView
android:id="@+id/systemSizePrefix"
android:text="@string/running_processes_header_system_prefix"
android:textAppearance="@*android:style/TextAppearance.DeviceDefault.Body1"
android:textColor="?android:attr/textColorSecondary"
+ android:layout_alignParentStart="true"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:layout_marginLeft="16dp"
android:maxLines="1" />
- <ImageView
- android:src="@drawable/dotted_line_480px"
- android:layout_width="0dip"
- android:layout_weight="1"
- android:layout_height="1px"
- android:layout_marginStart="1dip"
- android:layout_marginEnd="1dip"
- android:baselineAlignBottom="true"
- android:scaleType="center"
- android:contentDescription="@null" />
<TextView
android:id="@+id/systemSize"
android:textAppearance="@*android:style/TextAppearance.DeviceDefault.Body1"
android:textColor="?android:attr/textColorSecondary"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
+ android:layout_alignParentEnd="true"
android:maxLines="1" />
- </LinearLayout>
+ </RelativeLayout>
</LinearLayout>
<LinearLayout
@@ -100,7 +91,7 @@
android:scaleType="centerInside"
android:src="?android:attr/colorAccent"
android:contentDescription="@null" />
- <LinearLayout
+ <RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
@@ -113,25 +104,17 @@
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:layout_marginLeft="16dp"
+ android:layout_alignParentStart="true"
android:maxLines="1" />
- <ImageView
- android:src="@drawable/dotted_line_480px"
- android:layout_width="0dip"
- android:layout_weight="1"
- android:layout_height="1px"
- android:baselineAlignBottom="true"
- android:layout_marginStart="1dip"
- android:layout_marginEnd="1dip"
- android:scaleType="center"
- android:contentDescription="@null" />
<TextView
android:id="@+id/appsSize"
android:textAppearance="@*android:style/TextAppearance.DeviceDefault.Body1"
android:textColor="?android:attr/textColorSecondary"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
+ android:layout_alignParentEnd="true"
android:maxLines="1" />
- </LinearLayout>
+ </RelativeLayout>
</LinearLayout>
<LinearLayout
@@ -145,7 +128,7 @@
android:scaleType="centerInside"
android:src="@color/running_processes_free_ram"
android:contentDescription="@null" />
- <LinearLayout
+ <RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
@@ -158,25 +141,17 @@
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:layout_marginLeft="16dp"
+ android:layout_alignParentStart="true"
android:maxLines="1" />
- <ImageView
- android:src="@drawable/dotted_line_480px"
- android:layout_width="0dip"
- android:layout_weight="1"
- android:layout_height="1px"
- android:baselineAlignBottom="true"
- android:layout_marginStart="1dip"
- android:layout_marginEnd="1dip"
- android:scaleType="center"
- android:contentDescription="@null" />
<TextView
android:id="@+id/freeSize"
android:textAppearance="@*android:style/TextAppearance.DeviceDefault.Body1"
android:textColor="?android:attr/textColorSecondary"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
+ android:layout_alignParentEnd="true"
android:maxLines="1" />
- </LinearLayout>
+ </RelativeLayout>
</LinearLayout>
<TextView
diff --git a/res/layout/running_processes_item.xml b/res/layout/running_processes_item.xml
index 45121eb..2bca90e 100644
--- a/res/layout/running_processes_item.xml
+++ b/res/layout/running_processes_item.xml
@@ -17,71 +17,19 @@
*/
-->
-<GridLayout xmlns:android="http://schemas.android.com/apk/res/android"
+<RelativeLayout
+ xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:minHeight="?android:attr/listPreferredItemHeight"
- android:paddingStart="?android:attr/listPreferredItemPaddingStart"
- android:paddingEnd="?android:attr/listPreferredItemPaddingEnd"
- android:paddingTop="8dip"
- android:paddingBottom="8dip"
- android:columnCount="2">
-
- <ImageView
- android:id="@+id/icon"
- android:layout_width="@android:dimen/app_icon_size"
- android:layout_height="@android:dimen/app_icon_size"
- android:layout_rowSpan="2"
- android:layout_marginEnd="8dip"
- android:scaleType="centerInside"
- android:contentDescription="@null" />
-
- <LinearLayout
- android:layout_width="0dip"
- android:layout_gravity="fill_horizontal"
- android:layout_marginTop="2dip">
-
- <TextView
- android:id="@+id/name"
- android:layout_width="0dip"
- android:layout_height="wrap_content"
- android:layout_weight="1"
- android:singleLine="true"
- android:ellipsize="marquee"
- android:textAppearance="@*android:style/TextAppearance.DeviceDefault.Subhead"
- android:textAlignment="viewStart" />
-
- <TextView
- android:id="@+id/size"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_marginStart="8dip"
- android:textAppearance="@*android:style/TextAppearance.DeviceDefault.Body1"
- android:textColor="?android:attr/textColorSecondary" />
-
- </LinearLayout>
-
- <LinearLayout
- android:layout_width="0dip"
- android:layout_gravity="fill_horizontal|top">
-
- <TextView
- android:id="@+id/description"
- android:layout_width="0dip"
- android:layout_height="wrap_content"
- android:layout_weight="1"
- android:textAppearance="@*android:style/TextAppearance.DeviceDefault.Body1"
- android:textColor="?android:attr/textColorSecondary"
- android:textAlignment="viewStart" />
-
- <TextView
- android:id="@+id/uptime"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_marginStart="8dip"
- android:textAppearance="@*android:style/TextAppearance.DeviceDefault.Body1"
- android:textColor="?android:attr/textColorSecondary" />
-
- </LinearLayout>
-
-</GridLayout>
+ android:layout_height="match_parent">
+ <include
+ android:layout_width="60dp"
+ android:layout_height="match_parent"
+ android:layout_alignParentEnd="true"
+ android:id="@+id/widget_summary"
+ layout="@layout/preference_widget_two_summary"/>
+ <include
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:layout_toStartOf="@id/widget_summary"
+ layout="@layout/preference_material"/>
+</RelativeLayout>
\ No newline at end of file
diff --git a/res/layout/running_processes_view.xml b/res/layout/running_processes_view.xml
index 19293ab..a1cc6ab 100644
--- a/res/layout/running_processes_view.xml
+++ b/res/layout/running_processes_view.xml
@@ -15,26 +15,31 @@
* limitations under the License.
-->
-<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:orientation="vertical">
+<LinearLayout
+ xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:orientation="vertical">
<FrameLayout
+ android:layout_width="match_parent"
+ android:layout_height="0dp"
+ android:layout_weight="1">
+ <ListView
+ android:id="@android:id/list"
+ style="@style/PreferenceFragmentListSinglePane"
android:layout_width="match_parent"
- android:layout_height="0px"
- android:layout_weight="1">
- <ListView android:id="@android:id/list"
- style="@style/PreferenceFragmentListSinglePane"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:drawSelectorOnTop="false"
- android:scrollbarStyle="outsideOverlay"
- android:fastScrollEnabled="true" />
- <TextView android:id="@android:id/empty"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:gravity="center"
- android:text="@string/no_running_services"
- android:textAppearance="?android:attr/textAppearanceLarge" />
+ android:layout_height="match_parent"
+ android:paddingStart="0dp"
+ android:paddingEnd="0dp"
+ android:drawSelectorOnTop="false"
+ android:scrollbarStyle="outsideOverlay"
+ android:fastScrollEnabled="true"/>
+ <TextView
+ android:id="@android:id/empty"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:gravity="center"
+ android:text="@string/no_running_services"
+ android:textAppearance="?android:attr/textAppearanceLarge"/>
</FrameLayout>
</LinearLayout>
diff --git a/res/layout/separator_label.xml b/res/layout/separator_label.xml
deleted file mode 100644
index b0e69fa..0000000
--- a/res/layout/separator_label.xml
+++ /dev/null
@@ -1,21 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
-/*
-** Copyright 2008, 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.
-*/
--->
-
-<TextView xmlns:android="http://schemas.android.com/apk/res/android"
- style="?android:attr/listSeparatorTextViewStyle" />
diff --git a/res/layout/settings_color_picker_item.xml b/res/layout/settings_color_picker_item.xml
deleted file mode 100644
index c171950..0000000
--- a/res/layout/settings_color_picker_item.xml
+++ /dev/null
@@ -1,47 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2014 The Android Open Source Project
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-<LinearLayout
- xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:app="http://schemas.android.com/apk/res-auto"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:orientation="horizontal"
- android:background="?android:attr/selectableItemBackground" >
-
- <ImageView
- android:id="@+id/color_icon"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:paddingRight="8dp"
- android:paddingLeft="6dp"
- android:paddingTop="8dp"
- android:paddingBottom="8dp"
- android:layout_gravity="center_vertical" />
-
- <TextView
- android:id="@+id/color_text"
- android:gravity="center_vertical"
- android:layout_height="wrap_content"
- android:layout_width="0dp"
- android:layout_weight="1"
- android:paddingTop="8dp"
- android:paddingBottom="8dp"
- android:paddingRight="8dp"
- android:paddingLeft="8dp"
- android:textColor="@android:color/black"
- style="?android:attr/textAppearanceMedium" />
-
-</LinearLayout>
\ No newline at end of file
diff --git a/res/layout/tall_preference_category.xml b/res/layout/tall_preference_category.xml
deleted file mode 100644
index 7eefdab..0000000
--- a/res/layout/tall_preference_category.xml
+++ /dev/null
@@ -1,29 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2015 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.
--->
-
-<!-- Based on frameworks/base/core/res/res/layout/preference_category_material.xml.
- except has paddingBottom set.-->
-<TextView xmlns:android="http://schemas.android.com/apk/res/android"
- android:id="@android:id/title"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:layout_marginBottom="16dip"
- android:textAppearance="@*android:style/TextAppearance.DeviceDefault.Body2"
- android:textColor="?android:attr/colorAccent"
- android:paddingStart="?android:attr/listPreferredItemPaddingStart"
- android:paddingEnd="?android:attr/listPreferredItemPaddingEnd"
- android:paddingBottom="8dp"
- android:paddingTop="16dip" />
diff --git a/res/layout/widget_text_views.xml b/res/layout/widget_text_views.xml
deleted file mode 100644
index 9f0506e..0000000
--- a/res/layout/widget_text_views.xml
+++ /dev/null
@@ -1,50 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2015 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:orientation="horizontal"
- android:duplicateParentState="true">
-
- <TextView
- android:id="@+id/widget_text1"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_weight="1"
- android:layout_gravity="fill_horizontal|top"
- android:textAppearance="@*android:style/TextAppearance.DeviceDefault.Body1"
- android:textColor="?android:attr/textColorSecondary"
- android:textAlignment="viewStart"
- android:singleLine="true"
- android:ellipsize="marquee"
- android:duplicateParentState="true" />
-
- <TextView
- android:id="@+id/widget_text2"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_weight="1"
- android:layout_marginStart="8dip"
- android:layout_gravity="fill_horizontal|top"
- android:textAppearance="@*android:style/TextAppearance.DeviceDefault.Body1"
- android:textColor="?android:attr/textColorSecondary"
- android:textAlignment="viewEnd"
- android:singleLine="true"
- android:ellipsize="marquee"
- android:duplicateParentState="true" />
-
-</LinearLayout>
diff --git a/res/layout/wifi_dialog.xml b/res/layout/wifi_dialog.xml
index 7d55e7b..c8fd6ce 100644
--- a/res/layout/wifi_dialog.xml
+++ b/res/layout/wifi_dialog.xml
@@ -368,14 +368,14 @@
android:layout_height="wrap_content"
style="@style/wifi_item"
android:paddingBottom="4dp"
- android:importantForAccessibility="yes"
- android:contentDescription="@string/wifi_advanced_toggle_description_collapsed"
+ android:importantForAccessibility="no"
android:visibility="gone">
<CheckBox android:id="@+id/wifi_advanced_togglebox"
android:layout_width="match_parent"
android:layout_height="wrap_content"
style="@style/wifi_advanced_toggle"
- android:importantForAccessibility="noHideDescendants"
+ android:importantForAccessibility="yes"
+ android:contentDescription="@string/wifi_advanced_toggle_description"
android:text="@string/wifi_show_advanced" />
</LinearLayout>
diff --git a/res/values-mcc208-mnc10-fr/strings.xml b/res/values-mcc208-mnc10-fr/strings.xml
new file mode 100644
index 0000000..da8bfed
--- /dev/null
+++ b/res/values-mcc208-mnc10-fr/strings.xml
@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="utf-8"?>
+
+<resources xmlns:android="http://schemas.android.com/apk/res/android" xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
+ <string name="wifi_calling_settings_title">Activer Appels Wi-Fi</string>
+</resources>
diff --git a/res/values/config.xml b/res/values/config.xml
index a329397..06a1555 100755
--- a/res/values/config.xml
+++ b/res/values/config.xml
@@ -410,7 +410,7 @@
<string name="config_nearby_devices_slice_uri" translatable="false">content://com.google.android.gms.nearby.fastpair/device_status_list_item</string>
<!-- Grayscale settings intent -->
- <string name="config_grayscale_settings_intent" translate="false"></string>
+ <string name="config_grayscale_settings_intent" translatable="false"></string>
<!-- List containing the injected tile keys which are suppressed. -->
<string-array name="config_suppress_injected_tile_keys" translatable="false"/>
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 2ee24f3..381ef57 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -533,12 +533,6 @@
<!-- Main Settings screen settings summary text for the "Wireless controls" setting -->
<string name="radio_controls_summary">Manage Wi\u2011Fi, Bluetooth, airplane mode, mobile networks, & VPNs</string>
- <!-- check box cellular data title [CHAR LIMIT=30] -->
- <string name="cellular_data_title">Mobile data</string>
- <!-- check box Calls title [CHAR LIMIT=30] -->
- <string name="calls_title">Allow calls</string>
- <!-- check box SMS Messges title [CHAR LIMIT=30] -->
- <string name="sms_messages_title">SMS messages</string>
<!-- check box cellular data summary [CHAR LIMIT=85] -->
<string name="cellular_data_summary">Allow data usage over mobile network</string>
<!-- check box to allow data usage when roaming [CHAR LIMIT=41] -->
@@ -1410,9 +1404,6 @@
<item quantity="other">Must be fewer than <xliff:g id="number" example="17">%d</xliff:g> digits</item>
</plurals>
- <!-- Error shown when in PIN mode and user enters a non-digit -->
- <string name="lockpassword_pin_contains_non_digits">Must contain only digits 0-9</string>
-
<!-- Error shown when in PIN mode and PIN has been used recently. Please keep this string short! -->
<string name="lockpassword_pin_recently_used">Device admin doesn\'t allow using a recent PIN</string>
@@ -1467,6 +1458,11 @@
<item quantity="other">Must contain at least <xliff:g id="count" example="3">%d</xliff:g> non-letter characters</item>
</plurals>
+ <plurals name="lockpassword_password_requires_nonnumerical">
+ <item quantity="one">Must contain at least 1 non-numerical character</item>
+ <item quantity="other">Must contain at least <xliff:g id="count" example="3">%d</xliff:g> non-numerical characters</item>
+ </plurals>
+
<!-- Error shown when in PASSWORD mode and password has been used recently. Please keep this string short! -->
<string name="lockpassword_password_recently_used">Device admin doesn\'t allow using a recent
password</string>
@@ -1953,10 +1949,12 @@
<!-- Dialog for Access Points --> <skip />
<!-- Label to show/hide advanced options [CHAR LIMIT=40] -->
<string name="wifi_show_advanced">Advanced options</string>
- <!-- Message for talkback to say when Advanced Options expanded [CHAR LIMIT=NONE] -->
- <string name="wifi_advanced_toggle_description_expanded">Drop down list Advanced Options. Double-tap to collapse.</string>
- <!-- Message for talkback to say when Advanced Options is collapsed [CHAR LIMIT=NONE] -->
- <string name="wifi_advanced_toggle_description_collapsed">Drop down list Advanced Options. Double-tap to expand.</string>
+ <!-- Message for talkback to say when focus on Advanced Options[CHAR LIMIT=NONE] -->
+ <string name="wifi_advanced_toggle_description">Drop down list Advanced Options</string>
+ <!-- Extended message for talkback to say when Advanced Options is expanded. (e.g., Double-tap to collapse) [CHAR LIMIT=NONE] -->
+ <string name="wifi_advanced_toggle_description_expanded">collapse</string>
+ <!-- Extended message for talkback to say when Advanced Options is collapsed. (e.g., Double-tap to expand) [CHAR LIMIT=NONE] -->
+ <string name="wifi_advanced_toggle_description_collapsed">expand</string>
<!-- Label for the SSID of the network -->
<string name="wifi_ssid">Network name</string>
<!-- Hint for a text field to enter the SSID of a hidden wifi network. [CHAR LIMIT=35] -->
@@ -2208,8 +2206,8 @@
<string name="wifi_advanced_titlebar">Advanced Wi\u2011Fi</string>
<!-- Wi-Fi settings screen, advanced, title of the item to show the Wi-Fi device's SSID. [CHAR LIMIT=20] -->
<string name="wifi_advanced_ssid_title">SSID</string>
- <!-- Wi-Fi settings screen, advanced, title of the item to show the factory's Wi-Fi MAC address. [CHAR LIMIT=50] -->
- <string name="wifi_advanced_factory_mac_address_title">Factory MAC address</string>
+ <!-- Wi-Fi settings screen, advanced, title of the item to show the device's Wi-Fi MAC address. [CHAR LIMIT=50] -->
+ <string name="wifi_advanced_device_mac_address_title">Device MAC address</string>
<!-- Wi-Fi settings screen, advanced, title of the item to show the randomized Wi-Fi MAC address. [CHAR LIMIT=50] -->
<string name="wifi_advanced_randomized_mac_address_title">Randomized MAC address</string>
<!-- Title of the screen to adjust IP settings -->
@@ -3037,8 +3035,8 @@
<string name="status_operator">Network</string>
<!-- About phone, status item title. The MAC address of the Wi-Fi network adapter. -->
<string name="status_wifi_mac_address">Wi\u2011Fi MAC address</string>
- <!-- About phone, status item title. The Factory MAC address of the Wi-Fi network adapter. [CHAR LIMIT=50] -->
- <string name="status_factory_wifi_mac_address">Factory Wi\u2011Fi MAC address</string>
+ <!-- About phone, status item title. The device's MAC address of the Wi-Fi network adapter. [CHAR LIMIT=50] -->
+ <string name="status_device_wifi_mac_address">Device Wi\u2011Fi MAC address</string>
<!-- About phone, status item title. The bluetooth adapter's hardware address-->
<string name="status_bt_address">Bluetooth address</string>
<!-- About phone, status item title. The hardware serial number. [CHAR LIMIT=30]-->
@@ -5836,10 +5834,8 @@
<!-- Title of preference group for credential storage settings [CHAR LIMIT=30] -->
<string name="credentials_title">Credential storage</string>
- <!-- Title of preference to install certificates from SD card [CHAR LIMIT=30] -->
- <string name="credentials_install" product="nosdcard">Install from storage</string>
- <!-- Title of preference to install certificates from SD card [CHAR LIMIT=30] -->
- <string name="credentials_install" product="default">Install from SD card</string>
+ <!-- Title of preference to install certificates [CHAR LIMIT=30] -->
+ <string name="credentials_install">Install a certificate</string>
<!-- Summary of preference to install certificates from SD card [CHAR LIMIT=NONE] -->
<string name="credentials_install_summary" product="nosdcard">Install certificates from storage</string>
<!-- Summary of preference to install certificates from SD card [CHAR LIMIT=NONE] -->
@@ -5878,6 +5874,22 @@
<string name="credentials_not_erased">Credential storage couldn\u2019t be erased.</string>
<!-- Title of Usage Access preference item [CHAR LIMIT=30] -->
<string name="usage_access_title">Apps with usage access</string>
+ <!-- Title of CA certificate [CHAR LIMIT=30] -->
+ <string name="ca_certificate">CA certificate</string>
+ <!-- Title of User certificate [CHAR LIMIT=30] -->
+ <string name="user_certificate">VPN & app user certificate</string>
+ <!-- Title of Wi-Fi certificate [CHAR LIMIT=30] -->
+ <string name="wifi_certificate">Wi\u2011Fi certificate</string>
+ <!-- Title of warning shown to the user before they can install a CA certificate [CHAR LIMIT=NONE] -->
+ <string name="ca_certificate_warning_title">Your privacy is at risk</string>
+ <!-- Description of warning shown to the user before they can install a CA certificate [CHAR LIMIT=NONE] -->
+ <string name="ca_certificate_warning_description">CA certificates are used by websites, apps, and VPNs for encryption. Only install CA certificates from organizations you trust. \n\n If you install a CA certificate, the certificate owner could access your information, such as passwords, messages, or credit card details, from websites you visit or apps you use - even if that information is encrypted.</string>
+ <!-- Label for button to not install a CA certificate [CHAR_LIMIT=50] -->
+ <string name="ca_certificate_warning_dont_install">Don\u2019t install</string>
+ <!-- Label for button to continue installing a CA certificate [CHAR_LIMIT=50] -->
+ <string name="ca_certificate_warning_install_anyway">Install anyways</string>
+ <!-- Toast message that a certificate was not installed -->
+ <string name="cert_not_installed">Certificate not installed</string>
<!-- Sound settings screen, setting check box label -->
<string name="emergency_tone_title">Emergency dialing signal</string>
@@ -6835,6 +6847,8 @@
<string name="help_url_security" translatable="false"></string>
<!-- Help URL, Encryption settings [DO NOT TRANSLATE] -->
<string name="help_url_encryption" translatable="false"></string>
+ <!-- Help URL, Install certificate settings [DO NOT TRANSLATE] -->
+ <string name="help_url_install_certificate" translatable="false"></string>
<!-- Help URL, Tap & pay [DO NOT TRANSLATE] -->
<string name="help_url_nfc_payment" translatable="false"></string>
<!-- Help URL, Remote display [DO NOT TRANSLATE] -->
@@ -7041,8 +7055,6 @@
<string name="sim_select_card">Select a SIM card</string>
<!-- Label for a numbered SIM card. [CHAR LIMIT=40] -->
<string name="sim_card_number_title">SIM <xliff:g id="card_number">%1$d</xliff:g></string>
- <!-- Name label of Sim card that is empty. [CHAR LIMIT=40] -->
- <string name="sim_slot_empty">SIM empty</string>
<!-- Name label of Sim Editor. [CHAR LIMIT=40] -->
<string name="sim_editor_name">SIM name</string>
<!-- Hint for SIM name in sim name editor dialog. [CHAR LIMIT=40] -->
@@ -7088,8 +7100,6 @@
<!-- Message under title informing the user to touch to go to SIM Cards in Settings. [CHAR LIMIT=40] -->
<string name="sim_notification_summary">Tap to set up</string>
- <!-- This is a divider in the SIM cards preferences that is the header of various settings where the user chooses which SIM to use for phone calls, data, and SMS messages [CHAR LIMIT=50] -->
- <string name="sim_pref_divider">Preferred SIM for</string>
<!-- When a user chooses this "Ask first" preference for the SIM to use for phone calls, they'll be prompted to choose a SIM every time they initiate a call [CHAR LIMIT=50] -->
<string name="sim_calls_ask_first_prefs_title">Ask every time</string>
<!-- When a SIM preference hasn't been selected yet, this string is displayed as the pref summary until the user chooses a SIM subscription from the preference list [CHAR LIMIT=50] -->
diff --git a/res/xml/encryption_and_credential.xml b/res/xml/encryption_and_credential.xml
index f9d9679..f7e7184 100644
--- a/res/xml/encryption_and_credential.xml
+++ b/res/xml/encryption_and_credential.xml
@@ -58,17 +58,11 @@
settings:userRestriction="no_config_credentials" />
<com.android.settingslib.RestrictedPreference
- android:key="credentials_install"
+ android:key="install_certificate"
android:title="@string/credentials_install"
android:summary="@string/credentials_install_summary"
- settings:userRestriction="no_config_credentials">
-
- <intent
- android:action="android.credentials.INSTALL"
- android:targetPackage="com.android.certinstaller"
- android:targetClass="com.android.certinstaller.CertInstallerMain" />
-
- </com.android.settingslib.RestrictedPreference>
+ android:fragment="com.android.settings.security.InstallCertificateFromStorage"
+ settings:userRestriction="no_config_credentials" />
<com.android.settingslib.RestrictedPreference
android:key="credentials_reset"
diff --git a/res/xml/install_certificate_from_storage.xml b/res/xml/install_certificate_from_storage.xml
new file mode 100644
index 0000000..0cf4a36
--- /dev/null
+++ b/res/xml/install_certificate_from_storage.xml
@@ -0,0 +1,67 @@
+<!--
+ ~ Copyright (C) 2019 The Android Open Source Project
+ ~
+ ~ Licensed under the Apache License, Version 2.0 (the "License");
+ ~ you may not use this file except in compliance with the License.
+ ~ You may obtain a copy of the License at
+ ~
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~
+ ~ Unless required by applicable law or agreed to in writing, software
+ ~ distributed under the License is distributed on an "AS IS" BASIS,
+ ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ ~ See the License for the specific language governing permissions and
+ ~ limitations under the License.
+ -->
+
+<PreferenceScreen
+ xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:settings="http://schemas.android.com/apk/res-auto"
+ android:title="@string/credentials_install"
+ android:key="install_certificate_from_storage">
+
+ <PreferenceCategory
+ android:key="certificate_types">
+
+ <Preference
+ android:key="install_ca_certificate"
+ android:title="@string/ca_certificate">
+
+ <intent
+ android:targetPackage="com.android.settings"
+ android:targetClass="com.android.settings.security.InstallCaCertificateWarning">
+ </intent>
+
+ </Preference>
+
+ <Preference
+ android:key="install_user_certificate"
+ android:title="@string/user_certificate">
+
+ <intent
+ android:action="android.credentials.INSTALL"
+ android:targetPackage="com.android.certinstaller"
+ android:targetClass="com.android.certinstaller.CertInstallerMain">
+ <!-- Same value as CERTIFICATE_USAGE_USER in keystore/java/android/security/Credentials.java -->
+ <extra android:name="certificate_install_usage" android:value="user"/>
+ </intent>
+
+ </Preference>
+
+ <Preference
+ android:key="install_wifi_certificate"
+ android:title="@string/wifi_certificate">
+
+ <intent
+ android:action="android.credentials.INSTALL"
+ android:targetPackage="com.android.certinstaller"
+ android:targetClass="com.android.certinstaller.CertInstallerMain">
+ <!-- Same value as CERTIFICATE_USAGE_WIFI in keystore/java/android/security/Credentials.java -->
+ <extra android:name="certificate_install_usage" android:value="wifi"/>
+ </intent>
+
+ </Preference>
+
+ </PreferenceCategory>
+
+</PreferenceScreen>
\ No newline at end of file
diff --git a/res/xml/mobile_network_settings_v2.xml b/res/xml/mobile_network_settings_v2.xml
index 1b08a5c..732967d 100644
--- a/res/xml/mobile_network_settings_v2.xml
+++ b/res/xml/mobile_network_settings_v2.xml
@@ -145,7 +145,8 @@
<PreferenceCategory
android:key="calling_category"
- android:title="@string/call_category">
+ android:title="@string/call_category"
+ settings:controller="com.android.settings.network.telephony.CallingPreferenceCategoryController">
<PreferenceScreen
android:key="wifi_calling"
diff --git a/res/xml/my_device_info.xml b/res/xml/my_device_info.xml
index ccd52ea..3f22a7b 100644
--- a/res/xml/my_device_info.xml
+++ b/res/xml/my_device_info.xml
@@ -150,7 +150,7 @@
<Preference
android:key="wifi_mac_address"
android:order="46"
- android:title="@string/status_factory_wifi_mac_address"
+ android:title="@string/status_device_wifi_mac_address"
android:summary="@string/summary_placeholder"
android:selectable="false"
settings:enableCopying="true"/>
diff --git a/res/xml/privacy_dashboard_settings.xml b/res/xml/privacy_dashboard_settings.xml
index 3ac6f42..c0c4840 100644
--- a/res/xml/privacy_dashboard_settings.xml
+++ b/res/xml/privacy_dashboard_settings.xml
@@ -50,6 +50,7 @@
<Preference
android:key="privacy_manage_perms"
android:title="@string/app_permissions"
+ android:summary="@string/summary_placeholder"
settings:allowDividerAbove="true"
settings:keywords="@string/keywords_app_permissions"
settings:controller="com.android.settings.applications.AppPermissionsPreferenceController">
diff --git a/res/xml/sim_settings.xml b/res/xml/sim_settings.xml
deleted file mode 100644
index 63e4ba4..0000000
--- a/res/xml/sim_settings.xml
+++ /dev/null
@@ -1,37 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2014 The Android Open Source Project
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-
-<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
- android:key="sim_cards"
- android:title="@string/sim_settings_title">
-
- <PreferenceCategory
- android:key="sim_activities"
- android:title="@string/sim_pref_divider" >
-
- <Preference android:key="sim_cellular_data"
- android:title="@string/cellular_data_title" />
-
- <Preference android:key="sim_calls"
- android:title="@string/calls_title" />
-
- <Preference android:key="sim_sms"
- android:title="@string/sms_messages_title" />
-
- </PreferenceCategory>
-
-
-</PreferenceScreen>
diff --git a/src/com/android/settings/MasterClearConfirm.java b/src/com/android/settings/MasterClearConfirm.java
index a8c4341..679f18f 100644
--- a/src/com/android/settings/MasterClearConfirm.java
+++ b/src/com/android/settings/MasterClearConfirm.java
@@ -49,6 +49,7 @@
import com.google.android.setupcompat.template.FooterBarMixin;
import com.google.android.setupcompat.template.FooterButton;
import com.google.android.setupcompat.template.FooterButton.ButtonType;
+import com.google.android.setupcompat.util.WizardManagerHelper;
import com.google.android.setupdesign.GlifLayout;
/**
@@ -86,7 +87,7 @@
getActivity().getSystemService(Context.OEM_LOCK_SERVICE);
if (pdbManager != null && !oemLockManager.isOemUnlockAllowed() &&
- Utils.isDeviceProvisioned(getActivity())) {
+ WizardManagerHelper.isDeviceProvisioned(getActivity())) {
// if OEM unlock is allowed, the persistent data block will be wiped during FR
// process. If disabled, it will be wiped here, unless the device is still being
// provisioned, in which case the persistent data block will be preserved.
diff --git a/src/com/android/settings/Settings.java b/src/com/android/settings/Settings.java
index add1178..24963b3 100644
--- a/src/com/android/settings/Settings.java
+++ b/src/com/android/settings/Settings.java
@@ -33,7 +33,6 @@
public static class CreateShortcutActivity extends SettingsActivity { /* empty */ }
public static class FaceSettingsActivity extends SettingsActivity { /* empty */ }
public static class FingerprintSettingsActivity extends SettingsActivity { /* empty */ }
- public static class SimSettingsActivity extends SettingsActivity { /* empty */ }
public static class TetherSettingsActivity extends SettingsActivity { /* empty */ }
public static class WifiTetherSettingsActivity extends SettingsActivity { /* empty */ }
public static class VpnSettingsActivity extends SettingsActivity { /* empty */ }
diff --git a/src/com/android/settings/SettingsActivity.java b/src/com/android/settings/SettingsActivity.java
index 4d813d5..e459ab8 100644
--- a/src/com/android/settings/SettingsActivity.java
+++ b/src/com/android/settings/SettingsActivity.java
@@ -35,7 +35,6 @@
import android.os.UserHandle;
import android.os.UserManager;
import android.text.TextUtils;
-import android.util.FeatureFlagUtils;
import android.util.Log;
import android.view.View;
import android.widget.Button;
@@ -53,13 +52,11 @@
import com.android.internal.util.ArrayUtils;
import com.android.settings.Settings.WifiSettingsActivity;
import com.android.settings.applications.manageapplications.ManageApplications;
-import com.android.settings.core.FeatureFlags;
import com.android.settings.core.OnActivityResultListener;
import com.android.settings.core.SettingsBaseActivity;
import com.android.settings.core.SubSettingLauncher;
import com.android.settings.core.gateway.SettingsGateway;
import com.android.settings.dashboard.DashboardFeatureProvider;
-import com.android.settings.dashboard.profileselector.ProfileFragmentBridge;
import com.android.settings.homepage.TopLevelSettings;
import com.android.settings.overlay.FeatureFactory;
import com.android.settings.wfd.WifiDisplaySettings;
@@ -276,7 +273,7 @@
launchSettingFragment(initialFragmentName, intent);
}
- final boolean deviceProvisioned = Utils.isDeviceProvisioned(this);
+ final boolean deviceProvisioned = WizardManagerHelper.isDeviceProvisioned(this);
final ActionBar actionBar = getActionBar();
if (actionBar != null) {
@@ -568,15 +565,7 @@
throw new IllegalArgumentException("Invalid fragment for this activity: "
+ fragmentName);
}
- Fragment f = null;
- if (FeatureFlagUtils.isEnabled(this, FeatureFlags.PERSONAL_WORK_PROFILE)
- && UserManager.get(this).getUserProfiles().size() > 1
- && ProfileFragmentBridge.FRAGMENT_MAP.get(fragmentName) != null) {
- f = Fragment.instantiate(this, ProfileFragmentBridge.FRAGMENT_MAP.get(fragmentName),
- args);
- } else {
- f = Fragment.instantiate(this, fragmentName, args);
- }
+ Fragment f = Utils.getTargetFragment(this, fragmentName, args);
FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
transaction.replace(R.id.main_content, f);
if (titleResId > 0) {
diff --git a/src/com/android/settings/Utils.java b/src/com/android/settings/Utils.java
index 75db3e1..f5f5ccd 100644
--- a/src/com/android/settings/Utils.java
+++ b/src/com/android/settings/Utils.java
@@ -21,6 +21,9 @@
import static android.text.format.DateUtils.FORMAT_ABBREV_MONTH;
import static android.text.format.DateUtils.FORMAT_SHOW_DATE;
+import static com.android.settings.applications.manageapplications.ManageApplications.EXTRA_PERSONAL_ONLY;
+import static com.android.settings.applications.manageapplications.ManageApplications.EXTRA_WORK_ONLY;
+
import android.annotation.Nullable;
import android.app.ActionBar;
import android.app.Activity;
@@ -73,7 +76,6 @@
import android.provider.ContactsContract.Data;
import android.provider.ContactsContract.Profile;
import android.provider.ContactsContract.RawContacts;
-import android.provider.Settings;
import android.telephony.SubscriptionManager;
import android.telephony.TelephonyManager;
import android.text.Spannable;
@@ -82,6 +84,7 @@
import android.text.format.DateUtils;
import android.text.style.TtsSpan;
import android.util.ArraySet;
+import android.util.FeatureFlagUtils;
import android.util.IconDrawableFactory;
import android.util.Log;
import android.view.LayoutInflater;
@@ -102,6 +105,7 @@
import com.android.internal.util.ArrayUtils;
import com.android.internal.widget.LockPatternUtils;
import com.android.settings.core.FeatureFlags;
+import com.android.settings.dashboard.profileselector.ProfileFragmentBridge;
import com.android.settings.development.featureflags.FeatureFlagPersistent;
import com.android.settings.password.ChooseLockSettingsHelper;
import com.android.settingslib.widget.ActionBarShadowController;
@@ -729,11 +733,6 @@
}
}
- public static boolean isDeviceProvisioned(Context context) {
- return Settings.Global.getInt(context.getContentResolver(),
- Settings.Global.DEVICE_PROVISIONED, 0) != 0;
- }
-
public static boolean startQuietModeDialogIfNecessary(Context context, UserManager um,
int userId) {
if (um.isQuietModeEnabled(UserHandle.of(userId))) {
@@ -1065,4 +1064,27 @@
ActionBarShadowController.attachToView(activity, lifecycle, scrollView);
}
}
+
+ /**
+ * Return correct target fragment based on argument
+ *
+ * @param activity the activity target fragment will be launched.
+ * @param fragmentName initial target fragment name.
+ * @param args fragment launch arguments.
+ */
+ public static Fragment getTargetFragment(Activity activity, String fragmentName, Bundle args) {
+ Fragment f = null;
+ final boolean isWorkOnly = args == null ? false : args.getBoolean(EXTRA_WORK_ONLY);
+ final boolean isPersonalOnly = args == null ? false : args.getBoolean(EXTRA_PERSONAL_ONLY);
+ if (FeatureFlagUtils.isEnabled(activity, FeatureFlags.PERSONAL_WORK_PROFILE)
+ && UserManager.get(activity).getUserProfiles().size() > 1
+ && ProfileFragmentBridge.FRAGMENT_MAP.get(fragmentName) != null
+ && !isWorkOnly && !isPersonalOnly) {
+ f = Fragment.instantiate(activity, ProfileFragmentBridge.FRAGMENT_MAP.get(fragmentName),
+ args);
+ } else {
+ f = Fragment.instantiate(activity, fragmentName, args);
+ }
+ return f;
+ }
}
diff --git a/src/com/android/settings/accessibility/AccessibilityDetailsSettingsFragment.java b/src/com/android/settings/accessibility/AccessibilityDetailsSettingsFragment.java
index dc07ef0..18700dc 100644
--- a/src/com/android/settings/accessibility/AccessibilityDetailsSettingsFragment.java
+++ b/src/com/android/settings/accessibility/AccessibilityDetailsSettingsFragment.java
@@ -135,9 +135,6 @@
final String packageName = serviceInfo.packageName;
final ComponentName componentName = new ComponentName(packageName, serviceInfo.name);
- final List<AccessibilityServiceInfo> enabledServiceInfos = AccessibilityManager.getInstance(
- getActivity()).getEnabledAccessibilityServiceList(
- AccessibilityServiceInfo.FEEDBACK_ALL_MASK);
final Set<ComponentName> enabledServices =
AccessibilityUtils.getEnabledServicesFromSettings(getActivity());
final boolean serviceEnabled = enabledServices.contains(componentName);
@@ -146,8 +143,7 @@
description = getString(R.string.accessibility_service_default_description);
}
- if (serviceEnabled && AccessibilityUtils.hasServiceCrashed(
- packageName, serviceInfo.name, enabledServiceInfos)) {
+ if (serviceEnabled && info.crashed) {
// Update the summaries for services that have crashed.
description = getString(R.string.accessibility_description_state_stopped);
}
diff --git a/src/com/android/settings/accessibility/AccessibilitySettings.java b/src/com/android/settings/accessibility/AccessibilitySettings.java
index 56dc49d..5eb3313 100644
--- a/src/com/android/settings/accessibility/AccessibilitySettings.java
+++ b/src/com/android/settings/accessibility/AccessibilitySettings.java
@@ -332,8 +332,6 @@
List<AccessibilityServiceInfo> installedServices =
accessibilityManager.getInstalledAccessibilityServiceList();
- List<AccessibilityServiceInfo> enabledServiceInfos = accessibilityManager
- .getEnabledAccessibilityServiceList(AccessibilityServiceInfo.FEEDBACK_ALL_MASK);
Set<ComponentName> enabledServices = AccessibilityUtils.getEnabledServicesFromSettings(
getActivity());
List<String> permittedServices = mDpm.getPermittedAccessibilityServices(
@@ -376,8 +374,7 @@
description = getString(R.string.accessibility_service_default_description);
}
- if (serviceEnabled && AccessibilityUtils.hasServiceCrashed(
- packageName, serviceInfo.name, enabledServiceInfos)) {
+ if (serviceEnabled && info.crashed) {
// Update the summaries for services that have crashed.
preference.setSummary(R.string.accessibility_summary_state_stopped);
description = getString(R.string.accessibility_description_state_stopped);
diff --git a/src/com/android/settings/accounts/AccountPersonalDashboardFragment.java b/src/com/android/settings/accounts/AccountPersonalDashboardFragment.java
index ac426a2..e0db7f5 100644
--- a/src/com/android/settings/accounts/AccountPersonalDashboardFragment.java
+++ b/src/com/android/settings/accounts/AccountPersonalDashboardFragment.java
@@ -28,7 +28,6 @@
import com.android.settings.users.AutoSyncDataPreferenceController;
import com.android.settings.users.AutoSyncPersonalDataPreferenceController;
import com.android.settingslib.core.AbstractPreferenceController;
-import com.android.settingslib.search.SearchIndexable;
import java.util.ArrayList;
import java.util.List;
@@ -36,7 +35,6 @@
/**
* Account Setting page for personal profile.
*/
-@SearchIndexable
public class AccountPersonalDashboardFragment extends DashboardFragment {
private static final String TAG = "AccountPersonalFrag";
diff --git a/src/com/android/settings/accounts/AccountWorkProfileDashboardFragment.java b/src/com/android/settings/accounts/AccountWorkProfileDashboardFragment.java
index e3fceb8..a31340a 100644
--- a/src/com/android/settings/accounts/AccountWorkProfileDashboardFragment.java
+++ b/src/com/android/settings/accounts/AccountWorkProfileDashboardFragment.java
@@ -28,7 +28,6 @@
import com.android.settings.users.AutoSyncDataPreferenceController;
import com.android.settings.users.AutoSyncWorkDataPreferenceController;
import com.android.settingslib.core.AbstractPreferenceController;
-import com.android.settingslib.search.SearchIndexable;
import java.util.ArrayList;
import java.util.List;
@@ -36,7 +35,6 @@
/**
* Account Setting page for work profile.
*/
-@SearchIndexable
public class AccountWorkProfileDashboardFragment extends DashboardFragment {
private static final String TAG = "AccountWorkProfileFrag";
diff --git a/src/com/android/settings/applications/AppPermissionsPreferenceController.java b/src/com/android/settings/applications/AppPermissionsPreferenceController.java
index 59341d5..0a3bba7 100644
--- a/src/com/android/settings/applications/AppPermissionsPreferenceController.java
+++ b/src/com/android/settings/applications/AppPermissionsPreferenceController.java
@@ -105,7 +105,7 @@
final CharSequence summary = !permissionsToShow.isEmpty()
? mContext.getString(R.string.app_permissions_summary,
ListFormatter.getInstance().format(permissionsToShow).toLowerCase())
- : null;
+ : mContext.getString(R.string.runtime_permissions_summary_no_permissions_granted);
mPreference.setSummary(summary);
}
}
\ No newline at end of file
diff --git a/src/com/android/settings/applications/RunningProcessesView.java b/src/com/android/settings/applications/RunningProcessesView.java
index 5491ad1..5198a4a 100644
--- a/src/com/android/settings/applications/RunningProcessesView.java
+++ b/src/com/android/settings/applications/RunningProcessesView.java
@@ -164,11 +164,11 @@
public ViewHolder(View v) {
rootView = v;
- icon = (ImageView)v.findViewById(R.id.icon);
- name = (TextView)v.findViewById(R.id.name);
- description = (TextView)v.findViewById(R.id.description);
- size = (TextView)v.findViewById(R.id.size);
- uptime = (TextView)v.findViewById(R.id.uptime);
+ icon = v.findViewById(android.R.id.icon);
+ name = v.findViewById(android.R.id.title);
+ description = v.findViewById(android.R.id.summary);
+ size = v.findViewById(R.id.widget_summary1);
+ uptime = v.findViewById(R.id.widget_summary2);
v.setTag(this);
}
diff --git a/src/com/android/settings/applications/RunningServiceDetails.java b/src/com/android/settings/applications/RunningServiceDetails.java
index 6165fb4..e95b41a 100644
--- a/src/com/android/settings/applications/RunningServiceDetails.java
+++ b/src/com/android/settings/applications/RunningServiceDetails.java
@@ -226,7 +226,7 @@
void addServicesHeader() {
if (mNumServices == 0) {
- mServicesHeader = (TextView)mInflater.inflate(R.layout.separator_label,
+ mServicesHeader = (TextView) mInflater.inflate(R.layout.preference_category,
mAllDetails, false);
mServicesHeader.setText(R.string.runningservicedetails_services_title);
mAllDetails.addView(mServicesHeader);
@@ -236,7 +236,7 @@
void addProcessesHeader() {
if (mNumProcesses == 0) {
- mProcessesHeader = (TextView)mInflater.inflate(R.layout.separator_label,
+ mProcessesHeader = (TextView) mInflater.inflate(R.layout.preference_category,
mAllDetails, false);
mProcessesHeader.setText(R.string.runningservicedetails_processes_title);
mAllDetails.addView(mProcessesHeader);
diff --git a/src/com/android/settings/applications/appops/AppOpsState.java b/src/com/android/settings/applications/appops/AppOpsState.java
index 3c8d647..fed77ae 100644
--- a/src/com/android/settings/applications/appops/AppOpsState.java
+++ b/src/com/android/settings/applications/appops/AppOpsState.java
@@ -28,6 +28,7 @@
import android.os.Parcelable;
import android.text.format.DateUtils;
import android.util.Log;
+import android.util.Pair;
import android.util.SparseArray;
import com.android.settings.R;
@@ -618,7 +619,7 @@
}
AppOpsManager.OpEntry opEntry = new AppOpsManager.OpEntry(
- permOps.get(k), AppOpsManager.MODE_ALLOWED);
+ permOps.get(k), AppOpsManager.MODE_ALLOWED, new Pair[0]);
dummyOps.add(opEntry);
addOp(entries, pkgOps, appEntry, opEntry, packageName == null,
packageName == null ? 0 : opToOrder[opEntry.getOp()]);
diff --git a/src/com/android/settings/applications/manageapplications/ManageApplications.java b/src/com/android/settings/applications/manageapplications/ManageApplications.java
index 90ab71a..01289f2 100644
--- a/src/com/android/settings/applications/manageapplications/ManageApplications.java
+++ b/src/com/android/settings/applications/manageapplications/ManageApplications.java
@@ -143,6 +143,7 @@
public static final String EXTRA_STORAGE_TYPE = "storageType";
public static final String EXTRA_WORK_ONLY = "workProfileOnly";
public static final String EXTRA_WORK_ID = "workId";
+ public static final String EXTRA_PERSONAL_ONLY = "personalOnly";
private static final String EXTRA_SORT_ORDER = "sortOrder";
private static final String EXTRA_SHOW_SYSTEM = "showSystem";
@@ -234,6 +235,7 @@
private int mStorageType;
private boolean mIsWorkOnly;
private int mWorkUserId;
+ private boolean mIsPersonalOnly;
private View mEmptyView;
private int mFilterType;
@@ -308,6 +310,7 @@
}
final AppFilterRegistry appFilterRegistry = AppFilterRegistry.getInstance();
mFilter = appFilterRegistry.get(appFilterRegistry.getDefaultFilterType(mListType));
+ mIsPersonalOnly = args != null ? args.getBoolean(EXTRA_PERSONAL_ONLY) : false;
mIsWorkOnly = args != null ? args.getBoolean(EXTRA_WORK_ONLY) : false;
mWorkUserId = args != null ? args.getInt(EXTRA_WORK_ID) : NO_USER_SPECIFIED;
mExpandSearch = activity.getIntent().getBooleanExtra(EXTRA_EXPAND_SEARCH_VIEW, false);
@@ -405,8 +408,22 @@
final AppFilterRegistry appFilterRegistry = AppFilterRegistry.getInstance();
mFilterAdapter.enableFilter(appFilterRegistry.getDefaultFilterType(mListType));
+
+ AppFilter compositeFilter = getCompositeFilter(mListType, mStorageType, mVolumeUuid);
+ if (mIsWorkOnly) {
+ compositeFilter = new CompoundFilter(compositeFilter, ApplicationsState.FILTER_WORK);
+ }
+ if (mIsPersonalOnly) {
+ compositeFilter = new CompoundFilter(compositeFilter,
+ ApplicationsState.FILTER_PERSONAL);
+ }
+ if (compositeFilter != null) {
+ mApplications.setCompositeFilter(compositeFilter);
+ }
+
if (mListType == LIST_TYPE_MAIN) {
- if (UserManager.get(getActivity()).getUserProfiles().size() > 1) {
+ if (UserManager.get(getActivity()).getUserProfiles().size() > 1 && !mIsWorkOnly
+ && !mIsPersonalOnly) {
mFilterAdapter.enableFilter(FILTER_APPS_PERSONAL);
mFilterAdapter.enableFilter(FILTER_APPS_WORK);
}
@@ -420,15 +437,6 @@
if (mListType == LIST_TYPE_HIGH_POWER) {
mFilterAdapter.enableFilter(FILTER_APPS_POWER_WHITELIST_ALL);
}
-
- AppFilter compositeFilter = getCompositeFilter(mListType, mStorageType, mVolumeUuid);
- if (mIsWorkOnly) {
- final AppFilter workFilter = appFilterRegistry.get(FILTER_APPS_WORK).getFilter();
- compositeFilter = new CompoundFilter(compositeFilter, workFilter);
- }
- if (compositeFilter != null) {
- mApplications.setCompositeFilter(compositeFilter);
- }
}
@VisibleForTesting
@@ -449,9 +457,11 @@
return new CompoundFilter(ApplicationsState.FILTER_MOVIES, filter);
} else if (listType == LIST_TYPE_PHOTOGRAPHY) {
return new CompoundFilter(ApplicationsState.FILTER_PHOTOS, filter);
+ } else {
+ final AppFilterRegistry appFilterRegistry = AppFilterRegistry.getInstance();
+ return appFilterRegistry.get(
+ appFilterRegistry.getDefaultFilterType(listType)).getFilter();
}
-
- return null;
}
@Override
@@ -508,7 +518,7 @@
outState.putBoolean(EXTRA_SHOW_SYSTEM, mShowSystem);
outState.putBoolean(EXTRA_HAS_ENTRIES, mApplications.mHasReceivedLoadEntries);
outState.putBoolean(EXTRA_HAS_BRIDGE, mApplications.mHasReceivedBridgeCallback);
- if(mSearchView != null) {
+ if (mSearchView != null) {
outState.putBoolean(EXTRA_EXPAND_SEARCH_VIEW, !mSearchView.isIconified());
}
if (mApplications != null) {
@@ -1166,7 +1176,7 @@
mSearchFilter = new SearchFilter();
}
// If we haven't load apps list completely, don't filter anything.
- if(mOriginalEntries == null) {
+ if (mOriginalEntries == null) {
Log.w(TAG, "Apps haven't loaded completely yet, so nothing can be filtered");
return;
}
diff --git a/src/com/android/settings/bluetooth/AdvancedBluetoothDetailsHeaderController.java b/src/com/android/settings/bluetooth/AdvancedBluetoothDetailsHeaderController.java
index 7e10043..e245c22 100644
--- a/src/com/android/settings/bluetooth/AdvancedBluetoothDetailsHeaderController.java
+++ b/src/com/android/settings/bluetooth/AdvancedBluetoothDetailsHeaderController.java
@@ -92,7 +92,8 @@
public int getAvailabilityStatus() {
final boolean advancedEnabled = DeviceConfig.getBoolean(DeviceConfig.NAMESPACE_SETTINGS_UI,
SettingsUIDeviceConfig.BT_ADVANCED_HEADER_ENABLED, true);
- final boolean untetheredHeadset = BluetoothUtils.getBooleanMetaData(
+ final boolean untetheredHeadset = mCachedDevice != null
+ && BluetoothUtils.getBooleanMetaData(
mCachedDevice.getDevice(), BluetoothDevice.METADATA_IS_UNTETHERED_HEADSET);
return advancedEnabled && untetheredHeadset ? AVAILABLE : CONDITIONALLY_UNAVAILABLE;
}
diff --git a/src/com/android/settings/bluetooth/BluetoothDeviceDetailsFragment.java b/src/com/android/settings/bluetooth/BluetoothDeviceDetailsFragment.java
index c31b13e..59c5078 100644
--- a/src/com/android/settings/bluetooth/BluetoothDeviceDetailsFragment.java
+++ b/src/com/android/settings/bluetooth/BluetoothDeviceDetailsFragment.java
@@ -23,6 +23,7 @@
import android.content.Context;
import android.os.Bundle;
import android.provider.DeviceConfig;
+import android.util.Log;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
@@ -107,12 +108,13 @@
mDeviceAddress = getArguments().getString(KEY_DEVICE_ADDRESS);
mManager = getLocalBluetoothManager(context);
mCachedDevice = getCachedDevice(mDeviceAddress);
+ super.onAttach(context);
if (mCachedDevice == null) {
// Close this page if device is null with invalid device mac address
+ Log.w(TAG, "onAttach() CachedDevice is null!");
finish();
return;
}
- super.onAttach(context);
use(AdvancedBluetoothDetailsHeaderController.class).init(mCachedDevice);
final BluetoothFeatureProvider featureProvider = FeatureFactory.getFactory(
diff --git a/src/com/android/settings/bluetooth/BluetoothSliceBuilder.java b/src/com/android/settings/bluetooth/BluetoothSliceBuilder.java
index 18df872..5a4ee1f 100644
--- a/src/com/android/settings/bluetooth/BluetoothSliceBuilder.java
+++ b/src/com/android/settings/bluetooth/BluetoothSliceBuilder.java
@@ -136,6 +136,6 @@
final Intent intent = new Intent(ACTION_BLUETOOTH_SLICE_CHANGED)
.setClass(context, SliceBroadcastReceiver.class);
return PendingIntent.getBroadcast(context, 0 /* requestCode */, intent,
- PendingIntent.FLAG_CANCEL_CURRENT);
+ PendingIntent.FLAG_UPDATE_CURRENT);
}
}
diff --git a/src/com/android/settings/connecteddevice/usb/UsbDetailsFunctionsController.java b/src/com/android/settings/connecteddevice/usb/UsbDetailsFunctionsController.java
index 9c9400d..31bca12 100644
--- a/src/com/android/settings/connecteddevice/usb/UsbDetailsFunctionsController.java
+++ b/src/com/android/settings/connecteddevice/usb/UsbDetailsFunctionsController.java
@@ -114,16 +114,16 @@
if (function != previousFunction && !Utils.isMonkeyRunning()) {
mPreviousFunction = previousFunction;
- if (function == UsbManager.FUNCTION_RNDIS) {
- //Update the UI in advance to make it looks smooth
- final RadioButtonPreference prevPref =
- (RadioButtonPreference) mProfilesContainer.findPreference(
- UsbBackend.usbFunctionsToString(mPreviousFunction));
- if (prevPref != null) {
- prevPref.setChecked(false);
- preference.setChecked(true);
- }
+ //Update the UI in advance to make it looks smooth
+ final RadioButtonPreference prevPref =
+ (RadioButtonPreference) mProfilesContainer.findPreference(
+ UsbBackend.usbFunctionsToString(mPreviousFunction));
+ if (prevPref != null) {
+ prevPref.setChecked(false);
+ preference.setChecked(true);
+ }
+ if (function == UsbManager.FUNCTION_RNDIS) {
// We need to have entitlement check for usb tethering, so use API in
// ConnectivityManager.
mConnectivityManager.startTethering(TETHERING_USB, true /* showProvisioningUi */,
diff --git a/src/com/android/settings/core/gateway/SettingsGateway.java b/src/com/android/settings/core/gateway/SettingsGateway.java
index aa96a02..a318037 100644
--- a/src/com/android/settings/core/gateway/SettingsGateway.java
+++ b/src/com/android/settings/core/gateway/SettingsGateway.java
@@ -127,7 +127,6 @@
import com.android.settings.security.LockscreenDashboardFragment;
import com.android.settings.security.SecuritySettings;
import com.android.settings.shortcut.CreateShortcut;
-import com.android.settings.sim.SimSettings;
import com.android.settings.support.SupportDashboardActivity;
import com.android.settings.system.ResetDashboardFragment;
import com.android.settings.system.SystemDashboardFragment;
@@ -161,7 +160,6 @@
WifiSettings2.class.getName(),
ConfigureWifiSettings.class.getName(),
SavedAccessPointsWifiSettings.class.getName(),
- SimSettings.class.getName(),
TetherSettings.class.getName(),
WifiP2pSettings.class.getName(),
WifiTetherSettings.class.getName(),
diff --git a/src/com/android/settings/dashboard/profileselector/ProfileFragmentBridge.java b/src/com/android/settings/dashboard/profileselector/ProfileFragmentBridge.java
index 797782a..047f740 100644
--- a/src/com/android/settings/dashboard/profileselector/ProfileFragmentBridge.java
+++ b/src/com/android/settings/dashboard/profileselector/ProfileFragmentBridge.java
@@ -19,7 +19,8 @@
import android.util.ArrayMap;
import com.android.settings.accounts.AccountDashboardFragment;
-import com.android.settings.accounts.AccountProfileSelectFragment;
+import com.android.settings.applications.manageapplications.ManageApplications;
+import com.android.settings.deviceinfo.StorageDashboardFragment;
import java.util.Map;
@@ -37,6 +38,10 @@
static {
FRAGMENT_MAP = new ArrayMap<>();
FRAGMENT_MAP.put(AccountDashboardFragment.class.getName(),
- AccountProfileSelectFragment.class.getName());
+ ProfileSelectAccountFragment.class.getName());
+ FRAGMENT_MAP.put(ManageApplications.class.getName(),
+ ProfileSelectManageApplications.class.getName());
+ FRAGMENT_MAP.put(StorageDashboardFragment.class.getName(),
+ ProfileSelectStorageFragment.class.getName());
}
}
diff --git a/src/com/android/settings/accounts/AccountProfileSelectFragment.java b/src/com/android/settings/dashboard/profileselector/ProfileSelectAccountFragment.java
similarity index 77%
rename from src/com/android/settings/accounts/AccountProfileSelectFragment.java
rename to src/com/android/settings/dashboard/profileselector/ProfileSelectAccountFragment.java
index 128596d..ac67b58 100644
--- a/src/com/android/settings/accounts/AccountProfileSelectFragment.java
+++ b/src/com/android/settings/dashboard/profileselector/ProfileSelectAccountFragment.java
@@ -14,15 +14,16 @@
* limitations under the License.
*/
-package com.android.settings.accounts;
+package com.android.settings.dashboard.profileselector;
import androidx.fragment.app.Fragment;
-import com.android.settings.dashboard.profileselector.ProfileSelectFragment;
+import com.android.settings.accounts.AccountPersonalDashboardFragment;
+import com.android.settings.accounts.AccountWorkProfileDashboardFragment;
/**
* Account Setting page for personal/managed profile.
*/
-public class AccountProfileSelectFragment extends ProfileSelectFragment {
+public class ProfileSelectAccountFragment extends ProfileSelectFragment {
@Override
public Fragment[] getFragments() {
diff --git a/src/com/android/settings/dashboard/profileselector/ProfileSelectFragment.java b/src/com/android/settings/dashboard/profileselector/ProfileSelectFragment.java
index 96eace8..323e3cd 100644
--- a/src/com/android/settings/dashboard/profileselector/ProfileSelectFragment.java
+++ b/src/com/android/settings/dashboard/profileselector/ProfileSelectFragment.java
@@ -30,6 +30,8 @@
import com.android.settings.R;
import com.android.settings.core.InstrumentedFragment;
+import com.google.android.material.tabs.TabLayout;
+
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
@@ -69,6 +71,8 @@
mContentView = inflater.inflate(R.layout.profile_select_tablayout, null /* root */);
final ViewPager viewPager = mContentView.findViewById(R.id.view_pager);
viewPager.setAdapter(new ViewPagerAdapter(this));
+ final TabLayout tabs = mContentView.findViewById(R.id.tabs);
+ tabs.setupWithViewPager(viewPager);
return mContentView;
}
diff --git a/src/com/android/settings/dashboard/profileselector/ProfileSelectManageApplications.java b/src/com/android/settings/dashboard/profileselector/ProfileSelectManageApplications.java
new file mode 100644
index 0000000..7290258
--- /dev/null
+++ b/src/com/android/settings/dashboard/profileselector/ProfileSelectManageApplications.java
@@ -0,0 +1,49 @@
+/*
+ * Copyright (C) 2019 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.settings.dashboard.profileselector;
+
+import static com.android.settings.applications.manageapplications.ManageApplications.EXTRA_PERSONAL_ONLY;
+import static com.android.settings.applications.manageapplications.ManageApplications.EXTRA_WORK_ONLY;
+
+import android.os.Bundle;
+
+import androidx.fragment.app.Fragment;
+
+import com.android.settings.applications.manageapplications.ManageApplications;
+
+/**
+ * Application Setting page for personal/managed profile.
+ */
+public class ProfileSelectManageApplications extends ProfileSelectFragment {
+
+ @Override
+ public Fragment[] getFragments() {
+ final Bundle workOnly = new Bundle();
+ workOnly.putBoolean(EXTRA_WORK_ONLY, true);
+ final Fragment workFragment = new ManageApplications();
+ workFragment.setArguments(workOnly);
+
+ final Bundle personalOnly = new Bundle();
+ personalOnly.putBoolean(EXTRA_PERSONAL_ONLY, true);
+ final Fragment personalFragment = new ManageApplications();
+ personalFragment.setArguments(personalOnly);
+ return new Fragment[]{
+ personalFragment, //0
+ workFragment
+ };
+ }
+}
diff --git a/src/com/android/settings/dashboard/profileselector/ProfileSelectStorageFragment.java b/src/com/android/settings/dashboard/profileselector/ProfileSelectStorageFragment.java
new file mode 100644
index 0000000..c7e4fd8
--- /dev/null
+++ b/src/com/android/settings/dashboard/profileselector/ProfileSelectStorageFragment.java
@@ -0,0 +1,62 @@
+/*
+ * Copyright (C) 2019 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.settings.dashboard.profileselector;
+
+import android.content.pm.UserInfo;
+import android.os.Bundle;
+import android.os.UserManager;
+import android.os.storage.VolumeInfo;
+
+import androidx.fragment.app.Fragment;
+
+import com.android.settings.deviceinfo.StorageDashboardFragment;
+import com.android.settings.deviceinfo.StorageProfileFragment;
+
+/**
+ * Storage Setting page for personal/managed profile.
+ */
+public class ProfileSelectStorageFragment extends ProfileSelectFragment {
+ @Override
+ public Fragment[] getFragments() {
+
+ final Bundle storageBundle = new Bundle();
+ storageBundle.putString(VolumeInfo.EXTRA_VOLUME_ID, VolumeInfo.ID_PRIVATE_INTERNAL);
+
+ final Fragment storageDashboardFragment = new StorageDashboardFragment();
+ storageDashboardFragment.setArguments(storageBundle);
+
+ UserInfo targetUser = null;
+ for (UserInfo info : UserManager.get(getActivity()).getUsers()) {
+ if (!info.isPrimary()) {
+ targetUser = info;
+ break;
+ }
+ }
+ // TODO(b/143330969): Need to think about more profile users case
+ if (targetUser != null) {
+ storageBundle.putInt(StorageProfileFragment.USER_ID_EXTRA, targetUser.id);
+ }
+ final Fragment storageProfileFragment = new StorageProfileFragment();
+ storageProfileFragment.setArguments(storageBundle);
+
+ return new Fragment[]{
+ storageDashboardFragment,
+ storageProfileFragment
+ };
+ }
+}
+
diff --git a/src/com/android/settings/development/DevelopmentSettingsDashboardFragment.java b/src/com/android/settings/development/DevelopmentSettingsDashboardFragment.java
index 52a5cd9..8e8a82d 100644
--- a/src/com/android/settings/development/DevelopmentSettingsDashboardFragment.java
+++ b/src/com/android/settings/development/DevelopmentSettingsDashboardFragment.java
@@ -53,6 +53,8 @@
import com.android.settingslib.development.SystemPropPoker;
import com.android.settingslib.search.SearchIndexable;
+import com.google.android.setupcompat.util.WizardManagerHelper;
+
import java.util.ArrayList;
import java.util.List;
@@ -166,7 +168,7 @@
super.onActivityCreated(icicle);
// Apply page-level restrictions
setIfOnlyAvailableForAdmins(true);
- if (isUiRestricted() || !Utils.isDeviceProvisioned(getActivity())) {
+ if (isUiRestricted() || !WizardManagerHelper.isDeviceProvisioned(getActivity())) {
// Block access to developer options if the user is not the owner, if user policy
// restricts it, or if the device has not been provisioned
mIsAvailable = false;
diff --git a/src/com/android/settings/development/featureflags/FeatureFlagsPreferenceController.java b/src/com/android/settings/development/featureflags/FeatureFlagsPreferenceController.java
index 94636e9..f0b7961 100644
--- a/src/com/android/settings/development/featureflags/FeatureFlagsPreferenceController.java
+++ b/src/com/android/settings/development/featureflags/FeatureFlagsPreferenceController.java
@@ -24,13 +24,13 @@
import androidx.preference.PreferenceScreen;
import com.android.settings.core.BasePreferenceController;
-import com.android.settingslib.core.lifecycle.LifecycleObserver;
-import com.android.settingslib.core.lifecycle.events.OnStart;
import java.util.Map;
-public class FeatureFlagsPreferenceController extends BasePreferenceController
- implements LifecycleObserver, OnStart {
+/**
+ * A {@link BasePreferenceController} used in {@link FeatureFlagsDashboard}
+ */
+public class FeatureFlagsPreferenceController extends BasePreferenceController {
private PreferenceGroup mGroup;
@@ -47,13 +47,6 @@
public void displayPreference(PreferenceScreen screen) {
super.displayPreference(screen);
mGroup = screen.findPreference(getPreferenceKey());
- }
-
- @Override
- public void onStart() {
- if (mGroup == null) {
- return;
- }
final Map<String, String> featureMap = FeatureFlagUtils.getAllFeatureFlags();
if (featureMap == null) {
return;
diff --git a/src/com/android/settings/deviceinfo/BuildNumberPreferenceController.java b/src/com/android/settings/deviceinfo/BuildNumberPreferenceController.java
index dd522bf..40e34c0 100644
--- a/src/com/android/settings/deviceinfo/BuildNumberPreferenceController.java
+++ b/src/com/android/settings/deviceinfo/BuildNumberPreferenceController.java
@@ -46,6 +46,8 @@
import com.android.settingslib.core.lifecycle.events.OnStart;
import com.android.settingslib.development.DevelopmentSettingsEnabler;
+import com.google.android.setupcompat.util.WizardManagerHelper;
+
public class BuildNumberPreferenceController extends BasePreferenceController implements
LifecycleObserver, OnStart {
@@ -131,7 +133,7 @@
}
// Don't enable developer options until device has been provisioned
- if (!Utils.isDeviceProvisioned(mContext)) {
+ if (!WizardManagerHelper.isDeviceProvisioned(mContext)) {
mMetricsFeatureProvider.action(
mContext, SettingsEnums.ACTION_SETTINGS_BUILD_NUMBER_PREF);
return false;
diff --git a/src/com/android/settings/deviceinfo/storage/SecondaryUserController.java b/src/com/android/settings/deviceinfo/storage/SecondaryUserController.java
index c78d108..f6a989f 100644
--- a/src/com/android/settings/deviceinfo/storage/SecondaryUserController.java
+++ b/src/com/android/settings/deviceinfo/storage/SecondaryUserController.java
@@ -20,6 +20,7 @@
import android.content.pm.UserInfo;
import android.graphics.drawable.Drawable;
import android.os.UserManager;
+import android.util.FeatureFlagUtils;
import android.util.SparseArray;
import androidx.annotation.NonNull;
@@ -29,6 +30,7 @@
import androidx.preference.PreferenceScreen;
import com.android.settings.Utils;
+import com.android.settings.core.FeatureFlags;
import com.android.settings.core.PreferenceControllerMixin;
import com.android.settings.deviceinfo.StorageItemPreference;
import com.android.settingslib.core.AbstractPreferenceController;
@@ -66,7 +68,12 @@
*/
public static List<AbstractPreferenceController> getSecondaryUserControllers(
Context context, UserManager userManager) {
+
List<AbstractPreferenceController> controllers = new ArrayList<>();
+ if (FeatureFlagUtils.isEnabled(context, FeatureFlags.PERSONAL_WORK_PROFILE)) {
+ controllers.add(new NoSecondaryUserController(context));
+ return controllers;
+ }
UserInfo primaryUser = userManager.getPrimaryUser();
boolean addedUser = false;
List<UserInfo> infos = userManager.getUsers();
diff --git a/src/com/android/settings/deviceinfo/storage/StorageItemPreferenceController.java b/src/com/android/settings/deviceinfo/storage/StorageItemPreferenceController.java
index 525a887..31898d1 100644
--- a/src/com/android/settings/deviceinfo/storage/StorageItemPreferenceController.java
+++ b/src/com/android/settings/deviceinfo/storage/StorageItemPreferenceController.java
@@ -26,6 +26,7 @@
import android.os.Bundle;
import android.os.UserHandle;
import android.os.storage.VolumeInfo;
+import android.util.FeatureFlagUtils;
import android.util.Log;
import android.util.SparseArray;
@@ -37,6 +38,7 @@
import com.android.settings.R;
import com.android.settings.Settings;
import com.android.settings.applications.manageapplications.ManageApplications;
+import com.android.settings.core.FeatureFlags;
import com.android.settings.core.PreferenceControllerMixin;
import com.android.settings.core.SubSettingLauncher;
import com.android.settings.deviceinfo.PrivateVolumeSettings.SystemInfoFragment;
@@ -389,10 +391,18 @@
}
private Bundle getWorkAnnotatedBundle(int additionalCapacity) {
- final Bundle args = new Bundle(2 + additionalCapacity);
- args.putBoolean(ManageApplications.EXTRA_WORK_ONLY, mIsWorkProfile);
- args.putInt(ManageApplications.EXTRA_WORK_ID, mUserId);
- return args;
+ if (FeatureFlagUtils.isEnabled(mContext, FeatureFlags.PERSONAL_WORK_PROFILE)) {
+ final Bundle args = new Bundle(3 + additionalCapacity);
+ args.putBoolean(ManageApplications.EXTRA_WORK_ONLY, mIsWorkProfile);
+ args.putInt(ManageApplications.EXTRA_WORK_ID, mUserId);
+ args.putBoolean(ManageApplications.EXTRA_PERSONAL_ONLY, !mIsWorkProfile);
+ return args;
+ } else {
+ final Bundle args = new Bundle(2 + additionalCapacity);
+ args.putBoolean(ManageApplications.EXTRA_WORK_ONLY, mIsWorkProfile);
+ args.putInt(ManageApplications.EXTRA_WORK_ID, mUserId);
+ return args;
+ }
}
private Intent getFilesIntent() {
diff --git a/src/com/android/settings/homepage/contextualcards/ContextualCardManager.java b/src/com/android/settings/homepage/contextualcards/ContextualCardManager.java
index a941fdb..60a63ec 100644
--- a/src/com/android/settings/homepage/contextualcards/ContextualCardManager.java
+++ b/src/com/android/settings/homepage/contextualcards/ContextualCardManager.java
@@ -37,6 +37,7 @@
import androidx.loader.app.LoaderManager;
import androidx.loader.content.Loader;
+import com.android.settings.R;
import com.android.settings.homepage.contextualcards.conditional.ConditionalCardController;
import com.android.settings.homepage.contextualcards.logging.ContextualCardLogUtils;
import com.android.settings.homepage.contextualcards.slices.SliceContextualCardRenderer;
@@ -119,6 +120,10 @@
}
void loadContextualCards(LoaderManager loaderManager) {
+ if (mContext.getResources().getBoolean(R.bool.config_use_legacy_suggestion)) {
+ Log.w(TAG, "Legacy suggestion contextual card enabled, skipping contextual cards.");
+ return;
+ }
mStartTime = System.currentTimeMillis();
final CardContentLoaderCallbacks cardContentLoaderCallbacks =
new CardContentLoaderCallbacks(mContext);
diff --git a/src/com/android/settings/network/telephony/CallingPreferenceCategoryController.java b/src/com/android/settings/network/telephony/CallingPreferenceCategoryController.java
new file mode 100644
index 0000000..f836415
--- /dev/null
+++ b/src/com/android/settings/network/telephony/CallingPreferenceCategoryController.java
@@ -0,0 +1,31 @@
+/*
+ * Copyright (C) 2019 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.settings.network.telephony;
+
+import android.content.Context;
+
+import com.android.settings.widget.PreferenceCategoryController;
+
+/**
+ * Preference controller for "Calling" category
+ */
+public class CallingPreferenceCategoryController extends PreferenceCategoryController {
+
+ public CallingPreferenceCategoryController(Context context, String key) {
+ super(context, key);
+ }
+}
diff --git a/src/com/android/settings/network/telephony/MobileNetworkSettings.java b/src/com/android/settings/network/telephony/MobileNetworkSettings.java
index 6b5d720..a5bf313 100644
--- a/src/com/android/settings/network/telephony/MobileNetworkSettings.java
+++ b/src/com/android/settings/network/telephony/MobileNetworkSettings.java
@@ -154,7 +154,8 @@
if (!FeatureFlagPersistent.isEnabled(getContext(), FeatureFlags.NETWORK_INTERNET_V2)) {
use(EuiccPreferenceController.class).init(mSubId);
}
- use(WifiCallingPreferenceController.class).init(mSubId);
+ final WifiCallingPreferenceController wifiCallingPreferenceController =
+ use(WifiCallingPreferenceController.class).init(mSubId);
final OpenNetworkSelectPagePreferenceController openNetworkSelectPagePreferenceController =
use(OpenNetworkSelectPagePreferenceController.class).init(mSubId);
@@ -172,6 +173,8 @@
final VideoCallingPreferenceController videoCallingPreferenceController =
use(VideoCallingPreferenceController.class).init(mSubId);
+ use(CallingPreferenceCategoryController.class).setChildren(
+ Arrays.asList(wifiCallingPreferenceController, videoCallingPreferenceController));
use(Enhanced4gLtePreferenceController.class).init(mSubId)
.addListener(videoCallingPreferenceController);
use(Enhanced4gCallingPreferenceController.class).init(mSubId)
diff --git a/src/com/android/settings/network/telephony/VideoCallingPreferenceController.java b/src/com/android/settings/network/telephony/VideoCallingPreferenceController.java
index a16dc24..7f7a821 100644
--- a/src/com/android/settings/network/telephony/VideoCallingPreferenceController.java
+++ b/src/com/android/settings/network/telephony/VideoCallingPreferenceController.java
@@ -63,7 +63,6 @@
@Override
public int getAvailabilityStatus(int subId) {
return subId != SubscriptionManager.INVALID_SUBSCRIPTION_ID
- && MobileNetworkUtils.isWifiCallingEnabled(mContext, subId)
&& isVideoCallEnabled(subId)
? AVAILABLE
: CONDITIONALLY_UNAVAILABLE;
diff --git a/src/com/android/settings/network/telephony/WifiCallingPreferenceController.java b/src/com/android/settings/network/telephony/WifiCallingPreferenceController.java
index 5998483..8f8d0d0 100644
--- a/src/com/android/settings/network/telephony/WifiCallingPreferenceController.java
+++ b/src/com/android/settings/network/telephony/WifiCallingPreferenceController.java
@@ -49,9 +49,6 @@
public class WifiCallingPreferenceController extends TelephonyBasePreferenceController implements
LifecycleObserver, OnStart, OnStop {
- @VisibleForTesting
- static final String KEY_PREFERENCE_CATEGORY = "calling_category";
-
private TelephonyManager mTelephonyManager;
@VisibleForTesting
CarrierConfigManager mCarrierConfigManager;
@@ -95,13 +92,6 @@
if (intent != null) {
intent.putExtra(Settings.EXTRA_SUB_ID, mSubId);
}
- if (!isAvailable()) {
- // Set category as invisible
- final Preference preferenceCateogry = screen.findPreference(KEY_PREFERENCE_CATEGORY);
- if (preferenceCateogry != null) {
- preferenceCateogry.setVisible(false);
- }
- }
}
@Override
@@ -158,12 +148,14 @@
mTelephonyManager.getCallState(mSubId) == TelephonyManager.CALL_STATE_IDLE);
}
- public void init(int subId) {
+ public WifiCallingPreferenceController init(int subId) {
mSubId = subId;
mTelephonyManager = TelephonyManager.from(mContext).createForSubscriptionId(mSubId);
mImsManager = ImsManager.getInstance(mContext, SubscriptionManager.getPhoneId(mSubId));
mSimCallManager = mContext.getSystemService(TelecomManager.class)
.getSimCallManagerForSubscription(mSubId);
+
+ return this;
}
private class PhoneCallStateListener extends PhoneStateListener {
diff --git a/src/com/android/settings/notification/RemoteVolumePreferenceController.java b/src/com/android/settings/notification/RemoteVolumePreferenceController.java
index 816d80f..802d75f 100644
--- a/src/com/android/settings/notification/RemoteVolumePreferenceController.java
+++ b/src/com/android/settings/notification/RemoteVolumePreferenceController.java
@@ -23,6 +23,7 @@
import android.net.Uri;
import android.os.Looper;
import android.text.TextUtils;
+import android.util.Log;
import androidx.annotation.VisibleForTesting;
import androidx.lifecycle.OnLifecycleEvent;
@@ -40,6 +41,7 @@
public class RemoteVolumePreferenceController extends VolumeSeekBarPreferenceController {
private static final String KEY_REMOTE_VOLUME = "remote_volume";
+ private static final String TAG = "RemoteVolumePrefCtr";
@VisibleForTesting
static final int REMOTE_VOLUME = 100;
@@ -75,10 +77,20 @@
@Override
public void onRemoteVolumeChanged(MediaSession.Token token, int flags) {
if (Objects.equals(mActiveToken, token)) {
- final MediaController.PlaybackInfo pi = mMediaController.getPlaybackInfo();
- if (pi != null) {
- setSliderPosition(pi.getCurrentVolume());
+ if (mPreference == null) {
+ Log.e(TAG,"Preference is null");
+ return;
}
+ if (mMediaController == null) {
+ Log.e(TAG,"MediaController is null");
+ return;
+ }
+ final MediaController.PlaybackInfo pi = mMediaController.getPlaybackInfo();
+ if (pi == null) {
+ Log.e(TAG,"PlaybackInfo is null");
+ return;
+ }
+ mPreference.setProgress(pi.getCurrentVolume());
}
}
};
diff --git a/src/com/android/settings/panel/PanelFeatureProvider.java b/src/com/android/settings/panel/PanelFeatureProvider.java
index 85e098d..402a562 100644
--- a/src/com/android/settings/panel/PanelFeatureProvider.java
+++ b/src/com/android/settings/panel/PanelFeatureProvider.java
@@ -17,12 +17,12 @@
package com.android.settings.panel;
import android.content.Context;
+import android.os.Bundle;
public interface PanelFeatureProvider {
/**
- * Returns {@link PanelContent} as specified by the {@param panelType}, and
- * {@param mediaPackageName}.
+ * Returns {@link PanelContent} as specified by the {@param bundle}
*/
- PanelContent getPanel(Context context, String panelType, String mediaPackageName);
+ PanelContent getPanel(Context context, Bundle bundle);
}
diff --git a/src/com/android/settings/panel/PanelFeatureProviderImpl.java b/src/com/android/settings/panel/PanelFeatureProviderImpl.java
index e6b0a23..04d3095 100644
--- a/src/com/android/settings/panel/PanelFeatureProviderImpl.java
+++ b/src/com/android/settings/panel/PanelFeatureProviderImpl.java
@@ -19,16 +19,22 @@
import static com.android.settingslib.media.MediaOutputSliceConstants.ACTION_MEDIA_OUTPUT;
import android.content.Context;
+import android.os.Bundle;
import android.provider.Settings;
public class PanelFeatureProviderImpl implements PanelFeatureProvider {
@Override
- public PanelContent getPanel(Context context, String panelType, String mediaPackageName) {
+ public PanelContent getPanel(Context context, Bundle bundle) {
if (context == null) {
return null;
}
+ final String panelType =
+ bundle.getString(SettingsPanelActivity.KEY_PANEL_TYPE_ARGUMENT);
+ final String mediaPackageName =
+ bundle.getString(SettingsPanelActivity.KEY_MEDIA_PACKAGE_NAME);
+
switch (panelType) {
case Settings.Panel.ACTION_INTERNET_CONNECTIVITY:
return InternetConnectivityPanel.create(context);
diff --git a/src/com/android/settings/panel/PanelFragment.java b/src/com/android/settings/panel/PanelFragment.java
index 006ed00..0eda36f 100644
--- a/src/com/android/settings/panel/PanelFragment.java
+++ b/src/com/android/settings/panel/PanelFragment.java
@@ -161,17 +161,12 @@
mPanelSlices.setVisibility(View.GONE);
final Bundle arguments = getArguments();
- final String panelType =
- arguments.getString(SettingsPanelActivity.KEY_PANEL_TYPE_ARGUMENT);
final String callingPackageName =
arguments.getString(SettingsPanelActivity.KEY_CALLING_PACKAGE_NAME);
- final String mediaPackageName =
- arguments.getString(SettingsPanelActivity.KEY_MEDIA_PACKAGE_NAME);
- // TODO (b/124399577) transform interface to take a context and bundle.
mPanel = FeatureFactory.getFactory(activity)
.getPanelFeatureProvider()
- .getPanel(activity, panelType, mediaPackageName);
+ .getPanel(activity, arguments);
if (mPanel == null) {
activity.finish();
diff --git a/src/com/android/settings/password/ChooseLockGeneric.java b/src/com/android/settings/password/ChooseLockGeneric.java
index 4f1b050..6809f35 100644
--- a/src/com/android/settings/password/ChooseLockGeneric.java
+++ b/src/com/android/settings/password/ChooseLockGeneric.java
@@ -36,12 +36,8 @@
import android.app.settings.SettingsEnums;
import android.content.Context;
import android.content.Intent;
-import android.content.pm.UserInfo;
-import android.hardware.face.Face;
import android.hardware.face.FaceManager;
-import android.hardware.fingerprint.Fingerprint;
import android.hardware.fingerprint.FingerprintManager;
-import android.hardware.fingerprint.FingerprintManager.RemovalCallback;
import android.os.Bundle;
import android.os.UserHandle;
import android.os.UserManager;
@@ -76,7 +72,7 @@
import com.android.settingslib.RestrictedLockUtilsInternal;
import com.android.settingslib.RestrictedPreference;
-import java.util.List;
+import com.google.android.setupcompat.util.WizardManagerHelper;
public class ChooseLockGeneric extends SettingsActivity {
public static final String CONFIRM_CREDENTIALS = "confirm_credentials";
@@ -188,7 +184,8 @@
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
final Activity activity = getActivity();
- if (!Utils.isDeviceProvisioned(activity) && !canRunBeforeDeviceProvisioned()) {
+ if (!WizardManagerHelper.isDeviceProvisioned(activity)
+ && !canRunBeforeDeviceProvisioned()) {
Log.i(TAG, "Refusing to start because device is not provisioned");
activity.finish();
return;
@@ -760,8 +757,12 @@
if (quality == DevicePolicyManager.PASSWORD_QUALITY_UNSPECIFIED) {
// Clearing of user biometrics when screen lock is cleared is done at
// LockSettingsService.removeBiometricsForUser().
- mChooseLockSettingsHelper.utils().setLockCredential(
- LockscreenCredential.createNone(), mUserPassword, mUserId);
+ if (mUserPassword != null) {
+ // No need to call setLockCredential if the user currently doesn't
+ // have a password
+ mChooseLockSettingsHelper.utils().setLockCredential(
+ LockscreenCredential.createNone(), mUserPassword, mUserId);
+ }
mChooseLockSettingsHelper.utils().setLockScreenDisabled(disabled, mUserId);
getActivity().setResult(Activity.RESULT_OK);
finish();
diff --git a/src/com/android/settings/password/ChooseLockGenericController.java b/src/com/android/settings/password/ChooseLockGenericController.java
index 62a0063..1bfdac9 100644
--- a/src/com/android/settings/password/ChooseLockGenericController.java
+++ b/src/com/android/settings/password/ChooseLockGenericController.java
@@ -92,6 +92,7 @@
*/
public int upgradeQuality(int quality) {
// Compare specified quality and dpm quality
+ // TODO(b/142781408): convert from quality to credential type once PIN is supported.
int dpmUpgradedQuality = Math.max(quality, mDpm.getPasswordQuality(null, mUserId));
return Math.max(dpmUpgradedQuality,
PasswordMetrics.complexityLevelToMinQuality(mRequestedMinComplexity));
diff --git a/src/com/android/settings/password/ChooseLockPassword.java b/src/com/android/settings/password/ChooseLockPassword.java
index 6872543..ff94d8b 100644
--- a/src/com/android/settings/password/ChooseLockPassword.java
+++ b/src/com/android/settings/password/ChooseLockPassword.java
@@ -17,12 +17,20 @@
package com.android.settings.password;
import static android.app.admin.DevicePolicyManager.PASSWORD_COMPLEXITY_NONE;
-import static android.app.admin.DevicePolicyManager.PASSWORD_QUALITY_ALPHABETIC;
-import static android.app.admin.DevicePolicyManager.PASSWORD_QUALITY_ALPHANUMERIC;
-import static android.app.admin.DevicePolicyManager.PASSWORD_QUALITY_COMPLEX;
import static android.app.admin.DevicePolicyManager.PASSWORD_QUALITY_NUMERIC;
-import static android.app.admin.DevicePolicyManager.PASSWORD_QUALITY_NUMERIC_COMPLEX;
+import static com.android.internal.widget.PasswordValidationError.CONTAINS_INVALID_CHARACTERS;
+import static com.android.internal.widget.PasswordValidationError.CONTAINS_SEQUENCE;
+import static com.android.internal.widget.PasswordValidationError.NOT_ENOUGH_DIGITS;
+import static com.android.internal.widget.PasswordValidationError.NOT_ENOUGH_LETTERS;
+import static com.android.internal.widget.PasswordValidationError.NOT_ENOUGH_LOWER_CASE;
+import static com.android.internal.widget.PasswordValidationError.NOT_ENOUGH_NON_DIGITS;
+import static com.android.internal.widget.PasswordValidationError.NOT_ENOUGH_NON_LETTER;
+import static com.android.internal.widget.PasswordValidationError.NOT_ENOUGH_SYMBOLS;
+import static com.android.internal.widget.PasswordValidationError.NOT_ENOUGH_UPPER_CASE;
+import static com.android.internal.widget.PasswordValidationError.RECENTLY_USED;
+import static com.android.internal.widget.PasswordValidationError.TOO_LONG;
+import static com.android.internal.widget.PasswordValidationError.TOO_SHORT;
import static com.android.settings.password.ChooseLockSettingsHelper.EXTRA_KEY_REQUESTED_MIN_COMPLEXITY;
import android.app.Activity;
@@ -51,7 +59,6 @@
import android.view.View;
import android.view.ViewGroup;
import android.view.inputmethod.EditorInfo;
-import android.widget.LinearLayout;
import android.widget.TextView;
import android.widget.TextView.OnEditorActionListener;
@@ -64,6 +71,7 @@
import com.android.internal.widget.LockPatternUtils;
import com.android.internal.widget.LockPatternUtils.RequestThrottledException;
import com.android.internal.widget.LockscreenCredential;
+import com.android.internal.widget.PasswordValidationError;
import com.android.internal.widget.TextViewInputDisabler;
import com.android.settings.EncryptionInterstitial;
import com.android.settings.R;
@@ -79,7 +87,7 @@
import com.google.android.setupdesign.GlifLayout;
import java.util.ArrayList;
-import java.util.Arrays;
+import java.util.Collections;
import java.util.List;
public class ChooseLockPassword extends SettingsActivity {
@@ -192,17 +200,12 @@
private long mChallenge;
private ImeAwareEditText mPasswordEntry;
private TextViewInputDisabler mPasswordEntryInputDisabler;
- private int mPasswordMinLength = LockPatternUtils.MIN_LOCK_PASSWORD_SIZE;
- private int mPasswordMaxLength = 16;
- private int mPasswordMinLetters = 0;
- private int mPasswordMinUpperCase = 0;
- private int mPasswordMinLowerCase = 0;
- private int mPasswordMinSymbols = 0;
- private int mPasswordMinNumeric = 0;
- private int mPasswordMinNonLetter = 0;
- private int mPasswordMinLengthToFulfillAllPolicies = 0;
- private boolean mPasswordNumSequenceAllowed = true;
- @PasswordComplexity private int mRequestedMinComplexity = PASSWORD_COMPLEXITY_NONE;
+
+ // Minimum password metrics enforced by admins.
+ private PasswordMetrics mMinMetrics;
+ private List<PasswordValidationError> mValidationErrors;
+
+ @PasswordComplexity private int mMinComplexity = PASSWORD_COMPLEXITY_NONE;
protected int mUserId;
private byte[] mPasswordHistoryHashFactor;
@@ -228,28 +231,6 @@
private static final int CONFIRM_EXISTING_REQUEST = 58;
static final int RESULT_FINISHED = RESULT_FIRST_USER;
- private static final int MIN_LETTER_IN_PASSWORD = 0;
- private static final int MIN_UPPER_LETTERS_IN_PASSWORD = 1;
- private static final int MIN_LOWER_LETTERS_IN_PASSWORD = 2;
- private static final int MIN_SYMBOLS_IN_PASSWORD = 3;
- private static final int MIN_NUMBER_IN_PASSWORD = 4;
- private static final int MIN_NON_LETTER_IN_PASSWORD = 5;
-
- // Error code returned from {@link #validatePassword(byte[])}.
- static final int NO_ERROR = 0;
- static final int CONTAIN_INVALID_CHARACTERS = 1 << 0;
- static final int TOO_SHORT = 1 << 1;
- static final int TOO_LONG = 1 << 2;
- static final int CONTAIN_NON_DIGITS = 1 << 3;
- static final int CONTAIN_SEQUENTIAL_DIGITS = 1 << 4;
- static final int RECENTLY_USED = 1 << 5;
- static final int NOT_ENOUGH_LETTER = 1 << 6;
- static final int NOT_ENOUGH_UPPER_CASE = 1 << 7;
- static final int NOT_ENOUGH_LOWER_CASE = 1 << 8;
- static final int NOT_ENOUGH_DIGITS = 1 << 9;
- static final int NOT_ENOUGH_SYMBOLS = 1 << 10;
- static final int NOT_ENOUGH_NON_LETTER = 1 << 11;
-
/**
* Keep track internally of where the user is in choosing a pattern.
*/
@@ -381,13 +362,13 @@
mForFingerprint = intent.getBooleanExtra(
ChooseLockSettingsHelper.EXTRA_KEY_FOR_FINGERPRINT, false);
mForFace = intent.getBooleanExtra(ChooseLockSettingsHelper.EXTRA_KEY_FOR_FACE, false);
- mRequestedMinComplexity = intent.getIntExtra(
+ mMinComplexity = intent.getIntExtra(
EXTRA_KEY_REQUESTED_MIN_COMPLEXITY, PASSWORD_COMPLEXITY_NONE);
- mRequestedQuality = Math.max(
- intent.getIntExtra(LockPatternUtils.PASSWORD_TYPE_KEY, mRequestedQuality),
- mLockPatternUtils.getRequestedPasswordQuality(mUserId));
- loadDpmPasswordRequirements();
+ mRequestedQuality = intent.getIntExtra(
+ LockPatternUtils.PASSWORD_TYPE_KEY, PASSWORD_QUALITY_NUMERIC);
+
+ mMinMetrics = mLockPatternUtils.getRequestedPasswordMetrics(mUserId);
mChooseLockSettingsHelper = new ChooseLockSettingsHelper(getActivity());
if (intent.getBooleanExtra(
@@ -602,209 +583,23 @@
}
/**
- * Read the requirements from {@link DevicePolicyManager} and intent and aggregate them.
- */
- private void loadDpmPasswordRequirements() {
- final int dpmPasswordQuality = mLockPatternUtils.getRequestedPasswordQuality(mUserId);
- if (dpmPasswordQuality == PASSWORD_QUALITY_NUMERIC_COMPLEX) {
- mPasswordNumSequenceAllowed = false;
- }
- mPasswordMinLength = Math.max(LockPatternUtils.MIN_LOCK_PASSWORD_SIZE,
- mLockPatternUtils.getRequestedMinimumPasswordLength(mUserId));
- mPasswordMaxLength = mLockPatternUtils.getMaximumPasswordLength(mRequestedQuality);
- mPasswordMinLetters = mLockPatternUtils.getRequestedPasswordMinimumLetters(mUserId);
- mPasswordMinUpperCase = mLockPatternUtils.getRequestedPasswordMinimumUpperCase(mUserId);
- mPasswordMinLowerCase = mLockPatternUtils.getRequestedPasswordMinimumLowerCase(mUserId);
- mPasswordMinNumeric = mLockPatternUtils.getRequestedPasswordMinimumNumeric(mUserId);
- mPasswordMinSymbols = mLockPatternUtils.getRequestedPasswordMinimumSymbols(mUserId);
- mPasswordMinNonLetter = mLockPatternUtils.getRequestedPasswordMinimumNonLetter(mUserId);
-
- // Modify the value based on dpm policy
- switch (dpmPasswordQuality) {
- case PASSWORD_QUALITY_ALPHABETIC:
- if (mPasswordMinLetters == 0) {
- mPasswordMinLetters = 1;
- }
- break;
- case PASSWORD_QUALITY_ALPHANUMERIC:
- if (mPasswordMinLetters == 0) {
- mPasswordMinLetters = 1;
- }
- if (mPasswordMinNumeric == 0) {
- mPasswordMinNumeric = 1;
- }
- break;
- case PASSWORD_QUALITY_COMPLEX:
- // Reserve all the requirements.
- break;
- default:
- mPasswordMinNumeric = 0;
- mPasswordMinLetters = 0;
- mPasswordMinUpperCase = 0;
- mPasswordMinLowerCase = 0;
- mPasswordMinSymbols = 0;
- mPasswordMinNonLetter = 0;
- }
-
- mPasswordMinLengthToFulfillAllPolicies = getMinLengthToFulfillAllPolicies();
- }
-
- /**
- * Merges the dpm requirements and the min complexity requirements.
+ * Validates PIN/Password and returns the validation result and updates mValidationErrors
+ * and mPasswordReused to reflect validation results.
*
- * <p>Since there are more than one set of metrics to meet the min complexity requirement,
- * and we are not hard-coding any one of them to be the requirements the user must fulfil,
- * we are taking what the user has already entered into account when compiling the list of
- * requirements from min complexity. Then we merge this list with the DPM requirements, and
- * present the merged set as validation results to the user on the UI.
- *
- * <p>For example, suppose min complexity requires either ALPHABETIC(8+), or
- * ALPHANUMERIC(6+). If the user has entered "a", the length requirement displayed on the UI
- * would be 8. Then the user appends "1" to make it "a1". We now know the user is entering
- * an alphanumeric password so we would update the min complexity required min length to 6.
- * This might result in a little confusion for the user but the UI does not support showing
- * multiple sets of requirements / validation results as options to users, this is the best
- * we can do now.
- */
- private void mergeMinComplexityAndDpmRequirements(int userEnteredPasswordQuality) {
- if (mRequestedMinComplexity == PASSWORD_COMPLEXITY_NONE) {
- // dpm requirements are dominant if min complexity is none
- return;
- }
-
- // reset dpm requirements
- loadDpmPasswordRequirements();
-
- PasswordMetrics minMetrics = PasswordMetrics.getMinimumMetrics(
- mRequestedMinComplexity, userEnteredPasswordQuality, mRequestedQuality,
- requiresNumeric(), requiresLettersOrSymbols());
- mPasswordNumSequenceAllowed = mPasswordNumSequenceAllowed
- && minMetrics.quality != PASSWORD_QUALITY_NUMERIC_COMPLEX;
- mPasswordMinLength = Math.max(mPasswordMinLength, minMetrics.length);
- mPasswordMinLetters = Math.max(mPasswordMinLetters, minMetrics.letters);
- mPasswordMinUpperCase = Math.max(mPasswordMinUpperCase, minMetrics.upperCase);
- mPasswordMinLowerCase = Math.max(mPasswordMinLowerCase, minMetrics.lowerCase);
- mPasswordMinNumeric = Math.max(mPasswordMinNumeric, minMetrics.numeric);
- mPasswordMinSymbols = Math.max(mPasswordMinSymbols, minMetrics.symbols);
- mPasswordMinNonLetter = Math.max(mPasswordMinNonLetter, minMetrics.nonLetter);
-
- if (minMetrics.quality == PASSWORD_QUALITY_ALPHABETIC) {
- if (!requiresLettersOrSymbols()) {
- mPasswordMinLetters = 1;
- }
- }
- if (minMetrics.quality == PASSWORD_QUALITY_ALPHANUMERIC) {
- if (!requiresLettersOrSymbols()) {
- mPasswordMinLetters = 1;
- }
- if (!requiresNumeric()) {
- mPasswordMinNumeric = 1;
- }
- }
-
- mPasswordMinLengthToFulfillAllPolicies = getMinLengthToFulfillAllPolicies();
- }
-
- private boolean requiresLettersOrSymbols() {
- // This is the condition for the password to be considered ALPHABETIC according to
- // PasswordMetrics.computeForPassword()
- return mPasswordMinLetters + mPasswordMinUpperCase
- + mPasswordMinLowerCase + mPasswordMinSymbols + mPasswordMinNonLetter > 0;
- }
-
- private boolean requiresNumeric() {
- return mPasswordMinNumeric > 0;
- }
-
- /**
- * Validates PIN/Password and returns the validation result.
- *
- * @param password the raw password the user typed in
- * @return the validation result.
+ * @param credential credential the user typed in.
+ * @return whether password satisfies all the requirements.
*/
@VisibleForTesting
- int validatePassword(LockscreenCredential credential) {
+ boolean validatePassword(LockscreenCredential credential) {
final byte[] password = credential.getCredential();
- int errorCode = NO_ERROR;
- final PasswordMetrics metrics = PasswordMetrics.computeForPassword(password);
- mergeMinComplexityAndDpmRequirements(metrics.quality);
-
- if (password == null || password.length < mPasswordMinLength) {
- if (mPasswordMinLength > mPasswordMinLengthToFulfillAllPolicies) {
- errorCode |= TOO_SHORT;
- }
- } else if (password.length > mPasswordMaxLength) {
- errorCode |= TOO_LONG;
- } else {
- // The length requirements are fulfilled.
- if (!mPasswordNumSequenceAllowed
- && !requiresLettersOrSymbols()
- && metrics.numeric == password.length) {
- // Check for repeated characters or sequences (e.g. '1234', '0000', '2468')
- // if DevicePolicyManager or min password complexity requires a complex numeric
- // password. There can be two cases in the UI: 1. User chooses to enroll a
- // PIN, 2. User chooses to enroll a password but enters a numeric-only pin. We
- // should carry out the sequence check in both cases.
- //
- // Conditions for the !requiresLettersOrSymbols() to be necessary:
- // - DPM requires NUMERIC_COMPLEX
- // - min complexity not NONE, user picks PASSWORD type so ALPHABETIC or
- // ALPHANUMERIC is required
- // Imagine user has entered "12345678", if we don't skip the sequence check, the
- // validation result would show both "requires a letter" and "sequence not
- // allowed", while the only requirement the user needs to know is "requires a
- // letter" because once the user has fulfilled the alphabetic requirement, the
- // password would not be containing only digits so this check would not be
- // performed anyway.
- final int sequence = PasswordMetrics.maxLengthSequence(password);
- if (sequence > PasswordMetrics.MAX_ALLOWED_SEQUENCE) {
- errorCode |= CONTAIN_SEQUENTIAL_DIGITS;
- }
- }
- // Is the password recently used?
- if (mLockPatternUtils.checkPasswordHistory(password, getPasswordHistoryHashFactor(),
- mUserId)) {
- errorCode |= RECENTLY_USED;
- }
+ mValidationErrors = PasswordMetrics.validatePassword(
+ mMinMetrics, mMinComplexity, !mIsAlphaMode, password);
+ if (mValidationErrors.isEmpty() && mLockPatternUtils.checkPasswordHistory(
+ password, getPasswordHistoryHashFactor(), mUserId)) {
+ mValidationErrors =
+ Collections.singletonList(new PasswordValidationError(RECENTLY_USED));
}
-
- // Allow non-control Latin-1 characters only.
- for (int i = 0; i < password.length; i++) {
- char c = (char) password[i];
- if (c < 32 || c > 127) {
- errorCode |= CONTAIN_INVALID_CHARACTERS;
- break;
- }
- }
-
- // Ensure no non-digits if we are requesting numbers. This shouldn't be possible unless
- // user finds some way to bring up soft keyboard.
- if (mRequestedQuality == PASSWORD_QUALITY_NUMERIC
- || mRequestedQuality == PASSWORD_QUALITY_NUMERIC_COMPLEX) {
- if (metrics.letters > 0 || metrics.symbols > 0) {
- errorCode |= CONTAIN_NON_DIGITS;
- }
- }
-
- if (metrics.letters < mPasswordMinLetters) {
- errorCode |= NOT_ENOUGH_LETTER;
- }
- if (metrics.upperCase < mPasswordMinUpperCase) {
- errorCode |= NOT_ENOUGH_UPPER_CASE;
- }
- if (metrics.lowerCase < mPasswordMinLowerCase) {
- errorCode |= NOT_ENOUGH_LOWER_CASE;
- }
- if (metrics.symbols < mPasswordMinSymbols) {
- errorCode |= NOT_ENOUGH_SYMBOLS;
- }
- if (metrics.numeric < mPasswordMinNumeric) {
- errorCode |= NOT_ENOUGH_DIGITS;
- }
- if (metrics.nonLetter < mPasswordMinNonLetter) {
- errorCode |= NOT_ENOUGH_NON_LETTER;
- }
- return errorCode;
+ return mValidationErrors.isEmpty();
}
/**
@@ -830,7 +625,7 @@
mChosenPassword = mIsAlphaMode ? LockscreenCredential.createPassword(passwordText)
: LockscreenCredential.createPin(passwordText);
if (mUiStage == Stage.Introduction) {
- if (validatePassword(mChosenPassword) == NO_ERROR) {
+ if (validatePassword(mChosenPassword)) {
mFirstPassword = mChosenPassword;
mPasswordEntry.setText("");
updateStage(Stage.NeedToConfirm);
@@ -879,79 +674,79 @@
}
/**
- * @param errorCode error code returned from {@link #validatePassword(String)}.
+ * @param errorCode error code returned from password validation.
* @return an array of messages describing the error, important messages come first.
*/
- String[] convertErrorCodeToMessages(int errorCode) {
+ String[] convertErrorCodeToMessages() {
List<String> messages = new ArrayList<>();
- if ((errorCode & CONTAIN_INVALID_CHARACTERS) > 0) {
- messages.add(getString(R.string.lockpassword_illegal_character));
+ for (PasswordValidationError error : mValidationErrors) {
+ switch (error.errorCode) {
+ case CONTAINS_INVALID_CHARACTERS:
+ messages.add(getString(R.string.lockpassword_illegal_character));
+ break;
+ case NOT_ENOUGH_UPPER_CASE:
+ messages.add(getResources().getQuantityString(
+ R.plurals.lockpassword_password_requires_uppercase,
+ error.requirement, error.requirement));
+ break;
+ case NOT_ENOUGH_LOWER_CASE:
+ messages.add(getResources().getQuantityString(
+ R.plurals.lockpassword_password_requires_lowercase,
+ error.requirement, error.requirement));
+ break;
+ case NOT_ENOUGH_LETTERS:
+ messages.add(getResources().getQuantityString(
+ R.plurals.lockpassword_password_requires_letters,
+ error.requirement, error.requirement));
+ break;
+ case NOT_ENOUGH_DIGITS:
+ messages.add(getResources().getQuantityString(
+ R.plurals.lockpassword_password_requires_numeric,
+ error.requirement, error.requirement));
+ break;
+ case NOT_ENOUGH_SYMBOLS:
+ messages.add(getResources().getQuantityString(
+ R.plurals.lockpassword_password_requires_symbols,
+ error.requirement, error.requirement));
+ break;
+ case NOT_ENOUGH_NON_LETTER:
+ messages.add(getResources().getQuantityString(
+ R.plurals.lockpassword_password_requires_nonletter,
+ error.requirement, error.requirement));
+ break;
+ case NOT_ENOUGH_NON_DIGITS:
+ messages.add(getResources().getQuantityString(
+ R.plurals.lockpassword_password_requires_nonnumerical,
+ error.requirement, error.requirement));
+ break;
+ case TOO_SHORT:
+ messages.add(getResources().getQuantityString(
+ mIsAlphaMode
+ ? R.plurals.lockpassword_password_too_short
+ : R.plurals.lockpassword_pin_too_short,
+ error.requirement, error.requirement));
+ break;
+ case TOO_LONG:
+ messages.add(getResources().getQuantityString(
+ mIsAlphaMode
+ ? R.plurals.lockpassword_password_too_long
+ : R.plurals.lockpassword_pin_too_long,
+ error.requirement + 1, error.requirement + 1));
+ break;
+ case CONTAINS_SEQUENCE:
+ messages.add(getString(R.string.lockpassword_pin_no_sequential_digits));
+ break;
+ case RECENTLY_USED:
+ messages.add(getString(mIsAlphaMode
+ ? R.string.lockpassword_password_recently_used
+ : R.string.lockpassword_pin_recently_used));
+ break;
+ default:
+ Log.wtf(TAG, "unknown error validating password: " + error);
+ }
}
- if ((errorCode & CONTAIN_NON_DIGITS) > 0) {
- messages.add(getString(R.string.lockpassword_pin_contains_non_digits));
- }
- if ((errorCode & NOT_ENOUGH_UPPER_CASE) > 0) {
- messages.add(getResources().getQuantityString(
- R.plurals.lockpassword_password_requires_uppercase, mPasswordMinUpperCase,
- mPasswordMinUpperCase));
- }
- if ((errorCode & NOT_ENOUGH_LOWER_CASE) > 0) {
- messages.add(getResources().getQuantityString(
- R.plurals.lockpassword_password_requires_lowercase, mPasswordMinLowerCase,
- mPasswordMinLowerCase));
- }
- if ((errorCode & NOT_ENOUGH_LETTER) > 0) {
- messages.add(getResources().getQuantityString(
- R.plurals.lockpassword_password_requires_letters, mPasswordMinLetters,
- mPasswordMinLetters));
- }
- if ((errorCode & NOT_ENOUGH_DIGITS) > 0) {
- messages.add(getResources().getQuantityString(
- R.plurals.lockpassword_password_requires_numeric, mPasswordMinNumeric,
- mPasswordMinNumeric));
- }
- if ((errorCode & NOT_ENOUGH_SYMBOLS) > 0) {
- messages.add(getResources().getQuantityString(
- R.plurals.lockpassword_password_requires_symbols, mPasswordMinSymbols,
- mPasswordMinSymbols));
- }
- if ((errorCode & NOT_ENOUGH_NON_LETTER) > 0) {
- messages.add(getResources().getQuantityString(
- R.plurals.lockpassword_password_requires_nonletter, mPasswordMinNonLetter,
- mPasswordMinNonLetter));
- }
- if ((errorCode & TOO_SHORT) > 0) {
- messages.add(getResources().getQuantityString(
- mIsAlphaMode
- ? R.plurals.lockpassword_password_too_short
- : R.plurals.lockpassword_pin_too_short,
- mPasswordMinLength,
- mPasswordMinLength));
- }
- if ((errorCode & TOO_LONG) > 0) {
- messages.add(getResources().getQuantityString(
- mIsAlphaMode
- ? R.plurals.lockpassword_password_too_long
- : R.plurals.lockpassword_pin_too_long,
- mPasswordMaxLength + 1,
- mPasswordMaxLength + 1));
- }
- if ((errorCode & CONTAIN_SEQUENTIAL_DIGITS) > 0) {
- messages.add(getString(R.string.lockpassword_pin_no_sequential_digits));
- }
- if ((errorCode & RECENTLY_USED) > 0) {
- messages.add(getString((mIsAlphaMode) ? R.string.lockpassword_password_recently_used
- : R.string.lockpassword_pin_recently_used));
- }
- return messages.toArray(new String[0]);
- }
- private int getMinLengthToFulfillAllPolicies() {
- final int minLengthForLetters = Math.max(mPasswordMinLetters,
- mPasswordMinUpperCase + mPasswordMinLowerCase);
- final int minLengthForNonLetters = Math.max(mPasswordMinNonLetter,
- mPasswordMinSymbols + mPasswordMinNumeric);
- return minLengthForLetters + minLengthForNonLetters;
+ return messages.toArray(new String[0]);
}
/**
@@ -966,17 +761,17 @@
final int length = password.size();
if (mUiStage == Stage.Introduction) {
mPasswordRestrictionView.setVisibility(View.VISIBLE);
- final int errorCode = validatePassword(password);
- String[] messages = convertErrorCodeToMessages(errorCode);
+ final boolean passwordCompliant = validatePassword(password);
+ String[] messages = convertErrorCodeToMessages();
// Update the fulfillment of requirements.
mPasswordRequirementAdapter.setRequirements(messages);
// Enable/Disable the next button accordingly.
- setNextEnabled(errorCode == NO_ERROR);
+ setNextEnabled(passwordCompliant);
} else {
// Hide password requirement view when we are just asking user to confirm the pw.
mPasswordRestrictionView.setVisibility(View.GONE);
setHeaderText(getString(mUiStage.getHint(mIsAlphaMode, getStageType())));
- setNextEnabled(canInput && length >= mPasswordMinLength);
+ setNextEnabled(canInput && length >= LockPatternUtils.MIN_LOCK_PASSWORD_SIZE);
mSkipOrClearButton.setVisibility(toVisibility(canInput && length > 0));
}
int message = mUiStage.getMessage(mIsAlphaMode, getStageType());
diff --git a/src/com/android/settings/password/ConfirmDeviceCredentialActivity.java b/src/com/android/settings/password/ConfirmDeviceCredentialActivity.java
index 1da2a63..bf8c571 100644
--- a/src/com/android/settings/password/ConfirmDeviceCredentialActivity.java
+++ b/src/com/android/settings/password/ConfirmDeviceCredentialActivity.java
@@ -25,6 +25,7 @@
import android.app.trust.TrustManager;
import android.content.Context;
import android.content.Intent;
+import android.content.pm.PackageManager;
import android.hardware.biometrics.BiometricConstants;
import android.hardware.biometrics.BiometricManager;
import android.hardware.biometrics.BiometricPrompt;
@@ -52,6 +53,12 @@
public class ConfirmDeviceCredentialActivity extends FragmentActivity {
public static final String TAG = ConfirmDeviceCredentialActivity.class.getSimpleName();
+ /**
+ * If the intent is sent from {@link com.android.systemui.keyguard.WorkLockActivity} then
+ * check for device policy management flags.
+ */
+ public static final String EXTRA_FROM_WORK_LOCK_ACTIVITY = "from_work_lock_activity";
+
// The normal flow that apps go through
private static final int CREDENTIAL_NORMAL = 1;
// Unlocks the managed profile when the primary profile is unlocked
@@ -90,6 +97,8 @@
private TrustManager mTrustManager;
private ChooseLockSettingsHelper mChooseLockSettingsHelper;
private Handler mHandler = new Handler(Looper.getMainLooper());
+ private Context mContext;
+ private boolean mFromWorkLockActivity;
private String mTitle;
private String mDetails;
@@ -149,6 +158,8 @@
mLockPatternUtils = new LockPatternUtils(this);
Intent intent = getIntent();
+ mContext = this;
+ mFromWorkLockActivity = intent.getBooleanExtra(EXTRA_FROM_WORK_LOCK_ACTIVITY, false);
mTitle = intent.getStringExtra(KeyguardManager.EXTRA_TITLE);
mDetails = intent.getStringExtra(KeyguardManager.EXTRA_DESCRIPTION);
String alternateButton = intent.getStringExtra(
@@ -190,7 +201,7 @@
} else if (isManagedProfile && isInternalActivity()
&& !lockPatternUtils.isSeparateProfileChallengeEnabled(mUserId)) {
mCredentialMode = CREDENTIAL_MANAGED;
- if (isBiometricAllowed(effectiveUserId, mUserId)) {
+ if (mFromWorkLockActivity && isBiometricAllowed(effectiveUserId, mUserId)) {
showBiometricPrompt(bpBundle);
launchedBiometric = true;
} else {
@@ -256,10 +267,36 @@
|| !mUserManager.isUserUnlocked(mUserId);
}
+ /**
+ * TODO: Pass a list of disabled features to an internal BiometricPrompt API, so we can
+ * potentially show different modalities on multi-auth devices.
+ *
+ * @param effectiveUserId
+ * @return false if their exists one biometric on the device which is not disabled by the
+ * policy manager.
+ */
private boolean isBiometricDisabledByAdmin(int effectiveUserId) {
final int disabledFeatures =
- mDevicePolicyManager.getKeyguardDisabledFeatures(null, effectiveUserId);
- return (disabledFeatures & DevicePolicyManager.KEYGUARD_DISABLE_BIOMETRICS) != 0;
+ mDevicePolicyManager.getKeyguardDisabledFeatures(null, effectiveUserId);
+
+ final PackageManager pm = mContext.getPackageManager();
+ if (pm.hasSystemFeature(PackageManager.FEATURE_FINGERPRINT)
+ && (disabledFeatures & DevicePolicyManager.KEYGUARD_DISABLE_FINGERPRINT) == 0) {
+ Log.d(TAG,"Fingerprint enabled & allowed by device policy manager");
+ return false;
+ }
+ if (pm.hasSystemFeature(PackageManager.FEATURE_IRIS)
+ && (disabledFeatures & DevicePolicyManager.KEYGUARD_DISABLE_IRIS) == 0) {
+ Log.d(TAG,"Iris enabled & allowed by device policy manager");
+ return false;
+ }
+ if (pm.hasSystemFeature(PackageManager.FEATURE_FACE)
+ && (disabledFeatures & DevicePolicyManager.KEYGUARD_DISABLE_FACE) == 0) {
+ Log.d(TAG,"Face enabled & allowed by device policy manager");
+ return false;
+ }
+
+ return true;
}
private boolean isBiometricAllowed(int effectiveUserId, int realUserId) {
diff --git a/src/com/android/settings/password/SetNewPasswordActivity.java b/src/com/android/settings/password/SetNewPasswordActivity.java
index 055e5be..4bffbf5 100644
--- a/src/com/android/settings/password/SetNewPasswordActivity.java
+++ b/src/com/android/settings/password/SetNewPasswordActivity.java
@@ -32,16 +32,16 @@
import android.app.admin.PasswordMetrics;
import android.app.settings.SettingsEnums;
import android.content.ComponentName;
-import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.os.IBinder;
import android.util.Log;
-import com.android.settings.Utils;
import com.android.settings.overlay.FeatureFactory;
import com.android.settingslib.core.instrumentation.MetricsFeatureProvider;
+import com.google.android.setupcompat.util.WizardManagerHelper;
+
import java.util.List;
/**
@@ -110,7 +110,7 @@
@Override
public void launchChooseLock(Bundle chooseLockFingerprintExtras) {
- final boolean isInSetupWizard = !Utils.isDeviceProvisioned(this);
+ final boolean isInSetupWizard = !WizardManagerHelper.isDeviceProvisioned(this);
Intent intent = isInSetupWizard ? new Intent(this, SetupChooseLockGeneric.class)
: new Intent(this, ChooseLockGeneric.class);
intent.setAction(mNewPasswordAction);
diff --git a/src/com/android/settings/search/SearchFeatureProvider.java b/src/com/android/settings/search/SearchFeatureProvider.java
index 896f6e5..20d4e7c 100644
--- a/src/com/android/settings/search/SearchFeatureProvider.java
+++ b/src/com/android/settings/search/SearchFeatureProvider.java
@@ -34,6 +34,8 @@
import com.android.settings.overlay.FeatureFactory;
import com.android.settingslib.search.SearchIndexableResources;
+import com.google.android.setupcompat.util.WizardManagerHelper;
+
/**
* FeatureProvider for Settings Search
*/
@@ -67,8 +69,9 @@
return;
}
- if (!Utils.isDeviceProvisioned(activity) ||
- !Utils.isPackageEnabled(activity, getSettingsIntelligencePkgName(activity))) {
+ if (!WizardManagerHelper.isDeviceProvisioned(activity)
+ || !Utils.isPackageEnabled(activity, getSettingsIntelligencePkgName(activity))
+ || WizardManagerHelper.isAnySetupWizard(activity.getIntent())) {
final ViewGroup parent = (ViewGroup) toolbar.getParent();
if (parent != null) {
parent.setVisibility(View.GONE);
diff --git a/src/com/android/settings/search/SettingsSearchIndexablesProvider.java b/src/com/android/settings/search/SettingsSearchIndexablesProvider.java
index d3692b2..fab09fc 100644
--- a/src/com/android/settings/search/SettingsSearchIndexablesProvider.java
+++ b/src/com/android/settings/search/SettingsSearchIndexablesProvider.java
@@ -58,9 +58,11 @@
import android.util.ArraySet;
import android.util.Log;
+import androidx.annotation.Nullable;
import androidx.slice.SliceViewManager;
import com.android.settings.SettingsActivity;
+import com.android.settings.dashboard.DashboardFeatureProvider;
import com.android.settings.overlay.FeatureFactory;
import com.android.settings.slices.SettingsSliceProvider;
import com.android.settingslib.drawer.DashboardCategory;
@@ -118,6 +120,9 @@
return cursor;
}
+ /**
+ * Gets a Cursor of RawData. We use those data in search indexing time
+ */
@Override
public Cursor queryRawData(String[] projection) {
MatrixCursor cursor = new MatrixCursor(INDEXABLES_RAW_COLUMNS);
@@ -161,6 +166,38 @@
return cursor;
}
+ /**
+ * Gets a Cursor of dynamic Raw data similar to queryRawData. We use those data in search query
+ * time
+ */
+ @Nullable
+ @Override
+ public Cursor queryDynamicRawData(String[] projection) {
+ final Context context = getContext();
+ final DashboardFeatureProvider dashboardFeatureProvider =
+ FeatureFactory.getFactory(context).getDashboardFeatureProvider(context);
+
+ final MatrixCursor cursor = new MatrixCursor(INDEXABLES_RAW_COLUMNS);
+ for (DashboardCategory category : dashboardFeatureProvider.getAllCategories()) {
+ for (Tile tile : category.getTiles()) {
+ final String packageName = tile.getPackageName();
+ if (context.getPackageName().equals(packageName)) {
+ continue;
+ }
+ final Object[] ref = new Object[INDEXABLES_RAW_COLUMNS.length];
+ ref[COLUMN_INDEX_RAW_TITLE] = tile.getTitle(context);
+ ref[COLUMN_INDEX_RAW_SUMMARY_ON] = tile.getSummary(context);
+ ref[COLUMN_INDEX_RAW_SUMMARY_OFF] = tile.getSummary(context);
+ ref[COLUMN_INDEX_RAW_KEY] = dashboardFeatureProvider.getDashboardKeyForTile(
+ tile);
+ ref[COLUMN_INDEX_RAW_CLASS_NAME] = CATEGORY_KEY_TO_PARENT_MAP.get(
+ tile.getCategory());
+ cursor.addRow(ref);
+ }
+ }
+ return cursor;
+ }
+
@Override
public Cursor querySiteMapPairs() {
final MatrixCursor cursor = new MatrixCursor(SITE_MAP_COLUMNS);
diff --git a/src/com/android/settings/search/actionbar/SearchMenuController.java b/src/com/android/settings/search/actionbar/SearchMenuController.java
index 25d0d30..0243c09 100644
--- a/src/com/android/settings/search/actionbar/SearchMenuController.java
+++ b/src/com/android/settings/search/actionbar/SearchMenuController.java
@@ -17,8 +17,8 @@
package com.android.settings.search.actionbar;
import android.annotation.NonNull;
+import android.app.Activity;
import android.app.settings.SettingsEnums;
-import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.os.Bundle;
@@ -37,6 +37,8 @@
import com.android.settingslib.core.lifecycle.LifecycleObserver;
import com.android.settingslib.core.lifecycle.events.OnCreateOptionsMenu;
+import com.google.android.setupcompat.util.WizardManagerHelper;
+
public class SearchMenuController implements LifecycleObserver, OnCreateOptionsMenu {
public static final String NEED_SEARCH_ICON_IN_ACTION_BAR = "need_search_icon_in_action_bar";
@@ -61,13 +63,14 @@
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
- final Context context = mHost.getContext();
- final String SettingsIntelligencePkgName = context.getString(
+ final Activity activity = mHost.getActivity();
+ final String SettingsIntelligencePkgName = activity.getString(
R.string.config_settingsintelligence_package_name);
- if (!Utils.isDeviceProvisioned(mHost.getContext())) {
+ if (!WizardManagerHelper.isDeviceProvisioned(activity)
+ || WizardManagerHelper.isAnySetupWizard(activity.getIntent())) {
return;
}
- if (!Utils.isPackageEnabled(mHost.getContext(), SettingsIntelligencePkgName)) {
+ if (!Utils.isPackageEnabled(activity, SettingsIntelligencePkgName)) {
return;
}
if (menu == null) {
@@ -83,17 +86,17 @@
searchItem.setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS);
searchItem.setOnMenuItemClickListener(target -> {
- final Intent intent = FeatureFactory.getFactory(context)
+ final Intent intent = FeatureFactory.getFactory(activity)
.getSearchFeatureProvider()
- .buildSearchIntent(context, mPageId);
+ .buildSearchIntent(activity, mPageId);
- if (context.getPackageManager().queryIntentActivities(intent,
+ if (activity.getPackageManager().queryIntentActivities(intent,
PackageManager.MATCH_DEFAULT_ONLY).isEmpty()) {
return true;
}
- FeatureFactory.getFactory(context).getMetricsFeatureProvider()
- .action(context, SettingsEnums.ACTION_SEARCH_RESULTS);
+ FeatureFactory.getFactory(activity).getMetricsFeatureProvider()
+ .action(activity, SettingsEnums.ACTION_SEARCH_RESULTS);
mHost.startActivityForResult(intent, SearchFeatureProvider.REQUEST_CODE);
return true;
});
diff --git a/src/com/android/settings/security/EncryptionAndCredential.java b/src/com/android/settings/security/EncryptionAndCredential.java
index 3e88fa8..d873271 100644
--- a/src/com/android/settings/security/EncryptionAndCredential.java
+++ b/src/com/android/settings/security/EncryptionAndCredential.java
@@ -75,7 +75,7 @@
controllers.add(new CredentialStoragePreferenceController(context));
controllers.add(new UserCredentialsPreferenceController(context));
controllers.add(new ResetCredentialsPreferenceController(context, lifecycle));
- controllers.add(new InstallCredentialsPreferenceController(context));
+ controllers.add(new InstallCertificatePreferenceController(context));
return controllers;
}
diff --git a/src/com/android/settings/security/InstallCredentialsPreferenceController.java b/src/com/android/settings/security/InstallCaCertificatePreferenceController.java
similarity index 61%
copy from src/com/android/settings/security/InstallCredentialsPreferenceController.java
copy to src/com/android/settings/security/InstallCaCertificatePreferenceController.java
index ca9ed26..b2ded85 100644
--- a/src/com/android/settings/security/InstallCredentialsPreferenceController.java
+++ b/src/com/android/settings/security/InstallCaCertificatePreferenceController.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2017 The Android Open Source Project
+ * Copyright (C) 2019 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -19,17 +19,24 @@
import android.content.Context;
import android.os.UserManager;
-public class InstallCredentialsPreferenceController extends
- RestrictedEncryptionPreferenceController {
+import com.android.settings.core.BasePreferenceController;
- private static final String KEY_CREDENTIALS_INSTALL = "credentials_install";
+public class InstallCaCertificatePreferenceController extends
+ BasePreferenceController {
- public InstallCredentialsPreferenceController(Context context) {
+ private static final String KEY_INSTALL_CA_CERTIFICATE = "install_ca_certificate";
+
+ public InstallCaCertificatePreferenceController(Context context) {
super(context, UserManager.DISALLOW_CONFIG_CREDENTIALS);
}
@Override
+ public int getAvailabilityStatus() {
+ return AVAILABLE;
+ }
+
+ @Override
public String getPreferenceKey() {
- return KEY_CREDENTIALS_INSTALL;
+ return KEY_INSTALL_CA_CERTIFICATE;
}
}
diff --git a/src/com/android/settings/security/InstallCaCertificateWarning.java b/src/com/android/settings/security/InstallCaCertificateWarning.java
new file mode 100644
index 0000000..701d9f4
--- /dev/null
+++ b/src/com/android/settings/security/InstallCaCertificateWarning.java
@@ -0,0 +1,83 @@
+/*
+ * Copyright (C) 2019 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.settings.security;
+
+import android.annotation.Nullable;
+import android.app.Activity;
+import android.content.Intent;
+import android.os.Bundle;
+import android.security.Credentials;
+import android.view.View;
+import android.widget.Toast;
+
+import com.android.settings.R;
+
+import com.google.android.setupcompat.template.FooterBarMixin;
+import com.google.android.setupcompat.template.FooterButton;
+import com.google.android.setupdesign.GlifLayout;
+
+/**
+ * Creates a warning dialog explaining the consequences of installing a CA certificate
+ * This is displayed before a CA certificate can be installed from Settings.
+ */
+public class InstallCaCertificateWarning extends Activity {
+
+ @Override
+ public void onCreate(@Nullable Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+
+ setContentView(R.layout.ca_certificate_warning_dialog);
+ final GlifLayout layout = findViewById(R.id.setup_wizard_layout);
+
+ final FooterBarMixin mixin = layout.getMixin(FooterBarMixin.class);
+ mixin.setSecondaryButton(
+ new FooterButton.Builder(this)
+ .setText(R.string.ca_certificate_warning_install_anyway)
+ .setListener(installCaCertificate())
+ .setButtonType(FooterButton.ButtonType.OTHER)
+ .setTheme(R.style.SudGlifButton_Secondary)
+ .build()
+ );
+
+ mixin.setPrimaryButton(
+ new FooterButton.Builder(this)
+ .setText(R.string.ca_certificate_warning_dont_install)
+ .setListener(returnToInstallCertificateFromStorage())
+ .setButtonType(FooterButton.ButtonType.NEXT)
+ .setTheme(R.style.SudGlifButton_Primary)
+ .build()
+ );
+ }
+
+ private View.OnClickListener installCaCertificate() {
+ return v -> {
+ final Intent intent = new Intent();
+ intent.setAction(Credentials.INSTALL_ACTION);
+ intent.putExtra(Credentials.EXTRA_CERTIFICATE_USAGE, Credentials.CERTIFICATE_USAGE_CA);
+ startActivity(intent);
+ finish();
+ };
+ }
+
+ private View.OnClickListener returnToInstallCertificateFromStorage() {
+ return v -> {
+ Toast.makeText(this, R.string.cert_not_installed, Toast.LENGTH_SHORT).show();
+ finish();
+ };
+ }
+
+}
diff --git a/src/com/android/settings/security/InstallCertificateFromStorage.java b/src/com/android/settings/security/InstallCertificateFromStorage.java
new file mode 100644
index 0000000..90e68d4
--- /dev/null
+++ b/src/com/android/settings/security/InstallCertificateFromStorage.java
@@ -0,0 +1,93 @@
+/*
+ * Copyright (C) 2019 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.settings.security;
+
+import android.app.settings.SettingsEnums;
+import android.content.Context;
+import android.os.UserManager;
+
+import com.android.settings.R;
+import com.android.settings.dashboard.DashboardFragment;
+import com.android.settings.search.BaseSearchIndexProvider;
+import com.android.settingslib.core.AbstractPreferenceController;
+import com.android.settingslib.core.lifecycle.Lifecycle;
+import com.android.settingslib.search.SearchIndexable;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * Install certificate from storage settings.
+ */
+@SearchIndexable
+public class InstallCertificateFromStorage extends DashboardFragment {
+
+ private static final String TAG = "InstallCertificateFromStorage";
+
+ @Override
+ public int getMetricsCategory() {
+ return SettingsEnums.INSTALL_CERTIFICATE_FROM_STORAGE;
+ }
+
+ @Override
+ protected int getPreferenceScreenResId() {
+ return R.xml.install_certificate_from_storage;
+ }
+
+ @Override
+ protected String getLogTag() {
+ return TAG;
+ }
+
+ @Override
+ protected List<AbstractPreferenceController> createPreferenceControllers(Context context) {
+ return new ArrayList<AbstractPreferenceController>();
+ }
+
+ private static List<AbstractPreferenceController> buildPreferenceControllers(Context context,
+ Lifecycle lifecycle) {
+ final List<AbstractPreferenceController> controllers = new ArrayList<>();
+ controllers.add(new InstallCaCertificatePreferenceController(context));
+ controllers.add(new InstallUserCertificatePreferenceController(context));
+ controllers.add(new InstallWifiCertificatePreferenceController(context));
+ return controllers;
+ }
+
+ @Override
+ public int getHelpResource() {
+ return R.string.help_url_install_certificate;
+ }
+
+ /**
+ * For Search. Please keep it in sync when updating "createPreferenceHierarchy()"
+ */
+ public static final BaseSearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
+ new BaseSearchIndexProvider(R.xml.install_certificate_from_storage) {
+ @Override
+ public List<AbstractPreferenceController> createPreferenceControllers(
+ Context context) {
+ return buildPreferenceControllers(context, null /* lifecycle */);
+ }
+
+ @Override
+ protected boolean isPageSearchEnabled(Context context) {
+ final UserManager um = (UserManager) context.getSystemService(
+ Context.USER_SERVICE);
+ return um.isAdminUser();
+ }
+ };
+}
diff --git a/src/com/android/settings/security/InstallCredentialsPreferenceController.java b/src/com/android/settings/security/InstallCertificatePreferenceController.java
similarity index 78%
rename from src/com/android/settings/security/InstallCredentialsPreferenceController.java
rename to src/com/android/settings/security/InstallCertificatePreferenceController.java
index ca9ed26..2133069 100644
--- a/src/com/android/settings/security/InstallCredentialsPreferenceController.java
+++ b/src/com/android/settings/security/InstallCertificatePreferenceController.java
@@ -19,17 +19,17 @@
import android.content.Context;
import android.os.UserManager;
-public class InstallCredentialsPreferenceController extends
+public class InstallCertificatePreferenceController extends
RestrictedEncryptionPreferenceController {
- private static final String KEY_CREDENTIALS_INSTALL = "credentials_install";
+ private static final String KEY_INSTALL_CERTIFICATE = "install_certificate";
- public InstallCredentialsPreferenceController(Context context) {
+ public InstallCertificatePreferenceController(Context context) {
super(context, UserManager.DISALLOW_CONFIG_CREDENTIALS);
}
@Override
public String getPreferenceKey() {
- return KEY_CREDENTIALS_INSTALL;
+ return KEY_INSTALL_CERTIFICATE;
}
}
diff --git a/src/com/android/settings/security/InstallCredentialsPreferenceController.java b/src/com/android/settings/security/InstallUserCertificatePreferenceController.java
similarity index 61%
copy from src/com/android/settings/security/InstallCredentialsPreferenceController.java
copy to src/com/android/settings/security/InstallUserCertificatePreferenceController.java
index ca9ed26..ad2a606 100644
--- a/src/com/android/settings/security/InstallCredentialsPreferenceController.java
+++ b/src/com/android/settings/security/InstallUserCertificatePreferenceController.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2017 The Android Open Source Project
+ * Copyright (C) 2019 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -19,17 +19,24 @@
import android.content.Context;
import android.os.UserManager;
-public class InstallCredentialsPreferenceController extends
- RestrictedEncryptionPreferenceController {
+import com.android.settings.core.BasePreferenceController;
- private static final String KEY_CREDENTIALS_INSTALL = "credentials_install";
+public class InstallUserCertificatePreferenceController extends
+ BasePreferenceController {
- public InstallCredentialsPreferenceController(Context context) {
+ private static final String KEY_INSTALL_USER_CERTIFICATE = "install_user_certificate";
+
+ public InstallUserCertificatePreferenceController(Context context) {
super(context, UserManager.DISALLOW_CONFIG_CREDENTIALS);
}
@Override
+ public int getAvailabilityStatus() {
+ return AVAILABLE;
+ }
+
+ @Override
public String getPreferenceKey() {
- return KEY_CREDENTIALS_INSTALL;
+ return KEY_INSTALL_USER_CERTIFICATE;
}
}
diff --git a/src/com/android/settings/security/InstallCredentialsPreferenceController.java b/src/com/android/settings/security/InstallWifiCertificatePreferenceController.java
similarity index 61%
copy from src/com/android/settings/security/InstallCredentialsPreferenceController.java
copy to src/com/android/settings/security/InstallWifiCertificatePreferenceController.java
index ca9ed26..c7df34e 100644
--- a/src/com/android/settings/security/InstallCredentialsPreferenceController.java
+++ b/src/com/android/settings/security/InstallWifiCertificatePreferenceController.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2017 The Android Open Source Project
+ * Copyright (C) 2019 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -19,17 +19,24 @@
import android.content.Context;
import android.os.UserManager;
-public class InstallCredentialsPreferenceController extends
- RestrictedEncryptionPreferenceController {
+import com.android.settings.core.BasePreferenceController;
- private static final String KEY_CREDENTIALS_INSTALL = "credentials_install";
+public class InstallWifiCertificatePreferenceController extends
+ BasePreferenceController {
- public InstallCredentialsPreferenceController(Context context) {
+ private static final String KEY_INSTALL_WIFI_CERTIFICATE = "install_wifi_certificate";
+
+ public InstallWifiCertificatePreferenceController(Context context) {
super(context, UserManager.DISALLOW_CONFIG_CREDENTIALS);
}
@Override
+ public int getAvailabilityStatus() {
+ return AVAILABLE;
+ }
+
+ @Override
public String getPreferenceKey() {
- return KEY_CREDENTIALS_INSTALL;
+ return KEY_INSTALL_WIFI_CERTIFICATE;
}
}
diff --git a/src/com/android/settings/shortcut/CreateShortcutPreferenceController.java b/src/com/android/settings/shortcut/CreateShortcutPreferenceController.java
index 6b95b92..c0f7e1f 100644
--- a/src/com/android/settings/shortcut/CreateShortcutPreferenceController.java
+++ b/src/com/android/settings/shortcut/CreateShortcutPreferenceController.java
@@ -38,6 +38,11 @@
import android.view.View;
import android.widget.ImageView;
+import androidx.annotation.VisibleForTesting;
+import androidx.preference.Preference;
+import androidx.preference.PreferenceCategory;
+import androidx.preference.PreferenceGroup;
+
import com.android.settings.R;
import com.android.settings.Settings.TetherSettingsActivity;
import com.android.settings.core.BasePreferenceController;
@@ -49,11 +54,6 @@
import java.util.Comparator;
import java.util.List;
-import androidx.annotation.VisibleForTesting;
-import androidx.preference.Preference;
-import androidx.preference.PreferenceCategory;
-import androidx.preference.PreferenceGroup;
-
/**
* {@link BasePreferenceController} that populates a list of widgets that Settings app support.
*/
@@ -245,7 +245,7 @@
Drawable iconDrawable;
try {
iconDrawable = context.getPackageManager().getResourcesForApplication(app)
- .getDrawable(resource);
+ .getDrawable(resource, themedContext.getTheme());
if (iconDrawable instanceof LayerDrawable) {
iconDrawable = ((LayerDrawable) iconDrawable).getDrawable(1);
}
diff --git a/src/com/android/settings/sim/SimPreferenceDialog.java b/src/com/android/settings/sim/SimPreferenceDialog.java
deleted file mode 100644
index 0f22d2b..0000000
--- a/src/com/android/settings/sim/SimPreferenceDialog.java
+++ /dev/null
@@ -1,260 +0,0 @@
-/*
- * Copyright (C) 2015 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.sim;
-
-import android.app.Activity;
-import android.content.Context;
-import android.content.DialogInterface;
-import android.content.res.Resources;
-import android.graphics.Paint;
-import android.graphics.drawable.ShapeDrawable;
-import android.graphics.drawable.shapes.OvalShape;
-import android.os.Bundle;
-import android.telephony.PhoneNumberUtils;
-import android.telephony.SubscriptionInfo;
-import android.telephony.SubscriptionManager;
-import android.telephony.TelephonyManager;
-import android.text.TextUtils;
-import android.view.LayoutInflater;
-import android.view.View;
-import android.view.ViewGroup;
-import android.widget.AdapterView;
-import android.widget.ArrayAdapter;
-import android.widget.EditText;
-import android.widget.ImageView;
-import android.widget.Spinner;
-import android.widget.TextView;
-
-import androidx.appcompat.app.AlertDialog;
-
-import com.android.settings.R;
-import com.android.settings.Utils;
-
-public class SimPreferenceDialog extends Activity {
-
- private Context mContext;
- private SubscriptionInfo mSubInfoRecord;
- private int mSlotId;
- private int[] mTintArr;
- private String[] mColorStrings;
- private int mTintSelectorPos;
- private SubscriptionManager mSubscriptionManager;
- AlertDialog.Builder mBuilder;
- View mDialogLayout;
- private final String SIM_NAME = "sim_name";
- private final String TINT_POS = "tint_pos";
-
- @Override
- public void onCreate(Bundle bundle) {
- super.onCreate(bundle);
- mContext = this;
- final Bundle extras = getIntent().getExtras();
- mSlotId = extras.getInt(SimSettings.EXTRA_SLOT_ID, -1);
- mSubscriptionManager = SubscriptionManager.from(mContext);
- mSubInfoRecord = mSubscriptionManager.getActiveSubscriptionInfoForSimSlotIndex(mSlotId);
- mTintArr = mContext.getResources().getIntArray(com.android.internal.R.array.sim_colors);
- mColorStrings = mContext.getResources().getStringArray(R.array.color_picker);
- mTintSelectorPos = 0;
-
- mBuilder = new AlertDialog.Builder(mContext);
- LayoutInflater inflater = (LayoutInflater)mContext
- .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
- mDialogLayout = inflater.inflate(R.layout.multi_sim_dialog, null);
- mBuilder.setView(mDialogLayout);
-
- createEditDialog(bundle);
- }
-
- @Override
- public void onSaveInstanceState(Bundle savedInstanceState) {
- savedInstanceState.putInt(TINT_POS, mTintSelectorPos);
-
- final EditText nameText = (EditText)mDialogLayout.findViewById(R.id.sim_name);
- savedInstanceState.putString(SIM_NAME, nameText.getText().toString());
-
- super.onSaveInstanceState(savedInstanceState);
-
- }
-
- @Override
- public void onRestoreInstanceState(Bundle savedInstanceState) {
- super.onRestoreInstanceState(savedInstanceState);
-
- int pos = savedInstanceState.getInt(TINT_POS);
- final Spinner tintSpinner = (Spinner) mDialogLayout.findViewById(R.id.spinner);
- tintSpinner.setSelection(pos);
- mTintSelectorPos = pos;
-
- EditText nameText = (EditText)mDialogLayout.findViewById(R.id.sim_name);
- nameText.setText(savedInstanceState.getString(SIM_NAME));
- Utils.setEditTextCursorPosition(nameText);
- }
-
- private void createEditDialog(Bundle bundle) {
- final Resources res = mContext.getResources();
- EditText nameText = (EditText)mDialogLayout.findViewById(R.id.sim_name);
- nameText.setText(mSubInfoRecord.getDisplayName());
- Utils.setEditTextCursorPosition(nameText);
- final Spinner tintSpinner = (Spinner) mDialogLayout.findViewById(R.id.spinner);
- SelectColorAdapter adapter = new SelectColorAdapter(mContext,
- R.layout.settings_color_picker_item, mColorStrings);
- adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
- tintSpinner.setAdapter(adapter);
-
- for (int i = 0; i < mTintArr.length; i++) {
- if (mTintArr[i] == mSubInfoRecord.getIconTint()) {
- tintSpinner.setSelection(i);
- mTintSelectorPos = i;
- break;
- }
- }
-
- tintSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
- @Override
- public void onItemSelected(AdapterView<?> parent, View view,
- int pos, long id){
- tintSpinner.setSelection(pos);
- mTintSelectorPos = pos;
- }
-
- @Override
- public void onNothingSelected(AdapterView<?> parent) {
- }
- });
-
- final TelephonyManager tm = (TelephonyManager) mContext.getSystemService(
- Context.TELEPHONY_SERVICE);
- TextView numberView = (TextView)mDialogLayout.findViewById(R.id.number);
- final String rawNumber = tm.getLine1Number(mSubInfoRecord.getSubscriptionId());
- if (TextUtils.isEmpty(rawNumber)) {
- numberView.setText(res.getString(com.android.internal.R.string.unknownName));
- } else {
- numberView.setText(PhoneNumberUtils.formatNumber(rawNumber));
- }
-
- String simCarrierName = tm.getSimOperatorName(mSubInfoRecord.getSubscriptionId());
- TextView carrierView = (TextView)mDialogLayout.findViewById(R.id.carrier);
- carrierView.setText(!TextUtils.isEmpty(simCarrierName) ? simCarrierName :
- mContext.getString(com.android.internal.R.string.unknownName));
-
- mBuilder.setTitle(String.format(res.getString(R.string.sim_editor_title),
- (mSubInfoRecord.getSimSlotIndex() + 1)));
-
- mBuilder.setPositiveButton(R.string.okay, new DialogInterface.OnClickListener() {
- @Override
- public void onClick(DialogInterface dialog, int whichButton) {
- final EditText nameText = (EditText)mDialogLayout.findViewById(R.id.sim_name);
- Utils.setEditTextCursorPosition(nameText);
- String displayName = nameText.getText().toString();
- int subId = mSubInfoRecord.getSubscriptionId();
- mSubInfoRecord.setDisplayName(displayName);
- mSubscriptionManager.setDisplayName(displayName, subId,
- SubscriptionManager.NAME_SOURCE_USER_INPUT);
-
- final int tintSelected = tintSpinner.getSelectedItemPosition();
- int subscriptionId = mSubInfoRecord.getSubscriptionId();
- int tint = mTintArr[tintSelected];
- mSubInfoRecord.setIconTint(tint);
- mSubscriptionManager.setIconTint(tint, subscriptionId);
- dialog.dismiss();
- }
- });
-
- mBuilder.setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() {
- @Override
- public void onClick(DialogInterface dialog, int whichButton) {
- dialog.dismiss();
- }
- });
-
- mBuilder.setOnDismissListener(new DialogInterface.OnDismissListener() {
- @Override
- public void onDismiss(DialogInterface dialogInListener) {
- finish();
- }
- });
-
- mBuilder.create().show();
- }
-
- private class SelectColorAdapter extends ArrayAdapter<CharSequence> {
- private Context mContext;
- private int mResId;
-
- public SelectColorAdapter(
- Context context, int resource, String[] arr) {
- super(context, resource, arr);
- mContext = context;
- mResId = resource;
- }
-
- @Override
- public View getView(int position, View convertView, ViewGroup parent) {
- LayoutInflater inflater = (LayoutInflater)
- mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
-
- View rowView;
- final ViewHolder holder;
- Resources res = mContext.getResources();
- int iconSize = res.getDimensionPixelSize(R.dimen.color_swatch_size);
- int strokeWidth = res.getDimensionPixelSize(R.dimen.color_swatch_stroke_width);
-
- if (convertView == null) {
- // Cache views for faster scrolling
- rowView = inflater.inflate(mResId, null);
- holder = new ViewHolder();
- ShapeDrawable drawable = new ShapeDrawable(new OvalShape());
- drawable.setIntrinsicHeight(iconSize);
- drawable.setIntrinsicWidth(iconSize);
- drawable.getPaint().setStrokeWidth(strokeWidth);
- holder.label = (TextView) rowView.findViewById(R.id.color_text);
- holder.icon = (ImageView) rowView.findViewById(R.id.color_icon);
- holder.swatch = drawable;
- rowView.setTag(holder);
- } else {
- rowView = convertView;
- holder = (ViewHolder) rowView.getTag();
- }
-
- holder.label.setText(getItem(position));
- holder.swatch.getPaint().setColor(mTintArr[position]);
- holder.swatch.getPaint().setStyle(Paint.Style.FILL_AND_STROKE);
- holder.icon.setVisibility(View.VISIBLE);
- holder.icon.setImageDrawable(holder.swatch);
- return rowView;
- }
-
- @Override
- public View getDropDownView(int position, View convertView, ViewGroup parent) {
- View rowView = getView(position, convertView, parent);
- final ViewHolder holder = (ViewHolder) rowView.getTag();
-
- if (mTintSelectorPos == position) {
- holder.swatch.getPaint().setStyle(Paint.Style.FILL_AND_STROKE);
- } else {
- holder.swatch.getPaint().setStyle(Paint.Style.STROKE);
- }
- holder.icon.setVisibility(View.VISIBLE);
- return rowView;
- }
-
- private class ViewHolder {
- TextView label;
- ImageView icon;
- ShapeDrawable swatch;
- }
- }
-}
diff --git a/src/com/android/settings/sim/SimSettings.java b/src/com/android/settings/sim/SimSettings.java
deleted file mode 100644
index bd65508..0000000
--- a/src/com/android/settings/sim/SimSettings.java
+++ /dev/null
@@ -1,367 +0,0 @@
-/*
- * Copyright (C) 2014 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.sim;
-
-import android.app.settings.SettingsEnums;
-import android.content.Context;
-import android.content.Intent;
-import android.content.res.Resources;
-import android.graphics.drawable.BitmapDrawable;
-import android.os.Bundle;
-import android.os.SystemProperties;
-import android.provider.SearchIndexableResource;
-import android.telecom.PhoneAccountHandle;
-import android.telecom.TelecomManager;
-import android.telephony.PhoneNumberUtils;
-import android.telephony.PhoneStateListener;
-import android.telephony.SubscriptionInfo;
-import android.telephony.SubscriptionManager;
-import android.telephony.TelephonyManager;
-import android.text.TextUtils;
-import android.util.Log;
-
-import androidx.preference.Preference;
-import androidx.preference.PreferenceScreen;
-
-import com.android.internal.telephony.TelephonyProperties;
-import com.android.settings.R;
-import com.android.settings.RestrictedSettingsFragment;
-import com.android.settings.Utils;
-import com.android.settings.search.BaseSearchIndexProvider;
-import com.android.settingslib.search.Indexable;
-import com.android.settingslib.search.SearchIndexable;
-
-import java.util.ArrayList;
-import java.util.List;
-
-@SearchIndexable
-public class SimSettings extends RestrictedSettingsFragment implements Indexable {
- private static final String TAG = "SimSettings";
- private static final boolean DBG = false;
-
- private static final String DISALLOW_CONFIG_SIM = "no_config_sim";
- private static final String SIM_CARD_CATEGORY = "sim_cards";
- private static final String KEY_CELLULAR_DATA = "sim_cellular_data";
- private static final String KEY_CALLS = "sim_calls";
- private static final String KEY_SMS = "sim_sms";
- public static final String EXTRA_SLOT_ID = "slot_id";
-
- /**
- * By UX design we use only one Subscription Information(SubInfo) record per SIM slot.
- * mAvalableSubInfos is the list of SubInfos we present to the user.
- * mSubInfoList is the list of all SubInfos.
- * mSelectableSubInfos is the list of SubInfos that a user can select for data, calls, and SMS.
- */
- private List<SubscriptionInfo> mAvailableSubInfos = null;
- private List<SubscriptionInfo> mSubInfoList = null;
- private List<SubscriptionInfo> mSelectableSubInfos = null;
- private PreferenceScreen mSimCards = null;
- private SubscriptionManager mSubscriptionManager;
- private int mNumSlots;
- private Context mContext;
-
- private int mPhoneCount = TelephonyManager.getDefault().getPhoneCount();
- private int[] mCallState = new int[mPhoneCount];
- private PhoneStateListener[] mPhoneStateListener = new PhoneStateListener[mPhoneCount];
-
- public SimSettings() {
- super(DISALLOW_CONFIG_SIM);
- }
-
- @Override
- public int getMetricsCategory() {
- return SettingsEnums.SIM;
- }
-
- @Override
- public void onCreate(final Bundle bundle) {
- super.onCreate(bundle);
- mContext = getActivity();
-
- mSubscriptionManager = SubscriptionManager.from(getActivity());
- final TelephonyManager tm =
- (TelephonyManager) getActivity().getSystemService(Context.TELEPHONY_SERVICE);
- addPreferencesFromResource(R.xml.sim_settings);
-
- mNumSlots = tm.getSimCount();
- mSimCards = (PreferenceScreen)findPreference(SIM_CARD_CATEGORY);
- mAvailableSubInfos = new ArrayList<SubscriptionInfo>(mNumSlots);
- mSelectableSubInfos = new ArrayList<SubscriptionInfo>();
- SimSelectNotification.cancelSimSelectNotification(getActivity());
- }
-
- private final SubscriptionManager.OnSubscriptionsChangedListener mOnSubscriptionsChangeListener
- = new SubscriptionManager.OnSubscriptionsChangedListener() {
- @Override
- public void onSubscriptionsChanged() {
- if (DBG) log("onSubscriptionsChanged:");
- updateSubscriptions();
- }
- };
-
- private void updateSubscriptions() {
- mSubInfoList = mSubscriptionManager.getActiveSubscriptionInfoList(true);
- for (int i = 0; i < mNumSlots; ++i) {
- Preference pref = mSimCards.findPreference("sim" + i);
- if (pref instanceof SimPreference) {
- mSimCards.removePreference(pref);
- }
- }
- mAvailableSubInfos.clear();
- mSelectableSubInfos.clear();
-
- for (int i = 0; i < mNumSlots; ++i) {
- final SubscriptionInfo sir = mSubscriptionManager
- .getActiveSubscriptionInfoForSimSlotIndex(i);
- SimPreference simPreference = new SimPreference(getPrefContext(), sir, i);
- simPreference.setOrder(i-mNumSlots);
- mSimCards.addPreference(simPreference);
- mAvailableSubInfos.add(sir);
- if (sir != null) {
- mSelectableSubInfos.add(sir);
- }
- }
- updateAllOptions();
- }
-
- private void updateAllOptions() {
- updateSimSlotValues();
- updateActivitesCategory();
- }
-
- private void updateSimSlotValues() {
- final int prefSize = mSimCards.getPreferenceCount();
- for (int i = 0; i < prefSize; ++i) {
- Preference pref = mSimCards.getPreference(i);
- if (pref instanceof SimPreference) {
- ((SimPreference)pref).update();
- }
- }
- }
-
- private void updateActivitesCategory() {
- updateCellularDataValues();
- updateCallValues();
- updateSmsValues();
- }
-
- private void updateSmsValues() {
- final Preference simPref = findPreference(KEY_SMS);
- final SubscriptionInfo sir = mSubscriptionManager.getDefaultSmsSubscriptionInfo();
- simPref.setTitle(R.string.sms_messages_title);
- if (DBG) log("[updateSmsValues] mSubInfoList=" + mSubInfoList);
-
- if (sir != null) {
- simPref.setSummary(sir.getDisplayName());
- simPref.setEnabled(mSelectableSubInfos.size() > 1);
- } else if (sir == null) {
- simPref.setSummary(R.string.sim_selection_required_pref);
- simPref.setEnabled(mSelectableSubInfos.size() >= 1);
- }
- }
-
- private void updateCellularDataValues() {
- final Preference simPref = findPreference(KEY_CELLULAR_DATA);
- final SubscriptionInfo sir = mSubscriptionManager.getDefaultDataSubscriptionInfo();
- simPref.setTitle(R.string.cellular_data_title);
- if (DBG) log("[updateCellularDataValues] mSubInfoList=" + mSubInfoList);
-
- boolean callStateIdle = isCallStateIdle();
- final boolean ecbMode = SystemProperties.getBoolean(
- TelephonyProperties.PROPERTY_INECM_MODE, false);
- if (sir != null) {
- simPref.setSummary(sir.getDisplayName());
- // Enable data preference in msim mode and call state idle
- simPref.setEnabled((mSelectableSubInfos.size() > 1) && callStateIdle && !ecbMode);
- } else if (sir == null) {
- simPref.setSummary(R.string.sim_selection_required_pref);
- // Enable data preference in msim mode and call state idle
- simPref.setEnabled((mSelectableSubInfos.size() >= 1) && callStateIdle && !ecbMode);
- }
- }
-
- private void updateCallValues() {
- final Preference simPref = findPreference(KEY_CALLS);
- final TelecomManager telecomManager = TelecomManager.from(mContext);
- final PhoneAccountHandle phoneAccount =
- telecomManager.getUserSelectedOutgoingPhoneAccount();
- final List<PhoneAccountHandle> allPhoneAccounts =
- telecomManager.getCallCapablePhoneAccounts();
-
- simPref.setTitle(R.string.calls_title);
- simPref.setSummary(phoneAccount == null
- ? mContext.getResources().getString(R.string.sim_calls_ask_first_prefs_title)
- : (String)telecomManager.getPhoneAccount(phoneAccount).getLabel());
- simPref.setEnabled(allPhoneAccounts.size() > 1);
- }
-
- @Override
- public void onResume() {
- super.onResume();
- mSubscriptionManager.addOnSubscriptionsChangedListener(mOnSubscriptionsChangeListener);
- updateSubscriptions();
- final TelephonyManager tm =
- (TelephonyManager) getActivity().getSystemService(Context.TELEPHONY_SERVICE);
- if (mSelectableSubInfos.size() > 1) {
- Log.d(TAG, "Register for call state change");
- for (int i = 0; i < mPhoneCount; i++) {
- int subId = mSelectableSubInfos.get(i).getSubscriptionId();
- tm.createForSubscriptionId(subId).listen(getPhoneStateListener(i),
- PhoneStateListener.LISTEN_CALL_STATE);
- }
- }
- }
-
- @Override
- public void onPause() {
- super.onPause();
- mSubscriptionManager.removeOnSubscriptionsChangedListener(mOnSubscriptionsChangeListener);
- final TelephonyManager tm = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);
- for (int i = 0; i < mPhoneCount; i++) {
- if (mPhoneStateListener[i] != null) {
- tm.listen(mPhoneStateListener[i], PhoneStateListener.LISTEN_NONE);
- mPhoneStateListener[i] = null;
- }
- }
- }
-
- private PhoneStateListener getPhoneStateListener(int phoneId) {
- // Disable Sim selection for Data when voice call is going on as changing the default data
- // sim causes a modem reset currently and call gets disconnected
- // ToDo : Add subtext on disabled preference to let user know that default data sim cannot
- // be changed while call is going on
- final int i = phoneId;
- mPhoneStateListener[phoneId] = new PhoneStateListener() {
- @Override
- public void onCallStateChanged(int state, String incomingNumber) {
- if (DBG) log("PhoneStateListener.onCallStateChanged: state=" + state);
- mCallState[i] = state;
- updateCellularDataValues();
- }
- };
- return mPhoneStateListener[phoneId];
- }
-
- @Override
- public boolean onPreferenceTreeClick(final Preference preference) {
- final Context context = mContext;
- Intent intent = new Intent(context, SimDialogActivity.class);
- intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
-
- if (preference instanceof SimPreference) {
- Intent newIntent = new Intent(context, SimPreferenceDialog.class);
- newIntent.putExtra(EXTRA_SLOT_ID, ((SimPreference)preference).getSlotId());
- startActivity(newIntent);
- } else if (findPreference(KEY_CELLULAR_DATA) == preference) {
- intent.putExtra(SimDialogActivity.DIALOG_TYPE_KEY, SimDialogActivity.DATA_PICK);
- context.startActivity(intent);
- } else if (findPreference(KEY_CALLS) == preference) {
- intent.putExtra(SimDialogActivity.DIALOG_TYPE_KEY, SimDialogActivity.CALLS_PICK);
- context.startActivity(intent);
- } else if (findPreference(KEY_SMS) == preference) {
- intent.putExtra(SimDialogActivity.DIALOG_TYPE_KEY, SimDialogActivity.SMS_PICK);
- context.startActivity(intent);
- }
-
- return true;
- }
-
- private class SimPreference extends Preference {
- private SubscriptionInfo mSubInfoRecord;
- private int mSlotId;
- Context mContext;
-
- public SimPreference(Context context, SubscriptionInfo subInfoRecord, int slotId) {
- super(context);
-
- mContext = context;
- mSubInfoRecord = subInfoRecord;
- mSlotId = slotId;
- setKey("sim" + mSlotId);
- update();
- }
-
- public void update() {
- final Resources res = mContext.getResources();
-
- setTitle(String.format(mContext.getResources()
- .getString(R.string.sim_editor_title), (mSlotId + 1)));
- if (mSubInfoRecord != null) {
- if (TextUtils.isEmpty(getPhoneNumber(mSubInfoRecord))) {
- setSummary(mSubInfoRecord.getDisplayName());
- } else {
- setSummary(mSubInfoRecord.getDisplayName() + " - " +
- PhoneNumberUtils.createTtsSpannable(getPhoneNumber(mSubInfoRecord)));
- setEnabled(true);
- }
- setIcon(new BitmapDrawable(res, (mSubInfoRecord.createIconBitmap(mContext))));
- } else {
- setSummary(R.string.sim_slot_empty);
- setFragment(null);
- setEnabled(false);
- }
- }
-
- private int getSlotId() {
- return mSlotId;
- }
- }
-
- // Returns the line1Number. Line1number should always be read from TelephonyManager since it can
- // be overridden for display purposes.
- private String getPhoneNumber(SubscriptionInfo info) {
- final TelephonyManager tm =
- (TelephonyManager) mContext.getSystemService(Context.TELEPHONY_SERVICE);
- return tm.getLine1Number(info.getSubscriptionId());
- }
-
- private void log(String s) {
- Log.d(TAG, s);
- }
-
- /**
- * For search
- */
- public static final BaseSearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
- new BaseSearchIndexProvider() {
- @Override
- public List<SearchIndexableResource> getXmlResourcesToIndex(Context context,
- boolean enabled) {
- ArrayList<SearchIndexableResource> result =
- new ArrayList<SearchIndexableResource>();
-
- if (Utils.showSimCardTile(context)) {
- SearchIndexableResource sir = new SearchIndexableResource(context);
- sir.xmlResId = R.xml.sim_settings;
- result.add(sir);
- }
-
- return result;
- }
- };
-
- private boolean isCallStateIdle() {
- boolean callStateIdle = true;
- for (int i = 0; i < mCallState.length; i++) {
- if (TelephonyManager.CALL_STATE_IDLE != mCallState[i]) {
- callStateIdle = false;
- }
- }
- Log.d(TAG, "isCallStateIdle " + callStateIdle);
- return callStateIdle;
- }
-}
diff --git a/src/com/android/settings/slices/CustomSliceable.java b/src/com/android/settings/slices/CustomSliceable.java
index 9566be1..92c604e 100644
--- a/src/com/android/settings/slices/CustomSliceable.java
+++ b/src/com/android/settings/slices/CustomSliceable.java
@@ -95,7 +95,7 @@
.setData(getUri())
.setClass(context, SliceBroadcastReceiver.class);
return PendingIntent.getBroadcast(context, 0 /* requestCode */, intent,
- PendingIntent.FLAG_CANCEL_CURRENT);
+ PendingIntent.FLAG_UPDATE_CURRENT);
}
@Override
diff --git a/src/com/android/settings/slices/SliceBuilderUtils.java b/src/com/android/settings/slices/SliceBuilderUtils.java
index e82d13e..00d7950 100644
--- a/src/com/android/settings/slices/SliceBuilderUtils.java
+++ b/src/com/android/settings/slices/SliceBuilderUtils.java
@@ -159,7 +159,7 @@
.setClass(context, SliceBroadcastReceiver.class)
.putExtra(EXTRA_SLICE_KEY, data.getKey());
return PendingIntent.getBroadcast(context, 0 /* requestCode */, intent,
- PendingIntent.FLAG_CANCEL_CURRENT);
+ PendingIntent.FLAG_UPDATE_CURRENT);
}
/**
diff --git a/src/com/android/settings/users/UserSettings.java b/src/com/android/settings/users/UserSettings.java
index 5ad68fe..7a9f026 100644
--- a/src/com/android/settings/users/UserSettings.java
+++ b/src/com/android/settings/users/UserSettings.java
@@ -74,6 +74,8 @@
import com.android.settingslib.drawable.CircleFramedDrawable;
import com.android.settingslib.search.SearchIndexable;
+import com.google.android.setupcompat.util.WizardManagerHelper;
+
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
@@ -224,7 +226,7 @@
super.onCreate(icicle);
addPreferencesFromResource(R.xml.user_settings);
final Activity activity = getActivity();
- if (!Utils.isDeviceProvisioned(activity)) {
+ if (!WizardManagerHelper.isDeviceProvisioned(activity)) {
activity.finish();
return;
}
@@ -977,7 +979,8 @@
private void updateAddUser(Context context) {
if ((mUserCaps.mCanAddUser || mUserCaps.mDisallowAddUserSetByAdmin)
- && Utils.isDeviceProvisioned(context) && mUserCaps.mUserSwitcherEnabled) {
+ && WizardManagerHelper.isDeviceProvisioned(context)
+ && mUserCaps.mUserSwitcherEnabled) {
mAddUser.setVisible(true);
final boolean moreUsers = mUserManager.canAddMoreUsers();
mAddUser.setEnabled(moreUsers && !mAddingUser && mUserManager.canSwitchUsers());
diff --git a/src/com/android/settings/wifi/NetworkRequestDialogFragment.java b/src/com/android/settings/wifi/NetworkRequestDialogFragment.java
index a88b004..c7255f1 100644
--- a/src/com/android/settings/wifi/NetworkRequestDialogFragment.java
+++ b/src/com/android/settings/wifi/NetworkRequestDialogFragment.java
@@ -34,16 +34,19 @@
import android.widget.Button;
import android.widget.ProgressBar;
import android.widget.TextView;
+
import androidx.annotation.NonNull;
import androidx.annotation.VisibleForTesting;
import androidx.appcompat.app.AlertDialog;
import androidx.preference.internal.PreferenceImageView;
+
import com.android.settings.R;
import com.android.settingslib.Utils;
import com.android.settingslib.core.lifecycle.Lifecycle;
import com.android.settingslib.wifi.AccessPoint;
import com.android.settingslib.wifi.WifiTracker;
import com.android.settingslib.wifi.WifiTrackerFactory;
+
import java.util.ArrayList;
import java.util.List;
@@ -63,7 +66,8 @@
private boolean mShowLimitedItem = true;
private List<AccessPoint> mAccessPointList;
- private FilterWifiTracker mFilterWifiTracker;
+ @VisibleForTesting
+ FilterWifiTracker mFilterWifiTracker;
private AccessPointAdapter mDialogAdapter;
private NetworkRequestUserSelectionCallback mUserSelectionCallback;
@@ -115,7 +119,7 @@
neutralBtn.setVisibility(View.GONE);
neutralBtn.setOnClickListener(v -> {
mShowLimitedItem = false;
- renewAccessPointList(null /* List<ScanResult> */);
+ renewAccessPointList(null /* scanResults */);
notifyAdapterRefresh();
neutralBtn.setVisibility(View.GONE);
});
@@ -323,7 +327,8 @@
// Do nothing when selection is failed, let user could try again easily.
}
- private final class FilterWifiTracker {
+ @VisibleForTesting
+ final class FilterWifiTracker {
private final List<String> mAccessPointKeys;
private final WifiTracker mWifiTracker;
@@ -381,7 +386,8 @@
return result;
}
- private WifiTracker.WifiListener mWifiListener = new WifiTracker.WifiListener() {
+ @VisibleForTesting
+ WifiTracker.WifiListener mWifiListener = new WifiTracker.WifiListener() {
@Override
public void onWifiStateChanged(int state) {
@@ -395,6 +401,7 @@
@Override
public void onAccessPointsChanged() {
+ renewAccessPointList(null /* scanResults */);
notifyAdapterRefresh();
}
};
diff --git a/src/com/android/settings/wifi/WifiConfigController.java b/src/com/android/settings/wifi/WifiConfigController.java
index c31b857..94cb306 100644
--- a/src/com/android/settings/wifi/WifiConfigController.java
+++ b/src/com/android/settings/wifi/WifiConfigController.java
@@ -47,7 +47,10 @@
import android.util.Log;
import android.view.KeyEvent;
import android.view.View;
+import android.view.View.AccessibilityDelegate;
import android.view.ViewGroup;
+import android.view.accessibility.AccessibilityNodeInfo;
+import android.view.accessibility.AccessibilityNodeInfo.AccessibilityAction;
import android.view.inputmethod.EditorInfo;
import android.view.inputmethod.InputMethodManager;
import android.widget.AdapterView;
@@ -62,6 +65,8 @@
import android.widget.Spinner;
import android.widget.TextView;
+import androidx.annotation.VisibleForTesting;
+
import com.android.settings.ProxySelector;
import com.android.settings.R;
import com.android.settings.wifi.details.WifiPrivacyPreferenceController;
@@ -76,8 +81,6 @@
import java.util.Arrays;
import java.util.Iterator;
-import androidx.annotation.VisibleForTesting;
-
/**
* The class for allowing UIs like {@link WifiDialog} and {@link WifiConfigUiBase} to
* share the logic for controlling buttons, text fields, etc.
@@ -338,6 +341,7 @@
mAccessPoint.isCarrierAp() ? View.GONE : View.VISIBLE);
advancedTogglebox.setOnCheckedChangeListener(this);
advancedTogglebox.setChecked(showAdvancedFields);
+ setAdvancedOptionAccessibilityString(showAdvancedFields);
mView.findViewById(R.id.wifi_advanced_fields)
.setVisibility(showAdvancedFields ? View.VISIBLE : View.GONE);
if (mAccessPoint.isCarrierAp()) {
@@ -1363,7 +1367,7 @@
mIpAddressView.setText(
staticConfig.ipAddress.getAddress().getHostAddress());
mNetworkPrefixLengthView.setText(Integer.toString(staticConfig.ipAddress
- .getNetworkPrefixLength()));
+ .getPrefixLength()));
}
if (staticConfig.gateway != null) {
@@ -1554,21 +1558,17 @@
((EditText) mPasswordView).setSelection(pos);
}
} else if (view.getId() == R.id.wifi_advanced_togglebox) {
- final View advancedToggle = mView.findViewById(R.id.wifi_advanced_toggle);
final int toggleVisibility;
final int stringID;
if (isChecked) {
toggleVisibility = View.VISIBLE;
- stringID = R.string.wifi_advanced_toggle_description_expanded;
-
// Hide the SoftKeyboard temporary to let user can see most of the expanded items.
hideSoftKeyboard(mView.getWindowToken());
} else {
toggleVisibility = View.GONE;
- stringID = R.string.wifi_advanced_toggle_description_collapsed;
}
mView.findViewById(R.id.wifi_advanced_fields).setVisibility(toggleVisibility);
- advancedToggle.setContentDescription(mContext.getString(stringID));
+ setAdvancedOptionAccessibilityString(isChecked);
}
}
@@ -1677,6 +1677,8 @@
mView.findViewById(R.id.hidden_settings_field).setVisibility(View.VISIBLE);
((CheckBox) mView.findViewById(R.id.wifi_advanced_togglebox))
.setOnCheckedChangeListener(this);
+ // Set correct accessibility strings.
+ setAdvancedOptionAccessibilityString(false /* showAdvancedFields */);
}
/**
@@ -1767,4 +1769,26 @@
InputMethodManager.class);
inputMethodManager.hideSoftInputFromWindow(windowToken, 0 /* flags */);
}
+
+ private void setAdvancedOptionAccessibilityString(boolean showAdvancedFields) {
+ final CheckBox advancedToggleBox = mView.findViewById(R.id.wifi_advanced_togglebox);
+ advancedToggleBox.setAccessibilityDelegate(new AccessibilityDelegate() {
+ @Override
+ public void onInitializeAccessibilityNodeInfo(
+ View v, AccessibilityNodeInfo info) {
+ super.onInitializeAccessibilityNodeInfo(v, info);
+ // To let TalkBack don't pronounce checked/unchecked.
+ info.setCheckable(false /* checkable */);
+ // To let TalkBack don't pronounce CheckBox.
+ info.setClassName(null /* className */);
+ final CharSequence accessibilityDoubleTapExtend = mContext.getString(
+ showAdvancedFields ? R.string.wifi_advanced_toggle_description_expanded
+ : R.string.wifi_advanced_toggle_description_collapsed);
+ // Customize TalkBack's pronunciation which been appended to "Double-tap to".
+ final AccessibilityAction customClick = new AccessibilityAction(
+ AccessibilityNodeInfo.ACTION_CLICK, accessibilityDoubleTapExtend);
+ info.addAction(customClick);
+ }
+ });
+ }
}
diff --git a/src/com/android/settings/wifi/details/WifiDetailPreferenceController.java b/src/com/android/settings/wifi/details/WifiDetailPreferenceController.java
index 6cd9569..965b0ff 100644
--- a/src/com/android/settings/wifi/details/WifiDetailPreferenceController.java
+++ b/src/com/android/settings/wifi/details/WifiDetailPreferenceController.java
@@ -242,14 +242,28 @@
return mNetworkCapabilities.hasCapability(cap) != nc.hasCapability(cap);
}
+ private boolean hasPrivateDnsStatusChanged(NetworkCapabilities nc) {
+ // If this is the first time that WifiDetailPreferenceController gets
+ // NetworkCapabilities, report that something has changed and assign nc to
+ // mNetworkCapabilities in onCapabilitiesChanged. Note that the NetworkCapabilities
+ // from onCapabilitiesChanged() will never be null, so calling
+ // mNetworkCapabilities.isPrivateDnsBroken() would be safe next time.
+ if (mNetworkCapabilities == null) {
+ return true;
+ }
+
+ return mNetworkCapabilities.isPrivateDnsBroken() != nc.isPrivateDnsBroken();
+ }
+
@Override
public void onCapabilitiesChanged(Network network, NetworkCapabilities nc) {
// If the network just validated or lost Internet access or detected partial internet
- // connectivity, refresh network state. Don't do this on every NetworkCapabilities
- // change because refreshNetworkState sends IPCs to the system server from the UI
- // thread, which can cause jank.
+ // connectivity or private dns was broken, refresh network state. Don't do this on
+ // every NetworkCapabilities change because refreshEntityHeader sends IPCs to the
+ // system server from the UI thread, which can cause jank.
if (network.equals(mNetwork) && !nc.equals(mNetworkCapabilities)) {
- if (hasCapabilityChanged(nc, NET_CAPABILITY_VALIDATED)
+ if (hasPrivateDnsStatusChanged(nc)
+ || hasCapabilityChanged(nc, NET_CAPABILITY_VALIDATED)
|| hasCapabilityChanged(nc, NET_CAPABILITY_CAPTIVE_PORTAL)
|| hasCapabilityChanged(nc, NET_CAPABILITY_PARTIAL_CONNECTIVITY)) {
mAccessPoint.update(mWifiConfig, mWifiInfo, mNetworkInfo);
@@ -1194,7 +1208,7 @@
(mWifiConfig.macRandomizationSetting
== WifiConfiguration.RANDOMIZATION_PERSISTENT)
? R.string.wifi_advanced_randomized_mac_address_title
- : R.string.wifi_advanced_factory_mac_address_title);
+ : R.string.wifi_advanced_device_mac_address_title);
}
}
diff --git a/src/com/android/settings/wifi/qrcode/QrCamera.java b/src/com/android/settings/wifi/qrcode/QrCamera.java
index f0afd60..21be399 100644
--- a/src/com/android/settings/wifi/qrcode/QrCamera.java
+++ b/src/com/android/settings/wifi/qrcode/QrCamera.java
@@ -80,14 +80,16 @@
HINTS.put(DecodeHintType.POSSIBLE_FORMATS, FORMATS);
}
- private Camera mCamera;
+ @VisibleForTesting
+ Camera mCamera;
private Size mPreviewSize;
private WeakReference<Context> mContext;
private ScannerCallback mScannerCallback;
private MultiFormatReader mReader;
private DecodingTask mDecodeTask;
private int mCameraOrientation;
- private Camera.Parameters mParameters;
+ @VisibleForTesting
+ Camera.Parameters mParameters;
public QrCamera(Context context, ScannerCallback callback) {
mContext = new WeakReference<Context>(context);
@@ -171,12 +173,13 @@
boolean isValid(String qrCode);
}
- private void setCameraParameter() {
+ @VisibleForTesting
+ void setCameraParameter() {
mParameters = mCamera.getParameters();
mPreviewSize = getBestPreviewSize(mParameters);
mParameters.setPreviewSize(mPreviewSize.getWidth(), mPreviewSize.getHeight());
Size pictureSize = getBestPictureSize(mParameters);
- mParameters.setPreviewSize(pictureSize.getWidth(), pictureSize.getHeight());
+ mParameters.setPictureSize(pictureSize.getWidth(), pictureSize.getHeight());
if (mParameters.getSupportedFlashModes().contains(Parameters.FLASH_MODE_OFF)) {
mParameters.setFlashMode(Parameters.FLASH_MODE_OFF);
@@ -288,32 +291,43 @@
for (int i = 0; i < numberOfCameras; ++i) {
Camera.getCameraInfo(i, cameraInfo);
if (cameraInfo.facing == CameraInfo.CAMERA_FACING_BACK) {
+ releaseCamera();
mCamera = Camera.open(i);
- mCamera.setPreviewTexture(surface);
mCameraOrientation = cameraInfo.orientation;
break;
}
}
- if (mCamera == null) {
- Log.e(TAG, "Cannot find available back camera.");
- mScannerCallback.handleCameraFailure();
- return false;
- }
- setCameraParameter();
- setTransformationMatrix();
- if (!startPreview()) {
- Log.e(TAG, "Error to init Camera");
- mCamera = null;
- mScannerCallback.handleCameraFailure();
- return false;
- }
- return true;
- } catch (IOException e) {
- Log.e(TAG, "Error to init Camera");
+ } catch (RuntimeException e) {
+ Log.e(TAG, "Fail to open camera: " + e);
mCamera = null;
mScannerCallback.handleCameraFailure();
return false;
}
+
+ try {
+ if (mCamera == null) {
+ throw new IOException("Cannot find available back camera");
+ }
+ mCamera.setPreviewTexture(surface);
+ setCameraParameter();
+ setTransformationMatrix();
+ if (!startPreview()) {
+ throw new IOException("Lost contex");
+ }
+ } catch (IOException ioe) {
+ Log.e(TAG, "Fail to startPreview camera: " + ioe);
+ mCamera = null;
+ mScannerCallback.handleCameraFailure();
+ return false;
+ }
+ return true;
+ }
+ }
+
+ private void releaseCamera() {
+ if (mCamera != null) {
+ mCamera.release();
+ mCamera = null;
}
}
diff --git a/src/com/android/settings/wifi/tether/WifiTetherPreferenceController.java b/src/com/android/settings/wifi/tether/WifiTetherPreferenceController.java
index 8f6d489..73f1d82 100644
--- a/src/com/android/settings/wifi/tether/WifiTetherPreferenceController.java
+++ b/src/com/android/settings/wifi/tether/WifiTetherPreferenceController.java
@@ -16,14 +16,11 @@
package com.android.settings.wifi.tether;
-import android.content.BroadcastReceiver;
import android.content.Context;
-import android.content.Intent;
-import android.content.IntentFilter;
import android.net.ConnectivityManager;
+import android.net.wifi.WifiClient;
import android.net.wifi.WifiConfiguration;
import android.net.wifi.WifiManager;
-import android.provider.Settings;
import android.text.BidiFormatter;
import androidx.annotation.VisibleForTesting;
@@ -39,6 +36,8 @@
import com.android.settingslib.core.lifecycle.events.OnStart;
import com.android.settingslib.core.lifecycle.events.OnStop;
+import java.util.List;
+
public class WifiTetherPreferenceController extends AbstractPreferenceController
implements PreferenceControllerMixin, LifecycleObserver, OnStart, OnStop {
@@ -128,13 +127,13 @@
}
@Override
- public void onNumClientsChanged(int numClients) {
+ public void onConnectedClientsChanged(List<WifiClient> clients) {
if (mPreference != null
&& mSoftApState == WifiManager.WIFI_AP_STATE_ENABLED) {
// Only show the number of clients when state is on
mPreference.setSummary(mContext.getResources().getQuantityString(
- R.plurals.wifi_tether_connected_summary, numClients,
- numClients));
+ R.plurals.wifi_tether_connected_summary, clients.size(),
+ clients.size()));
}
}
});
diff --git a/src/com/android/settings/wifi/tether/WifiTetherSoftApManager.java b/src/com/android/settings/wifi/tether/WifiTetherSoftApManager.java
index 77a44b0..1a805bd 100644
--- a/src/com/android/settings/wifi/tether/WifiTetherSoftApManager.java
+++ b/src/com/android/settings/wifi/tether/WifiTetherSoftApManager.java
@@ -1,8 +1,11 @@
package com.android.settings.wifi.tether;
+import android.net.wifi.WifiClient;
import android.net.wifi.WifiManager;
import android.os.Handler;
+import java.util.List;
+
/**
* Wrapper for {@link android.net.wifi.WifiManager.SoftApCallback} to pass the robo test
*/
@@ -18,8 +21,8 @@
}
@Override
- public void onNumClientsChanged(int numClients) {
- mWifiTetherSoftApCallback.onNumClientsChanged(numClients);
+ public void onConnectedClientsChanged(List<WifiClient> clients) {
+ mWifiTetherSoftApCallback.onConnectedClientsChanged(clients);
}
};
private Handler mHandler;
@@ -42,6 +45,11 @@
public interface WifiTetherSoftApCallback {
void onStateChanged(int state, int failureReason);
- void onNumClientsChanged(int numClients);
+ /**
+ * Called when the connected clients to soft AP changes.
+ *
+ * @param clients the currently connected clients
+ */
+ void onConnectedClientsChanged(List<WifiClient> clients);
}
}
diff --git a/tests/robotests/assets/grandfather_not_implementing_index_provider b/tests/robotests/assets/grandfather_not_implementing_index_provider
index 20c1792..d0f02d3 100644
--- a/tests/robotests/assets/grandfather_not_implementing_index_provider
+++ b/tests/robotests/assets/grandfather_not_implementing_index_provider
@@ -6,6 +6,8 @@
com.android.settings.accessibility.ToggleScreenReaderPreferenceFragmentForSetupWizard
com.android.settings.accessibility.ToggleSelectToSpeakPreferenceFragmentForSetupWizard
com.android.settings.accounts.AccountDetailDashboardFragment
+com.android.settings.accounts.AccountPersonalDashboardFragment
+com.android.settings.accounts.AccountWorkProfileDashboardFragment
com.android.settings.accounts.AccountSyncSettings
com.android.settings.accounts.ChooseAccountFragment
com.android.settings.applications.appinfo.AppInfoDashboardFragment
diff --git a/tests/robotests/src/com/android/settings/applications/AppPermissionsPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/applications/AppPermissionsPreferenceControllerTest.java
index 986c2c7..f0fdc9c 100644
--- a/tests/robotests/src/com/android/settings/applications/AppPermissionsPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/applications/AppPermissionsPreferenceControllerTest.java
@@ -31,6 +31,8 @@
import androidx.preference.Preference;
+import com.android.settings.R;
+
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -70,14 +72,15 @@
}
@Test
- public void updateSummary_noGrantedPermission_shouldSetNullSummary() {
+ public void updateSummary_noGrantedPermission_shouldSetNoPermissionGrantedSummary() {
doNothing().when(mController).queryPermissionSummary();
mController.updateState(mPreference);
mController.mNumPackageChecked = 2;
mController.updateSummary(new ArrayList<>());
- assertThat(mPreference.getSummary()).isNull();
+ assertThat(mPreference.getSummary()).isEqualTo(
+ mContext.getString(R.string.runtime_permissions_summary_no_permissions_granted));
}
@Test
diff --git a/tests/robotests/src/com/android/settings/development/MockLocationAppPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/development/MockLocationAppPreferenceControllerTest.java
index 993ba72..3be4347 100644
--- a/tests/robotests/src/com/android/settings/development/MockLocationAppPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/development/MockLocationAppPreferenceControllerTest.java
@@ -20,6 +20,7 @@
import android.content.Intent;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager;
+import android.util.Pair;
import androidx.preference.Preference;
import androidx.preference.PreferenceScreen;
@@ -145,7 +146,6 @@
}
private AppOpsManager.OpEntry createOpEntry(int opMode) {
- return new OpEntry(0, false, opMode, null /*accessTimes*/, null /*rejectTimes*/,
- null /*durations*/, null /* proxyUids */, null /* proxyPackages */);
+ return new OpEntry(0, opMode, new Pair[0]);
}
}
diff --git a/tests/robotests/src/com/android/settings/development/featureflags/FeatureFlagPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/development/featureflags/FeatureFlagPreferenceControllerTest.java
index cf97544..acdf071 100644
--- a/tests/robotests/src/com/android/settings/development/featureflags/FeatureFlagPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/development/featureflags/FeatureFlagPreferenceControllerTest.java
@@ -28,7 +28,6 @@
import android.content.Context;
import android.os.Build;
-import android.os.SystemProperties;
import androidx.preference.PreferenceCategory;
import androidx.preference.PreferenceScreen;
@@ -77,9 +76,8 @@
@Test
public void onStart_shouldRefreshFeatureFlags() {
- mController.onStart();
+ mController.displayPreference(mScreen);
- verify(mCategory).removeAll();
verify(mCategory, atLeastOnce()).addPreference(any(FeatureFlagPreference.class));
}
}
diff --git a/tests/robotests/src/com/android/settings/fuelgauge/RestrictAppPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/fuelgauge/RestrictAppPreferenceControllerTest.java
index 774fba2..1febbe4 100644
--- a/tests/robotests/src/com/android/settings/fuelgauge/RestrictAppPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/fuelgauge/RestrictAppPreferenceControllerTest.java
@@ -34,6 +34,7 @@
import android.content.Intent;
import android.os.UserHandle;
import android.os.UserManager;
+import android.util.Pair;
import androidx.preference.Preference;
import androidx.preference.PreferenceManager;
@@ -83,14 +84,10 @@
MockitoAnnotations.initMocks(this);
final List<AppOpsManager.OpEntry> allowOps = new ArrayList<>();
allowOps.add(new AppOpsManager.OpEntry(
- AppOpsManager.OP_RUN_ANY_IN_BACKGROUND, false, AppOpsManager.MODE_ALLOWED,
- null /*accessTimes*/, null /*rejectTimes*/, null /*durations*/,
- null /* proxyUids */, null /* proxyPackages */));
+ AppOpsManager.OP_RUN_ANY_IN_BACKGROUND, AppOpsManager.MODE_ALLOWED, new Pair[0]));
final List<AppOpsManager.OpEntry> restrictedOps = new ArrayList<>();
restrictedOps.add(new AppOpsManager.OpEntry(
- AppOpsManager.OP_RUN_ANY_IN_BACKGROUND, false, AppOpsManager.MODE_IGNORED,
- null /*accessTimes*/, null /*rejectTimes*/, null /*durations*/,
- null /* proxyUids */, null /* proxyPackages */));
+ AppOpsManager.OP_RUN_ANY_IN_BACKGROUND, AppOpsManager.MODE_IGNORED, new Pair[0]));
mAllowedPackageOps = new AppOpsManager.PackageOps(
ALLOWED_PACKAGE_NAME, ALLOWED_UID, allowOps);
mRestrictedPackageOps = new AppOpsManager.PackageOps(
diff --git a/tests/robotests/src/com/android/settings/network/telephony/VideoCallingPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/network/telephony/VideoCallingPreferenceControllerTest.java
index d904ab3..3ada519 100644
--- a/tests/robotests/src/com/android/settings/network/telephony/VideoCallingPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/network/telephony/VideoCallingPreferenceControllerTest.java
@@ -27,6 +27,7 @@
import android.telephony.TelephonyManager;
import android.telephony.ims.feature.ImsFeature;
+import androidx.preference.PreferenceScreen;
import androidx.preference.SwitchPreference;
import com.android.ims.ImsManager;
@@ -49,6 +50,8 @@
private ImsManager mImsManager;
@Mock
private CarrierConfigManager mCarrierConfigManager;
+ @Mock
+ private PreferenceScreen mPreferenceScreen;
private VideoCallingPreferenceController mController;
private PersistableBundle mCarrierConfig;
@@ -125,4 +128,15 @@
assertThat(mPreference.isEnabled()).isTrue();
assertThat(mPreference.isChecked()).isTrue();
}
+
+
+ @Test
+ public void displayPreference_notAvailable_setPreferenceInvisible() {
+ doReturn(false).when(mImsManager).isVtEnabledByPlatform();
+
+ mController.displayPreference(mPreferenceScreen);
+
+ assertThat(mPreferenceScreen.isVisible()).isFalse();
+ }
+
}
diff --git a/tests/robotests/src/com/android/settings/network/telephony/WifiCallingPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/network/telephony/WifiCallingPreferenceControllerTest.java
index 57541af..1048acd 100644
--- a/tests/robotests/src/com/android/settings/network/telephony/WifiCallingPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/network/telephony/WifiCallingPreferenceControllerTest.java
@@ -64,7 +64,6 @@
private WifiCallingPreferenceController mController;
private Preference mPreference;
- private PreferenceCategory mPreferenceCategory;
private Context mContext;
private PersistableBundle mCarrierConfig;
@@ -87,10 +86,6 @@
mCarrierConfig = new PersistableBundle();
when(mCarrierConfigManager.getConfigForSubId(SUB_ID)).thenReturn(mCarrierConfig);
- mPreferenceCategory = new PreferenceCategory(mContext);
- when(mPreferenceScreen.findPreference(
- WifiCallingPreferenceController.KEY_PREFERENCE_CATEGORY)).thenReturn(
- mPreferenceCategory);
when(mPreferenceScreen.findPreference(mController.getPreferenceKey())).thenReturn(
mPreference);
}
@@ -164,12 +159,12 @@
}
@Test
- public void displayPreference_notAvailable_setCategoryInvisible() {
+ public void displayPreference_notAvailable_setPreferenceInvisible() {
mController.init(SubscriptionManager.INVALID_SUBSCRIPTION_ID);
mController.displayPreference(mPreferenceScreen);
- assertThat(mPreferenceCategory.isVisible()).isFalse();
+ assertThat(mPreferenceScreen.isVisible()).isFalse();
}
@Test
diff --git a/tests/robotests/src/com/android/settings/panel/PanelFeatureProviderImplTest.java b/tests/robotests/src/com/android/settings/panel/PanelFeatureProviderImplTest.java
index ae57a77..54f1894 100644
--- a/tests/robotests/src/com/android/settings/panel/PanelFeatureProviderImplTest.java
+++ b/tests/robotests/src/com/android/settings/panel/PanelFeatureProviderImplTest.java
@@ -17,17 +17,19 @@
package com.android.settings.panel;
+import static com.android.settings.panel.SettingsPanelActivity.KEY_MEDIA_PACKAGE_NAME;
+import static com.android.settings.panel.SettingsPanelActivity.KEY_PANEL_TYPE_ARGUMENT;
import static com.android.settingslib.media.MediaOutputSliceConstants.ACTION_MEDIA_OUTPUT;
import static com.google.common.truth.Truth.assertThat;
import android.content.Context;
+import android.os.Bundle;
import android.provider.Settings;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
-
import org.robolectric.RobolectricTestRunner;
import org.robolectric.RuntimeEnvironment;
@@ -38,33 +40,39 @@
private Context mContext;
private PanelFeatureProviderImpl mProvider;
+ private Bundle mBundle;
@Before
public void setUp() {
mContext = RuntimeEnvironment.application;
mProvider = new PanelFeatureProviderImpl();
+ mBundle = new Bundle();
+ mBundle.putString(KEY_MEDIA_PACKAGE_NAME, TEST_PACKAGENAME);
}
@Test
public void getPanel_internetConnectivityKey_returnsCorrectPanel() {
- final PanelContent panel = mProvider.getPanel(mContext,
- Settings.Panel.ACTION_INTERNET_CONNECTIVITY, TEST_PACKAGENAME);
+ mBundle.putString(KEY_PANEL_TYPE_ARGUMENT, Settings.Panel.ACTION_INTERNET_CONNECTIVITY);
+
+ final PanelContent panel = mProvider.getPanel(mContext, mBundle);
assertThat(panel).isInstanceOf(InternetConnectivityPanel.class);
}
@Test
public void getPanel_volume_returnsCorrectPanel() {
- final PanelContent panel = mProvider.getPanel(mContext,
- Settings.Panel.ACTION_VOLUME, TEST_PACKAGENAME);
+ mBundle.putString(KEY_PANEL_TYPE_ARGUMENT, Settings.Panel.ACTION_VOLUME);
+
+ final PanelContent panel = mProvider.getPanel(mContext, mBundle);
assertThat(panel).isInstanceOf(VolumePanel.class);
}
@Test
public void getPanel_mediaOutputKey_returnsCorrectPanel() {
- final PanelContent panel = mProvider.getPanel(mContext,
- ACTION_MEDIA_OUTPUT, TEST_PACKAGENAME);
+ mBundle.putString(KEY_PANEL_TYPE_ARGUMENT, ACTION_MEDIA_OUTPUT);
+
+ final PanelContent panel = mProvider.getPanel(mContext, mBundle);
assertThat(panel).isInstanceOf(MediaOutputPanel.class);
}
diff --git a/tests/robotests/src/com/android/settings/panel/PanelFragmentTest.java b/tests/robotests/src/com/android/settings/panel/PanelFragmentTest.java
index 44dc3bc..cbeff97 100644
--- a/tests/robotests/src/com/android/settings/panel/PanelFragmentTest.java
+++ b/tests/robotests/src/com/android/settings/panel/PanelFragmentTest.java
@@ -38,7 +38,6 @@
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
-
import org.robolectric.Robolectric;
import org.robolectric.RobolectricTestRunner;
import org.robolectric.RuntimeEnvironment;
@@ -63,7 +62,7 @@
mFakeFeatureFactory = FakeFeatureFactory.setupForTest();
mFakeFeatureFactory.panelFeatureProvider = mPanelFeatureProvider;
mFakePanelContent = new FakePanelContent();
- doReturn(mFakePanelContent).when(mPanelFeatureProvider).getPanel(any(), any(), any());
+ doReturn(mFakePanelContent).when(mPanelFeatureProvider).getPanel(any(), any());
mActivity = spy(Robolectric.buildActivity(FakeSettingsPanelActivity.class).setup().get());
@@ -83,7 +82,7 @@
new LinearLayout(mContext), null);
PanelSlicesLoaderCountdownLatch countdownLatch =
mPanelFragment.mPanelSlicesLoaderCountdownLatch;
- for (Uri sliecUri: mFakePanelContent.getSlices()) {
+ for (Uri sliecUri : mFakePanelContent.getSlices()) {
countdownLatch.markSliceLoaded(sliecUri);
}
diff --git a/tests/robotests/src/com/android/settings/panel/PanelSlicesAdapterTest.java b/tests/robotests/src/com/android/settings/panel/PanelSlicesAdapterTest.java
index 89288f6..9f4fffc 100644
--- a/tests/robotests/src/com/android/settings/panel/PanelSlicesAdapterTest.java
+++ b/tests/robotests/src/com/android/settings/panel/PanelSlicesAdapterTest.java
@@ -40,17 +40,15 @@
import com.android.settings.testutils.FakeFeatureFactory;
import org.junit.Before;
-import org.junit.runner.RunWith;
import org.junit.Test;
+import org.junit.runner.RunWith;
import org.mockito.MockitoAnnotations;
import org.robolectric.Robolectric;
import org.robolectric.RobolectricTestRunner;
import org.robolectric.RuntimeEnvironment;
import org.robolectric.android.controller.ActivityController;
-import java.util.ArrayList;
import java.util.LinkedHashMap;
-import java.util.List;
import java.util.Map;
@RunWith(RobolectricTestRunner.class)
@@ -74,7 +72,7 @@
mFakeFeatureFactory = FakeFeatureFactory.setupForTest();
mFakeFeatureFactory.panelFeatureProvider = mPanelFeatureProvider;
mFakePanelContent = new FakePanelContent();
- doReturn(mFakePanelContent).when(mPanelFeatureProvider).getPanel(any(), any(), any());
+ doReturn(mFakePanelContent).when(mPanelFeatureProvider).getPanel(any(), any());
ActivityController<FakeSettingsPanelActivity> activityController =
Robolectric.buildActivity(FakeSettingsPanelActivity.class);
diff --git a/tests/robotests/src/com/android/settings/panel/SettingsPanelActivityTest.java b/tests/robotests/src/com/android/settings/panel/SettingsPanelActivityTest.java
index a4b7aa5..44e5eefc 100644
--- a/tests/robotests/src/com/android/settings/panel/SettingsPanelActivityTest.java
+++ b/tests/robotests/src/com/android/settings/panel/SettingsPanelActivityTest.java
@@ -65,7 +65,7 @@
mPanelFeatureProvider = spy(new PanelFeatureProviderImpl());
mFakeFeatureFactory.panelFeatureProvider = mPanelFeatureProvider;
mFakePanelContent = new FakePanelContent();
- doReturn(mFakePanelContent).when(mPanelFeatureProvider).getPanel(any(), any(), any());
+ doReturn(mFakePanelContent).when(mPanelFeatureProvider).getPanel(any(), any());
}
@Test
diff --git a/tests/robotests/src/com/android/settings/password/ChooseLockPasswordTest.java b/tests/robotests/src/com/android/settings/password/ChooseLockPasswordTest.java
index 084d710..4bbf51d 100644
--- a/tests/robotests/src/com/android/settings/password/ChooseLockPasswordTest.java
+++ b/tests/robotests/src/com/android/settings/password/ChooseLockPasswordTest.java
@@ -77,7 +77,6 @@
SettingsShadowResources.overrideResource(
com.android.internal.R.string.config_headlineFontFamily, "");
mShadowDpm = ShadowDevicePolicyManager.getShadow();
- mShadowDpm.setPasswordMaximumLength(16);
}
@After
@@ -157,7 +156,7 @@
/* minComplexity= */ PASSWORD_COMPLEXITY_NONE,
/* passwordType= */ PASSWORD_QUALITY_ALPHABETIC,
/* userEnteredPassword= */ LockscreenCredential.createNone(),
- "Must contain at least 1 letter",
+ "Must contain at least 1 non-numerical character",
"Must be at least 10 characters");
}
@@ -180,7 +179,7 @@
/* minComplexity= */ PASSWORD_COMPLEXITY_MEDIUM,
/* passwordType= */ PASSWORD_QUALITY_ALPHABETIC,
/* userEnteredPassword= */ LockscreenCredential.createNone(),
- "Must contain at least 1 letter",
+ "Must contain at least 1 non-numerical character",
"Must be at least 4 characters");
}
@@ -193,7 +192,7 @@
/* minComplexity= */ PASSWORD_COMPLEXITY_LOW,
/* passwordType= */ PASSWORD_QUALITY_ALPHABETIC,
/* userEnteredPassword= */ LockscreenCredential.createNone(),
- "Must contain at least 1 letter",
+ "Must contain at least 1 non-numerical character",
"Must contain at least 1 numerical digit",
"Must be at least 9 characters");
}
@@ -220,7 +219,9 @@
/* passwordType= */ PASSWORD_QUALITY_ALPHABETIC,
/* userEnteredPassword= */ LockscreenCredential.createNone(),
"Must contain at least 2 special symbols",
- "Must be at least 6 characters");
+ "Must be at least 6 characters",
+ "Must contain at least 1 letter",
+ "Must contain at least 1 numerical digit");
}
@Test
@@ -280,7 +281,7 @@
/* minComplexity= */ PASSWORD_COMPLEXITY_LOW,
/* passwordType= */ PASSWORD_QUALITY_ALPHABETIC,
/* userEnteredPassword= */ LockscreenCredential.createPassword("12345678"),
- "Must contain at least 1 letter");
+ "Ascending, descending, or repeated sequence of digits isn't allowed");
}
@Test
@@ -291,8 +292,8 @@
/* minComplexity= */ PASSWORD_COMPLEXITY_HIGH,
/* passwordType= */ PASSWORD_QUALITY_ALPHABETIC,
/* userEnteredPassword= */ LockscreenCredential.createNone(),
- "Must contain at least 1 letter",
- "Must be at least 6 characters");
+ "Must be at least 6 characters",
+ "Must contain at least 1 non-numerical character");
}
@Test
@@ -303,8 +304,8 @@
/* minComplexity= */ PASSWORD_COMPLEXITY_HIGH,
/* passwordType= */ PASSWORD_QUALITY_ALPHABETIC,
/* userEnteredPassword= */ LockscreenCredential.createPassword("1"),
- "Must contain at least 1 letter",
- "Must be at least 6 characters");
+ "Must be at least 6 characters",
+ "Must contain at least 1 non-numerical character");
}
@Test
@@ -330,6 +331,28 @@
}
@Test
+ public void processAndValidatePasswordRequirements_defaultPinMinimumLength() {
+ mShadowDpm.setPasswordQuality(PASSWORD_QUALITY_UNSPECIFIED);
+
+ assertPasswordValidationResult(
+ /* minComplexity= */ PASSWORD_COMPLEXITY_NONE,
+ /* passwordType= */ PASSWORD_QUALITY_NUMERIC,
+ /* userEnteredPassword= */ LockscreenCredential.createPassword("11"),
+ "PIN must be at least 4 digits");
+ }
+
+ @Test
+ public void processAndValidatePasswordRequirements_maximumLength() {
+ mShadowDpm.setPasswordQuality(PASSWORD_QUALITY_UNSPECIFIED);
+
+ assertPasswordValidationResult(
+ /* minComplexity= */ PASSWORD_COMPLEXITY_NONE,
+ /* passwordType= */ PASSWORD_QUALITY_ALPHABETIC,
+ LockscreenCredential.createPassword("01234567890123456789"),
+ "Must be fewer than 17 characters");
+ }
+
+ @Test
public void assertThat_chooseLockIconChanged_WhenFingerprintExtraSet() {
ShadowDrawable drawable = setActivityAndGetIconDrawable(true);
assertThat(drawable.getCreatedFromResId()).isEqualTo(R.drawable.ic_fingerprint_header);
@@ -369,9 +392,8 @@
intent.putExtra(EXTRA_KEY_REQUESTED_MIN_COMPLEXITY, minComplexity);
ChooseLockPassword activity = buildChooseLockPasswordActivity(intent);
ChooseLockPasswordFragment fragment = getChooseLockPasswordFragment(activity);
- int validateResult = fragment.validatePassword(userEnteredPassword);
- String[] messages = fragment.convertErrorCodeToMessages(validateResult);
-
+ fragment.validatePassword(userEnteredPassword);
+ String[] messages = fragment.convertErrorCodeToMessages();
assertThat(messages).asList().containsExactly((Object[]) expectedValidationResult);
}
}
diff --git a/tests/robotests/src/com/android/settings/password/SetupChooseLockPasswordTest.java b/tests/robotests/src/com/android/settings/password/SetupChooseLockPasswordTest.java
index aeb16e6..77058c0 100644
--- a/tests/robotests/src/com/android/settings/password/SetupChooseLockPasswordTest.java
+++ b/tests/robotests/src/com/android/settings/password/SetupChooseLockPasswordTest.java
@@ -34,6 +34,7 @@
import com.android.settings.password.SetupChooseLockPassword.SetupChooseLockPasswordFragment;
import com.android.settings.testutils.shadow.SettingsShadowResources;
import com.android.settings.testutils.shadow.ShadowAlertDialogCompat;
+import com.android.settings.testutils.shadow.ShadowDevicePolicyManager;
import com.android.settings.testutils.shadow.ShadowLockPatternUtils;
import com.android.settings.testutils.shadow.ShadowUtils;
import com.android.settings.widget.ScrollToParentEditText;
@@ -62,6 +63,7 @@
shadows = {
SettingsShadowResources.class,
ShadowLockPatternUtils.class,
+ ShadowDevicePolicyManager.class,
ShadowUtils.class,
ShadowAlertDialogCompat.class
})
diff --git a/tests/robotests/src/com/android/settings/search/actionbar/SearchMenuControllerTest.java b/tests/robotests/src/com/android/settings/search/actionbar/SearchMenuControllerTest.java
index 3063912..e2b896a 100644
--- a/tests/robotests/src/com/android/settings/search/actionbar/SearchMenuControllerTest.java
+++ b/tests/robotests/src/com/android/settings/search/actionbar/SearchMenuControllerTest.java
@@ -17,29 +17,33 @@
package com.android.settings.search.actionbar;
import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.verifyZeroInteractions;
import static org.mockito.Mockito.when;
import android.app.settings.SettingsEnums;
-import android.content.Context;
+import android.content.Intent;
import android.os.Bundle;
import android.provider.Settings.Global;
import android.view.Menu;
import android.view.MenuItem;
+import androidx.fragment.app.FragmentActivity;
+
import com.android.settings.R;
import com.android.settings.core.InstrumentedFragment;
-import com.android.settings.core.InstrumentedPreferenceFragment;
import com.android.settings.testutils.shadow.ShadowUtils;
+import com.google.android.setupcompat.util.WizardManagerHelper;
+
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
+import org.robolectric.Robolectric;
import org.robolectric.RobolectricTestRunner;
-import org.robolectric.RuntimeEnvironment;
import org.robolectric.annotation.Config;
@RunWith(RobolectricTestRunner.class)
@@ -48,41 +52,28 @@
@Mock
private Menu mMenu;
- private TestPreferenceFragment mPreferenceHost;
private InstrumentedFragment mHost;
- private Context mContext;
+ private FragmentActivity mActivity;
@Before
public void setUp() {
MockitoAnnotations.initMocks(this);
- mContext = RuntimeEnvironment.application;
- mHost = new InstrumentedFragment() {
- @Override
- public Context getContext() {
- return mContext;
- }
+ mActivity = Robolectric.buildActivity(FragmentActivity.class).get();
+ mHost = spy(new InstrumentedFragment() {
@Override
public int getMetricsCategory() {
return SettingsEnums.TESTING;
}
- };
- mPreferenceHost = new TestPreferenceFragment();
- Global.putInt(mContext.getContentResolver(), Global.DEVICE_PROVISIONED, 1);
+ });
+ Global.putInt(mActivity.getContentResolver(), Global.DEVICE_PROVISIONED, 1);
+ when(mHost.getActivity()).thenReturn(mActivity);
when(mMenu.add(Menu.NONE, Menu.NONE, 0 /* order */, R.string.search_menu))
.thenReturn(mock(MenuItem.class));
}
@Test
- public void init_prefFragment_shouldAddMenu() {
- SearchMenuController.init(mPreferenceHost);
- mPreferenceHost.getSettingsLifecycle().onCreateOptionsMenu(mMenu, null /* inflater */);
-
- verify(mMenu).add(Menu.NONE, Menu.NONE, 0 /* order */, R.string.search_menu);
- }
-
- @Test
public void init_observableFragment_shouldAddMenu() {
SearchMenuController.init(mHost);
mHost.getSettingsLifecycle().onCreateOptionsMenu(mMenu, null /* inflater */);
@@ -103,26 +94,22 @@
@Test
public void init_deviceNotProvisioned_shouldNotAddMenu() {
- Global.putInt(mContext.getContentResolver(), Global.DEVICE_PROVISIONED, 0);
+ Global.putInt(mActivity.getContentResolver(), Global.DEVICE_PROVISIONED, 0);
SearchMenuController.init(mHost);
mHost.getSettingsLifecycle().onCreateOptionsMenu(mMenu, null /* inflater */);
verifyZeroInteractions(mMenu);
}
- private static class TestPreferenceFragment extends InstrumentedPreferenceFragment {
- @Override
- public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
- }
+ @Test
+ public void init_startFromSetupWizard_shouldNotAddMenu() {
+ final Intent intent = new Intent();
+ intent.putExtra(WizardManagerHelper.EXTRA_IS_SETUP_FLOW, true);
+ mActivity.setIntent(intent);
+ SearchMenuController.init(mHost);
- @Override
- public Context getContext() {
- return RuntimeEnvironment.application;
- }
+ mHost.getSettingsLifecycle().onCreateOptionsMenu(mMenu, null /* inflater */);
- @Override
- public int getMetricsCategory() {
- return SettingsEnums.TESTING;
- }
+ verifyZeroInteractions(mMenu);
}
}
diff --git a/tests/robotests/src/com/android/settings/security/InstallCertificateFromStorageTest.java b/tests/robotests/src/com/android/settings/security/InstallCertificateFromStorageTest.java
new file mode 100644
index 0000000..61c39fc
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/security/InstallCertificateFromStorageTest.java
@@ -0,0 +1,87 @@
+/*
+ * Copyright (C) 2019 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.settings.security;
+
+import static com.android.settings.security.InstallCertificateFromStorage.SEARCH_INDEX_DATA_PROVIDER;
+
+import static com.google.common.truth.Truth.assertThat;
+
+import android.app.admin.DevicePolicyManager;
+import android.app.settings.SettingsEnums;
+import android.content.Context;
+import android.os.UserManager;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+import org.robolectric.RobolectricTestRunner;
+import org.robolectric.RuntimeEnvironment;
+import org.robolectric.shadows.ShadowApplication;
+
+import java.util.ArrayList;
+import java.util.List;
+
+@RunWith(RobolectricTestRunner.class)
+public class InstallCertificateFromStorageTest {
+
+ @Mock
+ private UserManager mUserManager;
+
+ @Mock
+ private DevicePolicyManager mDevicePolicyManager;
+
+ private Context mContext;
+
+ private List<String> mTestKeys;
+
+ @Before
+ public void setUp() {
+ MockitoAnnotations.initMocks(this);
+ ShadowApplication application = ShadowApplication.getInstance();
+ application.setSystemService(Context.DEVICE_POLICY_SERVICE, mDevicePolicyManager);
+ application.setSystemService(Context.USER_SERVICE, mUserManager);
+ mContext = RuntimeEnvironment.application;
+ setUpTestKeys();
+ }
+
+ private void setUpTestKeys() {
+ mTestKeys = new ArrayList<>();
+ mTestKeys.add("install_certificate_from_storage");
+ mTestKeys.add("certificate_types");
+ mTestKeys.add("install_ca_certificate");
+ mTestKeys.add("install_user_certificate");
+ mTestKeys.add("install_wifi_certificate");
+ }
+
+ @Test
+ public void getMetricsCategory_shouldReturnInstallCertificateFromStorage() {
+ InstallCertificateFromStorage fragment = new InstallCertificateFromStorage();
+ assertThat(fragment.getMetricsCategory()).isEqualTo(
+ SettingsEnums.INSTALL_CERTIFICATE_FROM_STORAGE);
+ }
+
+ @Test
+ public void getNonIndexableKeys_existInXmlLayout() {
+ final List<String> nonIndexableKeys =
+ SEARCH_INDEX_DATA_PROVIDER.getNonIndexableKeys(mContext);
+
+ assertThat(nonIndexableKeys).containsAllIn(mTestKeys);
+ }
+
+}
diff --git a/tests/robotests/src/com/android/settings/security/RestrictedEncryptionPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/security/RestrictedEncryptionPreferenceControllerTest.java
index 79ece90..672d317 100644
--- a/tests/robotests/src/com/android/settings/security/RestrictedEncryptionPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/security/RestrictedEncryptionPreferenceControllerTest.java
@@ -40,9 +40,12 @@
private Context mContext;
private ShadowUserManager mUserManager;
private CredentialStoragePreferenceController mCredentialStoragePreferenceController;
- private InstallCredentialsPreferenceController mInstallCredentialsPreferenceController;
+ private InstallCertificatePreferenceController mInstallCertificatePreferenceController;
private ResetCredentialsPreferenceController mResetCredentialsPreferenceController;
private UserCredentialsPreferenceController mUserCredentialsPreferenceController;
+ private InstallCaCertificatePreferenceController mInstallCaCertificatePreferenceController;
+ private InstallUserCertificatePreferenceController mInstallUserCertificatePreferenceController;
+ private InstallWifiCertificatePreferenceController mInstallWifiCertificatePreferenceController;
private Lifecycle mLifecycle;
private LifecycleOwner mLifecycleOwner;
@@ -53,21 +56,30 @@
mLifecycle = new Lifecycle(mLifecycleOwner);
mCredentialStoragePreferenceController =
new CredentialStoragePreferenceController(mContext);
- mInstallCredentialsPreferenceController =
- new InstallCredentialsPreferenceController(mContext);
+ mInstallCertificatePreferenceController =
+ new InstallCertificatePreferenceController(mContext);
mResetCredentialsPreferenceController =
new ResetCredentialsPreferenceController(mContext, mLifecycle);
mUserCredentialsPreferenceController =
new UserCredentialsPreferenceController(mContext);
+ mInstallCaCertificatePreferenceController =
+ new InstallCaCertificatePreferenceController(mContext);
+ mInstallUserCertificatePreferenceController =
+ new InstallUserCertificatePreferenceController(mContext);
+ mInstallWifiCertificatePreferenceController =
+ new InstallWifiCertificatePreferenceController(mContext);
mUserManager = ShadowUserManager.getShadow();
}
@Test
public void isAvailable_noRestriction_shouldReturnTrue() {
assertThat(mCredentialStoragePreferenceController.isAvailable()).isTrue();
- assertThat(mInstallCredentialsPreferenceController.isAvailable()).isTrue();
+ assertThat(mInstallCertificatePreferenceController.isAvailable()).isTrue();
assertThat(mResetCredentialsPreferenceController.isAvailable()).isTrue();
assertThat(mUserCredentialsPreferenceController.isAvailable()).isTrue();
+ assertThat(mInstallCaCertificatePreferenceController.isAvailable()).isTrue();
+ assertThat(mInstallUserCertificatePreferenceController.isAvailable()).isTrue();
+ assertThat(mInstallWifiCertificatePreferenceController.isAvailable()).isTrue();
}
@Test
@@ -75,8 +87,11 @@
mUserManager.addBaseUserRestriction(UserManager.DISALLOW_CONFIG_CREDENTIALS);
assertThat(mCredentialStoragePreferenceController.isAvailable()).isFalse();
- assertThat(mInstallCredentialsPreferenceController.isAvailable()).isFalse();
+ assertThat(mInstallCertificatePreferenceController.isAvailable()).isFalse();
assertThat(mResetCredentialsPreferenceController.isAvailable()).isFalse();
assertThat(mUserCredentialsPreferenceController.isAvailable()).isFalse();
+ assertThat(mInstallCaCertificatePreferenceController.isAvailable()).isFalse();
+ assertThat(mInstallUserCertificatePreferenceController.isAvailable()).isFalse();
+ assertThat(mInstallWifiCertificatePreferenceController.isAvailable()).isFalse();
}
}
\ No newline at end of file
diff --git a/tests/robotests/src/com/android/settings/testutils/shadow/ShadowDevicePolicyManager.java b/tests/robotests/src/com/android/settings/testutils/shadow/ShadowDevicePolicyManager.java
index ca75916..b8fdf89 100644
--- a/tests/robotests/src/com/android/settings/testutils/shadow/ShadowDevicePolicyManager.java
+++ b/tests/robotests/src/com/android/settings/testutils/shadow/ShadowDevicePolicyManager.java
@@ -6,6 +6,8 @@
import android.annotation.Nullable;
import android.annotation.UserIdInt;
import android.app.admin.DevicePolicyManager;
+import android.app.admin.PasswordMetrics;
+import android.app.admin.PasswordPolicy;
import android.content.ComponentName;
import org.robolectric.RuntimeEnvironment;
@@ -26,7 +28,6 @@
private ComponentName mDeviceOwnerComponentName;
private int mDeviceOwnerUserId = -1;
private int mPasswordMinQuality = PASSWORD_QUALITY_UNSPECIFIED;
- private int mPasswordMaxLength = 16;
private int mPasswordMinLength = 0;
private int mPasswordMinSymbols = 0;
@@ -77,41 +78,26 @@
}
@Implementation
- public int getPasswordQuality(ComponentName admin, int userHandle) {
- return mPasswordMinQuality;
+ public PasswordMetrics getPasswordMinimumMetrics(int userHandle) {
+ PasswordPolicy policy = new PasswordPolicy();
+ policy.quality = mPasswordMinQuality;
+ policy.length = mPasswordMinLength;
+ policy.symbols = mPasswordMinSymbols;
+ return policy.getMinMetrics();
}
public void setPasswordQuality(int quality) {
mPasswordMinQuality = quality;
}
- @Implementation
- public int getPasswordMinimumLength(ComponentName admin, int userHandle) {
- return mPasswordMinLength;
- }
-
public void setPasswordMinimumLength(int length) {
mPasswordMinLength = length;
}
- @Implementation
- public int getPasswordMinimumSymbols(ComponentName admin, int userHandle) {
- return mPasswordMinSymbols;
- }
-
public void setPasswordMinimumSymbols(int numOfSymbols) {
mPasswordMinSymbols = numOfSymbols;
}
- @Implementation
- public int getPasswordMaximumLength(int quality) {
- return mPasswordMaxLength;
- }
-
- public void setPasswordMaximumLength(int length) {
- mPasswordMaxLength = length;
- }
-
public static ShadowDevicePolicyManager getShadow() {
return (ShadowDevicePolicyManager) Shadow.extract(
RuntimeEnvironment.application.getSystemService(DevicePolicyManager.class));
diff --git a/tests/robotests/src/com/android/settings/wifi/NetworkRequestDialogFragmentTest.java b/tests/robotests/src/com/android/settings/wifi/NetworkRequestDialogFragmentTest.java
index 4f75794..d292b73 100644
--- a/tests/robotests/src/com/android/settings/wifi/NetworkRequestDialogFragmentTest.java
+++ b/tests/robotests/src/com/android/settings/wifi/NetworkRequestDialogFragmentTest.java
@@ -17,6 +17,7 @@
package com.android.settings.wifi;
import static com.google.common.truth.Truth.assertThat;
+
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.times;
@@ -33,14 +34,16 @@
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
+
import androidx.appcompat.app.AlertDialog;
+import androidx.fragment.app.FragmentActivity;
+
import com.android.settings.R;
import com.android.settings.testutils.shadow.ShadowAlertDialogCompat;
import com.android.settingslib.wifi.AccessPoint;
import com.android.settingslib.wifi.WifiTracker;
import com.android.settingslib.wifi.WifiTrackerFactory;
-import java.util.ArrayList;
-import java.util.List;
+
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -49,6 +52,9 @@
import org.robolectric.RuntimeEnvironment;
import org.robolectric.annotation.Config;
+import java.util.ArrayList;
+import java.util.List;
+
@RunWith(RobolectricTestRunner.class)
@Config(shadows = ShadowAlertDialogCompat.class)
public class NetworkRequestDialogFragmentTest {
@@ -57,14 +63,14 @@
private static final String KEY_SECURITY = "key_security";
private static final String TEST_APP_NAME = "TestAppName";
- private NetworkRequestDialogActivity mActivity;
+ private FragmentActivity mActivity;
private NetworkRequestDialogFragment networkRequestDialogFragment;
private Context mContext;
private WifiTracker mWifiTracker;
@Before
public void setUp() {
- mActivity = Robolectric.buildActivity(NetworkRequestDialogActivity.class,
+ mActivity = Robolectric.buildActivity(FragmentActivity.class,
new Intent().putExtra(NetworkRequestDialogFragment.EXTRA_APP_NAME,
TEST_APP_NAME)).setup().get();
networkRequestDialogFragment = spy(NetworkRequestDialogFragment.newInstance());
@@ -108,7 +114,6 @@
@Test
public void onUserSelectionCallbackRegistration_onClick_shouldCallSelect() {
- // Assert.
final int indexClickItem = 3;
List<AccessPoint> accessPointList = createAccessPointList();
AccessPoint clickedAccessPoint = accessPointList.get(indexClickItem);
@@ -129,7 +134,6 @@
@Test
public void onMatch_shouldUpdatedList() {
- // Assert.
when(networkRequestDialogFragment.getContext()).thenReturn(mContext);
Context applicationContext = spy(RuntimeEnvironment.application.getApplicationContext());
when(mContext.getApplicationContext()).thenReturn(applicationContext);
@@ -140,15 +144,15 @@
List<AccessPoint> accessPointList = createAccessPointList();
when(mWifiTracker.getAccessPoints()).thenReturn(accessPointList);
- final String SSID_AP1 = "Test AP 1";
- final String SSID_AP2 = "Test AP 2";
+ final String ssidAp1 = "Test AP 1";
+ final String ssidAp2 = "Test AP 2";
List<ScanResult> scanResults = new ArrayList<>();
ScanResult scanResult = new ScanResult();
- scanResult.SSID = SSID_AP1;
+ scanResult.SSID = ssidAp1;
scanResult.capabilities = "WEP";
scanResults.add(scanResult);
scanResult = new ScanResult();
- scanResult.SSID = SSID_AP2;
+ scanResult.SSID = ssidAp2;
scanResult.capabilities = "WEP";
scanResults.add(scanResult);
@@ -159,8 +163,43 @@
List<AccessPoint> returnList = networkRequestDialogFragment.getAccessPointList();
assertThat(returnList).isNotEmpty();
assertThat(returnList.size()).isEqualTo(2);
- assertThat(returnList.get(0).getSsid()).isEqualTo(SSID_AP1);
- assertThat(returnList.get(1).getSsid()).isEqualTo(SSID_AP2);
+ assertThat(returnList.get(0).getSsid()).isEqualTo(ssidAp1);
+ assertThat(returnList.get(1).getSsid()).isEqualTo(ssidAp2);
+ }
+
+ @Test
+ public void onAccessPointsChanged_shouldUpdatedList() {
+ when(networkRequestDialogFragment.getContext()).thenReturn(mContext);
+ Context applicationContext = spy(RuntimeEnvironment.application.getApplicationContext());
+ when(mContext.getApplicationContext()).thenReturn(applicationContext);
+ WifiManager wifiManager = mock(WifiManager.class);
+ when(applicationContext.getSystemService(Context.WIFI_SERVICE)).thenReturn(wifiManager);
+ networkRequestDialogFragment.onResume();
+
+ List<AccessPoint> accessPointList = new ArrayList<>();
+ when(mWifiTracker.getAccessPoints()).thenReturn(accessPointList);
+
+ final String ssidAp1 = "Test AP 1";
+ List<ScanResult> scanResults = new ArrayList<>();
+ ScanResult scanResult = new ScanResult();
+ scanResult.SSID = ssidAp1;
+ scanResult.capabilities = "WEP";
+ scanResults.add(scanResult);
+
+ // Act.
+ networkRequestDialogFragment.onMatch(scanResults);
+
+ accessPointList = createAccessPointList();
+ when(mWifiTracker.getAccessPoints()).thenReturn(accessPointList);
+
+ // Act.
+ networkRequestDialogFragment.mFilterWifiTracker.mWifiListener.onAccessPointsChanged();
+
+ // Check.
+ List<AccessPoint> returnList = networkRequestDialogFragment.getAccessPointList();
+ assertThat(returnList).isNotEmpty();
+ assertThat(returnList.size()).isEqualTo(1);
+ assertThat(returnList.get(0).getSsid()).isEqualTo(ssidAp1);
}
private List<AccessPoint> createAccessPointList() {
@@ -208,16 +247,14 @@
public void onMatchManyResult_showNeutralButton() {
networkRequestDialogFragment.show(mActivity.getSupportFragmentManager(), /* tag */ null);
final AlertDialog alertDialog = ShadowAlertDialogCompat.getLatestAlertDialog();
-
-
List<AccessPoint> accessPointList = createAccessPointList();
when(mWifiTracker.getAccessPoints()).thenReturn(accessPointList);
- final String SSID_AP = "Test AP ";
+ final String ssidAp = "Test AP ";
final List<ScanResult> scanResults = new ArrayList<>();
for (int i = 0; i < 7 ; i ++) {
ScanResult scanResult = new ScanResult();
- scanResult.SSID = SSID_AP + i;
+ scanResult.SSID = ssidAp + i;
scanResult.capabilities = "WEP";
scanResults.add(scanResult);
}
@@ -230,15 +267,14 @@
@Test
public void clickNeutralButton_hideNeutralButton() {
- // Assert
networkRequestDialogFragment.show(mActivity.getSupportFragmentManager(), /* tag */ null);
final AlertDialog alertDialog = ShadowAlertDialogCompat.getLatestAlertDialog();
- final String SSID_AP = "Test AP ";
+ final String ssidAp = "Test AP ";
final List<ScanResult> scanResults = new ArrayList<>();
for (int i = 0; i < 6 ; i ++) {
ScanResult scanResult = new ScanResult();
- scanResult.SSID = SSID_AP + i;
+ scanResult.SSID = ssidAp + i;
scanResult.capabilities = "WEP";
scanResults.add(scanResult);
}
@@ -254,7 +290,6 @@
@Test
public void cancelDialog_callsReject() {
- // Assert
networkRequestDialogFragment.show(mActivity.getSupportFragmentManager(), /* tag */ null);
final AlertDialog alertDialog = ShadowAlertDialogCompat.getLatestAlertDialog();
final NetworkRequestUserSelectionCallback selectionCallback = mock(
diff --git a/tests/robotests/src/com/android/settings/wifi/WifiConfigControllerTest.java b/tests/robotests/src/com/android/settings/wifi/WifiConfigControllerTest.java
index 226dfdb..ab4bea8 100644
--- a/tests/robotests/src/com/android/settings/wifi/WifiConfigControllerTest.java
+++ b/tests/robotests/src/com/android/settings/wifi/WifiConfigControllerTest.java
@@ -557,4 +557,12 @@
assertThat(firstChild).isEqualTo(hiddenSettingLayout);
}
+
+ @Test
+ public void getAdvancedOptionContentDescription_whenViewInitialed_shouldBeCorrect() {
+ final CheckBox advButton = mView.findViewById(R.id.wifi_advanced_togglebox);
+
+ assertThat(advButton.getContentDescription()).isEqualTo(
+ mContext.getString(R.string.wifi_advanced_toggle_description));
+ }
}
diff --git a/tests/robotests/src/com/android/settings/wifi/details/WifiDetailPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/wifi/details/WifiDetailPreferenceControllerTest.java
index 4be0f01..81ac064 100644
--- a/tests/robotests/src/com/android/settings/wifi/details/WifiDetailPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/wifi/details/WifiDetailPreferenceControllerTest.java
@@ -992,6 +992,14 @@
updateNetworkCapabilities(nc);
inOrder.verify(mockHeaderController).setSummary(summary);
+ // UI will be refreshed when private DNS is broken.
+ summary = "Private DNS server cannot be accessed";
+ when(mockAccessPoint.getSettingsSummary(true /* convertSavedAsDisconnected */))
+ .thenReturn(summary);
+ nc.setPrivateDnsBroken(true);
+ updateNetworkCapabilities(nc);
+ inOrder.verify(mockHeaderController).setSummary(summary);
+
// UI will be refreshed when device connects to a partial connectivity network.
summary = "Limited connection";
when(mockAccessPoint.getSettingsSummary(true /*convertSavedAsDisconnected*/))
@@ -1866,7 +1874,7 @@
displayAndResume();
- verify(mockMacAddressPref).setTitle(R.string.wifi_advanced_factory_mac_address_title);
+ verify(mockMacAddressPref).setTitle(R.string.wifi_advanced_device_mac_address_title);
}
@Test
diff --git a/tests/robotests/src/com/android/settings/wifi/qrcode/QrCameraTest.java b/tests/robotests/src/com/android/settings/wifi/qrcode/QrCameraTest.java
index 3f67137..de0df73 100644
--- a/tests/robotests/src/com/android/settings/wifi/qrcode/QrCameraTest.java
+++ b/tests/robotests/src/com/android/settings/wifi/qrcode/QrCameraTest.java
@@ -18,14 +18,19 @@
import static com.google.common.truth.Truth.assertThat;
+import static org.mockito.ArgumentMatchers.anyInt;
import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.Matrix;
import android.graphics.Rect;
import android.graphics.SurfaceTexture;
-import android.util.Size;
+import android.hardware.Camera;
+import android.hardware.Camera.Parameters;
+import android.hardware.Camera.Size;
import com.google.zxing.BinaryBitmap;
import com.google.zxing.LuminanceSource;
@@ -33,9 +38,6 @@
import com.google.zxing.WriterException;
import com.google.zxing.common.HybridBinarizer;
-import java.util.concurrent.CountDownLatch;
-import java.util.concurrent.TimeUnit;
-
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -43,6 +45,12 @@
import org.robolectric.RobolectricTestRunner;
import org.robolectric.RuntimeEnvironment;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.TimeUnit;
+
@RunWith(RobolectricTestRunner.class)
public class QrCameraTest {
@@ -58,12 +66,12 @@
private class ScannerTestCallback implements QrCamera.ScannerCallback {
@Override
- public Size getViewSize() {
- return new Size(0, 0);
+ public android.util.Size getViewSize() {
+ return new android.util.Size(0, 0);
}
@Override
- public Rect getFramePosition(Size previewSize, int cameraOrientation) {
+ public Rect getFramePosition(android.util.Size previewSize, int cameraOrientation) {
return new Rect(0,0,0,0);
}
@@ -147,4 +155,22 @@
assertThat(mQrCode).isEqualTo(unicodeTest);
}
+
+ @Test
+ public void setCameraParameter_shouldSetParameters() {
+ mCamera.mCamera = mock(Camera.class);
+ Parameters parameters = mock(Camera.Parameters.class);
+ Size size = mCamera.mCamera.new Size(1920, 1440);
+ List<Camera.Size> sizes = new ArrayList<>(Arrays.asList(size));
+ when(parameters.getPreviewSize()).thenReturn(size);
+ when(parameters.getSupportedPreviewSizes()).thenReturn(sizes);
+ when(parameters.getSupportedPictureSizes()).thenReturn(sizes);
+ when(mCamera.mCamera.getParameters()).thenReturn(parameters);
+
+ mCamera.setCameraParameter();
+
+ verify(mCamera.mParameters).setPreviewSize(anyInt(), anyInt());
+ verify(mCamera.mParameters).setPictureSize(anyInt(), anyInt());
+ verify(mCamera.mCamera).setParameters(mCamera.mParameters);
+ }
}