Snap for 8019117 from fdfb0bcf44 to tm-release
Change-Id: I1f6bf08f2d3b6f085db68aae89f845a9d4ebbb67
This commit is contained in:
@@ -675,12 +675,12 @@
|
|||||||
<activity android:name=".network.telephony.ToggleSubscriptionDialogActivity"
|
<activity android:name=".network.telephony.ToggleSubscriptionDialogActivity"
|
||||||
android:exported="false"
|
android:exported="false"
|
||||||
android:permission="android.permission.WRITE_EMBEDDED_SUBSCRIPTIONS"
|
android:permission="android.permission.WRITE_EMBEDDED_SUBSCRIPTIONS"
|
||||||
android:theme="@style/Theme.AlertDialog"/>
|
android:theme="@style/Theme.AlertDialog.SimConfirmDialog"/>
|
||||||
|
|
||||||
<activity android:name=".network.telephony.DeleteEuiccSubscriptionDialogActivity"
|
<activity android:name=".network.telephony.DeleteEuiccSubscriptionDialogActivity"
|
||||||
android:exported="false"
|
android:exported="false"
|
||||||
android:permission="android.permission.WRITE_EMBEDDED_SUBSCRIPTIONS"
|
android:permission="android.permission.WRITE_EMBEDDED_SUBSCRIPTIONS"
|
||||||
android:theme="@style/Theme.AlertDialog"/>
|
android:theme="@style/Theme.AlertDialog.SimConfirmDialog"/>
|
||||||
|
|
||||||
<activity
|
<activity
|
||||||
android:name="Settings$TetherSettingsActivity"
|
android:name="Settings$TetherSettingsActivity"
|
||||||
@@ -832,6 +832,18 @@
|
|||||||
android:theme="@style/Theme.LocalePickerWithRegionActivity">
|
android:theme="@style/Theme.LocalePickerWithRegionActivity">
|
||||||
</activity>
|
</activity>
|
||||||
|
|
||||||
|
<activity
|
||||||
|
android:name=".applications.appinfo.AppLocalePickerActivity"
|
||||||
|
android:label="@string/app_locale_picker_title"
|
||||||
|
android:exported="true" >
|
||||||
|
<intent-filter>
|
||||||
|
<action android:name="android.settings.APP_LOCALE_SETTINGS" />
|
||||||
|
<category android:name="android.intent.category.DEFAULT" />
|
||||||
|
</intent-filter>
|
||||||
|
<meta-data android:name="com.android.settings.FRAGMENT_CLASS"
|
||||||
|
android:value="com.android.settings.applications.appinfo.AppLocaleDetails" />
|
||||||
|
</activity>
|
||||||
|
|
||||||
<activity
|
<activity
|
||||||
android:name=".Settings$LanguageAndInputSettingsActivity"
|
android:name=".Settings$LanguageAndInputSettingsActivity"
|
||||||
android:label="@string/language_settings"
|
android:label="@string/language_settings"
|
||||||
@@ -3417,7 +3429,7 @@
|
|||||||
|
|
||||||
<activity
|
<activity
|
||||||
android:name=".sim.SimDialogActivity"
|
android:name=".sim.SimDialogActivity"
|
||||||
android:theme="@style/Theme.AlertDialog"
|
android:theme="@style/Theme.AlertDialog.SimConfirmDialog"
|
||||||
android:label="@string/sim_settings_title"
|
android:label="@string/sim_settings_title"
|
||||||
android:launchMode="singleTop"
|
android:launchMode="singleTop"
|
||||||
android:exported="true"
|
android:exported="true"
|
||||||
@@ -4268,14 +4280,14 @@
|
|||||||
android:exported="false"
|
android:exported="false"
|
||||||
android:permission="android.permission.WRITE_EMBEDDED_SUBSCRIPTIONS"
|
android:permission="android.permission.WRITE_EMBEDDED_SUBSCRIPTIONS"
|
||||||
android:launchMode="singleInstance"
|
android:launchMode="singleInstance"
|
||||||
android:theme="@style/Theme.AlertDialog"/>
|
android:theme="@style/Theme.AlertDialog.SimConfirmDialog"/>
|
||||||
|
|
||||||
<activity
|
<activity
|
||||||
android:name=".sim.DsdsDialogActivity"
|
android:name=".sim.DsdsDialogActivity"
|
||||||
android:exported="false"
|
android:exported="false"
|
||||||
android:permission="android.permission.WRITE_EMBEDDED_SUBSCRIPTIONS"
|
android:permission="android.permission.WRITE_EMBEDDED_SUBSCRIPTIONS"
|
||||||
android:launchMode="singleInstance"
|
android:launchMode="singleInstance"
|
||||||
android:theme="@style/Theme.AlertDialog"/>
|
android:theme="@style/Theme.AlertDialog.SimConfirmDialog"/>
|
||||||
|
|
||||||
<service android:name=".sim.SimNotificationService"
|
<service android:name=".sim.SimNotificationService"
|
||||||
android:permission="android.permission.BIND_JOB_SERVICE" />
|
android:permission="android.permission.BIND_JOB_SERVICE" />
|
||||||
|
|||||||
41
res/drawable/sim_confirm_dialog_btn_outline.xml
Normal file
41
res/drawable/sim_confirm_dialog_btn_outline.xml
Normal file
@@ -0,0 +1,41 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<!--
|
||||||
|
~ Copyright (C) 2021 The Android Open Source Project
|
||||||
|
~
|
||||||
|
~ Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
~ you may not use this file except in compliance with the License.
|
||||||
|
~ You may obtain a copy of the License at
|
||||||
|
~
|
||||||
|
~ http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
~
|
||||||
|
~ Unless required by applicable law or agreed to in writing, software
|
||||||
|
~ distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
~ See the License for the specific language governing permissions and
|
||||||
|
~ limitations under the License.
|
||||||
|
-->
|
||||||
|
<inset xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:androidprv="http://schemas.android.com/apk/prv/res/android"
|
||||||
|
android:insetTop="16dp"
|
||||||
|
android:insetBottom="24dp">
|
||||||
|
<ripple android:color="?android:attr/colorControlHighlight">
|
||||||
|
<item android:id="@android:id/mask">
|
||||||
|
<shape android:shape="rectangle">
|
||||||
|
<solid android:color="@android:color/white"/>
|
||||||
|
<corners android:radius="24dp"/>
|
||||||
|
</shape>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<shape android:shape="rectangle">
|
||||||
|
<corners android:radius="24dp"/>
|
||||||
|
<solid android:color="@android:color/transparent"/>
|
||||||
|
<stroke android:color="?androidprv:attr/colorAccentPrimaryVariant"
|
||||||
|
android:width="1dp" />
|
||||||
|
<padding android:left="16dp"
|
||||||
|
android:top="8dp"
|
||||||
|
android:right="16dp"
|
||||||
|
android:bottom="8dp"/>
|
||||||
|
</shape>
|
||||||
|
</item>
|
||||||
|
</ripple>
|
||||||
|
</inset>
|
||||||
30
res/drawable/sim_confirm_dialog_rounded_bg.xml
Normal file
30
res/drawable/sim_confirm_dialog_rounded_bg.xml
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<!--
|
||||||
|
Copyright (C) 2021 The Android Open Source Project
|
||||||
|
|
||||||
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
you may not use this file except in compliance with the License.
|
||||||
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
-->
|
||||||
|
<inset xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:insetLeft="24dp"
|
||||||
|
android:insetRight="24dp">
|
||||||
|
<shape xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:shape="rectangle">
|
||||||
|
<solid android:color="@color/settingslib_state_on_color"/>
|
||||||
|
<corners
|
||||||
|
android:bottomLeftRadius="8dp"
|
||||||
|
android:topLeftRadius="8dp"
|
||||||
|
android:bottomRightRadius="8dp"
|
||||||
|
android:topRightRadius="8dp"
|
||||||
|
/>
|
||||||
|
</shape>
|
||||||
|
</inset>
|
||||||
@@ -16,42 +16,26 @@
|
|||||||
|
|
||||||
<!-- Layout of a single item for displaying sim cards. -->
|
<!-- Layout of a single item for displaying sim cards. -->
|
||||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
android:orientation="horizontal"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:background="?android:attr/selectableItemBackground" >
|
|
||||||
|
|
||||||
<ImageView android:id="@+id/icon"
|
|
||||||
android:layout_width="48dp"
|
|
||||||
android:layout_height="48dp"
|
|
||||||
android:scaleType="center" />
|
|
||||||
|
|
||||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
|
||||||
android:orientation="vertical"
|
android:orientation="vertical"
|
||||||
android:layout_marginStart="15dip"
|
|
||||||
android:layout_marginEnd="6dip"
|
|
||||||
android:layout_marginTop="6dip"
|
|
||||||
android:layout_marginBottom="6dip"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_width="0dp"
|
|
||||||
android:layout_weight="1" >
|
|
||||||
<TextView android:id="@+id/title"
|
|
||||||
android:textAppearance="?android:attr/textAppearanceLarge"
|
|
||||||
android:gravity="start|center_vertical"
|
|
||||||
android:layout_marginLeft="8dp"
|
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
android:minHeight="?attr/listPreferredItemHeightSmall"
|
||||||
|
android:background="@drawable/sim_confirm_dialog_rounded_bg"
|
||||||
|
android:gravity="center">
|
||||||
|
<TextView android:id="@+id/title"
|
||||||
|
android:textAppearance="@style/TextAppearance.SimConfirmDialogList"
|
||||||
|
android:gravity="start|center_vertical"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
android:singleLine="true"
|
android:singleLine="true"
|
||||||
android:ellipsize="marquee"
|
android:ellipsize="marquee"
|
||||||
android:fadingEdge="horizontal" />
|
android:fadingEdge="horizontal" />
|
||||||
<TextView android:id="@+id/summary"
|
<TextView android:id="@+id/summary"
|
||||||
android:textAppearance="?android:attr/textAppearanceSmall"
|
android:textAppearance="@style/TextAppearance.SimConfirmDialogList.Summary"
|
||||||
android:gravity="start|center_vertical"
|
android:gravity="start|center_vertical"
|
||||||
android:layout_marginLeft="8dp"
|
android:layout_width="wrap_content"
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_below="@id/title"
|
android:layout_below="@id/title"
|
||||||
android:textColor="?android:attr/textColorSecondary"
|
android:textColor="?android:attr/textColorSecondary"
|
||||||
android:layout_alignStart="@id/title" />
|
android:layout_alignStart="@id/title" />
|
||||||
</LinearLayout>
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|||||||
@@ -0,0 +1,30 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<!-- Copyright (C) 2021 The Android Open Source Project
|
||||||
|
|
||||||
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
you may not use this file except in compliance with the License.
|
||||||
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
-->
|
||||||
|
|
||||||
|
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:id="@+id/title"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:minHeight="?attr/listPreferredItemHeightSmall"
|
||||||
|
style="?attr/materialAlertDialogBodyTextStyle"
|
||||||
|
android:gravity="center"
|
||||||
|
android:paddingTop="?attr/listPreferredItemPaddingStart"
|
||||||
|
android:paddingBottom="?attr/listPreferredItemPaddingEnd"
|
||||||
|
android:paddingLeft="?attr/listPreferredItemPaddingLeft"
|
||||||
|
android:paddingRight="?attr/listPreferredItemPaddingRight"
|
||||||
|
android:background="@drawable/sim_confirm_dialog_rounded_bg"
|
||||||
|
android:textAppearance="@style/TextAppearance.SimConfirmDialogList"
|
||||||
|
/>
|
||||||
@@ -16,42 +16,49 @@
|
|||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:orientation="vertical"
|
android:orientation="vertical">
|
||||||
style="@style/Theme.Material3.DayNight.Dialog.Alert">
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/msg"
|
android:id="@+id/msg"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"/>
|
android:layout_height="wrap_content"
|
||||||
|
android:paddingEnd="24dp"
|
||||||
|
android:paddingTop="16dp"
|
||||||
|
android:paddingStart="24dp"
|
||||||
|
android:gravity="center"
|
||||||
|
android:textAppearance="@style/TextAppearance.DialogMessage"/>
|
||||||
<ListView
|
<ListView
|
||||||
android:id="@+id/carrier_list"
|
android:id="@+id/carrier_list"
|
||||||
android:layout_width="wrap_content"
|
android:layout_gravity="center"
|
||||||
|
android:paddingTop="16dp"
|
||||||
|
android:dividerHeight="1dp"
|
||||||
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"/>
|
android:layout_height="wrap_content"/>
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
|
android:id="@+id/info_outline_layout"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:minWidth="56dp"
|
|
||||||
android:gravity="start|top"
|
android:gravity="start|top"
|
||||||
android:orientation="horizontal"
|
android:orientation="horizontal"
|
||||||
android:paddingEnd="12dp"
|
android:paddingEnd="24dp"
|
||||||
android:paddingTop="16dp"
|
android:paddingTop="16dp"
|
||||||
android:paddingBottom="4dp"
|
android:paddingStart="24dp"
|
||||||
|
android:layout_marginBottom="16dp"
|
||||||
android:baselineAligned="true">
|
android:baselineAligned="true">
|
||||||
<ImageView
|
<ImageView
|
||||||
android:src="@drawable/ic_info_outline_24dp"
|
android:src="@drawable/ic_info_outline_24dp"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:tint="?android:attr/textColorTertiary"/>
|
android:tint="?android:attr/textColorTertiary"/>
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/info_outline"
|
android:id="@+id/info_outline"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:paddingTop="16dp"
|
android:paddingLeft="16dp"
|
||||||
android:paddingBottom="8dp"
|
|
||||||
android:text="@string/sim_action_switch_sub_dialog_info_outline_for_turning_off"
|
android:text="@string/sim_action_switch_sub_dialog_info_outline_for_turning_off"
|
||||||
android:textColor="?android:attr/textColorSecondary" />
|
android:textColor="?android:attr/textColorSecondary"
|
||||||
|
android:textAppearance="@style/TextAppearance.DialogMessage"/>
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
@@ -0,0 +1,25 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<!-- Copyright (C) 2021 The Android Open Source Project
|
||||||
|
|
||||||
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
you may not use this file except in compliance with the License.
|
||||||
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
-->
|
||||||
|
|
||||||
|
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:id="@+id/title"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:paddingEnd="24dp"
|
||||||
|
android:paddingTop="16dp"
|
||||||
|
android:paddingLeft="24dp"
|
||||||
|
android:gravity="center"
|
||||||
|
style="?android:attr/textAppearanceLarge"/>
|
||||||
@@ -16,9 +16,18 @@
|
|||||||
-->
|
-->
|
||||||
|
|
||||||
<resources>
|
<resources>
|
||||||
|
<style name="Widget.ActionBar.Base" parent="@android:style/Widget.DeviceDefault.ActionBar.Solid">
|
||||||
<style name="Widget.ActionBar.Base" parent="@android:style/Widget.DeviceDefault.ActionBar.Solid">
|
|
||||||
<item name="android:background">?android:attr/colorPrimaryDark</item>
|
<item name="android:background">?android:attr/colorPrimaryDark</item>
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
|
<style name="TextAppearance.SimConfirmDialogList" parent="@style/TextAppearance.DialogMessage">
|
||||||
|
<item name="android:fontFamily">@*android:string/config_headlineFontFamily</item>
|
||||||
|
<item name="android:textColor">?android:attr/textColorPrimaryInverse</item>
|
||||||
|
</style>
|
||||||
|
|
||||||
|
<style name="TextAppearance.SimConfirmDialogList.Summary">
|
||||||
|
<item name="android:textAppearance">?android:attr/textAppearanceSmall</item>
|
||||||
|
<item name="android:fontFamily">@*android:string/config_headlineFontFamily</item>
|
||||||
|
<item name="android:textColor">?android:attr/textColorPrimaryInverse</item>
|
||||||
|
</style>
|
||||||
</resources>
|
</resources>
|
||||||
@@ -34,6 +34,12 @@
|
|||||||
<item name="android:colorBackground">@*android:color/surface_dark</item>
|
<item name="android:colorBackground">@*android:color/surface_dark</item>
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
|
<style name="Theme.AlertDialog.Base.Material3" parent="Theme.MaterialComponents.DayNight.Dialog.Alert">
|
||||||
|
<item name="colorPrimary">@*android:color/primary_device_default_settings</item>
|
||||||
|
<item name="colorAccent">@*android:color/accent_device_default_dark</item>
|
||||||
|
<item name="android:colorBackground">@*android:color/surface_dark</item>
|
||||||
|
</style>
|
||||||
|
|
||||||
<!-- Material theme for the pages containing TabLayout and ViewPager -->
|
<!-- Material theme for the pages containing TabLayout and ViewPager -->
|
||||||
<style name="Theme.TabTheme" parent="@style/Theme.MaterialComponents.DayNight">
|
<style name="Theme.TabTheme" parent="@style/Theme.MaterialComponents.DayNight">
|
||||||
<item name="colorPrimary">@*android:color/edge_effect_device_default_dark</item>
|
<item name="colorPrimary">@*android:color/edge_effect_device_default_dark</item>
|
||||||
|
|||||||
@@ -12968,7 +12968,7 @@
|
|||||||
<!-- Status message indicating the device is in the process of disconnecting from one mobile network and immediately connecting to another. [CHAR_LIMIT=NONE] -->
|
<!-- Status message indicating the device is in the process of disconnecting from one mobile network and immediately connecting to another. [CHAR_LIMIT=NONE] -->
|
||||||
<string name="sim_action_enabling_sim_without_carrier_name">Connecting to network…</string>
|
<string name="sim_action_enabling_sim_without_carrier_name">Connecting to network…</string>
|
||||||
<!-- Text of progress dialog indicating the subscription switch is in progress. [CHAR_LIMIT=NONE] -->
|
<!-- Text of progress dialog indicating the subscription switch is in progress. [CHAR_LIMIT=NONE] -->
|
||||||
<string name="sim_action_switch_sub_dialog_progress">Switching to <xliff:g id="carrier_name" example="Google Fi">%1$s</xliff:g></string>
|
<string name="sim_action_switch_sub_dialog_progress">Switching to <xliff:g id="carrier_name" example="Google Fi">%1$s</xliff:g> for calls and messages…</string>
|
||||||
<!-- Title of error message indicating that the device could not disconnect from one mobile network and immediately connect to another. [CHAR_LIMIT=NONE] -->
|
<!-- Title of error message indicating that the device could not disconnect from one mobile network and immediately connect to another. [CHAR_LIMIT=NONE] -->
|
||||||
<string name="sim_action_enable_sim_fail_title">Can\u2019t switch carrier</string>
|
<string name="sim_action_enable_sim_fail_title">Can\u2019t switch carrier</string>
|
||||||
<!-- Body text of error message indicating the device could not disconnect from one mobile network and immediately connect to another, due to an unspecified issue. [CHAR_LIMIT=NONE] -->
|
<!-- Body text of error message indicating the device could not disconnect from one mobile network and immediately connect to another, due to an unspecified issue. [CHAR_LIMIT=NONE] -->
|
||||||
|
|||||||
@@ -926,4 +926,25 @@
|
|||||||
parent="@*android:style/TextAppearance.DeviceDefault">
|
parent="@*android:style/TextAppearance.DeviceDefault">
|
||||||
<item name="android:textColor">?android:attr/textColorSecondary</item>
|
<item name="android:textColor">?android:attr/textColorSecondary</item>
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
|
<style name="TextAppearance.SimConfirmDialogList" parent="@style/TextAppearance.DialogMessage"/>
|
||||||
|
|
||||||
|
<style name="TextAppearance.SimConfirmDialogList.Summary">
|
||||||
|
<item name="android:textAppearance">?android:attr/textAppearanceSmall</item>
|
||||||
|
</style>
|
||||||
|
|
||||||
|
<style name="SimConfirmDialog.OutlineButton" parent="@android:style/Widget.Material.Button">
|
||||||
|
<item name="android:layout_marginStart">8dp</item>
|
||||||
|
<item name="android:layout_height">36dp</item>
|
||||||
|
<item name="android:minWidth">0dp</item>
|
||||||
|
<item name="android:textSize">14sp</item>
|
||||||
|
<item name="android:lineHeight">20sp</item>
|
||||||
|
<item name="android:fontFamily">@*android:string/config_bodyFontFamilyMedium</item>
|
||||||
|
<item name="android:textColor">?android:attr/textColorPrimary</item>
|
||||||
|
<item name="android:background">@drawable/sim_confirm_dialog_btn_outline</item>
|
||||||
|
</style>
|
||||||
|
|
||||||
|
<style name="SimConfirmDialog.ButtonBarStyle" parent="@android:style/Widget.Material.ButtonBar">
|
||||||
|
<item name="android:paddingEnd">8dp</item>
|
||||||
|
</style>
|
||||||
</resources>
|
</resources>
|
||||||
|
|||||||
@@ -151,6 +151,13 @@
|
|||||||
<item name="buttonBarButtonStyle">@*android:style/Widget.DeviceDefault.Button.ButtonBar.AlertDialog</item>
|
<item name="buttonBarButtonStyle">@*android:style/Widget.DeviceDefault.Button.ButtonBar.AlertDialog</item>
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
|
|
||||||
|
<style name="Theme.AlertDialog.SimConfirmDialog">
|
||||||
|
<item name="buttonBarStyle">@style/SimConfirmDialog.ButtonBarStyle</item>
|
||||||
|
<item name="buttonBarButtonStyle">@style/SimConfirmDialog.OutlineButton</item>
|
||||||
|
<item name="android:textAllCaps">false</item>
|
||||||
|
</style>
|
||||||
|
|
||||||
<style name="Theme.ConfirmDeviceCredentials" parent="Theme.SubSettings">
|
<style name="Theme.ConfirmDeviceCredentials" parent="Theme.SubSettings">
|
||||||
<item name="confirmDeviceCredentialsSideMargin">@dimen/confirm_credentials_side_margin</item>
|
<item name="confirmDeviceCredentialsSideMargin">@dimen/confirm_credentials_side_margin</item>
|
||||||
<item name="confirmDeviceCredentialsTopMargin">@dimen/confirm_credentials_top_margin</item>
|
<item name="confirmDeviceCredentialsTopMargin">@dimen/confirm_credentials_top_margin</item>
|
||||||
|
|||||||
@@ -16,6 +16,7 @@
|
|||||||
|
|
||||||
package com.android.settings;
|
package com.android.settings;
|
||||||
|
|
||||||
|
import android.content.ActivityNotFoundException;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
@@ -24,6 +25,7 @@ import android.telephony.SubscriptionManager;
|
|||||||
import android.telephony.ims.ImsRcsManager;
|
import android.telephony.ims.ImsRcsManager;
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
import android.util.FeatureFlagUtils;
|
import android.util.FeatureFlagUtils;
|
||||||
|
import android.util.Log;
|
||||||
|
|
||||||
import com.android.internal.annotations.VisibleForTesting;
|
import com.android.internal.annotations.VisibleForTesting;
|
||||||
import com.android.settings.core.FeatureFlags;
|
import com.android.settings.core.FeatureFlags;
|
||||||
@@ -31,6 +33,7 @@ import com.android.settings.enterprise.EnterprisePrivacySettings;
|
|||||||
import com.android.settings.network.SubscriptionUtil;
|
import com.android.settings.network.SubscriptionUtil;
|
||||||
import com.android.settings.network.telephony.MobileNetworkUtils;
|
import com.android.settings.network.telephony.MobileNetworkUtils;
|
||||||
import com.android.settings.overlay.FeatureFactory;
|
import com.android.settings.overlay.FeatureFactory;
|
||||||
|
import com.android.settings.safetycenter.SafetyCenterStatus;
|
||||||
import com.android.settings.security.SecuritySettingsFeatureProvider;
|
import com.android.settings.security.SecuritySettingsFeatureProvider;
|
||||||
|
|
||||||
import com.google.android.setupdesign.util.ThemeHelper;
|
import com.google.android.setupdesign.util.ThemeHelper;
|
||||||
@@ -136,6 +139,27 @@ public class Settings extends SettingsActivity {
|
|||||||
/** Activity for the security dashboard. */
|
/** Activity for the security dashboard. */
|
||||||
public static class SecurityDashboardActivity extends SettingsActivity {
|
public static class SecurityDashboardActivity extends SettingsActivity {
|
||||||
|
|
||||||
|
private static final String TAG = "SecurityDashboardActivity";
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onCreate(Bundle savedState) {
|
||||||
|
super.onCreate(savedState);
|
||||||
|
handleSafetyCenterRedirection();
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Redirects to SafetyCenter if enabled. */
|
||||||
|
@VisibleForTesting
|
||||||
|
public void handleSafetyCenterRedirection() {
|
||||||
|
if (SafetyCenterStatus.isEnabled()) {
|
||||||
|
try {
|
||||||
|
startActivity(new Intent(Intent.ACTION_SAFETY_CENTER));
|
||||||
|
finish();
|
||||||
|
} catch (ActivityNotFoundException e) {
|
||||||
|
Log.e(TAG, "Unable to open safety center", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/** Whether the given fragment is allowed. */
|
/** Whether the given fragment is allowed. */
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
@Override
|
@Override
|
||||||
@@ -171,7 +195,30 @@ public class Settings extends SettingsActivity {
|
|||||||
public static class LocationSettingsActivity extends SettingsActivity { /* empty */ }
|
public static class LocationSettingsActivity extends SettingsActivity { /* empty */ }
|
||||||
public static class ScanningSettingsActivity extends SettingsActivity { /* empty */ }
|
public static class ScanningSettingsActivity extends SettingsActivity { /* empty */ }
|
||||||
public static class WifiScanningSettingsActivity extends SettingsActivity { /* empty */ }
|
public static class WifiScanningSettingsActivity extends SettingsActivity { /* empty */ }
|
||||||
public static class PrivacyDashboardActivity extends SettingsActivity { /* empty */ }
|
/** Activity for the privacy dashboard. */
|
||||||
|
public static class PrivacyDashboardActivity extends SettingsActivity {
|
||||||
|
|
||||||
|
private static final String TAG = "PrivacyDashboardActivity";
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onCreate(Bundle savedState) {
|
||||||
|
super.onCreate(savedState);
|
||||||
|
handleSafetyCenterRedirection();
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Redirects to SafetyCenter if enabled. */
|
||||||
|
@VisibleForTesting
|
||||||
|
public void handleSafetyCenterRedirection() {
|
||||||
|
if (SafetyCenterStatus.isEnabled()) {
|
||||||
|
try {
|
||||||
|
startActivity(new Intent(Intent.ACTION_SAFETY_CENTER));
|
||||||
|
finish();
|
||||||
|
} catch (ActivityNotFoundException e) {
|
||||||
|
Log.e(TAG, "Unable to open safety center", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
public static class PrivacySettingsActivity extends SettingsActivity { /* empty */ }
|
public static class PrivacySettingsActivity extends SettingsActivity { /* empty */ }
|
||||||
public static class FactoryResetActivity extends SettingsActivity {
|
public static class FactoryResetActivity extends SettingsActivity {
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -270,9 +270,14 @@ public class AppLocaleDetails extends AppInfoBase implements RadioButtonPreferen
|
|||||||
/** Gets per app's default locale */
|
/** Gets per app's default locale */
|
||||||
public static Locale getAppDefaultLocale(Context context, String packageName) {
|
public static Locale getAppDefaultLocale(Context context, String packageName) {
|
||||||
LocaleManager localeManager = context.getSystemService(LocaleManager.class);
|
LocaleManager localeManager = context.getSystemService(LocaleManager.class);
|
||||||
|
try {
|
||||||
LocaleList localeList = (localeManager == null)
|
LocaleList localeList = (localeManager == null)
|
||||||
? new LocaleList() : localeManager.getApplicationLocales(packageName);
|
? new LocaleList() : localeManager.getApplicationLocales(packageName);
|
||||||
return localeList.isEmpty() ? null : localeList.get(0);
|
return localeList.isEmpty() ? null : localeList.get(0);
|
||||||
|
} catch (IllegalArgumentException e) {
|
||||||
|
Log.w(TAG, "package name : " + packageName + " is not correct. " + e);
|
||||||
|
}
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Sets per app's default language to system. */
|
/** Sets per app's default language to system. */
|
||||||
|
|||||||
@@ -0,0 +1,53 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2021 The Android Open Source Project
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
package com.android.settings.applications.appinfo;
|
||||||
|
|
||||||
|
import android.content.Intent;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.util.Log;
|
||||||
|
|
||||||
|
import androidx.annotation.VisibleForTesting;
|
||||||
|
|
||||||
|
import com.android.settings.SettingsActivity;
|
||||||
|
import com.android.settings.applications.AppInfoBase;
|
||||||
|
|
||||||
|
/** Activity for the entry of {@link #AppLocaleDetails} from outside Settings app. */
|
||||||
|
public class AppLocalePickerActivity extends SettingsActivity {
|
||||||
|
private static final String TAG = "AppLocalePickerActivity";
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onCreate(Bundle savedState) {
|
||||||
|
Intent intent = getEntryIntent(getIntent());
|
||||||
|
if (intent == null) {
|
||||||
|
finish();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
setIntent(intent);
|
||||||
|
super.onCreate(savedState);
|
||||||
|
}
|
||||||
|
|
||||||
|
@VisibleForTesting
|
||||||
|
Intent getEntryIntent(Intent intent) {
|
||||||
|
String callingPackage = getCallingPackage();
|
||||||
|
if (callingPackage == null || callingPackage.isEmpty()) {
|
||||||
|
Log.d(TAG, "No calling package name is found.");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
final Bundle fragmentArgs = new Bundle();
|
||||||
|
fragmentArgs.putString(AppInfoBase.ARG_PACKAGE_NAME, callingPackage);
|
||||||
|
return intent.putExtra(SettingsActivity.EXTRA_SHOW_FRAGMENT_ARGUMENTS, fragmentArgs);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -42,6 +42,7 @@ import com.android.settings.applications.ProcessStatsUi;
|
|||||||
import com.android.settings.applications.UsageAccessDetails;
|
import com.android.settings.applications.UsageAccessDetails;
|
||||||
import com.android.settings.applications.appinfo.AlarmsAndRemindersDetails;
|
import com.android.settings.applications.appinfo.AlarmsAndRemindersDetails;
|
||||||
import com.android.settings.applications.appinfo.AppInfoDashboardFragment;
|
import com.android.settings.applications.appinfo.AppInfoDashboardFragment;
|
||||||
|
import com.android.settings.applications.appinfo.AppLocaleDetails;
|
||||||
import com.android.settings.applications.appinfo.DrawOverlayDetails;
|
import com.android.settings.applications.appinfo.DrawOverlayDetails;
|
||||||
import com.android.settings.applications.appinfo.ExternalSourcesDetails;
|
import com.android.settings.applications.appinfo.ExternalSourcesDetails;
|
||||||
import com.android.settings.applications.appinfo.ManageExternalStorageDetails;
|
import com.android.settings.applications.appinfo.ManageExternalStorageDetails;
|
||||||
@@ -331,7 +332,8 @@ public class SettingsGateway {
|
|||||||
MediaManagementAppsDetails.class.getName(),
|
MediaManagementAppsDetails.class.getName(),
|
||||||
AutoBrightnessSettings.class.getName(),
|
AutoBrightnessSettings.class.getName(),
|
||||||
OneHandedSettings.class.getName(),
|
OneHandedSettings.class.getName(),
|
||||||
MobileNetworkSettings.class.getName()
|
MobileNetworkSettings.class.getName(),
|
||||||
|
AppLocaleDetails.class.getName()
|
||||||
};
|
};
|
||||||
|
|
||||||
public static final String[] SETTINGS_FOR_RESTRICTED = {
|
public static final String[] SETTINGS_FOR_RESTRICTED = {
|
||||||
|
|||||||
@@ -112,9 +112,7 @@ public class ConfirmDialogFragment extends BaseDialogFragment
|
|||||||
ArrayList<String> list = getArguments().getStringArrayList(ARG_LIST);
|
ArrayList<String> list = getArguments().getStringArrayList(ARG_LIST);
|
||||||
|
|
||||||
Log.i(TAG, "Showing dialog with title =" + title);
|
Log.i(TAG, "Showing dialog with title =" + title);
|
||||||
AlertDialog.Builder builder =
|
AlertDialog.Builder builder = new AlertDialog.Builder(getContext())
|
||||||
new AlertDialog.Builder(getContext())
|
|
||||||
.setTitle(title)
|
|
||||||
.setPositiveButton(posBtnString, this)
|
.setPositiveButton(posBtnString, this)
|
||||||
.setNegativeButton(negBtnString, this);
|
.setNegativeButton(negBtnString, this);
|
||||||
|
|
||||||
@@ -124,13 +122,22 @@ public class ConfirmDialogFragment extends BaseDialogFragment
|
|||||||
View content = LayoutInflater.from(getContext()).inflate(
|
View content = LayoutInflater.from(getContext()).inflate(
|
||||||
R.layout.sim_confirm_dialog_multiple_enabled_profiles_supported, null);
|
R.layout.sim_confirm_dialog_multiple_enabled_profiles_supported, null);
|
||||||
|
|
||||||
|
if (!TextUtils.isEmpty(title)) {
|
||||||
|
View titleView = LayoutInflater.from(getContext()).inflate(
|
||||||
|
R.layout.sim_confirm_dialog_title_multiple_enabled_profiles_supported,
|
||||||
|
null);
|
||||||
|
TextView titleTextView = titleView.findViewById(R.id.title);
|
||||||
|
titleTextView.setText(title);
|
||||||
|
builder.setCustomTitle(titleTextView);
|
||||||
|
}
|
||||||
TextView dialogMessage = content.findViewById(R.id.msg);
|
TextView dialogMessage = content.findViewById(R.id.msg);
|
||||||
if (!TextUtils.isEmpty(message) && dialogMessage != null) {
|
if (!TextUtils.isEmpty(message) && dialogMessage != null) {
|
||||||
dialogMessage.setText(message);
|
dialogMessage.setText(message);
|
||||||
}
|
}
|
||||||
|
|
||||||
final ArrayAdapter<String> arrayAdapterItems = new ArrayAdapter<String>(
|
final ArrayAdapter<String> arrayAdapterItems = new ArrayAdapter<String>(
|
||||||
getContext(), android.R.layout.select_dialog_item, list);
|
getContext(),
|
||||||
|
R.layout.sim_confirm_dialog_item_multiple_enabled_profiles_supported, list);
|
||||||
final ListView lvItems = content.findViewById(R.id.carrier_list);
|
final ListView lvItems = content.findViewById(R.id.carrier_list);
|
||||||
if (lvItems != null) {
|
if (lvItems != null) {
|
||||||
lvItems.setAdapter(arrayAdapterItems);
|
lvItems.setAdapter(arrayAdapterItems);
|
||||||
@@ -153,6 +160,9 @@ public class ConfirmDialogFragment extends BaseDialogFragment
|
|||||||
}
|
}
|
||||||
builder.setView(content);
|
builder.setView(content);
|
||||||
} else {
|
} else {
|
||||||
|
if (!TextUtils.isEmpty(title)) {
|
||||||
|
builder.setTitle(title);
|
||||||
|
}
|
||||||
if (!TextUtils.isEmpty(message)) {
|
if (!TextUtils.isEmpty(message)) {
|
||||||
builder.setMessage(message);
|
builder.setMessage(message);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -122,6 +122,7 @@ public class MobileDataPreferenceController extends TelephonyTogglePreferenceCon
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isChecked() {
|
public boolean isChecked() {
|
||||||
|
mTelephonyManager = getTelephonyManager();
|
||||||
return mTelephonyManager.isDataEnabled();
|
return mTelephonyManager.isDataEnabled();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -152,8 +153,21 @@ public class MobileDataPreferenceController extends TelephonyTogglePreferenceCon
|
|||||||
public void init(FragmentManager fragmentManager, int subId) {
|
public void init(FragmentManager fragmentManager, int subId) {
|
||||||
mFragmentManager = fragmentManager;
|
mFragmentManager = fragmentManager;
|
||||||
mSubId = subId;
|
mSubId = subId;
|
||||||
mTelephonyManager = mContext.getSystemService(TelephonyManager.class)
|
mTelephonyManager = null;
|
||||||
.createForSubscriptionId(mSubId);
|
mTelephonyManager = getTelephonyManager();
|
||||||
|
}
|
||||||
|
|
||||||
|
private TelephonyManager getTelephonyManager() {
|
||||||
|
if (mTelephonyManager != null) {
|
||||||
|
return mTelephonyManager;
|
||||||
|
}
|
||||||
|
TelephonyManager telMgr =
|
||||||
|
mContext.getSystemService(TelephonyManager.class);
|
||||||
|
if (mSubId != SubscriptionManager.INVALID_SUBSCRIPTION_ID) {
|
||||||
|
telMgr = telMgr.createForSubscriptionId(mSubId);
|
||||||
|
}
|
||||||
|
mTelephonyManager = telMgr;
|
||||||
|
return telMgr;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setWifiPickerTrackerHelper(WifiPickerTrackerHelper helper) {
|
public void setWifiPickerTrackerHelper(WifiPickerTrackerHelper helper) {
|
||||||
@@ -163,6 +177,7 @@ public class MobileDataPreferenceController extends TelephonyTogglePreferenceCon
|
|||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
boolean isDialogNeeded() {
|
boolean isDialogNeeded() {
|
||||||
final boolean enableData = !isChecked();
|
final boolean enableData = !isChecked();
|
||||||
|
mTelephonyManager = getTelephonyManager();
|
||||||
final boolean isMultiSim = (mTelephonyManager.getActiveModemCount() > 1);
|
final boolean isMultiSim = (mTelephonyManager.getActiveModemCount() > 1);
|
||||||
final int defaultSubId = mSubscriptionManager.getDefaultDataSubscriptionId();
|
final int defaultSubId = mSubscriptionManager.getDefaultDataSubscriptionId();
|
||||||
final boolean needToDisableOthers = mSubscriptionManager
|
final boolean needToDisableOthers = mSubscriptionManager
|
||||||
|
|||||||
@@ -0,0 +1,172 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2021 The Android Open Source Project
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.android.settings.sim;
|
||||||
|
|
||||||
|
import android.app.Dialog;
|
||||||
|
import android.app.settings.SettingsEnums;
|
||||||
|
import android.content.DialogInterface;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.telephony.SubscriptionInfo;
|
||||||
|
import android.telephony.SubscriptionManager;
|
||||||
|
import android.text.TextUtils;
|
||||||
|
import android.util.Log;
|
||||||
|
import android.view.LayoutInflater;
|
||||||
|
import android.view.View;
|
||||||
|
import android.widget.LinearLayout;
|
||||||
|
import android.widget.ListView;
|
||||||
|
import android.widget.TextView;
|
||||||
|
|
||||||
|
import androidx.annotation.NonNull;
|
||||||
|
import androidx.annotation.Nullable;
|
||||||
|
import androidx.annotation.VisibleForTesting;
|
||||||
|
import androidx.appcompat.app.AlertDialog;
|
||||||
|
|
||||||
|
import com.android.settings.R;
|
||||||
|
import com.android.settings.network.SubscriptionUtil;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Presents a dialog asking the user if they want to switch the data to another sim
|
||||||
|
*/
|
||||||
|
public class SelectSpecificDataSimDialogFragment extends SimDialogFragment implements
|
||||||
|
DialogInterface.OnClickListener {
|
||||||
|
private static final String TAG = "PreferredSimDialogFrag";
|
||||||
|
|
||||||
|
private SubscriptionInfo mSubscriptionInfo;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the dialog fragment.
|
||||||
|
*/
|
||||||
|
public static SelectSpecificDataSimDialogFragment newInstance() {
|
||||||
|
final SelectSpecificDataSimDialogFragment
|
||||||
|
fragment = new SelectSpecificDataSimDialogFragment();
|
||||||
|
final Bundle args = initArguments(SimDialogActivity.DATA_PICK,
|
||||||
|
R.string.select_specific_sim_for_data_title);
|
||||||
|
fragment.setArguments(args);
|
||||||
|
return fragment;
|
||||||
|
}
|
||||||
|
|
||||||
|
@NonNull
|
||||||
|
@Override
|
||||||
|
public Dialog onCreateDialog(@Nullable Bundle savedInstanceState) {
|
||||||
|
final AlertDialog dialog = new AlertDialog.Builder(getContext())
|
||||||
|
.setNegativeButton(R.string.sim_action_no_thanks, null)
|
||||||
|
.create();
|
||||||
|
updateDialog(dialog);
|
||||||
|
return dialog;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onClick(DialogInterface dialog, int buttonClicked) {
|
||||||
|
if (buttonClicked != DialogInterface.BUTTON_POSITIVE) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
final SimDialogActivity activity = (SimDialogActivity) getActivity();
|
||||||
|
final SubscriptionInfo info = getTargetSubscriptionInfo();
|
||||||
|
if (info != null) {
|
||||||
|
activity.onSubscriptionSelected(getDialogType(), info.getSubscriptionId());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private SubscriptionInfo getNonDefaultDataSubscriptionInfo(SubscriptionInfo dds) {
|
||||||
|
List<SubscriptionInfo> subInfos = getSubscriptionManager().getActiveSubscriptionInfoList();
|
||||||
|
if (subInfos == null || dds == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return subInfos.stream().filter(subinfo -> subinfo != dds).findFirst().orElse(null);
|
||||||
|
}
|
||||||
|
|
||||||
|
private SubscriptionInfo getDefaultDataSubId() {
|
||||||
|
return getSubscriptionManager().getDefaultDataSubscriptionInfo();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void updateDialog(AlertDialog dialog) {
|
||||||
|
Log.d(TAG, "Dialog updated, dismiss status: " + mWasDismissed);
|
||||||
|
if (mWasDismissed) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
SubscriptionInfo activeSubInfo = getDefaultDataSubId();
|
||||||
|
SubscriptionInfo newSubInfo = getNonDefaultDataSubscriptionInfo(activeSubInfo);
|
||||||
|
|
||||||
|
if (newSubInfo == null || activeSubInfo == null) {
|
||||||
|
dismiss();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
setTargetSubscriptionInfo(newSubInfo);
|
||||||
|
|
||||||
|
CharSequence newDataCarrierName = SubscriptionUtil.getUniqueSubscriptionDisplayName(
|
||||||
|
newSubInfo, getContext());
|
||||||
|
CharSequence currentDataCarrierName = SubscriptionUtil.getUniqueSubscriptionDisplayName(
|
||||||
|
activeSubInfo, getContext());
|
||||||
|
|
||||||
|
String positive = getContext().getString(
|
||||||
|
R.string.select_specific_sim_for_data_button, newDataCarrierName);
|
||||||
|
String message = getContext().getString(R.string.select_specific_sim_for_data_msg,
|
||||||
|
newDataCarrierName, currentDataCarrierName);
|
||||||
|
|
||||||
|
View content = LayoutInflater.from(getContext()).inflate(
|
||||||
|
R.layout.sim_confirm_dialog_multiple_enabled_profiles_supported, null);
|
||||||
|
TextView dialogMessage = content.findViewById(R.id.msg);
|
||||||
|
if (!TextUtils.isEmpty(message) && dialogMessage != null) {
|
||||||
|
dialogMessage.setText(message);
|
||||||
|
}
|
||||||
|
|
||||||
|
final ListView lvItems = content.findViewById(R.id.carrier_list);
|
||||||
|
if (lvItems != null) {
|
||||||
|
lvItems.setVisibility(View.GONE);
|
||||||
|
}
|
||||||
|
final LinearLayout infoOutline = content.findViewById(R.id.info_outline_layout);
|
||||||
|
if (infoOutline != null) {
|
||||||
|
infoOutline.setVisibility(View.GONE);
|
||||||
|
}
|
||||||
|
dialog.setView(content);
|
||||||
|
|
||||||
|
View titleView = LayoutInflater.from(getContext()).inflate(
|
||||||
|
R.layout.sim_confirm_dialog_title_multiple_enabled_profiles_supported, null);
|
||||||
|
TextView titleTextView = titleView.findViewById(R.id.title);
|
||||||
|
titleTextView.setText(getContext().getString(getTitleResId(), newDataCarrierName));
|
||||||
|
|
||||||
|
dialog.setCustomTitle(titleTextView);
|
||||||
|
dialog.setButton(AlertDialog.BUTTON_POSITIVE, positive, this);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setTargetSubscriptionInfo(SubscriptionInfo subInfo) {
|
||||||
|
mSubscriptionInfo = subInfo;
|
||||||
|
}
|
||||||
|
|
||||||
|
private SubscriptionInfo getTargetSubscriptionInfo() {
|
||||||
|
return mSubscriptionInfo;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void updateDialog() {
|
||||||
|
updateDialog((AlertDialog) getDialog());
|
||||||
|
}
|
||||||
|
|
||||||
|
@VisibleForTesting
|
||||||
|
protected SubscriptionManager getSubscriptionManager() {
|
||||||
|
return getContext().getSystemService(SubscriptionManager.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getMetricsCategory() {
|
||||||
|
return SettingsEnums.DIALOG_PREFERRED_SIM_PICKER;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -95,15 +95,16 @@ public class SimDialogActivity extends FragmentActivity {
|
|||||||
private SimDialogFragment createFragment(int dialogType) {
|
private SimDialogFragment createFragment(int dialogType) {
|
||||||
switch (dialogType) {
|
switch (dialogType) {
|
||||||
case DATA_PICK:
|
case DATA_PICK:
|
||||||
return SimListDialogFragment.newInstance(dialogType, R.string.select_sim_for_data,
|
return getDataPickDialogFramgent();
|
||||||
false /* includeAskEveryTime */);
|
|
||||||
case CALLS_PICK:
|
case CALLS_PICK:
|
||||||
return CallsSimListDialogFragment.newInstance(dialogType,
|
return CallsSimListDialogFragment.newInstance(dialogType,
|
||||||
R.string.select_sim_for_calls,
|
R.string.select_sim_for_calls,
|
||||||
true /* includeAskEveryTime */);
|
true /* includeAskEveryTime */,
|
||||||
|
false /* isCancelItemShowed */);
|
||||||
case SMS_PICK:
|
case SMS_PICK:
|
||||||
return SimListDialogFragment.newInstance(dialogType, R.string.select_sim_for_sms,
|
return SimListDialogFragment.newInstance(dialogType, R.string.select_sim_for_sms,
|
||||||
true /* includeAskEveryTime */);
|
true /* includeAskEveryTime */,
|
||||||
|
false /* isCancelItemShowed */);
|
||||||
case PREFERRED_PICK:
|
case PREFERRED_PICK:
|
||||||
if (!getIntent().hasExtra(PREFERRED_SIM)) {
|
if (!getIntent().hasExtra(PREFERRED_SIM)) {
|
||||||
throw new IllegalArgumentException("Missing required extra " + PREFERRED_SIM);
|
throw new IllegalArgumentException("Missing required extra " + PREFERRED_SIM);
|
||||||
@@ -111,12 +112,23 @@ public class SimDialogActivity extends FragmentActivity {
|
|||||||
return PreferredSimDialogFragment.newInstance();
|
return PreferredSimDialogFragment.newInstance();
|
||||||
case SMS_PICK_FOR_MESSAGE:
|
case SMS_PICK_FOR_MESSAGE:
|
||||||
return SimListDialogFragment.newInstance(dialogType, R.string.select_sim_for_sms,
|
return SimListDialogFragment.newInstance(dialogType, R.string.select_sim_for_sms,
|
||||||
false /* includeAskEveryTime */);
|
false /* includeAskEveryTime */,
|
||||||
|
false /* isCancelItemShowed */);
|
||||||
default:
|
default:
|
||||||
throw new IllegalArgumentException("Invalid dialog type " + dialogType + " sent.");
|
throw new IllegalArgumentException("Invalid dialog type " + dialogType + " sent.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private SimDialogFragment getDataPickDialogFramgent() {
|
||||||
|
if (SubscriptionManager.getDefaultDataSubscriptionId()
|
||||||
|
== SubscriptionManager.INVALID_SUBSCRIPTION_ID) {
|
||||||
|
return SimListDialogFragment.newInstance(DATA_PICK, R.string.select_sim_for_data,
|
||||||
|
false /* includeAskEveryTime */,
|
||||||
|
true /* isCancelItemShowed */);
|
||||||
|
}
|
||||||
|
return SelectSpecificDataSimDialogFragment.newInstance();
|
||||||
|
}
|
||||||
|
|
||||||
public void onSubscriptionSelected(int dialogType, int subId) {
|
public void onSubscriptionSelected(int dialogType, int subId) {
|
||||||
if (getSupportFragmentManager().findFragmentByTag(Integer.toString(dialogType)) == null) {
|
if (getSupportFragmentManager().findFragmentByTag(Integer.toString(dialogType)) == null) {
|
||||||
Log.w(TAG, "onSubscriptionSelected ignored because stored fragment was null");
|
Log.w(TAG, "onSubscriptionSelected ignored because stored fragment was null");
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ import android.view.LayoutInflater;
|
|||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.widget.BaseAdapter;
|
import android.widget.BaseAdapter;
|
||||||
import android.widget.ImageView;
|
import android.widget.ListView;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
@@ -38,7 +38,6 @@ import androidx.annotation.VisibleForTesting;
|
|||||||
import androidx.appcompat.app.AlertDialog;
|
import androidx.appcompat.app.AlertDialog;
|
||||||
|
|
||||||
import com.android.settings.R;
|
import com.android.settings.R;
|
||||||
import com.android.settings.Utils;
|
|
||||||
import com.android.settings.network.SubscriptionUtil;
|
import com.android.settings.network.SubscriptionUtil;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@@ -52,16 +51,19 @@ public class SimListDialogFragment extends SimDialogFragment implements
|
|||||||
DialogInterface.OnClickListener {
|
DialogInterface.OnClickListener {
|
||||||
private static final String TAG = "SimListDialogFragment";
|
private static final String TAG = "SimListDialogFragment";
|
||||||
protected static final String KEY_INCLUDE_ASK_EVERY_TIME = "include_ask_every_time";
|
protected static final String KEY_INCLUDE_ASK_EVERY_TIME = "include_ask_every_time";
|
||||||
|
protected static final String KEY_SHOW_CANCEL_ITEM = "show_cancel_item";
|
||||||
|
private static final int LIST_VIEW_DIVIDER_LINE_WEIGHT = 2;
|
||||||
|
|
||||||
protected SelectSubscriptionAdapter mAdapter;
|
protected SelectSubscriptionAdapter mAdapter;
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
List<SubscriptionInfo> mSubscriptions;
|
List<SubscriptionInfo> mSubscriptions;
|
||||||
|
|
||||||
public static SimListDialogFragment newInstance(int dialogType, int titleResId,
|
public static SimListDialogFragment newInstance(int dialogType, int titleResId,
|
||||||
boolean includeAskEveryTime) {
|
boolean includeAskEveryTime, boolean isCancelItemShowed) {
|
||||||
final SimListDialogFragment fragment = new SimListDialogFragment();
|
final SimListDialogFragment fragment = new SimListDialogFragment();
|
||||||
final Bundle args = initArguments(dialogType, titleResId);
|
final Bundle args = initArguments(dialogType, titleResId);
|
||||||
args.putBoolean(KEY_INCLUDE_ASK_EVERY_TIME, includeAskEveryTime);
|
args.putBoolean(KEY_INCLUDE_ASK_EVERY_TIME, includeAskEveryTime);
|
||||||
|
args.putBoolean(KEY_SHOW_CANCEL_ITEM, isCancelItemShowed);
|
||||||
fragment.setArguments(args);
|
fragment.setArguments(args);
|
||||||
return fragment;
|
return fragment;
|
||||||
}
|
}
|
||||||
@@ -72,12 +74,20 @@ public class SimListDialogFragment extends SimDialogFragment implements
|
|||||||
mSubscriptions = new ArrayList<>();
|
mSubscriptions = new ArrayList<>();
|
||||||
|
|
||||||
final AlertDialog.Builder builder = new AlertDialog.Builder(getContext());
|
final AlertDialog.Builder builder = new AlertDialog.Builder(getContext());
|
||||||
builder.setTitle(getTitleResId());
|
View titleView = LayoutInflater.from(getContext()).inflate(
|
||||||
|
R.layout.sim_confirm_dialog_title_multiple_enabled_profiles_supported, null);
|
||||||
|
TextView titleTextView = titleView.findViewById(R.id.title);
|
||||||
|
titleTextView.setText(getContext().getString(getTitleResId()));
|
||||||
|
builder.setCustomTitle(titleTextView);
|
||||||
|
|
||||||
mAdapter = new SelectSubscriptionAdapter(builder.getContext(), mSubscriptions);
|
mAdapter = new SelectSubscriptionAdapter(builder.getContext(), mSubscriptions);
|
||||||
|
|
||||||
setAdapter(builder);
|
setAdapter(builder);
|
||||||
final Dialog dialog = builder.create();
|
|
||||||
|
final AlertDialog dialog = builder.create();
|
||||||
|
ListView listView = dialog.getListView();
|
||||||
|
if (listView != null) {
|
||||||
|
listView.setDividerHeight(LIST_VIEW_DIVIDER_LINE_WEIGHT);
|
||||||
|
}
|
||||||
updateDialog();
|
updateDialog();
|
||||||
return dialog;
|
return dialog;
|
||||||
}
|
}
|
||||||
@@ -112,10 +122,22 @@ public class SimListDialogFragment extends SimDialogFragment implements
|
|||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (getArguments().getBoolean(KEY_INCLUDE_ASK_EVERY_TIME)) {
|
boolean includeAskEveryTime = getArguments().getBoolean(KEY_INCLUDE_ASK_EVERY_TIME);
|
||||||
final List<SubscriptionInfo> tmp = new ArrayList<>(currentSubscriptions.size() + 1);
|
boolean isCancelItemShowed = getArguments().getBoolean(KEY_SHOW_CANCEL_ITEM);
|
||||||
|
if (includeAskEveryTime || isCancelItemShowed) {
|
||||||
|
int arraySize = currentSubscriptions.size()
|
||||||
|
+ (includeAskEveryTime ? 1 : 0)
|
||||||
|
+ (isCancelItemShowed ? 1 : 0);
|
||||||
|
final List<SubscriptionInfo> tmp = new ArrayList<>(arraySize);
|
||||||
|
if (includeAskEveryTime) {
|
||||||
|
// add the value of 'AskEveryTime' item
|
||||||
tmp.add(null);
|
tmp.add(null);
|
||||||
|
}
|
||||||
tmp.addAll(currentSubscriptions);
|
tmp.addAll(currentSubscriptions);
|
||||||
|
if (isCancelItemShowed) {
|
||||||
|
// add the value of 'Cancel' item
|
||||||
|
tmp.add(null);
|
||||||
|
}
|
||||||
currentSubscriptions = tmp;
|
currentSubscriptions = tmp;
|
||||||
}
|
}
|
||||||
if (currentSubscriptions.equals(mSubscriptions)) {
|
if (currentSubscriptions.equals(mSubscriptions)) {
|
||||||
@@ -177,19 +199,23 @@ public class SimListDialogFragment extends SimDialogFragment implements
|
|||||||
|
|
||||||
final TextView title = convertView.findViewById(R.id.title);
|
final TextView title = convertView.findViewById(R.id.title);
|
||||||
final TextView summary = convertView.findViewById(R.id.summary);
|
final TextView summary = convertView.findViewById(R.id.summary);
|
||||||
final ImageView icon = convertView.findViewById(R.id.icon);
|
|
||||||
|
|
||||||
if (sub == null) {
|
if (sub == null) {
|
||||||
|
if (position == 0) {
|
||||||
title.setText(R.string.sim_calls_ask_first_prefs_title);
|
title.setText(R.string.sim_calls_ask_first_prefs_title);
|
||||||
summary.setText("");
|
} else {
|
||||||
icon.setImageDrawable(mContext.getDrawable(R.drawable.ic_feedback_24dp));
|
title.setText(R.string.sim_action_cancel);
|
||||||
icon.setImageTintList(
|
}
|
||||||
Utils.getColorAttr(mContext, android.R.attr.textColorSecondary));
|
summary.setVisibility(View.GONE);
|
||||||
} else {
|
} else {
|
||||||
title.setText(SubscriptionUtil.getUniqueSubscriptionDisplayName(sub, mContext));
|
title.setText(SubscriptionUtil.getUniqueSubscriptionDisplayName(sub, mContext));
|
||||||
summary.setText(isMdnProvisioned(sub.getNumber()) ? sub.getNumber() : "");
|
String phoneNumber = isMdnProvisioned(sub.getNumber()) ? sub.getNumber() : "";
|
||||||
icon.setImageBitmap(sub.createIconBitmap(mContext));
|
if (!TextUtils.isEmpty(phoneNumber)) {
|
||||||
|
summary.setVisibility(View.VISIBLE);
|
||||||
|
summary.setText(phoneNumber);
|
||||||
|
} else {
|
||||||
|
summary.setVisibility(View.GONE);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return convertView;
|
return convertView;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -53,7 +53,8 @@ public class SimListDialogFragmentTest extends SimDialogFragmentTestBase<SimList
|
|||||||
final int dialogType = DATA_PICK;
|
final int dialogType = DATA_PICK;
|
||||||
setDialogType(dialogType);
|
setDialogType(dialogType);
|
||||||
mFragment = spy(SimListDialogFragment.newInstance(dialogType, R.string.select_sim_for_data,
|
mFragment = spy(SimListDialogFragment.newInstance(dialogType, R.string.select_sim_for_data,
|
||||||
false /* includeAskEveryTime */));
|
false /* includeAskEveryTime */,
|
||||||
|
false /* isCancelItemShowed */));
|
||||||
doReturn(null).when(mFragment).getCurrentSubscriptions();
|
doReturn(null).when(mFragment).getCurrentSubscriptions();
|
||||||
startDialog();
|
startDialog();
|
||||||
verify(mFragment).dismiss();
|
verify(mFragment).dismiss();
|
||||||
@@ -64,7 +65,8 @@ public class SimListDialogFragmentTest extends SimDialogFragmentTestBase<SimList
|
|||||||
final int dialogType = DATA_PICK;
|
final int dialogType = DATA_PICK;
|
||||||
setDialogType(dialogType);
|
setDialogType(dialogType);
|
||||||
mFragment = spy(SimListDialogFragment.newInstance(dialogType, R.string.select_sim_for_data,
|
mFragment = spy(SimListDialogFragment.newInstance(dialogType, R.string.select_sim_for_data,
|
||||||
false /* includeAskEveryTime */));
|
false /* includeAskEveryTime */,
|
||||||
|
false /* isCancelItemShowed */));
|
||||||
doReturn(Arrays.asList(mSim1, mSim2)).when(mFragment).getCurrentSubscriptions();
|
doReturn(Arrays.asList(mSim1, mSim2)).when(mFragment).getCurrentSubscriptions();
|
||||||
// Avoid problems robolectric has with our real adapter.
|
// Avoid problems robolectric has with our real adapter.
|
||||||
doNothing().when(mFragment).setAdapter(any());
|
doNothing().when(mFragment).setAdapter(any());
|
||||||
@@ -84,7 +86,8 @@ public class SimListDialogFragmentTest extends SimDialogFragmentTestBase<SimList
|
|||||||
final int dialogType = DATA_PICK;
|
final int dialogType = DATA_PICK;
|
||||||
setDialogType(dialogType);
|
setDialogType(dialogType);
|
||||||
mFragment = spy(SimListDialogFragment.newInstance(dialogType, R.string.select_sim_for_data,
|
mFragment = spy(SimListDialogFragment.newInstance(dialogType, R.string.select_sim_for_data,
|
||||||
false /* includeAskEveryTime */));
|
false /* includeAskEveryTime */,
|
||||||
|
false /* isCancelItemShowed */));
|
||||||
doReturn(Arrays.asList(mSim1, mSim2)).when(mFragment).getCurrentSubscriptions();
|
doReturn(Arrays.asList(mSim1, mSim2)).when(mFragment).getCurrentSubscriptions();
|
||||||
// Avoid problems robolectric has with our real adapter.
|
// Avoid problems robolectric has with our real adapter.
|
||||||
doNothing().when(mFragment).setAdapter(any());
|
doNothing().when(mFragment).setAdapter(any());
|
||||||
@@ -101,7 +104,8 @@ public class SimListDialogFragmentTest extends SimDialogFragmentTestBase<SimList
|
|||||||
final int dialogType = SMS_PICK;
|
final int dialogType = SMS_PICK;
|
||||||
setDialogType(dialogType);
|
setDialogType(dialogType);
|
||||||
mFragment = spy(SimListDialogFragment.newInstance(dialogType, R.string.select_sim_for_sms,
|
mFragment = spy(SimListDialogFragment.newInstance(dialogType, R.string.select_sim_for_sms,
|
||||||
true /* includeAskEveryTime */));
|
true /* includeAskEveryTime */,
|
||||||
|
false /* isCancelItemShowed */));
|
||||||
doReturn(Arrays.asList(mSim1, mSim2)).when(mFragment).getCurrentSubscriptions();
|
doReturn(Arrays.asList(mSim1, mSim2)).when(mFragment).getCurrentSubscriptions();
|
||||||
// Avoid problems robolectric has with our real adapter.
|
// Avoid problems robolectric has with our real adapter.
|
||||||
doNothing().when(mFragment).setAdapter(any());
|
doNothing().when(mFragment).setAdapter(any());
|
||||||
|
|||||||
@@ -0,0 +1,87 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2021 The Android Open Source Project
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.android.settings.applications.appinfo;
|
||||||
|
|
||||||
|
import static com.google.common.truth.Truth.assertThat;
|
||||||
|
|
||||||
|
import android.content.Intent;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.os.Looper;
|
||||||
|
|
||||||
|
import androidx.test.annotation.UiThreadTest;
|
||||||
|
import androidx.test.ext.junit.runners.AndroidJUnit4;
|
||||||
|
|
||||||
|
import com.android.settings.SettingsActivity;
|
||||||
|
import com.android.settings.applications.AppInfoBase;
|
||||||
|
|
||||||
|
import org.junit.After;
|
||||||
|
import org.junit.Before;
|
||||||
|
import org.junit.Test;
|
||||||
|
import org.junit.runner.RunWith;
|
||||||
|
|
||||||
|
@RunWith(AndroidJUnit4.class)
|
||||||
|
public class AppLocalePickerActivityTest {
|
||||||
|
private TestAppLocalePickerActivity mActivity;
|
||||||
|
|
||||||
|
@Before
|
||||||
|
@UiThreadTest
|
||||||
|
public void setUp() {
|
||||||
|
if (Looper.myLooper() == null) {
|
||||||
|
Looper.prepare();
|
||||||
|
}
|
||||||
|
mActivity = new TestAppLocalePickerActivity();
|
||||||
|
}
|
||||||
|
|
||||||
|
@After
|
||||||
|
public void cleanUp() {
|
||||||
|
mActivity = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void onCreate_getEntryIntent_returnNull() {
|
||||||
|
TestAppLocalePickerActivity.setCallingPackage(null);
|
||||||
|
Intent intent = new Intent();
|
||||||
|
|
||||||
|
assertThat(mActivity.getEntryIntent(intent)).isEqualTo(null);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void onCreate_getEntryIntent_returnIntentWithPackageName() {
|
||||||
|
String callingPackageName = "com.example.android";
|
||||||
|
TestAppLocalePickerActivity.setCallingPackage(callingPackageName);
|
||||||
|
Intent intent = new Intent();
|
||||||
|
|
||||||
|
Intent entryIntent = mActivity.getEntryIntent(intent);
|
||||||
|
|
||||||
|
Bundle outputBundle =
|
||||||
|
entryIntent.getBundleExtra(SettingsActivity.EXTRA_SHOW_FRAGMENT_ARGUMENTS);
|
||||||
|
String packageName = outputBundle.getString(AppInfoBase.ARG_PACKAGE_NAME);
|
||||||
|
assertThat(packageName).isEqualTo(callingPackageName);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static class TestAppLocalePickerActivity extends AppLocalePickerActivity {
|
||||||
|
private static String sCallingPackage;
|
||||||
|
@Override
|
||||||
|
public String getCallingPackage() {
|
||||||
|
return sCallingPackage;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void setCallingPackage(String packageName) {
|
||||||
|
sCallingPackage = packageName;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,107 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2021 The Android Open Source Project
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.android.settings.privacy;
|
||||||
|
|
||||||
|
import static com.google.common.truth.Truth.assertThat;
|
||||||
|
|
||||||
|
import static org.mockito.ArgumentMatchers.any;
|
||||||
|
import static org.mockito.Mockito.doNothing;
|
||||||
|
import static org.mockito.Mockito.spy;
|
||||||
|
import static org.mockito.Mockito.times;
|
||||||
|
import static org.mockito.Mockito.verify;
|
||||||
|
|
||||||
|
import android.content.Intent;
|
||||||
|
import android.provider.DeviceConfig;
|
||||||
|
|
||||||
|
import androidx.test.ext.junit.runners.AndroidJUnit4;
|
||||||
|
import androidx.test.platform.app.InstrumentationRegistry;
|
||||||
|
|
||||||
|
import com.android.settings.Settings;
|
||||||
|
import com.android.settings.SettingsActivity;
|
||||||
|
import com.android.settings.safetycenter.SafetyCenterStatus;
|
||||||
|
|
||||||
|
import org.junit.After;
|
||||||
|
import org.junit.Before;
|
||||||
|
import org.junit.Test;
|
||||||
|
import org.junit.runner.RunWith;
|
||||||
|
import org.mockito.ArgumentCaptor;
|
||||||
|
|
||||||
|
@RunWith(AndroidJUnit4.class)
|
||||||
|
public class PrivacyDashboardActivityTest {
|
||||||
|
|
||||||
|
private static final String DEFAULT_FRAGMENT_CLASSNAME = "DefaultFragmentClassname";
|
||||||
|
|
||||||
|
private Settings.PrivacyDashboardActivity mActivity;
|
||||||
|
|
||||||
|
@Before
|
||||||
|
public void setUp() {
|
||||||
|
DeviceConfig.resetToDefaults(android.provider.Settings.RESET_MODE_PACKAGE_DEFAULTS,
|
||||||
|
DeviceConfig.NAMESPACE_PRIVACY);
|
||||||
|
final Intent intent = new Intent();
|
||||||
|
intent.setAction(android.provider.Settings.ACTION_PRIVACY_SETTINGS);
|
||||||
|
intent.setClass(InstrumentationRegistry.getInstrumentation().getTargetContext(),
|
||||||
|
Settings.PrivacyDashboardActivity.class);
|
||||||
|
intent.putExtra(SettingsActivity.EXTRA_SHOW_FRAGMENT, DEFAULT_FRAGMENT_CLASSNAME);
|
||||||
|
InstrumentationRegistry.getInstrumentation().runOnMainSync(() -> {
|
||||||
|
try {
|
||||||
|
mActivity =
|
||||||
|
spy((Settings.PrivacyDashboardActivity) InstrumentationRegistry
|
||||||
|
.getInstrumentation().newActivity(
|
||||||
|
getClass().getClassLoader(),
|
||||||
|
Settings.PrivacyDashboardActivity.class.getName(),
|
||||||
|
intent));
|
||||||
|
} catch (Exception e) {
|
||||||
|
throw new RuntimeException(e); // nothing to do
|
||||||
|
}
|
||||||
|
});
|
||||||
|
doNothing().when(mActivity).startActivity(any(Intent.class));
|
||||||
|
}
|
||||||
|
|
||||||
|
@After
|
||||||
|
public void tearDown() {
|
||||||
|
DeviceConfig.resetToDefaults(android.provider.Settings.RESET_MODE_PACKAGE_DEFAULTS,
|
||||||
|
DeviceConfig.NAMESPACE_PRIVACY);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void onCreate_whenSafetyCenterEnabled_redirectsToSafetyCenter() {
|
||||||
|
DeviceConfig.setProperty(
|
||||||
|
DeviceConfig.NAMESPACE_PRIVACY,
|
||||||
|
SafetyCenterStatus.SAFETY_CENTER_IS_ENABLED,
|
||||||
|
/* value = */ Boolean.toString(true),
|
||||||
|
/* makeDefault = */ false);
|
||||||
|
final ArgumentCaptor<Intent> intentCaptor = ArgumentCaptor.forClass(Intent.class);
|
||||||
|
|
||||||
|
mActivity.handleSafetyCenterRedirection();
|
||||||
|
|
||||||
|
verify(mActivity).startActivity(intentCaptor.capture());
|
||||||
|
assertThat(intentCaptor.getValue().getAction()).isEqualTo(Intent.ACTION_SAFETY_CENTER);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void onCreate_whenSafetyCenterDisabled_doesntRedirectToSafetyCenter() {
|
||||||
|
DeviceConfig.setProperty(
|
||||||
|
DeviceConfig.NAMESPACE_PRIVACY,
|
||||||
|
SafetyCenterStatus.SAFETY_CENTER_IS_ENABLED,
|
||||||
|
/* value = */ Boolean.toString(false),
|
||||||
|
/* makeDefault = */ false);
|
||||||
|
|
||||||
|
mActivity.handleSafetyCenterRedirection();
|
||||||
|
|
||||||
|
verify(mActivity, times(0)).startActivity(any());
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -18,20 +18,29 @@ package com.android.settings.security;
|
|||||||
|
|
||||||
import static com.google.common.truth.Truth.assertThat;
|
import static com.google.common.truth.Truth.assertThat;
|
||||||
|
|
||||||
|
import static org.mockito.ArgumentMatchers.any;
|
||||||
|
import static org.mockito.Mockito.doNothing;
|
||||||
|
import static org.mockito.Mockito.spy;
|
||||||
|
import static org.mockito.Mockito.times;
|
||||||
|
import static org.mockito.Mockito.verify;
|
||||||
import static org.mockito.Mockito.when;
|
import static org.mockito.Mockito.when;
|
||||||
|
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
|
import android.provider.DeviceConfig;
|
||||||
|
|
||||||
import androidx.test.ext.junit.runners.AndroidJUnit4;
|
import androidx.test.ext.junit.runners.AndroidJUnit4;
|
||||||
import androidx.test.platform.app.InstrumentationRegistry;
|
import androidx.test.platform.app.InstrumentationRegistry;
|
||||||
|
|
||||||
import com.android.settings.Settings;
|
import com.android.settings.Settings;
|
||||||
import com.android.settings.SettingsActivity;
|
import com.android.settings.SettingsActivity;
|
||||||
|
import com.android.settings.safetycenter.SafetyCenterStatus;
|
||||||
import com.android.settings.testutils.FakeFeatureFactory;
|
import com.android.settings.testutils.FakeFeatureFactory;
|
||||||
|
|
||||||
|
import org.junit.After;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
|
import org.mockito.ArgumentCaptor;
|
||||||
import org.mockito.MockitoAnnotations;
|
import org.mockito.MockitoAnnotations;
|
||||||
|
|
||||||
@RunWith(AndroidJUnit4.class)
|
@RunWith(AndroidJUnit4.class)
|
||||||
@@ -48,6 +57,8 @@ public class SecurityDashboardActivityTest {
|
|||||||
MockitoAnnotations.initMocks(this);
|
MockitoAnnotations.initMocks(this);
|
||||||
FakeFeatureFactory mFeatureFactory = FakeFeatureFactory.setupForTest();
|
FakeFeatureFactory mFeatureFactory = FakeFeatureFactory.setupForTest();
|
||||||
mSecuritySettingsFeatureProvider = mFeatureFactory.getSecuritySettingsFeatureProvider();
|
mSecuritySettingsFeatureProvider = mFeatureFactory.getSecuritySettingsFeatureProvider();
|
||||||
|
DeviceConfig.resetToDefaults(android.provider.Settings.RESET_MODE_PACKAGE_DEFAULTS,
|
||||||
|
DeviceConfig.NAMESPACE_PRIVACY);
|
||||||
mDefaultIntent = new Intent();
|
mDefaultIntent = new Intent();
|
||||||
mDefaultIntent.setAction(android.provider.Settings.ACTION_SECURITY_SETTINGS);
|
mDefaultIntent.setAction(android.provider.Settings.ACTION_SECURITY_SETTINGS);
|
||||||
mDefaultIntent.setClass(InstrumentationRegistry.getInstrumentation().getTargetContext(),
|
mDefaultIntent.setClass(InstrumentationRegistry.getInstrumentation().getTargetContext(),
|
||||||
@@ -56,15 +67,22 @@ public class SecurityDashboardActivityTest {
|
|||||||
InstrumentationRegistry.getInstrumentation().runOnMainSync(() -> {
|
InstrumentationRegistry.getInstrumentation().runOnMainSync(() -> {
|
||||||
try {
|
try {
|
||||||
mActivity =
|
mActivity =
|
||||||
(Settings.SecurityDashboardActivity) InstrumentationRegistry
|
spy((Settings.SecurityDashboardActivity) InstrumentationRegistry
|
||||||
.getInstrumentation().newActivity(
|
.getInstrumentation().newActivity(
|
||||||
getClass().getClassLoader(),
|
getClass().getClassLoader(),
|
||||||
Settings.SecurityDashboardActivity.class.getName(),
|
Settings.SecurityDashboardActivity.class.getName(),
|
||||||
mDefaultIntent);
|
mDefaultIntent));
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
throw new RuntimeException(e); // nothing to do
|
throw new RuntimeException(e); // nothing to do
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
doNothing().when(mActivity).startActivity(any(Intent.class));
|
||||||
|
}
|
||||||
|
|
||||||
|
@After
|
||||||
|
public void tearDown() {
|
||||||
|
DeviceConfig.resetToDefaults(android.provider.Settings.RESET_MODE_PACKAGE_DEFAULTS,
|
||||||
|
DeviceConfig.NAMESPACE_PRIVACY);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -104,4 +122,32 @@ public class SecurityDashboardActivityTest {
|
|||||||
|
|
||||||
assertThat(mActivity.isValidFragment(ALTERNATIVE_FRAGMENT_CLASSNAME)).isTrue();
|
assertThat(mActivity.isValidFragment(ALTERNATIVE_FRAGMENT_CLASSNAME)).isTrue();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void onCreate_whenSafetyCenterEnabled_redirectsToSafetyCenter() {
|
||||||
|
DeviceConfig.setProperty(
|
||||||
|
DeviceConfig.NAMESPACE_PRIVACY,
|
||||||
|
SafetyCenterStatus.SAFETY_CENTER_IS_ENABLED,
|
||||||
|
/* value = */ Boolean.toString(true),
|
||||||
|
/* makeDefault = */ false);
|
||||||
|
final ArgumentCaptor<Intent> intentCaptor = ArgumentCaptor.forClass(Intent.class);
|
||||||
|
|
||||||
|
mActivity.handleSafetyCenterRedirection();
|
||||||
|
|
||||||
|
verify(mActivity).startActivity(intentCaptor.capture());
|
||||||
|
assertThat(intentCaptor.getValue().getAction()).isEqualTo(Intent.ACTION_SAFETY_CENTER);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void onCreate_whenSafetyCenterDisabled_doesntRedirectToSafetyCenter() {
|
||||||
|
DeviceConfig.setProperty(
|
||||||
|
DeviceConfig.NAMESPACE_PRIVACY,
|
||||||
|
SafetyCenterStatus.SAFETY_CENTER_IS_ENABLED,
|
||||||
|
/* value = */ Boolean.toString(false),
|
||||||
|
/* makeDefault = */ false);
|
||||||
|
|
||||||
|
mActivity.handleSafetyCenterRedirection();
|
||||||
|
|
||||||
|
verify(mActivity, times(0)).startActivity(any());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user