summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--packages/SystemUI/src/com/android/systemui/biometrics/data/repository/DisplayStateRepository.kt15
-rw-r--r--packages/SystemUI/src/com/android/systemui/biometrics/ui/binder/PromptFingerprintIconViewBinder.kt7
-rw-r--r--packages/SystemUI/src/com/android/systemui/biometrics/ui/viewmodel/PromptFingerprintIconViewModel.kt23
-rw-r--r--packages/SystemUI/tests/src/com/android/systemui/biometrics/data/repository/DisplayStateRepositoryTest.kt5
-rw-r--r--packages/SystemUI/tests/utils/src/com/android/systemui/biometrics/data/repository/FakeDisplayStateRepository.kt2
-rw-r--r--services/core/java/com/android/server/pm/ShortcutPackage.java2
-rw-r--r--services/core/java/com/android/server/wm/ActivityRecord.java12
-rw-r--r--services/core/java/com/android/server/wm/RecentTasks.java12
-rw-r--r--services/core/java/com/android/server/wm/Task.java3
-rw-r--r--services/tests/wmtests/src/com/android/server/wm/ActivityStarterTests.java9
-rw-r--r--services/tests/wmtests/src/com/android/server/wm/RecentTasksTest.java16
11 files changed, 53 insertions, 53 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/biometrics/data/repository/DisplayStateRepository.kt b/packages/SystemUI/src/com/android/systemui/biometrics/data/repository/DisplayStateRepository.kt
index 7a9efcf78999..c4c52e8b358e 100644
--- a/packages/SystemUI/src/com/android/systemui/biometrics/data/repository/DisplayStateRepository.kt
+++ b/packages/SystemUI/src/com/android/systemui/biometrics/data/repository/DisplayStateRepository.kt
@@ -41,6 +41,12 @@ import kotlinx.coroutines.flow.stateIn
/** Repository for the current state of the display */
interface DisplayStateRepository {
+ /**
+ * Whether or not the direction rotation is applied to get to an application's requested
+ * orientation is reversed.
+ */
+ val isReverseDefaultRotation: Boolean
+
/** Provides the current rear display state. */
val isInRearDisplayMode: StateFlow<Boolean>
@@ -59,6 +65,9 @@ constructor(
@Main handler: Handler,
@Main mainExecutor: Executor
) : DisplayStateRepository {
+ override val isReverseDefaultRotation =
+ context.resources.getBoolean(com.android.internal.R.bool.config_reverseDefaultRotation)
+
override val isInRearDisplayMode: StateFlow<Boolean> =
conflatedCallbackFlow {
val sendRearDisplayStateUpdate = { state: Boolean ->
@@ -94,7 +103,11 @@ constructor(
private fun getDisplayRotation(): DisplayRotation {
val cachedDisplayInfo = DisplayInfo()
context.display?.getDisplayInfo(cachedDisplayInfo)
- return cachedDisplayInfo.rotation.toDisplayRotation()
+ var rotation = cachedDisplayInfo.rotation
+ if (isReverseDefaultRotation) {
+ rotation = (rotation + 1) % 4
+ }
+ return rotation.toDisplayRotation()
}
override val currentRotation: StateFlow<DisplayRotation> =
diff --git a/packages/SystemUI/src/com/android/systemui/biometrics/ui/binder/PromptFingerprintIconViewBinder.kt b/packages/SystemUI/src/com/android/systemui/biometrics/ui/binder/PromptFingerprintIconViewBinder.kt
index 188c82b52374..d28f1dc78c13 100644
--- a/packages/SystemUI/src/com/android/systemui/biometrics/ui/binder/PromptFingerprintIconViewBinder.kt
+++ b/packages/SystemUI/src/com/android/systemui/biometrics/ui/binder/PromptFingerprintIconViewBinder.kt
@@ -17,7 +17,6 @@
package com.android.systemui.biometrics.ui.binder
-import android.view.DisplayInfo
import androidx.lifecycle.Lifecycle
import androidx.lifecycle.repeatOnLifecycle
import com.airbnb.lottie.LottieAnimationView
@@ -33,14 +32,14 @@ object PromptFingerprintIconViewBinder {
fun bind(view: LottieAnimationView, viewModel: PromptFingerprintIconViewModel) {
view.repeatWhenAttached {
repeatOnLifecycle(Lifecycle.State.STARTED) {
- val displayInfo = DisplayInfo()
- view.context.display?.getDisplayInfo(displayInfo)
- viewModel.setRotation(displayInfo.rotation)
viewModel.onConfigurationChanged(view.context.resources.configuration)
launch {
viewModel.iconAsset.collect { iconAsset ->
if (iconAsset != -1) {
view.setAnimation(iconAsset)
+ // TODO: must replace call below once non-sfps asset logic and
+ // shouldAnimateIconView logic is migrated to this ViewModel.
+ view.playAnimation()
}
}
}
diff --git a/packages/SystemUI/src/com/android/systemui/biometrics/ui/viewmodel/PromptFingerprintIconViewModel.kt b/packages/SystemUI/src/com/android/systemui/biometrics/ui/viewmodel/PromptFingerprintIconViewModel.kt
index b406ea41eff0..161a1274f83f 100644
--- a/packages/SystemUI/src/com/android/systemui/biometrics/ui/viewmodel/PromptFingerprintIconViewModel.kt
+++ b/packages/SystemUI/src/com/android/systemui/biometrics/ui/viewmodel/PromptFingerprintIconViewModel.kt
@@ -19,10 +19,10 @@ package com.android.systemui.biometrics.ui.viewmodel
import android.annotation.RawRes
import android.content.res.Configuration
-import android.view.Surface
import com.android.systemui.R
import com.android.systemui.biometrics.domain.interactor.DisplayStateInteractor
import com.android.systemui.biometrics.domain.interactor.PromptSelectorInteractor
+import com.android.systemui.biometrics.shared.model.DisplayRotation
import com.android.systemui.biometrics.shared.model.FingerprintSensorType
import javax.inject.Inject
import kotlinx.coroutines.flow.Flow
@@ -35,19 +35,21 @@ constructor(
private val displayStateInteractor: DisplayStateInteractor,
promptSelectorInteractor: PromptSelectorInteractor,
) {
- /** Current device rotation. */
- private var rotation: Int = Surface.ROTATION_0
-
/** Current BiometricPromptLayout.iconView asset. */
val iconAsset: Flow<Int> =
combine(
+ displayStateInteractor.currentRotation,
displayStateInteractor.isFolded,
displayStateInteractor.isInRearDisplayMode,
promptSelectorInteractor.sensorType,
- ) { isFolded: Boolean, isInRearDisplayMode: Boolean, sensorType: FingerprintSensorType ->
+ ) {
+ rotation: DisplayRotation,
+ isFolded: Boolean,
+ isInRearDisplayMode: Boolean,
+ sensorType: FingerprintSensorType ->
when (sensorType) {
FingerprintSensorType.POWER_BUTTON ->
- getSideFpsAnimationAsset(isFolded, isInRearDisplayMode)
+ getSideFpsAnimationAsset(rotation, isFolded, isInRearDisplayMode)
// Replace below when non-SFPS iconAsset logic is migrated to this ViewModel
else -> -1
}
@@ -55,11 +57,12 @@ constructor(
@RawRes
private fun getSideFpsAnimationAsset(
+ rotation: DisplayRotation,
isDeviceFolded: Boolean,
isInRearDisplayMode: Boolean,
): Int =
when (rotation) {
- Surface.ROTATION_90 ->
+ DisplayRotation.ROTATION_90 ->
if (isInRearDisplayMode) {
R.raw.biometricprompt_rear_portrait_reverse_base
} else if (isDeviceFolded) {
@@ -67,7 +70,7 @@ constructor(
} else {
R.raw.biometricprompt_portrait_base_topleft
}
- Surface.ROTATION_270 ->
+ DisplayRotation.ROTATION_270 ->
if (isInRearDisplayMode) {
R.raw.biometricprompt_rear_portrait_base
} else if (isDeviceFolded) {
@@ -89,8 +92,4 @@ constructor(
fun onConfigurationChanged(newConfig: Configuration) {
displayStateInteractor.onConfigurationChanged(newConfig)
}
-
- fun setRotation(newRotation: Int) {
- rotation = newRotation
- }
}
diff --git a/packages/SystemUI/tests/src/com/android/systemui/biometrics/data/repository/DisplayStateRepositoryTest.kt b/packages/SystemUI/tests/src/com/android/systemui/biometrics/data/repository/DisplayStateRepositoryTest.kt
index c9c46cbe8420..c825d2ea65ad 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/biometrics/data/repository/DisplayStateRepositoryTest.kt
+++ b/packages/SystemUI/tests/src/com/android/systemui/biometrics/data/repository/DisplayStateRepositoryTest.kt
@@ -82,6 +82,11 @@ class DisplayStateRepositoryTest : SysuiTestCase() {
rearDisplayDeviceStates
)
+ mContext.orCreateTestableResources.addOverride(
+ com.android.internal.R.bool.config_reverseDefaultRotation,
+ false
+ )
+
mContext = spy(mContext)
whenever(mContext.display).thenReturn(display)
diff --git a/packages/SystemUI/tests/utils/src/com/android/systemui/biometrics/data/repository/FakeDisplayStateRepository.kt b/packages/SystemUI/tests/utils/src/com/android/systemui/biometrics/data/repository/FakeDisplayStateRepository.kt
index 60291eece70b..3fdeb302dc34 100644
--- a/packages/SystemUI/tests/utils/src/com/android/systemui/biometrics/data/repository/FakeDisplayStateRepository.kt
+++ b/packages/SystemUI/tests/utils/src/com/android/systemui/biometrics/data/repository/FakeDisplayStateRepository.kt
@@ -29,6 +29,8 @@ class FakeDisplayStateRepository : DisplayStateRepository {
private val _currentRotation = MutableStateFlow<DisplayRotation>(DisplayRotation.ROTATION_0)
override val currentRotation: StateFlow<DisplayRotation> = _currentRotation.asStateFlow()
+ override val isReverseDefaultRotation = false
+
fun setIsInRearDisplayMode(isInRearDisplayMode: Boolean) {
_isInRearDisplayMode.value = isInRearDisplayMode
}
diff --git a/services/core/java/com/android/server/pm/ShortcutPackage.java b/services/core/java/com/android/server/pm/ShortcutPackage.java
index 28cb7f0b03a6..8456927b2cdf 100644
--- a/services/core/java/com/android/server/pm/ShortcutPackage.java
+++ b/services/core/java/com/android/server/pm/ShortcutPackage.java
@@ -376,6 +376,7 @@ class ShortcutPackage extends ShortcutPackageItem {
// Extract Icon and update the icon res ID and the bitmap path.
s.saveIconAndFixUpShortcutLocked(this, newShortcut);
s.fixUpShortcutResourceNamesAndValues(newShortcut);
+ ensureShortcutCountBeforePush();
saveShortcut(newShortcut);
}
@@ -430,7 +431,6 @@ class ShortcutPackage extends ShortcutPackageItem {
@NonNull List<ShortcutInfo> changedShortcuts) {
Preconditions.checkArgument(newShortcut.isEnabled(),
"pushDynamicShortcuts() cannot publish disabled shortcuts");
- ensureShortcutCountBeforePush();
newShortcut.addFlags(ShortcutInfo.FLAG_DYNAMIC);
diff --git a/services/core/java/com/android/server/wm/ActivityRecord.java b/services/core/java/com/android/server/wm/ActivityRecord.java
index 5fcfb0dd069b..1531b995086d 100644
--- a/services/core/java/com/android/server/wm/ActivityRecord.java
+++ b/services/core/java/com/android/server/wm/ActivityRecord.java
@@ -2117,8 +2117,7 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
hasBeenLaunched = false;
mTaskSupervisor = supervisor;
- info.taskAffinity = computeTaskAffinity(info.taskAffinity, info.applicationInfo.uid,
- info.launchMode, mActivityComponent);
+ info.taskAffinity = computeTaskAffinity(info.taskAffinity, info.applicationInfo.uid);
taskAffinity = info.taskAffinity;
final String uid = Integer.toString(info.applicationInfo.uid);
if (info.windowLayout != null && info.windowLayout.windowLayoutAffinity != null
@@ -2218,19 +2217,12 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
*
* @param affinity The affinity of the activity.
* @param uid The user-ID that has been assigned to this application.
- * @param launchMode The activity launch mode
- * @param componentName The activity component name. This is only useful when the given
- * launchMode is {@link ActivityInfo#LAUNCH_SINGLE_INSTANCE}
* @return The task affinity
*/
- static String computeTaskAffinity(String affinity, int uid, int launchMode,
- ComponentName componentName) {
+ static String computeTaskAffinity(String affinity, int uid) {
final String uidStr = Integer.toString(uid);
if (affinity != null && !affinity.startsWith(uidStr)) {
affinity = uidStr + ":" + affinity;
- if (launchMode == LAUNCH_SINGLE_INSTANCE && componentName != null) {
- affinity += ":" + componentName.hashCode();
- }
}
return affinity;
}
diff --git a/services/core/java/com/android/server/wm/RecentTasks.java b/services/core/java/com/android/server/wm/RecentTasks.java
index 4faaf5170f27..f33ecaa90531 100644
--- a/services/core/java/com/android/server/wm/RecentTasks.java
+++ b/services/core/java/com/android/server/wm/RecentTasks.java
@@ -183,6 +183,8 @@ class RecentTasks {
/** The non-empty tasks that are removed from recent tasks (see {@link #removeForAddTask}). */
private final ArrayList<Task> mHiddenTasks = new ArrayList<>();
+ /** The maximum size that the hidden tasks are cached. */
+ private static final int MAX_HIDDEN_TASK_SIZE = 10;
/** Whether to trim inactive tasks when activities are idle. */
private boolean mCheckTrimmableTasksOnIdle;
@@ -1497,9 +1499,13 @@ class RecentTasks {
return task.compareTo(rootHomeTask) < 0;
}
- /** Remove the tasks that user may not be able to return. */
+ /** Remove the tasks that user may not be able to return when exceeds the cache limit. */
private void removeUnreachableHiddenTasks(int windowingMode) {
- for (int i = mHiddenTasks.size() - 1; i >= 0; i--) {
+ final int size = mHiddenTasks.size();
+ if (size <= MAX_HIDDEN_TASK_SIZE) {
+ return;
+ }
+ for (int i = size - 1; i >= MAX_HIDDEN_TASK_SIZE; i--) {
final Task hiddenTask = mHiddenTasks.get(i);
if (!hiddenTask.hasChild() || hiddenTask.inRecents) {
// The task was removed by other path or it became reachable (added to recents).
@@ -1543,7 +1549,7 @@ class RecentTasks {
// A non-empty task is replaced by a new task. Because the removed task is no longer
// managed by the recent tasks list, add it to the hidden list to prevent the task
// from becoming dangling.
- mHiddenTasks.add(removedTask);
+ mHiddenTasks.add(0, removedTask);
}
notifyTaskRemoved(removedTask, false /* wasTrimmed */, false /* killProcess */);
if (DEBUG_RECENTS_TRIM_TASKS) {
diff --git a/services/core/java/com/android/server/wm/Task.java b/services/core/java/com/android/server/wm/Task.java
index c322563e9ae1..e5939c503aac 100644
--- a/services/core/java/com/android/server/wm/Task.java
+++ b/services/core/java/com/android/server/wm/Task.java
@@ -5417,8 +5417,7 @@ class Task extends TaskFragment {
// Basic case: for simple app-centric recents, we need to recreate
// the task if the affinity has changed.
- final String affinity = ActivityRecord.computeTaskAffinity(destAffinity, srec.getUid(),
- srec.launchMode, srec.mActivityComponent);
+ final String affinity = ActivityRecord.computeTaskAffinity(destAffinity, srec.getUid());
if (srec == null || srec.getTask().affinity == null
|| !srec.getTask().affinity.equals(affinity)) {
return true;
diff --git a/services/tests/wmtests/src/com/android/server/wm/ActivityStarterTests.java b/services/tests/wmtests/src/com/android/server/wm/ActivityStarterTests.java
index 9c754b969604..ec8e3bbaa122 100644
--- a/services/tests/wmtests/src/com/android/server/wm/ActivityStarterTests.java
+++ b/services/tests/wmtests/src/com/android/server/wm/ActivityStarterTests.java
@@ -1791,8 +1791,7 @@ public class ActivityStarterTests extends WindowTestsBase {
public void testLaunchActivityWithoutDisplayCategory() {
final ActivityInfo info = new ActivityInfo();
info.applicationInfo = new ApplicationInfo();
- info.taskAffinity = ActivityRecord.computeTaskAffinity("test", DEFAULT_FAKE_UID,
- 0 /* launchMode */, null /* componentName */);
+ info.taskAffinity = ActivityRecord.computeTaskAffinity("test", DEFAULT_FAKE_UID);
info.requiredDisplayCategory = "automotive";
final Task task = new TaskBuilder(mSupervisor).setCreateActivity(true).setActivityInfo(info)
.build();
@@ -1817,8 +1816,7 @@ public class ActivityStarterTests extends WindowTestsBase {
public void testLaunchActivityWithDifferentDisplayCategory() {
final ActivityInfo info = new ActivityInfo();
info.applicationInfo = new ApplicationInfo();
- info.taskAffinity = ActivityRecord.computeTaskAffinity("test", DEFAULT_FAKE_UID,
- 0 /* launchMode */, null /* componentName */);
+ info.taskAffinity = ActivityRecord.computeTaskAffinity("test", DEFAULT_FAKE_UID);
info.requiredDisplayCategory = "automotive";
final Task task = new TaskBuilder(mSupervisor).setCreateActivity(true).setActivityInfo(info)
.build();
@@ -1843,8 +1841,7 @@ public class ActivityStarterTests extends WindowTestsBase {
public void testLaunchActivityWithSameDisplayCategory() {
final ActivityInfo info = new ActivityInfo();
info.applicationInfo = new ApplicationInfo();
- info.taskAffinity = ActivityRecord.computeTaskAffinity("test", DEFAULT_FAKE_UID,
- 0 /* launchMode */, null /* componentName */);
+ info.taskAffinity = ActivityRecord.computeTaskAffinity("test", DEFAULT_FAKE_UID);
info.requiredDisplayCategory = "automotive";
final Task task = new TaskBuilder(mSupervisor).setCreateActivity(true).setActivityInfo(info)
.build();
diff --git a/services/tests/wmtests/src/com/android/server/wm/RecentTasksTest.java b/services/tests/wmtests/src/com/android/server/wm/RecentTasksTest.java
index df0808f72c3f..7cb58022c0e7 100644
--- a/services/tests/wmtests/src/com/android/server/wm/RecentTasksTest.java
+++ b/services/tests/wmtests/src/com/android/server/wm/RecentTasksTest.java
@@ -27,8 +27,6 @@ import static android.content.Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS;
import static android.content.Intent.FLAG_ACTIVITY_MULTIPLE_TASK;
import static android.content.Intent.FLAG_ACTIVITY_NEW_DOCUMENT;
import static android.content.Intent.FLAG_ACTIVITY_NEW_TASK;
-import static android.content.pm.ActivityInfo.LAUNCH_MULTIPLE;
-import static android.content.pm.ActivityInfo.LAUNCH_SINGLE_INSTANCE;
import static android.content.res.Configuration.ORIENTATION_PORTRAIT;
import static android.os.Process.NOBODY_UID;
@@ -451,25 +449,15 @@ public class RecentTasksTest extends WindowTestsBase {
final int uid = 10123;
final Task task1 = createTaskBuilder(".Task1").build();
final ComponentName componentName = getUniqueComponentName();
- task1.affinity = ActivityRecord.computeTaskAffinity(taskAffinity, uid, LAUNCH_MULTIPLE,
- componentName);
+ task1.affinity = ActivityRecord.computeTaskAffinity(taskAffinity, uid);
mRecentTasks.add(task1);
// Add another task to recents, and make sure the previous task was removed.
final Task task2 = createTaskBuilder(".Task2").build();
- task2.affinity = ActivityRecord.computeTaskAffinity(taskAffinity, uid, LAUNCH_MULTIPLE,
- componentName);
+ task2.affinity = ActivityRecord.computeTaskAffinity(taskAffinity, uid);
mRecentTasks.add(task2);
assertEquals(1, mRecentTasks.getRecentTasks(MAX_VALUE, 0 /* flags */,
true /* getTasksAllowed */, TEST_USER_0_ID, 0).getList().size());
-
- // Add another single-instance task to recents, and make sure no task is removed.
- final Task task3 = createTaskBuilder(".Task3").build();
- task3.affinity = ActivityRecord.computeTaskAffinity(taskAffinity, uid,
- LAUNCH_SINGLE_INSTANCE, componentName);
- mRecentTasks.add(task3);
- assertEquals(2, mRecentTasks.getRecentTasks(MAX_VALUE, 0 /* flags */,
- true /* getTasksAllowed */, TEST_USER_0_ID, 0).getList().size());
}
@Test