Snap for 11355999 from 3fc7f37c21 to 24Q2-release
Change-Id: Iba23b8260e2ef9654ba82b6269ac5e0c65a8e9e1
This commit is contained in:
@@ -627,6 +627,27 @@
|
||||
android:value="true" />
|
||||
</activity>
|
||||
|
||||
<activity android:name="Settings$SatelliteSettingActivity"
|
||||
android:label="@string/satellite_setting"
|
||||
android:exported="true"
|
||||
android:configChanges="orientation|keyboardHidden|screenSize">
|
||||
<intent-filter android:priority="1">
|
||||
<action android:name="android.settings.SATELLITE_SETTING" />
|
||||
<category android:name="android.intent.category.DEFAULT" />
|
||||
</intent-filter>
|
||||
<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>
|
||||
<meta-data android:name="com.android.settings.PRIMARY_PROFILE_CONTROLLED"
|
||||
android:value="true" />
|
||||
<meta-data android:name="com.android.settings.FRAGMENT_CLASS"
|
||||
android:value="com.android.settings.network.telephony.SatelliteSetting" />
|
||||
<meta-data android:name="com.android.settings.HIGHLIGHT_MENU_KEY"
|
||||
android:value="@string/menu_key_network"/>
|
||||
</activity>
|
||||
|
||||
<activity android:name="Settings$ApnSettingsActivity"
|
||||
android:label="@string/apn_settings"
|
||||
android:exported="true"
|
||||
@@ -641,7 +662,7 @@
|
||||
<category android:name="android.intent.category.VOICE_LAUNCH" />
|
||||
</intent-filter>
|
||||
<meta-data android:name="com.android.settings.PRIMARY_PROFILE_CONTROLLED"
|
||||
android:value="true" />
|
||||
android:value="true" />
|
||||
<meta-data android:name="com.android.settings.FRAGMENT_CLASS"
|
||||
android:value="com.android.settings.network.apn.ApnSettings" />
|
||||
<meta-data android:name="com.android.settings.HIGHLIGHT_MENU_KEY"
|
||||
|
||||
@@ -27,3 +27,10 @@ flag {
|
||||
description: "Gates whether to require an auth challenge for changing USB preferences"
|
||||
bug: "317367746"
|
||||
}
|
||||
|
||||
flag {
|
||||
name: "enable_saved_devices_order_by_recency"
|
||||
namespace: "pixel_cross_device_control"
|
||||
description: "Order the saved bluetooth devices by most recently connected."
|
||||
bug: "306160434"
|
||||
}
|
||||
25
res/drawable/ic_block_24px.xml
Normal file
25
res/drawable/ic_block_24px.xml
Normal file
@@ -0,0 +1,25 @@
|
||||
<!--
|
||||
Copyright (C) 2024 The Android Open Source Project
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
-->
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportWidth="960"
|
||||
android:viewportHeight="960"
|
||||
android:tint="?android:attr/colorControlNormal">
|
||||
<path
|
||||
android:fillColor="@android:color/white"
|
||||
android:pathData="M480,880Q397,880 324,848.5Q251,817 197,763Q143,709 111.5,636Q80,563 80,480Q80,397 111.5,324Q143,251 197,197Q251,143 324,111.5Q397,80 480,80Q563,80 636,111.5Q709,143 763,197Q817,251 848.5,324Q880,397 880,480Q880,563 848.5,636Q817,709 763,763Q709,817 636,848.5Q563,880 480,880ZM480,800Q534,800 584,782.5Q634,765 676,732L228,284Q195,326 177.5,376Q160,426 160,480Q160,614 253,707Q346,800 480,800ZM732,676Q765,634 782.5,584Q800,534 800,480Q800,346 707,253Q614,160 480,160Q426,160 376,177.5Q326,195 284,228L732,676Z"/>
|
||||
</vector>
|
||||
25
res/drawable/ic_check_circle_24px.xml
Normal file
25
res/drawable/ic_check_circle_24px.xml
Normal file
@@ -0,0 +1,25 @@
|
||||
<!--
|
||||
Copyright (C) 2024 The Android Open Source Project
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
-->
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportWidth="960"
|
||||
android:viewportHeight="960"
|
||||
android:tint="?attr/colorControlNormal">
|
||||
<path
|
||||
android:fillColor="@android:color/white"
|
||||
android:pathData="M424,664L706,382L650,326L424,552L310,438L254,494L424,664ZM480,880Q397,880 324,848.5Q251,817 197,763Q143,709 111.5,636Q80,563 80,480Q80,397 111.5,324Q143,251 197,197Q251,143 324,111.5Q397,80 480,80Q563,80 636,111.5Q709,143 763,197Q817,251 848.5,324Q880,397 880,480Q880,563 848.5,636Q817,709 763,763Q709,817 636,848.5Q563,880 480,880ZM480,800Q614,800 707,707Q800,614 800,480Q800,346 707,253Q614,160 480,160Q346,160 253,253Q160,346 160,480Q160,614 253,707Q346,800 480,800ZM480,480Q480,480 480,480Q480,480 480,480Q480,480 480,480Q480,480 480,480Q480,480 480,480Q480,480 480,480Q480,480 480,480Q480,480 480,480Z"/>
|
||||
</vector>
|
||||
25
res/drawable/ic_satellite_alt_24px.xml
Normal file
25
res/drawable/ic_satellite_alt_24px.xml
Normal file
@@ -0,0 +1,25 @@
|
||||
<!--
|
||||
Copyright (C) 2024 The Android Open Source Project
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
-->
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportWidth="960"
|
||||
android:viewportHeight="960"
|
||||
android:tint="?android:attr/colorControlNormal">
|
||||
<path
|
||||
android:fillColor="@android:color/white"
|
||||
android:pathData="M560,928L560,848Q677,848 758.5,766.5Q840,685 840,568L920,568Q920,643 891.5,708.5Q863,774 814.5,822.5Q766,871 700.5,899.5Q635,928 560,928ZM560,768L560,688Q610,688 645,653Q680,618 680,568L760,568Q760,651 701.5,709.5Q643,768 560,768ZM222,903Q207,903 192,897Q177,891 165,880L23,738Q12,726 6,711Q0,696 0,681Q0,665 6,650.5Q12,636 23,625L150,498Q173,475 207,474.5Q241,474 264,497L314,547L342,519L292,469Q269,446 269,413Q269,380 292,357L349,300Q372,277 405.5,277Q439,277 462,300L512,350L540,322L490,272Q467,249 467,215.5Q467,182 490,159L617,32Q629,20 644,14Q659,8 674,8Q689,8 703.5,14Q718,20 730,32L872,174Q884,185 889.5,199.5Q895,214 895,230Q895,245 889.5,260Q884,275 872,287L745,414Q722,437 688.5,437Q655,437 632,414L582,364L554,392L604,442Q627,465 626.5,498.5Q626,532 603,555L547,611Q524,634 490.5,634Q457,634 434,611L384,561L356,589L406,639Q429,662 428.5,696Q428,730 405,753L278,880Q267,891 252.5,897Q238,903 222,903ZM222,824Q222,824 222,824Q222,824 222,824L264,782L122,640L80,682Q80,682 80,682Q80,682 80,682L222,824ZM307,739L349,697Q349,697 349,697Q349,697 349,697L207,555Q207,555 207,555Q207,555 207,555L165,597L307,739ZM491,555Q491,555 491,555Q491,555 491,555L547,499Q547,499 547,499Q547,499 547,499L405,357Q405,357 405,357Q405,357 405,357L349,413Q349,413 349,413Q349,413 349,413L491,555ZM689,357Q689,357 689,357Q689,357 689,357L731,315L589,173L547,215Q547,215 547,215Q547,215 547,215L689,357ZM774,272L816,230Q816,230 816,230Q816,230 816,230L674,88Q674,88 674,88Q674,88 674,88L632,130L774,272ZM448,456L448,456Q448,456 448,456Q448,456 448,456L448,456Q448,456 448,456Q448,456 448,456L448,456Q448,456 448,456Q448,456 448,456L448,456Q448,456 448,456Q448,456 448,456Z"/>
|
||||
</vector>
|
||||
25
res/drawable/ic_signal_cellular_nodata_24px.xml
Normal file
25
res/drawable/ic_signal_cellular_nodata_24px.xml
Normal file
@@ -0,0 +1,25 @@
|
||||
<!--
|
||||
Copyright (C) 2024 The Android Open Source Project
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
-->
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportWidth="960"
|
||||
android:viewportHeight="960"
|
||||
android:tint="?android:attr/colorControlNormal">
|
||||
<path
|
||||
android:fillColor="@android:color/white"
|
||||
android:pathData="M676,860L620,804L704,720L620,636L676,580L760,664L844,580L900,636L817,720L900,804L844,860L760,777L676,860ZM80,880L880,81L880,508Q862,497 842,490.5Q822,484 800,480L800,274L273,800L530,800Q538,823 550,843Q562,863 577,880L80,880ZM273,800L800,274L800,274Q800,274 800,274Q800,274 800,274Q724,350 662,411.5Q600,473 540.5,532.5Q481,592 417,656Q353,720 273,800Q273,800 273,800Q273,800 273,800L273,800Z"/>
|
||||
</vector>
|
||||
@@ -0,0 +1,24 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
Copyright (C) 2024 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.
|
||||
-->
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:shape="rectangle">
|
||||
<corners android:radius="24dp"/>
|
||||
<solid android:color="@android:color/transparent"/>
|
||||
<stroke
|
||||
android:width="1dp"
|
||||
android:color="?android:attr/textColorPrimary"/>
|
||||
</shape>
|
||||
50
res/layout/satellite_setting_more_information_layout.xml
Normal file
50
res/layout/satellite_setting_more_information_layout.xml
Normal file
@@ -0,0 +1,50 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- Copyright (C) 2024 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:background="@drawable/satellite_more_information_background_outline"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingStart="?android:attr/listPreferredItemPaddingStart"
|
||||
android:paddingEnd="?android:attr/listPreferredItemPaddingEnd"
|
||||
android:minHeight="?android:attr/listPreferredItemHeight"
|
||||
android:focusable="false"
|
||||
android:gravity="center_vertical">
|
||||
|
||||
<TextView
|
||||
android:id="@android:id/summary"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:textAppearance="?android:attr/textAppearanceListItemSecondary"
|
||||
android:textColor="?android:attr/textColorSecondary"
|
||||
android:focusable="false"
|
||||
android:hyphenationFrequency="normalFast"
|
||||
android:lineBreakWordStyle="phrase"
|
||||
android:maxLines="10" />
|
||||
|
||||
<TextView
|
||||
android:id="@android:id/summary"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:textAppearance="?android:attr/textAppearanceListItemSecondary"
|
||||
android:textColor="?android:attr/textColorSecondary"
|
||||
android:focusable="false"
|
||||
android:hyphenationFrequency="normalFast"
|
||||
android:lineBreakWordStyle="phrase"
|
||||
android:maxLines="10" />
|
||||
|
||||
</LinearLayout>
|
||||
@@ -52,6 +52,9 @@
|
||||
<action
|
||||
android:id="@+id/action_advance_login_error"
|
||||
app:destination="@id/ps_account_error_fragment"/>
|
||||
<action
|
||||
android:id="@+id/action_success_fragment"
|
||||
app:destination="@id/ps_profile_success_fragment"/>
|
||||
</fragment>
|
||||
<fragment android:id="@+id/ps_profile_lock_fragment"
|
||||
android:name="com.android.settings.privatespace.PrivateSpaceSetLockFragment"
|
||||
|
||||
@@ -42,6 +42,10 @@
|
||||
<string name="config_avatar_picker_action" translatable="false">
|
||||
com.android.avatarpicker.FULL_SCREEN_ACTIVITY
|
||||
</string>
|
||||
<!-- User avatar dialog result broadcast explicit package -->
|
||||
<string name="config_avatar_picker_package" translatable="false">
|
||||
com.android.avatarpicker
|
||||
</string>
|
||||
|
||||
<!-- Package name and fully-qualified class name for the wallpaper picker activity. -->
|
||||
<string name="config_wallpaper_picker_package" translatable="false">com.android.settings</string>
|
||||
|
||||
@@ -1341,10 +1341,14 @@
|
||||
<string name="private_space_done_label">Done</string>
|
||||
<!-- Toast to show on private space setup completion informing user to scroll down All apps to access private space. [CHAR LIMIT=60] -->
|
||||
<string name="private_space_scrolldown_to_access">Scroll down to find private space</string>
|
||||
<!-- Title for private space account login error screen. [CHAR LIMIT=60] -->
|
||||
<string name="private_space_retry_signin_title">Sign in to set up a private space</string>
|
||||
<!-- Title for private space account login error screen. [CHAR LIMIT=30] -->
|
||||
<string name="private_space_retry_signin_title">Sign in</string>
|
||||
<!-- Summary for the private space account login error screen. [CHAR LIMIT=NONE] -->
|
||||
<string name="private_space_retry_summary">You need to sign in to an account to set up a private space</string>
|
||||
<string name="private_space_retry_summary">Sign in to an account to use with your private space</string>
|
||||
<!-- Label for button to skip private space account sign in. [CHAR LIMIT=30] -->
|
||||
<string name="private_space_skip_login_label">Not now</string>
|
||||
<!-- Label for button to coninue with private space account sign in. [CHAR LIMIT=30] -->
|
||||
<string name="private_space_continue_login_label">Continue</string>
|
||||
<!-- private space lock setup screen title. This title is asking the user to choose a type of screen lock (such as a pattern, PIN, or password) that they need to enter to unlock private space. [CHAR LIMIT=60] -->
|
||||
<string name="private_space_lock_setup_title">Choose a lock for your private space</string>
|
||||
<!-- private space lock setup screen description [CHAR LIMIT=NONE] -->
|
||||
@@ -3256,6 +3260,10 @@
|
||||
<!-- Summary of the communal settings under Settings > Communal [CHAR LIMIT=50] -->
|
||||
<string name="communal_settings_summary">Communal settings</string>
|
||||
|
||||
<!-- _satellite_setting_preference_layout -->
|
||||
<!-- _satellite_setting_preference_layout screen title-->
|
||||
<string name="satellite_setting">Satellite Messaging</string>
|
||||
|
||||
<!-- APN Settings -->
|
||||
<!-- APN settings screen title -->
|
||||
<string name="apn_settings">APNs</string>
|
||||
@@ -3370,7 +3378,7 @@
|
||||
<!-- Erase Euicc dialog and SD card & phone storage settings screen, title for the menu option and checkbox to let user decide whether erase eSIM data together [CHAR LIMIT=50] -->
|
||||
<string name="reset_esim_title">Erase eSIMs</string>
|
||||
<!-- Erase Euicc dialog and SD card & phone storage settings screen, message for the checkbox to let user decide whether erase eSIM data together [CHAR LIMIT=NONE] -->
|
||||
<string name="reset_esim_desc">This won’t cancel any mobile service plans. To download replacement SIMs, contact your carrier.</string>
|
||||
<string name="reset_esim_desc">This won’t cancel your mobile service plan. To get a replacement SIM, contact your carrier.</string>
|
||||
|
||||
<!-- SD card & phone storage settings screen, button on screen after user selects Reset network settings -->
|
||||
<string name="reset_network_button_text">Reset settings</string>
|
||||
@@ -3387,9 +3395,9 @@
|
||||
<!-- Reset settings complete toast text [CHAR LIMIT=75] -->
|
||||
<string name="reset_network_complete_toast">Network settings have been reset</string>
|
||||
<!-- Title of the error message shown when error happens during erase eSIM data [CHAR LIMIT=NONE] -->
|
||||
<string name="reset_esim_error_title">Can\u2019t erase SIMs</string>
|
||||
<string name="reset_esim_error_title">Can\u2019t erase eSIMs</string>
|
||||
<!-- Message of the error message shown when error happens during erase eSIM data [CHAR LIMIT=NONE] -->
|
||||
<string name="reset_esim_error_msg">eSIMs can\u2019t be erased due to an error.\n\nRestart your device and try again.</string>
|
||||
<string name="reset_esim_error_msg">Something went wrong and your eSIMs weren\u2019t erased.\n\nRestart your device and try again.</string>
|
||||
|
||||
<!-- Main Clear -->
|
||||
<!-- Button title to factory data reset the entire device [CHAR LIMIT=NONE] -->
|
||||
@@ -3405,7 +3413,7 @@
|
||||
<!-- SD card & phone storage settings screen, message on screen after user selects Reset phone button [CHAR LIMIT=NONE] -->
|
||||
<string name="main_clear_final_desc">All of your personal information and downloaded apps will be deleted. You can\u2019t undo this action.</string>
|
||||
<!-- SD card & phone storage settings screen, message on screen after user selects Reset phone button [CHAR LIMIT=NONE] -->
|
||||
<string name="main_clear_final_desc_esim">All of your personal information, including downloaded apps & SIMs, will be deleted. You can\u2019t undo this action.</string>
|
||||
<string name="main_clear_final_desc_esim">All of your personal information, including downloaded apps & eSIMs, will be deleted. You can\u2019t undo this action.</string>
|
||||
<!-- Main clear confirmation screen title [CHAR LIMIT=33] -->
|
||||
<string name="main_clear_confirm_title">Erase all data?</string>
|
||||
<!-- Error message for users that aren't allowed to factory reset [CHAR LIMIT=none] -->
|
||||
@@ -11362,7 +11370,7 @@
|
||||
|
||||
<!-- Mobile network details page. Label for an option that lets the user delete an eSIM from
|
||||
the device. [CHAR LIMIT=60] -->
|
||||
<string name="mobile_network_erase_sim">Erase SIM</string>
|
||||
<string name="mobile_network_erase_sim">Erase eSIM</string>
|
||||
|
||||
<!-- Title for preferred network type [CHAR LIMIT=NONE] -->
|
||||
<string name="preferred_network_mode_title">Preferred network type</string>
|
||||
@@ -11407,6 +11415,43 @@
|
||||
<string name="mobile_data_usage_title">App data usage</string>
|
||||
<!-- Summary to show the current network mode is invalid. [CHAR LIMIT=NONE]-->
|
||||
<string name="mobile_network_mode_error">Invalid Network Mode <xliff:g id="networkModeId" example="0">%1$d</xliff:g>. Ignore.</string>
|
||||
<!-- Title for _satellite_setting_preference_layout in mobile network settings [CHAR LIMIT=60] -->
|
||||
<string name="satellite_setting_title">Satellite messaging</string>
|
||||
<!-- Summary for _satellite_setting_preference_layout. [CHAR LIMIT=NONE]-->
|
||||
<string name="satellite_setting_enabled_summary">Send and receive text messages by satellite. Included with your account.</string>
|
||||
<!-- Summary for _satellite_setting_preference_layout. [CHAR LIMIT=NONE]-->
|
||||
<string name="satellite_setting_disabled_summary">Send and receive text messages by satellite. Non included with your account.</string>
|
||||
<!-- Search keywords for "_satellite_setting_preference_layout" [CHAR_LIMIT=NONE] -->
|
||||
<string name="keywords_satellite_setting">Satellite messaging</string>
|
||||
<!-- Category name "About satellite messaging" [CHAR_LIMIT=NONE] -->
|
||||
<string name="category_name_about_satellite_messaging">About satellite messaging</string>
|
||||
<!-- Summary for category "About satellite messaging" [CHAR_LIMIT=NONE] -->
|
||||
<string name="title_about_satellite_setting">You can send and receive text messages by satellite as part of an eligible <xliff:g id="carrier_name" example="T-Mobile">%1$s</xliff:g> account</string>
|
||||
<!-- Category title "Your mobile plan" [CHAR_LIMIT=NONE] -->
|
||||
<string name="category_title_your_satellite_plan">Your <xliff:g id="carrier_name" example="T-Mobile">%1$s</xliff:g> plan</string>
|
||||
<!-- Title for category "Your mobile plan when satellite is included in plan" [CHAR_LIMIT=NONE] -->
|
||||
<string name="title_have_satellite_plan">Satellite messaging is included with your account</string>
|
||||
<!-- Title for category "Your mobile plan when satellite is not included in plan" [CHAR_LIMIT=NONE] -->
|
||||
<string name="title_no_satellite_plan">Satellite messaging isn\u2019t included with your account</string>
|
||||
<!-- text view add satellite messaging" [CHAR_LIMIT=NONE] -->
|
||||
<string name="summary_add_satellite_setting">Add satellite messaging</string>
|
||||
<!-- Category name "How it works" [CHAR_LIMIT=NONE] -->
|
||||
<string name="category_name_how_it_works">How it works</string>
|
||||
<!-- Title for satellite connection guide [CHAR_LIMIT=NONE] -->
|
||||
<string name="title_satellite_connection_guide">When you don\u2019t have a mobile network</string>
|
||||
<!-- Summary for satellite connection guide [CHAR_LIMIT=NONE] -->
|
||||
<string name="summary_satellite_connection_guide">Your phone will auto-connect to a satellite. For the best connection, keep a clear view of the sky.</string>
|
||||
<!-- Title for satellite supported service [CHAR_LIMIT=NONE] -->
|
||||
<string name="title_supported_service">After your phone connects to a satellite</string>
|
||||
<!-- Summary for satellite supported service [CHAR_LIMIT=NONE] -->
|
||||
<string name="summary_supported_service">You can text anyone, including emergency services. Your phone will reconnect to a mobile network when available.</string>
|
||||
<!-- learn more text - more about satellite messaging [CHAR_LIMIT=NONE] -->
|
||||
<string name="satellite_setting_summary_more_information">Satellite messaging may take longer and is available only in some areas, Weather and certain structures may affect your satellite connection. Calling by satellite isn\u2019t available.\n\nIt may take some time for changes to your account to show in Settings. Contact <xliff:g id="carrier_name" example="T-Mobile">%1$s</xliff:g> for details.</string>
|
||||
<!-- more about satellite messaging [CHAR_LIMIT=NONE] -->
|
||||
<string name="more_about_satellite_messaging">More about satellite messaging</string>
|
||||
<!-- URL for more info about satellite messaging [CHAR LIMIT=60] -->
|
||||
<string name="more_info_satellite_messaging_link" translatable="false"></string>
|
||||
|
||||
<!-- Title for Apn settings in mobile network settings [CHAR LIMIT=60] -->
|
||||
<string name="mobile_network_apn_title">Access Point Names</string>
|
||||
<!-- Search keywords for "Access Point Names" [CHAR_LIMIT=NONE] -->
|
||||
@@ -11430,11 +11475,11 @@
|
||||
<!-- Title of confirmation dialog asking the user if they want to switch subscription. [CHAR_LIMIT=NONE] -->
|
||||
<string name="sim_action_switch_sub_dialog_mep_title">Use <xliff:g id="carrier_name" example="Google Fi">%1$s</xliff:g>?</string>
|
||||
<!-- Body text of confirmation dialog for switching subscription that involves switching SIM slots. Indicates that only one SIM can be active at a time. Also that switching will not cancel the user's mobile service plan. [CHAR_LIMIT=NONE] -->
|
||||
<string name="sim_action_switch_sub_dialog_text">Only one SIM can be active at a time.\n\nSwitching to <xliff:g id="to_carrier_name" example="Google Fi">%1$s</xliff:g> won\u2019t cancel your <xliff:g id="from_carrier_name" example="Sprint">%2$s</xliff:g> service.</string>
|
||||
<!-- Body text of confirmation dialog for switching subscription between two eSIM profiles. Indicates that only 1 eSIM can be active at a time. Also that switching will not cancel the user's mobile service plan. [CHAR_LIMIT=NONE] -->
|
||||
<string name="sim_action_switch_sub_dialog_text_downloaded">Only 1 eSIM can be active at a time.\n\nSwitching to <xliff:g id="to_carrier_name" example="Google Fi">%1$s</xliff:g> won\u2019t cancel your <xliff:g id="from_carrier_name" example="Sprint">%2$s</xliff:g> service.</string>
|
||||
<string name="sim_action_switch_sub_dialog_text">Only 1 SIM can be on at a time.\n\nSwitching to <xliff:g id="to_carrier_name" example="Google Fi">%1$s</xliff:g> won\u2019t cancel your <xliff:g id="from_carrier_name" example="Sprint">%2$s</xliff:g> service.</string>
|
||||
<!-- Body text of confirmation dialog for switching subscription between two eSIM profiles. Indicates that only 1 eSIM can be on at a time. Also that switching will not cancel the user's mobile service plan. [CHAR_LIMIT=NONE] -->
|
||||
<string name="sim_action_switch_sub_dialog_text_downloaded">Only 1 eSIM can be on at a time.\n\nSwitching to <xliff:g id="to_carrier_name" example="Google Fi">%1$s</xliff:g> won\u2019t cancel your <xliff:g id="from_carrier_name" example="Sprint">%2$s</xliff:g> service.</string>
|
||||
<!-- Body text of confirmation dialog for switching subscription between two eSIM profiles. Indicates that only one SIM can be active at a time. Also that switching will not cancel the user's mobile service plan. [CHAR_LIMIT=NONE] -->
|
||||
<string name="sim_action_switch_sub_dialog_text_single_sim">Only one SIM can be active at a time.\n\nSwitching won\u2019t cancel your <xliff:g id="to_carrier_name" example="Google Fi">%1$s</xliff:g> service.</string>
|
||||
<string name="sim_action_switch_sub_dialog_text_single_sim">Only 1 SIM can be on at a time.\n\nSwitching won\u2019t cancel your <xliff:g id="to_carrier_name" example="Google Fi">%1$s</xliff:g> service.</string>
|
||||
<!-- Body text of confirmation dialog for switching subscription between two eSIM profiles. Indicates that only one downloaded SIM can be active at a time. Also that switching will not cancel the user's mobile service plan. [CHAR_LIMIT=NONE] -->
|
||||
<string name="sim_action_switch_sub_dialog_mep_text">You can use 2 SIMs at a time. To use <xliff:g id="carrier_name" example="Google Fi">%1$s</xliff:g>, turn off another SIM.</string>
|
||||
<!-- Text of confirm button in the confirmation dialog asking the user if they want to switch subscription. [CHAR_LIMIT=NONE] -->
|
||||
@@ -11585,15 +11630,15 @@
|
||||
<!-- Title on confirmation dialog asking the user if they want to erase the eSIM from the device. [CHAR_LIMIT=NONE] -->
|
||||
<string name="erase_sim_dialog_title">Erase this eSIM?</string>
|
||||
<!-- Body text in confirmation dialog indicating what erasing a SIM entails. [CHAR_LIMIT=NONE] -->
|
||||
<string name="erase_sim_dialog_text">Erasing this SIM removes <xliff:g id="carrier_name_a" example="Google Fi">%1$s</xliff:g> service from this device.\n\nService for <xliff:g id="carrier_name_b" example="Google Fi">%1$s</xliff:g> won\'t be canceled.</string>
|
||||
<string name="erase_sim_dialog_text">This removes <xliff:g id="carrier_name_a" example="Google Fi">%1$s</xliff:g> service from this device, but your <xliff:g id="carrier_name_b" example="Google Fi">%1$s</xliff:g> plan won\'t be canceled.</string>
|
||||
<!-- Button label to erase the eSIM [CHAR_LIMIT=20] -->
|
||||
<string name="erase_sim_confirm_button">Erase</string>
|
||||
<!-- Status message indicating the device is in the process of erasing the SIM. [CHAR_LIMIT=NONE] -->
|
||||
<string name="erasing_sim">Erasing SIM…</string>
|
||||
<string name="erasing_sim">Erasing eSIM…</string>
|
||||
<!-- Title of error message indicating the device could not erase the SIM. [CHAR_LIMIT=NONE] -->
|
||||
<string name="erase_sim_fail_title">Can\'t erase SIM</string>
|
||||
<string name="erase_sim_fail_title">Can\'t erase eSIM</string>
|
||||
<!-- Body text of error message indicating the device could not erase the SIM due to an error. [CHAR_LIMIT=NONE] -->
|
||||
<string name="erase_sim_fail_text">This SIM can\'t be erased due to an error.\n\nRestart your device and try again.</string>
|
||||
<string name="erase_sim_fail_text">Something went wrong and this eSIM wasn\'t erased.\n\nRestart your device and try again.</string>
|
||||
|
||||
<!-- Title for Network connection request Dialog [CHAR LIMIT=60] -->
|
||||
<string name="network_connection_request_dialog_title">Connect to device</string>
|
||||
@@ -11998,9 +12043,9 @@
|
||||
<!-- Provider Model: title of eSIMs category. [CHAR LIMIT=50] -->
|
||||
<string name="downloaded_sims_category_title">eSIMs</string>
|
||||
<!-- Provider Model: summary of Active in SIM category. [CHAR LIMIT=50] -->
|
||||
<string name="sim_category_active_sim">Active</string>
|
||||
<string name="sim_category_active_sim">On</string>
|
||||
<!-- Provider Model: summary of Inactive in SIM category. [CHAR LIMIT=50] -->
|
||||
<string name="sim_category_inactive_sim">Inactive</string>
|
||||
<string name="sim_category_inactive_sim">Off</string>
|
||||
<!-- Provider Model: summary of default config. [CHAR LIMIT=50] -->
|
||||
<string name="sim_category_default_active_sim">\u0020/ Default for <xliff:g name="default_sim_config" example=" / Default for calls">%1$s</xliff:g></string>
|
||||
<!-- Provider Model: summary of default call. [CHAR LIMIT=50] -->
|
||||
|
||||
@@ -208,6 +208,7 @@
|
||||
<PreferenceCategory
|
||||
android:key="network_operators_category_key"
|
||||
android:title="@string/network_operator_category"
|
||||
settings:allowDividerBelow="true"
|
||||
settings:controller="com.android.settings.network.telephony.NetworkPreferenceCategoryController">
|
||||
|
||||
<com.android.settings.spa.preference.ComposePreference
|
||||
@@ -221,12 +222,19 @@
|
||||
settings:controller="com.android.settings.network.telephony.gsm.OpenNetworkSelectPagePreferenceController"/>
|
||||
</PreferenceCategory>
|
||||
|
||||
<com.android.settingslib.RestrictedPreference
|
||||
android:key="telephony_satellite_setting_key"
|
||||
android:persistent="false"
|
||||
android:title="@string/satellite_setting_title"
|
||||
settings:keywords="@string/keywords_satellite_setting"
|
||||
settings:controller=
|
||||
"com.android.settings.network.telephony.SatelliteSettingPreferenceController"/>
|
||||
|
||||
<!--We want separate APN setting from reset of settings because we want user to change it with caution-->
|
||||
<com.android.settingslib.RestrictedPreference
|
||||
android:key="telephony_apn_key"
|
||||
android:persistent="false"
|
||||
android:title="@string/mobile_network_apn_title"
|
||||
settings:allowDividerAbove="true"
|
||||
settings:keywords="@string/keywords_access_point_names"
|
||||
settings:controller="com.android.settings.network.telephony.ApnPreferenceController"/>
|
||||
|
||||
@@ -249,7 +257,7 @@
|
||||
android:title="@string/require_cellular_encryption_title"
|
||||
android:summary="@string/require_cellular_encryption_summary"
|
||||
settings:controller=
|
||||
"com.android.settings.network.telephony.NullAlgorithmsPreferenceController" />
|
||||
"com.android.settings.network.telephony.NullAlgorithmsPreferenceController"/>
|
||||
|
||||
<SwitchPreferenceCompat
|
||||
android:key="nr_advanced_calling"
|
||||
|
||||
65
res/xml/satellite_setting.xml
Normal file
65
res/xml/satellite_setting.xml
Normal file
@@ -0,0 +1,65 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- Copyright (C) 2024 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="satellite_setting"
|
||||
android:title="@string/satellite_setting"
|
||||
settings:keywords="@string/keywords_satellite_setting">
|
||||
|
||||
<PreferenceCategory
|
||||
android:title="@string/category_name_about_satellite_messaging">
|
||||
|
||||
<com.android.settingslib.widget.TopIntroPreference
|
||||
android:key="key_about_satellite_messaging"/>
|
||||
</PreferenceCategory>
|
||||
|
||||
<PreferenceCategory
|
||||
android:key="key_category_your_satellite_plan"
|
||||
android:title="@string/category_title_your_satellite_plan">
|
||||
|
||||
<Preference
|
||||
android:key="key_your_satellite_plan"
|
||||
android:icon="?android:attr/textColorPrimary"/>
|
||||
</PreferenceCategory>
|
||||
|
||||
<PreferenceCategory
|
||||
android:key="key_category_how_it_works"
|
||||
android:title="@string/category_name_how_it_works"
|
||||
android:clickable="false"
|
||||
android:focusable="false">
|
||||
|
||||
<Preference
|
||||
android:key="key_satellite_connection_guide"
|
||||
android:title="@string/title_satellite_connection_guide"
|
||||
android:summary="@string/summary_satellite_connection_guide"
|
||||
android:icon="@drawable/ic_signal_cellular_nodata_24px"/>
|
||||
|
||||
<Preference
|
||||
android:key="key_supported_service"
|
||||
android:title="@string/title_supported_service"
|
||||
android:summary="@string/summary_supported_service"
|
||||
android:icon="@drawable/ic_satellite_alt_24px"/>
|
||||
</PreferenceCategory>
|
||||
|
||||
<com.android.settingslib.widget.FooterPreference
|
||||
android:key="satellite_setting_extra_info_footer_pref"
|
||||
android:layout="@layout/satellite_setting_more_information_layout"
|
||||
android:selectable="false"
|
||||
settings:searchable="false"/>
|
||||
|
||||
</PreferenceScreen>
|
||||
@@ -345,6 +345,7 @@ public class Settings extends SettingsActivity {
|
||||
/* empty */
|
||||
}
|
||||
|
||||
public static class SatelliteSettingActivity extends SettingsActivity { /* empty */ }
|
||||
public static class ApnSettingsActivity extends SettingsActivity { /* empty */ }
|
||||
public static class WifiCallingSettingsActivity extends SettingsActivity { /* empty */ }
|
||||
public static class MemorySettingsActivity extends SettingsActivity { /* empty */ }
|
||||
|
||||
@@ -54,7 +54,9 @@ import android.graphics.drawable.AdaptiveIconDrawable;
|
||||
import android.graphics.drawable.BitmapDrawable;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.graphics.drawable.VectorDrawable;
|
||||
import android.hardware.face.Face;
|
||||
import android.hardware.face.FaceManager;
|
||||
import android.hardware.fingerprint.Fingerprint;
|
||||
import android.hardware.fingerprint.FingerprintManager;
|
||||
import android.net.ConnectivityManager;
|
||||
import android.net.LinkAddress;
|
||||
@@ -1333,4 +1335,64 @@ public final class Utils extends com.android.settingslib.Utils {
|
||||
return dreamsSupported && (!dreamsOnlyEnabledForDockUser || canCurrentUserDream(context));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Removes fingerprint templates enrolled for a given user.
|
||||
*
|
||||
* @param context application context.
|
||||
* @param userId the id of the relevant user
|
||||
*/
|
||||
public static void removeEnrolledFingerprintForUser(Context context, int userId) {
|
||||
FingerprintManager fingerprintManager = getFingerprintManagerOrNull(context);
|
||||
if (fingerprintManager != null && fingerprintManager.hasEnrolledTemplates(userId)) {
|
||||
fingerprintManager.removeAll(userId,
|
||||
fingerprintManagerRemovalCallback(userId));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes face templates enrolled for a given user.
|
||||
*
|
||||
* @param context application context.
|
||||
* @param userId the id of the relevant user
|
||||
*/
|
||||
public static void removeEnrolledFaceForUser(Context context, int userId) {
|
||||
FaceManager faceManager = getFaceManagerOrNull(context);
|
||||
if (faceManager != null && faceManager.hasEnrolledTemplates(userId)) {
|
||||
faceManager.removeAll(userId, faceManagerRemovalCallback(userId));
|
||||
}
|
||||
}
|
||||
|
||||
private static FaceManager.RemovalCallback faceManagerRemovalCallback(int userId) {
|
||||
return new FaceManager.RemovalCallback() {
|
||||
@Override
|
||||
public void onRemovalError(@Nullable Face face, int errMsgId, CharSequence err) {
|
||||
Log.e(TAG, "Unable to remove face template for user " + userId + ", error: " + err);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRemovalSucceeded(Face face, int remaining) {
|
||||
if (remaining == 0) {
|
||||
Log.d(TAG, "Enrolled face templates removed for user " + userId);
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
private static FingerprintManager.RemovalCallback fingerprintManagerRemovalCallback(
|
||||
int userId) {
|
||||
return new FingerprintManager.RemovalCallback() {
|
||||
@Override
|
||||
public void onRemovalError(@Nullable Fingerprint fp, int errMsgId, CharSequence err) {
|
||||
Log.e(TAG, "Unable to remove fingerprint for user " + userId + " , error: " + err);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRemovalSucceeded(Fingerprint fp, int remaining) {
|
||||
if (remaining == 0) {
|
||||
Log.d(TAG, "Enrolled fingerprints removed for user " + userId);
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,6 +17,7 @@ package com.android.settings.connecteddevice;
|
||||
|
||||
import android.bluetooth.BluetoothAdapter;
|
||||
import android.bluetooth.BluetoothDevice;
|
||||
import android.bluetooth.BluetoothManager;
|
||||
import android.content.BroadcastReceiver;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
@@ -36,13 +37,16 @@ import com.android.settings.bluetooth.SavedBluetoothDeviceUpdater;
|
||||
import com.android.settings.connecteddevice.dock.DockUpdater;
|
||||
import com.android.settings.core.BasePreferenceController;
|
||||
import com.android.settings.dashboard.DashboardFragment;
|
||||
import com.android.settings.flags.Flags;
|
||||
import com.android.settings.overlay.FeatureFactory;
|
||||
import com.android.settingslib.core.lifecycle.LifecycleObserver;
|
||||
import com.android.settingslib.core.lifecycle.events.OnStart;
|
||||
import com.android.settingslib.core.lifecycle.events.OnStop;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class PreviouslyConnectedDevicePreferenceController extends BasePreferenceController
|
||||
implements LifecycleObserver, OnStart, OnStop, DevicePreferenceCallback {
|
||||
@@ -56,11 +60,12 @@ public class PreviouslyConnectedDevicePreferenceController extends BasePreferenc
|
||||
|
||||
private final List<Preference> mDevicesList = new ArrayList<>();
|
||||
private final List<Preference> mDockDevicesList = new ArrayList<>();
|
||||
private final Map<BluetoothDevice, Preference> mDevicePreferenceMap = new HashMap<>();
|
||||
private final BluetoothAdapter mBluetoothAdapter;
|
||||
|
||||
private PreferenceGroup mPreferenceGroup;
|
||||
private BluetoothDeviceUpdater mBluetoothDeviceUpdater;
|
||||
private DockUpdater mSavedDockUpdater;
|
||||
private BluetoothAdapter mBluetoothAdapter;
|
||||
|
||||
@VisibleForTesting
|
||||
Preference mSeeAllPreference;
|
||||
@@ -81,7 +86,11 @@ public class PreviouslyConnectedDevicePreferenceController extends BasePreferenc
|
||||
mSavedDockUpdater = FeatureFactory.getFeatureFactory().getDockUpdaterFeatureProvider()
|
||||
.getSavedDockUpdater(context, this);
|
||||
mIntentFilter = new IntentFilter(BluetoothAdapter.ACTION_STATE_CHANGED);
|
||||
mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
|
||||
if (Flags.enableSavedDevicesOrderByRecency()) {
|
||||
mBluetoothAdapter = context.getSystemService(BluetoothManager.class).getAdapter();
|
||||
} else {
|
||||
mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -114,6 +123,9 @@ public class PreviouslyConnectedDevicePreferenceController extends BasePreferenc
|
||||
mContext.registerReceiver(mReceiver, mIntentFilter,
|
||||
Context.RECEIVER_EXPORTED_UNAUDITED);
|
||||
mBluetoothDeviceUpdater.refreshPreference();
|
||||
if (Flags.enableSavedDevicesOrderByRecency()) {
|
||||
updatePreferenceGroup();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -131,19 +143,37 @@ public class PreviouslyConnectedDevicePreferenceController extends BasePreferenc
|
||||
|
||||
@Override
|
||||
public void onDeviceAdded(Preference preference) {
|
||||
final List<BluetoothDevice> bluetoothDevices =
|
||||
mBluetoothAdapter.getMostRecentlyConnectedDevices();
|
||||
final int index = preference instanceof BluetoothDevicePreference
|
||||
? bluetoothDevices.indexOf(((BluetoothDevicePreference) preference)
|
||||
.getBluetoothDevice().getDevice()) : DOCK_DEVICE_INDEX;
|
||||
if (DEBUG) {
|
||||
Log.d(TAG, "onDeviceAdded() " + preference.getTitle() + ", index of : " + index);
|
||||
for (BluetoothDevice device : bluetoothDevices) {
|
||||
Log.d(TAG, "onDeviceAdded() most recently device : " + device.getName());
|
||||
if (Flags.enableSavedDevicesOrderByRecency()) {
|
||||
if (preference instanceof BluetoothDevicePreference) {
|
||||
mDevicePreferenceMap.put(
|
||||
((BluetoothDevicePreference) preference).getBluetoothDevice().getDevice(),
|
||||
preference);
|
||||
} else {
|
||||
mDockDevicesList.add(preference);
|
||||
}
|
||||
if (DEBUG) {
|
||||
Log.d(TAG, "onDeviceAdded() " + preference.getTitle());
|
||||
}
|
||||
updatePreferenceGroup();
|
||||
} else {
|
||||
final List<BluetoothDevice> bluetoothDevices =
|
||||
mBluetoothAdapter.getMostRecentlyConnectedDevices();
|
||||
final int index =
|
||||
preference instanceof BluetoothDevicePreference
|
||||
? bluetoothDevices.indexOf(
|
||||
((BluetoothDevicePreference) preference)
|
||||
.getBluetoothDevice()
|
||||
.getDevice())
|
||||
: DOCK_DEVICE_INDEX;
|
||||
if (DEBUG) {
|
||||
Log.d(TAG, "onDeviceAdded() " + preference.getTitle() + ", index of : " + index);
|
||||
for (BluetoothDevice device : bluetoothDevices) {
|
||||
Log.d(TAG, "onDeviceAdded() most recently device : " + device.getName());
|
||||
}
|
||||
}
|
||||
addPreference(index, preference);
|
||||
updatePreferenceVisibility();
|
||||
}
|
||||
addPreference(index, preference);
|
||||
updatePreferenceVisibility();
|
||||
}
|
||||
|
||||
private void addPreference(int index, Preference preference) {
|
||||
@@ -194,13 +224,57 @@ public class PreviouslyConnectedDevicePreferenceController extends BasePreferenc
|
||||
|
||||
@Override
|
||||
public void onDeviceRemoved(Preference preference) {
|
||||
if (preference instanceof BluetoothDevicePreference) {
|
||||
mDevicesList.remove(preference);
|
||||
if (Flags.enableSavedDevicesOrderByRecency()) {
|
||||
if (preference instanceof BluetoothDevicePreference) {
|
||||
mDevicePreferenceMap.remove(
|
||||
((BluetoothDevicePreference) preference).getBluetoothDevice().getDevice(),
|
||||
preference);
|
||||
} else {
|
||||
mDockDevicesList.remove(preference);
|
||||
}
|
||||
if (DEBUG) {
|
||||
Log.d(TAG, "onDeviceRemoved() " + preference.getTitle());
|
||||
}
|
||||
updatePreferenceGroup();
|
||||
} else {
|
||||
mDockDevicesList.remove(preference);
|
||||
}
|
||||
if (preference instanceof BluetoothDevicePreference) {
|
||||
mDevicesList.remove(preference);
|
||||
} else {
|
||||
mDockDevicesList.remove(preference);
|
||||
}
|
||||
|
||||
addPreference();
|
||||
addPreference();
|
||||
updatePreferenceVisibility();
|
||||
}
|
||||
}
|
||||
|
||||
/** Sort the preferenceGroup by most recently used. */
|
||||
public void updatePreferenceGroup() {
|
||||
mPreferenceGroup.removeAll();
|
||||
mPreferenceGroup.addPreference(mSeeAllPreference);
|
||||
if (mBluetoothAdapter != null && mBluetoothAdapter.isEnabled()) {
|
||||
// Bluetooth is supported
|
||||
int order = 0;
|
||||
for (BluetoothDevice device : mBluetoothAdapter.getMostRecentlyConnectedDevices()) {
|
||||
Preference preference = mDevicePreferenceMap.getOrDefault(device, null);
|
||||
if (preference != null) {
|
||||
preference.setOrder(order);
|
||||
mPreferenceGroup.addPreference(preference);
|
||||
order += 1;
|
||||
}
|
||||
if (order == MAX_DEVICE_NUM) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
for (Preference preference : mDockDevicesList) {
|
||||
if (order == MAX_DEVICE_NUM) {
|
||||
break;
|
||||
}
|
||||
preference.setOrder(order);
|
||||
mPreferenceGroup.addPreference(preference);
|
||||
order += 1;
|
||||
}
|
||||
}
|
||||
updatePreferenceVisibility();
|
||||
}
|
||||
|
||||
|
||||
@@ -15,6 +15,9 @@
|
||||
*/
|
||||
package com.android.settings.connecteddevice;
|
||||
|
||||
import android.bluetooth.BluetoothAdapter;
|
||||
import android.bluetooth.BluetoothDevice;
|
||||
import android.bluetooth.BluetoothManager;
|
||||
import android.content.Context;
|
||||
import android.content.pm.PackageManager;
|
||||
|
||||
@@ -23,18 +26,25 @@ import androidx.preference.Preference;
|
||||
import androidx.preference.PreferenceGroup;
|
||||
import androidx.preference.PreferenceScreen;
|
||||
|
||||
import com.android.settings.bluetooth.BluetoothDevicePreference;
|
||||
import com.android.settings.bluetooth.BluetoothDeviceUpdater;
|
||||
import com.android.settings.bluetooth.SavedBluetoothDeviceUpdater;
|
||||
import com.android.settings.connecteddevice.dock.DockUpdater;
|
||||
import com.android.settings.core.BasePreferenceController;
|
||||
import com.android.settings.core.PreferenceControllerMixin;
|
||||
import com.android.settings.dashboard.DashboardFragment;
|
||||
import com.android.settings.flags.Flags;
|
||||
import com.android.settings.overlay.DockUpdaterFeatureProvider;
|
||||
import com.android.settings.overlay.FeatureFactory;
|
||||
import com.android.settingslib.core.lifecycle.LifecycleObserver;
|
||||
import com.android.settingslib.core.lifecycle.events.OnStart;
|
||||
import com.android.settingslib.core.lifecycle.events.OnStop;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Controller to maintain the {@link PreferenceGroup} for all
|
||||
* saved devices. It uses {@link DevicePreferenceCallback} to add/remove {@link Preference}
|
||||
@@ -45,6 +55,10 @@ public class SavedDeviceGroupController extends BasePreferenceController
|
||||
|
||||
private static final String KEY = "saved_device_list";
|
||||
|
||||
private final Map<BluetoothDevice, Preference> mDevicePreferenceMap = new HashMap<>();
|
||||
private final List<Preference> mDockDevicesList = new ArrayList<>();
|
||||
private final BluetoothAdapter mBluetoothAdapter;
|
||||
|
||||
@VisibleForTesting
|
||||
PreferenceGroup mPreferenceGroup;
|
||||
private BluetoothDeviceUpdater mBluetoothDeviceUpdater;
|
||||
@@ -57,6 +71,7 @@ public class SavedDeviceGroupController extends BasePreferenceController
|
||||
FeatureFactory.getFeatureFactory().getDockUpdaterFeatureProvider();
|
||||
mSavedDockUpdater =
|
||||
dockUpdaterFeatureProvider.getSavedDockUpdater(context, this);
|
||||
mBluetoothAdapter = context.getSystemService(BluetoothManager.class).getAdapter();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -64,6 +79,9 @@ public class SavedDeviceGroupController extends BasePreferenceController
|
||||
mBluetoothDeviceUpdater.registerCallback();
|
||||
mSavedDockUpdater.registerCallback();
|
||||
mBluetoothDeviceUpdater.refreshPreference();
|
||||
if (Flags.enableSavedDevicesOrderByRecency()) {
|
||||
updatePreferenceGroup();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -101,17 +119,63 @@ public class SavedDeviceGroupController extends BasePreferenceController
|
||||
|
||||
@Override
|
||||
public void onDeviceAdded(Preference preference) {
|
||||
if (mPreferenceGroup.getPreferenceCount() == 0) {
|
||||
mPreferenceGroup.setVisible(true);
|
||||
if (Flags.enableSavedDevicesOrderByRecency()) {
|
||||
mPreferenceGroup.addPreference(preference);
|
||||
if (preference instanceof BluetoothDevicePreference) {
|
||||
mDevicePreferenceMap.put(
|
||||
((BluetoothDevicePreference) preference).getBluetoothDevice().getDevice(),
|
||||
preference);
|
||||
} else {
|
||||
mDockDevicesList.add(preference);
|
||||
}
|
||||
updatePreferenceGroup();
|
||||
} else {
|
||||
if (mPreferenceGroup.getPreferenceCount() == 0) {
|
||||
mPreferenceGroup.setVisible(true);
|
||||
}
|
||||
mPreferenceGroup.addPreference(preference);
|
||||
}
|
||||
mPreferenceGroup.addPreference(preference);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDeviceRemoved(Preference preference) {
|
||||
mPreferenceGroup.removePreference(preference);
|
||||
if (mPreferenceGroup.getPreferenceCount() == 0) {
|
||||
if (Flags.enableSavedDevicesOrderByRecency()) {
|
||||
mPreferenceGroup.removePreference(preference);
|
||||
if (preference instanceof BluetoothDevicePreference) {
|
||||
mDevicePreferenceMap.remove(
|
||||
((BluetoothDevicePreference) preference).getBluetoothDevice().getDevice(),
|
||||
preference);
|
||||
} else {
|
||||
mDockDevicesList.remove(preference);
|
||||
}
|
||||
updatePreferenceGroup();
|
||||
} else {
|
||||
mPreferenceGroup.removePreference(preference);
|
||||
if (mPreferenceGroup.getPreferenceCount() == 0) {
|
||||
mPreferenceGroup.setVisible(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/** Sort the preferenceGroup by most recently used. */
|
||||
public void updatePreferenceGroup() {
|
||||
if (mBluetoothAdapter == null || !mBluetoothAdapter.isEnabled()) {
|
||||
// Bluetooth is unsupported or disabled
|
||||
mPreferenceGroup.setVisible(false);
|
||||
} else {
|
||||
mPreferenceGroup.setVisible(true);
|
||||
int order = 0;
|
||||
for (BluetoothDevice device : mBluetoothAdapter.getMostRecentlyConnectedDevices()) {
|
||||
Preference preference = mDevicePreferenceMap.getOrDefault(device, null);
|
||||
if (preference != null) {
|
||||
preference.setOrder(order);
|
||||
order += 1;
|
||||
}
|
||||
}
|
||||
for (Preference preference : mDockDevicesList) {
|
||||
preference.setOrder(order);
|
||||
order += 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -130,4 +194,9 @@ public class SavedDeviceGroupController extends BasePreferenceController
|
||||
public void setSavedDockUpdater(DockUpdater savedDockUpdater) {
|
||||
mSavedDockUpdater = savedDockUpdater;
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
void setPreferenceGroup(PreferenceGroup preferenceGroup) {
|
||||
mPreferenceGroup = preferenceGroup;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -144,6 +144,7 @@ import com.android.settings.network.apn.ApnEditor;
|
||||
import com.android.settings.network.apn.ApnSettings;
|
||||
import com.android.settings.network.telephony.MobileNetworkSettings;
|
||||
import com.android.settings.network.telephony.NetworkSelectSettings;
|
||||
import com.android.settings.network.telephony.SatelliteSetting;
|
||||
import com.android.settings.network.tether.TetherSettings;
|
||||
import com.android.settings.nfc.PaymentSettings;
|
||||
import com.android.settings.notification.ConfigureNotificationSettings;
|
||||
@@ -301,6 +302,7 @@ public class SettingsGateway {
|
||||
AppNotificationSettings.class.getName(),
|
||||
NotificationAssistantPicker.class.getName(),
|
||||
ChannelNotificationSettings.class.getName(),
|
||||
SatelliteSetting.class.getName(),
|
||||
ApnSettings.class.getName(),
|
||||
ApnEditor.class.getName(),
|
||||
WifiCallingSettings.class.getName(),
|
||||
|
||||
@@ -28,6 +28,7 @@ import androidx.lifecycle.LifecycleOwner
|
||||
import androidx.preference.PreferenceScreen
|
||||
import com.android.settings.R
|
||||
import com.android.settings.core.BasePreferenceController
|
||||
import com.android.settings.flags.Flags
|
||||
import com.android.settingslib.RestrictedPreference
|
||||
import com.android.settingslib.Utils
|
||||
import com.android.settingslib.spa.framework.util.collectLatestWithLifecycle
|
||||
@@ -62,6 +63,7 @@ open class NetworkProviderCallsSmsController @JvmOverloads constructor(
|
||||
}
|
||||
|
||||
override fun getAvailabilityStatus() = when {
|
||||
Flags.isDualSimOnboardingEnabled() -> UNSUPPORTED_ON_DEVICE
|
||||
!SubscriptionUtil.isSimHardwareVisible(mContext) -> UNSUPPORTED_ON_DEVICE
|
||||
!mContext.userManager.isAdminUser -> DISABLED_FOR_USER
|
||||
else -> AVAILABLE
|
||||
|
||||
@@ -24,6 +24,7 @@ import androidx.annotation.VisibleForTesting;
|
||||
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.dashboard.DashboardFragment;
|
||||
import com.android.settings.flags.Flags;
|
||||
import com.android.settings.network.telephony.CallsDefaultSubscriptionController;
|
||||
import com.android.settings.network.telephony.NetworkProviderWifiCallingPreferenceController;
|
||||
import com.android.settings.network.telephony.SmsDefaultSubscriptionController;
|
||||
@@ -91,8 +92,9 @@ public class NetworkProviderCallsSmsFragment extends DashboardFragment {
|
||||
|
||||
@Override
|
||||
protected boolean isPageSearchEnabled(Context context) {
|
||||
return SubscriptionUtil.isSimHardwareVisible(context) &&
|
||||
context.getSystemService(UserManager.class).isAdminUser();
|
||||
return !Flags.isDualSimOnboardingEnabled()
|
||||
&& SubscriptionUtil.isSimHardwareVisible(context)
|
||||
&& context.getSystemService(UserManager.class).isAdminUser();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@@ -51,23 +51,24 @@ class WepNetworkDialogActivity : SpaBaseDialogActivity() {
|
||||
confirmButton = AlertDialogButton(
|
||||
getString(R.string.wifi_settings_ssid_block_button_close)
|
||||
) { finish() },
|
||||
dismissButton = AlertDialogButton(
|
||||
getString(R.string.wifi_settings_wep_networks_button_allow)
|
||||
) {
|
||||
SubSettingLauncher(context)
|
||||
.setTitleText(context.getText(R.string.network_and_internet_preferences_title))
|
||||
.setSourceMetricsCategory(SettingsEnums.CONFIGURE_WIFI)
|
||||
.setDestination(ConfigureWifiSettings::class.java.getName())
|
||||
.launch()
|
||||
finish()
|
||||
},
|
||||
dismissButton = if (wifiManager?.isWepSupported == true)
|
||||
AlertDialogButton(
|
||||
getString(R.string.wifi_settings_wep_networks_button_allow)
|
||||
) {
|
||||
SubSettingLauncher(context)
|
||||
.setTitleText(context.getText(R.string.network_and_internet_preferences_title))
|
||||
.setSourceMetricsCategory(SettingsEnums.CONFIGURE_WIFI)
|
||||
.setDestination(ConfigureWifiSettings::class.java.getName())
|
||||
.launch()
|
||||
finish()
|
||||
} else null,
|
||||
title = String.format(
|
||||
getString(R.string.wifi_settings_wep_networks_blocked_title),
|
||||
intent.getStringExtra(SSID) ?: SSID
|
||||
),
|
||||
text = {
|
||||
Text(
|
||||
if (wifiManager?.isWepSupported == false)
|
||||
if (wifiManager?.isWepSupported == true)
|
||||
getString(R.string.wifi_settings_wep_networks_summary_toggle_off)
|
||||
else getString(R.string.wifi_settings_wep_networks_summary_blocked_by_carrier),
|
||||
modifier = Modifier.fillMaxWidth(),
|
||||
|
||||
@@ -255,6 +255,11 @@ public class MobileNetworkSettings extends AbstractMobileNetworkSettings impleme
|
||||
roamingPreferenceController.init(getFragmentManager(), mSubId,
|
||||
mMobileNetworkInfoEntity);
|
||||
}
|
||||
final SatelliteSettingPreferenceController satelliteSettingPreferenceController = use(
|
||||
SatelliteSettingPreferenceController.class);
|
||||
if (satelliteSettingPreferenceController != null) {
|
||||
satelliteSettingPreferenceController.init(mSubId);
|
||||
}
|
||||
use(ApnPreferenceController.class).init(mSubId);
|
||||
use(CarrierPreferenceController.class).init(mSubId);
|
||||
use(DataUsagePreferenceController.class).init(mSubId);
|
||||
|
||||
@@ -358,7 +358,8 @@ public class MobileNetworkUtils {
|
||||
.createForSubscriptionId(subId);
|
||||
final SubscriptionManager subscriptionManager = context.getSystemService(
|
||||
SubscriptionManager.class).createForAllUserProfiles();
|
||||
telephonyManager.setDataEnabled(enabled);
|
||||
telephonyManager.setDataEnabledForReason(TelephonyManager.DATA_ENABLED_REASON_USER,
|
||||
enabled);
|
||||
|
||||
if (disableOtherSubscriptions) {
|
||||
final List<SubscriptionInfo> subInfoList =
|
||||
@@ -367,8 +368,10 @@ public class MobileNetworkUtils {
|
||||
for (SubscriptionInfo subInfo : subInfoList) {
|
||||
// We never disable mobile data for opportunistic subscriptions.
|
||||
if (subInfo.getSubscriptionId() != subId && !subInfo.isOpportunistic()) {
|
||||
context.getSystemService(TelephonyManager.class).createForSubscriptionId(
|
||||
subInfo.getSubscriptionId()).setDataEnabled(false);
|
||||
context.getSystemService(TelephonyManager.class)
|
||||
.createForSubscriptionId(subInfo.getSubscriptionId())
|
||||
.setDataEnabledForReason(TelephonyManager.DATA_ENABLED_REASON_USER,
|
||||
false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
198
src/com/android/settings/network/telephony/SatelliteSetting.java
Normal file
198
src/com/android/settings/network/telephony/SatelliteSetting.java
Normal file
@@ -0,0 +1,198 @@
|
||||
/*
|
||||
* Copyright (C) 2024 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.android.settings.network.telephony;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.settings.SettingsEnums;
|
||||
import android.content.Intent;
|
||||
import android.graphics.Typeface;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.os.UserManager;
|
||||
import android.telephony.SubscriptionManager;
|
||||
import android.telephony.TelephonyManager;
|
||||
import android.telephony.satellite.SatelliteManager;
|
||||
import android.text.SpannableString;
|
||||
import android.text.Spanned;
|
||||
import android.text.style.StyleSpan;
|
||||
import android.text.style.UnderlineSpan;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.preference.Preference;
|
||||
import androidx.preference.PreferenceCategory;
|
||||
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.dashboard.RestrictedDashboardFragment;
|
||||
import com.android.settingslib.HelpUtils;
|
||||
import com.android.settingslib.Utils;
|
||||
import com.android.settingslib.widget.FooterPreference;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
/** Handle Satellite Setting Preference Layout. */
|
||||
public class SatelliteSetting extends RestrictedDashboardFragment {
|
||||
private static final String TAG = "SatelliteSetting";
|
||||
public static final String PREF_KEY_ABOUT_SATELLITE_MESSAGING = "key_about_satellite_messaging";
|
||||
public static final String PREF_KEY_CATEGORY_YOUR_SATELLITE_PLAN =
|
||||
"key_category_your_satellite_plan";
|
||||
public static final String PREF_KEY_YOUR_SATELLITE_PLAN = "key_your_satellite_plan";
|
||||
public static final String PREF_KEY_CATEGORY_HOW_IT_WORKS = "key_category_how_it_works";
|
||||
private static final String KEY_FOOTER_PREFERENCE = "satellite_setting_extra_info_footer_pref";
|
||||
public static final String SUB_ID = "sub_id";
|
||||
|
||||
private Activity mActivity;
|
||||
private TelephonyManager mTelephonymanager;
|
||||
private SatelliteManager mSatelliteManager;
|
||||
private int mSubId;
|
||||
|
||||
public SatelliteSetting() {
|
||||
super(UserManager.DISALLOW_CONFIG_MOBILE_NETWORKS);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMetricsCategory() {
|
||||
return SettingsEnums.SATELLITE_SETTING;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreate(@NonNull Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
mActivity = getActivity();
|
||||
mTelephonymanager = mActivity.getSystemService(TelephonyManager.class);
|
||||
mSatelliteManager = mActivity.getSystemService(SatelliteManager.class);
|
||||
mSubId = mActivity.getIntent().getIntExtra(SUB_ID,
|
||||
SubscriptionManager.INVALID_SUBSCRIPTION_ID);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
|
||||
super.onViewCreated(view, savedInstanceState);
|
||||
updateDynamicPreferenceViews();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getLogTag() {
|
||||
return TAG;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getPreferenceScreenResId() {
|
||||
return R.xml.satellite_setting;
|
||||
}
|
||||
|
||||
private void updateDynamicPreferenceViews() {
|
||||
String operatorName = mTelephonymanager.getSimOperatorName(mSubId);
|
||||
boolean isSatelliteEligible = isSatelliteEligible();
|
||||
|
||||
// About satellite messaging
|
||||
Preference preference = findPreference(PREF_KEY_ABOUT_SATELLITE_MESSAGING);
|
||||
preference.setTitle(
|
||||
getResources().getString(R.string.title_about_satellite_setting, operatorName));
|
||||
|
||||
// Your mobile plan
|
||||
PreferenceCategory prefCategory = findPreference(PREF_KEY_CATEGORY_YOUR_SATELLITE_PLAN);
|
||||
prefCategory.setTitle(getResources().getString(R.string.category_title_your_satellite_plan,
|
||||
operatorName));
|
||||
|
||||
preference = findPreference(PREF_KEY_YOUR_SATELLITE_PLAN);
|
||||
Drawable icon;
|
||||
if (isSatelliteEligible) {
|
||||
/* In case satellite is allowed by carrier's entitlement server, the page will show
|
||||
the check icon with guidance that satellite is included in user's mobile plan */
|
||||
preference.setTitle(R.string.title_have_satellite_plan);
|
||||
icon = getResources().getDrawable(R.drawable.ic_check_circle_24px);
|
||||
} else {
|
||||
/* Or, it will show the blocked icon with the guidance that satellite is not included
|
||||
in user's mobile plan */
|
||||
preference.setTitle(R.string.title_no_satellite_plan);
|
||||
/* And, the link url provides more information via web page will be shown */
|
||||
SpannableString spannable = new SpannableString(
|
||||
getResources().getString(R.string.summary_add_satellite_setting));
|
||||
spannable.setSpan(new UnderlineSpan(), 0, spannable.length(),
|
||||
Spanned.SPAN_INCLUSIVE_INCLUSIVE);
|
||||
spannable.setSpan(new StyleSpan(Typeface.BOLD), 0, spannable.length(),
|
||||
Spanned.SPAN_INCLUSIVE_INCLUSIVE);
|
||||
preference.setSummary(spannable);
|
||||
/* The link will lead users to a guide page */
|
||||
preference.setOnPreferenceClickListener(pref -> {
|
||||
String url = getResources().getString(R.string.more_info_satellite_messaging_link);
|
||||
if (!url.isEmpty()) {
|
||||
Uri uri = Uri.parse(url);
|
||||
Intent intent = new Intent(Intent.ACTION_VIEW, uri);
|
||||
startActivity(intent);
|
||||
}
|
||||
return true;
|
||||
});
|
||||
icon = getResources().getDrawable(R.drawable.ic_block_24px);
|
||||
}
|
||||
icon.setTintList(Utils.getColorAttr(getContext(), android.R.attr.textColorPrimary));
|
||||
preference.setIcon(icon);
|
||||
|
||||
/* Composes "How it works" section, which guides how users can use satellite messaging, when
|
||||
satellite messaging is included in user's mobile plan, or it'll will be grey out. */
|
||||
if (!isSatelliteEligible) {
|
||||
PreferenceCategory category = findPreference(PREF_KEY_CATEGORY_HOW_IT_WORKS);
|
||||
category.setEnabled(false);
|
||||
category.setShouldDisableView(true);
|
||||
}
|
||||
|
||||
// More about satellite messaging
|
||||
FooterPreference footerPreference = findPreference(KEY_FOOTER_PREFERENCE);
|
||||
if (footerPreference != null) {
|
||||
footerPreference.setSummary(
|
||||
getResources().getString(R.string.satellite_setting_summary_more_information,
|
||||
operatorName));
|
||||
|
||||
final String[] link = new String[1];
|
||||
link[0] = getResources().getString(R.string.more_info_satellite_messaging_link);
|
||||
footerPreference.setLearnMoreAction(view -> {
|
||||
if (!link[0].isEmpty()) {
|
||||
Intent helpIntent = HelpUtils.getHelpIntent(mActivity, link[0],
|
||||
this.getClass().getName());
|
||||
if (helpIntent != null) {
|
||||
mActivity.startActivityForResult(helpIntent, /*requestCode=*/ 0);
|
||||
}
|
||||
}
|
||||
});
|
||||
footerPreference.setLearnMoreText(
|
||||
getResources().getString(R.string.more_about_satellite_messaging));
|
||||
|
||||
// TODO : b/320467418 add rounded rectangle border line to footer preference.
|
||||
}
|
||||
}
|
||||
|
||||
private boolean isSatelliteEligible() {
|
||||
try {
|
||||
Set<Integer> restrictionReason =
|
||||
mSatelliteManager.getSatelliteAttachRestrictionReasonsForCarrier(mSubId);
|
||||
return !restrictionReason.contains(
|
||||
SatelliteManager.SATELLITE_COMMUNICATION_RESTRICTION_REASON_ENTITLEMENT);
|
||||
} catch (SecurityException | IllegalStateException | IllegalArgumentException ex) {
|
||||
loge(ex.toString());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private static void loge(String message) {
|
||||
Log.e(TAG, message);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,139 @@
|
||||
/*
|
||||
* Copyright (C) 2024 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.android.settings.network.telephony;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.os.PersistableBundle;
|
||||
import android.provider.Settings;
|
||||
import android.telephony.CarrierConfigManager;
|
||||
import android.telephony.satellite.SatelliteManager;
|
||||
import android.util.Log;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.preference.Preference;
|
||||
import androidx.preference.PreferenceScreen;
|
||||
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.SettingsActivity;
|
||||
import com.android.settings.network.CarrierConfigCache;
|
||||
import com.android.settingslib.core.lifecycle.LifecycleObserver;
|
||||
import com.android.settingslib.core.lifecycle.events.OnStart;
|
||||
import com.android.settingslib.core.lifecycle.events.OnStop;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* Preference controller for "Satellite Setting"
|
||||
*/
|
||||
public class SatelliteSettingPreferenceController extends
|
||||
TelephonyBasePreferenceController implements LifecycleObserver, OnStart, OnStop {
|
||||
|
||||
private static final String TAG = "SatelliteSettingPreferenceController";
|
||||
|
||||
CarrierConfigCache mCarrierConfigCache;
|
||||
SatelliteManager mSatelliteManager;
|
||||
@Nullable private Boolean mIsSatelliteEligible = null;
|
||||
|
||||
public SatelliteSettingPreferenceController(@NonNull Context context, @NonNull String key) {
|
||||
super(context, key);
|
||||
mCarrierConfigCache = CarrierConfigCache.getInstance(context);
|
||||
mSatelliteManager = context.getSystemService(SatelliteManager.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getAvailabilityStatus(int subId) {
|
||||
final PersistableBundle carrierConfig = mCarrierConfigCache.getConfigForSubId(subId);
|
||||
final boolean isSatelliteAttachSupported = carrierConfig.getBoolean(
|
||||
CarrierConfigManager.KEY_SATELLITE_ATTACH_SUPPORTED_BOOL);
|
||||
|
||||
return isSatelliteAttachSupported ? AVAILABLE : CONDITIONALLY_UNAVAILABLE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStart() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStop() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void displayPreference(@NonNull PreferenceScreen screen) {
|
||||
super.displayPreference(screen);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateState(@Nullable Preference preference) {
|
||||
super.updateState(preference);
|
||||
if (preference != null) {
|
||||
updateSummary(preference);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean handlePreferenceTreeClick(@NonNull Preference preference) {
|
||||
if (getPreferenceKey().equals(preference.getKey())) {
|
||||
// This activity runs in phone process, we must use intent to start
|
||||
final Intent intent = new Intent(Settings.ACTION_SATELLITE_SETTING);
|
||||
// This will setup the Home and Search affordance
|
||||
intent.putExtra(SettingsActivity.EXTRA_SHOW_FRAGMENT_AS_SUBSETTING, true);
|
||||
intent.putExtra(SatelliteSetting.SUB_ID, mSubId);
|
||||
mContext.startActivity(intent);
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set subId for Satellite Settings page.
|
||||
* @param subId subscription ID.
|
||||
*/
|
||||
public void init(int subId) {
|
||||
logd("init(), subId=" + subId);
|
||||
mSubId = subId;
|
||||
}
|
||||
|
||||
private void updateSummary(Preference preference) {
|
||||
try {
|
||||
Set<Integer> restrictionReason =
|
||||
mSatelliteManager.getSatelliteAttachRestrictionReasonsForCarrier(mSubId);
|
||||
boolean isSatelliteEligible = !restrictionReason.contains(
|
||||
SatelliteManager.SATELLITE_COMMUNICATION_RESTRICTION_REASON_ENTITLEMENT);
|
||||
if (mIsSatelliteEligible == null || mIsSatelliteEligible != isSatelliteEligible) {
|
||||
mIsSatelliteEligible = isSatelliteEligible;
|
||||
String summary = mContext.getString(
|
||||
mIsSatelliteEligible ? R.string.satellite_setting_enabled_summary
|
||||
: R.string.satellite_setting_disabled_summary);
|
||||
preference.setSummary(summary);
|
||||
}
|
||||
} catch (SecurityException | IllegalStateException | IllegalArgumentException ex) {
|
||||
loge(ex.toString());
|
||||
preference.setSummary(R.string.satellite_setting_disabled_summary);
|
||||
}
|
||||
}
|
||||
|
||||
private static void logd(String message) {
|
||||
Log.d(TAG, message);
|
||||
}
|
||||
|
||||
private static void loge(String message) {
|
||||
Log.e(TAG, message);
|
||||
}
|
||||
}
|
||||
@@ -31,6 +31,7 @@ import android.view.ViewGroup;
|
||||
|
||||
import androidx.activity.OnBackPressedCallback;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.navigation.fragment.NavHostFragment;
|
||||
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.core.InstrumentedFragment;
|
||||
@@ -55,11 +56,20 @@ public class PrivateSpaceAccountLoginError extends InstrumentedFragment {
|
||||
final FooterBarMixin mixin = rootView.getMixin(FooterBarMixin.class);
|
||||
mixin.setPrimaryButton(
|
||||
new FooterButton.Builder(getContext())
|
||||
.setText(R.string.private_space_tryagain_label)
|
||||
.setText(R.string.private_space_continue_login_label)
|
||||
.setListener(nextScreen())
|
||||
.setButtonType(FooterButton.ButtonType.NEXT)
|
||||
.setTheme(com.google.android.setupdesign.R.style.SudGlifButton_Primary)
|
||||
.build());
|
||||
mixin.setSecondaryButton(
|
||||
new FooterButton.Builder(getContext())
|
||||
.setText(R.string.private_space_skip_login_label)
|
||||
.setListener(onSkip())
|
||||
.setButtonType(FooterButton.ButtonType.CANCEL)
|
||||
.setTheme(
|
||||
androidx.appcompat.R.style
|
||||
.Base_TextAppearance_AppCompat_Widget_Button)
|
||||
.build());
|
||||
OnBackPressedCallback callback =
|
||||
new OnBackPressedCallback(true /* enabled by default */) {
|
||||
@Override
|
||||
@@ -96,4 +106,17 @@ public class PrivateSpaceAccountLoginError extends InstrumentedFragment {
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
private View.OnClickListener onSkip() {
|
||||
return v -> {
|
||||
mMetricsFeatureProvider.action(
|
||||
getContext(), SettingsEnums.ACTION_PRIVATE_SPACE_SETUP_SKIP_ACCOUNT_LOGIN);
|
||||
mMetricsFeatureProvider.action(
|
||||
getContext(),
|
||||
SettingsEnums.ACTION_PRIVATE_SPACE_SETUP_ACCOUNT_LOGIN_SUCCESS,
|
||||
false);
|
||||
NavHostFragment.findNavController(PrivateSpaceAccountLoginError.this)
|
||||
.navigate(R.id.action_success_fragment);
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,6 +23,7 @@ import android.util.Log;
|
||||
import androidx.preference.Preference;
|
||||
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.Utils;
|
||||
import com.android.settings.biometrics.combination.CombinedBiometricStatusPreferenceController;
|
||||
import com.android.settings.privatespace.PrivateSpaceMaintainer;
|
||||
import com.android.settingslib.core.lifecycle.Lifecycle;
|
||||
@@ -72,6 +73,8 @@ public class FaceFingerprintUnlockController extends CombinedBiometricStatusPref
|
||||
super.updateState(preference);
|
||||
preference.setEnabled(true);
|
||||
} else {
|
||||
Utils.removeEnrolledFaceForUser(mContext, getUserId());
|
||||
Utils.removeEnrolledFingerprintForUser(mContext, getUserId());
|
||||
preference.setSummary(
|
||||
mContext.getString(R.string.lock_settings_profile_unified_summary));
|
||||
preference.setEnabled(false);
|
||||
|
||||
@@ -74,6 +74,7 @@ public class PrivateSpaceFacePreferenceController extends BiometricFaceStatusPre
|
||||
super.updateState(preference);
|
||||
preference.setEnabled(true);
|
||||
} else {
|
||||
Utils.removeEnrolledFaceForUser(mContext, getUserId());
|
||||
preference.setSummary(
|
||||
mContext.getString(R.string.lock_settings_profile_unified_summary));
|
||||
preference.setEnabled(false);
|
||||
|
||||
@@ -76,6 +76,7 @@ public class PrivateSpaceFingerprintPreferenceController
|
||||
super.updateState(preference);
|
||||
preference.setEnabled(true);
|
||||
} else {
|
||||
Utils.removeEnrolledFingerprintForUser(mContext, getUserId());
|
||||
preference.setSummary(
|
||||
mContext.getString(R.string.lock_settings_profile_unified_summary));
|
||||
preference.setEnabled(false);
|
||||
|
||||
@@ -44,8 +44,9 @@ public class SimLockPreferenceController extends BasePreferenceController {
|
||||
mUserManager = (UserManager) context.getSystemService(Context.USER_SERVICE);
|
||||
mCarrierConfigManager = (CarrierConfigManager)
|
||||
mContext.getSystemService(Context.CARRIER_CONFIG_SERVICE);
|
||||
mSubscriptionManager = (SubscriptionManager) context
|
||||
.getSystemService(Context.TELEPHONY_SUBSCRIPTION_SERVICE);
|
||||
mSubscriptionManager = ((SubscriptionManager) context
|
||||
.getSystemService(Context.TELEPHONY_SUBSCRIPTION_SERVICE))
|
||||
.createForAllUserProfiles();
|
||||
mTelephonyManager = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
|
||||
}
|
||||
|
||||
|
||||
@@ -195,7 +195,7 @@ public class EnableAutoDataSwitchDialogFragment extends SimDialogFragment implem
|
||||
}
|
||||
|
||||
private SubscriptionManager getSubscriptionManager() {
|
||||
return getContext().getSystemService(SubscriptionManager.class);
|
||||
return getContext().getSystemService(SubscriptionManager.class).createForAllUserProfiles();
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
|
||||
@@ -194,7 +194,7 @@ public class SelectSpecificDataSimDialogFragment extends SimDialogFragment imple
|
||||
|
||||
@VisibleForTesting
|
||||
protected SubscriptionManager getSubscriptionManager() {
|
||||
return getContext().getSystemService(SubscriptionManager.class);
|
||||
return getContext().getSystemService(SubscriptionManager.class).createForAllUserProfiles();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -125,7 +125,7 @@ public class SimListDialogFragment extends SimDialogFragment {
|
||||
|
||||
protected List<SubscriptionInfo> getCurrentSubscriptions() {
|
||||
final SubscriptionManager manager = getContext().getSystemService(
|
||||
SubscriptionManager.class);
|
||||
SubscriptionManager.class).createForAllUserProfiles();
|
||||
return manager.getActiveSubscriptionInfoList();
|
||||
}
|
||||
|
||||
|
||||
@@ -35,6 +35,7 @@ import android.graphics.BitmapFactory;
|
||||
import android.graphics.BlendMode;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.graphics.drawable.LayerDrawable;
|
||||
import android.multiuser.Flags;
|
||||
import android.net.Uri;
|
||||
import android.os.AsyncTask;
|
||||
import android.os.Bundle;
|
||||
@@ -892,13 +893,24 @@ public class UserSettings extends SettingsPreferenceFragment
|
||||
UserIcons.convertToBitmapAtUserIconSize(
|
||||
activity.getResources(), newUserIcon)));
|
||||
mMePreference.setIcon(newUserIcon);
|
||||
if (Flags.avatarSync()) {
|
||||
final String pkg = getString(R.string.config_avatar_picker_package);
|
||||
final String action = pkg + ".set.confirm";
|
||||
activity.sendBroadcast(new Intent(action).setPackage(pkg));
|
||||
}
|
||||
}
|
||||
|
||||
if (!TextUtils.isEmpty(newUserName) && !newUserName.equals(user.name)) {
|
||||
mMePreference.setTitle(newUserName);
|
||||
mUserManager.setUserName(user.id, newUserName);
|
||||
}
|
||||
}, null);
|
||||
}, () -> {
|
||||
if (Flags.avatarSync()) {
|
||||
final String pkg = getString(R.string.config_avatar_picker_package);
|
||||
final String action = pkg + ".set.cancel";
|
||||
activity.sendBroadcast(new Intent(action).setPackage(pkg));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private Dialog buildAddUserDialog(int userType) {
|
||||
|
||||
@@ -23,6 +23,7 @@ import static org.mockito.Mockito.doReturn;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.spy;
|
||||
|
||||
import android.accounts.AccountManager;
|
||||
import android.accounts.AuthenticatorDescription;
|
||||
import android.app.Activity;
|
||||
import android.app.admin.DevicePolicyManager;
|
||||
@@ -35,6 +36,7 @@ import androidx.fragment.app.FragmentActivity;
|
||||
import androidx.preference.Preference;
|
||||
import androidx.preference.PreferenceManager;
|
||||
import androidx.preference.PreferenceScreen;
|
||||
import androidx.test.core.app.ApplicationProvider;
|
||||
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.core.BasePreferenceController;
|
||||
@@ -44,33 +46,38 @@ import com.android.settings.testutils.shadow.ShadowRestrictedLockUtilsInternal;
|
||||
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.MockitoAnnotations;
|
||||
import org.mockito.junit.MockitoJUnit;
|
||||
import org.mockito.junit.MockitoRule;
|
||||
import org.robolectric.Robolectric;
|
||||
import org.robolectric.RobolectricTestRunner;
|
||||
import org.robolectric.RuntimeEnvironment;
|
||||
import org.robolectric.Shadows;
|
||||
import org.robolectric.annotation.Config;
|
||||
|
||||
@RunWith(RobolectricTestRunner.class)
|
||||
@Config(shadows = {ShadowAccountManager.class, ShadowContentResolver.class,
|
||||
ShadowRestrictedLockUtilsInternal.class})
|
||||
public class ChooseAccountPreferenceControllerTest {
|
||||
@Rule
|
||||
public final MockitoRule mMockitoRule = MockitoJUnit.rule();
|
||||
|
||||
private Context mContext;
|
||||
private ChooseAccountPreferenceController mController;
|
||||
private Activity mActivity;
|
||||
private PreferenceManager mPreferenceManager;
|
||||
private PreferenceScreen mPreferenceScreen;
|
||||
private ShadowAccountManager mAccountManager;
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
MockitoAnnotations.initMocks(this);
|
||||
mContext = RuntimeEnvironment.application;
|
||||
mContext = ApplicationProvider.getApplicationContext();
|
||||
mController = spy(new ChooseAccountPreferenceController(mContext, "controller_key"));
|
||||
mActivity = Robolectric.setupActivity(FragmentActivity.class);
|
||||
mPreferenceManager = new PreferenceManager(mContext);
|
||||
mPreferenceScreen = mPreferenceManager.createPreferenceScreen(mContext);
|
||||
mAccountManager = (ShadowAccountManager) Shadows.shadowOf(AccountManager.get(mContext));
|
||||
}
|
||||
|
||||
@After
|
||||
@@ -108,7 +115,7 @@ public class ChooseAccountPreferenceControllerTest {
|
||||
final AuthenticatorDescription authDesc = new AuthenticatorDescription("com.acct1",
|
||||
"com.android.settings",
|
||||
R.string.header_add_an_account, 0, 0, 0, false);
|
||||
ShadowAccountManager.addAuthenticator(authDesc);
|
||||
mAccountManager.addAuthenticator(authDesc);
|
||||
|
||||
final SyncAdapterType[] syncAdapters = {new SyncAdapterType("authority" /* authority */,
|
||||
"com.acct1" /* accountType */, false /* userVisible */,
|
||||
@@ -133,7 +140,7 @@ public class ChooseAccountPreferenceControllerTest {
|
||||
final AuthenticatorDescription authDesc = new AuthenticatorDescription("com.acct1",
|
||||
"com.android.settings",
|
||||
R.string.header_add_an_account, 0, 0, 0, false);
|
||||
ShadowAccountManager.addAuthenticator(authDesc);
|
||||
mAccountManager.addAuthenticator(authDesc);
|
||||
|
||||
final SyncAdapterType[] syncAdapters = {new SyncAdapterType("authority" /* authority */,
|
||||
"com.acct1" /* accountType */, false /* userVisible */,
|
||||
@@ -158,7 +165,7 @@ public class ChooseAccountPreferenceControllerTest {
|
||||
final AuthenticatorDescription authDesc = new AuthenticatorDescription("com.acct1",
|
||||
"com.android.settings",
|
||||
R.string.header_add_an_account, 0, 0, 0, false);
|
||||
ShadowAccountManager.addAuthenticator(authDesc);
|
||||
mAccountManager.addAuthenticator(authDesc);
|
||||
|
||||
final SyncAdapterType[] syncAdapters = {new SyncAdapterType("authority" /* authority */,
|
||||
"com.acct1" /* accountType */, false /* userVisible */,
|
||||
@@ -184,8 +191,8 @@ public class ChooseAccountPreferenceControllerTest {
|
||||
final AuthenticatorDescription authDesc2 = new AuthenticatorDescription("com.acct2",
|
||||
"com.android.settings",
|
||||
R.string.header_add_an_account, 0, 0, 0, false);
|
||||
ShadowAccountManager.addAuthenticator(authDesc);
|
||||
ShadowAccountManager.addAuthenticator(authDesc2);
|
||||
mAccountManager.addAuthenticator(authDesc);
|
||||
mAccountManager.addAuthenticator(authDesc2);
|
||||
|
||||
final SyncAdapterType[] syncAdapters = {new SyncAdapterType("authority" /* authority */,
|
||||
"com.acct1" /* accountType */, false /* userVisible */,
|
||||
|
||||
@@ -27,9 +27,14 @@ import static org.mockito.Mockito.when;
|
||||
|
||||
import android.bluetooth.BluetoothAdapter;
|
||||
import android.bluetooth.BluetoothDevice;
|
||||
import android.bluetooth.BluetoothManager;
|
||||
import android.content.Context;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.platform.test.annotations.RequiresFlagsDisabled;
|
||||
import android.platform.test.annotations.RequiresFlagsEnabled;
|
||||
import android.platform.test.flag.junit.CheckFlagsRule;
|
||||
import android.platform.test.flag.junit.DeviceFlagsValueProvider;
|
||||
import android.util.Pair;
|
||||
|
||||
import androidx.preference.Preference;
|
||||
@@ -42,11 +47,13 @@ import com.android.settings.bluetooth.BluetoothDevicePreference;
|
||||
import com.android.settings.bluetooth.BluetoothDeviceUpdater;
|
||||
import com.android.settings.connecteddevice.dock.DockUpdater;
|
||||
import com.android.settings.dashboard.DashboardFragment;
|
||||
import com.android.settings.flags.Flags;
|
||||
import com.android.settings.testutils.shadow.ShadowBluetoothAdapter;
|
||||
import com.android.settings.widget.SingleTargetGearPreference;
|
||||
import com.android.settingslib.bluetooth.CachedBluetoothDevice;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.Mock;
|
||||
@@ -70,6 +77,9 @@ public class PreviouslyConnectedDevicePreferenceControllerTest {
|
||||
private static final String FAKE_ADDRESS_4 = "AA:AA:AA:AA:AA:04";
|
||||
private static final String FAKE_ADDRESS_5 = "AA:AA:AA:AA:AA:05";
|
||||
|
||||
@Rule
|
||||
public final CheckFlagsRule mCheckFlagsRule = DeviceFlagsValueProvider.createCheckFlagsRule();
|
||||
|
||||
@Mock
|
||||
private DashboardFragment mDashboardFragment;
|
||||
@Mock
|
||||
@@ -105,6 +115,9 @@ public class PreviouslyConnectedDevicePreferenceControllerTest {
|
||||
@Mock
|
||||
private Drawable mDrawable;
|
||||
|
||||
@Mock private BluetoothManager mBluetoothManager;
|
||||
@Mock private BluetoothAdapter mBluetoothAdapter;
|
||||
|
||||
private Context mContext;
|
||||
private PreviouslyConnectedDevicePreferenceController mPreConnectedDeviceController;
|
||||
private PreferenceGroup mPreferenceGroup;
|
||||
@@ -117,10 +130,8 @@ public class PreviouslyConnectedDevicePreferenceControllerTest {
|
||||
mContext = spy(RuntimeEnvironment.application);
|
||||
doReturn(mContext).when(mDashboardFragment).getContext();
|
||||
doReturn(mPackageManager).when(mContext).getPackageManager();
|
||||
mPreConnectedDeviceController =
|
||||
new PreviouslyConnectedDevicePreferenceController(mContext, KEY);
|
||||
mPreConnectedDeviceController.setBluetoothDeviceUpdater(mBluetoothDeviceUpdater);
|
||||
mPreConnectedDeviceController.setSavedDockUpdater(mDockUpdater);
|
||||
when(mContext.getSystemService(BluetoothManager.class)).thenReturn(mBluetoothManager);
|
||||
when(mBluetoothManager.getAdapter()).thenReturn(mBluetoothAdapter);
|
||||
mShadowBluetoothAdapter = Shadow.extract(BluetoothAdapter.getDefaultAdapter());
|
||||
|
||||
when(mCachedDevice1.getDevice()).thenReturn(mBluetoothDevice1);
|
||||
@@ -145,7 +156,13 @@ public class PreviouslyConnectedDevicePreferenceControllerTest {
|
||||
mMostRecentlyConnectedDevices.add(mBluetoothDevice4);
|
||||
mMostRecentlyConnectedDevices.add(mBluetoothDevice3);
|
||||
mShadowBluetoothAdapter.setMostRecentlyConnectedDevices(mMostRecentlyConnectedDevices);
|
||||
when(mBluetoothAdapter.getMostRecentlyConnectedDevices())
|
||||
.thenReturn(mMostRecentlyConnectedDevices);
|
||||
|
||||
mPreConnectedDeviceController =
|
||||
new PreviouslyConnectedDevicePreferenceController(mContext, KEY);
|
||||
mPreConnectedDeviceController.setBluetoothDeviceUpdater(mBluetoothDeviceUpdater);
|
||||
mPreConnectedDeviceController.setSavedDockUpdater(mDockUpdater);
|
||||
mPreferenceGroup = spy(new PreferenceCategory(mContext));
|
||||
doReturn(mPreferenceManager).when(mPreferenceGroup).getPreferenceManager();
|
||||
mPreferenceGroup.setVisible(false);
|
||||
@@ -249,6 +266,7 @@ public class PreviouslyConnectedDevicePreferenceControllerTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@RequiresFlagsDisabled(Flags.FLAG_ENABLE_SAVED_DEVICES_ORDER_BY_RECENCY)
|
||||
public void onDeviceAdded_addPreferenceNotExistInRecentlyDevices_noCrash() {
|
||||
final BluetoothDevicePreference preference = new BluetoothDevicePreference(
|
||||
mContext, mCachedDevice5, true, BluetoothDevicePreference.SortType.TYPE_NO_SORT);
|
||||
@@ -259,6 +277,18 @@ public class PreviouslyConnectedDevicePreferenceControllerTest {
|
||||
assertThat(mPreferenceGroup.getPreferenceCount()).isEqualTo(2);
|
||||
}
|
||||
|
||||
@Test
|
||||
@RequiresFlagsEnabled(Flags.FLAG_ENABLE_SAVED_DEVICES_ORDER_BY_RECENCY)
|
||||
public void onDeviceAdded_addPreferenceNotExistInRecentlyDevices_doNothing() {
|
||||
final BluetoothDevicePreference preference = new BluetoothDevicePreference(
|
||||
mContext, mCachedDevice5, true, BluetoothDevicePreference.SortType.TYPE_NO_SORT);
|
||||
|
||||
mPreConnectedDeviceController.onDeviceAdded(preference);
|
||||
|
||||
// 1 see all preference
|
||||
assertThat(mPreferenceGroup.getPreferenceCount()).isEqualTo(1);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void onDeviceRemoved_removeLastDevice_showSeeAllPreference() {
|
||||
final BluetoothDevicePreference preference1 = new BluetoothDevicePreference(
|
||||
@@ -277,6 +307,7 @@ public class PreviouslyConnectedDevicePreferenceControllerTest {
|
||||
@Test
|
||||
public void updatePreferenceVisibility_bluetoothIsEnable_shouldShowCorrectText() {
|
||||
mShadowBluetoothAdapter.setEnabled(true);
|
||||
when(mBluetoothAdapter.isEnabled()).thenReturn(true);
|
||||
mPreConnectedDeviceController.updatePreferenceVisibility();
|
||||
|
||||
verify(mSeeAllPreference).setSummary("");
|
||||
@@ -285,9 +316,78 @@ public class PreviouslyConnectedDevicePreferenceControllerTest {
|
||||
@Test
|
||||
public void updatePreferenceVisibility_bluetoothIsDisable_shouldShowCorrectText() {
|
||||
mShadowBluetoothAdapter.setEnabled(false);
|
||||
when(mBluetoothAdapter.isEnabled()).thenReturn(false);
|
||||
mPreConnectedDeviceController.updatePreferenceVisibility();
|
||||
|
||||
verify(mSeeAllPreference).setSummary(
|
||||
mContext.getString(R.string.connected_device_see_all_summary));
|
||||
}
|
||||
|
||||
@Test
|
||||
@RequiresFlagsEnabled(Flags.FLAG_ENABLE_SAVED_DEVICES_ORDER_BY_RECENCY)
|
||||
public void updatePreferenceGroup_bluetoothIsEnable_shouldOrderByMostRecentlyConnected() {
|
||||
when(mBluetoothAdapter.isEnabled()).thenReturn(true);
|
||||
final BluetoothDevicePreference preference4 =
|
||||
new BluetoothDevicePreference(
|
||||
mContext,
|
||||
mCachedDevice4,
|
||||
true,
|
||||
BluetoothDevicePreference.SortType.TYPE_NO_SORT);
|
||||
final BluetoothDevicePreference preference3 =
|
||||
new BluetoothDevicePreference(
|
||||
mContext,
|
||||
mCachedDevice3,
|
||||
true,
|
||||
BluetoothDevicePreference.SortType.TYPE_NO_SORT);
|
||||
final BluetoothDevicePreference preference2 =
|
||||
new BluetoothDevicePreference(
|
||||
mContext,
|
||||
mCachedDevice2,
|
||||
true,
|
||||
BluetoothDevicePreference.SortType.TYPE_NO_SORT);
|
||||
mPreConnectedDeviceController.onDeviceAdded(preference4);
|
||||
mPreConnectedDeviceController.onDeviceAdded(preference3);
|
||||
mPreConnectedDeviceController.onDeviceAdded(preference2);
|
||||
|
||||
mPreConnectedDeviceController.updatePreferenceGroup();
|
||||
|
||||
// Refer to the order of {@link #mMostRecentlyConnectedDevices}, the first one is see all
|
||||
// preference
|
||||
assertThat(mPreferenceGroup.getPreferenceCount()).isEqualTo(4);
|
||||
assertThat(preference2.getOrder()).isEqualTo(0);
|
||||
assertThat(preference4.getOrder()).isEqualTo(1);
|
||||
assertThat(preference3.getOrder()).isEqualTo(2);
|
||||
}
|
||||
|
||||
@Test
|
||||
@RequiresFlagsEnabled(Flags.FLAG_ENABLE_SAVED_DEVICES_ORDER_BY_RECENCY)
|
||||
public void updatePreferenceGroup_bluetoothIsDisable_shouldShowOnlySeeAllPreference() {
|
||||
when(mBluetoothAdapter.isEnabled()).thenReturn(false);
|
||||
final BluetoothDevicePreference preference4 =
|
||||
new BluetoothDevicePreference(
|
||||
mContext,
|
||||
mCachedDevice4,
|
||||
true,
|
||||
BluetoothDevicePreference.SortType.TYPE_NO_SORT);
|
||||
final BluetoothDevicePreference preference3 =
|
||||
new BluetoothDevicePreference(
|
||||
mContext,
|
||||
mCachedDevice3,
|
||||
true,
|
||||
BluetoothDevicePreference.SortType.TYPE_NO_SORT);
|
||||
final BluetoothDevicePreference preference2 =
|
||||
new BluetoothDevicePreference(
|
||||
mContext,
|
||||
mCachedDevice2,
|
||||
true,
|
||||
BluetoothDevicePreference.SortType.TYPE_NO_SORT);
|
||||
mPreConnectedDeviceController.onDeviceAdded(preference4);
|
||||
mPreConnectedDeviceController.onDeviceAdded(preference3);
|
||||
mPreConnectedDeviceController.onDeviceAdded(preference2);
|
||||
|
||||
mPreConnectedDeviceController.updatePreferenceGroup();
|
||||
|
||||
// 1 see all preference
|
||||
assertThat(mPreferenceGroup.getPreferenceCount()).isEqualTo(1);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,29 +25,52 @@ import static org.mockito.Mockito.spy;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
import android.bluetooth.BluetoothAdapter;
|
||||
import android.bluetooth.BluetoothDevice;
|
||||
import android.bluetooth.BluetoothManager;
|
||||
import android.content.Context;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.platform.test.annotations.RequiresFlagsEnabled;
|
||||
import android.platform.test.flag.junit.CheckFlagsRule;
|
||||
import android.platform.test.flag.junit.DeviceFlagsValueProvider;
|
||||
import android.util.Pair;
|
||||
|
||||
import androidx.lifecycle.LifecycleOwner;
|
||||
import androidx.preference.PreferenceCategory;
|
||||
import androidx.preference.PreferenceGroup;
|
||||
import androidx.preference.PreferenceManager;
|
||||
|
||||
import com.android.settings.bluetooth.BluetoothDevicePreference;
|
||||
import com.android.settings.bluetooth.BluetoothDeviceUpdater;
|
||||
import com.android.settings.connecteddevice.dock.DockUpdater;
|
||||
import com.android.settings.dashboard.DashboardFragment;
|
||||
import com.android.settings.flags.Flags;
|
||||
import com.android.settingslib.bluetooth.CachedBluetoothDevice;
|
||||
import com.android.settingslib.core.lifecycle.Lifecycle;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.Answers;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.MockitoAnnotations;
|
||||
import org.robolectric.RobolectricTestRunner;
|
||||
import org.robolectric.RuntimeEnvironment;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@RunWith(RobolectricTestRunner.class)
|
||||
public class SavedDeviceGroupControllerTest {
|
||||
|
||||
private static final String FAKE_ADDRESS_1 = "AA:AA:AA:AA:AA:01";
|
||||
private static final String FAKE_ADDRESS_2 = "AA:AA:AA:AA:AA:02";
|
||||
private static final String FAKE_ADDRESS_3 = "AA:AA:AA:AA:AA:03";
|
||||
|
||||
@Rule
|
||||
public final CheckFlagsRule mCheckFlagsRule = DeviceFlagsValueProvider.createCheckFlagsRule();
|
||||
|
||||
@Mock
|
||||
private DashboardFragment mDashboardFragment;
|
||||
@Mock
|
||||
@@ -56,23 +79,57 @@ public class SavedDeviceGroupControllerTest {
|
||||
private DockUpdater mSavedDockUpdater;
|
||||
@Mock
|
||||
private PackageManager mPackageManager;
|
||||
@Mock private BluetoothManager mBluetoothManager;
|
||||
@Mock private BluetoothAdapter mBluetoothAdapter;
|
||||
@Mock private CachedBluetoothDevice mCachedDevice1;
|
||||
@Mock private CachedBluetoothDevice mCachedDevice2;
|
||||
@Mock private CachedBluetoothDevice mCachedDevice3;
|
||||
@Mock private BluetoothDevice mBluetoothDevice1;
|
||||
@Mock private BluetoothDevice mBluetoothDevice2;
|
||||
@Mock private BluetoothDevice mBluetoothDevice3;
|
||||
@Mock private Drawable mDrawable;
|
||||
@Mock private PreferenceManager mPreferenceManager;
|
||||
|
||||
private Context mContext;
|
||||
private SavedDeviceGroupController mSavedDeviceGroupController;
|
||||
private LifecycleOwner mLifecycleOwner;
|
||||
private Lifecycle mLifecycle;
|
||||
private PreferenceGroup mPreferenceGroup;
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
MockitoAnnotations.initMocks(this);
|
||||
Pair<Drawable, String> pairs = new Pair<>(mDrawable, "fake_device");
|
||||
mContext = spy(RuntimeEnvironment.application);
|
||||
mLifecycleOwner = () -> mLifecycle;
|
||||
mLifecycle = new Lifecycle(mLifecycleOwner);
|
||||
doReturn(mContext).when(mDashboardFragment).getContext();
|
||||
doReturn(mPackageManager).when(mContext).getPackageManager();
|
||||
|
||||
when(mCachedDevice1.getDevice()).thenReturn(mBluetoothDevice1);
|
||||
when(mCachedDevice1.getAddress()).thenReturn(FAKE_ADDRESS_1);
|
||||
when(mCachedDevice1.getDrawableWithDescription()).thenReturn(pairs);
|
||||
when(mCachedDevice2.getDevice()).thenReturn(mBluetoothDevice2);
|
||||
when(mCachedDevice2.getAddress()).thenReturn(FAKE_ADDRESS_2);
|
||||
when(mCachedDevice2.getDrawableWithDescription()).thenReturn(pairs);
|
||||
when(mCachedDevice3.getDevice()).thenReturn(mBluetoothDevice3);
|
||||
when(mCachedDevice3.getAddress()).thenReturn(FAKE_ADDRESS_3);
|
||||
when(mCachedDevice3.getDrawableWithDescription()).thenReturn(pairs);
|
||||
final List<BluetoothDevice> mMostRecentlyConnectedDevices = new ArrayList<>();
|
||||
mMostRecentlyConnectedDevices.add(mBluetoothDevice1);
|
||||
mMostRecentlyConnectedDevices.add(mBluetoothDevice2);
|
||||
mMostRecentlyConnectedDevices.add(mBluetoothDevice3);
|
||||
when(mContext.getSystemService(BluetoothManager.class)).thenReturn(mBluetoothManager);
|
||||
when(mBluetoothManager.getAdapter()).thenReturn(mBluetoothAdapter);
|
||||
when(mBluetoothAdapter.getMostRecentlyConnectedDevices())
|
||||
.thenReturn(mMostRecentlyConnectedDevices);
|
||||
|
||||
mPreferenceGroup = spy(new PreferenceCategory(mContext));
|
||||
when(mPreferenceGroup.getPreferenceManager()).thenReturn(mPreferenceManager);
|
||||
mSavedDeviceGroupController = new SavedDeviceGroupController(mContext);
|
||||
mSavedDeviceGroupController.setBluetoothDeviceUpdater(mBluetoothDeviceUpdater);
|
||||
mSavedDeviceGroupController.setSavedDockUpdater(mSavedDockUpdater);
|
||||
mSavedDeviceGroupController.setPreferenceGroup(mPreferenceGroup);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -118,4 +175,71 @@ public class SavedDeviceGroupControllerTest {
|
||||
assertThat(mSavedDeviceGroupController.getAvailabilityStatus()).isEqualTo(
|
||||
AVAILABLE);
|
||||
}
|
||||
|
||||
@Test
|
||||
@RequiresFlagsEnabled(Flags.FLAG_ENABLE_SAVED_DEVICES_ORDER_BY_RECENCY)
|
||||
public void updatePreferenceGroup_bluetoothIsEnable_shouldOrderByMostRecentlyConnected() {
|
||||
when(mBluetoothAdapter.isEnabled()).thenReturn(true);
|
||||
final BluetoothDevicePreference preference3 =
|
||||
new BluetoothDevicePreference(
|
||||
mContext,
|
||||
mCachedDevice3,
|
||||
true,
|
||||
BluetoothDevicePreference.SortType.TYPE_NO_SORT);
|
||||
final BluetoothDevicePreference preference2 =
|
||||
new BluetoothDevicePreference(
|
||||
mContext,
|
||||
mCachedDevice2,
|
||||
true,
|
||||
BluetoothDevicePreference.SortType.TYPE_NO_SORT);
|
||||
final BluetoothDevicePreference preference1 =
|
||||
new BluetoothDevicePreference(
|
||||
mContext,
|
||||
mCachedDevice1,
|
||||
true,
|
||||
BluetoothDevicePreference.SortType.TYPE_NO_SORT);
|
||||
mSavedDeviceGroupController.onDeviceAdded(preference3);
|
||||
mSavedDeviceGroupController.onDeviceAdded(preference2);
|
||||
mSavedDeviceGroupController.onDeviceAdded(preference1);
|
||||
|
||||
mSavedDeviceGroupController.updatePreferenceGroup();
|
||||
|
||||
// Refer to the order of {@link #mMostRecentlyConnectedDevices}
|
||||
assertThat(mPreferenceGroup.isVisible()).isTrue();
|
||||
assertThat(mPreferenceGroup.getPreferenceCount()).isEqualTo(3);
|
||||
assertThat(preference1.getOrder()).isEqualTo(0);
|
||||
assertThat(preference2.getOrder()).isEqualTo(1);
|
||||
assertThat(preference3.getOrder()).isEqualTo(2);
|
||||
}
|
||||
|
||||
@Test
|
||||
@RequiresFlagsEnabled(Flags.FLAG_ENABLE_SAVED_DEVICES_ORDER_BY_RECENCY)
|
||||
public void updatePreferenceGroup_bluetoothIsDisable_shouldShowNoPreference() {
|
||||
when(mBluetoothAdapter.isEnabled()).thenReturn(false);
|
||||
final BluetoothDevicePreference preference3 =
|
||||
new BluetoothDevicePreference(
|
||||
mContext,
|
||||
mCachedDevice3,
|
||||
true,
|
||||
BluetoothDevicePreference.SortType.TYPE_NO_SORT);
|
||||
final BluetoothDevicePreference preference2 =
|
||||
new BluetoothDevicePreference(
|
||||
mContext,
|
||||
mCachedDevice2,
|
||||
true,
|
||||
BluetoothDevicePreference.SortType.TYPE_NO_SORT);
|
||||
final BluetoothDevicePreference preference1 =
|
||||
new BluetoothDevicePreference(
|
||||
mContext,
|
||||
mCachedDevice2,
|
||||
true,
|
||||
BluetoothDevicePreference.SortType.TYPE_NO_SORT);
|
||||
mSavedDeviceGroupController.onDeviceAdded(preference3);
|
||||
mSavedDeviceGroupController.onDeviceAdded(preference2);
|
||||
mSavedDeviceGroupController.onDeviceAdded(preference1);
|
||||
|
||||
mSavedDeviceGroupController.updatePreferenceGroup();
|
||||
|
||||
assertThat(mPreferenceGroup.isVisible()).isFalse();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -41,7 +41,8 @@ import androidx.preference.Preference;
|
||||
import androidx.preference.PreferenceCategory;
|
||||
import androidx.preference.PreferenceManager;
|
||||
import androidx.preference.PreferenceScreen;
|
||||
import androidx.preference.SwitchPreference;
|
||||
import androidx.preference.SwitchPreferenceCompat;
|
||||
import androidx.test.core.app.ApplicationProvider;
|
||||
|
||||
import com.android.internal.compat.CompatibilityChangeConfig;
|
||||
import com.android.internal.compat.CompatibilityChangeInfo;
|
||||
@@ -51,13 +52,13 @@ import com.android.internal.compat.OverrideAllowedState;
|
||||
import com.android.settings.R;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.MockitoAnnotations;
|
||||
import org.mockito.junit.MockitoJUnit;
|
||||
import org.mockito.junit.MockitoRule;
|
||||
import org.robolectric.RobolectricTestRunner;
|
||||
import org.robolectric.RuntimeEnvironment;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
@@ -67,6 +68,8 @@ import java.util.Set;
|
||||
|
||||
@RunWith(RobolectricTestRunner.class)
|
||||
public class PlatformCompatDashboardTest {
|
||||
@Rule
|
||||
public final MockitoRule mMockitoRule = MockitoJUnit.rule();
|
||||
private PlatformCompatDashboard mDashboard;
|
||||
|
||||
@Mock
|
||||
@@ -87,7 +90,6 @@ public class PlatformCompatDashboardTest {
|
||||
|
||||
@Before
|
||||
public void setUp() throws RemoteException, NameNotFoundException {
|
||||
MockitoAnnotations.initMocks(this);
|
||||
mChanges = new CompatibilityChangeInfo[5];
|
||||
mChanges[0] = new CompatibilityChangeInfo(
|
||||
1L, "Default_Enabled", 0, 0, false, false, "", false);
|
||||
@@ -104,7 +106,7 @@ public class PlatformCompatDashboardTest {
|
||||
// By default, allow any change
|
||||
when(mOverrideValidator.getOverrideAllowedState(anyLong(),anyString()))
|
||||
.thenReturn(new OverrideAllowedState(ALLOWED, -1, -1));
|
||||
mContext = spy(RuntimeEnvironment.application);
|
||||
mContext = spy(ApplicationProvider.getApplicationContext());
|
||||
mPreferenceManager = new PreferenceManager(mContext);
|
||||
mPreferenceScreen = mPreferenceManager.createPreferenceScreen(mContext);
|
||||
mApplicationInfo.packageName = APP_NAME;
|
||||
@@ -141,7 +143,6 @@ public class PlatformCompatDashboardTest {
|
||||
R.string.platform_compat_selected_app_summary, APP_NAME, 1));
|
||||
}
|
||||
|
||||
@Ignore("b/313591873")
|
||||
@Test
|
||||
public void createPreferenceForChange_defaultEnabledChange_createCheckedEntry() {
|
||||
CompatibilityChangeInfo enabledChange = mChanges[0];
|
||||
@@ -152,15 +153,14 @@ public class PlatformCompatDashboardTest {
|
||||
Preference enabledPreference = mDashboard.createPreferenceForChange(mContext, enabledChange,
|
||||
config);
|
||||
|
||||
SwitchPreference enabledSwitchPreference = (SwitchPreference) enabledPreference;
|
||||
SwitchPreferenceCompat enabledSwitchPreference = (SwitchPreferenceCompat) enabledPreference;
|
||||
|
||||
assertThat(enabledPreference.getSummary()).isEqualTo(mChanges[0].getName());
|
||||
assertThat(enabledPreference instanceof SwitchPreference).isTrue();
|
||||
assertThat(enabledPreference instanceof SwitchPreferenceCompat).isTrue();
|
||||
assertThat(enabledSwitchPreference.isChecked()).isTrue();
|
||||
assertThat(enabledSwitchPreference.isEnabled()).isTrue();
|
||||
}
|
||||
|
||||
@Ignore("b/313591873")
|
||||
@Test
|
||||
public void createPreferenceForChange_defaultDisabledChange_createUncheckedEntry() {
|
||||
CompatibilityChangeInfo disabledChange = mChanges[1];
|
||||
@@ -172,12 +172,12 @@ public class PlatformCompatDashboardTest {
|
||||
disabledChange, config);
|
||||
|
||||
assertThat(disabledPreference.getSummary()).isEqualTo(mChanges[1].getName());
|
||||
SwitchPreference disabledSwitchPreference = (SwitchPreference) disabledPreference;
|
||||
SwitchPreferenceCompat disabledSwitchPreference =
|
||||
(SwitchPreferenceCompat) disabledPreference;
|
||||
assertThat(disabledSwitchPreference.isChecked()).isFalse();
|
||||
assertThat(disabledSwitchPreference.isEnabled()).isTrue();
|
||||
}
|
||||
|
||||
@Ignore("b/313591873")
|
||||
@Test
|
||||
public void createPreferenceForChange_cannotOverride_createDisabledEntry()
|
||||
throws RemoteException {
|
||||
@@ -191,15 +191,14 @@ public class PlatformCompatDashboardTest {
|
||||
Preference preference = mDashboard.createPreferenceForChange(mContext, enabledChange,
|
||||
config);
|
||||
|
||||
SwitchPreference switchPreference = (SwitchPreference) preference;
|
||||
SwitchPreferenceCompat switchPreference = (SwitchPreferenceCompat) preference;
|
||||
|
||||
assertThat(preference.getSummary()).isEqualTo(mChanges[0].getName());
|
||||
assertThat(preference instanceof SwitchPreference).isTrue();
|
||||
assertThat(preference instanceof SwitchPreferenceCompat).isTrue();
|
||||
assertThat(switchPreference.isChecked()).isTrue();
|
||||
assertThat(switchPreference.isEnabled()).isFalse();
|
||||
}
|
||||
|
||||
@Ignore("b/313591873")
|
||||
@Test
|
||||
public void createChangeCategoryPreference_enabledAndDisabled_hasTitleAndEntries() {
|
||||
Set<Long> enabledChanges = new HashSet<>();
|
||||
@@ -226,7 +225,7 @@ public class PlatformCompatDashboardTest {
|
||||
assertThat(category.getPreferenceCount()).isEqualTo(mChanges.length);
|
||||
for (int i = 0; i < mChanges.length; ++i) {
|
||||
Preference childPreference = category.getPreference(i);
|
||||
assertThat(childPreference instanceof SwitchPreference).isTrue();
|
||||
assertThat(childPreference instanceof SwitchPreferenceCompat).isTrue();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -114,7 +114,8 @@ public class MobileDataSliceTest {
|
||||
|
||||
mMobileDataSlice.onNotifyChange(intent);
|
||||
|
||||
verify(mTelephonyManager).setDataEnabled(true);
|
||||
verify(mTelephonyManager)
|
||||
.setDataEnabledForReason(TelephonyManager.DATA_ENABLED_REASON_USER, true);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -126,7 +127,8 @@ public class MobileDataSliceTest {
|
||||
|
||||
mMobileDataSlice.onNotifyChange(intent);
|
||||
|
||||
verify(mTelephonyManager).setDataEnabled(false);
|
||||
verify(mTelephonyManager)
|
||||
.setDataEnabledForReason(TelephonyManager.DATA_ENABLED_REASON_USER, false);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -138,7 +140,8 @@ public class MobileDataSliceTest {
|
||||
|
||||
mMobileDataSlice.onNotifyChange(intent);
|
||||
|
||||
verify(mTelephonyManager, times(0)).setDataEnabled(true);
|
||||
verify(mTelephonyManager, times(0))
|
||||
.setDataEnabledForReason(TelephonyManager.DATA_ENABLED_REASON_USER, true);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -16,9 +16,9 @@ import static com.google.common.truth.Truth.assertThat;
|
||||
|
||||
import static junit.framework.Assert.assertEquals;
|
||||
|
||||
import static org.mockito.ArgumentMatchers.eq;
|
||||
import static org.mockito.Mockito.doAnswer;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.times;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
@@ -30,8 +30,6 @@ import android.database.Cursor;
|
||||
import android.provider.Settings;
|
||||
import android.service.notification.ZenModeConfig;
|
||||
|
||||
import com.android.settings.R;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
@@ -204,7 +202,11 @@ public class ZenModeBackendTest {
|
||||
mBackend.saveConversationSenders(CONVERSATION_SENDERS_NONE);
|
||||
|
||||
ArgumentCaptor<Policy> captor = ArgumentCaptor.forClass(Policy.class);
|
||||
verify(mNotificationManager, times(1)).setNotificationPolicy(captor.capture());
|
||||
if (android.app.Flags.modesApi()) {
|
||||
verify(mNotificationManager).setNotificationPolicy(captor.capture(), eq(true));
|
||||
} else {
|
||||
verify(mNotificationManager).setNotificationPolicy(captor.capture());
|
||||
}
|
||||
|
||||
Policy expected = new Policy(
|
||||
PRIORITY_CATEGORY_CALLS | PRIORITY_CATEGORY_MESSAGES | PRIORITY_CATEGORY_ALARMS,
|
||||
@@ -228,7 +230,11 @@ public class ZenModeBackendTest {
|
||||
mBackend.saveConversationSenders(CONVERSATION_SENDERS_ANYONE);
|
||||
|
||||
ArgumentCaptor<Policy> captor = ArgumentCaptor.forClass(Policy.class);
|
||||
verify(mNotificationManager, times(1)).setNotificationPolicy(captor.capture());
|
||||
if (android.app.Flags.modesApi()) {
|
||||
verify(mNotificationManager).setNotificationPolicy(captor.capture(), eq(true));
|
||||
} else {
|
||||
verify(mNotificationManager).setNotificationPolicy(captor.capture());
|
||||
}
|
||||
|
||||
Policy expected = new Policy(PRIORITY_CATEGORY_CONVERSATIONS
|
||||
| PRIORITY_CATEGORY_CALLS | PRIORITY_CATEGORY_MESSAGES | PRIORITY_CATEGORY_ALARMS,
|
||||
@@ -253,7 +259,11 @@ public class ZenModeBackendTest {
|
||||
mBackend.saveSenders(PRIORITY_CATEGORY_CALLS, PRIORITY_SENDERS_ANY);
|
||||
|
||||
ArgumentCaptor<Policy> captor = ArgumentCaptor.forClass(Policy.class);
|
||||
verify(mNotificationManager, times(1)).setNotificationPolicy(captor.capture());
|
||||
if (android.app.Flags.modesApi()) {
|
||||
verify(mNotificationManager).setNotificationPolicy(captor.capture(), eq(true));
|
||||
} else {
|
||||
verify(mNotificationManager).setNotificationPolicy(captor.capture());
|
||||
}
|
||||
|
||||
Policy expected = new Policy(PRIORITY_CATEGORY_CONVERSATIONS
|
||||
| PRIORITY_CATEGORY_CALLS | PRIORITY_CATEGORY_MESSAGES | PRIORITY_CATEGORY_ALARMS,
|
||||
|
||||
@@ -17,13 +17,18 @@
|
||||
package com.android.settings.notification.zen;
|
||||
|
||||
import static android.app.slice.Slice.EXTRA_TOGGLE_STATE;
|
||||
import static android.provider.Settings.Global.ZEN_MODE_IMPORTANT_INTERRUPTIONS;
|
||||
import static android.provider.Settings.Global.ZEN_MODE_OFF;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.ArgumentMatchers.eq;
|
||||
import static org.mockito.Mockito.verify;
|
||||
|
||||
import android.app.NotificationManager;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.provider.Settings;
|
||||
|
||||
import androidx.slice.Slice;
|
||||
import androidx.slice.SliceMetadata;
|
||||
@@ -39,9 +44,12 @@ import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.MockitoAnnotations;
|
||||
import org.robolectric.RobolectricTestRunner;
|
||||
import org.robolectric.RuntimeEnvironment;
|
||||
import org.robolectric.annotation.Config;
|
||||
import org.robolectric.shadows.ShadowApplication;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -51,10 +59,17 @@ public class ZenModeSliceBuilderTest {
|
||||
|
||||
private Context mContext;
|
||||
|
||||
@Mock
|
||||
private NotificationManager mNm;
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
mContext = RuntimeEnvironment.application;
|
||||
|
||||
MockitoAnnotations.initMocks(this);
|
||||
ShadowApplication shadowApplication = ShadowApplication.getInstance();
|
||||
shadowApplication.setSystemService(Context.NOTIFICATION_SERVICE, mNm);
|
||||
|
||||
// Set-up specs for SliceMetadata.
|
||||
SliceProvider.setSpecs(SliceLiveData.SUPPORTED_SPECS);
|
||||
}
|
||||
@@ -99,24 +114,27 @@ public class ZenModeSliceBuilderTest {
|
||||
public void handleUriChange_turnOn_zenModeTurnsOn() {
|
||||
final Intent intent = new Intent();
|
||||
intent.putExtra(EXTRA_TOGGLE_STATE, true);
|
||||
NotificationManager.from(mContext).setZenMode(Settings.Global.ZEN_MODE_OFF, null, "");
|
||||
|
||||
ZenModeSliceBuilder.handleUriChange(mContext, intent);
|
||||
|
||||
final int zenMode = NotificationManager.from(mContext).getZenMode();
|
||||
assertThat(zenMode).isEqualTo(Settings.Global.ZEN_MODE_IMPORTANT_INTERRUPTIONS);
|
||||
if (android.app.Flags.modesApi()) {
|
||||
verify(mNm).setZenMode(eq(ZEN_MODE_IMPORTANT_INTERRUPTIONS), any(), any(), eq(true));
|
||||
} else {
|
||||
verify(mNm).setZenMode(eq(ZEN_MODE_IMPORTANT_INTERRUPTIONS), any(), any());
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void handleUriChange_turnOff_zenModeTurnsOff() {
|
||||
final Intent intent = new Intent();
|
||||
intent.putExtra(EXTRA_TOGGLE_STATE, false);
|
||||
NotificationManager.from(mContext).setZenMode(
|
||||
Settings.Global.ZEN_MODE_IMPORTANT_INTERRUPTIONS, null, "");
|
||||
|
||||
ZenModeSliceBuilder.handleUriChange(mContext, intent);
|
||||
|
||||
final int zenMode = NotificationManager.from(mContext).getZenMode();
|
||||
assertThat(zenMode).isEqualTo(Settings.Global.ZEN_MODE_OFF);
|
||||
if (android.app.Flags.modesApi()) {
|
||||
verify(mNm).setZenMode(eq(ZEN_MODE_OFF), any(), any(), eq(true));
|
||||
} else {
|
||||
verify(mNm).setZenMode(eq(ZEN_MODE_OFF), any(), any());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,17 +21,19 @@ import static android.app.NotificationManager.Policy.PRIORITY_CATEGORY_REPEAT_CA
|
||||
import static android.app.NotificationManager.Policy.SUPPRESSED_EFFECT_SCREEN_ON;
|
||||
|
||||
import static com.android.settings.notification.zen.ZenOnboardingActivity.ALWAYS_SHOW_THRESHOLD;
|
||||
import static com.android.settings.notification.zen.ZenOnboardingActivity
|
||||
.PREF_KEY_SUGGESTION_FIRST_DISPLAY_TIME;
|
||||
import static com.android.settings.notification.zen.ZenOnboardingActivity.PREF_KEY_SUGGESTION_FIRST_DISPLAY_TIME;
|
||||
import static com.android.settings.notification.zen.ZenOnboardingActivity.isSuggestionComplete;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.ArgumentMatchers.anyBoolean;
|
||||
import static org.mockito.ArgumentMatchers.eq;
|
||||
import static org.mockito.Mockito.never;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
import android.app.Flags;
|
||||
import android.app.NotificationManager;
|
||||
import android.app.NotificationManager.Policy;
|
||||
import android.content.Context;
|
||||
@@ -40,7 +42,6 @@ import android.provider.Settings;
|
||||
|
||||
import com.android.internal.logging.MetricsLogger;
|
||||
import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
|
||||
import com.android.settings.notification.zen.ZenOnboardingActivity;
|
||||
import com.android.settings.testutils.FakeFeatureFactory;
|
||||
|
||||
import org.junit.Before;
|
||||
@@ -103,7 +104,11 @@ public class ZenOnboardingActivityTest {
|
||||
verify(mMetricsLogger).action(MetricsEvent.ACTION_ZEN_ONBOARDING_OK);
|
||||
|
||||
ArgumentCaptor<Policy> captor = ArgumentCaptor.forClass(Policy.class);
|
||||
verify(mNm).setNotificationPolicy(captor.capture());
|
||||
if (android.app.Flags.modesApi()) {
|
||||
verify(mNm).setNotificationPolicy(captor.capture(), eq(true));
|
||||
} else {
|
||||
verify(mNm).setNotificationPolicy(captor.capture());
|
||||
}
|
||||
|
||||
Policy actual = captor.getValue();
|
||||
assertThat(actual.priorityCategories).isEqualTo(PRIORITY_CATEGORY_ALARMS
|
||||
@@ -123,7 +128,11 @@ public class ZenOnboardingActivityTest {
|
||||
mActivity.save(null);
|
||||
|
||||
verify(mMetricsLogger).action(MetricsEvent.ACTION_ZEN_ONBOARDING_KEEP_CURRENT_SETTINGS);
|
||||
verify(mNm, never()).setNotificationPolicy(any());
|
||||
if (Flags.modesApi()) {
|
||||
verify(mNm, never()).setNotificationPolicy(any(), anyBoolean());
|
||||
} else {
|
||||
verify(mNm, never()).setNotificationPolicy(any());
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -43,6 +43,7 @@ import android.widget.LinearLayout;
|
||||
|
||||
import androidx.lifecycle.LiveData;
|
||||
import androidx.slice.Slice;
|
||||
import androidx.test.core.app.ApplicationProvider;
|
||||
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.panel.PanelSlicesAdapter.SliceRowViewHolder;
|
||||
@@ -50,14 +51,14 @@ import com.android.settings.testutils.FakeFeatureFactory;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Before;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.ArgumentCaptor;
|
||||
import org.mockito.MockitoAnnotations;
|
||||
import org.mockito.junit.MockitoJUnit;
|
||||
import org.mockito.junit.MockitoRule;
|
||||
import org.robolectric.Robolectric;
|
||||
import org.robolectric.RobolectricTestRunner;
|
||||
import org.robolectric.RuntimeEnvironment;
|
||||
import org.robolectric.android.controller.ActivityController;
|
||||
import org.robolectric.annotation.Config;
|
||||
import org.robolectric.annotation.Implementation;
|
||||
@@ -69,6 +70,8 @@ import java.util.Map;
|
||||
@RunWith(RobolectricTestRunner.class)
|
||||
@Config(shadows = PanelSlicesAdapterTest.ShadowLayoutInflater.class)
|
||||
public class PanelSlicesAdapterTest {
|
||||
@Rule
|
||||
public final MockitoRule mMockitoRule = MockitoJUnit.rule();
|
||||
|
||||
private static LayoutInflater sLayoutInflater;
|
||||
|
||||
@@ -81,8 +84,7 @@ public class PanelSlicesAdapterTest {
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
MockitoAnnotations.initMocks(this);
|
||||
mContext = RuntimeEnvironment.application;
|
||||
mContext = ApplicationProvider.getApplicationContext();
|
||||
|
||||
mPanelFeatureProvider = spy(new PanelFeatureProviderImpl());
|
||||
mFakeFeatureFactory = FakeFeatureFactory.setupForTest();
|
||||
@@ -104,8 +106,7 @@ public class PanelSlicesAdapterTest {
|
||||
|
||||
private void addTestLiveData(Uri uri) {
|
||||
// Create a slice to return for the LiveData
|
||||
final Slice slice = spy(new Slice());
|
||||
doReturn(uri).when(slice).getUri();
|
||||
final Slice slice = new Slice();
|
||||
final LiveData<Slice> liveData = mock(LiveData.class);
|
||||
when(liveData.getValue()).thenReturn(slice);
|
||||
mData.put(uri, liveData);
|
||||
@@ -126,7 +127,6 @@ public class PanelSlicesAdapterTest {
|
||||
/**
|
||||
* ViewHolder should load and set the action label correctly.
|
||||
*/
|
||||
@Ignore("b/313576125")
|
||||
@Test
|
||||
public void setActionLabel_loadsActionLabel() {
|
||||
addTestLiveData(VOLUME_NOTIFICATION_URI);
|
||||
@@ -167,7 +167,6 @@ public class PanelSlicesAdapterTest {
|
||||
return foundLabel;
|
||||
}
|
||||
|
||||
@Ignore("b/313576125")
|
||||
@Test
|
||||
public void sizeOfAdapter_shouldNotExceedMaxNum() {
|
||||
for (int i = 0; i < MAX_NUM_OF_SLICES + 2; i++) {
|
||||
@@ -186,7 +185,6 @@ public class PanelSlicesAdapterTest {
|
||||
assertThat(adapter.getData().size()).isEqualTo(MAX_NUM_OF_SLICES);
|
||||
}
|
||||
|
||||
@Ignore("b/313576125")
|
||||
@Test
|
||||
public void mediaOutputIndicatorSlice_notSliderPanel_noSliderLayout() {
|
||||
addTestLiveData(MEDIA_OUTPUT_INDICATOR_SLICE_URI);
|
||||
@@ -203,7 +201,6 @@ public class PanelSlicesAdapterTest {
|
||||
assertThat(viewHolder.mSliceSliderLayout).isNull();
|
||||
}
|
||||
|
||||
@Ignore("b/313576125")
|
||||
@Test
|
||||
public void onBindViewHolder_viewTypeSlider_verifyActionLabelSet() {
|
||||
addTestLiveData(VOLUME_NOTIFICATION_URI);
|
||||
|
||||
@@ -77,6 +77,7 @@ public class SimLockPreferenceControllerTest {
|
||||
ShadowApplication shadowApplication = ShadowApplication.getInstance();
|
||||
shadowApplication.setSystemService(Context.TELEPHONY_SUBSCRIPTION_SERVICE,
|
||||
mSubscriptionManager);
|
||||
when(mSubscriptionManager.createForAllUserProfiles()).thenReturn(mSubscriptionManager);
|
||||
shadowApplication.setSystemService(Context.CARRIER_CONFIG_SERVICE, mCarrierManager);
|
||||
shadowApplication.setSystemService(Context.USER_SERVICE, mUserManager);
|
||||
shadowApplication.setSystemService(Context.TELEPHONY_SERVICE, mTelephonyManager);
|
||||
|
||||
@@ -68,6 +68,7 @@ public class EnableAutoDataSwitchDialogFragmentTest
|
||||
doReturn(mContext).when(mFragment).getContext();
|
||||
|
||||
doReturn(mSubscriptionManager).when(mContext).getSystemService(SubscriptionManager.class);
|
||||
doReturn(mSubscriptionManager).when(mSubscriptionManager).createForAllUserProfiles();
|
||||
doReturn(mTelephonyManager).when(mContext).getSystemService(TelephonyManager.class);
|
||||
doReturn(mTelephonyManager).when(mTelephonyManager).createForSubscriptionId(anyInt());
|
||||
doReturn(mUserManager).when(mContext).getSystemService(UserManager.class);
|
||||
|
||||
@@ -31,7 +31,7 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@Implements(AccountManager.class)
|
||||
public class ShadowAccountManager {
|
||||
public class ShadowAccountManager extends org.robolectric.shadows.ShadowAccountManager {
|
||||
|
||||
private static final Map<String, AuthenticatorDescription> sAuthenticators = new HashMap<>();
|
||||
private static final Map<Integer, List<Account>> sAccountsByUserId = new HashMap<>();
|
||||
@@ -41,7 +41,8 @@ public class ShadowAccountManager {
|
||||
return sAuthenticators.values().toArray(new AuthenticatorDescription[sAuthenticators.size()]);
|
||||
}
|
||||
|
||||
public static void addAuthenticator(AuthenticatorDescription authenticator) {
|
||||
@Override
|
||||
public void addAuthenticator(AuthenticatorDescription authenticator) {
|
||||
sAuthenticators.put(authenticator.type, authenticator);
|
||||
}
|
||||
|
||||
|
||||
@@ -16,6 +16,8 @@
|
||||
|
||||
package com.android.settings.testutils.shadow;
|
||||
|
||||
import static android.provider.Settings.DEFAULT_OVERRIDEABLE_BY_RESTORE;
|
||||
|
||||
import android.content.ContentResolver;
|
||||
import android.provider.Settings;
|
||||
|
||||
@@ -24,12 +26,13 @@ import com.google.common.collect.Table;
|
||||
|
||||
import org.robolectric.annotation.Implementation;
|
||||
import org.robolectric.annotation.Implements;
|
||||
import org.robolectric.shadows.ShadowSettings;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.WeakHashMap;
|
||||
|
||||
@Implements(Settings.Secure.class)
|
||||
public class ShadowSecureSettings {
|
||||
public class ShadowSecureSettings extends ShadowSettings.ShadowSecure {
|
||||
|
||||
private static final Map<ContentResolver, Table<Integer, String, Object>> sUserDataMap =
|
||||
new WeakHashMap<>();
|
||||
@@ -48,6 +51,16 @@ public class ShadowSecureSettings {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Same implementation as Settings.Secure because robolectric.ShadowSettings.ShadowSecure
|
||||
* overrides this API.
|
||||
*/
|
||||
@Implementation
|
||||
public static boolean putString(ContentResolver resolver, String name, String value) {
|
||||
return putStringForUser(resolver, name, value, null, false,
|
||||
resolver.getUserId(), DEFAULT_OVERRIDEABLE_BY_RESTORE);
|
||||
}
|
||||
|
||||
@Implementation
|
||||
public static String getStringForUser(ContentResolver resolver, String name, int userHandle) {
|
||||
final Table<Integer, String, Object> userTable = getUserTable(resolver);
|
||||
@@ -56,6 +69,15 @@ public class ShadowSecureSettings {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Same implementation as Settings.Secure because robolectric.ShadowSettings.ShadowSecure
|
||||
* overrides this API.
|
||||
*/
|
||||
@Implementation
|
||||
public static boolean putInt(ContentResolver resolver, String name, int value) {
|
||||
return putIntForUser(resolver, name, value, resolver.getUserId());
|
||||
}
|
||||
|
||||
@Implementation
|
||||
public static boolean putIntForUser(ContentResolver resolver, String name, int value,
|
||||
int userHandle) {
|
||||
@@ -66,6 +88,15 @@ public class ShadowSecureSettings {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Same implementation as Settings.Secure because robolectric.ShadowSettings.ShadowSecure
|
||||
* overrides this API.
|
||||
*/
|
||||
@Implementation
|
||||
public static int getInt(ContentResolver resolver, String name, int def) {
|
||||
return getIntForUser(resolver, name, def, resolver.getUserId());
|
||||
}
|
||||
|
||||
@Implementation
|
||||
public static int getIntForUser(ContentResolver resolver, String name, int def,
|
||||
int userHandle) {
|
||||
|
||||
@@ -45,7 +45,7 @@ class ResetAppPreferencesTest {
|
||||
}
|
||||
|
||||
private fun setResetAppPreferences() {
|
||||
val fakeMoreOptionsScope = object : MoreOptionsScope {
|
||||
val fakeMoreOptionsScope = object : MoreOptionsScope() {
|
||||
override fun dismiss() {}
|
||||
}
|
||||
composeTestRule.setContent {
|
||||
|
||||
@@ -32,6 +32,7 @@ android_test {
|
||||
"kotlinx_coroutines_test",
|
||||
"flag-junit",
|
||||
"Settings-testutils2",
|
||||
"MediaDrmSettingsFlagsLib",
|
||||
// Don't add SettingsLib libraries here - you can use them directly as they are in the
|
||||
// instrumented Settings app.
|
||||
],
|
||||
|
||||
@@ -0,0 +1,136 @@
|
||||
/*
|
||||
* Copyright (C) 2023 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.development.widevine;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
import static org.junit.Assume.assumeTrue;
|
||||
import static org.junit.Assume.assumeNoException;
|
||||
|
||||
import android.content.Context;
|
||||
import android.media.MediaDrm;
|
||||
import android.media.UnsupportedSchemeException;
|
||||
import android.media.NotProvisionedException;
|
||||
import android.sysprop.WidevineProperties;
|
||||
import android.util.Log;
|
||||
import android.content.Context;
|
||||
|
||||
import com.android.settings.media_drm.Flags;
|
||||
import android.platform.test.flag.junit.SetFlagsRule;
|
||||
|
||||
import androidx.preference.SwitchPreference;
|
||||
import androidx.test.core.app.ApplicationProvider;
|
||||
import androidx.test.ext.junit.runners.AndroidJUnit4;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
@RunWith(AndroidJUnit4.class)
|
||||
public class ForceL3FallbackPreferenceControllerTest {
|
||||
|
||||
private static final String PREF_KEY = "force_l3_fallback";
|
||||
private static final UUID WIDEVINE_UUID =
|
||||
new UUID(0xEDEF8BA979D64ACEL, 0xA3C827DCD51D21EDL);
|
||||
private static final String TAG = "ForceL3FallbackPreferenceControllerTest";
|
||||
|
||||
@Rule public final SetFlagsRule mSetFlagsRule = new SetFlagsRule();
|
||||
|
||||
private Context mContext;
|
||||
private ForceL3FallbackPreferenceController mController;
|
||||
private SwitchPreference mPreference;
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
mContext = ApplicationProvider.getApplicationContext();
|
||||
mController = new ForceL3FallbackPreferenceController(mContext, PREF_KEY);
|
||||
mPreference = new SwitchPreference(mContext);
|
||||
WidevineProperties.forcel3_enabled(false);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void updateState_flagEnabled_checkPreference() {
|
||||
mSetFlagsRule.enableFlags(Flags.FLAG_FORCE_L3_ENABLED);
|
||||
mController.updateState(mPreference);
|
||||
assertThat(mPreference.isEnabled()).isTrue();
|
||||
assertThat(mPreference.isChecked()).isFalse();
|
||||
assertThat(WidevineProperties.forcel3_enabled().orElse(false)).isFalse();
|
||||
|
||||
// Toggle to true
|
||||
mController.setChecked(true);
|
||||
mController.updateState(mPreference);
|
||||
assertThat(WidevineProperties.forcel3_enabled().orElse(false)).isTrue();
|
||||
assertThat(mPreference.isEnabled()).isTrue();
|
||||
assertThat(mPreference.isChecked()).isTrue();
|
||||
|
||||
// Toggle to false
|
||||
mController.setChecked(false);
|
||||
mController.updateState(mPreference);
|
||||
assertThat(WidevineProperties.forcel3_enabled().orElse(false)).isFalse();
|
||||
assertThat(mPreference.isEnabled()).isTrue();
|
||||
assertThat(mPreference.isChecked()).isFalse();
|
||||
|
||||
// Test flag rollback
|
||||
mController.setChecked(true);
|
||||
mController.updateState(mPreference);
|
||||
assertThat(mPreference.isChecked()).isTrue();
|
||||
assertThat(WidevineProperties.forcel3_enabled().orElse(false)).isTrue();
|
||||
mSetFlagsRule.disableFlags(Flags.FLAG_FORCE_L3_ENABLED);
|
||||
mController.updateState(mPreference);
|
||||
assertThat(mPreference.isEnabled()).isFalse();
|
||||
assertThat(mPreference.isChecked()).isFalse();
|
||||
assertThat(WidevineProperties.forcel3_enabled().orElse(false)).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void updateState_flagDisabled_checkPreference() {
|
||||
mSetFlagsRule.disableFlags(Flags.FLAG_FORCE_L3_ENABLED);
|
||||
mController.updateState(mPreference);
|
||||
assertThat(mPreference.isEnabled()).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void updateState_checkWidevine() throws Exception {
|
||||
MediaDrm drm;
|
||||
try {
|
||||
drm = new MediaDrm(WIDEVINE_UUID);
|
||||
assumeTrue(drm.getPropertyString("securityLevel").equals("L1"));
|
||||
mSetFlagsRule.enableFlags(Flags.FLAG_FORCE_L3_ENABLED);
|
||||
drm.close();
|
||||
} catch (UnsupportedSchemeException ex) {
|
||||
assumeNoException(ex);
|
||||
}
|
||||
|
||||
// L3 enforced
|
||||
mController.setChecked(true);
|
||||
mController.updateState(mPreference);
|
||||
assertThat(WidevineProperties.forcel3_enabled().orElse(false)).isTrue();
|
||||
assertThat(mPreference.isEnabled()).isTrue();
|
||||
assertThat(mPreference.isChecked()).isTrue();
|
||||
drm = new MediaDrm(WIDEVINE_UUID);
|
||||
assertThat(drm.getPropertyString("securityLevel")).isEqualTo("L3");
|
||||
|
||||
// Switch back to L1
|
||||
mController.setChecked(false);
|
||||
mController.updateState(mPreference);
|
||||
drm.close();
|
||||
drm = new MediaDrm(WIDEVINE_UUID);
|
||||
assertThat(drm.getPropertyString("securityLevel")).isEqualTo("L1");
|
||||
}
|
||||
}
|
||||
@@ -148,24 +148,30 @@ public class MobileNetworkUtilsTest {
|
||||
public void setMobileDataEnabled_setEnabled_enabled() {
|
||||
MobileNetworkUtils.setMobileDataEnabled(mContext, SUB_ID_1, true, false);
|
||||
|
||||
verify(mTelephonyManager).setDataEnabled(true);
|
||||
verify(mTelephonyManager2, never()).setDataEnabled(anyBoolean());
|
||||
verify(mTelephonyManager)
|
||||
.setDataEnabledForReason(TelephonyManager.DATA_ENABLED_REASON_USER, true);
|
||||
verify(mTelephonyManager2, never())
|
||||
.setDataEnabledForReason(anyInt(), anyBoolean());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void setMobileDataEnabled_setDisabled_disabled() {
|
||||
MobileNetworkUtils.setMobileDataEnabled(mContext, SUB_ID_2, true, false);
|
||||
|
||||
verify(mTelephonyManager2).setDataEnabled(true);
|
||||
verify(mTelephonyManager, never()).setDataEnabled(anyBoolean());
|
||||
verify(mTelephonyManager2)
|
||||
.setDataEnabledForReason(TelephonyManager.DATA_ENABLED_REASON_USER, true);
|
||||
verify(mTelephonyManager, never())
|
||||
.setDataEnabledForReason(anyInt(), anyBoolean());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void setMobileDataEnabled_disableOtherSubscriptions() {
|
||||
MobileNetworkUtils.setMobileDataEnabled(mContext, SUB_ID_1, true, true);
|
||||
|
||||
verify(mTelephonyManager).setDataEnabled(true);
|
||||
verify(mTelephonyManager2).setDataEnabled(false);
|
||||
verify(mTelephonyManager)
|
||||
.setDataEnabledForReason(TelephonyManager.DATA_ENABLED_REASON_USER, true);
|
||||
verify(mTelephonyManager2)
|
||||
.setDataEnabledForReason(TelephonyManager.DATA_ENABLED_REASON_USER, false);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
Reference in New Issue
Block a user