Merge "Update string"
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index e236177..c48d51b 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -2107,26 +2107,6 @@
android:value="com.android.settings.wfd.WifiDisplaySettings" />
</activity>
- <activity
- android:name="RadioInfo"
- android:label="@string/phone_info_label"
- android:process="com.android.phone">
- <intent-filter>
- <action android:name="android.intent.action.MAIN" />
- <category android:name="android.intent.category.DEVELOPMENT_PREFERENCE" />
- </intent-filter>
- </activity>
-
- <activity android:name="BandMode"
- android:label="@string/band_mode_title"
- android:process="com.android.phone">
- <intent-filter>
- <action android:name="android.intent.action.MAIN" />
- <category android:name="android.intent.category.DEFAULT" />
- <category android:name="android.intent.category.VOICE_LAUNCH" />
- </intent-filter>
- </activity>
-
<activity android:name="Settings$TestingSettingsActivity" android:label="@string/testing">
<meta-data android:name="com.android.settings.FRAGMENT_CLASS"
android:value="com.android.settings.TestingSettings" />
diff --git a/PREUPLOAD.cfg b/PREUPLOAD.cfg
index 8e1ab2b..883e968 100644
--- a/PREUPLOAD.cfg
+++ b/PREUPLOAD.cfg
@@ -3,3 +3,4 @@
strings_lint_hook = ${REPO_ROOT}/frameworks/base/tools/stringslint/stringslint_sha.sh ${PREUPLOAD_COMMIT}
+checkstyle_hook = ${REPO_ROOT}/prebuilts/checkstyle/checkstyle.py --sha ${PREUPLOAD_COMMIT}
diff --git a/res/drawable/ic_suggestion_close_button.xml b/res/drawable/ic_suggestion_close_button.xml
index 615b215..8b1f0f8 100644
--- a/res/drawable/ic_suggestion_close_button.xml
+++ b/res/drawable/ic_suggestion_close_button.xml
@@ -18,8 +18,10 @@
android:width="24dp"
android:height="24dp"
android:viewportWidth="24.0"
- android:viewportHeight="24.0">
+ android:viewportHeight="24.0"
+ android:tint="?android:attr/colorControlNormal">
+
<path
- android:fillColor="#FF000000"
+ android:fillColor="@android:color/white"
android:pathData="M18.3,5.71a0.996,0.996 0,0 0,-1.41 0L12,10.59 7.11,5.7A0.996,0.996 0,1 0,5.7 7.11L10.59,12 5.7,16.89a0.996,0.996 0,1 0,1.41 1.41L12,13.41l4.89,4.89a0.996,0.996 0,1 0,1.41 -1.41L13.41,12l4.89,-4.89c0.38,-0.38 0.38,-1.02 0,-1.4z"/>
</vector>
diff --git a/res/layout/band_mode.xml b/res/layout/band_mode.xml
deleted file mode 100644
index b43dd1d..0000000
--- a/res/layout/band_mode.xml
+++ /dev/null
@@ -1,30 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2007 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:padding="4dip"
- android:gravity="center_horizontal"
- android:layout_width="match_parent"
- android:layout_height="wrap_content">
-
- <ListView android:id="@+id/band"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:textSize="7sp">
- </ListView>
-
-</LinearLayout>
diff --git a/res/layout/profile_select_tablayout.xml b/res/layout/profile_select_tablayout.xml
new file mode 100644
index 0000000..afacaae
--- /dev/null
+++ b/res/layout/profile_select_tablayout.xml
@@ -0,0 +1,42 @@
+<!--
+ 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"
+ xmlns:app="http://schemas.android.com/apk/res-auto"
+ android:theme="@style/Theme.MaterialComponents.DayNight"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:orientation="vertical">
+
+ <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/radio_info.xml b/res/layout/radio_info.xml
deleted file mode 100644
index 5c918fc..0000000
--- a/res/layout/radio_info.xml
+++ /dev/null
@@ -1,414 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
-/* //device/apps/Settings/assets/res/any/layout/radio_info.xml
-**
-** Copyright 2006, 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="match_parent"
- android:layout_height="match_parent">
-
- <LinearLayout style="@style/info_layout"
- android:descendantFocusability="beforeDescendants"
- android:focusableInTouchMode="true">
-
- <!-- Phone index -->
- <TextView
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:text="@string/phone_index_label"
- style="@style/info_label"
- />
-
- <Spinner android:id="@+id/phoneIndex"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- />
-
- <!-- IMEI -->
- <LinearLayout style="@style/entry_layout">
- <TextView android:text="@string/radio_info_imei_label" style="@style/info_label" />
- <TextView android:id="@+id/imei" style="@style/info_value" />
- </LinearLayout>
-
- <!-- Phone Number -->
- <LinearLayout style="@style/entry_layout">
- <TextView android:text="@string/radio_info_phone_number_label" style="@style/info_label" />
- <TextView android:id="@+id/number" style="@style/info_value" />
- </LinearLayout>
-
- <!-- Subscription ID -->
- <LinearLayout style="@style/entry_layout">
- <TextView android:text="@string/radio_info_subid" style="@style/info_label" />
- <TextView android:id="@+id/subid" style="@style/info_value" />
- </LinearLayout>
-
- <!-- Default data subscription -->
- <LinearLayout style="@style/entry_layout">
- <TextView android:text="@string/radio_info_dds" style="@style/info_label" />
- <TextView android:id="@+id/dds" style="@style/info_value" />
- </LinearLayout>
-
- <!-- IMSI -->
- <LinearLayout style="@style/entry_layout">
- <TextView android:text="@string/radio_info_imsi_label" style="@style/info_label" />
- <TextView android:id="@+id/imsi" style="@style/info_value" />
- </LinearLayout>
-
- <!-- Network Identifier -->
- <LinearLayout style="@style/entry_layout">
- <TextView android:text="@string/radio_info_current_network_label" style="@style/info_label" />
- <TextView android:id="@+id/operator" style="@style/info_value" />
- </LinearLayout>
-
- <!-- Roaming -->
- <LinearLayout style="@style/entry_layout">
- <TextView android:text="@string/radio_info_roaming_label" style="@style/info_label" />
- <TextView android:id="@+id/roaming" style="@style/info_value" />
- </LinearLayout>
-
- <!-- Data Service Status -->
- <LinearLayout style="@style/entry_layout">
- <TextView android:text="@string/radio_info_gprs_service_label" style="@style/info_label" />
- <TextView android:id="@+id/gprs" style="@style/info_value" />
- </LinearLayout>
-
- <!-- Data Network Type -->
- <LinearLayout style="@style/entry_layout">
- <TextView android:text="@string/radio_info_data_network_type_label" style="@style/info_label" />
- <TextView android:id="@+id/data_network" style="@style/info_value" />
- </LinearLayout>
-
- <!-- Voice Service Status -->
- <LinearLayout style="@style/entry_layout">
- <TextView android:text="@string/radio_info_gsm_service_label" style="@style/info_label" />
- <TextView android:id="@+id/gsm" style="@style/info_value" />
- </LinearLayout>
-
- <!-- Voice Network Type -->
- <LinearLayout style="@style/entry_layout">
- <TextView android:text="@string/radio_info_voice_network_type_label" style="@style/info_label" />
- <TextView android:id="@+id/voice_network" style="@style/info_value" />
- </LinearLayout>
-
- <!-- Signal Strength -->
- <LinearLayout style="@style/entry_layout">
- <TextView android:text="@string/radio_info_signal_strength_label" style="@style/info_label" />
- <TextView android:id="@+id/dbm" style="@style/info_value" />
- </LinearLayout>
-
- <!-- Link Bandwidth -->
- <LinearLayout style="@style/entry_layout" android:orientation="horizontal">
- <TextView android:text="@string/radio_info_dl_kbps" style="@style/info_label" />
- <TextView android:id="@+id/dl_kbps" style="@style/info_value" />
- </LinearLayout>
-
- <!-- Link Bandwidth -->
- <LinearLayout style="@style/entry_layout" android:orientation="horizontal">
- <TextView android:text="@string/radio_info_ul_kbps" style="@style/info_label" />
- <TextView android:id="@+id/ul_kbps" style="@style/info_value" />
- </LinearLayout>
-
- <!-- Physical Channel Config -->
- <LinearLayout style="@style/entry_layout">
- <TextView android:text="@string/radio_info_phy_chan_config" style="@style/info_label" />
- <TextView android:id="@+id/phy_chan_config" style="@style/info_value" />
- </LinearLayout>
-
- <!-- Horizontal Rule -->
- <View
- android:layout_width="fill_parent"
- android:layout_height="1dip"
- android:background="?android:attr/listDivider" />
-
- <!-- Preferred Network Type -->
- <TextView
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:text="@string/radio_info_set_perferred_label"
- style="@style/info_label"
- />
-
- <Spinner android:id="@+id/preferredNetworkType"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- />
-
- <!-- Horizontal Rule -->
- <View
- android:layout_width="fill_parent"
- android:layout_height="1dip"
- android:background="?android:attr/listDivider" />
-
- <!-- Radio Power -->
- <Switch android:id="@+id/radio_power"
- android:textSize="14sp"
- android:layout_marginTop="8dip"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:text="@string/radio_info_radio_power"/>
-
- <!-- VoLTE provisioned -->
- <Switch android:id="@+id/volte_provisioned_switch"
- android:textSize="14sp"
- android:layout_marginTop="8dip"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:text="@string/volte_provisioned_switch_string"/>
-
- <!-- VT provisioned -->
- <Switch android:id="@+id/vt_provisioned_switch"
- android:textSize="14sp"
- android:layout_marginTop="8dip"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:text="@string/vt_provisioned_switch_string"/>
-
- <!-- Wifi Calling provisioned -->
- <Switch android:id="@+id/wfc_provisioned_switch"
- android:textSize="14sp"
- android:layout_marginTop="8dip"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:text="@string/wfc_provisioned_switch_string"/>
-
- <!-- EAB/Presence provisioned -->
- <Switch android:id="@+id/eab_provisioned_switch"
- android:textSize="14sp"
- android:layout_marginTop="8dip"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:text="@string/eab_provisioned_switch_string"/>
-
- <!-- Horizontal Rule -->
- <View
- android:layout_width="fill_parent"
- android:layout_height="1dip"
- android:background="?android:attr/listDivider" />
-
- <!-- Enable/Disable CBRS data -->
- <Switch android:id="@+id/cbrs_data_switch"
- android:textSize="14sp"
- android:layout_marginTop="8dip"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:text="@string/cbrs_data_switch_string" />
-
- <!-- Switch between SSSS(single sim single standby) and DSDS(dual sim dual standby). -->
- <Switch android:id="@+id/dsds_switch"
- android:textSize="14sp"
- android:layout_marginTop="8dip"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:text="@string/dsds_switch_string" />
-
- <!-- Horizontal Rule -->
- <View
- android:layout_width="fill_parent"
- android:layout_height="1dip"
- android:background="?android:attr/listDivider" />
-
- <!-- Ping stats -->
- <Button android:id="@+id/ping_test"
- android:textSize="14sp"
- android:layout_marginTop="8dip"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="@string/ping_test_label"
- />
-
- <LinearLayout style="@style/entry_layout">
- <TextView android:text="@string/radio_info_ping_hostname_v4" style="@style/info_label" />
- <TextView android:id="@+id/pingHostnameV4" style="@style/info_value" />
- </LinearLayout>
-
- <LinearLayout style="@style/entry_layout">
- <TextView android:text="@string/radio_info_ping_hostname_v6" style="@style/info_label" />
- <TextView android:id="@+id/pingHostnameV6" style="@style/info_value" />
- </LinearLayout>
-
- <LinearLayout style="@style/entry_layout">
- <TextView android:text="@string/radio_info_http_client_test" style="@style/info_label" />
- <TextView android:id="@+id/httpClientTest" style="@style/info_value" />
- </LinearLayout>
-
- <!-- Horizontal Rule -->
- <View
- android:layout_width="fill_parent"
- android:layout_height="1dip"
- android:background="?android:attr/listDivider" />
-
- <!-- PPP Sent -->
- <LinearLayout style="@style/entry_layout">
- <TextView android:text="@string/radio_info_ppp_sent_label"
- style="@style/info_label" />
- <TextView android:id="@+id/sent" style="@style/info_value" />
- </LinearLayout>
-
- <!-- PPP Received -->
- <LinearLayout style="@style/entry_layout">
- <TextView android:text="@string/radio_info_ppp_received_label"
- style="@style/info_label" />
- <TextView android:id="@+id/received" style="@style/info_value" />
- </LinearLayout>
-
- <!-- PPP Sent since last received -->
- <LinearLayout style="@style/entry_layout">
- <TextView android:text="@string/radio_info_ppp_resets_label"
- style="@style/info_label" />
- <TextView android:id="@+id/sentSinceReceived" style="@style/info_value" />
- </LinearLayout>
-
- <!-- Horizontal Rule -->
- <View
- android:layout_width="fill_parent"
- android:layout_height="1dip"
- android:background="?android:attr/listDivider" />
-
- <!-- Call Status -->
- <LinearLayout style="@style/entry_layout">
- <TextView android:text="@string/radio_info_call_status_label" style="@style/info_label" />
- <TextView android:id="@+id/call" style="@style/info_value" />
- </LinearLayout>
-
- <!-- Message Waiting Indicator -->
- <LinearLayout style="@style/entry_layout">
- <TextView android:text="@string/radio_info_message_waiting_label" style="@style/info_label" />
- <TextView android:id="@+id/mwi" style="@style/info_value" />
- </LinearLayout>
-
- <!-- Call Forwarding Indicator -->
- <LinearLayout style="@style/entry_layout">
- <TextView android:text="@string/radio_info_call_redirect_label" style="@style/info_label" />
- <TextView android:id="@+id/cfi" style="@style/info_value" />
- </LinearLayout>
-
- <!-- Horizontal Rule -->
- <View
- android:layout_width="fill_parent"
- android:layout_height="1dip"
- android:background="?android:attr/listDivider" />
-
- <!-- CellInfoListRate Selection -->
- <!-- Location -->
- <LinearLayout style="@style/entry_layout">
- <TextView android:text="@string/radio_info_signal_location_label" style="@style/info_label" />
- <TextView android:id="@+id/location" style="@style/info_value" />
- </LinearLayout>
-
- <TextView
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:text="@string/radio_info_cell_info_refresh_rate"
- style="@style/info_label"
- />
-
- <Spinner android:id="@+id/cell_info_rate_select"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- />
-
- <!-- CellInfo -->
- <LinearLayout style="@style/entry_layout">
- <TextView android:text="@string/radio_info_cellinfo_label"
- style="@style/info_label" />
- </LinearLayout>
- <LinearLayout style="@style/entry_layout">
- <TextView android:id="@+id/cellinfo"
- style="@style/info_value"
- android:minHeight="300dip"
- android:textSize="12sp" />
- </LinearLayout>
-
- <!-- Horizontal Rule -->
- <View
- android:layout_width="fill_parent"
- android:layout_height="1dip"
- android:background="?android:attr/listDivider" />
-
- <!-- Launch OEM-specific Info/Settings Activity (if any) -->
- <!-- Carrier Provisioning -->
- <LinearLayout style="@style/entry_layout"
- android:orientation="horizontal" >
- <Button android:id="@+id/carrier_provisioning"
- android:layout_marginTop="8dip"
- android:layout_weight="1"
- android:layout_width="0dp"
- android:layout_height="wrap_content"
- android:text="@string/carrier_provisioning"
- android:textSize="14sp"/>
- <Button android:id="@+id/trigger_carrier_provisioning"
- android:layout_marginTop="8dip"
- android:layout_weight="1"
- android:layout_width="0dp"
- android:layout_height="wrap_content"
- android:text="@string/trigger_carrier_provisioning"
- android:textSize="14sp"/>
- <Button android:id="@+id/oem_info"
- android:layout_marginTop="8dip"
- android:layout_weight="1"
- android:layout_width="0dp"
- android:layout_height="wrap_content"
- android:text="@string/oem_radio_info_label"
- android:textSize="14sp"/>
- </LinearLayout>
-
- <!-- SMSC -->
- <RelativeLayout android:layout_width="match_parent"
- android:layout_height="wrap_content">
- <TextView android:id="@+id/smsc_label"
- android:text="@string/radio_info_smsc_label"
- android:layout_alignBaseline="@+id/update_smsc"
- style="@style/info_label" />
- <Button android:id="@+id/refresh_smsc"
- android:textSize="14sp"
- android:layout_marginTop="8dip"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="@string/radio_info_smsc_refresh_label"
- android:layout_alignParentEnd="true"
- />
- <Button android:id="@+id/update_smsc"
- android:textSize="14sp"
- android:layout_marginTop="8dip"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="@string/radio_info_smsc_update_label"
- android:layout_toStartOf="@+id/refresh_smsc"
- android:layout_alignBaseline="@+id/refresh_smsc"
- />
- <EditText android:id="@+id/smsc"
- style="@style/form_value"
- android:layout_alignBaseline="@+id/refresh_smsc"
- android:layout_toStartOf="@id/update_smsc"
- android:layout_toEndOf="@id/smsc_label" />
- </RelativeLayout>
-
- <!-- Test setting to ignore bad DNS, useful in lab environments -->
- <LinearLayout style="@style/entry_layout">
- <Button android:id="@+id/dns_check_toggle"
- android:textSize="14sp"
- android:layout_marginTop="8dip"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="@string/radio_info_toggle_dns_check_label"
- />
- <TextView android:id="@+id/dnsCheckState" style="@style/info_value" />
- </LinearLayout>
-
-
- </LinearLayout>
-</ScrollView>
diff --git a/res/layout/usage_view.xml b/res/layout/usage_view.xml
index c24f289..a98ec3e 100644
--- a/res/layout/usage_view.xml
+++ b/res/layout/usage_view.xml
@@ -35,7 +35,8 @@
android:orientation="vertical">
<include android:id="@+id/label_top"
- layout="@layout/usage_side_label" />
+ layout="@layout/usage_side_label"
+ android:contentDescription="@null" />
<Space
android:id="@+id/space1"
@@ -44,7 +45,8 @@
android:layout_weight="1" />
<include android:id="@+id/label_middle"
- layout="@layout/usage_side_label" />
+ layout="@layout/usage_side_label"
+ android:contentDescription="@null" />
<Space
android:id="@+id/space2"
@@ -53,7 +55,8 @@
android:layout_weight="1" />
<include android:id="@+id/label_bottom"
- layout="@layout/usage_side_label" />
+ layout="@layout/usage_side_label"
+ android:contentDescription="@null" />
</LinearLayout>
@@ -82,7 +85,8 @@
android:layout_weight="1"
android:orientation="horizontal">
<include android:id="@+id/label_start"
- layout="@layout/usage_side_label" />
+ layout="@layout/usage_side_label"
+ android:contentDescription="@null" />
<Space
android:id="@+id/spacer"
@@ -91,7 +95,8 @@
android:layout_weight="1" />
<include android:id="@+id/label_end"
- layout="@layout/usage_side_label" />
+ layout="@layout/usage_side_label"
+ android:contentDescription="@null" />
</com.android.settings.widget.BottomLabelLayout>
</LinearLayout>
diff --git a/res/values/arrays.xml b/res/values/arrays.xml
index c9460dd..75205e9 100644
--- a/res/values/arrays.xml
+++ b/res/values/arrays.xml
@@ -1254,7 +1254,7 @@
<item>LTE/TDSCDMA/CDMA/EVDO/GSM/WCDMA</item>
<item>NR only</item>
<item>NR/LTE</item>
- <item>NR/LTE/CDME/EvDo</item>
+ <item>NR/LTE/CDMA/EvDo</item>
<item>NR/LTE/GSM/WCDMA</item>
<item>NR/LTE/CDMA/EvDo/GSM/WCDMA</item>
<item>NR/LTE/WCDMA</item>
diff --git a/res/values/strings.xml b/res/values/strings.xml
index a7ae954..2ee24f3 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -46,69 +46,6 @@
<!-- Settings main menu category heading. System (Updates, data, accessibility, about phone). [CHAR LIMIT=40] -->
<string name="header_category_system">System</string>
- <!-- Data Connection Enable. Only shown in diagnostic screen, so precise translation is not needed. -->
- <string name="radio_info_data_connection_enable">Enable Data Connection</string>
- <!-- Data Connection Disable. Only shown in diagnostic screen, so precise translation is not needed. -->
- <string name="radio_info_data_connection_disable">Disable Data Connection</string>
-
- <!-- VoLTE provisioning flag on. Only shown in diagnostic screen, so precise translation is not needed. -->
- <string name="volte_provisioned_switch_string">VoLTE Provisioned</string>
-
- <!-- Video calling provisioning flag on. Only shown in diagnostic screen, so precise translation is not needed. -->
- <string name="vt_provisioned_switch_string">Video Calling Provisioned</string>
-
- <!-- Wifi Calling provisioning flag on. Only shown in diagnostic screen, so precise translation is not needed. -->
- <string name="wfc_provisioned_switch_string">Wifi Calling Provisioned</string>
-
- <!-- EAB provisioning flag on. Only shown in diagnostic screen, so precise translation is not needed. -->
- <string name="eab_provisioned_switch_string">EAB/Presence Provisioned</string>
-
- <!-- Cbrs enable disable flag. Only shown in diagnostic screen, so precise translation is not needed -->
- <string name="cbrs_data_switch_string">Cbrs Data</string>
-
- <!-- Dsds enable/disable flag. Only shown in diagnostic screen, so precise translation is not needed, [CHAR LIMIT=none] -->
- <string name="dsds_switch_string">Enable DSDS</string>
-
- <!-- UI debug setting: Enable/Disable DSDS [CHAR LIMIT=none] -->
- <string name="dsds_dialog_title">Restart Device?</string>
-
- <!-- UI debug setting: Enable/Disable DSDS [CHAR LIMIT=none] -->
- <string name="dsds_dialog_message">You need to restart your device to change this setting.</string>
-
- <!-- UI debug setting: Enable/Disable DSDS [CHAR LIMIT=none] -->
- <string name="dsds_dialog_confirm">Restart</string>
-
- <!-- UI debug setting: Enable/Disable DSDS [CHAR LIMIT=none] -->
- <string name="dsds_dialog_cancel">Cancel</string>
-
- <!-- Title for controlling on/off for Mobile phone's radio power. Only shown in diagnostic screen, so precise translation is not needed. -->
- <string name="radio_info_radio_power">Mobile Radio Power</string>
-
- <!-- Phone Info screen. Menu item label. Used for diagnostic info screens, precise translation isn't needed -->
- <string name="radioInfo_menu_viewADN">View SIM Address Book</string>
- <!-- Phone Info screen. Menu item label. Used for diagnostic info screens, precise translation isn't needed -->
- <string name="radioInfo_menu_viewFDN">View Fixed Dialing Numbers</string>
- <!-- Phone Info screen. Menu item label. Used for diagnostic info screens, precise translation isn't needed -->
- <string name="radioInfo_menu_viewSDN">View Service Dialing Numbers</string>
- <!-- Phone Info screen. Menu item label. Used for diagnostic info screens, precise translation isn't needed -->
- <string name="radioInfo_menu_getIMS">IMS Service Status</string>
-
- <!-- Phone Info screen. IMS Registration Title. Used for diagnostic info screens, precise translation isn't needed -->
- <string name="radio_info_ims_reg_status_title">IMS Status</string>
-
- <!-- Phone Info screen. IMS Status - Registered. Used for diagnostic info screens, precise translation isn't needed -->
- <string name="radio_info_ims_reg_status_registered">Registered</string>
- <!-- Phone Info screen. Ims Status - Unregistered. Used for diagnostic info screens, precise translation isn't needed -->
- <string name="radio_info_ims_reg_status_not_registered">Not Registered</string>
-
- <!-- Phone Info screen. Ims Feature Status label. Used for diagnostic info screens, precise translation isn't needed -->
- <string name="radio_info_ims_feature_status_available">Available</string>
- <!-- Phone Info screen. Ims Feature status label. Used for diagnostic info screens, precise translation isn't needed -->
- <string name="radio_info_ims_feature_status_unavailable">Unavailable</string>
-
- <!-- Phone Info screen. IMS Registration. Used for diagnostic info screens, precise translation isn't needed -->
- <string name="radio_info_ims_reg_status">IMS Registration: <xliff:g id="status" example="registered">%1$s</xliff:g>\u000AVoice over LTE: <xliff:g id="availability" example="available">%2$s</xliff:g>\u000AVoice over WiFi: <xliff:g id="availability" example="available">%3$s</xliff:g>\u000AVideo Calling: <xliff:g id="availability" example="available">%4$s</xliff:g>\u000AUT Interface: <xliff:g id="availability" example="available">%5$s</xliff:g></string>
-
<!-- Phone Info screen. Status label. Used for diagnostic info screens, precise translation isn't needed -->
<string name="radioInfo_service_in">In Service</string>
<!-- Phone Info screen. Status label. Used for diagnostic info screens, precise translation isn't needed -->
@@ -124,13 +61,6 @@
<string name="radioInfo_roaming_not">Not Roaming</string>
<!-- Phone Info screen. Status label. Used for diagnostic info screens, precise translation isn't needed -->
- <string name="radioInfo_phone_idle">Idle</string>
- <!-- Phone Info screen. Status label. Used for diagnostic info screens, precise translation isn't needed -->
- <string name="radioInfo_phone_ringing">Ringing</string>
- <!-- Phone Info screen. Status label. Used for diagnostic info screens, precise translation isn't needed -->
- <string name="radioInfo_phone_offhook">Call in Progress</string>
-
- <!-- Phone Info screen. Status label. Used for diagnostic info screens, precise translation isn't needed -->
<string name="radioInfo_data_disconnected">Disconnected</string>
<!-- Phone Info screen. Status label. Used for diagnostic info screens, precise translation isn't needed -->
<string name="radioInfo_data_connecting">Connecting</string>
@@ -141,18 +71,6 @@
<!-- Used for diagnostic info screens, precise translation isn't needed -->
<string name="radioInfo_unknown">Unknown</string>
- <!-- Phone Info screen. Units shown after a value. Used for diagnostic info screens, precise translation isn't needed -->
- <string name="radioInfo_display_packets">pkts</string>
- <!-- Phone Info screen. Units shown after a value. Used for diagnostic info screens, precise translation isn't needed -->
- <string name="radioInfo_display_bytes">bytes</string>
- <!-- Phone Info screen. Units shown after a value. Used for diagnostic info screens, precise translation isn't needed -->
- <string name="radioInfo_display_dbm">dBm</string>
- <!-- Phone Info screen. Units shown after a value. Used for diagnostic info screens, precise translation isn't needed -->
- <string name="radioInfo_display_asu">asu</string>
- <!-- Used for diagnostic info screens, precise translation isn't needed -->
- <string name="radioInfo_lac">LAC</string>
- <!-- Used for diagnostic info screens, precise translation isn't needed -->
- <string name="radioInfo_cid">CID</string>
<!-- Used for diagnostic info screens, precise translation isn't needed. Unmounts the SD card from the phone, meaning it will become available for an attached computer [CHAR LIMIT=25] -->
<string name="sdcard_unmount" product="nosdcard">Unmount USB storage</string>
@@ -485,60 +403,6 @@
<string name="proxy_url_title">"PAC URL: "</string>
<!-- Radio Info screen. Label for a status item. Used for diagnostic info screens, precise translation isn't needed -->
- <string name="radio_info_subid">Current subId:</string>
- <!-- Radio Info screen. Label for a status item. Used for diagnostic info screens, precise translation isn't needed -->
- <string name="radio_info_dds">SubId of default data SIM:</string>
- <!-- Radio Info screen. Label for a status item. Used for diagnostic info screens, precise translation isn't needed -->
- <string name="radio_info_dl_kbps">DL Bandwidth (kbps):</string>
- <!-- Radio Info screen. Label for a status item. Used for diagnostic info screens, precise translation isn't needed -->
- <string name="radio_info_ul_kbps">UL Bandwidth (kbps):</string>
- <!-- Radio Info screen. Label for a status item. Used for diagnostic info screens, precise translation isn't needed -->
- <string name="radio_info_signal_location_label">Cell Location Info (deprecated):</string>
- <!-- Radio Info screen. Label for a status item. Used for diagnostic info screens, precise translation isn't needed -->
- <string name="radio_info_phy_chan_config">LTE Physical Channel Configuration:</string>
- <!-- Radio Info screen. Label for a status item. Used for diagnostic info screens, precise translation isn't needed -->
- <string name="radio_info_cell_info_refresh_rate">Cell Info Refresh Rate:</string>
- <!-- Radio Info screen. Label for a status item. Used for diagnostic info screens, precise translation isn't needed -->
- <string name="radio_info_cellinfo_label">All Cell Measurement Info:</string>
- <!-- Radio Info screen. Label for a status item. Used for diagnostic info screens, precise translation isn't needed -->
- <string name="radio_info_gprs_service_label">Data Service:</string>
- <!-- Radio Info screen. Label for a status item. Used for diagnostic info screens, precise translation isn't needed -->
- <string name="radio_info_roaming_label">Roaming:</string>
- <!-- Radio Info screen. Label for a status item. Used for diagnostic info screens, precise translation isn't needed -->
- <string name="radio_info_imei_label">IMEI:</string>
- <!-- Radio Info screen. Label for a status item. Used for diagnostic info screens, DO NOT TRANSLATE. -->
- <string name="radio_info_imsi_label">IMSI:</string>
- <!-- Radio Info screen. Label for a status item. Used for diagnostic info screens, precise translation isn't needed -->
- <string name="radio_info_call_redirect_label">Call Redirect:</string>
- <!-- Radio Info screen. Label for a status item. Used for diagnostic info screens, precise translation isn't needed -->
- <string name="radio_info_ppp_resets_label">Number of PPP Reset Since Boot:</string>
- <!-- Radio Info screen. Label for a status item. Used for diagnostic info screens, precise translation isn't needed -->
- <string name="radio_info_current_network_label">Current Network:</string>
- <!-- Radio Info screen. Label for a status item. Used for diagnostic info screens, precise translation isn't needed -->
- <string name="radio_info_ppp_received_label">Data Received:</string>
- <!-- Radio Info screen. Label for a status item. Used for diagnostic info screens, precise translation isn't needed -->
- <string name="radio_info_gsm_service_label">Voice Service:</string>
- <!-- Radio Info screen. Label for a status item. Used for diagnostic info screens, precise translation isn't needed -->
- <string name="radio_info_signal_strength_label">Signal Strength:</string>
- <!-- Radio Info screen. Label for a status item. Used for diagnostic info screens, precise translation isn't needed -->
- <string name="radio_info_call_status_label">Voice Call Status:</string>
- <!-- Radio Info screen. Label for a status item. Used for diagnostic info screens, precise translation isn't needed -->
- <string name="radio_info_ppp_sent_label">Data Sent:</string>
- <!-- Radio Info screen. Label for a status item. Used for diagnostic info screens, precise translation isn't needed -->
- <string name="radio_info_message_waiting_label">Message Waiting:</string>
- <!-- Radio Info screen. Label for a status item. Used for diagnostic info screens, precise translation isn't needed -->
- <string name="radio_info_phone_number_label">Phone Number:</string>
- <!-- Radio Info screen. Label for a status item. Used for diagnostic info screens, precise translation isn't needed -->
- <string name="radio_info_band_mode_label">Select Radio Band</string>
- <!-- Radio Info screen. Label for a status item. Used for diagnostic info screens, precise translation isn't needed -->
- <string name="radio_info_voice_network_type_label">Voice Network Type:</string>
- <!-- Radio Info screen. Label for a status item. Used for diagnostic info screens, precise translation isn't needed -->
- <string name="radio_info_data_network_type_label">Data Network Type:</string>
- <!-- Radio Info screen. Label for a status item. Used for diagnostic info screens, precise translation isn't needed -->
- <string name="phone_index_label">Select phone index</string>
- <!-- Radio Info screen. Label for a status item. Used for diagnostic info screens, precise translation isn't needed -->
- <string name="radio_info_set_perferred_label">Set Preferred Network Type:</string>
- <!-- Radio Info screen. Label for a status item. Used for diagnostic info screens, precise translation isn't needed -->
<string name="radio_info_ping_hostname_v4">Ping Hostname(www.google.com) IPv4:</string>
<!-- Radio Info screen. Label for a status item. Used for diagnostic info screens, precise translation isn't needed -->
<string name="radio_info_ping_hostname_v6">Ping Hostname(www.google.com) IPv6:</string>
@@ -546,28 +410,6 @@
<string name="radio_info_http_client_test">HTTP Client Test:</string>
<!-- Radio Info screen. Label for a status item. Used for diagnostic info screens, precise translation isn't needed -->
<string name="ping_test_label">Run Ping Test</string>
- <!-- Radio Info screen. Label for a status item. Used for diagnostic info screens, precise translation isn't needed -->
- <string name="radio_info_smsc_label">SMSC:</string>
- <!-- Radio Info screen. Label for a status item. Used for diagnostic info screens, precise translation isn't needed -->
- <string name="radio_info_smsc_update_label">Update</string>
- <!-- Radio Info screen. Label for a status item. Used for diagnostic info screens, precise translation isn't needed -->
- <string name="radio_info_smsc_refresh_label">Refresh</string>
- <!-- Radio Info screen. Label for a status item. Used for diagnostic info screens, precise translation isn't needed -->
- <string name="radio_info_toggle_dns_check_label">Toggle DNS Check</string>
- <!-- Radio Info screen. Label for a status item. Used for diagnostic info screens, precise translation isn't needed -->
- <string name="oem_radio_info_label">OEM-specific Info/Settings</string>
-
- <!-- Band Mode Selection -->
- <!-- Band mode screen. Title of activity. -->
- <string name="band_mode_title">Set Radio Band Mode</string>
- <!-- Band mode screen. Loading message. -->
- <string name="band_mode_loading">Loading Band List\u2026</string>
- <!-- Band mode screen. Button caption to set the bandmode. -->
- <string name="band_mode_set">Set</string>
- <!-- Band mode screen. Status message when unsuccessful. -->
- <string name="band_mode_failed">Unsuccessful</string>
- <!-- Band mode screen. Statusm essage when successful. -->
- <string name="band_mode_succeeded">Successful</string>
<!-- Instructions after the user changes the mass storage settings -->
<string name="sdcard_changes_instructions">Changes take effect when USB cable is reconnected.</string>
@@ -654,10 +496,6 @@
<string name="device_info_label">Device info</string>
<!-- The title of the activity to adjust display settings -->
<string name="display_label">Screen</string>
- <!-- The title of the activity to see phone info -->
- <string name="phone_info_label" product="tablet">Tablet info</string>
- <!-- The title of the activity to see phone info -->
- <string name="phone_info_label" product="default">Phone info</string>
<!-- The title of the activity to adjust SD card settings [CHAR LIMIT=25] -->
<string name="sd_card_settings_label" product="nosdcard">USB storage</string>
<!-- The title of the activity to adjust SD card settings-->
@@ -716,11 +554,11 @@
<!-- mobile network settings screen, button on dialog box that appears when you are roaming and clear the "Data roaming" check box -->
<string name="roaming_turn_it_on_button">Turn it on</string>
<!-- mobile network settings screen, message in dialog box that appears when you select the "Data roaming" check box -->
- <string name="roaming_warning">You may incur significant charges.</string>
+ <string name="roaming_warning">Roaming charges may apply.</string>
<!-- mobile network settings screen, message in dialog box that appears when you select the "Data roaming" check box. This is for multiuser tablets [CHAR LIMIT=none] -->
- <string name="roaming_warning_multiuser" product="tablet">When you allow data roaming, you may incur significant roaming charges!\n\nThis setting affects all users on this tablet.</string>
+ <string name="roaming_warning_multiuser" product="tablet">When you allow data roaming, roaming charges may apply.\n\nThis setting affects all users on this tablet.</string>
<!-- mobile network settings screen, message in dialog box that appears when you select the "Data roaming" check box. This is for multiuser phones [CHAR LIMIT=none] -->
- <string name="roaming_warning_multiuser" product="default">When you allow data roaming, you may incur significant roaming charges!\n\nThis setting affects all users on this phone.</string>
+ <string name="roaming_warning_multiuser" product="default">When you allow data roaming, roaming charges may apply.\n\nThis setting affects all users on this phone.</string>
<!-- mobile network settings screen, title of dialog box that appears when you select the "Data roaming" check box -->
<string name="roaming_reenable_title">Allow data roaming?</string>
<!-- mobile network settings screen, setting option name -->
@@ -1805,7 +1643,7 @@
<!-- Bluetooth connecting error message [CHAR LIMIT=NONE] -->
<string name="bluetooth_connect_failed">Couldn\'t connect. Try again.</string>
- <!-- Title of device details screen [CHAR LIMIT=40]-->
+ <!-- Title of device details screen [CHAR LIMIT=28]-->
<string name="device_details_title">Device details</string>
<!-- Title of the item to show device MAC address -->
<string name="bluetooth_device_mac_address">Device\'s Bluetooth address: <xliff:g id="address">%1$s</xliff:g></string>
@@ -2187,7 +2025,7 @@
<string name="wifi_ip_settings">IP settings</string>
<!-- Label for the spinner to show Wifi MAC randomization [CHAR LIMIT=25] -->
<string name="wifi_privacy_settings">Privacy</string>
- <!-- Summary for Wifi MAC randomization option when it is ephemeral network [CHAR LIMIT=40] -->
+ <!-- Summary for Wifi MAC randomization option when it is ephemeral network [CHAR LIMIT=50] -->
<string name="wifi_privacy_settings_ephemeral_summary">Randomized MAC</string>
<!-- Title for the fragment to add a device into the wifi network [CHAR LIMIT=50] -->
<string name="wifi_dpp_add_device_to_network">Add a device</string>
@@ -2370,9 +2208,9 @@
<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=30] -->
+ <!-- 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 randomized Wi-Fi MAC address. [CHAR LIMIT=30] -->
+ <!-- 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 -->
<!-- Wi-Fi settings screen, advanced, title of the item to show the Wi-Fi device's current IP address. -->
@@ -3199,7 +3037,7 @@
<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=30] -->
+ <!-- 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 bluetooth adapter's hardware address-->
<string name="status_bt_address">Bluetooth address</string>
@@ -4847,7 +4685,7 @@
<!-- Title for the accessibility preference category of interaction control services and settings. [CHAR LIMIT=50] -->
<string name="interaction_control_category_title">Interaction controls</string>
<!-- Title for the accessibility preference category of services downloaded by the user. [CHAR LIMIT=50] -->
- <string name="user_installed_services_category_title">Downloaded services</string>
+ <string name="user_installed_services_category_title">Downloaded apps</string>
<!-- Title for the accessibility preference category of settings considered to be experimental, meaning they might be changed or removed in the future. [CHAR LIMIT=50] -->
<string name="experimental_category_title">Experimental</string>
<!-- Title for feature flags dashboard where developers can turn on experimental features [CHAR LIMIT=50] -->
@@ -4971,7 +4809,7 @@
<!-- Title for accessibility preference for configuring touch feedback vibrations. -->
<string name="accessibility_touch_vibration_title">Touch feedback</string>
<!-- Used in the acessibilty service settings to control turning on/off the service entirely -->
- <string name="accessibility_service_master_switch_title">Use service</string>
+ <string name="accessibility_service_master_switch_title">Use <xliff:g id="accessibility_app_name" example="TalkBack">%1$s</xliff:g></string>
<!-- Used in the Color correction settings screen to control turning on/off the feature entirely -->
<string name="accessibility_daltonizer_master_switch_title">Use color correction</string>
<!-- Used in the Captions settings screen to control turning on/off the feature entirely -->
@@ -9852,6 +9690,12 @@
<!-- Optional part of data usage showing the remaining amount [CHAR LIMIT=13] -->
<string name="data_remaining"><xliff:g name="bytes" example="2 GB">^1</xliff:g> left</string>
+ <!-- Brief content description for data usage chart [CHAR LIMIT=NONE] -->
+ <string name="data_usage_chart_brief_content_description">Graph showing data usage between <xliff:g id="start_date" example="August 19">%1$s</xliff:g> and <xliff:g id="end_date" example="September 16">%2$s</xliff:g>.</string>
+
+ <!-- Content description for data usage chart when data is not available [CHAR LIMIT=NONE] -->
+ <string name="data_usage_chart_no_data_content_description">No data in this date range</string>
+
<!-- Informational text about time left in billing cycle [CHAR LIMIT=60] -->
<plurals name="billing_cycle_days_left">
<item quantity="one">%d day left</item>
@@ -10888,8 +10732,8 @@
<string name="preferred_network_mode_nr_only_summary">Preferred network mode: NR only</string>
<!-- NR / LTE [CHAR LIMIT=NONE] -->
<string name="preferred_network_mode_nr_lte_summary">Preferred network mode: NR / LTE</string>
- <!-- NR/LTE/CDME/EvDo [CHAR LIMIT=NONE] -->
- <string name="preferred_network_mode_nr_lte_cdma_evdo_summary">Preferred network mode: NR/LTE/CDME/EvDo</string>
+ <!-- NR/LTE/CDMA/EvDo [CHAR LIMIT=NONE] -->
+ <string name="preferred_network_mode_nr_lte_cdma_evdo_summary">Preferred network mode: NR/LTE/CDMA/EvDo</string>
<!-- NR/LTE/GSM/WCDMA [CHAR LIMIT=NONE] -->
<string name="preferred_network_mode_nr_lte_gsm_wcdma_summary">Preferred network mode: NR/LTE/GSM/WCDMA</string>
<!-- NR/LTE/TDSCDMA/CDMA/EvDo/GSM/WCDMA [CHAR LIMIT=NONE] -->
diff --git a/res/xml/accounts_personal_dashboard_settings.xml b/res/xml/accounts_personal_dashboard_settings.xml
new file mode 100644
index 0000000..db57e3d
--- /dev/null
+++ b/res/xml/accounts_personal_dashboard_settings.xml
@@ -0,0 +1,42 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ Copyright (C) 2019 The Android Open Source Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+ -->
+
+<PreferenceScreen
+ xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:settings="http://schemas.android.com/apk/res-auto"
+ android:key="user_and_account_settings_screen"
+ android:title="@string/account_dashboard_title"
+ settings:keywords="@string/keywords_accounts">
+
+ <PreferenceCategory
+ android:key="dashboard_tile_placeholder"
+ android:order="30"/>
+
+ <SwitchPreference
+ android:key="auto_sync_account_data"
+ android:title="@string/auto_sync_account_title"
+ android:summary="@string/auto_sync_account_summary"
+ android:order="100"
+ settings:allowDividerAbove="true"/>
+
+ <SwitchPreference
+ android:key="auto_sync_personal_account_data"
+ android:title="@string/account_settings_menu_auto_sync_personal"
+ android:summary="@string/auto_sync_account_summary"
+ android:order="110"/>
+
+</PreferenceScreen>
diff --git a/res/xml/accounts_work_dashboard_settings.xml b/res/xml/accounts_work_dashboard_settings.xml
new file mode 100644
index 0000000..b27357d
--- /dev/null
+++ b/res/xml/accounts_work_dashboard_settings.xml
@@ -0,0 +1,42 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ Copyright (C) 2019 The Android Open Source Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+ -->
+
+<PreferenceScreen
+ xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:settings="http://schemas.android.com/apk/res-auto"
+ android:key="user_and_account_settings_screen"
+ android:title="@string/account_dashboard_title"
+ settings:keywords="@string/keywords_accounts">
+
+ <PreferenceCategory
+ android:key="dashboard_tile_placeholder"
+ android:order="30"/>
+
+ <SwitchPreference
+ android:key="auto_sync_account_data"
+ android:title="@string/auto_sync_account_title"
+ android:summary="@string/auto_sync_account_summary"
+ android:order="100"
+ settings:allowDividerAbove="true"/>
+
+ <SwitchPreference
+ android:key="auto_sync_work_account_data"
+ android:title="@string/account_settings_menu_auto_sync_work"
+ android:summary="@string/auto_sync_account_summary"
+ android:order="110"/>
+
+</PreferenceScreen>
diff --git a/res/xml/mobile_network_settings_v2.xml b/res/xml/mobile_network_settings_v2.xml
index af1fe20..1b08a5c 100644
--- a/res/xml/mobile_network_settings_v2.xml
+++ b/res/xml/mobile_network_settings_v2.xml
@@ -137,6 +137,9 @@
<Preference
android:key="carrier_settings_version_key"
android:title="@string/carrier_settings_version"
+ android:enabled="false"
+ android:shouldDisableView="false"
+ android:selectable="false"
settings:controller="com.android.settings.network.telephony.CarrierSettingsVersionPreferenceController"
settings:enableCopying="true"/>
diff --git a/res/xml/testing_settings.xml b/res/xml/testing_settings.xml
index bce03e5..8419386 100644
--- a/res/xml/testing_settings.xml
+++ b/res/xml/testing_settings.xml
@@ -4,9 +4,9 @@
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.
@@ -16,13 +16,13 @@
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
android:title="@string/testing" >
-
+
<PreferenceScreen
android:title="@string/testing_phone_info"
android:key="radio_info_settings">
<intent android:action="android.intent.action.MAIN"
- android:targetPackage="com.android.settings"
- android:targetClass="com.android.settings.RadioInfo" />
+ android:targetPackage="com.android.phone"
+ android:targetClass="com.android.phone.settings.RadioInfo" />
</PreferenceScreen>
<PreferenceScreen
@@ -40,7 +40,7 @@
android:targetClass="com.android.settings.Settings$WifiInfoActivity" />
</PreferenceScreen>
- <!--
+ <!--
<PreferenceScreen
android:title="@string/testing_sim_toolkit">
<intent android:action="android.intent.action.MAIN"
@@ -50,4 +50,3 @@
-->
</PreferenceScreen>
-
diff --git a/src/com/android/settings/BandMode.java b/src/com/android/settings/BandMode.java
deleted file mode 100644
index 6987d92..0000000
--- a/src/com/android/settings/BandMode.java
+++ /dev/null
@@ -1,238 +0,0 @@
-package com.android.settings;
-
-import android.app.Activity;
-import android.content.DialogInterface;
-import android.os.AsyncResult;
-import android.os.Bundle;
-import android.os.Handler;
-import android.os.Message;
-import android.util.Log;
-import android.view.View;
-import android.view.Window;
-import android.widget.AdapterView;
-import android.widget.ArrayAdapter;
-import android.widget.ListView;
-
-import androidx.appcompat.app.AlertDialog;
-
-import com.android.internal.telephony.Phone;
-import com.android.internal.telephony.PhoneFactory;
-
-/**
- * Radio Band Mode Selection Class
- *
- * It will query baseband about all available band modes and display them
- * in screen. It will display all six band modes if the query failed.
- *
- * After user select one band, it will send the selection to baseband.
- *
- * It will alter user the result of select operation and exit, no matter success
- * or not.
- *
- */
-public class BandMode extends Activity {
- private static final String LOG_TAG = "phone";
- private static final boolean DBG = false;
-
- private static final int EVENT_BAND_SCAN_COMPLETED = 100;
- private static final int EVENT_BAND_SELECTION_DONE = 200;
-
- //Directly maps to RIL_RadioBandMode from ril.h
- private static final String[] BAND_NAMES = new String[] {
- "Automatic",
- "Europe",
- "United States",
- "Japan",
- "Australia",
- "Australia 2",
- "Cellular 800",
- "PCS",
- "Class 3 (JTACS)",
- "Class 4 (Korea-PCS)",
- "Class 5",
- "Class 6 (IMT2000)",
- "Class 7 (700Mhz-Upper)",
- "Class 8 (1800Mhz-Upper)",
- "Class 9 (900Mhz)",
- "Class 10 (800Mhz-Secondary)",
- "Class 11 (Europe PAMR 400Mhz)",
- "Class 15 (US-AWS)",
- "Class 16 (US-2500Mhz)"
- };
-
- private ListView mBandList;
- private ArrayAdapter mBandListAdapter;
- private BandListItem mTargetBand = null;
- private DialogInterface mProgressPanel;
-
- private Phone mPhone = null;
-
- @Override
- protected void onCreate(Bundle icicle) {
- super.onCreate(icicle);
-
- requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
- setContentView(R.layout.band_mode);
-
- mPhone = PhoneFactory.getDefaultPhone();
-
- mBandList = (ListView) findViewById(R.id.band);
- mBandListAdapter = new ArrayAdapter<BandListItem>(this,
- android.R.layout.simple_list_item_1);
- mBandList.setAdapter(mBandListAdapter);
- mBandList.setOnItemClickListener(mBandSelectionHandler);
-
- loadBandList();
- }
-
- private AdapterView.OnItemClickListener mBandSelectionHandler =
- new AdapterView.OnItemClickListener () {
- public void onItemClick(AdapterView parent, View v,
- int position, long id) {
-
- getWindow().setFeatureInt(
- Window.FEATURE_INDETERMINATE_PROGRESS,
- Window.PROGRESS_VISIBILITY_ON);
-
- mTargetBand = (BandListItem) parent.getAdapter().getItem(position);
-
- if (DBG) log("Select band : " + mTargetBand.toString());
-
- Message msg =
- mHandler.obtainMessage(EVENT_BAND_SELECTION_DONE);
- mPhone.setBandMode(mTargetBand.getBand(), msg);
- }
- };
-
- static private class BandListItem {
- private int mBandMode = Phone.BM_UNSPECIFIED;
-
- public BandListItem(int bm) {
- mBandMode = bm;
- }
-
- public int getBand() {
- return mBandMode;
- }
-
- public String toString() {
- if (mBandMode >= BAND_NAMES.length) return "Band mode " + mBandMode;
- return BAND_NAMES[mBandMode];
- }
- }
-
- private void loadBandList() {
- String str = getString(R.string.band_mode_loading);
-
- if (DBG) log(str);
-
-
- //ProgressDialog.show(this, null, str, true, true, null);
- mProgressPanel = new AlertDialog.Builder(this)
- .setMessage(str)
- .show();
-
- Message msg = mHandler.obtainMessage(EVENT_BAND_SCAN_COMPLETED);
- mPhone.queryAvailableBandMode(msg);
-
- }
-
- private void bandListLoaded(AsyncResult result) {
- if (DBG) log("network list loaded");
-
- if (mProgressPanel != null) mProgressPanel.dismiss();
-
- clearList();
-
- boolean addBandSuccess = false;
- BandListItem item;
-
- if (result.result != null) {
- int bands[] = (int[])result.result;
-
- if(bands.length == 0) {
- Log.wtf(LOG_TAG, "No Supported Band Modes");
- return;
- }
-
- int size = bands[0];
-
- if (size > 0) {
- mBandListAdapter.add(
- new BandListItem(Phone.BM_UNSPECIFIED)); //Always include AUTOMATIC
- for (int i=1; i<=size; i++) {
- if (bands[i] == Phone.BM_UNSPECIFIED) {
- continue;
- }
- item = new BandListItem(bands[i]);
- mBandListAdapter.add(item);
- if (DBG) log("Add " + item.toString());
- }
- addBandSuccess = true;
- }
- }
-
- if (addBandSuccess == false) {
- if (DBG) log("Error in query, add default list");
- for (int i=0; i<Phone.BM_NUM_BAND_MODES; i++) {
- item = new BandListItem(i);
- mBandListAdapter.add(item);
- if (DBG) log("Add default " + item.toString());
- }
- }
- mBandList.requestFocus();
- }
-
- private void displayBandSelectionResult(Throwable ex) {
- String status = getString(R.string.band_mode_set)
- +" [" + mTargetBand.toString() + "] ";
-
- if (ex != null) {
- status = status + getString(R.string.band_mode_failed);
- } else {
- status = status + getString(R.string.band_mode_succeeded);
- }
-
- mProgressPanel = new AlertDialog.Builder(this)
- .setMessage(status)
- .setPositiveButton(android.R.string.ok, null).show();
- }
-
- private void clearList() {
- while(mBandListAdapter.getCount() > 0) {
- mBandListAdapter.remove(
- mBandListAdapter.getItem(0));
- }
- }
-
- private void log(String msg) {
- Log.d(LOG_TAG, "[BandsList] " + msg);
- }
-
- private Handler mHandler = new Handler() {
- public void handleMessage(Message msg) {
- AsyncResult ar;
- switch (msg.what) {
- case EVENT_BAND_SCAN_COMPLETED:
- ar = (AsyncResult) msg.obj;
-
- bandListLoaded(ar);
- break;
-
- case EVENT_BAND_SELECTION_DONE:
- ar = (AsyncResult) msg.obj;
-
- getWindow().setFeatureInt(
- Window.FEATURE_INDETERMINATE_PROGRESS,
- Window.PROGRESS_VISIBILITY_OFF);
-
- if (!isFinishing()) {
- displayBandSelectionResult(ar.exception);
- }
- break;
- }
- }
- };
-
-
-}
diff --git a/src/com/android/settings/CryptKeeper.java b/src/com/android/settings/CryptKeeper.java
index 05054b4..604333f 100644
--- a/src/com/android/settings/CryptKeeper.java
+++ b/src/com/android/settings/CryptKeeper.java
@@ -727,7 +727,7 @@
public void onPatternDetected(List<LockPatternView.Cell> pattern) {
mLockPatternView.setEnabled(false);
if (pattern.size() >= MIN_LENGTH_BEFORE_REPORT) {
- new DecryptTask().execute(LockPatternUtils.patternToString(pattern));
+ new DecryptTask().execute(new String(LockPatternUtils.patternToByteArray(pattern)));
} else {
// Allow user to make as many of these as they want.
fakeUnlockAttempt(mLockPatternView);
diff --git a/src/com/android/settings/RadioInfo.java b/src/com/android/settings/RadioInfo.java
deleted file mode 100644
index 054e6cf..0000000
--- a/src/com/android/settings/RadioInfo.java
+++ /dev/null
@@ -1,1736 +0,0 @@
-/*
- * Copyright (C) 2006 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;
-
-import static android.net.ConnectivityManager.NetworkCallback;
-import static android.provider.Settings.Global.PREFERRED_NETWORK_MODE;
-
-import android.app.Activity;
-import android.app.QueuedWork;
-import android.content.ComponentName;
-import android.content.Context;
-import android.content.DialogInterface;
-import android.content.Intent;
-import android.content.pm.PackageManager;
-import android.content.pm.ResolveInfo;
-import android.content.res.Resources;
-import android.graphics.Typeface;
-import android.net.ConnectivityManager;
-import android.net.Network;
-import android.net.NetworkCapabilities;
-import android.net.NetworkRequest;
-import android.net.TrafficStats;
-import android.net.Uri;
-import android.os.AsyncResult;
-import android.os.Build;
-import android.os.Bundle;
-import android.os.Handler;
-import android.os.Message;
-import android.os.SystemProperties;
-import android.provider.Settings;
-import android.telephony.CarrierConfigManager;
-import android.telephony.CellIdentityCdma;
-import android.telephony.CellIdentityGsm;
-import android.telephony.CellIdentityLte;
-import android.telephony.CellIdentityWcdma;
-import android.telephony.CellInfo;
-import android.telephony.CellInfoCdma;
-import android.telephony.CellInfoGsm;
-import android.telephony.CellInfoLte;
-import android.telephony.CellInfoWcdma;
-import android.telephony.CellLocation;
-import android.telephony.CellSignalStrengthCdma;
-import android.telephony.CellSignalStrengthGsm;
-import android.telephony.CellSignalStrengthLte;
-import android.telephony.CellSignalStrengthWcdma;
-import android.telephony.PhoneStateListener;
-import android.telephony.PhysicalChannelConfig;
-import android.telephony.PreciseCallState;
-import android.telephony.ServiceState;
-import android.telephony.SignalStrength;
-import android.telephony.SubscriptionManager;
-import android.telephony.TelephonyManager;
-import android.telephony.cdma.CdmaCellLocation;
-import android.telephony.gsm.GsmCellLocation;
-import android.text.TextUtils;
-import android.util.Log;
-import android.view.Menu;
-import android.view.MenuItem;
-import android.view.View;
-import android.view.View.OnClickListener;
-import android.widget.AdapterView;
-import android.widget.ArrayAdapter;
-import android.widget.Button;
-import android.widget.CompoundButton;
-import android.widget.CompoundButton.OnCheckedChangeListener;
-import android.widget.EditText;
-import android.widget.Spinner;
-import android.widget.Switch;
-import android.widget.TextView;
-
-import androidx.appcompat.app.AlertDialog;
-import androidx.appcompat.app.AlertDialog.Builder;
-
-import com.android.ims.ImsConfig;
-import com.android.ims.ImsException;
-import com.android.ims.ImsManager;
-import com.android.internal.telephony.Phone;
-import com.android.internal.telephony.PhoneFactory;
-
-import java.io.IOException;
-import java.net.HttpURLConnection;
-import java.net.URL;
-import java.util.List;
-
-// TODO(b/123598192) consider to move this activity to telephony package.
-public class RadioInfo extends Activity {
- private static final String TAG = "RadioInfo";
-
- private static final String[] mPreferredNetworkLabels = {
- "GSM/WCDMA preferred",
- "GSM only",
- "WCDMA only",
- "GSM/WCDMA auto (PRL)",
- "CDMA/EvDo auto (PRL)",
- "CDMA only",
- "EvDo only",
- "CDMA/EvDo/GSM/WCDMA (PRL)",
- "CDMA + LTE/EvDo (PRL)",
- "GSM/WCDMA/LTE (PRL)",
- "LTE/CDMA/EvDo/GSM/WCDMA (PRL)",
- "LTE only",
- "LTE/WCDMA",
- "TDSCDMA only",
- "TDSCDMA/WCDMA",
- "LTE/TDSCDMA",
- "TDSCDMA/GSM",
- "LTE/TDSCDMA/GSM",
- "TDSCDMA/GSM/WCDMA",
- "LTE/TDSCDMA/WCDMA",
- "LTE/TDSCDMA/GSM/WCDMA",
- "TDSCDMA/CDMA/EvDo/GSM/WCDMA ",
- "LTE/TDSCDMA/CDMA/EvDo/GSM/WCDMA",
- "NR only",
- "NR/LTE",
- "NR/LTE/CDME/EvDo",
- "NR/LTE/GSM/WCDMA",
- "NR/LTE/CDMA/EvDo/GSM/WCDMA",
- "NR/LTE/WCDMA",
- "NR/LTE/TDSCDMA",
- "NR/LTE/TDSCDMA/GSM",
- "NR/LTE/TDSCDMA/WCDMA",
- "NR/LTE/TDSCDMA/GSM/WCDMA",
- "NR/LTE/TDSCDMA/CDMA/EvDo/GSM/WCDMA",
- "Unknown"
- };
-
- private static String[] mPhoneIndexLabels;
-
- private static final int CELL_INFO_LIST_RATE_DISABLED = Integer.MAX_VALUE;
- private static final int CELL_INFO_LIST_RATE_MAX = 0;
-
- private static final String DSDS_MODE_PROPERTY = "ro.boot.hardware.dsds";
-
- /**
- * A value indicates the device is always on dsds mode.
- * @see {@link #DSDS_MODE_PROPERTY}
- */
- private static final int ALWAYS_ON_DSDS_MODE = 1;
-
- private static final int IMS_VOLTE_PROVISIONED_CONFIG_ID =
- ImsConfig.ConfigConstants.VLT_SETTING_ENABLED;
-
- private static final int IMS_VT_PROVISIONED_CONFIG_ID =
- ImsConfig.ConfigConstants.LVC_SETTING_ENABLED;
-
- private static final int IMS_WFC_PROVISIONED_CONFIG_ID =
- ImsConfig.ConfigConstants.VOICE_OVER_WIFI_SETTING_ENABLED;
-
- private static final int EAB_PROVISIONED_CONFIG_ID =
- ImsConfig.ConfigConstants.EAB_SETTING_ENABLED;
-
- //Values in must match mCellInfoRefreshRates
- private static final String[] mCellInfoRefreshRateLabels = {
- "Disabled",
- "Immediate",
- "Min 5s",
- "Min 10s",
- "Min 60s"
- };
-
- //Values in seconds, must match mCellInfoRefreshRateLabels
- private static final int mCellInfoRefreshRates[] = {
- CELL_INFO_LIST_RATE_DISABLED,
- CELL_INFO_LIST_RATE_MAX,
- 5000,
- 10000,
- 60000
- };
-
- private static void log(String s) {
- Log.d(TAG, s);
- }
-
- private static final int EVENT_CFI_CHANGED = 302;
-
- private static final int EVENT_QUERY_PREFERRED_TYPE_DONE = 1000;
- private static final int EVENT_SET_PREFERRED_TYPE_DONE = 1001;
- private static final int EVENT_QUERY_SMSC_DONE = 1005;
- private static final int EVENT_UPDATE_SMSC_DONE = 1006;
-
- private static final int MENU_ITEM_SELECT_BAND = 0;
- private static final int MENU_ITEM_VIEW_ADN = 1;
- private static final int MENU_ITEM_VIEW_FDN = 2;
- private static final int MENU_ITEM_VIEW_SDN = 3;
- private static final int MENU_ITEM_GET_IMS_STATUS = 4;
- private static final int MENU_ITEM_TOGGLE_DATA = 5;
-
- private TextView mDeviceId; //DeviceId is the IMEI in GSM and the MEID in CDMA
- private TextView number;
- private TextView mSubscriptionId;
- private TextView mDds;
- private TextView mSubscriberId;
- private TextView callState;
- private TextView operatorName;
- private TextView roamingState;
- private TextView gsmState;
- private TextView gprsState;
- private TextView voiceNetwork;
- private TextView dataNetwork;
- private TextView dBm;
- private TextView mMwi;
- private TextView mCfi;
- private TextView mLocation;
- private TextView mCellInfo;
- private TextView sent;
- private TextView received;
- private TextView mPingHostnameV4;
- private TextView mPingHostnameV6;
- private TextView mHttpClientTest;
- private TextView mPhyChanConfig;
- private TextView dnsCheckState;
- private TextView mDownlinkKbps;
- private TextView mUplinkKbps;
- private EditText smsc;
- private Switch radioPowerOnSwitch;
- private Button cellInfoRefreshRateButton;
- private Button dnsCheckToggleButton;
- private Button pingTestButton;
- private Button updateSmscButton;
- private Button refreshSmscButton;
- private Button oemInfoButton;
- private Button carrierProvisioningButton;
- private Button triggercarrierProvisioningButton;
- private Switch imsVolteProvisionedSwitch;
- private Switch imsVtProvisionedSwitch;
- private Switch imsWfcProvisionedSwitch;
- private Switch eabProvisionedSwitch;
- private Switch cbrsDataSwitch;
- private Switch dsdsSwitch;
- private Spinner preferredNetworkType;
- private Spinner mSelectPhoneIndex;
- private Spinner cellInfoRefreshRateSpinner;
-
- private ConnectivityManager mConnectivityManager;
- private TelephonyManager mTelephonyManager;
- private ImsManager mImsManager = null;
- private Phone mPhone = null;
-
- private String mPingHostnameResultV4;
- private String mPingHostnameResultV6;
- private String mHttpClientTestResult;
- private boolean mMwiValue = false;
- private boolean mCfiValue = false;
-
- private List<CellInfo> mCellInfoResult = null;
- private CellLocation mCellLocationResult = null;
-
- private int mPreferredNetworkTypeResult;
- private int mCellInfoRefreshRateIndex;
- private int mSelectedPhoneIndex;
-
- private final NetworkRequest mDefaultNetworkRequest = new NetworkRequest.Builder()
- .addTransportType(NetworkCapabilities.TRANSPORT_CELLULAR)
- .addCapability(NetworkCapabilities.NET_CAPABILITY_INTERNET)
- .build();
-
- private final NetworkCallback mNetworkCallback = new NetworkCallback() {
- public void onCapabilitiesChanged(Network n, NetworkCapabilities nc) {
- int dlbw = nc.getLinkDownstreamBandwidthKbps();
- int ulbw = nc.getLinkUpstreamBandwidthKbps();
- updateBandwidths(dlbw, ulbw);
- }
- };
-
- // not final because we need to recreate this object to register on a new subId (b/117555407)
- private PhoneStateListener mPhoneStateListener = new RadioInfoPhoneStateListener();
- private class RadioInfoPhoneStateListener extends PhoneStateListener {
- @Override
- public void onDataConnectionStateChanged(int state) {
- updateDataState();
- updateNetworkType();
- }
-
- @Override
- public void onDataActivity(int direction) {
- updateDataStats2();
- }
-
- @Override
- public void onCallStateChanged(int state, String incomingNumber) {
- updateNetworkType();
- updatePhoneState(state);
- }
-
- @Override
- public void onPreciseCallStateChanged(PreciseCallState preciseState) {
- updateNetworkType();
- }
-
- @Override
- public void onCellLocationChanged(CellLocation location) {
- updateLocation(location);
- }
-
- @Override
- public void onMessageWaitingIndicatorChanged(boolean mwi) {
- mMwiValue = mwi;
- updateMessageWaiting();
- }
-
- @Override
- public void onCallForwardingIndicatorChanged(boolean cfi) {
- mCfiValue = cfi;
- updateCallRedirect();
- }
-
- @Override
- public void onCellInfoChanged(List<CellInfo> arrayCi) {
- log("onCellInfoChanged: arrayCi=" + arrayCi);
- mCellInfoResult = arrayCi;
- updateCellInfo(mCellInfoResult);
- }
-
- @Override
- public void onSignalStrengthsChanged(SignalStrength signalStrength) {
- log("onSignalStrengthChanged: SignalStrength=" +signalStrength);
- updateSignalStrength(signalStrength);
- }
-
- @Override
- public void onServiceStateChanged(ServiceState serviceState) {
- log("onServiceStateChanged: ServiceState=" + serviceState);
- updateServiceState(serviceState);
- updateRadioPowerState();
- updateNetworkType();
- updateImsProvisionedState();
- }
-
- @Override
- public void onPhysicalChannelConfigurationChanged(
- List<PhysicalChannelConfig> configs) {
- updatePhysicalChannelConfiguration(configs);
- }
-
- }
-
- private void updatePhysicalChannelConfiguration(List<PhysicalChannelConfig> configs) {
- StringBuilder sb = new StringBuilder();
- String div = "";
- sb.append("{");
- if (configs != null) {
- for(PhysicalChannelConfig c : configs) {
- sb.append(div).append(c);
- div = ",";
- }
- }
- sb.append("}");
- mPhyChanConfig.setText(sb.toString());
- }
-
- private void updatePreferredNetworkType(int type) {
- if (type >= mPreferredNetworkLabels.length || type < 0) {
- log("EVENT_QUERY_PREFERRED_TYPE_DONE: unknown " +
- "type=" + type);
- type = mPreferredNetworkLabels.length - 1; //set to Unknown
- }
- mPreferredNetworkTypeResult = type;
-
- preferredNetworkType.setSelection(mPreferredNetworkTypeResult, true);
- }
-
- private void updatePhoneIndex(int phoneIndex, int subId) {
- // unregister listeners on the old subId
- unregisterPhoneStateListener();
- mTelephonyManager.setCellInfoListRate(CELL_INFO_LIST_RATE_DISABLED);
-
- // update the subId
- mTelephonyManager = mTelephonyManager.createForSubscriptionId(subId);
-
- // update the phoneId
- mImsManager = ImsManager.getInstance(getApplicationContext(), phoneIndex);
- mPhone = PhoneFactory.getPhone(phoneIndex);
-
- updateAllFields();
- }
-
- private Handler mHandler = new Handler() {
- @Override
- public void handleMessage(Message msg) {
- AsyncResult ar;
- switch (msg.what) {
- case EVENT_QUERY_PREFERRED_TYPE_DONE:
- ar= (AsyncResult) msg.obj;
- if (ar.exception == null && ar.result != null) {
- updatePreferredNetworkType(((int[])ar.result)[0]);
- } else {
- //In case of an exception, we will set this to unknown
- updatePreferredNetworkType(mPreferredNetworkLabels.length-1);
- }
- break;
- case EVENT_SET_PREFERRED_TYPE_DONE:
- ar= (AsyncResult) msg.obj;
- if (ar.exception != null) {
- log("Set preferred network type failed.");
- }
- break;
- case EVENT_QUERY_SMSC_DONE:
- ar= (AsyncResult) msg.obj;
- if (ar.exception != null) {
- smsc.setText("refresh error");
- } else {
- smsc.setText((String)ar.result);
- }
- break;
- case EVENT_UPDATE_SMSC_DONE:
- updateSmscButton.setEnabled(true);
- ar= (AsyncResult) msg.obj;
- if (ar.exception != null) {
- smsc.setText("update error");
- }
- break;
- default:
- super.handleMessage(msg);
- break;
-
- }
- }
- };
-
- @Override
- public void onCreate(Bundle icicle) {
- super.onCreate(icicle);
- if (!android.os.Process.myUserHandle().isSystem()) {
- Log.e(TAG, "Not run from system user, don't do anything.");
- finish();
- return;
- }
-
- setContentView(R.layout.radio_info);
-
- log("Started onCreate");
-
- mTelephonyManager = (TelephonyManager)getSystemService(TELEPHONY_SERVICE);
- mConnectivityManager = (ConnectivityManager)getSystemService(CONNECTIVITY_SERVICE);
- mPhone = PhoneFactory.getDefaultPhone();
-
- mImsManager = ImsManager.getInstance(getApplicationContext(),
- SubscriptionManager.getDefaultVoicePhoneId());
-
- mPhoneIndexLabels = getPhoneIndexLabels(mTelephonyManager);
-
- mDeviceId = (TextView) findViewById(R.id.imei);
- number = (TextView) findViewById(R.id.number);
- mSubscriptionId = (TextView) findViewById(R.id.subid);
- mDds = (TextView) findViewById(R.id.dds);
- mSubscriberId = (TextView) findViewById(R.id.imsi);
- callState = (TextView) findViewById(R.id.call);
- operatorName = (TextView) findViewById(R.id.operator);
- roamingState = (TextView) findViewById(R.id.roaming);
- gsmState = (TextView) findViewById(R.id.gsm);
- gprsState = (TextView) findViewById(R.id.gprs);
- voiceNetwork = (TextView) findViewById(R.id.voice_network);
- dataNetwork = (TextView) findViewById(R.id.data_network);
- dBm = (TextView) findViewById(R.id.dbm);
- mMwi = (TextView) findViewById(R.id.mwi);
- mCfi = (TextView) findViewById(R.id.cfi);
- mLocation = (TextView) findViewById(R.id.location);
- mCellInfo = (TextView) findViewById(R.id.cellinfo);
- mCellInfo.setTypeface(Typeface.MONOSPACE);
-
- sent = (TextView) findViewById(R.id.sent);
- received = (TextView) findViewById(R.id.received);
- smsc = (EditText) findViewById(R.id.smsc);
- dnsCheckState = (TextView) findViewById(R.id.dnsCheckState);
- mPingHostnameV4 = (TextView) findViewById(R.id.pingHostnameV4);
- mPingHostnameV6 = (TextView) findViewById(R.id.pingHostnameV6);
- mHttpClientTest = (TextView) findViewById(R.id.httpClientTest);
-
- mPhyChanConfig = (TextView) findViewById(R.id.phy_chan_config);
-
- preferredNetworkType = (Spinner) findViewById(R.id.preferredNetworkType);
- ArrayAdapter<String> preferredNetworkTypeAdapter = new ArrayAdapter<String> (this,
- android.R.layout.simple_spinner_item, mPreferredNetworkLabels);
- preferredNetworkTypeAdapter
- .setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
- preferredNetworkType.setAdapter(preferredNetworkTypeAdapter);
-
- mSelectPhoneIndex = (Spinner) findViewById(R.id.phoneIndex);
- ArrayAdapter<String> phoneIndexAdapter = new ArrayAdapter<String> (this,
- android.R.layout.simple_spinner_item, mPhoneIndexLabels);
- phoneIndexAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
- mSelectPhoneIndex.setAdapter(phoneIndexAdapter);
-
- cellInfoRefreshRateSpinner = (Spinner) findViewById(R.id.cell_info_rate_select);
- ArrayAdapter<String> cellInfoAdapter = new ArrayAdapter<String>(this,
- android.R.layout.simple_spinner_item, mCellInfoRefreshRateLabels);
- cellInfoAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
- cellInfoRefreshRateSpinner.setAdapter(cellInfoAdapter);
-
- imsVolteProvisionedSwitch = (Switch) findViewById(R.id.volte_provisioned_switch);
- imsVtProvisionedSwitch = (Switch) findViewById(R.id.vt_provisioned_switch);
- imsWfcProvisionedSwitch = (Switch) findViewById(R.id.wfc_provisioned_switch);
- eabProvisionedSwitch = (Switch) findViewById(R.id.eab_provisioned_switch);
-
- if (!ImsManager.isImsSupportedOnDevice(mPhone.getContext())) {
- imsVolteProvisionedSwitch.setVisibility(View.GONE);
- imsVtProvisionedSwitch.setVisibility(View.GONE);
- imsWfcProvisionedSwitch.setVisibility(View.GONE);
- eabProvisionedSwitch.setVisibility(View.GONE);
- }
-
- cbrsDataSwitch = (Switch) findViewById(R.id.cbrs_data_switch);
- cbrsDataSwitch.setVisibility(isCbrsSupported() ? View.VISIBLE : View.GONE);
-
- dsdsSwitch = findViewById(R.id.dsds_switch);
- if (isDsdsSupported() && !dsdsModeOnly()) {
- dsdsSwitch.setVisibility(View.VISIBLE);
- dsdsSwitch.setOnClickListener(v -> {
- if (mTelephonyManager.doesSwitchMultiSimConfigTriggerReboot()) {
- // Undo the click action until user clicks the confirm dialog.
- dsdsSwitch.toggle();
- showDsdsChangeDialog();
- } else {
- performDsdsSwitch();
- }
- });
- dsdsSwitch.setChecked(isDsdsEnabled());
- } else {
- dsdsSwitch.setVisibility(View.GONE);
- }
-
- radioPowerOnSwitch = (Switch) findViewById(R.id.radio_power);
-
- mDownlinkKbps = (TextView) findViewById(R.id.dl_kbps);
- mUplinkKbps = (TextView) findViewById(R.id.ul_kbps);
- updateBandwidths(0, 0);
-
- pingTestButton = (Button) findViewById(R.id.ping_test);
- pingTestButton.setOnClickListener(mPingButtonHandler);
- updateSmscButton = (Button) findViewById(R.id.update_smsc);
- updateSmscButton.setOnClickListener(mUpdateSmscButtonHandler);
- refreshSmscButton = (Button) findViewById(R.id.refresh_smsc);
- refreshSmscButton.setOnClickListener(mRefreshSmscButtonHandler);
- dnsCheckToggleButton = (Button) findViewById(R.id.dns_check_toggle);
- dnsCheckToggleButton.setOnClickListener(mDnsCheckButtonHandler);
- carrierProvisioningButton = (Button) findViewById(R.id.carrier_provisioning);
- carrierProvisioningButton.setOnClickListener(mCarrierProvisioningButtonHandler);
- triggercarrierProvisioningButton = (Button) findViewById(R.id.trigger_carrier_provisioning);
- triggercarrierProvisioningButton.setOnClickListener(
- mTriggerCarrierProvisioningButtonHandler);
-
- oemInfoButton = (Button) findViewById(R.id.oem_info);
- oemInfoButton.setOnClickListener(mOemInfoButtonHandler);
- PackageManager pm = getPackageManager();
- Intent oemInfoIntent = new Intent("com.android.settings.OEM_RADIO_INFO");
- List<ResolveInfo> oemInfoIntentList = pm.queryIntentActivities(oemInfoIntent, 0);
- if (oemInfoIntentList.size() == 0) {
- oemInfoButton.setEnabled(false);
- }
-
- mCellInfoRefreshRateIndex = 0; //disabled
- mPreferredNetworkTypeResult = mPreferredNetworkLabels.length - 1; //Unknown
- mSelectedPhoneIndex = 0; //phone 0
-
- //FIXME: Replace with TelephonyManager call
- mPhone.getPreferredNetworkType(
- mHandler.obtainMessage(EVENT_QUERY_PREFERRED_TYPE_DONE));
-
- restoreFromBundle(icicle);
- }
-
- @Override
- protected void onResume() {
- super.onResume();
-
- log("Started onResume");
-
- updateAllFields();
- }
-
- private void updateAllFields() {
- updateMessageWaiting();
- updateCallRedirect();
- updateDataState();
- updateDataStats2();
- updateRadioPowerState();
- updateImsProvisionedState();
- updateProperties();
- updateDnsCheckState();
- updateNetworkType();
-
- updateLocation(mCellLocationResult);
- updateCellInfo(mCellInfoResult);
- updateSubscriptionIds();
-
- mPingHostnameV4.setText(mPingHostnameResultV4);
- mPingHostnameV6.setText(mPingHostnameResultV6);
- mHttpClientTest.setText(mHttpClientTestResult);
-
- cellInfoRefreshRateSpinner.setOnItemSelectedListener(mCellInfoRefreshRateHandler);
- //set selection after registering listener to force update
- cellInfoRefreshRateSpinner.setSelection(mCellInfoRefreshRateIndex);
-
- //set selection before registering to prevent update
- preferredNetworkType.setSelection(mPreferredNetworkTypeResult, true);
- preferredNetworkType.setOnItemSelectedListener(mPreferredNetworkHandler);
-
- // set phone index
- mSelectPhoneIndex.setSelection(mSelectedPhoneIndex, true);
- mSelectPhoneIndex.setOnItemSelectedListener(mSelectPhoneIndexHandler);
-
- radioPowerOnSwitch.setOnCheckedChangeListener(mRadioPowerOnChangeListener);
- imsVolteProvisionedSwitch.setOnCheckedChangeListener(mImsVolteCheckedChangeListener);
- imsVtProvisionedSwitch.setOnCheckedChangeListener(mImsVtCheckedChangeListener);
- imsWfcProvisionedSwitch.setOnCheckedChangeListener(mImsWfcCheckedChangeListener);
- eabProvisionedSwitch.setOnCheckedChangeListener(mEabCheckedChangeListener);
-
- if (isCbrsSupported()) {
- cbrsDataSwitch.setChecked(getCbrsDataState());
- cbrsDataSwitch.setOnCheckedChangeListener(mCbrsDataSwitchChangeListener);
- }
-
- unregisterPhoneStateListener();
- registerPhoneStateListener();
-
- mConnectivityManager.registerNetworkCallback(
- mDefaultNetworkRequest, mNetworkCallback, mHandler);
-
- smsc.clearFocus();
- }
-
- @Override
- protected void onPause() {
- super.onPause();
-
- log("onPause: unregister phone & data intents");
-
- mTelephonyManager.listen(mPhoneStateListener, PhoneStateListener.LISTEN_NONE);
- mTelephonyManager.setCellInfoListRate(CELL_INFO_LIST_RATE_DISABLED);
- mConnectivityManager.unregisterNetworkCallback(mNetworkCallback);
-
- }
-
- private void restoreFromBundle(Bundle b) {
- if(b == null) {
- return;
- }
-
- mPingHostnameResultV4 = b.getString("mPingHostnameResultV4","");
- mPingHostnameResultV6 = b.getString("mPingHostnameResultV6","");
- mHttpClientTestResult = b.getString("mHttpClientTestResult","");
-
- mPingHostnameV4.setText(mPingHostnameResultV4);
- mPingHostnameV6.setText(mPingHostnameResultV6);
- mHttpClientTest.setText(mHttpClientTestResult);
-
- mPreferredNetworkTypeResult = b.getInt("mPreferredNetworkTypeResult",
- mPreferredNetworkLabels.length - 1);
-
- mSelectedPhoneIndex = b.getInt("mSelectedPhoneIndex", 0);
-
- mCellInfoRefreshRateIndex = b.getInt("mCellInfoRefreshRateIndex", 0);
- }
-
- @Override
- protected void onSaveInstanceState(Bundle outState) {
- outState.putString("mPingHostnameResultV4", mPingHostnameResultV4);
- outState.putString("mPingHostnameResultV6", mPingHostnameResultV6);
- outState.putString("mHttpClientTestResult", mHttpClientTestResult);
-
- outState.putInt("mPreferredNetworkTypeResult", mPreferredNetworkTypeResult);
- outState.putInt("mSelectedPhoneIndex", mSelectedPhoneIndex);
- outState.putInt("mCellInfoRefreshRateIndex", mCellInfoRefreshRateIndex);
-
- }
-
- @Override
- public boolean onCreateOptionsMenu(Menu menu) {
- menu.add(0, MENU_ITEM_SELECT_BAND, 0, R.string.radio_info_band_mode_label)
- .setOnMenuItemClickListener(mSelectBandCallback)
- .setAlphabeticShortcut('b');
- menu.add(1, MENU_ITEM_VIEW_ADN, 0,
- R.string.radioInfo_menu_viewADN).setOnMenuItemClickListener(mViewADNCallback);
- menu.add(1, MENU_ITEM_VIEW_FDN, 0,
- R.string.radioInfo_menu_viewFDN).setOnMenuItemClickListener(mViewFDNCallback);
- menu.add(1, MENU_ITEM_VIEW_SDN, 0,
- R.string.radioInfo_menu_viewSDN).setOnMenuItemClickListener(mViewSDNCallback);
- if (ImsManager.isImsSupportedOnDevice(mPhone.getContext())) {
- menu.add(1, MENU_ITEM_GET_IMS_STATUS,
- 0, R.string.radioInfo_menu_getIMS).setOnMenuItemClickListener(mGetImsStatus);
- }
- menu.add(1, MENU_ITEM_TOGGLE_DATA,
- 0, R.string.radio_info_data_connection_disable).setOnMenuItemClickListener(mToggleData);
- return true;
- }
-
- @Override
- public boolean onPrepareOptionsMenu(Menu menu) {
- // Get the TOGGLE DATA menu item in the right state.
- MenuItem item = menu.findItem(MENU_ITEM_TOGGLE_DATA);
- int state = mTelephonyManager.getDataState();
- boolean visible = true;
-
- switch (state) {
- case TelephonyManager.DATA_CONNECTED:
- case TelephonyManager.DATA_SUSPENDED:
- item.setTitle(R.string.radio_info_data_connection_disable);
- break;
- case TelephonyManager.DATA_DISCONNECTED:
- item.setTitle(R.string.radio_info_data_connection_enable);
- break;
- default:
- visible = false;
- break;
- }
- item.setVisible(visible);
- return true;
- }
-
- // returns array of string labels for each phone index. The array index is equal to the phone
- // index.
- private static String[] getPhoneIndexLabels(TelephonyManager tm) {
- int phones = tm.getPhoneCount();
- String[] labels = new String[phones];
- for (int i = 0; i < phones; i++) {
- labels[i] = "Phone " + i;
- }
- return labels;
- }
-
- private void unregisterPhoneStateListener() {
- mTelephonyManager.listen(mPhoneStateListener, PhoneStateListener.LISTEN_NONE);
-
- // clear all fields so they are blank until the next listener event occurs
- operatorName.setText("");
- gprsState.setText("");
- dataNetwork.setText("");
- voiceNetwork.setText("");
- sent.setText("");
- received.setText("");
- callState.setText("");
- mLocation.setText("");
- mMwiValue = false;
- mMwi.setText("");
- mCfiValue = false;
- mCfi.setText("");
- mCellInfo.setText("");
- dBm.setText("");
- gsmState.setText("");
- roamingState.setText("");
- mPhyChanConfig.setText("");
- }
-
- // register mPhoneStateListener for relevant fields using the current TelephonyManager
- private void registerPhoneStateListener() {
- mPhoneStateListener = new RadioInfoPhoneStateListener();
- mTelephonyManager.listen(mPhoneStateListener,
- PhoneStateListener.LISTEN_CALL_STATE
- //b/27803938 - RadioInfo currently cannot read PRECISE_CALL_STATE
- // | PhoneStateListener.LISTEN_PRECISE_CALL_STATE
- | PhoneStateListener.LISTEN_DATA_CONNECTION_STATE
- | PhoneStateListener.LISTEN_DATA_ACTIVITY
- | PhoneStateListener.LISTEN_CELL_LOCATION
- | PhoneStateListener.LISTEN_MESSAGE_WAITING_INDICATOR
- | PhoneStateListener.LISTEN_CALL_FORWARDING_INDICATOR
- | PhoneStateListener.LISTEN_CELL_INFO
- | PhoneStateListener.LISTEN_SERVICE_STATE
- | PhoneStateListener.LISTEN_SIGNAL_STRENGTHS
- | PhoneStateListener.LISTEN_PHYSICAL_CHANNEL_CONFIGURATION);
- }
-
- private void updateDnsCheckState() {
- //FIXME: Replace with a TelephonyManager call
- dnsCheckState.setText(mPhone.isDnsCheckDisabled() ?
- "0.0.0.0 allowed" :"0.0.0.0 not allowed");
- }
-
- private void updateBandwidths(int dlbw, int ulbw) {
- dlbw = (dlbw < 0 || dlbw == Integer.MAX_VALUE) ? -1 : dlbw;
- ulbw = (ulbw < 0 || ulbw == Integer.MAX_VALUE) ? -1 : ulbw;
- mDownlinkKbps.setText(String.format("%-5d", dlbw));
- mUplinkKbps.setText(String.format("%-5d", ulbw));
- }
-
-
- private final void
- updateSignalStrength(SignalStrength signalStrength) {
- Resources r = getResources();
-
- int signalDbm = signalStrength.getDbm();
-
- int signalAsu = signalStrength.getAsuLevel();
-
- if (-1 == signalAsu) signalAsu = 0;
-
- dBm.setText(String.valueOf(signalDbm) + " "
- + r.getString(R.string.radioInfo_display_dbm) + " "
- + String.valueOf(signalAsu) + " "
- + r.getString(R.string.radioInfo_display_asu));
- }
-
- private final void updateLocation(CellLocation location) {
- Resources r = getResources();
- if (location instanceof GsmCellLocation) {
- GsmCellLocation loc = (GsmCellLocation)location;
- int lac = loc.getLac();
- int cid = loc.getCid();
- mLocation.setText(r.getString(R.string.radioInfo_lac) + " = "
- + ((lac == -1) ? "unknown" : Integer.toHexString(lac))
- + " "
- + r.getString(R.string.radioInfo_cid) + " = "
- + ((cid == -1) ? "unknown" : Integer.toHexString(cid)));
- } else if (location instanceof CdmaCellLocation) {
- CdmaCellLocation loc = (CdmaCellLocation)location;
- int bid = loc.getBaseStationId();
- int sid = loc.getSystemId();
- int nid = loc.getNetworkId();
- int lat = loc.getBaseStationLatitude();
- int lon = loc.getBaseStationLongitude();
- mLocation.setText("BID = "
- + ((bid == -1) ? "unknown" : Integer.toHexString(bid))
- + " "
- + "SID = "
- + ((sid == -1) ? "unknown" : Integer.toHexString(sid))
- + " "
- + "NID = "
- + ((nid == -1) ? "unknown" : Integer.toHexString(nid))
- + "\n"
- + "LAT = "
- + ((lat == -1) ? "unknown" : Integer.toHexString(lat))
- + " "
- + "LONG = "
- + ((lon == -1) ? "unknown" : Integer.toHexString(lon)));
- } else {
- mLocation.setText("unknown");
- }
-
-
- }
-
- private final String getCellInfoDisplayString(int i) {
- return (i != Integer.MAX_VALUE) ? Integer.toString(i) : "";
- }
-
- private final String getCellInfoDisplayString(long i) {
- return (i != Long.MAX_VALUE) ? Long.toString(i) : "";
- }
-
- private final String getConnectionStatusString(CellInfo ci) {
- String regStr = "";
- String connStatStr = "";
- String connector = "";
-
- if (ci.isRegistered()) {
- regStr = "R";
- }
- switch (ci.getCellConnectionStatus()) {
- case CellInfo.CONNECTION_PRIMARY_SERVING: connStatStr = "P"; break;
- case CellInfo.CONNECTION_SECONDARY_SERVING: connStatStr = "S"; break;
- case CellInfo.CONNECTION_NONE: connStatStr = "N"; break;
- case CellInfo.CONNECTION_UNKNOWN: /* Field is unsupported */ break;
- default: break;
- }
- if (!TextUtils.isEmpty(regStr) && !TextUtils.isEmpty(connStatStr)) {
- connector = "+";
- }
-
- return regStr + connector + connStatStr;
- }
-
- private final String buildCdmaInfoString(CellInfoCdma ci) {
- CellIdentityCdma cidCdma = ci.getCellIdentity();
- CellSignalStrengthCdma ssCdma = ci.getCellSignalStrength();
-
- return String.format("%-3.3s %-5.5s %-5.5s %-5.5s %-6.6s %-6.6s %-6.6s %-6.6s %-5.5s",
- getConnectionStatusString(ci),
- getCellInfoDisplayString(cidCdma.getSystemId()),
- getCellInfoDisplayString(cidCdma.getNetworkId()),
- getCellInfoDisplayString(cidCdma.getBasestationId()),
- getCellInfoDisplayString(ssCdma.getCdmaDbm()),
- getCellInfoDisplayString(ssCdma.getCdmaEcio()),
- getCellInfoDisplayString(ssCdma.getEvdoDbm()),
- getCellInfoDisplayString(ssCdma.getEvdoEcio()),
- getCellInfoDisplayString(ssCdma.getEvdoSnr()));
- }
-
- private final String buildGsmInfoString(CellInfoGsm ci) {
- CellIdentityGsm cidGsm = ci.getCellIdentity();
- CellSignalStrengthGsm ssGsm = ci.getCellSignalStrength();
-
- return String.format("%-3.3s %-3.3s %-3.3s %-5.5s %-5.5s %-6.6s %-4.4s %-4.4s\n",
- getConnectionStatusString(ci),
- getCellInfoDisplayString(cidGsm.getMcc()),
- getCellInfoDisplayString(cidGsm.getMnc()),
- getCellInfoDisplayString(cidGsm.getLac()),
- getCellInfoDisplayString(cidGsm.getCid()),
- getCellInfoDisplayString(cidGsm.getArfcn()),
- getCellInfoDisplayString(cidGsm.getBsic()),
- getCellInfoDisplayString(ssGsm.getDbm()));
- }
-
- private final String buildLteInfoString(CellInfoLte ci) {
- CellIdentityLte cidLte = ci.getCellIdentity();
- CellSignalStrengthLte ssLte = ci.getCellSignalStrength();
-
- return String.format(
- "%-3.3s %-3.3s %-3.3s %-5.5s %-5.5s %-3.3s %-6.6s %-2.2s %-4.4s %-4.4s %-2.2s\n",
- getConnectionStatusString(ci),
- getCellInfoDisplayString(cidLte.getMcc()),
- getCellInfoDisplayString(cidLte.getMnc()),
- getCellInfoDisplayString(cidLte.getTac()),
- getCellInfoDisplayString(cidLte.getCi()),
- getCellInfoDisplayString(cidLte.getPci()),
- getCellInfoDisplayString(cidLte.getEarfcn()),
- getCellInfoDisplayString(cidLte.getBandwidth()),
- getCellInfoDisplayString(ssLte.getDbm()),
- getCellInfoDisplayString(ssLte.getRsrq()),
- getCellInfoDisplayString(ssLte.getTimingAdvance()));
- }
-
- private final String buildWcdmaInfoString(CellInfoWcdma ci) {
- CellIdentityWcdma cidWcdma = ci.getCellIdentity();
- CellSignalStrengthWcdma ssWcdma = ci.getCellSignalStrength();
-
- return String.format("%-3.3s %-3.3s %-3.3s %-5.5s %-5.5s %-6.6s %-3.3s %-4.4s\n",
- getConnectionStatusString(ci),
- getCellInfoDisplayString(cidWcdma.getMcc()),
- getCellInfoDisplayString(cidWcdma.getMnc()),
- getCellInfoDisplayString(cidWcdma.getLac()),
- getCellInfoDisplayString(cidWcdma.getCid()),
- getCellInfoDisplayString(cidWcdma.getUarfcn()),
- getCellInfoDisplayString(cidWcdma.getPsc()),
- getCellInfoDisplayString(ssWcdma.getDbm()));
- }
-
- private final String buildCellInfoString(List<CellInfo> arrayCi) {
- String value = new String();
- StringBuilder cdmaCells = new StringBuilder(),
- gsmCells = new StringBuilder(),
- lteCells = new StringBuilder(),
- wcdmaCells = new StringBuilder();
-
- if (arrayCi != null) {
- for (CellInfo ci : arrayCi) {
-
- if (ci instanceof CellInfoLte) {
- lteCells.append(buildLteInfoString((CellInfoLte) ci));
- } else if (ci instanceof CellInfoWcdma) {
- wcdmaCells.append(buildWcdmaInfoString((CellInfoWcdma) ci));
- } else if (ci instanceof CellInfoGsm) {
- gsmCells.append(buildGsmInfoString((CellInfoGsm) ci));
- } else if (ci instanceof CellInfoCdma) {
- cdmaCells.append(buildCdmaInfoString((CellInfoCdma) ci));
- }
- }
- if (lteCells.length() != 0) {
- value += String.format(
- "LTE\n%-3.3s %-3.3s %-3.3s %-5.5s %-5.5s %-3.3s"
- + " %-6.6s %-2.2s %-4.4s %-4.4s %-2.2s\n",
- "SRV", "MCC", "MNC", "TAC", "CID", "PCI",
- "EARFCN", "BW", "RSRP", "RSRQ", "TA");
- value += lteCells.toString();
- }
- if (wcdmaCells.length() != 0) {
- value += String.format(
- "WCDMA\n%-3.3s %-3.3s %-3.3s %-5.5s %-5.5s %-6.6s %-3.3s %-4.4s\n",
- "SRV", "MCC", "MNC", "LAC", "CID", "UARFCN", "PSC", "RSCP");
- value += wcdmaCells.toString();
- }
- if (gsmCells.length() != 0) {
- value += String.format(
- "GSM\n%-3.3s %-3.3s %-3.3s %-5.5s %-5.5s %-6.6s %-4.4s %-4.4s\n",
- "SRV", "MCC", "MNC", "LAC", "CID", "ARFCN", "BSIC", "RSSI");
- value += gsmCells.toString();
- }
- if (cdmaCells.length() != 0) {
- value += String.format(
- "CDMA/EVDO\n%-3.3s %-5.5s %-5.5s %-5.5s %-6.6s %-6.6s %-6.6s %-6.6s %-5.5s\n",
- "SRV", "SID", "NID", "BSID", "C-RSSI", "C-ECIO", "E-RSSI", "E-ECIO", "E-SNR");
- value += cdmaCells.toString();
- }
- } else {
- value ="unknown";
- }
-
- return value.toString();
- }
-
- private final void updateCellInfo(List<CellInfo> arrayCi) {
- mCellInfo.setText(buildCellInfoString(arrayCi));
- }
-
- private final void updateSubscriptionIds() {
- mSubscriptionId.setText(Integer.toString(mPhone.getSubId()));
- mDds.setText(Integer.toString(SubscriptionManager.getDefaultDataSubscriptionId()));
- }
-
- private final void
- updateMessageWaiting() {
- mMwi.setText(String.valueOf(mMwiValue));
- }
-
- private final void
- updateCallRedirect() {
- mCfi.setText(String.valueOf(mCfiValue));
- }
-
-
- private final void
- updateServiceState(ServiceState serviceState) {
- int state = serviceState.getState();
- Resources r = getResources();
- String display = r.getString(R.string.radioInfo_unknown);
-
- switch (state) {
- case ServiceState.STATE_IN_SERVICE:
- display = r.getString(R.string.radioInfo_service_in);
- break;
- case ServiceState.STATE_OUT_OF_SERVICE:
- case ServiceState.STATE_EMERGENCY_ONLY:
- display = r.getString(R.string.radioInfo_service_emergency);
- break;
- case ServiceState.STATE_POWER_OFF:
- display = r.getString(R.string.radioInfo_service_off);
- break;
- }
-
- gsmState.setText(display);
-
- if (serviceState.getRoaming()) {
- roamingState.setText(R.string.radioInfo_roaming_in);
- } else {
- roamingState.setText(R.string.radioInfo_roaming_not);
- }
-
- operatorName.setText(serviceState.getOperatorAlphaLong());
- }
-
- private final void
- updatePhoneState(int state) {
- Resources r = getResources();
- String display = r.getString(R.string.radioInfo_unknown);
-
- switch (state) {
- case TelephonyManager.CALL_STATE_IDLE:
- display = r.getString(R.string.radioInfo_phone_idle);
- break;
- case TelephonyManager.CALL_STATE_RINGING:
- display = r.getString(R.string.radioInfo_phone_ringing);
- break;
- case TelephonyManager.CALL_STATE_OFFHOOK:
- display = r.getString(R.string.radioInfo_phone_offhook);
- break;
- }
-
- callState.setText(display);
- }
-
- private final void
- updateDataState() {
- int state = mTelephonyManager.getDataState();
- Resources r = getResources();
- String display = r.getString(R.string.radioInfo_unknown);
-
- switch (state) {
- case TelephonyManager.DATA_CONNECTED:
- display = r.getString(R.string.radioInfo_data_connected);
- break;
- case TelephonyManager.DATA_CONNECTING:
- display = r.getString(R.string.radioInfo_data_connecting);
- break;
- case TelephonyManager.DATA_DISCONNECTED:
- display = r.getString(R.string.radioInfo_data_disconnected);
- break;
- case TelephonyManager.DATA_SUSPENDED:
- display = r.getString(R.string.radioInfo_data_suspended);
- break;
- }
-
- gprsState.setText(display);
- }
-
- private final void updateNetworkType() {
- if(mPhone != null) {
- ServiceState ss = mPhone.getServiceState();
- dataNetwork.setText(ServiceState.rilRadioTechnologyToString(
- mPhone.getServiceState().getRilDataRadioTechnology()));
- voiceNetwork.setText(ServiceState.rilRadioTechnologyToString(
- mPhone.getServiceState().getRilVoiceRadioTechnology()));
- }
- }
-
- private final void
- updateProperties() {
- String s;
- Resources r = getResources();
-
- s = mPhone.getDeviceId();
- if (s == null) s = r.getString(R.string.radioInfo_unknown);
- mDeviceId.setText(s);
-
- s = mPhone.getSubscriberId();
- if (s == null) s = r.getString(R.string.radioInfo_unknown);
- mSubscriberId.setText(s);
-
- //FIXME: Replace with a TelephonyManager call
- s = mPhone.getLine1Number();
- if (s == null) s = r.getString(R.string.radioInfo_unknown);
- number.setText(s);
- }
-
- private final void updateDataStats2() {
- Resources r = getResources();
-
- long txPackets = TrafficStats.getMobileTxPackets();
- long rxPackets = TrafficStats.getMobileRxPackets();
- long txBytes = TrafficStats.getMobileTxBytes();
- long rxBytes = TrafficStats.getMobileRxBytes();
-
- String packets = r.getString(R.string.radioInfo_display_packets);
- String bytes = r.getString(R.string.radioInfo_display_bytes);
-
- sent.setText(txPackets + " " + packets + ", " + txBytes + " " + bytes);
- received.setText(rxPackets + " " + packets + ", " + rxBytes + " " + bytes);
- }
-
- /**
- * Ping a host name
- */
- private final void pingHostname() {
- try {
- try {
- Process p4 = Runtime.getRuntime().exec("ping -c 1 www.google.com");
- int status4 = p4.waitFor();
- if (status4 == 0) {
- mPingHostnameResultV4 = "Pass";
- } else {
- mPingHostnameResultV4 = String.format("Fail(%d)", status4);
- }
- } catch (IOException e) {
- mPingHostnameResultV4 = "Fail: IOException";
- }
- try {
- Process p6 = Runtime.getRuntime().exec("ping6 -c 1 www.google.com");
- int status6 = p6.waitFor();
- if (status6 == 0) {
- mPingHostnameResultV6 = "Pass";
- } else {
- mPingHostnameResultV6 = String.format("Fail(%d)", status6);
- }
- } catch (IOException e) {
- mPingHostnameResultV6 = "Fail: IOException";
- }
- } catch (InterruptedException e) {
- mPingHostnameResultV4 = mPingHostnameResultV6 = "Fail: InterruptedException";
- }
- }
-
- /**
- * This function checks for basic functionality of HTTP Client.
- */
- private void httpClientTest() {
- HttpURLConnection urlConnection = null;
- try {
- // TODO: Hardcoded for now, make it UI configurable
- URL url = new URL("https://www.google.com");
- urlConnection = (HttpURLConnection) url.openConnection();
- if (urlConnection.getResponseCode() == 200) {
- mHttpClientTestResult = "Pass";
- } else {
- mHttpClientTestResult = "Fail: Code: " + urlConnection.getResponseMessage();
- }
- } catch (IOException e) {
- mHttpClientTestResult = "Fail: IOException";
- } finally {
- if (urlConnection != null) {
- urlConnection.disconnect();
- }
- }
- }
-
- private void refreshSmsc() {
- //FIXME: Replace with a TelephonyManager call
- mPhone.getSmscAddress(mHandler.obtainMessage(EVENT_QUERY_SMSC_DONE));
- }
-
- private final void updateAllCellInfo() {
-
- mCellInfo.setText("");
- mLocation.setText("");
-
- final Runnable updateAllCellInfoResults = new Runnable() {
- public void run() {
- updateLocation(mCellLocationResult);
- updateCellInfo(mCellInfoResult);
- }
- };
-
- Thread locThread = new Thread() {
- @Override
- public void run() {
- mCellInfoResult = mTelephonyManager.getAllCellInfo();
- mCellLocationResult = mTelephonyManager.getCellLocation();
-
- mHandler.post(updateAllCellInfoResults);
- }
- };
- locThread.start();
- }
-
- private final void updatePingState() {
- // Set all to unknown since the threads will take a few secs to update.
- mPingHostnameResultV4 = getResources().getString(R.string.radioInfo_unknown);
- mPingHostnameResultV6 = getResources().getString(R.string.radioInfo_unknown);
- mHttpClientTestResult = getResources().getString(R.string.radioInfo_unknown);
-
- mPingHostnameV4.setText(mPingHostnameResultV4);
- mPingHostnameV6.setText(mPingHostnameResultV6);
- mHttpClientTest.setText(mHttpClientTestResult);
-
- final Runnable updatePingResults = new Runnable() {
- public void run() {
- mPingHostnameV4.setText(mPingHostnameResultV4);
- mPingHostnameV6.setText(mPingHostnameResultV6);
- mHttpClientTest.setText(mHttpClientTestResult);
- }
- };
-
- Thread hostname = new Thread() {
- @Override
- public void run() {
- pingHostname();
- mHandler.post(updatePingResults);
- }
- };
- hostname.start();
-
- Thread httpClient = new Thread() {
- @Override
- public void run() {
- httpClientTest();
- mHandler.post(updatePingResults);
- }
- };
- httpClient.start();
- }
-
- private MenuItem.OnMenuItemClickListener mViewADNCallback = new MenuItem.OnMenuItemClickListener() {
- public boolean onMenuItemClick(MenuItem item) {
- Intent intent = new Intent(Intent.ACTION_VIEW);
- // XXX We need to specify the component here because if we don't
- // the activity manager will try to resolve the type by calling
- // the content provider, which causes it to be loaded in a process
- // other than the Dialer process, which causes a lot of stuff to
- // break.
- intent.setClassName("com.android.phone", "com.android.phone.SimContacts");
- startActivity(intent);
- return true;
- }
- };
-
- private MenuItem.OnMenuItemClickListener mViewFDNCallback = new MenuItem.OnMenuItemClickListener() {
- public boolean onMenuItemClick(MenuItem item) {
- Intent intent = new Intent(Intent.ACTION_VIEW);
- // XXX We need to specify the component here because if we don't
- // the activity manager will try to resolve the type by calling
- // the content provider, which causes it to be loaded in a process
- // other than the Dialer process, which causes a lot of stuff to
- // break.
- intent.setClassName("com.android.phone", "com.android.phone.settings.fdn.FdnList");
- startActivity(intent);
- return true;
- }
- };
-
- private MenuItem.OnMenuItemClickListener mViewSDNCallback = new MenuItem.OnMenuItemClickListener() {
- public boolean onMenuItemClick(MenuItem item) {
- Intent intent = new Intent(
- Intent.ACTION_VIEW, Uri.parse("content://icc/sdn"));
- // XXX We need to specify the component here because if we don't
- // the activity manager will try to resolve the type by calling
- // the content provider, which causes it to be loaded in a process
- // other than the Dialer process, which causes a lot of stuff to
- // break.
- intent.setClassName("com.android.phone", "com.android.phone.ADNList");
- startActivity(intent);
- return true;
- }
- };
-
- private MenuItem.OnMenuItemClickListener mGetImsStatus = new MenuItem.OnMenuItemClickListener() {
- public boolean onMenuItemClick(MenuItem item) {
- boolean isImsRegistered = mPhone.isImsRegistered();
- boolean availableVolte = mPhone.isVolteEnabled();
- boolean availableWfc = mPhone.isWifiCallingEnabled();
- boolean availableVt = mPhone.isVideoEnabled();
- boolean availableUt = mPhone.isUtEnabled();
-
- final String imsRegString = isImsRegistered ?
- getString(R.string.radio_info_ims_reg_status_registered) :
- getString(R.string.radio_info_ims_reg_status_not_registered);
-
- final String available = getString(R.string.radio_info_ims_feature_status_available);
- final String unavailable = getString(
- R.string.radio_info_ims_feature_status_unavailable);
-
- String imsStatus = getString(R.string.radio_info_ims_reg_status,
- imsRegString,
- availableVolte ? available : unavailable,
- availableWfc ? available : unavailable,
- availableVt ? available : unavailable,
- availableUt ? available : unavailable);
-
- AlertDialog imsDialog = new AlertDialog.Builder(RadioInfo.this)
- .setMessage(imsStatus)
- .setTitle(getString(R.string.radio_info_ims_reg_status_title))
- .create();
-
- imsDialog.show();
-
- return true;
- }
- };
-
- private MenuItem.OnMenuItemClickListener mSelectBandCallback = new MenuItem.OnMenuItemClickListener() {
- public boolean onMenuItemClick(MenuItem item) {
- Intent intent = new Intent();
- intent.setClass(RadioInfo.this, BandMode.class);
- startActivity(intent);
- return true;
- }
- };
-
- private MenuItem.OnMenuItemClickListener mToggleData = new MenuItem.OnMenuItemClickListener() {
- public boolean onMenuItemClick(MenuItem item) {
- int state = mTelephonyManager.getDataState();
- switch (state) {
- case TelephonyManager.DATA_CONNECTED:
- mTelephonyManager.setDataEnabled(false);
- break;
- case TelephonyManager.DATA_DISCONNECTED:
- mTelephonyManager.setDataEnabled(true);
- break;
- default:
- // do nothing
- break;
- }
- return true;
- }
- };
-
- private boolean isRadioOn() {
- //FIXME: Replace with a TelephonyManager call
- return mPhone.getServiceState().getState() != ServiceState.STATE_POWER_OFF;
- }
-
- private void updateRadioPowerState() {
- //delightful hack to prevent on-checked-changed calls from
- //actually forcing the radio preference to its transient/current value.
- radioPowerOnSwitch.setOnCheckedChangeListener(null);
- radioPowerOnSwitch.setChecked(isRadioOn());
- radioPowerOnSwitch.setOnCheckedChangeListener(mRadioPowerOnChangeListener);
- }
-
- void setImsVolteProvisionedState(boolean state) {
- Log.d(TAG, "setImsVolteProvisioned state: " + ((state)? "on":"off"));
- setImsConfigProvisionedState(IMS_VOLTE_PROVISIONED_CONFIG_ID, state);
- }
-
- void setImsVtProvisionedState(boolean state) {
- Log.d(TAG, "setImsVtProvisioned() state: " + ((state)? "on":"off"));
- setImsConfigProvisionedState(IMS_VT_PROVISIONED_CONFIG_ID, state);
- }
-
- void setImsWfcProvisionedState(boolean state) {
- Log.d(TAG, "setImsWfcProvisioned() state: " + ((state)? "on":"off"));
- setImsConfigProvisionedState(IMS_WFC_PROVISIONED_CONFIG_ID, state);
- }
-
- void setEabProvisionedState(boolean state) {
- Log.d(TAG, "setEabProvisioned() state: " + ((state)? "on":"off"));
- setImsConfigProvisionedState(EAB_PROVISIONED_CONFIG_ID, state);
- }
-
- void setImsConfigProvisionedState(int configItem, boolean state) {
- if (mPhone != null && mImsManager != null) {
- QueuedWork.queue(new Runnable() {
- public void run() {
- try {
- mImsManager.getConfigInterface().setProvisionedValue(
- configItem,
- state? 1 : 0);
- } catch (ImsException e) {
- Log.e(TAG, "setImsConfigProvisioned() exception:", e);
- }
- }
- }, false);
- }
- }
-
- OnCheckedChangeListener mRadioPowerOnChangeListener = new OnCheckedChangeListener() {
- @Override
- public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
- log("toggle radio power: currently " + (isRadioOn()?"on":"off"));
- mPhone.setRadioPower(isChecked);
- }
- };
-
- private boolean isImsVolteProvisioned() {
- if (mPhone != null && mImsManager != null) {
- return mImsManager.isVolteEnabledByPlatform(mPhone.getContext())
- && mImsManager.isVolteProvisionedOnDevice(mPhone.getContext());
- }
- return false;
- }
-
- OnCheckedChangeListener mImsVolteCheckedChangeListener = new OnCheckedChangeListener() {
- @Override
- public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
- setImsVolteProvisionedState(isChecked);
- }
- };
-
- private boolean isImsVtProvisioned() {
- if (mPhone != null && mImsManager != null) {
- return mImsManager.isVtEnabledByPlatform(mPhone.getContext())
- && mImsManager.isVtProvisionedOnDevice(mPhone.getContext());
- }
- return false;
- }
-
- OnCheckedChangeListener mImsVtCheckedChangeListener = new OnCheckedChangeListener() {
- @Override
- public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
- setImsVtProvisionedState(isChecked);
- }
- };
-
- private boolean isImsWfcProvisioned() {
- if (mPhone != null && mImsManager != null) {
- return mImsManager.isWfcEnabledByPlatform(mPhone.getContext())
- && mImsManager.isWfcProvisionedOnDevice(mPhone.getContext());
- }
- return false;
- }
-
- OnCheckedChangeListener mImsWfcCheckedChangeListener = new OnCheckedChangeListener() {
- @Override
- public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
- setImsWfcProvisionedState(isChecked);
- }
- };
-
- private boolean isEabProvisioned() {
- return isFeatureProvisioned(EAB_PROVISIONED_CONFIG_ID, false);
- }
-
- OnCheckedChangeListener mEabCheckedChangeListener = new OnCheckedChangeListener() {
- @Override
- public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
- setEabProvisionedState(isChecked);
- }
- };
-
- private boolean isFeatureProvisioned(int featureId, boolean defaultValue) {
- boolean provisioned = defaultValue;
- if (mImsManager != null) {
- try {
- ImsConfig imsConfig = mImsManager.getConfigInterface();
- if (imsConfig != null) {
- provisioned =
- (imsConfig.getProvisionedValue(featureId)
- == ImsConfig.FeatureValueConstants.ON);
- }
- } catch (ImsException ex) {
- Log.e(TAG, "isFeatureProvisioned() exception:", ex);
- }
- }
-
- log("isFeatureProvisioned() featureId=" + featureId + " provisioned=" + provisioned);
- return provisioned;
- }
-
- private static boolean isEabEnabledByPlatform(Context context) {
- if (context != null) {
- CarrierConfigManager configManager = (CarrierConfigManager)
- context.getSystemService(Context.CARRIER_CONFIG_SERVICE);
- if (configManager != null && configManager.getConfig().getBoolean(
- CarrierConfigManager.KEY_USE_RCS_PRESENCE_BOOL)) {
- return true;
- }
- }
- return false;
- }
-
- private void updateImsProvisionedState() {
- if (!ImsManager.isImsSupportedOnDevice(mPhone.getContext())) {
- return;
- }
- log("updateImsProvisionedState isImsVolteProvisioned()=" + isImsVolteProvisioned());
- //delightful hack to prevent on-checked-changed calls from
- //actually forcing the ims provisioning to its transient/current value.
- imsVolteProvisionedSwitch.setOnCheckedChangeListener(null);
- imsVolteProvisionedSwitch.setChecked(isImsVolteProvisioned());
- imsVolteProvisionedSwitch.setOnCheckedChangeListener(mImsVolteCheckedChangeListener);
- imsVolteProvisionedSwitch.setEnabled(!Build.IS_USER
- && mImsManager.isVolteEnabledByPlatform(mPhone.getContext()));
-
- imsVtProvisionedSwitch.setOnCheckedChangeListener(null);
- imsVtProvisionedSwitch.setChecked(isImsVtProvisioned());
- imsVtProvisionedSwitch.setOnCheckedChangeListener(mImsVtCheckedChangeListener);
- imsVtProvisionedSwitch.setEnabled(!Build.IS_USER
- && mImsManager.isVtEnabledByPlatform(mPhone.getContext()));
-
- imsWfcProvisionedSwitch.setOnCheckedChangeListener(null);
- imsWfcProvisionedSwitch.setChecked(isImsWfcProvisioned());
- imsWfcProvisionedSwitch.setOnCheckedChangeListener(mImsWfcCheckedChangeListener);
- imsWfcProvisionedSwitch.setEnabled(!Build.IS_USER
- && mImsManager.isWfcEnabledByPlatform(mPhone.getContext()));
-
- eabProvisionedSwitch.setOnCheckedChangeListener(null);
- eabProvisionedSwitch.setChecked(isEabProvisioned());
- eabProvisionedSwitch.setOnCheckedChangeListener(mEabCheckedChangeListener);
- eabProvisionedSwitch.setEnabled(!Build.IS_USER
- && isEabEnabledByPlatform(mPhone.getContext()));
- }
-
- OnClickListener mDnsCheckButtonHandler = new OnClickListener() {
- public void onClick(View v) {
- //FIXME: Replace with a TelephonyManager call
- mPhone.disableDnsCheck(!mPhone.isDnsCheckDisabled());
- updateDnsCheckState();
- }
- };
-
- OnClickListener mOemInfoButtonHandler = new OnClickListener() {
- public void onClick(View v) {
- Intent intent = new Intent("com.android.settings.OEM_RADIO_INFO");
- try {
- startActivity(intent);
- } catch (android.content.ActivityNotFoundException ex) {
- log("OEM-specific Info/Settings Activity Not Found : " + ex);
- // If the activity does not exist, there are no OEM
- // settings, and so we can just do nothing...
- }
- }
- };
-
- OnClickListener mPingButtonHandler = new OnClickListener() {
- public void onClick(View v) {
- updatePingState();
- }
- };
-
- OnClickListener mUpdateSmscButtonHandler = new OnClickListener() {
- public void onClick(View v) {
- updateSmscButton.setEnabled(false);
- mPhone.setSmscAddress(smsc.getText().toString(),
- mHandler.obtainMessage(EVENT_UPDATE_SMSC_DONE));
- }
- };
-
- OnClickListener mRefreshSmscButtonHandler = new OnClickListener() {
- public void onClick(View v) {
- refreshSmsc();
- }
- };
-
- OnClickListener mCarrierProvisioningButtonHandler = new OnClickListener() {
- public void onClick(View v) {
- final Intent intent = new Intent("com.android.settings.CARRIER_PROVISIONING");
- final ComponentName serviceComponent = ComponentName.unflattenFromString(
- "com.android.omadm.service/.DMIntentReceiver");
- intent.setComponent(serviceComponent);
- sendBroadcast(intent);
- }
- };
-
- OnClickListener mTriggerCarrierProvisioningButtonHandler = new OnClickListener() {
- public void onClick(View v) {
- final Intent intent = new Intent("com.android.settings.TRIGGER_CARRIER_PROVISIONING");
- final ComponentName serviceComponent = ComponentName.unflattenFromString(
- "com.android.omadm.service/.DMIntentReceiver");
- intent.setComponent(serviceComponent);
- sendBroadcast(intent);
- }
- };
-
- AdapterView.OnItemSelectedListener mPreferredNetworkHandler =
- new AdapterView.OnItemSelectedListener() {
-
- public void onItemSelected(AdapterView parent, View v, int pos, long id) {
- if (mPreferredNetworkTypeResult != pos && pos >= 0
- && pos <= mPreferredNetworkLabels.length - 2) {
- mPreferredNetworkTypeResult = pos;
-
- // TODO: Possibly migrate this to TelephonyManager.setPreferredNetworkType()
- // which today still has some issues (mostly that the "set" is conditional
- // on a successful modem call, which is not what we want). Instead we always
- // want this setting to be set, so that if the radio hiccups and this setting
- // is for some reason unsuccessful, future calls to the radio will reflect
- // the users's preference which is set here.
- final int subId = mPhone.getSubId();
- if (SubscriptionManager.isUsableSubIdValue(subId)) {
- Settings.Global.putInt(mPhone.getContext().getContentResolver(),
- PREFERRED_NETWORK_MODE + subId, mPreferredNetworkTypeResult);
- }
- log("Calling setPreferredNetworkType(" + mPreferredNetworkTypeResult + ")");
- Message msg = mHandler.obtainMessage(EVENT_SET_PREFERRED_TYPE_DONE);
- mPhone.setPreferredNetworkType(mPreferredNetworkTypeResult, msg);
- }
- }
-
- public void onNothingSelected(AdapterView parent) {
- }
- };
-
- AdapterView.OnItemSelectedListener mSelectPhoneIndexHandler =
- new AdapterView.OnItemSelectedListener() {
-
- public void onItemSelected(AdapterView parent, View v, int pos, long id) {
- if (pos >= 0 && pos <= mPhoneIndexLabels.length - 1) {
- // the array position is equal to the phone index
- int phoneIndex = pos;
- Phone[] phones = PhoneFactory.getPhones();
- if (phones == null || phones.length <= phoneIndex) {
- return;
- }
- // getSubId says it takes a slotIndex, but it actually takes a phone index
- int subId = SubscriptionManager.INVALID_SUBSCRIPTION_ID;
- int[] subIds = SubscriptionManager.getSubId(phoneIndex);
- if (subIds != null && subIds.length > 0) {
- subId = subIds[0];
- }
- mSelectedPhoneIndex = phoneIndex;
-
- updatePhoneIndex(phoneIndex, subId);
- }
- }
-
- public void onNothingSelected(AdapterView parent) {
- }
- };
-
- AdapterView.OnItemSelectedListener mCellInfoRefreshRateHandler =
- new AdapterView.OnItemSelectedListener() {
-
- public void onItemSelected(AdapterView parent, View v, int pos, long id) {
- mCellInfoRefreshRateIndex = pos;
- mTelephonyManager.setCellInfoListRate(mCellInfoRefreshRates[pos]);
- updateAllCellInfo();
- }
-
- public void onNothingSelected(AdapterView parent) {
- }
- };
-
- boolean isCbrsSupported() {
- return getResources().getBoolean(
- com.android.internal.R.bool.config_cbrs_supported);
- }
-
- void updateCbrsDataState(boolean state) {
- Log.d(TAG, "setCbrsDataSwitchState() state:" + ((state)? "on":"off"));
- if (mTelephonyManager != null) {
- QueuedWork.queue(new Runnable() {
- public void run() {
- mTelephonyManager.setOpportunisticNetworkState(state);
- cbrsDataSwitch.setChecked(getCbrsDataState());
- }
- }, false);
- }
- }
-
- boolean getCbrsDataState() {
- boolean state = false;
- if (mTelephonyManager != null) {
- state = mTelephonyManager.isOpportunisticNetworkEnabled();
- }
- Log.d(TAG, "getCbrsDataState() state:" +((state)? "on":"off"));
- return state;
- }
-
- OnCheckedChangeListener mCbrsDataSwitchChangeListener = new OnCheckedChangeListener() {
- @Override
- public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
- updateCbrsDataState(isChecked);
- }
- };
-
- private void showDsdsChangeDialog() {
- final AlertDialog confirmDialog = new Builder(RadioInfo.this)
- .setTitle(R.string.dsds_dialog_title)
- .setMessage(R.string.dsds_dialog_message)
- .setPositiveButton(R.string.dsds_dialog_confirm, mOnDsdsDialogConfirmedListener)
- .setNegativeButton(R.string.dsds_dialog_cancel, mOnDsdsDialogConfirmedListener)
- .create();
- confirmDialog.show();
- }
-
- private static boolean isDsdsSupported() {
- return (TelephonyManager.getDefault().isMultiSimSupported()
- == TelephonyManager.MULTISIM_ALLOWED);
- }
-
- private static boolean isDsdsEnabled() {
- return TelephonyManager.getDefault().getPhoneCount() > 1;
- }
-
- private void performDsdsSwitch() {
- mTelephonyManager.switchMultiSimConfig(dsdsSwitch.isChecked() ? 2 : 1);
- }
-
- /**
- * @return {@code True} if the device is only supported dsds mode.
- */
- private boolean dsdsModeOnly() {
- String dsdsMode = SystemProperties.get(DSDS_MODE_PROPERTY);
- return !TextUtils.isEmpty(dsdsMode) && Integer.parseInt(dsdsMode) == ALWAYS_ON_DSDS_MODE;
- }
-
- DialogInterface.OnClickListener mOnDsdsDialogConfirmedListener =
- new DialogInterface.OnClickListener() {
- @Override
- public void onClick(DialogInterface dialog, int which) {
- if (which == DialogInterface.BUTTON_POSITIVE) {
- dsdsSwitch.toggle();
- performDsdsSwitch();
- }
- }
- };
-}
diff --git a/src/com/android/settings/RegulatoryInfoDisplayActivity.java b/src/com/android/settings/RegulatoryInfoDisplayActivity.java
index 4c7515d..20aafc2 100644
--- a/src/com/android/settings/RegulatoryInfoDisplayActivity.java
+++ b/src/com/android/settings/RegulatoryInfoDisplayActivity.java
@@ -60,12 +60,6 @@
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
- Resources resources = getResources();
-
- if (!resources.getBoolean(R.bool.config_show_regulatory_info)) {
- finish(); // no regulatory info to display for this device
- }
-
AlertDialog.Builder builder = new AlertDialog.Builder(this)
.setTitle(R.string.regulatory_labels)
.setOnDismissListener(this);
@@ -95,7 +89,8 @@
}
}
- CharSequence regulatoryText = resources.getText(R.string.regulatory_info_text);
+ CharSequence regulatoryText = getResources()
+ .getText(R.string.regulatory_info_text);
if (regulatoryInfoDrawableExists) {
View view = getLayoutInflater().inflate(R.layout.regulatory_info, null);
diff --git a/src/com/android/settings/SettingsActivity.java b/src/com/android/settings/SettingsActivity.java
index 9270a5a..4d813d5 100644
--- a/src/com/android/settings/SettingsActivity.java
+++ b/src/com/android/settings/SettingsActivity.java
@@ -35,6 +35,7 @@
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;
@@ -52,11 +53,13 @@
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;
@@ -565,7 +568,15 @@
throw new IllegalArgumentException("Invalid fragment for this activity: "
+ fragmentName);
}
- Fragment f = Fragment.instantiate(this, fragmentName, args);
+ 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);
+ }
FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
transaction.replace(R.id.main_content, f);
if (titleResId > 0) {
diff --git a/src/com/android/settings/accessibility/AccessibilityShortcutPreferenceFragment.java b/src/com/android/settings/accessibility/AccessibilityShortcutPreferenceFragment.java
index 95a2b76..ab855bc 100644
--- a/src/com/android/settings/accessibility/AccessibilityShortcutPreferenceFragment.java
+++ b/src/com/android/settings/accessibility/AccessibilityShortcutPreferenceFragment.java
@@ -34,6 +34,7 @@
import com.android.internal.accessibility.AccessibilityShortcutController;
import com.android.settings.R;
+import com.android.settings.widget.SwitchBar;
import com.android.settings.search.BaseSearchIndexProvider;
import com.android.settingslib.search.Indexable;
import com.android.settingslib.accessibility.AccessibilityUtils;
@@ -126,6 +127,13 @@
updatePreferences();
}
+ @Override
+ protected void updateSwitchBarText(SwitchBar switchBar) {
+ final String switchBarText = getString(R.string.accessibility_service_master_switch_title,
+ getString(R.string.accessibility_global_gesture_preference_title));
+ switchBar.setSwitchBarText(switchBarText, switchBarText);
+ }
+
private void updatePreferences() {
ContentResolver cr = getContentResolver();
Context context = getContext();
diff --git a/src/com/android/settings/accessibility/ToggleAccessibilityServicePreferenceFragment.java b/src/com/android/settings/accessibility/ToggleAccessibilityServicePreferenceFragment.java
index 1556bec..f30af54 100644
--- a/src/com/android/settings/accessibility/ToggleAccessibilityServicePreferenceFragment.java
+++ b/src/com/android/settings/accessibility/ToggleAccessibilityServicePreferenceFragment.java
@@ -44,6 +44,7 @@
import com.android.internal.widget.LockPatternUtils;
import com.android.settings.R;
import com.android.settings.password.ConfirmDeviceCredentialActivity;
+import com.android.settings.widget.SwitchBar;
import com.android.settings.widget.ToggleSwitch;
import com.android.settings.widget.ToggleSwitch.OnBeforeCheckedChangeListener;
import com.android.settingslib.accessibility.AccessibilityUtils;
@@ -211,6 +212,15 @@
}
}
+ @Override
+ protected void updateSwitchBarText(SwitchBar switchBar) {
+ final AccessibilityServiceInfo info = getAccessibilityServiceInfo();
+ final String switchBarText = (info == null) ? "" :
+ getString(R.string.accessibility_service_master_switch_title,
+ info.getResolveInfo().loadLabel(getPackageManager()));
+ switchBar.setSwitchBarText(switchBarText, switchBarText);
+ }
+
private void updateSwitchBarToggleSwitch() {
final boolean checked = AccessibilityUtils.getEnabledServicesFromSettings(getActivity())
.contains(mComponentName);
diff --git a/src/com/android/settings/accessibility/ToggleAutoclickPreferenceFragment.java b/src/com/android/settings/accessibility/ToggleAutoclickPreferenceFragment.java
index df72cff..45dd39e 100644
--- a/src/com/android/settings/accessibility/ToggleAutoclickPreferenceFragment.java
+++ b/src/com/android/settings/accessibility/ToggleAutoclickPreferenceFragment.java
@@ -172,6 +172,13 @@
return false;
}
+ @Override
+ protected void updateSwitchBarText(SwitchBar switchBar) {
+ final String switchBarText = getString(R.string.accessibility_service_master_switch_title,
+ getString(R.string.accessibility_autoclick_preference_title));
+ switchBar.setSwitchBarText(switchBarText, switchBarText);
+ }
+
/**
* Converts seek bar preference progress value to autoclick delay associated with it.
*/
diff --git a/src/com/android/settings/accessibility/ToggleDaltonizerPreferenceFragment.java b/src/com/android/settings/accessibility/ToggleDaltonizerPreferenceFragment.java
index c5376eb..e02a74a 100644
--- a/src/com/android/settings/accessibility/ToggleDaltonizerPreferenceFragment.java
+++ b/src/com/android/settings/accessibility/ToggleDaltonizerPreferenceFragment.java
@@ -105,8 +105,9 @@
@Override
protected void updateSwitchBarText(SwitchBar switchBar) {
- switchBar.setSwitchBarText(R.string.accessibility_daltonizer_master_switch_title,
- R.string.accessibility_daltonizer_master_switch_title);
+ final String switchBarText = getString(R.string.accessibility_service_master_switch_title,
+ getString(R.string.accessibility_display_daltonizer_preference_title));
+ switchBar.setSwitchBarText(switchBarText, switchBarText);
}
private void initPreferences() {
diff --git a/src/com/android/settings/accessibility/ToggleFeaturePreferenceFragment.java b/src/com/android/settings/accessibility/ToggleFeaturePreferenceFragment.java
index 314a577..a4b1878 100644
--- a/src/com/android/settings/accessibility/ToggleFeaturePreferenceFragment.java
+++ b/src/com/android/settings/accessibility/ToggleFeaturePreferenceFragment.java
@@ -58,10 +58,10 @@
SettingsActivity activity = (SettingsActivity) getActivity();
mSwitchBar = activity.getSwitchBar();
- updateSwitchBarText(mSwitchBar);
mToggleSwitch = mSwitchBar.getSwitch();
onProcessArguments(getArguments());
+ updateSwitchBarText(mSwitchBar);
// Show the "Settings" menu as if it were a preference screen
if (mSettingsTitle != null && mSettingsIntent != null) {
diff --git a/src/com/android/settings/accessibility/ToggleScreenMagnificationPreferenceFragment.java b/src/com/android/settings/accessibility/ToggleScreenMagnificationPreferenceFragment.java
index ec3ebcc..842ec5c 100644
--- a/src/com/android/settings/accessibility/ToggleScreenMagnificationPreferenceFragment.java
+++ b/src/com/android/settings/accessibility/ToggleScreenMagnificationPreferenceFragment.java
@@ -50,6 +50,7 @@
ToggleFeaturePreferenceFragment implements SwitchBar.OnSwitchChangeListener {
private static final int DIALOG_ID_GESTURE_NAVIGATION_TUTORIAL = 1;
+ private static final int DIALOG_ID_ACCESSIBILITY_BUTTON_TUTORIAL = 2;
private Dialog mDialog;
@@ -172,14 +173,17 @@
@Override
public Dialog onCreateDialog(int dialogId) {
- if (dialogId == DIALOG_ID_GESTURE_NAVIGATION_TUTORIAL) {
- if (isGestureNavigateEnabled()) {
+ switch (dialogId) {
+ case DIALOG_ID_GESTURE_NAVIGATION_TUTORIAL:
mDialog = AccessibilityGestureNavigationTutorial
.showGestureNavigationTutorialDialog(getActivity());
- } else {
+ break;
+ case DIALOG_ID_ACCESSIBILITY_BUTTON_TUTORIAL:
mDialog = AccessibilityGestureNavigationTutorial
.showAccessibilityButtonTutorialDialog(getActivity());
- }
+ break;
+ default:
+ throw new IllegalArgumentException();
}
return mDialog;
@@ -193,7 +197,14 @@
@Override
public int getDialogMetricsCategory(int dialogId) {
- return SettingsEnums.ACCESSIBILITY_TOGGLE_SCREEN_MAGNIFICATION;
+ switch (dialogId) {
+ case DIALOG_ID_GESTURE_NAVIGATION_TUTORIAL:
+ return SettingsEnums.DIALOG_TOGGLE_SCREEN_MAGNIFICATION_GESTURE_NAVIGATION;
+ case DIALOG_ID_ACCESSIBILITY_BUTTON_TUTORIAL:
+ return SettingsEnums.DIALOG_TOGGLE_SCREEN_MAGNIFICATION_ACCESSIBILITY_BUTTON;
+ default:
+ return 0;
+ }
}
@Override
@@ -206,7 +217,8 @@
if (enabled && TextUtils.equals(
Settings.Secure.ACCESSIBILITY_DISPLAY_MAGNIFICATION_NAVBAR_ENABLED,
preferenceKey)) {
- showDialog(DIALOG_ID_GESTURE_NAVIGATION_TUTORIAL);
+ showDialog(isGestureNavigateEnabled() ? DIALOG_ID_GESTURE_NAVIGATION_TUTORIAL
+ : DIALOG_ID_ACCESSIBILITY_BUTTON_TUTORIAL);
}
MagnificationPreferenceFragment.setChecked(getContentResolver(), preferenceKey, enabled);
updateConfigurationWarningIfNeeded();
@@ -228,6 +240,13 @@
}
@Override
+ protected void updateSwitchBarText(SwitchBar switchBar) {
+ final String switchBarText = getString(R.string.accessibility_service_master_switch_title,
+ getString(R.string.accessibility_screen_magnification_title));
+ switchBar.setSwitchBarText(switchBarText, switchBarText);
+ }
+
+ @Override
protected void onProcessArguments(Bundle arguments) {
super.onProcessArguments(arguments);
if (arguments == null) {
diff --git a/src/com/android/settings/accounts/AccountDashboardFragment.java b/src/com/android/settings/accounts/AccountDashboardFragment.java
index 83f071a..46c08ab 100644
--- a/src/com/android/settings/accounts/AccountDashboardFragment.java
+++ b/src/com/android/settings/accounts/AccountDashboardFragment.java
@@ -23,6 +23,7 @@
import com.android.settings.R;
import com.android.settings.SettingsPreferenceFragment;
import com.android.settings.dashboard.DashboardFragment;
+import com.android.settings.dashboard.profileselector.ProfileSelectFragment;
import com.android.settings.search.BaseSearchIndexProvider;
import com.android.settings.users.AutoSyncDataPreferenceController;
import com.android.settings.users.AutoSyncPersonalDataPreferenceController;
@@ -70,7 +71,8 @@
final List<AbstractPreferenceController> controllers = new ArrayList<>();
final AccountPreferenceController accountPrefController =
- new AccountPreferenceController(context, parent, authorities);
+ new AccountPreferenceController(context, parent, authorities,
+ ProfileSelectFragment.ALL);
if (parent != null) {
parent.getSettingsLifecycle().addObserver(accountPrefController);
}
diff --git a/src/com/android/settings/accounts/AccountPersonalDashboardFragment.java b/src/com/android/settings/accounts/AccountPersonalDashboardFragment.java
new file mode 100644
index 0000000..ac426a2
--- /dev/null
+++ b/src/com/android/settings/accounts/AccountPersonalDashboardFragment.java
@@ -0,0 +1,97 @@
+/*
+ * 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.accounts;
+
+import static android.provider.Settings.EXTRA_AUTHORITIES;
+
+import android.app.settings.SettingsEnums;
+import android.content.Context;
+
+import com.android.settings.R;
+import com.android.settings.SettingsPreferenceFragment;
+import com.android.settings.dashboard.DashboardFragment;
+import com.android.settings.dashboard.profileselector.ProfileSelectFragment;
+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;
+
+/**
+ * Account Setting page for personal profile.
+ */
+@SearchIndexable
+public class AccountPersonalDashboardFragment extends DashboardFragment {
+
+ private static final String TAG = "AccountPersonalFrag";
+
+ @Override
+ public int getMetricsCategory() {
+ return SettingsEnums.ACCOUNT;
+ }
+
+ @Override
+ protected String getLogTag() {
+ return TAG;
+ }
+
+ @Override
+ protected int getPreferenceScreenResId() {
+ return R.xml.accounts_personal_dashboard_settings;
+ }
+
+ @Override
+ public int getHelpResource() {
+ return R.string.help_url_user_and_account_dashboard;
+ }
+
+ @Override
+ protected List<AbstractPreferenceController> createPreferenceControllers(Context context) {
+ final String[] authorities = getIntent().getStringArrayExtra(EXTRA_AUTHORITIES);
+ return buildPreferenceControllers(context, this /* parent */, authorities);
+ }
+
+ private static List<AbstractPreferenceController> buildPreferenceControllers(Context context,
+ SettingsPreferenceFragment parent, String[] authorities) {
+ final List<AbstractPreferenceController> controllers = new ArrayList<>();
+
+ final AccountPreferenceController accountPrefController =
+ new AccountPreferenceController(context, parent, authorities,
+ ProfileSelectFragment.PERSONAL);
+ if (parent != null) {
+ parent.getSettingsLifecycle().addObserver(accountPrefController);
+ }
+ controllers.add(accountPrefController);
+ controllers.add(new AutoSyncDataPreferenceController(context, parent));
+ controllers.add(new AutoSyncPersonalDataPreferenceController(context, parent));
+ return controllers;
+ }
+
+ // TODO: b/141601408. After featureFlag settings_work_profile is launched, unmark this
+// public static final BaseSearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
+// new BaseSearchIndexProvider(R.xml.accounts_personal_dashboard_settings) {
+//
+// @Override
+// public List<AbstractPreferenceController> createPreferenceControllers(
+// Context context) {
+// return buildPreferenceControllers(
+// context, null /* parent */, null /* authorities*/);
+// }
+// };
+}
diff --git a/src/com/android/settings/accounts/AccountPreferenceController.java b/src/com/android/settings/accounts/AccountPreferenceController.java
index 5c930e2..8e3e702 100644
--- a/src/com/android/settings/accounts/AccountPreferenceController.java
+++ b/src/com/android/settings/accounts/AccountPreferenceController.java
@@ -53,8 +53,8 @@
import com.android.settings.Utils;
import com.android.settings.core.PreferenceControllerMixin;
import com.android.settings.core.SubSettingLauncher;
+import com.android.settings.dashboard.profileselector.ProfileSelectFragment;
import com.android.settings.overlay.FeatureFactory;
-import com.android.settingslib.search.SearchIndexableRaw;
import com.android.settingslib.RestrictedPreference;
import com.android.settingslib.accounts.AuthenticatorHelper;
import com.android.settingslib.core.AbstractPreferenceController;
@@ -62,6 +62,7 @@
import com.android.settingslib.core.lifecycle.LifecycleObserver;
import com.android.settingslib.core.lifecycle.events.OnPause;
import com.android.settingslib.core.lifecycle.events.OnResume;
+import com.android.settingslib.search.SearchIndexableRaw;
import java.util.ArrayList;
import java.util.Collections;
@@ -81,8 +82,8 @@
private UserManager mUm;
private SparseArray<ProfileData> mProfiles = new SparseArray<ProfileData>();
- private ManagedProfileBroadcastReceiver mManagedProfileBroadcastReceiver
- = new ManagedProfileBroadcastReceiver();
+ private ManagedProfileBroadcastReceiver mManagedProfileBroadcastReceiver =
+ new ManagedProfileBroadcastReceiver();
private Preference mProfileNotAvailablePreference;
private String[] mAuthorities;
private int mAuthoritiesCount = 0;
@@ -90,6 +91,7 @@
private int mAccountProfileOrder = ORDER_ACCOUNT_PROFILES;
private AccountRestrictionHelper mHelper;
private MetricsFeatureProvider mMetricsFeatureProvider;
+ private @ProfileSelectFragment.ProfileType int mType;
/**
* Holds data related to the accounts belonging to one profile.
@@ -130,13 +132,14 @@
}
public AccountPreferenceController(Context context, SettingsPreferenceFragment parent,
- String[] authorities) {
- this(context, parent, authorities, new AccountRestrictionHelper(context));
+ String[] authorities, @ProfileSelectFragment.ProfileType int type) {
+ this(context, parent, authorities, new AccountRestrictionHelper(context), type);
}
@VisibleForTesting
AccountPreferenceController(Context context, SettingsPreferenceFragment parent,
- String[] authorities, AccountRestrictionHelper helper) {
+ String[] authorities, AccountRestrictionHelper helper,
+ @ProfileSelectFragment.ProfileType int type) {
super(context);
mUm = (UserManager) context.getSystemService(Context.USER_SERVICE);
mAuthorities = authorities;
@@ -147,6 +150,7 @@
final FeatureFactory featureFactory = FeatureFactory.getFactory(mContext);
mMetricsFeatureProvider = featureFactory.getMetricsFeatureProvider();
mHelper = helper;
+ mType = type;
}
@Override
@@ -186,7 +190,7 @@
}
if (userInfo.isManagedProfile()) {
if (!mHelper.hasBaseUserRestriction(DISALLOW_REMOVE_MANAGED_PROFILE,
- UserHandle.myUserId())) {
+ UserHandle.myUserId())) {
SearchIndexableRaw data = new SearchIndexableRaw(mContext);
data.title = res.getString(R.string.remove_managed_profile_label);
data.screenTitle = screenTitle;
@@ -277,7 +281,13 @@
List<UserInfo> profiles = mUm.getProfiles(UserHandle.myUserId());
final int profilesCount = profiles.size();
for (int i = 0; i < profilesCount; i++) {
- updateProfileUi(profiles.get(i));
+ if (profiles.get(i).isManagedProfile()
+ && (mType & ProfileSelectFragment.WORK) != 0) {
+ updateProfileUi(profiles.get(i));
+ } else if (!profiles.get(i).isManagedProfile()
+ && (mType & ProfileSelectFragment.PERSONAL) != 0) {
+ updateProfileUi(profiles.get(i));
+ }
}
}
cleanUpPreferences();
@@ -302,7 +312,7 @@
if (userInfo.isEnabled()) {
// recreate the authentication helper to refresh the list of enabled accounts
data.authenticatorHelper =
- new AuthenticatorHelper(mContext, userInfo.getUserHandle(), this);
+ new AuthenticatorHelper(mContext, userInfo.getUserHandle(), this);
}
return;
}
@@ -310,27 +320,28 @@
final ProfileData profileData = new ProfileData();
profileData.userInfo = userInfo;
AccessiblePreferenceCategory preferenceGroup =
- mHelper.createAccessiblePreferenceCategory(mParent.getPreferenceManager().getContext());
+ mHelper.createAccessiblePreferenceCategory(
+ mParent.getPreferenceManager().getContext());
preferenceGroup.setOrder(mAccountProfileOrder++);
if (isSingleProfile()) {
preferenceGroup.setTitle(context.getString(R.string.account_for_section_header,
BidiFormatter.getInstance().unicodeWrap(userInfo.name)));
preferenceGroup.setContentDescription(
- mContext.getString(R.string.account_settings));
+ mContext.getString(R.string.account_settings));
} else if (userInfo.isManagedProfile()) {
preferenceGroup.setTitle(R.string.category_work);
String workGroupSummary = getWorkGroupSummary(context, userInfo);
preferenceGroup.setSummary(workGroupSummary);
preferenceGroup.setContentDescription(
- mContext.getString(R.string.accessibility_category_work, workGroupSummary));
+ mContext.getString(R.string.accessibility_category_work, workGroupSummary));
profileData.removeWorkProfilePreference = newRemoveWorkProfilePreference();
mHelper.enforceRestrictionOnPreference(profileData.removeWorkProfilePreference,
- DISALLOW_REMOVE_MANAGED_PROFILE, UserHandle.myUserId());
+ DISALLOW_REMOVE_MANAGED_PROFILE, UserHandle.myUserId());
profileData.managedProfilePreference = newManagedProfileSettings();
} else {
preferenceGroup.setTitle(R.string.category_personal);
preferenceGroup.setContentDescription(
- mContext.getString(R.string.accessibility_category_personal));
+ mContext.getString(R.string.accessibility_category_personal));
}
final PreferenceScreen screen = mParent.getPreferenceScreen();
if (screen != null) {
@@ -342,14 +353,14 @@
userInfo.getUserHandle(), this);
profileData.addAccountPreference = newAddAccountPreference();
mHelper.enforceRestrictionOnPreference(profileData.addAccountPreference,
- DISALLOW_MODIFY_ACCOUNTS, userInfo.id);
+ DISALLOW_MODIFY_ACCOUNTS, userInfo.id);
}
mProfiles.put(userInfo.id, profileData);
}
private RestrictedPreference newAddAccountPreference() {
RestrictedPreference preference =
- new RestrictedPreference(mParent.getPreferenceManager().getContext());
+ new RestrictedPreference(mParent.getPreferenceManager().getContext());
preference.setTitle(R.string.add_account_label);
preference.setIcon(R.drawable.ic_add_24dp);
preference.setOnPreferenceClickListener(this);
@@ -359,7 +370,7 @@
private RestrictedPreference newRemoveWorkProfilePreference() {
RestrictedPreference preference = new RestrictedPreference(
- mParent.getPreferenceManager().getContext());
+ mParent.getPreferenceManager().getContext());
preference.setTitle(R.string.remove_managed_profile_label);
preference.setIcon(R.drawable.ic_delete);
preference.setOnPreferenceClickListener(this);
@@ -393,7 +404,7 @@
return;
}
final int count = mProfiles.size();
- for (int i = count-1; i >= 0; i--) {
+ for (int i = count - 1; i >= 0; i--) {
final ProfileData data = mProfiles.valueAt(i);
if (data.pendingRemoval) {
screen.removePreference(data.preferenceGroup);
@@ -449,7 +460,7 @@
}
for (String key : preferenceToRemove.keySet()) {
profileData.preferenceGroup.removePreference(
- profileData.accountPreferences.get(key));
+ profileData.accountPreferences.get(key));
profileData.accountPreferences.remove(key);
}
} else {
@@ -457,7 +468,7 @@
// Put a label instead of the accounts list
if (mProfileNotAvailablePreference == null) {
mProfileNotAvailablePreference =
- new Preference(mParent.getPreferenceManager().getContext());
+ new Preference(mParent.getPreferenceManager().getContext());
}
mProfileNotAvailablePreference.setEnabled(false);
mProfileNotAvailablePreference.setIcon(R.drawable.empty_icon);
@@ -507,26 +518,26 @@
continue;
}
final ArrayList<String> auths =
- helper.getAuthoritiesForAccountType(account.type);
+ helper.getAuthoritiesForAccountType(account.type);
if (!AccountRestrictionHelper.showAccount(mAuthorities, auths)) {
continue;
}
final Bundle fragmentArguments = new Bundle();
fragmentArguments.putParcelable(AccountDetailDashboardFragment.KEY_ACCOUNT,
- account);
+ account);
fragmentArguments.putParcelable(AccountDetailDashboardFragment.KEY_USER_HANDLE,
- userHandle);
+ userHandle);
fragmentArguments.putString(AccountDetailDashboardFragment.KEY_ACCOUNT_TYPE,
- accountType);
+ accountType);
fragmentArguments.putString(AccountDetailDashboardFragment.KEY_ACCOUNT_LABEL,
- label.toString());
+ label.toString());
fragmentArguments.putInt(AccountDetailDashboardFragment.KEY_ACCOUNT_TITLE_RES,
- titleResId);
+ titleResId);
fragmentArguments.putParcelable(EXTRA_USER, userHandle);
accountTypePreferences.add(new AccountTypePreference(
- prefContext, mMetricsFeatureProvider.getMetricsCategory(mParent),
- account, titleResPackageName, titleResId, label,
- AccountDetailDashboardFragment.class.getName(), fragmentArguments, icon));
+ prefContext, mMetricsFeatureProvider.getMetricsCategory(mParent),
+ account, titleResPackageName, titleResId, label,
+ AccountDetailDashboardFragment.class.getName(), fragmentArguments, icon));
}
helper.preloadDrawableForType(mContext, accountType);
}
@@ -536,7 +547,7 @@
public int compare(AccountTypePreference t1, AccountTypePreference t2) {
int result = t1.getSummary().toString().compareTo(t2.getSummary().toString());
return result != 0
- ? result : t1.getTitle().toString().compareTo(t2.getTitle().toString());
+ ? result : t1.getTitle().toString().compareTo(t2.getTitle().toString());
}
});
return accountTypePreferences;
diff --git a/src/com/android/settings/accounts/AccountProfileSelectFragment.java b/src/com/android/settings/accounts/AccountProfileSelectFragment.java
new file mode 100644
index 0000000..128596d
--- /dev/null
+++ b/src/com/android/settings/accounts/AccountProfileSelectFragment.java
@@ -0,0 +1,34 @@
+/*
+ * 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.accounts;
+import androidx.fragment.app.Fragment;
+
+import com.android.settings.dashboard.profileselector.ProfileSelectFragment;
+
+/**
+ * Account Setting page for personal/managed profile.
+ */
+public class AccountProfileSelectFragment extends ProfileSelectFragment {
+
+ @Override
+ public Fragment[] getFragments() {
+ return new Fragment[] {
+ new AccountPersonalDashboardFragment(),
+ new AccountWorkProfileDashboardFragment()
+ };
+ }
+}
diff --git a/src/com/android/settings/accounts/AccountWorkProfileDashboardFragment.java b/src/com/android/settings/accounts/AccountWorkProfileDashboardFragment.java
new file mode 100644
index 0000000..e3fceb8
--- /dev/null
+++ b/src/com/android/settings/accounts/AccountWorkProfileDashboardFragment.java
@@ -0,0 +1,97 @@
+/*
+ * 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.accounts;
+
+import static android.provider.Settings.EXTRA_AUTHORITIES;
+
+import android.app.settings.SettingsEnums;
+import android.content.Context;
+
+import com.android.settings.R;
+import com.android.settings.SettingsPreferenceFragment;
+import com.android.settings.dashboard.DashboardFragment;
+import com.android.settings.dashboard.profileselector.ProfileSelectFragment;
+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;
+
+/**
+ * Account Setting page for work profile.
+ */
+@SearchIndexable
+public class AccountWorkProfileDashboardFragment extends DashboardFragment {
+
+ private static final String TAG = "AccountWorkProfileFrag";
+
+ @Override
+ public int getMetricsCategory() {
+ return SettingsEnums.ACCOUNT;
+ }
+
+ @Override
+ protected String getLogTag() {
+ return TAG;
+ }
+
+ @Override
+ protected int getPreferenceScreenResId() {
+ return R.xml.accounts_work_dashboard_settings;
+ }
+
+ @Override
+ public int getHelpResource() {
+ return R.string.help_url_user_and_account_dashboard;
+ }
+
+ @Override
+ protected List<AbstractPreferenceController> createPreferenceControllers(Context context) {
+ final String[] authorities = getIntent().getStringArrayExtra(EXTRA_AUTHORITIES);
+ return buildPreferenceControllers(context, this /* parent */, authorities);
+ }
+
+ private static List<AbstractPreferenceController> buildPreferenceControllers(Context context,
+ SettingsPreferenceFragment parent, String[] authorities) {
+ final List<AbstractPreferenceController> controllers = new ArrayList<>();
+
+ final AccountPreferenceController accountPrefController =
+ new AccountPreferenceController(context, parent, authorities,
+ ProfileSelectFragment.WORK);
+ if (parent != null) {
+ parent.getSettingsLifecycle().addObserver(accountPrefController);
+ }
+ controllers.add(accountPrefController);
+ controllers.add(new AutoSyncDataPreferenceController(context, parent));
+ controllers.add(new AutoSyncWorkDataPreferenceController(context, parent));
+ return controllers;
+ }
+
+ // TODO: b/141601408. After featureFlag settings_work_profile is launched, unmark this
+// public static final BaseSearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
+// new BaseSearchIndexProvider(R.xml.accounts_work_dashboard_settings) {
+//
+// @Override
+// public List<AbstractPreferenceController> createPreferenceControllers(
+// Context context) {
+// return buildPreferenceControllers(
+// context, null /* parent */, null /* authorities*/);
+// }
+// };
+}
diff --git a/src/com/android/settings/core/FeatureFlags.java b/src/com/android/settings/core/FeatureFlags.java
index fee9c42..8203b35 100644
--- a/src/com/android/settings/core/FeatureFlags.java
+++ b/src/com/android/settings/core/FeatureFlags.java
@@ -27,4 +27,5 @@
public static final String NETWORK_INTERNET_V2 = "settings_network_and_internet_v2";
public static final String WIFI_DETAILS_DATAUSAGE_HEADER =
"settings_wifi_details_datausage_header";
+ public static final String PERSONAL_WORK_PROFILE = "settings_work_profile";
}
diff --git a/src/com/android/settings/dashboard/profileselector/ProfileFragmentBridge.java b/src/com/android/settings/dashboard/profileselector/ProfileFragmentBridge.java
new file mode 100644
index 0000000..797782a
--- /dev/null
+++ b/src/com/android/settings/dashboard/profileselector/ProfileFragmentBridge.java
@@ -0,0 +1,42 @@
+/*
+ * 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.util.ArrayMap;
+
+import com.android.settings.accounts.AccountDashboardFragment;
+import com.android.settings.accounts.AccountProfileSelectFragment;
+
+import java.util.Map;
+
+/**
+ * A registry to keep track of which page and its own profile selection page.
+ */
+public class ProfileFragmentBridge {
+
+ /**
+ * Map from parent fragment to category key. The parent fragment hosts child with
+ * category_key.
+ */
+ public static final Map<String, String> FRAGMENT_MAP;
+
+ static {
+ FRAGMENT_MAP = new ArrayMap<>();
+ FRAGMENT_MAP.put(AccountDashboardFragment.class.getName(),
+ AccountProfileSelectFragment.class.getName());
+ }
+}
diff --git a/src/com/android/settings/dashboard/profileselector/ProfileSelectFragment.java b/src/com/android/settings/dashboard/profileselector/ProfileSelectFragment.java
new file mode 100644
index 0000000..96eace8
--- /dev/null
+++ b/src/com/android/settings/dashboard/profileselector/ProfileSelectFragment.java
@@ -0,0 +1,116 @@
+/*
+ * 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.annotation.IntDef;
+import android.content.Context;
+import android.os.Bundle;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+
+import androidx.fragment.app.Fragment;
+import androidx.fragment.app.FragmentStatePagerAdapter;
+import androidx.viewpager.widget.ViewPager;
+
+import com.android.settings.R;
+import com.android.settings.core.InstrumentedFragment;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+
+/**
+ * Base fragment class for per profile settings.
+ */
+public abstract class ProfileSelectFragment extends InstrumentedFragment {
+
+ /**
+ * Denotes the profile type.
+ */
+ @Retention(RetentionPolicy.SOURCE)
+ @IntDef({PERSONAL, WORK, ALL})
+ public @interface ProfileType {
+ }
+
+ /**
+ * It is personal work profile.
+ */
+ public static final int PERSONAL = 1;
+
+ /**
+ * It is work profile
+ */
+ public static final int WORK = 1 << 1;
+
+ /**
+ * It is personal and work profile
+ */
+ public static final int ALL = PERSONAL | WORK;
+
+ private View mContentView;
+
+ @Override
+ public View onCreateView(LayoutInflater inflater, ViewGroup container,
+ Bundle savedInstanceState) {
+ mContentView = inflater.inflate(R.layout.profile_select_tablayout, null /* root */);
+ final ViewPager viewPager = mContentView.findViewById(R.id.view_pager);
+ viewPager.setAdapter(new ViewPagerAdapter(this));
+ return mContentView;
+ }
+
+ @Override
+ public int getMetricsCategory() {
+ return METRICS_CATEGORY_UNKNOWN;
+ }
+
+ /**
+ * Returns an array of {@link Fragment} to display in the
+ * {@link com.google.android.material.tabs.TabLayout}
+ */
+ public abstract Fragment[] getFragments();
+
+ static class ViewPagerAdapter extends FragmentStatePagerAdapter {
+
+ private final Fragment[] mChildFragments;
+ private final Context mContext;
+
+ ViewPagerAdapter(ProfileSelectFragment fragment) {
+ super(fragment.getActivity().getSupportFragmentManager());
+ mContext = fragment.getContext();
+ mChildFragments = fragment.getFragments();
+ }
+
+ @Override
+ public Fragment getItem(int position) {
+ return mChildFragments[position];
+ }
+
+ @Override
+ public int getCount() {
+ return mChildFragments.length;
+ }
+
+ @Override
+ public CharSequence getPageTitle(int position) {
+ if (position == 0) {
+ return mContext.getString(R.string.category_personal);
+ } else {
+ return mContext.getString(R.string.category_work);
+ }
+ }
+ }
+}
diff --git a/src/com/android/settings/datausage/ChartDataUsagePreference.java b/src/com/android/settings/datausage/ChartDataUsagePreference.java
index 17f23c4..6c845a9 100644
--- a/src/com/android/settings/datausage/ChartDataUsagePreference.java
+++ b/src/com/android/settings/datausage/ChartDataUsagePreference.java
@@ -15,10 +15,12 @@
package com.android.settings.datausage;
import android.content.Context;
+import android.content.res.Resources;
import android.net.NetworkPolicy;
import android.net.TrafficStats;
import android.text.SpannableStringBuilder;
import android.text.TextUtils;
+import android.text.format.DateUtils;
import android.text.format.Formatter;
import android.text.style.ForegroundColorSpan;
import android.util.AttributeSet;
@@ -34,7 +36,11 @@
import com.android.settingslib.net.NetworkCycleChartData;
import com.android.settingslib.net.NetworkCycleData;
+import java.util.ArrayList;
+import java.util.Comparator;
import java.util.List;
+import java.util.Map;
+import java.util.stream.Collectors;
public class ChartDataUsagePreference extends Preference {
@@ -45,6 +51,7 @@
private final int mWarningColor;
private final int mLimitColor;
+ private Resources mResources;
private NetworkPolicy mPolicy;
private long mStart;
private long mEnd;
@@ -54,6 +61,7 @@
public ChartDataUsagePreference(Context context, AttributeSet attrs) {
super(context, attrs);
+ mResources = context.getResources();
setSelectable(false);
mLimitColor = Utils.getColorAttrDefaultColor(context, android.R.attr.colorError);
mWarningColor = Utils.getColorAttrDefaultColor(context, android.R.attr.textColorSecondary);
@@ -72,6 +80,7 @@
chart.clearPaths();
chart.configureGraph(toInt(mEnd - mStart), top);
calcPoints(chart, mNetworkCycleChartData.getUsageBuckets());
+ setupContentDescription(chart, mNetworkCycleChartData.getUsageBuckets());
chart.setBottomLabels(new CharSequence[] {
Utils.formatDateRange(getContext(), mStart, mStart),
Utils.formatDateRange(getContext(), mEnd, mEnd),
@@ -118,6 +127,130 @@
}
}
+ private void setupContentDescription(UsageView chart, List<NetworkCycleData> usageSummary) {
+ final Context context = getContext();
+ final StringBuilder contentDescription = new StringBuilder();
+ final int flags = DateUtils.FORMAT_SHOW_DATE | DateUtils.FORMAT_ABBREV_MONTH;
+
+ // Setup a brief content description.
+ final String startDate = DateUtils.formatDateTime(context, mStart, flags);
+ final String endDate = DateUtils.formatDateTime(context, mEnd, flags);
+ final String briefContentDescription = mResources
+ .getString(R.string.data_usage_chart_brief_content_description, startDate, endDate);
+ contentDescription.append(briefContentDescription);
+
+ if (usageSummary == null || usageSummary.isEmpty()) {
+ final String noDataContentDescription = mResources
+ .getString(R.string.data_usage_chart_no_data_content_description);
+ contentDescription.append(noDataContentDescription);
+ chart.setContentDescription(contentDescription);
+ return;
+ }
+
+ // Append more detailed stats.
+ String nodeDate;
+ String nodeContentDescription;
+ final List<DataUsageSummaryNode> densedStatsData = getDensedStatsData(usageSummary);
+ for (DataUsageSummaryNode data : densedStatsData) {
+ final int dataUsagePercentage = data.getDataUsagePercentage();
+ if (!data.isFromMultiNode() || dataUsagePercentage == 100) {
+ nodeDate = DateUtils.formatDateTime(context, data.getStartTime(), flags);
+ } else {
+ nodeDate = DateUtils.formatDateRange(context, data.getStartTime(),
+ data.getEndTime(), flags);
+ }
+ nodeContentDescription = String.format(";%s %d%%", nodeDate, dataUsagePercentage);
+
+ contentDescription.append(nodeContentDescription);
+ }
+
+ chart.setContentDescription(contentDescription);
+ }
+
+ /**
+ * To avoid wordy data, e.g., Aug 2: 0%; Aug 3: 0%;...Aug 22: 0%; Aug 23: 2%.
+ * Collect the date of the same percentage, e.g., Aug 2 to Aug 22: 0%; Aug 23: 2%.
+ */
+ @VisibleForTesting
+ List<DataUsageSummaryNode> getDensedStatsData(List<NetworkCycleData> usageSummary) {
+ final List<DataUsageSummaryNode> dataUsageSummaryNodes = new ArrayList<>();
+ final long overallDataUsage = usageSummary.stream()
+ .mapToLong(NetworkCycleData::getTotalUsage).sum();
+ long cumulatedDataUsage = 0L;
+ int cumulatedDataUsagePercentage = 0;
+
+ // Collect List of DataUsageSummaryNode for data usage percentage information.
+ for (NetworkCycleData data : usageSummary) {
+ cumulatedDataUsage += data.getTotalUsage();
+ cumulatedDataUsagePercentage = (int) ((cumulatedDataUsage * 100) / overallDataUsage);
+
+ final DataUsageSummaryNode node = new DataUsageSummaryNode(data.getStartTime(),
+ data.getEndTime(), cumulatedDataUsagePercentage);
+ dataUsageSummaryNodes.add(node);
+ }
+
+ // Group nodes of the same data usage percentage.
+ final Map<Integer, List<DataUsageSummaryNode>> nodesByDataUsagePercentage
+ = dataUsageSummaryNodes.stream().collect(
+ Collectors.groupingBy(DataUsageSummaryNode::getDataUsagePercentage));
+
+ // Collect densed nodes from collection of the same data usage percentage
+ final List<DataUsageSummaryNode> densedNodes = new ArrayList<>();
+ nodesByDataUsagePercentage.forEach((percentage, nodes) -> {
+ final long startTime = nodes.stream().mapToLong(DataUsageSummaryNode::getStartTime)
+ .min().getAsLong();
+ final long endTime = nodes.stream().mapToLong(DataUsageSummaryNode::getEndTime)
+ .max().getAsLong();
+
+ final DataUsageSummaryNode densedNode = new DataUsageSummaryNode(
+ startTime, endTime, percentage);
+ if (nodes.size() > 1) {
+ densedNode.setFromMultiNode(true /* isFromMultiNode */);
+ }
+
+ densedNodes.add(densedNode);
+ });
+
+ return densedNodes.stream()
+ .sorted(Comparator.comparingInt(DataUsageSummaryNode::getDataUsagePercentage))
+ .collect(Collectors.toList());
+ }
+
+ @VisibleForTesting
+ class DataUsageSummaryNode {
+ private long mStartTime;
+ private long mEndTime;
+ private int mDataUsagePercentage;
+ private boolean mIsFromMultiNode;
+
+ public DataUsageSummaryNode(long startTime, long endTime, int dataUsagePercentage) {
+ mStartTime = startTime;
+ mEndTime = endTime;
+ mDataUsagePercentage = dataUsagePercentage;
+ mIsFromMultiNode = false;
+ }
+
+ public long getStartTime() {
+ return mStartTime;
+ }
+
+ public long getEndTime() {
+ return mEndTime;
+ }
+
+ public int getDataUsagePercentage() {
+ return mDataUsagePercentage;
+ }
+
+ public void setFromMultiNode(boolean isFromMultiNode) {
+ mIsFromMultiNode = isFromMultiNode;
+ }
+
+ public boolean isFromMultiNode() {
+ return mIsFromMultiNode;
+ }
+ }
+
private int toInt(long l) {
// Don't need that much resolution on these times.
return (int) (l / (1000 * 60));
@@ -151,8 +284,8 @@
}
private CharSequence getLabel(long bytes, int str, int mLimitColor) {
- Formatter.BytesResult result = Formatter.formatBytes(getContext().getResources(),
- bytes, Formatter.FLAG_SHORTER | Formatter.FLAG_IEC_UNITS);
+ Formatter.BytesResult result = Formatter.formatBytes(mResources, bytes,
+ Formatter.FLAG_SHORTER | Formatter.FLAG_IEC_UNITS);
CharSequence label = TextUtils.expandTemplate(getContext().getText(str),
result.value, result.units);
return new SpannableStringBuilder().append(label, new ForegroundColorSpan(mLimitColor), 0);
diff --git a/src/com/android/settings/datausage/DataSaverBackend.java b/src/com/android/settings/datausage/DataSaverBackend.java
index db92659..92b2ef9 100644
--- a/src/com/android/settings/datausage/DataSaverBackend.java
+++ b/src/com/android/settings/datausage/DataSaverBackend.java
@@ -23,6 +23,7 @@
import android.net.INetworkPolicyListener;
import android.net.NetworkPolicyManager;
import android.os.RemoteException;
+import android.telephony.SubscriptionPlan;
import android.util.SparseIntArray;
import com.android.settings.overlay.FeatureFactory;
@@ -199,8 +200,11 @@
}
@Override
- public void onSubscriptionOverride(int subId, int overrideMask, int overrideValue,
- long networkTypeMask) {
+ public void onSubscriptionOverride(int subId, int overrideMask, int overrideValue) {
+ }
+
+ @Override
+ public void onSubscriptionPlansChanged(int subId, SubscriptionPlan[] plans) {
}
};
diff --git a/src/com/android/settings/notification/AllowSoundPreferenceController.java b/src/com/android/settings/notification/AllowSoundPreferenceController.java
index 7862f4b..dcf4779 100644
--- a/src/com/android/settings/notification/AllowSoundPreferenceController.java
+++ b/src/com/android/settings/notification/AllowSoundPreferenceController.java
@@ -34,10 +34,10 @@
private static final String TAG = "AllowSoundPrefContr";
private static final String KEY_IMPORTANCE = "allow_sound";
- private NotificationSettingsBase.ImportanceListener mImportanceListener;
+ private NotificationSettings.ImportanceListener mImportanceListener;
public AllowSoundPreferenceController(Context context,
- NotificationSettingsBase.ImportanceListener importanceListener,
+ NotificationSettings.ImportanceListener importanceListener,
NotificationBackend backend) {
super(context, backend);
mImportanceListener = importanceListener;
diff --git a/src/com/android/settings/notification/AppBubbleNotificationSettings.java b/src/com/android/settings/notification/AppBubbleNotificationSettings.java
index 82bab24..860c445 100644
--- a/src/com/android/settings/notification/AppBubbleNotificationSettings.java
+++ b/src/com/android/settings/notification/AppBubbleNotificationSettings.java
@@ -30,7 +30,7 @@
import java.util.List;
@SearchIndexable
-public class AppBubbleNotificationSettings extends NotificationSettingsBase implements
+public class AppBubbleNotificationSettings extends NotificationSettings implements
GlobalBubblePermissionObserverMixin.Listener {
private static final String TAG = "AppBubNotiSettings";
private GlobalBubblePermissionObserverMixin mObserverMixin;
diff --git a/src/com/android/settings/notification/AppNotificationSettings.java b/src/com/android/settings/notification/AppNotificationSettings.java
index dc06f47..24f38b1 100644
--- a/src/com/android/settings/notification/AppNotificationSettings.java
+++ b/src/com/android/settings/notification/AppNotificationSettings.java
@@ -34,7 +34,7 @@
import androidx.preference.PreferenceScreen;
/** These settings are per app, so should not be returned in global search results. */
-public class AppNotificationSettings extends NotificationSettingsBase {
+public class AppNotificationSettings extends NotificationSettings {
private static final String TAG = "AppNotificationSettings";
private static final boolean DEBUG = Log.isLoggable(TAG, Log.DEBUG);
diff --git a/src/com/android/settings/notification/BlockPreferenceController.java b/src/com/android/settings/notification/BlockPreferenceController.java
index 37589d9..27144b8 100644
--- a/src/com/android/settings/notification/BlockPreferenceController.java
+++ b/src/com/android/settings/notification/BlockPreferenceController.java
@@ -35,10 +35,10 @@
implements PreferenceControllerMixin, SwitchBar.OnSwitchChangeListener {
private static final String KEY_BLOCK = "block";
- private NotificationSettingsBase.ImportanceListener mImportanceListener;
+ private NotificationSettings.ImportanceListener mImportanceListener;
public BlockPreferenceController(Context context,
- NotificationSettingsBase.ImportanceListener importanceListener,
+ NotificationSettings.ImportanceListener importanceListener,
NotificationBackend backend) {
super(context, backend);
mImportanceListener = importanceListener;
diff --git a/src/com/android/settings/notification/ChannelNotificationSettings.java b/src/com/android/settings/notification/ChannelNotificationSettings.java
index 09bf0e2..ff3eebc 100644
--- a/src/com/android/settings/notification/ChannelNotificationSettings.java
+++ b/src/com/android/settings/notification/ChannelNotificationSettings.java
@@ -35,7 +35,7 @@
import java.util.ArrayList;
import java.util.List;
-public class ChannelNotificationSettings extends NotificationSettingsBase {
+public class ChannelNotificationSettings extends NotificationSettings {
private static final String TAG = "ChannelSettings";
@Override
diff --git a/src/com/android/settings/notification/HighImportancePreferenceController.java b/src/com/android/settings/notification/HighImportancePreferenceController.java
index da9b3b4..6c8c354 100644
--- a/src/com/android/settings/notification/HighImportancePreferenceController.java
+++ b/src/com/android/settings/notification/HighImportancePreferenceController.java
@@ -31,10 +31,10 @@
implements PreferenceControllerMixin, Preference.OnPreferenceChangeListener {
private static final String KEY_IMPORTANCE = "high_importance";
- private NotificationSettingsBase.ImportanceListener mImportanceListener;
+ private NotificationSettings.ImportanceListener mImportanceListener;
public HighImportancePreferenceController(Context context,
- NotificationSettingsBase.ImportanceListener importanceListener,
+ NotificationSettings.ImportanceListener importanceListener,
NotificationBackend backend) {
super(context, backend);
mImportanceListener = importanceListener;
diff --git a/src/com/android/settings/notification/ImportancePreferenceController.java b/src/com/android/settings/notification/ImportancePreferenceController.java
index 4ef4593..a9bd182 100644
--- a/src/com/android/settings/notification/ImportancePreferenceController.java
+++ b/src/com/android/settings/notification/ImportancePreferenceController.java
@@ -32,10 +32,10 @@
implements PreferenceControllerMixin, Preference.OnPreferenceChangeListener {
private static final String KEY_IMPORTANCE = "importance";
- private NotificationSettingsBase.ImportanceListener mImportanceListener;
+ private NotificationSettings.ImportanceListener mImportanceListener;
public ImportancePreferenceController(Context context,
- NotificationSettingsBase.ImportanceListener importanceListener,
+ NotificationSettings.ImportanceListener importanceListener,
NotificationBackend backend) {
super(context, backend);
mImportanceListener = importanceListener;
diff --git a/src/com/android/settings/notification/MinImportancePreferenceController.java b/src/com/android/settings/notification/MinImportancePreferenceController.java
index 0af0c8d..19d950c 100644
--- a/src/com/android/settings/notification/MinImportancePreferenceController.java
+++ b/src/com/android/settings/notification/MinImportancePreferenceController.java
@@ -31,10 +31,10 @@
implements PreferenceControllerMixin, Preference.OnPreferenceChangeListener {
private static final String KEY_IMPORTANCE = "min_importance";
- private NotificationSettingsBase.ImportanceListener mImportanceListener;
+ private NotificationSettings.ImportanceListener mImportanceListener;
public MinImportancePreferenceController(Context context,
- NotificationSettingsBase.ImportanceListener importanceListener,
+ NotificationSettings.ImportanceListener importanceListener,
NotificationBackend backend) {
super(context, backend);
mImportanceListener = importanceListener;
diff --git a/src/com/android/settings/notification/NotificationSettingsBase.java b/src/com/android/settings/notification/NotificationSettings.java
similarity index 98%
rename from src/com/android/settings/notification/NotificationSettingsBase.java
rename to src/com/android/settings/notification/NotificationSettings.java
index 27a2de0..938a7ba 100644
--- a/src/com/android/settings/notification/NotificationSettingsBase.java
+++ b/src/com/android/settings/notification/NotificationSettings.java
@@ -64,7 +64,7 @@
import java.util.Comparator;
import java.util.List;
-abstract public class NotificationSettingsBase extends DashboardFragment {
+abstract public class NotificationSettings extends DashboardFragment {
private static final String TAG = "NotifiSettingsBase";
private static final boolean DEBUG = Log.isLoggable(TAG, Log.DEBUG);
diff --git a/src/com/android/settings/notification/NotificationStation.java b/src/com/android/settings/notification/NotificationStation.java
index c2c8b60..754dfa2 100644
--- a/src/com/android/settings/notification/NotificationStation.java
+++ b/src/com/android/settings/notification/NotificationStation.java
@@ -79,6 +79,9 @@
private static class HistoricalNotificationInfo {
public String key;
public NotificationChannel channel;
+ // Historical notifications don't have Ranking information. for most fields that's ok
+ // but we need channel id to launch settings.
+ public String channelId;
public String pkg;
public Drawable pkgicon;
public CharSequence pkgname;
@@ -416,6 +419,7 @@
info.timestamp = sbn.getPostTime();
info.priority = n.priority;
info.key = sbn.getKey();
+ info.channelId = sbn.getNotification().getChannelId();
info.active = active;
info.notificationExtra = generateExtraText(sbn, info);
@@ -724,7 +728,8 @@
public void performClick() {
Intent intent = new Intent(Settings.ACTION_CHANNEL_NOTIFICATION_SETTINGS)
.putExtra(EXTRA_APP_PACKAGE, mInfo.pkg)
- .putExtra(EXTRA_CHANNEL_ID, mInfo.channel.getId());
+ .putExtra(EXTRA_CHANNEL_ID,
+ mInfo.channel != null ? mInfo.channel.getId() : mInfo.channelId);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
getContext().startActivity(intent);
}
diff --git a/src/com/android/settings/notification/SoundPreferenceController.java b/src/com/android/settings/notification/SoundPreferenceController.java
index 566f3f2..8530de0 100644
--- a/src/com/android/settings/notification/SoundPreferenceController.java
+++ b/src/com/android/settings/notification/SoundPreferenceController.java
@@ -39,12 +39,12 @@
private static final String KEY_SOUND = "ringtone";
private final SettingsPreferenceFragment mFragment;
- private final NotificationSettingsBase.ImportanceListener mListener;
+ private final NotificationSettings.ImportanceListener mListener;
private NotificationSoundPreference mPreference;
protected static final int CODE = 200;
public SoundPreferenceController(Context context, SettingsPreferenceFragment hostFragment,
- NotificationSettingsBase.ImportanceListener importanceListener,
+ NotificationSettings.ImportanceListener importanceListener,
NotificationBackend backend) {
super(context, backend);
mFragment = hostFragment;
diff --git a/src/com/android/settings/password/ChooseLockGeneric.java b/src/com/android/settings/password/ChooseLockGeneric.java
index f86292b..4f1b050 100644
--- a/src/com/android/settings/password/ChooseLockGeneric.java
+++ b/src/com/android/settings/password/ChooseLockGeneric.java
@@ -61,6 +61,7 @@
import androidx.preference.PreferenceScreen;
import com.android.internal.widget.LockPatternUtils;
+import com.android.internal.widget.LockscreenCredential;
import com.android.settings.EncryptionInterstitial;
import com.android.settings.EventLogTags;
import com.android.settings.R;
@@ -151,7 +152,7 @@
private boolean mPasswordConfirmed = false;
private boolean mWaitingForConfirmation = false;
private boolean mForChangeCredRequiredForBoot = false;
- private byte[] mUserPassword;
+ private LockscreenCredential mUserPassword;
private LockPatternUtils mLockPatternUtils;
private FingerprintManager mFingerprintManager;
private FaceManager mFaceManager;
@@ -207,7 +208,7 @@
.getBooleanExtra(CONFIRM_CREDENTIALS, true);
if (getActivity() instanceof ChooseLockGeneric.InternalActivity) {
mPasswordConfirmed = !confirmCredentials;
- mUserPassword = getActivity().getIntent().getByteArrayExtra(
+ mUserPassword = getActivity().getIntent().getParcelableExtra(
ChooseLockSettingsHelper.EXTRA_KEY_PASSWORD);
}
@@ -233,7 +234,7 @@
mPasswordConfirmed = savedInstanceState.getBoolean(PASSWORD_CONFIRMED);
mWaitingForConfirmation = savedInstanceState.getBoolean(WAITING_FOR_CONFIRMATION);
if (mUserPassword == null) {
- mUserPassword = savedInstanceState.getByteArray(
+ mUserPassword = savedInstanceState.getParcelable(
ChooseLockSettingsHelper.EXTRA_KEY_PASSWORD);
}
}
@@ -392,11 +393,11 @@
if (requestCode == CONFIRM_EXISTING_REQUEST && resultCode == Activity.RESULT_OK) {
mPasswordConfirmed = true;
mUserPassword = data != null
- ? data.getByteArrayExtra(ChooseLockSettingsHelper.EXTRA_KEY_PASSWORD)
+ ? data.getParcelableExtra(ChooseLockSettingsHelper.EXTRA_KEY_PASSWORD)
: null;
updatePreferencesOrFinish(false /* isRecreatingActivity */);
if (mForChangeCredRequiredForBoot) {
- if (!(mUserPassword == null || mUserPassword.length == 0)) {
+ if (mUserPassword != null && !mUserPassword.isNone()) {
maybeEnableEncryption(
mLockPatternUtils.getKeyguardStoredPasswordQuality(mUserId), false);
} else {
@@ -459,7 +460,7 @@
outState.putBoolean(PASSWORD_CONFIRMED, mPasswordConfirmed);
outState.putBoolean(WAITING_FOR_CONFIRMATION, mWaitingForConfirmation);
if (mUserPassword != null) {
- outState.putByteArray(ChooseLockSettingsHelper.EXTRA_KEY_PASSWORD, mUserPassword);
+ outState.putParcelable(ChooseLockSettingsHelper.EXTRA_KEY_PASSWORD, mUserPassword);
}
}
@@ -682,7 +683,7 @@
setPreferenceSummary(ScreenLockType.MANAGED, R.string.secure_lock_encryption_warning);
}
- protected Intent getLockManagedPasswordIntent(byte[] password) {
+ protected Intent getLockManagedPasswordIntent(LockscreenCredential password) {
return mManagedPasswordProvider.createIntent(false, password);
}
@@ -759,7 +760,8 @@
if (quality == DevicePolicyManager.PASSWORD_QUALITY_UNSPECIFIED) {
// Clearing of user biometrics when screen lock is cleared is done at
// LockSettingsService.removeBiometricsForUser().
- mChooseLockSettingsHelper.utils().clearLock(mUserPassword, mUserId);
+ 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/ChooseLockPassword.java b/src/com/android/settings/password/ChooseLockPassword.java
index 820aecb..6872543 100644
--- a/src/com/android/settings/password/ChooseLockPassword.java
+++ b/src/com/android/settings/password/ChooseLockPassword.java
@@ -63,6 +63,7 @@
import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.widget.LockPatternUtils;
import com.android.internal.widget.LockPatternUtils.RequestThrottledException;
+import com.android.internal.widget.LockscreenCredential;
import com.android.internal.widget.TextViewInputDisabler;
import com.android.settings.EncryptionInterstitial;
import com.android.settings.R;
@@ -124,7 +125,7 @@
return this;
}
- public IntentBuilder setPassword(byte[] password) {
+ public IntentBuilder setPassword(LockscreenCredential password) {
mIntent.putExtra(ChooseLockSettingsHelper.EXTRA_KEY_PASSWORD, password);
return this;
}
@@ -180,13 +181,13 @@
public static class ChooseLockPasswordFragment extends InstrumentedFragment
implements OnEditorActionListener, TextWatcher, SaveAndFinishWorker.Listener {
- private static final String KEY_FIRST_PIN = "first_pin";
+ private static final String KEY_FIRST_PASSWORD = "first_password";
private static final String KEY_UI_STAGE = "ui_stage";
- private static final String KEY_CURRENT_PASSWORD = "current_password";
+ private static final String KEY_CURRENT_CREDENTIAL = "current_credential";
private static final String FRAGMENT_TAG_SAVE_AND_FINISH = "save_and_finish_worker";
- private byte[] mCurrentPassword;
- private byte[] mChosenPassword;
+ private LockscreenCredential mCurrentCredential;
+ private LockscreenCredential mChosenPassword;
private boolean mHasChallenge;
private long mChallenge;
private ImeAwareEditText mPasswordEntry;
@@ -215,7 +216,7 @@
protected boolean mForFingerprint;
protected boolean mForFace;
- private byte[] mFirstPin;
+ private LockscreenCredential mFirstPassword;
private RecyclerView mPasswordRestrictionView;
protected boolean mIsAlphaMode;
protected FooterButton mSkipOrClearButton;
@@ -394,13 +395,13 @@
SaveAndFinishWorker w = new SaveAndFinishWorker();
final boolean required = getActivity().getIntent().getBooleanExtra(
EncryptionInterstitial.EXTRA_REQUIRE_PASSWORD, true);
- byte[] currentBytes = intent.getByteArrayExtra(
+ LockscreenCredential currentCredential = intent.getParcelableExtra(
ChooseLockSettingsHelper.EXTRA_KEY_PASSWORD);
w.setBlocking(true);
w.setListener(this);
w.start(mChooseLockSettingsHelper.utils(), required, false, 0,
- currentBytes, currentBytes, mRequestedQuality, mUserId);
+ currentCredential, currentCredential, mUserId);
}
mTextChangedHandler = new TextChangedHandler();
}
@@ -482,7 +483,7 @@
Intent intent = getActivity().getIntent();
final boolean confirmCredentials = intent.getBooleanExtra(
ChooseLockGeneric.CONFIRM_CREDENTIALS, true);
- mCurrentPassword = intent.getByteArrayExtra(
+ mCurrentCredential = intent.getParcelableExtra(
ChooseLockSettingsHelper.EXTRA_KEY_PASSWORD);
mHasChallenge = intent.getBooleanExtra(
ChooseLockSettingsHelper.EXTRA_KEY_HAS_CHALLENGE, false);
@@ -497,15 +498,15 @@
} else {
// restore from previous state
- mFirstPin = savedInstanceState.getByteArray(KEY_FIRST_PIN);
+ mFirstPassword = savedInstanceState.getParcelable(KEY_FIRST_PASSWORD);
final String state = savedInstanceState.getString(KEY_UI_STAGE);
if (state != null) {
mUiStage = Stage.valueOf(state);
updateStage(mUiStage);
}
- if (mCurrentPassword == null) {
- mCurrentPassword = savedInstanceState.getByteArray(KEY_CURRENT_PASSWORD);
+ if (mCurrentCredential == null) {
+ mCurrentCredential = savedInstanceState.getParcelable(KEY_CURRENT_CREDENTIAL);
}
// Re-attach to the exiting worker if there is one.
@@ -563,8 +564,8 @@
public void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState);
outState.putString(KEY_UI_STAGE, mUiStage.name());
- outState.putByteArray(KEY_FIRST_PIN, mFirstPin);
- outState.putByteArray(KEY_CURRENT_PASSWORD, mCurrentPassword);
+ outState.putParcelable(KEY_FIRST_PASSWORD, mFirstPassword);
+ outState.putParcelable(KEY_CURRENT_CREDENTIAL, mCurrentCredential);
}
@Override
@@ -577,7 +578,7 @@
getActivity().setResult(RESULT_FINISHED);
getActivity().finish();
} else {
- mCurrentPassword = data.getByteArrayExtra(
+ mCurrentCredential = data.getParcelableExtra(
ChooseLockSettingsHelper.EXTRA_KEY_PASSWORD);
}
break;
@@ -722,7 +723,8 @@
* @return the validation result.
*/
@VisibleForTesting
- int validatePassword(byte[] password) {
+ int validatePassword(LockscreenCredential credential) {
+ final byte[] password = credential.getCredential();
int errorCode = NO_ERROR;
final PasswordMetrics metrics = PasswordMetrics.computeForPassword(password);
mergeMinComplexityAndDpmRequirements(metrics.quality);
@@ -812,7 +814,8 @@
private byte[] getPasswordHistoryHashFactor() {
if (mPasswordHistoryHashFactor == null) {
mPasswordHistoryHashFactor = mLockPatternUtils.getPasswordHistoryHashFactor(
- mCurrentPassword, mUserId);
+ mCurrentCredential != null ? mCurrentCredential
+ : LockscreenCredential.createNone(), mUserId);
}
return mPasswordHistoryHashFactor;
}
@@ -820,20 +823,22 @@
public void handleNext() {
if (mSaveAndFinishWorker != null) return;
// TODO(b/120484642): This is a point of entry for passwords from the UI
- mChosenPassword = LockPatternUtils.charSequenceToByteArray(mPasswordEntry.getText());
- if (mChosenPassword == null || mChosenPassword.length == 0) {
+ final Editable passwordText = mPasswordEntry.getText();
+ if (TextUtils.isEmpty(passwordText)) {
return;
}
+ mChosenPassword = mIsAlphaMode ? LockscreenCredential.createPassword(passwordText)
+ : LockscreenCredential.createPin(passwordText);
if (mUiStage == Stage.Introduction) {
if (validatePassword(mChosenPassword) == NO_ERROR) {
- mFirstPin = mChosenPassword;
+ mFirstPassword = mChosenPassword;
mPasswordEntry.setText("");
updateStage(Stage.NeedToConfirm);
} else {
- Arrays.fill(mChosenPassword, (byte) 0);
+ mChosenPassword.zeroize();
}
} else if (mUiStage == Stage.NeedToConfirm) {
- if (Arrays.equals(mFirstPin, mChosenPassword)) {
+ if (mChosenPassword.equals(mFirstPassword)) {
startSaveAndFinish();
} else {
CharSequence tmp = mPasswordEntry.getText();
@@ -841,7 +846,7 @@
Selection.setSelection((Spannable) tmp, 0, tmp.length());
}
updateStage(Stage.ConfirmWrong);
- Arrays.fill(mChosenPassword, (byte) 0);
+ mChosenPassword.zeroize();
}
}
}
@@ -954,8 +959,11 @@
*/
protected void updateUi() {
final boolean canInput = mSaveAndFinishWorker == null;
- byte[] password = LockPatternUtils.charSequenceToByteArray(mPasswordEntry.getText());
- final int length = password.length;
+
+ LockscreenCredential password = mIsAlphaMode
+ ? LockscreenCredential.createPasswordOrNone(mPasswordEntry.getText())
+ : LockscreenCredential.createPinOrNone(mPasswordEntry.getText());
+ final int length = password.size();
if (mUiStage == Stage.Introduction) {
mPasswordRestrictionView.setVisibility(View.VISIBLE);
final int errorCode = validatePassword(password);
@@ -981,7 +989,7 @@
setNextText(mUiStage.buttonText);
mPasswordEntryInputDisabler.setInputEnabled(canInput);
- Arrays.fill(password, (byte) 0);
+ password.zeroize();
}
protected int toVisibility(boolean visibleOrGone) {
@@ -1033,7 +1041,7 @@
final boolean required = getActivity().getIntent().getBooleanExtra(
EncryptionInterstitial.EXTRA_REQUIRE_PASSWORD, true);
mSaveAndFinishWorker.start(mLockPatternUtils, required, mHasChallenge, mChallenge,
- mChosenPassword, mCurrentPassword, mRequestedQuality, mUserId);
+ mChosenPassword, mCurrentCredential, mUserId);
}
@Override
@@ -1041,13 +1049,13 @@
getActivity().setResult(RESULT_FINISHED, resultData);
if (mChosenPassword != null) {
- Arrays.fill(mChosenPassword, (byte) 0);
+ mChosenPassword.zeroize();
}
- if (mCurrentPassword != null) {
- Arrays.fill(mCurrentPassword, (byte) 0);
+ if (mCurrentCredential != null) {
+ mCurrentCredential.zeroize();
}
- if (mFirstPin != null) {
- Arrays.fill(mFirstPin, (byte) 0);
+ if (mFirstPassword != null) {
+ mFirstPassword.zeroize();
}
mPasswordEntry.setText("");
@@ -1088,18 +1096,18 @@
public static class SaveAndFinishWorker extends SaveChosenLockWorkerBase {
- private byte[] mChosenPassword;
- private byte[] mCurrentPassword;
- private int mRequestedQuality;
+ private LockscreenCredential mChosenPassword;
+ private LockscreenCredential mCurrentCredential;
public void start(LockPatternUtils utils, boolean required,
boolean hasChallenge, long challenge,
- byte[] chosenPassword, byte[] currentPassword, int requestedQuality, int userId) {
+ LockscreenCredential chosenPassword, LockscreenCredential currentCredential,
+ int userId) {
prepare(utils, required, hasChallenge, challenge, userId);
mChosenPassword = chosenPassword;
- mCurrentPassword = currentPassword;
- mRequestedQuality = requestedQuality;
+ mCurrentCredential = currentCredential != null ? currentCredential
+ : LockscreenCredential.createNone();
mUserId = userId;
start();
@@ -1107,13 +1115,13 @@
@Override
protected Pair<Boolean, Intent> saveAndVerifyInBackground() {
- final boolean success = mUtils.saveLockPassword(
- mChosenPassword, mCurrentPassword, mRequestedQuality, mUserId);
+ final boolean success = mUtils.setLockCredential(
+ mChosenPassword, mCurrentCredential, mUserId);
Intent result = null;
if (success && mHasChallenge) {
byte[] token;
try {
- token = mUtils.verifyPassword(mChosenPassword, mChallenge, mUserId);
+ token = mUtils.verifyCredential(mChosenPassword, mChallenge, mUserId);
} catch (RequestThrottledException e) {
token = null;
}
diff --git a/src/com/android/settings/password/ChooseLockPattern.java b/src/com/android/settings/password/ChooseLockPattern.java
index 5de4e3a..b81b0c4 100644
--- a/src/com/android/settings/password/ChooseLockPattern.java
+++ b/src/com/android/settings/password/ChooseLockPattern.java
@@ -36,12 +36,14 @@
import androidx.fragment.app.Fragment;
+import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.widget.LinearLayoutWithDefaultTouchRecepient;
import com.android.internal.widget.LockPatternUtils;
import com.android.internal.widget.LockPatternUtils.RequestThrottledException;
import com.android.internal.widget.LockPatternView;
import com.android.internal.widget.LockPatternView.Cell;
import com.android.internal.widget.LockPatternView.DisplayMode;
+import com.android.internal.widget.LockscreenCredential;
import com.android.settings.EncryptionInterstitial;
import com.android.settings.R;
import com.android.settings.SettingsActivity;
@@ -116,7 +118,7 @@
return this;
}
- public IntentBuilder setPattern(byte[] pattern) {
+ public IntentBuilder setPattern(LockscreenCredential pattern) {
mIntent.putExtra(ChooseLockSettingsHelper.EXTRA_KEY_PASSWORD, pattern);
return this;
}
@@ -188,7 +190,7 @@
private static final String FRAGMENT_TAG_SAVE_AND_FINISH = "save_and_finish_worker";
- private byte[] mCurrentPattern;
+ private LockscreenCredential mCurrentCredential;
private boolean mHasChallenge;
private long mChallenge;
protected TextView mTitleText;
@@ -198,7 +200,7 @@
protected TextView mFooterText;
protected FooterButton mSkipOrClearButton;
private FooterButton mNextButton;
- protected List<LockPatternView.Cell> mChosenPattern = null;
+ @VisibleForTesting protected LockscreenCredential mChosenPattern;
private ColorStateList mDefaultHeaderColorList;
// ScrollView that contains title and header, only exist in land mode
@@ -225,7 +227,7 @@
getActivity().setResult(RESULT_FINISHED);
getActivity().finish();
} else {
- mCurrentPattern = data.getByteArrayExtra(
+ mCurrentCredential = data.getParcelableExtra(
ChooseLockSettingsHelper.EXTRA_KEY_PASSWORD);
}
@@ -262,16 +264,19 @@
if (mUiStage == Stage.NeedToConfirm || mUiStage == Stage.ConfirmWrong) {
if (mChosenPattern == null) throw new IllegalStateException(
"null chosen pattern in stage 'need to confirm");
- if (mChosenPattern.equals(pattern)) {
- updateStage(Stage.ChoiceConfirmed);
- } else {
- updateStage(Stage.ConfirmWrong);
+ try (LockscreenCredential confirmPattern =
+ LockscreenCredential.createPattern(pattern)) {
+ if (mChosenPattern.equals(confirmPattern)) {
+ updateStage(Stage.ChoiceConfirmed);
+ } else {
+ updateStage(Stage.ConfirmWrong);
+ }
}
} else if (mUiStage == Stage.Introduction || mUiStage == Stage.ChoiceTooShort){
if (pattern.size() < LockPatternUtils.MIN_LOCK_PATTERN_SIZE) {
updateStage(Stage.ChoiceTooShort);
} else {
- mChosenPattern = new ArrayList<LockPatternView.Cell>(pattern);
+ mChosenPattern = LockscreenCredential.createPattern(pattern);
updateStage(Stage.FirstChoiceValid);
}
} else {
@@ -458,12 +463,12 @@
SaveAndFinishWorker w = new SaveAndFinishWorker();
final boolean required = getActivity().getIntent().getBooleanExtra(
EncryptionInterstitial.EXTRA_REQUIRE_PASSWORD, true);
- byte[] current = intent.getByteArrayExtra(
+ LockscreenCredential current = intent.getParcelableExtra(
ChooseLockSettingsHelper.EXTRA_KEY_PASSWORD);
w.setBlocking(true);
w.setListener(this);
w.start(mChooseLockSettingsHelper.utils(), required,
- false, 0, LockPatternUtils.byteArrayToPattern(current), current, mUserId);
+ false, 0, current, current, mUserId);
}
mForFingerprint = intent.getBooleanExtra(
ChooseLockSettingsHelper.EXTRA_KEY_FOR_FINGERPRINT, false);
@@ -541,8 +546,8 @@
final boolean confirmCredentials = getActivity().getIntent()
.getBooleanExtra(ChooseLockGeneric.CONFIRM_CREDENTIALS, true);
Intent intent = getActivity().getIntent();
- mCurrentPattern =
- intent.getByteArrayExtra(ChooseLockSettingsHelper.EXTRA_KEY_PASSWORD);
+ mCurrentCredential =
+ intent.getParcelableExtra(ChooseLockSettingsHelper.EXTRA_KEY_PASSWORD);
mHasChallenge = intent.getBooleanExtra(
ChooseLockSettingsHelper.EXTRA_KEY_HAS_CHALLENGE, false);
mChallenge = intent.getLongExtra(ChooseLockSettingsHelper.EXTRA_KEY_CHALLENGE, 0);
@@ -565,13 +570,10 @@
}
} else {
// restore from previous state
- final byte[] pattern = savedInstanceState.getByteArray(KEY_PATTERN_CHOICE);
- if (pattern != null) {
- mChosenPattern = LockPatternUtils.byteArrayToPattern(pattern);
- }
+ mChosenPattern = savedInstanceState.getParcelable(KEY_PATTERN_CHOICE);
- if (mCurrentPattern == null) {
- mCurrentPattern = savedInstanceState.getByteArray(KEY_CURRENT_PATTERN);
+ if (mCurrentCredential == null) {
+ mCurrentCredential = savedInstanceState.getParcelable(KEY_CURRENT_PATTERN);
}
updateStage(Stage.values()[savedInstanceState.getInt(KEY_UI_STAGE)]);
@@ -606,6 +608,7 @@
public void handleLeftButton() {
if (mUiStage.leftMode == LeftButtonMode.Retry) {
+ mChosenPattern.zeroize();
mChosenPattern = null;
mLockPatternView.clearPattern();
updateStage(Stage.Introduction);
@@ -667,12 +670,11 @@
outState.putInt(KEY_UI_STAGE, mUiStage.ordinal());
if (mChosenPattern != null) {
- outState.putByteArray(KEY_PATTERN_CHOICE,
- LockPatternUtils.patternToByteArray(mChosenPattern));
+ outState.putParcelable(KEY_PATTERN_CHOICE, mChosenPattern);
}
- if (mCurrentPattern != null) {
- outState.putByteArray(KEY_CURRENT_PATTERN, mCurrentPattern);
+ if (mCurrentCredential != null) {
+ outState.putParcelable(KEY_CURRENT_PATTERN, mCurrentCredential);
}
}
@@ -812,15 +814,18 @@
final boolean required = getActivity().getIntent().getBooleanExtra(
EncryptionInterstitial.EXTRA_REQUIRE_PASSWORD, true);
mSaveAndFinishWorker.start(mChooseLockSettingsHelper.utils(), required,
- mHasChallenge, mChallenge, mChosenPattern, mCurrentPattern, mUserId);
+ mHasChallenge, mChallenge, mChosenPattern, mCurrentCredential, mUserId);
}
@Override
public void onChosenLockSaveFinished(boolean wasSecureBefore, Intent resultData) {
getActivity().setResult(RESULT_FINISHED, resultData);
- if (mCurrentPattern != null) {
- Arrays.fill(mCurrentPattern, (byte) 0);
+ if (mChosenPattern != null) {
+ mChosenPattern.zeroize();
+ }
+ if (mCurrentCredential != null) {
+ mCurrentCredential.zeroize();
}
if (!wasSecureBefore) {
@@ -835,16 +840,17 @@
public static class SaveAndFinishWorker extends SaveChosenLockWorkerBase {
- private List<LockPatternView.Cell> mChosenPattern;
- private byte[] mCurrentPattern;
+ private LockscreenCredential mChosenPattern;
+ private LockscreenCredential mCurrentCredential;
private boolean mLockVirgin;
- public void start(LockPatternUtils utils, boolean credentialRequired,
- boolean hasChallenge, long challenge,
- List<LockPatternView.Cell> chosenPattern, byte[] currentPattern, int userId) {
+ public void start(LockPatternUtils utils, boolean credentialRequired, boolean hasChallenge,
+ long challenge, LockscreenCredential chosenPattern,
+ LockscreenCredential currentCredential, int userId) {
prepare(utils, credentialRequired, hasChallenge, challenge, userId);
- mCurrentPattern = currentPattern;
+ mCurrentCredential = currentCredential != null ? currentCredential
+ : LockscreenCredential.createNone();
mChosenPattern = chosenPattern;
mUserId = userId;
@@ -856,12 +862,13 @@
@Override
protected Pair<Boolean, Intent> saveAndVerifyInBackground() {
final int userId = mUserId;
- final boolean success = mUtils.saveLockPattern(mChosenPattern, mCurrentPattern, userId);
+ final boolean success = mUtils.setLockCredential(mChosenPattern, mCurrentCredential,
+ userId);
Intent result = null;
if (success && mHasChallenge) {
byte[] token;
try {
- token = mUtils.verifyPattern(mChosenPattern, mChallenge, userId);
+ token = mUtils.verifyCredential(mChosenPattern, mChallenge, userId);
} catch (RequestThrottledException e) {
token = null;
}
diff --git a/src/com/android/settings/password/ConfirmLockPassword.java b/src/com/android/settings/password/ConfirmLockPassword.java
index 5c891cd..13d3749 100644
--- a/src/com/android/settings/password/ConfirmLockPassword.java
+++ b/src/com/android/settings/password/ConfirmLockPassword.java
@@ -27,6 +27,7 @@
import android.os.SystemClock;
import android.os.UserManager;
import android.os.storage.StorageManager;
+import android.text.Editable;
import android.text.InputType;
import android.text.TextUtils;
import android.view.KeyEvent;
@@ -44,6 +45,7 @@
import com.android.internal.widget.LockPatternChecker;
import com.android.internal.widget.LockPatternUtils;
+import com.android.internal.widget.LockscreenCredential;
import com.android.internal.widget.TextViewInputDisabler;
import com.android.settings.R;
import com.android.settings.widget.ImeAwareEditText;
@@ -332,10 +334,13 @@
}
// TODO(b/120484642): This is a point of entry for passwords from the UI
- final byte[] pin = LockPatternUtils.charSequenceToByteArray(mPasswordEntry.getText());
- if (pin == null || pin.length == 0) {
+ final Editable passwordText = mPasswordEntry.getText();
+ if (TextUtils.isEmpty(passwordText)) {
return;
}
+ final LockscreenCredential credential =
+ mIsAlpha ? LockscreenCredential.createPassword(passwordText)
+ : LockscreenCredential.createPin(passwordText);
mPasswordEntryInputDisabler.setInputEnabled(false);
final boolean verifyChallenge = getActivity().getIntent().getBooleanExtra(
@@ -344,11 +349,11 @@
Intent intent = new Intent();
if (verifyChallenge) {
if (isInternalActivity()) {
- startVerifyPassword(pin, intent);
+ startVerifyPassword(credential, intent);
return;
}
} else {
- startCheckPassword(pin, intent);
+ startCheckPassword(credential, intent);
return;
}
@@ -359,7 +364,7 @@
return getActivity() instanceof ConfirmLockPassword.InternalActivity;
}
- private void startVerifyPassword(final byte[] pin, final Intent intent) {
+ private void startVerifyPassword(LockscreenCredential credential, final Intent intent) {
long challenge = getActivity().getIntent().getLongExtra(
ChooseLockSettingsHelper.EXTRA_KEY_CHALLENGE, 0);
final int localEffectiveUserId = mEffectiveUserId;
@@ -383,29 +388,32 @@
}
};
mPendingLockCheck = (localEffectiveUserId == localUserId)
- ? LockPatternChecker.verifyPassword(
- mLockPatternUtils, pin, challenge, localUserId, onVerifyCallback)
+ ? LockPatternChecker.verifyCredential(
+ mLockPatternUtils, credential, challenge, localUserId, onVerifyCallback)
: LockPatternChecker.verifyTiedProfileChallenge(
- mLockPatternUtils, pin, false, challenge, localUserId,
+ mLockPatternUtils, credential, challenge, localUserId,
onVerifyCallback);
}
- private void startCheckPassword(final byte[] pin, final Intent intent) {
+ private void startCheckPassword(final LockscreenCredential credential,
+ final Intent intent) {
final int localEffectiveUserId = mEffectiveUserId;
- mPendingLockCheck = LockPatternChecker.checkPassword(
+ mPendingLockCheck = LockPatternChecker.checkCredential(
mLockPatternUtils,
- pin,
+ credential,
localEffectiveUserId,
new LockPatternChecker.OnCheckCallback() {
@Override
public void onChecked(boolean matched, int timeoutMs) {
mPendingLockCheck = null;
if (matched && isInternalActivity() && mReturnCredentials) {
+ // TODO: get rid of EXTRA_KEY_TYPE, since EXTRA_KEY_PASSWORD already
+ // distinguishes beteween PIN and password.
intent.putExtra(ChooseLockSettingsHelper.EXTRA_KEY_TYPE,
mIsAlpha ? StorageManager.CRYPT_TYPE_PASSWORD
: StorageManager.CRYPT_TYPE_PIN);
intent.putExtra(
- ChooseLockSettingsHelper.EXTRA_KEY_PASSWORD, pin);
+ ChooseLockSettingsHelper.EXTRA_KEY_PASSWORD, credential);
}
mCredentialCheckResultTracker.setResult(matched, intent, timeoutMs,
localEffectiveUserId);
diff --git a/src/com/android/settings/password/ConfirmLockPattern.java b/src/com/android/settings/password/ConfirmLockPattern.java
index b1d8e60..2f7557e 100644
--- a/src/com/android/settings/password/ConfirmLockPattern.java
+++ b/src/com/android/settings/password/ConfirmLockPattern.java
@@ -37,6 +37,7 @@
import com.android.internal.widget.LockPatternUtils;
import com.android.internal.widget.LockPatternView;
import com.android.internal.widget.LockPatternView.Cell;
+import com.android.internal.widget.LockscreenCredential;
import com.android.settings.R;
import com.android.settingslib.animation.AppearAnimationCreator;
import com.android.settingslib.animation.AppearAnimationUtils;
@@ -401,14 +402,16 @@
final boolean verifyChallenge = getActivity().getIntent().getBooleanExtra(
ChooseLockSettingsHelper.EXTRA_KEY_HAS_CHALLENGE, false);
+ final LockscreenCredential credential = LockscreenCredential.createPattern(pattern);
+ //TODO: how to sanitize this?
Intent intent = new Intent();
if (verifyChallenge) {
if (isInternalActivity()) {
- startVerifyPattern(pattern, intent);
+ startVerifyPattern(credential, intent);
return;
}
} else {
- startCheckPattern(pattern, intent);
+ startCheckPattern(credential, intent);
return;
}
@@ -419,7 +422,7 @@
return getActivity() instanceof ConfirmLockPattern.InternalActivity;
}
- private void startVerifyPattern(final List<LockPatternView.Cell> pattern,
+ private void startVerifyPattern(final LockscreenCredential pattern,
final Intent intent) {
final int localEffectiveUserId = mEffectiveUserId;
final int localUserId = mUserId;
@@ -444,15 +447,15 @@
}
};
mPendingLockCheck = (localEffectiveUserId == localUserId)
- ? LockPatternChecker.verifyPattern(
+ ? LockPatternChecker.verifyCredential(
mLockPatternUtils, pattern, challenge, localUserId,
onVerifyCallback)
: LockPatternChecker.verifyTiedProfileChallenge(
- mLockPatternUtils, LockPatternUtils.patternToByteArray(pattern),
- true, challenge, localUserId, onVerifyCallback);
+ mLockPatternUtils, pattern,
+ challenge, localUserId, onVerifyCallback);
}
- private void startCheckPattern(final List<LockPatternView.Cell> pattern,
+ private void startCheckPattern(final LockscreenCredential pattern,
final Intent intent) {
if (pattern.size() < LockPatternUtils.MIN_PATTERN_REGISTER_FAIL) {
// Pattern size is less than the minimum, do not count it as an fail attempt.
@@ -461,7 +464,7 @@
}
final int localEffectiveUserId = mEffectiveUserId;
- mPendingLockCheck = LockPatternChecker.checkPattern(
+ mPendingLockCheck = LockPatternChecker.checkCredential(
mLockPatternUtils,
pattern,
localEffectiveUserId,
@@ -473,7 +476,7 @@
intent.putExtra(ChooseLockSettingsHelper.EXTRA_KEY_TYPE,
StorageManager.CRYPT_TYPE_PATTERN);
intent.putExtra(ChooseLockSettingsHelper.EXTRA_KEY_PASSWORD,
- LockPatternUtils.patternToByteArray(pattern));
+ pattern);
}
mCredentialCheckResultTracker.setResult(matched, intent, timeoutMs,
localEffectiveUserId);
diff --git a/src/com/android/settings/password/ManagedLockPasswordProvider.java b/src/com/android/settings/password/ManagedLockPasswordProvider.java
index 5006926..ac8a73a 100644
--- a/src/com/android/settings/password/ManagedLockPasswordProvider.java
+++ b/src/com/android/settings/password/ManagedLockPasswordProvider.java
@@ -19,6 +19,8 @@
import android.content.Context;
import android.content.Intent;
+import com.android.internal.widget.LockscreenCredential;
+
/**
* Helper for handling managed passwords in security settings UI.
* It provides resources that should be shown in settings UI when lock password quality is set to
@@ -59,7 +61,7 @@
* @param password Current lock password.
* @return Intent that should update lock password to a managed password.
*/
- Intent createIntent(boolean requirePasswordToDecrypt, byte[] password) {
+ Intent createIntent(boolean requirePasswordToDecrypt, LockscreenCredential password) {
return null;
}
}
diff --git a/src/com/android/settings/security/CryptKeeperSettings.java b/src/com/android/settings/security/CryptKeeperSettings.java
index 6555f56..aa47b2b 100644
--- a/src/com/android/settings/security/CryptKeeperSettings.java
+++ b/src/com/android/settings/security/CryptKeeperSettings.java
@@ -37,6 +37,7 @@
import androidx.appcompat.app.AlertDialog;
import androidx.preference.Preference;
+import com.android.internal.widget.LockscreenCredential;
import com.android.settings.CryptKeeperConfirm;
import com.android.settings.R;
import com.android.settings.SettingsActivity;
@@ -193,9 +194,10 @@
// confirmation prompt; otherwise, go back to the initial state.
if (resultCode == Activity.RESULT_OK && data != null) {
int type = data.getIntExtra(ChooseLockSettingsHelper.EXTRA_KEY_TYPE, -1);
- byte[] password = data.getByteArrayExtra(ChooseLockSettingsHelper.EXTRA_KEY_PASSWORD);
- if (!(password == null || password.length == 0)) {
- showFinalConfirmation(type, password);
+ LockscreenCredential password = data.getParcelableExtra(
+ ChooseLockSettingsHelper.EXTRA_KEY_PASSWORD);
+ if (password != null && !password.isNone()) {
+ showFinalConfirmation(type, password.getCredential());
}
}
}
diff --git a/src/com/android/settings/security/LockUnificationPreferenceController.java b/src/com/android/settings/security/LockUnificationPreferenceController.java
index bf374de..4bac601 100644
--- a/src/com/android/settings/security/LockUnificationPreferenceController.java
+++ b/src/com/android/settings/security/LockUnificationPreferenceController.java
@@ -32,6 +32,7 @@
import androidx.preference.PreferenceScreen;
import com.android.internal.widget.LockPatternUtils;
+import com.android.internal.widget.LockscreenCredential;
import com.android.settings.R;
import com.android.settings.Utils;
import com.android.settings.core.PreferenceControllerMixin;
@@ -70,8 +71,8 @@
private RestrictedSwitchPreference mUnifyProfile;
- private byte[] mCurrentDevicePassword;
- private byte[] mCurrentProfilePassword;
+ private LockscreenCredential mCurrentDevicePassword;
+ private LockscreenCredential mCurrentProfilePassword;
private boolean mKeepDeviceLock;
@Override
@@ -89,6 +90,8 @@
.getSecurityFeatureProvider()
.getLockPatternUtils(context);
mProfileUserId = Utils.getManagedProfileId(mUm, MY_USER_ID);
+ mCurrentDevicePassword = LockscreenCredential.createNone();
+ mCurrentProfilePassword = LockscreenCredential.createNone();
}
@Override
@@ -151,13 +154,13 @@
} else if (requestCode == UNIFY_LOCK_CONFIRM_DEVICE_REQUEST
&& resultCode == Activity.RESULT_OK) {
mCurrentDevicePassword =
- data.getByteArrayExtra(ChooseLockSettingsHelper.EXTRA_KEY_PASSWORD);
+ data.getParcelableExtra(ChooseLockSettingsHelper.EXTRA_KEY_PASSWORD);
launchConfirmProfileLock();
return true;
} else if (requestCode == UNIFY_LOCK_CONFIRM_PROFILE_REQUEST
&& resultCode == Activity.RESULT_OK) {
mCurrentProfilePassword =
- data.getByteArrayExtra(ChooseLockSettingsHelper.EXTRA_KEY_PASSWORD);
+ data.getParcelableExtra(ChooseLockSettingsHelper.EXTRA_KEY_PASSWORD);
unifyLocks();
return true;
}
@@ -221,17 +224,8 @@
}
private void unifyKeepingWorkLock() {
- final int profileQuality =
- mLockPatternUtils.getKeyguardStoredPasswordQuality(mProfileUserId);
- // PASSWORD_QUALITY_SOMETHING means pattern, everything above means PIN/password.
- if (profileQuality == DevicePolicyManager.PASSWORD_QUALITY_SOMETHING) {
- mLockPatternUtils.saveLockPattern(
- LockPatternUtils.byteArrayToPattern(mCurrentProfilePassword),
- mCurrentDevicePassword, MY_USER_ID);
- } else {
- mLockPatternUtils.saveLockPassword(
- mCurrentProfilePassword, mCurrentDevicePassword, profileQuality, MY_USER_ID);
- }
+ mLockPatternUtils.setLockCredential(
+ mCurrentProfilePassword, mCurrentDevicePassword, MY_USER_ID);
mLockPatternUtils.setSeparateProfileChallengeEnabled(mProfileUserId, false,
mCurrentProfilePassword);
final boolean profilePatternVisibility =
diff --git a/src/com/android/settings/slices/SlicePreference.java b/src/com/android/settings/slices/SlicePreference.java
index a2a7fe1..fe5ed60 100644
--- a/src/com/android/settings/slices/SlicePreference.java
+++ b/src/com/android/settings/slices/SlicePreference.java
@@ -46,6 +46,7 @@
mSliceView = findViewById(R.id.slice_view);
mSliceView.setShowTitleItems(true);
mSliceView.setScrollable(false);
+ mSliceView.setVisibility(View.GONE);
}
public void onSliceUpdated(Slice slice) {
diff --git a/src/com/android/settings/slices/SlicePreferenceController.java b/src/com/android/settings/slices/SlicePreferenceController.java
index 8f3d0fb..df28304 100644
--- a/src/com/android/settings/slices/SlicePreferenceController.java
+++ b/src/com/android/settings/slices/SlicePreferenceController.java
@@ -65,7 +65,6 @@
mUri = uri;
mLiveData = SliceLiveData.fromUri(mContext, mUri, (int type, Throwable source) -> {
Log.w(TAG, "Slice may be null. uri = " + uri + ", error = " + type);
- onChanged(null);
});
//TODO(b/120803703): figure out why we need to remove observer first
diff --git a/src/com/android/settings/widget/SwitchBar.java b/src/com/android/settings/widget/SwitchBar.java
index 0dd59e6..de0d98b 100644
--- a/src/com/android/settings/widget/SwitchBar.java
+++ b/src/com/android/settings/widget/SwitchBar.java
@@ -77,14 +77,12 @@
private TextView mTextView;
private String mLabel;
private String mSummary;
+ private String mOnText;
+ private String mOffText;
@ColorInt
private int mBackgroundColor;
@ColorInt
private int mBackgroundActivatedColor;
- @StringRes
- private int mOnTextId;
- @StringRes
- private int mOffTextId;
private boolean mLoggingIntialized;
private boolean mDisabledByAdmin;
@@ -178,14 +176,20 @@
}
public void setTextViewLabelAndBackground(boolean isChecked) {
- mLabel = getResources().getString(isChecked ? mOnTextId : mOffTextId);
+ mLabel = isChecked ? mOnText : mOffText;
setBackgroundColor(isChecked ? mBackgroundActivatedColor : mBackgroundColor);
updateText();
}
- public void setSwitchBarText(int onText, int offText) {
- mOnTextId = onText;
- mOffTextId = offText;
+ public void setSwitchBarText(int onTextId, int offTextId) {
+ mOnText = getResources().getString(onTextId);
+ mOffText = getResources().getString(offTextId);
+ setTextViewLabelAndBackground(isChecked());
+ }
+
+ public void setSwitchBarText(String onText, String offText) {
+ mOnText = onText;
+ mOffText = offText;
setTextViewLabelAndBackground(isChecked());
}
diff --git a/src/com/android/settings/wifi/savedaccesspoints/SavedAccessPointsPreferenceController.java b/src/com/android/settings/wifi/savedaccesspoints/SavedAccessPointsPreferenceController.java
index b8e36a4..81803dd 100644
--- a/src/com/android/settings/wifi/savedaccesspoints/SavedAccessPointsPreferenceController.java
+++ b/src/com/android/settings/wifi/savedaccesspoints/SavedAccessPointsPreferenceController.java
@@ -16,10 +16,8 @@
package com.android.settings.wifi.savedaccesspoints;
-
import android.content.Context;
import android.net.wifi.WifiManager;
-import android.util.Log;
import androidx.annotation.VisibleForTesting;
import androidx.preference.Preference;
@@ -27,10 +25,6 @@
import androidx.preference.PreferenceScreen;
import com.android.settings.core.BasePreferenceController;
-import com.android.settings.R;
-import com.android.settingslib.core.lifecycle.LifecycleObserver;
-import com.android.settingslib.core.lifecycle.events.OnStart;
-import com.android.settingslib.utils.ThreadUtils;
import com.android.settingslib.wifi.AccessPoint;
import com.android.settingslib.wifi.AccessPointPreference;
import com.android.settingslib.wifi.AccessPointPreference.UserBadgeCache;
@@ -38,21 +32,22 @@
import java.util.Collections;
import java.util.List;
+import java.util.stream.Collectors;
/**
* Controller that manages a PreferenceGroup, which contains a list of saved access points.
*/
public class SavedAccessPointsPreferenceController extends BasePreferenceController implements
- LifecycleObserver, OnStart, Preference.OnPreferenceClickListener,
- WifiManager.ActionListener {
+ Preference.OnPreferenceClickListener {
- private static final String TAG = "SavedAPPrefCtrl";
+ private static final String TAG = "SavedApPrefCtrl";
private final WifiManager mWifiManager;
-
private final UserBadgeCache mUserBadgeCache;
private PreferenceGroup mPreferenceGroup;
private SavedAccessPointsWifiSettings mHost;
+ @VisibleForTesting
+ List<AccessPoint> mAccessPoints;
public SavedAccessPointsPreferenceController(Context context,
String preferenceKey) {
@@ -68,86 +63,46 @@
@Override
public int getAvailabilityStatus() {
- return AVAILABLE;
+ return mAccessPoints.size() > 0 ? AVAILABLE : CONDITIONALLY_UNAVAILABLE;
}
@Override
public void displayPreference(PreferenceScreen screen) {
- super.displayPreference(screen);
mPreferenceGroup = screen.findPreference(getPreferenceKey());
- }
-
- @Override
- public void onStart() {
refreshSavedAccessPoints();
- }
-
- public void postRefreshSavedAccessPoints() {
- ThreadUtils.postOnMainThread(() -> refreshSavedAccessPoints());
+ updatePreference();
+ super.displayPreference(screen);
}
@Override
public boolean onPreferenceClick(Preference preference) {
- final Preference preferenceInGroup = mPreferenceGroup.findPreference(preference.getKey());
if (mHost != null) {
+ final Preference preferenceInGroup =
+ mPreferenceGroup.findPreference(preference.getKey());
mHost.showWifiPage((AccessPointPreference) preferenceInGroup);
}
return false;
}
- @Override
- public void onSuccess() {
- postRefreshSavedAccessPoints();
+ private void refreshSavedAccessPoints() {
+ mAccessPoints = WifiSavedConfigUtils.getAllConfigs(mContext, mWifiManager).stream()
+ .filter(accessPoint -> !accessPoint.isPasspointConfig())
+ .sorted(SavedNetworkComparator.INSTANCE)
+ .collect(Collectors.toList());
}
- @Override
- public void onFailure(int reason) {
- postRefreshSavedAccessPoints();
- }
-
- @VisibleForTesting
- void refreshSavedAccessPoints() {
- if (mPreferenceGroup == null) {
- Log.w(TAG, "PreferenceGroup is null, skipping.");
- return;
- }
- final Context prefContext = mPreferenceGroup.getContext();
-
- final List<AccessPoint> accessPoints =
- WifiSavedConfigUtils.getAllConfigs(mContext, mWifiManager);
- Collections.sort(accessPoints, SavedNetworkComparator.INSTANCE);
+ private void updatePreference() {
mPreferenceGroup.removeAll();
+ for (AccessPoint accessPoint : mAccessPoints) {
+ final String key = accessPoint.getKey();
- final int accessPointsSize = accessPoints.size();
- for (int i = 0; i < accessPointsSize; ++i) {
- AccessPoint ap = accessPoints.get(i);
-
- if (mHost != null && mHost.isSubscriptionsFeatureEnabled()
- && ap.isPasspointConfig()) {
- continue;
- }
-
- String key = ap.getKey();
- AccessPointPreference preference = new AccessPointPreference(ap, prefContext,
- mUserBadgeCache, true);
+ final AccessPointPreference preference = new AccessPointPreference(accessPoint,
+ mContext, mUserBadgeCache, true /* forSavedNetworks */);
preference.setKey(key);
preference.setIcon(null);
preference.setOnPreferenceClickListener(this);
+
mPreferenceGroup.addPreference(preference);
- preference.setOrder(i);
- }
-
- if (mPreferenceGroup.getPreferenceCount() < 1) {
- Log.w(TAG, "Saved networks activity loaded, but there are no saved networks!");
- mPreferenceGroup.setVisible(false);
- } else {
- mPreferenceGroup.setVisible(true);
- }
-
- if (mHost != null && !mHost.isSubscriptionsFeatureEnabled()) {
- mPreferenceGroup.setVisible(true);
- mPreferenceGroup.setTitle(null);
- mPreferenceGroup.setLayoutResource(R.layout.preference_category_no_label);
}
}
}
diff --git a/src/com/android/settings/wifi/savedaccesspoints/SavedAccessPointsWifiSettings.java b/src/com/android/settings/wifi/savedaccesspoints/SavedAccessPointsWifiSettings.java
index cf2fc99..863e87a 100644
--- a/src/com/android/settings/wifi/savedaccesspoints/SavedAccessPointsWifiSettings.java
+++ b/src/com/android/settings/wifi/savedaccesspoints/SavedAccessPointsWifiSettings.java
@@ -20,13 +20,13 @@
import android.app.settings.SettingsEnums;
import android.content.Context;
import android.os.Bundle;
-import android.util.FeatureFlagUtils;
+
+import androidx.annotation.VisibleForTesting;
+import androidx.preference.PreferenceScreen;
import com.android.settings.R;
-import com.android.settings.core.FeatureFlags;
import com.android.settings.core.SubSettingLauncher;
import com.android.settings.dashboard.DashboardFragment;
-import com.android.settings.development.featureflags.FeatureFlagPersistent;
import com.android.settings.wifi.WifiSettings;
import com.android.settings.wifi.details.WifiNetworkDetailsFragment;
import com.android.settingslib.wifi.AccessPoint;
@@ -39,7 +39,8 @@
private static final String TAG = "SavedAccessPoints";
- private Bundle mAccessPointSavedState;
+ @VisibleForTesting
+ Bundle mAccessPointSavedState;
private AccessPoint mSelectedAccessPoint;
// Instance state key
@@ -76,10 +77,22 @@
if (savedInstanceState.containsKey(SAVE_DIALOG_ACCESS_POINT_STATE)) {
mAccessPointSavedState =
savedInstanceState.getBundle(SAVE_DIALOG_ACCESS_POINT_STATE);
+ } else {
+ mAccessPointSavedState = null;
}
}
}
+ @Override
+ public void onStart() {
+ super.onStart();
+ if (mAccessPointSavedState != null) {
+ final PreferenceScreen screen = getPreferenceScreen();
+ use(SavedAccessPointsPreferenceController.class).displayPreference(screen);
+ use(SubscribedAccessPointsPreferenceController.class).displayPreference(screen);
+ }
+ }
+
public void showWifiPage(@Nullable AccessPointPreference accessPoint) {
removeDialog(WifiSettings.WIFI_DIALOG_ID);
@@ -117,9 +130,4 @@
outState.putBundle(SAVE_DIALOG_ACCESS_POINT_STATE, mAccessPointSavedState);
}
}
-
- boolean isSubscriptionsFeatureEnabled() {
- return FeatureFlagUtils.isEnabled(getContext(), FeatureFlags.MOBILE_NETWORK_V2)
- && FeatureFlagPersistent.isEnabled(getContext(), FeatureFlags.NETWORK_INTERNET_V2);
- }
}
diff --git a/src/com/android/settings/wifi/savedaccesspoints/SubscribedAccessPointsPreferenceController.java b/src/com/android/settings/wifi/savedaccesspoints/SubscribedAccessPointsPreferenceController.java
index 048999a..4d7dc60 100644
--- a/src/com/android/settings/wifi/savedaccesspoints/SubscribedAccessPointsPreferenceController.java
+++ b/src/com/android/settings/wifi/savedaccesspoints/SubscribedAccessPointsPreferenceController.java
@@ -16,10 +16,8 @@
package com.android.settings.wifi.savedaccesspoints;
-
import android.content.Context;
import android.net.wifi.WifiManager;
-import android.util.Log;
import androidx.annotation.VisibleForTesting;
import androidx.preference.Preference;
@@ -27,10 +25,6 @@
import androidx.preference.PreferenceScreen;
import com.android.settings.core.BasePreferenceController;
-import com.android.settings.utils.PreferenceGroupChildrenCache;
-import com.android.settingslib.core.lifecycle.LifecycleObserver;
-import com.android.settingslib.core.lifecycle.events.OnStart;
-import com.android.settingslib.utils.ThreadUtils;
import com.android.settingslib.wifi.AccessPoint;
import com.android.settingslib.wifi.AccessPointPreference;
import com.android.settingslib.wifi.AccessPointPreference.UserBadgeCache;
@@ -38,29 +32,28 @@
import java.util.Collections;
import java.util.List;
+import java.util.stream.Collectors;
/**
* Controller that manages a PreferenceGroup, which contains a list of subscribed access points.
*/
-// TODO(b/127206629): Code refactor to avoid duplicated coding after removed feature flag.
public class SubscribedAccessPointsPreferenceController extends BasePreferenceController implements
- LifecycleObserver, OnStart, Preference.OnPreferenceClickListener,
- WifiManager.ActionListener {
+ Preference.OnPreferenceClickListener {
- private static final String TAG = "SubscribedAPPrefCtrl";
+ private static final String TAG = "SubscribedApPrefCtrl";
private final WifiManager mWifiManager;
- private final PreferenceGroupChildrenCache mChildrenCache;
private final UserBadgeCache mUserBadgeCache;
private PreferenceGroup mPreferenceGroup;
private SavedAccessPointsWifiSettings mHost;
+ @VisibleForTesting
+ List<AccessPoint> mAccessPoints;
public SubscribedAccessPointsPreferenceController(Context context,
String preferenceKey) {
super(context, preferenceKey);
mUserBadgeCache = new AccessPointPreference.UserBadgeCache(context.getPackageManager());
mWifiManager = context.getSystemService(WifiManager.class);
- mChildrenCache = new PreferenceGroupChildrenCache();
}
public SubscribedAccessPointsPreferenceController setHost(SavedAccessPointsWifiSettings host) {
@@ -70,89 +63,46 @@
@Override
public int getAvailabilityStatus() {
- return AVAILABLE;
+ return mAccessPoints.size() > 0 ? AVAILABLE : CONDITIONALLY_UNAVAILABLE;
}
@Override
public void displayPreference(PreferenceScreen screen) {
- super.displayPreference(screen);
mPreferenceGroup = screen.findPreference(getPreferenceKey());
- }
-
- @Override
- public void onStart() {
refreshSubscribedAccessPoints();
- }
-
- public void postRefreshSubscribedAccessPoints() {
- ThreadUtils.postOnMainThread(() -> refreshSubscribedAccessPoints());
+ updatePreference();
+ super.displayPreference(screen);
}
@Override
public boolean onPreferenceClick(Preference preference) {
if (mHost != null) {
- mHost.showWifiPage((AccessPointPreference) preference);
+ final Preference preferenceInGroup =
+ mPreferenceGroup.findPreference(preference.getKey());
+ mHost.showWifiPage((AccessPointPreference) preferenceInGroup);
}
return false;
}
- @Override
- public void onSuccess() {
- postRefreshSubscribedAccessPoints();
+ private void refreshSubscribedAccessPoints() {
+ mAccessPoints = WifiSavedConfigUtils.getAllConfigs(mContext, mWifiManager).stream()
+ .filter(accessPoint -> accessPoint.isPasspointConfig())
+ .sorted(SavedNetworkComparator.INSTANCE)
+ .collect(Collectors.toList());
}
- @Override
- public void onFailure(int reason) {
- postRefreshSubscribedAccessPoints();
- }
+ private void updatePreference() {
+ mPreferenceGroup.removeAll();
+ for (AccessPoint accessPoint : mAccessPoints) {
+ final String key = accessPoint.getKey();
- @VisibleForTesting
- void refreshSubscribedAccessPoints() {
- if (mPreferenceGroup == null) {
- Log.w(TAG, "PreferenceGroup is null, skipping.");
- return;
- }
+ final AccessPointPreference preference = new AccessPointPreference(accessPoint,
+ mContext, mUserBadgeCache, true /* forSavedNetworks */);
+ preference.setKey(key);
+ preference.setIcon(null);
+ preference.setOnPreferenceClickListener(this);
- if (mHost != null && !mHost.isSubscriptionsFeatureEnabled()) {
- mPreferenceGroup.setVisible(false);
- return;
- }
-
- final Context prefContext = mPreferenceGroup.getContext();
-
- final List<AccessPoint> accessPoints =
- WifiSavedConfigUtils.getAllConfigs(mContext, mWifiManager);
- Collections.sort(accessPoints, SavedNetworkComparator.INSTANCE);
- mChildrenCache.cacheRemoveAllPrefs(mPreferenceGroup);
-
- final int accessPointsSize = accessPoints.size();
- for (int i = 0; i < accessPointsSize; ++i) {
- AccessPoint ap = accessPoints.get(i);
- if (!ap.isPasspointConfig()) {
- continue;
- }
-
- final String key = ap.getKey();
- AccessPointPreference preference =
- (AccessPointPreference) mChildrenCache.getCachedPreference(key);
- if (preference == null) {
- preference = new AccessPointPreference(ap, prefContext, mUserBadgeCache, true);
- preference.setKey(key);
- preference.setIcon(null);
- preference.setOnPreferenceClickListener(this);
- mPreferenceGroup.addPreference(preference);
- }
- preference.setOrder(i);
- }
-
- mChildrenCache.removeCachedPrefs(mPreferenceGroup);
-
- if (mPreferenceGroup.getPreferenceCount() < 1) {
- Log.w(TAG, "Subscribed networks activity loaded,"
- + " but there are no subscribed networks!");
- mPreferenceGroup.setVisible(false);
- } else {
- mPreferenceGroup.setVisible(true);
+ mPreferenceGroup.addPreference(preference);
}
}
}
diff --git a/tests/robotests/src/com/android/settings/accounts/AccountPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/accounts/AccountPreferenceControllerTest.java
index 65f485e..bf64190 100644
--- a/tests/robotests/src/com/android/settings/accounts/AccountPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/accounts/AccountPreferenceControllerTest.java
@@ -46,6 +46,7 @@
import com.android.settings.AccessiblePreferenceCategory;
import com.android.settings.R;
import com.android.settings.SettingsPreferenceFragment;
+import com.android.settings.dashboard.profileselector.ProfileSelectFragment;
import com.android.settings.testutils.shadow.ShadowAccountManager;
import com.android.settings.testutils.shadow.ShadowContentResolver;
import com.android.settingslib.search.SearchIndexableRaw;
@@ -96,7 +97,8 @@
when(mAccountManager.getAuthenticatorTypesAsUser(anyInt()))
.thenReturn(new AuthenticatorDescription[0]);
when(mAccountManager.getAccountsAsUser(anyInt())).thenReturn(new Account[0]);
- mController = new AccountPreferenceController(mContext, mFragment, null, mAccountHelper);
+ mController = new AccountPreferenceController(mContext, mFragment, null, mAccountHelper,
+ ProfileSelectFragment.ALL);
}
@After
diff --git a/tests/robotests/src/com/android/settings/datausage/ChartDataUsagePreferenceTest.java b/tests/robotests/src/com/android/settings/datausage/ChartDataUsagePreferenceTest.java
index 39bf9cf..8881b49 100644
--- a/tests/robotests/src/com/android/settings/datausage/ChartDataUsagePreferenceTest.java
+++ b/tests/robotests/src/com/android/settings/datausage/ChartDataUsagePreferenceTest.java
@@ -18,11 +18,19 @@
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.verify;
-import android.content.Context;
+import android.app.Activity;
import android.util.SparseIntArray;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.widget.TextView;
+import androidx.preference.PreferenceViewHolder;
+
+import com.android.settings.R;
+import com.android.settings.datausage.ChartDataUsagePreference.DataUsageSummaryNode;
import com.android.settings.widget.UsageView;
import com.android.settingslib.net.NetworkCycleChartData;
import com.android.settingslib.net.NetworkCycleData;
@@ -32,8 +40,8 @@
import org.junit.runner.RunWith;
import org.mockito.ArgumentCaptor;
import org.mockito.MockitoAnnotations;
+import org.robolectric.Robolectric;
import org.robolectric.RobolectricTestRunner;
-import org.robolectric.RuntimeEnvironment;
import java.util.ArrayList;
import java.util.List;
@@ -49,15 +57,20 @@
private List<NetworkCycleData> mNetworkCycleData;
private NetworkCycleChartData mNetworkCycleChartData;
- private Context mContext;
private ChartDataUsagePreference mPreference;
+ private Activity mActivity;
+ private PreferenceViewHolder mHolder;
@Before
public void setUp() {
MockitoAnnotations.initMocks(this);
- mContext = RuntimeEnvironment.application;
- mPreference = new ChartDataUsagePreference(mContext, null);
+ mActivity = spy(Robolectric.setupActivity(Activity.class));
+ mPreference = new ChartDataUsagePreference(mActivity, null /* attrs */);
+ LayoutInflater inflater = LayoutInflater.from(mActivity);
+ View view = inflater.inflate(mPreference.getLayoutResource(), null /* root */,
+ false /* attachToRoot */);
+ mHolder = spy(PreferenceViewHolder.createInstanceForTests(view));
}
@Test
@@ -148,6 +161,40 @@
assertThat(points.keyAt(6)).isEqualTo(TimeUnit.DAYS.toMinutes(5));
}
+ @Test
+ public void notifyChange_nonEmptyDataUsage_shouldHaveSingleContentDescription() {
+ final UsageView chart = (UsageView) mHolder.findViewById(R.id.data_usage);
+ final TextView labelTop = (TextView) mHolder.findViewById(R.id.label_top);
+ final TextView labelMiddle = (TextView) mHolder.findViewById(R.id.label_middle);
+ final TextView labelBottom = (TextView) mHolder.findViewById(R.id.label_bottom);
+ final TextView labelStart = (TextView) mHolder.findViewById(R.id.label_start);
+ final TextView labelEnd = (TextView) mHolder.findViewById(R.id.label_end);
+ createTestNetworkData();
+ mPreference.setNetworkCycleData(mNetworkCycleChartData);
+
+ mPreference.onBindViewHolder(mHolder);
+
+ assertThat(chart.getContentDescription()).isNotNull();
+ assertThat(labelTop.getContentDescription()).isNull();
+ assertThat(labelMiddle.getContentDescription()).isNull();
+ assertThat(labelBottom.getContentDescription()).isNull();
+ assertThat(labelStart.getContentDescription()).isNull();
+ assertThat(labelEnd.getContentDescription()).isNull();
+ }
+
+ @Test
+ public void getDensedStatsData_someSamePercentageNodes_getDifferentPercentageNodes() {
+ createSomeSamePercentageNetworkData();
+ final List<DataUsageSummaryNode> densedStatsData =
+ mPreference.getDensedStatsData(mNetworkCycleData);
+
+ assertThat(mNetworkCycleData.size()).isEqualTo(8);
+ assertThat(densedStatsData.size()).isEqualTo(3);
+ assertThat(densedStatsData.get(0).getDataUsagePercentage()).isEqualTo(33);
+ assertThat(densedStatsData.get(1).getDataUsagePercentage()).isEqualTo(99);
+ assertThat(densedStatsData.get(2).getDataUsagePercentage()).isEqualTo(100);
+ }
+
private void createTestNetworkData() {
mNetworkCycleData = new ArrayList<>();
// create 10 arbitrary network data
@@ -169,6 +216,18 @@
mNetworkCycleChartData = builder.build();
}
+ private void createSomeSamePercentageNetworkData() {
+ mNetworkCycleData = new ArrayList<>();
+ mNetworkCycleData.add(createNetworkCycleData(1521583200000L, 1521586800000L, 100));//33%
+ mNetworkCycleData.add(createNetworkCycleData(1521586800000L, 1521590400000L, 1)); //33%
+ mNetworkCycleData.add(createNetworkCycleData(1521590400000L, 1521655200000L, 0)); //33%
+ mNetworkCycleData.add(createNetworkCycleData(1521655200000L, 1521658800000L, 0)); //33%
+ mNetworkCycleData.add(createNetworkCycleData(1521658800000L, 1521662400000L, 200));//99%
+ mNetworkCycleData.add(createNetworkCycleData(1521662400000L, 1521666000000L, 1)); //99%
+ mNetworkCycleData.add(createNetworkCycleData(1521666000000L, 1521669600000L, 1)); //100
+ mNetworkCycleData.add(createNetworkCycleData(1521669600000L, 1521673200000L, 0)); //100%
+ }
+
private NetworkCycleData createNetworkCycleData(long start, long end, long usage) {
return new NetworkCycleData.Builder()
.setStartTime(start).setEndTime(end).setTotalUsage(usage).build();
diff --git a/tests/robotests/src/com/android/settings/notification/AllowSoundPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/notification/AllowSoundPreferenceControllerTest.java
index f747842..f59ef85 100644
--- a/tests/robotests/src/com/android/settings/notification/AllowSoundPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/notification/AllowSoundPreferenceControllerTest.java
@@ -67,7 +67,7 @@
private PreferenceScreen mScreen;
@Mock
- private NotificationSettingsBase.ImportanceListener mImportanceListener;
+ private NotificationSettings.ImportanceListener mImportanceListener;
private AllowSoundPreferenceController mController;
diff --git a/tests/robotests/src/com/android/settings/notification/BlockPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/notification/BlockPreferenceControllerTest.java
index 41655fa..4c22a6d 100644
--- a/tests/robotests/src/com/android/settings/notification/BlockPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/notification/BlockPreferenceControllerTest.java
@@ -68,7 +68,7 @@
private UserManager mUm;
@Mock
- private NotificationSettingsBase.ImportanceListener mImportanceListener;
+ private NotificationSettings.ImportanceListener mImportanceListener;
private BlockPreferenceController mController;
@Mock
diff --git a/tests/robotests/src/com/android/settings/notification/HighImportancePreferenceControllerTest.java b/tests/robotests/src/com/android/settings/notification/HighImportancePreferenceControllerTest.java
index a89a826..db2eca0 100644
--- a/tests/robotests/src/com/android/settings/notification/HighImportancePreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/notification/HighImportancePreferenceControllerTest.java
@@ -60,7 +60,7 @@
@Mock
private NotificationBackend mBackend;
@Mock
- private NotificationSettingsBase.ImportanceListener mImportanceListener;
+ private NotificationSettings.ImportanceListener mImportanceListener;
@Mock
private UserManager mUm;
@Mock(answer = Answers.RETURNS_DEEP_STUBS)
diff --git a/tests/robotests/src/com/android/settings/notification/ImportancePreferenceControllerTest.java b/tests/robotests/src/com/android/settings/notification/ImportancePreferenceControllerTest.java
index 999631e..9b91a07 100644
--- a/tests/robotests/src/com/android/settings/notification/ImportancePreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/notification/ImportancePreferenceControllerTest.java
@@ -66,7 +66,7 @@
@Mock
private NotificationBackend mBackend;
@Mock
- private NotificationSettingsBase.ImportanceListener mImportanceListener;
+ private NotificationSettings.ImportanceListener mImportanceListener;
@Mock
private UserManager mUm;
@Mock(answer = Answers.RETURNS_DEEP_STUBS)
diff --git a/tests/robotests/src/com/android/settings/notification/MinImportancePreferenceControllerTest.java b/tests/robotests/src/com/android/settings/notification/MinImportancePreferenceControllerTest.java
index b8ef7d1..abed4aa 100644
--- a/tests/robotests/src/com/android/settings/notification/MinImportancePreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/notification/MinImportancePreferenceControllerTest.java
@@ -60,7 +60,7 @@
@Mock
private NotificationBackend mBackend;
@Mock
- private NotificationSettingsBase.ImportanceListener mImportanceListener;
+ private NotificationSettings.ImportanceListener mImportanceListener;
@Mock
private UserManager mUm;
@Mock(answer = Answers.RETURNS_DEEP_STUBS)
diff --git a/tests/robotests/src/com/android/settings/notification/SoundPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/notification/SoundPreferenceControllerTest.java
index f09f63b..3e727e9 100644
--- a/tests/robotests/src/com/android/settings/notification/SoundPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/notification/SoundPreferenceControllerTest.java
@@ -79,7 +79,7 @@
@Mock
private SettingsPreferenceFragment mFragment;
@Mock
- private NotificationSettingsBase.ImportanceListener mImportanceListener;
+ private NotificationSettings.ImportanceListener mImportanceListener;
private SoundPreferenceController mController;
diff --git a/tests/robotests/src/com/android/settings/password/ChooseLockPasswordTest.java b/tests/robotests/src/com/android/settings/password/ChooseLockPasswordTest.java
index 73707a6..084d710 100644
--- a/tests/robotests/src/com/android/settings/password/ChooseLockPasswordTest.java
+++ b/tests/robotests/src/com/android/settings/password/ChooseLockPasswordTest.java
@@ -41,6 +41,7 @@
import android.content.Intent;
import android.os.UserHandle;
+import com.android.internal.widget.LockscreenCredential;
import com.android.settings.R;
import com.android.settings.password.ChooseLockPassword.ChooseLockPasswordFragment;
import com.android.settings.password.ChooseLockPassword.IntentBuilder;
@@ -87,7 +88,7 @@
@Test
public void intentBuilder_setPassword_shouldAddExtras() {
Intent intent = new IntentBuilder(application)
- .setPassword("password".getBytes())
+ .setPassword(LockscreenCredential.createPassword("password"))
.setPasswordQuality(DevicePolicyManager.PASSWORD_QUALITY_NUMERIC)
.setUserId(123)
.build();
@@ -95,9 +96,10 @@
assertThat(intent.getBooleanExtra(ChooseLockSettingsHelper.EXTRA_KEY_HAS_CHALLENGE, true))
.named("EXTRA_KEY_HAS_CHALLENGE")
.isFalse();
- assertThat(intent.getByteArrayExtra(ChooseLockSettingsHelper.EXTRA_KEY_PASSWORD))
+ assertThat((LockscreenCredential) intent.getParcelableExtra(
+ ChooseLockSettingsHelper.EXTRA_KEY_PASSWORD))
.named("EXTRA_KEY_PASSWORD")
- .isEqualTo("password".getBytes());
+ .isEqualTo(LockscreenCredential.createPassword("password"));
assertThat(intent.getIntExtra(PASSWORD_TYPE_KEY, 0))
.named("PASSWORD_TYPE_KEY")
.isEqualTo(DevicePolicyManager.PASSWORD_QUALITY_NUMERIC);
@@ -154,7 +156,7 @@
assertPasswordValidationResult(
/* minComplexity= */ PASSWORD_COMPLEXITY_NONE,
/* passwordType= */ PASSWORD_QUALITY_ALPHABETIC,
- /* userEnteredPassword= */ "",
+ /* userEnteredPassword= */ LockscreenCredential.createNone(),
"Must contain at least 1 letter",
"Must be at least 10 characters");
}
@@ -166,7 +168,7 @@
assertPasswordValidationResult(
/* minComplexity= */ PASSWORD_COMPLEXITY_HIGH,
/* passwordType= */ PASSWORD_QUALITY_NUMERIC,
- /* userEnteredPassword= */ "",
+ /* userEnteredPassword= */ LockscreenCredential.createNone(),
"PIN must be at least 8 digits");
}
@@ -177,7 +179,7 @@
assertPasswordValidationResult(
/* minComplexity= */ PASSWORD_COMPLEXITY_MEDIUM,
/* passwordType= */ PASSWORD_QUALITY_ALPHABETIC,
- /* userEnteredPassword= */ "",
+ /* userEnteredPassword= */ LockscreenCredential.createNone(),
"Must contain at least 1 letter",
"Must be at least 4 characters");
}
@@ -190,7 +192,7 @@
assertPasswordValidationResult(
/* minComplexity= */ PASSWORD_COMPLEXITY_LOW,
/* passwordType= */ PASSWORD_QUALITY_ALPHABETIC,
- /* userEnteredPassword= */ "",
+ /* userEnteredPassword= */ LockscreenCredential.createNone(),
"Must contain at least 1 letter",
"Must contain at least 1 numerical digit",
"Must be at least 9 characters");
@@ -204,7 +206,7 @@
assertPasswordValidationResult(
/* minComplexity= */ PASSWORD_COMPLEXITY_MEDIUM,
/* passwordType= */ PASSWORD_QUALITY_NUMERIC,
- /* userEnteredPassword= */ "",
+ /* userEnteredPassword= */ LockscreenCredential.createNone(),
"PIN must be at least 11 digits");
}
@@ -216,7 +218,7 @@
assertPasswordValidationResult(
/* minComplexity= */ PASSWORD_COMPLEXITY_HIGH,
/* passwordType= */ PASSWORD_QUALITY_ALPHABETIC,
- /* userEnteredPassword= */ "",
+ /* userEnteredPassword= */ LockscreenCredential.createNone(),
"Must contain at least 2 special symbols",
"Must be at least 6 characters");
}
@@ -229,7 +231,7 @@
assertPasswordValidationResult(
/* minComplexity= */ PASSWORD_COMPLEXITY_NONE,
/* passwordType= */ PASSWORD_QUALITY_NUMERIC,
- /* userEnteredPassword= */ "12345678",
+ /* userEnteredPassword= */ LockscreenCredential.createPassword("12345678"),
"Ascending, descending, or repeated sequence of digits isn't allowed");
}
@@ -241,7 +243,7 @@
assertPasswordValidationResult(
/* minComplexity= */ PASSWORD_COMPLEXITY_NONE,
/* passwordType= */ PASSWORD_QUALITY_ALPHABETIC,
- /* userEnteredPassword= */ "12345678",
+ /* userEnteredPassword= */ LockscreenCredential.createPassword("12345678"),
"Ascending, descending, or repeated sequence of digits isn't allowed");
}
@@ -253,7 +255,7 @@
assertPasswordValidationResult(
/* minComplexity= */ PASSWORD_COMPLEXITY_HIGH,
/* passwordType= */ PASSWORD_QUALITY_NUMERIC,
- /* userEnteredPassword= */ "12345678",
+ /* userEnteredPassword= */ LockscreenCredential.createPassword("12345678"),
"Ascending, descending, or repeated sequence of digits isn't allowed");
}
@@ -265,7 +267,7 @@
assertPasswordValidationResult(
/* minComplexity= */ PASSWORD_COMPLEXITY_HIGH,
/* passwordType= */ PASSWORD_QUALITY_NUMERIC,
- /* userEnteredPassword= */ "12345678",
+ /* userEnteredPassword= */ LockscreenCredential.createPassword("12345678"),
"Ascending, descending, or repeated sequence of digits isn't allowed");
}
@@ -277,7 +279,7 @@
assertPasswordValidationResult(
/* minComplexity= */ PASSWORD_COMPLEXITY_LOW,
/* passwordType= */ PASSWORD_QUALITY_ALPHABETIC,
- /* userEnteredPassword= */ "12345678",
+ /* userEnteredPassword= */ LockscreenCredential.createPassword("12345678"),
"Must contain at least 1 letter");
}
@@ -288,7 +290,7 @@
assertPasswordValidationResult(
/* minComplexity= */ PASSWORD_COMPLEXITY_HIGH,
/* passwordType= */ PASSWORD_QUALITY_ALPHABETIC,
- /* userEnteredPassword= */ "",
+ /* userEnteredPassword= */ LockscreenCredential.createNone(),
"Must contain at least 1 letter",
"Must be at least 6 characters");
}
@@ -300,7 +302,7 @@
assertPasswordValidationResult(
/* minComplexity= */ PASSWORD_COMPLEXITY_HIGH,
/* passwordType= */ PASSWORD_QUALITY_ALPHABETIC,
- /* userEnteredPassword= */ "1",
+ /* userEnteredPassword= */ LockscreenCredential.createPassword("1"),
"Must contain at least 1 letter",
"Must be at least 6 characters");
}
@@ -312,7 +314,7 @@
assertPasswordValidationResult(
/* minComplexity= */ PASSWORD_COMPLEXITY_HIGH,
/* passwordType= */ PASSWORD_QUALITY_ALPHABETIC,
- /* userEnteredPassword= */ "b",
+ /* userEnteredPassword= */ LockscreenCredential.createPassword("b"),
"Must be at least 6 characters");
}
@@ -323,7 +325,7 @@
assertPasswordValidationResult(
/* minComplexity= */ PASSWORD_COMPLEXITY_HIGH,
/* passwordType= */ PASSWORD_QUALITY_ALPHABETIC,
- /* userEnteredPassword= */ "b1",
+ /* userEnteredPassword= */ LockscreenCredential.createPassword("b1"),
"Must be at least 6 characters");
}
@@ -359,16 +361,15 @@
}
private void assertPasswordValidationResult(@PasswordComplexity int minComplexity,
- int passwordType, String userEnteredPassword, String... expectedValidationResult) {
+ int passwordType, LockscreenCredential userEnteredPassword,
+ String... expectedValidationResult) {
Intent intent = new Intent();
intent.putExtra(CONFIRM_CREDENTIALS, false);
intent.putExtra(PASSWORD_TYPE_KEY, passwordType);
intent.putExtra(EXTRA_KEY_REQUESTED_MIN_COMPLEXITY, minComplexity);
ChooseLockPassword activity = buildChooseLockPasswordActivity(intent);
ChooseLockPasswordFragment fragment = getChooseLockPasswordFragment(activity);
- byte[] userEnteredPasswordBytes = userEnteredPassword != null
- ? userEnteredPassword.getBytes() : null;
- int validateResult = fragment.validatePassword(userEnteredPasswordBytes);
+ int validateResult = fragment.validatePassword(userEnteredPassword);
String[] messages = fragment.convertErrorCodeToMessages(validateResult);
assertThat(messages).asList().containsExactly((Object[]) expectedValidationResult);
diff --git a/tests/robotests/src/com/android/settings/password/ChooseLockPatternTest.java b/tests/robotests/src/com/android/settings/password/ChooseLockPatternTest.java
index 48ebbec..0100744 100644
--- a/tests/robotests/src/com/android/settings/password/ChooseLockPatternTest.java
+++ b/tests/robotests/src/com/android/settings/password/ChooseLockPatternTest.java
@@ -24,6 +24,8 @@
import android.os.UserHandle;
import android.view.View;
+import com.android.internal.widget.LockPatternUtils;
+import com.android.internal.widget.LockscreenCredential;
import com.android.settings.R;
import com.android.settings.password.ChooseLockPattern.ChooseLockPatternFragment;
import com.android.settings.password.ChooseLockPattern.IntentBuilder;
@@ -52,7 +54,7 @@
@Test
public void intentBuilder_setPattern_shouldAddExtras() {
Intent intent = new IntentBuilder(application)
- .setPattern("pattern".getBytes())
+ .setPattern(createPattern("1234"))
.setUserId(123)
.build();
@@ -60,10 +62,10 @@
.getBooleanExtra(ChooseLockSettingsHelper.EXTRA_KEY_HAS_CHALLENGE, true))
.named("EXTRA_KEY_HAS_CHALLENGE")
.isFalse();
- assertThat(intent
- .getByteArrayExtra(ChooseLockSettingsHelper.EXTRA_KEY_PASSWORD))
+ assertThat((LockscreenCredential) intent
+ .getParcelableExtra(ChooseLockSettingsHelper.EXTRA_KEY_PASSWORD))
.named("EXTRA_KEY_PASSWORD")
- .isEqualTo("pattern".getBytes());
+ .isEqualTo(createPattern("1234"));
assertThat(intent.getIntExtra(Intent.EXTRA_USER_ID, 0))
.named("EXTRA_USER_ID")
.isEqualTo(123);
@@ -120,4 +122,9 @@
.build())
.setup().get();
}
+
+ private LockscreenCredential createPattern(String patternString) {
+ return LockscreenCredential.createPattern(LockPatternUtils.byteArrayToPattern(
+ patternString.getBytes()));
+ }
}
diff --git a/tests/robotests/src/com/android/settings/testutils/shadow/ShadowLockPatternUtils.java b/tests/robotests/src/com/android/settings/testutils/shadow/ShadowLockPatternUtils.java
index e9be346..38756ac 100644
--- a/tests/robotests/src/com/android/settings/testutils/shadow/ShadowLockPatternUtils.java
+++ b/tests/robotests/src/com/android/settings/testutils/shadow/ShadowLockPatternUtils.java
@@ -20,6 +20,7 @@
import android.content.ComponentName;
import com.android.internal.widget.LockPatternUtils;
+import com.android.internal.widget.LockscreenCredential;
import org.robolectric.annotation.Implementation;
import org.robolectric.annotation.Implements;
@@ -66,7 +67,8 @@
}
@Implementation
- protected byte[] getPasswordHistoryHashFactor(byte[] currentPassword, int userId) {
+ protected byte[] getPasswordHistoryHashFactor(LockscreenCredential currentPassword,
+ int userId) {
return null;
}
diff --git a/tests/robotests/src/com/android/settings/widget/SwitchBarTest.java b/tests/robotests/src/com/android/settings/widget/SwitchBarTest.java
index f186222..31cb966 100644
--- a/tests/robotests/src/com/android/settings/widget/SwitchBarTest.java
+++ b/tests/robotests/src/com/android/settings/widget/SwitchBarTest.java
@@ -85,6 +85,24 @@
}
@Test
+ public void setCheck_customLabelWithStringType_shouldUpdateTextAndBackground() {
+ final String onText = mContext.getString(
+ R.string.accessibility_service_master_switch_title);
+ final String offText = mContext.getString(
+ R.string.accessibility_service_master_switch_title);
+ final TextView switchBarTextView = ((TextView) mBar.findViewById(R.id.switch_text));
+
+ mBar.setSwitchBarText(onText, offText);
+
+ assertThat(switchBarTextView.getText()).isEqualTo(offText);
+
+ mBar.setChecked(true);
+
+ assertThat(mBar.getBackground()).isInstanceOf(ColorDrawable.class);
+ assertThat(switchBarTextView.getText()).isEqualTo(onText);
+ }
+
+ @Test
public void disabledByAdmin_shouldDelegateToRestrictedIcon() {
mBar.setDisabledByAdmin(new EnforcedAdmin());
assertThat(mBar.getDelegatingView().getId()).isEqualTo(R.id.restricted_icon);
diff --git a/tests/robotests/src/com/android/settings/wifi/savedaccesspoints/SavedAccessPointsPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/wifi/savedaccesspoints/SavedAccessPointsPreferenceControllerTest.java
index 196c97b..73e1297 100644
--- a/tests/robotests/src/com/android/settings/wifi/savedaccesspoints/SavedAccessPointsPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/wifi/savedaccesspoints/SavedAccessPointsPreferenceControllerTest.java
@@ -17,11 +17,11 @@
package com.android.settings.wifi.savedaccesspoints;
import static com.android.settings.core.BasePreferenceController.AVAILABLE;
+import static com.android.settings.core.BasePreferenceController.CONDITIONALLY_UNAVAILABLE;
import static com.google.common.truth.Truth.assertThat;
import static org.mockito.ArgumentMatchers.any;
-import static org.mockito.Mockito.doNothing;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.verify;
@@ -30,16 +30,19 @@
import android.content.Context;
import android.net.wifi.WifiConfiguration;
import android.net.wifi.WifiManager;
+import android.os.Bundle;
import androidx.preference.PreferenceCategory;
import androidx.preference.PreferenceScreen;
-import com.android.settings.core.FeatureFlags;
-import com.android.settings.development.featureflags.FeatureFlagPersistent;
import com.android.settings.testutils.shadow.ShadowAccessPoint;
import com.android.settings.testutils.shadow.ShadowWifiManager;
+import com.android.settingslib.wifi.AccessPoint;
import com.android.settingslib.wifi.AccessPointPreference;
+import java.util.ArrayList;
+import java.util.Arrays;
+
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -79,47 +82,21 @@
}
@Test
- public void getAvailability_alwaysAvailable() {
+ public void getAvailability_noSavedAccessPoint_shouldNotAvailable() {
+ mController.mAccessPoints = new ArrayList<>();
+
+ assertThat(mController.getAvailabilityStatus()).isEqualTo(CONDITIONALLY_UNAVAILABLE);
+ }
+
+ @Test
+ public void getAvailability_oneSavedAccessPoint_shouldAvailable() {
+ final AccessPoint accessPoint = new AccessPoint(mContext, new Bundle() /* savedState */);
+ mController.mAccessPoints = new ArrayList<AccessPoint>(Arrays.asList(accessPoint));
+
assertThat(mController.getAvailabilityStatus()).isEqualTo(AVAILABLE);
}
@Test
- public void onStart_shouldRefreshApList() {
- doNothing().when(mController).refreshSavedAccessPoints();
-
- mController.onStart();
-
- verify(mController).refreshSavedAccessPoints();
- }
-
- @Test
- public void postRefresh_shouldRefreshApList() {
- doNothing().when(mController).refreshSavedAccessPoints();
-
- mController.postRefreshSavedAccessPoints();
-
- verify(mController).refreshSavedAccessPoints();
- }
-
- @Test
- public void forget_onSuccess_shouldRefreshApList() {
- doNothing().when(mController).refreshSavedAccessPoints();
-
- mController.onSuccess();
-
- verify(mController).refreshSavedAccessPoints();
- }
-
- @Test
- public void forget_onFailure_shouldRefreshApList() {
- doNothing().when(mController).refreshSavedAccessPoints();
-
- mController.onFailure(0 /* reason */);
-
- verify(mController).refreshSavedAccessPoints();
- }
-
- @Test
@Config(shadows = ShadowAccessPoint.class)
public void refreshSavedAccessPoints_shouldListNonSubscribedAPs() {
final WifiConfiguration config = new WifiConfiguration();
@@ -131,7 +108,6 @@
final ArgumentCaptor<AccessPointPreference> captor =
ArgumentCaptor.forClass(AccessPointPreference.class);
mController.displayPreference(mPreferenceScreen);
- mController.refreshSavedAccessPoints();
verify(mPreferenceCategory).addPreference(captor.capture());
@@ -142,13 +118,10 @@
@Test
@Config(shadows = ShadowAccessPoint.class)
public void refreshSavedAccessPoints_shouldNotListSubscribedAPs() {
- FeatureFlagPersistent.setEnabled(mContext, FeatureFlags.NETWORK_INTERNET_V2, true);
-
mWifiManager.addOrUpdatePasspointConfiguration(
SubscribedAccessPointsPreferenceControllerTest.createMockPasspointConfiguration());
mController.displayPreference(mPreferenceScreen);
- mController.refreshSavedAccessPoints();
verify(mPreferenceCategory, never()).addPreference(any(AccessPointPreference.class));
}
diff --git a/tests/robotests/src/com/android/settings/wifi/savedaccesspoints/SavedAccessPointsWifiSettingsTest.java b/tests/robotests/src/com/android/settings/wifi/savedaccesspoints/SavedAccessPointsWifiSettingsTest.java
index cda4005..923f05e 100644
--- a/tests/robotests/src/com/android/settings/wifi/savedaccesspoints/SavedAccessPointsWifiSettingsTest.java
+++ b/tests/robotests/src/com/android/settings/wifi/savedaccesspoints/SavedAccessPointsWifiSettingsTest.java
@@ -23,6 +23,7 @@
import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
import com.android.settings.R;
import com.android.settingslib.core.AbstractPreferenceController;
+
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
diff --git a/tests/robotests/src/com/android/settings/wifi/savedaccesspoints/SubscribedAccessPointsPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/wifi/savedaccesspoints/SubscribedAccessPointsPreferenceControllerTest.java
index 581f531..f9307db 100644
--- a/tests/robotests/src/com/android/settings/wifi/savedaccesspoints/SubscribedAccessPointsPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/wifi/savedaccesspoints/SubscribedAccessPointsPreferenceControllerTest.java
@@ -17,11 +17,11 @@
package com.android.settings.wifi.savedaccesspoints;
import static com.android.settings.core.BasePreferenceController.AVAILABLE;
+import static com.android.settings.core.BasePreferenceController.CONDITIONALLY_UNAVAILABLE;
import static com.google.common.truth.Truth.assertThat;
import static org.mockito.ArgumentMatchers.any;
-import static org.mockito.Mockito.doNothing;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.verify;
@@ -32,16 +32,19 @@
import android.net.wifi.WifiManager;
import android.net.wifi.hotspot2.PasspointConfiguration;
import android.net.wifi.hotspot2.pps.HomeSp;
+import android.os.Bundle;
import androidx.preference.PreferenceCategory;
import androidx.preference.PreferenceScreen;
-import com.android.settings.core.FeatureFlags;
-import com.android.settings.development.featureflags.FeatureFlagPersistent;
import com.android.settings.testutils.shadow.ShadowAccessPoint;
import com.android.settings.testutils.shadow.ShadowWifiManager;
+import com.android.settingslib.wifi.AccessPoint;
import com.android.settingslib.wifi.AccessPointPreference;
+import java.util.ArrayList;
+import java.util.Arrays;
+
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -78,52 +81,24 @@
when(mPreferenceScreen.findPreference(mController.getPreferenceKey()))
.thenReturn(mPreferenceCategory);
when(mPreferenceCategory.getContext()).thenReturn(mContext);
-
- FeatureFlagPersistent.setEnabled(mContext, FeatureFlags.NETWORK_INTERNET_V2, true);
}
@Test
- public void getAvailability_alwaysAvailable() {
+ public void getAvailability_noSavedAccessPoint_shouldNotAvailable() {
+ mController.mAccessPoints = new ArrayList<>();
+
+ assertThat(mController.getAvailabilityStatus()).isEqualTo(CONDITIONALLY_UNAVAILABLE);
+ }
+
+ @Test
+ public void getAvailability_oneSavedAccessPoint_shouldAvailable() {
+ final AccessPoint accessPoint = new AccessPoint(mContext, new Bundle() /* savedState */);
+ mController.mAccessPoints = new ArrayList<AccessPoint>(Arrays.asList(accessPoint));
+
assertThat(mController.getAvailabilityStatus()).isEqualTo(AVAILABLE);
}
@Test
- public void onStart_shouldRefreshApList() {
- doNothing().when(mController).refreshSubscribedAccessPoints();
-
- mController.onStart();
-
- verify(mController).refreshSubscribedAccessPoints();
- }
-
- @Test
- public void postRefresh_shouldRefreshApList() {
- doNothing().when(mController).refreshSubscribedAccessPoints();
-
- mController.postRefreshSubscribedAccessPoints();
-
- verify(mController).refreshSubscribedAccessPoints();
- }
-
- @Test
- public void forget_onSuccess_shouldRefreshApList() {
- doNothing().when(mController).refreshSubscribedAccessPoints();
-
- mController.onSuccess();
-
- verify(mController).refreshSubscribedAccessPoints();
- }
-
- @Test
- public void forget_onFailure_shouldRefreshApList() {
- doNothing().when(mController).refreshSubscribedAccessPoints();
-
- mController.onFailure(0 /* reason */);
-
- verify(mController).refreshSubscribedAccessPoints();
- }
-
- @Test
@Config(shadows = ShadowAccessPoint.class)
public void refreshSubscribedAccessPoints_shouldNotListNonSubscribedAPs() {
final WifiConfiguration config = new WifiConfiguration();
@@ -133,7 +108,6 @@
mWifiManager.addNetwork(config);
mController.displayPreference(mPreferenceScreen);
- mController.refreshSubscribedAccessPoints();
verify(mPreferenceCategory, never()).addPreference(any(AccessPointPreference.class));
}
@@ -144,7 +118,6 @@
mWifiManager.addOrUpdatePasspointConfiguration(createMockPasspointConfiguration());
mController.displayPreference(mPreferenceScreen);
- mController.refreshSubscribedAccessPoints();
final ArgumentCaptor<AccessPointPreference> captor =
ArgumentCaptor.forClass(AccessPointPreference.class);
diff --git a/tests/unit/src/com/android/settings/RegulatoryInfoDisplayActivityTest.java b/tests/unit/src/com/android/settings/RegulatoryInfoDisplayActivityTest.java
deleted file mode 100644
index 1701ddf..0000000
--- a/tests/unit/src/com/android/settings/RegulatoryInfoDisplayActivityTest.java
+++ /dev/null
@@ -1,73 +0,0 @@
-/*
- * Copyright (C) 2017 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.settings;
-
-import static junit.framework.Assert.fail;
-
-import android.app.Instrumentation;
-import android.app.UiAutomation;
-import android.content.Context;
-import android.content.Intent;
-import android.content.pm.ResolveInfo;
-
-import androidx.test.InstrumentationRegistry;
-import androidx.test.filters.SmallTest;
-import androidx.test.runner.AndroidJUnit4;
-
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-
-@RunWith(AndroidJUnit4.class)
-@SmallTest
-public class RegulatoryInfoDisplayActivityTest {
- private static final String TAG = "RegulatoryInfoTest";
-
- private Instrumentation mInstrumentation;
- private Intent mRegulatoryInfoIntent;
- private UiAutomation mUiAutomation;
-
- @Before
- public void setUp() {
- mInstrumentation = InstrumentationRegistry.getInstrumentation();
- mUiAutomation = InstrumentationRegistry.getInstrumentation().getUiAutomation();
- mRegulatoryInfoIntent = new Intent("android.settings.SHOW_REGULATORY_INFO")
- .addCategory(Intent.CATEGORY_DEFAULT)
- .setPackage(mInstrumentation.getTargetContext().getPackageName());
- }
-
- @Test
- public void resolveRegulatoryInfoIntent_intentShouldMatchConfig() {
- // Load intent from PackageManager and load config from Settings app
- final Context context = mInstrumentation.getTargetContext();
-
- final boolean hasRegulatoryInfo = context.getResources()
- .getBoolean(R.bool.config_show_regulatory_info);
- final ResolveInfo resolveInfo = mInstrumentation.getTargetContext().getPackageManager()
- .resolveActivity(mRegulatoryInfoIntent, 0 /* flags */);
-
- // Check config and intent both enable or both disabled.
- if (hasRegulatoryInfo && resolveInfo == null) {
- fail("Config enables regulatory info but there is no handling intent");
- return;
- }
- if (!hasRegulatoryInfo && resolveInfo != null) {
- fail("Config disables regulatory info but there is at least one handling intent");
- return;
- }
- }
-}
diff --git a/tests/unit/src/com/android/settings/password/ChooseLockGenericTest.java b/tests/unit/src/com/android/settings/password/ChooseLockGenericTest.java
index 582afd2..4b539cc 100644
--- a/tests/unit/src/com/android/settings/password/ChooseLockGenericTest.java
+++ b/tests/unit/src/com/android/settings/password/ChooseLockGenericTest.java
@@ -43,6 +43,7 @@
import androidx.test.runner.lifecycle.Stage;
import com.android.internal.widget.LockPatternUtils;
+import com.android.internal.widget.LockscreenCredential;
import org.junit.Before;
import org.junit.Rule;
@@ -150,7 +151,7 @@
.putExtra(LockPatternUtils.PASSWORD_TYPE_KEY,
DevicePolicyManager.PASSWORD_QUALITY_NUMERIC)
.putExtra(ChooseLockSettingsHelper.EXTRA_KEY_PASSWORD,
- "12345")
+ LockscreenCredential.createPin("12345"))
.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
getInstrumentation().getContext().startActivity(newPasswordIntent);
mDevice.waitForIdle();