Merge "Recategorise private space settings items" into main
diff --git a/res/drawable/ic_category_vd_theme_24.xml b/res/drawable/ic_category_vd_theme_24.xml
new file mode 100644
index 0000000..4cf30cf
--- /dev/null
+++ b/res/drawable/ic_category_vd_theme_24.xml
@@ -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="M260,440L480,80L700,440L260,440ZM700,880Q625,880 572.5,827.5Q520,775 520,700Q520,625 572.5,572.5Q625,520 700,520Q775,520 827.5,572.5Q880,625 880,700Q880,775 827.5,827.5Q775,880 700,880ZM120,860L120,540L440,540L440,860L120,860ZM700,800Q742,800 771,771Q800,742 800,700Q800,658 771,629Q742,600 700,600Q658,600 629,629Q600,658 600,700Q600,742 629,771Q658,800 700,800ZM200,780L360,780L360,620L200,620L200,780ZM402,360L558,360L480,234L402,360ZM480,360L480,360L480,360L480,360ZM360,620L360,620L360,620L360,620L360,620ZM700,700Q700,700 700,700Q700,700 700,700Q700,700 700,700Q700,700 700,700Q700,700 700,700Q700,700 700,700Q700,700 700,700Q700,700 700,700Z"/>
+</vector>
\ No newline at end of file
diff --git a/res/layout/wifi_dpp_qrcode_generator_fragment.xml b/res/layout/wifi_dpp_qrcode_generator_fragment.xml
index f70abd5..6df56c6 100644
--- a/res/layout/wifi_dpp_qrcode_generator_fragment.xml
+++ b/res/layout/wifi_dpp_qrcode_generator_fragment.xml
@@ -62,7 +62,8 @@
android:focusable="true"
android:longClickable="true"
android:textAppearance="@android:style/TextAppearance.Material.Body1"
- android:textColor="?android:attr/textColorSecondary"/>
+ android:textColor="?android:attr/textColorSecondary"
+ android:typeface="monospace" />
</LinearLayout>
</LinearLayout>
diff --git a/res/values/config.xml b/res/values/config.xml
index e3d8e7d..6d9d784 100644
--- a/res/values/config.xml
+++ b/res/values/config.xml
@@ -387,6 +387,9 @@
<!-- Whether Wi-Fi hotspot speed should be shown or not. -->
<bool name="config_show_wifi_hotspot_speed">true</bool>
+ <!-- Whether or not Internet preference should be shown. -->
+ <bool name="config_show_internet_settings">true</bool>
+
<!-- Whether toggle_airplane is available or not. -->
<bool name="config_show_toggle_airplane">true</bool>
@@ -604,8 +607,11 @@
<!-- Media Uri to view audio storage category. -->
<string name="config_audio_storage_category_uri" translatable="false">content://com.android.providers.media.documents/root/audio_root</string>
- <!-- Media Uri to view documents & other storage category. -->
- <string name="config_documents_and_other_storage_category_uri" translatable="false">content://com.android.providers.media.documents/root/documents_root</string>
+ <!-- Media Uri to view documents storage category. -->
+ <string name="config_documents_storage_category_uri" translatable="false">content://com.android.providers.media.documents/root/documents_root</string>
+
+ <!-- Media Uri to view "other" storage category. -->
+ <string name="config_other_storage_category_uri" translatable="false">content://com.android.providers.media.documents/root/others_root</string>
<!-- Whether to show Smart Storage toggle -->
<bool name="config_show_smart_storage_toggle">true</bool>
diff --git a/res/values/strings.xml b/res/values/strings.xml
index f3532bd..835cc24 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -5731,7 +5731,9 @@
<!-- Category title for battery background settings in power usage detail page [CHAR LIMIT=NONE] -->
<string name="manager_battery_usage_category_title">Manage battery usage</string>
- <!-- Title for allow background usage [CHAR LIMIT=NONE] -->
+ <!-- Title for allow background usage settings page [CHAR LIMIT=NONE] -->
+ <string name="manager_battery_usage_allow_background_usage_settings_title">Allow background usage</string>
+ <!-- Title for the allow background usage toggle [CHAR LIMIT=NONE] -->
<string name="manager_battery_usage_allow_background_usage_title">Allow background usage</string>
<!-- Summary for allow background usage [CHAR LIMIT=NONE] -->
<string name="manager_battery_usage_allow_background_usage_summary">Enable for real-time updates, disable to save battery</string>
@@ -6672,9 +6674,9 @@
<string name="data_usage_app_restrict_dialog">This feature may cause an app that depends on background data to stop working when only mobile networks are available.\n\nYou can find more appropriate data usage controls in the settings available within the app.</string>
<!-- Body of dialog shown when user attempts to restrict background data before a network data limit has been set. [CHAR LIMIT=NONE] -->
<string name="data_usage_restrict_denied_dialog">Restricting background data is possible only when you\u2019ve set a mobile data limit.</string>
- <!-- Title of dialog shown when user enables global auto sync [CHAR LIMIT=32] -->
+ <!-- Title of dialog shown when user enables global auto sync [CHAR LIMIT=48] -->
<string name="data_usage_auto_sync_on_dialog_title">Turn auto-sync data on?</string>
- <!-- Title of dialog shown when user disables global auto sync [CHAR LIMIT=32] -->
+ <!-- Title of dialog shown when user disables global auto sync [CHAR LIMIT=48] -->
<string name="data_usage_auto_sync_off_dialog_title">Turn auto-sync data off?</string>
<!-- Body of dialog shown when user disables global auto sync [CHAR LIMIT=none] -->
<string name="data_usage_auto_sync_off_dialog">This will conserve data and battery usage, but you\u2019ll need to sync each account manually to collect recent information. And you won\u2019t receive notifications when updates occur.</string>
@@ -10959,9 +10961,6 @@
<!-- Preference label for the Apps storage section. [CHAR LIMIT=50] -->
<string name="storage_apps">Apps</string>
- <!-- Preference label for the Documents & other storage section. [CHAR LIMIT=50] -->
- <string name="storage_documents_and_other">Documents & other</string>
-
<!-- Old Preference label for the System storage section. [CHAR LIMIT=50] -->
<string name="storage_system">System</string>
@@ -11112,6 +11111,9 @@
<!-- Title of the warning dialog for enabling the credential provider. [CHAR_LIMIT=NONE] -->
<string name="credman_enable_confirmation_message_title">Use %1$s\?</string>
+ <!-- Content description for credential manager provider on/off switch. [CHAR_LIMIT=NONE] -->
+ <string name="credman_on_off_switch_content_description">%1$s on/off</string>
+
<!-- Positive button text for disabling credential manager. [CHAR_LIMIT=30] -->
<string name="credman_confirmation_turn_off_positive_button">Turn off</string>
diff --git a/res/xml/accounts_work_dashboard_settings_credman.xml b/res/xml/accounts_work_dashboard_settings_credman.xml
index 44bdb52..c275b82 100644
--- a/res/xml/accounts_work_dashboard_settings_credman.xml
+++ b/res/xml/accounts_work_dashboard_settings_credman.xml
@@ -22,6 +22,9 @@
android:title="@string/account_dashboard_title_with_passkeys"
settings:keywords="@string/keywords_accounts">
+ <com.android.settingslib.widget.TopIntroPreference
+ android:title="@string/credman_main_settings_intro_text" />
+
<PreferenceCategory
android:key="default_service_category"
android:order="10"
diff --git a/res/xml/mobile_network_settings.xml b/res/xml/mobile_network_settings.xml
index adb84b6..3c01109 100644
--- a/res/xml/mobile_network_settings.xml
+++ b/res/xml/mobile_network_settings.xml
@@ -36,6 +36,7 @@
<ListPreference
android:key="calls_preference"
android:title="@string/calls_preference"
+ android:summary="@string/summary_placeholder"
android:enabled="false"
settings:controller="com.android.settings.network.telephony.CallsDefaultSubscriptionController"
settings:allowDividerAbove="true"/>
@@ -43,6 +44,7 @@
<ListPreference
android:key="sms_preference"
android:title="@string/sms_preference"
+ android:summary="@string/summary_placeholder"
android:enabled="false"
settings:controller="com.android.settings.network.telephony.SmsDefaultSubscriptionController"/>
diff --git a/res/xml/power_background_usage_detail.xml b/res/xml/power_background_usage_detail.xml
index fb089fd..5c7b6a5 100644
--- a/res/xml/power_background_usage_detail.xml
+++ b/res/xml/power_background_usage_detail.xml
@@ -18,7 +18,7 @@
<PreferenceScreen
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:settings="http://schemas.android.com/apk/res-auto"
- android:title="@string/manager_battery_usage_allow_background_usage_title">
+ android:title="@string/manager_battery_usage_allow_background_usage_settings_title">
<com.android.settingslib.widget.LayoutPreference
android:key="header_view"
diff --git a/res/xml/storage_category_fragment.xml b/res/xml/storage_category_fragment.xml
index 58bd891..8af6639 100644
--- a/res/xml/storage_category_fragment.xml
+++ b/res/xml/storage_category_fragment.xml
@@ -57,15 +57,20 @@
android:icon="@drawable/ic_videogame_vd_theme_24"
android:order="105"/>
<com.android.settings.deviceinfo.StorageItemPreference
- android:key="pref_documents_and_other"
- android:title="@string/storage_documents_and_other"
+ android:key="pref_documents"
+ android:title="@string/storage_documents"
android:icon="@drawable/ic_folder_vd_theme_24"
android:order="106"/>
<com.android.settings.deviceinfo.StorageItemPreference
+ android:key="pref_other"
+ android:title="@string/storage_other"
+ android:icon="@drawable/ic_category_vd_theme_24"
+ android:order="107"/>
+ <com.android.settings.deviceinfo.StorageItemPreference
android:key="pref_trash"
android:title="@string/storage_trash"
android:icon="@drawable/ic_trash_can"
- android:order="107"/>
+ android:order="108"/>
<!-- Preference order 100~200 are 'ONLY' for storage category
preferences that are sorted by size. -->
<PreferenceCategory
diff --git a/res/xml/storage_dashboard_fragment.xml b/res/xml/storage_dashboard_fragment.xml
index fd866ad..f14f4ad 100644
--- a/res/xml/storage_dashboard_fragment.xml
+++ b/res/xml/storage_dashboard_fragment.xml
@@ -76,15 +76,20 @@
android:icon="@drawable/ic_videogame_vd_theme_24"
android:order="105"/>
<com.android.settings.deviceinfo.StorageItemPreference
- android:key="pref_documents_and_other"
- android:title="@string/storage_documents_and_other"
+ android:key="pref_documents"
+ android:title="@string/storage_documents"
android:icon="@drawable/ic_folder_vd_theme_24"
android:order="106"/>
<com.android.settings.deviceinfo.StorageItemPreference
+ android:key="pref_other"
+ android:title="@string/storage_other"
+ android:icon="@drawable/ic_category_vd_theme_24"
+ android:order="107"/>
+ <com.android.settings.deviceinfo.StorageItemPreference
android:key="pref_trash"
android:title="@string/storage_trash"
android:icon="@drawable/ic_trash_can"
- android:order="107"/>
+ android:order="108"/>
<!-- Preference order 100~200 are 'ONLY' for storage category
preferences that are sorted by size. -->
<PreferenceCategory
diff --git a/src/com/android/settings/applications/AppCounter.java b/src/com/android/settings/applications/AppCounter.java
index 2b1e47e..bc752e9 100644
--- a/src/com/android/settings/applications/AppCounter.java
+++ b/src/com/android/settings/applications/AppCounter.java
@@ -72,8 +72,7 @@
}
private boolean isArchivingEnabled() {
- return mFf.archiving() || SystemProperties.getBoolean("pm.archiving.enabled", false)
- || Flags.appArchiving();
+ return mFf.archiving() || Flags.appArchiving();
}
@Override
diff --git a/src/com/android/settings/applications/credentials/CredentialManagerPreferenceController.java b/src/com/android/settings/applications/credentials/CredentialManagerPreferenceController.java
index 47beeb6..a92b755 100644
--- a/src/com/android/settings/applications/credentials/CredentialManagerPreferenceController.java
+++ b/src/com/android/settings/applications/credentials/CredentialManagerPreferenceController.java
@@ -1072,6 +1072,22 @@
return mChecked;
}
+ @Override
+ public void setTitle(@Nullable CharSequence title) {
+ super.setTitle(title);
+ maybeUpdateContentDescription();
+ }
+
+ private void maybeUpdateContentDescription() {
+ final CharSequence appName = getTitle();
+
+ if (mSwitch != null && !TextUtils.isEmpty(appName)) {
+ mSwitch.setContentDescription(
+ getContext().getString(
+ R.string.credman_on_off_switch_content_description, appName));
+ }
+ }
+
public void setPreferenceListener(OnCombiPreferenceClickListener onClickListener) {
mOnClickListener = onClickListener;
}
@@ -1094,6 +1110,9 @@
// Store this for later.
mSwitch = switchView;
+
+ // Update the content description.
+ maybeUpdateContentDescription();
}
super.setOnPreferenceClickListener(
diff --git a/src/com/android/settings/applications/credentials/PrimaryProviderPreference.java b/src/com/android/settings/applications/credentials/PrimaryProviderPreference.java
index 84459e0..4a45ea4 100644
--- a/src/com/android/settings/applications/credentials/PrimaryProviderPreference.java
+++ b/src/com/android/settings/applications/credentials/PrimaryProviderPreference.java
@@ -129,6 +129,7 @@
}
});
setVisibility(mOpenButton, mOpenButtonVisible);
+ holder.itemView.setClickable(false);
mChangeButton = (Button) holder.findViewById(R.id.change_button);
mChangeButton.setOnClickListener(
diff --git a/src/com/android/settings/biometrics/face/FaceEnrollIntroductionInternal.java b/src/com/android/settings/biometrics/face/FaceEnrollIntroductionInternal.java
index 7dd29da..51d3a3a 100644
--- a/src/com/android/settings/biometrics/face/FaceEnrollIntroductionInternal.java
+++ b/src/com/android/settings/biometrics/face/FaceEnrollIntroductionInternal.java
@@ -16,8 +16,34 @@
package com.android.settings.biometrics.face;
+import static com.android.settings.Utils.SETTINGS_PACKAGE_NAME;
+
+import android.content.Intent;
+import android.os.Bundle;
+
+import androidx.fragment.app.FragmentActivity;
+
/**
* Wrapper of {@link FaceEnrollIntroduction} to use with a pre-defined task affinity.
+ *
+ * <p>Trampolines over to FaceEnrollIntroduction - doing this as a trampoline rather than having
+ * this activity extend FaceEnrollIntroduction works around b/331157120.
*/
-public class FaceEnrollIntroductionInternal extends FaceEnrollIntroduction {
+public class FaceEnrollIntroductionInternal extends FragmentActivity {
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ if (isFinishing()) {
+ return;
+ }
+
+ // Copy our intent to grab all extras. Drop flags so we don't start new tasks twice.
+ Intent trampoline = new Intent(getIntent());
+ trampoline.setFlags(0);
+
+ // Trampoline to the intended activity, and finish
+ trampoline.setClassName(SETTINGS_PACKAGE_NAME, FaceEnrollIntroduction.class.getName());
+ startActivity(trampoline);
+ finish();
+ }
}
diff --git a/src/com/android/settings/bluetooth/BluetoothPairingController.java b/src/com/android/settings/bluetooth/BluetoothPairingController.java
index f75d301..dc7d4dc 100644
--- a/src/com/android/settings/bluetooth/BluetoothPairingController.java
+++ b/src/com/android/settings/bluetooth/BluetoothPairingController.java
@@ -448,7 +448,7 @@
switch (mType) {
case BluetoothDevice.PAIRING_VARIANT_PASSKEY_CONFIRMATION:
case BluetoothDevice.PAIRING_VARIANT_DISPLAY_PASSKEY:
- return String.format(Locale.US, "%06d", passkey);
+ return String.format(Locale.getDefault(), "%06d", passkey);
case BluetoothDevice.PAIRING_VARIANT_DISPLAY_PIN:
return String.format("%04d", passkey);
diff --git a/src/com/android/settings/datausage/ChartDataUsagePreference.java b/src/com/android/settings/datausage/ChartDataUsagePreference.java
index e8e2109..0c7db71 100644
--- a/src/com/android/settings/datausage/ChartDataUsagePreference.java
+++ b/src/com/android/settings/datausage/ChartDataUsagePreference.java
@@ -124,7 +124,7 @@
UsageView chart, @NonNull List<NetworkUsageData> usageSummary) {
final Context context = getContext();
final StringBuilder contentDescription = new StringBuilder();
- final int flags = DateUtils.FORMAT_SHOW_DATE | DateUtils.FORMAT_ABBREV_MONTH;
+ final int flags = DateUtils.FORMAT_SHOW_DATE;
// Setup a brief content description.
final String startDate = DateUtils.formatDateTime(context, mStart, flags);
@@ -153,7 +153,7 @@
nodeDate = DateUtils.formatDateRange(context, data.getStartTime(),
data.getEndTime(), flags);
}
- nodeContentDescription = String.format(";%s %d%%", nodeDate, dataUsagePercentage);
+ nodeContentDescription = String.format("; %s, %d%%", nodeDate, dataUsagePercentage);
contentDescription.append(nodeContentDescription);
}
diff --git a/src/com/android/settings/deviceinfo/storage/StorageAsyncLoader.java b/src/com/android/settings/deviceinfo/storage/StorageAsyncLoader.java
index 4906cf2..7b8b237 100644
--- a/src/com/android/settings/deviceinfo/storage/StorageAsyncLoader.java
+++ b/src/com/android/settings/deviceinfo/storage/StorageAsyncLoader.java
@@ -98,15 +98,24 @@
media /* queryArgs */);
result.systemSize = getSystemSize();
- final Bundle documentsAndOtherQueryArgs = new Bundle();
- documentsAndOtherQueryArgs.putString(ContentResolver.QUERY_ARG_SQL_SELECTION,
- FileColumns.MEDIA_TYPE + "!=" + FileColumns.MEDIA_TYPE_IMAGE
- + " AND " + FileColumns.MEDIA_TYPE + "!=" + FileColumns.MEDIA_TYPE_VIDEO
- + " AND " + FileColumns.MEDIA_TYPE + "!=" + FileColumns.MEDIA_TYPE_AUDIO
- + " AND " + FileColumns.MIME_TYPE + " IS NOT NULL");
- result.documentsAndOtherSize = getFilesSize(info.id,
+ final Bundle documentsQueryArgs = new Bundle();
+ documentsQueryArgs.putString(ContentResolver.QUERY_ARG_SQL_SELECTION,
+ FileColumns.MEDIA_TYPE + "=" + FileColumns.MEDIA_TYPE_DOCUMENT);
+ result.documentsSize = getFilesSize(info.id,
MediaStore.Files.getContentUri(MediaStore.VOLUME_EXTERNAL_PRIMARY),
- documentsAndOtherQueryArgs);
+ documentsQueryArgs);
+
+ final Bundle otherQueryArgs = new Bundle();
+ otherQueryArgs.putString(ContentResolver.QUERY_ARG_SQL_SELECTION,
+ FileColumns.MEDIA_TYPE + "!=" + FileColumns.MEDIA_TYPE_IMAGE
+ + " AND " + FileColumns.MEDIA_TYPE + "!=" + FileColumns.MEDIA_TYPE_VIDEO
+ + " AND " + FileColumns.MEDIA_TYPE + "!=" + FileColumns.MEDIA_TYPE_AUDIO
+ + " AND " + FileColumns.MEDIA_TYPE + "!="
+ + FileColumns.MEDIA_TYPE_DOCUMENT
+ + " AND " + FileColumns.MIME_TYPE + " IS NOT NULL");
+ result.otherSize = getFilesSize(info.id,
+ MediaStore.Files.getContentUri(MediaStore.VOLUME_EXTERNAL_PRIMARY),
+ otherQueryArgs);
final Bundle trashQueryArgs = new Bundle();
trashQueryArgs.putInt(MediaStore.QUERY_ARG_MATCH_TRASHED, MediaStore.MATCH_ONLY);
@@ -236,7 +245,8 @@
public long audioSize;
public long imagesSize;
public long videosSize;
- public long documentsAndOtherSize;
+ public long documentsSize;
+ public long otherSize;
public long trashSize;
public long systemSize;
diff --git a/src/com/android/settings/deviceinfo/storage/StorageCacheHelper.java b/src/com/android/settings/deviceinfo/storage/StorageCacheHelper.java
index 50690cb..253427f 100644
--- a/src/com/android/settings/deviceinfo/storage/StorageCacheHelper.java
+++ b/src/com/android/settings/deviceinfo/storage/StorageCacheHelper.java
@@ -32,7 +32,8 @@
private static final String AUDIO_SIZE_KEY = "audio_size_key";
private static final String APPS_SIZE_KEY = "apps_size_key";
private static final String GAMES_SIZE_KEY = "games_size_key";
- private static final String DOCUMENTS_AND_OTHER_SIZE_KEY = "documents_and_other_size_key";
+ private static final String DOCUMENTS_SIZE_KEY = "documents_size_key";
+ private static final String OTHER_SIZE_KEY = "other_size_key";
private static final String TRASH_SIZE_KEY = "trash_size_key";
private static final String SYSTEM_SIZE_KEY = "system_size_key";
private static final String TEMPORARY_FILES_SIZE_KEY = "temporary_files_size_key";
@@ -64,7 +65,8 @@
.putLong(AUDIO_SIZE_KEY, data.audioSize)
.putLong(APPS_SIZE_KEY, data.allAppsExceptGamesSize)
.putLong(GAMES_SIZE_KEY, data.gamesSize)
- .putLong(DOCUMENTS_AND_OTHER_SIZE_KEY, data.documentsAndOtherSize)
+ .putLong(DOCUMENTS_SIZE_KEY, data.documentsSize)
+ .putLong(OTHER_SIZE_KEY, data.otherSize)
.putLong(TRASH_SIZE_KEY, data.trashSize)
.putLong(SYSTEM_SIZE_KEY, data.systemSize)
.putLong(TEMPORARY_FILES_SIZE_KEY, data.temporaryFilesSize)
@@ -108,7 +110,8 @@
result.audioSize = mSharedPreferences.getLong(AUDIO_SIZE_KEY, 0);
result.allAppsExceptGamesSize = mSharedPreferences.getLong(APPS_SIZE_KEY, 0);
result.gamesSize = mSharedPreferences.getLong(GAMES_SIZE_KEY, 0);
- result.documentsAndOtherSize = mSharedPreferences.getLong(DOCUMENTS_AND_OTHER_SIZE_KEY, 0);
+ result.documentsSize = mSharedPreferences.getLong(DOCUMENTS_SIZE_KEY, 0);
+ result.otherSize = mSharedPreferences.getLong(OTHER_SIZE_KEY, 0);
result.trashSize = mSharedPreferences.getLong(TRASH_SIZE_KEY, 0);
result.systemSize = mSharedPreferences.getLong(SYSTEM_SIZE_KEY, 0);
result.temporaryFilesSize = mSharedPreferences.getLong(TEMPORARY_FILES_SIZE_KEY, 0);
@@ -126,7 +129,8 @@
public long audioSize;
public long imagesSize;
public long videosSize;
- public long documentsAndOtherSize;
+ public long documentsSize;
+ public long otherSize;
public long trashSize;
public long systemSize;
public long temporaryFilesSize;
diff --git a/src/com/android/settings/deviceinfo/storage/StorageItemPreferenceController.java b/src/com/android/settings/deviceinfo/storage/StorageItemPreferenceController.java
index 62422ca..d4e2b7a 100644
--- a/src/com/android/settings/deviceinfo/storage/StorageItemPreferenceController.java
+++ b/src/com/android/settings/deviceinfo/storage/StorageItemPreferenceController.java
@@ -92,7 +92,9 @@
@VisibleForTesting
static final String GAMES_KEY = "pref_games";
@VisibleForTesting
- static final String DOCUMENTS_AND_OTHER_KEY = "pref_documents_and_other";
+ static final String DOCUMENTS_KEY = "pref_documents";
+ @VisibleForTesting
+ static final String OTHER_KEY = "pref_other";
@VisibleForTesting
static final String SYSTEM_KEY = "pref_system";
@VisibleForTesting
@@ -109,7 +111,9 @@
@VisibleForTesting
final Uri mAudioUri;
@VisibleForTesting
- final Uri mDocumentsAndOtherUri;
+ final Uri mDocumentsUri;
+ @VisibleForTesting
+ final Uri mOtherUri;
// This value should align with the design of storage_dashboard_fragment.xml
private static final int LAST_STORAGE_CATEGORY_PREFERENCE_ORDER = 200;
@@ -139,7 +143,9 @@
@VisibleForTesting
@Nullable StorageItemPreference mGamesPreference;
@VisibleForTesting
- @Nullable StorageItemPreference mDocumentsAndOtherPreference;
+ @Nullable StorageItemPreference mDocumentsPreference;
+ @VisibleForTesting
+ @Nullable StorageItemPreference mOtherPreference;
@VisibleForTesting
@Nullable StorageItemPreference mTrashPreference;
@VisibleForTesting
@@ -186,8 +192,10 @@
.getString(R.string.config_videos_storage_category_uri));
mAudioUri = Uri.parse(context.getResources()
.getString(R.string.config_audio_storage_category_uri));
- mDocumentsAndOtherUri = Uri.parse(context.getResources()
- .getString(R.string.config_documents_and_other_storage_category_uri));
+ mDocumentsUri = Uri.parse(context.getResources()
+ .getString(R.string.config_documents_storage_category_uri));
+ mOtherUri = Uri.parse(context.getResources()
+ .getString(R.string.config_other_storage_category_uri));
}
@VisibleForTesting
@@ -224,8 +232,11 @@
case GAMES_KEY:
launchGamesIntent();
return true;
- case DOCUMENTS_AND_OTHER_KEY:
- launchActivityWithUri(mDocumentsAndOtherUri);
+ case DOCUMENTS_KEY:
+ launchActivityWithUri(mDocumentsUri);
+ return true;
+ case OTHER_KEY:
+ launchActivityWithUri(mOtherUri);
return true;
case SYSTEM_KEY:
final SystemInfoFragment dialog = new SystemInfoFragment();
@@ -311,9 +322,11 @@
// If we don't have a shared volume for our internal storage (or the shared volume isn't
// mounted as readable for whatever reason), we should hide the File preference.
if (visible) {
- mDocumentsAndOtherPreference.setVisible(mIsDocumentsPrefShown);
+ mDocumentsPreference.setVisible(mIsDocumentsPrefShown);
+ mOtherPreference.setVisible(mIsDocumentsPrefShown);
} else {
- mDocumentsAndOtherPreference.setVisible(false);
+ mDocumentsPreference.setVisible(false);
+ mOtherPreference.setVisible(false);
}
}
@@ -330,20 +343,24 @@
if (mPrivateStorageItemPreferences == null) {
mPrivateStorageItemPreferences = new ArrayList<>();
- mPrivateStorageItemPreferences.add(mImagesPreference);
- mPrivateStorageItemPreferences.add(mVideosPreference);
- mPrivateStorageItemPreferences.add(mAudioPreference);
- mPrivateStorageItemPreferences.add(mAppsPreference);
- mPrivateStorageItemPreferences.add(mGamesPreference);
- mPrivateStorageItemPreferences.add(mDocumentsAndOtherPreference);
+ // Adding categories in the reverse order so that
+ // They would be in the right order after sorting
mPrivateStorageItemPreferences.add(mTrashPreference);
+ mPrivateStorageItemPreferences.add(mOtherPreference);
+ mPrivateStorageItemPreferences.add(mDocumentsPreference);
+ mPrivateStorageItemPreferences.add(mGamesPreference);
+ mPrivateStorageItemPreferences.add(mAppsPreference);
+ mPrivateStorageItemPreferences.add(mAudioPreference);
+ mPrivateStorageItemPreferences.add(mVideosPreference);
+ mPrivateStorageItemPreferences.add(mImagesPreference);
}
mScreen.removePreference(mImagesPreference);
mScreen.removePreference(mVideosPreference);
mScreen.removePreference(mAudioPreference);
mScreen.removePreference(mAppsPreference);
mScreen.removePreference(mGamesPreference);
- mScreen.removePreference(mDocumentsAndOtherPreference);
+ mScreen.removePreference(mDocumentsPreference);
+ mScreen.removePreference(mOtherPreference);
mScreen.removePreference(mTrashPreference);
// Sort display order by size.
@@ -378,7 +395,8 @@
tintPreference(mAudioPreference);
tintPreference(mAppsPreference);
tintPreference(mGamesPreference);
- tintPreference(mDocumentsAndOtherPreference);
+ tintPreference(mDocumentsPreference);
+ tintPreference(mOtherPreference);
tintPreference(mSystemPreference);
tintPreference(mTemporaryFilesPreference);
tintPreference(mTrashPreference);
@@ -408,7 +426,8 @@
mAudioPreference = screen.findPreference(AUDIO_KEY);
mAppsPreference = screen.findPreference(APPS_KEY);
mGamesPreference = screen.findPreference(GAMES_KEY);
- mDocumentsAndOtherPreference = screen.findPreference(DOCUMENTS_AND_OTHER_KEY);
+ mDocumentsPreference = screen.findPreference(DOCUMENTS_KEY);
+ mOtherPreference = screen.findPreference(OTHER_KEY);
mCategorySplitterPreferenceCategory = screen.findPreference(CATEGORY_SPLITTER);
mSystemPreference = screen.findPreference(SYSTEM_KEY);
mTemporaryFilesPreference = screen.findPreference(TEMPORARY_FILES_KEY);
@@ -434,8 +453,8 @@
mAudioPreference.setStorageSize(storageCache.audioSize, mTotalSize, animate);
mAppsPreference.setStorageSize(storageCache.allAppsExceptGamesSize, mTotalSize, animate);
mGamesPreference.setStorageSize(storageCache.gamesSize, mTotalSize, animate);
- mDocumentsAndOtherPreference.setStorageSize(storageCache.documentsAndOtherSize, mTotalSize,
- animate);
+ mDocumentsPreference.setStorageSize(storageCache.documentsSize, mTotalSize, animate);
+ mOtherPreference.setStorageSize(storageCache.otherSize, mTotalSize, animate);
mTrashPreference.setStorageSize(storageCache.trashSize, mTotalSize, animate);
if (mSystemPreference != null) {
mSystemPreference.setStorageSize(storageCache.systemSize, mTotalSize, animate);
@@ -471,7 +490,8 @@
storageCache.audioSize = data.audioSize;
storageCache.allAppsExceptGamesSize = data.allAppsExceptGamesSize;
storageCache.gamesSize = data.gamesSize;
- storageCache.documentsAndOtherSize = data.documentsAndOtherSize;
+ storageCache.documentsSize = data.documentsSize;
+ storageCache.otherSize = data.otherSize;
storageCache.trashSize = data.trashSize;
storageCache.systemSize = data.systemSize;
// Everything else that hasn't already been attributed is tracked as
@@ -484,7 +504,8 @@
+ otherData.audioSize
+ otherData.videosSize
+ otherData.imagesSize
- + otherData.documentsAndOtherSize
+ + otherData.documentsSize
+ + otherData.otherSize
+ otherData.trashSize
+ otherData.allAppsExceptGamesSize;
attributedSize -= otherData.duplicateCodeSize;
diff --git a/src/com/android/settings/network/EraseEuiccDataDialogFragment.java b/src/com/android/settings/network/EraseEuiccDataDialogFragment.java
index 3bf9db3..01ced4e 100644
--- a/src/com/android/settings/network/EraseEuiccDataDialogFragment.java
+++ b/src/com/android/settings/network/EraseEuiccDataDialogFragment.java
@@ -43,6 +43,9 @@
"com.android.settings.network";
public static void show(ResetDashboardFragment host) {
+ if (host.getActivity() == null) {
+ return;
+ }
final EraseEuiccDataDialogFragment dialog = new EraseEuiccDataDialogFragment();
dialog.setTargetFragment(host, 0 /* requestCode */);
final FragmentManager manager = host.getActivity().getSupportFragmentManager();
diff --git a/src/com/android/settings/network/EuiccRacConnectivityDialogFragment.java b/src/com/android/settings/network/EuiccRacConnectivityDialogFragment.java
index 76a587e..663631f 100644
--- a/src/com/android/settings/network/EuiccRacConnectivityDialogFragment.java
+++ b/src/com/android/settings/network/EuiccRacConnectivityDialogFragment.java
@@ -33,14 +33,25 @@
import androidx.fragment.app.FragmentManager;
import com.android.settings.R;
-import com.android.settings.core.instrumentation.InstrumentedDialogFragment;
+import com.android.settings.overlay.FeatureFactory;
import com.android.settings.system.ResetDashboardFragment;
+import com.android.settingslib.core.instrumentation.MetricsFeatureProvider;
+import com.android.settingslib.core.lifecycle.ObservableDialogFragment;
-public class EuiccRacConnectivityDialogFragment extends InstrumentedDialogFragment
- implements DialogInterface.OnClickListener {
+public class EuiccRacConnectivityDialogFragment extends ObservableDialogFragment
+ implements DialogInterface.OnClickListener, DialogInterface.OnCancelListener {
public static final String TAG = "EuiccRacConnectivityDlg";
+ private static final int METRICS_TAG =
+ SettingsEnums.ACTION_RESET_ESIMS_RAC_CONNECTIVITY_WARNING;
+ private static final int METRICS_CANCEL_VALUE = 0;
+ private static final int METRICS_CONTINUE_VALUE = 1;
+
+ private MetricsFeatureProvider mMetricsFeatureProvider;
static void show(ResetDashboardFragment host) {
+ if (host.getActivity() == null) {
+ return;
+ }
final EuiccRacConnectivityDialogFragment dialog = new EuiccRacConnectivityDialogFragment();
dialog.setTargetFragment(host, /* requestCode= */ 0);
final FragmentManager manager = host.getActivity().getSupportFragmentManager();
@@ -48,8 +59,9 @@
}
@Override
- public int getMetricsCategory() {
- return SettingsEnums.RESET_EUICC;
+ public void onCreate(@Nullable Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ mMetricsFeatureProvider = FeatureFactory.getFeatureFactory().getMetricsFeatureProvider();
}
@NonNull
@@ -62,7 +74,7 @@
new AlertDialog.Builder(getContext())
.setOnDismissListener(this)
// Return is on the right side
- .setPositiveButton(R.string.wifi_warning_return_button, null)
+ .setPositiveButton(R.string.wifi_warning_return_button, this)
// Continue is on the left side
.setNegativeButton(R.string.wifi_warning_continue_button, this);
@@ -109,7 +121,24 @@
// Positions of the buttons have been switch:
// negative button = left button = the button to continue
if (which == DialogInterface.BUTTON_NEGATIVE) {
+ logMetrics(METRICS_CONTINUE_VALUE);
EraseEuiccDataDialogFragment.show(((ResetDashboardFragment) fragment));
+ } else {
+ logMetrics(METRICS_CANCEL_VALUE);
}
}
+
+ @Override
+ public void onCancel(@NonNull DialogInterface dialog) {
+ final Fragment fragment = getTargetFragment();
+ if (!(fragment instanceof ResetDashboardFragment)) {
+ Log.e(TAG, "getTargetFragment return unexpected type");
+ return;
+ }
+ logMetrics(METRICS_CANCEL_VALUE);
+ }
+
+ private void logMetrics(int value) {
+ mMetricsFeatureProvider.action(getActivity(), METRICS_TAG, value);
+ }
}
diff --git a/src/com/android/settings/network/InternetPreferenceController.java b/src/com/android/settings/network/InternetPreferenceController.java
index 1f5042f..aed44d5 100644
--- a/src/com/android/settings/network/InternetPreferenceController.java
+++ b/src/com/android/settings/network/InternetPreferenceController.java
@@ -180,7 +180,7 @@
@Override
public boolean isAvailable() {
- return true;
+ return mContext.getResources().getBoolean(R.bool.config_show_internet_settings);
}
@Override
diff --git a/src/com/android/settings/network/NetworkMobileProviderController.java b/src/com/android/settings/network/NetworkMobileProviderController.java
index e0db395..8d9d353 100644
--- a/src/com/android/settings/network/NetworkMobileProviderController.java
+++ b/src/com/android/settings/network/NetworkMobileProviderController.java
@@ -24,7 +24,6 @@
import androidx.preference.PreferenceScreen;
import com.android.settings.core.BasePreferenceController;
-import com.android.settings.wifi.WifiPickerTrackerHelper;
import com.android.settingslib.core.lifecycle.Lifecycle;
/**
@@ -117,12 +116,6 @@
mPreferenceCategory.setVisible(available);
}
- public void setWifiPickerTrackerHelper(WifiPickerTrackerHelper helper) {
- if (mSubscriptionsController != null) {
- mSubscriptionsController.setWifiPickerTrackerHelper(helper);
- }
- }
-
/**
* Hides the preference.
*/
diff --git a/src/com/android/settings/network/NetworkProviderSettings.java b/src/com/android/settings/network/NetworkProviderSettings.java
index 0bc426c..6abe52b 100644
--- a/src/com/android/settings/network/NetworkProviderSettings.java
+++ b/src/com/android/settings/network/NetworkProviderSettings.java
@@ -295,6 +295,12 @@
@Override
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
+ final Context context = getContext();
+ if (context != null && !context.getResources().getBoolean(
+ R.bool.config_show_internet_settings)) {
+ finish();
+ return;
+ }
mAirplaneModeEnabler = new AirplaneModeEnabler(getContext(), this);
// TODO(b/37429702): Add animations and preference comparator back after initial screen is
@@ -477,10 +483,6 @@
mOpenSsid = intent.getStringExtra(EXTRA_START_CONNECT_SSID);
}
- if (mNetworkMobileProviderController != null) {
- mNetworkMobileProviderController.setWifiPickerTrackerHelper(mWifiPickerTrackerHelper);
- }
-
requireActivity().addMenuProvider(mMenuProvider);
}
diff --git a/src/com/android/settings/network/SubscriptionsPreferenceController.java b/src/com/android/settings/network/SubscriptionsPreferenceController.java
index 09ce02e..d9a6464 100644
--- a/src/com/android/settings/network/SubscriptionsPreferenceController.java
+++ b/src/com/android/settings/network/SubscriptionsPreferenceController.java
@@ -68,6 +68,7 @@
import com.android.settingslib.mobile.TelephonyIcons;
import com.android.settingslib.net.SignalStrengthUtil;
import com.android.wifitrackerlib.WifiEntry;
+import com.android.wifitrackerlib.WifiPickerTracker;
import java.util.Collections;
import java.util.List;
@@ -82,7 +83,7 @@
LifecycleObserver, SubscriptionsChangeListener.SubscriptionsChangeListenerClient,
MobileDataEnabledListener.Client, DataConnectivityListener.Client,
SignalStrengthListener.Callback, TelephonyDisplayInfoListener.Callback,
- TelephonyCallback.CarrierNetworkListener {
+ TelephonyCallback.CarrierNetworkListener, WifiPickerTracker.WifiPickerTrackerCallback {
private static final String TAG = "SubscriptionsPrefCntrlr";
private UpdateListener mUpdateListener;
@@ -95,7 +96,8 @@
private DataConnectivityListener mConnectivityListener;
private SignalStrengthListener mSignalStrengthListener;
private TelephonyDisplayInfoListener mTelephonyDisplayInfoListener;
- private WifiPickerTrackerHelper mWifiPickerTrackerHelper;
+ @VisibleForTesting
+ WifiPickerTrackerHelper mWifiPickerTrackerHelper;
private final WifiManager mWifiManager;
private boolean mCarrierNetworkChangeMode;
@@ -163,6 +165,7 @@
mSignalStrengthListener = new SignalStrengthListener(context, this);
mTelephonyDisplayInfoListener = new TelephonyDisplayInfoListener(context, this);
lifecycle.addObserver(this);
+ mWifiPickerTrackerHelper = new WifiPickerTrackerHelper(lifecycle, context, this);
mSubsPrefCtrlInjector = createSubsPrefCtrlInjector();
mConfig = mSubsPrefCtrlInjector.getConfig(mContext);
}
@@ -485,8 +488,24 @@
update();
}
- public void setWifiPickerTrackerHelper(WifiPickerTrackerHelper helper) {
- mWifiPickerTrackerHelper = helper;
+ @Override
+ public void onNumSavedNetworksChanged() {
+ //Do nothing
+ }
+
+ @Override
+ public void onNumSavedSubscriptionsChanged() {
+ //Do nothing
+ }
+
+ @Override
+ public void onWifiStateChanged() {
+ update();
+ }
+
+ @Override
+ public void onWifiEntriesChanged() {
+ update();
}
@VisibleForTesting
diff --git a/src/com/android/settings/network/apn/ApnEditPageProvider.kt b/src/com/android/settings/network/apn/ApnEditPageProvider.kt
index a287b84..71fe4d6 100644
--- a/src/com/android/settings/network/apn/ApnEditPageProvider.kt
+++ b/src/com/android/settings/network/apn/ApnEditPageProvider.kt
@@ -27,6 +27,7 @@
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
+import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.MutableState
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
@@ -39,6 +40,7 @@
import androidx.navigation.NavType
import androidx.navigation.navArgument
import com.android.settings.R
+import com.android.settings.network.telephony.SubscriptionRepository
import com.android.settingslib.spa.framework.common.SettingsPageProvider
import com.android.settingslib.spa.framework.compose.LocalNavController
import com.android.settingslib.spa.framework.theme.SettingsDimension
@@ -78,6 +80,18 @@
mutableStateOf(apnDataInit)
}
ApnPage(apnDataInit, apnDataCur, uriInit)
+ SubscriptionNotEnabledEffect(subId)
+ }
+
+ @Composable
+ private fun SubscriptionNotEnabledEffect(subId: Int) {
+ val context = LocalContext.current
+ val navController = LocalNavController.current
+ LaunchedEffect(subId) {
+ SubscriptionRepository(context).isSubscriptionEnabledFlow(subId).collect { isEnabled ->
+ if (!isEnabled) navController.navigateBack()
+ }
+ }
}
fun getRoute(
diff --git a/src/com/android/settings/network/apn/ApnSettings.java b/src/com/android/settings/network/apn/ApnSettings.java
index be90653..80239cb 100644
--- a/src/com/android/settings/network/apn/ApnSettings.java
+++ b/src/com/android/settings/network/apn/ApnSettings.java
@@ -52,8 +52,11 @@
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.MotionEvent;
+import android.view.View;
import android.widget.Toast;
+import androidx.annotation.NonNull;
+import androidx.annotation.Nullable;
import androidx.preference.Preference;
import androidx.preference.PreferenceGroup;
@@ -61,9 +64,12 @@
import com.android.settings.RestrictedSettingsFragment;
import com.android.settings.flags.Flags;
import com.android.settings.network.SubscriptionUtil;
+import com.android.settings.network.telephony.SubscriptionRepository;
import com.android.settings.spa.SpaActivity;
import com.android.settingslib.RestrictedLockUtils.EnforcedAdmin;
+import kotlin.Unit;
+
import java.util.ArrayList;
/** Handle each different apn setting. */
@@ -92,13 +98,6 @@
Telephony.Carriers.EDITED_STATUS,
};
- /** Copied from {@code com.android.internal.telephony.TelephonyIntents} */
- private static final String ACTION_SIM_STATE_CHANGED =
- "android.intent.action.SIM_STATE_CHANGED";
- /** Copied from {@code com.android.internal.telephony.IccCardConstants} */
- public static final String INTENT_KEY_ICC_STATE = "ss";
- public static final String INTENT_VALUE_ICC_ABSENT = "ABSENT";
-
private static final int ID_INDEX = 0;
private static final int NAME_INDEX = 1;
private static final int APN_INDEX = 2;
@@ -162,16 +161,7 @@
private final BroadcastReceiver mReceiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
- String action = intent.getAction();
- if (ACTION_SIM_STATE_CHANGED.equals(action)
- && intent.getStringExtra(INTENT_KEY_ICC_STATE)
- .equals(INTENT_VALUE_ICC_ABSENT)) {
- final SubscriptionManager sm = context.getSystemService(SubscriptionManager.class);
- if (sm != null && !sm.isActiveSubscriptionId(mSubId)) {
- Log.d(TAG, "Due to SIM absent, closes APN settings page");
- finish();
- }
- } else if (intent.getAction().equals(
+ if (intent.getAction().equals(
TelephonyManager.ACTION_SUBSCRIPTION_CARRIER_IDENTITY_CHANGED)) {
if (mRestoreDefaultApnMode) {
return;
@@ -223,7 +213,6 @@
mPhoneId = SubscriptionUtil.getPhoneId(activity, mSubId);
mIntentFilter = new IntentFilter();
mIntentFilter.addAction(TelephonyManager.ACTION_SUBSCRIPTION_CARRIER_IDENTITY_CHANGED);
- mIntentFilter.addAction(ACTION_SIM_STATE_CHANGED);
setIfOnlyAvailableForAdmins(true);
@@ -264,6 +253,20 @@
}
@Override
+ public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
+ super.onViewCreated(view, savedInstanceState);
+
+ new SubscriptionRepository(requireContext())
+ .collectSubscriptionEnabled(mSubId, getViewLifecycleOwner(), (isEnabled) -> {
+ if (!isEnabled) {
+ Log.d(TAG, "Due to subscription not enabled, closes APN settings page");
+ finish();
+ }
+ return Unit.INSTANCE;
+ });
+ }
+
+ @Override
public void onResume() {
super.onResume();
diff --git a/src/com/android/settings/network/telephony/DefaultSubscriptionController.java b/src/com/android/settings/network/telephony/DefaultSubscriptionController.java
index 03ce7f6..024fb83 100644
--- a/src/com/android/settings/network/telephony/DefaultSubscriptionController.java
+++ b/src/com/android/settings/network/telephony/DefaultSubscriptionController.java
@@ -116,8 +116,6 @@
public void displayPreference(PreferenceScreen screen) {
super.displayPreference(screen);
mPreference = screen.findPreference(getPreferenceKey());
- // Set a summary placeholder to reduce flicker.
- mPreference.setSummaryProvider(pref -> mContext.getString(R.string.summary_placeholder));
updateEntries();
}
diff --git a/src/com/android/settings/network/telephony/SubscriptionRepository.kt b/src/com/android/settings/network/telephony/SubscriptionRepository.kt
index b0a39ec..938f4d8 100644
--- a/src/com/android/settings/network/telephony/SubscriptionRepository.kt
+++ b/src/com/android/settings/network/telephony/SubscriptionRepository.kt
@@ -20,7 +20,9 @@
import android.telephony.SubscriptionInfo
import android.telephony.SubscriptionManager
import android.util.Log
+import androidx.lifecycle.LifecycleOwner
import com.android.settings.network.SubscriptionUtil
+import com.android.settingslib.spa.framework.util.collectLatestWithLifecycle
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.asExecutor
import kotlinx.coroutines.channels.awaitClose
@@ -43,6 +45,16 @@
context.getSelectableSubscriptionInfoList()
fun isSubscriptionEnabledFlow(subId: Int) = context.isSubscriptionEnabledFlow(subId)
+
+ /** TODO: Move this to UI layer, when UI layer migrated to Kotlin. */
+ fun collectSubscriptionEnabled(
+ subId: Int,
+ lifecycleOwner: LifecycleOwner,
+ action: (Boolean) -> Unit,
+ ) {
+ isSubscriptionEnabledFlow(subId).collectLatestWithLifecycle(lifecycleOwner, action = action)
+ }
+
}
val Context.subscriptionManager: SubscriptionManager?
@@ -52,7 +64,8 @@
fun Context.isSubscriptionEnabledFlow(subId: Int) = subscriptionsChangedFlow().map {
subscriptionManager?.isSubscriptionEnabled(subId) ?: false
-}.flowOn(Dispatchers.Default)
+}.conflate().onEach { Log.d(TAG, "[$subId] isSubscriptionEnabledFlow: $it") }
+ .flowOn(Dispatchers.Default)
fun Context.phoneNumberFlow(subscriptionInfo: SubscriptionInfo) = subscriptionsChangedFlow().map {
SubscriptionUtil.getFormattedPhoneNumber(this, subscriptionInfo)
diff --git a/src/com/android/settings/privatespace/PrivateSpaceBroadcastReceiver.java b/src/com/android/settings/privatespace/PrivateSpaceBroadcastReceiver.java
index 4c59ab9..fe65ab6 100644
--- a/src/com/android/settings/privatespace/PrivateSpaceBroadcastReceiver.java
+++ b/src/com/android/settings/privatespace/PrivateSpaceBroadcastReceiver.java
@@ -33,7 +33,7 @@
public void onReceive(Context context, Intent intent) {
if (android.multiuser.Flags.enablePrivateSpaceFeatures()
&& android.multiuser.Flags.blockPrivateSpaceCreation()) {
- Log.d("Here", "Intent: " + intent.getAction());
+ Log.d(TAG, "Received Intent: " + intent.getAction());
PrivateSpaceMaintainer privateSpaceMaintainer =
PrivateSpaceMaintainer.getInstance(context);
// Disable the PrivateSpaceAuthenticationActivity when
diff --git a/src/com/android/settings/privatespace/SetupSuccessFragment.java b/src/com/android/settings/privatespace/SetupSuccessFragment.java
index 90be48e..6eb3e9f 100644
--- a/src/com/android/settings/privatespace/SetupSuccessFragment.java
+++ b/src/com/android/settings/privatespace/SetupSuccessFragment.java
@@ -17,6 +17,7 @@
package com.android.settings.privatespace;
import android.app.Activity;
+import android.app.ActivityManager;
import android.app.settings.SettingsEnums;
import android.content.Intent;
import android.content.pm.PackageManager;
@@ -39,6 +40,8 @@
import com.google.android.setupcompat.template.FooterButton;
import com.google.android.setupdesign.GlifLayout;
+import java.util.List;
+
/** Fragment for the final screen shown on successful completion of private space setup. */
public class SetupSuccessFragment extends InstrumentedFragment {
private static final String TAG = "SetupSuccessFragment";
@@ -103,7 +106,7 @@
accessPrivateSpaceToast();
startActivity(allAppsIntent);
Log.i(TAG, "Private space setup complete");
- activity.finish();
+ deleteAllTaskAndFinish(activity);
}
};
}
@@ -118,4 +121,12 @@
drawable)
.show();
}
+
+ private void deleteAllTaskAndFinish(Activity activity) {
+ ActivityManager activityManager = activity.getSystemService(ActivityManager.class);
+ List<ActivityManager.AppTask> tasks = activityManager.getAppTasks();
+ for (var task : tasks) {
+ task.finishAndRemoveTask();
+ }
+ }
}
diff --git a/src/com/android/settings/spa/app/appinfo/AppInfoSettings.kt b/src/com/android/settings/spa/app/appinfo/AppInfoSettings.kt
index 2fd8fc5..f38dd96 100644
--- a/src/com/android/settings/spa/app/appinfo/AppInfoSettings.kt
+++ b/src/com/android/settings/spa/app/appinfo/AppInfoSettings.kt
@@ -179,5 +179,4 @@
}
fun isArchivingEnabled(featureFlags: PmFeatureFlags) =
- featureFlags.archiving() || SystemProperties.getBoolean("pm.archiving.enabled", false)
- || Flags.appArchiving()
\ No newline at end of file
+ featureFlags.archiving() || Flags.appArchiving()
\ No newline at end of file
diff --git a/src/com/android/settings/spa/app/appinfo/HibernationSwitchPreference.kt b/src/com/android/settings/spa/app/appinfo/HibernationSwitchPreference.kt
index 86d7f44..7a45ed4 100644
--- a/src/com/android/settings/spa/app/appinfo/HibernationSwitchPreference.kt
+++ b/src/com/android/settings/spa/app/appinfo/HibernationSwitchPreference.kt
@@ -93,8 +93,7 @@
}
private fun isArchivingEnabled() =
- PmFlags.archiving() || SystemProperties.getBoolean("pm.archiving.enabled", false)
- || Flags.appArchiving()
+ PmFlags.archiving() || Flags.appArchiving()
private class HibernationSwitchPresenter(context: Context, private val app: ApplicationInfo) {
private val appOpsManager = context.appOpsManager
diff --git a/src/com/android/settings/spa/network/SimsSection.kt b/src/com/android/settings/spa/network/SimsSection.kt
index bf0a33e..df92b37 100644
--- a/src/com/android/settings/spa/network/SimsSection.kt
+++ b/src/com/android/settings/spa/network/SimsSection.kt
@@ -24,6 +24,8 @@
import androidx.compose.foundation.layout.Column
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.outlined.Add
+import androidx.compose.material.icons.outlined.SimCard
+import androidx.compose.material.icons.outlined.SimCardDownload
import androidx.compose.runtime.Composable
import androidx.compose.runtime.State
import androidx.compose.runtime.remember
@@ -65,6 +67,7 @@
model = object : SwitchPreferenceModel {
override val title = subInfo.displayName.toString()
override val summary = { phoneNumber.value ?: "" }
+ override val icon = @Composable { SimIcon(subInfo.isEmbedded) }
override val checked = { checked.value }
override val onCheckedChange = { newChecked: Boolean ->
SubscriptionUtil.startToggleSubscriptionDialogActivity(
@@ -81,6 +84,11 @@
}
@Composable
+private fun SimIcon(isEmbedded: Boolean) {
+ SettingsIcon(if (isEmbedded) Icons.Outlined.SimCardDownload else Icons.Outlined.SimCard)
+}
+
+@Composable
fun phoneNumber(subInfo: SubscriptionInfo): State<String?> {
val context = LocalContext.current
return remember(subInfo) {
diff --git a/src/com/android/settings/wallpaper/WallpaperSuggestionActivity.java b/src/com/android/settings/wallpaper/WallpaperSuggestionActivity.java
index 675e10f..14ef483 100644
--- a/src/com/android/settings/wallpaper/WallpaperSuggestionActivity.java
+++ b/src/com/android/settings/wallpaper/WallpaperSuggestionActivity.java
@@ -17,7 +17,6 @@
package com.android.settings.wallpaper;
import android.app.WallpaperManager;
-import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
@@ -81,10 +80,9 @@
SearchIndexableRaw data = new SearchIndexableRaw(context);
data.title = controller.getTitle();
data.screenTitle = data.title;
- ComponentName component = controller.getComponentName();
- data.intentTargetPackage = component.getPackageName();
- data.intentTargetClass = component.getClassName();
- data.intentAction = controller.getComponentActionName();
+ data.intentTargetPackage = context.getPackageName();
+ data.intentTargetClass = WallpaperSuggestionActivity.class.getName();
+ data.intentAction = Intent.ACTION_MAIN;
data.key = SUPPORT_SEARCH_INDEX_KEY;
data.keywords = controller.getKeywords();
result.add(data);
diff --git a/src/com/android/settings/wifi/dpp/WifiDppQrCodeGeneratorFragment.java b/src/com/android/settings/wifi/dpp/WifiDppQrCodeGeneratorFragment.java
index 210e94c..3d437e2 100644
--- a/src/com/android/settings/wifi/dpp/WifiDppQrCodeGeneratorFragment.java
+++ b/src/com/android/settings/wifi/dpp/WifiDppQrCodeGeneratorFragment.java
@@ -26,7 +26,6 @@
import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.provider.Settings;
-import android.text.InputType;
import android.text.TextUtils;
import android.util.Log;
import android.view.LayoutInflater;
@@ -120,8 +119,6 @@
final String password = wifiNetworkConfig.getPreSharedKey();
TextView passwordView = view.findViewById(R.id.password);
- passwordView.setInputType(
- InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD);
if (TextUtils.isEmpty(password)) {
mSummary.setText(getString(
R.string.wifi_dpp_scan_open_network_qr_code_with_another_device,
diff --git a/tests/robotests/src/com/android/settings/deviceinfo/PrivateVolumeUnmountTest.java b/tests/robotests/src/com/android/settings/deviceinfo/PrivateVolumeUnmountTest.java
index 4704475..9425d08 100644
--- a/tests/robotests/src/com/android/settings/deviceinfo/PrivateVolumeUnmountTest.java
+++ b/tests/robotests/src/com/android/settings/deviceinfo/PrivateVolumeUnmountTest.java
@@ -30,19 +30,23 @@
import org.junit.Test;
import org.junit.runner.RunWith;
import org.robolectric.RobolectricTestRunner;
+import org.robolectric.android.util.concurrent.PausedExecutorService;
import org.robolectric.annotation.Config;
-import org.robolectric.annotation.LooperMode;
+import org.robolectric.shadows.ShadowLooper;
+import org.robolectric.shadows.ShadowPausedAsyncTask;
import org.robolectric.shadows.androidx.fragment.FragmentController;
@RunWith(RobolectricTestRunner.class)
-@LooperMode(LooperMode.Mode.LEGACY)
@Config(shadows = ShadowStorageManager.class)
public class PrivateVolumeUnmountTest {
private PrivateVolumeUnmount mFragment;
+ private PausedExecutorService mExecutorService;
@Before
public void setUp() {
+ mExecutorService = new PausedExecutorService();
+ ShadowPausedAsyncTask.overrideExecutor(mExecutorService);
Bundle bundle = new Bundle();
bundle.putString(VolumeInfo.EXTRA_VOLUME_ID, "id");
mFragment = FragmentController.of(new PrivateVolumeUnmount(), bundle)
@@ -65,6 +69,8 @@
final Button confirm = mFragment.getView().findViewById(R.id.confirm);
confirm.performClick();
+ mExecutorService.runAll();
+ ShadowLooper.idleMainLooper();
assertThat(ShadowStorageManager.isUnmountCalled()).isTrue();
}
diff --git a/tests/robotests/src/com/android/settings/deviceinfo/storage/StorageCacheHelperTest.java b/tests/robotests/src/com/android/settings/deviceinfo/storage/StorageCacheHelperTest.java
index a26ea1d..6468446 100644
--- a/tests/robotests/src/com/android/settings/deviceinfo/storage/StorageCacheHelperTest.java
+++ b/tests/robotests/src/com/android/settings/deviceinfo/storage/StorageCacheHelperTest.java
@@ -36,6 +36,7 @@
private static final long FAKE_APPS_SIZE = 4000L;
private static final long FAKE_GAMES_SIZE = 5000L;
private static final long FAKE_DOCS_SIZE = 1500L;
+ private static final long FAKE_OTHER_SIZE = 2000L;
private static final long FAKE_TRASH_SIZE = 500L;
private static final long FAKE_SYSTEM_SIZE = 2300L;
private static final long FAKE_TOTAL_SIZE = 256000L;
@@ -72,6 +73,8 @@
assertThat(storageCache.imagesSize).isEqualTo(FAKE_IMAGES_SIZE);
assertThat(storageCache.temporaryFilesSize).isEqualTo(FAKE_TEMPORARY_FILES_SIZE);
+ assertThat(storageCache.documentsSize).isEqualTo(FAKE_DOCS_SIZE);
+ assertThat(storageCache.otherSize).isEqualTo(FAKE_OTHER_SIZE);
assertThat(storageCache.totalSize).isEqualTo(0);
}
@@ -97,7 +100,8 @@
result.trashSize = FAKE_TRASH_SIZE;
result.systemSize = FAKE_SYSTEM_SIZE;
result.imagesSize = FAKE_IMAGES_SIZE;
- result.documentsAndOtherSize = FAKE_DOCS_SIZE;
+ result.documentsSize = FAKE_DOCS_SIZE;
+ result.otherSize = FAKE_OTHER_SIZE;
result.audioSize = FAKE_AUDIO_SIZE;
result.gamesSize = FAKE_GAMES_SIZE;
result.videosSize = FAKE_VIDEOS_SIZE;
diff --git a/tests/robotests/src/com/android/settings/deviceinfo/storage/StorageItemPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/deviceinfo/storage/StorageItemPreferenceControllerTest.java
index 2590f52..306d80c 100644
--- a/tests/robotests/src/com/android/settings/deviceinfo/storage/StorageItemPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/deviceinfo/storage/StorageItemPreferenceControllerTest.java
@@ -124,8 +124,10 @@
apps.setIcon(R.drawable.ic_storage_apps);
final StorageItemPreference games = spy(new StorageItemPreference(mContext));
games.setIcon(R.drawable.ic_videogame_vd_theme_24);
- final StorageItemPreference documentsAndOther = spy(new StorageItemPreference(mContext));
- documentsAndOther.setIcon(R.drawable.ic_folder_vd_theme_24);
+ final StorageItemPreference documents = spy(new StorageItemPreference(mContext));
+ documents.setIcon(R.drawable.ic_folder_vd_theme_24);
+ final StorageItemPreference other = spy(new StorageItemPreference(mContext));
+ other.setIcon(R.drawable.ic_category_vd_theme_24);
final StorageItemPreference system = spy(new StorageItemPreference(mContext));
system.setIcon(R.drawable.ic_android_vd_theme_24);
final StorageItemPreference temporaryFiles = spy(new StorageItemPreference(mContext));
@@ -147,8 +149,10 @@
.thenReturn(apps);
when(screen.findPreference(eq(StorageItemPreferenceController.GAMES_KEY)))
.thenReturn(games);
- when(screen.findPreference(eq(StorageItemPreferenceController.DOCUMENTS_AND_OTHER_KEY)))
- .thenReturn(documentsAndOther);
+ when(screen.findPreference(eq(StorageItemPreferenceController.DOCUMENTS_KEY)))
+ .thenReturn(documents);
+ when(screen.findPreference(eq(StorageItemPreferenceController.OTHER_KEY)))
+ .thenReturn(other);
when(screen.findPreference(eq(StorageItemPreferenceController.SYSTEM_KEY)))
.thenReturn(system);
when(screen.findPreference(eq(StorageItemPreferenceController.TEMPORARY_FILES_KEY)))
@@ -225,7 +229,8 @@
assertThat(mController.mAudioPreference.isVisible()).isFalse();
assertThat(mController.mAppsPreference.isVisible()).isFalse();
assertThat(mController.mGamesPreference.isVisible()).isFalse();
- assertThat(mController.mDocumentsAndOtherPreference.isVisible()).isFalse();
+ assertThat(mController.mDocumentsPreference.isVisible()).isFalse();
+ assertThat(mController.mOtherPreference.isVisible()).isFalse();
assertThat(mController.mSystemPreference.isVisible()).isFalse();
assertThat(mController.mTemporaryFilesPreference.isVisible()).isFalse();
assertThat(mController.mTrashPreference.isVisible()).isFalse();
@@ -278,8 +283,8 @@
}
@Test
- public void launchDocumentsAndOtherIntent_resolveActionViewNull_settingsIntent() {
- mPreference.setKey(StorageItemPreferenceController.DOCUMENTS_AND_OTHER_KEY);
+ public void launchDocumentsIntent_resolveActionViewNull_settingsIntent() {
+ mPreference.setKey(StorageItemPreferenceController.DOCUMENTS_KEY);
final Context mockContext = getMockContext();
mController = new StorageItemPreferenceController(mockContext, mFragment, mVolume,
mSvp, ProfileSelectFragment.ProfileType.PERSONAL);
@@ -291,7 +296,24 @@
Intent intent = argumentCaptor.getValue();
assertThat(intent.getAction()).isEqualTo(Intent.ACTION_VIEW);
- assertThat(intent.getData()).isEqualTo(mController.mDocumentsAndOtherUri);
+ assertThat(intent.getData()).isEqualTo(mController.mDocumentsUri);
+ }
+
+ @Test
+ public void launchOtherIntent_resolveActionViewNull_settingsIntent() {
+ mPreference.setKey(StorageItemPreferenceController.OTHER_KEY);
+ final Context mockContext = getMockContext();
+ mController = new StorageItemPreferenceController(mockContext, mFragment, mVolume,
+ mSvp, ProfileSelectFragment.ProfileType.PERSONAL);
+ mController.handlePreferenceTreeClick(mPreference);
+
+ final ArgumentCaptor<Intent> argumentCaptor = ArgumentCaptor.forClass(Intent.class);
+ verify(mockContext).startActivityAsUser(argumentCaptor.capture(),
+ nullable(UserHandle.class));
+
+ Intent intent = argumentCaptor.getValue();
+ assertThat(intent.getAction()).isEqualTo(Intent.ACTION_VIEW);
+ assertThat(intent.getData()).isEqualTo(mController.mOtherUri);
}
@Test
@@ -359,7 +381,8 @@
result.imagesSize = MEGABYTE_IN_BYTES * 350;
result.videosSize = GIGABYTE_IN_BYTES * 30;
result.audioSize = MEGABYTE_IN_BYTES * 40;
- result.documentsAndOtherSize = MEGABYTE_IN_BYTES * 50;
+ result.documentsSize = MEGABYTE_IN_BYTES * 50;
+ result.otherSize = MEGABYTE_IN_BYTES * 70;
result.trashSize = KILOBYTE_IN_BYTES * 100;
result.allAppsExceptGamesSize = MEGABYTE_IN_BYTES * 90;
result.systemSize = MEGABYTE_IN_BYTES * 60;
@@ -373,8 +396,8 @@
assertThat(mController.mAudioPreference.getSummary().toString()).isEqualTo("40 MB");
assertThat(mController.mAppsPreference.getSummary().toString()).isEqualTo("90 MB");
assertThat(mController.mGamesPreference.getSummary().toString()).isEqualTo("80 MB");
- assertThat(mController.mDocumentsAndOtherPreference.getSummary().toString())
- .isEqualTo("50 MB");
+ assertThat(mController.mDocumentsPreference.getSummary().toString()).isEqualTo("50 MB");
+ assertThat(mController.mOtherPreference.getSummary().toString()).isEqualTo("70 MB");
assertThat(mController.mTrashPreference.getSummary().toString()).isEqualTo("100 kB");
assertThat(mController.mSystemPreference.getSummary().toString())
.isEqualTo("60 MB");
@@ -392,8 +415,8 @@
verify(mController.mAudioPreference, times(2)).setIcon(nullable(Drawable.class));
verify(mController.mAppsPreference, times(2)).setIcon(nullable(Drawable.class));
verify(mController.mGamesPreference, times(2)).setIcon(nullable(Drawable.class));
- verify(mController.mDocumentsAndOtherPreference, times(2))
- .setIcon(nullable(Drawable.class));
+ verify(mController.mDocumentsPreference, times(2)).setIcon(nullable(Drawable.class));
+ verify(mController.mOtherPreference, times(2)).setIcon(nullable(Drawable.class));
verify(mController.mSystemPreference, times(2)).setIcon(nullable(Drawable.class));
verify(mController.mTemporaryFilesPreference, times(2)).setIcon(nullable(Drawable.class));
verify(mController.mTrashPreference, times(2)).setIcon(nullable(Drawable.class));
@@ -408,7 +431,8 @@
mController.displayPreference(mPreferenceScreen);
- assertThat(mController.mDocumentsAndOtherPreference.isVisible()).isTrue();
+ assertThat(mController.mDocumentsPreference.isVisible()).isTrue();
+ assertThat(mController.mOtherPreference.isVisible()).isTrue();
}
@Test
@@ -423,7 +447,8 @@
mController.setPrivateStorageCategoryPreferencesVisibility(true);
- assertThat(mController.mDocumentsAndOtherPreference.isVisible()).isFalse();
+ assertThat(mController.mDocumentsPreference.isVisible()).isFalse();
+ assertThat(mController.mOtherPreference.isVisible()).isFalse();
}
@Test
@@ -438,7 +463,8 @@
// And we bring it back.
mController.setVolume(mVolume);
- assertThat(mController.mDocumentsAndOtherPreference.isVisible()).isTrue();
+ assertThat(mController.mDocumentsPreference.isVisible()).isTrue();
+ assertThat(mController.mOtherPreference.isVisible()).isTrue();
}
@Test
@@ -458,7 +484,8 @@
assertThat(mController.mAudioPreference.isVisible()).isFalse();
assertThat(mController.mAppsPreference.isVisible()).isFalse();
assertThat(mController.mGamesPreference.isVisible()).isFalse();
- assertThat(mController.mDocumentsAndOtherPreference.isVisible()).isFalse();
+ assertThat(mController.mDocumentsPreference.isVisible()).isFalse();
+ assertThat(mController.mOtherPreference.isVisible()).isFalse();
assertThat(mController.mSystemPreference.isVisible()).isFalse();
assertThat(mController.mTemporaryFilesPreference.isVisible()).isFalse();
assertThat(mController.mTrashPreference.isVisible()).isFalse();
diff --git a/tests/robotests/src/com/android/settings/enterprise/EnterpriseSetDefaultAppsListPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/enterprise/EnterpriseSetDefaultAppsListPreferenceControllerTest.java
index 1a16d04..dc614555 100644
--- a/tests/robotests/src/com/android/settings/enterprise/EnterpriseSetDefaultAppsListPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/enterprise/EnterpriseSetDefaultAppsListPreferenceControllerTest.java
@@ -37,6 +37,7 @@
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.SettingsPreferenceFragment;
@@ -46,23 +47,27 @@
import com.android.settings.testutils.FakeFeatureFactory;
import org.junit.Before;
+import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.ArgumentCaptor;
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 org.robolectric.annotation.LooperMode;
-import org.robolectric.shadows.ShadowApplication;
+import org.robolectric.android.util.concurrent.PausedExecutorService;
+import org.robolectric.shadows.ShadowLooper;
+import org.robolectric.shadows.ShadowPausedAsyncTask;
import java.util.Arrays;
import java.util.Collections;
@RunWith(RobolectricTestRunner.class)
-@LooperMode(LooperMode.Mode.LEGACY)
public class EnterpriseSetDefaultAppsListPreferenceControllerTest {
+ @Rule
+ public final MockitoRule mMockitoRule = MockitoJUnit.rule();
+
private static final int USER_ID = 0;
private static final int APP_UID = 0;
@@ -82,11 +87,13 @@
private Context mContext;
private FakeFeatureFactory mFeatureFactory;
+ private PausedExecutorService mExecutorService;
@Before
public void setUp() {
- MockitoAnnotations.initMocks(this);
- mContext = spy(RuntimeEnvironment.application);
+ mExecutorService = new PausedExecutorService();
+ ShadowPausedAsyncTask.overrideExecutor(mExecutorService);
+ mContext = spy(ApplicationProvider.getApplicationContext());
mFeatureFactory = FakeFeatureFactory.setupForTest();
when(mFragment.getPreferenceScreen()).thenReturn(mScreen);
when(mPrefenceManager.getContext()).thenReturn(mContext);
@@ -127,7 +134,8 @@
new UserAppInfo(user, appInfo2)));
new EnterpriseSetDefaultAppsListPreferenceController(mContext, mFragment, mPackageManager);
- ShadowApplication.runBackgroundTasks();
+ mExecutorService.runAll();
+ ShadowLooper.idleMainLooper();
ArgumentCaptor<Preference> apps = ArgumentCaptor.forClass(Preference.class);
verify(mScreen, times(2)).addPreference(apps.capture());
diff --git a/tests/robotests/src/com/android/settings/fuelgauge/batteryusage/DataProcessManagerTest.java b/tests/robotests/src/com/android/settings/fuelgauge/batteryusage/DataProcessManagerTest.java
index b025db8..7faca0d 100644
--- a/tests/robotests/src/com/android/settings/fuelgauge/batteryusage/DataProcessManagerTest.java
+++ b/tests/robotests/src/com/android/settings/fuelgauge/batteryusage/DataProcessManagerTest.java
@@ -41,19 +41,24 @@
import android.os.UserManager;
import android.text.format.DateUtils;
+import androidx.test.core.app.ApplicationProvider;
+
import com.android.settings.fuelgauge.batteryusage.db.AppUsageEventEntity;
import org.junit.After;
import org.junit.Before;
+import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.ArgumentCaptor;
import org.mockito.Captor;
import org.mockito.Mock;
-import org.mockito.MockitoAnnotations;
+import org.mockito.junit.MockitoJUnit;
+import org.mockito.junit.MockitoRule;
import org.robolectric.RobolectricTestRunner;
-import org.robolectric.RuntimeEnvironment;
-import org.robolectric.annotation.LooperMode;
+import org.robolectric.android.util.concurrent.PausedExecutorService;
+import org.robolectric.shadows.ShadowLooper;
+import org.robolectric.shadows.ShadowPausedAsyncTask;
import java.util.ArrayList;
import java.util.Collections;
@@ -65,10 +70,14 @@
@RunWith(RobolectricTestRunner.class)
public final class DataProcessManagerTest {
+ @Rule
+ public final MockitoRule mMockitoRule = MockitoJUnit.rule();
+
private static final String FAKE_ENTRY_KEY = "fake_entry_key";
private Context mContext;
private DataProcessManager mDataProcessManager;
+ private PausedExecutorService mExecutorService;
@Mock private UserIdsSeries mUserIdsSeries;
@Mock private IUsageStatsManager mUsageStatsManager;
@@ -80,9 +89,9 @@
@Before
public void setUp() {
- MockitoAnnotations.initMocks(this);
-
- mContext = spy(RuntimeEnvironment.application);
+ mExecutorService = new PausedExecutorService();
+ ShadowPausedAsyncTask.overrideExecutor(mExecutorService);
+ mContext = spy(ApplicationProvider.getApplicationContext());
DataProcessor.sTestSystemAppsPackageNames = Set.of();
DataProcessor.sUsageStatsManager = mUsageStatsManager;
doReturn(mContext).when(mContext).getApplicationContext();
@@ -117,7 +126,6 @@
}
@Test
- @LooperMode(LooperMode.Mode.LEGACY)
public void constructor_noLevelData() {
final DataProcessManager dataProcessManager =
new DataProcessManager(
@@ -129,7 +137,6 @@
}
@Test
- @LooperMode(LooperMode.Mode.LEGACY)
public void start_loadEmptyDatabaseAppUsageData() {
final MatrixCursor cursor =
new MatrixCursor(
@@ -142,6 +149,8 @@
doReturn(true).when(mUserManager).isUserUnlocked(anyInt());
mDataProcessManager.start();
+ mExecutorService.runAll();
+ ShadowLooper.idleMainLooper();
assertThat(mDataProcessManager.getIsCurrentAppUsageLoaded()).isTrue();
assertThat(mDataProcessManager.getIsDatabaseAppUsageLoaded()).isTrue();
@@ -152,7 +161,6 @@
}
@Test
- @LooperMode(LooperMode.Mode.LEGACY)
public void start_loadExpectedAppUsageData() throws RemoteException {
final List<BatteryLevelData.PeriodBatteryLevelData> hourlyBatteryLevelsPerDay =
new ArrayList<>();
@@ -254,6 +262,8 @@
hourlyBatteryLevelsPerDay,
/* batteryHistoryMap= */ new HashMap<>());
dataProcessManager.start();
+ mExecutorService.runAll();
+ ShadowLooper.idleMainLooper();
assertThat(dataProcessManager.getIsCurrentAppUsageLoaded()).isTrue();
assertThat(dataProcessManager.getIsDatabaseAppUsageLoaded()).isTrue();
@@ -301,7 +311,6 @@
}
@Test
- @LooperMode(LooperMode.Mode.LEGACY)
public void start_currentUserLocked_emptyAppUsageList() throws RemoteException {
final UsageEvents.Event event =
getUsageEvent(UsageEvents.Event.ACTIVITY_RESUMED, /* timestamp= */ 1, "package");
@@ -323,6 +332,8 @@
DatabaseUtils.sFakeSupplier = () -> cursor;
mDataProcessManager.start();
+ mExecutorService.runAll();
+ ShadowLooper.idleMainLooper();
assertThat(mDataProcessManager.getAppUsageEventList()).isEmpty();
assertThat(mDataProcessManager.getAppUsagePeriodMap()).isNull();
@@ -330,7 +341,6 @@
}
@Test
- @LooperMode(LooperMode.Mode.LEGACY)
public void getBatteryLevelData_emptyHistoryMap_returnNull() {
assertThat(
DataProcessManager.getBatteryLevelData(
diff --git a/tests/robotests/src/com/android/settings/network/EuiccRacConnectivityDialogFragmentTest.java b/tests/robotests/src/com/android/settings/network/EuiccRacConnectivityDialogFragmentTest.java
new file mode 100644
index 0000000..3a4ba6e
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/network/EuiccRacConnectivityDialogFragmentTest.java
@@ -0,0 +1,83 @@
+/*
+ * 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;
+
+import static org.mockito.Mockito.verify;
+
+import android.app.settings.SettingsEnums;
+import android.content.DialogInterface;
+
+import com.android.settings.system.ResetDashboardFragment;
+import com.android.settings.testutils.FakeFeatureFactory;
+
+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.shadows.androidx.fragment.FragmentController;
+
+@RunWith(RobolectricTestRunner.class)
+public class EuiccRacConnectivityDialogFragmentTest {
+ private static final int CONTINUE_VALUE = 1;
+ private static final int CANCEL_VALUE = 0;
+
+ private EuiccRacConnectivityDialogFragment mRacDialogFragment;
+ private FakeFeatureFactory mFeatureFactory;
+ @Mock private DialogInterface mDialogInterface;
+
+ @Before
+ public void setUp() {
+ MockitoAnnotations.initMocks(this);
+ mFeatureFactory = FakeFeatureFactory.setupForTest();
+ mRacDialogFragment = new EuiccRacConnectivityDialogFragment();
+
+ FragmentController.setupFragment(mRacDialogFragment);
+ mRacDialogFragment.setTargetFragment(new ResetDashboardFragment(), /* requestCode= */ 0);
+ }
+
+ @Test
+ public void dialogAction_continue_intentResetESIMS_metricsLogged() {
+ mRacDialogFragment.onClick(mDialogInterface, DialogInterface.BUTTON_NEGATIVE);
+ verify(mFeatureFactory.metricsFeatureProvider)
+ .action(
+ mRacDialogFragment.getActivity(),
+ SettingsEnums.ACTION_RESET_ESIMS_RAC_CONNECTIVITY_WARNING,
+ CONTINUE_VALUE);
+ }
+
+ @Test
+ public void dialogAction_backCancel_intentResetESIMS_metricsLogged() {
+ mRacDialogFragment.onCancel(mDialogInterface);
+ verify(mFeatureFactory.metricsFeatureProvider)
+ .action(
+ mRacDialogFragment.getActivity(),
+ SettingsEnums.ACTION_RESET_ESIMS_RAC_CONNECTIVITY_WARNING,
+ CANCEL_VALUE);
+ }
+
+ @Test
+ public void dialogAction_buttonCancel_intentResetESIMS_metricsLogged() {
+ mRacDialogFragment.onCancel(mDialogInterface);
+ verify(mFeatureFactory.metricsFeatureProvider)
+ .action(
+ mRacDialogFragment.getActivity(),
+ SettingsEnums.ACTION_RESET_ESIMS_RAC_CONNECTIVITY_WARNING,
+ CANCEL_VALUE);
+ }
+}
diff --git a/tests/spa_unit/src/com/android/settings/spa/app/appinfo/HibernationSwitchPreferenceTest.kt b/tests/spa_unit/src/com/android/settings/spa/app/appinfo/HibernationSwitchPreferenceTest.kt
index b61e3a9..a0be3f2 100644
--- a/tests/spa_unit/src/com/android/settings/spa/app/appinfo/HibernationSwitchPreferenceTest.kt
+++ b/tests/spa_unit/src/com/android/settings/spa/app/appinfo/HibernationSwitchPreferenceTest.kt
@@ -163,8 +163,7 @@
}
private fun isArchivingEnabled() =
- PmFlags.archiving() || SystemProperties.getBoolean("pm.archiving.enabled", false)
- || Flags.appArchiving()
+ PmFlags.archiving() || Flags.appArchiving()
@Test
fun `An app targets Q with ops mode default when hibernation targets pre S - not exempted`() {
mockOpsMode(MODE_DEFAULT)
diff --git a/tests/unit/src/com/android/settings/network/InternetPreferenceControllerTest.java b/tests/unit/src/com/android/settings/network/InternetPreferenceControllerTest.java
index 4ba12cb..8a4acd2 100644
--- a/tests/unit/src/com/android/settings/network/InternetPreferenceControllerTest.java
+++ b/tests/unit/src/com/android/settings/network/InternetPreferenceControllerTest.java
@@ -49,6 +49,7 @@
import androidx.test.core.app.ApplicationProvider;
import androidx.test.ext.junit.runners.AndroidJUnit4;
+import com.android.settings.R;
import com.android.settings.testutils.ResourcesUtils;
import com.android.settings.wifi.WifiPickerTrackerHelper;
import com.android.settings.wifi.WifiSummaryUpdater;
@@ -188,8 +189,9 @@
}
@Test
- public void isAvailable_shouldBeTrue() {
- assertThat(mController.isAvailable()).isTrue();
+ public void isAvailable_shouldMatchPrefFlag() {
+ assertThat(mController.isAvailable()).isEqualTo(
+ mContext.getResources().getBoolean(R.bool.config_show_internet_settings));
}
@Test
diff --git a/tests/unit/src/com/android/settings/network/SubscriptionsPreferenceControllerTest.java b/tests/unit/src/com/android/settings/network/SubscriptionsPreferenceControllerTest.java
index 58a3f3a..c443b23 100644
--- a/tests/unit/src/com/android/settings/network/SubscriptionsPreferenceControllerTest.java
+++ b/tests/unit/src/com/android/settings/network/SubscriptionsPreferenceControllerTest.java
@@ -165,7 +165,7 @@
mController = new FakeSubscriptionsPreferenceController(mContext, mLifecycle,
mUpdateListener, KEY, 5);
Settings.Global.putInt(mContext.getContentResolver(), Settings.Global.AIRPLANE_MODE_ON, 0);
- mController.setWifiPickerTrackerHelper(mWifiPickerTrackerHelper);
+ mController.mWifiPickerTrackerHelper = mWifiPickerTrackerHelper;
}
@After
diff --git a/tests/unit/src/com/android/settings/privatespace/PrivateSpaceAuthenticationActivityTest.java b/tests/unit/src/com/android/settings/privatespace/PrivateSpaceAuthenticationActivityTest.java
index 8a7bd70..499cd93 100644
--- a/tests/unit/src/com/android/settings/privatespace/PrivateSpaceAuthenticationActivityTest.java
+++ b/tests/unit/src/com/android/settings/privatespace/PrivateSpaceAuthenticationActivityTest.java
@@ -18,6 +18,7 @@
import static com.google.common.truth.Truth.assertThat;
+import static org.junit.Assume.assumeTrue;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.doNothing;
import static org.mockito.Mockito.spy;
@@ -27,6 +28,7 @@
import android.content.Context;
import android.content.Intent;
import android.os.Flags;
+import android.os.UserManager;
import android.platform.test.annotations.RequiresFlagsEnabled;
import android.platform.test.flag.junit.CheckFlagsRule;
import android.platform.test.flag.junit.DeviceFlagsValueProvider;
@@ -91,6 +93,7 @@
@RequiresFlagsEnabled({Flags.FLAG_ALLOW_PRIVATE_PROFILE,
android.multiuser.Flags.FLAG_ENABLE_PRIVATE_SPACE_FEATURES})
public void whenPrivateProfileDoesNotExist_triggersSetupFlow() {
+ assumeTrue(mContext.getSystemService(UserManager.class).canAddPrivateProfile());
when(mPrivateSpaceMaintainer.doesPrivateSpaceExist()).thenReturn(false);
final ArgumentCaptor<Intent> intentCaptor = ArgumentCaptor.forClass(Intent.class);
diff --git a/tests/unit/src/com/android/settings/privatespace/PrivateSpaceMaintainerTest.java b/tests/unit/src/com/android/settings/privatespace/PrivateSpaceMaintainerTest.java
index f75e76f..637b485 100644
--- a/tests/unit/src/com/android/settings/privatespace/PrivateSpaceMaintainerTest.java
+++ b/tests/unit/src/com/android/settings/privatespace/PrivateSpaceMaintainerTest.java
@@ -81,6 +81,7 @@
public void deletePrivateSpace_psExists_deletesPS() {
mSetFlagsRule.enableFlags(
android.multiuser.Flags.FLAG_ENABLE_PRIVATE_SPACE_FEATURES);
+ assumeTrue(mContext.getSystemService(UserManager.class).canAddPrivateProfile());
PrivateSpaceMaintainer privateSpaceMaintainer =
PrivateSpaceMaintainer.getInstance(mContext);
privateSpaceMaintainer.createPrivateSpace();
@@ -114,6 +115,7 @@
public void createPrivateSpace_psDoesNotExist_createsPS() {
mSetFlagsRule.enableFlags(
android.multiuser.Flags.FLAG_ENABLE_PRIVATE_SPACE_FEATURES);
+ assumeTrue(mContext.getSystemService(UserManager.class).canAddPrivateProfile());
PrivateSpaceMaintainer privateSpaceMaintainer =
PrivateSpaceMaintainer.getInstance(mContext);
privateSpaceMaintainer.deletePrivateSpace();
@@ -129,6 +131,7 @@
public void createPrivateSpace_psExists_returnsFalse() {
mSetFlagsRule.enableFlags(
android.multiuser.Flags.FLAG_ENABLE_PRIVATE_SPACE_FEATURES);
+ assumeTrue(mContext.getSystemService(UserManager.class).canAddPrivateProfile());
PrivateSpaceMaintainer privateSpaceMaintainer =
PrivateSpaceMaintainer.getInstance(mContext);
privateSpaceMaintainer.deletePrivateSpace();
@@ -145,6 +148,7 @@
public void createPrivateSpace_psDoesNotExist_resetsHidePSSettings() {
mSetFlagsRule.enableFlags(
android.multiuser.Flags.FLAG_ENABLE_PRIVATE_SPACE_FEATURES);
+ assumeTrue(mContext.getSystemService(UserManager.class).canAddPrivateProfile());
PrivateSpaceMaintainer privateSpaceMaintainer =
PrivateSpaceMaintainer.getInstance(mContext);
Settings.Secure.putInt(
@@ -168,6 +172,7 @@
Flags.FLAG_ALLOW_PRIVATE_PROFILE,
android.multiuser.Flags.FLAG_ENABLE_PS_SENSITIVE_NOTIFICATIONS_TOGGLE,
android.multiuser.Flags.FLAG_ENABLE_PRIVATE_SPACE_FEATURES);
+ assumeTrue(mContext.getSystemService(UserManager.class).canAddPrivateProfile());
PrivateSpaceMaintainer privateSpaceMaintainer =
PrivateSpaceMaintainer.getInstance(mContext);
privateSpaceMaintainer.deletePrivateSpace();
@@ -185,6 +190,7 @@
public void createPrivateSpace_psExists_doesNotResetHidePSSettings() {
mSetFlagsRule.enableFlags(
android.multiuser.Flags.FLAG_ENABLE_PRIVATE_SPACE_FEATURES);
+ assumeTrue(mContext.getSystemService(UserManager.class).canAddPrivateProfile());
PrivateSpaceMaintainer privateSpaceMaintainer =
PrivateSpaceMaintainer.getInstance(mContext);
privateSpaceMaintainer.createPrivateSpace();
@@ -230,6 +236,7 @@
public void lockPrivateSpace_psExistsAndPrivateProfileRunning_locksCreatedPrivateSpace() {
mSetFlagsRule.enableFlags(
android.multiuser.Flags.FLAG_ENABLE_PRIVATE_SPACE_FEATURES);
+ assumeTrue(mContext.getSystemService(UserManager.class).canAddPrivateProfile());
PrivateSpaceMaintainer privateSpaceMaintainer =
PrivateSpaceMaintainer.getInstance(mContext);
privateSpaceMaintainer.createPrivateSpace();
@@ -248,6 +255,7 @@
public void lockPrivateSpace_psExistsAndPrivateProfileNotRunning_returnsFalse() {
mSetFlagsRule.enableFlags(
android.multiuser.Flags.FLAG_ENABLE_PRIVATE_SPACE_FEATURES);
+ assumeTrue(mContext.getSystemService(UserManager.class).canAddPrivateProfile());
PrivateSpaceMaintainer privateSpaceMaintainer =
PrivateSpaceMaintainer.getInstance(mContext);
privateSpaceMaintainer.createPrivateSpace();
@@ -284,6 +292,7 @@
public void createPrivateSpace_psDoesNotExist_setsUserSetupComplete() {
mSetFlagsRule.enableFlags(
android.multiuser.Flags.FLAG_ENABLE_PRIVATE_SPACE_FEATURES);
+ assumeTrue(mContext.getSystemService(UserManager.class).canAddPrivateProfile());
PrivateSpaceMaintainer privateSpaceMaintainer =
PrivateSpaceMaintainer.getInstance(mContext);
privateSpaceMaintainer.createPrivateSpace();
@@ -298,6 +307,7 @@
public void createPrivateSpace_pSExists_doesNotChangeUserSetupSetting() {
mSetFlagsRule.enableFlags(
android.multiuser.Flags.FLAG_ENABLE_PRIVATE_SPACE_FEATURES);
+ assumeTrue(mContext.getSystemService(UserManager.class).canAddPrivateProfile());
PrivateSpaceMaintainer privateSpaceMaintainer =
PrivateSpaceMaintainer.getInstance(mContext);
privateSpaceMaintainer.createPrivateSpace();
@@ -316,6 +326,7 @@
Flags.FLAG_ALLOW_PRIVATE_PROFILE,
android.multiuser.Flags.FLAG_SUPPORT_AUTOLOCK_FOR_PRIVATE_SPACE,
android.multiuser.Flags.FLAG_ENABLE_PRIVATE_SPACE_FEATURES);
+ assumeTrue(mContext.getSystemService(UserManager.class).canAddPrivateProfile());
final int autoLockOption = 2;
PrivateSpaceMaintainer privateSpaceMaintainer =
PrivateSpaceMaintainer.getInstance(mContext);
@@ -340,6 +351,7 @@
Flags.FLAG_ALLOW_PRIVATE_PROFILE,
android.multiuser.Flags.FLAG_SUPPORT_AUTOLOCK_FOR_PRIVATE_SPACE,
android.multiuser.Flags.FLAG_ENABLE_PRIVATE_SPACE_FEATURES);
+ assumeTrue(mContext.getSystemService(UserManager.class).canAddPrivateProfile());
final int privateSpaceAutLockValue = 1;
PrivateSpaceMaintainer privateSpaceMaintainer =
PrivateSpaceMaintainer.getInstance(mContext);
diff --git a/tests/unit/src/com/android/settings/privatespace/delete/PrivateSpaceDeletionProgressFragmentTest.java b/tests/unit/src/com/android/settings/privatespace/delete/PrivateSpaceDeletionProgressFragmentTest.java
index ffc1edf..d6eadd5 100644
--- a/tests/unit/src/com/android/settings/privatespace/delete/PrivateSpaceDeletionProgressFragmentTest.java
+++ b/tests/unit/src/com/android/settings/privatespace/delete/PrivateSpaceDeletionProgressFragmentTest.java
@@ -20,6 +20,7 @@
import static com.google.common.truth.Truth.assertThat;
+import static org.junit.Assume.assumeTrue;
import static org.mockito.Mockito.doNothing;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.spy;
@@ -28,6 +29,7 @@
import android.app.settings.SettingsEnums;
import android.content.Context;
import android.os.Flags;
+import android.os.UserManager;
import android.platform.test.flag.junit.SetFlagsRule;
import androidx.test.annotation.UiThreadTest;
@@ -90,6 +92,7 @@
doNothing().when(spyFragment).showSuccessfulDeletionToast();
mSetFlagsRule.enableFlags(Flags.FLAG_ALLOW_PRIVATE_PROFILE,
android.multiuser.Flags.FLAG_ENABLE_PRIVATE_SPACE_FEATURES);
+ assumeTrue(mContext.getSystemService(UserManager.class).canAddPrivateProfile());
mPrivateSpaceMaintainer.createPrivateSpace();
spyFragment.deletePrivateSpace();
@@ -104,6 +107,7 @@
doNothing().when(spyFragment).showSuccessfulDeletionToast();
mSetFlagsRule.enableFlags(Flags.FLAG_ALLOW_PRIVATE_PROFILE,
android.multiuser.Flags.FLAG_ENABLE_PRIVATE_SPACE_FEATURES);
+ assumeTrue(mContext.getSystemService(UserManager.class).canAddPrivateProfile());
mPrivateSpaceMaintainer.createPrivateSpace();
spyFragment.deletePrivateSpace();
@@ -128,6 +132,7 @@
doNothing().when(spyFragment).showDeletionInternalErrorToast();
mSetFlagsRule.enableFlags(Flags.FLAG_ALLOW_PRIVATE_PROFILE,
android.multiuser.Flags.FLAG_ENABLE_PRIVATE_SPACE_FEATURES);
+ assumeTrue(mContext.getSystemService(UserManager.class).canAddPrivateProfile());
spyFragment.deletePrivateSpace();