From 68529256769dec7c1c9184ca75070f7e23a45d7c Mon Sep 17 00:00:00 2001 From: Haijie Hong Date: Thu, 31 Oct 2024 16:16:45 +0800 Subject: [PATCH] Allow launch activity from background for PendingIntent BUG: 343317785 Test: local test Flag: com.android.settings.flags.enable_bluetooth_device_details_polish Change-Id: I22c430c0d3879f034f3a491471781aa9b49a02f2 --- .../ui/view/DeviceDetailsFragmentFormatter.kt | 46 +++++++++---------- 1 file changed, 21 insertions(+), 25 deletions(-) diff --git a/src/com/android/settings/bluetooth/ui/view/DeviceDetailsFragmentFormatter.kt b/src/com/android/settings/bluetooth/ui/view/DeviceDetailsFragmentFormatter.kt index 13c3b501025..1c8aafdbce1 100644 --- a/src/com/android/settings/bluetooth/ui/view/DeviceDetailsFragmentFormatter.kt +++ b/src/com/android/settings/bluetooth/ui/view/DeviceDetailsFragmentFormatter.kt @@ -16,6 +16,7 @@ package com.android.settings.bluetooth.ui.view +import android.app.ActivityOptions import android.bluetooth.BluetoothAdapter import android.content.Context import android.content.Intent @@ -206,25 +207,21 @@ class DeviceDetailsFragmentFormatterImpl( .collectAsStateWithLifecycle(initialValue = false) val settings = contents - AnimatedVisibility( - visible = settings.isNotEmpty(), - enter = fadeIn(), - exit = fadeOut(), - ) { + AnimatedVisibility(visible = settings.isNotEmpty(), enter = fadeIn(), exit = fadeOut()) { Box { Box( modifier = - Modifier.matchParentSize() - .padding(16.dp, 0.dp, 8.dp, 0.dp) - .background( - color = - if (highlighted) { - MaterialTheme.colorScheme.primaryContainer - } else { - Color.Transparent - }, - shape = RoundedCornerShape(28.dp), - ), + Modifier.matchParentSize() + .padding(16.dp, 0.dp, 8.dp, 0.dp) + .background( + color = + if (highlighted) { + MaterialTheme.colorScheme.primaryContainer + } else { + Color.Transparent + }, + shape = RoundedCornerShape(28.dp), + ) ) {} buildPreferences(settings) } @@ -257,17 +254,11 @@ class DeviceDetailsFragmentFormatterImpl( } } else -> { - if ( - !settings.all { - it is DeviceSettingPreferenceModel.MultiTogglePreference - } - ) { + if (!settings.all { it is DeviceSettingPreferenceModel.MultiTogglePreference }) { return } buildMultiTogglePreference( - settings.filterIsInstance< - DeviceSettingPreferenceModel.MultiTogglePreference - >() + settings.filterIsInstance() ) } } @@ -375,7 +366,12 @@ class DeviceDetailsFragmentFormatterImpl( context.startActivity(action.intent) } is DeviceSettingActionModel.PendingIntentAction -> { - action.pendingIntent.send() + val options = + ActivityOptions.makeBasic() + .setPendingIntentBackgroundActivityStartMode( + ActivityOptions.MODE_BACKGROUND_ACTIVITY_START_ALLOW_ALWAYS + ) + action.pendingIntent.send(options.toBundle()) } } }