Merge "[Audiosharing] Dismiss all dialogs before show a new one." into main
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index 85a443e..f88c55d 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -1741,6 +1741,8 @@
android:targetActivity=".spa.SpaBridgeActivity">
<meta-data android:name="com.android.settings.spa.DESTINATION"
android:value="TogglePermissionAppList/UseFullScreenIntent"/>
+ <meta-data android:name="com.android.settings.HIGHLIGHT_MENU_KEY"
+ android:value="@string/menu_key_apps"/>
</activity-alias>
<activity-alias android:name="AppManageFullScreenIntent"
@@ -1753,6 +1755,8 @@
</intent-filter>
<meta-data android:name="com.android.settings.spa.DESTINATION"
android:value="TogglePermissionAppInfoPage/UseFullScreenIntent"/>
+ <meta-data android:name="com.android.settings.HIGHLIGHT_MENU_KEY"
+ android:value="@string/menu_key_apps"/>
</activity-alias>
<activity android:name=".applications.InstalledAppOpenByDefaultActivity"
@@ -4967,6 +4971,8 @@
</intent-filter>
<meta-data android:name="com.android.settings.spa.DESTINATION"
android:value="UsageStats"/>
+ <meta-data android:name="com.android.settings.HIGHLIGHT_MENU_KEY"
+ android:value="@string/menu_key_apps"/>
</activity-alias>
<!-- [b/197780098] Disable eager initialization of Jetpack libraries. -->
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 6ed0d82..6ccfbb7 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -6071,10 +6071,6 @@
<!-- Backup and reset Settings screen --><skip />
<!-- Backup and reset settings menu and activity title -->
<string name="privacy_settings_title">Backup</string>
- <!-- Summary for the Backup settings when it is turned on. -->
- <string name="backup_summary_state_on">On</string>
- <!-- Summary for the Backup settings when it is turned off. -->
- <string name="backup_summary_state_off">Off</string>
<!-- Backup section title -->
<string name="backup_section_title">Backup & restore</string>
<!-- Personal data section title -->
diff --git a/src/com/android/settings/applications/AppInfoBase.java b/src/com/android/settings/applications/AppInfoBase.java
index 6f8597e..2c41be4 100644
--- a/src/com/android/settings/applications/AppInfoBase.java
+++ b/src/com/android/settings/applications/AppInfoBase.java
@@ -144,10 +144,14 @@
if (mAppEntry != null) {
// Get application info again to refresh changed properties of application
try {
- mPackageInfo = mPm.getPackageInfoAsUser(mAppEntry.info.packageName,
- PackageManager.MATCH_DISABLED_COMPONENTS |
- PackageManager.GET_SIGNING_CERTIFICATES |
- PackageManager.GET_PERMISSIONS, mUserId);
+ mPackageInfo = mPm.getPackageInfoAsUser(
+ mAppEntry.info.packageName,
+ PackageManager.PackageInfoFlags.of(
+ PackageManager.MATCH_DISABLED_COMPONENTS
+ | PackageManager.GET_SIGNING_CERTIFICATES
+ | PackageManager.GET_PERMISSIONS
+ | PackageManager.MATCH_ARCHIVED_PACKAGES),
+ mUserId);
} catch (NameNotFoundException e) {
Log.e(TAG, "Exception when retrieving package:" + mAppEntry.info.packageName, e);
}
diff --git a/src/com/android/settings/applications/appinfo/AppInfoDashboardFragment.java b/src/com/android/settings/applications/appinfo/AppInfoDashboardFragment.java
index e771ff4..82d55f3 100644
--- a/src/com/android/settings/applications/appinfo/AppInfoDashboardFragment.java
+++ b/src/com/android/settings/applications/appinfo/AppInfoDashboardFragment.java
@@ -731,10 +731,12 @@
try {
mPackageInfo = activity.getPackageManager().getPackageInfo(
mAppEntry.info.packageName,
- PackageManager.MATCH_DISABLED_COMPONENTS |
- PackageManager.MATCH_ANY_USER |
- PackageManager.GET_SIGNATURES |
- PackageManager.GET_PERMISSIONS);
+ PackageManager.PackageInfoFlags.of(
+ PackageManager.MATCH_DISABLED_COMPONENTS
+ | PackageManager.MATCH_ANY_USER
+ | PackageManager.GET_SIGNATURES
+ | PackageManager.GET_PERMISSIONS
+ | PackageManager.MATCH_ARCHIVED_PACKAGES));
} catch (NameNotFoundException e) {
Log.e(TAG, "Exception when retrieving package:" + mAppEntry.info.packageName, e);
}
diff --git a/src/com/android/settings/backup/BackupSettingsHelper.java b/src/com/android/settings/backup/BackupSettingsHelper.java
index b55172e..258f54d 100644
--- a/src/com/android/settings/backup/BackupSettingsHelper.java
+++ b/src/com/android/settings/backup/BackupSettingsHelper.java
@@ -24,7 +24,6 @@
import android.os.RemoteException;
import android.os.ServiceManager;
import android.os.UserHandle;
-import android.os.UserManager;
import android.text.TextUtils;
import android.util.Log;
@@ -51,24 +50,6 @@
}
/**
- * If there is only one profile, show whether the backup is on or off.
- * Otherwise, show nothing.
- */
- public String getSummary() {
- UserManager userManager = (UserManager) mContext.getSystemService(Context.USER_SERVICE);
- if (userManager.getUserProfiles().size() == 1) {
- try {
- int resId = mBackupManager.isBackupEnabled()
- ? R.string.backup_summary_state_on : R.string.backup_summary_state_off;
- return mContext.getText(resId).toString();
- } catch (RemoteException e) {
- Log.e(TAG, "Error getting isBackupEnabled", e);
- }
- }
- return null;
- }
-
- /**
* Returns an intent to launch backup settings from backup transport if the intent was provided
* by the transport. Otherwise returns the intent to launch the default backup settings screen.
*
diff --git a/src/com/android/settings/datausage/lib/AppPreferenceRepository.kt b/src/com/android/settings/datausage/lib/AppPreferenceRepository.kt
index a71bc8f..3bfb24a 100644
--- a/src/com/android/settings/datausage/lib/AppPreferenceRepository.kt
+++ b/src/com/android/settings/datausage/lib/AppPreferenceRepository.kt
@@ -19,10 +19,13 @@
import android.content.Context
import android.content.pm.PackageManager
import android.os.UserHandle
+import android.util.IconDrawableFactory
import androidx.preference.Preference
-import com.android.settingslib.Utils
-class AppPreferenceRepository(private val context: Context) {
+class AppPreferenceRepository(
+ private val context: Context,
+ private val iconDrawableFactory: IconDrawableFactory = IconDrawableFactory.newInstance(context),
+) {
private val packageManager = context.packageManager
fun loadAppPreferences(uids: List<Int>): List<Preference> = uids.flatMap { uid ->
@@ -38,7 +41,7 @@
private fun getPreference(packageName: String, userId: Int): Preference? = try {
val app = packageManager.getApplicationInfoAsUser(packageName, 0, userId)
Preference(context).apply {
- icon = Utils.getBadgedIcon(context, app)
+ icon = iconDrawableFactory.getBadgedIcon(app)
title = app.loadLabel(packageManager)
isSelectable = false
}
diff --git a/src/com/android/settings/inputmethod/NewKeyboardLayoutPickerController.java b/src/com/android/settings/inputmethod/NewKeyboardLayoutPickerController.java
index 879f134..9545276 100644
--- a/src/com/android/settings/inputmethod/NewKeyboardLayoutPickerController.java
+++ b/src/com/android/settings/inputmethod/NewKeyboardLayoutPickerController.java
@@ -83,6 +83,7 @@
mFinalSelectedLayout = mLayout;
mKeyboardLayouts = mIm.getKeyboardLayoutListForInputDevice(
mInputDeviceIdentifier, mUserId, mInputMethodInfo, mInputMethodSubtype);
+ NewKeyboardSettingsUtils.sortKeyboardLayoutsByLabel(mKeyboardLayouts);
parent.getActivity().setTitle(mTitle);
}
diff --git a/src/com/android/settings/inputmethod/NewKeyboardSettingsUtils.java b/src/com/android/settings/inputmethod/NewKeyboardSettingsUtils.java
index f3dc0a3..a927165 100644
--- a/src/com/android/settings/inputmethod/NewKeyboardSettingsUtils.java
+++ b/src/com/android/settings/inputmethod/NewKeyboardSettingsUtils.java
@@ -27,6 +27,8 @@
import android.view.inputmethod.InputMethodSubtype;
import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Comparator;
import java.util.List;
/**
@@ -123,4 +125,11 @@
InputDeviceIdentifier identifier, InputMethodInfo info, InputMethodSubtype subtype) {
return inputManager.getKeyboardLayoutForInputDevice(identifier, userId, info, subtype);
}
+
+ static void sortKeyboardLayoutsByLabel(KeyboardLayout[] keyboardLayouts) {
+ Arrays.sort(
+ keyboardLayouts,
+ Comparator.comparing(KeyboardLayout::getLabel)
+ );
+ }
}
diff --git a/src/com/android/settings/spa/SpaAppBridgeActivity.kt b/src/com/android/settings/spa/SpaAppBridgeActivity.kt
index 1a77442..a68d220 100644
--- a/src/com/android/settings/spa/SpaAppBridgeActivity.kt
+++ b/src/com/android/settings/spa/SpaAppBridgeActivity.kt
@@ -20,7 +20,6 @@
import android.content.Intent
import android.os.Bundle
import android.os.UserHandle
-import com.android.settings.spa.SpaBridgeActivity.Companion.getDestination
import com.android.settings.spa.SpaBridgeActivity.Companion.startSpaActivityFromBridge
/**
@@ -33,11 +32,7 @@
class SpaAppBridgeActivity : Activity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
- getDestination()?.let { destinationPrefix ->
- getDestinationForApp(destinationPrefix, intent)?.let { destination ->
- startSpaActivityFromBridge(destination)
- }
- }
+ startSpaActivityFromBridge { getDestinationForApp(it, intent) }
finish()
}
diff --git a/src/com/android/settings/spa/SpaBridgeActivity.kt b/src/com/android/settings/spa/SpaBridgeActivity.kt
index 0e239ae..61d8f51 100644
--- a/src/com/android/settings/spa/SpaBridgeActivity.kt
+++ b/src/com/android/settings/spa/SpaBridgeActivity.kt
@@ -18,12 +18,10 @@
import android.app.Activity
import android.content.Intent
-import android.content.pm.PackageManager
-import android.content.pm.PackageManager.ComponentInfoFlags
import android.os.Bundle
-import androidx.annotation.VisibleForTesting
import com.android.settings.activityembedding.ActivityEmbeddingUtils
import com.android.settings.activityembedding.EmbeddedDeepLinkUtils.tryStartMultiPaneDeepLink
+import com.android.settings.spa.SpaDestination.Companion.getDestination
import com.android.settingslib.spa.framework.util.SESSION_EXTERNAL
import com.android.settingslib.spa.framework.util.appendSpaParams
@@ -37,29 +35,23 @@
class SpaBridgeActivity : Activity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
- getDestination()?.let { destination ->
- startSpaActivityFromBridge(destination)
- }
+ startSpaActivityFromBridge()
finish()
}
companion object {
- fun Activity.startSpaActivityFromBridge(destination: String) {
+ fun Activity.startSpaActivityFromBridge(destinationFactory: (String) -> String? = { it }) {
+ val (destination, highlightMenuKey) = getDestination(destinationFactory) ?: return
val intent = Intent(this, SpaActivity::class.java)
- .appendSpaParams(destination = destination)
- .appendSpaParams(sessionName = SESSION_EXTERNAL)
+ .appendSpaParams(
+ destination = destination,
+ sessionName = SESSION_EXTERNAL,
+ )
if (!ActivityEmbeddingUtils.isEmbeddingActivityEnabled(this) ||
- !tryStartMultiPaneDeepLink(intent)) {
+ !tryStartMultiPaneDeepLink(intent, highlightMenuKey)
+ ) {
startActivity(intent)
}
}
-
- fun Activity.getDestination(): String? =
- packageManager.getActivityInfo(
- componentName, ComponentInfoFlags.of(PackageManager.GET_META_DATA.toLong())
- ).metaData.getString(META_DATA_KEY_DESTINATION)
-
- @VisibleForTesting
- const val META_DATA_KEY_DESTINATION = "com.android.settings.spa.DESTINATION"
}
}
diff --git a/src/com/android/settings/spa/SpaDestination.kt b/src/com/android/settings/spa/SpaDestination.kt
new file mode 100644
index 0000000..bdec1d8
--- /dev/null
+++ b/src/com/android/settings/spa/SpaDestination.kt
@@ -0,0 +1,49 @@
+/*
+ * Copyright (C) 2023 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.settings.spa
+
+import android.app.Activity
+import android.content.pm.PackageManager
+import androidx.annotation.VisibleForTesting
+import com.android.settings.SettingsActivity.META_DATA_KEY_HIGHLIGHT_MENU_KEY
+
+data class SpaDestination(
+ val destination: String,
+ val highlightMenuKey: String?,
+) {
+ companion object {
+ fun Activity.getDestination(
+ destinationFactory: (String) -> String? = { it },
+ ): SpaDestination? {
+ val metaData = packageManager.getActivityInfo(
+ componentName,
+ PackageManager.ComponentInfoFlags.of(PackageManager.GET_META_DATA.toLong())
+ ).metaData
+ val destination = metaData.getString(META_DATA_KEY_DESTINATION)
+ if (destination.isNullOrBlank()) return null
+ val finalDestination = destinationFactory(destination)
+ if (finalDestination.isNullOrBlank()) return null
+ return SpaDestination(
+ destination = finalDestination,
+ highlightMenuKey = metaData.getString(META_DATA_KEY_HIGHLIGHT_MENU_KEY),
+ )
+ }
+
+ @VisibleForTesting
+ const val META_DATA_KEY_DESTINATION = "com.android.settings.spa.DESTINATION"
+ }
+}
diff --git a/tests/robotests/src/com/android/settings/backup/BackupSettingsHelperTest.java b/tests/robotests/src/com/android/settings/backup/BackupSettingsHelperTest.java
index b6ef32c..17f17c1 100644
--- a/tests/robotests/src/com/android/settings/backup/BackupSettingsHelperTest.java
+++ b/tests/robotests/src/com/android/settings/backup/BackupSettingsHelperTest.java
@@ -34,7 +34,6 @@
import android.content.res.Resources;
import android.os.IBinder;
import android.os.RemoteException;
-import android.os.UserHandle;
import com.android.settings.R;
@@ -48,8 +47,6 @@
import org.robolectric.annotation.Config;
import org.robolectric.annotation.Implementation;
import org.robolectric.annotation.Implements;
-import org.robolectric.shadow.api.Shadow;
-import org.robolectric.shadows.ShadowUserManager;
@RunWith(RobolectricTestRunner.class)
@Config(shadows = BackupSettingsHelperTest.ShadowBackupManagerStub.class)
@@ -72,46 +69,12 @@
@Mock
private static IBackupManager mBackupManager;
- private ShadowUserManager mUserManager;
-
@Before
public void setUp() throws Exception {
MockitoAnnotations.initMocks(this);
mContext = spy(RuntimeEnvironment.application.getApplicationContext());
when(mBackupManager.getCurrentTransport()).thenReturn("test_transport");
mBackupSettingsHelper = new BackupSettingsHelper(mContext);
- mUserManager = Shadow.extract(mContext.getSystemService(Context.USER_SERVICE));
- }
-
- @Test
- public void testGetSummary_backupEnabledOnlyOneProfile_showsOn() throws Exception {
- mUserManager.addUserProfile(new UserHandle(0));
- when(mBackupManager.isBackupEnabled()).thenReturn(true);
-
- String backupSummary = mBackupSettingsHelper.getSummary();
-
- assertThat(backupSummary).isEqualTo(mContext.getString(R.string.backup_summary_state_on));
- }
-
- @Test
- public void testGetSummary_backupDisabledOnlyOneProfile_showsOff() throws Exception {
- mUserManager.addUserProfile(new UserHandle(0));
- when(mBackupManager.isBackupEnabled()).thenReturn(false);
-
- String backupSummary = mBackupSettingsHelper.getSummary();
-
- assertThat(backupSummary).isEqualTo(mContext.getString(R.string.backup_summary_state_off));
- }
-
- @Test
- public void testGetSummary_TwoProfiles_returnsNull() throws Exception {
- mUserManager.addUserProfile(new UserHandle(0));
- mUserManager.addUserProfile(new UserHandle(10));
- when(mBackupManager.isBackupEnabled()).thenReturn(true);
-
- String backupSummary = mBackupSettingsHelper.getSummary();
-
- assertThat(backupSummary).isNull();
}
@Test
diff --git a/tests/robotests/src/com/android/settings/development/SelectDebugAppPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/development/SelectDebugAppPreferenceControllerTest.java
index a998ddc..94fce17 100644
--- a/tests/robotests/src/com/android/settings/development/SelectDebugAppPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/development/SelectDebugAppPreferenceControllerTest.java
@@ -36,6 +36,7 @@
import androidx.preference.PreferenceScreen;
import org.junit.Before;
+import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
@@ -71,6 +72,7 @@
mController.displayPreference(mPreferenceScreen);
}
+ @Ignore("b/314919354")
@Test
public void handlePreferenceTreeClick_preferenceClicked_launchActivity() {
final Intent activityStartIntent = new Intent(mContext, AppPicker.class);
diff --git a/tests/robotests/src/com/android/settings/shortcut/CreateShortcutPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/shortcut/CreateShortcutPreferenceControllerTest.java
index 3705ba8..9727dd1 100644
--- a/tests/robotests/src/com/android/settings/shortcut/CreateShortcutPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/shortcut/CreateShortcutPreferenceControllerTest.java
@@ -116,6 +116,7 @@
.isEqualTo(SHORTCUT_ID_PREFIX + intent.getComponent().flattenToShortString());
}
+ @Ignore("b/314924127")
@Test
public void queryShortcuts_shouldOnlyIncludeSystemApp() {
final ResolveInfo ri1 = new ResolveInfo();
@@ -139,6 +140,7 @@
assertThat(info.get(0).activityInfo).isEqualTo(ri2.activityInfo);
}
+ @Ignore("b/314924127")
@Test
public void queryShortcuts_shouldSortBasedOnPriority() {
final ResolveInfo ri1 = new ResolveInfo();
diff --git a/tests/robotests/src/com/android/settings/slices/SettingsSliceProviderTest.java b/tests/robotests/src/com/android/settings/slices/SettingsSliceProviderTest.java
index 57f4e17..84c8586 100644
--- a/tests/robotests/src/com/android/settings/slices/SettingsSliceProviderTest.java
+++ b/tests/robotests/src/com/android/settings/slices/SettingsSliceProviderTest.java
@@ -64,6 +64,7 @@
import org.junit.After;
import org.junit.Before;
+import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
@@ -200,6 +201,7 @@
.registerIntentToUri(eq(FakeToggleController.INTENT_FILTER), eq(INTENT_SLICE_URI));
}
+ @Ignore("b/314925256")
@Test
public void loadSlice_registersBackgroundListener() {
SliceTestUtils.insertSliceToDb(mContext, KEY);
diff --git a/tests/robotests/src/com/android/settings/support/SupportDashboardActivityTest.java b/tests/robotests/src/com/android/settings/support/SupportDashboardActivityTest.java
index f510994..16df9ba 100644
--- a/tests/robotests/src/com/android/settings/support/SupportDashboardActivityTest.java
+++ b/tests/robotests/src/com/android/settings/support/SupportDashboardActivityTest.java
@@ -29,6 +29,7 @@
import com.android.settingslib.search.SearchIndexableRaw;
import org.junit.Before;
+import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.robolectric.RobolectricTestRunner;
@@ -64,6 +65,7 @@
assertThat(value.intentAction).isEqualTo(ACTION_SUPPORT_SETTINGS);
}
+ @Ignore("b/314927625")
@Test
public void shouldHandleIntentAction() {
PackageManager packageManager = mContext.getPackageManager();
diff --git a/tests/robotests/src/com/android/settings/survey/SurveyMixinTest.java b/tests/robotests/src/com/android/settings/survey/SurveyMixinTest.java
index 8f43268..635343e 100644
--- a/tests/robotests/src/com/android/settings/survey/SurveyMixinTest.java
+++ b/tests/robotests/src/com/android/settings/survey/SurveyMixinTest.java
@@ -13,6 +13,7 @@
import com.android.settings.testutils.FakeFeatureFactory;
import org.junit.Before;
+import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
@@ -39,6 +40,7 @@
mProvider = FakeFeatureFactory.setupForTest().getSurveyFeatureProvider(mContext);
}
+ @Ignore("b/314929422")
@Test
public void onResume_noActionIfActivityDoesNotExist() {
// Pretend we are an activity that is starting up
diff --git a/tests/robotests/src/com/android/settings/wifi/WifiDialogActivityTest.java b/tests/robotests/src/com/android/settings/wifi/WifiDialogActivityTest.java
index 5a39368..82aff4e 100644
--- a/tests/robotests/src/com/android/settings/wifi/WifiDialogActivityTest.java
+++ b/tests/robotests/src/com/android/settings/wifi/WifiDialogActivityTest.java
@@ -50,6 +50,7 @@
import com.google.android.setupcompat.util.WizardManagerHelper;
import org.junit.Before;
+import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
@@ -89,6 +90,7 @@
WifiDialogActivity mActivity;
+ @Ignore("b/314867581")
@Before
public void setUp() {
MockitoAnnotations.initMocks(this);
diff --git a/tests/robotests/src/com/android/settings/wifi/WifiNoInternetDialogTest.java b/tests/robotests/src/com/android/settings/wifi/WifiNoInternetDialogTest.java
index 8e52210..64bf525 100644
--- a/tests/robotests/src/com/android/settings/wifi/WifiNoInternetDialogTest.java
+++ b/tests/robotests/src/com/android/settings/wifi/WifiNoInternetDialogTest.java
@@ -45,6 +45,7 @@
import com.android.settings.R;
import org.junit.Before;
+import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.ArgumentCaptor;
@@ -55,6 +56,7 @@
import org.robolectric.RobolectricTestRunner;
import org.robolectric.RuntimeEnvironment;
+@Ignore("b/314867581")
@RunWith(RobolectricTestRunner.class)
public class WifiNoInternetDialogTest {
diff --git a/tests/robotests/src/com/android/settings/wifi/dpp/WifiDppConfiguratorActivityTest.java b/tests/robotests/src/com/android/settings/wifi/dpp/WifiDppConfiguratorActivityTest.java
index d8605de..73e4811 100644
--- a/tests/robotests/src/com/android/settings/wifi/dpp/WifiDppConfiguratorActivityTest.java
+++ b/tests/robotests/src/com/android/settings/wifi/dpp/WifiDppConfiguratorActivityTest.java
@@ -29,6 +29,7 @@
import androidx.test.core.app.ApplicationProvider;
import org.junit.Before;
+import org.junit.Ignore;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -39,6 +40,7 @@
import org.robolectric.Robolectric;
import org.robolectric.RobolectricTestRunner;
+@Ignore("b/314867581")
@RunWith(RobolectricTestRunner.class)
public class WifiDppConfiguratorActivityTest {
diff --git a/tests/robotests/src/com/android/settings/wifi/dpp/WifiDppEnrolleeActivityTest.java b/tests/robotests/src/com/android/settings/wifi/dpp/WifiDppEnrolleeActivityTest.java
index 67d4678..c099060 100644
--- a/tests/robotests/src/com/android/settings/wifi/dpp/WifiDppEnrolleeActivityTest.java
+++ b/tests/robotests/src/com/android/settings/wifi/dpp/WifiDppEnrolleeActivityTest.java
@@ -28,6 +28,7 @@
import com.android.settingslib.wifi.WifiRestrictionsCache;
import org.junit.Before;
+import org.junit.Ignore;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -37,6 +38,7 @@
import org.robolectric.Robolectric;
import org.robolectric.RobolectricTestRunner;
+@Ignore("b/314867581")
@RunWith(RobolectricTestRunner.class)
public class WifiDppEnrolleeActivityTest {
diff --git a/tests/robotests/src/com/android/settings/wifi/savedaccesspoints2/SavedAccessPointsWifiSettings2Test.java b/tests/robotests/src/com/android/settings/wifi/savedaccesspoints2/SavedAccessPointsWifiSettings2Test.java
index 3e6c64b..fc0b946 100644
--- a/tests/robotests/src/com/android/settings/wifi/savedaccesspoints2/SavedAccessPointsWifiSettings2Test.java
+++ b/tests/robotests/src/com/android/settings/wifi/savedaccesspoints2/SavedAccessPointsWifiSettings2Test.java
@@ -47,6 +47,7 @@
import org.robolectric.RuntimeEnvironment;
import org.robolectric.annotation.Config;
+@Ignore("b/314867581")
@RunWith(RobolectricTestRunner.class)
@Config(shadows = ShadowInteractionJankMonitor.class)
public class SavedAccessPointsWifiSettings2Test {
diff --git a/tests/spa_unit/src/com/android/settings/datausage/lib/AppPreferenceRepositoryTest.kt b/tests/spa_unit/src/com/android/settings/datausage/lib/AppPreferenceRepositoryTest.kt
index c7371ee..05fce8f 100644
--- a/tests/spa_unit/src/com/android/settings/datausage/lib/AppPreferenceRepositoryTest.kt
+++ b/tests/spa_unit/src/com/android/settings/datausage/lib/AppPreferenceRepositoryTest.kt
@@ -21,6 +21,7 @@
import android.content.pm.PackageManager
import android.graphics.drawable.Drawable
import android.os.UserHandle
+import android.util.IconDrawableFactory
import androidx.test.core.app.ApplicationProvider
import androidx.test.ext.junit.runners.AndroidJUnit4
import com.google.common.truth.Truth.assertThat
@@ -43,7 +44,9 @@
on { packageManager } doReturn packageManager
}
- private val repository = AppPreferenceRepository(context)
+ private val mockIconDrawableFactory = mock<IconDrawableFactory>()
+
+ private val repository = AppPreferenceRepository(context, mockIconDrawableFactory)
@Test
fun loadAppPreferences_packageNotFound_returnEmpty() {
@@ -61,9 +64,11 @@
@Test
fun loadAppPreferences_packageFound_returnPreference() {
val app = mock<ApplicationInfo> {
- on { loadUnbadgedIcon(any()) } doReturn UNBADGED_ICON
on { loadLabel(any()) } doReturn LABEL
}
+ mockIconDrawableFactory.stub {
+ on { getBadgedIcon(app) } doReturn UNBADGED_ICON
+ }
packageManager.stub {
on {
getApplicationInfoAsUser(PACKAGE_NAME, 0, UserHandle.getUserId(UID))
diff --git a/tests/spa_unit/src/com/android/settings/spa/SpaBridgeActivityTest.kt b/tests/spa_unit/src/com/android/settings/spa/SpaBridgeActivityTest.kt
deleted file mode 100644
index 48fa823..0000000
--- a/tests/spa_unit/src/com/android/settings/spa/SpaBridgeActivityTest.kt
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
- * Copyright (C) 2023 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.settings.spa
-
-import android.app.Activity
-import android.content.ComponentName
-import android.content.pm.ActivityInfo
-import android.content.pm.PackageManager
-import android.content.pm.PackageManager.ComponentInfoFlags
-import androidx.core.os.bundleOf
-import androidx.test.ext.junit.runners.AndroidJUnit4
-import com.android.settings.spa.SpaBridgeActivity.Companion.META_DATA_KEY_DESTINATION
-import com.android.settings.spa.SpaBridgeActivity.Companion.getDestination
-import com.google.common.truth.Truth.assertThat
-import org.junit.Test
-import org.junit.runner.RunWith
-import org.mockito.kotlin.any
-import org.mockito.kotlin.doReturn
-import org.mockito.kotlin.eq
-import org.mockito.kotlin.mock
-
-@RunWith(AndroidJUnit4::class)
-class SpaBridgeActivityTest {
- private val mockPackageManager = mock<PackageManager> {
- on { getActivityInfo(eq(COMPONENT_NAME), any<ComponentInfoFlags>()) } doReturn
- ActivityInfo().apply {
- metaData = bundleOf(META_DATA_KEY_DESTINATION to DESTINATION)
- }
- }
-
- private val activity = mock<Activity> {
- on { componentName } doReturn COMPONENT_NAME
- on { packageManager } doReturn mockPackageManager
- }
-
- @Test
- fun getDestination() {
- val destination = activity.getDestination()
-
- assertThat(destination).isEqualTo(DESTINATION)
- }
-
- private companion object {
- const val PACKAGE_NAME = "package.name"
- const val ACTIVITY_NAME = "ActivityName"
- val COMPONENT_NAME = ComponentName(PACKAGE_NAME, ACTIVITY_NAME)
- const val DESTINATION = "Destination"
- }
-}
diff --git a/tests/spa_unit/src/com/android/settings/spa/SpaDestinationTest.kt b/tests/spa_unit/src/com/android/settings/spa/SpaDestinationTest.kt
new file mode 100644
index 0000000..0b9eb22
--- /dev/null
+++ b/tests/spa_unit/src/com/android/settings/spa/SpaDestinationTest.kt
@@ -0,0 +1,97 @@
+/*
+ * Copyright (C) 2023 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.settings.spa
+
+import android.app.Activity
+import android.content.ComponentName
+import android.content.pm.ActivityInfo
+import android.content.pm.PackageManager
+import android.os.Bundle
+import androidx.core.os.bundleOf
+import androidx.test.ext.junit.runners.AndroidJUnit4
+import com.android.settings.SettingsActivity.META_DATA_KEY_HIGHLIGHT_MENU_KEY
+import com.android.settings.spa.SpaDestination.Companion.META_DATA_KEY_DESTINATION
+import com.android.settings.spa.SpaDestination.Companion.getDestination
+import com.google.common.truth.Truth.assertThat
+import org.junit.Test
+import org.junit.runner.RunWith
+import org.mockito.kotlin.any
+import org.mockito.kotlin.doAnswer
+import org.mockito.kotlin.doReturn
+import org.mockito.kotlin.eq
+import org.mockito.kotlin.mock
+
+@RunWith(AndroidJUnit4::class)
+class SpaDestinationTest {
+ private var activityMetadata: Bundle = bundleOf()
+
+ private val mockPackageManager = mock<PackageManager> {
+ on {
+ getActivityInfo(
+ eq(COMPONENT_NAME),
+ any<PackageManager.ComponentInfoFlags>()
+ )
+ } doAnswer {
+ ActivityInfo().apply { metaData = activityMetadata }
+ }
+ }
+
+ private val activity = mock<Activity> {
+ on { componentName } doReturn COMPONENT_NAME
+ on { packageManager } doReturn mockPackageManager
+ }
+
+ @Test
+ fun getDestination_noDestination_returnNull() {
+ activityMetadata = bundleOf()
+
+ val destination = activity.getDestination()
+
+ assertThat(destination).isNull()
+ }
+
+ @Test
+ fun getDestination_withoutHighlightMenuKey() {
+ activityMetadata = bundleOf(META_DATA_KEY_DESTINATION to DESTINATION)
+
+ val (destination, highlightMenuKey) = activity.getDestination()!!
+
+ assertThat(destination).isEqualTo(DESTINATION)
+ assertThat(highlightMenuKey).isNull()
+ }
+
+ @Test
+ fun getDestination_withHighlightMenuKey() {
+ activityMetadata = bundleOf(
+ META_DATA_KEY_DESTINATION to DESTINATION,
+ META_DATA_KEY_HIGHLIGHT_MENU_KEY to HIGHLIGHT_MENU_KEY,
+ )
+
+ val (destination, highlightMenuKey) = activity.getDestination()!!
+
+ assertThat(destination).isEqualTo(DESTINATION)
+ assertThat(highlightMenuKey).isEqualTo(HIGHLIGHT_MENU_KEY)
+ }
+
+ private companion object {
+ const val PACKAGE_NAME = "package.name"
+ const val ACTIVITY_NAME = "ActivityName"
+ val COMPONENT_NAME = ComponentName(PACKAGE_NAME, ACTIVITY_NAME)
+ const val DESTINATION = "Destination"
+ const val HIGHLIGHT_MENU_KEY = "apps"
+ }
+}