Loading src/com/android/settings/spa/app/appinfo/AppArchiveButton.kt +4 −3 Original line number Diff line number Diff line Loading @@ -54,6 +54,7 @@ class AppArchiveButton( private val packageName = packageInfoPresenter.packageName private val userHandle = UserHandle.of(packageInfoPresenter.userId) private var broadcastReceiverIsCreated = false private lateinit var appLabel: CharSequence @Composable fun getActionButton(app: ApplicationInfo): ActionButton { Loading @@ -61,11 +62,12 @@ class AppArchiveButton( val intentFilter = IntentFilter(INTENT_ACTION) DisposableBroadcastReceiverAsUser(intentFilter, userHandle) { intent -> if (app.packageName == intent.getStringExtra(PackageInstaller.EXTRA_PACKAGE_NAME)) { onReceive(intent, app) onReceive(intent) } } broadcastReceiverIsCreated = true } appLabel = userPackageManager.getApplicationLabel(app) return ActionButton( text = context.getString(R.string.archive), imageVector = Icons.Outlined.CloudUpload, Loading Loading @@ -113,10 +115,9 @@ class AppArchiveButton( } } private fun onReceive(intent: Intent, app: ApplicationInfo) { private fun onReceive(intent: Intent) { when (val status = intent.getIntExtra(PackageInstaller.EXTRA_STATUS, Int.MIN_VALUE)) { PackageInstaller.STATUS_SUCCESS -> { val appLabel = userPackageManager.getApplicationLabel(app) Toast.makeText( context, context.getString(R.string.archiving_succeeded, appLabel), Loading tests/spa_unit/src/com/android/settings/spa/app/appinfo/AppArchiveButtonTest.kt +4 −1 Original line number Diff line number Diff line Loading @@ -63,8 +63,10 @@ class AppArchiveButtonTest { whenever(packageInfoPresenter.context).thenReturn(context) whenever(packageInfoPresenter.userPackageManager).thenReturn(userPackageManager) whenever(userPackageManager.packageInstaller).thenReturn(packageInstaller) whenever(userPackageManager.getApplicationLabel(any())).thenReturn(APP_LABEL) whenever(packageInfoPresenter.packageName).thenReturn(PACKAGE_NAME) appArchiveButton = AppArchiveButton(packageInfoPresenter, isHibernationSwitchEnabledStateFlow) appArchiveButton = AppArchiveButton(packageInfoPresenter, isHibernationSwitchEnabledStateFlow) } @Test Loading Loading @@ -150,5 +152,6 @@ class AppArchiveButtonTest { private companion object { const val PACKAGE_NAME = "package.name" const val APP_LABEL = "App label" } } tests/spa_unit/src/com/android/settings/spa/app/appinfo/AppButtonsTest.kt +7 −2 Original line number Diff line number Diff line Loading @@ -45,6 +45,7 @@ import org.junit.runner.RunWith import org.mockito.Mock import org.mockito.MockitoSession import org.mockito.Spy import org.mockito.kotlin.any import org.mockito.quality.Strictness import org.mockito.Mockito.`when` as whenever Loading Loading @@ -80,6 +81,7 @@ class AppButtonsTest { whenever(packageInfoPresenter.context).thenReturn(context) whenever(packageInfoPresenter.packageName).thenReturn(PACKAGE_NAME) whenever(packageInfoPresenter.userPackageManager).thenReturn(packageManager) whenever(packageManager.getApplicationLabel(any())).thenReturn(APP_LABEL) whenever(packageManager.packageInstaller).thenReturn(packageInstaller) whenever(packageManager.getPackageInfo(PACKAGE_NAME, 0)).thenReturn(PACKAGE_INFO) whenever(AppUtils.isMainlineModule(packageManager, PACKAGE_NAME)).thenReturn(false) Loading Loading @@ -113,7 +115,8 @@ class AppButtonsTest { featureFlags.setFlag(Flags.FLAG_ARCHIVING, false) setContent() composeTestRule.onNodeWithText(context.getString(R.string.launch_instant_app)).assertIsDisplayed() composeTestRule.onNodeWithText(context.getString(R.string.launch_instant_app)) .assertIsDisplayed() } @Test Loading @@ -122,7 +125,8 @@ class AppButtonsTest { featureFlags.setFlag(Flags.FLAG_ARCHIVING, true) setContent() composeTestRule.onNodeWithText(context.getString(R.string.launch_instant_app)).assertIsNotDisplayed() composeTestRule.onNodeWithText(context.getString(R.string.launch_instant_app)) .assertIsNotDisplayed() } @Test Loading Loading @@ -184,6 +188,7 @@ class AppButtonsTest { private companion object { const val PACKAGE_NAME = "package.name" const val APP_LABEL = "App label" val PACKAGE_INFO = PackageInfo().apply { applicationInfo = ApplicationInfo().apply { packageName = PACKAGE_NAME Loading Loading
src/com/android/settings/spa/app/appinfo/AppArchiveButton.kt +4 −3 Original line number Diff line number Diff line Loading @@ -54,6 +54,7 @@ class AppArchiveButton( private val packageName = packageInfoPresenter.packageName private val userHandle = UserHandle.of(packageInfoPresenter.userId) private var broadcastReceiverIsCreated = false private lateinit var appLabel: CharSequence @Composable fun getActionButton(app: ApplicationInfo): ActionButton { Loading @@ -61,11 +62,12 @@ class AppArchiveButton( val intentFilter = IntentFilter(INTENT_ACTION) DisposableBroadcastReceiverAsUser(intentFilter, userHandle) { intent -> if (app.packageName == intent.getStringExtra(PackageInstaller.EXTRA_PACKAGE_NAME)) { onReceive(intent, app) onReceive(intent) } } broadcastReceiverIsCreated = true } appLabel = userPackageManager.getApplicationLabel(app) return ActionButton( text = context.getString(R.string.archive), imageVector = Icons.Outlined.CloudUpload, Loading Loading @@ -113,10 +115,9 @@ class AppArchiveButton( } } private fun onReceive(intent: Intent, app: ApplicationInfo) { private fun onReceive(intent: Intent) { when (val status = intent.getIntExtra(PackageInstaller.EXTRA_STATUS, Int.MIN_VALUE)) { PackageInstaller.STATUS_SUCCESS -> { val appLabel = userPackageManager.getApplicationLabel(app) Toast.makeText( context, context.getString(R.string.archiving_succeeded, appLabel), Loading
tests/spa_unit/src/com/android/settings/spa/app/appinfo/AppArchiveButtonTest.kt +4 −1 Original line number Diff line number Diff line Loading @@ -63,8 +63,10 @@ class AppArchiveButtonTest { whenever(packageInfoPresenter.context).thenReturn(context) whenever(packageInfoPresenter.userPackageManager).thenReturn(userPackageManager) whenever(userPackageManager.packageInstaller).thenReturn(packageInstaller) whenever(userPackageManager.getApplicationLabel(any())).thenReturn(APP_LABEL) whenever(packageInfoPresenter.packageName).thenReturn(PACKAGE_NAME) appArchiveButton = AppArchiveButton(packageInfoPresenter, isHibernationSwitchEnabledStateFlow) appArchiveButton = AppArchiveButton(packageInfoPresenter, isHibernationSwitchEnabledStateFlow) } @Test Loading Loading @@ -150,5 +152,6 @@ class AppArchiveButtonTest { private companion object { const val PACKAGE_NAME = "package.name" const val APP_LABEL = "App label" } }
tests/spa_unit/src/com/android/settings/spa/app/appinfo/AppButtonsTest.kt +7 −2 Original line number Diff line number Diff line Loading @@ -45,6 +45,7 @@ import org.junit.runner.RunWith import org.mockito.Mock import org.mockito.MockitoSession import org.mockito.Spy import org.mockito.kotlin.any import org.mockito.quality.Strictness import org.mockito.Mockito.`when` as whenever Loading Loading @@ -80,6 +81,7 @@ class AppButtonsTest { whenever(packageInfoPresenter.context).thenReturn(context) whenever(packageInfoPresenter.packageName).thenReturn(PACKAGE_NAME) whenever(packageInfoPresenter.userPackageManager).thenReturn(packageManager) whenever(packageManager.getApplicationLabel(any())).thenReturn(APP_LABEL) whenever(packageManager.packageInstaller).thenReturn(packageInstaller) whenever(packageManager.getPackageInfo(PACKAGE_NAME, 0)).thenReturn(PACKAGE_INFO) whenever(AppUtils.isMainlineModule(packageManager, PACKAGE_NAME)).thenReturn(false) Loading Loading @@ -113,7 +115,8 @@ class AppButtonsTest { featureFlags.setFlag(Flags.FLAG_ARCHIVING, false) setContent() composeTestRule.onNodeWithText(context.getString(R.string.launch_instant_app)).assertIsDisplayed() composeTestRule.onNodeWithText(context.getString(R.string.launch_instant_app)) .assertIsDisplayed() } @Test Loading @@ -122,7 +125,8 @@ class AppButtonsTest { featureFlags.setFlag(Flags.FLAG_ARCHIVING, true) setContent() composeTestRule.onNodeWithText(context.getString(R.string.launch_instant_app)).assertIsNotDisplayed() composeTestRule.onNodeWithText(context.getString(R.string.launch_instant_app)) .assertIsNotDisplayed() } @Test Loading Loading @@ -184,6 +188,7 @@ class AppButtonsTest { private companion object { const val PACKAGE_NAME = "package.name" const val APP_LABEL = "App label" val PACKAGE_INFO = PackageInfo().apply { applicationInfo = ApplicationInfo().apply { packageName = PACKAGE_NAME Loading