Merge "AudioDeviceBroker: fix createBtDeviceInfo for HEADSET profile" into main
diff --git a/apct-tests/perftests/multiuser/src/android/multiuser/BenchmarkRunner.java b/apct-tests/perftests/multiuser/src/android/multiuser/BenchmarkRunner.java
index 459c286..515ddc8 100644
--- a/apct-tests/perftests/multiuser/src/android/multiuser/BenchmarkRunner.java
+++ b/apct-tests/perftests/multiuser/src/android/multiuser/BenchmarkRunner.java
@@ -19,16 +19,13 @@
import android.os.Bundle;
import android.os.SystemClock;
import android.perftests.utils.ShellHelper;
-import android.util.Log;
import java.util.ArrayList;
// Based on //platform/frameworks/base/apct-tests/perftests/utils/BenchmarkState.java
public class BenchmarkRunner {
- private static final String TAG = BenchmarkRunner.class.getSimpleName();
+
private static final long COOL_OFF_PERIOD_MS = 1000;
- private static final int CPU_IDLE_TIMEOUT_MS = 60 * 1000;
- private static final int CPU_IDLE_THRESHOLD_PERCENTAGE = 90;
private static final int NUM_ITERATIONS = 4;
@@ -83,7 +80,7 @@
private void prepareForNextRun() {
SystemClock.sleep(COOL_OFF_PERIOD_MS);
- waitCoolDownPeriod();
+ ShellHelper.runShellCommand("am wait-for-broadcast-idle --flush-broadcast-loopers");
mStartTimeNs = System.nanoTime();
mPausedDurationNs = 0;
}
@@ -105,7 +102,7 @@
* to avoid unnecessary waiting.
*/
public void resumeTiming() {
- waitCoolDownPeriod();
+ ShellHelper.runShellCommand("am wait-for-broadcast-idle --flush-broadcast-loopers");
resumeTimer();
}
@@ -165,56 +162,4 @@
}
return null;
}
-
- /** Waits for the broadcast queue and the CPU cores to be idle. */
- public void waitCoolDownPeriod() {
- waitForBroadcastIdle();
- waitForCpuIdle();
- }
-
- private void waitForBroadcastIdle() {
- Log.d(TAG, "starting to waitForBroadcastIdle");
- final long startedAt = System.currentTimeMillis();
- ShellHelper.runShellCommand("am wait-for-broadcast-idle --flush-broadcast-loopers");
- final long elapsed = System.currentTimeMillis() - startedAt;
- Log.d(TAG, "waitForBroadcastIdle is complete in " + elapsed + " ms");
- }
- private void waitForCpuIdle() {
- Log.d(TAG, "starting to waitForCpuIdle");
- final long startedAt = System.currentTimeMillis();
- while (true) {
- final int idleCpuPercentage = getIdleCpuPercentage();
- final long elapsed = System.currentTimeMillis() - startedAt;
- Log.d(TAG, "waitForCpuIdle " + idleCpuPercentage + "% (" + elapsed + "ms elapsed)");
- if (idleCpuPercentage >= CPU_IDLE_THRESHOLD_PERCENTAGE) {
- Log.d(TAG, "waitForCpuIdle is complete in " + elapsed + " ms");
- return;
- }
- if (elapsed >= CPU_IDLE_TIMEOUT_MS) {
- Log.e(TAG, "Ending waitForCpuIdle because it didn't finish in "
- + CPU_IDLE_TIMEOUT_MS + " ms");
- return;
- }
- SystemClock.sleep(1000);
- }
- }
-
- private int getIdleCpuPercentage() {
- String output = ShellHelper.runShellCommand("top -m 1 -n 1");
- String[] tokens = output.split("\\s+");
- float totalCpu = -1;
- float idleCpu = -1;
- for (String token : tokens) {
- if (token.contains("%cpu")) {
- totalCpu = Float.parseFloat(token.split("%")[0]);
- } else if (token.contains("%idle")) {
- idleCpu = Float.parseFloat(token.split("%")[0]);
- }
- }
- if (totalCpu < 0 || idleCpu < 0) {
- Log.e(TAG, "Could not get idle cpu percentage, output=" + output);
- return -1;
- }
- return (int) (100 * idleCpu / totalCpu);
- }
}
\ No newline at end of file
diff --git a/apct-tests/perftests/multiuser/src/android/multiuser/UserLifecycleTests.java b/apct-tests/perftests/multiuser/src/android/multiuser/UserLifecycleTests.java
index 98ab0c2..762e2af 100644
--- a/apct-tests/perftests/multiuser/src/android/multiuser/UserLifecycleTests.java
+++ b/apct-tests/perftests/multiuser/src/android/multiuser/UserLifecycleTests.java
@@ -188,6 +188,21 @@
}
}
+ /** Tests creating a new user, with wait times between iterations. */
+ @Test(timeout = TIMEOUT_MAX_TEST_TIME_MS)
+ public void createUser_realistic() throws RemoteException {
+ while (mRunner.keepRunning()) {
+ Log.i(TAG, "Starting timer");
+ final int userId = createUserNoFlags();
+
+ mRunner.pauseTiming();
+ Log.i(TAG, "Stopping timer");
+ removeUser(userId);
+ waitCoolDownPeriod();
+ mRunner.resumeTimingForNextIteration();
+ }
+ }
+
/** Tests creating and starting a new user. */
@Test(timeout = TIMEOUT_MAX_TEST_TIME_MS)
public void createAndStartUser() throws RemoteException {
@@ -224,6 +239,7 @@
mRunner.pauseTiming();
Log.d(TAG, "Stopping timer");
removeUser(userId);
+ waitCoolDownPeriod();
mRunner.resumeTimingForNextIteration();
}
}
@@ -238,6 +254,7 @@
mRunner.pauseTiming();
final int userId = createUserNoFlags();
+ waitForBroadcastIdle();
runThenWaitForBroadcasts(userId, () -> {
mRunner.resumeTiming();
Log.i(TAG, "Starting timer");
@@ -292,6 +309,9 @@
preStartUser(userId, numberOfIterationsToSkip);
+ waitForBroadcastIdle();
+ waitCoolDownPeriod();
+
runThenWaitForBroadcasts(userId, () -> {
mRunner.resumeTiming();
Log.i(TAG, "Starting timer");
@@ -333,6 +353,9 @@
while (mRunner.keepRunning()) {
mRunner.pauseTiming();
+ waitForBroadcastIdle();
+ waitCoolDownPeriod();
+
runThenWaitForBroadcasts(userId, () -> {
mRunner.resumeTiming();
Log.i(TAG, "Starting timer");
@@ -397,6 +420,7 @@
while (mRunner.keepRunning()) {
mRunner.pauseTiming();
+ waitCoolDownPeriod();
mRunner.resumeTiming();
Log.i(TAG, "Starting timer");
@@ -430,6 +454,7 @@
mRunner.pauseTiming();
Log.d(TAG, "Stopping timer");
removeUser(userId);
+ waitCoolDownPeriod();
mRunner.resumeTimingForNextIteration();
}
}
@@ -441,7 +466,6 @@
mRunner.pauseTiming();
final int startUser = mAm.getCurrentUser();
final int userId = createUserNoFlags();
-
mRunner.resumeTiming();
Log.i(TAG, "Starting timer");
@@ -455,6 +479,27 @@
}
}
+ /** Tests switching to an uninitialized user with wait times between iterations. */
+ @Test(timeout = TIMEOUT_MAX_TEST_TIME_MS)
+ public void switchUser_realistic() throws Exception {
+ while (mRunner.keepRunning()) {
+ mRunner.pauseTiming();
+ final int startUser = ActivityManager.getCurrentUser();
+ final int userId = createUserNoFlags();
+ waitCoolDownPeriod();
+ Log.d(TAG, "Starting timer");
+ mRunner.resumeTiming();
+
+ switchUser(userId);
+
+ mRunner.pauseTiming();
+ Log.d(TAG, "Stopping timer");
+ switchUserNoCheck(startUser);
+ removeUser(userId);
+ mRunner.resumeTimingForNextIteration();
+ }
+ }
+
/** Tests switching to a previously-started, but no-longer-running, user. */
@Test(timeout = TIMEOUT_MAX_TEST_TIME_MS)
public void switchUser_stopped() throws RemoteException {
@@ -462,7 +507,6 @@
mRunner.pauseTiming();
final int startUser = mAm.getCurrentUser();
final int testUser = initializeNewUserAndSwitchBack(/* stopNewUser */ true);
-
mRunner.resumeTiming();
Log.i(TAG, "Starting timer");
@@ -492,6 +536,7 @@
while (mRunner.keepRunning()) {
mRunner.pauseTiming();
+ waitCoolDownPeriod();
Log.d(TAG, "Starting timer");
mRunner.resumeTiming();
@@ -517,6 +562,7 @@
/* useStaticWallpaper */true);
while (mRunner.keepRunning()) {
mRunner.pauseTiming();
+ waitCoolDownPeriod();
Log.d(TAG, "Starting timer");
mRunner.resumeTiming();
@@ -560,6 +606,7 @@
final int testUser = initializeNewUserAndSwitchBack(/* stopNewUser */ false);
while (mRunner.keepRunning()) {
mRunner.pauseTiming();
+ waitCoolDownPeriod();
Log.d(TAG, "Starting timer");
mRunner.resumeTiming();
@@ -567,6 +614,7 @@
mRunner.pauseTiming();
Log.d(TAG, "Stopping timer");
+ waitForBroadcastIdle();
switchUserNoCheck(startUser);
mRunner.resumeTimingForNextIteration();
}
@@ -583,6 +631,7 @@
/* useStaticWallpaper */ true);
while (mRunner.keepRunning()) {
mRunner.pauseTiming();
+ waitCoolDownPeriod();
Log.d(TAG, "Starting timer");
mRunner.resumeTiming();
@@ -590,6 +639,7 @@
mRunner.pauseTiming();
Log.d(TAG, "Stopping timer");
+ waitForBroadcastIdle();
switchUserNoCheck(startUser);
mRunner.resumeTimingForNextIteration();
}
@@ -625,11 +675,13 @@
@Test(timeout = TIMEOUT_MAX_TEST_TIME_MS)
public void stopUser_realistic() throws RemoteException {
final int userId = createUserNoFlags();
+ waitCoolDownPeriod();
while (mRunner.keepRunning()) {
mRunner.pauseTiming();
runThenWaitForBroadcasts(userId, ()-> {
mIam.startUserInBackground(userId);
}, Intent.ACTION_USER_STARTED, Intent.ACTION_MEDIA_MOUNTED);
+ waitCoolDownPeriod();
Log.d(TAG, "Starting timer");
mRunner.resumeTiming();
@@ -651,7 +703,7 @@
final int startUser = mAm.getCurrentUser();
final int userId = createUserNoFlags();
- mRunner.waitCoolDownPeriod();
+ waitForBroadcastIdle();
mUserSwitchWaiter.runThenWaitUntilBootCompleted(userId, () -> {
mRunner.resumeTiming();
Log.i(TAG, "Starting timer");
@@ -674,7 +726,7 @@
final int startUser = ActivityManager.getCurrentUser();
final int userId = createUserNoFlags();
- mRunner.waitCoolDownPeriod();
+ waitCoolDownPeriod();
mUserSwitchWaiter.runThenWaitUntilBootCompleted(userId, () -> {
mRunner.resumeTiming();
Log.d(TAG, "Starting timer");
@@ -700,7 +752,7 @@
switchUser(userId);
}, Intent.ACTION_MEDIA_MOUNTED);
- mRunner.waitCoolDownPeriod();
+ waitForBroadcastIdle();
mUserSwitchWaiter.runThenWaitUntilSwitchCompleted(startUser, () -> {
runThenWaitForBroadcasts(userId, () -> {
mRunner.resumeTiming();
@@ -729,7 +781,7 @@
switchUser(userId);
}, Intent.ACTION_MEDIA_MOUNTED);
- mRunner.waitCoolDownPeriod();
+ waitCoolDownPeriod();
mUserSwitchWaiter.runThenWaitUntilSwitchCompleted(startUser, () -> {
runThenWaitForBroadcasts(userId, () -> {
mRunner.resumeTiming();
@@ -775,6 +827,7 @@
Log.d(TAG, "Stopping timer");
attestTrue("Failed creating profile " + userId, mUm.isManagedProfile(userId));
removeUser(userId);
+ waitCoolDownPeriod();
mRunner.resumeTimingForNextIteration();
}
}
@@ -815,6 +868,7 @@
mRunner.pauseTiming();
Log.d(TAG, "Stopping timer");
removeUser(userId);
+ waitCoolDownPeriod();
mRunner.resumeTimingForNextIteration();
}
}
@@ -859,6 +913,7 @@
mRunner.pauseTiming();
Log.d(TAG, "Stopping timer");
+ waitCoolDownPeriod();
mRunner.resumeTimingForNextIteration();
}
removeUser(userId);
@@ -910,6 +965,7 @@
mRunner.pauseTiming();
Log.d(TAG, "Stopping timer");
removeUser(userId);
+ waitCoolDownPeriod();
mRunner.resumeTimingForNextIteration();
}
}
@@ -974,6 +1030,7 @@
mRunner.pauseTiming();
Log.d(TAG, "Stopping timer");
removeUser(userId);
+ waitCoolDownPeriod();
mRunner.resumeTimingForNextIteration();
}
}
@@ -1014,6 +1071,7 @@
mRunner.pauseTiming();
Log.d(TAG, "Stopping timer");
removeUser(userId);
+ waitCoolDownPeriod();
mRunner.resumeTimingForNextIteration();
}
}
@@ -1066,6 +1124,7 @@
mRunner.pauseTiming();
Log.d(TAG, "Stopping timer");
removeUser(userId);
+ waitCoolDownPeriod();
mRunner.resumeTimingForNextIteration();
}
}
@@ -1105,6 +1164,7 @@
runThenWaitForBroadcasts(userId, () -> {
startUserInBackgroundAndWaitForUnlock(userId);
}, Intent.ACTION_MEDIA_MOUNTED);
+ waitCoolDownPeriod();
mRunner.resumeTiming();
Log.d(TAG, "Starting timer");
@@ -1220,7 +1280,6 @@
* If lack of success should fail the test, use {@link #switchUser(int)} instead.
*/
private boolean switchUserNoCheck(int userId) throws RemoteException {
- mRunner.waitCoolDownPeriod();
final boolean[] success = {true};
mUserSwitchWaiter.runThenWaitUntilSwitchCompleted(userId, () -> {
mAm.switchUser(userId);
@@ -1237,7 +1296,7 @@
*/
private void stopUserAfterWaitingForBroadcastIdle(int userId)
throws RemoteException {
- mRunner.waitCoolDownPeriod();
+ waitForBroadcastIdle();
stopUser(userId);
}
@@ -1379,8 +1438,6 @@
*/
private void runThenWaitForBroadcasts(int userId, FunctionalUtils.ThrowingRunnable runnable,
String... actions) {
- mRunner.waitCoolDownPeriod();
-
final String unreceivedAction =
mBroadcastWaiter.runThenWaitForBroadcasts(userId, runnable, actions);
@@ -1481,4 +1538,28 @@
assertEquals("", ShellHelper.runShellCommand("setprop " + name + " " + value));
return TextUtils.firstNotEmpty(oldValue, "invalid");
}
+
+ private void waitForBroadcastIdle() {
+ try {
+ ShellHelper.runShellCommandWithTimeout(
+ "am wait-for-broadcast-idle --flush-broadcast-loopers", TIMEOUT_IN_SECOND);
+ } catch (TimeoutException e) {
+ Log.e(TAG, "Ending waitForBroadcastIdle because it is taking too long", e);
+ }
+ }
+
+ private void sleep(long ms) {
+ try {
+ Thread.sleep(ms);
+ } catch (InterruptedException e) {
+ // Ignore
+ }
+ }
+
+ private void waitCoolDownPeriod() {
+ // Heuristic value based on local tests. Stability increased compared to no waiting.
+ final int tenSeconds = 1000 * 10;
+ waitForBroadcastIdle();
+ sleep(tenSeconds);
+ }
}
diff --git a/apct-tests/perftests/permission/src/android/perftests/permission/PermissionManagerPerfTest.kt b/apct-tests/perftests/permission/src/android/perftests/permission/PermissionManagerPerfTest.kt
new file mode 100644
index 0000000..8b8036e
--- /dev/null
+++ b/apct-tests/perftests/permission/src/android/perftests/permission/PermissionManagerPerfTest.kt
@@ -0,0 +1,75 @@
+/*
+ * 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 android.perftests.permission
+
+import android.Manifest
+import android.companion.virtual.VirtualDeviceManager.PERSISTENT_DEVICE_ID_DEFAULT
+import android.content.Context
+import android.perftests.utils.PerfStatusReporter
+import android.permission.PermissionManager
+import androidx.test.ext.junit.runners.AndroidJUnit4
+import androidx.test.platform.app.InstrumentationRegistry
+import com.android.compatibility.common.util.AdoptShellPermissionsRule
+import com.android.compatibility.common.util.SystemUtil.runShellCommand
+import org.junit.After
+import org.junit.Before
+import org.junit.Rule
+import org.junit.Test
+import org.junit.runner.RunWith
+
+@RunWith(AndroidJUnit4::class)
+class PermissionManagerPerfTest {
+ @get:Rule var perfStatusReporter = PerfStatusReporter()
+ @get:Rule
+ val mAdoptShellPermissionsRule =
+ AdoptShellPermissionsRule(
+ InstrumentationRegistry.getInstrumentation().getUiAutomation(),
+ Manifest.permission.INSTALL_PACKAGES,
+ Manifest.permission.DELETE_PACKAGES,
+ Manifest.permission.GRANT_RUNTIME_PERMISSIONS,
+ Manifest.permission.MANAGE_ONE_TIME_PERMISSION_SESSIONS,
+ Manifest.permission.REVOKE_RUNTIME_PERMISSIONS,
+ )
+
+ val context: Context = InstrumentationRegistry.getInstrumentation().targetContext
+ val permissionManager = context.getSystemService(PermissionManager::class.java)!!
+
+ @Before
+ fun setup() {
+ val apkPath = "$APK_DIR${APK_NAME}.apk"
+ runShellCommand("pm install -tg $apkPath")
+ }
+
+ @After
+ fun cleanup() {
+ runShellCommand("pm uninstall $PKG_NAME")
+ }
+
+ @Test
+ fun testGetAllPermissionStates() {
+ val benchmarkState = perfStatusReporter.benchmarkState
+ while (benchmarkState.keepRunning()) {
+ permissionManager.getAllPermissionStates(PKG_NAME, PERSISTENT_DEVICE_ID_DEFAULT)
+ }
+ }
+
+ companion object {
+ private const val APK_DIR = "/data/local/tmp/perftests/"
+ private const val APK_NAME = "UsePermissionApp0"
+ private const val PKG_NAME = "android.perftests.appenumeration0"
+ }
+}
diff --git a/apct-tests/perftests/permission/src/android/perftests/permission/PermissionServicePerfTest.kt b/apct-tests/perftests/permission/src/android/perftests/permission/PermissionServicePerfTest.kt
index 13e67e3..1139835 100644
--- a/apct-tests/perftests/permission/src/android/perftests/permission/PermissionServicePerfTest.kt
+++ b/apct-tests/perftests/permission/src/android/perftests/permission/PermissionServicePerfTest.kt
@@ -36,6 +36,7 @@
import java.io.InputStreamReader
import java.util.concurrent.TimeUnit
import java.util.function.BiConsumer
+import org.junit.Ignore
@RunWith(AndroidJUnit4::class)
class PermissionServicePerfTest {
@@ -48,6 +49,7 @@
val mUiAutomation = InstrumentationRegistry.getInstrumentation().getUiAutomation()
@Test
+ @Ignore("Fails to capture duration, results in infinite loop and execution timeout")
fun testInstallPackages() {
mUiAutomation.executeShellCommand(COMMAND_TRACE_START)
eventually { assertThat(Trace.isTagEnabled(TRACE_TAG)).isTrue() }
diff --git a/core/java/android/app/admin/DevicePolicyManager.java b/core/java/android/app/admin/DevicePolicyManager.java
index 44444b5..67752f2 100644
--- a/core/java/android/app/admin/DevicePolicyManager.java
+++ b/core/java/android/app/admin/DevicePolicyManager.java
@@ -62,6 +62,7 @@
import static android.app.admin.flags.Flags.FLAG_HEADLESS_DEVICE_OWNER_SINGLE_USER_ENABLED;
import static android.app.admin.flags.Flags.FLAG_SECURITY_LOG_V2_ENABLED;
import static android.app.admin.flags.Flags.onboardingBugreportV2Enabled;
+import static android.app.admin.flags.Flags.onboardingConsentlessBugreports;
import static android.app.admin.flags.Flags.FLAG_IS_MTE_POLICY_ENFORCED;
import static android.content.Intent.LOCAL_FLAG_FROM_SYSTEM;
import static android.net.NetworkCapabilities.NET_ENTERPRISE_ID_1;
@@ -17626,6 +17627,17 @@
return onboardingBugreportV2Enabled();
}
+ // TODO(b/308755220): Remove once the build is finalised.
+ /**
+ * Returns true if the flag for consentless bugreports is enabled.
+ *
+ * @hide
+ */
+ @UnsupportedAppUsage
+ public boolean isOnboardingConsentlessBugreportFlagEnabled() {
+ return onboardingConsentlessBugreports();
+ }
+
/**
* Returns the subscription ids of all subscriptions which were downloaded by the calling
* admin.
diff --git a/core/java/android/content/Intent.java b/core/java/android/content/Intent.java
index c8cae82..02d62a2 100644
--- a/core/java/android/content/Intent.java
+++ b/core/java/android/content/Intent.java
@@ -8157,6 +8157,9 @@
int eq = uri.indexOf('=', i);
if (eq < 0) eq = i-1;
int semi = uri.indexOf(';', i);
+ if (semi < 0) {
+ throw new URISyntaxException(uri, "uri end not found");
+ }
String value = eq < semi ? Uri.decode(uri.substring(eq + 1, semi)) : "";
// action
diff --git a/core/java/android/content/pm/PackageInstaller.java b/core/java/android/content/pm/PackageInstaller.java
index bbd0e9f..821034a 100644
--- a/core/java/android/content/pm/PackageInstaller.java
+++ b/core/java/android/content/pm/PackageInstaller.java
@@ -3468,8 +3468,12 @@
* Android S ({@link android.os.Build.VERSION_CODES#S API 31})</li>
* <li>{@link android.os.Build.VERSION_CODES#R API 30} or higher on
* Android T ({@link android.os.Build.VERSION_CODES#TIRAMISU API 33})</li>
- * <li>{@link android.os.Build.VERSION_CODES#S API 31} or higher <b>after</b>
- * Android T ({@link android.os.Build.VERSION_CODES#TIRAMISU API 33})</li>
+ * <li>{@link android.os.Build.VERSION_CODES#S API 31} or higher on
+ * Android U ({@link android.os.Build.VERSION_CODES#UPSIDE_DOWN_CAKE API 34})
+ * </li>
+ * <li>{@link android.os.Build.VERSION_CODES#TIRAMISU API 33} or higher on
+ * Android V ({@link android.os.Build.VERSION_CODES#VANILLA_ICE_CREAM API 35})
+ * </li>
* </ul>
* </li>
* <li>The installer is:
diff --git a/core/java/android/content/pm/multiuser.aconfig b/core/java/android/content/pm/multiuser.aconfig
index e2a131c..5668c54 100644
--- a/core/java/android/content/pm/multiuser.aconfig
+++ b/core/java/android/content/pm/multiuser.aconfig
@@ -140,6 +140,16 @@
}
}
+flag {
+ name: "fix_avatar_concurrent_file_write"
+ namespace: "multiuser"
+ description: "Fix potential unexpected behavior due to concurrent file writing"
+ bug: "339351031"
+ metadata {
+ purpose: PURPOSE_BUGFIX
+ }
+}
+
# This flag guards the private space feature and all its implementations excluding the APIs. APIs are guarded by android.os.Flags.allow_private_profile.
flag {
name: "enable_private_space_features"
diff --git a/core/java/android/hardware/input/InputManager.java b/core/java/android/hardware/input/InputManager.java
index 9eabc8d..53771e3 100644
--- a/core/java/android/hardware/input/InputManager.java
+++ b/core/java/android/hardware/input/InputManager.java
@@ -963,11 +963,10 @@
* originate from the system, just that we were unable to verify it. This can
* happen for a number of reasons during normal operation.
*
- * @param event The {@link android.view.InputEvent} to check
+ * @param event The {@link android.view.InputEvent} to check.
*
* @return {@link android.view.VerifiedInputEvent}, which is a subset of the provided
- * {@link android.view.InputEvent}
- * {@code null} if the event could not be verified.
+ * {@link android.view.InputEvent}, or {@code null} if the event could not be verified.
*/
@Nullable
public VerifiedInputEvent verifyInputEvent(@NonNull InputEvent event) {
diff --git a/core/java/android/os/OWNERS b/core/java/android/os/OWNERS
index 9f3364f..04d4970 100644
--- a/core/java/android/os/OWNERS
+++ b/core/java/android/os/OWNERS
@@ -107,4 +107,8 @@
per-file ProfilingServiceManager.java = file:/PERFORMANCE_OWNERS
# Memory
-per-file OomKillRecord.java = file:/MEMORY_OWNERS
\ No newline at end of file
+per-file OomKillRecord.java = file:/MEMORY_OWNERS
+
+# MessageQueue
+per-file MessageQueue.java = mfasheh@google.com, shayba@google.com
+per-file Message.java = mfasheh@google.com, shayba@google.com
diff --git a/core/java/android/security/responsible_apis_flags.aconfig b/core/java/android/security/responsible_apis_flags.aconfig
index c7d951b..56d3669 100644
--- a/core/java/android/security/responsible_apis_flags.aconfig
+++ b/core/java/android/security/responsible_apis_flags.aconfig
@@ -45,3 +45,10 @@
description: "Do not allow intents without an action to match any intent filters"
bug: "293560872"
}
+
+flag {
+ name: "asm_opt_system_into_enforcement"
+ namespace: "responsible_apis"
+ description: "Opt the system into enforcement of BAL"
+ bug: "339403750"
+}
diff --git a/core/java/android/view/Display.java b/core/java/android/view/Display.java
index ba1915c..15b0c13 100644
--- a/core/java/android/view/Display.java
+++ b/core/java/android/view/Display.java
@@ -2263,6 +2263,7 @@
this(modeId, width, height, refreshRate, vsyncRate, false, alternativeRefreshRates,
supportedHdrTypes);
}
+
/**
* @hide
*/
diff --git a/core/java/android/view/DisplayInfo.java b/core/java/android/view/DisplayInfo.java
index da86e2d..8b9d876 100644
--- a/core/java/android/view/DisplayInfo.java
+++ b/core/java/android/view/DisplayInfo.java
@@ -213,7 +213,7 @@
/**
* The supported modes that will be exposed externally.
- * Might have different set of modes that supportedModes for VRR displays
+ * Might have different set of modes than supportedModes for VRR displays
*/
public Display.Mode[] appsSupportedModes = Display.Mode.EMPTY_ARRAY;
diff --git a/core/java/android/view/MotionEvent.java b/core/java/android/view/MotionEvent.java
index 6db40bf..79a9f2d 100644
--- a/core/java/android/view/MotionEvent.java
+++ b/core/java/android/view/MotionEvent.java
@@ -682,7 +682,8 @@
* <li>For a touch screen or touch pad, reports the approximate size of the contact area in
* relation to the maximum detectable size for the device. The value is normalized
* to a range from 0 (smallest detectable size) to 1 (largest detectable size),
- * although it is not a linear scale. This value is of limited use.
+ * although it is not a linear scale. The value of size can be used to
+ * determine fat touch events.
* To obtain calibrated size information, use
* {@link #AXIS_TOUCH_MAJOR} or {@link #AXIS_TOOL_MAJOR}.
* </ul>
@@ -2795,13 +2796,8 @@
}
/**
- * Returns the current pressure of this event for the given pointer
- * <em>index</em> (use {@link #getPointerId(int)} to find the pointer
- * identifier for this index).
- * The pressure generally
- * ranges from 0 (no pressure at all) to 1 (normal pressure), however
- * values higher than 1 may be generated depending on the calibration of
- * the input device.
+ * Returns the value of {@link #AXIS_PRESSURE} for the given pointer <em>index</em>.
+ *
* @param pointerIndex Raw index of pointer to retrieve. Value may be from 0
* (the first pointer that is down) to {@link #getPointerCount()}-1.
*
@@ -2812,14 +2808,8 @@
}
/**
- * Returns a scaled value of the approximate size for the given pointer
- * <em>index</em> (use {@link #getPointerId(int)} to find the pointer
- * identifier for this index).
- * This represents some approximation of the area of the screen being
- * pressed; the actual value in pixels corresponding to the
- * touch is normalized with the device specific range of values
- * and scaled to a value between 0 and 1. The value of size can be used to
- * determine fat touch events.
+ * Returns the value of {@link #AXIS_SIZE} for the given pointer <em>index</em>.
+ *
* @param pointerIndex Raw index of pointer to retrieve. Value may be from 0
* (the first pointer that is down) to {@link #getPointerCount()}-1.
*
@@ -2830,10 +2820,8 @@
}
/**
- * Returns the length of the major axis of an ellipse that describes the touch
- * area at the point of contact for the given pointer
- * <em>index</em> (use {@link #getPointerId(int)} to find the pointer
- * identifier for this index).
+ * Returns the value of {@link #AXIS_TOUCH_MAJOR} for the given pointer <em>index</em>.
+ *
* @param pointerIndex Raw index of pointer to retrieve. Value may be from 0
* (the first pointer that is down) to {@link #getPointerCount()}-1.
*
@@ -2844,10 +2832,8 @@
}
/**
- * Returns the length of the minor axis of an ellipse that describes the touch
- * area at the point of contact for the given pointer
- * <em>index</em> (use {@link #getPointerId(int)} to find the pointer
- * identifier for this index).
+ * Returns the value of {@link #AXIS_TOUCH_MINOR} for the given pointer <em>index</em>.
+ *
* @param pointerIndex Raw index of pointer to retrieve. Value may be from 0
* (the first pointer that is down) to {@link #getPointerCount()}-1.
*
@@ -2858,12 +2844,8 @@
}
/**
- * Returns the length of the major axis of an ellipse that describes the size of
- * the approaching tool for the given pointer
- * <em>index</em> (use {@link #getPointerId(int)} to find the pointer
- * identifier for this index).
- * The tool area represents the estimated size of the finger or pen that is
- * touching the device independent of its actual touch area at the point of contact.
+ * Returns the value of {@link #AXIS_TOOL_MAJOR} for the given pointer <em>index</em>.
+ *
* @param pointerIndex Raw index of pointer to retrieve. Value may be from 0
* (the first pointer that is down) to {@link #getPointerCount()}-1.
*
@@ -2874,12 +2856,8 @@
}
/**
- * Returns the length of the minor axis of an ellipse that describes the size of
- * the approaching tool for the given pointer
- * <em>index</em> (use {@link #getPointerId(int)} to find the pointer
- * identifier for this index).
- * The tool area represents the estimated size of the finger or pen that is
- * touching the device independent of its actual touch area at the point of contact.
+ * Returns the value of {@link #AXIS_TOOL_MINOR} for the given pointer <em>index</em>.
+ *
* @param pointerIndex Raw index of pointer to retrieve. Value may be from 0
* (the first pointer that is down) to {@link #getPointerCount()}-1.
*
@@ -2890,15 +2868,8 @@
}
/**
- * Returns the orientation of the touch area and tool area in radians clockwise from vertical
- * for the given pointer <em>index</em> (use {@link #getPointerId(int)} to find the pointer
- * identifier for this index).
- * An angle of 0 radians indicates that the major axis of contact is oriented
- * upwards, is perfectly circular or is of unknown orientation. A positive angle
- * indicates that the major axis of contact is oriented to the right. A negative angle
- * indicates that the major axis of contact is oriented to the left.
- * The full range is from -PI/2 radians (finger pointing fully left) to PI/2 radians
- * (finger pointing fully right).
+ * Returns the value of {@link #AXIS_ORIENTATION} for the given pointer <em>index</em>.
+ *
* @param pointerIndex Raw index of pointer to retrieve. Value may be from 0
* (the first pointer that is down) to {@link #getPointerCount()}-1.
*
diff --git a/core/java/android/view/View.java b/core/java/android/view/View.java
index 075ee1b..5e3f09a 100644
--- a/core/java/android/view/View.java
+++ b/core/java/android/view/View.java
@@ -1984,9 +1984,25 @@
public @interface ContentSensitivity {}
/**
- * Automatically determine whether a view displays sensitive content. For example, available
- * autofill hints (or some other signal) can be used to determine if this view
- * displays sensitive content.
+ * Content sensitivity is determined by the framework. The framework uses a heuristic to
+ * determine if this view displays sensitive content.
+ * Autofill hints i.e. {@link #getAutofillHints()} are used in the heuristic
+ * to determine if this view should be considered as a sensitive view.
+ * <p>
+ * {@link #AUTOFILL_HINT_USERNAME},
+ * {@link #AUTOFILL_HINT_PASSWORD},
+ * {@link #AUTOFILL_HINT_CREDIT_CARD_NUMBER},
+ * {@link #AUTOFILL_HINT_CREDIT_CARD_SECURITY_CODE},
+ * {@link #AUTOFILL_HINT_CREDIT_CARD_EXPIRATION_DATE},
+ * {@link #AUTOFILL_HINT_CREDIT_CARD_EXPIRATION_DAY},
+ * {@link #AUTOFILL_HINT_CREDIT_CARD_EXPIRATION_MONTH},
+ * {@link #AUTOFILL_HINT_CREDIT_CARD_EXPIRATION_YEAR}
+ * are considered sensitive hints by the framework, and the list may include more hints
+ * in the future.
+ *
+ * <p> The window hosting a sensitive view will be marked as secure during an active media
+ * projection session. This would be equivalent to applying
+ * {@link android.view.WindowManager.LayoutParams#FLAG_SECURE} to the window.
*
* @see #getContentSensitivity()
*/
@@ -1996,6 +2012,10 @@
/**
* The view displays sensitive content.
*
+ * <p> The window hosting a sensitive view will be marked as secure during an active media
+ * projection session. This would be equivalent to applying
+ * {@link android.view.WindowManager.LayoutParams#FLAG_SECURE} to the window.
+ *
* @see #getContentSensitivity()
*/
@FlaggedApi(FLAG_SENSITIVE_CONTENT_APP_PROTECTION_API)
@@ -10548,9 +10568,13 @@
/**
* Sets content sensitivity mode to determine whether this view displays sensitive content
- * (e.g. username, password etc.). The system may improve user privacy i.e. hide content
+ * (e.g. username, password etc.). The system will improve user privacy i.e. hide content
* drawn by a sensitive view from screen sharing and recording.
*
+ * <p> The window hosting a sensitive view will be marked as secure during an active media
+ * projection session. This would be equivalent to applying
+ * {@link android.view.WindowManager.LayoutParams#FLAG_SECURE} to the window.
+ *
* @param mode {@link #CONTENT_SENSITIVITY_AUTO}, {@link #CONTENT_SENSITIVITY_NOT_SENSITIVE}
* or {@link #CONTENT_SENSITIVITY_SENSITIVE}
*/
@@ -10574,8 +10598,7 @@
* {@link #setContentSensitivity(int)}.
*/
@FlaggedApi(FLAG_SENSITIVE_CONTENT_APP_PROTECTION_API)
- public @ContentSensitivity
- final int getContentSensitivity() {
+ public @ContentSensitivity final int getContentSensitivity() {
return (mPrivateFlags4 & PFLAG4_CONTENT_SENSITIVITY_MASK)
>> PFLAG4_CONTENT_SENSITIVITY_SHIFT;
}
diff --git a/core/java/android/view/WindowManager.java b/core/java/android/view/WindowManager.java
index 0f54940b..42bf420 100644
--- a/core/java/android/view/WindowManager.java
+++ b/core/java/android/view/WindowManager.java
@@ -2801,6 +2801,10 @@
* it from appearing in screenshots or from being viewed on non-secure
* displays.
*
+ * <p>See {@link android.view.View#setContentSensitivity(int)}, a window hosting
+ * a sensitive view will be marked as secure during media projection, preventing
+ * it from being viewed on non-secure displays and during screen share.
+ *
* <p>See {@link android.view.Display#FLAG_SECURE} for more details about
* secure surfaces and secure displays.
*/
diff --git a/core/java/android/window/BackEvent.java b/core/java/android/window/BackEvent.java
index 5562360..d3733b7 100644
--- a/core/java/android/window/BackEvent.java
+++ b/core/java/android/window/BackEvent.java
@@ -48,6 +48,12 @@
@SwipeEdge
private final int mSwipeEdge;
+ /** @hide */
+ public static BackEvent fromBackMotionEvent(BackMotionEvent backMotionEvent) {
+ return new BackEvent(backMotionEvent.getTouchX(), backMotionEvent.getTouchY(),
+ backMotionEvent.getProgress(), backMotionEvent.getSwipeEdge());
+ }
+
/**
* Creates a new {@link BackEvent} instance.
*
diff --git a/core/java/android/window/ImeOnBackInvokedDispatcher.java b/core/java/android/window/ImeOnBackInvokedDispatcher.java
index 3b9b162..2a12507 100644
--- a/core/java/android/window/ImeOnBackInvokedDispatcher.java
+++ b/core/java/android/window/ImeOnBackInvokedDispatcher.java
@@ -32,6 +32,7 @@
import com.android.internal.annotations.VisibleForTesting;
import java.util.ArrayList;
+import java.util.function.Consumer;
/**
* A {@link OnBackInvokedDispatcher} for IME that forwards {@link OnBackInvokedCallback}
@@ -52,17 +53,8 @@
static final String RESULT_KEY_PRIORITY = "priority";
static final int RESULT_CODE_REGISTER = 0;
static final int RESULT_CODE_UNREGISTER = 1;
- static final int RESULT_CODE_START_DISPATCHING = 2;
- static final int RESULT_CODE_STOP_DISPATCHING = 3;
@NonNull
private final ResultReceiver mResultReceiver;
- @NonNull
- private final BackProgressAnimator mProgressAnimator = new BackProgressAnimator();
- @NonNull
- private final BackTouchTracker mTouchTracker = new BackTouchTracker();
- // The handler to run callbacks on. This should be on the same thread
- // the ViewRootImpl holding IME's WindowOnBackInvokedDispatcher is created on.
- private Handler mHandler;
public ImeOnBackInvokedDispatcher(Handler handler) {
mResultReceiver = new ResultReceiver(handler) {
@@ -89,10 +81,6 @@
mResultReceiver = in.readTypedObject(ResultReceiver.CREATOR);
}
- void setHandler(@NonNull Handler handler) {
- mHandler = handler;
- }
-
@Override
public void registerOnBackInvokedCallback(
@OnBackInvokedDispatcher.Priority int priority,
@@ -103,14 +91,7 @@
// This is necessary because the callback is sent to and registered from
// the app process, which may treat the IME callback as weakly referenced. This will not
// cause a memory leak because the app side already clears the reference correctly.
- final IOnBackInvokedCallback iCallback =
- new ImeOnBackInvokedCallbackWrapper(
- callback,
- mTouchTracker,
- mProgressAnimator,
- this,
- mHandler != null ? mHandler : Handler.getMain(),
- false /* useWeakRef */);
+ final IOnBackInvokedCallback iCallback = new ImeOnBackInvokedCallbackWrapper(callback);
bundle.putBinder(RESULT_KEY_CALLBACK, iCallback.asBinder());
bundle.putInt(RESULT_KEY_PRIORITY, priority);
bundle.putInt(RESULT_KEY_ID, callback.hashCode());
@@ -135,12 +116,6 @@
dest.writeTypedObject(mResultReceiver, flags);
}
- /** Sets the progress thresholds for touch tracking */
- public void setProgressThresholds(float linearDistance, float maxDistance,
- float nonLinearFactor) {
- mTouchTracker.setProgressThresholds(linearDistance, maxDistance, nonLinearFactor);
- }
-
@NonNull
public static final Parcelable.Creator<ImeOnBackInvokedDispatcher> CREATOR =
new Parcelable.Creator<ImeOnBackInvokedDispatcher>() {
@@ -162,15 +137,10 @@
int priority = resultData.getInt(RESULT_KEY_PRIORITY);
final IOnBackInvokedCallback callback = IOnBackInvokedCallback.Stub.asInterface(
resultData.getBinder(RESULT_KEY_CALLBACK));
- registerReceivedCallback(
- callback, priority, callbackId, receivingDispatcher);
+ registerReceivedCallback(callback, priority, callbackId, receivingDispatcher);
} else if (resultCode == RESULT_CODE_UNREGISTER) {
final int callbackId = resultData.getInt(RESULT_KEY_ID);
unregisterReceivedCallback(callbackId, receivingDispatcher);
- } else if (resultCode == RESULT_CODE_START_DISPATCHING) {
- receiveStartDispatching(receivingDispatcher);
- } else if (resultCode == RESULT_CODE_STOP_DISPATCHING) {
- receiveStopDispatching(receivingDispatcher);
}
}
@@ -212,63 +182,6 @@
mImeCallbacks.remove(callback);
}
- static class ImeOnBackInvokedCallbackWrapper extends
- WindowOnBackInvokedDispatcher.OnBackInvokedCallbackWrapper {
- @NonNull
- private final ImeOnBackInvokedDispatcher mDispatcher;
-
- ImeOnBackInvokedCallbackWrapper(
- @NonNull OnBackInvokedCallback callback,
- @NonNull BackTouchTracker touchTracker,
- @NonNull BackProgressAnimator progressAnimator,
- @NonNull ImeOnBackInvokedDispatcher dispatcher,
- @NonNull Handler handler,
- boolean useWeakRef) {
- super(callback, touchTracker, progressAnimator, handler, useWeakRef);
- mDispatcher = dispatcher;
- }
-
- @Override
- public void onBackStarted(BackMotionEvent backEvent) {
- super.onBackStarted(backEvent);
- mDispatcher.sendStartDispatching();
- }
-
- @Override
- public void onBackCancelled() {
- super.onBackCancelled();
- mDispatcher.sendStopDispatching();
- }
-
- @Override
- public void onBackInvoked() throws RemoteException {
- super.onBackInvoked();
- mDispatcher.sendStopDispatching();
- }
- }
-
- /** Notifies the app process that we've stopped dispatching to an IME callback */
- private void sendStopDispatching() {
- mResultReceiver.send(RESULT_CODE_STOP_DISPATCHING, null /* unused bundle */);
- }
-
- /** Notifies the app process that we've started dispatching to an IME callback */
- private void sendStartDispatching() {
- mResultReceiver.send(RESULT_CODE_START_DISPATCHING, null /* unused bundle */);
- }
-
- /** Receives IME's message that dispatching has started. */
- private void receiveStopDispatching(
- @NonNull WindowOnBackInvokedDispatcher receivingDispatcher) {
- receivingDispatcher.onStopImeDispatching();
- }
-
- /** Receives IME's message that dispatching has stopped. */
- private void receiveStartDispatching(
- @NonNull WindowOnBackInvokedDispatcher receivingDispatcher) {
- receivingDispatcher.onStartImeDispatching();
- }
-
/** Clears all registered callbacks on the instance. */
public void clear() {
// Unregister previously registered callbacks if there's any.
@@ -278,14 +191,10 @@
}
}
mImeCallbacks.clear();
- // We should also stop running animations since all callbacks have been removed.
- // note: mSpring.skipToEnd(), in ProgressAnimator.reset(), requires the main handler.
- Handler.getMain().post(mProgressAnimator::reset);
- sendStopDispatching();
}
@VisibleForTesting(visibility = PACKAGE)
- public static class ImeOnBackInvokedCallback implements OnBackInvokedCallback {
+ public static class ImeOnBackInvokedCallback implements OnBackAnimationCallback {
@NonNull
private final IOnBackInvokedCallback mIOnBackInvokedCallback;
/**
@@ -303,11 +212,42 @@
}
@Override
+ public void onBackStarted(@NonNull BackEvent backEvent) {
+ try {
+ mIOnBackInvokedCallback.onBackStarted(
+ new BackMotionEvent(backEvent.getTouchX(), backEvent.getTouchY(),
+ backEvent.getProgress(), 0f, 0f, false, backEvent.getSwipeEdge(),
+ null));
+ } catch (RemoteException e) {
+ Log.e(TAG, "Exception when invoking forwarded callback. e: ", e);
+ }
+ }
+
+ @Override
+ public void onBackProgressed(@NonNull BackEvent backEvent) {
+ try {
+ mIOnBackInvokedCallback.onBackProgressed(
+ new BackMotionEvent(backEvent.getTouchX(), backEvent.getTouchY(),
+ backEvent.getProgress(), 0f, 0f, false, backEvent.getSwipeEdge(),
+ null));
+ } catch (RemoteException e) {
+ Log.e(TAG, "Exception when invoking forwarded callback. e: ", e);
+ }
+ }
+
+ @Override
public void onBackInvoked() {
try {
- if (mIOnBackInvokedCallback != null) {
- mIOnBackInvokedCallback.onBackInvoked();
- }
+ mIOnBackInvokedCallback.onBackInvoked();
+ } catch (RemoteException e) {
+ Log.e(TAG, "Exception when invoking forwarded callback. e: ", e);
+ }
+ }
+
+ @Override
+ public void onBackCancelled() {
+ try {
+ mIOnBackInvokedCallback.onBackCancelled();
} catch (RemoteException e) {
Log.e(TAG, "Exception when invoking forwarded callback. e: ", e);
}
@@ -317,10 +257,6 @@
return mId;
}
- IOnBackInvokedCallback getIOnBackInvokedCallback() {
- return mIOnBackInvokedCallback;
- }
-
@Override
public String toString() {
return "ImeCallback=ImeOnBackInvokedCallback@" + mId
@@ -358,4 +294,50 @@
}
}
}
+
+ /**
+ * Wrapper class that wraps an OnBackInvokedCallback. This is used when a callback is sent from
+ * the IME process to the app process.
+ */
+ private class ImeOnBackInvokedCallbackWrapper extends IOnBackInvokedCallback.Stub {
+
+ private final OnBackInvokedCallback mCallback;
+
+ ImeOnBackInvokedCallbackWrapper(@NonNull OnBackInvokedCallback callback) {
+ mCallback = callback;
+ }
+
+ @Override
+ public void onBackStarted(BackMotionEvent backMotionEvent) {
+ maybeRunOnAnimationCallback((animationCallback) -> animationCallback.onBackStarted(
+ BackEvent.fromBackMotionEvent(backMotionEvent)));
+ }
+
+ @Override
+ public void onBackProgressed(BackMotionEvent backMotionEvent) {
+ maybeRunOnAnimationCallback((animationCallback) -> animationCallback.onBackProgressed(
+ BackEvent.fromBackMotionEvent(backMotionEvent)));
+ }
+
+ @Override
+ public void onBackCancelled() {
+ maybeRunOnAnimationCallback(OnBackAnimationCallback::onBackCancelled);
+ }
+
+ @Override
+ public void onBackInvoked() {
+ mCallback.onBackInvoked();
+ }
+
+ @Override
+ public void setTriggerBack(boolean triggerBack) {
+ // no-op
+ }
+
+ private void maybeRunOnAnimationCallback(Consumer<OnBackAnimationCallback> block) {
+ if (mCallback instanceof OnBackAnimationCallback) {
+ block.accept((OnBackAnimationCallback) mCallback);
+ }
+ }
+ }
}
diff --git a/core/java/android/window/TransitionInfo.java b/core/java/android/window/TransitionInfo.java
index 4ffd880..8a79754 100644
--- a/core/java/android/window/TransitionInfo.java
+++ b/core/java/android/window/TransitionInfo.java
@@ -39,6 +39,7 @@
import static android.view.WindowManager.TransitionType;
import static android.view.WindowManager.transitTypeToString;
+import android.annotation.AnimRes;
import android.annotation.ColorInt;
import android.annotation.IntDef;
import android.annotation.NonNull;
@@ -54,6 +55,8 @@
import android.view.SurfaceControl;
import android.view.WindowManager;
+import com.android.window.flags.Flags;
+
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.util.ArrayList;
@@ -211,6 +214,8 @@
private final ArrayList<Change> mChanges = new ArrayList<>();
private final ArrayList<Root> mRoots = new ArrayList<>();
+ // TODO(b/327332488): Clean-up usages after the flag is fully enabled.
+ @Deprecated
private AnimationOptions mOptions;
/** This is only a BEST-EFFORT id used for log correlation. DO NOT USE for any real work! */
@@ -275,7 +280,15 @@
mRoots.add(other);
}
+ /**
+ * @deprecated Set {@link AnimationOptions} to change. This method is only used if
+ * {@link Flags#FLAG_MOVE_ANIMATION_OPTIONS_TO_CHANGE} is disabled.
+ */
+ @Deprecated
public void setAnimationOptions(@Nullable AnimationOptions options) {
+ if (Flags.moveAnimationOptionsToChange()) {
+ return;
+ }
mOptions = options;
}
@@ -340,6 +353,11 @@
return mRoots.get(0).mLeash;
}
+ /**
+ * @deprecated Use {@link Change#getAnimationOptions()} instead. This method is called only
+ * if {@link Flags#FLAG_MOVE_ANIMATION_OPTIONS_TO_CHANGE} is disabled.
+ */
+ @Deprecated
@Nullable
public AnimationOptions getAnimationOptions() {
return mOptions;
@@ -661,6 +679,7 @@
private SurfaceControl mSnapshot = null;
private float mSnapshotLuma;
private ComponentName mActivityComponent = null;
+ private AnimationOptions mAnimationOptions = null;
public Change(@Nullable WindowContainerToken container, @NonNull SurfaceControl leash) {
mContainer = container;
@@ -690,6 +709,7 @@
mSnapshot = in.readTypedObject(SurfaceControl.CREATOR);
mSnapshotLuma = in.readFloat();
mActivityComponent = in.readTypedObject(ComponentName.CREATOR);
+ mAnimationOptions = in.readTypedObject(AnimationOptions.CREATOR);
}
private Change localRemoteCopy() {
@@ -713,6 +733,7 @@
out.mSnapshot = mSnapshot != null ? new SurfaceControl(mSnapshot, "localRemote") : null;
out.mSnapshotLuma = mSnapshotLuma;
out.mActivityComponent = mActivityComponent;
+ out.mAnimationOptions = mAnimationOptions;
return out;
}
@@ -813,6 +834,16 @@
mActivityComponent = component;
}
+ /**
+ * Sets {@link AnimationOptions} to override animation.
+ */
+ public void setAnimationOptions(@Nullable AnimationOptions options) {
+ if (!Flags.moveAnimationOptionsToChange()) {
+ return;
+ }
+ mAnimationOptions = options;
+ }
+
/** @return the container that is changing. May be null if non-remotable (eg. activity) */
@Nullable
public WindowContainerToken getContainer() {
@@ -952,6 +983,14 @@
return mActivityComponent;
}
+ /**
+ * Returns the {@link AnimationOptions}.
+ */
+ @Nullable
+ public AnimationOptions getAnimationOptions() {
+ return mAnimationOptions;
+ }
+
/** @hide */
@Override
public void writeToParcel(@NonNull Parcel dest, int flags) {
@@ -976,6 +1015,7 @@
dest.writeTypedObject(mSnapshot, flags);
dest.writeFloat(mSnapshotLuma);
dest.writeTypedObject(mActivityComponent, flags);
+ dest.writeTypedObject(mAnimationOptions, flags);
}
@NonNull
@@ -1028,6 +1068,9 @@
if (mEndFixedRotation != ROTATION_UNDEFINED) {
sb.append(" endFixedRotation="); sb.append(mEndFixedRotation);
}
+ if (mBackgroundColor != 0) {
+ sb.append(" bc=").append(Integer.toHexString(mBackgroundColor));
+ }
if (mSnapshot != null) {
sb.append(" snapshot="); sb.append(mSnapshot);
}
@@ -1042,6 +1085,9 @@
sb.append(" taskParent=");
sb.append(mTaskInfo.parentTaskId);
}
+ if (mAnimationOptions != null) {
+ sb.append(" opt=").append(mAnimationOptions);
+ }
sb.append('}');
return sb.toString();
}
@@ -1051,14 +1097,23 @@
@SuppressWarnings("UserHandleName")
public static final class AnimationOptions implements Parcelable {
+ /**
+ * The default value for animation resources ID, which means to use the system default
+ * animation.
+ */
+ @SuppressWarnings("ResourceType") // Use as a hint to use the system default animation.
+ @AnimRes
+ public static final int DEFAULT_ANIMATION_RESOURCES_ID = 0xFFFFFFFF;
+
private int mType;
- private int mEnterResId;
- private int mExitResId;
+ private @AnimRes int mEnterResId = DEFAULT_ANIMATION_RESOURCES_ID;
+ private @AnimRes int mExitResId = DEFAULT_ANIMATION_RESOURCES_ID;
private boolean mOverrideTaskTransition;
private String mPackageName;
private final Rect mTransitionBounds = new Rect();
private HardwareBuffer mThumbnail;
private int mAnimations;
+ // TODO(b/295805497): Extract it from AnimationOptions
private @ColorInt int mBackgroundColor;
// Customize activity transition animation
private CustomActivityTransition mCustomActivityOpenTransition;
@@ -1121,10 +1176,18 @@
customTransition.addCustomActivityTransition(enterResId, exitResId, backgroundColor);
}
- /** Make options for a custom animation based on anim resources */
+ /**
+ * Make options for a custom animation based on anim resources.
+ *
+ * @param packageName the package name to find the animation resources
+ * @param enterResId the open animation resources ID
+ * @param exitResId the close animation resources ID
+ * @param backgroundColor the background color
+ * @param overrideTaskTransition whether to override the task transition
+ */
@NonNull
public static AnimationOptions makeCustomAnimOptions(@NonNull String packageName,
- int enterResId, int exitResId, @ColorInt int backgroundColor,
+ @AnimRes int enterResId, @AnimRes int exitResId, @ColorInt int backgroundColor,
boolean overrideTaskTransition) {
AnimationOptions options = new AnimationOptions(ANIM_CUSTOM);
options.mPackageName = packageName;
@@ -1182,10 +1245,12 @@
return mType;
}
+ @AnimRes
public int getEnterResId() {
return mEnterResId;
}
+ @AnimRes
public int getExitResId() {
return mExitResId;
}
@@ -1284,6 +1349,12 @@
if (!mTransitionBounds.isEmpty()) {
sb.append(" bounds=").append(mTransitionBounds);
}
+ if (mEnterResId != DEFAULT_ANIMATION_RESOURCES_ID) {
+ sb.append(" enterResId=").append(mEnterResId);
+ }
+ if (mExitResId != DEFAULT_ANIMATION_RESOURCES_ID) {
+ sb.append(" exitResId=").append(mExitResId);
+ }
sb.append('}');
return sb.toString();
}
diff --git a/core/java/android/window/WindowOnBackInvokedDispatcher.java b/core/java/android/window/WindowOnBackInvokedDispatcher.java
index b9c8839..0ff52f1 100644
--- a/core/java/android/window/WindowOnBackInvokedDispatcher.java
+++ b/core/java/android/window/WindowOnBackInvokedDispatcher.java
@@ -105,7 +105,6 @@
// The threshold for back swipe full progress.
private float mBackSwipeLinearThreshold;
private float mNonLinearProgressFactor;
- private boolean mImeDispatchingActive;
public WindowOnBackInvokedDispatcher(@NonNull Context context, Looper looper) {
mChecker = new Checker(context);
@@ -176,18 +175,19 @@
mImeDispatcher.registerOnBackInvokedCallback(priority, callback);
return;
}
- if ((callback instanceof ImeOnBackInvokedDispatcher.DefaultImeOnBackAnimationCallback
- || callback instanceof ImeOnBackInvokedDispatcher.ImeOnBackInvokedCallback)
- && !isOnBackInvokedCallbackEnabled()) {
+ if (callback instanceof ImeOnBackInvokedDispatcher.ImeOnBackInvokedCallback) {
// Fall back to compat back key injection if legacy back behaviour should be used.
- return;
+ if (!isOnBackInvokedCallbackEnabled()) return;
+ if (callback instanceof ImeOnBackInvokedDispatcher.DefaultImeOnBackAnimationCallback
+ && mImeBackAnimationController != null) {
+ // register ImeBackAnimationController instead to play predictive back animation
+ callback = mImeBackAnimationController;
+ }
}
+
if (!mOnBackInvokedCallbacks.containsKey(priority)) {
mOnBackInvokedCallbacks.put(priority, new ArrayList<>());
}
- if (callback instanceof ImeOnBackInvokedDispatcher.DefaultImeOnBackAnimationCallback) {
- callback = mImeBackAnimationController;
- }
ArrayList<OnBackInvokedCallback> callbacks = mOnBackInvokedCallbacks.get(priority);
// If callback has already been added, remove it and re-add it.
@@ -250,7 +250,7 @@
*/
public boolean isBackGestureInProgress() {
synchronized (mLock) {
- return mTouchTracker.isActive() || mImeDispatchingActive;
+ return mTouchTracker.isActive();
}
}
@@ -308,16 +308,8 @@
OnBackInvokedCallbackInfo callbackInfo = null;
if (callback != null) {
int priority = mAllCallbacks.get(callback);
- final IOnBackInvokedCallback iCallback =
- callback instanceof ImeOnBackInvokedDispatcher
- .ImeOnBackInvokedCallback
- ? ((ImeOnBackInvokedDispatcher.ImeOnBackInvokedCallback)
- callback).getIOnBackInvokedCallback()
- : new OnBackInvokedCallbackWrapper(
- callback,
- mTouchTracker,
- mProgressAnimator,
- mHandler);
+ final IOnBackInvokedCallback iCallback = new OnBackInvokedCallbackWrapper(
+ callback, mTouchTracker, mProgressAnimator, mHandler);
callbackInfo = new OnBackInvokedCallbackInfo(
iCallback,
priority,
@@ -367,10 +359,6 @@
float linearDistance = Math.min(maxDistance, mBackSwipeLinearThreshold);
mTouchTracker.setProgressThresholds(
linearDistance, maxDistance, mNonLinearProgressFactor);
- if (mImeDispatcher != null) {
- mImeDispatcher.setProgressThresholds(
- linearDistance, maxDistance, mNonLinearProgressFactor);
- }
}
/**
@@ -402,46 +390,9 @@
}
}
- /**
- * Called when we start dispatching to a callback registered from IME.
- */
- public void onStartImeDispatching() {
- synchronized (mLock) {
- mImeDispatchingActive = true;
- }
- }
-
- /**
- * Called when we stop dispatching to a callback registered from IME.
- */
- public void onStopImeDispatching() {
- synchronized (mLock) {
- mImeDispatchingActive = false;
- }
- }
-
- static class OnBackInvokedCallbackWrapper extends IOnBackInvokedCallback.Stub {
- static class CallbackRef {
- final WeakReference<OnBackInvokedCallback> mWeakRef;
- final OnBackInvokedCallback mStrongRef;
- CallbackRef(@NonNull OnBackInvokedCallback callback, boolean useWeakRef) {
- if (useWeakRef) {
- mWeakRef = new WeakReference<>(callback);
- mStrongRef = null;
- } else {
- mStrongRef = callback;
- mWeakRef = null;
- }
- }
-
- OnBackInvokedCallback get() {
- if (mStrongRef != null) {
- return mStrongRef;
- }
- return mWeakRef.get();
- }
- }
- final CallbackRef mCallbackRef;
+ private static class OnBackInvokedCallbackWrapper extends IOnBackInvokedCallback.Stub {
+ @NonNull
+ private final WeakReference<OnBackInvokedCallback> mCallback;
@NonNull
private final BackProgressAnimator mProgressAnimator;
@NonNull
@@ -454,19 +405,7 @@
@NonNull BackTouchTracker touchTracker,
@NonNull BackProgressAnimator progressAnimator,
@NonNull Handler handler) {
- mCallbackRef = new CallbackRef(callback, true /* useWeakRef */);
- mTouchTracker = touchTracker;
- mProgressAnimator = progressAnimator;
- mHandler = handler;
- }
-
- OnBackInvokedCallbackWrapper(
- @NonNull OnBackInvokedCallback callback,
- @NonNull BackTouchTracker touchTracker,
- @NonNull BackProgressAnimator progressAnimator,
- @NonNull Handler handler,
- boolean useWeakRef) {
- mCallbackRef = new CallbackRef(callback, useWeakRef);
+ mCallback = new WeakReference<>(callback);
mTouchTracker = touchTracker;
mProgressAnimator = progressAnimator;
mHandler = handler;
@@ -489,11 +428,7 @@
backEvent.getTouchX(), backEvent.getTouchY(), backEvent.getSwipeEdge());
if (callback != null) {
- callback.onBackStarted(new BackEvent(
- backEvent.getTouchX(),
- backEvent.getTouchY(),
- backEvent.getProgress(),
- backEvent.getSwipeEdge()));
+ callback.onBackStarted(BackEvent.fromBackMotionEvent(backEvent));
mProgressAnimator.onBackStarted(backEvent, callback::onBackProgressed);
}
});
@@ -519,7 +454,7 @@
boolean isInProgress = mProgressAnimator.isBackAnimationInProgress();
mProgressAnimator.reset();
// TODO(b/333957271): Re-introduce auto fling progress generation.
- final OnBackInvokedCallback callback = mCallbackRef.get();
+ final OnBackInvokedCallback callback = mCallback.get();
if (callback == null) {
Log.d(TAG, "Trying to call onBackInvoked() on a null callback reference.");
return;
@@ -539,7 +474,7 @@
@Nullable
private OnBackAnimationCallback getBackAnimationCallback() {
- OnBackInvokedCallback callback = mCallbackRef.get();
+ OnBackInvokedCallback callback = mCallback.get();
return callback instanceof OnBackAnimationCallback ? (OnBackAnimationCallback) callback
: null;
}
@@ -569,11 +504,6 @@
public void setImeOnBackInvokedDispatcher(
@NonNull ImeOnBackInvokedDispatcher imeDispatcher) {
mImeDispatcher = imeDispatcher;
- mImeDispatcher.setHandler(mHandler);
- mImeDispatcher.setProgressThresholds(
- mTouchTracker.getLinearDistance(),
- mTouchTracker.getMaxDistance(),
- mTouchTracker.getNonLinearFactor());
}
/** Returns true if a non-null {@link ImeOnBackInvokedDispatcher} has been set. **/
diff --git a/core/java/com/android/internal/compat/ChangeReporter.java b/core/java/com/android/internal/compat/ChangeReporter.java
index d8f1309..ded142c 100644
--- a/core/java/com/android/internal/compat/ChangeReporter.java
+++ b/core/java/com/android/internal/compat/ChangeReporter.java
@@ -98,7 +98,7 @@
public void reportChange(int uid, long changeId, int state, boolean isLoggableBySdk) {
boolean isAlreadyReported =
checkAndSetIsAlreadyReported(uid, new ChangeReport(changeId, state));
- if (shouldWriteToStatsLog(isAlreadyReported)) {
+ if (!isAlreadyReported) {
FrameworkStatsLog.write(FrameworkStatsLog.APP_COMPATIBILITY_CHANGE_REPORTED, uid,
changeId, state, mSource);
}
@@ -136,16 +136,14 @@
/**
* Returns whether the next report should be logged to FrameworkStatsLog.
*
- * @param isAlreadyReported is the change already reported
+ * @param uid affected by the change
+ * @param changeId the reported change id
+ * @param state of the reported change - enabled/disabled/only logged
* @return true if the report should be logged
*/
@VisibleForTesting
- boolean shouldWriteToStatsLog(boolean isAlreadyReported) {
- // We don't log for system server
- if (mSource == SOURCE_SYSTEM_SERVER) return false;
-
- // Don't log if already reported
- return !isAlreadyReported;
+ boolean shouldWriteToStatsLog(int uid, long changeId, int state) {
+ return !isAlreadyReported(uid, new ChangeReport(changeId, state));
}
/**
@@ -162,6 +160,8 @@
boolean isAlreadyReported, int state, boolean isLoggableBySdk) {
// If log all bit is on, always return true.
if (mDebugLogAll) return true;
+ // If the change has already been reported, do not write.
+ if (isAlreadyReported) return false;
// If the flag is turned off or the TAG's logging is forced to debug level with
// `adb setprop log.tag.CompatChangeReporter=DEBUG`, write to debug since the above checks
@@ -224,19 +224,6 @@
return mReportedChanges.getOrDefault(uid, EMPTY_SET).contains(report);
}
- /**
- * Returns whether the next report should be logged.
- *
- * @param uid affected by the change
- * @param changeId the reported change id
- * @param state of the reported change - enabled/disabled/only logged
- * @return true if the report should be logged
- */
- @VisibleForTesting
- boolean isAlreadyReported(int uid, long changeId, int state) {
- return isAlreadyReported(uid, new ChangeReport(changeId, state));
- }
-
private void markAsReported(int uid, ChangeReport report) {
mReportedChanges.computeIfAbsent(uid, NEW_CHANGE_REPORT_SET).add(report);
}
diff --git a/core/java/com/android/internal/graphics/ColorUtils.java b/core/java/com/android/internal/graphics/ColorUtils.java
index dff9551..f72a5ca 100644
--- a/core/java/com/android/internal/graphics/ColorUtils.java
+++ b/core/java/com/android/internal/graphics/ColorUtils.java
@@ -392,7 +392,7 @@
* Convert RGB components to its CIE Lab representative components.
*
* <ul>
- * <li>outLab[0] is L [0 ...1)</li>
+ * <li>outLab[0] is L [0 ...100)</li>
* <li>outLab[1] is a [-128...127)</li>
* <li>outLab[2] is b [-128...127)</li>
* </ul>
@@ -474,7 +474,7 @@
* 2° Standard Observer (1931).</p>
*
* <ul>
- * <li>outLab[0] is L [0 ...1)</li>
+ * <li>outLab[0] is L [0 ...100)</li>
* <li>outLab[1] is a [-128...127)</li>
* <li>outLab[2] is b [-128...127)</li>
* </ul>
diff --git a/core/java/com/android/internal/os/TimeoutRecord.java b/core/java/com/android/internal/os/TimeoutRecord.java
index 1f4abc1..e9a8d4b 100644
--- a/core/java/com/android/internal/os/TimeoutRecord.java
+++ b/core/java/com/android/internal/os/TimeoutRecord.java
@@ -45,7 +45,6 @@
TimeoutKind.APP_REGISTERED,
TimeoutKind.SHORT_FGS_TIMEOUT,
TimeoutKind.JOB_SERVICE,
- TimeoutKind.FGS_TIMEOUT,
})
@Retention(RetentionPolicy.SOURCE)
@@ -60,7 +59,6 @@
int SHORT_FGS_TIMEOUT = 8;
int JOB_SERVICE = 9;
int APP_START = 10;
- int FGS_TIMEOUT = 11;
}
/** Kind of timeout, e.g. BROADCAST_RECEIVER, etc. */
@@ -188,12 +186,6 @@
return TimeoutRecord.endingNow(TimeoutKind.SHORT_FGS_TIMEOUT, reason);
}
- /** Record for a "foreground service" timeout. */
- @NonNull
- public static TimeoutRecord forFgsTimeout(String reason) {
- return TimeoutRecord.endingNow(TimeoutKind.FGS_TIMEOUT, reason);
- }
-
/** Record for a job related timeout. */
@NonNull
public static TimeoutRecord forJobService(String reason) {
diff --git a/core/java/com/android/internal/os/anr/AnrLatencyTracker.java b/core/java/com/android/internal/os/anr/AnrLatencyTracker.java
index e11067d..f62ff38 100644
--- a/core/java/com/android/internal/os/anr/AnrLatencyTracker.java
+++ b/core/java/com/android/internal/os/anr/AnrLatencyTracker.java
@@ -22,7 +22,6 @@
import static com.android.internal.util.FrameworkStatsLog.ANRLATENCY_REPORTED__ANR_TYPE__BROADCAST_OF_INTENT;
import static com.android.internal.util.FrameworkStatsLog.ANRLATENCY_REPORTED__ANR_TYPE__CONTENT_PROVIDER_NOT_RESPONDING;
import static com.android.internal.util.FrameworkStatsLog.ANRLATENCY_REPORTED__ANR_TYPE__EXECUTING_SERVICE;
-import static com.android.internal.util.FrameworkStatsLog.ANRLATENCY_REPORTED__ANR_TYPE__FGS_TIMEOUT;
import static com.android.internal.util.FrameworkStatsLog.ANRLATENCY_REPORTED__ANR_TYPE__INPUT_DISPATCHING_TIMEOUT;
import static com.android.internal.util.FrameworkStatsLog.ANRLATENCY_REPORTED__ANR_TYPE__INPUT_DISPATCHING_TIMEOUT_NO_FOCUSED_WINDOW;
import static com.android.internal.util.FrameworkStatsLog.ANRLATENCY_REPORTED__ANR_TYPE__JOB_SERVICE;
@@ -549,8 +548,6 @@
return ANRLATENCY_REPORTED__ANR_TYPE__SHORT_FGS_TIMEOUT;
case TimeoutKind.JOB_SERVICE:
return ANRLATENCY_REPORTED__ANR_TYPE__JOB_SERVICE;
- case TimeoutKind.FGS_TIMEOUT:
- return ANRLATENCY_REPORTED__ANR_TYPE__FGS_TIMEOUT;
default:
return ANRLATENCY_REPORTED__ANR_TYPE__UNKNOWN_ANR_TYPE;
}
diff --git a/core/res/res/drawable-car/car_activity_resolver_list_background.xml b/core/res/res/drawable-car/car_activity_resolver_list_background.xml
new file mode 100644
index 0000000..dbbadd8
--- /dev/null
+++ b/core/res/res/drawable-car/car_activity_resolver_list_background.xml
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- 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.
+-->
+<shape xmlns:android="http://schemas.android.com/apk/res/android"
+ android:shape="rectangle">
+ <solid android:color="?attr/colorBackgroundFloating" />
+ <corners android:radius="@dimen/car_activity_resolver_corner_radius" />
+</shape>
\ No newline at end of file
diff --git a/core/res/res/layout-car/car_resolver_list.xml b/core/res/res/layout-car/car_resolver_list.xml
index 755cbfe..08c9861 100644
--- a/core/res/res/layout-car/car_resolver_list.xml
+++ b/core/res/res/layout-car/car_resolver_list.xml
@@ -18,91 +18,43 @@
-->
<com.android.internal.widget.ResolverDrawerLayout
xmlns:android="http://schemas.android.com/apk/res/android"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
+ android:layout_width="@dimen/car_activity_resolver_width"
+ android:layout_height="wrap_content"
+ android:layout_gravity="center"
android:id="@id/contentPanel">
<LinearLayout
android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:weightSum="5"
- android:layout_alwaysShow="true"
+ android:layout_height="wrap_content"
android:orientation="vertical"
- android:background="?attr/colorBackgroundFloating"
- android:elevation="8dp">
+ android:background="@drawable/car_activity_resolver_list_background">
<LinearLayout
- android:id="@+id/button_bar"
- android:visibility="gone"
- style="?attr/buttonBarStyle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
- android:layout_ignoreOffset="true"
- android:layout_alwaysShow="true"
- android:layout_hasNestedScrollIndicator="true"
- android:background="?attr/colorBackgroundFloating"
+ android:background="@drawable/car_activity_resolver_list_background"
android:orientation="horizontal"
- android:paddingTop="8dp"
- android:paddingStart="12dp"
- android:weightSum="4"
- android:paddingEnd="12dp"
- android:elevation="8dp">
-
+ android:paddingVertical="@dimen/car_padding_4"
+ android:paddingHorizontal="@dimen/car_padding_4" >
<TextView
android:id="@+id/profile_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
- android:layout_marginEnd="8dp"
- android:paddingStart="8dp"
- android:paddingEnd="8dp"
- android:textSize="40sp"
- android:layout_weight="4"
- android:layout_gravity="left"
- android:visibility="gone"
- android:textColor="?attr/colorAccent"
- android:singleLine="true"/>
+ android:visibility="gone" />
<TextView
android:id="@+id/title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
- android:layout_gravity="left"
- android:layout_weight="3"
- android:paddingTop="8dp"
- android:layout_below="@id/profile_button"
- android:textAppearance="?android:attr/textAppearanceLarge"
- android:paddingBottom="8dp"/>
-
- <Button
- android:id="@+id/button_once"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:enabled="false"
- android:layout_gravity="right"
- style="?attr/buttonBarButtonStyle"
- android:text="@string/activity_resolver_use_once"
- android:layout_weight="0.5"
- android:onClick="onButtonClick"/>
-
- <Button
- android:id="@+id/button_always"
- android:layout_marginLeft="2dp"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:enabled="false"
- android:layout_gravity="right"
- style="?attr/buttonBarButtonStyle"
- android:text="@string/activity_resolver_use_always"
- android:layout_weight="0.5"
- android:onClick="onButtonClick"/>
+ android:layout_gravity="start"
+ android:textAppearance="@android:style/TextAppearance.DeviceDefault.DialogWindowTitle" />
</LinearLayout>
<FrameLayout
android:id="@+id/stub"
android:visibility="gone"
android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:background="?attr/colorBackgroundFloating"/>
+ android:layout_height="wrap_content"/>
<TabHost
android:id="@+id/profile_tabhost"
@@ -110,25 +62,22 @@
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
- android:background="?attr/colorBackgroundFloating">
+ android:background="?android:attr/colorBackgroundFloating">
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TabWidget
android:id="@android:id/tabs"
+ android:visibility="gone"
android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:visibility="gone">
+ android:layout_height="wrap_content">
</TabWidget>
<View
android:id="@+id/resolver_tab_divider"
android:visibility="gone"
android:layout_width="match_parent"
- android:layout_height="1dp"
- android:background="?attr/colorBackgroundFloating"
- android:foreground="?attr/dividerVertical"
- android:layout_marginBottom="8dp"/>
+ android:layout_height="wrap_content" />
<FrameLayout
android:id="@android:id/tabcontent"
android:layout_width="match_parent"
@@ -141,24 +90,38 @@
</LinearLayout>
</TabHost>
- <View
- android:layout_alwaysShow="true"
+ <LinearLayout
+ android:id="@+id/button_bar"
+ android:visibility="gone"
android:layout_width="match_parent"
- android:layout_height="1dp"
- android:background="?attr/colorBackgroundFloating"
- android:foreground="?attr/dividerVertical"/>
+ android:layout_height="wrap_content"
+ android:layout_marginVertical="@dimen/car_padding_4"
+ android:layout_marginHorizontal="@dimen/car_padding_4"
+ android:padding="0dp"
+ android:gravity="center"
+ android:background="@drawable/car_activity_resolver_list_background"
+ android:orientation="vertical">
- <TextView android:id="@+id/empty"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:background="?attr/colorBackgroundFloating"
- android:elevation="8dp"
- android:layout_alwaysShow="true"
- android:text="@string/noApplications"
- android:padding="32dp"
- android:gravity="center"
- android:visibility="gone"/>
+ <Button
+ android:id="@+id/button_once"
+ android:layout_width="match_parent"
+ android:layout_height="@dimen/car_button_height"
+ android:enabled="false"
+ android:layout_gravity="center"
+ android:layout_marginBottom="@dimen/car_padding_2"
+ android:text="@string/activity_resolver_use_once"
+ android:onClick="onButtonClick"/>
+
+ <Button
+ android:id="@+id/button_always"
+ android:layout_width="match_parent"
+ android:layout_height="@dimen/car_button_height"
+ android:enabled="false"
+ android:layout_gravity="center"
+ android:text="@string/activity_resolver_use_always"
+ android:onClick="onButtonClick"/>
+ </LinearLayout>
</LinearLayout>
-</com.android.internal.widget.ResolverDrawerLayout>
+</com.android.internal.widget.ResolverDrawerLayout>
\ No newline at end of file
diff --git a/core/res/res/layout-car/car_resolver_list_with_default.xml b/core/res/res/layout-car/car_resolver_list_with_default.xml
index 5e450b2..08cc7ff 100644
--- a/core/res/res/layout-car/car_resolver_list_with_default.xml
+++ b/core/res/res/layout-car/car_resolver_list_with_default.xml
@@ -18,138 +18,78 @@
-->
<com.android.internal.widget.ResolverDrawerLayout
xmlns:android="http://schemas.android.com/apk/res/android"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:maxCollapsedHeight="200dp"
+ android:layout_width="@dimen/car_activity_resolver_width"
+ android:layout_height="wrap_content"
+ android:layout_gravity="center"
android:id="@id/contentPanel">
<LinearLayout
android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:weightSum="5"
- android:layout_alwaysShow="true"
+ android:layout_height="wrap_content"
android:orientation="vertical"
- android:background="?attr/colorBackgroundFloating"
- android:elevation="8dp">
+ android:layout_gravity="center"
+ android:background="@drawable/car_activity_resolver_list_background">
+
+ <FrameLayout
+ android:id="@+id/stub"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:background="@drawable/car_activity_resolver_list_background"/>
+
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
- android:layout_weight="0.5"
+ android:minHeight="@dimen/car_activity_resolver_list_item_height"
android:orientation="horizontal">
+ <RadioButton
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:focusable="false"
+ android:clickable="false"
+ android:layout_marginStart="?attr/listPreferredItemPaddingStart"
+ android:layout_gravity="start|center_vertical"
+ android:checked="true"/>
+
<ImageView
android:id="@+id/icon"
- android:layout_width="60dp"
- android:layout_height="60dp"
- android:layout_gravity="start|top"
- android:layout_marginStart="10dp"
- android:layout_marginEnd="5dp"
- android:layout_marginTop="10dp"
+ android:layout_width="@dimen/car_icon_size"
+ android:layout_height="@dimen/car_icon_size"
+ android:layout_gravity="start|center_vertical"
+ android:layout_marginStart="@dimen/car_padding_4"
android:src="@drawable/resolver_icon_placeholder"
android:scaleType="fitCenter"/>
<TextView
android:id="@+id/title"
- android:layout_width="0dp"
- android:layout_weight="1"
- android:layout_height="?attr/listPreferredItemHeight"
- android:layout_marginStart="16dp"
- android:textAppearance="?android:attr/textAppearanceLarge"
- android:gravity="start|center_vertical"
- android:paddingEnd="16dp"/>
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_marginHorizontal="?attr/listPreferredItemPaddingStart"
+ style="?android:attr/textAppearanceListItem"
+ android:layout_gravity="start|center_vertical" />
<LinearLayout
android:id="@+id/profile_button"
- android:layout_width="wrap_content"
- android:layout_height="48dp"
- android:layout_marginTop="4dp"
- android:layout_marginEnd="4dp"
- android:paddingStart="8dp"
- android:paddingEnd="8dp"
- android:paddingTop="4dp"
- android:paddingBottom="4dp"
- android:focusable="true"
android:visibility="gone"
- style="?attr/borderlessButtonStyle">
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content">
<ImageView
android:id="@+id/icon"
- android:layout_width="24dp"
- android:layout_height="24dp"
- android:layout_gravity="start|center_vertical"
- android:layout_marginEnd="?attr/listPreferredItemPaddingEnd"
- android:layout_marginTop="12dp"
- android:layout_marginBottom="12dp"
- android:scaleType="fitCenter"/>
+ android:visibility="gone"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content" />
<TextView
android:id="@id/text1"
+ android:visibility="gone"
android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_gravity="start|center_vertical"
- android:layout_marginEnd="?attr/listPreferredItemPaddingEnd"
- android:textAppearance="?attr/textAppearanceButton"
- android:textColor="?attr/textColorPrimary"
- android:minLines="1"
- android:maxLines="1"
- android:ellipsize="marquee"/>
+ android:layout_height="wrap_content" />
</LinearLayout>
</LinearLayout>
- <LinearLayout
- android:id="@+id/button_bar"
- android:visibility="gone"
- style="?attr/buttonBarStyle"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:layout_alwaysShow="true"
- android:gravity="end|center_vertical"
- android:layout_weight="0.5"
- android:orientation="horizontal"
- android:layoutDirection="locale"
- android:measureWithLargestChild="true"
- android:paddingTop="8dp"
- android:paddingBottom="8dp"
- android:paddingStart="12dp"
- android:paddingEnd="12dp"
- android:elevation="8dp">
-
- <Button
- android:id="@+id/button_once"
- android:layout_width="wrap_content"
- android:layout_gravity="start"
- android:maxLines="2"
- style="?attr/buttonBarButtonStyle"
- android:minHeight="@dimen/alert_dialog_button_bar_height"
- android:layout_height="wrap_content"
- android:enabled="false"
- android:text="@string/activity_resolver_use_once"
- android:onClick="onButtonClick"/>
-
- <Button
- android:id="@+id/button_always"
- android:layout_width="wrap_content"
- android:layout_gravity="end"
- android:maxLines="2"
- android:minHeight="@dimen/alert_dialog_button_bar_height"
- style="?attr/buttonBarButtonStyle"
- android:layout_height="wrap_content"
- android:enabled="false"
- android:text="@string/activity_resolver_use_always"
- android:onClick="onButtonClick"/>
- </LinearLayout>
-
- <FrameLayout
- android:id="@+id/stub"
- android:layout_alwaysShow="true"
- android:visibility="gone"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:background="?attr/colorBackgroundFloating"/>
-
<TabHost
- android:layout_alwaysShow="true"
android:id="@+id/profile_tabhost"
android:layout_width="match_parent"
android:layout_height="wrap_content"
@@ -170,10 +110,7 @@
android:id="@+id/resolver_tab_divider"
android:visibility="gone"
android:layout_width="match_parent"
- android:layout_height="1dp"
- android:background="?attr/colorBackgroundFloating"
- android:foreground="?attr/dividerVertical"
- android:layout_marginBottom="8dp"/>
+ android:layout_height="wrap_content" />
<FrameLayout
android:id="@android:id/tabcontent"
android:layout_width="match_parent"
@@ -187,10 +124,36 @@
</LinearLayout>
</TabHost>
- <View
+ <LinearLayout
+ android:id="@+id/button_bar"
+ android:visibility="gone"
android:layout_width="match_parent"
- android:layout_height="1dp"
- android:background="?attr/dividerVertical"/>
+ android:layout_height="wrap_content"
+ android:layout_marginVertical="@dimen/car_padding_4"
+ android:layout_marginHorizontal="@dimen/car_padding_4"
+ android:gravity="center"
+ android:background="@drawable/car_activity_resolver_list_background"
+ android:orientation="vertical">
+
+ <Button
+ android:id="@+id/button_once"
+ android:layout_width="match_parent"
+ android:layout_height="@dimen/car_button_height"
+ android:enabled="false"
+ android:layout_gravity="center"
+ android:layout_marginBottom="@dimen/car_padding_2"
+ android:text="@string/activity_resolver_use_once"
+ android:onClick="onButtonClick"/>
+
+ <Button
+ android:id="@+id/button_always"
+ android:layout_width="match_parent"
+ android:layout_height="@dimen/car_button_height"
+ android:enabled="false"
+ android:layout_gravity="center"
+ android:text="@string/activity_resolver_use_always"
+ android:onClick="onButtonClick"/>
+ </LinearLayout>
</LinearLayout>
</com.android.internal.widget.ResolverDrawerLayout>
diff --git a/core/res/res/values/dimens_car.xml b/core/res/res/values/dimens_car.xml
index c5dddb8..99377ff 100644
--- a/core/res/res/values/dimens_car.xml
+++ b/core/res/res/values/dimens_car.xml
@@ -151,4 +151,10 @@
<dimen name="action_bar_button_margin">@*android:dimen/car_padding_4</dimen>
<dimen name="action_bar_button_max_width">268dp</dimen>
<dimen name="action_bar_toggle_internal_padding">@*android:dimen/car_padding_3</dimen>
+
+ <!-- Intent Resolver -->
+ <dimen name="car_activity_resolver_width">706dp</dimen>
+ <dimen name="car_activity_resolver_list_item_height">96dp</dimen>
+ <dimen name="car_activity_resolver_list_max_height">256dp</dimen>
+ <dimen name="car_activity_resolver_corner_radius">24dp</dimen>
</resources>
diff --git a/core/tests/PlatformCompatFramework/src/com/android/internal/compat/ChangeReporterTest.java b/core/tests/PlatformCompatFramework/src/com/android/internal/compat/ChangeReporterTest.java
index c32fd45..12a42f9 100644
--- a/core/tests/PlatformCompatFramework/src/com/android/internal/compat/ChangeReporterTest.java
+++ b/core/tests/PlatformCompatFramework/src/com/android/internal/compat/ChangeReporterTest.java
@@ -31,21 +31,21 @@
@Rule public final SetFlagsRule mSetFlagsRule = new SetFlagsRule();
@Test
- public void testIsAlreadyReportedOnce() {
+ public void testStatsLogOnce() {
ChangeReporter reporter = new ChangeReporter(ChangeReporter.SOURCE_UNKNOWN_SOURCE);
int myUid = 1022, otherUid = 1023;
long myChangeId = 500L, otherChangeId = 600L;
int myState = ChangeReporter.STATE_ENABLED, otherState = ChangeReporter.STATE_DISABLED;
- assertFalse(reporter.isAlreadyReported(myUid, myChangeId, myState));
+ assertTrue(reporter.shouldWriteToStatsLog(myUid, myChangeId, myState));
reporter.reportChange(myUid, myChangeId, myState);
// Same report will not be logged again.
- assertTrue(reporter.isAlreadyReported(myUid, myChangeId, myState));
+ assertFalse(reporter.shouldWriteToStatsLog(myUid, myChangeId, myState));
// Other reports will be logged.
- assertFalse(reporter.isAlreadyReported(otherUid, myChangeId, myState));
- assertFalse(reporter.isAlreadyReported(myUid, otherChangeId, myState));
- assertFalse(reporter.isAlreadyReported(myUid, myChangeId, otherState));
+ assertTrue(reporter.shouldWriteToStatsLog(otherUid, myChangeId, myState));
+ assertTrue(reporter.shouldWriteToStatsLog(myUid, otherChangeId, myState));
+ assertTrue(reporter.shouldWriteToStatsLog(myUid, myChangeId, otherState));
}
@Test
@@ -55,15 +55,15 @@
long myChangeId = 500L;
int myState = ChangeReporter.STATE_ENABLED;
- assertFalse(reporter.isAlreadyReported(myUid, myChangeId, myState));
+ assertTrue(reporter.shouldWriteToStatsLog(myUid, myChangeId, myState));
reporter.reportChange(myUid, myChangeId, myState);
// Same report will not be logged again.
- assertTrue(reporter.isAlreadyReported(myUid, myChangeId, myState));
+ assertFalse(reporter.shouldWriteToStatsLog(myUid, myChangeId, myState));
reporter.resetReportedChanges(myUid);
// Same report will be logged again after reset.
- assertFalse(reporter.isAlreadyReported(myUid, myChangeId, myState));
+ assertTrue(reporter.shouldWriteToStatsLog(myUid, myChangeId, myState));
}
@Test
@@ -196,21 +196,4 @@
// off.
assertTrue(reporter.shouldWriteToDebug(myUid, myChangeId, myDisabledState, false));
}
-
- @Test
- public void testDontLogSystemServer() {
- ChangeReporter systemServerReporter =
- new ChangeReporter(ChangeReporter.SOURCE_SYSTEM_SERVER);
-
- // We never log from system server, even if already reported.
- assertFalse(systemServerReporter.shouldWriteToStatsLog(false));
- assertFalse(systemServerReporter.shouldWriteToStatsLog(true));
-
- ChangeReporter unknownSourceReporter =
- new ChangeReporter(ChangeReporter.SOURCE_UNKNOWN_SOURCE);
-
- // Otherwise we log if it's not already been reported.
- assertTrue(unknownSourceReporter.shouldWriteToStatsLog(false));
- assertFalse(unknownSourceReporter.shouldWriteToStatsLog(true));
- }
}
diff --git a/libs/WindowManager/Jetpack/src/androidx/window/extensions/embedding/DividerPresenter.java b/libs/WindowManager/Jetpack/src/androidx/window/extensions/embedding/DividerPresenter.java
index 23dc96c..e8f01c2 100644
--- a/libs/WindowManager/Jetpack/src/androidx/window/extensions/embedding/DividerPresenter.java
+++ b/libs/WindowManager/Jetpack/src/androidx/window/extensions/embedding/DividerPresenter.java
@@ -718,17 +718,30 @@
if (dividerPosition >= minPosition && dividerPosition <= maxPosition) {
return dividerPosition;
}
- int[] possiblePositions = {0, minPosition, maxPosition, fullyExpandedPosition};
- return snap(dividerPosition, possiblePositions);
+ final int[] snapPositions = {0, minPosition, maxPosition, fullyExpandedPosition};
+ return snap(dividerPosition, snapPositions);
}
- if (velocity < 0) {
- return minPosition;
+ return dividerPositionForFling(
+ dividerPosition, minPosition, maxPosition, velocity);
+ }
+
+ /**
+ * Returns the closest position that is in the fling direction.
+ */
+ private static int dividerPositionForFling(int dividerPosition, int minPosition,
+ int maxPosition, float velocity) {
+ final boolean isBackwardDirection = velocity < 0;
+ if (isBackwardDirection) {
+ return dividerPosition < maxPosition ? minPosition : maxPosition;
} else {
- return maxPosition;
+ return dividerPosition > minPosition ? maxPosition : minPosition;
}
}
- /** Calculates the snapped divider position based on the possible positions and distance. */
+ /**
+ * Returns the snapped position from a list of possible positions. Currently, this method
+ * snaps to the closest position by distance from the divider position.
+ */
private static int snap(int dividerPosition, int[] possiblePositions) {
int snappedPosition = dividerPosition;
float minDistance = Float.MAX_VALUE;
diff --git a/libs/WindowManager/Jetpack/tests/unittest/src/androidx/window/extensions/embedding/DividerPresenterTest.java b/libs/WindowManager/Jetpack/tests/unittest/src/androidx/window/extensions/embedding/DividerPresenterTest.java
index 3f67607..af3c4da 100644
--- a/libs/WindowManager/Jetpack/tests/unittest/src/androidx/window/extensions/embedding/DividerPresenterTest.java
+++ b/libs/WindowManager/Jetpack/tests/unittest/src/androidx/window/extensions/embedding/DividerPresenterTest.java
@@ -715,25 +715,51 @@
nonFlingVelocity,
displayDensity));
- // Divider position is greater than minPosition and the velocity is enough for fling
+ // Divider position is in the closed to maxPosition bounds and the velocity is enough for
+ // backward fling
assertEquals(
- 30, // minPosition
+ 2000, // maxPosition
DividerPresenter.dividerPositionWithDraggingToFullscreenAllowed(
- 50 /* dividerPosition */,
- 30 /* minPosition */,
- 900 /* maxPosition */,
- 1200 /* fullyExpandedPosition */,
+ 2200 /* dividerPosition */,
+ 1000 /* minPosition */,
+ 2000 /* maxPosition */,
+ 2500 /* fullyExpandedPosition */,
-flingVelocity,
displayDensity));
- // Divider position is less than maxPosition and the velocity is enough for fling
+ // Divider position is not in the closed to maxPosition bounds and the velocity is enough
+ // for backward fling
assertEquals(
- 900, // maxPosition
+ 1000, // minPosition
DividerPresenter.dividerPositionWithDraggingToFullscreenAllowed(
- 800 /* dividerPosition */,
- 30 /* minPosition */,
- 900 /* maxPosition */,
- 1200 /* fullyExpandedPosition */,
+ 1200 /* dividerPosition */,
+ 1000 /* minPosition */,
+ 2000 /* maxPosition */,
+ 2500 /* fullyExpandedPosition */,
+ -flingVelocity,
+ displayDensity));
+
+ // Divider position is in the closed to minPosition bounds and the velocity is enough for
+ // forward fling
+ assertEquals(
+ 1000, // minPosition
+ DividerPresenter.dividerPositionWithDraggingToFullscreenAllowed(
+ 500 /* dividerPosition */,
+ 1000 /* minPosition */,
+ 2000 /* maxPosition */,
+ 2500 /* fullyExpandedPosition */,
+ flingVelocity,
+ displayDensity));
+
+ // Divider position is not in the closed to minPosition bounds and the velocity is enough
+ // for forward fling
+ assertEquals(
+ 2000, // maxPosition
+ DividerPresenter.dividerPositionWithDraggingToFullscreenAllowed(
+ 1200 /* dividerPosition */,
+ 1000 /* minPosition */,
+ 2000 /* maxPosition */,
+ 2500 /* fullyExpandedPosition */,
flingVelocity,
displayDensity));
}
diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/activityembedding/ActivityEmbeddingAnimationSpec.java b/libs/WindowManager/Shell/src/com/android/wm/shell/activityembedding/ActivityEmbeddingAnimationSpec.java
index 0272f1c..b986862 100644
--- a/libs/WindowManager/Shell/src/com/android/wm/shell/activityembedding/ActivityEmbeddingAnimationSpec.java
+++ b/libs/WindowManager/Shell/src/com/android/wm/shell/activityembedding/ActivityEmbeddingAnimationSpec.java
@@ -38,6 +38,7 @@
import android.window.TransitionInfo;
import com.android.internal.policy.TransitionAnimation;
+import com.android.window.flags.Flags;
import com.android.wm.shell.shared.TransitionUtil;
/** Animation spec for ActivityEmbedding transition. */
@@ -202,7 +203,7 @@
Animation loadOpenAnimation(@NonNull TransitionInfo info,
@NonNull TransitionInfo.Change change, @NonNull Rect wholeAnimationBounds) {
final boolean isEnter = TransitionUtil.isOpeningType(change.getMode());
- final Animation customAnimation = loadCustomAnimation(info, isEnter);
+ final Animation customAnimation = loadCustomAnimation(info, change, isEnter);
final Animation animation;
if (customAnimation != null) {
animation = customAnimation;
@@ -229,7 +230,7 @@
Animation loadCloseAnimation(@NonNull TransitionInfo info,
@NonNull TransitionInfo.Change change, @NonNull Rect wholeAnimationBounds) {
final boolean isEnter = TransitionUtil.isOpeningType(change.getMode());
- final Animation customAnimation = loadCustomAnimation(info, isEnter);
+ final Animation customAnimation = loadCustomAnimation(info, change, isEnter);
final Animation animation;
if (customAnimation != null) {
animation = customAnimation;
@@ -261,8 +262,14 @@
}
@Nullable
- private Animation loadCustomAnimation(@NonNull TransitionInfo info, boolean isEnter) {
- final TransitionInfo.AnimationOptions options = info.getAnimationOptions();
+ private Animation loadCustomAnimation(@NonNull TransitionInfo info,
+ @NonNull TransitionInfo.Change change, boolean isEnter) {
+ final TransitionInfo.AnimationOptions options;
+ if (Flags.moveAnimationOptionsToChange()) {
+ options = change.getAnimationOptions();
+ } else {
+ options = info.getAnimationOptions();
+ }
if (options == null || options.getType() != ANIM_CUSTOM) {
return null;
}
diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/activityembedding/ActivityEmbeddingController.java b/libs/WindowManager/Shell/src/com/android/wm/shell/activityembedding/ActivityEmbeddingController.java
index d6b9d34..b4ef9f0f 100644
--- a/libs/WindowManager/Shell/src/com/android/wm/shell/activityembedding/ActivityEmbeddingController.java
+++ b/libs/WindowManager/Shell/src/com/android/wm/shell/activityembedding/ActivityEmbeddingController.java
@@ -32,6 +32,7 @@
import android.util.ArrayMap;
import android.view.SurfaceControl;
import android.window.TransitionInfo;
+import android.window.TransitionInfo.AnimationOptions;
import android.window.TransitionRequestInfo;
import android.window.WindowContainerTransaction;
@@ -39,6 +40,7 @@
import androidx.annotation.Nullable;
import com.android.internal.annotations.VisibleForTesting;
+import com.android.window.flags.Flags;
import com.android.wm.shell.shared.TransitionUtil;
import com.android.wm.shell.sysui.ShellInit;
import com.android.wm.shell.transition.Transitions;
@@ -117,24 +119,39 @@
return false;
}
- final TransitionInfo.AnimationOptions options = info.getAnimationOptions();
- if (options != null) {
- // Scene-transition should be handled by app side.
- if (options.getType() == ANIM_SCENE_TRANSITION) {
+ return shouldAnimateAnimationOptions(info);
+ }
+
+ private boolean shouldAnimateAnimationOptions(@NonNull TransitionInfo info) {
+ if (!Flags.moveAnimationOptionsToChange()) {
+ return shouldAnimateAnimationOptions(info.getAnimationOptions());
+ }
+ for (TransitionInfo.Change change : info.getChanges()) {
+ if (!shouldAnimateAnimationOptions(change.getAnimationOptions())) {
+ // If any of override animation is not supported, don't animate the transition.
return false;
}
- // The case of ActivityOptions#makeCustomAnimation, Activity#overridePendingTransition,
- // and Activity#overrideActivityTransition are supported.
- if (options.getType() == ANIM_CUSTOM) {
- return true;
- }
- // Use default transition handler to animate other override animation.
- return !isSupportedOverrideAnimation(options);
}
-
return true;
}
+ private boolean shouldAnimateAnimationOptions(@Nullable AnimationOptions options) {
+ if (options == null) {
+ return true;
+ }
+ // Scene-transition should be handled by app side.
+ if (options.getType() == ANIM_SCENE_TRANSITION) {
+ return false;
+ }
+ // The case of ActivityOptions#makeCustomAnimation, Activity#overridePendingTransition,
+ // and Activity#overrideActivityTransition are supported.
+ if (options.getType() == ANIM_CUSTOM) {
+ return true;
+ }
+ // Use default transition handler to animate other override animation.
+ return !isSupportedOverrideAnimation(options);
+ }
+
@Override
public boolean startAnimation(@NonNull IBinder transition, @NonNull TransitionInfo info,
@NonNull SurfaceControl.Transaction startTransaction,
diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/back/CrossActivityBackAnimation.kt b/libs/WindowManager/Shell/src/com/android/wm/shell/back/CrossActivityBackAnimation.kt
index 0112768..9114c7a 100644
--- a/libs/WindowManager/Shell/src/com/android/wm/shell/back/CrossActivityBackAnimation.kt
+++ b/libs/WindowManager/Shell/src/com/android/wm/shell/back/CrossActivityBackAnimation.kt
@@ -110,6 +110,7 @@
private val postCommitFlingSpring = SpringForce(SPRING_SCALE)
.setStiffness(SpringForce.STIFFNESS_LOW)
.setDampingRatio(SpringForce.DAMPING_RATIO_LOW_BOUNCY)
+ protected var gestureProgress = 0f
/** Background color to be used during the animation, also see [getBackgroundColor] */
protected var customizedBackgroundColor = 0
@@ -213,6 +214,7 @@
private fun onGestureProgress(backEvent: BackEvent) {
val progress = gestureInterpolator.getInterpolation(backEvent.progress)
+ gestureProgress = progress
currentClosingRect.setInterpolatedRectF(startClosingRect, targetClosingRect, progress)
val yOffset = getYOffset(currentClosingRect, backEvent.touchY)
currentClosingRect.offset(0f, yOffset)
@@ -258,9 +260,11 @@
}
// kick off spring animation with the current velocity from the pre-commit phase, this
- // affects the scaling of the closing activity during post-commit
+ // affects the scaling of the closing and/or opening activity during post-commit
+ val startVelocity =
+ if (gestureProgress < 0.1f) -DEFAULT_FLING_VELOCITY else -velocity * SPRING_SCALE
val flingAnimation = SpringAnimation(postCommitFlingScale, SPRING_SCALE)
- .setStartVelocity(min(0f, -velocity * SPRING_SCALE))
+ .setStartVelocity(startVelocity.coerceIn(-MAX_FLING_VELOCITY, 0f))
.setStartValue(SPRING_SCALE)
.setSpring(postCommitFlingSpring)
flingAnimation.start()
@@ -319,19 +323,22 @@
isLetterboxed = false
enteringHasSameLetterbox = false
lastPostCommitFlingScale = SPRING_SCALE
+ gestureProgress = 0f
}
protected fun applyTransform(
leash: SurfaceControl?,
rect: RectF,
alpha: Float,
- baseTransformation: Transformation? = null
+ baseTransformation: Transformation? = null,
+ flingMode: FlingMode = FlingMode.NO_FLING
) {
if (leash == null || !leash.isValid) return
tempRectF.set(rect)
- if (leash == closingTarget?.leash) {
- lastPostCommitFlingScale = (postCommitFlingScale.value / SPRING_SCALE).coerceIn(
- minimumValue = MAX_FLING_SCALE, maximumValue = lastPostCommitFlingScale
+ if (flingMode != FlingMode.NO_FLING) {
+ lastPostCommitFlingScale = min(
+ postCommitFlingScale.value / SPRING_SCALE,
+ if (flingMode == FlingMode.FLING_BOUNCE) 1f else lastPostCommitFlingScale
)
// apply an additional scale to the closing target to account for fling velocity
tempRectF.scaleCentered(lastPostCommitFlingScale)
@@ -533,14 +540,30 @@
private const val MAX_SCRIM_ALPHA_DARK = 0.8f
private const val MAX_SCRIM_ALPHA_LIGHT = 0.2f
private const val SPRING_SCALE = 100f
- private const val MAX_FLING_SCALE = 0.6f
+ private const val MAX_FLING_VELOCITY = 1000f
+ private const val DEFAULT_FLING_VELOCITY = 120f
+ }
+
+ enum class FlingMode {
+ NO_FLING,
+
+ /**
+ * This is used for the closing target in custom cross-activity back animations. When the
+ * back gesture is flung, the closing target shrinks a bit further with a spring motion.
+ */
+ FLING_SHRINK,
+
+ /**
+ * This is used for the closing and opening target in the default cross-activity back
+ * animation. When the back gesture is flung, the closing and opening targets shrink a
+ * bit further and then bounce back with a spring motion.
+ */
+ FLING_BOUNCE
}
}
// The target will loose focus when alpha == 0, so keep a minimum value for it.
-private fun keepMinimumAlpha(transAlpha: Float): Float {
- return max(transAlpha.toDouble(), 0.005).toFloat()
-}
+private fun keepMinimumAlpha(transAlpha: Float) = max(transAlpha, 0.005f)
private fun isDarkMode(context: Context): Boolean {
return context.resources.configuration.uiMode and Configuration.UI_MODE_NIGHT_MASK ==
diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/back/CustomCrossActivityBackAnimation.kt b/libs/WindowManager/Shell/src/com/android/wm/shell/back/CustomCrossActivityBackAnimation.kt
index c4aafea..c738ce5 100644
--- a/libs/WindowManager/Shell/src/com/android/wm/shell/back/CustomCrossActivityBackAnimation.kt
+++ b/libs/WindowManager/Shell/src/com/android/wm/shell/back/CustomCrossActivityBackAnimation.kt
@@ -57,7 +57,6 @@
private var enterAnimation: Animation? = null
private var closeAnimation: Animation? = null
private val transformation = Transformation()
- private var gestureProgress = 0f
override val allowEnteringYShift = false
@@ -105,7 +104,6 @@
}
override fun getPreCommitEnteringBaseTransformation(progress: Float): Transformation {
- gestureProgress = progress
transformation.clear()
enterAnimation!!.getTransformationAt(progress * PRE_COMMIT_MAX_PROGRESS, transformation)
return transformation
@@ -134,7 +132,13 @@
if (closingTarget == null || enteringTarget == null) return
val closingProgress = closeAnimation!!.getPostCommitProgress(linearProgress)
- applyTransform(closingTarget!!.leash, currentClosingRect, closingProgress, closeAnimation!!)
+ applyTransform(
+ closingTarget!!.leash,
+ currentClosingRect,
+ closingProgress,
+ closeAnimation!!,
+ FlingMode.FLING_SHRINK
+ )
val enteringProgress = MathUtils.lerp(
gestureProgress * PRE_COMMIT_MAX_PROGRESS,
1f,
@@ -144,7 +148,8 @@
enteringTarget!!.leash,
currentEnteringRect,
enteringProgress,
- enterAnimation!!
+ enterAnimation!!,
+ FlingMode.NO_FLING
)
applyTransaction()
}
@@ -153,11 +158,12 @@
leash: SurfaceControl,
rect: RectF,
progress: Float,
- animation: Animation
+ animation: Animation,
+ flingMode: FlingMode
) {
transformation.clear()
animation.getTransformationAt(progress, transformation)
- applyTransform(leash, rect, transformation.alpha, transformation)
+ applyTransform(leash, rect, transformation.alpha, transformation, flingMode)
}
override fun finishAnimation() {
@@ -166,7 +172,6 @@
enterAnimation?.reset()
enterAnimation = null
transformation.clear()
- gestureProgress = 0f
super.finishAnimation()
}
diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/back/DefaultCrossActivityBackAnimation.kt b/libs/WindowManager/Shell/src/com/android/wm/shell/back/DefaultCrossActivityBackAnimation.kt
index 44752fe..3b5eb36 100644
--- a/libs/WindowManager/Shell/src/com/android/wm/shell/back/DefaultCrossActivityBackAnimation.kt
+++ b/libs/WindowManager/Shell/src/com/android/wm/shell/back/DefaultCrossActivityBackAnimation.kt
@@ -43,7 +43,7 @@
Choreographer.getInstance()
) {
- private val postCommitInterpolator = Interpolators.FAST_OUT_SLOW_IN
+ private val postCommitInterpolator = Interpolators.EMPHASIZED
private val enteringStartOffset =
context.resources.getDimension(R.dimen.cross_activity_back_entering_start_offset)
override val allowEnteringYShift = true
@@ -87,17 +87,27 @@
override fun onPostCommitProgress(linearProgress: Float) {
super.onPostCommitProgress(linearProgress)
- val closingAlpha = max(1f - linearProgress * 2, 0f)
+ val closingAlpha = max(1f - linearProgress * 5, 0f)
val progress = postCommitInterpolator.getInterpolation(linearProgress)
currentClosingRect.setInterpolatedRectF(startClosingRect, targetClosingRect, progress)
- applyTransform(closingTarget?.leash, currentClosingRect, closingAlpha)
+ applyTransform(
+ closingTarget?.leash,
+ currentClosingRect,
+ closingAlpha,
+ flingMode = FlingMode.FLING_BOUNCE
+ )
currentEnteringRect.setInterpolatedRectF(startEnteringRect, targetEnteringRect, progress)
- applyTransform(enteringTarget?.leash, currentEnteringRect, 1f)
+ applyTransform(
+ enteringTarget?.leash,
+ currentEnteringRect,
+ 1f,
+ flingMode = FlingMode.FLING_BOUNCE
+ )
applyTransaction()
}
companion object {
- private const val POST_COMMIT_DURATION = 300L
+ private const val POST_COMMIT_DURATION = 450L
}
}
diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/desktopmode/DesktopTasksController.kt b/libs/WindowManager/Shell/src/com/android/wm/shell/desktopmode/DesktopTasksController.kt
index ef384c7..ee7e4d1 100644
--- a/libs/WindowManager/Shell/src/com/android/wm/shell/desktopmode/DesktopTasksController.kt
+++ b/libs/WindowManager/Shell/src/com/android/wm/shell/desktopmode/DesktopTasksController.kt
@@ -486,7 +486,9 @@
"DesktopTasksController: cancelDragToDesktop taskId=%d",
task.taskId
)
- dragToDesktopTransitionHandler.cancelDragToDesktopTransition()
+ dragToDesktopTransitionHandler.cancelDragToDesktopTransition(
+ DragToDesktopTransitionHandler.CancelState.STANDARD_CANCEL
+ )
}
private fun moveToFullscreenWithAnimation(task: RunningTaskInfo, position: Point) {
@@ -1105,20 +1107,31 @@
@JvmOverloads
fun requestSplit(
taskInfo: RunningTaskInfo,
- leftOrTop: Boolean = false,
+ leftOrTop: Boolean = false
) {
- val windowingMode = taskInfo.windowingMode
- if (
- windowingMode == WINDOWING_MODE_FULLSCREEN || windowingMode == WINDOWING_MODE_FREEFORM
- ) {
- val wct = WindowContainerTransaction()
- addMoveToSplitChanges(wct, taskInfo)
- splitScreenController.requestEnterSplitSelect(
- taskInfo,
- wct,
- if (leftOrTop) SPLIT_POSITION_TOP_OR_LEFT else SPLIT_POSITION_BOTTOM_OR_RIGHT,
- taskInfo.configuration.windowConfiguration.bounds
- )
+ // If a drag to desktop is in progress, we want to enter split select
+ // even if the requesting task is already in split.
+ val isDragging = dragToDesktopTransitionHandler.inProgress
+ val shouldRequestSplit = taskInfo.isFullscreen || taskInfo.isFreeform || isDragging
+ if (shouldRequestSplit) {
+ if (isDragging) {
+ releaseVisualIndicator()
+ val cancelState = if (leftOrTop) {
+ DragToDesktopTransitionHandler.CancelState.CANCEL_SPLIT_LEFT
+ } else {
+ DragToDesktopTransitionHandler.CancelState.CANCEL_SPLIT_RIGHT
+ }
+ dragToDesktopTransitionHandler.cancelDragToDesktopTransition(cancelState)
+ } else {
+ val wct = WindowContainerTransaction()
+ addMoveToSplitChanges(wct, taskInfo)
+ splitScreenController.requestEnterSplitSelect(
+ taskInfo,
+ wct,
+ if (leftOrTop) SPLIT_POSITION_TOP_OR_LEFT else SPLIT_POSITION_BOTTOM_OR_RIGHT,
+ taskInfo.configuration.windowConfiguration.bounds
+ )
+ }
}
}
@@ -1247,7 +1260,10 @@
* @param taskInfo the task being dragged.
* @param y height of drag, to be checked against status bar height.
*/
- fun onDragPositioningEndThroughStatusBar(inputCoordinates: PointF, taskInfo: RunningTaskInfo) {
+ fun onDragPositioningEndThroughStatusBar(
+ inputCoordinates: PointF,
+ taskInfo: RunningTaskInfo,
+ ) {
val indicator = getVisualIndicator() ?: return
val indicatorType = indicator.updateIndicatorType(inputCoordinates, taskInfo.windowingMode)
when (indicatorType) {
@@ -1264,10 +1280,10 @@
cancelDragToDesktop(taskInfo)
}
DesktopModeVisualIndicator.IndicatorType.TO_SPLIT_LEFT_INDICATOR -> {
- finalizeDragToDesktop(taskInfo, getSnapBounds(taskInfo, SnapPosition.LEFT))
+ requestSplit(taskInfo, leftOrTop = true)
}
DesktopModeVisualIndicator.IndicatorType.TO_SPLIT_RIGHT_INDICATOR -> {
- finalizeDragToDesktop(taskInfo, getSnapBounds(taskInfo, SnapPosition.RIGHT))
+ requestSplit(taskInfo, leftOrTop = false)
}
}
}
diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/desktopmode/DragToDesktopTransitionHandler.kt b/libs/WindowManager/Shell/src/com/android/wm/shell/desktopmode/DragToDesktopTransitionHandler.kt
index 98c79d7..d99b724 100644
--- a/libs/WindowManager/Shell/src/com/android/wm/shell/desktopmode/DragToDesktopTransitionHandler.kt
+++ b/libs/WindowManager/Shell/src/com/android/wm/shell/desktopmode/DragToDesktopTransitionHandler.kt
@@ -4,6 +4,7 @@
import android.animation.AnimatorListenerAdapter
import android.animation.RectEvaluator
import android.animation.ValueAnimator
+import android.app.ActivityManager.RunningTaskInfo
import android.app.ActivityOptions
import android.app.ActivityOptions.SourceInfo
import android.app.ActivityTaskManager.INVALID_TASK_ID
@@ -12,9 +13,11 @@
import android.app.PendingIntent.FLAG_MUTABLE
import android.app.WindowConfiguration.ACTIVITY_TYPE_HOME
import android.app.WindowConfiguration.WINDOWING_MODE_FREEFORM
+import android.app.WindowConfiguration.WINDOWING_MODE_MULTI_WINDOW
import android.content.Context
import android.content.Intent
import android.content.Intent.FILL_IN_COMPONENT
+import android.graphics.PointF
import android.graphics.Rect
import android.os.Bundle
import android.os.IBinder
@@ -30,6 +33,7 @@
import com.android.wm.shell.common.split.SplitScreenConstants.SPLIT_POSITION_BOTTOM_OR_RIGHT
import com.android.wm.shell.common.split.SplitScreenConstants.SPLIT_POSITION_TOP_OR_LEFT
import com.android.wm.shell.common.split.SplitScreenConstants.SPLIT_POSITION_UNDEFINED
+import com.android.wm.shell.common.split.SplitScreenConstants.SplitPosition
import com.android.wm.shell.protolog.ShellProtoLogGroup
import com.android.wm.shell.shared.TransitionUtil
import com.android.wm.shell.splitscreen.SplitScreenController
@@ -186,7 +190,7 @@
* outside the desktop drop zone and is instead dropped back into the status bar region that
* means the user wants to remain in their current windowing mode.
*/
- fun cancelDragToDesktopTransition() {
+ fun cancelDragToDesktopTransition(cancelState: CancelState) {
if (!inProgress) {
// Don't attempt to cancel a drag to desktop transition since there is no transition in
// progress which means that the drag to desktop transition was never successfully
@@ -200,13 +204,32 @@
clearState()
return
}
- state.cancelled = true
- if (state.draggedTaskChange != null) {
+ state.cancelState = cancelState
+
+ if (state.draggedTaskChange != null && cancelState == CancelState.STANDARD_CANCEL) {
// Regular case, transient launch of Home happened as is waiting for the cancel
// transient to start and merge. Animate the cancellation (scale back to original
// bounds) first before actually starting the cancel transition so that the wallpaper
// is visible behind the animating task.
startCancelAnimation()
+ } else if (
+ state.draggedTaskChange != null &&
+ (cancelState == CancelState.CANCEL_SPLIT_LEFT ||
+ cancelState == CancelState.CANCEL_SPLIT_RIGHT)
+ ) {
+ // We have a valid dragged task, but the animation will be handled by
+ // SplitScreenController; request the transition here.
+ @SplitPosition val splitPosition = if (cancelState == CancelState.CANCEL_SPLIT_LEFT) {
+ SPLIT_POSITION_TOP_OR_LEFT
+ } else {
+ SPLIT_POSITION_BOTTOM_OR_RIGHT
+ }
+ val wct = WindowContainerTransaction()
+ restoreWindowOrder(wct, state)
+ state.startTransitionFinishTransaction?.apply()
+ state.startTransitionFinishCb?.onTransitionFinished(null /* wct */)
+ requestSplitFromScaledTask(splitPosition, wct)
+ clearState()
} else {
// There's no dragged task, this can happen when the "cancel" happened too quickly
// before the "start" transition is even ready (like on a fling gesture). The
@@ -217,6 +240,54 @@
}
}
+ /** Calculate the bounds of a scaled task, then use those bounds to request split select. */
+ private fun requestSplitFromScaledTask(
+ @SplitPosition splitPosition: Int,
+ wct: WindowContainerTransaction
+ ) {
+ val state = requireTransitionState()
+ val taskInfo = state.draggedTaskChange?.taskInfo
+ ?: error("Expected non-null taskInfo")
+ val taskBounds = Rect(taskInfo.configuration.windowConfiguration.bounds)
+ val taskScale = state.dragAnimator.scale
+ val scaledWidth = taskBounds.width() * taskScale
+ val scaledHeight = taskBounds.height() * taskScale
+ val dragPosition = PointF(state.dragAnimator.position)
+ state.dragAnimator.cancelAnimator()
+ val animatedTaskBounds = Rect(
+ dragPosition.x.toInt(),
+ dragPosition.y.toInt(),
+ (dragPosition.x + scaledWidth).toInt(),
+ (dragPosition.y + scaledHeight).toInt()
+ )
+ requestSplitSelect(wct, taskInfo, splitPosition, animatedTaskBounds)
+ }
+
+ private fun requestSplitSelect(
+ wct: WindowContainerTransaction,
+ taskInfo: RunningTaskInfo,
+ @SplitPosition splitPosition: Int,
+ taskBounds: Rect = Rect(taskInfo.configuration.windowConfiguration.bounds)
+ ) {
+ // Prepare to exit split in order to enter split select.
+ if (taskInfo.windowingMode == WINDOWING_MODE_MULTI_WINDOW) {
+ splitScreenController.prepareExitSplitScreen(
+ wct,
+ splitScreenController.getStageOfTask(taskInfo.taskId),
+ SplitScreenController.EXIT_REASON_DESKTOP_MODE
+ )
+ splitScreenController.transitionHandler.onSplitToDesktop()
+ }
+ wct.setWindowingMode(taskInfo.token, WINDOWING_MODE_MULTI_WINDOW)
+ wct.setDensityDpi(taskInfo.token, context.resources.displayMetrics.densityDpi)
+ splitScreenController.requestEnterSplitSelect(
+ taskInfo,
+ wct,
+ splitPosition,
+ taskBounds
+ )
+ }
+
override fun startAnimation(
transition: IBinder,
info: TransitionInfo,
@@ -261,7 +332,7 @@
is TransitionState.FromSplit -> {
state.splitRootChange = change
val layer =
- if (!state.cancelled) {
+ if (state.cancelState == CancelState.NO_CANCEL) {
// Normal case, split root goes to the bottom behind everything
// else.
appLayers - i
@@ -311,8 +382,18 @@
// Do not do this in the cancel-early case though, since in that case nothing should
// happen on screen so the layering will remain the same as if no transition
// occurred.
- if (change.taskInfo?.taskId == state.draggedTaskId && !state.cancelled) {
+ if (
+ change.taskInfo?.taskId == state.draggedTaskId &&
+ state.cancelState != CancelState.STANDARD_CANCEL
+ ) {
+ // We need access to the dragged task's change in both non-cancel and split
+ // cancel cases.
state.draggedTaskChange = change
+ }
+ if (
+ change.taskInfo?.taskId == state.draggedTaskId &&
+ state.cancelState == CancelState.NO_CANCEL
+ ) {
taskDisplayAreaOrganizer.reparentToDisplayArea(
change.endDisplayId,
change.leash,
@@ -331,11 +412,11 @@
state.startTransitionFinishTransaction = finishTransaction
startTransaction.apply()
- if (!state.cancelled) {
+ if (state.cancelState == CancelState.NO_CANCEL) {
// Normal case, start animation to scale down the dragged task. It'll also be moved to
// follow the finger and when released we'll start the next phase/transition.
state.dragAnimator.startAnimation()
- } else {
+ } else if (state.cancelState == CancelState.STANDARD_CANCEL) {
// Cancel-early case, the state was flagged was cancelled already, which means the
// gesture ended in the cancel region. This can happen even before the start transition
// is ready/animate here when cancelling quickly like with a fling. There's no point
@@ -343,6 +424,26 @@
// directly into starting the cancel transition to restore WM order. Surfaces should
// not move as if no transition happened.
startCancelDragToDesktopTransition()
+ } else if (
+ state.cancelState == CancelState.CANCEL_SPLIT_LEFT ||
+ state.cancelState == CancelState.CANCEL_SPLIT_RIGHT
+ ){
+ // Cancel-early case for split-cancel. The state was flagged already as a cancel for
+ // requesting split select. Similar to the above, this can happen due to quick fling
+ // gestures. We can simply request split here without needing to calculate animated
+ // task bounds as the task has not shrunk at all.
+ val splitPosition = if (state.cancelState == CancelState.CANCEL_SPLIT_LEFT) {
+ SPLIT_POSITION_TOP_OR_LEFT
+ } else {
+ SPLIT_POSITION_BOTTOM_OR_RIGHT
+ }
+ val taskInfo = state.draggedTaskChange?.taskInfo
+ ?: error("Expected non-null task info.")
+ val wct = WindowContainerTransaction()
+ restoreWindowOrder(wct)
+ state.startTransitionFinishTransaction?.apply()
+ state.startTransitionFinishCb?.onTransitionFinished(null /* wct */)
+ requestSplitSelect(wct, taskInfo, splitPosition)
}
return true
}
@@ -355,6 +456,12 @@
finishCallback: Transitions.TransitionFinishCallback
) {
val state = requireTransitionState()
+ // We don't want to merge the split select animation if that's what we requested.
+ if (state.cancelState == CancelState.CANCEL_SPLIT_LEFT ||
+ state.cancelState == CancelState.CANCEL_SPLIT_RIGHT) {
+ clearState()
+ return
+ }
val isCancelTransition =
info.type == TRANSIT_DESKTOP_MODE_CANCEL_DRAG_TO_DESKTOP &&
transition == state.cancelTransitionToken &&
@@ -552,6 +659,17 @@
private fun startCancelDragToDesktopTransition() {
val state = requireTransitionState()
val wct = WindowContainerTransaction()
+ restoreWindowOrder(wct, state)
+ state.cancelTransitionToken =
+ transitions.startTransition(
+ TRANSIT_DESKTOP_MODE_CANCEL_DRAG_TO_DESKTOP, wct, this
+ )
+ }
+
+ private fun restoreWindowOrder(
+ wct: WindowContainerTransaction,
+ state: TransitionState = requireTransitionState()
+ ) {
when (state) {
is TransitionState.FromFullscreen -> {
// There may have been tasks sent behind home that are not the dragged task (like
@@ -580,9 +698,6 @@
}
val homeWc = state.homeToken ?: error("Home task should be non-null before cancelling")
wct.restoreTransientOrder(homeWc)
-
- state.cancelTransitionToken =
- transitions.startTransition(TRANSIT_DESKTOP_MODE_CANCEL_DRAG_TO_DESKTOP, wct, this)
}
private fun clearState() {
@@ -624,7 +739,7 @@
abstract var cancelTransitionToken: IBinder?
abstract var homeToken: WindowContainerToken?
abstract var draggedTaskChange: Change?
- abstract var cancelled: Boolean
+ abstract var cancelState: CancelState
abstract var startAborted: Boolean
data class FromFullscreen(
@@ -636,7 +751,7 @@
override var cancelTransitionToken: IBinder? = null,
override var homeToken: WindowContainerToken? = null,
override var draggedTaskChange: Change? = null,
- override var cancelled: Boolean = false,
+ override var cancelState: CancelState = CancelState.NO_CANCEL,
override var startAborted: Boolean = false,
var otherRootChanges: MutableList<Change> = mutableListOf()
) : TransitionState()
@@ -650,13 +765,25 @@
override var cancelTransitionToken: IBinder? = null,
override var homeToken: WindowContainerToken? = null,
override var draggedTaskChange: Change? = null,
- override var cancelled: Boolean = false,
+ override var cancelState: CancelState = CancelState.NO_CANCEL,
override var startAborted: Boolean = false,
var splitRootChange: Change? = null,
var otherSplitTask: Int
) : TransitionState()
}
+ /** Enum to provide context on cancelling a drag to desktop event. */
+ enum class CancelState {
+ /** No cancel case; this drag is not flagged for a cancel event. */
+ NO_CANCEL,
+ /** A standard cancel event; should restore task to previous windowing mode. */
+ STANDARD_CANCEL,
+ /** A cancel event where the task will request to enter split on the left side. */
+ CANCEL_SPLIT_LEFT,
+ /** A cancel event where the task will request to enter split on the right side. */
+ CANCEL_SPLIT_RIGHT
+ }
+
companion object {
/** The duration of the animation to commit or cancel the drag-to-desktop gesture. */
private const val DRAG_TO_DESKTOP_FINISH_ANIM_DURATION_MS = 336L
diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/keyguard/KeyguardTransitionHandler.java b/libs/WindowManager/Shell/src/com/android/wm/shell/keyguard/KeyguardTransitionHandler.java
index c79eef7e..cd478e5 100644
--- a/libs/WindowManager/Shell/src/com/android/wm/shell/keyguard/KeyguardTransitionHandler.java
+++ b/libs/WindowManager/Shell/src/com/android/wm/shell/keyguard/KeyguardTransitionHandler.java
@@ -143,6 +143,10 @@
}
public static boolean handles(TransitionInfo info) {
+ // There is no animation for screen-wake unless we are immediately unlocking.
+ if (info.getType() == WindowManager.TRANSIT_WAKE && !info.isKeyguardGoingAway()) {
+ return false;
+ }
return (info.getFlags() & KEYGUARD_VISIBILITY_TRANSIT_FLAGS) != 0;
}
diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/pip2/animation/PipAlphaAnimator.java b/libs/WindowManager/Shell/src/com/android/wm/shell/pip2/animation/PipAlphaAnimator.java
new file mode 100644
index 0000000..3e298e5
--- /dev/null
+++ b/libs/WindowManager/Shell/src/com/android/wm/shell/pip2/animation/PipAlphaAnimator.java
@@ -0,0 +1,110 @@
+/*
+ * 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.wm.shell.pip2.animation;
+
+import android.animation.Animator;
+import android.animation.ValueAnimator;
+import android.annotation.IntDef;
+import android.view.SurfaceControl;
+
+import androidx.annotation.NonNull;
+import androidx.annotation.Nullable;
+
+import com.android.wm.shell.pip2.PipSurfaceTransactionHelper;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+
+/**
+ * Animator that handles the alpha animation for entering PIP
+ */
+public class PipAlphaAnimator extends ValueAnimator implements ValueAnimator.AnimatorUpdateListener,
+ ValueAnimator.AnimatorListener {
+ @IntDef(prefix = {"FADE_"}, value = {
+ FADE_IN,
+ FADE_OUT
+ })
+
+ @Retention(RetentionPolicy.SOURCE)
+ public @interface Fade {}
+
+ public static final int FADE_IN = 0;
+ public static final int FADE_OUT = 1;
+
+ private final SurfaceControl mLeash;
+ private final SurfaceControl.Transaction mStartTransaction;
+
+ // optional callbacks for tracking animation start and end
+ @Nullable private Runnable mAnimationStartCallback;
+ @Nullable private Runnable mAnimationEndCallback;
+
+ private final PipSurfaceTransactionHelper.SurfaceControlTransactionFactory
+ mSurfaceControlTransactionFactory;
+
+ public PipAlphaAnimator(SurfaceControl leash,
+ SurfaceControl.Transaction tx,
+ @Fade int direction) {
+ mLeash = leash;
+ mStartTransaction = tx;
+ if (direction == FADE_IN) {
+ setFloatValues(0f, 1f);
+ } else { // direction == FADE_OUT
+ setFloatValues(1f, 0f);
+ }
+ mSurfaceControlTransactionFactory =
+ new PipSurfaceTransactionHelper.VsyncSurfaceControlTransactionFactory();
+ addListener(this);
+ addUpdateListener(this);
+ }
+
+ public void setAnimationStartCallback(@NonNull Runnable runnable) {
+ mAnimationStartCallback = runnable;
+ }
+
+ public void setAnimationEndCallback(@NonNull Runnable runnable) {
+ mAnimationEndCallback = runnable;
+ }
+
+ @Override
+ public void onAnimationStart(@NonNull Animator animation) {
+ if (mAnimationStartCallback != null) {
+ mAnimationStartCallback.run();
+ }
+ if (mStartTransaction != null) {
+ mStartTransaction.apply();
+ }
+ }
+
+ @Override
+ public void onAnimationUpdate(@NonNull ValueAnimator animation) {
+ final float alpha = (Float) animation.getAnimatedValue();
+ mSurfaceControlTransactionFactory.getTransaction().setAlpha(mLeash, alpha).apply();
+ }
+
+ @Override
+ public void onAnimationEnd(@NonNull Animator animation) {
+ if (mAnimationEndCallback != null) {
+ mAnimationEndCallback.run();
+ }
+ }
+
+ @Override
+ public void onAnimationCancel(@NonNull Animator animation) {}
+
+ @Override
+ public void onAnimationRepeat(@NonNull Animator animation) {}
+}
diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/pip2/phone/PipTransition.java b/libs/WindowManager/Shell/src/com/android/wm/shell/pip2/phone/PipTransition.java
index 7dddd27..3e215d9 100644
--- a/libs/WindowManager/Shell/src/com/android/wm/shell/pip2/phone/PipTransition.java
+++ b/libs/WindowManager/Shell/src/com/android/wm/shell/pip2/phone/PipTransition.java
@@ -52,6 +52,7 @@
import com.android.wm.shell.common.pip.PipUtils;
import com.android.wm.shell.pip.PipContentOverlay;
import com.android.wm.shell.pip.PipTransitionController;
+import com.android.wm.shell.pip2.animation.PipAlphaAnimator;
import com.android.wm.shell.sysui.ShellInit;
import com.android.wm.shell.transition.Transitions;
@@ -392,8 +393,14 @@
// cache the PiP task token and leash
WindowContainerToken pipTaskToken = pipChange.getContainer();
- startTransaction.apply();
- finishCallback.onTransitionFinished(null);
+ Preconditions.checkNotNull(mPipLeash, "Leash is null for alpha transition.");
+ // start transition with 0 alpha
+ startTransaction.setAlpha(mPipLeash, 0f);
+ PipAlphaAnimator animator = new PipAlphaAnimator(mPipLeash,
+ startTransaction, PipAlphaAnimator.FADE_IN);
+ animator.setAnimationEndCallback(() -> finishCallback.onTransitionFinished(null));
+
+ animator.start();
return true;
}
diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/transition/DefaultTransitionHandler.java b/libs/WindowManager/Shell/src/com/android/wm/shell/transition/DefaultTransitionHandler.java
index 2d6ba6e..018c904 100644
--- a/libs/WindowManager/Shell/src/com/android/wm/shell/transition/DefaultTransitionHandler.java
+++ b/libs/WindowManager/Shell/src/com/android/wm/shell/transition/DefaultTransitionHandler.java
@@ -103,6 +103,7 @@
import com.android.internal.policy.ScreenDecorationsUtils;
import com.android.internal.policy.TransitionAnimation;
import com.android.internal.protolog.common.ProtoLog;
+import com.android.window.flags.Flags;
import com.android.wm.shell.RootTaskDisplayAreaOrganizer;
import com.android.wm.shell.common.DisplayController;
import com.android.wm.shell.common.DisplayLayout;
@@ -543,7 +544,13 @@
mTransactionPool, mMainExecutor, animRelOffset, cornerRadius,
clipRect);
- if (info.getAnimationOptions() != null) {
+ final TransitionInfo.AnimationOptions options;
+ if (Flags.moveAnimationOptionsToChange()) {
+ options = info.getAnimationOptions();
+ } else {
+ options = change.getAnimationOptions();
+ }
+ if (options != null) {
attachThumbnail(animations, onAnimFinish, change, info.getAnimationOptions(),
cornerRadius);
}
@@ -725,7 +732,12 @@
final boolean isOpeningType = TransitionUtil.isOpeningType(type);
final boolean enter = TransitionUtil.isOpeningType(changeMode);
final boolean isTask = change.getTaskInfo() != null;
- final TransitionInfo.AnimationOptions options = info.getAnimationOptions();
+ final TransitionInfo.AnimationOptions options;
+ if (Flags.moveAnimationOptionsToChange()) {
+ options = change.getAnimationOptions();
+ } else {
+ options = info.getAnimationOptions();
+ }
final int overrideType = options != null ? options.getType() : ANIM_NONE;
final Rect endBounds = TransitionUtil.isClosingType(changeMode)
? mRotator.getEndBoundsInStartRotation(change)
diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/transition/TransitionAnimationHelper.java b/libs/WindowManager/Shell/src/com/android/wm/shell/transition/TransitionAnimationHelper.java
index ad4f02d..2047b5a 100644
--- a/libs/WindowManager/Shell/src/com/android/wm/shell/transition/TransitionAnimationHelper.java
+++ b/libs/WindowManager/Shell/src/com/android/wm/shell/transition/TransitionAnimationHelper.java
@@ -55,6 +55,7 @@
import com.android.internal.R;
import com.android.internal.policy.TransitionAnimation;
import com.android.internal.protolog.common.ProtoLog;
+import com.android.window.flags.Flags;
import com.android.wm.shell.protolog.ShellProtoLogGroup;
import com.android.wm.shell.shared.TransitionUtil;
@@ -71,7 +72,12 @@
final int changeFlags = change.getFlags();
final boolean enter = TransitionUtil.isOpeningType(changeMode);
final boolean isTask = change.getTaskInfo() != null;
- final TransitionInfo.AnimationOptions options = info.getAnimationOptions();
+ final TransitionInfo.AnimationOptions options;
+ if (Flags.moveAnimationOptionsToChange()) {
+ options = change.getAnimationOptions();
+ } else {
+ options = info.getAnimationOptions();
+ }
final int overrideType = options != null ? options.getType() : ANIM_NONE;
int animAttr = 0;
boolean translucent = false;
@@ -246,7 +252,7 @@
if (!a.getShowBackdrop()) {
return defaultColor;
}
- if (info.getAnimationOptions() != null
+ if (!Flags.moveAnimationOptionsToChange() && info.getAnimationOptions() != null
&& info.getAnimationOptions().getBackgroundColor() != 0) {
// If available use the background color provided through AnimationOptions
return info.getAnimationOptions().getBackgroundColor();
diff --git a/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/activityembedding/ActivityEmbeddingAnimationRunnerTests.java b/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/activityembedding/ActivityEmbeddingAnimationRunnerTests.java
index ea522cd..bd20c11 100644
--- a/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/activityembedding/ActivityEmbeddingAnimationRunnerTests.java
+++ b/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/activityembedding/ActivityEmbeddingAnimationRunnerTests.java
@@ -32,14 +32,19 @@
import static org.mockito.Mockito.verifyNoMoreInteractions;
import android.animation.Animator;
+import android.platform.test.annotations.DisableFlags;
+import android.platform.test.annotations.EnableFlags;
+import android.platform.test.flag.junit.SetFlagsRule;
import android.window.TransitionInfo;
import androidx.test.ext.junit.runners.AndroidJUnit4;
import androidx.test.filters.SmallTest;
+import com.android.window.flags.Flags;
import com.android.wm.shell.transition.TransitionInfoBuilder;
import org.junit.Before;
+import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.ArgumentCaptor;
@@ -56,12 +61,16 @@
@RunWith(AndroidJUnit4.class)
public class ActivityEmbeddingAnimationRunnerTests extends ActivityEmbeddingAnimationTestBase {
+ @Rule
+ public SetFlagsRule mRule = new SetFlagsRule();
+
@Before
public void setup() {
super.setUp();
doNothing().when(mController).onAnimationFinished(any());
}
+ @EnableFlags(Flags.FLAG_MOVE_ANIMATION_OPTIONS_TO_CHANGE)
@Test
public void testStartAnimation() {
final TransitionInfo info = new TransitionInfoBuilder(TRANSIT_OPEN, 0)
@@ -87,6 +96,7 @@
verify(mController).onAnimationFinished(mTransition);
}
+ @EnableFlags(Flags.FLAG_MOVE_ANIMATION_OPTIONS_TO_CHANGE)
@Test
public void testChangesBehindStartingWindow() {
final TransitionInfo info = new TransitionInfoBuilder(TRANSIT_OPEN, 0)
@@ -101,6 +111,7 @@
assertEquals(0, animator.getDuration());
}
+ @EnableFlags(Flags.FLAG_MOVE_ANIMATION_OPTIONS_TO_CHANGE)
@Test
public void testTransitionTypeDragResize() {
final TransitionInfo info = new TransitionInfoBuilder(TRANSIT_TASK_FRAGMENT_DRAG_RESIZE, 0)
@@ -115,8 +126,9 @@
assertEquals(0, animator.getDuration());
}
+ @DisableFlags(Flags.FLAG_MOVE_ANIMATION_OPTIONS_TO_CHANGE)
@Test
- public void testInvalidCustomAnimation() {
+ public void testInvalidCustomAnimation_disableAnimationOptionsPerChange() {
final TransitionInfo info = new TransitionInfoBuilder(TRANSIT_OPEN, 0)
.addChange(createChange(FLAG_IN_TASK_WITH_EMBEDDED_ACTIVITY))
.build();
@@ -131,4 +143,22 @@
// An invalid custom animation is equivalent to jump-cut.
assertEquals(0, animator.getDuration());
}
+
+ @EnableFlags(Flags.FLAG_MOVE_ANIMATION_OPTIONS_TO_CHANGE)
+ @Test
+ public void testInvalidCustomAnimation_enableAnimationOptionsPerChange() {
+ final TransitionInfo info = new TransitionInfoBuilder(TRANSIT_OPEN, 0)
+ .addChange(createChange(FLAG_IN_TASK_WITH_EMBEDDED_ACTIVITY))
+ .build();
+ info.getChanges().getFirst().setAnimationOptions(TransitionInfo.AnimationOptions
+ .makeCustomAnimOptions("packageName", 0 /* enterResId */, 0 /* exitResId */,
+ 0 /* backgroundColor */, false /* overrideTaskTransition */));
+ final Animator animator = mAnimRunner.createAnimator(
+ info, mStartTransaction, mFinishTransaction,
+ () -> mFinishCallback.onTransitionFinished(null /* wct */),
+ new ArrayList<>());
+
+ // An invalid custom animation is equivalent to jump-cut.
+ assertEquals(0, animator.getDuration());
+ }
}
diff --git a/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/activityembedding/ActivityEmbeddingControllerTests.java b/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/activityembedding/ActivityEmbeddingControllerTests.java
index 974d69b..39d5507 100644
--- a/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/activityembedding/ActivityEmbeddingControllerTests.java
+++ b/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/activityembedding/ActivityEmbeddingControllerTests.java
@@ -32,6 +32,9 @@
import android.animation.Animator;
import android.animation.ValueAnimator;
import android.graphics.Rect;
+import android.platform.test.annotations.DisableFlags;
+import android.platform.test.annotations.EnableFlags;
+import android.platform.test.flag.junit.SetFlagsRule;
import android.view.SurfaceControl;
import android.window.TransitionInfo;
@@ -39,9 +42,11 @@
import androidx.test.ext.junit.runners.AndroidJUnit4;
import androidx.test.filters.SmallTest;
+import com.android.window.flags.Flags;
import com.android.wm.shell.transition.TransitionInfoBuilder;
import org.junit.Before;
+import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -59,6 +64,9 @@
private static final Rect EMBEDDED_LEFT_BOUNDS = new Rect(0, 0, 500, 500);
private static final Rect EMBEDDED_RIGHT_BOUNDS = new Rect(500, 0, 1000, 500);
+ @Rule
+ public SetFlagsRule mRule = new SetFlagsRule();
+
@Before
public void setup() {
super.setUp();
@@ -66,11 +74,13 @@
any());
}
+ @EnableFlags(Flags.FLAG_MOVE_ANIMATION_OPTIONS_TO_CHANGE)
@Test
public void testInstantiate() {
verify(mShellInit).addInitCallback(any(), any());
}
+ @EnableFlags(Flags.FLAG_MOVE_ANIMATION_OPTIONS_TO_CHANGE)
@Test
public void testOnInit() {
mController.onInit();
@@ -78,6 +88,7 @@
verify(mTransitions).addHandler(mController);
}
+ @EnableFlags(Flags.FLAG_MOVE_ANIMATION_OPTIONS_TO_CHANGE)
@Test
public void testSetAnimScaleSetting() {
mController.setAnimScaleSetting(1.0f);
@@ -86,6 +97,7 @@
verify(mAnimSpec).setAnimScaleSetting(1.0f);
}
+ @EnableFlags(Flags.FLAG_MOVE_ANIMATION_OPTIONS_TO_CHANGE)
@Test
public void testStartAnimation_containsNonActivityEmbeddingChange() {
final TransitionInfo.Change nonEmbeddedOpen = createChange(0 /* flags */);
@@ -122,6 +134,7 @@
assertFalse(info2.getChanges().contains(nonEmbeddedClose));
}
+ @EnableFlags(Flags.FLAG_MOVE_ANIMATION_OPTIONS_TO_CHANGE)
@Test
public void testStartAnimation_containsOnlyFillTaskActivityEmbeddingChange() {
final TransitionInfo info = new TransitionInfoBuilder(TRANSIT_OPEN, 0)
@@ -138,6 +151,7 @@
verifyNoMoreInteractions(mFinishCallback);
}
+ @EnableFlags(Flags.FLAG_MOVE_ANIMATION_OPTIONS_TO_CHANGE)
@Test
public void testStartAnimation_containsActivityEmbeddingSplitChange() {
// Change that occupies only part of the Task.
@@ -155,6 +169,7 @@
verifyNoMoreInteractions(mFinishTransaction);
}
+ @EnableFlags(Flags.FLAG_MOVE_ANIMATION_OPTIONS_TO_CHANGE)
@Test
public void testStartAnimation_containsChangeEnterActivityEmbeddingSplit() {
// Change that is entering ActivityEmbedding split.
@@ -171,6 +186,7 @@
verifyNoMoreInteractions(mFinishTransaction);
}
+ @EnableFlags(Flags.FLAG_MOVE_ANIMATION_OPTIONS_TO_CHANGE)
@Test
public void testStartAnimation_containsChangeExitActivityEmbeddingSplit() {
// Change that is exiting ActivityEmbedding split.
@@ -187,8 +203,9 @@
verifyNoMoreInteractions(mFinishTransaction);
}
+ @DisableFlags(Flags.FLAG_MOVE_ANIMATION_OPTIONS_TO_CHANGE)
@Test
- public void testShouldAnimate_containsAnimationOptions() {
+ public void testShouldAnimate_containsAnimationOptions_disableAnimOptionsPerChange() {
final TransitionInfo info = new TransitionInfoBuilder(TRANSIT_CLOSE, 0)
.addChange(createEmbeddedChange(EMBEDDED_RIGHT_BOUNDS, TASK_BOUNDS, TASK_BOUNDS))
.build();
@@ -206,6 +223,28 @@
assertFalse(mController.shouldAnimate(info));
}
+ @EnableFlags(Flags.FLAG_MOVE_ANIMATION_OPTIONS_TO_CHANGE)
+ @Test
+ public void testShouldAnimate_containsAnimationOptions_enableAnimOptionsPerChange() {
+ final TransitionInfo info = new TransitionInfoBuilder(TRANSIT_CLOSE, 0)
+ .addChange(createEmbeddedChange(EMBEDDED_RIGHT_BOUNDS, TASK_BOUNDS, TASK_BOUNDS))
+ .build();
+ final TransitionInfo.Change change = info.getChanges().getFirst();
+
+ change.setAnimationOptions(TransitionInfo.AnimationOptions
+ .makeCustomAnimOptions("packageName", 0 /* enterResId */, 0 /* exitResId */,
+ 0 /* backgroundColor */, false /* overrideTaskTransition */));
+ assertTrue(mController.shouldAnimate(info));
+
+ change.setAnimationOptions(TransitionInfo.AnimationOptions
+ .makeSceneTransitionAnimOptions());
+ assertFalse(mController.shouldAnimate(info));
+
+ change.setAnimationOptions(TransitionInfo.AnimationOptions.makeCrossProfileAnimOptions());
+ assertFalse(mController.shouldAnimate(info));
+ }
+
+ @EnableFlags(Flags.FLAG_MOVE_ANIMATION_OPTIONS_TO_CHANGE)
@UiThreadTest
@Test
public void testMergeAnimation() {
@@ -242,6 +281,7 @@
verify(mFinishCallback).onTransitionFinished(any());
}
+ @EnableFlags(Flags.FLAG_MOVE_ANIMATION_OPTIONS_TO_CHANGE)
@Test
public void testOnAnimationFinished() {
// Should not call finish when there is no transition.
diff --git a/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/desktopmode/DragToDesktopTransitionHandlerTest.kt b/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/desktopmode/DragToDesktopTransitionHandlerTest.kt
index 2ade3fb..bbf523b 100644
--- a/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/desktopmode/DragToDesktopTransitionHandlerTest.kt
+++ b/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/desktopmode/DragToDesktopTransitionHandlerTest.kt
@@ -18,6 +18,8 @@
import com.android.wm.shell.RootTaskDisplayAreaOrganizer
import com.android.wm.shell.ShellTestCase
import com.android.wm.shell.TestRunningTaskInfoBuilder
+import com.android.wm.shell.common.split.SplitScreenConstants.SPLIT_POSITION_BOTTOM_OR_RIGHT
+import com.android.wm.shell.common.split.SplitScreenConstants.SPLIT_POSITION_TOP_OR_LEFT
import com.android.wm.shell.splitscreen.SplitScreenController
import com.android.wm.shell.transition.Transitions
import com.android.wm.shell.transition.Transitions.TRANSIT_DESKTOP_MODE_CANCEL_DRAG_TO_DESKTOP
@@ -48,6 +50,7 @@
@Mock private lateinit var transitions: Transitions
@Mock private lateinit var taskDisplayAreaOrganizer: RootTaskDisplayAreaOrganizer
@Mock private lateinit var splitScreenController: SplitScreenController
+ @Mock private lateinit var dragAnimator: MoveToDesktopAnimator
private val transactionSupplier = Supplier { mock<SurfaceControl.Transaction>() }
@@ -68,7 +71,6 @@
@Test
fun startDragToDesktop_animateDragWhenReady() {
val task = createTask()
- val dragAnimator = mock<MoveToDesktopAnimator>()
// Simulate transition is started.
val transition = startDragToDesktopTransition(task, dragAnimator)
@@ -90,36 +92,36 @@
@Test
fun startDragToDesktop_cancelledBeforeReady_startCancelTransition() {
- val task = createTask()
- val dragAnimator = mock<MoveToDesktopAnimator>()
- // Simulate transition is started and is ready to animate.
- val transition = startDragToDesktopTransition(task, dragAnimator)
-
- handler.cancelDragToDesktopTransition()
-
- handler.startAnimation(
- transition = transition,
- info =
- createTransitionInfo(
- type = TRANSIT_DESKTOP_MODE_START_DRAG_TO_DESKTOP,
- draggedTask = task
- ),
- startTransaction = mock(),
- finishTransaction = mock(),
- finishCallback = {}
- )
-
- // Don't even animate the "drag" since it was already cancelled.
- verify(dragAnimator, never()).startAnimation()
- // Instead, start the cancel transition.
+ performEarlyCancel(DragToDesktopTransitionHandler.CancelState.STANDARD_CANCEL)
verify(transitions)
.startTransition(eq(TRANSIT_DESKTOP_MODE_CANCEL_DRAG_TO_DESKTOP), any(), eq(handler))
}
@Test
+ fun startDragToDesktop_cancelledBeforeReady_verifySplitLeftCancel() {
+ performEarlyCancel(DragToDesktopTransitionHandler.CancelState.CANCEL_SPLIT_LEFT)
+ verify(splitScreenController).requestEnterSplitSelect(
+ any(),
+ any(),
+ eq(SPLIT_POSITION_TOP_OR_LEFT),
+ any()
+ )
+ }
+
+ @Test
+ fun startDragToDesktop_cancelledBeforeReady_verifySplitRightCancel() {
+ performEarlyCancel(DragToDesktopTransitionHandler.CancelState.CANCEL_SPLIT_RIGHT)
+ verify(splitScreenController).requestEnterSplitSelect(
+ any(),
+ any(),
+ eq(SPLIT_POSITION_BOTTOM_OR_RIGHT),
+ any()
+ )
+ }
+
+ @Test
fun startDragToDesktop_aborted_finishDropped() {
val task = createTask()
- val dragAnimator = mock<MoveToDesktopAnimator>()
// Simulate transition is started.
val transition = startDragToDesktopTransition(task, dragAnimator)
// But the transition was aborted.
@@ -137,14 +139,15 @@
@Test
fun startDragToDesktop_aborted_cancelDropped() {
val task = createTask()
- val dragAnimator = mock<MoveToDesktopAnimator>()
// Simulate transition is started.
val transition = startDragToDesktopTransition(task, dragAnimator)
// But the transition was aborted.
handler.onTransitionConsumed(transition, aborted = true, mock())
// Attempt to finish the failed drag start.
- handler.cancelDragToDesktopTransition()
+ handler.cancelDragToDesktopTransition(
+ DragToDesktopTransitionHandler.CancelState.STANDARD_CANCEL
+ )
// Should not be attempted and state should be reset.
assertFalse(handler.inProgress)
@@ -153,7 +156,6 @@
@Test
fun startDragToDesktop_anotherTransitionInProgress_startDropped() {
val task = createTask()
- val dragAnimator = mock<MoveToDesktopAnimator>()
// Simulate attempt to start two drag to desktop transitions.
startDragToDesktopTransition(task, dragAnimator)
@@ -169,39 +171,63 @@
@Test
fun cancelDragToDesktop_startWasReady_cancel() {
- val task = createTask()
- val dragAnimator = mock<MoveToDesktopAnimator>()
- whenever(dragAnimator.position).thenReturn(PointF())
- // Simulate transition is started and is ready to animate.
- val transition = startDragToDesktopTransition(task, dragAnimator)
- handler.startAnimation(
- transition = transition,
- info =
- createTransitionInfo(
- type = TRANSIT_DESKTOP_MODE_START_DRAG_TO_DESKTOP,
- draggedTask = task
- ),
- startTransaction = mock(),
- finishTransaction = mock(),
- finishCallback = {}
- )
+ startDrag()
// Then user cancelled after it had already started.
- handler.cancelDragToDesktopTransition()
+ handler.cancelDragToDesktopTransition(
+ DragToDesktopTransitionHandler.CancelState.STANDARD_CANCEL
+ )
// Cancel animation should run since it had already started.
verify(dragAnimator).cancelAnimator()
}
@Test
+ fun cancelDragToDesktop_splitLeftCancelType_splitRequested() {
+ startDrag()
+
+ // Then user cancelled it, requesting split.
+ handler.cancelDragToDesktopTransition(
+ DragToDesktopTransitionHandler.CancelState.CANCEL_SPLIT_LEFT
+ )
+
+ // Verify the request went through split controller.
+ verify(splitScreenController).requestEnterSplitSelect(
+ any(),
+ any(),
+ eq(SPLIT_POSITION_TOP_OR_LEFT),
+ any()
+ )
+ }
+
+ @Test
+ fun cancelDragToDesktop_splitRightCancelType_splitRequested() {
+ startDrag()
+
+ // Then user cancelled it, requesting split.
+ handler.cancelDragToDesktopTransition(
+ DragToDesktopTransitionHandler.CancelState.CANCEL_SPLIT_RIGHT
+ )
+
+ // Verify the request went through split controller.
+ verify(splitScreenController).requestEnterSplitSelect(
+ any(),
+ any(),
+ eq(SPLIT_POSITION_BOTTOM_OR_RIGHT),
+ any()
+ )
+ }
+
+ @Test
fun cancelDragToDesktop_startWasNotReady_animateCancel() {
val task = createTask()
- val dragAnimator = mock<MoveToDesktopAnimator>()
// Simulate transition is started and is ready to animate.
startDragToDesktopTransition(task, dragAnimator)
// Then user cancelled before the transition was ready and animated.
- handler.cancelDragToDesktopTransition()
+ handler.cancelDragToDesktopTransition(
+ DragToDesktopTransitionHandler.CancelState.STANDARD_CANCEL
+ )
// No need to animate the cancel since the start animation couldn't even start.
verifyZeroInteractions(dragAnimator)
@@ -210,7 +236,9 @@
@Test
fun cancelDragToDesktop_transitionNotInProgress_dropCancel() {
// Then cancel is called before the transition was started.
- handler.cancelDragToDesktopTransition()
+ handler.cancelDragToDesktopTransition(
+ DragToDesktopTransitionHandler.CancelState.STANDARD_CANCEL
+ )
// Verify cancel is dropped.
verify(transitions, never()).startTransition(
@@ -233,6 +261,24 @@
)
}
+ private fun startDrag() {
+ val task = createTask()
+ whenever(dragAnimator.position).thenReturn(PointF())
+ // Simulate transition is started and is ready to animate.
+ val transition = startDragToDesktopTransition(task, dragAnimator)
+ handler.startAnimation(
+ transition = transition,
+ info =
+ createTransitionInfo(
+ type = TRANSIT_DESKTOP_MODE_START_DRAG_TO_DESKTOP,
+ draggedTask = task
+ ),
+ startTransaction = mock(),
+ finishTransaction = mock(),
+ finishCallback = {}
+ )
+ }
+
private fun startDragToDesktopTransition(
task: RunningTaskInfo,
dragAnimator: MoveToDesktopAnimator
@@ -250,6 +296,29 @@
return token
}
+ private fun performEarlyCancel(cancelState: DragToDesktopTransitionHandler.CancelState) {
+ val task = createTask()
+ // Simulate transition is started and is ready to animate.
+ val transition = startDragToDesktopTransition(task, dragAnimator)
+
+ handler.cancelDragToDesktopTransition(cancelState)
+
+ handler.startAnimation(
+ transition = transition,
+ info =
+ createTransitionInfo(
+ type = TRANSIT_DESKTOP_MODE_START_DRAG_TO_DESKTOP,
+ draggedTask = task
+ ),
+ startTransaction = mock(),
+ finishTransaction = mock(),
+ finishCallback = {}
+ )
+
+ // Don't even animate the "drag" since it was already cancelled.
+ verify(dragAnimator, never()).startAnimation()
+ }
+
private fun createTask(
@WindowingMode windowingMode: Int = WINDOWING_MODE_FULLSCREEN,
isHome: Boolean = false,
diff --git a/media/java/android/media/RingtoneManager.java b/media/java/android/media/RingtoneManager.java
index 86113df..47e3a0f 100644
--- a/media/java/android/media/RingtoneManager.java
+++ b/media/java/android/media/RingtoneManager.java
@@ -921,9 +921,13 @@
+ " ignored: failure to find mimeType (no access from this context?)");
return;
}
- if (!(mimeType.startsWith("audio/") || mimeType.equals("application/ogg"))) {
+ if (!(mimeType.startsWith("audio/") || mimeType.equals("application/ogg")
+ || mimeType.equals("application/x-flac")
+ // also check for video ringtones
+ || mimeType.startsWith("video/") || mimeType.equals("application/mp4"))) {
Log.e(TAG, "setActualDefaultRingtoneUri for URI:" + ringtoneUri
- + " ignored: associated mimeType:" + mimeType + " is not an audio type");
+ + " ignored: associated MIME type:" + mimeType
+ + " is not a recognized audio or video type");
return;
}
}
diff --git a/media/tests/AudioPolicyTest/src/com/android/audiopolicytest/AudioPolicyDeathTest.java b/media/tests/AudioPolicyTest/src/com/android/audiopolicytest/AudioPolicyDeathTest.java
index 48c51af..61670e9 100644
--- a/media/tests/AudioPolicyTest/src/com/android/audiopolicytest/AudioPolicyDeathTest.java
+++ b/media/tests/AudioPolicyTest/src/com/android/audiopolicytest/AudioPolicyDeathTest.java
@@ -128,7 +128,7 @@
res.getInt(mContext.getResources().getString(R.string.status_key)));
});
- // Launch process registering a dynamic auido policy and dying after RECORD_TIME_MS ms
+ // Launch process registering a dynamic audio policy and dying after RECORD_TIME_MS ms
// RECORD_TIME_MS must be shorter than PLAYBACK_TIME_MS
Intent intent = new Intent(mContext, AudioPolicyDeathTestActivity.class);
intent.putExtra(mContext.getResources().getString(R.string.capture_duration_key),
diff --git a/packages/CompanionDeviceManager/Android.bp b/packages/CompanionDeviceManager/Android.bp
index ce32ec4..4ef1c2b 100644
--- a/packages/CompanionDeviceManager/Android.bp
+++ b/packages/CompanionDeviceManager/Android.bp
@@ -48,4 +48,9 @@
platform_apis: true,
generate_product_characteristics_rro: true,
+
+ optimize: {
+ optimize: true,
+ optimized_shrink_resources: true,
+ },
}
diff --git a/packages/DynamicSystemInstallationService/Android.bp b/packages/DynamicSystemInstallationService/Android.bp
index b8f54b3..ae69019 100644
--- a/packages/DynamicSystemInstallationService/Android.bp
+++ b/packages/DynamicSystemInstallationService/Android.bp
@@ -30,10 +30,6 @@
certificate: "platform",
privileged: true,
platform_apis: true,
-
- optimize: {
- enabled: false,
- },
}
java_library {
diff --git a/packages/PackageInstaller/src/com/android/packageinstaller/InstallStart.java b/packages/PackageInstaller/src/com/android/packageinstaller/InstallStart.java
index 3fea599..379dfe3 100644
--- a/packages/PackageInstaller/src/com/android/packageinstaller/InstallStart.java
+++ b/packages/PackageInstaller/src/com/android/packageinstaller/InstallStart.java
@@ -125,13 +125,14 @@
-1, callingUid) == PackageManager.PERMISSION_GRANTED;
boolean isSystemDownloadsProvider = PackageUtil.getSystemDownloadsProviderInfo(
mPackageManager, callingUid) != null;
- boolean isTrustedSource = false;
- if (sourceInfo != null && sourceInfo.isPrivilegedApp()) {
- isTrustedSource = intent.getBooleanExtra(Intent.EXTRA_NOT_UNKNOWN_SOURCE, false) || (
- callingUid != Process.INVALID_UID && checkPermission(
- Manifest.permission.INSTALL_PACKAGES, -1 /* pid */, callingUid)
- == PackageManager.PERMISSION_GRANTED);
- }
+
+ boolean isPrivilegedAndKnown = (sourceInfo != null && sourceInfo.isPrivilegedApp()) &&
+ intent.getBooleanExtra(Intent.EXTRA_NOT_UNKNOWN_SOURCE, false);
+ boolean isInstallPkgPermissionGranted =
+ checkPermission(Manifest.permission.INSTALL_PACKAGES, /* pid= */ -1, callingUid)
+ == PackageManager.PERMISSION_GRANTED;
+
+ boolean isTrustedSource = isPrivilegedAndKnown || isInstallPkgPermissionGranted;
if (!isTrustedSource && !isSystemDownloadsProvider && !isDocumentsManager
&& callingUid != Process.INVALID_UID) {
@@ -154,7 +155,7 @@
mAbortInstall = true;
}
- checkDevicePolicyRestrictions();
+ checkDevicePolicyRestrictions(isTrustedSource);
final String installerPackageNameFromIntent = getIntent().getStringExtra(
Intent.EXTRA_INSTALLER_PACKAGE_NAME);
@@ -304,12 +305,17 @@
return callingUid == installerUid;
}
- private void checkDevicePolicyRestrictions() {
- final String[] restrictions = new String[] {
- UserManager.DISALLOW_INSTALL_APPS,
- UserManager.DISALLOW_INSTALL_UNKNOWN_SOURCES,
- UserManager.DISALLOW_INSTALL_UNKNOWN_SOURCES_GLOBALLY
- };
+ private void checkDevicePolicyRestrictions(boolean isTrustedSource) {
+ String[] restrictions;
+ if(isTrustedSource) {
+ restrictions = new String[] { UserManager.DISALLOW_INSTALL_APPS };
+ } else {
+ restrictions = new String[] {
+ UserManager.DISALLOW_INSTALL_APPS,
+ UserManager.DISALLOW_INSTALL_UNKNOWN_SOURCES,
+ UserManager.DISALLOW_INSTALL_UNKNOWN_SOURCES_GLOBALLY
+ };
+ }
final DevicePolicyManager dpm = getSystemService(DevicePolicyManager.class);
for (String restriction : restrictions) {
diff --git a/packages/SettingsProvider/src/com/android/providers/settings/SettingsProvider.java b/packages/SettingsProvider/src/com/android/providers/settings/SettingsProvider.java
index 096cccc..15f8a7b 100644
--- a/packages/SettingsProvider/src/com/android/providers/settings/SettingsProvider.java
+++ b/packages/SettingsProvider/src/com/android/providers/settings/SettingsProvider.java
@@ -1972,7 +1972,7 @@
File cacheFile = getCacheFile(name, callingUserId);
if (cacheFile != null) {
- if (!isValidAudioUri(name, value)) {
+ if (!isValidMediaUri(name, value)) {
return false;
}
// Invalidate any relevant cache files
@@ -2031,7 +2031,7 @@
return true;
}
- private boolean isValidAudioUri(String name, String uri) {
+ private boolean isValidMediaUri(String name, String uri) {
if (uri != null) {
Uri audioUri = Uri.parse(uri);
if (Settings.AUTHORITY.equals(
@@ -2049,10 +2049,13 @@
return false;
}
if (!(mimeType.startsWith("audio/") || mimeType.equals("application/ogg")
- || mimeType.equals("application/x-flac"))) {
+ || mimeType.equals("application/x-flac")
+ // also check for video ringtones
+ || mimeType.startsWith("video/") || mimeType.equals("application/mp4"))) {
Slog.e(LOG_TAG,
"mutateSystemSetting for setting: " + name + " URI: " + audioUri
- + " ignored: associated mimeType: " + mimeType + " is not an audio type");
+ + " ignored: associated MIME type:" + mimeType
+ + " is not a recognized audio or video type");
return false;
}
}
diff --git a/packages/SystemUI/Android.bp b/packages/SystemUI/Android.bp
index 7a098ee..07a00fb 100644
--- a/packages/SystemUI/Android.bp
+++ b/packages/SystemUI/Android.bp
@@ -78,29 +78,15 @@
visibility: ["//visibility:private"],
}
-// Tests where robolectric conversion caused errors in SystemUITests at runtime
-filegroup {
- name: "SystemUI-tests-broken-robofiles-sysui-run",
- srcs: [
- "tests/src/**/systemui/globalactions/GlobalActionsDialogLiteTest.java",
- "tests/src/**/systemui/media/controls/domain/pipeline/LegacyMediaDataManagerImplTest.kt",
- "tests/src/**/systemui/media/controls/domain/pipeline/MediaDataProcessorTest.kt",
- "tests/src/**/systemui/media/dialog/MediaOutputAdapterTest.java",
- "tests/src/**/systemui/media/dialog/MediaOutputBaseDialogTest.java",
- "tests/src/**/systemui/media/dialog/MediaOutputBroadcastDialogTest.java",
- "tests/src/**/systemui/media/dialog/MediaOutputDialogTest.java",
- "tests/src/**/systemui/mediaprojection/permission/MediaProjectionPermissionDialogDelegateTest.kt",
- ],
-}
-
+// Tests where robolectric failed at runtime. (go/multivalent-tests)
filegroup {
name: "SystemUI-tests-broken-robofiles-run",
srcs: [
- "tests/src/**/systemui/keyguard/CustomizationProviderTest.kt",
"tests/src/**/systemui/globalactions/GlobalActionsColumnLayoutTest.java",
"tests/src/**/systemui/globalactions/GlobalActionsDialogLiteTest.java",
"tests/src/**/systemui/globalactions/GlobalActionsImeTest.java",
"tests/src/**/systemui/graphics/ImageLoaderTest.kt",
+ "tests/src/**/systemui/keyguard/CustomizationProviderTest.kt",
"tests/src/**/systemui/keyguard/KeyguardViewMediatorTest.java",
"tests/src/**/systemui/keyguard/LifecycleTest.java",
"tests/src/**/systemui/keyguard/data/repository/KeyguardTransitionRepositoryTest.kt",
@@ -114,12 +100,22 @@
"tests/src/**/systemui/media/dialog/MediaOutputDialogTest.java",
"tests/src/**/systemui/media/controls/domain/resume/MediaResumeListenerTest.kt",
"tests/src/**/systemui/mediaprojection/taskswitcher/ui/TaskSwitcherNotificationCoordinatorTest.kt",
- "tests/src/**/systemui/util/LifecycleFragmentTest.java",
- "tests/src/**/systemui/util/TestableAlertDialogTest.kt",
- "tests/src/**/systemui/util/kotlin/PairwiseFlowTest",
- "tests/src/**/systemui/util/sensors/AsyncManagerTest.java",
- "tests/src/**/systemui/util/sensors/ThresholdSensorImplTest.java",
- "tests/src/**/systemui/util/wakelock/KeepAwakeAnimationListenerTest.java",
+ "tests/src/**/systemui/navigationbar/NavigationBarButtonTest.java",
+ "tests/src/**/systemui/people/PeopleProviderTest.java",
+ "tests/src/**/systemui/people/PeopleSpaceUtilsTest.java",
+ "tests/src/**/systemui/people/widget/PeopleSpaceWidgetManagerTest.java",
+ "tests/src/**/systemui/people/PeopleTileViewHelperTest.java",
+ "tests/src/**/systemui/power/data/repository/PowerRepositoryImplTest.kt",
+ "tests/src/**/systemui/privacy/PrivacyConfigFlagsTest.kt",
+ "tests/src/**/systemui/privacy/PrivacyDialogV2Test.kt",
+ "tests/src/**/systemui/qs/external/TileRequestDialogEventLoggerTest.kt",
+ "tests/src/**/systemui/qs/AutoAddTrackerTest.kt",
+ "tests/src/**/systemui/qs/external/TileRequestDialogEventLoggerTest.kt",
+ "tests/src/**/systemui/qs/tiles/DndTileTest.kt",
+ "tests/src/**/systemui/qs/tiles/DreamTileTest.java",
+ "tests/src/**/systemui/qs/FgsManagerControllerTest.java",
+ "tests/src/**/systemui/qs/QSPanelTest.kt",
+ "tests/src/**/systemui/reardisplay/RearDisplayDialogControllerTest.java",
"tests/src/**/systemui/statusbar/KeyboardShortcutListSearchTest.java",
"tests/src/**/systemui/statusbar/KeyboardShortcutsTest.java",
"tests/src/**/systemui/statusbar/KeyguardIndicationControllerWithCoroutinesTest.kt",
@@ -166,6 +162,17 @@
"tests/src/**/systemui/statusbar/policy/RemoteInputViewTest.java",
"tests/src/**/systemui/statusbar/policy/SmartReplyViewTest.java",
"tests/src/**/systemui/statusbar/StatusBarStateControllerImplTest.kt",
+ "tests/src/**/systemui/theme/ThemeOverlayApplierTest.java",
+ "tests/src/**/systemui/touch/TouchInsetManagerTest.java",
+ "tests/src/**/systemui/util/LifecycleFragmentTest.java",
+ "tests/src/**/systemui/util/TestableAlertDialogTest.kt",
+ "tests/src/**/systemui/util/kotlin/PairwiseFlowTest",
+ "tests/src/**/systemui/util/sensors/AsyncManagerTest.java",
+ "tests/src/**/systemui/util/sensors/ThresholdSensorImplTest.java",
+ "tests/src/**/systemui/util/wakelock/KeepAwakeAnimationListenerTest.java",
+ "tests/src/**/systemui/volume/VolumeDialogImplTest.java",
+ "tests/src/**/systemui/wallet/controller/QuickAccessWalletControllerTest.java",
+ "tests/src/**/systemui/wallet/ui/WalletScreenControllerTest.java",
],
}
@@ -800,7 +807,6 @@
":SystemUI-tests-robofiles",
],
exclude_srcs: [
- ":SystemUI-tests-broken-robofiles-sysui-run",
":SystemUI-tests-broken-robofiles-compile",
":SystemUI-tests-broken-robofiles-run",
],
diff --git a/packages/SystemUI/aconfig/systemui.aconfig b/packages/SystemUI/aconfig/systemui.aconfig
index 3310cfa..2cb297a 100644
--- a/packages/SystemUI/aconfig/systemui.aconfig
+++ b/packages/SystemUI/aconfig/systemui.aconfig
@@ -33,6 +33,13 @@
}
flag {
+ name: "notification_row_content_binder_refactor"
+ namespace: "systemui"
+ description: "Convert the NotificationContentInflater to Kotlin and restructure it to support modern views"
+ bug: "343942780"
+}
+
+flag {
name: "notification_minimalism_prototype"
namespace: "systemui"
description: "Prototype of notification minimalism; the new 'Intermediate' lockscreen customization proposal."
@@ -407,6 +414,13 @@
}
flag {
+ name: "clock_reactive_variants"
+ namespace: "systemui"
+ description: "Add reactive variant fonts to some clocks"
+ bug: "343495953"
+}
+
+flag {
name: "fast_unlock_transition"
namespace: "systemui"
description: "Faster wallpaper unlock transition"
diff --git a/packages/SystemUI/animation/src/com/android/systemui/surfaceeffects/glowboxeffect/GlowBoxConfig.kt b/packages/SystemUI/animation/src/com/android/systemui/surfaceeffects/glowboxeffect/GlowBoxConfig.kt
new file mode 100644
index 0000000..72f0e86
--- /dev/null
+++ b/packages/SystemUI/animation/src/com/android/systemui/surfaceeffects/glowboxeffect/GlowBoxConfig.kt
@@ -0,0 +1,46 @@
+/*
+ * 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.systemui.surfaceeffects.glowboxeffect
+
+/** Parameters used to play [GlowBoxEffect]. */
+data class GlowBoxConfig(
+ /** Start center position X in px. */
+ val startCenterX: Float,
+ /** Start center position Y in px. */
+ val startCenterY: Float,
+ /** End center position X in px. */
+ val endCenterX: Float,
+ /** End center position Y in px. */
+ val endCenterY: Float,
+ /** Width of the box in px. */
+ val width: Float,
+ /** Height of the box in px. */
+ val height: Float,
+ /** Color of the box in ARGB, Apply alpha value if needed. */
+ val color: Int,
+ /** Amount of blur (or glow) of the box. */
+ val blurAmount: Float,
+ /**
+ * Duration of the animation. Note that the full duration of the animation is
+ * [duration] + [easeInDuration] + [easeOutDuration].
+ */
+ val duration: Long,
+ /** Ease in duration of the animation. */
+ val easeInDuration: Long,
+ /** Ease out duration of the animation. */
+ val easeOutDuration: Long,
+)
diff --git a/packages/SystemUI/animation/src/com/android/systemui/surfaceeffects/glowboxeffect/GlowBoxEffect.kt b/packages/SystemUI/animation/src/com/android/systemui/surfaceeffects/glowboxeffect/GlowBoxEffect.kt
new file mode 100644
index 0000000..5e590c1
--- /dev/null
+++ b/packages/SystemUI/animation/src/com/android/systemui/surfaceeffects/glowboxeffect/GlowBoxEffect.kt
@@ -0,0 +1,185 @@
+/*
+ * 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.systemui.surfaceeffects.glowboxeffect
+
+import android.animation.ValueAnimator
+import android.graphics.Paint
+import androidx.annotation.VisibleForTesting
+import androidx.core.animation.doOnEnd
+import com.android.systemui.surfaceeffects.PaintDrawCallback
+import com.android.systemui.surfaceeffects.utils.MathUtils.lerp
+
+/** Glow box effect where the box moves from start to end positions defined in the [config]. */
+class GlowBoxEffect(
+ private var config: GlowBoxConfig,
+ private val paintDrawCallback: PaintDrawCallback,
+ private val stateChangedCallback: AnimationStateChangedCallback? = null
+) {
+ private val glowBoxShader =
+ GlowBoxShader().apply {
+ setSize(config.width, config.height)
+ setCenter(config.startCenterX, config.startCenterY)
+ setBlur(config.blurAmount)
+ setColor(config.color)
+ }
+ private var animator: ValueAnimator? = null
+ @VisibleForTesting var state: AnimationState = AnimationState.NOT_PLAYING
+ private val paint = Paint().apply { shader = glowBoxShader }
+
+ fun updateConfig(newConfig: GlowBoxConfig) {
+ this.config = newConfig
+
+ with(glowBoxShader) {
+ setSize(config.width, config.height)
+ setCenter(config.startCenterX, config.startCenterY)
+ setBlur(config.blurAmount)
+ setColor(config.color)
+ }
+ }
+
+ fun play() {
+ if (state != AnimationState.NOT_PLAYING) {
+ return
+ }
+
+ playEaseIn()
+ }
+
+ /** Finishes the animation with ease out. */
+ fun finish(force: Boolean = false) {
+ // If it's playing ease out, cancel immediately.
+ if (force && state == AnimationState.EASE_OUT) {
+ animator?.cancel()
+ return
+ }
+
+ // If it's playing either ease in or main, fast-forward to ease out.
+ if (state == AnimationState.EASE_IN || state == AnimationState.MAIN) {
+ animator?.pause()
+ playEaseOut()
+ }
+
+ // At this point, animation state should be ease out. Cancel it if force is true.
+ if (force) {
+ animator?.cancel()
+ }
+ }
+
+ private fun playEaseIn() {
+ if (state == AnimationState.EASE_IN) {
+ return
+ }
+ state = AnimationState.EASE_IN
+ stateChangedCallback?.onStart()
+
+ animator =
+ ValueAnimator.ofFloat(0f, 1f).apply {
+ duration = config.easeInDuration
+ addUpdateListener {
+ val progress = it.animatedValue as Float
+ glowBoxShader.setCenter(
+ lerp(config.startCenterX, config.endCenterX, progress),
+ lerp(config.startCenterY, config.endCenterY, progress)
+ )
+
+ draw()
+ }
+
+ doOnEnd {
+ animator = null
+ playMain()
+ }
+
+ start()
+ }
+ }
+
+ private fun playMain() {
+ if (state == AnimationState.MAIN) {
+ return
+ }
+ state = AnimationState.MAIN
+
+ animator =
+ ValueAnimator.ofFloat(0f, 1f).apply {
+ duration = config.duration
+ addUpdateListener { draw() }
+
+ doOnEnd {
+ animator = null
+ playEaseOut()
+ }
+
+ start()
+ }
+ }
+
+ private fun playEaseOut() {
+ if (state == AnimationState.EASE_OUT) return
+ state = AnimationState.EASE_OUT
+
+ animator =
+ ValueAnimator.ofFloat(0f, 1f).apply {
+ duration = config.easeOutDuration
+ addUpdateListener {
+ val progress = it.animatedValue as Float
+ glowBoxShader.setCenter(
+ lerp(config.endCenterX, config.startCenterX, progress),
+ lerp(config.endCenterY, config.startCenterY, progress)
+ )
+
+ draw()
+ }
+
+ doOnEnd {
+ animator = null
+ state = AnimationState.NOT_PLAYING
+ stateChangedCallback?.onEnd()
+ }
+
+ start()
+ }
+ }
+
+ private fun draw() {
+ paintDrawCallback.onDraw(paint)
+ }
+
+ /**
+ * The animation state of the effect. The animation state transitions as follows: [EASE_IN] ->
+ * [MAIN] -> [EASE_OUT] -> [NOT_PLAYING].
+ */
+ enum class AnimationState {
+ EASE_IN,
+ MAIN,
+ EASE_OUT,
+ NOT_PLAYING,
+ }
+
+ interface AnimationStateChangedCallback {
+ /**
+ * Triggered when the animation starts, specifically when the states goes from
+ * [AnimationState.NOT_PLAYING] to [AnimationState.EASE_IN].
+ */
+ fun onStart()
+ /**
+ * Triggered when the animation ends, specifically when the states goes from
+ * [AnimationState.EASE_OUT] to [AnimationState.NOT_PLAYING].
+ */
+ fun onEnd()
+ }
+}
diff --git a/packages/SystemUI/animation/src/com/android/systemui/surfaceeffects/glowboxeffect/GlowBoxShader.kt b/packages/SystemUI/animation/src/com/android/systemui/surfaceeffects/glowboxeffect/GlowBoxShader.kt
new file mode 100644
index 0000000..3693408
--- /dev/null
+++ b/packages/SystemUI/animation/src/com/android/systemui/surfaceeffects/glowboxeffect/GlowBoxShader.kt
@@ -0,0 +1,58 @@
+/*
+ * 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.systemui.surfaceeffects.glowboxeffect
+
+import android.graphics.RuntimeShader
+import com.android.systemui.surfaceeffects.shaderutil.SdfShaderLibrary
+
+/** Soft box shader. */
+class GlowBoxShader : RuntimeShader(GLOW_SHADER) {
+ // language=AGSL
+ private companion object {
+ private const val SHADER =
+ """
+ uniform half2 in_center;
+ uniform half2 in_size;
+ uniform half in_blur;
+ layout(color) uniform half4 in_color;
+
+ float4 main(float2 fragcoord) {
+ half glow = soften(sdBox(fragcoord - in_center, in_size), in_blur);
+ return in_color * (1. - glow);
+ }
+ """
+
+ private const val GLOW_SHADER =
+ SdfShaderLibrary.BOX_SDF + SdfShaderLibrary.SHADER_SDF_OPERATION_LIB + SHADER
+ }
+
+ fun setCenter(x: Float, y: Float) {
+ setFloatUniform("in_center", x, y)
+ }
+
+ fun setSize(width: Float, height: Float) {
+ setFloatUniform("in_size", width, height)
+ }
+
+ fun setBlur(blurAmount: Float) {
+ setFloatUniform("in_blur", blurAmount)
+ }
+
+ fun setColor(color: Int) {
+ setColorUniform("in_color", color)
+ }
+}
diff --git a/packages/SystemUI/animation/src/com/android/systemui/surfaceeffects/shaderutil/SdfShaderLibrary.kt b/packages/SystemUI/animation/src/com/android/systemui/surfaceeffects/shaderutil/SdfShaderLibrary.kt
index 7889893..4efab58 100644
--- a/packages/SystemUI/animation/src/com/android/systemui/surfaceeffects/shaderutil/SdfShaderLibrary.kt
+++ b/packages/SystemUI/animation/src/com/android/systemui/surfaceeffects/shaderutil/SdfShaderLibrary.kt
@@ -35,17 +35,26 @@
}
"""
+ const val BOX_SDF =
+ """
+ float sdBox(vec2 p, vec2 size) {
+ size = size * 0.5;
+ vec2 d = abs(p) - size;
+ return length(max(d, 0.)) + min(max(d.x, d.y), 0.) / size.y;
+ }
+ """
+
const val ROUNDED_BOX_SDF =
"""
float sdRoundedBox(vec2 p, vec2 size, float cornerRadius) {
size *= 0.5;
cornerRadius *= 0.5;
- vec2 d = abs(p)-size+cornerRadius;
+ vec2 d = abs(p) - size + cornerRadius;
float outside = length(max(d, 0.0));
float inside = min(max(d.x, d.y), 0.0);
- return (outside+inside-cornerRadius)/size.y;
+ return (outside + inside - cornerRadius) / size.y;
}
float roundedBoxRing(vec2 p, vec2 size, float cornerRadius,
diff --git a/packages/SystemUI/animation/src/com/android/systemui/surfaceeffects/utils/MathUtils.kt b/packages/SystemUI/animation/src/com/android/systemui/surfaceeffects/utils/MathUtils.kt
new file mode 100644
index 0000000..7ed3b87
--- /dev/null
+++ b/packages/SystemUI/animation/src/com/android/systemui/surfaceeffects/utils/MathUtils.kt
@@ -0,0 +1,24 @@
+/*
+ * 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.systemui.surfaceeffects.utils
+
+/** Copied from android.utils.MathUtils */
+object MathUtils {
+ fun lerp(start: Float, stop: Float, amount: Float): Float {
+ return start + (stop - start) * amount
+ }
+}
diff --git a/packages/SystemUI/compose/features/src/com/android/systemui/communal/ui/compose/CommunalContainer.kt b/packages/SystemUI/compose/features/src/com/android/systemui/communal/ui/compose/CommunalContainer.kt
index a90f82e..c329384 100644
--- a/packages/SystemUI/compose/features/src/com/android/systemui/communal/ui/compose/CommunalContainer.kt
+++ b/packages/SystemUI/compose/features/src/com/android/systemui/communal/ui/compose/CommunalContainer.kt
@@ -1,9 +1,16 @@
package com.android.systemui.communal.ui.compose
+import androidx.compose.animation.core.LinearEasing
+import androidx.compose.animation.core.RepeatMode
+import androidx.compose.animation.core.animateFloat
+import androidx.compose.animation.core.infiniteRepeatable
+import androidx.compose.animation.core.rememberInfiniteTransition
import androidx.compose.animation.core.tween
import androidx.compose.foundation.background
+import androidx.compose.foundation.isSystemInDarkTheme
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
+import androidx.compose.foundation.layout.BoxScope
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxSize
@@ -13,12 +20,20 @@
import androidx.compose.runtime.Composable
import androidx.compose.runtime.DisposableEffect
import androidx.compose.runtime.getValue
+import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.rememberCoroutineScope
+import androidx.compose.runtime.setValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
+import androidx.compose.ui.composed
+import androidx.compose.ui.draw.alpha
+import androidx.compose.ui.geometry.Offset
+import androidx.compose.ui.graphics.Brush
import androidx.compose.ui.graphics.Color
+import androidx.compose.ui.layout.onGloballyPositioned
import androidx.compose.ui.res.dimensionResource
+import androidx.compose.ui.unit.IntSize
import androidx.compose.ui.unit.dp
import androidx.lifecycle.compose.collectAsStateWithLifecycle
import com.android.compose.animation.scene.CommunalSwipeDetector
@@ -36,8 +51,10 @@
import com.android.compose.animation.scene.SwipeDirection
import com.android.compose.animation.scene.observableTransitionState
import com.android.compose.animation.scene.transitions
+import com.android.compose.theme.LocalAndroidColorScheme
import com.android.systemui.Flags
import com.android.systemui.Flags.glanceableHubFullscreenSwipe
+import com.android.systemui.communal.shared.model.CommunalBackgroundType
import com.android.systemui.communal.shared.model.CommunalScenes
import com.android.systemui.communal.shared.model.CommunalTransitionKeys
import com.android.systemui.communal.ui.compose.extensions.allowGestures
@@ -102,6 +119,10 @@
val touchesAllowed by viewModel.touchesAllowed.collectAsStateWithLifecycle(initialValue = false)
val showGestureIndicator by
viewModel.showGestureIndicator.collectAsStateWithLifecycle(initialValue = false)
+ val backgroundType by
+ viewModel.communalBackground.collectAsStateWithLifecycle(
+ initialValue = CommunalBackgroundType.DEFAULT
+ )
val state: MutableSceneTransitionLayoutState = remember {
MutableSceneTransitionLayoutState(
initialScene = currentSceneKey,
@@ -174,7 +195,7 @@
userActions =
mapOf(Swipe(SwipeDirection.Right, fromSource = Edge.Left) to CommunalScenes.Blank)
) {
- CommunalScene(colors, content)
+ CommunalScene(backgroundType, colors, content)
}
}
@@ -186,17 +207,87 @@
/** Scene containing the glanceable hub UI. */
@Composable
private fun SceneScope.CommunalScene(
+ backgroundType: CommunalBackgroundType,
colors: CommunalColors,
content: CommunalContent,
modifier: Modifier = Modifier,
) {
- val backgroundColor by colors.backgroundColor.collectAsStateWithLifecycle()
-
- Box(
- modifier =
- Modifier.element(Communal.Elements.Scrim)
- .fillMaxSize()
- .background(Color(backgroundColor.toArgb())),
- )
+ Box(modifier = Modifier.element(Communal.Elements.Scrim).fillMaxSize()) {
+ when (backgroundType) {
+ CommunalBackgroundType.DEFAULT -> DefaultBackground(colors = colors)
+ CommunalBackgroundType.STATIC_GRADIENT -> StaticLinearGradient()
+ CommunalBackgroundType.ANIMATED -> AnimatedLinearGradient()
+ }
+ }
with(content) { Content(modifier = modifier) }
}
+
+/** Default background of the hub, a single color */
+@Composable
+private fun BoxScope.DefaultBackground(
+ colors: CommunalColors,
+) {
+ val backgroundColor by colors.backgroundColor.collectAsStateWithLifecycle()
+ Box(
+ modifier = Modifier.matchParentSize().background(Color(backgroundColor.toArgb())),
+ )
+}
+
+/** Experimental hub background, static linear gradient */
+@Composable
+private fun BoxScope.StaticLinearGradient() {
+ val colors = LocalAndroidColorScheme.current
+ Box(
+ Modifier.matchParentSize()
+ .background(
+ Brush.linearGradient(colors = listOf(colors.primary, colors.primaryContainer)),
+ )
+ )
+ BackgroundTopScrim()
+}
+
+/** Experimental hub background, animated linear gradient */
+@Composable
+private fun BoxScope.AnimatedLinearGradient() {
+ val colors = LocalAndroidColorScheme.current
+ Box(
+ Modifier.matchParentSize()
+ .animatedGradientBackground(colors = listOf(colors.primary, colors.primaryContainer))
+ )
+ BackgroundTopScrim()
+}
+
+/** Scrim placed on top of the background in order to dim/bright colors */
+@Composable
+private fun BoxScope.BackgroundTopScrim() {
+ val darkTheme = isSystemInDarkTheme()
+ val scrimOnTopColor = if (darkTheme) Color.Black else Color.White
+ Box(Modifier.matchParentSize().alpha(0.34f).background(scrimOnTopColor))
+}
+
+/** Modifier which sets the background of a composable to an animated gradient */
+@Composable
+private fun Modifier.animatedGradientBackground(colors: List<Color>): Modifier = composed {
+ var size by remember { mutableStateOf(IntSize.Zero) }
+ val transition = rememberInfiniteTransition(label = "scrim background")
+ val startOffsetX by
+ transition.animateFloat(
+ initialValue = -size.width.toFloat(),
+ targetValue = size.width.toFloat(),
+ animationSpec =
+ infiniteRepeatable(
+ animation = tween(durationMillis = 5_000, easing = LinearEasing),
+ repeatMode = RepeatMode.Reverse,
+ ),
+ label = "scrim start offset"
+ )
+ background(
+ brush =
+ Brush.linearGradient(
+ colors = colors,
+ start = Offset(startOffsetX, 0f),
+ end = Offset(startOffsetX + size.width.toFloat(), size.height.toFloat()),
+ )
+ )
+ .onGloballyPositioned { size = it.size }
+}
diff --git a/packages/SystemUI/compose/features/src/com/android/systemui/notifications/ui/composable/Notifications.kt b/packages/SystemUI/compose/features/src/com/android/systemui/notifications/ui/composable/Notifications.kt
index ee3ffce..27a834b 100644
--- a/packages/SystemUI/compose/features/src/com/android/systemui/notifications/ui/composable/Notifications.kt
+++ b/packages/SystemUI/compose/features/src/com/android/systemui/notifications/ui/composable/Notifications.kt
@@ -170,6 +170,7 @@
maxScrimTop: () -> Float,
shouldPunchHoleBehindScrim: Boolean,
shouldFillMaxSize: Boolean = true,
+ shouldReserveSpaceForNavBar: Boolean = true,
shadeMode: ShadeMode,
modifier: Modifier = Modifier,
) {
@@ -353,7 +354,7 @@
.fillMaxWidth()
.notificationStackHeight(
view = stackScrollView,
- padding = navBarHeight.toInt()
+ padding = if (shouldReserveSpaceForNavBar) navBarHeight.toInt() else 0
)
.onSizeChanged { size -> stackHeight.intValue = size.height },
)
diff --git a/packages/SystemUI/compose/features/src/com/android/systemui/notifications/ui/composable/NotificationsShadeScene.kt b/packages/SystemUI/compose/features/src/com/android/systemui/notifications/ui/composable/NotificationsShadeScene.kt
index 7ca68fb..edb1727 100644
--- a/packages/SystemUI/compose/features/src/com/android/systemui/notifications/ui/composable/NotificationsShadeScene.kt
+++ b/packages/SystemUI/compose/features/src/com/android/systemui/notifications/ui/composable/NotificationsShadeScene.kt
@@ -94,6 +94,7 @@
maxScrimTop = { 0f },
shouldPunchHoleBehindScrim = false,
shouldFillMaxSize = false,
+ shouldReserveSpaceForNavBar = false,
shadeMode = ShadeMode.Dual,
modifier = Modifier.fillMaxWidth(),
)
diff --git a/packages/SystemUI/compose/features/src/com/android/systemui/qs/ui/composable/QuickSettingsShadeScene.kt b/packages/SystemUI/compose/features/src/com/android/systemui/qs/ui/composable/QuickSettingsShadeScene.kt
index 4d946bf..4bf90ec 100644
--- a/packages/SystemUI/compose/features/src/com/android/systemui/qs/ui/composable/QuickSettingsShadeScene.kt
+++ b/packages/SystemUI/compose/features/src/com/android/systemui/qs/ui/composable/QuickSettingsShadeScene.kt
@@ -16,22 +16,44 @@
package com.android.systemui.qs.ui.composable
+import androidx.compose.animation.AnimatedVisibility
+import androidx.compose.animation.EnterTransition
+import androidx.compose.animation.ExitTransition
+import androidx.compose.animation.core.tween
+import androidx.compose.animation.fadeIn
+import androidx.compose.animation.fadeOut
import androidx.compose.foundation.layout.Arrangement
+import androidx.compose.foundation.layout.Box
+import androidx.compose.foundation.layout.Column
+import androidx.compose.foundation.layout.fillMaxWidth
+import androidx.compose.foundation.layout.height
+import androidx.compose.foundation.layout.heightIn
import androidx.compose.foundation.layout.padding
+import androidx.compose.material3.Button
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
+import androidx.compose.runtime.getValue
+import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.dp
+import androidx.lifecycle.compose.collectAsStateWithLifecycle
import com.android.compose.animation.scene.SceneScope
import com.android.compose.animation.scene.UserAction
import com.android.compose.animation.scene.UserActionResult
+import com.android.systemui.battery.BatteryMeterViewController
+import com.android.systemui.brightness.ui.compose.BrightnessSliderContainer
import com.android.systemui.dagger.SysUISingleton
import com.android.systemui.keyguard.ui.composable.LockscreenContent
+import com.android.systemui.qs.panels.ui.compose.EditMode
+import com.android.systemui.qs.panels.ui.compose.TileGrid
import com.android.systemui.qs.ui.viewmodel.QuickSettingsShadeSceneViewModel
import com.android.systemui.scene.shared.model.Scenes
import com.android.systemui.scene.ui.composable.ComposableScene
+import com.android.systemui.shade.ui.composable.ExpandedShadeHeader
import com.android.systemui.shade.ui.composable.OverlayShade
-import com.android.systemui.shade.ui.viewmodel.OverlayShadeViewModel
+import com.android.systemui.shade.ui.viewmodel.ShadeHeaderViewModel
+import com.android.systemui.statusbar.phone.ui.StatusBarIconController
+import com.android.systemui.statusbar.phone.ui.TintedIconManager
import dagger.Lazy
import java.util.Optional
import javax.inject.Inject
@@ -41,9 +63,12 @@
class QuickSettingsShadeScene
@Inject
constructor(
- viewModel: QuickSettingsShadeSceneViewModel,
- private val overlayShadeViewModel: OverlayShadeViewModel,
+ private val viewModel: QuickSettingsShadeSceneViewModel,
private val lockscreenContent: Lazy<Optional<LockscreenContent>>,
+ private val shadeHeaderViewModel: ShadeHeaderViewModel,
+ private val tintedIconManagerFactory: TintedIconManager.Factory,
+ private val batteryMeterViewControllerFactory: BatteryMeterViewController.Factory,
+ private val statusBarIconController: StatusBarIconController,
) : ComposableScene {
override val key = Scenes.QuickSettingsShade
@@ -56,21 +81,101 @@
modifier: Modifier,
) {
OverlayShade(
- viewModel = overlayShadeViewModel,
- modifier = modifier,
+ viewModel = viewModel.overlayShadeViewModel,
horizontalArrangement = Arrangement.End,
lockscreenContent = lockscreenContent,
+ modifier = modifier,
) {
- Text(
- text = "Quick settings grid",
- modifier = Modifier.padding(QuickSettingsShade.Dimensions.Padding)
+ Column {
+ ExpandedShadeHeader(
+ viewModel = shadeHeaderViewModel,
+ createTintedIconManager = tintedIconManagerFactory::create,
+ createBatteryMeterViewController = batteryMeterViewControllerFactory::create,
+ statusBarIconController = statusBarIconController,
+ modifier = Modifier.padding(QuickSettingsShade.Dimensions.Padding),
+ )
+
+ ShadeBody(
+ viewModel = viewModel,
+ )
+ }
+ }
+ }
+}
+
+@Composable
+private fun ShadeBody(
+ viewModel: QuickSettingsShadeSceneViewModel,
+) {
+ val isEditing by viewModel.editModeViewModel.isEditing.collectAsStateWithLifecycle()
+
+ Box {
+ // The main Quick Settings grid layout.
+ AnimatedVisibility(
+ visible = !isEditing,
+ enter = QuickSettingsShade.Transitions.QuickSettingsLayoutEnter,
+ exit = QuickSettingsShade.Transitions.QuickSettingsLayoutExit,
+ ) {
+ QuickSettingsLayout(
+ viewModel = viewModel,
+ )
+ }
+
+ // The Quick Settings Editor layout.
+ AnimatedVisibility(
+ visible = isEditing,
+ enter = QuickSettingsShade.Transitions.QuickSettingsEditorEnter,
+ exit = QuickSettingsShade.Transitions.QuickSettingsEditorExit,
+ ) {
+ EditMode(
+ viewModel = viewModel.editModeViewModel,
+ modifier = Modifier.fillMaxWidth().padding(QuickSettingsShade.Dimensions.Padding)
)
}
}
}
+@Composable
+private fun QuickSettingsLayout(
+ viewModel: QuickSettingsShadeSceneViewModel,
+ modifier: Modifier = Modifier,
+) {
+ Column(
+ verticalArrangement = Arrangement.spacedBy(QuickSettingsShade.Dimensions.Padding),
+ horizontalAlignment = Alignment.CenterHorizontally,
+ modifier = modifier.fillMaxWidth().padding(QuickSettingsShade.Dimensions.Padding),
+ ) {
+ BrightnessSliderContainer(
+ viewModel = viewModel.brightnessSliderViewModel,
+ modifier =
+ Modifier.fillMaxWidth()
+ .height(QuickSettingsShade.Dimensions.BrightnessSliderHeight),
+ )
+ TileGrid(
+ viewModel = viewModel.tileGridViewModel,
+ modifier =
+ Modifier.fillMaxWidth().heightIn(max = QuickSettingsShade.Dimensions.GridMaxHeight),
+ )
+ Button(
+ onClick = { viewModel.editModeViewModel.startEditing() },
+ ) {
+ Text("Edit mode")
+ }
+ }
+}
+
object QuickSettingsShade {
+
object Dimensions {
val Padding = 16.dp
+ val BrightnessSliderHeight = 64.dp
+ val GridMaxHeight = 400.dp
+ }
+
+ object Transitions {
+ val QuickSettingsLayoutEnter: EnterTransition = fadeIn(tween(500))
+ val QuickSettingsLayoutExit: ExitTransition = fadeOut(tween(500))
+ val QuickSettingsEditorEnter: EnterTransition = fadeIn(tween(500))
+ val QuickSettingsEditorExit: ExitTransition = fadeOut(tween(500))
}
}
diff --git a/packages/SystemUI/compose/features/src/com/android/systemui/scene/ui/composable/SceneContainerTransitions.kt b/packages/SystemUI/compose/features/src/com/android/systemui/scene/ui/composable/SceneContainerTransitions.kt
index 3255b08..10c4030 100644
--- a/packages/SystemUI/compose/features/src/com/android/systemui/scene/ui/composable/SceneContainerTransitions.kt
+++ b/packages/SystemUI/compose/features/src/com/android/systemui/scene/ui/composable/SceneContainerTransitions.kt
@@ -104,9 +104,9 @@
)
}
overscroll(Scenes.NotificationsShade, Orientation.Vertical) {
- translate(OverlayShade.Elements.Panel, y = { OverlayShade.Dimensions.OverscrollLimit })
+ translate(OverlayShade.Elements.Panel, y = OverlayShade.Dimensions.OverscrollLimit)
}
overscroll(Scenes.QuickSettingsShade, Orientation.Vertical) {
- translate(OverlayShade.Elements.Panel, y = { OverlayShade.Dimensions.OverscrollLimit })
+ translate(OverlayShade.Elements.Panel, y = OverlayShade.Dimensions.OverscrollLimit)
}
}
diff --git a/packages/SystemUI/compose/features/src/com/android/systemui/shade/ui/composable/OverlayShade.kt b/packages/SystemUI/compose/features/src/com/android/systemui/shade/ui/composable/OverlayShade.kt
index d776e2a..6924d43 100644
--- a/packages/SystemUI/compose/features/src/com/android/systemui/shade/ui/composable/OverlayShade.kt
+++ b/packages/SystemUI/compose/features/src/com/android/systemui/shade/ui/composable/OverlayShade.kt
@@ -199,7 +199,7 @@
val PanelCornerRadius = 46.dp
val PanelWidthMedium = 390.dp
val PanelWidthLarge = 474.dp
- val OverscrollLimit = 100f
+ val OverscrollLimit = 32.dp
}
object Shapes {
diff --git a/packages/SystemUI/compose/features/src/com/android/systemui/volume/panel/component/spatialaudio/SpatialAudioModule.kt b/packages/SystemUI/compose/features/src/com/android/systemui/volume/panel/component/spatialaudio/SpatialAudioModule.kt
index da29d58..48af8cd 100644
--- a/packages/SystemUI/compose/features/src/com/android/systemui/volume/panel/component/spatialaudio/SpatialAudioModule.kt
+++ b/packages/SystemUI/compose/features/src/com/android/systemui/volume/panel/component/spatialaudio/SpatialAudioModule.kt
@@ -16,16 +16,13 @@
package com.android.systemui.volume.panel.component.spatialaudio
-import com.android.systemui.volume.panel.component.button.ui.composable.ButtonComponent
import com.android.systemui.volume.panel.component.shared.model.VolumePanelComponents
import com.android.systemui.volume.panel.component.spatial.domain.SpatialAudioAvailabilityCriteria
-import com.android.systemui.volume.panel.component.spatial.ui.viewmodel.SpatialAudioViewModel
-import com.android.systemui.volume.panel.component.spatialaudio.ui.composable.SpatialAudioPopup
+import com.android.systemui.volume.panel.component.spatialaudio.ui.composable.SpatialAudioComponent
import com.android.systemui.volume.panel.domain.ComponentAvailabilityCriteria
import com.android.systemui.volume.panel.shared.model.VolumePanelUiComponent
import dagger.Binds
import dagger.Module
-import dagger.Provides
import dagger.multibindings.IntoMap
import dagger.multibindings.StringKey
@@ -40,14 +37,8 @@
criteria: SpatialAudioAvailabilityCriteria
): ComponentAvailabilityCriteria
- companion object {
-
- @Provides
- @IntoMap
- @StringKey(VolumePanelComponents.SPATIAL_AUDIO)
- fun provideVolumePanelUiComponent(
- viewModel: SpatialAudioViewModel,
- popup: SpatialAudioPopup,
- ): VolumePanelUiComponent = ButtonComponent(viewModel.spatialAudioButton, popup::show)
- }
+ @Binds
+ @IntoMap
+ @StringKey(VolumePanelComponents.SPATIAL_AUDIO)
+ fun bindVolumePanelUiComponent(component: SpatialAudioComponent): VolumePanelUiComponent
}
diff --git a/packages/SystemUI/compose/features/src/com/android/systemui/volume/panel/component/spatialaudio/ui/composable/SpatialAudioComponent.kt b/packages/SystemUI/compose/features/src/com/android/systemui/volume/panel/component/spatialaudio/ui/composable/SpatialAudioComponent.kt
new file mode 100644
index 0000000..2d89b5c
--- /dev/null
+++ b/packages/SystemUI/compose/features/src/com/android/systemui/volume/panel/component/spatialaudio/ui/composable/SpatialAudioComponent.kt
@@ -0,0 +1,60 @@
+/*
+ * 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.systemui.volume.panel.component.spatialaudio.ui.composable
+
+import androidx.compose.runtime.Composable
+import androidx.compose.runtime.getValue
+import androidx.compose.runtime.remember
+import androidx.compose.ui.Modifier
+import androidx.lifecycle.compose.collectAsStateWithLifecycle
+import com.android.systemui.volume.panel.component.button.ui.composable.ButtonComponent
+import com.android.systemui.volume.panel.component.button.ui.composable.ToggleButtonComponent
+import com.android.systemui.volume.panel.component.spatial.domain.model.SpatialAudioEnabledModel
+import com.android.systemui.volume.panel.component.spatial.ui.viewmodel.SpatialAudioViewModel
+import com.android.systemui.volume.panel.ui.composable.ComposeVolumePanelUiComponent
+import com.android.systemui.volume.panel.ui.composable.VolumePanelComposeScope
+import javax.inject.Inject
+
+/** [ComposeVolumePanelUiComponent] that represents spatial audio button in the Volume Panel. */
+class SpatialAudioComponent
+@Inject
+constructor(
+ private val viewModel: SpatialAudioViewModel,
+ private val popup: SpatialAudioPopup,
+) : ComposeVolumePanelUiComponent {
+
+ @Composable
+ override fun VolumePanelComposeScope.Content(modifier: Modifier) {
+ val shouldUsePopup by viewModel.shouldUsePopup.collectAsStateWithLifecycle()
+
+ val buttonComponent: ComposeVolumePanelUiComponent =
+ remember(shouldUsePopup) {
+ if (shouldUsePopup) {
+ ButtonComponent(viewModel.spatialAudioButton, popup::show)
+ } else {
+ ToggleButtonComponent(viewModel.spatialAudioButton) {
+ if (it) {
+ viewModel.setEnabled(SpatialAudioEnabledModel.SpatialAudioEnabled)
+ } else {
+ viewModel.setEnabled(SpatialAudioEnabledModel.Disabled)
+ }
+ }
+ }
+ }
+ with(buttonComponent) { Content(modifier) }
+ }
+}
diff --git a/packages/SystemUI/compose/scene/src/com/android/compose/animation/scene/AnimateSharedAsState.kt b/packages/SystemUI/compose/scene/src/com/android/compose/animation/scene/AnimateSharedAsState.kt
index 5d1a7c5..7fd3a176 100644
--- a/packages/SystemUI/compose/scene/src/com/android/compose/animation/scene/AnimateSharedAsState.kt
+++ b/packages/SystemUI/compose/scene/src/com/android/compose/animation/scene/AnimateSharedAsState.kt
@@ -27,11 +27,12 @@
import androidx.compose.runtime.snapshotFlow
import androidx.compose.runtime.snapshots.SnapshotStateMap
import androidx.compose.ui.graphics.Color
-import androidx.compose.ui.graphics.lerp
+import androidx.compose.ui.graphics.colorspace.ColorSpaces
import androidx.compose.ui.unit.Dp
-import androidx.compose.ui.unit.lerp
+import androidx.compose.ui.unit.dp
import androidx.compose.ui.util.fastCoerceIn
-import androidx.compose.ui.util.lerp
+import androidx.compose.ui.util.fastLastOrNull
+import kotlin.math.roundToInt
/**
* A [State] whose [value] is animated.
@@ -74,7 +75,7 @@
key: ValueKey,
canOverflow: Boolean = true,
): AnimatedState<Int> {
- return animateSceneValueAsState(value, key, ::lerp, canOverflow)
+ return animateSceneValueAsState(value, key, SharedIntType, canOverflow)
}
/**
@@ -88,7 +89,19 @@
key: ValueKey,
canOverflow: Boolean = true,
): AnimatedState<Int> {
- return animateElementValueAsState(value, key, ::lerp, canOverflow)
+ return animateElementValueAsState(value, key, SharedIntType, canOverflow)
+}
+
+private object SharedIntType : SharedValueType<Int, Int> {
+ override val unspecifiedValue: Int = Int.MIN_VALUE
+ override val zeroDeltaValue: Int = 0
+
+ override fun lerp(a: Int, b: Int, progress: Float): Int =
+ androidx.compose.ui.util.lerp(a, b, progress)
+
+ override fun diff(a: Int, b: Int): Int = a - b
+
+ override fun addWeighted(a: Int, b: Int, bWeight: Float): Int = (a + b * bWeight).roundToInt()
}
/**
@@ -102,7 +115,7 @@
key: ValueKey,
canOverflow: Boolean = true,
): AnimatedState<Float> {
- return animateSceneValueAsState(value, key, ::lerp, canOverflow)
+ return animateSceneValueAsState(value, key, SharedFloatType, canOverflow)
}
/**
@@ -116,7 +129,19 @@
key: ValueKey,
canOverflow: Boolean = true,
): AnimatedState<Float> {
- return animateElementValueAsState(value, key, ::lerp, canOverflow)
+ return animateElementValueAsState(value, key, SharedFloatType, canOverflow)
+}
+
+private object SharedFloatType : SharedValueType<Float, Float> {
+ override val unspecifiedValue: Float = Float.MIN_VALUE
+ override val zeroDeltaValue: Float = 0f
+
+ override fun lerp(a: Float, b: Float, progress: Float): Float =
+ androidx.compose.ui.util.lerp(a, b, progress)
+
+ override fun diff(a: Float, b: Float): Float = a - b
+
+ override fun addWeighted(a: Float, b: Float, bWeight: Float): Float = a + b * bWeight
}
/**
@@ -130,7 +155,7 @@
key: ValueKey,
canOverflow: Boolean = true,
): AnimatedState<Dp> {
- return animateSceneValueAsState(value, key, ::lerp, canOverflow)
+ return animateSceneValueAsState(value, key, SharedDpType, canOverflow)
}
/**
@@ -144,7 +169,20 @@
key: ValueKey,
canOverflow: Boolean = true,
): AnimatedState<Dp> {
- return animateElementValueAsState(value, key, ::lerp, canOverflow)
+ return animateElementValueAsState(value, key, SharedDpType, canOverflow)
+}
+
+private object SharedDpType : SharedValueType<Dp, Dp> {
+ override val unspecifiedValue: Dp = Dp.Unspecified
+ override val zeroDeltaValue: Dp = 0.dp
+
+ override fun lerp(a: Dp, b: Dp, progress: Float): Dp {
+ return androidx.compose.ui.unit.lerp(a, b, progress)
+ }
+
+ override fun diff(a: Dp, b: Dp): Dp = a - b
+
+ override fun addWeighted(a: Dp, b: Dp, bWeight: Float): Dp = a + b * bWeight
}
/**
@@ -157,7 +195,7 @@
value: Color,
key: ValueKey,
): AnimatedState<Color> {
- return animateSceneValueAsState(value, key, ::lerp, canOverflow = false)
+ return animateSceneValueAsState(value, key, SharedColorType, canOverflow = false)
}
/**
@@ -170,9 +208,56 @@
value: Color,
key: ValueKey,
): AnimatedState<Color> {
- return animateElementValueAsState(value, key, ::lerp, canOverflow = false)
+ return animateElementValueAsState(value, key, SharedColorType, canOverflow = false)
}
+private object SharedColorType : SharedValueType<Color, ColorDelta> {
+ override val unspecifiedValue: Color = Color.Unspecified
+ override val zeroDeltaValue: ColorDelta = ColorDelta(0f, 0f, 0f, 0f)
+
+ override fun lerp(a: Color, b: Color, progress: Float): Color {
+ return androidx.compose.ui.graphics.lerp(a, b, progress)
+ }
+
+ override fun diff(a: Color, b: Color): ColorDelta {
+ // Similar to lerp, we convert colors to the Oklab color space to perform operations on
+ // colors.
+ val aOklab = a.convert(ColorSpaces.Oklab)
+ val bOklab = b.convert(ColorSpaces.Oklab)
+ return ColorDelta(
+ red = aOklab.red - bOklab.red,
+ green = aOklab.green - bOklab.green,
+ blue = aOklab.blue - bOklab.blue,
+ alpha = aOklab.alpha - bOklab.alpha,
+ )
+ }
+
+ override fun addWeighted(a: Color, b: ColorDelta, bWeight: Float): Color {
+ val aOklab = a.convert(ColorSpaces.Oklab)
+ return Color(
+ red = aOklab.red + b.red * bWeight,
+ green = aOklab.green + b.green * bWeight,
+ blue = aOklab.blue + b.blue * bWeight,
+ alpha = aOklab.alpha + b.alpha * bWeight,
+ colorSpace = ColorSpaces.Oklab,
+ )
+ .convert(aOklab.colorSpace)
+ }
+}
+
+/**
+ * Represents the diff between two colors in the same color space.
+ *
+ * Note: This class is necessary because Color() checks the bounds of its values and UncheckedColor
+ * is internal.
+ */
+private class ColorDelta(
+ val red: Float,
+ val green: Float,
+ val blue: Float,
+ val alpha: Float,
+)
+
@Composable
internal fun <T> animateSharedValueAsState(
layoutImpl: SceneTransitionLayoutImpl,
@@ -180,23 +265,22 @@
element: ElementKey?,
key: ValueKey,
value: T,
- lerp: (T, T, Float) -> T,
+ type: SharedValueType<T, *>,
canOverflow: Boolean,
): AnimatedState<T> {
DisposableEffect(layoutImpl, scene, element, key) {
// Create the associated maps that hold the current value for each (element, scene) pair.
val valueMap = layoutImpl.sharedValues.getOrPut(key) { mutableMapOf() }
- val sceneToValueMap =
- valueMap.getOrPut(element) { SnapshotStateMap<SceneKey, Any>() }
- as SnapshotStateMap<SceneKey, T>
- sceneToValueMap[scene] = value
+ val sharedValue = valueMap.getOrPut(element) { SharedValue(type) } as SharedValue<T, *>
+ val targetValues = sharedValue.targetValues
+ targetValues[scene] = value
onDispose {
// Remove the value associated to the current scene, and eventually remove the maps if
// they are empty.
- sceneToValueMap.remove(scene)
+ targetValues.remove(scene)
- if (sceneToValueMap.isEmpty() && valueMap[element] === sceneToValueMap) {
+ if (targetValues.isEmpty() && valueMap[element] === sharedValue) {
valueMap.remove(element)
if (valueMap.isEmpty() && layoutImpl.sharedValues[key] === valueMap) {
@@ -208,34 +292,25 @@
// Update the current value. Note that side effects run after disposable effects, so we know
// that the associated maps were created at this point.
- SideEffect { sceneToValueMap<T>(layoutImpl, key, element)[scene] = value }
-
- return remember(layoutImpl, scene, element, lerp, canOverflow) {
- object : AnimatedState<T> {
- override val value: T
- get() = value(layoutImpl, scene, element, key, lerp, canOverflow)
-
- @Composable
- override fun unsafeCompositionState(initialValue: T): State<T> {
- val state = remember { mutableStateOf(initialValue) }
-
- val animatedState = this
- LaunchedEffect(animatedState) {
- snapshotFlow { animatedState.value }.collect { state.value = it }
- }
-
- return state
- }
+ SideEffect {
+ if (value == type.unspecifiedValue) {
+ error("value is equal to $value, which is the undefined value for this type.")
}
+
+ sharedValue<T, Any>(layoutImpl, key, element).targetValues[scene] = value
+ }
+
+ return remember(layoutImpl, scene, element, canOverflow) {
+ AnimatedStateImpl<T, Any>(layoutImpl, scene, element, key, canOverflow)
}
}
-private fun <T> sceneToValueMap(
+private fun <T, Delta> sharedValue(
layoutImpl: SceneTransitionLayoutImpl,
key: ValueKey,
element: ElementKey?
-): MutableMap<SceneKey, T> {
- return layoutImpl.sharedValues[key]?.get(element)?.let { it as SnapshotStateMap<SceneKey, T> }
+): SharedValue<T, Delta> {
+ return layoutImpl.sharedValues[key]?.get(element)?.let { it as SharedValue<T, Delta> }
?: error(valueReadTooEarlyMessage(key))
}
@@ -244,62 +319,155 @@
"means that you are reading it during composition, which you should not do. See the " +
"documentation of AnimatedState for more information."
-private fun <T> value(
- layoutImpl: SceneTransitionLayoutImpl,
- scene: SceneKey,
- element: ElementKey?,
- key: ValueKey,
- lerp: (T, T, Float) -> T,
- canOverflow: Boolean,
-): T {
- return valueOrNull(layoutImpl, scene, element, key, lerp, canOverflow)
- ?: error(valueReadTooEarlyMessage(key))
+internal class SharedValue<T, Delta>(
+ val type: SharedValueType<T, Delta>,
+) {
+ /** The target value of this shared value for each scene. */
+ val targetValues = SnapshotStateMap<SceneKey, T>()
+
+ /** The last value of this shared value. */
+ var lastValue: T = type.unspecifiedValue
+
+ /** The value of this shared value before the last interruption (if any). */
+ var valueBeforeInterruption: T = type.unspecifiedValue
+
+ /** The delta value to add to this shared value to have smoother interruptions. */
+ var valueInterruptionDelta = type.zeroDeltaValue
+
+ /** The last transition that was used when the value of this shared state. */
+ var lastTransition: TransitionState.Transition? = null
}
-private fun <T> valueOrNull(
- layoutImpl: SceneTransitionLayoutImpl,
- scene: SceneKey,
- element: ElementKey?,
- key: ValueKey,
- lerp: (T, T, Float) -> T,
- canOverflow: Boolean,
-): T? {
- val sceneToValueMap = sceneToValueMap<T>(layoutImpl, key, element)
- fun sceneValue(scene: SceneKey): T? = sceneToValueMap[scene]
+private class AnimatedStateImpl<T, Delta>(
+ private val layoutImpl: SceneTransitionLayoutImpl,
+ private val scene: SceneKey,
+ private val element: ElementKey?,
+ private val key: ValueKey,
+ private val canOverflow: Boolean,
+) : AnimatedState<T> {
+ override val value: T
+ get() = value()
- return when (val transition = layoutImpl.state.transitionState) {
- is TransitionState.Idle -> sceneValue(transition.currentScene)
- is TransitionState.Transition -> {
- // Note: no need to check for transition ready here given that all target values are
- // defined during composition, we should already have the correct values to interpolate
- // between here.
- val fromValue = sceneValue(transition.fromScene)
- val toValue = sceneValue(transition.toScene)
- if (fromValue != null && toValue != null) {
- if (fromValue == toValue) {
- // Optimization: avoid reading progress if the values are the same, so we don't
- // relayout/redraw for nothing.
- fromValue
- } else {
- // In the case of bouncing, if the value remains constant during the overscroll,
- // we should use the value of the scene we are bouncing around.
- if (!canOverflow && transition is TransitionState.HasOverscrollProperties) {
- val bouncingScene = transition.bouncingScene
- if (bouncingScene != null) {
- return sceneValue(bouncingScene)
- }
+ private fun value(): T {
+ val sharedValue = sharedValue<T, Delta>(layoutImpl, key, element)
+ val transition = transition(sharedValue)
+ val value: T =
+ valueOrNull(sharedValue, transition)
+ // TODO(b/311600838): Remove this. We should not have to fallback to the current
+ // scene value, but we have to because code of removed nodes can still run if they
+ // are placed with a graphics layer.
+ ?: sharedValue[scene]
+ ?: error(valueReadTooEarlyMessage(key))
+ val interruptedValue = computeInterruptedValue(sharedValue, transition, value)
+ sharedValue.lastValue = interruptedValue
+ return interruptedValue
+ }
+
+ private operator fun SharedValue<T, *>.get(scene: SceneKey): T? = targetValues[scene]
+
+ private fun valueOrNull(
+ sharedValue: SharedValue<T, *>,
+ transition: TransitionState.Transition?,
+ ): T? {
+ if (transition == null) {
+ return sharedValue[layoutImpl.state.transitionState.currentScene]
+ }
+
+ val fromValue = sharedValue[transition.fromScene]
+ val toValue = sharedValue[transition.toScene]
+ return if (fromValue != null && toValue != null) {
+ if (fromValue == toValue) {
+ // Optimization: avoid reading progress if the values are the same, so we don't
+ // relayout/redraw for nothing.
+ fromValue
+ } else {
+ // In the case of bouncing, if the value remains constant during the overscroll, we
+ // should use the value of the scene we are bouncing around.
+ if (!canOverflow && transition is TransitionState.HasOverscrollProperties) {
+ val bouncingScene = transition.bouncingScene
+ if (bouncingScene != null) {
+ return sharedValue[bouncingScene]
}
-
- val progress =
- if (canOverflow) transition.progress
- else transition.progress.fastCoerceIn(0f, 1f)
- lerp(fromValue, toValue, progress)
}
- } else fromValue ?: toValue
+
+ val progress =
+ if (canOverflow) transition.progress
+ else transition.progress.fastCoerceIn(0f, 1f)
+ sharedValue.type.lerp(fromValue, toValue, progress)
+ }
+ } else fromValue ?: toValue
+ }
+
+ private fun transition(sharedValue: SharedValue<T, Delta>): TransitionState.Transition? {
+ val targetValues = sharedValue.targetValues
+ val transition =
+ if (element != null) {
+ layoutImpl.elements[element]?.sceneStates?.let { sceneStates ->
+ layoutImpl.state.currentTransitions.fastLastOrNull { transition ->
+ transition.fromScene in sceneStates || transition.toScene in sceneStates
+ }
+ }
+ } else {
+ layoutImpl.state.currentTransitions.fastLastOrNull { transition ->
+ transition.fromScene in targetValues || transition.toScene in targetValues
+ }
+ }
+
+ val previousTransition = sharedValue.lastTransition
+ sharedValue.lastTransition = transition
+
+ if (transition != previousTransition && transition != null && previousTransition != null) {
+ // The previous transition was interrupted by another transition.
+ sharedValue.valueBeforeInterruption = sharedValue.lastValue
+ sharedValue.valueInterruptionDelta = sharedValue.type.zeroDeltaValue
+ } else if (transition == null && previousTransition != null) {
+ // The transition was just finished.
+ sharedValue.valueBeforeInterruption = sharedValue.type.unspecifiedValue
+ sharedValue.valueInterruptionDelta = sharedValue.type.zeroDeltaValue
+ }
+
+ return transition
+ }
+
+ /**
+ * Compute what [value] should be if we take the
+ * [interruption progress][TransitionState.Transition.interruptionProgress] of [transition] into
+ * account.
+ */
+ private fun computeInterruptedValue(
+ sharedValue: SharedValue<T, Delta>,
+ transition: TransitionState.Transition?,
+ value: T,
+ ): T {
+ val type = sharedValue.type
+ if (sharedValue.valueBeforeInterruption != type.unspecifiedValue) {
+ sharedValue.valueInterruptionDelta =
+ type.diff(sharedValue.valueBeforeInterruption, value)
+ sharedValue.valueBeforeInterruption = type.unspecifiedValue
+ }
+
+ val delta = sharedValue.valueInterruptionDelta
+ return if (delta == type.zeroDeltaValue || transition == null) {
+ value
+ } else {
+ val interruptionProgress = transition.interruptionProgress(layoutImpl)
+ if (interruptionProgress == 0f) {
+ value
+ } else {
+ type.addWeighted(value, delta, interruptionProgress)
+ }
}
}
- // TODO(b/311600838): Remove this. We should not have to fallback to the current scene value,
- // but we have to because code of removed nodes can still run if they are placed with a graphics
- // layer.
- ?: sceneValue(scene)
+
+ @Composable
+ override fun unsafeCompositionState(initialValue: T): State<T> {
+ val state = remember { mutableStateOf(initialValue) }
+
+ val animatedState = this
+ LaunchedEffect(animatedState) {
+ snapshotFlow { animatedState.value }.collect { state.value = it }
+ }
+
+ return state
+ }
}
diff --git a/packages/SystemUI/compose/scene/src/com/android/compose/animation/scene/DraggableHandler.kt b/packages/SystemUI/compose/scene/src/com/android/compose/animation/scene/DraggableHandler.kt
index 1f81245..e9633c2 100644
--- a/packages/SystemUI/compose/scene/src/com/android/compose/animation/scene/DraggableHandler.kt
+++ b/packages/SystemUI/compose/scene/src/com/android/compose/animation/scene/DraggableHandler.kt
@@ -148,9 +148,9 @@
val swipes = computeSwipes(fromScene, startedPosition, pointersDown)
val result =
swipes.findUserActionResult(fromScene, overSlop, true)
- // As we were unable to locate a valid target scene, the initial SwipeTransition
- // cannot be defined. Consequently, a simple NoOp Controller will be returned.
- ?: return NoOpDragController
+ // As we were unable to locate a valid target scene, the initial SwipeTransition
+ // cannot be defined. Consequently, a simple NoOp Controller will be returned.
+ ?: return NoOpDragController
return updateDragController(
swipes = swipes,
@@ -521,6 +521,7 @@
}
return SwipeTransition(
+ layoutImpl = layoutImpl,
layoutState = layoutState,
coroutineScope = coroutineScope,
key = result.transitionKey,
@@ -534,6 +535,7 @@
private fun SwipeTransition(old: SwipeTransition): SwipeTransition {
return SwipeTransition(
+ layoutImpl = old.layoutImpl,
layoutState = old.layoutState,
coroutineScope = old.coroutineScope,
key = old.key,
@@ -550,6 +552,7 @@
}
private class SwipeTransition(
+ val layoutImpl: SceneTransitionLayoutImpl,
val layoutState: BaseSceneTransitionLayoutState,
val coroutineScope: CoroutineScope,
val key: TransitionKey?,
@@ -607,6 +610,12 @@
override val overscrollScope: OverscrollScope =
object : OverscrollScope {
+ override val density: Float
+ get() = layoutImpl.density.density
+
+ override val fontScale: Float
+ get() = layoutImpl.density.fontScale
+
override val absoluteDistance: Float
get() = distance().absoluteValue
}
diff --git a/packages/SystemUI/compose/scene/src/com/android/compose/animation/scene/MovableElement.kt b/packages/SystemUI/compose/scene/src/com/android/compose/animation/scene/MovableElement.kt
index 4b20aca..be005ea 100644
--- a/packages/SystemUI/compose/scene/src/com/android/compose/animation/scene/MovableElement.kt
+++ b/packages/SystemUI/compose/scene/src/com/android/compose/animation/scene/MovableElement.kt
@@ -77,7 +77,7 @@
override fun <T> animateElementValueAsState(
value: T,
key: ValueKey,
- lerp: (start: T, stop: T, fraction: Float) -> T,
+ type: SharedValueType<T, *>,
canOverflow: Boolean
): AnimatedState<T> {
return animateSharedValueAsState(
@@ -86,7 +86,7 @@
element,
key,
value,
- lerp,
+ type,
canOverflow,
)
}
@@ -184,8 +184,7 @@
fromSceneZIndex = layoutImpl.scenes.getValue(transition.fromScene).zIndex,
toSceneZIndex = layoutImpl.scenes.getValue(transition.toScene).zIndex,
) != null
- }
- ?: return false
+ } ?: return false
// Always compose movable elements in the scene picked by their scene picker.
return shouldDrawOrComposeSharedElement(
diff --git a/packages/SystemUI/compose/scene/src/com/android/compose/animation/scene/Scene.kt b/packages/SystemUI/compose/scene/src/com/android/compose/animation/scene/Scene.kt
index 6fef33c..936f4ba 100644
--- a/packages/SystemUI/compose/scene/src/com/android/compose/animation/scene/Scene.kt
+++ b/packages/SystemUI/compose/scene/src/com/android/compose/animation/scene/Scene.kt
@@ -24,7 +24,6 @@
import androidx.compose.runtime.mutableFloatStateOf
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.setValue
-import androidx.compose.ui.ExperimentalComposeUiApi
import androidx.compose.ui.Modifier
import androidx.compose.ui.layout.approachLayout
import androidx.compose.ui.platform.testTag
@@ -69,7 +68,6 @@
}
@Composable
- @OptIn(ExperimentalComposeUiApi::class)
fun Content(modifier: Modifier = Modifier) {
Box(
modifier
@@ -96,6 +94,7 @@
private val layoutImpl: SceneTransitionLayoutImpl,
private val scene: Scene,
) : SceneScope, ElementStateScope by layoutImpl.elementStateScope {
+ override val sceneKey: SceneKey = scene.key
override val layoutState: SceneTransitionLayoutState = layoutImpl.state
override fun Modifier.element(key: ElementKey): Modifier {
@@ -124,7 +123,7 @@
override fun <T> animateSceneValueAsState(
value: T,
key: ValueKey,
- lerp: (T, T, Float) -> T,
+ type: SharedValueType<T, *>,
canOverflow: Boolean
): AnimatedState<T> {
return animateSharedValueAsState(
@@ -133,7 +132,7 @@
element = null,
key = key,
value = value,
- lerp = lerp,
+ type = type,
canOverflow = canOverflow,
)
}
diff --git a/packages/SystemUI/compose/scene/src/com/android/compose/animation/scene/SceneTransitionLayout.kt b/packages/SystemUI/compose/scene/src/com/android/compose/animation/scene/SceneTransitionLayout.kt
index cf8c584..2946b04 100644
--- a/packages/SystemUI/compose/scene/src/com/android/compose/animation/scene/SceneTransitionLayout.kt
+++ b/packages/SystemUI/compose/scene/src/com/android/compose/animation/scene/SceneTransitionLayout.kt
@@ -167,6 +167,9 @@
@Stable
@ElementDsl
interface BaseSceneScope : ElementStateScope {
+ /** The key of this scene. */
+ val sceneKey: SceneKey
+
/** The state of the [SceneTransitionLayout] in which this scene is contained. */
val layoutState: SceneTransitionLayoutState
@@ -285,9 +288,7 @@
*
* @param value the value of this shared value in the current scene.
* @param key the key of this shared value.
- * @param lerp the *linear* interpolation function that should be used to interpolate between
- * two different values. Note that it has to be linear because the [fraction] passed to this
- * interpolator is already interpolated.
+ * @param type the [SharedValueType] of this animated value.
* @param canOverflow whether this value can overflow past the values it is interpolated
* between, for instance because the transition is animated using a bouncy spring.
* @see animateSceneIntAsState
@@ -299,11 +300,39 @@
fun <T> animateSceneValueAsState(
value: T,
key: ValueKey,
- lerp: (start: T, stop: T, fraction: Float) -> T,
+ type: SharedValueType<T, *>,
canOverflow: Boolean,
): AnimatedState<T>
}
+/**
+ * The type of a shared value animated using [ElementScope.animateElementValueAsState] or
+ * [SceneScope.animateSceneValueAsState].
+ */
+@Stable
+interface SharedValueType<T, Delta> {
+ /** The unspecified value for this type. */
+ val unspecifiedValue: T
+
+ /**
+ * The zero value of this type. It should be equal to what [diff(x, x)] returns for any value of
+ * x.
+ */
+ val zeroDeltaValue: Delta
+
+ /**
+ * Return the linear interpolation of [a] and [b] at the given [progress], i.e. `a + (b - a) *
+ * progress`.
+ */
+ fun lerp(a: T, b: T, progress: Float): T
+
+ /** Return `a - b`. */
+ fun diff(a: T, b: T): Delta
+
+ /** Return `a + b * bWeight`. */
+ fun addWeighted(a: T, b: Delta, bWeight: Float): T
+}
+
@Stable
@ElementDsl
interface ElementScope<ContentScope> {
@@ -312,9 +341,7 @@
*
* @param value the value of this shared value in the current scene.
* @param key the key of this shared value.
- * @param lerp the *linear* interpolation function that should be used to interpolate between
- * two different values. Note that it has to be linear because the [fraction] passed to this
- * interpolator is already interpolated.
+ * @param type the [SharedValueType] of this animated value.
* @param canOverflow whether this value can overflow past the values it is interpolated
* between, for instance because the transition is animated using a bouncy spring.
* @see animateElementIntAsState
@@ -326,7 +353,7 @@
fun <T> animateElementValueAsState(
value: T,
key: ValueKey,
- lerp: (start: T, stop: T, fraction: Float) -> T,
+ type: SharedValueType<T, *>,
canOverflow: Boolean,
): AnimatedState<T>
diff --git a/packages/SystemUI/compose/scene/src/com/android/compose/animation/scene/SceneTransitionLayoutImpl.kt b/packages/SystemUI/compose/scene/src/com/android/compose/animation/scene/SceneTransitionLayoutImpl.kt
index c614265..5fa7c87 100644
--- a/packages/SystemUI/compose/scene/src/com/android/compose/animation/scene/SceneTransitionLayoutImpl.kt
+++ b/packages/SystemUI/compose/scene/src/com/android/compose/animation/scene/SceneTransitionLayoutImpl.kt
@@ -85,15 +85,14 @@
* The different values of a shared value keyed by a a [ValueKey] and the different elements and
* scenes it is associated to.
*/
- private var _sharedValues:
- MutableMap<ValueKey, MutableMap<ElementKey?, SnapshotStateMap<SceneKey, *>>>? =
+ private var _sharedValues: MutableMap<ValueKey, MutableMap<ElementKey?, SharedValue<*, *>>>? =
null
- internal val sharedValues:
- MutableMap<ValueKey, MutableMap<ElementKey?, SnapshotStateMap<SceneKey, *>>>
+ internal val sharedValues: MutableMap<ValueKey, MutableMap<ElementKey?, SharedValue<*, *>>>
get() =
_sharedValues
- ?: mutableMapOf<ValueKey, MutableMap<ElementKey?, SnapshotStateMap<SceneKey, *>>>()
- .also { _sharedValues = it }
+ ?: mutableMapOf<ValueKey, MutableMap<ElementKey?, SharedValue<*, *>>>().also {
+ _sharedValues = it
+ }
// TODO(b/317958526): Lazily allocate scene gesture handlers the first time they are needed.
private val horizontalDraggableHandler: DraggableHandlerImpl
diff --git a/packages/SystemUI/compose/scene/src/com/android/compose/animation/scene/SceneTransitionLayoutState.kt b/packages/SystemUI/compose/scene/src/com/android/compose/animation/scene/SceneTransitionLayoutState.kt
index a5b6d24..44affd9 100644
--- a/packages/SystemUI/compose/scene/src/com/android/compose/animation/scene/SceneTransitionLayoutState.kt
+++ b/packages/SystemUI/compose/scene/src/com/android/compose/animation/scene/SceneTransitionLayoutState.kt
@@ -457,7 +457,7 @@
*/
internal fun startTransition(
transition: TransitionState.Transition,
- transitionKey: TransitionKey?,
+ transitionKey: TransitionKey? = null,
chain: Boolean = true,
) {
checkThread()
diff --git a/packages/SystemUI/compose/scene/src/com/android/compose/animation/scene/TransitionDsl.kt b/packages/SystemUI/compose/scene/src/com/android/compose/animation/scene/TransitionDsl.kt
index a4682ff..465a410 100644
--- a/packages/SystemUI/compose/scene/src/com/android/compose/animation/scene/TransitionDsl.kt
+++ b/packages/SystemUI/compose/scene/src/com/android/compose/animation/scene/TransitionDsl.kt
@@ -20,6 +20,7 @@
import androidx.compose.animation.core.SpringSpec
import androidx.compose.foundation.gestures.Orientation
import androidx.compose.ui.geometry.Offset
+import androidx.compose.ui.unit.Density
import androidx.compose.ui.unit.Dp
import androidx.compose.ui.unit.dp
import com.android.compose.animation.scene.TransitionState.HasOverscrollProperties.Companion.DistanceUnspecified
@@ -192,7 +193,7 @@
)
}
-interface OverscrollScope {
+interface OverscrollScope : Density {
/**
* Return the absolute distance between fromScene and toScene, if available, otherwise
* [DistanceUnspecified].
diff --git a/packages/SystemUI/compose/scene/tests/src/com/android/compose/animation/scene/AnimatedSharedAsStateTest.kt b/packages/SystemUI/compose/scene/tests/src/com/android/compose/animation/scene/AnimatedSharedAsStateTest.kt
index e8854cf..6e8b208 100644
--- a/packages/SystemUI/compose/scene/tests/src/com/android/compose/animation/scene/AnimatedSharedAsStateTest.kt
+++ b/packages/SystemUI/compose/scene/tests/src/com/android/compose/animation/scene/AnimatedSharedAsStateTest.kt
@@ -32,7 +32,12 @@
import androidx.compose.ui.unit.lerp
import androidx.compose.ui.util.lerp
import androidx.test.ext.junit.runners.AndroidJUnit4
+import com.android.compose.animation.scene.TestScenes.SceneA
+import com.android.compose.animation.scene.TestScenes.SceneB
+import com.android.compose.animation.scene.TestScenes.SceneC
+import com.android.compose.animation.scene.TestScenes.SceneD
import com.google.common.truth.Truth.assertThat
+import kotlinx.coroutines.test.runTest
import org.junit.Assert.assertThrows
import org.junit.Rule
import org.junit.Test
@@ -130,8 +135,8 @@
// The transition lasts 64ms = 4 frames.
spec = tween(durationMillis = 16 * 4, easing = LinearEasing)
},
- fromScene = TestScenes.SceneA,
- toScene = TestScenes.SceneB,
+ fromScene = SceneA,
+ toScene = SceneB,
) {
before {
assertThat(lastValueInFrom).isEqualTo(fromValues)
@@ -189,8 +194,8 @@
// The transition lasts 64ms = 4 frames.
spec = tween(durationMillis = 16 * 4, easing = LinearEasing)
},
- fromScene = TestScenes.SceneA,
- toScene = TestScenes.SceneB,
+ fromScene = SceneA,
+ toScene = SceneB,
) {
before {
assertThat(lastValueInFrom).isEqualTo(fromValues)
@@ -243,8 +248,8 @@
// The transition lasts 64ms = 4 frames.
spec = tween(durationMillis = 16 * 4, easing = LinearEasing)
},
- fromScene = TestScenes.SceneA,
- toScene = TestScenes.SceneB,
+ fromScene = SceneA,
+ toScene = SceneB,
) {
before {
assertThat(lastValueInFrom).isEqualTo(fromValues)
@@ -381,4 +386,61 @@
}
}
}
+
+ @Test
+ fun animatedValueIsUsingLastTransition() = runTest {
+ val state =
+ rule.runOnUiThread { MutableSceneTransitionLayoutStateImpl(SceneA, transitions {}) }
+
+ val foo = ValueKey("foo")
+ val bar = ValueKey("bar")
+ val lastValues = mutableMapOf<ValueKey, MutableMap<SceneKey, Float>>()
+
+ @Composable
+ fun SceneScope.animateFloat(value: Float, key: ValueKey) {
+ val animatedValue = animateSceneFloatAsState(value, key)
+ LaunchedEffect(animatedValue) {
+ snapshotFlow { animatedValue.value }
+ .collect { lastValues.getOrPut(key) { mutableMapOf() }[sceneKey] = it }
+ }
+ }
+
+ rule.setContent {
+ SceneTransitionLayout(state) {
+ // foo goes from 0f to 100f in A => B.
+ scene(SceneA) { animateFloat(0f, foo) }
+ scene(SceneB) { animateFloat(100f, foo) }
+
+ // bar goes from 0f to 10f in C => D.
+ scene(SceneC) { animateFloat(0f, bar) }
+ scene(SceneD) { animateFloat(10f, bar) }
+ }
+ }
+
+ rule.runOnUiThread {
+ // A => B is at 30%.
+ state.startTransition(
+ transition(
+ from = SceneA,
+ to = SceneB,
+ progress = { 0.3f },
+ onFinish = neverFinish(),
+ )
+ )
+
+ // C => D is at 70%.
+ state.startTransition(transition(from = SceneC, to = SceneD, progress = { 0.7f }))
+ }
+ rule.waitForIdle()
+
+ assertThat(lastValues[foo]?.get(SceneA)).isWithin(0.001f).of(30f)
+ assertThat(lastValues[foo]?.get(SceneB)).isWithin(0.001f).of(30f)
+ assertThat(lastValues[foo]?.get(SceneC)).isNull()
+ assertThat(lastValues[foo]?.get(SceneD)).isNull()
+
+ assertThat(lastValues[bar]?.get(SceneA)).isNull()
+ assertThat(lastValues[bar]?.get(SceneB)).isNull()
+ assertThat(lastValues[bar]?.get(SceneC)).isWithin(0.001f).of(7f)
+ assertThat(lastValues[bar]?.get(SceneD)).isWithin(0.001f).of(7f)
+ }
}
diff --git a/packages/SystemUI/compose/scene/tests/src/com/android/compose/animation/scene/ElementTest.kt b/packages/SystemUI/compose/scene/tests/src/com/android/compose/animation/scene/ElementTest.kt
index 9692fae..beb74bc 100644
--- a/packages/SystemUI/compose/scene/tests/src/com/android/compose/animation/scene/ElementTest.kt
+++ b/packages/SystemUI/compose/scene/tests/src/com/android/compose/animation/scene/ElementTest.kt
@@ -59,6 +59,7 @@
import androidx.compose.ui.unit.IntSize
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.lerp
+import androidx.compose.ui.util.lerp
import androidx.test.ext.junit.runners.AndroidJUnit4
import com.android.compose.animation.scene.TestScenes.SceneA
import com.android.compose.animation.scene.TestScenes.SceneB
@@ -348,7 +349,7 @@
),
onLayoutImpl = { nullableLayoutImpl = it },
) {
- scene(SceneA) { /* Nothing */}
+ scene(SceneA) { /* Nothing */ }
scene(SceneB) { Box(Modifier.element(key)) }
scene(SceneC) {
when (sceneCState) {
@@ -1083,10 +1084,17 @@
}
val layoutSize = DpSize(200.dp, 100.dp)
+ val lastValues = mutableMapOf<SceneKey, Float>()
@Composable
- fun SceneScope.Foo(size: Dp, modifier: Modifier = Modifier) {
- Box(modifier.element(TestElements.Foo).size(size))
+ fun SceneScope.Foo(size: Dp, value: Float, modifier: Modifier = Modifier) {
+ val sceneKey = this.sceneKey
+ Element(TestElements.Foo, modifier.size(size)) {
+ val animatedValue = animateElementFloatAsState(value, TestValues.Value1)
+ LaunchedEffect(animatedValue) {
+ snapshotFlow { animatedValue.value }.collect { lastValues[sceneKey] = it }
+ }
+ }
}
// The size of Foo when idle in A, B or C.
@@ -1094,6 +1102,11 @@
val sizeInB = 30.dp
val sizeInC = 50.dp
+ // The target value when idle in A, B, or C.
+ val valueInA = 0f
+ val valueInB = 100f
+ val valueInC = 200f
+
lateinit var layoutImpl: SceneTransitionLayoutImpl
rule.setContent {
SceneTransitionLayoutForTesting(
@@ -1103,7 +1116,9 @@
) {
// In scene A, Foo is aligned at the TopStart.
scene(SceneA) {
- Box(Modifier.fillMaxSize()) { Foo(sizeInA, Modifier.align(Alignment.TopStart)) }
+ Box(Modifier.fillMaxSize()) {
+ Foo(sizeInA, valueInA, Modifier.align(Alignment.TopStart))
+ }
}
// In scene C, Foo is aligned at the BottomEnd, so it moves vertically when coming
@@ -1111,14 +1126,16 @@
// values and deltas are properly cleared once all transitions are done.
scene(SceneC) {
Box(Modifier.fillMaxSize()) {
- Foo(sizeInC, Modifier.align(Alignment.BottomEnd))
+ Foo(sizeInC, valueInC, Modifier.align(Alignment.BottomEnd))
}
}
// In scene B, Foo is aligned at the TopEnd, so it moves horizontally when coming
// from A.
scene(SceneB) {
- Box(Modifier.fillMaxSize()) { Foo(sizeInB, Modifier.align(Alignment.TopEnd)) }
+ Box(Modifier.fillMaxSize()) {
+ Foo(sizeInB, valueInB, Modifier.align(Alignment.TopEnd))
+ }
}
}
}
@@ -1134,6 +1151,10 @@
.assertSizeIsEqualTo(sizeInA)
.assertPositionInRootIsEqualTo(offsetInA.x, offsetInA.y)
+ assertThat(lastValues[SceneA]).isWithin(0.001f).of(valueInA)
+ assertThat(lastValues[SceneB]).isNull()
+ assertThat(lastValues[SceneC]).isNull()
+
// Current transition is A => B at 50%.
val aToBProgress = 0.5f
val aToB =
@@ -1145,12 +1166,17 @@
)
val offsetInAToB = lerp(offsetInA, offsetInB, aToBProgress)
val sizeInAToB = lerp(sizeInA, sizeInB, aToBProgress)
+ val valueInAToB = lerp(valueInA, valueInB, aToBProgress)
rule.runOnUiThread { state.startTransition(aToB, transitionKey = null) }
rule
.onNode(isElement(TestElements.Foo, SceneB))
.assertSizeIsEqualTo(sizeInAToB)
.assertPositionInRootIsEqualTo(offsetInAToB.x, offsetInAToB.y)
+ assertThat(lastValues[SceneA]).isWithin(0.001f).of(valueInAToB)
+ assertThat(lastValues[SceneB]).isWithin(0.001f).of(valueInAToB)
+ assertThat(lastValues[SceneC]).isNull()
+
// Start B => C at 0%.
var bToCProgress by mutableFloatStateOf(0f)
var interruptionProgress by mutableFloatStateOf(1f)
@@ -1167,6 +1193,11 @@
// to the current transition offset and size.
val offsetInterruptionDelta = offsetInAToB - offsetInB
val sizeInterruptionDelta = sizeInAToB - sizeInB
+ val valueInterruptionDelta = valueInAToB - valueInB
+
+ assertThat(offsetInterruptionDelta).isNotEqualTo(DpOffset.Zero)
+ assertThat(sizeInterruptionDelta).isNotEqualTo(0.dp)
+ assertThat(valueInterruptionDelta).isNotEqualTo(0f)
// Interruption progress is at 100% and bToC is at 0%, so Foo should be at the same offset
// and size as right before the interruption.
@@ -1175,11 +1206,16 @@
.assertPositionInRootIsEqualTo(offsetInAToB.x, offsetInAToB.y)
.assertSizeIsEqualTo(sizeInAToB)
+ assertThat(lastValues[SceneA]).isWithin(0.001f).of(valueInAToB)
+ assertThat(lastValues[SceneB]).isWithin(0.001f).of(valueInAToB)
+ assertThat(lastValues[SceneC]).isWithin(0.001f).of(valueInAToB)
+
// Move the transition forward at 30% and set the interruption progress to 50%.
bToCProgress = 0.3f
interruptionProgress = 0.5f
val offsetInBToC = lerp(offsetInB, offsetInC, bToCProgress)
val sizeInBToC = lerp(sizeInB, sizeInC, bToCProgress)
+ val valueInBToC = lerp(valueInB, valueInC, bToCProgress)
val offsetInBToCWithInterruption =
offsetInBToC +
DpOffset(
@@ -1187,6 +1223,9 @@
offsetInterruptionDelta.y * interruptionProgress,
)
val sizeInBToCWithInterruption = sizeInBToC + sizeInterruptionDelta * interruptionProgress
+ val valueInBToCWithInterruption =
+ valueInBToC + valueInterruptionDelta * interruptionProgress
+
rule.waitForIdle()
rule
.onNode(isElement(TestElements.Foo, SceneB))
@@ -1196,6 +1235,10 @@
)
.assertSizeIsEqualTo(sizeInBToCWithInterruption)
+ assertThat(lastValues[SceneA]).isWithin(0.001f).of(valueInBToCWithInterruption)
+ assertThat(lastValues[SceneB]).isWithin(0.001f).of(valueInBToCWithInterruption)
+ assertThat(lastValues[SceneC]).isWithin(0.001f).of(valueInBToCWithInterruption)
+
// Finish the transition and interruption.
bToCProgress = 1f
interruptionProgress = 0f
diff --git a/packages/SystemUI/compose/scene/tests/src/com/android/compose/animation/scene/SceneTransitionLayoutTest.kt b/packages/SystemUI/compose/scene/tests/src/com/android/compose/animation/scene/SceneTransitionLayoutTest.kt
index 3751a22..08532bd 100644
--- a/packages/SystemUI/compose/scene/tests/src/com/android/compose/animation/scene/SceneTransitionLayoutTest.kt
+++ b/packages/SystemUI/compose/scene/tests/src/com/android/compose/animation/scene/SceneTransitionLayoutTest.kt
@@ -461,4 +461,30 @@
assertThat(exception).hasMessageThat().contains(Back.toString())
assertThat(exception).hasMessageThat().contains(SceneA.debugName)
}
+
+ @Test
+ fun sceneKeyInScope() {
+ val state = rule.runOnUiThread { MutableSceneTransitionLayoutState(SceneA) }
+
+ var keyInA: SceneKey? = null
+ var keyInB: SceneKey? = null
+ var keyInC: SceneKey? = null
+ rule.setContent {
+ SceneTransitionLayout(state) {
+ scene(SceneA) { keyInA = sceneKey }
+ scene(SceneB) { keyInB = sceneKey }
+ scene(SceneC) { keyInC = sceneKey }
+ }
+ }
+
+ // Snap to B then C to compose these scenes at least once.
+ rule.runOnUiThread { state.snapToScene(SceneB) }
+ rule.waitForIdle()
+ rule.runOnUiThread { state.snapToScene(SceneC) }
+ rule.waitForIdle()
+
+ assertThat(keyInA).isEqualTo(SceneA)
+ assertThat(keyInB).isEqualTo(SceneB)
+ assertThat(keyInC).isEqualTo(SceneC)
+ }
}
diff --git a/packages/SystemUI/compose/scene/tests/src/com/android/compose/animation/scene/SwipeToSceneTest.kt b/packages/SystemUI/compose/scene/tests/src/com/android/compose/animation/scene/SwipeToSceneTest.kt
index 3a806a4..25ea2ee 100644
--- a/packages/SystemUI/compose/scene/tests/src/com/android/compose/animation/scene/SwipeToSceneTest.kt
+++ b/packages/SystemUI/compose/scene/tests/src/com/android/compose/animation/scene/SwipeToSceneTest.kt
@@ -30,6 +30,7 @@
import androidx.compose.ui.geometry.Offset
import androidx.compose.ui.platform.LocalViewConfiguration
import androidx.compose.ui.platform.testTag
+import androidx.compose.ui.test.assertPositionInRootIsEqualTo
import androidx.compose.ui.test.junit4.createComposeRule
import androidx.compose.ui.test.onRoot
import androidx.compose.ui.test.performTouchInput
@@ -594,4 +595,43 @@
assertThat(transition).hasToScene(SceneB)
assertThat(transition).hasProgress(0.5f, tolerance = 0.01f)
}
+
+ @Test
+ fun overscrollScopeExtendsDensity() {
+ val swipeDistance = 100.dp
+ val state =
+ rule.runOnUiThread {
+ MutableSceneTransitionLayoutState(
+ SceneA,
+ transitions {
+ from(SceneA, to = SceneB) { distance = FixedDistance(swipeDistance) }
+
+ overscroll(SceneB, Orientation.Vertical) {
+ translate(TestElements.Foo, x = { 20.dp.toPx() }, y = { 30.dp.toPx() })
+ }
+ }
+ )
+ }
+ val layoutSize = 200.dp
+ var touchSlop = 0f
+ rule.setContent {
+ touchSlop = LocalViewConfiguration.current.touchSlop
+ SceneTransitionLayout(state, Modifier.size(layoutSize)) {
+ scene(SceneA, userActions = mapOf(Swipe.Down to SceneB)) {
+ Box(Modifier.fillMaxSize())
+ }
+ scene(SceneB) { Box(Modifier.element(TestElements.Foo).fillMaxSize()) }
+ }
+ }
+
+ // Swipe down by twice the swipe distance so that we are at 100% overscrolling on scene B.
+ rule.onRoot().performTouchInput {
+ val middle = (layoutSize / 2).toPx()
+ down(Offset(middle, middle))
+ moveBy(Offset(0f, touchSlop + (swipeDistance * 2).toPx()), delayMillis = 1_000)
+ }
+
+ // Foo should be translated by (20dp, 30dp).
+ rule.onNode(isElement(TestElements.Foo)).assertPositionInRootIsEqualTo(20.dp, 30.dp)
+ }
}
diff --git a/packages/SystemUI/compose/scene/tests/src/com/android/compose/animation/scene/Transition.kt b/packages/SystemUI/compose/scene/tests/src/com/android/compose/animation/scene/Transition.kt
index a609be4..e6fa69d 100644
--- a/packages/SystemUI/compose/scene/tests/src/com/android/compose/animation/scene/Transition.kt
+++ b/packages/SystemUI/compose/scene/tests/src/com/android/compose/animation/scene/Transition.kt
@@ -41,8 +41,10 @@
return object : TransitionState.Transition(from, to), TransitionState.HasOverscrollProperties {
override val currentScene: SceneKey
get() = current()
+
override val progress: Float
get() = progress()
+
override val progressVelocity: Float
get() = progressVelocity()
@@ -53,6 +55,8 @@
override val orientation: Orientation = orientation
override val overscrollScope: OverscrollScope =
object : OverscrollScope {
+ override val density: Float = 1f
+ override val fontScale: Float = 1f
override val absoluteDistance = 0f
}
diff --git a/packages/SystemUI/customization/src/com/android/systemui/shared/clocks/DefaultClockController.kt b/packages/SystemUI/customization/src/com/android/systemui/shared/clocks/DefaultClockController.kt
index b392014..502dbe3 100644
--- a/packages/SystemUI/customization/src/com/android/systemui/shared/clocks/DefaultClockController.kt
+++ b/packages/SystemUI/customization/src/com/android/systemui/shared/clocks/DefaultClockController.kt
@@ -239,6 +239,8 @@
}
inner class DefaultClockEvents : ClockEvents {
+ override var isReactiveTouchInteractionEnabled: Boolean = false
+
override fun onTimeFormatChanged(is24Hr: Boolean) =
clocks.forEach { it.refreshFormat(is24Hr) }
diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/communal/data/repository/CommunalSettingsRepositoryImplTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/communal/data/repository/CommunalSettingsRepositoryImplTest.kt
index 89c5495..fb2b33d 100644
--- a/packages/SystemUI/multivalentTests/src/com/android/systemui/communal/data/repository/CommunalSettingsRepositoryImplTest.kt
+++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/communal/data/repository/CommunalSettingsRepositoryImplTest.kt
@@ -34,6 +34,8 @@
import com.android.systemui.SysuiTestCase
import com.android.systemui.broadcast.broadcastDispatcher
import com.android.systemui.communal.data.model.DisabledReason
+import com.android.systemui.communal.data.repository.CommunalSettingsRepositoryImpl.Companion.GLANCEABLE_HUB_BACKGROUND_SETTING
+import com.android.systemui.communal.shared.model.CommunalBackgroundType
import com.android.systemui.coroutines.collectLastValue
import com.android.systemui.flags.Flags.COMMUNAL_SERVICE_ENABLED
import com.android.systemui.flags.fakeFeatureFlagsClassic
@@ -43,6 +45,7 @@
import com.android.systemui.util.mockito.whenever
import com.android.systemui.util.settings.fakeSettings
import com.google.common.truth.Truth.assertThat
+import com.google.common.truth.Truth.assertWithMessage
import kotlinx.coroutines.test.runTest
import org.junit.Before
import org.junit.Test
@@ -216,6 +219,32 @@
)
}
+ @Test
+ fun backgroundType_defaultValue() =
+ testScope.runTest {
+ val backgroundType by collectLastValue(underTest.getBackground(PRIMARY_USER))
+ assertThat(backgroundType).isEqualTo(CommunalBackgroundType.DEFAULT)
+ }
+
+ @Test
+ fun backgroundType_verifyAllValues() =
+ testScope.runTest {
+ val backgroundType by collectLastValue(underTest.getBackground(PRIMARY_USER))
+ for (type in CommunalBackgroundType.entries) {
+ kosmos.fakeSettings.putIntForUser(
+ GLANCEABLE_HUB_BACKGROUND_SETTING,
+ type.value,
+ PRIMARY_USER.id
+ )
+ assertWithMessage(
+ "Expected $type when $GLANCEABLE_HUB_BACKGROUND_SETTING is set to" +
+ " ${type.value} but was $backgroundType"
+ )
+ .that(backgroundType)
+ .isEqualTo(type)
+ }
+ }
+
private fun setKeyguardFeaturesDisabled(user: UserInfo, disabledFlags: Int) {
whenever(kosmos.devicePolicyManager.getKeyguardDisabledFeatures(nullable(), eq(user.id)))
.thenReturn(disabledFlags)
diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/communal/view/viewmodel/CommunalViewModelTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/communal/view/viewmodel/CommunalViewModelTest.kt
index a1bad39..9dcea82 100644
--- a/packages/SystemUI/multivalentTests/src/com/android/systemui/communal/view/viewmodel/CommunalViewModelTest.kt
+++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/communal/view/viewmodel/CommunalViewModelTest.kt
@@ -37,6 +37,7 @@
import com.android.systemui.communal.data.repository.fakeCommunalWidgetRepository
import com.android.systemui.communal.domain.interactor.communalInteractor
import com.android.systemui.communal.domain.interactor.communalSceneInteractor
+import com.android.systemui.communal.domain.interactor.communalSettingsInteractor
import com.android.systemui.communal.domain.interactor.communalTutorialInteractor
import com.android.systemui.communal.domain.model.CommunalContentModel
import com.android.systemui.communal.shared.model.CommunalScenes
@@ -152,6 +153,7 @@
kosmos.keyguardInteractor,
kosmos.communalSceneInteractor,
kosmos.communalInteractor,
+ kosmos.communalSettingsInteractor,
kosmos.communalTutorialInteractor,
kosmos.shadeInteractor,
mediaHost,
diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/keyguard/domain/interactor/KeyguardQuickAffordanceInteractorTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/keyguard/domain/interactor/KeyguardQuickAffordanceInteractorTest.kt
index 5068f68..78a1167 100644
--- a/packages/SystemUI/multivalentTests/src/com/android/systemui/keyguard/domain/interactor/KeyguardQuickAffordanceInteractorTest.kt
+++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/keyguard/domain/interactor/KeyguardQuickAffordanceInteractorTest.kt
@@ -350,7 +350,7 @@
}
@Test
- fun quickAffordance_doNotSendUpdatesWhileShadeExpandingAndStillHidden() =
+ fun quickAffordance_updateOncePerShadeExpansion() =
testScope.runTest {
val shadeExpansion = MutableStateFlow(0f)
whenever(shadeInteractor.anyExpansion).thenReturn(shadeExpansion)
@@ -365,9 +365,7 @@
shadeExpansion.value = i / 10f
}
- assertThat(collectedValue[0])
- .isInstanceOf(KeyguardQuickAffordanceModel.Hidden::class.java)
- assertThat(collectedValue.size).isEqualTo(initialSize)
+ assertThat(collectedValue.size).isEqualTo(initialSize + 1)
}
@Test
diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/keyguard/ui/viewmodel/DozingToGoneTransitionViewModelTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/keyguard/ui/viewmodel/DozingToGoneTransitionViewModelTest.kt
index 79671b8..bf3231e 100644
--- a/packages/SystemUI/multivalentTests/src/com/android/systemui/keyguard/ui/viewmodel/DozingToGoneTransitionViewModelTest.kt
+++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/keyguard/ui/viewmodel/DozingToGoneTransitionViewModelTest.kt
@@ -53,7 +53,7 @@
@Test
fun lockscreenAlpha() =
testScope.runTest {
- val viewState = ViewStateAccessor(alpha = { 0.6f })
+ val viewState = ViewStateAccessor()
val alpha by collectValues(underTest.lockscreenAlpha(viewState))
keyguardTransitionRepository.sendTransitionSteps(
@@ -62,11 +62,9 @@
testScope
)
- assertThat(alpha[0]).isEqualTo(0.6f)
- // Fades out just prior to halfway
+ // Remain at zero throughout
+ assertThat(alpha[0]).isEqualTo(0f)
assertThat(alpha[1]).isEqualTo(0f)
- // Must finish at 0
- assertThat(alpha[2]).isEqualTo(0f)
}
@Test
diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/keyguard/ui/viewmodel/KeyguardRootViewModelTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/keyguard/ui/viewmodel/KeyguardRootViewModelTest.kt
index 33e2cac..49df345 100644
--- a/packages/SystemUI/multivalentTests/src/com/android/systemui/keyguard/ui/viewmodel/KeyguardRootViewModelTest.kt
+++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/keyguard/ui/viewmodel/KeyguardRootViewModelTest.kt
@@ -399,6 +399,53 @@
}
@Test
+ @DisableSceneContainer
+ fun alphaFromShadeExpansion_doesNotEmitWhenTransitionRunning() =
+ testScope.runTest {
+ keyguardTransitionRepository.sendTransitionSteps(
+ from = KeyguardState.AOD,
+ to = KeyguardState.LOCKSCREEN,
+ testScope,
+ )
+
+ val alpha by collectLastValue(underTest.alpha(viewState))
+ shadeTestUtil.setQsExpansion(0f)
+ runCurrent()
+ assertThat(alpha).isEqualTo(1f)
+
+ keyguardTransitionRepository.sendTransitionSteps(
+ from = KeyguardState.LOCKSCREEN,
+ to = KeyguardState.PRIMARY_BOUNCER,
+ testScope,
+ )
+ assertThat(alpha).isEqualTo(0f)
+
+ keyguardTransitionRepository.sendTransitionSteps(
+ listOf(
+ TransitionStep(
+ from = KeyguardState.PRIMARY_BOUNCER,
+ to = KeyguardState.LOCKSCREEN,
+ transitionState = TransitionState.STARTED,
+ value = 0f,
+ ),
+ TransitionStep(
+ from = KeyguardState.PRIMARY_BOUNCER,
+ to = KeyguardState.LOCKSCREEN,
+ transitionState = TransitionState.RUNNING,
+ value = 0.8f,
+ ),
+ ),
+ testScope,
+ )
+ // Alpha should be 1f from the above transition
+ assertThat(alpha).isEqualTo(1f)
+
+ shadeTestUtil.setQsExpansion(0.5f)
+ // Alpha should remain unchanged instead of fading out
+ assertThat(alpha).isEqualTo(1f)
+ }
+
+ @Test
fun alpha_shadeClosedOverLockscreen_isOne() =
testScope.runTest {
val alpha by collectLastValue(underTest.alpha(viewState))
diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/scene/domain/startable/ScrimStartableTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/scene/domain/startable/ScrimStartableTest.kt
new file mode 100644
index 0000000..0e90afe
--- /dev/null
+++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/scene/domain/startable/ScrimStartableTest.kt
@@ -0,0 +1,452 @@
+/*
+ * 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.
+ */
+
+@file:OptIn(ExperimentalCoroutinesApi::class)
+
+package com.android.systemui.scene.domain.startable
+
+import androidx.test.filters.SmallTest
+import com.android.compose.animation.scene.ObservableTransitionState
+import com.android.compose.animation.scene.SceneKey
+import com.android.systemui.SysuiTestCase
+import com.android.systemui.bouncer.data.repository.fakeKeyguardBouncerRepository
+import com.android.systemui.coroutines.collectLastValue
+import com.android.systemui.flags.EnableSceneContainer
+import com.android.systemui.keyguard.data.repository.fakeDeviceEntryFingerprintAuthRepository
+import com.android.systemui.keyguard.data.repository.fakeKeyguardRepository
+import com.android.systemui.keyguard.domain.interactor.biometricUnlockInteractor
+import com.android.systemui.keyguard.shared.model.BiometricUnlockSource
+import com.android.systemui.keyguard.shared.model.DozeStateModel
+import com.android.systemui.keyguard.shared.model.DozeTransitionModel
+import com.android.systemui.keyguard.shared.model.SuccessFingerprintAuthenticationStatus
+import com.android.systemui.kosmos.testScope
+import com.android.systemui.scene.data.repository.setSceneTransition
+import com.android.systemui.scene.domain.interactor.sceneInteractor
+import com.android.systemui.scene.shared.model.Scenes
+import com.android.systemui.settings.brightness.domain.interactor.brightnessMirrorShowingInteractor
+import com.android.systemui.statusbar.domain.interactor.keyguardOcclusionInteractor
+import com.android.systemui.statusbar.phone.BiometricUnlockController
+import com.android.systemui.statusbar.phone.ScrimState
+import com.android.systemui.statusbar.phone.centralSurfaces
+import com.android.systemui.statusbar.phone.dozeServiceHost
+import com.android.systemui.statusbar.phone.statusBarKeyguardViewManager
+import com.android.systemui.testKosmos
+import com.google.common.truth.Truth.assertThat
+import com.google.common.truth.Truth.assertWithMessage
+import kotlin.reflect.full.memberProperties
+import kotlinx.coroutines.ExperimentalCoroutinesApi
+import kotlinx.coroutines.flow.flowOf
+import kotlinx.coroutines.test.TestScope
+import kotlinx.coroutines.test.runCurrent
+import kotlinx.coroutines.test.runTest
+import org.junit.Before
+import org.junit.BeforeClass
+import org.junit.Test
+import org.junit.runner.RunWith
+import org.mockito.kotlin.mock
+import org.mockito.kotlin.whenever
+import platform.test.runner.parameterized.Parameter
+import platform.test.runner.parameterized.ParameterizedAndroidJunit4
+import platform.test.runner.parameterized.Parameters
+
+@SmallTest
+@RunWith(ParameterizedAndroidJunit4::class)
+@EnableSceneContainer
+class ScrimStartableTest : SysuiTestCase() {
+
+ companion object {
+ @Parameters(name = "{0}")
+ @JvmStatic
+ fun testSpecs(): List<TestSpec> {
+ return listOf(
+ TestSpec(
+ id = 0,
+ expectedState = ScrimState.KEYGUARD,
+ Preconditions(
+ isOnKeyguard = true,
+ isAlternateBouncerVisible = true,
+ isTransitioningAwayFromKeyguard = true,
+ ),
+ ),
+ TestSpec(
+ id = 1,
+ expectedState = null,
+ Preconditions(
+ isOnKeyguard = true,
+ isAlternateBouncerVisible = true,
+ isTransitioningToShade = true,
+ ),
+ ),
+ TestSpec(
+ id = 2,
+ expectedState = ScrimState.BOUNCER,
+ Preconditions(
+ isOnKeyguard = true,
+ isCurrentSceneBouncer = true,
+ ),
+ ),
+ TestSpec(
+ id = 3,
+ expectedState = ScrimState.BOUNCER_SCRIMMED,
+ Preconditions(
+ isOnKeyguard = true,
+ isCurrentSceneBouncer = true,
+ isBouncerScrimmingNeeded = true,
+ ),
+ ),
+ TestSpec(
+ id = 4,
+ expectedState = ScrimState.BRIGHTNESS_MIRROR,
+ Preconditions(
+ isOnKeyguard = true,
+ isBrightnessMirrorVisible = true,
+ ),
+ ),
+ TestSpec(
+ id = 5,
+ expectedState = ScrimState.BRIGHTNESS_MIRROR,
+ Preconditions(
+ isOnKeyguard = true,
+ isCurrentSceneBouncer = true,
+ isBiometricWakeAndUnlock = true,
+ isBrightnessMirrorVisible = true,
+ ),
+ ),
+ TestSpec(
+ id = 6,
+ expectedState = ScrimState.SHADE_LOCKED,
+ Preconditions(
+ isOnKeyguard = true,
+ isCurrentSceneShade = true,
+ ),
+ ),
+ TestSpec(
+ id = 7,
+ expectedState = ScrimState.PULSING,
+ Preconditions(
+ isOnKeyguard = true,
+ isDozing = true,
+ isPulsing = true,
+ ),
+ ),
+ TestSpec(
+ id = 8,
+ expectedState = ScrimState.OFF,
+ Preconditions(
+ isOnKeyguard = true,
+ hasPendingScreenOffCallback = true,
+ ),
+ ),
+ TestSpec(
+ id = 9,
+ expectedState = ScrimState.AOD,
+ Preconditions(
+ isOnKeyguard = true,
+ isDozing = true,
+ ),
+ ),
+ TestSpec(
+ id = 10,
+ expectedState = ScrimState.GLANCEABLE_HUB,
+ Preconditions(
+ isIdleOnCommunal = true,
+ ),
+ ),
+ TestSpec(
+ id = 11,
+ expectedState = ScrimState.GLANCEABLE_HUB_OVER_DREAM,
+ Preconditions(isIdleOnCommunal = true, isDreaming = true),
+ ),
+ TestSpec(
+ id = 12,
+ expectedState = ScrimState.UNLOCKED,
+ Preconditions(
+ isDeviceEntered = true,
+ ),
+ ),
+ TestSpec(
+ id = 13,
+ expectedState = ScrimState.UNLOCKED,
+ Preconditions(
+ isOnKeyguard = true,
+ isBiometricWakeAndUnlock = true,
+ ),
+ ),
+ TestSpec(
+ id = 14,
+ expectedState = ScrimState.KEYGUARD,
+ Preconditions(),
+ ),
+ TestSpec(
+ id = 15,
+ expectedState = ScrimState.DREAMING,
+ Preconditions(
+ isOnKeyguard = true,
+ isOccluded = true,
+ isDreaming = true,
+ ),
+ ),
+ TestSpec(
+ id = 16,
+ expectedState = ScrimState.UNLOCKED,
+ Preconditions(
+ isOnKeyguard = true,
+ isOccluded = true,
+ ),
+ ),
+ )
+ }
+
+ @BeforeClass
+ @JvmStatic
+ fun setUpClass() {
+ val seenIds = mutableSetOf<Int>()
+ testSpecs().forEach { testSpec ->
+ assertWithMessage("Duplicate TestSpec id=${testSpec.id}")
+ .that(seenIds)
+ .doesNotContain(testSpec.id)
+ seenIds.add(testSpec.id)
+ }
+ }
+ }
+
+ private val kosmos = testKosmos()
+ private val testScope = kosmos.testScope
+
+ private val underTest = kosmos.scrimStartable
+
+ @JvmField @Parameter(0) var testSpec: TestSpec? = null
+
+ @Before
+ fun setUp() {
+ kosmos.dozeServiceHost.initialize(
+ /* centralSurfaces= */ kosmos.centralSurfaces,
+ /* statusBarKeyguardViewManager= */ kosmos.statusBarKeyguardViewManager,
+ /* notificationShadeWindowViewController= */ mock(),
+ /* ambientIndicationContainer= */ mock(),
+ )
+ underTest.start()
+ }
+
+ @Test
+ fun test() =
+ testScope.runTest {
+ val observedState by collectLastValue(underTest.scrimState)
+ val preconditions = checkNotNull(testSpec).preconditions
+ preconditions.assertValid()
+
+ setUpWith(preconditions)
+
+ runCurrent()
+
+ assertThat(observedState).isEqualTo(checkNotNull(testSpec).expectedState)
+ }
+
+ /** Sets up the state to match what's specified in the given [preconditions]. */
+ private fun TestScope.setUpWith(
+ preconditions: Preconditions,
+ ) {
+ kosmos.fakeKeyguardBouncerRepository.setAlternateVisible(
+ preconditions.isAlternateBouncerVisible
+ )
+
+ if (preconditions.isDeviceEntered) {
+ kosmos.fakeDeviceEntryFingerprintAuthRepository.setAuthenticationStatus(
+ SuccessFingerprintAuthenticationStatus(0, true)
+ )
+ whenIdle(on = Scenes.Gone)
+ } else {
+ whenIdle(on = Scenes.Lockscreen)
+ }
+ runCurrent()
+
+ when {
+ preconditions.isTransitioningToShade ->
+ whenTransitioning(
+ from = Scenes.Lockscreen,
+ to = Scenes.Shade,
+ )
+ preconditions.isTransitioningAwayFromKeyguard ->
+ whenTransitioning(
+ from = Scenes.Lockscreen,
+ to = Scenes.Gone,
+ )
+ preconditions.isCurrentSceneShade -> whenIdle(on = Scenes.Shade)
+ preconditions.isCurrentSceneBouncer -> whenIdle(on = Scenes.Bouncer)
+ preconditions.isIdleOnCommunal -> whenIdle(on = Scenes.Communal)
+ }
+
+ kosmos.keyguardOcclusionInteractor.setWmNotifiedShowWhenLockedActivityOnTop(
+ showWhenLockedActivityOnTop = preconditions.isOccluded,
+ taskInfo = if (preconditions.isOccluded) mock() else null,
+ )
+
+ if (preconditions.isBiometricWakeAndUnlock) {
+ kosmos.biometricUnlockInteractor.setBiometricUnlockState(
+ BiometricUnlockController.MODE_WAKE_AND_UNLOCK,
+ BiometricUnlockSource.FINGERPRINT_SENSOR,
+ )
+ }
+
+ kosmos.brightnessMirrorShowingInteractor.setMirrorShowing(
+ preconditions.isBrightnessMirrorVisible
+ )
+
+ if (preconditions.hasPendingScreenOffCallback) {
+ kosmos.dozeServiceHost.prepareForGentleSleep {}
+ } else {
+ kosmos.dozeServiceHost.cancelGentleSleep()
+ }
+
+ kosmos.fakeKeyguardRepository.setIsDozing(preconditions.isDozing)
+ if (preconditions.isPulsing) {
+ kosmos.fakeKeyguardRepository.setDozeTransitionModel(
+ DozeTransitionModel(to = DozeStateModel.DOZE_PULSING)
+ )
+ }
+ kosmos.fakeKeyguardRepository.setDreaming(preconditions.isDreaming)
+
+ whenever(kosmos.statusBarKeyguardViewManager.primaryBouncerNeedsScrimming())
+ .thenReturn(preconditions.isBouncerScrimmingNeeded)
+
+ runCurrent()
+ }
+
+ /** Sets up an idle state on the given [on] scene. */
+ private fun whenIdle(on: SceneKey) {
+ kosmos.setSceneTransition(ObservableTransitionState.Idle(on))
+ kosmos.sceneInteractor.changeScene(on, "")
+ }
+
+ /** Sets up a transitioning state between the [given] and [to] scenes. */
+ private fun whenTransitioning(from: SceneKey, to: SceneKey, progress: Float = 0.5f) {
+ val currentScene = if (progress > 0.5f) to else from
+ kosmos.setSceneTransition(
+ ObservableTransitionState.Transition(
+ fromScene = from,
+ toScene = to,
+ progress = flowOf(progress),
+ currentScene = flowOf(currentScene),
+ isInitiatedByUserInput = true,
+ isUserInputOngoing = flowOf(false),
+ )
+ )
+ kosmos.sceneInteractor.changeScene(currentScene, "")
+ }
+
+ data class Preconditions(
+ /** Whether bouncer or lockscreen scene is in the nav stack. */
+ val isOnKeyguard: Boolean = false,
+ val isAlternateBouncerVisible: Boolean = false,
+ /** Whether any non-shade nor QS scene is transitioning to a shade or QS scene. */
+ val isTransitioningToShade: Boolean = false,
+ val isOccluded: Boolean = false,
+ val isCurrentSceneBouncer: Boolean = false,
+ val isBiometricWakeAndUnlock: Boolean = false,
+ /** Whether there's an active transition from lockscreen or bouncer to gone. */
+ val isTransitioningAwayFromKeyguard: Boolean = false,
+ val isBrightnessMirrorVisible: Boolean = false,
+ /** Whether the current scene is a shade or QS scene. */
+ val isCurrentSceneShade: Boolean = false,
+ val isDeviceEntered: Boolean = false,
+ val isPulsing: Boolean = false,
+ val hasPendingScreenOffCallback: Boolean = false,
+ val isDozing: Boolean = false,
+ val isIdleOnCommunal: Boolean = false,
+ val isDreaming: Boolean = false,
+ val isBouncerScrimmingNeeded: Boolean = false,
+ ) {
+ override fun toString(): String {
+ // Only include values overridden to true:
+ return buildString {
+ append("(")
+ append(
+ Preconditions::class
+ .memberProperties
+ .filter { it.get(this@Preconditions) == true }
+ .joinToString(", ") { "${it.name}=true" }
+ )
+ append(")")
+ }
+ }
+
+ fun assertValid() {
+ assertWithMessage("isOccluded cannot be true without isOnKeyguard also being true")
+ .that(!isOccluded || isOnKeyguard)
+ .isTrue()
+
+ assertWithMessage(
+ "isCurrentSceneBouncer cannot be true without isOnKeyguard also being true"
+ )
+ .that(!isCurrentSceneBouncer || isOnKeyguard)
+ .isTrue()
+
+ assertWithMessage(
+ "isTransitioningAwayFromKeyguard cannot be true without isOnKeyguard being true"
+ )
+ .that(!isTransitioningAwayFromKeyguard || isOnKeyguard)
+ .isTrue()
+
+ assertWithMessage(
+ "isCurrentSceneBouncer cannot be true at the same time as isCurrentSceneShade"
+ )
+ .that(!isCurrentSceneBouncer || !isCurrentSceneShade)
+ .isTrue()
+
+ assertWithMessage(
+ "isCurrentSceneBouncer cannot be true at the same time as isIdleOnCommunal"
+ )
+ .that(!isCurrentSceneBouncer || !isIdleOnCommunal)
+ .isTrue()
+
+ assertWithMessage(
+ "isCurrentSceneShade cannot be true at the same time as isIdleOnCommunal"
+ )
+ .that(!isCurrentSceneShade || !isIdleOnCommunal)
+ .isTrue()
+
+ assertWithMessage("isDeviceEntered cannot be true at the same time as isOnKeyguard")
+ .that(!isDeviceEntered || !isOnKeyguard)
+ .isTrue()
+
+ assertWithMessage(
+ "isDeviceEntered cannot be true at the same time as isCurrentSceneBouncer"
+ )
+ .that(!isDeviceEntered || !isCurrentSceneBouncer)
+ .isTrue()
+
+ assertWithMessage(
+ "isDeviceEntered cannot be true at the same time as isAlternateBouncerVisible"
+ )
+ .that(!isDeviceEntered || !isAlternateBouncerVisible)
+ .isTrue()
+
+ assertWithMessage("isPulsing cannot be true if both isDozing is false")
+ .that(!isPulsing || isDozing)
+ .isTrue()
+ }
+ }
+
+ data class TestSpec(
+ val id: Int,
+ val expectedState: ScrimState?,
+ val preconditions: Preconditions,
+ ) {
+ override fun toString(): String {
+ return "id=$id, expected=$expectedState, preconditions=$preconditions"
+ }
+ }
+}
diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/volume/domain/interactor/AudioOutputInteractorTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/volume/domain/interactor/AudioOutputInteractorTest.kt
index b83b93b..10a4eb7 100644
--- a/packages/SystemUI/multivalentTests/src/com/android/systemui/volume/domain/interactor/AudioOutputInteractorTest.kt
+++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/volume/domain/interactor/AudioOutputInteractorTest.kt
@@ -50,6 +50,8 @@
import org.mockito.kotlin.mock
import org.mockito.kotlin.whenever
+private const val builtInDeviceName = "This phone"
+
@OptIn(ExperimentalCoroutinesApi::class)
@RunWith(AndroidJUnit4::class)
@SmallTest
@@ -71,6 +73,10 @@
addOverride(R.drawable.ic_media_speaker_device, testIcon)
addOverride(com.android.internal.R.drawable.ic_bt_hearing_aid, testIcon)
+
+ addOverride(R.string.media_transfer_this_device_name_tv, builtInDeviceName)
+ addOverride(R.string.media_transfer_this_device_name_tablet, builtInDeviceName)
+ addOverride(R.string.media_transfer_this_device_name, builtInDeviceName)
}
}
}
@@ -90,7 +96,7 @@
assertThat(device).isInstanceOf(AudioOutputDevice.BuiltIn::class.java)
assertThat(device!!.icon).isEqualTo(testIcon)
- assertThat(device!!.name).isEqualTo("built_in")
+ assertThat(device!!.name).isEqualTo(builtInDeviceName)
}
}
}
diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/volume/panel/component/mediaoutput/domain/interactor/MediaOutputComponentInteractorTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/volume/panel/component/mediaoutput/domain/interactor/MediaOutputComponentInteractorTest.kt
new file mode 100644
index 0000000..8921a23
--- /dev/null
+++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/volume/panel/component/mediaoutput/domain/interactor/MediaOutputComponentInteractorTest.kt
@@ -0,0 +1,141 @@
+/*
+ * 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.systemui.volume.panel.component.mediaoutput.domain.interactor
+
+import android.graphics.drawable.TestStubDrawable
+import android.media.AudioManager
+import android.testing.TestableLooper
+import androidx.test.ext.junit.runners.AndroidJUnit4
+import androidx.test.filters.SmallTest
+import com.android.settingslib.R
+import com.android.systemui.SysuiTestCase
+import com.android.systemui.coroutines.collectLastValue
+import com.android.systemui.kosmos.testScope
+import com.android.systemui.testKosmos
+import com.android.systemui.volume.data.repository.TestAudioDevicesFactory
+import com.android.systemui.volume.data.repository.audioRepository
+import com.android.systemui.volume.data.repository.audioSharingRepository
+import com.android.systemui.volume.domain.model.AudioOutputDevice
+import com.android.systemui.volume.localMediaController
+import com.android.systemui.volume.localMediaRepository
+import com.android.systemui.volume.mediaControllerRepository
+import com.android.systemui.volume.panel.component.mediaoutput.domain.model.MediaOutputComponentModel
+import com.android.systemui.volume.panel.shared.model.filterData
+import com.google.common.truth.Truth.assertThat
+import kotlinx.coroutines.ExperimentalCoroutinesApi
+import kotlinx.coroutines.test.runCurrent
+import kotlinx.coroutines.test.runTest
+import org.junit.Before
+import org.junit.Test
+import org.junit.runner.RunWith
+
+private const val builtInDeviceName = "This phone"
+
+@OptIn(ExperimentalCoroutinesApi::class)
+@SmallTest
+@RunWith(AndroidJUnit4::class)
+@TestableLooper.RunWithLooper(setAsMainLooper = true)
+class MediaOutputComponentInteractorTest : SysuiTestCase() {
+
+ private val kosmos = testKosmos()
+
+ private lateinit var underTest: MediaOutputComponentInteractor
+
+ @Before
+ fun setUp() =
+ with(kosmos) {
+ audioRepository.setMode(AudioManager.MODE_NORMAL)
+ localMediaRepository.updateCurrentConnectedDevice(
+ TestMediaDevicesFactory.builtInMediaDevice(deviceIcon = testIcon)
+ )
+
+ with(context.orCreateTestableResources) {
+ addOverride(R.drawable.ic_smartphone, testIcon)
+
+ addOverride(R.string.media_transfer_this_device_name_tv, builtInDeviceName)
+ addOverride(R.string.media_transfer_this_device_name_tablet, builtInDeviceName)
+ addOverride(R.string.media_transfer_this_device_name, builtInDeviceName)
+ }
+
+ underTest = mediaOutputComponentInteractor
+ }
+
+ @Test
+ fun inCall_stateIs_Calling() =
+ with(kosmos) {
+ testScope.runTest {
+ with(audioRepository) {
+ setMode(AudioManager.MODE_IN_CALL)
+ setCommunicationDevice(TestAudioDevicesFactory.builtInDevice())
+ }
+
+ val model by collectLastValue(underTest.mediaOutputModel.filterData())
+ runCurrent()
+
+ assertThat(model)
+ .isEqualTo(
+ MediaOutputComponentModel.Calling(
+ AudioOutputDevice.BuiltIn(builtInDeviceName, testIcon),
+ false,
+ )
+ )
+ }
+ }
+
+ @Test
+ fun hasSession_stateIs_MediaSession() =
+ with(kosmos) {
+ testScope.runTest {
+ mediaControllerRepository.setActiveSessions(listOf(localMediaController))
+
+ val model by collectLastValue(underTest.mediaOutputModel.filterData())
+ runCurrent()
+
+ with(model as MediaOutputComponentModel.MediaSession) {
+ assertThat(session.appLabel).isEqualTo("local_media_controller_label")
+ assertThat(session.packageName).isEqualTo("local.test.pkg")
+ assertThat(session.canAdjustVolume).isTrue()
+ assertThat(device)
+ .isEqualTo(AudioOutputDevice.BuiltIn("built_in_media", testIcon))
+ assertThat(isInAudioSharing).isFalse()
+ }
+ }
+ }
+
+ @Test
+ fun noMediaOrCall_stateIs_Idle() =
+ with(kosmos) {
+ testScope.runTest {
+ audioSharingRepository.setInAudioSharing(true)
+
+ val model by collectLastValue(underTest.mediaOutputModel.filterData())
+ runCurrent()
+
+ assertThat(model)
+ .isEqualTo(
+ MediaOutputComponentModel.Idle(
+ AudioOutputDevice.BuiltIn("built_in_media", testIcon),
+ true,
+ )
+ )
+ }
+ }
+
+ private companion object {
+ val testIcon = TestStubDrawable()
+ }
+}
diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/volume/panel/component/mediaoutput/ui/viewmodel/MediaOutputViewModelTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/volume/panel/component/mediaoutput/ui/viewmodel/MediaOutputViewModelTest.kt
index d497b4a..86a20dc 100644
--- a/packages/SystemUI/multivalentTests/src/com/android/systemui/volume/panel/component/mediaoutput/ui/viewmodel/MediaOutputViewModelTest.kt
+++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/volume/panel/component/mediaoutput/ui/viewmodel/MediaOutputViewModelTest.kt
@@ -31,14 +31,11 @@
import com.android.systemui.util.mockito.mock
import com.android.systemui.util.mockito.whenever
import com.android.systemui.volume.data.repository.audioSharingRepository
-import com.android.systemui.volume.domain.interactor.audioModeInteractor
-import com.android.systemui.volume.domain.interactor.audioOutputInteractor
import com.android.systemui.volume.localMediaController
import com.android.systemui.volume.localMediaRepository
import com.android.systemui.volume.mediaControllerRepository
-import com.android.systemui.volume.mediaDeviceSessionInteractor
import com.android.systemui.volume.mediaOutputActionsInteractor
-import com.android.systemui.volume.mediaOutputInteractor
+import com.android.systemui.volume.panel.component.mediaoutput.domain.interactor.mediaOutputComponentInteractor
import com.google.common.truth.Truth.assertThat
import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.test.runCurrent
@@ -66,10 +63,7 @@
applicationContext,
testScope.backgroundScope,
mediaOutputActionsInteractor,
- mediaDeviceSessionInteractor,
- audioOutputInteractor,
- audioModeInteractor,
- mediaOutputInteractor,
+ mediaOutputComponentInteractor,
uiEventLogger,
)
diff --git a/packages/SystemUI/plugin/src/com/android/systemui/plugins/clocks/ClockProviderPlugin.kt b/packages/SystemUI/plugin/src/com/android/systemui/plugins/clocks/ClockProviderPlugin.kt
index 629c96c..c7998f0 100644
--- a/packages/SystemUI/plugin/src/com/android/systemui/plugins/clocks/ClockProviderPlugin.kt
+++ b/packages/SystemUI/plugin/src/com/android/systemui/plugins/clocks/ClockProviderPlugin.kt
@@ -153,6 +153,9 @@
/** Events that should call when various rendering parameters change */
interface ClockEvents {
+ /** Set to enable or disable swipe interaction */
+ var isReactiveTouchInteractionEnabled: Boolean
+
/** Call whenever timezone changes */
fun onTimeZoneChanged(timeZone: TimeZone)
diff --git a/packages/SystemUI/res-keyguard/drawable/ic_spatial_speaker.xml b/packages/SystemUI/res-keyguard/drawable/ic_spatial_speaker.xml
new file mode 100644
index 0000000..82b222e7
--- /dev/null
+++ b/packages/SystemUI/res-keyguard/drawable/ic_spatial_speaker.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:viewportHeight="960"
+ android:viewportWidth="960">
+ <path
+ android:fillColor="@android:color/white"
+ android:pathData="M360,880q-134,0 -227,-93T40,560h80q0,100 70,170t170,70v80ZM360,740q-75,0 -127.5,-52.5T180,560h80q0,42 29,71t71,29v80ZM400,600q-33,0 -56.5,-23.5T320,520v-320q0,-33 23.5,-56.5T400,120h160q33,0 56.5,23.5T640,200v320q0,33 -23.5,56.5T560,600L400,600ZM400,520h160v-320L400,200v320ZM600,740v-80q42,0 71,-29t29,-71h80q0,75 -52.5,127.5T600,740ZM600,880v-80q100,0 170,-70t70,-170h80q0,134 -93,227T600,880ZM400,520h160,-160Z" />
+</vector>
diff --git a/packages/SystemUI/res/values/strings.xml b/packages/SystemUI/res/values/strings.xml
index 1226bbf..5fc9195 100644
--- a/packages/SystemUI/res/values/strings.xml
+++ b/packages/SystemUI/res/values/strings.xml
@@ -895,11 +895,9 @@
<string name="qs_record_issue_dropdown_screenrecord">Screen record</string>
<!-- QuickSettings: Issue Type Drop down choices list in Record Issue Start Dialog [CHAR LIMIT=30] -->
- <string-array name="qs_record_issue_types">
- <item>Performance</item>
- <item>User Interface</item>
- <item>Battery</item>
- </string-array>
+ <string name="performance">Performance</string>
+ <string name="user_interface">User Interface</string>
+ <string name="thermal">Thermal</string>
<!-- QuickSettings: Label for the toggle that controls whether One-handed mode is enabled. [CHAR LIMIT=NONE] -->
<string name="quick_settings_onehanded_label">One-handed mode</string>
@@ -1944,15 +1942,15 @@
<!-- Name used to refer to the "Back" key on the keyboard. -->
<string name="keyboard_key_back">Back</string>
<!-- Name used to refer to the "Up" arrow key on the keyboard. -->
- <string name="keyboard_key_dpad_up">Up arrow</string>
+ <string name="keyboard_key_dpad_up" translatable="false">Up arrow</string>
<!-- Name used to refer to the "Down" arrow key on the keyboard. -->
- <string name="keyboard_key_dpad_down">Down arrow</string>
+ <string name="keyboard_key_dpad_down" translatable="false">Down arrow</string>
<!-- Name used to refer to the "Left" arrow key on the keyboard. -->
- <string name="keyboard_key_dpad_left">Left arrow</string>
+ <string name="keyboard_key_dpad_left" translatable="false">Left arrow</string>
<!-- Name used to refer to the "Right" arrow key on the keyboard. -->
- <string name="keyboard_key_dpad_right">Right arrow</string>
+ <string name="keyboard_key_dpad_right" translatable="false">Right arrow</string>
<!-- Name used to refer to the "Center" arrow key on the keyboard. -->
- <string name="keyboard_key_dpad_center">Center</string>
+ <string name="keyboard_key_dpad_center" translatable="false">Center</string>
<!-- Name used to refer to the "Tab" key on the keyboard. -->
<string name="keyboard_key_tab">Tab</string>
<!-- Name used to refer to the "Space" key on the keyboard. -->
diff --git a/packages/SystemUI/res/xml/fileprovider.xml b/packages/SystemUI/res/xml/fileprovider.xml
index 71cc05d..78b7e95 100644
--- a/packages/SystemUI/res/xml/fileprovider.xml
+++ b/packages/SystemUI/res/xml/fileprovider.xml
@@ -19,5 +19,4 @@
<cache-path name="leak" path="leak/"/>
<external-path name="screenrecord" path="."/>
<cache-path name="multi_user" path="multi_user/" />
- <root-path name="traces" path="/data/local/traces"/>
</paths>
diff --git a/packages/SystemUI/src/com/android/keyguard/KeyguardClockSwitchController.java b/packages/SystemUI/src/com/android/keyguard/KeyguardClockSwitchController.java
index 47e4b49..f688d4f 100644
--- a/packages/SystemUI/src/com/android/keyguard/KeyguardClockSwitchController.java
+++ b/packages/SystemUI/src/com/android/keyguard/KeyguardClockSwitchController.java
@@ -308,14 +308,14 @@
mStatusArea = mView.findViewById(R.id.keyguard_status_area);
mBgExecutor.execute(() -> {
- mSecureSettings.registerContentObserverForUser(
+ mSecureSettings.registerContentObserverForUserSync(
Settings.Secure.LOCKSCREEN_USE_DOUBLE_LINE_CLOCK,
false, /* notifyForDescendants */
mDoubleLineClockObserver,
UserHandle.USER_ALL
);
- mSecureSettings.registerContentObserverForUser(
+ mSecureSettings.registerContentObserverForUserSync(
Settings.Secure.LOCK_SCREEN_WEATHER_ENABLED,
false, /* notifyForDescendants */
mShowWeatherObserver,
@@ -372,8 +372,8 @@
setClock(null);
mBgExecutor.execute(() -> {
- mSecureSettings.unregisterContentObserver(mDoubleLineClockObserver);
- mSecureSettings.unregisterContentObserver(mShowWeatherObserver);
+ mSecureSettings.unregisterContentObserverSync(mDoubleLineClockObserver);
+ mSecureSettings.unregisterContentObserverSync(mShowWeatherObserver);
});
mKeyguardUnlockAnimationController.removeKeyguardUnlockAnimationListener(
diff --git a/packages/SystemUI/src/com/android/systemui/accessibility/WindowMagnificationSettings.java b/packages/SystemUI/src/com/android/systemui/accessibility/WindowMagnificationSettings.java
index ca24ccb..f2a68a8 100644
--- a/packages/SystemUI/src/com/android/systemui/accessibility/WindowMagnificationSettings.java
+++ b/packages/SystemUI/src/com/android/systemui/accessibility/WindowMagnificationSettings.java
@@ -319,7 +319,7 @@
}
// Unregister observer before removing view
- mSecureSettings.unregisterContentObserver(mMagnificationCapabilityObserver);
+ mSecureSettings.unregisterContentObserverSync(mMagnificationCapabilityObserver);
mWindowManager.removeView(mSettingView);
mIsVisible = false;
if (resetPosition) {
@@ -380,7 +380,7 @@
mWindowManager.addView(mSettingView, mParams);
- mSecureSettings.registerContentObserverForUser(
+ mSecureSettings.registerContentObserverForUserSync(
Settings.Secure.ACCESSIBILITY_MAGNIFICATION_CAPABILITY,
mMagnificationCapabilityObserver,
UserHandle.USER_CURRENT);
diff --git a/packages/SystemUI/src/com/android/systemui/accessibility/floatingmenu/MenuInfoRepository.java b/packages/SystemUI/src/com/android/systemui/accessibility/floatingmenu/MenuInfoRepository.java
index eb840f1..ffb5f3d 100644
--- a/packages/SystemUI/src/com/android/systemui/accessibility/floatingmenu/MenuInfoRepository.java
+++ b/packages/SystemUI/src/com/android/systemui/accessibility/floatingmenu/MenuInfoRepository.java
@@ -240,26 +240,26 @@
}
void registerObserversAndCallbacks() {
- mSecureSettings.registerContentObserverForUser(
+ mSecureSettings.registerContentObserverForUserSync(
mSecureSettings.getUriFor(Settings.Secure.ACCESSIBILITY_BUTTON_TARGETS),
/* notifyForDescendants */ false, mMenuTargetFeaturesContentObserver,
UserHandle.USER_CURRENT);
if (!com.android.systemui.Flags.floatingMenuNarrowTargetContentObserver()) {
- mSecureSettings.registerContentObserverForUser(
+ mSecureSettings.registerContentObserverForUserSync(
mSecureSettings.getUriFor(ENABLED_ACCESSIBILITY_SERVICES),
/* notifyForDescendants */ false,
mMenuTargetFeaturesContentObserver,
UserHandle.USER_CURRENT);
}
- mSecureSettings.registerContentObserverForUser(
+ mSecureSettings.registerContentObserverForUserSync(
mSecureSettings.getUriFor(Settings.Secure.ACCESSIBILITY_FLOATING_MENU_SIZE),
/* notifyForDescendants */ false, mMenuSizeContentObserver,
UserHandle.USER_CURRENT);
- mSecureSettings.registerContentObserverForUser(
+ mSecureSettings.registerContentObserverForUserSync(
mSecureSettings.getUriFor(ACCESSIBILITY_FLOATING_MENU_FADE_ENABLED),
/* notifyForDescendants */ false, mMenuFadeOutContentObserver,
UserHandle.USER_CURRENT);
- mSecureSettings.registerContentObserverForUser(
+ mSecureSettings.registerContentObserverForUserSync(
mSecureSettings.getUriFor(ACCESSIBILITY_FLOATING_MENU_OPACITY),
/* notifyForDescendants */ false, mMenuFadeOutContentObserver,
UserHandle.USER_CURRENT);
diff --git a/packages/SystemUI/src/com/android/systemui/accessibility/fontscaling/FontScalingDialogDelegate.kt b/packages/SystemUI/src/com/android/systemui/accessibility/fontscaling/FontScalingDialogDelegate.kt
index 91bc0c1..eaf541d 100644
--- a/packages/SystemUI/src/com/android/systemui/accessibility/fontscaling/FontScalingDialogDelegate.kt
+++ b/packages/SystemUI/src/com/android/systemui/accessibility/fontscaling/FontScalingDialogDelegate.kt
@@ -29,12 +29,12 @@
import android.widget.TextView
import androidx.annotation.MainThread
import androidx.annotation.WorkerThread
-import com.android.systemui.res.R
import com.android.systemui.common.ui.view.SeekBarWithIconButtonsView
import com.android.systemui.common.ui.view.SeekBarWithIconButtonsView.OnSeekBarWithIconButtonsChangeListener
import com.android.systemui.common.ui.view.SeekBarWithIconButtonsView.OnSeekBarWithIconButtonsChangeListener.ControlUnitType
import com.android.systemui.dagger.qualifiers.Background
import com.android.systemui.dagger.qualifiers.Main
+import com.android.systemui.res.R
import com.android.systemui.settings.UserTracker
import com.android.systemui.statusbar.phone.SystemUIDialog
import com.android.systemui.util.concurrency.DelayableExecutor
@@ -46,7 +46,9 @@
import kotlin.math.roundToInt
/** The Dialog that contains a seekbar for changing the font size. */
-class FontScalingDialogDelegate @Inject constructor(
+class FontScalingDialogDelegate
+@Inject
+constructor(
private val context: Context,
private val systemUIDialogFactory: SystemUIDialog.Factory,
private val layoutInflater: LayoutInflater,
@@ -84,9 +86,9 @@
dialog.setTitle(R.string.font_scaling_dialog_title)
dialog.setView(layoutInflater.inflate(R.layout.font_scaling_dialog, null))
dialog.setPositiveButton(
- R.string.quick_settings_done,
- /* onClick = */ null,
- /* dismissOnClick = */ true
+ R.string.quick_settings_done,
+ /* onClick = */ null,
+ /* dismissOnClick = */ true
)
}
@@ -142,7 +144,7 @@
}
)
doneButton.setOnClickListener { dialog.dismiss() }
- systemSettings.registerContentObserver(Settings.System.FONT_SCALE, fontSizeObserver)
+ systemSettings.registerContentObserverSync(Settings.System.FONT_SCALE, fontSizeObserver)
}
/**
@@ -165,7 +167,7 @@
override fun onStop(dialog: SystemUIDialog) {
cancelUpdateFontScaleRunnable?.run()
cancelUpdateFontScaleRunnable = null
- systemSettings.unregisterContentObserver(fontSizeObserver)
+ systemSettings.unregisterContentObserverSync(fontSizeObserver)
}
@MainThread
diff --git a/packages/SystemUI/src/com/android/systemui/biometrics/data/repository/FaceUserSettingsRepository.kt b/packages/SystemUI/src/com/android/systemui/biometrics/data/repository/FaceUserSettingsRepository.kt
index 68c4a10..2970890 100644
--- a/packages/SystemUI/src/com/android/systemui/biometrics/data/repository/FaceUserSettingsRepository.kt
+++ b/packages/SystemUI/src/com/android/systemui/biometrics/data/repository/FaceUserSettingsRepository.kt
@@ -75,7 +75,7 @@
) {
fun fetch(): Boolean = getIntForUser(key, if (defaultValue) 1 else 0, userId) > 0
- registerContentObserverForUser(
+ registerContentObserverForUserSync(
key,
false /* notifyForDescendants */,
object : ContentObserver(handler) {
diff --git a/packages/SystemUI/src/com/android/systemui/biometrics/ui/binder/PromptIconViewBinder.kt b/packages/SystemUI/src/com/android/systemui/biometrics/ui/binder/PromptIconViewBinder.kt
index 9e836c3..adf5b74 100644
--- a/packages/SystemUI/src/com/android/systemui/biometrics/ui/binder/PromptIconViewBinder.kt
+++ b/packages/SystemUI/src/com/android/systemui/biometrics/ui/binder/PromptIconViewBinder.kt
@@ -20,16 +20,21 @@
import android.graphics.drawable.Animatable2
import android.graphics.drawable.AnimatedVectorDrawable
import android.graphics.drawable.Drawable
+import android.util.Log
+import androidx.constraintlayout.widget.ConstraintLayout
+import androidx.constraintlayout.widget.ConstraintSet
import androidx.lifecycle.Lifecycle
import androidx.lifecycle.repeatOnLifecycle
import com.airbnb.lottie.LottieAnimationView
import com.airbnb.lottie.LottieOnCompositionLoadedListener
+import com.airbnb.lottie.LottieListener
import com.android.settingslib.widget.LottieColorUtils
import com.android.systemui.Flags.constraintBp
import com.android.systemui.biometrics.ui.viewmodel.PromptIconViewModel
import com.android.systemui.biometrics.ui.viewmodel.PromptIconViewModel.AuthType
import com.android.systemui.biometrics.ui.viewmodel.PromptViewModel
import com.android.systemui.lifecycle.repeatWhenAttached
+import com.android.systemui.res.R
import com.android.systemui.util.kotlin.Utils.Companion.toQuad
import com.android.systemui.util.kotlin.Utils.Companion.toQuint
import com.android.systemui.util.kotlin.Utils.Companion.toTriple
@@ -37,6 +42,8 @@
import kotlinx.coroutines.flow.combine
import kotlinx.coroutines.launch
+private const val TAG = "PromptIconViewBinder"
+
/** Sub-binder for [BiometricPromptLayout.iconView]. */
object PromptIconViewBinder {
/**
@@ -155,6 +162,7 @@
when (activeAuthType) {
AuthType.Fingerprint,
AuthType.Coex -> {
+ iconView.setIconFailureListener(iconAsset, activeAuthType)
iconView.setAnimation(iconAsset)
iconView.frame = 0
@@ -171,6 +179,10 @@
iconView.context.getDrawable(iconAsset)
as AnimatedVectorDrawable
faceIcon?.apply {
+ iconView.setIconFailureListener(
+ iconAsset,
+ activeAuthType
+ )
iconView.setImageDrawable(this)
if (shouldAnimateIconView) {
forceAnimationOnUI()
@@ -200,6 +212,7 @@
)
.collect { (iconOverlayAsset, shouldAnimateIconOverlay, showingError) ->
if (iconOverlayAsset != -1) {
+ iconOverlayView.setIconOverlayFailureListener(iconOverlayAsset)
iconOverlayView.setAnimation(iconOverlayAsset)
iconOverlayView.frame = 0
LottieColorUtils.applyDynamicColors(
@@ -234,3 +247,96 @@
}
}
}
+
+private val assetIdToString: Map<Int, String> =
+ mapOf(
+ // UDFPS assets
+ R.raw.fingerprint_dialogue_error_to_fingerprint_lottie to
+ "fingerprint_dialogue_error_to_fingerprint_lottie",
+ R.raw.fingerprint_dialogue_error_to_success_lottie to
+ "fingerprint_dialogue_error_to_success_lottie",
+ R.raw.fingerprint_dialogue_fingerprint_to_error_lottie to
+ "fingerprint_dialogue_fingerprint_to_error_lottie",
+ R.raw.fingerprint_dialogue_fingerprint_to_success_lottie to
+ "fingerprint_dialogue_fingerprint_to_success_lottie",
+ // SFPS assets
+ R.raw.biometricprompt_fingerprint_to_error_landscape to
+ "biometricprompt_fingerprint_to_error_landscape",
+ R.raw.biometricprompt_folded_base_bottomright to "biometricprompt_folded_base_bottomright",
+ R.raw.biometricprompt_folded_base_default to "biometricprompt_folded_base_default",
+ R.raw.biometricprompt_folded_base_topleft to "biometricprompt_folded_base_topleft",
+ R.raw.biometricprompt_landscape_base to "biometricprompt_landscape_base",
+ R.raw.biometricprompt_portrait_base_bottomright to
+ "biometricprompt_portrait_base_bottomright",
+ R.raw.biometricprompt_portrait_base_topleft to "biometricprompt_portrait_base_topleft",
+ R.raw.biometricprompt_symbol_error_to_fingerprint_landscape to
+ "biometricprompt_symbol_error_to_fingerprint_landscape",
+ R.raw.biometricprompt_symbol_error_to_fingerprint_portrait_bottomright to
+ "biometricprompt_symbol_error_to_fingerprint_portrait_bottomright",
+ R.raw.biometricprompt_symbol_error_to_fingerprint_portrait_topleft to
+ "biometricprompt_symbol_error_to_fingerprint_portrait_topleft",
+ R.raw.biometricprompt_symbol_error_to_success_landscape to
+ "biometricprompt_symbol_error_to_success_landscape",
+ R.raw.biometricprompt_symbol_error_to_success_portrait_bottomright to
+ "biometricprompt_symbol_error_to_success_portrait_bottomright",
+ R.raw.biometricprompt_symbol_error_to_success_portrait_topleft to
+ "biometricprompt_symbol_error_to_success_portrait_topleft",
+ R.raw.biometricprompt_symbol_fingerprint_to_error_portrait_bottomright to
+ "biometricprompt_symbol_fingerprint_to_error_portrait_bottomright",
+ R.raw.biometricprompt_symbol_fingerprint_to_error_portrait_topleft to
+ "biometricprompt_symbol_fingerprint_to_error_portrait_topleft",
+ R.raw.biometricprompt_symbol_fingerprint_to_success_landscape to
+ "biometricprompt_symbol_fingerprint_to_success_landscape",
+ R.raw.biometricprompt_symbol_fingerprint_to_success_portrait_bottomright to
+ "biometricprompt_symbol_fingerprint_to_success_portrait_bottomright",
+ R.raw.biometricprompt_symbol_fingerprint_to_success_portrait_topleft to
+ "biometricprompt_symbol_fingerprint_to_success_portrait_topleft",
+ // Face assets
+ R.drawable.face_dialog_wink_from_dark to "face_dialog_wink_from_dark",
+ R.drawable.face_dialog_dark_to_checkmark to "face_dialog_dark_to_checkmark",
+ R.drawable.face_dialog_pulse_light_to_dark to "face_dialog_pulse_light_to_dark",
+ R.drawable.face_dialog_pulse_dark_to_light to "face_dialog_pulse_dark_to_light",
+ R.drawable.face_dialog_dark_to_error to "face_dialog_dark_to_error",
+ R.drawable.face_dialog_error_to_idle to "face_dialog_error_to_idle",
+ R.drawable.face_dialog_idle_static to "face_dialog_idle_static",
+ // Co-ex assets
+ R.raw.fingerprint_dialogue_unlocked_to_checkmark_success_lottie to
+ "fingerprint_dialogue_unlocked_to_checkmark_success_lottie",
+ R.raw.fingerprint_dialogue_error_to_unlock_lottie to
+ "fingerprint_dialogue_error_to_unlock_lottie",
+ R.raw.fingerprint_dialogue_fingerprint_to_unlock_lottie to
+ "fingerprint_dialogue_fingerprint_to_unlock_lottie",
+ )
+
+private fun getAssetNameFromId(id: Int): String {
+ return assetIdToString.getOrDefault(id, "Asset $id not found")
+}
+
+private fun LottieAnimationView.setIconFailureListener(iconAsset: Int, activeAuthType: AuthType) {
+ setFailureListener(
+ LottieListener<Throwable> { result: Throwable? ->
+ Log.d(
+ TAG,
+ "Collecting iconAsset | " +
+ "activeAuthType = $activeAuthType | " +
+ "Invalid resource id: $iconAsset, " +
+ "name ${getAssetNameFromId(iconAsset)}",
+ result
+ )
+ }
+ )
+}
+
+private fun LottieAnimationView.setIconOverlayFailureListener(iconOverlayAsset: Int) {
+ setFailureListener(
+ LottieListener<Throwable> { result: Throwable? ->
+ Log.d(
+ TAG,
+ "Collecting iconOverlayAsset | " +
+ "Invalid resource id: $iconOverlayAsset, " +
+ "name ${getAssetNameFromId(iconOverlayAsset)}",
+ result
+ )
+ }
+ )
+}
diff --git a/packages/SystemUI/src/com/android/systemui/communal/data/repository/CommunalSettingsRepository.kt b/packages/SystemUI/src/com/android/systemui/communal/data/repository/CommunalSettingsRepository.kt
index 88cb64c..1c47e50 100644
--- a/packages/SystemUI/src/com/android/systemui/communal/data/repository/CommunalSettingsRepository.kt
+++ b/packages/SystemUI/src/com/android/systemui/communal/data/repository/CommunalSettingsRepository.kt
@@ -30,6 +30,7 @@
import com.android.systemui.communal.data.model.DisabledReason.DISABLED_REASON_FLAG
import com.android.systemui.communal.data.model.DisabledReason.DISABLED_REASON_INVALID_USER
import com.android.systemui.communal.data.model.DisabledReason.DISABLED_REASON_USER_SETTING
+import com.android.systemui.communal.shared.model.CommunalBackgroundType
import com.android.systemui.dagger.SysUISingleton
import com.android.systemui.dagger.qualifiers.Background
import com.android.systemui.flags.FeatureFlagsClassic
@@ -59,6 +60,9 @@
/** Keyguard widgets enabled state by Device Policy Manager for the specified user. */
fun getAllowedByDevicePolicy(user: UserInfo): Flow<Boolean>
+
+ /** The type of background to use for the hub. Used to experiment with different backgrounds. */
+ fun getBackground(user: UserInfo): Flow<CommunalBackgroundType>
}
@SysUISingleton
@@ -126,6 +130,21 @@
.emitOnStart()
.map { devicePolicyManager.areKeyguardWidgetsAllowed(user.id) }
+ override fun getBackground(user: UserInfo): Flow<CommunalBackgroundType> =
+ secureSettings
+ .observerFlow(userId = user.id, names = arrayOf(GLANCEABLE_HUB_BACKGROUND_SETTING))
+ .emitOnStart()
+ .map {
+ val intType =
+ secureSettings.getIntForUser(
+ GLANCEABLE_HUB_BACKGROUND_SETTING,
+ CommunalBackgroundType.DEFAULT.value,
+ user.id
+ )
+ CommunalBackgroundType.entries.find { type -> type.value == intType }
+ ?: CommunalBackgroundType.DEFAULT
+ }
+
private fun getEnabledByUser(user: UserInfo): Flow<Boolean> =
secureSettings
.observerFlow(userId = user.id, names = arrayOf(Settings.Secure.GLANCEABLE_HUB_ENABLED))
@@ -141,6 +160,7 @@
companion object {
const val GLANCEABLE_HUB_CONTENT_SETTING = "glanceable_hub_content_setting"
+ const val GLANCEABLE_HUB_BACKGROUND_SETTING = "glanceable_hub_background"
private const val ENABLED_SETTING_DEFAULT = 1
}
}
diff --git a/packages/SystemUI/src/com/android/systemui/communal/domain/interactor/CommunalSettingsInteractor.kt b/packages/SystemUI/src/com/android/systemui/communal/domain/interactor/CommunalSettingsInteractor.kt
index 3e5126a..f043d58 100644
--- a/packages/SystemUI/src/com/android/systemui/communal/domain/interactor/CommunalSettingsInteractor.kt
+++ b/packages/SystemUI/src/com/android/systemui/communal/domain/interactor/CommunalSettingsInteractor.kt
@@ -21,6 +21,7 @@
import com.android.systemui.communal.data.model.CommunalEnabledState
import com.android.systemui.communal.data.model.CommunalWidgetCategories
import com.android.systemui.communal.data.repository.CommunalSettingsRepository
+import com.android.systemui.communal.shared.model.CommunalBackgroundType
import com.android.systemui.dagger.SysUISingleton
import com.android.systemui.dagger.qualifiers.Background
import com.android.systemui.log.dagger.CommunalTableLog
@@ -30,6 +31,7 @@
import com.android.systemui.user.domain.interactor.SelectedUserInteractor
import java.util.concurrent.Executor
import javax.inject.Inject
+import kotlinx.coroutines.CoroutineDispatcher
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.channels.awaitClose
@@ -38,6 +40,7 @@
import kotlinx.coroutines.flow.StateFlow
import kotlinx.coroutines.flow.flatMapLatest
import kotlinx.coroutines.flow.flowOf
+import kotlinx.coroutines.flow.flowOn
import kotlinx.coroutines.flow.map
import kotlinx.coroutines.flow.stateIn
@@ -47,6 +50,7 @@
@Inject
constructor(
@Background private val bgScope: CoroutineScope,
+ @Background private val bgDispatcher: CoroutineDispatcher,
@Background private val bgExecutor: Executor,
private val repository: CommunalSettingsRepository,
userInteractor: SelectedUserInteractor,
@@ -78,6 +82,12 @@
initialValue = CommunalWidgetCategories.defaultCategories
)
+ /** The type of background to use for the hub. Used to experiment with different backgrounds */
+ val communalBackground: Flow<CommunalBackgroundType> =
+ userInteractor.selectedUserInfo
+ .flatMapLatest { user -> repository.getBackground(user) }
+ .flowOn(bgDispatcher)
+
private val workProfileUserInfoCallbackFlow: Flow<UserInfo?> = conflatedCallbackFlow {
fun send(profiles: List<UserInfo>) {
trySend(profiles.find { it.isManagedProfile })
diff --git a/packages/SystemUI/src/com/android/systemui/communal/shared/model/CommunalBackgroundType.kt b/packages/SystemUI/src/com/android/systemui/communal/shared/model/CommunalBackgroundType.kt
new file mode 100644
index 0000000..8b816db
--- /dev/null
+++ b/packages/SystemUI/src/com/android/systemui/communal/shared/model/CommunalBackgroundType.kt
@@ -0,0 +1,24 @@
+/*
+ * 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.systemui.communal.shared.model
+
+/** Models the types of background that can be shown on the hub. */
+enum class CommunalBackgroundType(val value: Int) {
+ DEFAULT(0),
+ STATIC_GRADIENT(1),
+ ANIMATED(2),
+}
diff --git a/packages/SystemUI/src/com/android/systemui/communal/ui/viewmodel/CommunalViewModel.kt b/packages/SystemUI/src/com/android/systemui/communal/ui/viewmodel/CommunalViewModel.kt
index ce69ee8..3e00b04 100644
--- a/packages/SystemUI/src/com/android/systemui/communal/ui/viewmodel/CommunalViewModel.kt
+++ b/packages/SystemUI/src/com/android/systemui/communal/ui/viewmodel/CommunalViewModel.kt
@@ -21,8 +21,10 @@
import android.view.accessibility.AccessibilityNodeInfo
import com.android.systemui.communal.domain.interactor.CommunalInteractor
import com.android.systemui.communal.domain.interactor.CommunalSceneInteractor
+import com.android.systemui.communal.domain.interactor.CommunalSettingsInteractor
import com.android.systemui.communal.domain.interactor.CommunalTutorialInteractor
import com.android.systemui.communal.domain.model.CommunalContentModel
+import com.android.systemui.communal.shared.model.CommunalBackgroundType
import com.android.systemui.dagger.SysUISingleton
import com.android.systemui.dagger.qualifiers.Application
import com.android.systemui.dagger.qualifiers.Main
@@ -70,6 +72,7 @@
keyguardInteractor: KeyguardInteractor,
communalSceneInteractor: CommunalSceneInteractor,
private val communalInteractor: CommunalInteractor,
+ private val communalSettingsInteractor: CommunalSettingsInteractor,
tutorialInteractor: CommunalTutorialInteractor,
private val shadeInteractor: ShadeInteractor,
@Named(MediaModule.COMMUNAL_HUB) mediaHost: MediaHost,
@@ -284,6 +287,10 @@
*/
val showGestureIndicator: Flow<Boolean> = not(keyguardInteractor.isDreaming)
+ /** The type of background to use for the hub. */
+ val communalBackground: Flow<CommunalBackgroundType> =
+ communalSettingsInteractor.communalBackground
+
companion object {
const val POPUP_AUTO_HIDE_TIMEOUT_MS = 12000L
}
@@ -291,5 +298,6 @@
sealed class PopupType {
object CtaTile : PopupType()
+
object CustomizeWidgetButton : PopupType()
}
diff --git a/packages/SystemUI/src/com/android/systemui/complication/ComplicationTypesUpdater.java b/packages/SystemUI/src/com/android/systemui/complication/ComplicationTypesUpdater.java
index 0bdc7f1..84807fb 100644
--- a/packages/SystemUI/src/com/android/systemui/complication/ComplicationTypesUpdater.java
+++ b/packages/SystemUI/src/com/android/systemui/complication/ComplicationTypesUpdater.java
@@ -69,15 +69,15 @@
}
};
- mSecureSettings.registerContentObserverForUser(
+ mSecureSettings.registerContentObserverForUserSync(
Settings.Secure.SCREENSAVER_COMPLICATIONS_ENABLED,
settingsObserver,
UserHandle.myUserId());
- mSecureSettings.registerContentObserverForUser(
+ mSecureSettings.registerContentObserverForUserSync(
Settings.Secure.SCREENSAVER_HOME_CONTROLS_ENABLED,
settingsObserver,
UserHandle.myUserId());
- mSecureSettings.registerContentObserverForUser(
+ mSecureSettings.registerContentObserverForUserSync(
Settings.Secure.LOCKSCREEN_SHOW_CONTROLS,
settingsObserver,
UserHandle.myUserId());
diff --git a/packages/SystemUI/src/com/android/systemui/dock/DockManagerExtensions.kt b/packages/SystemUI/src/com/android/systemui/dock/DockManagerExtensions.kt
index 1bbdfcd..4dbb32d 100644
--- a/packages/SystemUI/src/com/android/systemui/dock/DockManagerExtensions.kt
+++ b/packages/SystemUI/src/com/android/systemui/dock/DockManagerExtensions.kt
@@ -19,18 +19,16 @@
import com.android.systemui.common.coroutine.ConflatedCallbackFlow
import kotlinx.coroutines.channels.awaitClose
import kotlinx.coroutines.flow.Flow
-import kotlinx.coroutines.flow.distinctUntilChanged
/**
- * Retrieves whether or not the device is docked according to DockManager. Emits a starting value of
- * isDocked.
+ * Retrieves whether or not the device is docked according to DockManager. Emits a starting value
+ * of isDocked.
*/
fun DockManager.retrieveIsDocked(): Flow<Boolean> =
ConflatedCallbackFlow.conflatedCallbackFlow {
- val callback = DockManager.DockEventListener { trySend(isDocked) }
- addListener(callback)
- trySend(isDocked)
+ val callback = DockManager.DockEventListener { trySend(isDocked) }
+ addListener(callback)
+ trySend(isDocked)
- awaitClose { removeListener(callback) }
- }
- .distinctUntilChanged()
+ awaitClose { removeListener(callback) }
+ }
\ No newline at end of file
diff --git a/packages/SystemUI/src/com/android/systemui/doze/DozeSensors.java b/packages/SystemUI/src/com/android/systemui/doze/DozeSensors.java
index 3194942..7ae8409 100644
--- a/packages/SystemUI/src/com/android/systemui/doze/DozeSensors.java
+++ b/packages/SystemUI/src/com/android/systemui/doze/DozeSensors.java
@@ -426,7 +426,7 @@
}
if (!anyListening) {
- mSecureSettings.unregisterContentObserver(mSettingsObserver);
+ mSecureSettings.unregisterContentObserverSync(mSettingsObserver);
} else if (!mSettingRegistered) {
for (TriggerSensor s : mTriggerSensors) {
s.registerSettingsObserver(mSettingsObserver);
@@ -750,7 +750,7 @@
public void registerSettingsObserver(ContentObserver settingsObserver) {
if (mConfigured && !TextUtils.isEmpty(mSetting)) {
- mSecureSettings.registerContentObserverForUser(
+ mSecureSettings.registerContentObserverForUserSync(
mSetting, mSettingsObserver, UserHandle.USER_ALL);
}
}
diff --git a/packages/SystemUI/src/com/android/systemui/globalactions/GlobalActionsDialogLite.java b/packages/SystemUI/src/com/android/systemui/globalactions/GlobalActionsDialogLite.java
index 49be03c..1e4fb4f 100644
--- a/packages/SystemUI/src/com/android/systemui/globalactions/GlobalActionsDialogLite.java
+++ b/packages/SystemUI/src/com/android/systemui/globalactions/GlobalActionsDialogLite.java
@@ -428,7 +428,7 @@
// get notified of phone state changes
mTelephonyListenerManager.addServiceStateListener(mPhoneStateListener);
- mGlobalSettings.registerContentObserver(
+ mGlobalSettings.registerContentObserverSync(
Settings.Global.getUriFor(Settings.Global.AIRPLANE_MODE_ON), true,
mAirplaneModeObserver);
mHasVibrator = vibrator.hasVibrator();
@@ -453,7 +453,7 @@
public void destroy() {
mBroadcastDispatcher.unregisterReceiver(mBroadcastReceiver);
mTelephonyListenerManager.removeServiceStateListener(mPhoneStateListener);
- mGlobalSettings.unregisterContentObserver(mAirplaneModeObserver);
+ mGlobalSettings.unregisterContentObserverSync(mAirplaneModeObserver);
mConfigurationController.removeCallback(this);
}
diff --git a/packages/SystemUI/src/com/android/systemui/keyboard/PhysicalKeyboardCoreStartable.kt b/packages/SystemUI/src/com/android/systemui/keyboard/PhysicalKeyboardCoreStartable.kt
index f16a3bd..90867edd 100644
--- a/packages/SystemUI/src/com/android/systemui/keyboard/PhysicalKeyboardCoreStartable.kt
+++ b/packages/SystemUI/src/com/android/systemui/keyboard/PhysicalKeyboardCoreStartable.kt
@@ -19,10 +19,12 @@
import android.hardware.input.InputSettings
import com.android.systemui.CoreStartable
+import com.android.systemui.Flags
import com.android.systemui.dagger.SysUISingleton
import com.android.systemui.flags.FeatureFlags
-import com.android.systemui.flags.Flags
+import com.android.systemui.flags.Flags as LegacyFlag
import com.android.systemui.keyboard.backlight.ui.KeyboardBacklightDialogCoordinator
+import com.android.systemui.keyboard.docking.binder.KeyboardDockingIndicationViewBinder
import com.android.systemui.keyboard.stickykeys.ui.StickyKeysIndicatorCoordinator
import dagger.Lazy
import javax.inject.Inject
@@ -34,14 +36,18 @@
constructor(
private val keyboardBacklightDialogCoordinator: Lazy<KeyboardBacklightDialogCoordinator>,
private val stickyKeysIndicatorCoordinator: Lazy<StickyKeysIndicatorCoordinator>,
+ private val keyboardDockingIndicationViewBinder: Lazy<KeyboardDockingIndicationViewBinder>,
private val featureFlags: FeatureFlags,
) : CoreStartable {
override fun start() {
- if (featureFlags.isEnabled(Flags.KEYBOARD_BACKLIGHT_INDICATOR)) {
+ if (featureFlags.isEnabled(LegacyFlag.KEYBOARD_BACKLIGHT_INDICATOR)) {
keyboardBacklightDialogCoordinator.get().startListening()
}
if (InputSettings.isAccessibilityStickyKeysFeatureEnabled()) {
stickyKeysIndicatorCoordinator.get().startListening()
}
+ if (Flags.keyboardDockingIndicator()) {
+ keyboardDockingIndicationViewBinder.get().startListening()
+ }
}
}
diff --git a/packages/SystemUI/src/com/android/systemui/keyboard/docking/binder/KeyboardDockingIndicationViewBinder.kt b/packages/SystemUI/src/com/android/systemui/keyboard/docking/binder/KeyboardDockingIndicationViewBinder.kt
new file mode 100644
index 0000000..f649be2
--- /dev/null
+++ b/packages/SystemUI/src/com/android/systemui/keyboard/docking/binder/KeyboardDockingIndicationViewBinder.kt
@@ -0,0 +1,100 @@
+/*
+ * 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.systemui.keyboard.docking.binder
+
+import android.content.Context
+import android.graphics.Paint
+import android.graphics.PixelFormat
+import android.view.WindowManager
+import com.android.systemui.dagger.SysUISingleton
+import com.android.systemui.dagger.qualifiers.Application
+import com.android.systemui.keyboard.docking.ui.KeyboardDockingIndicationView
+import com.android.systemui.keyboard.docking.ui.viewmodel.KeyboardDockingIndicationViewModel
+import com.android.systemui.surfaceeffects.PaintDrawCallback
+import com.android.systemui.surfaceeffects.glowboxeffect.GlowBoxEffect
+import javax.inject.Inject
+import kotlinx.coroutines.CoroutineScope
+import kotlinx.coroutines.launch
+
+@SysUISingleton
+class KeyboardDockingIndicationViewBinder
+@Inject
+constructor(
+ context: Context,
+ @Application private val applicationScope: CoroutineScope,
+ private val viewModel: KeyboardDockingIndicationViewModel,
+ private val windowManager: WindowManager
+) {
+
+ private val windowLayoutParams =
+ WindowManager.LayoutParams().apply {
+ width = WindowManager.LayoutParams.MATCH_PARENT
+ height = WindowManager.LayoutParams.MATCH_PARENT
+ format = PixelFormat.TRANSLUCENT
+ type = WindowManager.LayoutParams.TYPE_KEYGUARD_DIALOG
+ fitInsetsTypes = 0 // Ignore insets from all system bars
+ title = "Edge glow effect"
+ flags =
+ (WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE or
+ WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE)
+ setTrustedOverlay()
+ }
+
+ private var glowEffect: GlowBoxEffect? = null
+ private val glowEffectView = KeyboardDockingIndicationView(context, null)
+
+ private val drawCallback =
+ object : PaintDrawCallback {
+ override fun onDraw(paint: Paint) {
+ glowEffectView.draw(paint)
+ }
+ }
+
+ private val stateChangedCallback =
+ object : GlowBoxEffect.AnimationStateChangedCallback {
+ override fun onStart() {
+ windowManager.addView(glowEffectView, windowLayoutParams)
+ }
+
+ override fun onEnd() {
+ windowManager.removeView(glowEffectView)
+ }
+ }
+
+ fun startListening() {
+ applicationScope.launch {
+ viewModel.edgeGlow.collect { config ->
+ if (glowEffect == null) {
+ glowEffect = GlowBoxEffect(config, drawCallback, stateChangedCallback)
+ } else {
+ glowEffect?.finish(force = true)
+ glowEffect!!.updateConfig(config)
+ }
+ }
+ }
+
+ applicationScope.launch {
+ viewModel.keyboardConnected.collect { connected ->
+ if (connected) {
+ glowEffect?.play()
+ } else {
+ glowEffect?.finish()
+ }
+ }
+ }
+ }
+}
diff --git a/packages/SystemUI/src/com/android/systemui/keyboard/docking/domain/interactor/KeyboardDockingIndicationInteractor.kt b/packages/SystemUI/src/com/android/systemui/keyboard/docking/domain/interactor/KeyboardDockingIndicationInteractor.kt
new file mode 100644
index 0000000..c670b5e
--- /dev/null
+++ b/packages/SystemUI/src/com/android/systemui/keyboard/docking/domain/interactor/KeyboardDockingIndicationInteractor.kt
@@ -0,0 +1,29 @@
+/*
+ * 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.systemui.keyboard.docking.domain.interactor
+
+import com.android.systemui.dagger.SysUISingleton
+import com.android.systemui.keyboard.data.repository.KeyboardRepository
+import javax.inject.Inject
+
+/** Listens for keyboard docking event. */
+@SysUISingleton
+class KeyboardDockingIndicationInteractor
+@Inject
+constructor(keyboardRepository: KeyboardRepository) {
+ val onKeyboardConnected = keyboardRepository.isAnyKeyboardConnected
+}
diff --git a/packages/SystemUI/src/com/android/systemui/keyboard/docking/ui/KeyboardDockingIndicationView.kt b/packages/SystemUI/src/com/android/systemui/keyboard/docking/ui/KeyboardDockingIndicationView.kt
new file mode 100644
index 0000000..de8b2cf
--- /dev/null
+++ b/packages/SystemUI/src/com/android/systemui/keyboard/docking/ui/KeyboardDockingIndicationView.kt
@@ -0,0 +1,42 @@
+/*
+ * 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.systemui.keyboard.docking.ui
+
+import android.content.Context
+import android.graphics.Canvas
+import android.graphics.Paint
+import android.util.AttributeSet
+import android.view.View
+
+/** View that's used for rendering keyboard docking indicator. */
+class KeyboardDockingIndicationView(context: Context?, attrs: AttributeSet?) :
+ View(context, attrs) {
+
+ private var paint: Paint? = null
+
+ override fun onDraw(canvas: Canvas) {
+ if (!canvas.isHardwareAccelerated) {
+ return
+ }
+ paint?.let { canvas.drawPaint(it) }
+ }
+
+ fun draw(paint: Paint) {
+ this.paint = paint
+ invalidate()
+ }
+}
diff --git a/packages/SystemUI/src/com/android/systemui/keyboard/docking/ui/viewmodel/KeyboardDockingIndicationViewModel.kt b/packages/SystemUI/src/com/android/systemui/keyboard/docking/ui/viewmodel/KeyboardDockingIndicationViewModel.kt
new file mode 100644
index 0000000..2578b78
--- /dev/null
+++ b/packages/SystemUI/src/com/android/systemui/keyboard/docking/ui/viewmodel/KeyboardDockingIndicationViewModel.kt
@@ -0,0 +1,142 @@
+/*
+ * 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.systemui.keyboard.docking.ui.viewmodel
+
+import android.content.Context
+import android.view.Surface
+import android.view.WindowManager
+import com.android.settingslib.Utils
+import com.android.systemui.common.ui.domain.interactor.ConfigurationInteractor
+import com.android.systemui.dagger.SysUISingleton
+import com.android.systemui.dagger.qualifiers.Background
+import com.android.systemui.keyboard.docking.domain.interactor.KeyboardDockingIndicationInteractor
+import com.android.systemui.surfaceeffects.glowboxeffect.GlowBoxConfig
+import javax.inject.Inject
+import kotlinx.coroutines.CoroutineScope
+import kotlinx.coroutines.flow.MutableStateFlow
+import kotlinx.coroutines.flow.asStateFlow
+import kotlinx.coroutines.launch
+
+@SysUISingleton
+class KeyboardDockingIndicationViewModel
+@Inject
+constructor(
+ private val windowManager: WindowManager,
+ private val context: Context,
+ keyboardDockingIndicationInteractor: KeyboardDockingIndicationInteractor,
+ configurationInteractor: ConfigurationInteractor,
+ @Background private val backgroundScope: CoroutineScope,
+) {
+
+ private val _edgeGlow: MutableStateFlow<GlowBoxConfig> = MutableStateFlow(createEffectConfig())
+ val edgeGlow = _edgeGlow.asStateFlow()
+ val keyboardConnected = keyboardDockingIndicationInteractor.onKeyboardConnected
+
+ init {
+ /**
+ * Expected behaviors:
+ * 1) On keyboard docking event, we play the animation for a fixed duration.
+ * 2) If the keyboard gets disconnected during the animation, we finish the animation with
+ * ease out.
+ * 3) If the configuration changes (e.g., device rotation), we force cancel the animation
+ * with no ease out.
+ */
+ backgroundScope.launch {
+ configurationInteractor.onAnyConfigurationChange.collect {
+ _edgeGlow.value = createEffectConfig()
+ }
+ }
+ }
+
+ private fun createEffectConfig(): GlowBoxConfig {
+ val bounds = windowManager.currentWindowMetrics.bounds
+ val width = bounds.width().toFloat()
+ val height = bounds.height().toFloat()
+
+ val startCenterX: Float
+ val startCenterY: Float
+ val endCenterX: Float
+ val endCenterY: Float
+ val boxWidth: Float
+ val boxHeight: Float
+
+ when (context.display.rotation) {
+ Surface.ROTATION_0 -> {
+ endCenterX = width
+ endCenterY = height * 0.5f
+ startCenterX = endCenterX + OFFSET
+ startCenterY = endCenterY
+ boxWidth = THICKNESS
+ boxHeight = height
+ }
+ Surface.ROTATION_90 -> {
+ endCenterX = width * 0.5f
+ endCenterY = 0f
+ startCenterX = endCenterX
+ startCenterY = endCenterY - OFFSET
+ boxWidth = width
+ boxHeight = THICKNESS
+ }
+ Surface.ROTATION_180 -> {
+ endCenterX = 0f
+ endCenterY = height * 0.5f
+ startCenterX = endCenterX - OFFSET
+ startCenterY = endCenterY
+ boxWidth = THICKNESS
+ boxHeight = height
+ }
+ Surface.ROTATION_270 -> {
+ endCenterX = width * 0.5f
+ endCenterY = height
+ startCenterX = endCenterX
+ startCenterY = endCenterY + OFFSET
+ boxWidth = width
+ boxHeight = THICKNESS
+ }
+ else -> { // Shouldn't happen. Just fall off to ROTATION_0
+ endCenterX = width
+ endCenterY = height * 0.5f
+ startCenterX = endCenterX + OFFSET
+ startCenterY = endCenterY
+ boxWidth = THICKNESS
+ boxHeight = height
+ }
+ }
+
+ return GlowBoxConfig(
+ startCenterX = startCenterX,
+ startCenterY = startCenterY,
+ endCenterX = endCenterX,
+ endCenterY = endCenterY,
+ width = boxWidth,
+ height = boxHeight,
+ color = Utils.getColorAttr(context, android.R.attr.colorAccent).defaultColor,
+ blurAmount = BLUR_AMOUNT,
+ duration = DURATION,
+ easeInDuration = EASE_DURATION,
+ easeOutDuration = EASE_DURATION
+ )
+ }
+
+ private companion object {
+ private const val OFFSET = 300f
+ private const val THICKNESS = 20f
+ private const val BLUR_AMOUNT = 700f
+ private const val DURATION = 3000L
+ private const val EASE_DURATION = 800L
+ }
+}
diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/data/repository/KeyguardRepository.kt b/packages/SystemUI/src/com/android/systemui/keyguard/data/repository/KeyguardRepository.kt
index a2bbcad..f15896b 100644
--- a/packages/SystemUI/src/com/android/systemui/keyguard/data/repository/KeyguardRepository.kt
+++ b/packages/SystemUI/src/com/android/systemui/keyguard/data/repository/KeyguardRepository.kt
@@ -183,7 +183,7 @@
val statusBarState: StateFlow<StatusBarState>
/** Observable for biometric unlock state which includes the mode and unlock source */
- val biometricUnlockState: Flow<BiometricUnlockModel>
+ val biometricUnlockState: StateFlow<BiometricUnlockModel>
fun setBiometricUnlockState(
unlockMode: BiometricUnlockMode,
@@ -307,17 +307,20 @@
private val _dismissAction: MutableStateFlow<DismissAction> =
MutableStateFlow(DismissAction.None)
override val dismissAction = _dismissAction.asStateFlow()
+
override fun setDismissAction(dismissAction: DismissAction) {
_dismissAction.value = dismissAction
}
private val _keyguardDone: MutableSharedFlow<KeyguardDone> = MutableSharedFlow()
override val keyguardDone = _keyguardDone.asSharedFlow()
+
override suspend fun setKeyguardDone(keyguardDoneType: KeyguardDone) {
_keyguardDone.emit(keyguardDoneType)
}
override val keyguardDoneAnimationsFinished: MutableSharedFlow<Unit> = MutableSharedFlow()
+
override fun keyguardDoneAnimationsFinished() {
keyguardDoneAnimationsFinished.tryEmit(Unit)
}
@@ -490,6 +493,7 @@
override fun onStartDream() {
trySendWithFailureLogging(true, TAG, "updated isDreamingWithOverlay")
}
+
override fun onWakeUp() {
trySendWithFailureLogging(false, TAG, "updated isDreamingWithOverlay")
}
@@ -618,7 +622,8 @@
private val _biometricUnlockState: MutableStateFlow<BiometricUnlockModel> =
MutableStateFlow(BiometricUnlockModel(BiometricUnlockMode.NONE, null))
- override val biometricUnlockState = _biometricUnlockState.asStateFlow()
+ override val biometricUnlockState: StateFlow<BiometricUnlockModel> =
+ _biometricUnlockState.asStateFlow()
override fun setBiometricUnlockState(
unlockMode: BiometricUnlockMode,
diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/data/repository/KeyguardTransitionRepository.kt b/packages/SystemUI/src/com/android/systemui/keyguard/data/repository/KeyguardTransitionRepository.kt
index f488d3b..8ec460a 100644
--- a/packages/SystemUI/src/com/android/systemui/keyguard/data/repository/KeyguardTransitionRepository.kt
+++ b/packages/SystemUI/src/com/android/systemui/keyguard/data/repository/KeyguardTransitionRepository.kt
@@ -265,7 +265,7 @@
state: TransitionState
) {
if (updateTransitionId != transitionId) {
- Log.w(TAG, "Attempting to update with old/invalid transitionId: $transitionId")
+ Log.wtf(TAG, "Attempting to update with old/invalid transitionId: $transitionId")
return
}
diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/domain/interactor/BiometricUnlockInteractor.kt b/packages/SystemUI/src/com/android/systemui/keyguard/domain/interactor/BiometricUnlockInteractor.kt
index 576fafd..ebc3483 100644
--- a/packages/SystemUI/src/com/android/systemui/keyguard/domain/interactor/BiometricUnlockInteractor.kt
+++ b/packages/SystemUI/src/com/android/systemui/keyguard/domain/interactor/BiometricUnlockInteractor.kt
@@ -3,6 +3,7 @@
import com.android.systemui.dagger.SysUISingleton
import com.android.systemui.keyguard.data.repository.KeyguardRepository
import com.android.systemui.keyguard.shared.model.BiometricUnlockMode
+import com.android.systemui.keyguard.shared.model.BiometricUnlockModel
import com.android.systemui.keyguard.shared.model.BiometricUnlockSource
import com.android.systemui.statusbar.phone.BiometricUnlockController.MODE_DISMISS_BOUNCER
import com.android.systemui.statusbar.phone.BiometricUnlockController.MODE_NONE
@@ -15,6 +16,7 @@
import com.android.systemui.statusbar.phone.BiometricUnlockController.WakeAndUnlockMode
import javax.inject.Inject
import kotlinx.coroutines.ExperimentalCoroutinesApi
+import kotlinx.coroutines.flow.StateFlow
@ExperimentalCoroutinesApi
@SysUISingleton
@@ -24,6 +26,8 @@
private val keyguardRepository: KeyguardRepository,
) {
+ val unlockState: StateFlow<BiometricUnlockModel> = keyguardRepository.biometricUnlockState
+
fun setBiometricUnlockState(
@WakeAndUnlockMode unlockStateInt: Int,
biometricUnlockSource: BiometricUnlockSource?,
diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/domain/interactor/FromDozingTransitionInteractor.kt b/packages/SystemUI/src/com/android/systemui/keyguard/domain/interactor/FromDozingTransitionInteractor.kt
index f5e98f1..f3692bd 100644
--- a/packages/SystemUI/src/com/android/systemui/keyguard/domain/interactor/FromDozingTransitionInteractor.kt
+++ b/packages/SystemUI/src/com/android/systemui/keyguard/domain/interactor/FromDozingTransitionInteractor.kt
@@ -29,6 +29,7 @@
import com.android.systemui.keyguard.shared.model.KeyguardState
import com.android.systemui.power.domain.interactor.PowerInteractor
import com.android.systemui.util.kotlin.Utils.Companion.sample
+import com.android.systemui.util.kotlin.sample
import javax.inject.Inject
import kotlin.time.Duration.Companion.milliseconds
import kotlinx.coroutines.CoroutineDispatcher
@@ -65,6 +66,7 @@
override fun start() {
listenForDozingToAny()
+ listenForDozingToGoneViaBiometrics()
listenForWakeFromDozing()
listenForTransitionToCamera(scope, keyguardInteractor)
}
@@ -77,6 +79,35 @@
isKeyguardDismissible && !isKeyguardShowing
}
+ private fun listenForDozingToGoneViaBiometrics() {
+ if (KeyguardWmStateRefactor.isEnabled) {
+ return
+ }
+
+ // This is separate from `listenForDozingToAny` because any delay on wake and unlock will
+ // cause a noticeable issue with animations
+ scope.launch {
+ powerInteractor.isAwake
+ .filterRelevantKeyguardStateAnd { isAwake -> isAwake }
+ .sample(
+ keyguardInteractor.biometricUnlockState,
+ ::Pair,
+ )
+ .collect {
+ (
+ _,
+ biometricUnlockState,
+ ) ->
+ if (isWakeAndUnlock(biometricUnlockState.mode)) {
+ startTransitionTo(
+ KeyguardState.GONE,
+ ownerReason = "biometric wake and unlock",
+ )
+ }
+ }
+ }
+ }
+
private fun listenForDozingToAny() {
if (KeyguardWmStateRefactor.isEnabled) {
return
@@ -87,7 +118,6 @@
.debounce(50L)
.filterRelevantKeyguardStateAnd { isAwake -> isAwake }
.sample(
- keyguardInteractor.biometricUnlockState,
keyguardInteractor.isKeyguardOccluded,
communalInteractor.isIdleOnCommunal,
canTransitionToGoneOnWake,
@@ -96,7 +126,6 @@
.collect {
(
_,
- biometricUnlockState,
occluded,
isIdleOnCommunal,
canTransitionToGoneOnWake,
@@ -104,8 +133,6 @@
startTransitionTo(
if (!deviceEntryRepository.isLockscreenEnabled()) {
KeyguardState.GONE
- } else if (isWakeAndUnlock(biometricUnlockState.mode)) {
- KeyguardState.GONE
} else if (canTransitionToGoneOnWake) {
KeyguardState.GONE
} else if (primaryBouncerShowing) {
diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/domain/interactor/FromPrimaryBouncerTransitionInteractor.kt b/packages/SystemUI/src/com/android/systemui/keyguard/domain/interactor/FromPrimaryBouncerTransitionInteractor.kt
index 19b2b81..8cf4b53 100644
--- a/packages/SystemUI/src/com/android/systemui/keyguard/domain/interactor/FromPrimaryBouncerTransitionInteractor.kt
+++ b/packages/SystemUI/src/com/android/systemui/keyguard/domain/interactor/FromPrimaryBouncerTransitionInteractor.kt
@@ -222,17 +222,24 @@
override fun getDefaultAnimatorForTransitionsToState(toState: KeyguardState): ValueAnimator {
return ValueAnimator().apply {
interpolator = Interpolators.LINEAR
- duration = DEFAULT_DURATION.inWholeMilliseconds
+ duration =
+ when (toState) {
+ KeyguardState.AOD -> TO_AOD_DURATION
+ KeyguardState.DOZING -> TO_DOZING_DURATION
+ KeyguardState.GONE -> TO_GONE_DURATION
+ KeyguardState.LOCKSCREEN -> TO_LOCKSCREEN_DURATION
+ else -> DEFAULT_DURATION
+ }.inWholeMilliseconds
}
}
companion object {
private val DEFAULT_DURATION = 300.milliseconds
+ val TO_AOD_DURATION = DEFAULT_DURATION
+ val TO_DOZING_DURATION = DEFAULT_DURATION
val TO_GONE_DURATION = 500.milliseconds
val TO_GONE_SHORT_DURATION = 200.milliseconds
- val TO_AOD_DURATION = DEFAULT_DURATION
- val TO_LOCKSCREEN_DURATION = DEFAULT_DURATION
- val TO_DOZING_DURATION = DEFAULT_DURATION
+ val TO_LOCKSCREEN_DURATION = 450.milliseconds
val TO_GONE_SURFACE_BEHIND_VISIBLE_THRESHOLD = 0.5f
}
}
diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/domain/interactor/KeyguardInteractor.kt b/packages/SystemUI/src/com/android/systemui/keyguard/domain/interactor/KeyguardInteractor.kt
index b142b44..73835a3c 100644
--- a/packages/SystemUI/src/com/android/systemui/keyguard/domain/interactor/KeyguardInteractor.kt
+++ b/packages/SystemUI/src/com/android/systemui/keyguard/domain/interactor/KeyguardInteractor.kt
@@ -181,6 +181,8 @@
/** Doze transition information. */
val dozeTransitionModel: Flow<DozeTransitionModel> = repository.dozeTransitionModel
+ val isPulsing: Flow<Boolean> = dozeTransitionModel.map { it.to == DozeStateModel.DOZE_PULSING }
+
/**
* Whether the system is dreaming. [isDreaming] will be always be true when [isDozing] is true,
* but not vice-versa.
diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/domain/interactor/KeyguardQuickAffordanceInteractor.kt b/packages/SystemUI/src/com/android/systemui/keyguard/domain/interactor/KeyguardQuickAffordanceInteractor.kt
index 8ffa4bb..ccce3bf 100644
--- a/packages/SystemUI/src/com/android/systemui/keyguard/domain/interactor/KeyguardQuickAffordanceInteractor.kt
+++ b/packages/SystemUI/src/com/android/systemui/keyguard/domain/interactor/KeyguardQuickAffordanceInteractor.kt
@@ -105,35 +105,33 @@
}
return combine(
- quickAffordanceAlwaysVisible(position),
- keyguardInteractor.isDozing,
- if (SceneContainerFlag.isEnabled) {
- sceneInteractor
- .get()
- .transitionState
- .map {
- when (it) {
- is ObservableTransitionState.Idle ->
- it.currentScene == Scenes.Lockscreen
- is ObservableTransitionState.Transition ->
- it.fromScene == Scenes.Lockscreen ||
- it.toScene == Scenes.Lockscreen
- }
+ quickAffordanceAlwaysVisible(position),
+ keyguardInteractor.isDozing,
+ if (SceneContainerFlag.isEnabled) {
+ sceneInteractor
+ .get()
+ .transitionState
+ .map {
+ when (it) {
+ is ObservableTransitionState.Idle ->
+ it.currentScene == Scenes.Lockscreen
+ is ObservableTransitionState.Transition ->
+ it.fromScene == Scenes.Lockscreen || it.toScene == Scenes.Lockscreen
}
- .distinctUntilChanged()
- } else {
- keyguardInteractor.isKeyguardShowing
- },
- shadeInteractor.anyExpansion.map { it < 1.0f }.distinctUntilChanged(),
- biometricSettingsRepository.isCurrentUserInLockdown,
- ) { affordance, isDozing, isKeyguardShowing, isQuickSettingsVisible, isUserInLockdown ->
- if (!isDozing && isKeyguardShowing && isQuickSettingsVisible && !isUserInLockdown) {
- affordance
- } else {
- KeyguardQuickAffordanceModel.Hidden
- }
+ }
+ .distinctUntilChanged()
+ } else {
+ keyguardInteractor.isKeyguardShowing
+ },
+ shadeInteractor.anyExpansion.map { it < 1.0f }.distinctUntilChanged(),
+ biometricSettingsRepository.isCurrentUserInLockdown,
+ ) { affordance, isDozing, isKeyguardShowing, isQuickSettingsVisible, isUserInLockdown ->
+ if (!isDozing && isKeyguardShowing && isQuickSettingsVisible && !isUserInLockdown) {
+ affordance
+ } else {
+ KeyguardQuickAffordanceModel.Hidden
}
- .distinctUntilChanged()
+ }
}
/**
diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/domain/interactor/KeyguardTransitionAuditLogger.kt b/packages/SystemUI/src/com/android/systemui/keyguard/domain/interactor/KeyguardTransitionAuditLogger.kt
index cf6942e..e132eb7 100644
--- a/packages/SystemUI/src/com/android/systemui/keyguard/domain/interactor/KeyguardTransitionAuditLogger.kt
+++ b/packages/SystemUI/src/com/android/systemui/keyguard/domain/interactor/KeyguardTransitionAuditLogger.kt
@@ -104,6 +104,12 @@
}
scope.launch {
+ keyguardInteractor.isKeyguardGoingAway.collect {
+ logger.log(TAG, VERBOSE, "isKeyguardGoingAway", it)
+ }
+ }
+
+ scope.launch {
keyguardInteractor.isKeyguardOccluded.collect {
logger.log(TAG, VERBOSE, "isOccluded", it)
}
diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/ui/binder/KeyguardIndicationAreaBinder.kt b/packages/SystemUI/src/com/android/systemui/keyguard/ui/binder/KeyguardIndicationAreaBinder.kt
index 807c322..23c2491 100644
--- a/packages/SystemUI/src/com/android/systemui/keyguard/ui/binder/KeyguardIndicationAreaBinder.kt
+++ b/packages/SystemUI/src/com/android/systemui/keyguard/ui/binder/KeyguardIndicationAreaBinder.kt
@@ -65,7 +65,7 @@
val configurationBasedDimensions = MutableStateFlow(loadFromResources(view))
val disposableHandle =
view.repeatWhenAttached {
- repeatOnLifecycle(Lifecycle.State.CREATED) {
+ repeatOnLifecycle(Lifecycle.State.STARTED) {
launch("$TAG#viewModel.alpha") {
// Do not independently apply alpha, as [KeyguardRootViewModel] should work
// for this and all its children
diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/ui/binder/KeyguardQuickAffordanceViewBinder.kt b/packages/SystemUI/src/com/android/systemui/keyguard/ui/binder/KeyguardQuickAffordanceViewBinder.kt
index 1cf009d..b9a79dc 100644
--- a/packages/SystemUI/src/com/android/systemui/keyguard/ui/binder/KeyguardQuickAffordanceViewBinder.kt
+++ b/packages/SystemUI/src/com/android/systemui/keyguard/ui/binder/KeyguardQuickAffordanceViewBinder.kt
@@ -30,7 +30,6 @@
import androidx.core.view.updateLayoutParams
import androidx.lifecycle.Lifecycle
import androidx.lifecycle.repeatOnLifecycle
-import com.android.app.tracing.coroutines.launch
import com.android.settingslib.Utils
import com.android.systemui.animation.Expandable
import com.android.systemui.animation.view.LaunchableImageView
@@ -81,8 +80,8 @@
val configurationBasedDimensions = MutableStateFlow(loadFromResources(view))
val disposableHandle =
view.repeatWhenAttached {
- repeatOnLifecycle(Lifecycle.State.CREATED) {
- launch("$TAG#viewModel.collect") {
+ repeatOnLifecycle(Lifecycle.State.STARTED) {
+ launch {
viewModel.collect { buttonModel ->
updateButton(
view = button,
@@ -94,7 +93,7 @@
}
}
- launch("$TAG#updateButtonAlpha") {
+ launch {
updateButtonAlpha(
view = button,
viewModel = viewModel,
@@ -102,7 +101,7 @@
)
}
- launch("$TAG#configurationBasedDimensions") {
+ launch {
configurationBasedDimensions.collect { dimensions ->
button.updateLayoutParams<ViewGroup.LayoutParams> {
width = dimensions.buttonSizePx.width
@@ -324,6 +323,4 @@
private data class ConfigurationBasedDimensions(
val buttonSizePx: Size,
)
-
- private const val TAG = "KeyguardQuickAffordanceViewBinder"
}
diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/ui/viewmodel/DozingToGoneTransitionViewModel.kt b/packages/SystemUI/src/com/android/systemui/keyguard/ui/viewmodel/DozingToGoneTransitionViewModel.kt
index 77ebfce..480f948 100644
--- a/packages/SystemUI/src/com/android/systemui/keyguard/ui/viewmodel/DozingToGoneTransitionViewModel.kt
+++ b/packages/SystemUI/src/com/android/systemui/keyguard/ui/viewmodel/DozingToGoneTransitionViewModel.kt
@@ -16,7 +16,6 @@
package com.android.systemui.keyguard.ui.viewmodel
-import android.util.MathUtils
import com.android.systemui.dagger.SysUISingleton
import com.android.systemui.keyguard.domain.interactor.FromDozingTransitionInteractor.Companion.TO_GONE_DURATION
import com.android.systemui.keyguard.shared.model.Edge
@@ -50,12 +49,10 @@
)
fun lockscreenAlpha(viewState: ViewStateAccessor): Flow<Float> {
- var startAlpha = 1f
return transitionAnimation.sharedFlow(
duration = 200.milliseconds,
- onStart = { startAlpha = viewState.alpha() },
- onStep = { MathUtils.lerp(startAlpha, 0f, it) },
- onFinish = { 0f },
+ onStart = { 0f },
+ onStep = { 0f },
)
}
diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/ui/viewmodel/KeyguardQuickAffordancesCombinedViewModel.kt b/packages/SystemUI/src/com/android/systemui/keyguard/ui/viewmodel/KeyguardQuickAffordancesCombinedViewModel.kt
index 244d842..c4383fc 100644
--- a/packages/SystemUI/src/com/android/systemui/keyguard/ui/viewmodel/KeyguardQuickAffordancesCombinedViewModel.kt
+++ b/packages/SystemUI/src/com/android/systemui/keyguard/ui/viewmodel/KeyguardQuickAffordancesCombinedViewModel.kt
@@ -18,7 +18,6 @@
package com.android.systemui.keyguard.ui.viewmodel
import androidx.annotation.VisibleForTesting
-import com.android.systemui.dagger.qualifiers.Application
import com.android.systemui.keyguard.domain.interactor.KeyguardInteractor
import com.android.systemui.keyguard.domain.interactor.KeyguardQuickAffordanceInteractor
import com.android.systemui.keyguard.domain.interactor.KeyguardTransitionInteractor
@@ -29,23 +28,19 @@
import com.android.systemui.shade.domain.interactor.ShadeInteractor
import com.android.systemui.shared.keyguard.shared.model.KeyguardQuickAffordanceSlots
import javax.inject.Inject
-import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.MutableStateFlow
-import kotlinx.coroutines.flow.SharingStarted
import kotlinx.coroutines.flow.combine
import kotlinx.coroutines.flow.distinctUntilChanged
import kotlinx.coroutines.flow.flatMapLatest
import kotlinx.coroutines.flow.map
import kotlinx.coroutines.flow.merge
-import kotlinx.coroutines.flow.stateIn
@OptIn(ExperimentalCoroutinesApi::class)
class KeyguardQuickAffordancesCombinedViewModel
@Inject
constructor(
- @Application applicationScope: CoroutineScope,
private val quickAffordanceInteractor: KeyguardQuickAffordanceInteractor,
private val keyguardInteractor: KeyguardInteractor,
shadeInteractor: ShadeInteractor,
@@ -89,20 +84,15 @@
/** The only time the expansion is important is while lockscreen is actively displayed */
private val shadeExpansionAlpha =
combine(
- showingLockscreen,
- shadeInteractor.anyExpansion,
- ) { showingLockscreen, expansion ->
- if (showingLockscreen) {
- 1 - expansion
- } else {
- 0f
- }
+ showingLockscreen,
+ shadeInteractor.anyExpansion,
+ ) { showingLockscreen, expansion ->
+ if (showingLockscreen) {
+ 1 - expansion
+ } else {
+ 0f
}
- .stateIn(
- scope = applicationScope,
- started = SharingStarted.Lazily,
- initialValue = 0f,
- )
+ }
/**
* ID of the slot that's currently selected in the preview that renders exclusively in the
diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/ui/viewmodel/KeyguardRootViewModel.kt b/packages/SystemUI/src/com/android/systemui/keyguard/ui/viewmodel/KeyguardRootViewModel.kt
index 1ec2a49..ee52ad0 100644
--- a/packages/SystemUI/src/com/android/systemui/keyguard/ui/viewmodel/KeyguardRootViewModel.kt
+++ b/packages/SystemUI/src/com/android/systemui/keyguard/ui/viewmodel/KeyguardRootViewModel.kt
@@ -36,6 +36,7 @@
import com.android.systemui.keyguard.shared.model.KeyguardState.GONE
import com.android.systemui.keyguard.shared.model.KeyguardState.LOCKSCREEN
import com.android.systemui.keyguard.shared.model.KeyguardState.OCCLUDED
+import com.android.systemui.keyguard.shared.model.KeyguardState.PRIMARY_BOUNCER
import com.android.systemui.keyguard.shared.model.TransitionState.RUNNING
import com.android.systemui.keyguard.shared.model.TransitionState.STARTED
import com.android.systemui.keyguard.ui.StateToValue
@@ -159,12 +160,26 @@
edge = Edge.create(from = LOCKSCREEN, to = Scenes.Gone),
edgeWithoutSceneContainer = Edge.create(from = LOCKSCREEN, to = GONE),
),
+ keyguardTransitionInteractor.isInTransition(
+ edge = Edge.create(from = PRIMARY_BOUNCER, to = Scenes.Lockscreen),
+ edgeWithoutSceneContainer =
+ Edge.create(from = PRIMARY_BOUNCER, to = LOCKSCREEN),
+ ),
isOnLockscreen,
shadeInteractor.qsExpansion,
shadeInteractor.shadeExpansion,
- ) { lockscreenToGoneTransitionRunning, isOnLockscreen, qsExpansion, shadeExpansion ->
+ ) {
+ lockscreenToGoneTransitionRunning,
+ primaryBouncerToLockscreenTransitionRunning,
+ isOnLockscreen,
+ qsExpansion,
+ shadeExpansion ->
// Fade out quickly as the shade expands
- if (isOnLockscreen && !lockscreenToGoneTransitionRunning) {
+ if (
+ isOnLockscreen &&
+ !lockscreenToGoneTransitionRunning &&
+ !primaryBouncerToLockscreenTransitionRunning
+ ) {
val alpha =
1f -
MathUtils.constrainedMap(
diff --git a/packages/SystemUI/src/com/android/systemui/media/controls/ui/controller/MediaCarouselController.kt b/packages/SystemUI/src/com/android/systemui/media/controls/ui/controller/MediaCarouselController.kt
index 7bacdeb..edead51 100644
--- a/packages/SystemUI/src/com/android/systemui/media/controls/ui/controller/MediaCarouselController.kt
+++ b/packages/SystemUI/src/com/android/systemui/media/controls/ui/controller/MediaCarouselController.kt
@@ -397,7 +397,7 @@
listenForLockscreenSettingChanges(applicationScope)
// Notifies all active players about animation scale changes.
- globalSettings.registerContentObserver(
+ globalSettings.registerContentObserverSync(
Settings.Global.getUriFor(Settings.Global.ANIMATOR_DURATION_SCALE),
animationScaleObserver
)
diff --git a/packages/SystemUI/src/com/android/systemui/media/controls/ui/controller/MediaHierarchyManager.kt b/packages/SystemUI/src/com/android/systemui/media/controls/ui/controller/MediaHierarchyManager.kt
index 6589038..601d563 100644
--- a/packages/SystemUI/src/com/android/systemui/media/controls/ui/controller/MediaHierarchyManager.kt
+++ b/packages/SystemUI/src/com/android/systemui/media/controls/ui/controller/MediaHierarchyManager.kt
@@ -167,6 +167,7 @@
private var targetBounds: Rect = Rect()
private val mediaFrame
get() = mediaCarouselController.mediaFrame
+
private var statusbarState: Int = statusBarStateController.state
private var animator =
ValueAnimator.ofFloat(0.0f, 1.0f).apply {
@@ -600,7 +601,7 @@
}
}
}
- secureSettings.registerContentObserverForUser(
+ secureSettings.registerContentObserverForUserSync(
Settings.Secure.MEDIA_CONTROLS_LOCK_SCREEN,
settingsObserver,
UserHandle.USER_ALL
diff --git a/packages/SystemUI/src/com/android/systemui/qrcodescanner/controller/QRCodeScannerController.java b/packages/SystemUI/src/com/android/systemui/qrcodescanner/controller/QRCodeScannerController.java
index 2d460a0..765b45b 100644
--- a/packages/SystemUI/src/com/android/systemui/qrcodescanner/controller/QRCodeScannerController.java
+++ b/packages/SystemUI/src/com/android/systemui/qrcodescanner/controller/QRCodeScannerController.java
@@ -341,7 +341,7 @@
}
mQRCodeScannerPreferenceObserver.forEach((key, value) -> {
- mSecureSettings.unregisterContentObserver(value);
+ mSecureSettings.unregisterContentObserverSync(value);
});
// Reset cached values to default as we are no longer listening
@@ -418,7 +418,7 @@
});
}
});
- mSecureSettings.registerContentObserverForUser(
+ mSecureSettings.registerContentObserverForUserSync(
mSecureSettings.getUriFor(LOCK_SCREEN_SHOW_QR_CODE_SCANNER), false,
mQRCodeScannerPreferenceObserver.get(userId), userId);
}
diff --git a/packages/SystemUI/src/com/android/systemui/qs/AutoAddTracker.kt b/packages/SystemUI/src/com/android/systemui/qs/AutoAddTracker.kt
index 2fafba1..e4bafcd 100644
--- a/packages/SystemUI/src/com/android/systemui/qs/AutoAddTracker.kt
+++ b/packages/SystemUI/src/com/android/systemui/qs/AutoAddTracker.kt
@@ -52,7 +52,9 @@
*
* It also handles restore gracefully.
*/
-class AutoAddTracker @VisibleForTesting constructor(
+class AutoAddTracker
+@VisibleForTesting
+constructor(
private val secureSettings: SecureSettings,
private val broadcastDispatcher: BroadcastDispatcher,
private val qsHost: QSHost,
@@ -66,39 +68,43 @@
private val FILTER = IntentFilter(Intent.ACTION_SETTING_RESTORED)
}
- @GuardedBy("autoAdded")
- private val autoAdded = ArraySet<String>()
+ @GuardedBy("autoAdded") private val autoAdded = ArraySet<String>()
private var restoredTiles: Map<String, AutoTile>? = null
override val currentUserId: Int
get() = userId
- private val contentObserver = object : ContentObserver(mainHandler) {
- override fun onChange(
- selfChange: Boolean,
- uris: Collection<Uri>,
- flags: Int,
- _userId: Int
- ) {
- if (_userId != userId) {
- // Ignore changes outside of our user. We'll load the correct value on user change
- return
+ private val contentObserver =
+ object : ContentObserver(mainHandler) {
+ override fun onChange(
+ selfChange: Boolean,
+ uris: Collection<Uri>,
+ flags: Int,
+ _userId: Int
+ ) {
+ if (_userId != userId) {
+ // Ignore changes outside of our user. We'll load the correct value on user
+ // change
+ return
+ }
+ loadTiles()
}
- loadTiles()
}
- }
- private val restoreReceiver = object : BroadcastReceiver() {
- override fun onReceive(context: Context, intent: Intent) {
- if (intent.action != Intent.ACTION_SETTING_RESTORED) return
- processRestoreIntent(intent)
+ private val restoreReceiver =
+ object : BroadcastReceiver() {
+ override fun onReceive(context: Context, intent: Intent) {
+ if (intent.action != Intent.ACTION_SETTING_RESTORED) return
+ processRestoreIntent(intent)
+ }
}
- }
private fun processRestoreIntent(intent: Intent) {
when (intent.getStringExtra(Intent.EXTRA_SETTING_NAME)) {
Settings.Secure.QS_TILES -> {
- restoredTiles = intent.getStringExtra(Intent.EXTRA_SETTING_NEW_VALUE)
+ restoredTiles =
+ intent
+ .getStringExtra(Intent.EXTRA_SETTING_NEW_VALUE)
?.split(DELIMITER)
?.mapIndexed(::AutoTile)
?.associateBy(AutoTile::tileType)
@@ -109,13 +115,11 @@
}
Settings.Secure.QS_AUTO_ADDED_TILES -> {
restoredTiles?.let { restoredTiles ->
- val restoredAutoAdded = intent
- .getStringExtra(Intent.EXTRA_SETTING_NEW_VALUE)
- ?.split(DELIMITER)
+ val restoredAutoAdded =
+ intent.getStringExtra(Intent.EXTRA_SETTING_NEW_VALUE)?.split(DELIMITER)
?: emptyList()
- val autoAddedBeforeRestore = intent
- .getStringExtra(Intent.EXTRA_SETTING_PREVIOUS_VALUE)
- ?.split(DELIMITER)
+ val autoAddedBeforeRestore =
+ intent.getStringExtra(Intent.EXTRA_SETTING_PREVIOUS_VALUE)?.split(DELIMITER)
?: emptyList()
val tilesToRemove = restoredAutoAdded.filter { it !in restoredTiles }
@@ -123,50 +127,51 @@
Log.d(TAG, "Removing tiles: $tilesToRemove")
qsHost.removeTiles(tilesToRemove)
}
- val tiles = synchronized(autoAdded) {
- autoAdded.clear()
- autoAdded.addAll(restoredAutoAdded + autoAddedBeforeRestore)
- getTilesFromListLocked()
- }
+ val tiles =
+ synchronized(autoAdded) {
+ autoAdded.clear()
+ autoAdded.addAll(restoredAutoAdded + autoAddedBeforeRestore)
+ getTilesFromListLocked()
+ }
saveTiles(tiles)
- } ?: run {
- Log.w(TAG, "${Settings.Secure.QS_AUTO_ADDED_TILES} restored before " +
- "${Settings.Secure.QS_TILES} for user $userId")
}
+ ?: run {
+ Log.w(
+ TAG,
+ "${Settings.Secure.QS_AUTO_ADDED_TILES} restored before " +
+ "${Settings.Secure.QS_TILES} for user $userId"
+ )
+ }
}
else -> {} // Do nothing for other Settings
}
}
- /**
- * Init method must be called after construction to start listening
- */
+ /** Init method must be called after construction to start listening */
fun initialize() {
dumpManager.registerDumpable(TAG, this)
loadTiles()
- secureSettings.registerContentObserverForUser(
- secureSettings.getUriFor(Settings.Secure.QS_AUTO_ADDED_TILES),
- contentObserver,
- UserHandle.USER_ALL
+ secureSettings.registerContentObserverForUserSync(
+ secureSettings.getUriFor(Settings.Secure.QS_AUTO_ADDED_TILES),
+ contentObserver,
+ UserHandle.USER_ALL
)
registerBroadcastReceiver()
}
- /**
- * Unregister listeners, receivers and observers
- */
+ /** Unregister listeners, receivers and observers */
fun destroy() {
dumpManager.unregisterDumpable(TAG)
- secureSettings.unregisterContentObserver(contentObserver)
+ secureSettings.unregisterContentObserverSync(contentObserver)
unregisterBroadcastReceiver()
}
private fun registerBroadcastReceiver() {
broadcastDispatcher.registerReceiver(
- restoreReceiver,
- FILTER,
- backgroundExecutor,
- UserHandle.of(userId)
+ restoreReceiver,
+ FILTER,
+ backgroundExecutor,
+ UserHandle.of(userId)
)
}
@@ -186,13 +191,9 @@
fun getRestoredTilePosition(tile: String): Int =
restoredTiles?.get(tile)?.index ?: QSHost.POSITION_AT_END
- /**
- * Returns `true` if the tile has been auto-added before
- */
+ /** Returns `true` if the tile has been auto-added before */
fun isAdded(tile: String): Boolean {
- return synchronized(autoAdded) {
- tile in autoAdded
- }
+ return synchronized(autoAdded) { tile in autoAdded }
}
/**
@@ -201,13 +202,14 @@
* From here on, [isAdded] will return true for that tile.
*/
fun setTileAdded(tile: String) {
- val tiles = synchronized(autoAdded) {
- if (autoAdded.add(tile)) {
- getTilesFromListLocked()
- } else {
- null
+ val tiles =
+ synchronized(autoAdded) {
+ if (autoAdded.add(tile)) {
+ getTilesFromListLocked()
+ } else {
+ null
+ }
}
- }
tiles?.let { saveTiles(it) }
}
@@ -217,13 +219,14 @@
* This allows for this tile to be auto-added again in the future.
*/
fun setTileRemoved(tile: String) {
- val tiles = synchronized(autoAdded) {
- if (autoAdded.remove(tile)) {
- getTilesFromListLocked()
- } else {
- null
+ val tiles =
+ synchronized(autoAdded) {
+ if (autoAdded.remove(tile)) {
+ getTilesFromListLocked()
+ } else {
+ null
+ }
}
- }
tiles?.let { saveTiles(it) }
}
@@ -233,12 +236,12 @@
private fun saveTiles(tiles: String) {
secureSettings.putStringForUser(
- Settings.Secure.QS_AUTO_ADDED_TILES,
- tiles,
- /* tag */ null,
- /* makeDefault */ false,
- userId,
- /* overrideableByRestore */ true
+ Settings.Secure.QS_AUTO_ADDED_TILES,
+ tiles,
+ /* tag */ null,
+ /* makeDefault */ false,
+ userId,
+ /* overrideableByRestore */ true
)
}
@@ -261,7 +264,9 @@
}
@SysUISingleton
- class Builder @Inject constructor(
+ class Builder
+ @Inject
+ constructor(
private val secureSettings: SecureSettings,
private val broadcastDispatcher: BroadcastDispatcher,
private val qsHost: QSHost,
@@ -278,16 +283,16 @@
fun build(): AutoAddTracker {
return AutoAddTracker(
- secureSettings,
- broadcastDispatcher,
- qsHost,
- dumpManager,
- handler,
- executor,
- userId
+ secureSettings,
+ broadcastDispatcher,
+ qsHost,
+ dumpManager,
+ handler,
+ executor,
+ userId
)
}
}
private data class AutoTile(val index: Int, val tileType: String)
-}
\ No newline at end of file
+}
diff --git a/packages/SystemUI/src/com/android/systemui/qs/QSTileHost.java b/packages/SystemUI/src/com/android/systemui/qs/QSTileHost.java
index 828d6ed..03c2aa6 100644
--- a/packages/SystemUI/src/com/android/systemui/qs/QSTileHost.java
+++ b/packages/SystemUI/src/com/android/systemui/qs/QSTileHost.java
@@ -108,7 +108,7 @@
private AutoTileManager mAutoTiles;
private final ArrayList<QSFactory> mQsFactories = new ArrayList<>();
private int mCurrentUser;
- private final ShadeController mShadeController;
+ private final Lazy<ShadeController> mShadeControllerProvider;
private Context mUserContext;
private UserTracker mUserTracker;
private SecureSettings mSecureSettings;
@@ -130,7 +130,7 @@
PluginManager pluginManager,
TunerService tunerService,
Provider<AutoTileManager> autoTiles,
- ShadeController shadeController,
+ Lazy<ShadeController> shadeControllerProvider,
QSLogger qsLogger,
UserTracker userTracker,
SecureSettings secureSettings,
@@ -149,7 +149,7 @@
mUserFileManager = userFileManager;
mFeatureFlags = featureFlags;
- mShadeController = shadeController;
+ mShadeControllerProvider = shadeControllerProvider;
if (featureFlags.getTilesEnabled()) {
mQsFactories.add(newQsTileFactoryProvider.get());
@@ -216,17 +216,17 @@
@Override
public void collapsePanels() {
- mShadeController.postAnimateCollapseShade();
+ mShadeControllerProvider.get().postAnimateCollapseShade();
}
@Override
public void forceCollapsePanels() {
- mShadeController.postAnimateForceCollapseShade();
+ mShadeControllerProvider.get().postAnimateForceCollapseShade();
}
@Override
public void openPanels() {
- mShadeController.postAnimateExpandQs();
+ mShadeControllerProvider.get().postAnimateExpandQs();
}
@Override
diff --git a/packages/SystemUI/src/com/android/systemui/qs/ReduceBrightColorsControllerImpl.java b/packages/SystemUI/src/com/android/systemui/qs/ReduceBrightColorsControllerImpl.java
index 4fc6609..846d63f 100644
--- a/packages/SystemUI/src/com/android/systemui/qs/ReduceBrightColorsControllerImpl.java
+++ b/packages/SystemUI/src/com/android/systemui/qs/ReduceBrightColorsControllerImpl.java
@@ -77,8 +77,8 @@
public void onUserChanged(int newUser, Context userContext) {
synchronized (mListeners) {
if (mListeners.size() > 0) {
- mSecureSettings.unregisterContentObserver(mContentObserver);
- mSecureSettings.registerContentObserverForUser(
+ mSecureSettings.unregisterContentObserverSync(mContentObserver);
+ mSecureSettings.registerContentObserverForUserSync(
Settings.Secure.REDUCE_BRIGHT_COLORS_ACTIVATED,
false, mContentObserver, newUser);
}
@@ -94,7 +94,7 @@
if (!mListeners.contains(listener)) {
mListeners.add(listener);
if (mListeners.size() == 1) {
- mSecureSettings.registerContentObserverForUser(
+ mSecureSettings.registerContentObserverForUserSync(
Settings.Secure.REDUCE_BRIGHT_COLORS_ACTIVATED,
false, mContentObserver, mUserTracker.getUserId());
}
@@ -106,7 +106,7 @@
public void removeCallback(@androidx.annotation.NonNull Listener listener) {
synchronized (mListeners) {
if (mListeners.remove(listener) && mListeners.size() == 0) {
- mSecureSettings.unregisterContentObserver(mContentObserver);
+ mSecureSettings.unregisterContentObserverSync(mContentObserver);
}
}
}
diff --git a/packages/SystemUI/src/com/android/systemui/qs/SettingObserver.java b/packages/SystemUI/src/com/android/systemui/qs/SettingObserver.java
index eb11568..6092348 100644
--- a/packages/SystemUI/src/com/android/systemui/qs/SettingObserver.java
+++ b/packages/SystemUI/src/com/android/systemui/qs/SettingObserver.java
@@ -74,10 +74,10 @@
mListening = listening;
if (listening) {
mObservedValue = getValueFromProvider();
- mSettingsProxy.registerContentObserver(
+ mSettingsProxy.registerContentObserverSync(
mSettingsProxy.getUriFor(mSettingName), false, this);
} else {
- mSettingsProxy.unregisterContentObserver(this);
+ mSettingsProxy.unregisterContentObserverSync(this);
mObservedValue = mDefaultValue;
}
}
diff --git a/packages/SystemUI/src/com/android/systemui/qs/UserSettingObserver.java b/packages/SystemUI/src/com/android/systemui/qs/UserSettingObserver.java
index 539c2d6..1b34c33 100644
--- a/packages/SystemUI/src/com/android/systemui/qs/UserSettingObserver.java
+++ b/packages/SystemUI/src/com/android/systemui/qs/UserSettingObserver.java
@@ -76,10 +76,10 @@
mListening = listening;
if (listening) {
mObservedValue = getValueFromProvider();
- mSettingsProxy.registerContentObserverForUser(
+ mSettingsProxy.registerContentObserverForUserSync(
mSettingsProxy.getUriFor(mSettingName), false, this, mUserId);
} else {
- mSettingsProxy.unregisterContentObserver(this);
+ mSettingsProxy.unregisterContentObserverSync(this);
mObservedValue = mDefaultValue;
}
}
diff --git a/packages/SystemUI/src/com/android/systemui/qs/pipeline/data/repository/UserAutoAddRepository.kt b/packages/SystemUI/src/com/android/systemui/qs/pipeline/data/repository/UserAutoAddRepository.kt
index d452241..9fcb0db 100644
--- a/packages/SystemUI/src/com/android/systemui/qs/pipeline/data/repository/UserAutoAddRepository.kt
+++ b/packages/SystemUI/src/com/android/systemui/qs/pipeline/data/repository/UserAutoAddRepository.kt
@@ -44,9 +44,8 @@
@Background private val bgDispatcher: CoroutineDispatcher,
) {
- private val changeEvents = MutableSharedFlow<ChangeAction>(
- extraBufferCapacity = CHANGES_BUFFER_SIZE
- )
+ private val changeEvents =
+ MutableSharedFlow<ChangeAction>(extraBufferCapacity = CHANGES_BUFFER_SIZE)
private lateinit var _autoAdded: StateFlow<Set<TileSpec>>
@@ -85,8 +84,8 @@
trySend(Unit)
}
}
- secureSettings.registerContentObserverForUser(SETTING, observer, userId)
- awaitClose { secureSettings.unregisterContentObserver(observer) }
+ secureSettings.registerContentObserverForUserSync(SETTING, observer, userId)
+ awaitClose { secureSettings.unregisterContentObserverSync(observer) }
}
.map { load() }
.flowOn(bgDispatcher)
diff --git a/packages/SystemUI/src/com/android/systemui/qs/pipeline/data/repository/UserTileSpecRepository.kt b/packages/SystemUI/src/com/android/systemui/qs/pipeline/data/repository/UserTileSpecRepository.kt
index aca8733..1f9570a 100644
--- a/packages/SystemUI/src/com/android/systemui/qs/pipeline/data/repository/UserTileSpecRepository.kt
+++ b/packages/SystemUI/src/com/android/systemui/qs/pipeline/data/repository/UserTileSpecRepository.kt
@@ -98,8 +98,8 @@
trySend(Unit)
}
}
- secureSettings.registerContentObserverForUser(SETTING, observer, userId)
- awaitClose { secureSettings.unregisterContentObserver(observer) }
+ secureSettings.registerContentObserverForUserSync(SETTING, observer, userId)
+ awaitClose { secureSettings.unregisterContentObserverSync(observer) }
}
.map { loadTilesFromSettings(userId) }
.flowOn(backgroundDispatcher)
diff --git a/packages/SystemUI/src/com/android/systemui/qs/tiles/RecordIssueTile.kt b/packages/SystemUI/src/com/android/systemui/qs/tiles/RecordIssueTile.kt
index 9937ea4..e680102 100644
--- a/packages/SystemUI/src/com/android/systemui/qs/tiles/RecordIssueTile.kt
+++ b/packages/SystemUI/src/com/android/systemui/qs/tiles/RecordIssueTile.kt
@@ -46,11 +46,14 @@
import com.android.systemui.recordissue.IssueRecordingService
import com.android.systemui.recordissue.IssueRecordingState
import com.android.systemui.recordissue.RecordIssueDialogDelegate
+import com.android.systemui.recordissue.TraceurMessageSender
import com.android.systemui.res.R
import com.android.systemui.screenrecord.RecordingService
import com.android.systemui.settings.UserContextProvider
import com.android.systemui.statusbar.phone.KeyguardDismissUtil
import com.android.systemui.statusbar.policy.KeyguardStateController
+import com.android.traceur.TraceUtils.PresetTraceType
+import java.util.concurrent.Executor
import javax.inject.Inject
class RecordIssueTile
@@ -70,6 +73,8 @@
private val dialogTransitionAnimator: DialogTransitionAnimator,
private val panelInteractor: PanelInteractor,
private val userContextProvider: UserContextProvider,
+ private val traceurMessageSender: TraceurMessageSender,
+ @Background private val bgExecutor: Executor,
private val issueRecordingState: IssueRecordingState,
private val delegateFactory: RecordIssueDialogDelegate.Factory,
) :
@@ -96,6 +101,11 @@
}
}
+ override fun handleDestroy() {
+ super.handleDestroy()
+ bgExecutor.execute { traceurMessageSender.unbindFromTraceur(mContext) }
+ }
+
override fun getTileLabel(): CharSequence = mContext.getString(R.string.qs_record_issue_label)
/**
@@ -121,14 +131,14 @@
}
}
- private fun startIssueRecordingService(screenRecord: Boolean, winscopeTracing: Boolean) =
+ private fun startIssueRecordingService(screenRecord: Boolean, traceType: PresetTraceType) =
PendingIntent.getForegroundService(
userContextProvider.userContext,
RecordingService.REQUEST_CODE,
IssueRecordingService.getStartIntent(
userContextProvider.userContext,
screenRecord,
- winscopeTracing
+ traceType
),
PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_IMMUTABLE
)
@@ -147,7 +157,7 @@
val dialog: AlertDialog =
delegateFactory
.create {
- startIssueRecordingService(it.screenRecord, it.winscopeTracing)
+ startIssueRecordingService(it.screenRecord, it.traceType)
dialogTransitionAnimator.disableAllCurrentDialogsExitAnimations()
panelInteractor.collapsePanels()
}
diff --git a/packages/SystemUI/src/com/android/systemui/qs/ui/viewmodel/QuickSettingsShadeSceneViewModel.kt b/packages/SystemUI/src/com/android/systemui/qs/ui/viewmodel/QuickSettingsShadeSceneViewModel.kt
index d48d55d..c1a5646 100644
--- a/packages/SystemUI/src/com/android/systemui/qs/ui/viewmodel/QuickSettingsShadeSceneViewModel.kt
+++ b/packages/SystemUI/src/com/android/systemui/qs/ui/viewmodel/QuickSettingsShadeSceneViewModel.kt
@@ -21,8 +21,12 @@
import com.android.compose.animation.scene.Swipe
import com.android.compose.animation.scene.UserAction
import com.android.compose.animation.scene.UserActionResult
+import com.android.systemui.brightness.ui.viewmodel.BrightnessSliderViewModel
import com.android.systemui.dagger.SysUISingleton
import com.android.systemui.dagger.qualifiers.Application
+import com.android.systemui.qs.panels.ui.viewmodel.EditModeViewModel
+import com.android.systemui.qs.panels.ui.viewmodel.TileGridViewModel
+import com.android.systemui.qs.ui.adapter.QSSceneAdapter
import com.android.systemui.shade.ui.viewmodel.OverlayShadeViewModel
import javax.inject.Inject
import kotlinx.coroutines.CoroutineScope
@@ -37,7 +41,11 @@
@Inject
constructor(
@Application private val applicationScope: CoroutineScope,
- overlayShadeViewModel: OverlayShadeViewModel,
+ val overlayShadeViewModel: OverlayShadeViewModel,
+ val brightnessSliderViewModel: BrightnessSliderViewModel,
+ val tileGridViewModel: TileGridViewModel,
+ val editModeViewModel: EditModeViewModel,
+ val qsSceneAdapter: QSSceneAdapter,
) {
val destinationScenes: StateFlow<Map<UserAction, UserActionResult>> =
overlayShadeViewModel.backgroundScene
diff --git a/packages/SystemUI/src/com/android/systemui/recordissue/IssueRecordingConfig.kt b/packages/SystemUI/src/com/android/systemui/recordissue/IssueRecordingConfig.kt
index bb3b654..23dbc26 100644
--- a/packages/SystemUI/src/com/android/systemui/recordissue/IssueRecordingConfig.kt
+++ b/packages/SystemUI/src/com/android/systemui/recordissue/IssueRecordingConfig.kt
@@ -16,4 +16,6 @@
package com.android.systemui.recordissue
-data class IssueRecordingConfig(val screenRecord: Boolean, val winscopeTracing: Boolean)
+import com.android.traceur.TraceUtils.PresetTraceType
+
+data class IssueRecordingConfig(val screenRecord: Boolean, val traceType: PresetTraceType)
diff --git a/packages/SystemUI/src/com/android/systemui/recordissue/IssueRecordingService.kt b/packages/SystemUI/src/com/android/systemui/recordissue/IssueRecordingService.kt
index 6694878..5ede64a 100644
--- a/packages/SystemUI/src/com/android/systemui/recordissue/IssueRecordingService.kt
+++ b/packages/SystemUI/src/com/android/systemui/recordissue/IssueRecordingService.kt
@@ -24,8 +24,6 @@
import android.net.Uri
import android.os.Handler
import android.os.UserHandle
-import android.util.Log
-import androidx.core.content.FileProvider
import com.android.internal.logging.UiEventLogger
import com.android.systemui.animation.DialogTransitionAnimator
import com.android.systemui.dagger.qualifiers.LongRunning
@@ -37,16 +35,10 @@
import com.android.systemui.screenrecord.RecordingServiceStrings
import com.android.systemui.settings.UserContextProvider
import com.android.systemui.statusbar.phone.KeyguardDismissUtil
-import com.android.traceur.FileSender
-import com.android.traceur.TraceUtils
-import java.io.File
-import java.io.FileOutputStream
-import java.nio.file.Files
+import com.android.traceur.MessageConstants.INTENT_EXTRA_TRACE_TYPE
+import com.android.traceur.TraceUtils.PresetTraceType
import java.util.concurrent.Executor
-import java.util.zip.ZipEntry
-import java.util.zip.ZipOutputStream
import javax.inject.Inject
-import kotlin.jvm.optionals.getOrElse
class IssueRecordingService
@Inject
@@ -60,6 +52,7 @@
keyguardDismissUtil: KeyguardDismissUtil,
private val dialogTransitionAnimator: DialogTransitionAnimator,
private val panelInteractor: PanelInteractor,
+ private val traceurMessageSender: TraceurMessageSender,
private val issueRecordingState: IssueRecordingState,
private val iActivityManager: IActivityManager,
) :
@@ -82,17 +75,14 @@
override fun onStartCommand(intent: Intent?, flags: Int, startId: Int): Int {
when (intent?.action) {
ACTION_START -> {
- TraceUtils.traceStart(
- this,
- DEFAULT_TRACE_TAGS,
- DEFAULT_BUFFER_SIZE,
- DEFAULT_IS_INCLUDING_WINSCOPE,
- DEFAULT_IS_INCLUDING_APP_TRACE,
- DEFAULT_IS_LONG_TRACE,
- DEFAULT_ATTACH_TO_BUGREPORT,
- DEFAULT_MAX_TRACE_SIZE,
- DEFAULT_MAX_TRACE_DURATION_IN_MINUTES
- )
+ bgExecutor.execute {
+ traceurMessageSender.startTracing(
+ intent.getSerializableExtra(
+ INTENT_EXTRA_TRACE_TYPE,
+ PresetTraceType::class.java
+ )
+ )
+ }
issueRecordingState.isRecording = true
if (!intent.getBooleanExtra(EXTRA_SCREEN_RECORD, false)) {
// If we don't want to record the screen, the ACTION_SHOW_START_NOTIF action
@@ -102,7 +92,10 @@
}
ACTION_STOP,
ACTION_STOP_NOTIF -> {
- TraceUtils.traceStop(this)
+ // ViewCapture needs to save it's data before it is disabled, or else the data will
+ // be lost. This is expected to change in the near future, and when that happens
+ // this line should be removed.
+ bgExecutor.execute { traceurMessageSender.stopTracing() }
issueRecordingState.isRecording = false
}
ACTION_SHARE -> {
@@ -117,7 +110,7 @@
if (issueRecordingState.takeBugReport) {
iActivityManager.requestBugReportWithExtraAttachment(screenRecording)
} else {
- shareRecording(screenRecording)
+ traceurMessageSender.shareTraces(applicationContext, screenRecording)
}
}
@@ -134,75 +127,10 @@
return super.onStartCommand(intent, flags, startId)
}
- private fun shareRecording(screenRecording: Uri?) {
- val traces =
- TraceUtils.traceDump(this, TRACE_FILE_NAME).getOrElse {
- Log.v(
- TAG,
- "Traces were not present. This can happen if users double" +
- "click on share notification. Traces are cleaned up after sharing" +
- "so they won't be present for the 2nd share attempt."
- )
- return
- }
- val perfetto = FileProvider.getUriForFile(this, AUTHORITY, traces.first())
- val urisToShare = mutableListOf(perfetto)
- traces.removeFirst()
-
- getZipWinscopeFileUri(traces)?.let { urisToShare.add(it) }
- screenRecording?.let { urisToShare.add(it) }
-
- val sendIntent =
- FileSender.buildSendIntent(this, urisToShare).addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
-
- // TODO: Debug why the notification shade isn't closing upon starting the BetterBug activity
- mKeyguardDismissUtil.executeWhenUnlocked(
- {
- startActivity(sendIntent)
- false
- },
- false,
- false
- )
- }
-
- private fun getZipWinscopeFileUri(traceFiles: List<File>): Uri? {
- try {
- externalCacheDir?.mkdirs()
- val outZip: File = File.createTempFile(TEMP_FILE_PREFIX, ZIP_SUFFIX, externalCacheDir)
- ZipOutputStream(FileOutputStream(outZip)).use { os ->
- traceFiles.forEach { file ->
- os.putNextEntry(ZipEntry(file.name))
- Files.copy(file.toPath(), os)
- os.closeEntry()
- }
- }
- return FileProvider.getUriForFile(this, AUTHORITY, outZip)
- } catch (e: Exception) {
- Log.e(TAG, "Failed to zip and package Recordings. Cannot share with BetterBug.", e)
- return null
- }
- }
-
companion object {
private const val TAG = "IssueRecordingService"
private const val CHANNEL_ID = "issue_record"
private const val EXTRA_SCREEN_RECORD = "extra_screenRecord"
- private const val EXTRA_WINSCOPE_TRACING = "extra_winscopeTracing"
- private const val ZIP_SUFFIX = ".zip"
- private const val TEMP_FILE_PREFIX = "winscope_recordings"
-
- private val DEFAULT_TRACE_TAGS = listOf<String>()
- private const val DEFAULT_BUFFER_SIZE = 16384
- private const val DEFAULT_IS_INCLUDING_WINSCOPE = true
- private const val DEFAULT_IS_LONG_TRACE = false
- private const val DEFAULT_IS_INCLUDING_APP_TRACE = true
- private const val DEFAULT_ATTACH_TO_BUGREPORT = true
- private const val DEFAULT_MAX_TRACE_SIZE = 10240
- private const val DEFAULT_MAX_TRACE_DURATION_IN_MINUTES = 30
-
- private val TRACE_FILE_NAME = TraceUtils.getOutputFilename(TraceUtils.RecordingType.TRACE)
- private const val AUTHORITY = "com.android.systemui.fileprovider"
/**
* Get an intent to stop the issue recording service.
@@ -223,12 +151,12 @@
fun getStartIntent(
context: Context,
screenRecord: Boolean,
- winscopeTracing: Boolean,
+ traceType: PresetTraceType,
): Intent =
Intent(context, IssueRecordingService::class.java)
.setAction(ACTION_START)
.putExtra(EXTRA_SCREEN_RECORD, screenRecord)
- .putExtra(EXTRA_WINSCOPE_TRACING, winscopeTracing)
+ .putExtra(INTENT_EXTRA_TRACE_TYPE, traceType)
}
}
diff --git a/packages/SystemUI/src/com/android/systemui/recordissue/RecordIssueDialogDelegate.kt b/packages/SystemUI/src/com/android/systemui/recordissue/RecordIssueDialogDelegate.kt
index 68b8836..84a063a 100644
--- a/packages/SystemUI/src/com/android/systemui/recordissue/RecordIssueDialogDelegate.kt
+++ b/packages/SystemUI/src/com/android/systemui/recordissue/RecordIssueDialogDelegate.kt
@@ -19,6 +19,7 @@
import android.annotation.SuppressLint
import android.app.AlertDialog
import android.content.Context
+import android.content.Intent
import android.content.res.ColorStateList
import android.graphics.Color
import android.os.Bundle
@@ -45,6 +46,8 @@
import com.android.systemui.settings.UserFileManager
import com.android.systemui.settings.UserTracker
import com.android.systemui.statusbar.phone.SystemUIDialog
+import com.android.traceur.MessageConstants.INTENT_EXTRA_TRACE_TYPE
+import com.android.traceur.TraceUtils.PresetTraceType
import dagger.assisted.Assisted
import dagger.assisted.AssistedFactory
import dagger.assisted.AssistedInject
@@ -64,9 +67,19 @@
private val userFileManager: UserFileManager,
private val screenCaptureDisabledDialogDelegate: ScreenCaptureDisabledDialogDelegate,
private val issueRecordingState: IssueRecordingState,
+ private val traceurMessageSender: TraceurMessageSender,
@Assisted private val onStarted: Consumer<IssueRecordingConfig>,
) : SystemUIDialog.Delegate {
+ private val issueTypeOptions: Map<Int, PresetTraceType> =
+ hashMapOf(
+ Pair(R.string.performance, PresetTraceType.PERFORMANCE),
+ Pair(R.string.user_interface, PresetTraceType.UI),
+ Pair(R.string.battery, PresetTraceType.BATTERY),
+ Pair(R.string.thermal, PresetTraceType.THERMAL)
+ )
+ private var selectedIssueType: PresetTraceType? = null
+
/** To inject dependencies and allow for easier testing */
@AssistedFactory
interface Factory {
@@ -92,7 +105,7 @@
onStarted.accept(
IssueRecordingConfig(
screenRecordSwitch.isChecked,
- true /* TODO: Base this on issueType selected */
+ selectedIssueType ?: PresetTraceType.UNSET
)
)
dismiss()
@@ -100,6 +113,7 @@
false
)
}
+ bgExecutor.execute { traceurMessageSender.bindToTraceur(dialog.context) }
}
override fun createDialog(): SystemUIDialog = factory.create(this)
@@ -166,20 +180,25 @@
@MainThread
private fun onIssueTypeClicked(context: Context, onIssueTypeSelected: Runnable) {
- val selectedCategory = issueTypeButton.text.toString()
val popupMenu = PopupMenu(context, issueTypeButton)
- context.resources.getStringArray(R.array.qs_record_issue_types).forEachIndexed { i, cat ->
- popupMenu.menu.add(0, 0, i, cat).apply {
+ issueTypeOptions.keys.forEach {
+ popupMenu.menu.add(it).apply {
setIcon(R.drawable.arrow_pointing_down)
- if (selectedCategory != cat) {
+ if (issueTypeOptions[it] != selectedIssueType) {
iconTintList = ColorStateList.valueOf(Color.TRANSPARENT)
}
+ intent = Intent().putExtra(INTENT_EXTRA_TRACE_TYPE, issueTypeOptions[it])
}
}
popupMenu.apply {
setOnMenuItemClickListener {
issueTypeButton.text = it.title
+ selectedIssueType =
+ it.intent?.getSerializableExtra(
+ INTENT_EXTRA_TRACE_TYPE,
+ PresetTraceType::class.java
+ )
onIssueTypeSelected.run()
true
}
diff --git a/packages/SystemUI/src/com/android/systemui/recordissue/TraceurMessageSender.kt b/packages/SystemUI/src/com/android/systemui/recordissue/TraceurMessageSender.kt
new file mode 100644
index 0000000..189336c
--- /dev/null
+++ b/packages/SystemUI/src/com/android/systemui/recordissue/TraceurMessageSender.kt
@@ -0,0 +1,157 @@
+/*
+ * 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.systemui.recordissue
+
+import android.annotation.SuppressLint
+import android.content.ComponentName
+import android.content.Context
+import android.content.Intent
+import android.content.ServiceConnection
+import android.content.pm.PackageManager
+import android.net.Uri
+import android.os.Bundle
+import android.os.Handler
+import android.os.IBinder
+import android.os.Looper
+import android.os.Message
+import android.os.Messenger
+import android.util.Log
+import androidx.annotation.WorkerThread
+import com.android.systemui.dagger.SysUISingleton
+import com.android.systemui.dagger.qualifiers.Background
+import com.android.traceur.FileSender
+import com.android.traceur.MessageConstants
+import com.android.traceur.TraceUtils.PresetTraceType
+import javax.inject.Inject
+
+private const val TAG = "TraceurMessageSender"
+
+@SysUISingleton
+class TraceurMessageSender @Inject constructor(@Background private val backgroundLooper: Looper) {
+ private var binder: Messenger? = null
+ private var isBound: Boolean = false
+
+ private val traceurConnection =
+ object : ServiceConnection {
+ override fun onServiceConnected(className: ComponentName, service: IBinder) {
+ binder = Messenger(service)
+ isBound = true
+ }
+
+ override fun onServiceDisconnected(className: ComponentName) {
+ binder = null
+ isBound = false
+ }
+ }
+
+ @SuppressLint("WrongConstant")
+ @WorkerThread
+ fun bindToTraceur(context: Context) {
+ if (isBound) {
+ // Binding needs to happen after the phone has been unlocked. The RecordIssueTile is
+ // initialized before this happens though, so binding is placed at a later time, during
+ // normal operations that can be repeated. This check avoids calling "bindService" 2x+
+ return
+ }
+ try {
+ val info =
+ context.packageManager.getPackageInfo(
+ MessageConstants.TRACING_APP_PACKAGE_NAME,
+ PackageManager.MATCH_SYSTEM_ONLY
+ )
+ val intent =
+ Intent().setClassName(info.packageName, MessageConstants.TRACING_APP_ACTIVITY)
+ val flags =
+ Context.BIND_AUTO_CREATE or
+ Context.BIND_FOREGROUND_SERVICE_WHILE_AWAKE or
+ Context.BIND_WAIVE_PRIORITY
+ context.bindService(intent, traceurConnection, flags)
+ } catch (e: Exception) {
+ Log.e(TAG, "failed to bind to Traceur's service", e)
+ }
+ }
+
+ @WorkerThread
+ fun unbindFromTraceur(context: Context) {
+ if (isBound) {
+ context.unbindService(traceurConnection)
+ }
+ }
+
+ @WorkerThread
+ fun startTracing(traceType: PresetTraceType?) {
+ val data =
+ Bundle().apply { putSerializable(MessageConstants.INTENT_EXTRA_TRACE_TYPE, traceType) }
+ notifyTraceur(MessageConstants.START_WHAT, data)
+ }
+
+ @WorkerThread fun stopTracing() = notifyTraceur(MessageConstants.STOP_WHAT)
+
+ @WorkerThread
+ fun shareTraces(context: Context, screenRecord: Uri?) {
+ val replyHandler = Messenger(TraceurMessageHandler(context, screenRecord, backgroundLooper))
+ notifyTraceur(MessageConstants.SHARE_WHAT, replyTo = replyHandler)
+ }
+
+ @WorkerThread
+ private fun notifyTraceur(what: Int, data: Bundle = Bundle(), replyTo: Messenger? = null) {
+ try {
+ binder!!.send(
+ Message.obtain().apply {
+ this.what = what
+ this.data = data
+ this.replyTo = replyTo
+ }
+ )
+ } catch (e: Exception) {
+ Log.e(TAG, "failed to notify Traceur", e)
+ }
+ }
+
+ private class TraceurMessageHandler(
+ private val context: Context,
+ private val screenRecord: Uri?,
+ looper: Looper,
+ ) : Handler(looper) {
+
+ override fun handleMessage(msg: Message) {
+ if (MessageConstants.SHARE_WHAT == msg.what) {
+ shareTraces(
+ msg.data.getParcelable(MessageConstants.EXTRA_PERFETTO, Uri::class.java),
+ msg.data.getParcelable(MessageConstants.EXTRA_WINSCOPE, Uri::class.java)
+ )
+ } else {
+ throw IllegalArgumentException("received unknown msg.what: " + msg.what)
+ }
+ }
+
+ private fun shareTraces(perfetto: Uri?, winscope: Uri?) {
+ val uris: List<Uri> =
+ mutableListOf<Uri>().apply {
+ perfetto?.let { add(it) }
+ winscope?.let { add(it) }
+ screenRecord?.let { add(it) }
+ }
+ val fileSharingIntent =
+ FileSender.buildSendIntent(context, uris)
+ .addFlags(
+ Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT
+ )
+ context.startActivity(fileSharingIntent)
+ }
+ }
+}
diff --git a/packages/SystemUI/src/com/android/systemui/retail/data/repository/RetailModeRepository.kt b/packages/SystemUI/src/com/android/systemui/retail/data/repository/RetailModeRepository.kt
index 3c0aa38..09fd7df 100644
--- a/packages/SystemUI/src/com/android/systemui/retail/data/repository/RetailModeRepository.kt
+++ b/packages/SystemUI/src/com/android/systemui/retail/data/repository/RetailModeRepository.kt
@@ -66,9 +66,9 @@
}
}
- globalSettings.registerContentObserver(RETAIL_MODE_SETTING, observer)
+ globalSettings.registerContentObserverSync(RETAIL_MODE_SETTING, observer)
- awaitClose { globalSettings.unregisterContentObserver(observer) }
+ awaitClose { globalSettings.unregisterContentObserverSync(observer) }
}
.onStart { emit(Unit) }
.map { globalSettings.getInt(RETAIL_MODE_SETTING, 0) != 0 }
diff --git a/packages/SystemUI/src/com/android/systemui/scene/KeyguardlessSceneContainerFrameworkModule.kt b/packages/SystemUI/src/com/android/systemui/scene/KeyguardlessSceneContainerFrameworkModule.kt
index 8169dec..7a9d09a 100644
--- a/packages/SystemUI/src/com/android/systemui/scene/KeyguardlessSceneContainerFrameworkModule.kt
+++ b/packages/SystemUI/src/com/android/systemui/scene/KeyguardlessSceneContainerFrameworkModule.kt
@@ -20,6 +20,7 @@
import com.android.systemui.notifications.ui.composable.NotificationsShadeSessionModule
import com.android.systemui.scene.domain.interactor.WindowRootViewVisibilityInteractor
import com.android.systemui.scene.domain.startable.SceneContainerStartable
+import com.android.systemui.scene.domain.startable.ScrimStartable
import com.android.systemui.scene.shared.model.SceneContainerConfig
import com.android.systemui.scene.shared.model.Scenes
import com.android.systemui.shade.shared.flag.DualShade
@@ -50,6 +51,11 @@
@Binds
@IntoMap
+ @ClassKey(ScrimStartable::class)
+ fun scrimStartable(impl: ScrimStartable): CoreStartable
+
+ @Binds
+ @IntoMap
@ClassKey(WindowRootViewVisibilityInteractor::class)
fun bindWindowRootViewVisibilityInteractor(
impl: WindowRootViewVisibilityInteractor
diff --git a/packages/SystemUI/src/com/android/systemui/scene/SceneContainerFrameworkModule.kt b/packages/SystemUI/src/com/android/systemui/scene/SceneContainerFrameworkModule.kt
index 9bd2694..7e6dfb8 100644
--- a/packages/SystemUI/src/com/android/systemui/scene/SceneContainerFrameworkModule.kt
+++ b/packages/SystemUI/src/com/android/systemui/scene/SceneContainerFrameworkModule.kt
@@ -21,6 +21,7 @@
import com.android.systemui.notifications.ui.composable.NotificationsShadeSessionModule
import com.android.systemui.scene.domain.interactor.WindowRootViewVisibilityInteractor
import com.android.systemui.scene.domain.startable.SceneContainerStartable
+import com.android.systemui.scene.domain.startable.ScrimStartable
import com.android.systemui.scene.shared.model.SceneContainerConfig
import com.android.systemui.scene.shared.model.Scenes
import com.android.systemui.shade.shared.flag.DualShade
@@ -56,6 +57,11 @@
@Binds
@IntoMap
+ @ClassKey(ScrimStartable::class)
+ fun scrimStartable(impl: ScrimStartable): CoreStartable
+
+ @Binds
+ @IntoMap
@ClassKey(WindowRootViewVisibilityInteractor::class)
fun bindWindowRootViewVisibilityInteractor(
impl: WindowRootViewVisibilityInteractor
diff --git a/packages/SystemUI/src/com/android/systemui/scene/domain/startable/ScrimStartable.kt b/packages/SystemUI/src/com/android/systemui/scene/domain/startable/ScrimStartable.kt
new file mode 100644
index 0000000..c6f51b3
--- /dev/null
+++ b/packages/SystemUI/src/com/android/systemui/scene/domain/startable/ScrimStartable.kt
@@ -0,0 +1,236 @@
+/*
+ * 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.
+ */
+
+@file:OptIn(ExperimentalCoroutinesApi::class)
+
+package com.android.systemui.scene.domain.startable
+
+import androidx.annotation.VisibleForTesting
+import com.android.compose.animation.scene.ObservableTransitionState
+import com.android.compose.animation.scene.SceneKey
+import com.android.systemui.CoreStartable
+import com.android.systemui.bouncer.domain.interactor.AlternateBouncerInteractor
+import com.android.systemui.dagger.SysUISingleton
+import com.android.systemui.dagger.qualifiers.Application
+import com.android.systemui.deviceentry.domain.interactor.DeviceEntryInteractor
+import com.android.systemui.keyguard.domain.interactor.BiometricUnlockInteractor
+import com.android.systemui.keyguard.domain.interactor.KeyguardInteractor
+import com.android.systemui.keyguard.shared.model.BiometricUnlockMode
+import com.android.systemui.keyguard.shared.model.BiometricUnlockModel
+import com.android.systemui.scene.domain.interactor.SceneContainerOcclusionInteractor
+import com.android.systemui.scene.domain.interactor.SceneInteractor
+import com.android.systemui.scene.shared.flag.SceneContainerFlag
+import com.android.systemui.scene.shared.model.Scenes
+import com.android.systemui.settings.brightness.domain.interactor.BrightnessMirrorShowingInteractor
+import com.android.systemui.statusbar.phone.DozeServiceHost
+import com.android.systemui.statusbar.phone.ScrimController
+import com.android.systemui.statusbar.phone.ScrimState
+import com.android.systemui.statusbar.phone.StatusBarKeyguardViewManager
+import com.android.systemui.utils.coroutines.flow.conflatedCallbackFlow
+import javax.inject.Inject
+import kotlinx.coroutines.CoroutineScope
+import kotlinx.coroutines.ExperimentalCoroutinesApi
+import kotlinx.coroutines.channels.awaitClose
+import kotlinx.coroutines.flow.Flow
+import kotlinx.coroutines.flow.combine
+import kotlinx.coroutines.flow.filterNotNull
+import kotlinx.coroutines.flow.map
+import kotlinx.coroutines.flow.onEach
+import kotlinx.coroutines.launch
+
+@SysUISingleton
+class ScrimStartable
+@Inject
+constructor(
+ @Application private val applicationScope: CoroutineScope,
+ private val scrimController: ScrimController,
+ sceneInteractor: SceneInteractor,
+ deviceEntryInteractor: DeviceEntryInteractor,
+ keyguardInteractor: KeyguardInteractor,
+ occlusionInteractor: SceneContainerOcclusionInteractor,
+ biometricUnlockInteractor: BiometricUnlockInteractor,
+ private val statusBarKeyguardViewManager: StatusBarKeyguardViewManager,
+ private val alternateBouncerInteractor: AlternateBouncerInteractor,
+ brightnessMirrorShowingInteractor: BrightnessMirrorShowingInteractor,
+ private val dozeServiceHost: DozeServiceHost,
+) : CoreStartable {
+
+ @VisibleForTesting
+ val scrimState: Flow<ScrimState?> =
+ combine(
+ deviceEntryInteractor.isDeviceEntered,
+ occlusionInteractor.invisibleDueToOcclusion,
+ sceneInteractor.currentScene,
+ sceneInteractor.transitionState,
+ keyguardInteractor.isDozing,
+ keyguardInteractor.isDreaming,
+ biometricUnlockInteractor.unlockState,
+ brightnessMirrorShowingInteractor.isShowing,
+ keyguardInteractor.isPulsing,
+ conflatedCallbackFlow {
+ val listener =
+ DozeServiceHost.HasPendingScreenOffCallbackChangeListener {
+ hasPendingScreenOffCallback ->
+ trySend(hasPendingScreenOffCallback)
+ }
+ dozeServiceHost.setHasPendingScreenOffCallbackChangeListener(listener)
+ awaitClose {
+ dozeServiceHost.setHasPendingScreenOffCallbackChangeListener(null)
+ }
+ },
+ ) { flowValues ->
+ val isDeviceEntered = flowValues[0] as Boolean
+ val isOccluded = flowValues[1] as Boolean
+ val currentScene = flowValues[2] as SceneKey
+ val transitionState = flowValues[3] as ObservableTransitionState
+ val isDozing = flowValues[4] as Boolean
+ val isDreaming = flowValues[5] as Boolean
+ val biometricUnlockState = flowValues[6] as BiometricUnlockModel
+ val isBrightnessMirrorVisible = flowValues[7] as Boolean
+ val isPulsing = flowValues[8] as Boolean
+ val hasPendingScreenOffCallback = flowValues[9] as Boolean
+
+ // This is true when the lockscreen scene is either the current scene or somewhere
+ // in the
+ // navigation back stack of scenes.
+ val isOnKeyguard = !isDeviceEntered
+ val isCurrentSceneBouncer = currentScene == Scenes.Bouncer
+ // This is true when moving away from one of the keyguard scenes to the gone scene.
+ // It
+ // happens only when unlocking or when dismissing a dismissible lockscreen.
+ val isTransitioningAwayFromKeyguard =
+ transitionState is ObservableTransitionState.Transition &&
+ transitionState.fromScene.isKeyguard() &&
+ transitionState.toScene == Scenes.Gone
+
+ // This is true when any of the shade scenes is the current scene.
+ val isCurrentSceneShade = currentScene.isShade()
+ // This is true when moving into one of the shade scenes when a non-shade scene.
+ val isTransitioningToShade =
+ transitionState is ObservableTransitionState.Transition &&
+ !transitionState.fromScene.isShade() &&
+ transitionState.toScene.isShade()
+
+ // This is true after completing a transition to communal.
+ val isIdleOnCommunal = transitionState.isIdle(Scenes.Communal)
+
+ // This is true during the process of an unlock of the device.
+ // TODO(b/330587738): add support for remote unlock animations. If such an
+ // animation is underway, unlocking should be true.
+ val unlocking =
+ isOnKeyguard &&
+ (biometricUnlockState.mode == BiometricUnlockMode.WAKE_AND_UNLOCK ||
+ isTransitioningAwayFromKeyguard)
+
+ if (alternateBouncerInteractor.isVisibleState()) {
+ // This will cancel the keyguardFadingAway animation if it is running. We need
+ // to do
+ // this as otherwise it can remain pending and leave keyguard in a weird state.
+ onKeyguardFadedAway(isTransitioningAwayFromKeyguard)
+ if (!isTransitioningToShade) {
+ // Safeguard which prevents the scrim from being stuck in the wrong
+ // state
+ Model(scrimState = ScrimState.KEYGUARD, unlocking = unlocking)
+ } else {
+ // Assume scrim state for shade is already correct and do nothing
+ null
+ }
+ } else if (isCurrentSceneBouncer && !unlocking) {
+ // Bouncer needs the front scrim when it's on top of an activity, tapping on a
+ // notification, editing QS or being dismissed by
+ // FLAG_DISMISS_KEYGUARD_ACTIVITY.
+ Model(
+ scrimState =
+ if (statusBarKeyguardViewManager.primaryBouncerNeedsScrimming()) {
+ ScrimState.BOUNCER_SCRIMMED
+ } else {
+ ScrimState.BOUNCER
+ },
+ unlocking = false,
+ )
+ } else if (isBrightnessMirrorVisible) {
+ Model(scrimState = ScrimState.BRIGHTNESS_MIRROR, unlocking = unlocking)
+ } else if (isCurrentSceneShade && !isDeviceEntered) {
+ Model(scrimState = ScrimState.SHADE_LOCKED, unlocking = unlocking)
+ } else if (isPulsing) {
+ Model(scrimState = ScrimState.PULSING, unlocking = unlocking)
+ } else if (hasPendingScreenOffCallback) {
+ Model(scrimState = ScrimState.OFF, unlocking = unlocking)
+ } else if (isDozing && !unlocking) {
+ // This will cancel the keyguardFadingAway animation if it is running. We need
+ // to do
+ // this as otherwise it can remain pending and leave keyguard in a weird state.
+ onKeyguardFadedAway(isTransitioningAwayFromKeyguard)
+ Model(scrimState = ScrimState.AOD, unlocking = false)
+ } else if (isIdleOnCommunal) {
+ if (isOnKeyguard && isDreaming && !unlocking) {
+ Model(scrimState = ScrimState.GLANCEABLE_HUB_OVER_DREAM, unlocking = false)
+ } else {
+ Model(scrimState = ScrimState.GLANCEABLE_HUB, unlocking = unlocking)
+ }
+ } else if (isOnKeyguard && !unlocking && !isOccluded) {
+ Model(scrimState = ScrimState.KEYGUARD, unlocking = false)
+ } else if (isOnKeyguard && !unlocking && isDreaming) {
+ Model(scrimState = ScrimState.DREAMING, unlocking = false)
+ } else {
+ Model(scrimState = ScrimState.UNLOCKED, unlocking = unlocking)
+ }
+ }
+ .onEach { model ->
+ if (model != null) {
+ scrimController.setExpansionAffectsAlpha(!model.unlocking)
+ }
+ }
+ .map { model -> model?.scrimState }
+
+ override fun start() {
+ if (!SceneContainerFlag.isEnabled) {
+ return
+ }
+
+ hydrateScrimState()
+ }
+
+ private fun hydrateScrimState() {
+ applicationScope.launch {
+ scrimState.filterNotNull().collect { scrimState ->
+ scrimController.transitionTo(scrimState)
+ }
+ }
+ }
+
+ private fun onKeyguardFadedAway(isKeyguardGoingAway: Boolean) {
+ if (isKeyguardGoingAway) {
+ statusBarKeyguardViewManager.onKeyguardFadedAway()
+ }
+ }
+
+ private fun SceneKey.isKeyguard(): Boolean {
+ return this == Scenes.Lockscreen || this == Scenes.Bouncer
+ }
+
+ private fun SceneKey.isShade(): Boolean {
+ return this == Scenes.Shade ||
+ this == Scenes.QuickSettings ||
+ this == Scenes.NotificationsShade ||
+ this == Scenes.QuickSettingsShade
+ }
+
+ private data class Model(
+ val scrimState: ScrimState,
+ val unlocking: Boolean,
+ )
+}
diff --git a/packages/SystemUI/src/com/android/systemui/settings/brightness/BrightnessController.java b/packages/SystemUI/src/com/android/systemui/settings/brightness/BrightnessController.java
index 37f2a21..49810762 100644
--- a/packages/SystemUI/src/com/android/systemui/settings/brightness/BrightnessController.java
+++ b/packages/SystemUI/src/com/android/systemui/settings/brightness/BrightnessController.java
@@ -137,14 +137,14 @@
public void startObserving() {
if (!mObserving) {
mObserving = true;
- mSecureSettings.registerContentObserverForUser(
+ mSecureSettings.registerContentObserverForUserSync(
BRIGHTNESS_MODE_URI,
false, this, UserHandle.USER_ALL);
}
}
public void stopObserving() {
- mSecureSettings.unregisterContentObserver(this);
+ mSecureSettings.unregisterContentObserverSync(this);
mObserving = false;
}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/ImmersiveModeConfirmation.java b/packages/SystemUI/src/com/android/systemui/statusbar/ImmersiveModeConfirmation.java
index 95768e5..2dfc920 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/ImmersiveModeConfirmation.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/ImmersiveModeConfirmation.java
@@ -318,10 +318,10 @@
};
// Register to listen for changes in Settings.Secure settings.
- mSecureSettings.registerContentObserverForUser(
+ mSecureSettings.registerContentObserverForUserSync(
Settings.Secure.IMMERSIVE_MODE_CONFIRMATIONS, mContentObserver,
UserHandle.USER_CURRENT);
- mSecureSettings.registerContentObserverForUser(
+ mSecureSettings.registerContentObserverForUserSync(
Settings.Secure.USER_SETUP_COMPLETE, mContentObserver,
UserHandle.USER_CURRENT);
}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/inflation/NotifUiAdjustmentProvider.kt b/packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/inflation/NotifUiAdjustmentProvider.kt
index 4c2ef83..4c82bc1 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/inflation/NotifUiAdjustmentProvider.kt
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/inflation/NotifUiAdjustmentProvider.kt
@@ -37,11 +37,13 @@
import javax.inject.Inject
/**
- * A class which provides an adjustment object to the preparation coordinator which is uses
- * to ensure that notifications are reinflated when ranking-derived information changes.
+ * A class which provides an adjustment object to the preparation coordinator which is uses to
+ * ensure that notifications are reinflated when ranking-derived information changes.
*/
@SysUISingleton
-class NotifUiAdjustmentProvider @Inject constructor(
+class NotifUiAdjustmentProvider
+@Inject
+constructor(
@Main private val handler: Handler,
private val secureSettings: SecureSettings,
private val lockscreenUserManager: NotificationLockscreenUserManager,
@@ -53,14 +55,13 @@
private val dirtyListeners = ListenerSet<Runnable>()
private var isSnoozeSettingsEnabled = false
- /**
- * Update the snooze enabled value on user switch
- */
- private val userTrackerCallback = object : UserTracker.Callback {
- override fun onUserChanged(newUser: Int, userContext: Context) {
- updateSnoozeEnabled()
+ /** Update the snooze enabled value on user switch */
+ private val userTrackerCallback =
+ object : UserTracker.Callback {
+ override fun onUserChanged(newUser: Int, userContext: Context) {
+ updateSnoozeEnabled()
+ }
}
- }
init {
userTracker.addCallback(userTrackerCallback, HandlerExecutor(handler))
@@ -75,7 +76,7 @@
)
}
updateSnoozeEnabled()
- secureSettings.registerContentObserverForUser(
+ secureSettings.registerContentObserverForUserSync(
SHOW_NOTIFICATION_SNOOZE,
settingsObserver,
UserHandle.USER_ALL
@@ -93,7 +94,7 @@
onSensitiveStateChangedListener
)
}
- secureSettings.unregisterContentObserver(settingsObserver)
+ secureSettings.unregisterContentObserverSync(settingsObserver)
}
}
@@ -104,12 +105,13 @@
private val onSensitiveStateChangedListener = Runnable { dirtyListeners.forEach(Runnable::run) }
- private val settingsObserver = object : ContentObserver(handler) {
- override fun onChange(selfChange: Boolean) {
- updateSnoozeEnabled()
- dirtyListeners.forEach(Runnable::run)
+ private val settingsObserver =
+ object : ContentObserver(handler) {
+ override fun onChange(selfChange: Boolean) {
+ updateSnoozeEnabled()
+ dirtyListeners.forEach(Runnable::run)
+ }
}
- }
private fun updateSnoozeEnabled() {
isSnoozeSettingsEnabled =
@@ -126,22 +128,23 @@
}
/**
- * Returns a adjustment object for the given entry. This can be compared to a previous instance
+ * Returns a adjustment object for the given entry. This can be compared to a previous instance
* from the same notification using [NotifUiAdjustment.needReinflate] to determine if it should
* be reinflated.
*/
- fun calculateAdjustment(entry: NotificationEntry) = NotifUiAdjustment(
- key = entry.key,
- smartActions = entry.ranking.smartActions,
- smartReplies = entry.ranking.smartReplies,
- isConversation = entry.ranking.isConversation,
- isSnoozeEnabled = isSnoozeSettingsEnabled && !entry.isCanceled,
- isMinimized = isEntryMinimized(entry),
- needsRedaction =
- lockscreenUserManager.needsRedaction(entry) ||
- (screenshareNotificationHiding() &&
- sensitiveNotifProtectionController.shouldProtectNotification(entry)),
- isChildInGroup = entry.hasEverBeenGroupChild(),
- isGroupSummary = entry.hasEverBeenGroupSummary(),
- )
+ fun calculateAdjustment(entry: NotificationEntry) =
+ NotifUiAdjustment(
+ key = entry.key,
+ smartActions = entry.ranking.smartActions,
+ smartReplies = entry.ranking.smartReplies,
+ isConversation = entry.ranking.isConversation,
+ isSnoozeEnabled = isSnoozeSettingsEnabled && !entry.isCanceled,
+ isMinimized = isEntryMinimized(entry),
+ needsRedaction =
+ lockscreenUserManager.needsRedaction(entry) ||
+ (screenshareNotificationHiding() &&
+ sensitiveNotifProtectionController.shouldProtectNotification(entry)),
+ isChildInGroup = entry.hasEverBeenGroupChild(),
+ isGroupSummary = entry.hasEverBeenGroupSummary(),
+ )
}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/interruption/CommonVisualInterruptionSuppressors.kt b/packages/SystemUI/src/com/android/systemui/statusbar/notification/interruption/CommonVisualInterruptionSuppressors.kt
index 42a5bdf..f84b5f4 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/interruption/CommonVisualInterruptionSuppressors.kt
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/interruption/CommonVisualInterruptionSuppressors.kt
@@ -33,8 +33,8 @@
import android.provider.Settings
import android.provider.Settings.Global.HEADS_UP_NOTIFICATIONS_ENABLED
import android.provider.Settings.Global.HEADS_UP_OFF
+import com.android.internal.logging.UiEvent
import com.android.internal.logging.UiEventLogger
-import com.android.internal.logging.UiEvent;
import com.android.systemui.dagger.qualifiers.Main
import com.android.systemui.plugins.statusbar.StatusBarStateController
import com.android.systemui.settings.UserTracker
@@ -86,7 +86,7 @@
}
}
- globalSettings.registerContentObserver(
+ globalSettings.registerContentObserverSync(
globalSettings.getUriFor(HEADS_UP_NOTIFICATIONS_ENABLED),
/* notifyForDescendants = */ true,
observer
@@ -94,7 +94,7 @@
// QQQ: Do we need to register for SETTING_HEADS_UP_TICKER? It seems unused.
- observer.onChange(/* selfChange = */ true)
+ observer.onChange(/* selfChange= */ true)
}
}
@@ -243,6 +243,7 @@
override fun shouldSuppress(entry: NotificationEntry) =
keyguardNotificationVisibilityProvider.shouldHideNotification(entry)
}
+
class AvalancheSuppressor(
private val avalancheProvider: AvalancheProvider,
private val systemClock: SystemClock,
@@ -268,38 +269,33 @@
SUPPRESS
}
- enum class AvalancheEvent(private val id: Int) : UiEventLogger.UiEventEnum {
- @UiEvent(doc = "An avalanche event occurred but this notification was suppressed by a " +
- "non-avalanche suppressor.")
- START(1802),
-
- @UiEvent(doc = "HUN was suppressed in avalanche.")
- SUPPRESS(1803),
-
- @UiEvent(doc = "HUN allowed during avalanche because it is high priority.")
- ALLOW_CONVERSATION_AFTER_AVALANCHE(1804),
-
- @UiEvent(doc = "HUN allowed during avalanche because it is a high priority conversation.")
- ALLOW_HIGH_PRIORITY_CONVERSATION_ANY_TIME(1805),
-
- @UiEvent(doc = "HUN allowed during avalanche because it is a call.")
- ALLOW_CALLSTYLE(1806),
-
- @UiEvent(doc = "HUN allowed during avalanche because it is a calendar notification.")
- ALLOW_CATEGORY_REMINDER(1807),
-
- @UiEvent(doc = "HUN allowed during avalanche because it is a calendar notification.")
- ALLOW_CATEGORY_EVENT(1808),
-
- @UiEvent(doc = "HUN allowed during avalanche because it has a full screen intent and " +
- "the full screen intent permission is granted.")
- ALLOW_FSI_WITH_PERMISSION_ON(1809),
-
- @UiEvent(doc = "HUN allowed during avalanche because it is colorized.")
- ALLOW_COLORIZED(1810),
-
- @UiEvent(doc = "HUN allowed during avalanche because it is an emergency notification.")
- ALLOW_EMERGENCY(1811);
+ enum class AvalancheEvent(private val id: Int) : UiEventLogger.UiEventEnum {
+ @UiEvent(
+ doc =
+ "An avalanche event occurred but this notification was suppressed by a " +
+ "non-avalanche suppressor."
+ )
+ START(1802),
+ @UiEvent(doc = "HUN was suppressed in avalanche.") SUPPRESS(1803),
+ @UiEvent(doc = "HUN allowed during avalanche because it is high priority.")
+ ALLOW_CONVERSATION_AFTER_AVALANCHE(1804),
+ @UiEvent(doc = "HUN allowed during avalanche because it is a high priority conversation.")
+ ALLOW_HIGH_PRIORITY_CONVERSATION_ANY_TIME(1805),
+ @UiEvent(doc = "HUN allowed during avalanche because it is a call.") ALLOW_CALLSTYLE(1806),
+ @UiEvent(doc = "HUN allowed during avalanche because it is a calendar notification.")
+ ALLOW_CATEGORY_REMINDER(1807),
+ @UiEvent(doc = "HUN allowed during avalanche because it is a calendar notification.")
+ ALLOW_CATEGORY_EVENT(1808),
+ @UiEvent(
+ doc =
+ "HUN allowed during avalanche because it has a full screen intent and " +
+ "the full screen intent permission is granted."
+ )
+ ALLOW_FSI_WITH_PERMISSION_ON(1809),
+ @UiEvent(doc = "HUN allowed during avalanche because it is colorized.")
+ ALLOW_COLORIZED(1810),
+ @UiEvent(doc = "HUN allowed during avalanche because it is an emergency notification.")
+ ALLOW_EMERGENCY(1811);
override fun getId(): Int {
return id
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/interruption/KeyguardNotificationVisibilityProvider.kt b/packages/SystemUI/src/com/android/systemui/statusbar/notification/interruption/KeyguardNotificationVisibilityProvider.kt
index 332ece4..c7548aa 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/interruption/KeyguardNotificationVisibilityProvider.kt
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/interruption/KeyguardNotificationVisibilityProvider.kt
@@ -14,7 +14,6 @@
import com.android.systemui.dagger.SysUISingleton
import com.android.systemui.dagger.qualifiers.Main
import com.android.systemui.flags.FeatureFlagsClassic
-import com.android.systemui.flags.Flags
import com.android.systemui.plugins.statusbar.StatusBarStateController
import com.android.systemui.settings.UserTracker
import com.android.systemui.statusbar.NotificationLockscreenUserManager
@@ -41,8 +40,8 @@
/** Determines if notifications should be visible based on the state of the keyguard. */
interface KeyguardNotificationVisibilityProvider {
/**
- * Determines if the given notification should be hidden based on the current keyguard state.
- * If a [Consumer] registered via [addOnStateChangedListener] is invoked, the results of this
+ * Determines if the given notification should be hidden based on the current keyguard state. If
+ * a [Consumer] registered via [addOnStateChangedListener] is invoked, the results of this
* method may no longer be valid and should be re-queried.
*/
fun shouldHideNotification(entry: NotificationEntry): Boolean
@@ -61,8 +60,9 @@
@Module
interface KeyguardNotificationVisibilityProviderImplModule {
@Binds
- fun bindImpl(impl: KeyguardNotificationVisibilityProviderImpl):
- KeyguardNotificationVisibilityProvider
+ fun bindImpl(
+ impl: KeyguardNotificationVisibilityProviderImpl
+ ): KeyguardNotificationVisibilityProvider
@Binds
@IntoMap
@@ -71,7 +71,9 @@
}
@SysUISingleton
-class KeyguardNotificationVisibilityProviderImpl @Inject constructor(
+class KeyguardNotificationVisibilityProviderImpl
+@Inject
+constructor(
@Main private val handler: Handler,
private val keyguardStateController: KeyguardStateController,
private val lockscreenUserManager: NotificationLockscreenUserManager,
@@ -84,76 +86,88 @@
private val featureFlags: FeatureFlagsClassic
) : CoreStartable, KeyguardNotificationVisibilityProvider {
private val showSilentNotifsUri =
- secureSettings.getUriFor(Settings.Secure.LOCK_SCREEN_SHOW_SILENT_NOTIFICATIONS)
+ secureSettings.getUriFor(Settings.Secure.LOCK_SCREEN_SHOW_SILENT_NOTIFICATIONS)
private val onStateChangedListeners = ListenerSet<Consumer<String>>()
private var hideSilentNotificationsOnLockscreen: Boolean = false
- private val userTrackerCallback = object : UserTracker.Callback {
- override fun onUserChanged(newUser: Int, userContext: Context) {
- readShowSilentNotificationSetting()
- if (isLockedOrLocking) {
- // maybe public mode changed
- notifyStateChanged("onUserSwitched")
+ private val userTrackerCallback =
+ object : UserTracker.Callback {
+ override fun onUserChanged(newUser: Int, userContext: Context) {
+ readShowSilentNotificationSetting()
+ if (isLockedOrLocking) {
+ // maybe public mode changed
+ notifyStateChanged("onUserSwitched")
+ }
}
}
- }
override fun start() {
readShowSilentNotificationSetting()
- keyguardStateController.addCallback(object : KeyguardStateController.Callback {
- override fun onUnlockedChanged() {
- notifyStateChanged("onUnlockedChanged")
- }
+ keyguardStateController.addCallback(
+ object : KeyguardStateController.Callback {
+ override fun onUnlockedChanged() {
+ notifyStateChanged("onUnlockedChanged")
+ }
- override fun onKeyguardShowingChanged() {
- notifyStateChanged("onKeyguardShowingChanged")
+ override fun onKeyguardShowingChanged() {
+ notifyStateChanged("onKeyguardShowingChanged")
+ }
}
- })
- keyguardUpdateMonitor.registerCallback(object : KeyguardUpdateMonitorCallback() {
- override fun onStrongAuthStateChanged(userId: Int) {
- notifyStateChanged("onStrongAuthStateChanged")
+ )
+ keyguardUpdateMonitor.registerCallback(
+ object : KeyguardUpdateMonitorCallback() {
+ override fun onStrongAuthStateChanged(userId: Int) {
+ notifyStateChanged("onStrongAuthStateChanged")
+ }
}
- })
+ )
// register lockscreen settings changed callbacks:
- val settingsObserver: ContentObserver = object : ContentObserver(handler) {
- override fun onChange(selfChange: Boolean, uri: Uri?) {
- if (uri == showSilentNotifsUri) {
- readShowSilentNotificationSetting()
- }
- if (isLockedOrLocking) {
- notifyStateChanged("Settings $uri changed")
+ val settingsObserver: ContentObserver =
+ object : ContentObserver(handler) {
+ override fun onChange(selfChange: Boolean, uri: Uri?) {
+ if (uri == showSilentNotifsUri) {
+ readShowSilentNotificationSetting()
+ }
+ if (isLockedOrLocking) {
+ notifyStateChanged("Settings $uri changed")
+ }
}
}
- }
- secureSettings.registerContentObserverForUser(
- Settings.Secure.LOCK_SCREEN_SHOW_NOTIFICATIONS,
- settingsObserver,
- UserHandle.USER_ALL)
+ secureSettings.registerContentObserverForUserSync(
+ Settings.Secure.LOCK_SCREEN_SHOW_NOTIFICATIONS,
+ settingsObserver,
+ UserHandle.USER_ALL
+ )
- secureSettings.registerContentObserverForUser(
- Settings.Secure.LOCK_SCREEN_ALLOW_PRIVATE_NOTIFICATIONS,
- true,
- settingsObserver,
- UserHandle.USER_ALL)
+ secureSettings.registerContentObserverForUserSync(
+ Settings.Secure.LOCK_SCREEN_ALLOW_PRIVATE_NOTIFICATIONS,
+ true,
+ settingsObserver,
+ UserHandle.USER_ALL
+ )
- globalSettings.registerContentObserver(Settings.Global.ZEN_MODE, settingsObserver)
+ globalSettings.registerContentObserverSync(Settings.Global.ZEN_MODE, settingsObserver)
- secureSettings.registerContentObserverForUser(
- Settings.Secure.LOCK_SCREEN_SHOW_SILENT_NOTIFICATIONS,
- settingsObserver,
- UserHandle.USER_ALL)
+ secureSettings.registerContentObserverForUserSync(
+ Settings.Secure.LOCK_SCREEN_SHOW_SILENT_NOTIFICATIONS,
+ settingsObserver,
+ UserHandle.USER_ALL
+ )
// register (maybe) public mode changed callbacks:
- statusBarStateController.addCallback(object : StatusBarStateController.StateListener {
- override fun onStateChanged(newState: Int) {
- notifyStateChanged("onStatusBarStateChanged")
+ statusBarStateController.addCallback(
+ object : StatusBarStateController.StateListener {
+ override fun onStateChanged(newState: Int) {
+ notifyStateChanged("onStatusBarStateChanged")
+ }
+
+ override fun onUpcomingStateChanged(state: Int) {
+ notifyStateChanged("onStatusBarUpcomingStateChanged")
+ }
}
- override fun onUpcomingStateChanged(state: Int) {
- notifyStateChanged("onStatusBarUpcomingStateChanged")
- }
- })
+ )
userTracker.addCallback(userTrackerCallback, HandlerExecutor(handler))
}
@@ -169,45 +183,48 @@
onStateChangedListeners.forEach { it.accept(reason) }
}
- override fun shouldHideNotification(entry: NotificationEntry): Boolean = when {
- // Keyguard state doesn't matter if the keyguard is not showing.
- !isLockedOrLocking -> false
- // Notifications not allowed on the lockscreen, always hide.
- !lockscreenUserManager.shouldShowLockscreenNotifications() -> true
- // User settings do not allow this notification on the lockscreen, so hide it.
- userSettingsDisallowNotification(entry) -> true
- // Entry is explicitly marked SECRET, so hide it.
- entry.sbn.notification.visibility == VISIBILITY_SECRET -> true
- // if entry is silent, apply custom logic to see if should hide
- shouldHideIfEntrySilent(entry) -> true
- else -> false
- }
+ override fun shouldHideNotification(entry: NotificationEntry): Boolean =
+ when {
+ // Keyguard state doesn't matter if the keyguard is not showing.
+ !isLockedOrLocking -> false
+ // Notifications not allowed on the lockscreen, always hide.
+ !lockscreenUserManager.shouldShowLockscreenNotifications() -> true
+ // User settings do not allow this notification on the lockscreen, so hide it.
+ userSettingsDisallowNotification(entry) -> true
+ // Entry is explicitly marked SECRET, so hide it.
+ entry.sbn.notification.visibility == VISIBILITY_SECRET -> true
+ // if entry is silent, apply custom logic to see if should hide
+ shouldHideIfEntrySilent(entry) -> true
+ else -> false
+ }
- private fun shouldHideIfEntrySilent(entry: ListEntry): Boolean = when {
- // Show if explicitly high priority (not hidden)
- highPriorityProvider.isExplicitlyHighPriority(entry) -> false
- // Ambient notifications are hidden always from lock screen
- entry.representativeEntry?.isAmbient == true -> true
- // [Now notification is silent]
- // Hide regardless of parent priority if user wants silent notifs hidden
- hideSilentNotificationsOnLockscreen -> true
- // Parent priority is high enough to be shown on the lockscreen, do not hide.
- entry.parent?.let(::shouldHideIfEntrySilent) == false -> false
- // Show when silent notifications are allowed on lockscreen
- else -> false
- }
+ private fun shouldHideIfEntrySilent(entry: ListEntry): Boolean =
+ when {
+ // Show if explicitly high priority (not hidden)
+ highPriorityProvider.isExplicitlyHighPriority(entry) -> false
+ // Ambient notifications are hidden always from lock screen
+ entry.representativeEntry?.isAmbient == true -> true
+ // [Now notification is silent]
+ // Hide regardless of parent priority if user wants silent notifs hidden
+ hideSilentNotificationsOnLockscreen -> true
+ // Parent priority is high enough to be shown on the lockscreen, do not hide.
+ entry.parent?.let(::shouldHideIfEntrySilent) == false -> false
+ // Show when silent notifications are allowed on lockscreen
+ else -> false
+ }
private fun userSettingsDisallowNotification(entry: NotificationEntry): Boolean {
- fun disallowForUser(user: Int) = when {
- // user is in lockdown, always disallow
- keyguardUpdateMonitor.isUserInLockdown(user) -> true
- // device isn't public, no need to check public-related settings, so allow
- !lockscreenUserManager.isLockscreenPublicMode(user) -> false
- // entry is meant to be secret on the lockscreen, disallow
- isRankingVisibilitySecret(entry) -> true
- // disallow if user disallows notifications in public
- else -> !lockscreenUserManager.userAllowsNotificationsInPublic(user)
- }
+ fun disallowForUser(user: Int) =
+ when {
+ // user is in lockdown, always disallow
+ keyguardUpdateMonitor.isUserInLockdown(user) -> true
+ // device isn't public, no need to check public-related settings, so allow
+ !lockscreenUserManager.isLockscreenPublicMode(user) -> false
+ // entry is meant to be secret on the lockscreen, disallow
+ isRankingVisibilitySecret(entry) -> true
+ // disallow if user disallows notifications in public
+ else -> !lockscreenUserManager.userAllowsNotificationsInPublic(user)
+ }
val currentUser = lockscreenUserManager.currentUserId
val notifUser = entry.sbn.user.identifier
return when {
@@ -222,28 +239,35 @@
// ranking.lockscreenVisibilityOverride contains possibly out of date DPC and Setting
// info, and NotificationLockscreenUserManagerImpl is already listening for updates
// to those
- return entry.ranking.channel != null && entry.ranking.channel.lockscreenVisibility ==
- VISIBILITY_SECRET
+ return entry.ranking.channel != null &&
+ entry.ranking.channel.lockscreenVisibility == VISIBILITY_SECRET
}
- override fun dump(pw: PrintWriter, args: Array<out String>) = pw.asIndenting().run {
- println("isLockedOrLocking", isLockedOrLocking)
- withIncreasedIndent {
- println("keyguardStateController.isShowing", keyguardStateController.isShowing)
- println("statusBarStateController.currentOrUpcomingState",
- statusBarStateController.currentOrUpcomingState)
+ override fun dump(pw: PrintWriter, args: Array<out String>) =
+ pw.asIndenting().run {
+ println("isLockedOrLocking", isLockedOrLocking)
+ withIncreasedIndent {
+ println("keyguardStateController.isShowing", keyguardStateController.isShowing)
+ println(
+ "statusBarStateController.currentOrUpcomingState",
+ statusBarStateController.currentOrUpcomingState
+ )
+ }
+ println("hideSilentNotificationsOnLockscreen", hideSilentNotificationsOnLockscreen)
}
- println("hideSilentNotificationsOnLockscreen", hideSilentNotificationsOnLockscreen)
- }
- private val isLockedOrLocking get() =
- keyguardStateController.isShowing ||
+ private val isLockedOrLocking
+ get() =
+ keyguardStateController.isShowing ||
statusBarStateController.currentOrUpcomingState == StatusBarState.KEYGUARD
private fun readShowSilentNotificationSetting() {
val showSilentNotifs =
- secureSettings.getBoolForUser(Settings.Secure.LOCK_SCREEN_SHOW_SILENT_NOTIFICATIONS,
- false, UserHandle.USER_CURRENT)
+ secureSettings.getBoolForUser(
+ Settings.Secure.LOCK_SCREEN_SHOW_SILENT_NOTIFICATIONS,
+ false,
+ UserHandle.USER_CURRENT
+ )
hideSilentNotificationsOnLockscreen = !showSilentNotifs
}
}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/interruption/NotificationInterruptStateProviderImpl.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/interruption/NotificationInterruptStateProviderImpl.java
index 74925c8..fea360d 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/interruption/NotificationInterruptStateProviderImpl.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/interruption/NotificationInterruptStateProviderImpl.java
@@ -171,11 +171,11 @@
};
if (ENABLE_HEADS_UP) {
- mGlobalSettings.registerContentObserver(
+ mGlobalSettings.registerContentObserverSync(
mGlobalSettings.getUriFor(HEADS_UP_NOTIFICATIONS_ENABLED),
true,
headsUpObserver);
- mGlobalSettings.registerContentObserver(
+ mGlobalSettings.registerContentObserverSync(
mGlobalSettings.getUriFor(SETTING_HEADS_UP_TICKER), true,
headsUpObserver);
}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/NotificationSettingsController.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/NotificationSettingsController.java
index a17c066..30dbfed 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/NotificationSettingsController.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/NotificationSettingsController.java
@@ -92,9 +92,9 @@
synchronized (mListeners) {
if (mListeners.size() > 0) {
- mSecureSettings.unregisterContentObserver(mContentObserver);
+ mSecureSettings.unregisterContentObserverSync(mContentObserver);
for (Uri uri : mListeners.keySet()) {
- mSecureSettings.registerContentObserverForUser(
+ mSecureSettings.registerContentObserverForUserSync(
uri, false, mContentObserver, newUser);
}
}
@@ -131,7 +131,7 @@
mListeners.put(uri, currentListeners);
if (currentListeners.size() == 1) {
mBackgroundHandler.post(() -> {
- mSecureSettings.registerContentObserverForUser(
+ mSecureSettings.registerContentObserverForUserSync(
uri, false, mContentObserver, mUserTracker.getUserId());
});
}
@@ -159,7 +159,7 @@
if (mListeners.size() == 0) {
mBackgroundHandler.post(() -> {
- mSecureSettings.unregisterContentObserver(mContentObserver);
+ mSecureSettings.unregisterContentObserverSync(mContentObserver);
});
}
}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/shared/NotificationRowContentBinderRefactor.kt b/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/shared/NotificationRowContentBinderRefactor.kt
new file mode 100644
index 0000000..997acdd
--- /dev/null
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/shared/NotificationRowContentBinderRefactor.kt
@@ -0,0 +1,53 @@
+/*
+ * 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.systemui.statusbar.notification.row.shared
+
+import com.android.systemui.Flags
+import com.android.systemui.flags.FlagToken
+import com.android.systemui.flags.RefactorFlagUtils
+
+/** Helper for reading or using the notification row content binder refactor flag state. */
+@Suppress("NOTHING_TO_INLINE")
+object NotificationRowContentBinderRefactor {
+ /** The aconfig flag name */
+ const val FLAG_NAME = Flags.FLAG_NOTIFICATION_ROW_CONTENT_BINDER_REFACTOR
+
+ /** A token used for dependency declaration */
+ val token: FlagToken
+ get() = FlagToken(FLAG_NAME, isEnabled)
+
+ /** Is the refactor enabled */
+ @JvmStatic
+ inline val isEnabled
+ get() = Flags.notificationRowContentBinderRefactor()
+
+ /**
+ * Called to ensure code is only run when the flag is enabled. This protects users from the
+ * unintended behaviors caused by accidentally running new logic, while also crashing on an eng
+ * build to ensure that the refactor author catches issues in testing.
+ */
+ @JvmStatic
+ inline fun isUnexpectedlyInLegacyMode() =
+ RefactorFlagUtils.isUnexpectedlyInLegacyMode(isEnabled, FLAG_NAME)
+
+ /**
+ * Called to ensure code is only run when the flag is disabled. This will throw an exception if
+ * the flag is enabled to ensure that the refactor author catches issues in testing.
+ */
+ @JvmStatic
+ inline fun assertInLegacyMode() = RefactorFlagUtils.assertInLegacyMode(isEnabled, FLAG_NAME)
+}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/CentralSurfacesImpl.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/CentralSurfacesImpl.java
index 78a8036..7567f36 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/CentralSurfacesImpl.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/CentralSurfacesImpl.java
@@ -2800,6 +2800,10 @@
@Override
@VisibleForTesting
public void updateScrimController() {
+ if (SceneContainerFlag.isEnabled()) {
+ return;
+ }
+
Trace.beginSection("CentralSurfaces#updateScrimController");
boolean unlocking = mKeyguardStateController.isShowing() && (
@@ -2822,15 +2826,15 @@
// Assume scrim state for shade is already correct and do nothing
} else {
// Safeguard which prevents the scrim from being stuck in the wrong state
- mScrimController.transitionTo(ScrimState.KEYGUARD);
+ mScrimController.legacyTransitionTo(ScrimState.KEYGUARD);
}
} else {
if ((!mKeyguardStateController.isOccluded() || mShadeSurface.isPanelExpanded())
&& (mState == StatusBarState.SHADE || mState == StatusBarState.SHADE_LOCKED
|| mTransitionToFullShadeProgress > 0f)) {
- mScrimController.transitionTo(ScrimState.AUTH_SCRIMMED_SHADE);
+ mScrimController.legacyTransitionTo(ScrimState.AUTH_SCRIMMED_SHADE);
} else {
- mScrimController.transitionTo(ScrimState.AUTH_SCRIMMED);
+ mScrimController.legacyTransitionTo(ScrimState.AUTH_SCRIMMED);
}
}
// This will cancel the keyguardFadingAway animation if it is running. We need to do
@@ -2842,40 +2846,40 @@
// FLAG_DISMISS_KEYGUARD_ACTIVITY.
ScrimState state = mStatusBarKeyguardViewManager.primaryBouncerNeedsScrimming()
? ScrimState.BOUNCER_SCRIMMED : ScrimState.BOUNCER;
- mScrimController.transitionTo(state);
+ mScrimController.legacyTransitionTo(state);
} else if (mBrightnessMirrorVisible) {
- mScrimController.transitionTo(ScrimState.BRIGHTNESS_MIRROR);
+ mScrimController.legacyTransitionTo(ScrimState.BRIGHTNESS_MIRROR);
} else if (mState == StatusBarState.SHADE_LOCKED) {
- mScrimController.transitionTo(ScrimState.SHADE_LOCKED);
+ mScrimController.legacyTransitionTo(ScrimState.SHADE_LOCKED);
} else if (mDozeServiceHost.isPulsing()) {
- mScrimController.transitionTo(ScrimState.PULSING,
+ mScrimController.legacyTransitionTo(ScrimState.PULSING,
mDozeScrimController.getScrimCallback());
} else if (mDozeServiceHost.hasPendingScreenOffCallback()) {
- mScrimController.transitionTo(ScrimState.OFF, new ScrimController.Callback() {
+ mScrimController.legacyTransitionTo(ScrimState.OFF, new ScrimController.Callback() {
@Override
public void onFinished() {
mDozeServiceHost.executePendingScreenOffCallback();
}
});
} else if (mDozing && !unlocking) {
- mScrimController.transitionTo(ScrimState.AOD);
+ mScrimController.legacyTransitionTo(ScrimState.AOD);
// This will cancel the keyguardFadingAway animation if it is running. We need to do
// this as otherwise it can remain pending and leave keyguard in a weird state.
mUnlockScrimCallback.onCancelled();
} else if (mIsIdleOnCommunal) {
if (dreaming) {
- mScrimController.transitionTo(ScrimState.GLANCEABLE_HUB_OVER_DREAM);
+ mScrimController.legacyTransitionTo(ScrimState.GLANCEABLE_HUB_OVER_DREAM);
} else {
- mScrimController.transitionTo(ScrimState.GLANCEABLE_HUB);
+ mScrimController.legacyTransitionTo(ScrimState.GLANCEABLE_HUB);
}
} else if (mKeyguardStateController.isShowing()
&& !mKeyguardStateController.isOccluded()
&& !unlocking) {
- mScrimController.transitionTo(ScrimState.KEYGUARD);
+ mScrimController.legacyTransitionTo(ScrimState.KEYGUARD);
} else if (dreaming) {
- mScrimController.transitionTo(ScrimState.DREAMING);
+ mScrimController.legacyTransitionTo(ScrimState.DREAMING);
} else {
- mScrimController.transitionTo(ScrimState.UNLOCKED, mUnlockScrimCallback);
+ mScrimController.legacyTransitionTo(ScrimState.UNLOCKED, mUnlockScrimCallback);
}
updateLightRevealScrimVisibility();
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/DozeServiceHost.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/DozeServiceHost.java
index 77f3706..330383f 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/DozeServiceHost.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/DozeServiceHost.java
@@ -29,6 +29,8 @@
import android.view.MotionEvent;
import android.view.View;
+import androidx.annotation.Nullable;
+
import com.android.internal.annotations.VisibleForTesting;
import com.android.keyguard.KeyguardUpdateMonitor;
import com.android.systemui.assist.AssistManager;
@@ -74,6 +76,11 @@
private final PowerManager mPowerManager;
private boolean mAnimateWakeup;
private boolean mIgnoreTouchWhilePulsing;
+ private final HasPendingScreenOffCallbackChangeListener
+ mDefaultHasPendingScreenOffCallbackChangeListener =
+ hasPendingScreenOffCallback -> { /* no op */ };
+ private HasPendingScreenOffCallbackChangeListener mHasPendingScreenOffCallbackChangeListener =
+ mDefaultHasPendingScreenOffCallbackChangeListener;
private Runnable mPendingScreenOffCallback;
@VisibleForTesting
boolean mWakeLockScreenPerformsAuth = SystemProperties.getBoolean(
@@ -434,12 +441,14 @@
Log.w(TAG, "Overlapping onDisplayOffCallback. Ignoring previous one.");
}
mPendingScreenOffCallback = onDisplayOffCallback;
+ mHasPendingScreenOffCallbackChangeListener.onHasPendingScreenOffCallbackChanged(true);
mCentralSurfaces.updateScrimController();
}
@Override
public void cancelGentleSleep() {
mPendingScreenOffCallback = null;
+ mHasPendingScreenOffCallbackChangeListener.onHasPendingScreenOffCallbackChanged(false);
if (mScrimController.getState() == ScrimState.OFF) {
mCentralSurfaces.updateScrimController();
}
@@ -448,11 +457,27 @@
/**
* When the dozing host is waiting for scrims to fade out to change the display state.
*/
- boolean hasPendingScreenOffCallback() {
+ public boolean hasPendingScreenOffCallback() {
return mPendingScreenOffCallback != null;
}
/**
+ * Sets a listener to be notified whenever the result of {@link #hasPendingScreenOffCallback()}
+ * changes.
+ *
+ * <p>Setting the listener automatically notifies the listener inline.
+ */
+ public void setHasPendingScreenOffCallbackChangeListener(
+ @Nullable HasPendingScreenOffCallbackChangeListener listener) {
+ mHasPendingScreenOffCallbackChangeListener = listener != null
+ ? listener
+ : mDefaultHasPendingScreenOffCallbackChangeListener;
+
+ mHasPendingScreenOffCallbackChangeListener.onHasPendingScreenOffCallbackChanged(
+ mPendingScreenOffCallback != null);
+ }
+
+ /**
* Executes an nullifies the pending display state callback.
*
* @see #hasPendingScreenOffCallback()
@@ -464,6 +489,7 @@
}
mPendingScreenOffCallback.run();
mPendingScreenOffCallback = null;
+ mHasPendingScreenOffCallbackChangeListener.onHasPendingScreenOffCallbackChanged(false);
}
boolean shouldAnimateWakeup() {
@@ -524,4 +550,14 @@
}
}
};
+
+ /**
+ * Defines interface for classes that can be notified about changes to having or not having a
+ * pending screen-off callback.
+ */
+ public interface HasPendingScreenOffCallbackChangeListener {
+
+ /** Notifies that there now is or isn't a pending screen-off callback. */
+ void onHasPendingScreenOffCallbackChanged(boolean hasPendingScreenOffCallback);
+ }
}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardStatusBarViewController.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardStatusBarViewController.java
index 6d4301f..e44edcb 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardStatusBarViewController.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardStatusBarViewController.java
@@ -398,7 +398,7 @@
mSystemIconsContainer.setOnHoverListener(hoverListener);
mView.setOnApplyWindowInsetsListener(
(view, windowInsets) -> mView.updateWindowInsets(windowInsets, mInsetsProvider));
- mSecureSettings.registerContentObserverForUser(
+ mSecureSettings.registerContentObserverForUserSync(
Settings.Secure.STATUS_BAR_SHOW_VIBRATE_ICON,
false,
mVolumeSettingObserver,
@@ -416,7 +416,7 @@
mStatusBarStateController.removeCallback(mStatusBarStateListener);
mKeyguardUpdateMonitor.removeCallback(mKeyguardUpdateMonitorCallback);
mDisableStateTracker.stopTracking(mCommandQueue);
- mSecureSettings.unregisterContentObserver(mVolumeSettingObserver);
+ mSecureSettings.unregisterContentObserverSync(mVolumeSettingObserver);
if (mTintedIconManager != null) {
mStatusBarIconController.removeIconGroup(mTintedIconManager);
}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/ScrimController.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/ScrimController.java
index fe001b3..9cece76 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/ScrimController.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/ScrimController.java
@@ -72,6 +72,7 @@
import com.android.systemui.keyguard.ui.viewmodel.AlternateBouncerToGoneTransitionViewModel;
import com.android.systemui.keyguard.ui.viewmodel.PrimaryBouncerToGoneTransitionViewModel;
import com.android.systemui.res.R;
+import com.android.systemui.scene.shared.flag.SceneContainerFlag;
import com.android.systemui.scene.shared.model.Scenes;
import com.android.systemui.scrim.ScrimView;
import com.android.systemui.shade.ShadeViewController;
@@ -319,8 +320,11 @@
mScrimBehind.setViewAlpha(mBehindAlpha);
};
+ @VisibleForTesting
Consumer<TransitionStep> mBouncerToGoneTransition;
+ private boolean mViewsAttached;
+
@Inject
public ScrimController(
LightBarController lightBarController,
@@ -432,6 +436,16 @@
state.prepare(state);
}
+ hydrateStateInternally(behindScrim);
+
+ mViewsAttached = true;
+ }
+
+ private void hydrateStateInternally(ScrimView behindScrim) {
+ if (SceneContainerFlag.isEnabled()) {
+ return;
+ }
+
// Directly control transition to UNLOCKED scrim state from PRIMARY_BOUNCER, and make sure
// to report back that keyguard has faded away. This fixes cases where the scrim state was
// rapidly switching on unlock, due to shifts in state in CentralSurfacesImpl
@@ -443,7 +457,7 @@
if (state == TransitionState.STARTED) {
setExpansionAffectsAlpha(false);
- transitionTo(ScrimState.UNLOCKED);
+ legacyTransitionTo(ScrimState.UNLOCKED);
}
if (state == TransitionState.FINISHED || state == TransitionState.CANCELED) {
@@ -508,10 +522,36 @@
}
public void transitionTo(ScrimState state) {
- transitionTo(state, null);
+ if (SceneContainerFlag.isUnexpectedlyInLegacyMode() || !mViewsAttached) {
+ return;
+ }
+
+ internalTransitionTo(state, null);
}
- public void transitionTo(ScrimState state, Callback callback) {
+ /**
+ * Transitions to the given {@link ScrimState}.
+ *
+ * @deprecated Legacy codepath only. Do not call directly.
+ */
+ @Deprecated
+ public void legacyTransitionTo(ScrimState state) {
+ SceneContainerFlag.assertInLegacyMode();
+ internalTransitionTo(state, null);
+ }
+
+ /**
+ * Transitions to the given {@link ScrimState}.
+ *
+ * @deprecated Legacy codepath only. Do not call directly.
+ */
+ @Deprecated
+ public void legacyTransitionTo(ScrimState state, Callback callback) {
+ SceneContainerFlag.assertInLegacyMode();
+ internalTransitionTo(state, callback);
+ }
+
+ private void internalTransitionTo(ScrimState state, Callback callback) {
if (mIsBouncerToGoneTransitionRunning) {
Log.i(TAG, "Skipping transition to: " + state
+ " while mIsBouncerToGoneTransitionRunning");
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/UnlockedScreenOffAnimationController.kt b/packages/SystemUI/src/com/android/systemui/statusbar/phone/UnlockedScreenOffAnimationController.kt
index 479aef1..c53558e 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/UnlockedScreenOffAnimationController.kt
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/UnlockedScreenOffAnimationController.kt
@@ -23,9 +23,9 @@
import com.android.systemui.keyguard.KeyguardViewMediator
import com.android.systemui.keyguard.MigrateClocksToBlueprint
import com.android.systemui.keyguard.WakefulnessLifecycle
-import com.android.systemui.shade.domain.interactor.ShadeLockscreenInteractor
import com.android.systemui.shade.ShadeViewController
import com.android.systemui.shade.domain.interactor.PanelExpansionInteractor
+import com.android.systemui.shade.domain.interactor.ShadeLockscreenInteractor
import com.android.systemui.statusbar.CircleReveal
import com.android.systemui.statusbar.LightRevealScrim
import com.android.systemui.statusbar.NotificationShadeWindowController
@@ -162,7 +162,7 @@
this.centralSurfaces = centralSurfaces
updateAnimatorDurationScale()
- globalSettings.registerContentObserver(
+ globalSettings.registerContentObserverSync(
Settings.Global.getUriFor(Settings.Global.ANIMATOR_DURATION_SCALE),
/* notify for descendants */ false,
animatorDurationScaleObserver
@@ -376,8 +376,9 @@
// We currently draw both the light reveal scrim, and the AOD UI, in the shade. If it's
// already expanded and showing notifications/QS, the animation looks really messy. For now,
// disable it if the notification panel is expanded.
- if ((!this::centralSurfaces.isInitialized ||
- panelExpansionInteractorLazy.get().isPanelExpanded) &&
+ if (
+ (!this::centralSurfaces.isInitialized ||
+ panelExpansionInteractorLazy.get().isPanelExpanded) &&
// Status bar might be expanded because we have started
// playing the animation already
!isAnimationPlaying()
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/fragment/CollapsedStatusBarFragment.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/fragment/CollapsedStatusBarFragment.java
index aac211a..3d8090d 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/fragment/CollapsedStatusBarFragment.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/fragment/CollapsedStatusBarFragment.java
@@ -80,6 +80,10 @@
import com.android.systemui.util.CarrierConfigTracker.DefaultDataSubscriptionChangedListener;
import com.android.systemui.util.settings.SecureSettings;
+import kotlin.Unit;
+
+import kotlinx.coroutines.DisposableHandle;
+
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
@@ -90,10 +94,6 @@
import javax.inject.Inject;
-import kotlin.Unit;
-
-import kotlinx.coroutines.DisposableHandle;
-
/**
* Contains the collapsed status bar and handles hiding/showing based on disable flags
* and keyguard state. Also manages lifecycle to make sure the views it contains are being
@@ -431,7 +431,7 @@
initOngoingCallChip();
mAnimationScheduler.addCallback(this);
- mSecureSettings.registerContentObserverForUser(
+ mSecureSettings.registerContentObserverForUserSync(
Settings.Secure.STATUS_BAR_SHOW_VIBRATE_ICON,
false,
mVolumeSettingObserver,
@@ -445,7 +445,7 @@
mStatusBarStateController.removeCallback(this);
mOngoingCallController.removeCallback(mOngoingCallListener);
mAnimationScheduler.removeCallback(this);
- mSecureSettings.unregisterContentObserver(mVolumeSettingObserver);
+ mSecureSettings.unregisterContentObserverSync(mVolumeSettingObserver);
}
@Override
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/policy/BaseHeadsUpManager.java b/packages/SystemUI/src/com/android/systemui/statusbar/policy/BaseHeadsUpManager.java
index 4bd8681..fad5df8 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/policy/BaseHeadsUpManager.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/policy/BaseHeadsUpManager.java
@@ -138,7 +138,7 @@
}
}
};
- globalSettings.registerContentObserver(
+ globalSettings.registerContentObserverSync(
globalSettings.getUriFor(SETTING_HEADS_UP_SNOOZE_LENGTH_MS),
/* notifyForDescendants = */ false,
settingsObserver);
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/policy/DeviceProvisionedControllerImpl.kt b/packages/SystemUI/src/com/android/systemui/statusbar/policy/DeviceProvisionedControllerImpl.kt
index 8b63dfe..8123f8f 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/policy/DeviceProvisionedControllerImpl.kt
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/policy/DeviceProvisionedControllerImpl.kt
@@ -42,16 +42,16 @@
import javax.inject.Inject
@SysUISingleton
-open class DeviceProvisionedControllerImpl @Inject constructor(
+open class DeviceProvisionedControllerImpl
+@Inject
+constructor(
private val secureSettings: SecureSettings,
private val globalSettings: GlobalSettings,
private val userTracker: UserTracker,
private val dumpManager: DumpManager,
@Background private val backgroundHandler: Handler,
@Main private val mainExecutor: Executor
-) : DeviceProvisionedController,
- DeviceProvisionedController.DeviceProvisionedListener,
- Dumpable {
+) : DeviceProvisionedController, DeviceProvisionedController.DeviceProvisionedListener, Dumpable {
companion object {
private const val ALL_USERS = -1
@@ -63,8 +63,7 @@
private val userSetupUri = secureSettings.getUriFor(Settings.Secure.USER_SETUP_COMPLETE)
private val deviceProvisioned = AtomicBoolean(false)
- @GuardedBy("lock")
- private val userSetupComplete = SparseBooleanArray()
+ @GuardedBy("lock") private val userSetupComplete = SparseBooleanArray()
@GuardedBy("lock")
private val listeners = ArraySet<DeviceProvisionedController.DeviceProvisionedListener>()
@@ -81,42 +80,42 @@
return _currentUser
}
- private val observer = object : ContentObserver(backgroundHandler) {
- override fun onChange(
- selfChange: Boolean,
- uris: MutableCollection<Uri>,
- flags: Int,
- userId: Int
- ) {
- val updateDeviceProvisioned = deviceProvisionedUri in uris
- val updateUser = if (userSetupUri in uris) userId else NO_USERS
- updateValues(updateDeviceProvisioned, updateUser)
- if (updateDeviceProvisioned) {
- onDeviceProvisionedChanged()
- }
- if (updateUser != NO_USERS) {
- onUserSetupChanged()
+ private val observer =
+ object : ContentObserver(backgroundHandler) {
+ override fun onChange(
+ selfChange: Boolean,
+ uris: MutableCollection<Uri>,
+ flags: Int,
+ userId: Int
+ ) {
+ val updateDeviceProvisioned = deviceProvisionedUri in uris
+ val updateUser = if (userSetupUri in uris) userId else NO_USERS
+ updateValues(updateDeviceProvisioned, updateUser)
+ if (updateDeviceProvisioned) {
+ onDeviceProvisionedChanged()
+ }
+ if (updateUser != NO_USERS) {
+ onUserSetupChanged()
+ }
}
}
- }
- private val userChangedCallback = object : UserTracker.Callback {
- @WorkerThread
- override fun onUserChanged(newUser: Int, userContext: Context) {
- updateValues(updateDeviceProvisioned = false, updateUser = newUser)
- onUserSwitched()
+ private val userChangedCallback =
+ object : UserTracker.Callback {
+ @WorkerThread
+ override fun onUserChanged(newUser: Int, userContext: Context) {
+ updateValues(updateDeviceProvisioned = false, updateUser = newUser)
+ onUserSwitched()
+ }
+
+ override fun onProfilesChanged(profiles: List<UserInfo>) {}
}
- override fun onProfilesChanged(profiles: List<UserInfo>) {}
- }
-
init {
userSetupComplete.put(currentUser, false)
}
- /**
- * Call to initialize values and register observers
- */
+ /** Call to initialize values and register observers */
open fun init() {
if (!initted.compareAndSet(false, true)) {
return
@@ -124,31 +123,39 @@
dumpManager.registerDumpable(this)
updateValues()
userTracker.addCallback(userChangedCallback, backgroundExecutor)
- globalSettings.registerContentObserver(deviceProvisionedUri, observer)
- secureSettings.registerContentObserverForUser(userSetupUri, observer, UserHandle.USER_ALL)
+ globalSettings.registerContentObserverSync(deviceProvisionedUri, observer)
+ secureSettings.registerContentObserverForUserSync(
+ userSetupUri,
+ observer,
+ UserHandle.USER_ALL
+ )
}
@WorkerThread
- private fun updateValues(
- updateDeviceProvisioned: Boolean = true,
- updateUser: Int = ALL_USERS
- ) {
+ private fun updateValues(updateDeviceProvisioned: Boolean = true, updateUser: Int = ALL_USERS) {
if (updateDeviceProvisioned) {
- deviceProvisioned
- .set(globalSettings.getInt(Settings.Global.DEVICE_PROVISIONED, 0) != 0)
+ deviceProvisioned.set(globalSettings.getInt(Settings.Global.DEVICE_PROVISIONED, 0) != 0)
}
synchronized(lock) {
if (updateUser == ALL_USERS) {
val n = userSetupComplete.size()
for (i in 0 until n) {
val user = userSetupComplete.keyAt(i)
- val value = secureSettings
- .getIntForUser(Settings.Secure.USER_SETUP_COMPLETE, 0, user) != 0
+ val value =
+ secureSettings.getIntForUser(
+ Settings.Secure.USER_SETUP_COMPLETE,
+ 0,
+ user
+ ) != 0
userSetupComplete.put(user, value)
}
} else if (updateUser != NO_USERS) {
- val value = secureSettings
- .getIntForUser(Settings.Secure.USER_SETUP_COMPLETE, 0, updateUser) != 0
+ val value =
+ secureSettings.getIntForUser(
+ Settings.Secure.USER_SETUP_COMPLETE,
+ 0,
+ updateUser
+ ) != 0
userSetupComplete.put(updateUser, value)
}
}
@@ -160,15 +167,11 @@
* The listener will not be called when this happens.
*/
override fun addCallback(listener: DeviceProvisionedController.DeviceProvisionedListener) {
- synchronized(lock) {
- listeners.add(listener)
- }
+ synchronized(lock) { listeners.add(listener) }
}
override fun removeCallback(listener: DeviceProvisionedController.DeviceProvisionedListener) {
- synchronized(lock) {
- listeners.remove(listener)
- }
+ synchronized(lock) { listeners.remove(listener) }
}
override fun isDeviceProvisioned(): Boolean {
@@ -176,20 +179,14 @@
}
override fun isUserSetup(user: Int): Boolean {
- val index = synchronized(lock) {
- userSetupComplete.indexOfKey(user)
- }
+ val index = synchronized(lock) { userSetupComplete.indexOfKey(user) }
return if (index < 0) {
- val value = secureSettings
- .getIntForUser(Settings.Secure.USER_SETUP_COMPLETE, 0, user) != 0
- synchronized(lock) {
- userSetupComplete.put(user, value)
- }
+ val value =
+ secureSettings.getIntForUser(Settings.Secure.USER_SETUP_COMPLETE, 0, user) != 0
+ synchronized(lock) { userSetupComplete.put(user, value) }
value
} else {
- synchronized(lock) {
- userSetupComplete.get(user, false)
- }
+ synchronized(lock) { userSetupComplete.get(user, false) }
}
}
@@ -214,12 +211,8 @@
protected fun dispatchChange(
callback: DeviceProvisionedController.DeviceProvisionedListener.() -> Unit
) {
- val listenersCopy = synchronized(lock) {
- ArrayList(listeners)
- }
- mainExecutor.execute {
- listenersCopy.forEach(callback)
- }
+ val listenersCopy = synchronized(lock) { ArrayList(listeners) }
+ mainExecutor.execute { listenersCopy.forEach(callback) }
}
override fun dump(pw: PrintWriter, args: Array<out String>) {
@@ -229,4 +222,4 @@
pw.println("Listeners: $listeners")
}
}
-}
\ No newline at end of file
+}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/policy/LocationControllerImpl.java b/packages/SystemUI/src/com/android/systemui/statusbar/policy/LocationControllerImpl.java
index 9eee5d0..f57b696 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/policy/LocationControllerImpl.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/policy/LocationControllerImpl.java
@@ -115,7 +115,7 @@
};
// Register to listen for changes in Settings.Secure settings.
- mSecureSettings.registerContentObserverForUser(
+ mSecureSettings.registerContentObserverForUserSync(
Settings.Secure.LOCATION_SHOW_SYSTEM_OPS, mContentObserver, UserHandle.USER_ALL);
// Register to listen for changes in DeviceConfig settings.
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/policy/SensitiveNotificationProtectionControllerImpl.java b/packages/SystemUI/src/com/android/systemui/statusbar/policy/SensitiveNotificationProtectionControllerImpl.java
index 40bb67f..9ab8175 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/policy/SensitiveNotificationProtectionControllerImpl.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/policy/SensitiveNotificationProtectionControllerImpl.java
@@ -188,7 +188,7 @@
});
}
};
- settings.registerContentObserver(
+ settings.registerContentObserverSync(
DISABLE_SCREEN_SHARE_PROTECTIONS_FOR_APPS_AND_NOTIFICATIONS,
developerOptionsObserver);
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/policy/ZenModeControllerImpl.java b/packages/SystemUI/src/com/android/systemui/statusbar/policy/ZenModeControllerImpl.java
index 600005b..e09e577 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/policy/ZenModeControllerImpl.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/policy/ZenModeControllerImpl.java
@@ -140,13 +140,13 @@
mNoMan = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
if (registerZenModeContentObserverBackground()) {
bgHandler.post(() -> {
- globalSettings.registerContentObserver(Global.ZEN_MODE, modeContentObserver);
- globalSettings.registerContentObserver(Global.ZEN_MODE_CONFIG_ETAG,
+ globalSettings.registerContentObserverSync(Global.ZEN_MODE, modeContentObserver);
+ globalSettings.registerContentObserverSync(Global.ZEN_MODE_CONFIG_ETAG,
configContentObserver);
});
} else {
- globalSettings.registerContentObserver(Global.ZEN_MODE, modeContentObserver);
- globalSettings.registerContentObserver(Global.ZEN_MODE_CONFIG_ETAG,
+ globalSettings.registerContentObserverSync(Global.ZEN_MODE, modeContentObserver);
+ globalSettings.registerContentObserverSync(Global.ZEN_MODE_CONFIG_ETAG,
configContentObserver);
}
updateZenMode(getModeSettingValueFromProvider());
diff --git a/packages/SystemUI/src/com/android/systemui/theme/ThemeOverlayController.java b/packages/SystemUI/src/com/android/systemui/theme/ThemeOverlayController.java
index 7494649..4963aae 100644
--- a/packages/SystemUI/src/com/android/systemui/theme/ThemeOverlayController.java
+++ b/packages/SystemUI/src/com/android/systemui/theme/ThemeOverlayController.java
@@ -444,7 +444,7 @@
filter.addAction(Intent.ACTION_WALLPAPER_CHANGED);
mBroadcastDispatcher.registerReceiver(mBroadcastReceiver, filter, mMainExecutor,
UserHandle.ALL);
- mSecureSettings.registerContentObserverForUser(
+ mSecureSettings.registerContentObserverForUserSync(
Settings.Secure.THEME_CUSTOMIZATION_OVERLAY_PACKAGES,
false,
new ContentObserver(mBgHandler) {
diff --git a/packages/SystemUI/src/com/android/systemui/util/settings/SettingsProxy.kt b/packages/SystemUI/src/com/android/systemui/util/settings/SettingsProxy.kt
index ec89610..ed52233 100644
--- a/packages/SystemUI/src/com/android/systemui/util/settings/SettingsProxy.kt
+++ b/packages/SystemUI/src/com/android/systemui/util/settings/SettingsProxy.kt
@@ -37,7 +37,6 @@
interface SettingsProxy {
/** Returns the [ContentResolver] this instance was constructed with. */
fun getContentResolver(): ContentResolver
-
/**
* Construct the content URI for a particular name/value pair, useful for monitoring changes
* with a ContentObserver.
@@ -46,42 +45,36 @@
* @return the corresponding content URI, or null if not present
*/
fun getUriFor(name: String): Uri
-
/**
* Convenience wrapper around [ContentResolver.registerContentObserver].'
*
* Implicitly calls [getUriFor] on the passed in name.
*/
- fun registerContentObserver(name: String, settingsObserver: ContentObserver) {
- registerContentObserver(getUriFor(name), settingsObserver)
+ fun registerContentObserverSync(name: String, settingsObserver: ContentObserver) {
+ registerContentObserverSync(getUriFor(name), settingsObserver)
}
-
/** Convenience wrapper around [ContentResolver.registerContentObserver].' */
- fun registerContentObserver(uri: Uri, settingsObserver: ContentObserver) =
- registerContentObserver(uri, false, settingsObserver)
-
+ fun registerContentObserverSync(uri: Uri, settingsObserver: ContentObserver) =
+ registerContentObserverSync(uri, false, settingsObserver)
/**
* Convenience wrapper around [ContentResolver.registerContentObserver].'
*
* Implicitly calls [getUriFor] on the passed in name.
*/
- fun registerContentObserver(
+ fun registerContentObserverSync(
name: String,
notifyForDescendants: Boolean,
settingsObserver: ContentObserver
- ) = registerContentObserver(getUriFor(name), notifyForDescendants, settingsObserver)
-
+ ) = registerContentObserverSync(getUriFor(name), notifyForDescendants, settingsObserver)
/** Convenience wrapper around [ContentResolver.registerContentObserver].' */
- fun registerContentObserver(
+ fun registerContentObserverSync(
uri: Uri,
notifyForDescendants: Boolean,
settingsObserver: ContentObserver
) = getContentResolver().registerContentObserver(uri, notifyForDescendants, settingsObserver)
-
/** See [ContentResolver.unregisterContentObserver]. */
- fun unregisterContentObserver(settingsObserver: ContentObserver) =
+ fun unregisterContentObserverSync(settingsObserver: ContentObserver) =
getContentResolver().unregisterContentObserver(settingsObserver)
-
/**
* Look up a name in the database.
*
@@ -89,7 +82,6 @@
* @return the corresponding value, or null if not present
*/
fun getString(name: String): String
-
/**
* Store a name/value pair into the database.
*
@@ -98,7 +90,6 @@
* @return true if the value was set, false on database errors
*/
fun putString(name: String, value: String): Boolean
-
/**
* Store a name/value pair into the database.
*
@@ -129,7 +120,6 @@
* @see .resetToDefaults
*/
fun putString(name: String, value: String, tag: String, makeDefault: Boolean): Boolean
-
/**
* Convenience function for retrieving a single secure settings value as an integer. Note that
* internally setting values are always stored as strings; this function converts the string to
@@ -148,7 +138,6 @@
def
}
}
-
/**
* Convenience function for retrieving a single secure settings value as an integer. Note that
* internally setting values are always stored as strings; this function converts the string to
@@ -171,7 +160,6 @@
throw SettingNotFoundException(name)
}
}
-
/**
* Convenience function for updating a single settings value as an integer. This will either
* create a new entry in the table if the given name does not exist, or modify the value of the
@@ -185,7 +173,6 @@
fun putInt(name: String, value: Int): Boolean {
return putString(name, value.toString())
}
-
/**
* Convenience function for retrieving a single secure settings value as a boolean. Note that
* internally setting values are always stored as strings; this function converts the string to
@@ -199,7 +186,6 @@
fun getBool(name: String, def: Boolean): Boolean {
return getInt(name, if (def) 1 else 0) != 0
}
-
/**
* Convenience function for retrieving a single secure settings value as a boolean. Note that
* internally setting values are always stored as strings; this function converts the string to
@@ -217,7 +203,6 @@
fun getBool(name: String): Boolean {
return getInt(name) != 0
}
-
/**
* Convenience function for updating a single settings value as a boolean. This will either
* create a new entry in the table if the given name does not exist, or modify the value of the
@@ -231,7 +216,6 @@
fun putBool(name: String, value: Boolean): Boolean {
return putInt(name, if (value) 1 else 0)
}
-
/**
* Convenience function for retrieving a single secure settings value as a `long`. Note that
* internally setting values are always stored as strings; this function converts the string to
@@ -246,7 +230,6 @@
val valString = getString(name)
return parseLongOrUseDefault(valString, def)
}
-
/**
* Convenience function for retrieving a single secure settings value as a `long`. Note that
* internally setting values are always stored as strings; this function converts the string to
@@ -265,7 +248,6 @@
val valString = getString(name)
return parseLongOrThrow(name, valString)
}
-
/**
* Convenience function for updating a secure settings value as a long integer. This will either
* create a new entry in the table if the given name does not exist, or modify the value of the
@@ -279,7 +261,6 @@
fun putLong(name: String, value: Long): Boolean {
return putString(name, value.toString())
}
-
/**
* Convenience function for retrieving a single secure settings value as a floating point
* number. Note that internally setting values are always stored as strings; this function
@@ -294,7 +275,6 @@
val v = getString(name)
return parseFloat(v, def)
}
-
/**
* Convenience function for retrieving a single secure settings value as a float. Note that
* internally setting values are always stored as strings; this function converts the string to
@@ -313,7 +293,6 @@
val v = getString(name)
return parseFloatOrThrow(name, v)
}
-
/**
* Convenience function for updating a single settings value as a floating point number. This
* will either create a new entry in the table if the given name does not exist, or modify the
@@ -327,7 +306,6 @@
fun putFloat(name: String, value: Float): Boolean {
return putString(name, value.toString())
}
-
companion object {
/** Convert a string to a long, or uses a default if the string is malformed or null */
@JvmStatic
@@ -341,7 +319,6 @@
}
return value
}
-
/** Convert a string to a long, or throws an exception if the string is malformed or null */
@JvmStatic
@Throws(SettingNotFoundException::class)
@@ -355,7 +332,6 @@
throw SettingNotFoundException(name)
}
}
-
/** Convert a string to a float, or uses a default if the string is malformed or null */
@JvmStatic
fun parseFloat(v: String?, def: Float): Float {
@@ -365,7 +341,6 @@
def
}
}
-
/**
* Convert a string to a float, or throws an exception if the string is malformed or null
*/
diff --git a/packages/SystemUI/src/com/android/systemui/util/settings/SettingsProxyExt.kt b/packages/SystemUI/src/com/android/systemui/util/settings/SettingsProxyExt.kt
index 7484368..d757e33 100644
--- a/packages/SystemUI/src/com/android/systemui/util/settings/SettingsProxyExt.kt
+++ b/packages/SystemUI/src/com/android/systemui/util/settings/SettingsProxyExt.kt
@@ -39,9 +39,9 @@
}
}
- names.forEach { name -> registerContentObserverForUser(name, observer, userId) }
+ names.forEach { name -> registerContentObserverForUserSync(name, observer, userId) }
- awaitClose { unregisterContentObserver(observer) }
+ awaitClose { unregisterContentObserverSync(observer) }
}
}
@@ -57,9 +57,9 @@
}
}
- names.forEach { name -> registerContentObserver(name, observer) }
+ names.forEach { name -> registerContentObserverSync(name, observer) }
- awaitClose { unregisterContentObserver(observer) }
+ awaitClose { unregisterContentObserverSync(observer) }
}
}
}
diff --git a/packages/SystemUI/src/com/android/systemui/util/settings/UserSettingsProxy.kt b/packages/SystemUI/src/com/android/systemui/util/settings/UserSettingsProxy.kt
index 2285270..ed13943 100644
--- a/packages/SystemUI/src/com/android/systemui/util/settings/UserSettingsProxy.kt
+++ b/packages/SystemUI/src/com/android/systemui/util/settings/UserSettingsProxy.kt
@@ -41,10 +41,8 @@
* instances, unifying setting related actions in one place.
*/
interface UserSettingsProxy : SettingsProxy {
-
/** Returns that [UserTracker] this instance was constructed with. */
val userTracker: UserTracker
-
/** Returns the user id for the associated [ContentResolver]. */
var userId: Int
get() = getContentResolver().userId
@@ -53,7 +51,6 @@
"userId cannot be set in interface, use setter from an implementation instead."
)
}
-
/**
* Returns the actual current user handle when querying with the current user. Otherwise,
* returns the passed in user id.
@@ -63,63 +60,57 @@
userHandle
} else userTracker.userId
}
-
- override fun registerContentObserver(uri: Uri, settingsObserver: ContentObserver) {
- registerContentObserverForUser(uri, settingsObserver, userId)
+ override fun registerContentObserverSync(uri: Uri, settingsObserver: ContentObserver) {
+ registerContentObserverForUserSync(uri, settingsObserver, userId)
}
-
/** Convenience wrapper around [ContentResolver.registerContentObserver].' */
- override fun registerContentObserver(
+ override fun registerContentObserverSync(
uri: Uri,
notifyForDescendants: Boolean,
settingsObserver: ContentObserver
) {
- registerContentObserverForUser(uri, notifyForDescendants, settingsObserver, userId)
+ registerContentObserverForUserSync(uri, notifyForDescendants, settingsObserver, userId)
}
-
/**
* Convenience wrapper around [ContentResolver.registerContentObserver]
*
* Implicitly calls [getUriFor] on the passed in name.
*/
- fun registerContentObserverForUser(
+ fun registerContentObserverForUserSync(
name: String,
settingsObserver: ContentObserver,
userHandle: Int
) {
- registerContentObserverForUser(getUriFor(name), settingsObserver, userHandle)
+ registerContentObserverForUserSync(getUriFor(name), settingsObserver, userHandle)
}
-
/** Convenience wrapper around [ContentResolver.registerContentObserver] */
- fun registerContentObserverForUser(
+ fun registerContentObserverForUserSync(
uri: Uri,
settingsObserver: ContentObserver,
userHandle: Int
) {
- registerContentObserverForUser(uri, false, settingsObserver, userHandle)
+ registerContentObserverForUserSync(uri, false, settingsObserver, userHandle)
}
-
/**
* Convenience wrapper around [ContentResolver.registerContentObserver]
*
* Implicitly calls [getUriFor] on the passed in name.
*/
- fun registerContentObserverForUser(
+ fun registerContentObserverForUserSync(
name: String,
notifyForDescendants: Boolean,
settingsObserver: ContentObserver,
userHandle: Int
) {
- registerContentObserverForUser(
+ registerContentObserverForUserSync(
getUriFor(name),
notifyForDescendants,
settingsObserver,
userHandle
)
}
-
/** Convenience wrapper around [ContentResolver.registerContentObserver] */
- fun registerContentObserverForUser(
+ fun registerContentObserverForUserSync(
uri: Uri,
notifyForDescendants: Boolean,
settingsObserver: ContentObserver,
@@ -136,7 +127,6 @@
Unit
}
}
-
/**
* Look up a name in the database.
*
@@ -146,10 +136,8 @@
override fun getString(name: String): String {
return getStringForUser(name, userId)
}
-
/** See [getString]. */
fun getStringForUser(name: String, userHandle: Int): String
-
/**
* Store a name/value pair into the database. Values written by this method will be overridden
* if a restore happens in the future.
@@ -162,10 +150,8 @@
override fun putString(name: String, value: String): Boolean {
return putStringForUser(name, value, userId)
}
-
/** Similar implementation to [putString] for the specified [userHandle]. */
fun putStringForUser(name: String, value: String, userHandle: Int): Boolean
-
/** Similar implementation to [putString] for the specified [userHandle]. */
fun putStringForUser(
name: String,
@@ -175,11 +161,9 @@
@UserIdInt userHandle: Int,
overrideableByRestore: Boolean
): Boolean
-
override fun getInt(name: String, def: Int): Int {
return getIntForUser(name, def, userId)
}
-
/** Similar implementation to [getInt] for the specified [userHandle]. */
fun getIntForUser(name: String, def: Int, userHandle: Int): Int {
val v = getStringForUser(name, userHandle)
@@ -189,10 +173,8 @@
def
}
}
-
@Throws(SettingNotFoundException::class)
override fun getInt(name: String) = getIntForUser(name, userId)
-
/** Similar implementation to [getInt] for the specified [userHandle]. */
@Throws(SettingNotFoundException::class)
fun getIntForUser(name: String, userHandle: Int): Int {
@@ -203,66 +185,52 @@
throw SettingNotFoundException(name)
}
}
-
override fun putInt(name: String, value: Int) = putIntForUser(name, value, userId)
-
/** Similar implementation to [getInt] for the specified [userHandle]. */
fun putIntForUser(name: String, value: Int, userHandle: Int) =
putStringForUser(name, value.toString(), userHandle)
-
override fun getBool(name: String, def: Boolean) = getBoolForUser(name, def, userId)
-
/** Similar implementation to [getBool] for the specified [userHandle]. */
fun getBoolForUser(name: String, def: Boolean, userHandle: Int) =
getIntForUser(name, if (def) 1 else 0, userHandle) != 0
-
@Throws(SettingNotFoundException::class)
override fun getBool(name: String) = getBoolForUser(name, userId)
-
/** Similar implementation to [getBool] for the specified [userHandle]. */
@Throws(SettingNotFoundException::class)
fun getBoolForUser(name: String, userHandle: Int): Boolean {
return getIntForUser(name, userHandle) != 0
}
-
override fun putBool(name: String, value: Boolean): Boolean {
return putBoolForUser(name, value, userId)
}
-
/** Similar implementation to [putBool] for the specified [userHandle]. */
fun putBoolForUser(name: String, value: Boolean, userHandle: Int) =
putIntForUser(name, if (value) 1 else 0, userHandle)
-
/** Similar implementation to [getLong] for the specified [userHandle]. */
fun getLongForUser(name: String, def: Long, userHandle: Int): Long {
val valString = getStringForUser(name, userHandle)
return parseLongOrUseDefault(valString, def)
}
-
/** Similar implementation to [getLong] for the specified [userHandle]. */
@Throws(SettingNotFoundException::class)
fun getLongForUser(name: String, userHandle: Int): Long {
val valString = getStringForUser(name, userHandle)
return parseLongOrThrow(name, valString)
}
-
/** Similar implementation to [putLong] for the specified [userHandle]. */
fun putLongForUser(name: String, value: Long, userHandle: Int) =
putStringForUser(name, value.toString(), userHandle)
-
/** Similar implementation to [getFloat] for the specified [userHandle]. */
fun getFloatForUser(name: String, def: Float, userHandle: Int): Float {
val v = getStringForUser(name, userHandle)
return parseFloat(v, def)
}
-
/** Similar implementation to [getFloat] for the specified [userHandle]. */
@Throws(SettingNotFoundException::class)
fun getFloatForUser(name: String, userHandle: Int): Float {
val v = getStringForUser(name, userHandle)
return parseFloatOrThrow(name, v)
}
-
/** Similar implementation to [putFloat] for the specified [userHandle]. */
fun putFloatForUser(name: String, value: Float, userHandle: Int) =
putStringForUser(name, value.toString(), userHandle)
diff --git a/packages/SystemUI/src/com/android/systemui/volume/domain/interactor/AudioOutputInteractor.kt b/packages/SystemUI/src/com/android/systemui/volume/domain/interactor/AudioOutputInteractor.kt
index e0f64b4..154737c 100644
--- a/packages/SystemUI/src/com/android/systemui/volume/domain/interactor/AudioOutputInteractor.kt
+++ b/packages/SystemUI/src/com/android/systemui/volume/domain/interactor/AudioOutputInteractor.kt
@@ -17,15 +17,18 @@
package com.android.systemui.volume.domain.interactor
import android.bluetooth.BluetoothAdapter
+import android.content.Context
import android.media.AudioDeviceInfo
import com.android.settingslib.bluetooth.CachedBluetoothDevice
import com.android.settingslib.bluetooth.LocalBluetoothManager
import com.android.settingslib.media.BluetoothMediaDevice
import com.android.settingslib.media.MediaDevice
import com.android.settingslib.media.MediaDevice.MediaDeviceType
+import com.android.settingslib.media.PhoneMediaDevice
import com.android.settingslib.volume.data.repository.AudioRepository
import com.android.settingslib.volume.data.repository.AudioSharingRepository
import com.android.settingslib.volume.domain.interactor.AudioModeInteractor
+import com.android.systemui.dagger.qualifiers.Application
import com.android.systemui.dagger.qualifiers.Background
import com.android.systemui.volume.domain.model.AudioOutputDevice
import com.android.systemui.volume.panel.component.mediaoutput.domain.interactor.MediaOutputInteractor
@@ -36,6 +39,7 @@
import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.SharingStarted
+import kotlinx.coroutines.flow.StateFlow
import kotlinx.coroutines.flow.flatMapLatest
import kotlinx.coroutines.flow.flowOn
import kotlinx.coroutines.flow.map
@@ -47,6 +51,7 @@
class AudioOutputInteractor
@Inject
constructor(
+ @Application private val context: Context,
audioRepository: AudioRepository,
audioModeInteractor: AudioModeInteractor,
@VolumePanelScope scope: CoroutineScope,
@@ -58,7 +63,7 @@
audioSharingRepository: AudioSharingRepository,
) {
- val currentAudioDevice: Flow<AudioOutputDevice> =
+ val currentAudioDevice: StateFlow<AudioOutputDevice> =
audioModeInteractor.isOngoingCall
.flatMapLatest { isOngoingCall ->
if (isOngoingCall) {
@@ -102,7 +107,7 @@
)
}
return AudioOutputDevice.BuiltIn(
- name = productName.toString(),
+ name = PhoneMediaDevice.getMediaTransferThisDeviceName(context),
icon = deviceIconInteractor.loadIcon(type),
)
}
diff --git a/packages/SystemUI/src/com/android/systemui/volume/panel/component/mediaoutput/domain/interactor/MediaOutputActionsInteractor.kt b/packages/SystemUI/src/com/android/systemui/volume/panel/component/mediaoutput/domain/interactor/MediaOutputActionsInteractor.kt
index 199bc3b..333f4ad 100644
--- a/packages/SystemUI/src/com/android/systemui/volume/panel/component/mediaoutput/domain/interactor/MediaOutputActionsInteractor.kt
+++ b/packages/SystemUI/src/com/android/systemui/volume/panel/component/mediaoutput/domain/interactor/MediaOutputActionsInteractor.kt
@@ -21,7 +21,7 @@
import com.android.systemui.animation.DialogTransitionAnimator
import com.android.systemui.animation.Expandable
import com.android.systemui.media.dialog.MediaOutputDialogManager
-import com.android.systemui.volume.panel.component.mediaoutput.shared.model.SessionWithPlaybackState
+import com.android.systemui.volume.panel.component.mediaoutput.domain.model.MediaOutputComponentModel
import com.android.systemui.volume.panel.dagger.scope.VolumePanelScope
import javax.inject.Inject
@@ -29,14 +29,12 @@
@VolumePanelScope
class MediaOutputActionsInteractor
@Inject
-constructor(
- private val mediaOutputDialogManager: MediaOutputDialogManager,
-) {
+constructor(private val mediaOutputDialogManager: MediaOutputDialogManager) {
- fun onBarClick(sessionWithPlaybackState: SessionWithPlaybackState?, expandable: Expandable?) {
- if (sessionWithPlaybackState?.isPlaybackActive == true) {
+ fun onBarClick(model: MediaOutputComponentModel?, expandable: Expandable?) {
+ if (model is MediaOutputComponentModel.MediaSession) {
mediaOutputDialogManager.createAndShowWithController(
- sessionWithPlaybackState.session.packageName,
+ model.session.packageName,
false,
expandable?.dialogController()
)
diff --git a/packages/SystemUI/src/com/android/systemui/volume/panel/component/mediaoutput/domain/interactor/MediaOutputComponentInteractor.kt b/packages/SystemUI/src/com/android/systemui/volume/panel/component/mediaoutput/domain/interactor/MediaOutputComponentInteractor.kt
new file mode 100644
index 0000000..ed25129
--- /dev/null
+++ b/packages/SystemUI/src/com/android/systemui/volume/panel/component/mediaoutput/domain/interactor/MediaOutputComponentInteractor.kt
@@ -0,0 +1,105 @@
+/*
+ * 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.systemui.volume.panel.component.mediaoutput.domain.interactor
+
+import com.android.settingslib.volume.domain.interactor.AudioModeInteractor
+import com.android.systemui.volume.domain.interactor.AudioOutputInteractor
+import com.android.systemui.volume.domain.model.AudioOutputDevice
+import com.android.systemui.volume.panel.component.mediaoutput.domain.model.MediaOutputComponentModel
+import com.android.systemui.volume.panel.component.mediaoutput.shared.model.SessionWithPlaybackState
+import com.android.systemui.volume.panel.dagger.scope.VolumePanelScope
+import com.android.systemui.volume.panel.shared.model.Result
+import com.android.systemui.volume.panel.shared.model.filterData
+import com.android.systemui.volume.panel.shared.model.wrapInResult
+import javax.inject.Inject
+import kotlinx.coroutines.CoroutineScope
+import kotlinx.coroutines.ExperimentalCoroutinesApi
+import kotlinx.coroutines.flow.Flow
+import kotlinx.coroutines.flow.SharingStarted
+import kotlinx.coroutines.flow.StateFlow
+import kotlinx.coroutines.flow.combine
+import kotlinx.coroutines.flow.filter
+import kotlinx.coroutines.flow.flatMapLatest
+import kotlinx.coroutines.flow.flowOf
+import kotlinx.coroutines.flow.map
+import kotlinx.coroutines.flow.mapNotNull
+import kotlinx.coroutines.flow.stateIn
+
+/** Gathers together a domain state for the Media Output Volume Panel component. */
+@OptIn(ExperimentalCoroutinesApi::class)
+@VolumePanelScope
+class MediaOutputComponentInteractor
+@Inject
+constructor(
+ @VolumePanelScope private val coroutineScope: CoroutineScope,
+ private val mediaDeviceSessionInteractor: MediaDeviceSessionInteractor,
+ audioOutputInteractor: AudioOutputInteractor,
+ audioModeInteractor: AudioModeInteractor,
+ interactor: MediaOutputInteractor,
+) {
+
+ private val sessionWithPlaybackState: StateFlow<Result<SessionWithPlaybackState?>> =
+ interactor.defaultActiveMediaSession
+ .filterData()
+ .flatMapLatest { session ->
+ if (session == null) {
+ flowOf(null)
+ } else {
+ mediaDeviceSessionInteractor.playbackState(session).mapNotNull { playback ->
+ playback?.let { SessionWithPlaybackState(session, playback.isActive) }
+ }
+ }
+ }
+ .wrapInResult()
+ .stateIn(
+ coroutineScope,
+ SharingStarted.Eagerly,
+ Result.Loading(),
+ )
+
+ private val currentAudioDevice: Flow<AudioOutputDevice> =
+ audioOutputInteractor.currentAudioDevice.filter { it !is AudioOutputDevice.Unknown }
+
+ val mediaOutputModel: StateFlow<Result<MediaOutputComponentModel>> =
+ audioModeInteractor.isOngoingCall
+ .flatMapLatest { isOngoingCall ->
+ audioOutputInteractor.isInAudioSharing.flatMapLatest { isInAudioSharing ->
+ if (isOngoingCall) {
+ currentAudioDevice.map {
+ MediaOutputComponentModel.Calling(it, isInAudioSharing)
+ }
+ } else {
+ combine(sessionWithPlaybackState.filterData(), currentAudioDevice) {
+ sessionWithPlaybackState,
+ currentAudioDevice ->
+ if (sessionWithPlaybackState == null) {
+ MediaOutputComponentModel.Idle(currentAudioDevice, isInAudioSharing)
+ } else {
+ MediaOutputComponentModel.MediaSession(
+ sessionWithPlaybackState.session,
+ sessionWithPlaybackState.isPlaybackActive,
+ currentAudioDevice,
+ isInAudioSharing,
+ )
+ }
+ }
+ }
+ }
+ }
+ .wrapInResult()
+ .stateIn(coroutineScope, SharingStarted.Eagerly, Result.Loading())
+}
diff --git a/packages/SystemUI/src/com/android/systemui/volume/panel/component/mediaoutput/domain/model/MediaOutputComponentModel.kt b/packages/SystemUI/src/com/android/systemui/volume/panel/component/mediaoutput/domain/model/MediaOutputComponentModel.kt
new file mode 100644
index 0000000..220fb2b
--- /dev/null
+++ b/packages/SystemUI/src/com/android/systemui/volume/panel/component/mediaoutput/domain/model/MediaOutputComponentModel.kt
@@ -0,0 +1,47 @@
+/*
+ * 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.systemui.volume.panel.component.mediaoutput.domain.model
+
+import com.android.systemui.volume.domain.model.AudioOutputDevice
+import com.android.systemui.volume.panel.component.mediaoutput.shared.model.MediaDeviceSession
+
+/** Models domain data for the Media Output Component */
+sealed interface MediaOutputComponentModel {
+
+ val device: AudioOutputDevice
+ val isInAudioSharing: Boolean
+
+ /** There is an ongoing call on the device. */
+ data class Calling(
+ override val device: AudioOutputDevice,
+ override val isInAudioSharing: Boolean,
+ ) : MediaOutputComponentModel
+
+ /** There is media playing on the device. */
+ data class MediaSession(
+ val session: MediaDeviceSession,
+ val isPlaybackActive: Boolean,
+ override val device: AudioOutputDevice,
+ override val isInAudioSharing: Boolean,
+ ) : MediaOutputComponentModel
+
+ /** There is nothing playing on the device. */
+ data class Idle(
+ override val device: AudioOutputDevice,
+ override val isInAudioSharing: Boolean,
+ ) : MediaOutputComponentModel
+}
diff --git a/packages/SystemUI/src/com/android/systemui/volume/panel/component/mediaoutput/ui/viewmodel/MediaOutputViewModel.kt b/packages/SystemUI/src/com/android/systemui/volume/panel/component/mediaoutput/ui/viewmodel/MediaOutputViewModel.kt
index 40b7977..36b42f2 100644
--- a/packages/SystemUI/src/com/android/systemui/volume/panel/component/mediaoutput/ui/viewmodel/MediaOutputViewModel.kt
+++ b/packages/SystemUI/src/com/android/systemui/volume/panel/component/mediaoutput/ui/viewmodel/MediaOutputViewModel.kt
@@ -18,33 +18,24 @@
import android.content.Context
import com.android.internal.logging.UiEventLogger
-import com.android.settingslib.volume.domain.interactor.AudioModeInteractor
import com.android.systemui.animation.Expandable
import com.android.systemui.common.shared.model.Color
import com.android.systemui.common.shared.model.Icon
import com.android.systemui.res.R
-import com.android.systemui.volume.domain.interactor.AudioOutputInteractor
import com.android.systemui.volume.domain.model.AudioOutputDevice
-import com.android.systemui.volume.panel.component.mediaoutput.domain.interactor.MediaDeviceSessionInteractor
import com.android.systemui.volume.panel.component.mediaoutput.domain.interactor.MediaOutputActionsInteractor
-import com.android.systemui.volume.panel.component.mediaoutput.domain.interactor.MediaOutputInteractor
-import com.android.systemui.volume.panel.component.mediaoutput.shared.model.SessionWithPlaybackState
+import com.android.systemui.volume.panel.component.mediaoutput.domain.interactor.MediaOutputComponentInteractor
+import com.android.systemui.volume.panel.component.mediaoutput.domain.model.MediaOutputComponentModel
import com.android.systemui.volume.panel.dagger.scope.VolumePanelScope
import com.android.systemui.volume.panel.shared.model.Result
import com.android.systemui.volume.panel.shared.model.filterData
-import com.android.systemui.volume.panel.shared.model.wrapInResult
import com.android.systemui.volume.panel.ui.VolumePanelUiEvent
import javax.inject.Inject
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.flow.SharingStarted
import kotlinx.coroutines.flow.StateFlow
-import kotlinx.coroutines.flow.combine
-import kotlinx.coroutines.flow.filter
-import kotlinx.coroutines.flow.flatMapLatest
-import kotlinx.coroutines.flow.flowOf
import kotlinx.coroutines.flow.map
-import kotlinx.coroutines.flow.mapNotNull
import kotlinx.coroutines.flow.stateIn
/** Models the UI of the Media Output Volume Panel component. */
@@ -56,61 +47,40 @@
private val context: Context,
@VolumePanelScope private val coroutineScope: CoroutineScope,
private val actionsInteractor: MediaOutputActionsInteractor,
- private val mediaDeviceSessionInteractor: MediaDeviceSessionInteractor,
- private val audioOutputInteractor: AudioOutputInteractor,
- audioModeInteractor: AudioModeInteractor,
- interactor: MediaOutputInteractor,
+ private val mediaOutputComponentInteractor: MediaOutputComponentInteractor,
private val uiEventLogger: UiEventLogger,
) {
- private val sessionWithPlaybackState: StateFlow<Result<SessionWithPlaybackState?>> =
- interactor.defaultActiveMediaSession
- .filterData()
- .flatMapLatest { session ->
- if (session == null) {
- flowOf(null)
- } else {
- mediaDeviceSessionInteractor.playbackState(session).mapNotNull { playback ->
- playback?.let { SessionWithPlaybackState(session, playback.isActive) }
- }
- }
- }
- .wrapInResult()
- .stateIn(
- coroutineScope,
- SharingStarted.Eagerly,
- Result.Loading(),
- )
-
val connectedDeviceViewModel: StateFlow<ConnectedDeviceViewModel?> =
- combine(
- sessionWithPlaybackState.filterData(),
- audioModeInteractor.isOngoingCall,
- audioOutputInteractor.currentAudioDevice.filter {
- it !is AudioOutputDevice.Unknown
- },
- audioOutputInteractor.isInAudioSharing,
- ) { mediaDeviceSession, isOngoingCall, currentConnectedDevice, isInAudioSharing ->
+ mediaOutputComponentInteractor.mediaOutputModel
+ .filterData()
+ .map { mediaOutputModel ->
val label =
- when {
- isOngoingCall -> context.getString(R.string.media_output_title_ongoing_call)
- mediaDeviceSession?.isPlaybackActive == true ->
- context.getString(
- R.string.media_output_label_title,
- mediaDeviceSession.session.appLabel
- )
- else -> context.getString(R.string.media_output_title_without_playing)
+ when (mediaOutputModel) {
+ is MediaOutputComponentModel.Idle -> {
+ context.getString(R.string.media_output_title_without_playing)
+ }
+ is MediaOutputComponentModel.MediaSession -> {
+ if (mediaOutputModel.isPlaybackActive) {
+ context.getString(
+ R.string.media_output_label_title,
+ mediaOutputModel.session.appLabel,
+ )
+ } else {
+ context.getString(R.string.media_output_title_without_playing)
+ }
+ }
+ is MediaOutputComponentModel.Calling -> {
+ context.getString(R.string.media_output_title_ongoing_call)
+ }
}
ConnectedDeviceViewModel(
label,
- when (isInAudioSharing) {
- true -> {
- context.getString(R.string.audio_sharing_description)
- }
- false -> {
- currentConnectedDevice.name
- }
- }
+ if (mediaOutputModel.isInAudioSharing) {
+ context.getString(R.string.audio_sharing_description)
+ } else {
+ mediaOutputModel.device.name
+ },
)
}
.stateIn(
@@ -120,16 +90,20 @@
)
val deviceIconViewModel: StateFlow<DeviceIconViewModel?> =
- combine(sessionWithPlaybackState.filterData(), audioOutputInteractor.currentAudioDevice) {
- mediaDeviceSession,
- currentConnectedDevice ->
+ mediaOutputComponentInteractor.mediaOutputModel
+ .filterData()
+ .map { mediaOutputModel ->
val icon: Icon =
- currentConnectedDevice
- .takeIf { currentConnectedDevice !is AudioOutputDevice.Unknown }
+ mediaOutputModel.device
+ .takeIf { it !is AudioOutputDevice.Unknown }
?.icon
?.let { Icon.Loaded(it, null) }
?: Icon.Resource(R.drawable.ic_media_home_devices, null)
- if (mediaDeviceSession?.isPlaybackActive == true) {
+ val isPlaybackActive =
+ (mediaOutputModel as? MediaOutputComponentModel.MediaSession)
+ ?.isPlaybackActive == true
+ val isCalling = mediaOutputModel is MediaOutputComponentModel.Calling
+ if (isPlaybackActive || isCalling) {
DeviceIconViewModel.IsPlaying(
icon = icon,
iconColor =
@@ -156,8 +130,9 @@
)
val enabled: StateFlow<Boolean> =
- audioOutputInteractor.isInAudioSharing
- .map { !it }
+ mediaOutputComponentInteractor.mediaOutputModel
+ .filterData()
+ .map { !it.isInAudioSharing }
.stateIn(
coroutineScope,
SharingStarted.Eagerly,
@@ -166,7 +141,11 @@
fun onBarClick(expandable: Expandable?) {
uiEventLogger.log(VolumePanelUiEvent.VOLUME_PANEL_MEDIA_OUTPUT_CLICKED)
- val result = sessionWithPlaybackState.value
- actionsInteractor.onBarClick((result as? Result.Data)?.data, expandable)
+ val result: Result<MediaOutputComponentModel> =
+ mediaOutputComponentInteractor.mediaOutputModel.value
+ actionsInteractor.onBarClick(
+ (result as? Result.Data<MediaOutputComponentModel>)?.data,
+ expandable
+ )
}
}
diff --git a/packages/SystemUI/src/com/android/systemui/volume/panel/component/spatial/ui/viewmodel/SpatialAudioViewModel.kt b/packages/SystemUI/src/com/android/systemui/volume/panel/component/spatial/ui/viewmodel/SpatialAudioViewModel.kt
index 4b2d26a..6c6a1cc 100644
--- a/packages/SystemUI/src/com/android/systemui/volume/panel/component/spatial/ui/viewmodel/SpatialAudioViewModel.kt
+++ b/packages/SystemUI/src/com/android/systemui/volume/panel/component/spatial/ui/viewmodel/SpatialAudioViewModel.kt
@@ -48,15 +48,31 @@
private val uiEventLogger: UiEventLogger,
) {
+ private val spatialSpeakerIcon =
+ Icon.Resource(R.drawable.ic_spatial_speaker, contentDescription = null)
+
val spatialAudioButton: StateFlow<ButtonViewModel?> =
- interactor.isEnabled
- .map {
- val isChecked = it is SpatialAudioEnabledModel.SpatialAudioEnabled
- it.toViewModel(isChecked)
+ combine(interactor.isEnabled, interactor.isAvailable) { isEnabled, isAvailable ->
+ isEnabled
+ .toViewModel(
+ isChecked = isEnabled is SpatialAudioEnabledModel.SpatialAudioEnabled,
+ isHeadTrackingAvailable =
+ isAvailable is SpatialAudioAvailabilityModel.SpatialAudio,
+ )
.copy(label = context.getString(R.string.volume_panel_spatial_audio_title))
}
.stateIn(scope, SharingStarted.Eagerly, null)
+ val shouldUsePopup: StateFlow<Boolean> =
+ interactor.isAvailable
+ .map {
+ // head tracking availability means there are three possible states for the spatial
+ // audio: disabled, enabled regular, enabled with head tracking.
+ // Show popup in this case instead of a togglealbe button.
+ it is SpatialAudioAvailabilityModel.SpatialAudio
+ }
+ .stateIn(scope, SharingStarted.Eagerly, false)
+
val isAvailable: StateFlow<Boolean> =
availabilityCriteria.isAvailable().stateIn(scope, SharingStarted.Eagerly, true)
@@ -73,8 +89,12 @@
}
}
.map { isEnabled ->
- val isChecked = isEnabled == currentIsEnabled
- val buttonViewModel: ButtonViewModel = isEnabled.toViewModel(isChecked)
+ val buttonViewModel: ButtonViewModel =
+ isEnabled.toViewModel(
+ isChecked = isEnabled == currentIsEnabled,
+ isHeadTrackingAvailable =
+ isAvailable is SpatialAudioAvailabilityModel.HeadTracking,
+ )
SpatialAudioButtonViewModel(button = buttonViewModel, model = isEnabled)
}
}
@@ -97,11 +117,21 @@
scope.launch { interactor.setEnabled(model) }
}
- private fun SpatialAudioEnabledModel.toViewModel(isChecked: Boolean): ButtonViewModel {
+ private fun SpatialAudioEnabledModel.toViewModel(
+ isChecked: Boolean,
+ isHeadTrackingAvailable: Boolean,
+ ): ButtonViewModel {
+ // This method deliberately uses the same icon for the case when head tracking is disabled
+ // to show a toggle button with a non-changing icon
if (this is SpatialAudioEnabledModel.HeadTrackingEnabled) {
return ButtonViewModel(
isActive = isChecked,
- icon = Icon.Resource(R.drawable.ic_head_tracking, contentDescription = null),
+ icon =
+ if (isHeadTrackingAvailable) {
+ Icon.Resource(R.drawable.ic_head_tracking, contentDescription = null)
+ } else {
+ spatialSpeakerIcon
+ },
label = context.getString(R.string.volume_panel_spatial_audio_tracking)
)
}
@@ -109,7 +139,12 @@
if (this is SpatialAudioEnabledModel.SpatialAudioEnabled) {
return ButtonViewModel(
isActive = isChecked,
- icon = Icon.Resource(R.drawable.ic_spatial_audio, contentDescription = null),
+ icon =
+ if (isHeadTrackingAvailable) {
+ Icon.Resource(R.drawable.ic_spatial_audio, contentDescription = null)
+ } else {
+ spatialSpeakerIcon
+ },
label = context.getString(R.string.volume_panel_spatial_audio_fixed)
)
}
@@ -117,7 +152,12 @@
if (this is SpatialAudioEnabledModel.Disabled) {
return ButtonViewModel(
isActive = isChecked,
- icon = Icon.Resource(R.drawable.ic_spatial_audio_off, contentDescription = null),
+ icon =
+ if (isHeadTrackingAvailable) {
+ Icon.Resource(R.drawable.ic_spatial_audio_off, contentDescription = null)
+ } else {
+ spatialSpeakerIcon
+ },
label = context.getString(R.string.volume_panel_spatial_audio_off)
)
}
diff --git a/packages/SystemUI/src/com/android/systemui/wallet/controller/QuickAccessWalletController.java b/packages/SystemUI/src/com/android/systemui/wallet/controller/QuickAccessWalletController.java
index ff18418..1d32a4f 100644
--- a/packages/SystemUI/src/com/android/systemui/wallet/controller/QuickAccessWalletController.java
+++ b/packages/SystemUI/src/com/android/systemui/wallet/controller/QuickAccessWalletController.java
@@ -149,12 +149,12 @@
if (event == WALLET_PREFERENCE_CHANGE && mWalletPreferenceObserver != null) {
mWalletPreferenceChangeEvents--;
if (mWalletPreferenceChangeEvents == 0) {
- mSecureSettings.unregisterContentObserver(mWalletPreferenceObserver);
+ mSecureSettings.unregisterContentObserverSync(mWalletPreferenceObserver);
}
} else if (event == DEFAULT_PAYMENT_APP_CHANGE && mDefaultPaymentAppObserver != null) {
mDefaultPaymentAppChangeEvents--;
if (mDefaultPaymentAppChangeEvents == 0) {
- mSecureSettings.unregisterContentObserver(mDefaultPaymentAppObserver);
+ mSecureSettings.unregisterContentObserverSync(mDefaultPaymentAppObserver);
}
} else if (event == DEFAULT_WALLET_APP_CHANGE && mDefaultWalletAppObserver != null) {
mDefaultWalletAppChangeEvents--;
@@ -312,7 +312,7 @@
}
};
- mSecureSettings.registerContentObserverForUser(
+ mSecureSettings.registerContentObserverForUserSync(
Settings.Secure.NFC_PAYMENT_DEFAULT_COMPONENT,
false /* notifyForDescendants */,
mDefaultPaymentAppObserver,
@@ -351,7 +351,7 @@
}
};
- mSecureSettings.registerContentObserverForUser(
+ mSecureSettings.registerContentObserverForUserSync(
QuickAccessWalletClientImpl.SETTING_KEY,
false /* notifyForDescendants */,
mWalletPreferenceObserver,
diff --git a/packages/SystemUI/tests/src/com/android/keyguard/KeyguardClockSwitchControllerTest.java b/packages/SystemUI/tests/src/com/android/keyguard/KeyguardClockSwitchControllerTest.java
index 99b5a4b..cfa74f0 100644
--- a/packages/SystemUI/tests/src/com/android/keyguard/KeyguardClockSwitchControllerTest.java
+++ b/packages/SystemUI/tests/src/com/android/keyguard/KeyguardClockSwitchControllerTest.java
@@ -181,7 +181,7 @@
ArgumentCaptor.forClass(ContentObserver.class);
mController.init();
mExecutor.runAllReady();
- verify(mSecureSettings).registerContentObserverForUser(
+ verify(mSecureSettings).registerContentObserverForUserSync(
eq(Settings.Secure.LOCKSCREEN_USE_DOUBLE_LINE_CLOCK),
anyBoolean(), observerCaptor.capture(), eq(UserHandle.USER_ALL));
ContentObserver observer = observerCaptor.getValue();
@@ -247,7 +247,7 @@
ArgumentCaptor.forClass(ContentObserver.class);
mController.init();
mExecutor.runAllReady();
- verify(mSecureSettings).registerContentObserverForUser(
+ verify(mSecureSettings).registerContentObserverForUserSync(
eq(Settings.Secure.LOCK_SCREEN_WEATHER_ENABLED), anyBoolean(),
observerCaptor.capture(), eq(UserHandle.USER_ALL));
ContentObserver observer = observerCaptor.getValue();
diff --git a/packages/SystemUI/tests/src/com/android/systemui/accessibility/WindowMagnificationSettingsTest.java b/packages/SystemUI/tests/src/com/android/systemui/accessibility/WindowMagnificationSettingsTest.java
index 92b06ba..138fed2 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/accessibility/WindowMagnificationSettingsTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/accessibility/WindowMagnificationSettingsTest.java
@@ -393,7 +393,7 @@
mWindowMagnificationSettings.showSettingPanel();
- verify(mSecureSettings).registerContentObserverForUser(
+ verify(mSecureSettings).registerContentObserverForUserSync(
eq(ACCESSIBILITY_MAGNIFICATION_CAPABILITY),
any(ContentObserver.class),
eq(UserHandle.USER_CURRENT));
@@ -408,7 +408,7 @@
mWindowMagnificationSettings.showSettingPanel();
mWindowMagnificationSettings.hideSettingPanel();
- verify(mSecureSettings).unregisterContentObserver(any(ContentObserver.class));
+ verify(mSecureSettings).unregisterContentObserverSync(any(ContentObserver.class));
}
@Test
diff --git a/packages/SystemUI/tests/src/com/android/systemui/biometrics/data/repository/FaceSettingsRepositoryImplTest.kt b/packages/SystemUI/tests/src/com/android/systemui/biometrics/data/repository/FaceSettingsRepositoryImplTest.kt
index 9ba56d2..6391986 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/biometrics/data/repository/FaceSettingsRepositoryImplTest.kt
+++ b/packages/SystemUI/tests/src/com/android/systemui/biometrics/data/repository/FaceSettingsRepositoryImplTest.kt
@@ -82,7 +82,12 @@
val keys =
captureMany<String> {
verify(secureSettings)
- .registerContentObserverForUser(capture(), anyBoolean(), any(), eq(USER_ID))
+ .registerContentObserverForUserSync(
+ capture(),
+ anyBoolean(),
+ any(),
+ eq(USER_ID)
+ )
}
assertThat(keys).containsExactly(FACE_UNLOCK_ALWAYS_REQUIRE_CONFIRMATION)
@@ -102,7 +107,7 @@
val observer =
withArgCaptor<ContentObserver> {
verify(secureSettings)
- .registerContentObserverForUser(
+ .registerContentObserverForUserSync(
eq(setting),
anyBoolean(),
capture(),
diff --git a/packages/SystemUI/tests/src/com/android/systemui/controls/settings/ControlsSettingsDialogManagerImplTest.kt b/packages/SystemUI/tests/src/com/android/systemui/controls/settings/ControlsSettingsDialogManagerImplTest.kt
index 590989d..154c373 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/controls/settings/ControlsSettingsDialogManagerImplTest.kt
+++ b/packages/SystemUI/tests/src/com/android/systemui/controls/settings/ControlsSettingsDialogManagerImplTest.kt
@@ -332,7 +332,7 @@
}
private fun attachRepositoryToSettings() {
- secureSettings.registerContentObserver(
+ secureSettings.registerContentObserverSync(
SETTING_SHOW,
object : ContentObserver(null) {
override fun onChange(selfChange: Boolean) {
@@ -343,7 +343,7 @@
}
)
- secureSettings.registerContentObserver(
+ secureSettings.registerContentObserverSync(
SETTING_ACTION,
object : ContentObserver(null) {
override fun onChange(selfChange: Boolean) {
diff --git a/packages/SystemUI/tests/src/com/android/systemui/globalactions/GlobalActionsDialogLiteTest.java b/packages/SystemUI/tests/src/com/android/systemui/globalactions/GlobalActionsDialogLiteTest.java
index cfe37ee..e2cca38 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/globalactions/GlobalActionsDialogLiteTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/globalactions/GlobalActionsDialogLiteTest.java
@@ -42,7 +42,6 @@
import android.os.UserManager;
import android.provider.Settings;
import android.service.dreams.IDreamManager;
-import android.testing.AndroidTestingRunner;
import android.testing.TestableLooper;
import android.view.GestureDetector;
import android.view.IWindowManager;
@@ -52,6 +51,7 @@
import android.window.OnBackInvokedCallback;
import android.window.OnBackInvokedDispatcher;
+import androidx.test.ext.junit.runners.AndroidJUnit4;
import androidx.test.filters.FlakyTest;
import androidx.test.filters.SmallTest;
@@ -99,7 +99,7 @@
import java.util.concurrent.Executor;
@SmallTest
-@RunWith(AndroidTestingRunner.class)
+@RunWith(AndroidJUnit4.class)
@TestableLooper.RunWithLooper(setAsMainLooper = true)
public class GlobalActionsDialogLiteTest extends SysuiTestCase {
private GlobalActionsDialogLite mGlobalActionsDialogLite;
diff --git a/packages/SystemUI/tests/src/com/android/systemui/keyboard/docking/ui/viewmodel/KeyboardDockingIndicationViewModelTest.kt b/packages/SystemUI/tests/src/com/android/systemui/keyboard/docking/ui/viewmodel/KeyboardDockingIndicationViewModelTest.kt
new file mode 100644
index 0000000..3a86868
--- /dev/null
+++ b/packages/SystemUI/tests/src/com/android/systemui/keyboard/docking/ui/viewmodel/KeyboardDockingIndicationViewModelTest.kt
@@ -0,0 +1,99 @@
+/*
+ * 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.systemui.keyboard.docking.ui.viewmodel
+
+import android.graphics.Rect
+import android.view.WindowInsets
+import android.view.WindowManager
+import android.view.WindowMetrics
+import androidx.test.filters.SmallTest
+import com.android.systemui.SysuiTestCase
+import com.android.systemui.common.ui.data.repository.FakeConfigurationRepository
+import com.android.systemui.common.ui.domain.interactor.ConfigurationInteractor
+import com.android.systemui.keyboard.data.repository.FakeKeyboardRepository
+import com.android.systemui.keyboard.docking.domain.interactor.KeyboardDockingIndicationInteractor
+import com.google.common.truth.Truth.assertThat
+import kotlinx.coroutines.test.StandardTestDispatcher
+import kotlinx.coroutines.test.TestScope
+import kotlinx.coroutines.test.runTest
+import org.junit.Before
+import org.junit.Test
+import org.junit.runner.RunWith
+import org.junit.runners.JUnit4
+import org.mockito.Mockito.spy
+import org.mockito.MockitoAnnotations
+import org.mockito.kotlin.doReturn
+import org.mockito.kotlin.whenever
+
+@SmallTest
+@RunWith(JUnit4::class)
+class KeyboardDockingIndicationViewModelTest : SysuiTestCase() {
+ private val testScope = TestScope(StandardTestDispatcher())
+
+ private lateinit var keyboardRepository: FakeKeyboardRepository
+ private lateinit var configurationRepository: FakeConfigurationRepository
+ private lateinit var underTest: KeyboardDockingIndicationViewModel
+ private lateinit var windowManager: WindowManager
+
+ @Before
+ fun setup() {
+ MockitoAnnotations.initMocks(this)
+
+ keyboardRepository = FakeKeyboardRepository()
+ configurationRepository = FakeConfigurationRepository()
+ windowManager = spy(context.getSystemService(WindowManager::class.java)!!)
+
+ val keyboardDockingIndicationInteractor =
+ KeyboardDockingIndicationInteractor(keyboardRepository)
+ val configurationInteractor = ConfigurationInteractor(configurationRepository)
+
+ underTest =
+ KeyboardDockingIndicationViewModel(
+ windowManager,
+ context,
+ keyboardDockingIndicationInteractor,
+ configurationInteractor,
+ testScope.backgroundScope
+ )
+ }
+
+ @Test
+ fun onConfigurationChanged_createsNewConfig() {
+ val oldBounds = Rect(0, 0, 10, 10)
+ val newBounds = Rect(10, 10, 20, 20)
+ val inset = WindowInsets(Rect(1, 1, 1, 1))
+ val density = 1f
+
+ doReturn(WindowMetrics(oldBounds, inset, density))
+ .whenever(windowManager)
+ .currentWindowMetrics
+
+ val firstGlow = underTest.edgeGlow.value
+
+ testScope.runTest {
+ configurationRepository.onAnyConfigurationChange()
+ // Ensure there's some change in the config so that flow emits the new value.
+ doReturn(WindowMetrics(newBounds, inset, density))
+ .whenever(windowManager)
+ .currentWindowMetrics
+
+ val secondGlow = underTest.edgeGlow.value
+
+ assertThat(firstGlow.hashCode()).isNotEqualTo(secondGlow.hashCode())
+ }
+ }
+}
diff --git a/packages/SystemUI/tests/src/com/android/systemui/keyguard/domain/interactor/KeyguardTransitionScenariosTest.kt b/packages/SystemUI/tests/src/com/android/systemui/keyguard/domain/interactor/KeyguardTransitionScenariosTest.kt
index e02fb29..86a976f 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/keyguard/domain/interactor/KeyguardTransitionScenariosTest.kt
+++ b/packages/SystemUI/tests/src/com/android/systemui/keyguard/domain/interactor/KeyguardTransitionScenariosTest.kt
@@ -570,13 +570,13 @@
// WHEN biometrics succeeds with wake and unlock mode
powerInteractor.setAwakeForTest()
keyguardRepository.setBiometricUnlockState(BiometricUnlockMode.WAKE_AND_UNLOCK)
- advanceTimeBy(60L)
+ runCurrent()
assertThat(transitionRepository)
.startedTransition(
to = KeyguardState.GONE,
from = KeyguardState.DOZING,
- ownerName = "FromDozingTransitionInteractor",
+ ownerName = "FromDozingTransitionInteractor(biometric wake and unlock)",
animatorAssertion = { it.isNotNull() }
)
diff --git a/packages/SystemUI/tests/src/com/android/systemui/keyguard/ui/viewmodel/KeyguardQuickAffordancesCombinedViewModelTest.kt b/packages/SystemUI/tests/src/com/android/systemui/keyguard/ui/viewmodel/KeyguardQuickAffordancesCombinedViewModelTest.kt
index 16dd9af..e33d75c 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/keyguard/ui/viewmodel/KeyguardQuickAffordancesCombinedViewModelTest.kt
+++ b/packages/SystemUI/tests/src/com/android/systemui/keyguard/ui/viewmodel/KeyguardQuickAffordancesCombinedViewModelTest.kt
@@ -50,7 +50,6 @@
import com.android.systemui.keyguard.shared.quickaffordance.ActivationState
import com.android.systemui.keyguard.shared.quickaffordance.KeyguardQuickAffordancePosition
import com.android.systemui.keyguard.shared.quickaffordance.KeyguardQuickAffordancesMetricsLogger
-import com.android.systemui.kosmos.applicationCoroutineScope
import com.android.systemui.kosmos.testDispatcher
import com.android.systemui.kosmos.testScope
import com.android.systemui.plugins.ActivityStarter
@@ -290,7 +289,6 @@
underTest =
KeyguardQuickAffordancesCombinedViewModel(
- applicationScope = kosmos.applicationCoroutineScope,
quickAffordanceInteractor =
KeyguardQuickAffordanceInteractor(
keyguardInteractor = keyguardInteractor,
diff --git a/packages/SystemUI/tests/src/com/android/systemui/media/controls/domain/pipeline/LegacyMediaDataManagerImplTest.kt b/packages/SystemUI/tests/src/com/android/systemui/media/controls/domain/pipeline/LegacyMediaDataManagerImplTest.kt
index 3372f06..bdee936 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/media/controls/domain/pipeline/LegacyMediaDataManagerImplTest.kt
+++ b/packages/SystemUI/tests/src/com/android/systemui/media/controls/domain/pipeline/LegacyMediaDataManagerImplTest.kt
@@ -40,9 +40,9 @@
import android.os.Bundle
import android.provider.Settings
import android.service.notification.StatusBarNotification
-import android.testing.AndroidTestingRunner
import android.testing.TestableLooper.RunWithLooper
import androidx.media.utils.MediaConstants
+import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.filters.SmallTest
import com.android.dx.mockito.inline.extended.ExtendedMockito
import com.android.internal.logging.InstanceId
@@ -113,7 +113,7 @@
@SmallTest
@RunWithLooper(setAsMainLooper = true)
-@RunWith(AndroidTestingRunner::class)
+@RunWith(AndroidJUnit4::class)
class LegacyMediaDataManagerImplTest : SysuiTestCase() {
@JvmField @Rule val mockito = MockitoJUnit.rule()
diff --git a/packages/SystemUI/tests/src/com/android/systemui/media/controls/domain/pipeline/MediaDataProcessorTest.kt b/packages/SystemUI/tests/src/com/android/systemui/media/controls/domain/pipeline/MediaDataProcessorTest.kt
index 3906c40..18b4c48 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/media/controls/domain/pipeline/MediaDataProcessorTest.kt
+++ b/packages/SystemUI/tests/src/com/android/systemui/media/controls/domain/pipeline/MediaDataProcessorTest.kt
@@ -40,10 +40,10 @@
import android.os.Bundle
import android.provider.Settings
import android.service.notification.StatusBarNotification
-import android.testing.AndroidTestingRunner
import android.testing.TestableLooper
import android.testing.TestableLooper.RunWithLooper
import androidx.media.utils.MediaConstants
+import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.filters.SmallTest
import com.android.dx.mockito.inline.extended.ExtendedMockito
import com.android.internal.logging.InstanceId
@@ -125,7 +125,7 @@
@OptIn(ExperimentalCoroutinesApi::class)
@SmallTest
@RunWithLooper(setAsMainLooper = true)
-@RunWith(AndroidTestingRunner::class)
+@RunWith(AndroidJUnit4::class)
class MediaDataProcessorTest : SysuiTestCase() {
val kosmos = testKosmos()
diff --git a/packages/SystemUI/tests/src/com/android/systemui/media/controls/ui/controller/MediaCarouselControllerTest.kt b/packages/SystemUI/tests/src/com/android/systemui/media/controls/ui/controller/MediaCarouselControllerTest.kt
index 3ca5b42..f7b3f2e 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/media/controls/ui/controller/MediaCarouselControllerTest.kt
+++ b/packages/SystemUI/tests/src/com/android/systemui/media/controls/ui/controller/MediaCarouselControllerTest.kt
@@ -196,7 +196,7 @@
whenever(mediaFlags.isPersistentSsCardEnabled()).thenReturn(false)
MediaPlayerData.clear()
verify(globalSettings)
- .registerContentObserver(
+ .registerContentObserverSync(
eq(Settings.Global.getUriFor(Settings.Global.ANIMATOR_DURATION_SCALE)),
capture(settingsObserverCaptor)
)
diff --git a/packages/SystemUI/tests/src/com/android/systemui/media/dialog/MediaOutputAdapterTest.java b/packages/SystemUI/tests/src/com/android/systemui/media/dialog/MediaOutputAdapterTest.java
index 95e34a9..ec02c64 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/media/dialog/MediaOutputAdapterTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/media/dialog/MediaOutputAdapterTest.java
@@ -35,13 +35,13 @@
import android.app.WallpaperColors;
import android.graphics.Bitmap;
import android.graphics.drawable.Icon;
-import android.testing.AndroidTestingRunner;
import android.testing.TestableLooper;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.SeekBar;
import androidx.core.graphics.drawable.IconCompat;
+import androidx.test.ext.junit.runners.AndroidJUnit4;
import androidx.test.filters.SmallTest;
import com.android.settingslib.media.LocalMediaManager;
@@ -62,7 +62,7 @@
import java.util.stream.Collectors;
@SmallTest
-@RunWith(AndroidTestingRunner.class)
+@RunWith(AndroidJUnit4.class)
@TestableLooper.RunWithLooper(setAsMainLooper = true)
public class MediaOutputAdapterTest extends SysuiTestCase {
diff --git a/packages/SystemUI/tests/src/com/android/systemui/media/dialog/MediaOutputBaseDialogTest.java b/packages/SystemUI/tests/src/com/android/systemui/media/dialog/MediaOutputBaseDialogTest.java
index 9616f610..d5cd86e 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/media/dialog/MediaOutputBaseDialogTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/media/dialog/MediaOutputBaseDialogTest.java
@@ -34,7 +34,6 @@
import android.media.session.PlaybackState;
import android.os.Bundle;
import android.os.PowerExemptionManager;
-import android.testing.AndroidTestingRunner;
import android.testing.TestableLooper;
import android.view.View;
import android.widget.Button;
@@ -42,6 +41,7 @@
import android.widget.TextView;
import androidx.core.graphics.drawable.IconCompat;
+import androidx.test.ext.junit.runners.AndroidJUnit4;
import androidx.test.filters.SmallTest;
import com.android.settingslib.bluetooth.CachedBluetoothDeviceManager;
@@ -67,7 +67,7 @@
import java.util.List;
@SmallTest
-@RunWith(AndroidTestingRunner.class)
+@RunWith(AndroidJUnit4.class)
@TestableLooper.RunWithLooper(setAsMainLooper = true)
public class MediaOutputBaseDialogTest extends SysuiTestCase {
diff --git a/packages/SystemUI/tests/src/com/android/systemui/media/dialog/MediaOutputBroadcastDialogTest.java b/packages/SystemUI/tests/src/com/android/systemui/media/dialog/MediaOutputBroadcastDialogTest.java
index 16b00c0..87d2245 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/media/dialog/MediaOutputBroadcastDialogTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/media/dialog/MediaOutputBroadcastDialogTest.java
@@ -33,13 +33,13 @@
import android.media.AudioManager;
import android.media.session.MediaSessionManager;
import android.os.PowerExemptionManager;
-import android.testing.AndroidTestingRunner;
import android.testing.TestableLooper;
import android.view.View;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.TextView;
+import androidx.test.ext.junit.runners.AndroidJUnit4;
import androidx.test.filters.SmallTest;
import com.android.settingslib.bluetooth.CachedBluetoothDevice;
@@ -72,7 +72,7 @@
import java.util.List;
@SmallTest
-@RunWith(AndroidTestingRunner.class)
+@RunWith(AndroidJUnit4.class)
@TestableLooper.RunWithLooper
public class MediaOutputBroadcastDialogTest extends SysuiTestCase {
diff --git a/packages/SystemUI/tests/src/com/android/systemui/media/dialog/MediaOutputDialogTest.java b/packages/SystemUI/tests/src/com/android/systemui/media/dialog/MediaOutputDialogTest.java
index 92d0a72..f20b04a 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/media/dialog/MediaOutputDialogTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/media/dialog/MediaOutputDialogTest.java
@@ -38,12 +38,12 @@
import android.platform.test.annotations.RequiresFlagsEnabled;
import android.platform.test.flag.junit.CheckFlagsRule;
import android.platform.test.flag.junit.DeviceFlagsValueProvider;
-import android.testing.AndroidTestingRunner;
import android.testing.TestableLooper;
import android.util.FeatureFlagUtils;
import android.view.View;
import androidx.annotation.NonNull;
+import androidx.test.ext.junit.runners.AndroidJUnit4;
import androidx.test.filters.MediumTest;
import com.android.internal.logging.UiEventLogger;
@@ -75,7 +75,7 @@
import java.util.function.Consumer;
@MediumTest
-@RunWith(AndroidTestingRunner.class)
+@RunWith(AndroidJUnit4.class)
@TestableLooper.RunWithLooper
public class MediaOutputDialogTest extends SysuiTestCase {
diff --git a/packages/SystemUI/tests/src/com/android/systemui/mediaprojection/permission/MediaProjectionPermissionDialogDelegateTest.kt b/packages/SystemUI/tests/src/com/android/systemui/mediaprojection/permission/MediaProjectionPermissionDialogDelegateTest.kt
index e044eec..548366e 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/mediaprojection/permission/MediaProjectionPermissionDialogDelegateTest.kt
+++ b/packages/SystemUI/tests/src/com/android/systemui/mediaprojection/permission/MediaProjectionPermissionDialogDelegateTest.kt
@@ -18,11 +18,11 @@
import android.app.AlertDialog
import android.media.projection.MediaProjectionConfig
-import android.testing.AndroidTestingRunner
import android.testing.TestableLooper
import android.view.WindowManager
import android.widget.Spinner
import android.widget.TextView
+import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.filters.SmallTest
import com.android.systemui.SysuiTestCase
import com.android.systemui.flags.FeatureFlagsClassic
@@ -40,7 +40,7 @@
import org.mockito.Mockito.`when` as whenever
@SmallTest
-@RunWith(AndroidTestingRunner::class)
+@RunWith(AndroidJUnit4::class)
@TestableLooper.RunWithLooper(setAsMainLooper = true)
class MediaProjectionPermissionDialogDelegateTest : SysuiTestCase() {
diff --git a/packages/SystemUI/tests/src/com/android/systemui/navigationbar/NavigationBarButtonTest.java b/packages/SystemUI/tests/src/com/android/systemui/navigationbar/NavigationBarButtonTest.java
index 3eb7329..85244fd 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/navigationbar/NavigationBarButtonTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/navigationbar/NavigationBarButtonTest.java
@@ -27,12 +27,12 @@
import android.hardware.display.VirtualDisplay;
import android.media.ImageReader;
import android.os.SystemClock;
-import android.testing.AndroidTestingRunner;
import android.testing.TestableLooper.RunWithLooper;
import android.util.Log;
import android.view.Display;
import android.view.DisplayInfo;
+import androidx.test.ext.junit.runners.AndroidJUnit4;
import androidx.test.filters.SmallTest;
import com.android.systemui.SysuiTestCase;
@@ -53,7 +53,7 @@
import java.util.function.Predicate;
/** atest NavigationBarButtonTest */
-@RunWith(AndroidTestingRunner.class)
+@RunWith(AndroidJUnit4.class)
@RunWithLooper
@SmallTest
public class NavigationBarButtonTest extends SysuiTestCase {
diff --git a/packages/SystemUI/tests/src/com/android/systemui/navigationbar/NavigationBarControllerImplTest.java b/packages/SystemUI/tests/src/com/android/systemui/navigationbar/NavigationBarControllerImplTest.java
index 354a87a..d5361ac 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/navigationbar/NavigationBarControllerImplTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/navigationbar/NavigationBarControllerImplTest.java
@@ -39,9 +39,9 @@
import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.verify;
-import android.testing.AndroidTestingRunner;
import android.util.SparseArray;
+import androidx.test.ext.junit.runners.AndroidJUnit4;
import androidx.test.filters.SmallTest;
import com.android.dx.mockito.inline.extended.StaticMockitoSession;
@@ -72,7 +72,7 @@
import java.util.Optional;
/** atest NavigationBarControllerTest */
-@RunWith(AndroidTestingRunner.class)
+@RunWith(AndroidJUnit4.class)
@SmallTest
public class NavigationBarControllerImplTest extends SysuiTestCase {
diff --git a/packages/SystemUI/tests/src/com/android/systemui/navigationbar/NavigationBarInflaterViewTest.java b/packages/SystemUI/tests/src/com/android/systemui/navigationbar/NavigationBarInflaterViewTest.java
index 52d02b6..a358c18 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/navigationbar/NavigationBarInflaterViewTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/navigationbar/NavigationBarInflaterViewTest.java
@@ -22,12 +22,12 @@
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.spy;
-import android.testing.AndroidTestingRunner;
import android.testing.TestableLooper.RunWithLooper;
import android.util.SparseArray;
import android.view.View;
import android.widget.FrameLayout;
+import androidx.test.ext.junit.runners.AndroidJUnit4;
import androidx.test.filters.SmallTest;
import com.android.systemui.SysuiTestCase;
@@ -41,7 +41,7 @@
import org.junit.runner.RunWith;
/** atest NavigationBarInflaterViewTest */
-@RunWith(AndroidTestingRunner.class)
+@RunWith(AndroidJUnit4.class)
@RunWithLooper
@SmallTest
public class NavigationBarInflaterViewTest extends SysuiTestCase {
diff --git a/packages/SystemUI/tests/src/com/android/systemui/navigationbar/NavigationBarTest.java b/packages/SystemUI/tests/src/com/android/systemui/navigationbar/NavigationBarTest.java
index 6cea1e8..2b60f65 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/navigationbar/NavigationBarTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/navigationbar/NavigationBarTest.java
@@ -57,7 +57,6 @@
import android.os.SystemClock;
import android.provider.DeviceConfig;
import android.telecom.TelecomManager;
-import android.testing.AndroidTestingRunner;
import android.testing.TestableLooper;
import android.testing.TestableLooper.RunWithLooper;
import android.view.Display;
@@ -73,6 +72,7 @@
import android.view.accessibility.AccessibilityManager;
import android.view.inputmethod.InputMethodManager;
+import androidx.test.ext.junit.runners.AndroidJUnit4;
import androidx.test.filters.SmallTest;
import com.android.internal.logging.MetricsLogger;
@@ -132,7 +132,7 @@
import java.util.Optional;
import java.util.concurrent.Executor;
-@RunWith(AndroidTestingRunner.class)
+@RunWith(AndroidJUnit4.class)
@RunWithLooper(setAsMainLooper = true)
@SmallTest
public class NavigationBarTest extends SysuiTestCase {
diff --git a/packages/SystemUI/tests/src/com/android/systemui/navigationbar/NavigationBarTransitionsTest.java b/packages/SystemUI/tests/src/com/android/systemui/navigationbar/NavigationBarTransitionsTest.java
index fb08bf5..fbfd35f 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/navigationbar/NavigationBarTransitionsTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/navigationbar/NavigationBarTransitionsTest.java
@@ -25,9 +25,9 @@
import static org.mockito.Mockito.when;
import android.content.Context;
-import android.testing.AndroidTestingRunner;
import android.testing.TestableLooper.RunWithLooper;
+import androidx.test.ext.junit.runners.AndroidJUnit4;
import androidx.test.filters.SmallTest;
import com.android.systemui.SysuiTestCase;
@@ -46,7 +46,7 @@
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
-@RunWith(AndroidTestingRunner.class)
+@RunWith(AndroidJUnit4.class)
@RunWithLooper
@SmallTest
public class NavigationBarTransitionsTest extends SysuiTestCase {
@@ -105,4 +105,4 @@
assertTrue(mTransitions.isLightsOut(BarTransitions.MODE_LIGHTS_OUT));
}
-}
\ No newline at end of file
+}
diff --git a/packages/SystemUI/tests/src/com/android/systemui/navigationbar/buttons/KeyButtonViewTest.java b/packages/SystemUI/tests/src/com/android/systemui/navigationbar/buttons/KeyButtonViewTest.java
index a1010a0..841f620 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/navigationbar/buttons/KeyButtonViewTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/navigationbar/buttons/KeyButtonViewTest.java
@@ -40,11 +40,11 @@
import static org.mockito.Mockito.verify;
import android.hardware.input.InputManagerGlobal;
-import android.testing.AndroidTestingRunner;
import android.testing.TestableLooper;
import android.testing.TestableLooper.RunWithLooper;
import android.view.KeyEvent;
+import androidx.test.ext.junit.runners.AndroidJUnit4;
import androidx.test.filters.SmallTest;
import com.android.internal.logging.MetricsLogger;
@@ -60,7 +60,7 @@
import org.mockito.Captor;
import org.mockito.MockitoAnnotations;
-@RunWith(AndroidTestingRunner.class)
+@RunWith(AndroidJUnit4.class)
@RunWithLooper
@SmallTest
public class KeyButtonViewTest extends SysuiTestCase {
@@ -164,4 +164,4 @@
verify(mUiEventLogger, times(1)).log(expected);
}
}
-}
\ No newline at end of file
+}
diff --git a/packages/SystemUI/tests/src/com/android/systemui/navigationbar/buttons/NearestTouchFrameTest.java b/packages/SystemUI/tests/src/com/android/systemui/navigationbar/buttons/NearestTouchFrameTest.java
index 038b42b..6a3c615 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/navigationbar/buttons/NearestTouchFrameTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/navigationbar/buttons/NearestTouchFrameTest.java
@@ -28,11 +28,11 @@
import android.content.Context;
import android.content.res.Configuration;
import android.graphics.Rect;
-import android.testing.AndroidTestingRunner;
import android.testing.TestableLooper.RunWithLooper;
import android.view.MotionEvent;
import android.view.View;
+import androidx.test.ext.junit.runners.AndroidJUnit4;
import androidx.test.filters.SmallTest;
import com.android.systemui.SysuiTestCase;
@@ -46,7 +46,7 @@
import java.util.Map;
-@RunWith(AndroidTestingRunner.class)
+@RunWith(AndroidJUnit4.class)
@RunWithLooper
@SmallTest
public class NearestTouchFrameTest extends SysuiTestCase {
@@ -276,4 +276,4 @@
v.setBottom(height);
return v;
}
-}
\ No newline at end of file
+}
diff --git a/packages/SystemUI/tests/src/com/android/systemui/navigationbar/gestural/BackPanelControllerTest.kt b/packages/SystemUI/tests/src/com/android/systemui/navigationbar/gestural/BackPanelControllerTest.kt
index 23cf7fb..b169cc1 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/navigationbar/gestural/BackPanelControllerTest.kt
+++ b/packages/SystemUI/tests/src/com/android/systemui/navigationbar/gestural/BackPanelControllerTest.kt
@@ -17,7 +17,6 @@
package com.android.systemui.navigationbar.gestural
import android.os.Handler
-import android.testing.AndroidTestingRunner
import android.testing.TestableLooper
import android.view.HapticFeedbackConstants
import android.view.MotionEvent
@@ -26,6 +25,7 @@
import android.view.MotionEvent.ACTION_UP
import android.view.ViewConfiguration
import android.view.WindowManager
+import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.filters.SmallTest
import com.android.internal.jank.Cuj
import com.android.internal.util.LatencyTracker
@@ -49,7 +49,7 @@
import org.mockito.MockitoAnnotations
@SmallTest
-@RunWith(AndroidTestingRunner::class)
+@RunWith(AndroidJUnit4::class)
@TestableLooper.RunWithLooper(setAsMainLooper = true)
class BackPanelControllerTest : SysuiTestCase() {
companion object {
diff --git a/packages/SystemUI/tests/src/com/android/systemui/navigationbar/gestural/FloatingRotationButtonPositionCalculatorTest.kt b/packages/SystemUI/tests/src/com/android/systemui/navigationbar/gestural/FloatingRotationButtonPositionCalculatorTest.kt
index 5f206b3..f3cea3e 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/navigationbar/gestural/FloatingRotationButtonPositionCalculatorTest.kt
+++ b/packages/SystemUI/tests/src/com/android/systemui/navigationbar/gestural/FloatingRotationButtonPositionCalculatorTest.kt
@@ -8,10 +8,12 @@
import com.android.systemui.shared.rotation.FloatingRotationButtonPositionCalculator.Position
import com.google.common.truth.Truth.assertThat
import org.junit.Test
+import platform.test.runner.parameterized.ParameterizedAndroidJunit4
+import platform.test.runner.parameterized.Parameter
+import platform.test.runner.parameterized.Parameters
import org.junit.runner.RunWith
-import org.junit.runners.Parameterized
-@RunWith(Parameterized::class)
+@RunWith(ParameterizedAndroidJunit4::class)
@SmallTest
internal class FloatingRotationButtonPositionCalculatorTest(
private val testCase: TestCase,
@@ -61,7 +63,7 @@
MARGIN_DEFAULT, MARGIN_TASKBAR_LEFT, MARGIN_TASKBAR_BOTTOM, false
)
- @Parameterized.Parameters(name = "{0}")
+ @Parameters(name = "{0}")
@JvmStatic
fun getParams(): Collection<TestCase> =
listOf(
diff --git a/packages/SystemUI/tests/src/com/android/systemui/notetask/LaunchNotesRoleSettingsTrampolineActivityTest.kt b/packages/SystemUI/tests/src/com/android/systemui/notetask/LaunchNotesRoleSettingsTrampolineActivityTest.kt
index bdb095a..0f13f03 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/notetask/LaunchNotesRoleSettingsTrampolineActivityTest.kt
+++ b/packages/SystemUI/tests/src/com/android/systemui/notetask/LaunchNotesRoleSettingsTrampolineActivityTest.kt
@@ -18,8 +18,8 @@
import android.content.Context
import android.content.Intent
-import android.testing.AndroidTestingRunner
import android.testing.TestableLooper
+import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.filters.SmallTest
import androidx.test.rule.ActivityTestRule
import com.android.dx.mockito.inline.extended.ExtendedMockito.verify
@@ -37,7 +37,7 @@
import org.mockito.Mock
import org.mockito.MockitoAnnotations
-@RunWith(AndroidTestingRunner::class)
+@RunWith(AndroidJUnit4::class)
@SmallTest
@TestableLooper.RunWithLooper
class LaunchNotesRoleSettingsTrampolineActivityTest : SysuiTestCase() {
diff --git a/packages/SystemUI/tests/src/com/android/systemui/notetask/NoteTaskBubblesServiceTest.kt b/packages/SystemUI/tests/src/com/android/systemui/notetask/NoteTaskBubblesServiceTest.kt
index 06127a7..9ef6b9c 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/notetask/NoteTaskBubblesServiceTest.kt
+++ b/packages/SystemUI/tests/src/com/android/systemui/notetask/NoteTaskBubblesServiceTest.kt
@@ -19,8 +19,8 @@
import android.content.Intent
import android.graphics.drawable.Icon
import android.os.UserHandle
+import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.filters.SmallTest
-import androidx.test.runner.AndroidJUnit4
import com.android.systemui.res.R
import com.android.systemui.SysuiTestCase
import com.android.systemui.notetask.NoteTaskBubblesController.NoteTaskBubblesService
diff --git a/packages/SystemUI/tests/src/com/android/systemui/notetask/NoteTaskControllerTest.kt b/packages/SystemUI/tests/src/com/android/systemui/notetask/NoteTaskControllerTest.kt
index b7618d2..0196f95 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/notetask/NoteTaskControllerTest.kt
+++ b/packages/SystemUI/tests/src/com/android/systemui/notetask/NoteTaskControllerTest.kt
@@ -42,9 +42,9 @@
import android.os.UserHandle
import android.os.UserManager
import android.provider.Settings
+import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.ext.truth.content.IntentSubject.assertThat
import androidx.test.filters.SmallTest
-import androidx.test.runner.AndroidJUnit4
import com.android.systemui.SysuiTestCase
import com.android.systemui.notetask.NoteTaskController.Companion.EXTRA_SHORTCUT_BADGE_OVERRIDE_PACKAGE
import com.android.systemui.notetask.NoteTaskController.Companion.SHORTCUT_ID
diff --git a/packages/SystemUI/tests/src/com/android/systemui/notetask/NoteTaskEventLoggerTest.kt b/packages/SystemUI/tests/src/com/android/systemui/notetask/NoteTaskEventLoggerTest.kt
index 4101c94..c9a5d06 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/notetask/NoteTaskEventLoggerTest.kt
+++ b/packages/SystemUI/tests/src/com/android/systemui/notetask/NoteTaskEventLoggerTest.kt
@@ -16,8 +16,8 @@
package com.android.systemui.notetask
import android.os.UserHandle
+import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.filters.SmallTest
-import androidx.test.runner.AndroidJUnit4
import com.android.internal.logging.UiEventLogger
import com.android.systemui.SysuiTestCase
import com.android.systemui.notetask.NoteTaskEventLogger.NoteTaskUiEvent.NOTE_CLOSED_VIA_STYLUS_TAIL_BUTTON
diff --git a/packages/SystemUI/tests/src/com/android/systemui/notetask/NoteTaskInfoResolverTest.kt b/packages/SystemUI/tests/src/com/android/systemui/notetask/NoteTaskInfoResolverTest.kt
index 2c86a8d..0c88da7 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/notetask/NoteTaskInfoResolverTest.kt
+++ b/packages/SystemUI/tests/src/com/android/systemui/notetask/NoteTaskInfoResolverTest.kt
@@ -19,8 +19,8 @@
import android.app.role.RoleManager
import android.content.pm.ApplicationInfo
import android.content.pm.PackageManager
+import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.filters.SmallTest
-import androidx.test.runner.AndroidJUnit4
import com.android.systemui.SysuiTestCase
import com.android.systemui.util.mockito.eq
import com.android.systemui.util.mockito.whenever
diff --git a/packages/SystemUI/tests/src/com/android/systemui/notetask/NoteTaskInfoTest.kt b/packages/SystemUI/tests/src/com/android/systemui/notetask/NoteTaskInfoTest.kt
index 24f39d1..8f4078b 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/notetask/NoteTaskInfoTest.kt
+++ b/packages/SystemUI/tests/src/com/android/systemui/notetask/NoteTaskInfoTest.kt
@@ -16,7 +16,7 @@
package com.android.systemui.notetask
import android.os.UserHandle
-import android.testing.AndroidTestingRunner
+import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.filters.SmallTest
import com.android.systemui.SysuiTestCase
import com.android.systemui.notetask.NoteTaskEntryPoint.WIDGET_PICKER_SHORTCUT_IN_MULTI_WINDOW_MODE
@@ -26,7 +26,7 @@
/** atest SystemUITests:NoteTaskInfoTest */
@SmallTest
-@RunWith(AndroidTestingRunner::class)
+@RunWith(AndroidJUnit4::class)
internal class NoteTaskInfoTest : SysuiTestCase() {
@Test
diff --git a/packages/SystemUI/tests/src/com/android/systemui/notetask/NoteTaskInitializerTest.kt b/packages/SystemUI/tests/src/com/android/systemui/notetask/NoteTaskInitializerTest.kt
index 7833007..1ec4814 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/notetask/NoteTaskInitializerTest.kt
+++ b/packages/SystemUI/tests/src/com/android/systemui/notetask/NoteTaskInitializerTest.kt
@@ -19,12 +19,12 @@
import android.app.role.RoleManager.ROLE_NOTES
import android.os.UserHandle
import android.os.UserManager
-import android.testing.AndroidTestingRunner
import android.view.KeyEvent
import android.view.KeyEvent.ACTION_DOWN
import android.view.KeyEvent.ACTION_UP
import android.view.KeyEvent.KEYCODE_N
import android.view.KeyEvent.KEYCODE_STYLUS_BUTTON_TAIL
+import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.filters.SmallTest
import com.android.keyguard.KeyguardUpdateMonitor
import com.android.systemui.SysuiTestCase
@@ -54,7 +54,7 @@
/** atest SystemUITests:NoteTaskInitializerTest */
@OptIn(ExperimentalCoroutinesApi::class, InternalNoteTaskApi::class)
@SmallTest
-@RunWith(AndroidTestingRunner::class)
+@RunWith(AndroidJUnit4::class)
internal class NoteTaskInitializerTest : SysuiTestCase() {
@Mock lateinit var commandQueue: CommandQueue
diff --git a/packages/SystemUI/tests/src/com/android/systemui/notetask/quickaffordance/NoteTaskQuickAffordanceConfigTest.kt b/packages/SystemUI/tests/src/com/android/systemui/notetask/quickaffordance/NoteTaskQuickAffordanceConfigTest.kt
index 231b333..f624f20 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/notetask/quickaffordance/NoteTaskQuickAffordanceConfigTest.kt
+++ b/packages/SystemUI/tests/src/com/android/systemui/notetask/quickaffordance/NoteTaskQuickAffordanceConfigTest.kt
@@ -25,7 +25,7 @@
import android.hardware.input.InputSettings
import android.os.UserHandle
import android.os.UserManager
-import android.testing.AndroidTestingRunner
+import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.filters.SmallTest
import com.android.dx.mockito.inline.extended.ExtendedMockito
import com.android.systemui.SysuiTestCase
@@ -63,7 +63,7 @@
/** atest SystemUITests:NoteTaskQuickAffordanceConfigTest */
@SmallTest
-@RunWith(AndroidTestingRunner::class)
+@RunWith(AndroidJUnit4::class)
internal class NoteTaskQuickAffordanceConfigTest : SysuiTestCase() {
@Mock lateinit var controller: NoteTaskController
diff --git a/packages/SystemUI/tests/src/com/android/systemui/notetask/shortcut/LaunchNoteTaskActivityTest.kt b/packages/SystemUI/tests/src/com/android/systemui/notetask/shortcut/LaunchNoteTaskActivityTest.kt
index 1f0f0d7..9969dcd 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/notetask/shortcut/LaunchNoteTaskActivityTest.kt
+++ b/packages/SystemUI/tests/src/com/android/systemui/notetask/shortcut/LaunchNoteTaskActivityTest.kt
@@ -16,8 +16,8 @@
package com.android.systemui.notetask.shortcut
-import android.testing.AndroidTestingRunner
import android.testing.TestableLooper
+import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.filters.SmallTest
import androidx.test.rule.ActivityTestRule
import com.android.dx.mockito.inline.extended.ExtendedMockito.verify
@@ -35,7 +35,7 @@
import org.mockito.Mock
import org.mockito.MockitoAnnotations
-@RunWith(AndroidTestingRunner::class)
+@RunWith(AndroidJUnit4::class)
@SmallTest
@TestableLooper.RunWithLooper
class LaunchNoteTaskActivityTest : SysuiTestCase() {
diff --git a/packages/SystemUI/tests/src/com/android/systemui/people/NotificationHelperTest.java b/packages/SystemUI/tests/src/com/android/systemui/people/NotificationHelperTest.java
index 1b713dd..3673a25 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/people/NotificationHelperTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/people/NotificationHelperTest.java
@@ -36,8 +36,8 @@
import android.os.Bundle;
import android.os.UserHandle;
import android.service.notification.StatusBarNotification;
-import android.testing.AndroidTestingRunner;
+import androidx.test.ext.junit.runners.AndroidJUnit4;
import androidx.test.filters.SmallTest;
import com.android.internal.util.ArrayUtils;
@@ -52,7 +52,7 @@
import java.util.List;
import java.util.Set;
-@RunWith(AndroidTestingRunner.class)
+@RunWith(AndroidJUnit4.class)
@SmallTest
public class NotificationHelperTest extends SysuiTestCase {
private static final String SHORTCUT_ID_1 = "101";
diff --git a/packages/SystemUI/tests/src/com/android/systemui/people/PeopleBackupFollowUpJobTest.java b/packages/SystemUI/tests/src/com/android/systemui/people/PeopleBackupFollowUpJobTest.java
index 0d1749c..dae3452 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/people/PeopleBackupFollowUpJobTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/people/PeopleBackupFollowUpJobTest.java
@@ -35,8 +35,8 @@
import android.net.Uri;
import android.os.RemoteException;
import android.preference.PreferenceManager;
-import android.testing.AndroidTestingRunner;
+import androidx.test.ext.junit.runners.AndroidJUnit4;
import androidx.test.filters.SmallTest;
import com.android.systemui.SysuiTestCase;
@@ -56,7 +56,7 @@
import java.util.Map;
import java.util.Set;
-@RunWith(AndroidTestingRunner.class)
+@RunWith(AndroidJUnit4.class)
@SmallTest
public class PeopleBackupFollowUpJobTest extends SysuiTestCase {
private static final String SHORTCUT_ID_1 = "101";
diff --git a/packages/SystemUI/tests/src/com/android/systemui/people/PeopleProviderTest.java b/packages/SystemUI/tests/src/com/android/systemui/people/PeopleProviderTest.java
index 50ab1c7..776cf19 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/people/PeopleProviderTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/people/PeopleProviderTest.java
@@ -29,9 +29,9 @@
import android.os.Bundle;
import android.os.RemoteException;
import android.os.UserHandle;
-import android.testing.AndroidTestingRunner;
import android.widget.RemoteViews;
+import androidx.test.ext.junit.runners.AndroidJUnit4;
import androidx.test.filters.SmallTest;
import com.android.systemui.SysuiTestCase;
@@ -46,7 +46,7 @@
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
-@RunWith(AndroidTestingRunner.class)
+@RunWith(AndroidJUnit4.class)
@SmallTest
public class PeopleProviderTest extends SysuiTestCase {
private static final String TAG = "PeopleProviderTest";
diff --git a/packages/SystemUI/tests/src/com/android/systemui/people/PeopleSpaceUtilsTest.java b/packages/SystemUI/tests/src/com/android/systemui/people/PeopleSpaceUtilsTest.java
index 84a8ab0..48afaa0 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/people/PeopleSpaceUtilsTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/people/PeopleSpaceUtilsTest.java
@@ -52,9 +52,9 @@
import android.os.Bundle;
import android.os.UserHandle;
import android.provider.ContactsContract;
-import android.testing.AndroidTestingRunner;
import android.util.DisplayMetrics;
+import androidx.test.ext.junit.runners.AndroidJUnit4;
import androidx.test.filters.SmallTest;
import com.android.internal.appwidget.IAppWidgetService;
@@ -81,7 +81,7 @@
import java.util.Map;
import java.util.Optional;
-@RunWith(AndroidTestingRunner.class)
+@RunWith(AndroidJUnit4.class)
@SmallTest
public class PeopleSpaceUtilsTest extends SysuiTestCase {
diff --git a/packages/SystemUI/tests/src/com/android/systemui/people/PeopleTileViewHelperTest.java b/packages/SystemUI/tests/src/com/android/systemui/people/PeopleTileViewHelperTest.java
index 3d1da00..a90c10a 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/people/PeopleTileViewHelperTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/people/PeopleTileViewHelperTest.java
@@ -52,12 +52,12 @@
import android.graphics.drawable.Icon;
import android.net.Uri;
import android.os.UserHandle;
-import android.testing.AndroidTestingRunner;
import android.util.DisplayMetrics;
import android.view.View;
import android.widget.RemoteViews;
import android.widget.TextView;
+import androidx.test.ext.junit.runners.AndroidJUnit4;
import androidx.test.filters.SmallTest;
import com.android.systemui.SysuiTestCase;
@@ -73,7 +73,7 @@
import java.time.Duration;
import java.util.Arrays;
-@RunWith(AndroidTestingRunner.class)
+@RunWith(AndroidJUnit4.class)
@SmallTest
public class PeopleTileViewHelperTest extends SysuiTestCase {
diff --git a/packages/SystemUI/tests/src/com/android/systemui/people/SharedPreferencesHelperTest.java b/packages/SystemUI/tests/src/com/android/systemui/people/SharedPreferencesHelperTest.java
index 7cd5e22..ae7fba9 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/people/SharedPreferencesHelperTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/people/SharedPreferencesHelperTest.java
@@ -24,8 +24,8 @@
import android.content.Context;
import android.content.SharedPreferences;
-import android.testing.AndroidTestingRunner;
+import androidx.test.ext.junit.runners.AndroidJUnit4;
import androidx.test.filters.SmallTest;
import com.android.systemui.SysuiTestCase;
@@ -34,7 +34,7 @@
import org.junit.Test;
import org.junit.runner.RunWith;
-@RunWith(AndroidTestingRunner.class)
+@RunWith(AndroidJUnit4.class)
@SmallTest
public class SharedPreferencesHelperTest extends SysuiTestCase {
private static final String SHORTCUT_ID_1 = "101";
diff --git a/packages/SystemUI/tests/src/com/android/systemui/people/widget/LaunchConversationActivityTest.java b/packages/SystemUI/tests/src/com/android/systemui/people/widget/LaunchConversationActivityTest.java
index c8ebd12..e701dc6 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/people/widget/LaunchConversationActivityTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/people/widget/LaunchConversationActivityTest.java
@@ -36,9 +36,9 @@
import android.os.UserHandle;
import android.os.UserManager;
import android.service.notification.NotificationListenerService;
-import android.testing.AndroidTestingRunner;
import android.testing.TestableLooper.RunWithLooper;
+import androidx.test.ext.junit.runners.AndroidJUnit4;
import androidx.test.filters.SmallTest;
import com.android.internal.statusbar.IStatusBarService;
@@ -64,7 +64,7 @@
import java.util.Optional;
@SmallTest
-@RunWith(AndroidTestingRunner.class)
+@RunWith(AndroidJUnit4.class)
@RunWithLooper
public class LaunchConversationActivityTest extends SysuiTestCase {
private static final String EMPTY_STRING = "";
diff --git a/packages/SystemUI/tests/src/com/android/systemui/people/widget/PeopleBackupHelperTest.java b/packages/SystemUI/tests/src/com/android/systemui/people/widget/PeopleBackupHelperTest.java
index 5d526e1..b3ded15 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/people/widget/PeopleBackupHelperTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/people/widget/PeopleBackupHelperTest.java
@@ -36,8 +36,8 @@
import android.os.RemoteException;
import android.os.UserHandle;
import android.preference.PreferenceManager;
-import android.testing.AndroidTestingRunner;
+import androidx.test.ext.junit.runners.AndroidJUnit4;
import androidx.test.filters.SmallTest;
import com.android.systemui.SysuiTestCase;
@@ -57,7 +57,7 @@
import java.util.Map;
import java.util.Set;
-@RunWith(AndroidTestingRunner.class)
+@RunWith(AndroidJUnit4.class)
@SmallTest
public class PeopleBackupHelperTest extends SysuiTestCase {
private static final String SHORTCUT_ID_1 = "101";
diff --git a/packages/SystemUI/tests/src/com/android/systemui/people/widget/PeopleSpaceWidgetManagerTest.java b/packages/SystemUI/tests/src/com/android/systemui/people/widget/PeopleSpaceWidgetManagerTest.java
index 0998c0c..56a2adc 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/people/widget/PeopleSpaceWidgetManagerTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/people/widget/PeopleSpaceWidgetManagerTest.java
@@ -99,10 +99,10 @@
import android.service.notification.ConversationChannelWrapper;
import android.service.notification.StatusBarNotification;
import android.service.notification.ZenModeConfig;
-import android.testing.AndroidTestingRunner;
import android.text.TextUtils;
import androidx.preference.PreferenceManager;
+import androidx.test.ext.junit.runners.AndroidJUnit4;
import androidx.test.filters.SmallTest;
import com.android.systemui.SysuiTestCase;
@@ -145,7 +145,7 @@
import java.util.stream.Collectors;
@SmallTest
-@RunWith(AndroidTestingRunner.class)
+@RunWith(AndroidJUnit4.class)
public class PeopleSpaceWidgetManagerTest extends SysuiTestCase {
private static final long MIN_LINGER_DURATION = 5;
diff --git a/packages/SystemUI/tests/src/com/android/systemui/power/PowerNotificationWarningsTest.java b/packages/SystemUI/tests/src/com/android/systemui/power/PowerNotificationWarningsTest.java
index b95d3aa..bdd8dc8 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/power/PowerNotificationWarningsTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/power/PowerNotificationWarningsTest.java
@@ -42,9 +42,9 @@
import android.os.Bundle;
import android.os.Handler;
import android.os.UserHandle;
-import android.testing.AndroidTestingRunner;
import android.testing.TestableLooper;
+import androidx.test.ext.junit.runners.AndroidJUnit4;
import androidx.test.filters.SmallTest;
import com.android.internal.logging.UiEventLogger;
@@ -70,7 +70,7 @@
import java.lang.ref.WeakReference;
@SmallTest
-@RunWith(AndroidTestingRunner.class)
+@RunWith(AndroidJUnit4.class)
@TestableLooper.RunWithLooper
public class PowerNotificationWarningsTest extends SysuiTestCase {
diff --git a/packages/SystemUI/tests/src/com/android/systemui/power/PowerUITest.java b/packages/SystemUI/tests/src/com/android/systemui/power/PowerUITest.java
index cae170f..4f4f0d9 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/power/PowerUITest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/power/PowerUITest.java
@@ -38,11 +38,11 @@
import android.provider.Settings;
import android.service.vr.IVrManager;
import android.service.vr.IVrStateCallbacks;
-import android.testing.AndroidTestingRunner;
import android.testing.TestableLooper;
import android.testing.TestableLooper.RunWithLooper;
import android.testing.TestableResources;
+import androidx.test.ext.junit.runners.AndroidJUnit4;
import androidx.test.filters.SmallTest;
import com.android.settingslib.fuelgauge.Estimate;
@@ -64,7 +64,7 @@
import java.time.Duration;
import java.util.concurrent.TimeUnit;
-@RunWith(AndroidTestingRunner.class)
+@RunWith(AndroidJUnit4.class)
@RunWithLooper
@SmallTest
public class PowerUITest extends SysuiTestCase {
diff --git a/packages/SystemUI/tests/src/com/android/systemui/power/data/repository/PowerRepositoryImplTest.kt b/packages/SystemUI/tests/src/com/android/systemui/power/data/repository/PowerRepositoryImplTest.kt
index f3b114d..02a3429 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/power/data/repository/PowerRepositoryImplTest.kt
+++ b/packages/SystemUI/tests/src/com/android/systemui/power/data/repository/PowerRepositoryImplTest.kt
@@ -21,6 +21,7 @@
import android.content.Intent
import android.content.IntentFilter
import android.os.PowerManager
+import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.filters.SmallTest
import com.android.systemui.SysuiTestCase
import com.android.systemui.broadcast.BroadcastDispatcher
@@ -37,7 +38,6 @@
import org.junit.Before
import org.junit.Test
import org.junit.runner.RunWith
-import org.junit.runners.JUnit4
import org.mockito.ArgumentCaptor
import org.mockito.Captor
import org.mockito.Mock
@@ -48,7 +48,7 @@
import org.mockito.MockitoAnnotations
@SmallTest
-@RunWith(JUnit4::class)
+@RunWith(AndroidJUnit4::class)
class PowerRepositoryImplTest : SysuiTestCase() {
private val systemClock = FakeSystemClock()
diff --git a/packages/SystemUI/tests/src/com/android/systemui/power/domain/interactor/PowerInteractorTest.kt b/packages/SystemUI/tests/src/com/android/systemui/power/domain/interactor/PowerInteractorTest.kt
index 42cf9f4..12c9eb9 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/power/domain/interactor/PowerInteractorTest.kt
+++ b/packages/SystemUI/tests/src/com/android/systemui/power/domain/interactor/PowerInteractorTest.kt
@@ -18,6 +18,7 @@
package com.android.systemui.power.domain.interactor
import android.os.PowerManager
+import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.filters.SmallTest
import com.android.systemui.SysuiTestCase
import com.android.systemui.classifier.FalsingCollector
@@ -39,13 +40,12 @@
import org.junit.Before
import org.junit.Test
import org.junit.runner.RunWith
-import org.junit.runners.JUnit4
import org.mockito.Mock
import org.mockito.Mockito.verify
import org.mockito.MockitoAnnotations
@SmallTest
-@RunWith(JUnit4::class)
+@RunWith(AndroidJUnit4::class)
class PowerInteractorTest : SysuiTestCase() {
private lateinit var underTest: PowerInteractor
diff --git a/packages/SystemUI/tests/src/com/android/systemui/privacy/AppOpsPrivacyItemMonitorTest.kt b/packages/SystemUI/tests/src/com/android/systemui/privacy/AppOpsPrivacyItemMonitorTest.kt
index 14ecf93..4bee924 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/privacy/AppOpsPrivacyItemMonitorTest.kt
+++ b/packages/SystemUI/tests/src/com/android/systemui/privacy/AppOpsPrivacyItemMonitorTest.kt
@@ -19,8 +19,8 @@
import android.app.AppOpsManager
import android.content.pm.UserInfo
import android.os.UserHandle
-import android.testing.AndroidTestingRunner
import android.testing.TestableLooper.RunWithLooper
+import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.filters.SmallTest
import com.android.systemui.SysuiTestCase
import com.android.systemui.appops.AppOpItem
@@ -52,7 +52,7 @@
import org.mockito.Mockito.verify
import org.mockito.MockitoAnnotations
-@RunWith(AndroidTestingRunner::class)
+@RunWith(AndroidJUnit4::class)
@SmallTest
@RunWithLooper
class AppOpsPrivacyItemMonitorTest : SysuiTestCase() {
@@ -385,4 +385,4 @@
`when`(privacyConfig.locationAvailable).thenReturn(value)
argCaptorConfigCallback.value.onFlagLocationChanged(value)
}
-}
\ No newline at end of file
+}
diff --git a/packages/SystemUI/tests/src/com/android/systemui/privacy/PrivacyChipBuilderTest.kt b/packages/SystemUI/tests/src/com/android/systemui/privacy/PrivacyChipBuilderTest.kt
index dcee5a716..0d6652c 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/privacy/PrivacyChipBuilderTest.kt
+++ b/packages/SystemUI/tests/src/com/android/systemui/privacy/PrivacyChipBuilderTest.kt
@@ -16,8 +16,8 @@
package com.android.systemui.privacy
+import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.filters.SmallTest
-import androidx.test.runner.AndroidJUnit4
import com.android.systemui.SysuiTestCase
import org.junit.Assert.assertEquals
import org.junit.Test
@@ -74,4 +74,4 @@
val appList = textBuilder.appsAndTypes.map { it.first }.map { it.packageName }
assertEquals(listOf("Camera", "Microphone", "Location"), appList)
}
-}
\ No newline at end of file
+}
diff --git a/packages/SystemUI/tests/src/com/android/systemui/privacy/PrivacyConfigFlagsTest.kt b/packages/SystemUI/tests/src/com/android/systemui/privacy/PrivacyConfigFlagsTest.kt
index 272f149..4768b88 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/privacy/PrivacyConfigFlagsTest.kt
+++ b/packages/SystemUI/tests/src/com/android/systemui/privacy/PrivacyConfigFlagsTest.kt
@@ -17,7 +17,7 @@
package com.android.systemui.privacy
import android.provider.DeviceConfig
-import android.testing.AndroidTestingRunner
+import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.filters.SmallTest
import com.android.internal.config.sysui.SystemUiDeviceConfigFlags
import com.android.systemui.SysuiTestCase
@@ -37,7 +37,7 @@
import org.mockito.Mockito.verify
import org.mockito.MockitoAnnotations
-@RunWith(AndroidTestingRunner::class)
+@RunWith(AndroidJUnit4::class)
@SmallTest
class PrivacyConfigFlagsTest : SysuiTestCase() {
companion object {
@@ -146,4 +146,4 @@
false
)
}
-}
\ No newline at end of file
+}
diff --git a/packages/SystemUI/tests/src/com/android/systemui/privacy/PrivacyDialogControllerTest.kt b/packages/SystemUI/tests/src/com/android/systemui/privacy/PrivacyDialogControllerTest.kt
index 84e9107..58afcb7 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/privacy/PrivacyDialogControllerTest.kt
+++ b/packages/SystemUI/tests/src/com/android/systemui/privacy/PrivacyDialogControllerTest.kt
@@ -30,7 +30,7 @@
import android.os.UserHandle
import android.permission.PermissionGroupUsage
import android.permission.PermissionManager
-import android.testing.AndroidTestingRunner
+import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.filters.SmallTest
import com.android.internal.logging.UiEventLogger
import com.android.systemui.SysuiTestCase
@@ -64,7 +64,7 @@
import org.mockito.MockitoAnnotations
@SmallTest
-@RunWith(AndroidTestingRunner::class)
+@RunWith(AndroidJUnit4::class)
class PrivacyDialogControllerTest : SysuiTestCase() {
companion object {
@@ -824,4 +824,4 @@
`when`(usage.proxyLabel).thenReturn(proxyLabel)
return usage
}
-}
\ No newline at end of file
+}
diff --git a/packages/SystemUI/tests/src/com/android/systemui/privacy/PrivacyDialogControllerV2Test.kt b/packages/SystemUI/tests/src/com/android/systemui/privacy/PrivacyDialogControllerV2Test.kt
index 0c7e099..1c63161 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/privacy/PrivacyDialogControllerV2Test.kt
+++ b/packages/SystemUI/tests/src/com/android/systemui/privacy/PrivacyDialogControllerV2Test.kt
@@ -30,8 +30,8 @@
import android.os.UserHandle
import android.permission.PermissionGroupUsage
import android.permission.PermissionManager
-import android.testing.AndroidTestingRunner
import android.widget.LinearLayout
+import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.filters.SmallTest
import com.android.internal.logging.UiEventLogger
import com.android.systemui.SysuiTestCase
@@ -66,7 +66,7 @@
import org.mockito.MockitoAnnotations
@SmallTest
-@RunWith(AndroidTestingRunner::class)
+@RunWith(AndroidJUnit4::class)
class PrivacyDialogControllerV2Test : SysuiTestCase() {
companion object {
diff --git a/packages/SystemUI/tests/src/com/android/systemui/privacy/PrivacyDialogTest.kt b/packages/SystemUI/tests/src/com/android/systemui/privacy/PrivacyDialogTest.kt
index b754145..9ac04cf 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/privacy/PrivacyDialogTest.kt
+++ b/packages/SystemUI/tests/src/com/android/systemui/privacy/PrivacyDialogTest.kt
@@ -16,11 +16,11 @@
package com.android.systemui.privacy
-import android.testing.AndroidTestingRunner
import android.testing.TestableLooper
import android.view.View
import android.view.ViewGroup
import android.widget.TextView
+import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.filters.SmallTest
import com.android.systemui.res.R
import com.android.systemui.SysuiTestCase
@@ -38,7 +38,7 @@
import android.text.TextUtils
@SmallTest
-@RunWith(AndroidTestingRunner::class)
+@RunWith(AndroidJUnit4::class)
@TestableLooper.RunWithLooper(setAsMainLooper = true)
class PrivacyDialogTest : SysuiTestCase() {
@@ -401,4 +401,4 @@
assertThat(TextUtils.isEmpty(dialog.window?.attributes?.title)).isFalse()
}
-}
\ No newline at end of file
+}
diff --git a/packages/SystemUI/tests/src/com/android/systemui/privacy/PrivacyDialogV2Test.kt b/packages/SystemUI/tests/src/com/android/systemui/privacy/PrivacyDialogV2Test.kt
index 6c01ba5..f7cf458 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/privacy/PrivacyDialogV2Test.kt
+++ b/packages/SystemUI/tests/src/com/android/systemui/privacy/PrivacyDialogV2Test.kt
@@ -17,12 +17,12 @@
package com.android.systemui.privacy
import android.content.Intent
-import android.testing.AndroidTestingRunner
import android.testing.TestableLooper
import android.view.View
import android.view.ViewGroup
import android.view.ViewGroup.LayoutParams.MATCH_PARENT
import android.widget.TextView
+import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.filters.SmallTest
import com.android.systemui.res.R
import com.android.systemui.SysuiTestCase
@@ -38,7 +38,7 @@
import org.mockito.MockitoAnnotations
@SmallTest
-@RunWith(AndroidTestingRunner::class)
+@RunWith(AndroidJUnit4::class)
@TestableLooper.RunWithLooper(setAsMainLooper = true)
class PrivacyDialogV2Test : SysuiTestCase() {
diff --git a/packages/SystemUI/tests/src/com/android/systemui/privacy/PrivacyItemControllerTest.kt b/packages/SystemUI/tests/src/com/android/systemui/privacy/PrivacyItemControllerTest.kt
index d563632..4f1fb71 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/privacy/PrivacyItemControllerTest.kt
+++ b/packages/SystemUI/tests/src/com/android/systemui/privacy/PrivacyItemControllerTest.kt
@@ -18,8 +18,8 @@
import android.app.ActivityManager
import android.os.UserHandle
-import android.testing.AndroidTestingRunner
import android.testing.TestableLooper.RunWithLooper
+import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.filters.SmallTest
import com.android.systemui.SysuiTestCase
import com.android.systemui.dump.DumpManager
@@ -49,7 +49,7 @@
import org.mockito.Mockito.verifyNoMoreInteractions
import org.mockito.MockitoAnnotations
-@RunWith(AndroidTestingRunner::class)
+@RunWith(AndroidJUnit4::class)
@SmallTest
@RunWithLooper
class PrivacyItemControllerTest : SysuiTestCase() {
@@ -417,4 +417,4 @@
assertTrue(privacyItemController.privacyList.isEmpty())
}
-}
\ No newline at end of file
+}
diff --git a/packages/SystemUI/tests/src/com/android/systemui/process/condition/SystemProcessConditionTest.java b/packages/SystemUI/tests/src/com/android/systemui/process/condition/SystemProcessConditionTest.java
index f573358..5250d56 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/process/condition/SystemProcessConditionTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/process/condition/SystemProcessConditionTest.java
@@ -19,9 +19,9 @@
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
-import android.testing.AndroidTestingRunner;
import android.testing.TestableLooper;
+import androidx.test.ext.junit.runners.AndroidJUnit4;
import androidx.test.filters.SmallTest;
import com.android.systemui.SysuiTestCase;
@@ -39,7 +39,7 @@
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
-@RunWith(AndroidTestingRunner.class)
+@RunWith(AndroidJUnit4.class)
@TestableLooper.RunWithLooper
@SmallTest
public class SystemProcessConditionTest extends SysuiTestCase {
diff --git a/packages/SystemUI/tests/src/com/android/systemui/qrcodescanner/controller/QRCodeScannerControllerTest.java b/packages/SystemUI/tests/src/com/android/systemui/qrcodescanner/controller/QRCodeScannerControllerTest.java
index e905e9c..8ccaf6b 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/qrcodescanner/controller/QRCodeScannerControllerTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/qrcodescanner/controller/QRCodeScannerControllerTest.java
@@ -34,9 +34,9 @@
import android.os.UserHandle;
import android.provider.DeviceConfig;
import android.provider.Settings;
-import android.testing.AndroidTestingRunner;
import android.testing.TestableLooper;
+import androidx.test.ext.junit.runners.AndroidJUnit4;
import androidx.test.filters.SmallTest;
import com.android.internal.config.sysui.SystemUiDeviceConfigFlags;
@@ -56,7 +56,7 @@
import java.util.Collections;
import java.util.List;
-@RunWith(AndroidTestingRunner.class)
+@RunWith(AndroidJUnit4.class)
@TestableLooper.RunWithLooper
@SmallTest
public class QRCodeScannerControllerTest extends SysuiTestCase {
diff --git a/packages/SystemUI/tests/src/com/android/systemui/qs/AutoAddTrackerTest.java b/packages/SystemUI/tests/src/com/android/systemui/qs/AutoAddTrackerTest.java
index dee1cc8..1eeaef7 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/qs/AutoAddTrackerTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/qs/AutoAddTrackerTest.java
@@ -30,9 +30,9 @@
import android.content.IntentFilter;
import android.os.UserHandle;
import android.provider.Settings.Secure;
-import android.testing.AndroidTestingRunner;
import android.testing.TestableLooper.RunWithLooper;
+import androidx.test.ext.junit.runners.AndroidJUnit4;
import androidx.test.filters.SmallTest;
import com.android.systemui.SysuiTestCase;
@@ -54,7 +54,7 @@
import java.util.List;
import java.util.concurrent.Executor;
-@RunWith(AndroidTestingRunner.class)
+@RunWith(AndroidJUnit4.class)
@RunWithLooper
@SmallTest
public class AutoAddTrackerTest extends SysuiTestCase {
@@ -308,4 +308,4 @@
user
);
}
-}
\ No newline at end of file
+}
diff --git a/packages/SystemUI/tests/src/com/android/systemui/qs/FgsManagerControllerTest.java b/packages/SystemUI/tests/src/com/android/systemui/qs/FgsManagerControllerTest.java
index d39a635..16ae466 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/qs/FgsManagerControllerTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/qs/FgsManagerControllerTest.java
@@ -43,9 +43,9 @@
import android.os.RemoteException;
import android.os.UserHandle;
import android.provider.DeviceConfig;
-import android.testing.AndroidTestingRunner;
import android.testing.TestableLooper;
+import androidx.test.ext.junit.runners.AndroidJUnit4;
import androidx.test.filters.SmallTest;
import com.android.internal.config.sysui.SystemUiDeviceConfigFlags;
@@ -73,7 +73,7 @@
import java.util.ArrayList;
import java.util.List;
-@RunWith(AndroidTestingRunner.class)
+@RunWith(AndroidJUnit4.class)
@TestableLooper.RunWithLooper
@SmallTest
public class FgsManagerControllerTest extends SysuiTestCase {
diff --git a/packages/SystemUI/tests/src/com/android/systemui/qs/HeaderPrivacyIconsControllerTest.kt b/packages/SystemUI/tests/src/com/android/systemui/qs/HeaderPrivacyIconsControllerTest.kt
index f98b68f..3ae7a16 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/qs/HeaderPrivacyIconsControllerTest.kt
+++ b/packages/SystemUI/tests/src/com/android/systemui/qs/HeaderPrivacyIconsControllerTest.kt
@@ -6,8 +6,8 @@
import android.content.IntentFilter
import android.permission.PermissionManager
import android.safetycenter.SafetyCenterManager
-import android.testing.AndroidTestingRunner
import android.view.View
+import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.filters.SmallTest
import com.android.internal.logging.UiEventLogger
import com.android.systemui.SysuiTestCase
@@ -46,7 +46,7 @@
private fun <T> any(): T = Mockito.any<T>()
@SmallTest
-@RunWith(AndroidTestingRunner::class)
+@RunWith(AndroidJUnit4::class)
class HeaderPrivacyIconsControllerTest : SysuiTestCase() {
@Mock
@@ -269,4 +269,4 @@
whenever(privacyItemController.micCameraAvailable).thenReturn(micCamera)
whenever(privacyItemController.locationAvailable).thenReturn(location)
}
-}
\ No newline at end of file
+}
diff --git a/packages/SystemUI/tests/src/com/android/systemui/qs/LeftRightArrowPressedListenerTest.kt b/packages/SystemUI/tests/src/com/android/systemui/qs/LeftRightArrowPressedListenerTest.kt
index 40eccad..466a09b 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/qs/LeftRightArrowPressedListenerTest.kt
+++ b/packages/SystemUI/tests/src/com/android/systemui/qs/LeftRightArrowPressedListenerTest.kt
@@ -16,11 +16,11 @@
package com.android.systemui.qs
-import android.testing.AndroidTestingRunner
import android.view.KeyEvent
import android.view.KeyEvent.KEYCODE_DPAD_LEFT
import android.view.View
import androidx.core.util.Consumer
+import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.filters.SmallTest
import com.android.systemui.SysuiTestCase
import com.google.common.truth.Truth.assertThat
@@ -28,7 +28,7 @@
import org.junit.Test
import org.junit.runner.RunWith
-@RunWith(AndroidTestingRunner::class)
+@RunWith(AndroidJUnit4::class)
@SmallTest
class LeftRightArrowPressedListenerTest : SysuiTestCase() {
diff --git a/packages/SystemUI/tests/src/com/android/systemui/qs/PagedTileLayoutTest.kt b/packages/SystemUI/tests/src/com/android/systemui/qs/PagedTileLayoutTest.kt
index 8ef3f57..db8612a 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/qs/PagedTileLayoutTest.kt
+++ b/packages/SystemUI/tests/src/com/android/systemui/qs/PagedTileLayoutTest.kt
@@ -1,9 +1,9 @@
package com.android.systemui.qs
import android.content.Context
-import android.testing.AndroidTestingRunner
import android.view.View
import android.widget.Scroller
+import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.filters.SmallTest
import com.android.systemui.SysuiTestCase
import com.android.systemui.qs.PageIndicator.PageScrollActionListener
@@ -19,7 +19,7 @@
import org.mockito.Mockito.verify
import org.mockito.MockitoAnnotations
-@RunWith(AndroidTestingRunner::class)
+@RunWith(AndroidJUnit4::class)
@SmallTest
class PagedTileLayoutTest : SysuiTestCase() {
diff --git a/packages/SystemUI/tests/src/com/android/systemui/qs/QSContainerImplTest.kt b/packages/SystemUI/tests/src/com/android/systemui/qs/QSContainerImplTest.kt
index 8c5d99a..52ad931 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/qs/QSContainerImplTest.kt
+++ b/packages/SystemUI/tests/src/com/android/systemui/qs/QSContainerImplTest.kt
@@ -1,9 +1,9 @@
package com.android.systemui.qs
-import android.testing.AndroidTestingRunner
import android.testing.TestableLooper
import android.view.View
import android.widget.FrameLayout
+import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.filters.SmallTest
import com.android.systemui.res.R
import com.android.systemui.SysuiTestCase
@@ -18,7 +18,7 @@
import org.mockito.MockitoAnnotations
import org.mockito.Mockito.`when` as whenever
-@RunWith(AndroidTestingRunner::class)
+@RunWith(AndroidJUnit4::class)
@TestableLooper.RunWithLooper
@SmallTest
class QSContainerImplTest : SysuiTestCase() {
@@ -70,4 +70,4 @@
eq(originalPadding)
)
}
-}
\ No newline at end of file
+}
diff --git a/packages/SystemUI/tests/src/com/android/systemui/qs/QSFooterViewControllerTest.java b/packages/SystemUI/tests/src/com/android/systemui/qs/QSFooterViewControllerTest.java
index 5ae0c24..fb58b90 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/qs/QSFooterViewControllerTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/qs/QSFooterViewControllerTest.java
@@ -27,11 +27,11 @@
import android.content.ClipData;
import android.content.ClipboardManager;
-import android.testing.AndroidTestingRunner;
import android.testing.TestableLooper;
import android.view.View;
import android.widget.TextView;
+import androidx.test.ext.junit.runners.AndroidJUnit4;
import androidx.test.filters.SmallTest;
import com.android.systemui.plugins.ActivityStarter;
@@ -49,7 +49,7 @@
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
-@RunWith(AndroidTestingRunner.class)
+@RunWith(AndroidJUnit4.class)
@TestableLooper.RunWithLooper
@SmallTest
public class QSFooterViewControllerTest extends LeakCheckedTest {
diff --git a/packages/SystemUI/tests/src/com/android/systemui/qs/QSImplTest.java b/packages/SystemUI/tests/src/com/android/systemui/qs/QSImplTest.java
index 09d6a1a..c0d390a 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/qs/QSImplTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/qs/QSImplTest.java
@@ -42,7 +42,6 @@
import android.content.Context;
import android.graphics.Rect;
import android.os.Bundle;
-import android.testing.AndroidTestingRunner;
import android.testing.TestableLooper.RunWithLooper;
import android.view.Display;
import android.view.LayoutInflater;
@@ -52,6 +51,7 @@
import androidx.compose.ui.platform.ComposeView;
import androidx.lifecycle.Lifecycle;
+import androidx.test.ext.junit.runners.AndroidJUnit4;
import androidx.test.filters.SmallTest;
import com.android.keyguard.BouncerPanelExpansionCalculator;
@@ -82,7 +82,7 @@
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
-@RunWith(AndroidTestingRunner.class)
+@RunWith(AndroidJUnit4.class)
@RunWithLooper(setAsMainLooper = true)
@SmallTest
public class QSImplTest extends SysuiTestCase {
diff --git a/packages/SystemUI/tests/src/com/android/systemui/qs/QSPanelControllerTest.kt b/packages/SystemUI/tests/src/com/android/systemui/qs/QSPanelControllerTest.kt
index 545d19d..02c5b5a 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/qs/QSPanelControllerTest.kt
+++ b/packages/SystemUI/tests/src/com/android/systemui/qs/QSPanelControllerTest.kt
@@ -1,8 +1,8 @@
package com.android.systemui.qs
import android.content.res.Configuration
+import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.filters.SmallTest
-import android.testing.AndroidTestingRunner
import android.testing.TestableResources
import android.view.ContextThemeWrapper
import com.android.internal.logging.MetricsLogger
@@ -41,7 +41,7 @@
import org.mockito.Mockito.`when` as whenever
@SmallTest
-@RunWith(AndroidTestingRunner::class)
+@RunWith(AndroidJUnit4::class)
class QSPanelControllerTest : SysuiTestCase() {
@Mock private lateinit var qsPanel: QSPanel
diff --git a/packages/SystemUI/tests/src/com/android/systemui/qs/QSPanelSwitchToParentTest.kt b/packages/SystemUI/tests/src/com/android/systemui/qs/QSPanelSwitchToParentTest.kt
index 56f2905..56e25fc 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/qs/QSPanelSwitchToParentTest.kt
+++ b/packages/SystemUI/tests/src/com/android/systemui/qs/QSPanelSwitchToParentTest.kt
@@ -18,9 +18,9 @@
import com.google.common.truth.Truth.assertThat
+import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.filters.SmallTest
-import android.testing.AndroidTestingRunner
import android.view.View
import android.view.ViewGroup
import android.widget.FrameLayout
@@ -30,7 +30,7 @@
import org.junit.Test
import org.junit.runner.RunWith
-@RunWith(AndroidTestingRunner::class)
+@RunWith(AndroidJUnit4::class)
@SmallTest
class QSPanelSwitchToParentTest : SysuiTestCase() {
@@ -159,4 +159,4 @@
private val ViewGroup.childrenList: List<View>
get() = children.toList()
-}
\ No newline at end of file
+}
diff --git a/packages/SystemUI/tests/src/com/android/systemui/qs/QSPanelTest.kt b/packages/SystemUI/tests/src/com/android/systemui/qs/QSPanelTest.kt
index e2a4d67..2d282dc 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/qs/QSPanelTest.kt
+++ b/packages/SystemUI/tests/src/com/android/systemui/qs/QSPanelTest.kt
@@ -14,7 +14,6 @@
package com.android.systemui.qs
import android.graphics.Rect
-import android.testing.AndroidTestingRunner
import android.testing.TestableContext
import android.testing.TestableLooper
import android.testing.TestableLooper.RunWithLooper
@@ -26,6 +25,7 @@
import android.view.accessibility.AccessibilityNodeInfo
import android.widget.FrameLayout
import android.widget.LinearLayout
+import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.filters.SmallTest
import com.android.systemui.res.R
import com.android.systemui.SysuiTestCase
@@ -45,7 +45,7 @@
import org.mockito.Mockito.verify
import org.mockito.MockitoAnnotations
-@RunWith(AndroidTestingRunner::class)
+@RunWith(AndroidJUnit4::class)
@RunWithLooper
@SmallTest
class QSPanelTest : SysuiTestCase() {
diff --git a/packages/SystemUI/tests/src/com/android/systemui/qs/QSSecurityFooterTest.java b/packages/SystemUI/tests/src/com/android/systemui/qs/QSSecurityFooterTest.java
index 0abcc64..dad65f5 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/qs/QSSecurityFooterTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/qs/QSSecurityFooterTest.java
@@ -42,7 +42,6 @@
import android.os.Looper;
import android.provider.DeviceConfig;
import android.provider.Settings;
-import android.testing.AndroidTestingRunner;
import android.testing.TestableLooper;
import android.testing.TestableLooper.RunWithLooper;
import android.text.SpannableStringBuilder;
@@ -51,6 +50,7 @@
import android.widget.TextView;
import androidx.annotation.Nullable;
+import androidx.test.ext.junit.runners.AndroidJUnit4;
import androidx.test.filters.SmallTest;
import com.android.systemui.SysuiTestCase;
@@ -83,7 +83,7 @@
*/
@SmallTest
-@RunWith(AndroidTestingRunner.class)
+@RunWith(AndroidJUnit4.class)
@RunWithLooper
public class QSSecurityFooterTest extends SysuiTestCase {
diff --git a/packages/SystemUI/tests/src/com/android/systemui/qs/QSSquishinessControllerTest.kt b/packages/SystemUI/tests/src/com/android/systemui/qs/QSSquishinessControllerTest.kt
index e2a0626..ecdabbf 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/qs/QSSquishinessControllerTest.kt
+++ b/packages/SystemUI/tests/src/com/android/systemui/qs/QSSquishinessControllerTest.kt
@@ -1,6 +1,6 @@
package com.android.systemui.qs
-import android.testing.AndroidTestingRunner
+import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.filters.SmallTest
import com.android.systemui.SysuiTestCase
import org.junit.Before
@@ -12,7 +12,7 @@
import org.mockito.Mockito.verify
import org.mockito.junit.MockitoJUnit
-@RunWith(AndroidTestingRunner::class)
+@RunWith(AndroidJUnit4::class)
@SmallTest
class QSSquishinessControllerTest : SysuiTestCase() {
@@ -45,4 +45,4 @@
verify(qsPanelController).setSquishinessFraction(0.5f)
verify(quickQsPanelController).setSquishinessFraction(0.5f)
}
-}
\ No newline at end of file
+}
diff --git a/packages/SystemUI/tests/src/com/android/systemui/qs/QSTileHostTest.java b/packages/SystemUI/tests/src/com/android/systemui/qs/QSTileHostTest.java
index 5e14b1a..6d1bc82 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/qs/QSTileHostTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/qs/QSTileHostTest.java
@@ -41,10 +41,10 @@
import android.os.Handler;
import android.os.Looper;
import android.os.UserHandle;
-import android.testing.AndroidTestingRunner;
import android.util.SparseArray;
import androidx.annotation.Nullable;
+import androidx.test.ext.junit.runners.AndroidJUnit4;
import androidx.test.filters.SmallTest;
import com.android.internal.logging.MetricsLogger;
@@ -53,7 +53,6 @@
import com.android.systemui.animation.Expandable;
import com.android.systemui.classifier.FalsingManagerFake;
import com.android.systemui.dump.nano.SystemUIProtoDump;
-import com.android.systemui.flags.FakeFeatureFlags;
import com.android.systemui.plugins.ActivityStarter;
import com.android.systemui.plugins.PluginManager;
import com.android.systemui.plugins.qs.QSFactory;
@@ -95,7 +94,7 @@
import javax.inject.Provider;
-@RunWith(AndroidTestingRunner.class)
+@RunWith(AndroidJUnit4.class)
@SmallTest
public class QSTileHostTest extends SysuiTestCase {
@@ -133,8 +132,6 @@
private SparseArray<SharedPreferences> mSharedPreferencesByUser;
- private FakeFeatureFlags mFeatureFlags;
-
private QSPipelineFlagsRepository mQSPipelineFlagsRepository;
private FakeExecutor mMainExecutor;
@@ -144,7 +141,6 @@
@Before
public void setUp() {
MockitoAnnotations.initMocks(this);
- mFeatureFlags = new FakeFeatureFlags();
mSetFlagsRule.disableFlags(FLAG_QS_NEW_PIPELINE);
mSetFlagsRule.disableFlags(FLAG_QS_NEW_TILES);
@@ -170,12 +166,12 @@
saveSetting("");
setUpTileFactory();
mQSTileHost = new TestQSTileHost(mContext, () -> null, mDefaultFactory, mMainExecutor,
- mPluginManager, mTunerService, () -> mAutoTiles, mShadeController,
+ mPluginManager, mTunerService, () -> mAutoTiles, () -> mShadeController,
mQSLogger, mUserTracker, mSecureSettings, mCustomTileStatePersister,
mTileLifecycleManagerFactory, mUserFileManager, mQSPipelineFlagsRepository);
mMainExecutor.runAllReady();
- mSecureSettings.registerContentObserverForUser(SETTING, new ContentObserver(null) {
+ mSecureSettings.registerContentObserverForUserSync(SETTING, new ContentObserver(null) {
@Override
public void onChange(boolean selfChange) {
super.onChange(selfChange);
@@ -689,7 +685,7 @@
QSFactory defaultFactory, Executor mainExecutor,
PluginManager pluginManager, TunerService tunerService,
Provider<AutoTileManager> autoTiles,
- ShadeController shadeController, QSLogger qsLogger,
+ Lazy<ShadeController> shadeController, QSLogger qsLogger,
UserTracker userTracker, SecureSettings secureSettings,
CustomTileStatePersister customTileStatePersister,
TileLifecycleManager.Factory tileLifecycleManagerFactory,
diff --git a/packages/SystemUI/tests/src/com/android/systemui/qs/QuickQSPanelControllerTest.kt b/packages/SystemUI/tests/src/com/android/systemui/qs/QuickQSPanelControllerTest.kt
index fee4b53..369bb22 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/qs/QuickQSPanelControllerTest.kt
+++ b/packages/SystemUI/tests/src/com/android/systemui/qs/QuickQSPanelControllerTest.kt
@@ -17,8 +17,8 @@
package com.android.systemui.qs
import android.content.res.Configuration
-import android.testing.AndroidTestingRunner
import android.view.ContextThemeWrapper
+import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.filters.SmallTest
import com.android.internal.logging.MetricsLogger
import com.android.internal.logging.testing.UiEventLoggerFake
@@ -50,7 +50,7 @@
import org.mockito.Mockito.`when` as whenever
@SmallTest
-@RunWith(AndroidTestingRunner::class)
+@RunWith(AndroidJUnit4::class)
class QuickQSPanelControllerTest : SysuiTestCase() {
@Mock private lateinit var quickQSPanel: QuickQSPanel
diff --git a/packages/SystemUI/tests/src/com/android/systemui/qs/QuickQSPanelTest.kt b/packages/SystemUI/tests/src/com/android/systemui/qs/QuickQSPanelTest.kt
index e5369fc..3d6ba94 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/qs/QuickQSPanelTest.kt
+++ b/packages/SystemUI/tests/src/com/android/systemui/qs/QuickQSPanelTest.kt
@@ -1,10 +1,10 @@
package com.android.systemui.qs
-import android.testing.AndroidTestingRunner
import android.testing.TestableLooper
import android.view.ViewGroup
import android.view.accessibility.AccessibilityNodeInfo
import android.widget.FrameLayout
+import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.filters.SmallTest
import com.android.systemui.SysuiTestCase
import com.android.systemui.qs.logging.QSLogger
@@ -16,7 +16,7 @@
import org.mockito.Mockito
import org.mockito.MockitoAnnotations
-@RunWith(AndroidTestingRunner::class)
+@RunWith(AndroidJUnit4::class)
@TestableLooper.RunWithLooper
@SmallTest
class QuickQSPanelTest : SysuiTestCase() {
@@ -63,4 +63,4 @@
quickQSPanel.performAccessibilityAction(AccessibilityNodeInfo.ACTION_EXPAND, null)
Mockito.verify(mockRunnable).run()
}
-}
\ No newline at end of file
+}
diff --git a/packages/SystemUI/tests/src/com/android/systemui/qs/QuickStatusBarHeaderControllerTest.kt b/packages/SystemUI/tests/src/com/android/systemui/qs/QuickStatusBarHeaderControllerTest.kt
index 4915e55..a0ccec1 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/qs/QuickStatusBarHeaderControllerTest.kt
+++ b/packages/SystemUI/tests/src/com/android/systemui/qs/QuickStatusBarHeaderControllerTest.kt
@@ -17,7 +17,7 @@
package com.android.systemui.qs
import android.content.Context
-import android.testing.AndroidTestingRunner
+import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.filters.SmallTest
import com.android.systemui.SysuiTestCase
import org.junit.After
@@ -31,7 +31,7 @@
import org.mockito.MockitoAnnotations
@SmallTest
-@RunWith(AndroidTestingRunner::class)
+@RunWith(AndroidJUnit4::class)
class QuickStatusBarHeaderControllerTest : SysuiTestCase() {
@Mock
diff --git a/packages/SystemUI/tests/src/com/android/systemui/qs/TileStateToProtoTest.kt b/packages/SystemUI/tests/src/com/android/systemui/qs/TileStateToProtoTest.kt
index bc947fb..be388a1 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/qs/TileStateToProtoTest.kt
+++ b/packages/SystemUI/tests/src/com/android/systemui/qs/TileStateToProtoTest.kt
@@ -2,8 +2,8 @@
import android.content.ComponentName
import android.service.quicksettings.Tile
-import android.testing.AndroidTestingRunner
import android.widget.Switch
+import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.filters.SmallTest
import com.android.systemui.SysuiTestCase
import com.android.systemui.plugins.qs.QSTile
@@ -12,7 +12,7 @@
import org.junit.Test
import org.junit.runner.RunWith
-@RunWith(AndroidTestingRunner::class)
+@RunWith(AndroidJUnit4::class)
@SmallTest
class TileStateToProtoTest : SysuiTestCase() {
diff --git a/packages/SystemUI/tests/src/com/android/systemui/qs/UserSettingObserverTest.kt b/packages/SystemUI/tests/src/com/android/systemui/qs/UserSettingObserverTest.kt
index 8f06fe2..90e0dd8 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/qs/UserSettingObserverTest.kt
+++ b/packages/SystemUI/tests/src/com/android/systemui/qs/UserSettingObserverTest.kt
@@ -17,8 +17,8 @@
package com.android.systemui.qs
import android.os.Handler
-import android.testing.AndroidTestingRunner
import android.testing.TestableLooper
+import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.filters.SmallTest
import com.android.systemui.SysuiTestCase
import com.android.systemui.util.settings.FakeSettings
@@ -33,7 +33,7 @@
private typealias Callback = (Int, Boolean) -> Unit
@SmallTest
-@RunWith(AndroidTestingRunner::class)
+@RunWith(AndroidJUnit4::class)
@TestableLooper.RunWithLooper
class UserSettingObserverTest : SysuiTestCase() {
diff --git a/packages/SystemUI/tests/src/com/android/systemui/qs/customize/TileAdapterDelegateTest.java b/packages/SystemUI/tests/src/com/android/systemui/qs/customize/TileAdapterDelegateTest.java
index 6e2f5db..9f2b1ea 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/qs/customize/TileAdapterDelegateTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/qs/customize/TileAdapterDelegateTest.java
@@ -24,11 +24,11 @@
import static org.mockito.Mockito.when;
import android.os.Bundle;
-import android.testing.AndroidTestingRunner;
import android.view.View;
import android.view.accessibility.AccessibilityNodeInfo;
import androidx.core.view.accessibility.AccessibilityNodeInfoCompat;
+import androidx.test.ext.junit.runners.AndroidJUnit4;
import androidx.test.filters.SmallTest;
import com.android.systemui.SysuiTestCase;
@@ -41,7 +41,7 @@
import org.mockito.MockitoAnnotations;
@SmallTest
-@RunWith(AndroidTestingRunner.class)
+@RunWith(AndroidJUnit4.class)
public class TileAdapterDelegateTest extends SysuiTestCase {
private static final int MOVE_TO_POSITION_ID = R.id.accessibility_action_qs_move_to_position;
diff --git a/packages/SystemUI/tests/src/com/android/systemui/qs/customize/TileAdapterTest.java b/packages/SystemUI/tests/src/com/android/systemui/qs/customize/TileAdapterTest.java
index f8a98af..cbcd810 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/qs/customize/TileAdapterTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/qs/customize/TileAdapterTest.java
@@ -17,10 +17,10 @@
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.verify;
-import android.testing.AndroidTestingRunner;
import android.testing.TestableLooper;
import android.testing.TestableLooper.RunWithLooper;
+import androidx.test.ext.junit.runners.AndroidJUnit4;
import androidx.test.filters.SmallTest;
import com.android.internal.logging.testing.UiEventLoggerFake;
@@ -37,7 +37,7 @@
import java.util.Collections;
-@RunWith(AndroidTestingRunner.class)
+@RunWith(AndroidJUnit4.class)
@RunWithLooper
@SmallTest
public class TileAdapterTest extends SysuiTestCase {
diff --git a/packages/SystemUI/tests/src/com/android/systemui/qs/customize/TileQueryHelperTest.java b/packages/SystemUI/tests/src/com/android/systemui/qs/customize/TileQueryHelperTest.java
index 8bf743884..09a6c2c 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/qs/customize/TileQueryHelperTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/qs/customize/TileQueryHelperTest.java
@@ -40,12 +40,12 @@
import android.content.pm.ServiceInfo;
import android.provider.Settings;
import android.service.quicksettings.Tile;
-import android.testing.AndroidTestingRunner;
import android.testing.TestableLooper;
import android.text.TextUtils;
import android.util.ArraySet;
import androidx.annotation.Nullable;
+import androidx.test.ext.junit.runners.AndroidJUnit4;
import androidx.test.filters.SmallTest;
import com.android.internal.logging.InstanceId;
@@ -75,7 +75,7 @@
import java.util.concurrent.Executor;
@SmallTest
-@RunWith(AndroidTestingRunner.class)
+@RunWith(AndroidJUnit4.class)
@TestableLooper.RunWithLooper
public class TileQueryHelperTest extends SysuiTestCase {
private static final String CURRENT_TILES = "internet,dnd,nfc";
diff --git a/packages/SystemUI/tests/src/com/android/systemui/qs/external/CustomTileStatePersisterTest.kt b/packages/SystemUI/tests/src/com/android/systemui/qs/external/CustomTileStatePersisterTest.kt
index 81d02b8..14eaa03 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/qs/external/CustomTileStatePersisterTest.kt
+++ b/packages/SystemUI/tests/src/com/android/systemui/qs/external/CustomTileStatePersisterTest.kt
@@ -20,7 +20,7 @@
import android.content.Context
import android.content.SharedPreferences
import android.service.quicksettings.Tile
-import android.testing.AndroidTestingRunner
+import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.filters.SmallTest
import com.android.systemui.SysuiTestCase
import com.android.systemui.util.mockito.capture
@@ -41,7 +41,7 @@
import org.mockito.MockitoAnnotations
@SmallTest
-@RunWith(AndroidTestingRunner::class)
+@RunWith(AndroidJUnit4::class)
class CustomTileStatePersisterTest : SysuiTestCase() {
companion object {
@@ -167,4 +167,4 @@
assertThat(customTileStatePersister.readState(KEY)!!.label).isNull()
}
-}
\ No newline at end of file
+}
diff --git a/packages/SystemUI/tests/src/com/android/systemui/qs/external/CustomTileTest.kt b/packages/SystemUI/tests/src/com/android/systemui/qs/external/CustomTileTest.kt
index a8e9db5..bd03acb 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/qs/external/CustomTileTest.kt
+++ b/packages/SystemUI/tests/src/com/android/systemui/qs/external/CustomTileTest.kt
@@ -31,8 +31,8 @@
import android.os.Parcel
import android.service.quicksettings.IQSTileService
import android.service.quicksettings.Tile
+import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.filters.SmallTest
-import android.testing.AndroidTestingRunner
import android.testing.TestableLooper
import android.view.IWindowManager
import com.android.internal.logging.MetricsLogger
@@ -74,7 +74,7 @@
@SmallTest
-@RunWith(AndroidTestingRunner::class)
+@RunWith(AndroidJUnit4::class)
@TestableLooper.RunWithLooper(setAsMainLooper = true)
class CustomTileTest : SysuiTestCase() {
@@ -563,4 +563,4 @@
parcel.setDataPosition(0)
return Tile.CREATOR.createFromParcel(parcel)
-}
\ No newline at end of file
+}
diff --git a/packages/SystemUI/tests/src/com/android/systemui/qs/external/TileRequestDialogTest.kt b/packages/SystemUI/tests/src/com/android/systemui/qs/external/TileRequestDialogTest.kt
index 78c2acf..2db5e83 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/qs/external/TileRequestDialogTest.kt
+++ b/packages/SystemUI/tests/src/com/android/systemui/qs/external/TileRequestDialogTest.kt
@@ -22,11 +22,11 @@
import android.graphics.Color
import android.graphics.drawable.Drawable
import android.graphics.drawable.Icon
-import android.testing.AndroidTestingRunner
import android.testing.TestableLooper
import android.view.ViewGroup
import android.widget.ImageView
import android.widget.TextView
+import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.filters.SmallTest
import com.android.systemui.res.R
import com.android.systemui.SysuiTestCase
@@ -48,7 +48,7 @@
import java.util.Arrays
@SmallTest
-@RunWith(AndroidTestingRunner::class)
+@RunWith(AndroidJUnit4::class)
@TestableLooper.RunWithLooper
class TileRequestDialogTest : SysuiTestCase() {
diff --git a/packages/SystemUI/tests/src/com/android/systemui/qs/external/TileServiceRequestControllerTest.kt b/packages/SystemUI/tests/src/com/android/systemui/qs/external/TileServiceRequestControllerTest.kt
index 3afa6ad..89ec687 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/qs/external/TileServiceRequestControllerTest.kt
+++ b/packages/SystemUI/tests/src/com/android/systemui/qs/external/TileServiceRequestControllerTest.kt
@@ -22,7 +22,7 @@
import android.content.DialogInterface
import android.graphics.drawable.Icon
import android.os.RemoteException
-import android.testing.AndroidTestingRunner
+import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.filters.SmallTest
import com.android.internal.logging.InstanceId
import com.android.internal.statusbar.IAddTileResultCallback
@@ -51,7 +51,7 @@
import org.mockito.MockitoAnnotations
@SmallTest
-@RunWith(AndroidTestingRunner::class)
+@RunWith(AndroidJUnit4::class)
class TileServiceRequestControllerTest : SysuiTestCase() {
companion object {
diff --git a/packages/SystemUI/tests/src/com/android/systemui/qs/footer/domain/interactor/FooterActionsInteractorTest.kt b/packages/SystemUI/tests/src/com/android/systemui/qs/footer/domain/interactor/FooterActionsInteractorTest.kt
index 720c25a..c5a2370 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/qs/footer/domain/interactor/FooterActionsInteractorTest.kt
+++ b/packages/SystemUI/tests/src/com/android/systemui/qs/footer/domain/interactor/FooterActionsInteractorTest.kt
@@ -19,8 +19,8 @@
import android.content.Context
import android.content.Intent
import android.provider.Settings
-import android.testing.AndroidTestingRunner
import android.testing.TestableLooper
+import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.filters.SmallTest
import com.android.internal.logging.nano.MetricsProto
import com.android.internal.logging.testing.FakeMetricsLogger
@@ -49,7 +49,7 @@
import org.mockito.Mockito.`when` as whenever
@SmallTest
-@RunWith(AndroidTestingRunner::class)
+@RunWith(AndroidJUnit4::class)
@TestableLooper.RunWithLooper
class FooterActionsInteractorTest : SysuiTestCase() {
private lateinit var utils: FooterActionsTestUtils
diff --git a/packages/SystemUI/tests/src/com/android/systemui/qs/footer/ui/viewmodel/FooterActionsViewModelTest.kt b/packages/SystemUI/tests/src/com/android/systemui/qs/footer/ui/viewmodel/FooterActionsViewModelTest.kt
index 1cb3bf6..31652a5 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/qs/footer/ui/viewmodel/FooterActionsViewModelTest.kt
+++ b/packages/SystemUI/tests/src/com/android/systemui/qs/footer/ui/viewmodel/FooterActionsViewModelTest.kt
@@ -18,10 +18,10 @@
import android.graphics.drawable.Drawable
import android.os.UserManager
-import android.testing.AndroidTestingRunner
import android.testing.TestableLooper
import android.testing.TestableLooper.RunWithLooper
import android.view.ContextThemeWrapper
+import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.filters.SmallTest
import com.android.settingslib.Utils
import com.android.settingslib.drawable.UserIconDrawable
@@ -57,7 +57,7 @@
import org.mockito.Mockito.`when` as whenever
@SmallTest
-@RunWith(AndroidTestingRunner::class)
+@RunWith(AndroidJUnit4::class)
@RunWithLooper
class FooterActionsViewModelTest : SysuiTestCase() {
private val testScope = TestScope()
diff --git a/packages/SystemUI/tests/src/com/android/systemui/qs/panels/domain/interactor/GridConsistencyInteractorTest.kt b/packages/SystemUI/tests/src/com/android/systemui/qs/panels/domain/interactor/GridConsistencyInteractorTest.kt
index 87031d9..b206f56 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/qs/panels/domain/interactor/GridConsistencyInteractorTest.kt
+++ b/packages/SystemUI/tests/src/com/android/systemui/qs/panels/domain/interactor/GridConsistencyInteractorTest.kt
@@ -16,7 +16,7 @@
package com.android.systemui.qs.panels.domain.interactor
-import android.testing.AndroidTestingRunner
+import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.filters.SmallTest
import com.android.systemui.SysuiTestCase
import com.android.systemui.kosmos.testScope
@@ -39,7 +39,7 @@
@OptIn(ExperimentalCoroutinesApi::class)
@SmallTest
-@RunWith(AndroidTestingRunner::class)
+@RunWith(AndroidJUnit4::class)
class GridConsistencyInteractorTest : SysuiTestCase() {
private val iconOnlyTiles =
diff --git a/packages/SystemUI/tests/src/com/android/systemui/qs/panels/domain/interactor/InfiniteGridConsistencyInteractorTest.kt b/packages/SystemUI/tests/src/com/android/systemui/qs/panels/domain/interactor/InfiniteGridConsistencyInteractorTest.kt
index 1eb6d63..1e2e82f 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/qs/panels/domain/interactor/InfiniteGridConsistencyInteractorTest.kt
+++ b/packages/SystemUI/tests/src/com/android/systemui/qs/panels/domain/interactor/InfiniteGridConsistencyInteractorTest.kt
@@ -16,7 +16,7 @@
package com.android.systemui.qs.panels.domain.interactor
-import android.testing.AndroidTestingRunner
+import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.filters.SmallTest
import com.android.systemui.SysuiTestCase
import com.android.systemui.kosmos.testScope
@@ -30,7 +30,7 @@
import org.junit.runner.RunWith
@SmallTest
-@RunWith(AndroidTestingRunner::class)
+@RunWith(AndroidJUnit4::class)
class InfiniteGridConsistencyInteractorTest : SysuiTestCase() {
private val iconOnlyTiles =
diff --git a/packages/SystemUI/tests/src/com/android/systemui/qs/tileimpl/QSFactoryImplTest.kt b/packages/SystemUI/tests/src/com/android/systemui/qs/tileimpl/QSFactoryImplTest.kt
index 5201e5d..12c566c 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/qs/tileimpl/QSFactoryImplTest.kt
+++ b/packages/SystemUI/tests/src/com/android/systemui/qs/tileimpl/QSFactoryImplTest.kt
@@ -17,7 +17,7 @@
package com.android.systemui.qs.tileimpl
import android.content.ComponentName
-import android.testing.AndroidTestingRunner
+import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.filters.SmallTest
import com.android.systemui.SysuiTestCase
import com.android.systemui.qs.QSHost
@@ -93,7 +93,7 @@
"font_scaling" to FontScalingTile::class.java
)
-@RunWith(AndroidTestingRunner::class)
+@RunWith(AndroidJUnit4::class)
@SmallTest
class QSFactoryImplTest : SysuiTestCase() {
diff --git a/packages/SystemUI/tests/src/com/android/systemui/qs/tileimpl/QSIconViewImplTest.java b/packages/SystemUI/tests/src/com/android/systemui/qs/tileimpl/QSIconViewImplTest.java
index 81a9604..2580ac2 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/qs/tileimpl/QSIconViewImplTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/qs/tileimpl/QSIconViewImplTest.java
@@ -27,10 +27,10 @@
import android.graphics.drawable.AnimatedVectorDrawable;
import android.graphics.drawable.Drawable;
import android.service.quicksettings.Tile;
-import android.testing.AndroidTestingRunner;
import android.testing.UiThreadTest;
import android.widget.ImageView;
+import androidx.test.ext.junit.runners.AndroidJUnit4;
import androidx.test.filters.SmallTest;
import com.android.systemui.SysuiTestCase;
@@ -43,7 +43,7 @@
import org.mockito.InOrder;
import org.mockito.Mockito;
-@RunWith(AndroidTestingRunner.class)
+@RunWith(AndroidJUnit4.class)
@UiThreadTest
@SmallTest
public class QSIconViewImplTest extends SysuiTestCase {
diff --git a/packages/SystemUI/tests/src/com/android/systemui/qs/tileimpl/QSTileImplTest.java b/packages/SystemUI/tests/src/com/android/systemui/qs/tileimpl/QSTileImplTest.java
index c706244..e46416c 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/qs/tileimpl/QSTileImplTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/qs/tileimpl/QSTileImplTest.java
@@ -48,11 +48,11 @@
import android.os.Looper;
import android.provider.Settings;
import android.service.quicksettings.Tile;
-import android.testing.AndroidTestingRunner;
import android.testing.TestableLooper;
import android.testing.TestableLooper.RunWithLooper;
import androidx.annotation.Nullable;
+import androidx.test.ext.junit.runners.AndroidJUnit4;
import androidx.test.filters.SmallTest;
import com.android.internal.logging.InstanceId;
@@ -85,7 +85,7 @@
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
-@RunWith(AndroidTestingRunner.class)
+@RunWith(AndroidJUnit4.class)
@RunWithLooper(setAsMainLooper = true)
@SmallTest
public class QSTileImplTest extends SysuiTestCase {
diff --git a/packages/SystemUI/tests/src/com/android/systemui/qs/tileimpl/QSTileViewImplTest.kt b/packages/SystemUI/tests/src/com/android/systemui/qs/tileimpl/QSTileViewImplTest.kt
index 196f654..6618308 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/qs/tileimpl/QSTileViewImplTest.kt
+++ b/packages/SystemUI/tests/src/com/android/systemui/qs/tileimpl/QSTileViewImplTest.kt
@@ -22,13 +22,13 @@
import android.platform.test.annotations.DisableFlags
import android.platform.test.annotations.EnableFlags
import android.service.quicksettings.Tile
-import android.testing.AndroidTestingRunner
import android.testing.TestableLooper
import android.text.TextUtils
import android.view.ContextThemeWrapper
import android.view.View
import android.view.accessibility.AccessibilityNodeInfo
import android.widget.TextView
+import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.filters.SmallTest
import com.android.systemui.Flags.FLAG_QUICK_SETTINGS_VISUAL_HAPTICS_LONGPRESS
import com.android.systemui.res.R
@@ -45,7 +45,7 @@
import org.mockito.Mock
import org.mockito.MockitoAnnotations
-@RunWith(AndroidTestingRunner::class)
+@RunWith(AndroidJUnit4::class)
@SmallTest
@TestableLooper.RunWithLooper(setAsMainLooper = true)
class QSTileViewImplTest : SysuiTestCase() {
diff --git a/packages/SystemUI/tests/src/com/android/systemui/qs/tileimpl/ResourceIconTest.kt b/packages/SystemUI/tests/src/com/android/systemui/qs/tileimpl/ResourceIconTest.kt
index 9c1cad6..e112bb0 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/qs/tileimpl/ResourceIconTest.kt
+++ b/packages/SystemUI/tests/src/com/android/systemui/qs/tileimpl/ResourceIconTest.kt
@@ -16,14 +16,14 @@
package com.android.systemui.qs.tileimpl
-import android.testing.AndroidTestingRunner
+import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.filters.SmallTest
import com.android.systemui.SysuiTestCase
import org.junit.Assert.assertEquals
import org.junit.Test
import org.junit.runner.RunWith
-@RunWith(AndroidTestingRunner::class)
+@RunWith(AndroidJUnit4::class)
@SmallTest
class ResourceIconTest : SysuiTestCase() {
diff --git a/packages/SystemUI/tests/src/com/android/systemui/qs/tileimpl/TilesStatesTextTest.kt b/packages/SystemUI/tests/src/com/android/systemui/qs/tileimpl/TilesStatesTextTest.kt
index f2400ec..9c20a6c 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/qs/tileimpl/TilesStatesTextTest.kt
+++ b/packages/SystemUI/tests/src/com/android/systemui/qs/tileimpl/TilesStatesTextTest.kt
@@ -16,7 +16,7 @@
package com.android.systemui.qs.tileimpl
-import android.testing.AndroidTestingRunner
+import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.filters.MediumTest
import com.android.systemui.res.R
import com.android.systemui.SysuiTestCase
@@ -26,7 +26,7 @@
import org.junit.Test
import org.junit.runner.RunWith
-@RunWith(AndroidTestingRunner::class)
+@RunWith(AndroidJUnit4::class)
@MediumTest
class TilesStatesTextTest : SysuiTestCase() {
@@ -76,4 +76,4 @@
assertThat(SubtitleArrayMapping.getSubtitleId(null))
.isEqualTo(R.array.tile_states_default)
}
-}
\ No newline at end of file
+}
diff --git a/packages/SystemUI/tests/src/com/android/systemui/qs/tiles/AirplaneModeTileTest.kt b/packages/SystemUI/tests/src/com/android/systemui/qs/tiles/AirplaneModeTileTest.kt
index ad87315..7a99aef 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/qs/tiles/AirplaneModeTileTest.kt
+++ b/packages/SystemUI/tests/src/com/android/systemui/qs/tiles/AirplaneModeTileTest.kt
@@ -18,8 +18,8 @@
import android.net.ConnectivityManager
import android.os.Handler
-import android.testing.AndroidTestingRunner
import android.testing.TestableLooper
+import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.filters.SmallTest
import com.android.internal.logging.MetricsLogger
import com.android.internal.telephony.flags.Flags
@@ -50,7 +50,7 @@
import org.mockito.kotlin.times
import org.mockito.kotlin.verify
-@RunWith(AndroidTestingRunner::class)
+@RunWith(AndroidJUnit4::class)
@TestableLooper.RunWithLooper(setAsMainLooper = true)
@SmallTest
class AirplaneModeTileTest : SysuiTestCase() {
diff --git a/packages/SystemUI/tests/src/com/android/systemui/qs/tiles/AlarmTileTest.kt b/packages/SystemUI/tests/src/com/android/systemui/qs/tiles/AlarmTileTest.kt
index 52b8455..518b6de 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/qs/tiles/AlarmTileTest.kt
+++ b/packages/SystemUI/tests/src/com/android/systemui/qs/tiles/AlarmTileTest.kt
@@ -5,8 +5,8 @@
import android.os.Handler
import android.provider.AlarmClock
import android.service.quicksettings.Tile
-import android.testing.AndroidTestingRunner
import android.testing.TestableLooper
+import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.filters.SmallTest
import com.android.internal.logging.MetricsLogger
import com.android.systemui.SysuiTestCase
@@ -33,7 +33,7 @@
import org.mockito.MockitoAnnotations
@SmallTest
-@RunWith(AndroidTestingRunner::class)
+@RunWith(AndroidJUnit4::class)
@TestableLooper.RunWithLooper(setAsMainLooper = true)
class AlarmTileTest : SysuiTestCase() {
@@ -152,4 +152,4 @@
verify(activityStarter).postStartActivityDismissingKeyguard(pendingIntent,
null /* animationController */)
}
-}
\ No newline at end of file
+}
diff --git a/packages/SystemUI/tests/src/com/android/systemui/qs/tiles/BatterySaverTileTest.kt b/packages/SystemUI/tests/src/com/android/systemui/qs/tiles/BatterySaverTileTest.kt
index 2c49e92..d6be314 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/qs/tiles/BatterySaverTileTest.kt
+++ b/packages/SystemUI/tests/src/com/android/systemui/qs/tiles/BatterySaverTileTest.kt
@@ -18,9 +18,9 @@
import android.content.Context
import android.os.Handler
-import android.testing.AndroidTestingRunner
import android.testing.TestableLooper
import android.testing.TestableLooper.RunWithLooper
+import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.filters.SmallTest
import com.android.internal.logging.MetricsLogger
import com.android.systemui.SysuiTestCase
@@ -50,7 +50,7 @@
import org.mockito.Mockito.`when`
import org.mockito.MockitoAnnotations
-@RunWith(AndroidTestingRunner::class)
+@RunWith(AndroidJUnit4::class)
@RunWithLooper(setAsMainLooper = true)
@SmallTest
class BatterySaverTileTest : SysuiTestCase() {
diff --git a/packages/SystemUI/tests/src/com/android/systemui/qs/tiles/BluetoothTileTest.kt b/packages/SystemUI/tests/src/com/android/systemui/qs/tiles/BluetoothTileTest.kt
index 1ffbb7b..9a924ed 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/qs/tiles/BluetoothTileTest.kt
+++ b/packages/SystemUI/tests/src/com/android/systemui/qs/tiles/BluetoothTileTest.kt
@@ -4,9 +4,9 @@
import android.os.Handler
import android.os.Looper
import android.os.UserManager
-import android.testing.AndroidTestingRunner
import android.testing.TestableLooper
import android.testing.TestableLooper.RunWithLooper
+import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.filters.SmallTest
import com.android.internal.logging.MetricsLogger
import com.android.internal.telephony.flags.Flags
@@ -42,7 +42,7 @@
import org.mockito.Mockito.`when`
import org.mockito.MockitoAnnotations
-@RunWith(AndroidTestingRunner::class)
+@RunWith(AndroidJUnit4::class)
@RunWithLooper(setAsMainLooper = true)
@SmallTest
class BluetoothTileTest : SysuiTestCase() {
diff --git a/packages/SystemUI/tests/src/com/android/systemui/qs/tiles/CameraToggleTileTest.kt b/packages/SystemUI/tests/src/com/android/systemui/qs/tiles/CameraToggleTileTest.kt
index 0e4b113..093cdf2 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/qs/tiles/CameraToggleTileTest.kt
+++ b/packages/SystemUI/tests/src/com/android/systemui/qs/tiles/CameraToggleTileTest.kt
@@ -19,8 +19,8 @@
import android.os.Handler
import android.provider.Settings
import android.safetycenter.SafetyCenterManager
-import android.testing.AndroidTestingRunner
import android.testing.TestableLooper
+import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.filters.SmallTest
import com.android.internal.logging.MetricsLogger
import com.android.systemui.res.R
@@ -44,7 +44,7 @@
import org.mockito.MockitoAnnotations
import org.mockito.Mockito.`when` as whenever
-@RunWith(AndroidTestingRunner::class)
+@RunWith(AndroidJUnit4::class)
@TestableLooper.RunWithLooper(setAsMainLooper = true)
@SmallTest
class CameraToggleTileTest : SysuiTestCase() {
diff --git a/packages/SystemUI/tests/src/com/android/systemui/qs/tiles/CastTileTest.java b/packages/SystemUI/tests/src/com/android/systemui/qs/tiles/CastTileTest.java
index 46ee569..50cf5cc5 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/qs/tiles/CastTileTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/qs/tiles/CastTileTest.java
@@ -32,10 +32,10 @@
import android.media.projection.MediaProjectionInfo;
import android.os.Handler;
import android.service.quicksettings.Tile;
-import android.testing.AndroidTestingRunner;
import android.testing.TestableLooper;
import androidx.lifecycle.LifecycleOwner;
+import androidx.test.ext.junit.runners.AndroidJUnit4;
import androidx.test.filters.SmallTest;
import com.android.internal.logging.MetricsLogger;
@@ -73,7 +73,7 @@
import java.util.ArrayList;
import java.util.List;
-@RunWith(AndroidTestingRunner.class)
+@RunWith(AndroidJUnit4.class)
@TestableLooper.RunWithLooper(setAsMainLooper = true)
@SmallTest
public class CastTileTest extends SysuiTestCase {
diff --git a/packages/SystemUI/tests/src/com/android/systemui/qs/tiles/ColorCorrectionTileTest.java b/packages/SystemUI/tests/src/com/android/systemui/qs/tiles/ColorCorrectionTileTest.java
index 2250ef3..028beb5 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/qs/tiles/ColorCorrectionTileTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/qs/tiles/ColorCorrectionTileTest.java
@@ -26,9 +26,9 @@
import android.content.Intent;
import android.os.Handler;
import android.provider.Settings;
-import android.testing.AndroidTestingRunner;
import android.testing.TestableLooper;
+import androidx.test.ext.junit.runners.AndroidJUnit4;
import androidx.test.filters.SmallTest;
import com.android.internal.logging.MetricsLogger;
@@ -51,7 +51,7 @@
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
-@RunWith(AndroidTestingRunner.class)
+@RunWith(AndroidJUnit4.class)
@TestableLooper.RunWithLooper(setAsMainLooper = true)
@SmallTest
public class ColorCorrectionTileTest extends SysuiTestCase {
diff --git a/packages/SystemUI/tests/src/com/android/systemui/qs/tiles/ColorInversionTileTest.java b/packages/SystemUI/tests/src/com/android/systemui/qs/tiles/ColorInversionTileTest.java
index ea43326..1343527 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/qs/tiles/ColorInversionTileTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/qs/tiles/ColorInversionTileTest.java
@@ -26,9 +26,9 @@
import android.content.Intent;
import android.os.Handler;
import android.provider.Settings;
-import android.testing.AndroidTestingRunner;
import android.testing.TestableLooper;
+import androidx.test.ext.junit.runners.AndroidJUnit4;
import androidx.test.filters.SmallTest;
import com.android.internal.logging.MetricsLogger;
@@ -54,7 +54,7 @@
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
-@RunWith(AndroidTestingRunner.class)
+@RunWith(AndroidJUnit4.class)
@TestableLooper.RunWithLooper(setAsMainLooper = true)
@SmallTest
public class ColorInversionTileTest extends SysuiTestCase {
diff --git a/packages/SystemUI/tests/src/com/android/systemui/qs/tiles/DataSaverTileTest.kt b/packages/SystemUI/tests/src/com/android/systemui/qs/tiles/DataSaverTileTest.kt
index 043ddf5..73ae4ee 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/qs/tiles/DataSaverTileTest.kt
+++ b/packages/SystemUI/tests/src/com/android/systemui/qs/tiles/DataSaverTileTest.kt
@@ -17,8 +17,8 @@
package com.android.systemui.qs.tiles
import android.os.Handler
-import android.testing.AndroidTestingRunner
import android.testing.TestableLooper
+import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.filters.SmallTest
import com.android.internal.logging.MetricsLogger
import com.android.systemui.SysuiTestCase
@@ -43,7 +43,7 @@
import org.mockito.Mock
import org.mockito.MockitoAnnotations
-@RunWith(AndroidTestingRunner::class)
+@RunWith(AndroidJUnit4::class)
@TestableLooper.RunWithLooper(setAsMainLooper = true)
@SmallTest
class DataSaverTileTest : SysuiTestCase() {
diff --git a/packages/SystemUI/tests/src/com/android/systemui/qs/tiles/DeviceControlsTileTest.kt b/packages/SystemUI/tests/src/com/android/systemui/qs/tiles/DeviceControlsTileTest.kt
index 874368b..418d126 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/qs/tiles/DeviceControlsTileTest.kt
+++ b/packages/SystemUI/tests/src/com/android/systemui/qs/tiles/DeviceControlsTileTest.kt
@@ -22,9 +22,9 @@
import android.os.Handler
import android.provider.Settings
import android.service.quicksettings.Tile
-import android.testing.AndroidTestingRunner
import android.testing.TestableLooper
import androidx.lifecycle.LifecycleOwner
+import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.filters.SmallTest
import com.android.internal.logging.MetricsLogger
import com.android.systemui.res.R
@@ -70,7 +70,7 @@
import java.util.Optional
@SmallTest
-@RunWith(AndroidTestingRunner::class)
+@RunWith(AndroidJUnit4::class)
@TestableLooper.RunWithLooper(setAsMainLooper = true)
class DeviceControlsTileTest : SysuiTestCase() {
diff --git a/packages/SystemUI/tests/src/com/android/systemui/qs/tiles/DndTileTest.kt b/packages/SystemUI/tests/src/com/android/systemui/qs/tiles/DndTileTest.kt
index 1173fa3..e01744e 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/qs/tiles/DndTileTest.kt
+++ b/packages/SystemUI/tests/src/com/android/systemui/qs/tiles/DndTileTest.kt
@@ -23,9 +23,9 @@
import android.provider.Settings
import android.provider.Settings.Global.ZEN_MODE_NO_INTERRUPTIONS
import android.provider.Settings.Global.ZEN_MODE_OFF
-import android.testing.AndroidTestingRunner
import android.testing.TestableLooper
import android.view.ContextThemeWrapper
+import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.filters.SmallTest
import com.android.internal.logging.MetricsLogger
import com.android.systemui.res.R
@@ -59,7 +59,7 @@
import org.mockito.Mockito.`when` as whenever
@SmallTest
-@RunWith(AndroidTestingRunner::class)
+@RunWith(AndroidJUnit4::class)
@TestableLooper.RunWithLooper(setAsMainLooper = true)
class DndTileTest : SysuiTestCase() {
diff --git a/packages/SystemUI/tests/src/com/android/systemui/qs/tiles/DreamTileTest.java b/packages/SystemUI/tests/src/com/android/systemui/qs/tiles/DreamTileTest.java
index a3c2975..190d80f 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/qs/tiles/DreamTileTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/qs/tiles/DreamTileTest.java
@@ -35,9 +35,9 @@
import android.provider.Settings;
import android.service.dreams.IDreamManager;
import android.service.quicksettings.Tile;
-import android.testing.AndroidTestingRunner;
import android.testing.TestableLooper;
+import androidx.test.ext.junit.runners.AndroidJUnit4;
import androidx.test.filters.SmallTest;
import com.android.internal.logging.MetricsLogger;
@@ -63,7 +63,7 @@
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
-@RunWith(AndroidTestingRunner.class)
+@RunWith(AndroidJUnit4.class)
@TestableLooper.RunWithLooper(setAsMainLooper = true)
@SmallTest
public class DreamTileTest extends SysuiTestCase {
diff --git a/packages/SystemUI/tests/src/com/android/systemui/qs/tiles/FlashlightTileTest.kt b/packages/SystemUI/tests/src/com/android/systemui/qs/tiles/FlashlightTileTest.kt
index c1a0928..f90463e 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/qs/tiles/FlashlightTileTest.kt
+++ b/packages/SystemUI/tests/src/com/android/systemui/qs/tiles/FlashlightTileTest.kt
@@ -2,8 +2,8 @@
import android.content.Context
import android.os.Handler
-import android.testing.AndroidTestingRunner
import android.testing.TestableLooper
+import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.filters.SmallTest
import com.android.internal.logging.MetricsLogger
import com.android.systemui.res.R
@@ -26,7 +26,7 @@
import org.mockito.Mockito
import org.mockito.MockitoAnnotations
-@RunWith(AndroidTestingRunner::class)
+@RunWith(AndroidJUnit4::class)
@TestableLooper.RunWithLooper(setAsMainLooper = true)
@SmallTest
class FlashlightTileTest : SysuiTestCase() {
diff --git a/packages/SystemUI/tests/src/com/android/systemui/qs/tiles/FontScalingTileTest.kt b/packages/SystemUI/tests/src/com/android/systemui/qs/tiles/FontScalingTileTest.kt
index 1c42dd1..c854920 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/qs/tiles/FontScalingTileTest.kt
+++ b/packages/SystemUI/tests/src/com/android/systemui/qs/tiles/FontScalingTileTest.kt
@@ -18,8 +18,8 @@
import android.content.Intent
import android.os.Handler
import android.provider.Settings
-import android.testing.AndroidTestingRunner
import android.testing.TestableLooper
+import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.filters.SmallTest
import com.android.internal.logging.MetricsLogger
import com.android.systemui.SysuiTestCase
@@ -52,7 +52,7 @@
import org.mockito.Mockito.`when`
import org.mockito.MockitoAnnotations
-@RunWith(AndroidTestingRunner::class)
+@RunWith(AndroidJUnit4::class)
@TestableLooper.RunWithLooper(setAsMainLooper = true)
@SmallTest
class FontScalingTileTest : SysuiTestCase() {
diff --git a/packages/SystemUI/tests/src/com/android/systemui/qs/tiles/HearingDevicesTileTest.java b/packages/SystemUI/tests/src/com/android/systemui/qs/tiles/HearingDevicesTileTest.java
index 56671bf..59ee0b8 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/qs/tiles/HearingDevicesTileTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/qs/tiles/HearingDevicesTileTest.java
@@ -28,10 +28,10 @@
import android.platform.test.annotations.DisableFlags;
import android.platform.test.annotations.EnableFlags;
import android.provider.Settings;
-import android.testing.AndroidTestingRunner;
import android.testing.TestableLooper;
import android.view.View;
+import androidx.test.ext.junit.runners.AndroidJUnit4;
import androidx.test.filters.SmallTest;
import com.android.internal.logging.MetricsLogger;
@@ -57,7 +57,7 @@
import org.mockito.junit.MockitoRule;
/** Tests for {@link HearingDevicesTile}. */
-@RunWith(AndroidTestingRunner.class)
+@RunWith(AndroidJUnit4.class)
@TestableLooper.RunWithLooper(setAsMainLooper = true)
@SmallTest
public class HearingDevicesTileTest extends SysuiTestCase {
diff --git a/packages/SystemUI/tests/src/com/android/systemui/qs/tiles/HotspotTileTest.java b/packages/SystemUI/tests/src/com/android/systemui/qs/tiles/HotspotTileTest.java
index a85b49b6..5bd6944 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/qs/tiles/HotspotTileTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/qs/tiles/HotspotTileTest.java
@@ -23,9 +23,9 @@
import android.os.Handler;
import android.service.quicksettings.Tile;
-import android.testing.AndroidTestingRunner;
import android.testing.TestableLooper;
+import androidx.test.ext.junit.runners.AndroidJUnit4;
import androidx.test.filters.SmallTest;
import com.android.dx.mockito.inline.extended.ExtendedMockito;
@@ -54,7 +54,7 @@
import org.mockito.junit.MockitoJUnit;
import org.mockito.junit.MockitoRule;
-@RunWith(AndroidTestingRunner.class)
+@RunWith(AndroidJUnit4.class)
@TestableLooper.RunWithLooper(setAsMainLooper = true)
@SmallTest
public class HotspotTileTest extends SysuiTestCase {
diff --git a/packages/SystemUI/tests/src/com/android/systemui/qs/tiles/InternetTileTest.java b/packages/SystemUI/tests/src/com/android/systemui/qs/tiles/InternetTileTest.java
index 0ea61f9..8ea79d7 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/qs/tiles/InternetTileTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/qs/tiles/InternetTileTest.java
@@ -23,9 +23,9 @@
import android.os.Handler;
import android.service.quicksettings.Tile;
-import android.testing.AndroidTestingRunner;
import android.testing.TestableLooper;
+import androidx.test.ext.junit.runners.AndroidJUnit4;
import androidx.test.filters.SmallTest;
import com.android.internal.logging.MetricsLogger;
@@ -51,7 +51,7 @@
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
-@RunWith(AndroidTestingRunner.class)
+@RunWith(AndroidJUnit4.class)
@TestableLooper.RunWithLooper(setAsMainLooper = true)
@SmallTest
public class InternetTileTest extends SysuiTestCase {
diff --git a/packages/SystemUI/tests/src/com/android/systemui/qs/tiles/LocationTileTest.kt b/packages/SystemUI/tests/src/com/android/systemui/qs/tiles/LocationTileTest.kt
index 62a50e3..0a1455f 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/qs/tiles/LocationTileTest.kt
+++ b/packages/SystemUI/tests/src/com/android/systemui/qs/tiles/LocationTileTest.kt
@@ -18,8 +18,8 @@
import android.content.Context
import android.os.Handler
-import android.testing.AndroidTestingRunner
import android.testing.TestableLooper
+import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.filters.SmallTest
import com.android.internal.logging.MetricsLogger
import com.android.systemui.res.R
@@ -47,7 +47,7 @@
import org.mockito.Mockito.`when`
import org.mockito.MockitoAnnotations
-@RunWith(AndroidTestingRunner::class)
+@RunWith(AndroidJUnit4::class)
@TestableLooper.RunWithLooper(setAsMainLooper = true)
@SmallTest
class LocationTileTest : SysuiTestCase() {
diff --git a/packages/SystemUI/tests/src/com/android/systemui/qs/tiles/MicrophoneToggleTileTest.kt b/packages/SystemUI/tests/src/com/android/systemui/qs/tiles/MicrophoneToggleTileTest.kt
index b98a7570..dbdf3a4 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/qs/tiles/MicrophoneToggleTileTest.kt
+++ b/packages/SystemUI/tests/src/com/android/systemui/qs/tiles/MicrophoneToggleTileTest.kt
@@ -19,8 +19,8 @@
import android.os.Handler
import android.provider.Settings
import android.safetycenter.SafetyCenterManager
-import android.testing.AndroidTestingRunner
import android.testing.TestableLooper
+import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.filters.SmallTest
import com.android.internal.logging.MetricsLogger
import com.android.systemui.res.R
@@ -44,7 +44,7 @@
import org.mockito.MockitoAnnotations
import org.mockito.Mockito.`when` as whenever
-@RunWith(AndroidTestingRunner::class)
+@RunWith(AndroidJUnit4::class)
@TestableLooper.RunWithLooper(setAsMainLooper = true)
@SmallTest
class MicrophoneToggleTileTest : SysuiTestCase() {
diff --git a/packages/SystemUI/tests/src/com/android/systemui/qs/tiles/NfcTileTest.java b/packages/SystemUI/tests/src/com/android/systemui/qs/tiles/NfcTileTest.java
index f6bc692..442a948 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/qs/tiles/NfcTileTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/qs/tiles/NfcTileTest.java
@@ -24,9 +24,9 @@
import android.content.Context;
import android.content.pm.PackageManager;
import android.os.Handler;
-import android.testing.AndroidTestingRunner;
import android.testing.TestableLooper;
+import androidx.test.ext.junit.runners.AndroidJUnit4;
import androidx.test.filters.SmallTest;
import com.android.internal.logging.MetricsLogger;
@@ -47,7 +47,7 @@
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
-@RunWith(AndroidTestingRunner.class)
+@RunWith(AndroidJUnit4.class)
@TestableLooper.RunWithLooper(setAsMainLooper = true)
@SmallTest
public class NfcTileTest extends SysuiTestCase {
diff --git a/packages/SystemUI/tests/src/com/android/systemui/qs/tiles/NightDisplayTileTest.kt b/packages/SystemUI/tests/src/com/android/systemui/qs/tiles/NightDisplayTileTest.kt
index a1d9e414..f1c5895 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/qs/tiles/NightDisplayTileTest.kt
+++ b/packages/SystemUI/tests/src/com/android/systemui/qs/tiles/NightDisplayTileTest.kt
@@ -19,8 +19,8 @@
import android.hardware.display.ColorDisplayManager
import android.hardware.display.NightDisplayListener
import android.os.Handler
-import android.testing.AndroidTestingRunner
import android.testing.TestableLooper
+import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.filters.SmallTest
import com.android.internal.logging.MetricsLogger
import com.android.systemui.res.R
@@ -45,7 +45,7 @@
import org.mockito.MockitoAnnotations
import org.mockito.Mockito.`when` as whenever
-@RunWith(AndroidTestingRunner::class)
+@RunWith(AndroidJUnit4::class)
@TestableLooper.RunWithLooper(setAsMainLooper = true)
@SmallTest
class NightDisplayTileTest : SysuiTestCase() {
diff --git a/packages/SystemUI/tests/src/com/android/systemui/qs/tiles/OneHandedModeTileTest.java b/packages/SystemUI/tests/src/com/android/systemui/qs/tiles/OneHandedModeTileTest.java
index c391153..d6fa124 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/qs/tiles/OneHandedModeTileTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/qs/tiles/OneHandedModeTileTest.java
@@ -22,9 +22,9 @@
import static org.mockito.Mockito.when;
import android.os.Handler;
-import android.testing.AndroidTestingRunner;
import android.testing.TestableLooper;
+import androidx.test.ext.junit.runners.AndroidJUnit4;
import androidx.test.filters.SmallTest;
import com.android.internal.logging.MetricsLogger;
@@ -45,7 +45,7 @@
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
-@RunWith(AndroidTestingRunner.class)
+@RunWith(AndroidJUnit4.class)
@TestableLooper.RunWithLooper(setAsMainLooper = true)
@SmallTest
public class OneHandedModeTileTest extends SysuiTestCase {
diff --git a/packages/SystemUI/tests/src/com/android/systemui/qs/tiles/QRCodeScannerTileTest.java b/packages/SystemUI/tests/src/com/android/systemui/qs/tiles/QRCodeScannerTileTest.java
index d7beb5d..f8f82f2 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/qs/tiles/QRCodeScannerTileTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/qs/tiles/QRCodeScannerTileTest.java
@@ -24,9 +24,9 @@
import android.os.Handler;
import android.service.quicksettings.Tile;
-import android.testing.AndroidTestingRunner;
import android.testing.TestableLooper;
+import androidx.test.ext.junit.runners.AndroidJUnit4;
import androidx.test.filters.SmallTest;
import com.android.internal.logging.MetricsLogger;
@@ -49,7 +49,7 @@
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
-@RunWith(AndroidTestingRunner.class)
+@RunWith(AndroidJUnit4.class)
@TestableLooper.RunWithLooper(setAsMainLooper = true)
@SmallTest
public class QRCodeScannerTileTest extends SysuiTestCase {
diff --git a/packages/SystemUI/tests/src/com/android/systemui/qs/tiles/QuickAccessWalletTileTest.java b/packages/SystemUI/tests/src/com/android/systemui/qs/tiles/QuickAccessWalletTileTest.java
index 122d9e4..914bd0e 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/qs/tiles/QuickAccessWalletTileTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/qs/tiles/QuickAccessWalletTileTest.java
@@ -52,9 +52,9 @@
import android.service.quickaccesswallet.QuickAccessWalletService;
import android.service.quickaccesswallet.WalletCard;
import android.service.quicksettings.Tile;
-import android.testing.AndroidTestingRunner;
import android.testing.TestableLooper;
+import androidx.test.ext.junit.runners.AndroidJUnit4;
import androidx.test.filters.SmallTest;
import com.android.internal.logging.MetricsLogger;
@@ -83,7 +83,7 @@
import java.util.Collections;
-@RunWith(AndroidTestingRunner.class)
+@RunWith(AndroidJUnit4.class)
@TestableLooper.RunWithLooper(setAsMainLooper = true)
@SmallTest
public class QuickAccessWalletTileTest extends SysuiTestCase {
diff --git a/packages/SystemUI/tests/src/com/android/systemui/qs/tiles/RecordIssueTileTest.kt b/packages/SystemUI/tests/src/com/android/systemui/qs/tiles/RecordIssueTileTest.kt
index 37654d5..df59e57 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/qs/tiles/RecordIssueTileTest.kt
+++ b/packages/SystemUI/tests/src/com/android/systemui/qs/tiles/RecordIssueTileTest.kt
@@ -18,8 +18,8 @@
import android.os.Handler
import android.service.quicksettings.Tile
-import android.testing.AndroidTestingRunner
import android.testing.TestableLooper
+import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.filters.SmallTest
import com.android.internal.logging.MetricsLogger
import com.android.systemui.SysuiTestCase
@@ -33,6 +33,7 @@
import com.android.systemui.qs.pipeline.domain.interactor.PanelInteractor
import com.android.systemui.recordissue.IssueRecordingState
import com.android.systemui.recordissue.RecordIssueDialogDelegate
+import com.android.systemui.recordissue.TraceurMessageSender
import com.android.systemui.res.R
import com.android.systemui.settings.UserContextProvider
import com.android.systemui.statusbar.phone.KeyguardDismissUtil
@@ -41,6 +42,7 @@
import com.android.systemui.util.mockito.any
import com.android.systemui.util.mockito.whenever
import com.google.common.truth.Truth.assertThat
+import java.util.concurrent.Executors
import org.junit.Before
import org.junit.Test
import org.junit.runner.RunWith
@@ -54,7 +56,7 @@
* This class tests the functionality of the RecordIssueTile. The initial state of the tile is
* always be inactive at the start of these tests.
*/
-@RunWith(AndroidTestingRunner::class)
+@RunWith(AndroidJUnit4::class)
@TestableLooper.RunWithLooper(setAsMainLooper = true)
@SmallTest
class RecordIssueTileTest : SysuiTestCase() {
@@ -70,6 +72,7 @@
@Mock private lateinit var dialogLauncherAnimator: DialogTransitionAnimator
@Mock private lateinit var panelInteractor: PanelInteractor
@Mock private lateinit var userContextProvider: UserContextProvider
+ @Mock private lateinit var traceurMessageSender: TraceurMessageSender
@Mock private lateinit var delegateFactory: RecordIssueDialogDelegate.Factory
@Mock private lateinit var dialogDelegate: RecordIssueDialogDelegate
@Mock private lateinit var dialog: SystemUIDialog
@@ -102,6 +105,8 @@
dialogLauncherAnimator,
panelInteractor,
userContextProvider,
+ traceurMessageSender,
+ Executors.newSingleThreadExecutor(),
issueRecordingState,
delegateFactory,
)
diff --git a/packages/SystemUI/tests/src/com/android/systemui/qs/tiles/ReduceBrightColorsTileTest.java b/packages/SystemUI/tests/src/com/android/systemui/qs/tiles/ReduceBrightColorsTileTest.java
index 8eaa876..798e9fb 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/qs/tiles/ReduceBrightColorsTileTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/qs/tiles/ReduceBrightColorsTileTest.java
@@ -25,9 +25,9 @@
import android.os.Handler;
import android.service.quicksettings.Tile;
-import android.testing.AndroidTestingRunner;
import android.testing.TestableLooper;
+import androidx.test.ext.junit.runners.AndroidJUnit4;
import androidx.test.filters.SmallTest;
import com.android.internal.R;
@@ -52,7 +52,7 @@
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
-@RunWith(AndroidTestingRunner.class)
+@RunWith(AndroidJUnit4.class)
@TestableLooper.RunWithLooper(setAsMainLooper = true)
@SmallTest
public class ReduceBrightColorsTileTest extends SysuiTestCase {
diff --git a/packages/SystemUI/tests/src/com/android/systemui/qs/tiles/RotationLockTileTest.java b/packages/SystemUI/tests/src/com/android/systemui/qs/tiles/RotationLockTileTest.java
index c02fca7..4193063 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/qs/tiles/RotationLockTileTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/qs/tiles/RotationLockTileTest.java
@@ -27,10 +27,10 @@
import android.content.pm.PackageManager;
import android.hardware.SensorPrivacyManager;
import android.os.Handler;
-import android.testing.AndroidTestingRunner;
import android.testing.TestableLooper;
import android.testing.TestableResources;
+import androidx.test.ext.junit.runners.AndroidJUnit4;
import androidx.test.filters.SmallTest;
import com.android.internal.logging.MetricsLogger;
@@ -58,7 +58,7 @@
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
-@RunWith(AndroidTestingRunner.class)
+@RunWith(AndroidJUnit4.class)
@TestableLooper.RunWithLooper(setAsMainLooper = true)
@SmallTest
public class RotationLockTileTest extends SysuiTestCase {
diff --git a/packages/SystemUI/tests/src/com/android/systemui/qs/tiles/ScreenRecordTileTest.java b/packages/SystemUI/tests/src/com/android/systemui/qs/tiles/ScreenRecordTileTest.java
index 507fb86..0d12483 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/qs/tiles/ScreenRecordTileTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/qs/tiles/ScreenRecordTileTest.java
@@ -31,9 +31,9 @@
import android.app.Dialog;
import android.os.Handler;
import android.service.quicksettings.Tile;
-import android.testing.AndroidTestingRunner;
import android.testing.TestableLooper;
+import androidx.test.ext.junit.runners.AndroidJUnit4;
import androidx.test.filters.SmallTest;
import com.android.internal.logging.MetricsLogger;
@@ -64,7 +64,7 @@
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
-@RunWith(AndroidTestingRunner.class)
+@RunWith(AndroidJUnit4.class)
@TestableLooper.RunWithLooper(setAsMainLooper = true)
@SmallTest
public class ScreenRecordTileTest extends SysuiTestCase {
diff --git a/packages/SystemUI/tests/src/com/android/systemui/qs/tiles/UiModeNightTileTest.kt b/packages/SystemUI/tests/src/com/android/systemui/qs/tiles/UiModeNightTileTest.kt
index 47fc3ec..8324a73 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/qs/tiles/UiModeNightTileTest.kt
+++ b/packages/SystemUI/tests/src/com/android/systemui/qs/tiles/UiModeNightTileTest.kt
@@ -21,8 +21,8 @@
import android.content.res.Configuration
import android.content.res.Resources
import android.os.Handler
-import android.testing.AndroidTestingRunner
import android.testing.TestableLooper
+import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.filters.SmallTest
import com.android.internal.logging.MetricsLogger
import com.android.systemui.res.R
@@ -47,7 +47,7 @@
import org.mockito.Mockito.`when`
import org.mockito.MockitoAnnotations
-@RunWith(AndroidTestingRunner::class)
+@RunWith(AndroidJUnit4::class)
@TestableLooper.RunWithLooper(setAsMainLooper = true)
@SmallTest
class UiModeNightTileTest : SysuiTestCase() {
diff --git a/packages/SystemUI/tests/src/com/android/systemui/qs/tiles/UserDetailViewAdapterTest.kt b/packages/SystemUI/tests/src/com/android/systemui/qs/tiles/UserDetailViewAdapterTest.kt
index f9d69c2..c764c54 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/qs/tiles/UserDetailViewAdapterTest.kt
+++ b/packages/SystemUI/tests/src/com/android/systemui/qs/tiles/UserDetailViewAdapterTest.kt
@@ -19,10 +19,10 @@
import android.content.Context
import android.content.pm.UserInfo
import android.graphics.Bitmap
-import android.testing.AndroidTestingRunner
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
+import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.filters.SmallTest
import com.android.internal.logging.testing.UiEventLoggerFake
import com.android.internal.util.UserIcons
@@ -45,7 +45,7 @@
import org.mockito.Mockito.`when`
import org.mockito.MockitoAnnotations
-@RunWith(AndroidTestingRunner::class)
+@RunWith(AndroidJUnit4::class)
@SmallTest
class UserDetailViewAdapterTest : SysuiTestCase() {
diff --git a/packages/SystemUI/tests/src/com/android/systemui/qs/tiles/dialog/InternetAdapterTest.java b/packages/SystemUI/tests/src/com/android/systemui/qs/tiles/dialog/InternetAdapterTest.java
index ff712ad..b888617 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/qs/tiles/dialog/InternetAdapterTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/qs/tiles/dialog/InternetAdapterTest.java
@@ -13,11 +13,11 @@
import android.content.Context;
import android.graphics.drawable.Drawable;
-import android.testing.AndroidTestingRunner;
import android.testing.TestableResources;
import android.view.View;
import android.widget.LinearLayout;
+import androidx.test.ext.junit.runners.AndroidJUnit4;
import androidx.test.filters.SmallTest;
import com.android.systemui.SysuiTestCase;
@@ -39,7 +39,7 @@
import java.util.List;
@SmallTest
-@RunWith(AndroidTestingRunner.class)
+@RunWith(AndroidJUnit4.class)
public class InternetAdapterTest extends SysuiTestCase {
private static final String WIFI_KEY = "Wi-Fi_Key";
diff --git a/packages/SystemUI/tests/src/com/android/systemui/qs/tiles/dialog/InternetDialogDelegateControllerTest.java b/packages/SystemUI/tests/src/com/android/systemui/qs/tiles/dialog/InternetDialogDelegateControllerTest.java
index 29487cd..5273495 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/qs/tiles/dialog/InternetDialogDelegateControllerTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/qs/tiles/dialog/InternetDialogDelegateControllerTest.java
@@ -51,7 +51,6 @@
import android.telephony.TelephonyCallback;
import android.telephony.TelephonyDisplayInfo;
import android.telephony.TelephonyManager;
-import android.testing.AndroidTestingRunner;
import android.testing.TestableLooper;
import android.testing.TestableResources;
import android.text.TextUtils;
@@ -59,6 +58,7 @@
import android.view.View;
import android.view.WindowManager;
+import androidx.test.ext.junit.runners.AndroidJUnit4;
import androidx.test.filters.SmallTest;
import com.android.internal.logging.UiEventLogger;
@@ -101,7 +101,7 @@
import java.util.Map;
@SmallTest
-@RunWith(AndroidTestingRunner.class)
+@RunWith(AndroidJUnit4.class)
@TestableLooper.RunWithLooper(setAsMainLooper = true)
public class InternetDialogDelegateControllerTest extends SysuiTestCase {
diff --git a/packages/SystemUI/tests/src/com/android/systemui/qs/tiles/dialog/InternetDialogDelegateTest.java b/packages/SystemUI/tests/src/com/android/systemui/qs/tiles/dialog/InternetDialogDelegateTest.java
index aefcc87..ff8c448 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/qs/tiles/dialog/InternetDialogDelegateTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/qs/tiles/dialog/InternetDialogDelegateTest.java
@@ -18,7 +18,6 @@
import android.content.Intent;
import android.os.Handler;
import android.telephony.TelephonyManager;
-import android.testing.AndroidTestingRunner;
import android.testing.TestableLooper;
import android.view.View;
import android.widget.LinearLayout;
@@ -26,6 +25,7 @@
import android.widget.TextView;
import androidx.recyclerview.widget.RecyclerView;
+import androidx.test.ext.junit.runners.AndroidJUnit4;
import androidx.test.filters.SmallTest;
import com.android.dx.mockito.inline.extended.ExtendedMockito;
@@ -56,7 +56,7 @@
@Ignore("b/257089187")
@SmallTest
-@RunWith(AndroidTestingRunner.class)
+@RunWith(AndroidJUnit4.class)
@TestableLooper.RunWithLooper(setAsMainLooper = true)
public class InternetDialogDelegateTest extends SysuiTestCase {
diff --git a/packages/SystemUI/tests/src/com/android/systemui/qs/tiles/dialog/WifiStateWorkerTest.java b/packages/SystemUI/tests/src/com/android/systemui/qs/tiles/dialog/WifiStateWorkerTest.java
index 5d7ba7b..57484c2 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/qs/tiles/dialog/WifiStateWorkerTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/qs/tiles/dialog/WifiStateWorkerTest.java
@@ -35,8 +35,8 @@
import android.content.Intent;
import android.net.wifi.WifiManager;
-import android.testing.AndroidTestingRunner;
+import androidx.test.ext.junit.runners.AndroidJUnit4;
import androidx.test.filters.SmallTest;
import com.android.systemui.SysuiTestCase;
@@ -52,7 +52,7 @@
import org.mockito.junit.MockitoJUnit;
import org.mockito.junit.MockitoRule;
-@RunWith(AndroidTestingRunner.class)
+@RunWith(AndroidJUnit4.class)
@SmallTest
public class WifiStateWorkerTest extends SysuiTestCase {
diff --git a/packages/SystemUI/tests/src/com/android/systemui/qs/user/UserSwitchDialogControllerTest.kt b/packages/SystemUI/tests/src/com/android/systemui/qs/user/UserSwitchDialogControllerTest.kt
index e48d96b..ad6c64b 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/qs/user/UserSwitchDialogControllerTest.kt
+++ b/packages/SystemUI/tests/src/com/android/systemui/qs/user/UserSwitchDialogControllerTest.kt
@@ -19,8 +19,8 @@
import android.content.DialogInterface
import android.content.Intent
import android.provider.Settings
-import android.testing.AndroidTestingRunner
import android.widget.Button
+import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.filters.SmallTest
import com.android.internal.logging.UiEventLogger
import com.android.systemui.SysuiTestCase
@@ -53,7 +53,7 @@
import org.mockito.MockitoAnnotations
@SmallTest
-@RunWith(AndroidTestingRunner::class)
+@RunWith(AndroidJUnit4::class)
class UserSwitchDialogControllerTest : SysuiTestCase() {
@Mock
diff --git a/packages/SystemUI/tests/src/com/android/systemui/reardisplay/RearDisplayDialogControllerTest.java b/packages/SystemUI/tests/src/com/android/systemui/reardisplay/RearDisplayDialogControllerTest.java
index b75b318..3aaaf95 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/reardisplay/RearDisplayDialogControllerTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/reardisplay/RearDisplayDialogControllerTest.java
@@ -29,12 +29,12 @@
import android.content.res.Resources;
import android.hardware.devicestate.DeviceState;
import android.hardware.devicestate.DeviceStateManager;
-import android.testing.AndroidTestingRunner;
import android.testing.TestableLooper;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.TextView;
+import androidx.test.ext.junit.runners.AndroidJUnit4;
import androidx.test.filters.SmallTest;
import com.android.systemui.SysuiTestCase;
@@ -54,7 +54,7 @@
import org.mockito.MockitoAnnotations;
@SmallTest
-@RunWith(AndroidTestingRunner.class)
+@RunWith(AndroidJUnit4.class)
@TestableLooper.RunWithLooper(setAsMainLooper = true)
public class RearDisplayDialogControllerTest extends SysuiTestCase {
diff --git a/packages/SystemUI/tests/src/com/android/systemui/recents/OverviewProxyServiceTest.kt b/packages/SystemUI/tests/src/com/android/systemui/recents/OverviewProxyServiceTest.kt
index 74deae3..fc74586 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/recents/OverviewProxyServiceTest.kt
+++ b/packages/SystemUI/tests/src/com/android/systemui/recents/OverviewProxyServiceTest.kt
@@ -23,9 +23,9 @@
import android.os.PowerManager
import android.os.Process
import android.os.UserHandle
-import android.testing.AndroidTestingRunner
import android.testing.TestableContext
import android.testing.TestableLooper
+import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.filters.SmallTest
import com.android.dx.mockito.inline.extended.ExtendedMockito
import com.android.internal.app.AssistUtils
@@ -81,7 +81,7 @@
import org.mockito.MockitoAnnotations
@SmallTest
-@RunWith(AndroidTestingRunner::class)
+@RunWith(AndroidJUnit4::class)
@TestableLooper.RunWithLooper(setAsMainLooper = true)
class OverviewProxyServiceTest : SysuiTestCase() {
diff --git a/packages/SystemUI/tests/src/com/android/systemui/recordissue/RecordIssueDialogDelegateTest.kt b/packages/SystemUI/tests/src/com/android/systemui/recordissue/RecordIssueDialogDelegateTest.kt
index fcc6b4f..ca60650 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/recordissue/RecordIssueDialogDelegateTest.kt
+++ b/packages/SystemUI/tests/src/com/android/systemui/recordissue/RecordIssueDialogDelegateTest.kt
@@ -20,10 +20,10 @@
import android.content.Context
import android.content.SharedPreferences
import android.os.UserHandle
-import android.testing.AndroidTestingRunner
import android.testing.TestableLooper
import android.widget.Button
import android.widget.Switch
+import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.filters.SmallTest
import com.android.systemui.SysuiTestCase
import com.android.systemui.animation.DialogTransitionAnimator
@@ -63,7 +63,7 @@
import org.mockito.MockitoAnnotations
@SmallTest
-@RunWith(AndroidTestingRunner::class)
+@RunWith(AndroidJUnit4::class)
@TestableLooper.RunWithLooper(setAsMainLooper = true)
class RecordIssueDialogDelegateTest : SysuiTestCase() {
@@ -81,6 +81,7 @@
@Mock private lateinit var sysuiState: SysUiState
@Mock private lateinit var systemUIDialogManager: SystemUIDialogManager
@Mock private lateinit var broadcastDispatcher: BroadcastDispatcher
+ @Mock private lateinit var traceurMessageSender: TraceurMessageSender
private val systemClock = FakeSystemClock()
private val bgExecutor = FakeExecutor(systemClock)
private val mainExecutor = FakeExecutor(systemClock)
@@ -131,6 +132,7 @@
userFileManager,
screenCaptureDisabledDialogDelegate,
issueRecordingState,
+ traceurMessageSender
) {
latch.countDown()
}
diff --git a/packages/SystemUI/tests/src/com/android/systemui/retail/data/repository/RetailModeSettingsRepositoryTest.kt b/packages/SystemUI/tests/src/com/android/systemui/retail/data/repository/RetailModeSettingsRepositoryTest.kt
index fe80f70..ba7a65d 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/retail/data/repository/RetailModeSettingsRepositoryTest.kt
+++ b/packages/SystemUI/tests/src/com/android/systemui/retail/data/repository/RetailModeSettingsRepositoryTest.kt
@@ -17,7 +17,7 @@
package com.android.systemui.retail.data.repository
import android.provider.Settings
-import android.testing.AndroidTestingRunner
+import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.filters.SmallTest
import com.android.systemui.SysuiTestCase
import com.android.systemui.coroutines.collectLastValue
@@ -33,7 +33,7 @@
@OptIn(ExperimentalCoroutinesApi::class)
@SmallTest
-@RunWith(AndroidTestingRunner::class)
+@RunWith(AndroidJUnit4::class)
class RetailModeSettingsRepositoryTest : SysuiTestCase() {
private val globalSettings = FakeGlobalSettings()
diff --git a/packages/SystemUI/tests/src/com/android/systemui/retail/domain/interactor/RetailModeInteractorImplTest.kt b/packages/SystemUI/tests/src/com/android/systemui/retail/domain/interactor/RetailModeInteractorImplTest.kt
index 8f13169..b536520 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/retail/domain/interactor/RetailModeInteractorImplTest.kt
+++ b/packages/SystemUI/tests/src/com/android/systemui/retail/domain/interactor/RetailModeInteractorImplTest.kt
@@ -16,7 +16,7 @@
package com.android.systemui.retail.domain.interactor
-import android.testing.AndroidTestingRunner
+import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.filters.SmallTest
import com.android.systemui.SysuiTestCase
import com.android.systemui.retail.data.repository.FakeRetailModeRepository
@@ -25,7 +25,7 @@
import org.junit.runner.RunWith
@SmallTest
-@RunWith(AndroidTestingRunner::class)
+@RunWith(AndroidJUnit4::class)
class RetailModeInteractorImplTest : SysuiTestCase() {
private val retailModeRepository = FakeRetailModeRepository()
diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/collection/coordinator/PreparationCoordinatorTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/collection/coordinator/PreparationCoordinatorTest.java
index 8012768..dc9c22f 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/collection/coordinator/PreparationCoordinatorTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/collection/coordinator/PreparationCoordinatorTest.java
@@ -320,7 +320,7 @@
.thenReturn(1);
ArgumentCaptor<ContentObserver> contentObserverCaptor = ArgumentCaptor.forClass(
ContentObserver.class);
- verify(mSecureSettings).registerContentObserverForUser(eq(SHOW_NOTIFICATION_SNOOZE),
+ verify(mSecureSettings).registerContentObserverForUserSync(eq(SHOW_NOTIFICATION_SNOOZE),
contentObserverCaptor.capture(), anyInt());
ContentObserver contentObserver = contentObserverCaptor.getValue();
contentObserver.onChange(false);
diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/collection/inflation/NotifUiAdjustmentProviderTest.kt b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/collection/inflation/NotifUiAdjustmentProviderTest.kt
index 7943872..2f77b33 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/collection/inflation/NotifUiAdjustmentProviderTest.kt
+++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/collection/inflation/NotifUiAdjustmentProviderTest.kt
@@ -69,22 +69,21 @@
private val groupMembershipManager: GroupMembershipManager = mock()
private val section = NotifSection(mock(), 0)
- private val entry = NotificationEntryBuilder()
- .setSection(section)
- .setParent(GroupEntry.ROOT_ENTRY)
- .build()
+ private val entry =
+ NotificationEntryBuilder().setSection(section).setParent(GroupEntry.ROOT_ENTRY).build()
private lateinit var contentObserver: ContentObserver
- private val adjustmentProvider = NotifUiAdjustmentProvider(
- handler,
- secureSettings,
- lockscreenUserManager,
- sensitiveNotifProtectionController,
- sectionStyleProvider,
- userTracker,
- groupMembershipManager,
- )
+ private val adjustmentProvider =
+ NotifUiAdjustmentProvider(
+ handler,
+ secureSettings,
+ lockscreenUserManager,
+ sensitiveNotifProtectionController,
+ sectionStyleProvider,
+ userTracker,
+ groupMembershipManager,
+ )
@Before
fun setup() {
@@ -92,9 +91,8 @@
adjustmentProvider.addDirtyListener(dirtyListener)
verify(secureSettings).getIntForUser(eq(SHOW_NOTIFICATION_SNOOZE), any(), any())
contentObserver = withArgCaptor {
- verify(secureSettings).registerContentObserverForUser(
- eq(SHOW_NOTIFICATION_SNOOZE), capture(), any()
- )
+ verify(secureSettings)
+ .registerContentObserverForUserSync(eq(SHOW_NOTIFICATION_SNOOZE), capture(), any())
}
verifyNoMoreInteractions(secureSettings, dirtyListener)
}
diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/row/NotificationContentInflaterTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/row/NotificationContentInflaterTest.java
index 62bffdd..0d3ab86 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/row/NotificationContentInflaterTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/row/NotificationContentInflaterTest.java
@@ -27,6 +27,7 @@
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.anyInt;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.spy;
@@ -50,7 +51,6 @@
import androidx.test.ext.junit.runners.AndroidJUnit4;
import androidx.test.filters.SmallTest;
-import androidx.test.filters.Suppress;
import com.android.systemui.SysuiTestCase;
import com.android.systemui.media.controls.util.MediaFeatureFlag;
@@ -81,7 +81,6 @@
@SmallTest
@RunWith(AndroidJUnit4.class)
@RunWithLooper(setAsMainLooper = true)
-@Suppress
public class NotificationContentInflaterTest extends SysuiTestCase {
private NotificationContentInflater mNotificationInflater;
@@ -128,7 +127,7 @@
TestableLooper.get(this));
ExpandableNotificationRow row = mHelper.createRow(mBuilder.build());
mRow = spy(row);
- when(mNotifLayoutInflaterFactoryProvider.provide(any(), any()))
+ when(mNotifLayoutInflaterFactoryProvider.provide(any(), anyInt()))
.thenReturn(mNotifLayoutInflaterFactory);
mNotificationInflater = new NotificationContentInflater(
@@ -282,6 +281,7 @@
}
@Test
+ @Ignore
public void testUsesSameViewWhenCachedPossibleToReuse() throws Exception {
// GIVEN a cached view.
RemoteViews contractedRemoteView = mBuilder.createContentView();
@@ -347,6 +347,7 @@
}
@Test
+ @Ignore
public void testNotificationViewHeightTooSmallFailsValidation() {
View view = mock(View.class);
when(view.getHeight())
diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/row/NotificationSettingsControllerTest.kt b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/row/NotificationSettingsControllerTest.kt
index 352b79f..310fa67 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/row/NotificationSettingsControllerTest.kt
+++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/row/NotificationSettingsControllerTest.kt
@@ -102,6 +102,7 @@
verify(userTracker).addCallback(any(), any())
verify(dumpManager).registerNormalDumpable(anyString(), eq(controller))
}
+
@Test
fun updateContentObserverRegistration_onUserChange_noSettingsListeners() {
verify(userTracker).addCallback(capture(userTrackerCallbackCaptor), any())
@@ -112,10 +113,11 @@
userCallback.onUserChanged(userId, context)
// Validate: Nothing to do, since we aren't monitoring settings
- verify(secureSettings, never()).unregisterContentObserver(any())
+ verify(secureSettings, never()).unregisterContentObserverSync(any())
verify(secureSettings, never())
- .registerContentObserverForUser(any(Uri::class.java), anyBoolean(), any(), anyInt())
+ .registerContentObserverForUserSync(any(Uri::class.java), anyBoolean(), any(), anyInt())
}
+
@Test
fun updateContentObserverRegistration_onUserChange_withSettingsListeners() {
// When: someone is listening to a setting
@@ -129,9 +131,9 @@
userCallback.onUserChanged(userId, context)
// Validate: The tracker is unregistered and re-registered with the new user
- verify(secureSettings).unregisterContentObserver(any())
+ verify(secureSettings).unregisterContentObserverSync(any())
verify(secureSettings)
- .registerContentObserverForUser(eq(settingUri1), eq(false), any(), eq(userId))
+ .registerContentObserverForUserSync(eq(settingUri1), eq(false), any(), eq(userId))
}
@Test
@@ -140,7 +142,7 @@
verifyZeroInteractions(secureSettings)
testableLooper.processAllMessages()
verify(secureSettings)
- .registerContentObserverForUser(
+ .registerContentObserverForUserSync(
eq(settingUri1),
eq(false),
any(),
@@ -149,7 +151,7 @@
controller.addCallback(settingUri1, Mockito.mock(Listener::class.java))
verify(secureSettings)
- .registerContentObserverForUser(any(Uri::class.java), anyBoolean(), any(), anyInt())
+ .registerContentObserverForUserSync(any(Uri::class.java), anyBoolean(), any(), anyInt())
}
@Test
@@ -158,7 +160,7 @@
verifyZeroInteractions(secureSettings)
testableLooper.processAllMessages()
verify(secureSettings)
- .registerContentObserverForUser(
+ .registerContentObserverForUserSync(
eq(settingUri1),
eq(false),
any(),
@@ -170,7 +172,7 @@
verifyNoMoreInteractions(secureSettings)
testableLooper.processAllMessages()
verify(secureSettings)
- .registerContentObserverForUser(
+ .registerContentObserverForUserSync(
eq(settingUri2),
eq(false),
any(),
@@ -186,7 +188,7 @@
verifyZeroInteractions(secureSettings)
testableLooper.processAllMessages()
verify(secureSettings)
- .registerContentObserverForUser(
+ .registerContentObserverForUserSync(
eq(settingUri1),
eq(false),
any(),
@@ -198,18 +200,18 @@
verifyNoMoreInteractions(secureSettings)
testableLooper.processAllMessages()
verify(secureSettings)
- .registerContentObserverForUser(eq(settingUri2), anyBoolean(), any(), anyInt())
+ .registerContentObserverForUserSync(eq(settingUri2), anyBoolean(), any(), anyInt())
clearInvocations(secureSettings)
controller.removeCallback(settingUri2, listenerSetting2)
testableLooper.processAllMessages()
- verify(secureSettings, never()).unregisterContentObserver(any())
+ verify(secureSettings, never()).unregisterContentObserverSync(any())
clearInvocations(secureSettings)
controller.removeCallback(settingUri1, listenerSetting1)
verifyNoMoreInteractions(secureSettings)
testableLooper.processAllMessages()
- verify(secureSettings).unregisterContentObserver(any())
+ verify(secureSettings).unregisterContentObserverSync(any())
}
@Test
@@ -253,7 +255,7 @@
testableLooper.processAllMessages()
verify(secureSettings)
- .registerContentObserverForUser(
+ .registerContentObserverForUserSync(
any(Uri::class.java),
anyBoolean(),
capture(settingsObserverCaptor),
diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/CentralSurfacesImplTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/CentralSurfacesImplTest.java
index cb9790b..7ea85a1 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/CentralSurfacesImplTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/CentralSurfacesImplTest.java
@@ -133,6 +133,7 @@
import com.android.systemui.power.domain.interactor.PowerInteractor;
import com.android.systemui.res.R;
import com.android.systemui.scene.domain.interactor.WindowRootViewVisibilityInteractor;
+import com.android.systemui.scene.domain.startable.ScrimStartable;
import com.android.systemui.scene.shared.flag.SceneContainerFlag;
import com.android.systemui.settings.UserTracker;
import com.android.systemui.settings.brightness.BrightnessSliderController;
@@ -254,7 +255,6 @@
@Mock private IDreamManager mDreamManager;
@Mock private LightRevealScrimViewModel mLightRevealScrimViewModel;
@Mock private LightRevealScrim mLightRevealScrim;
- @Mock private ScrimController mScrimController;
@Mock private DozeScrimController mDozeScrimController;
@Mock private Lazy<BiometricUnlockController> mBiometricUnlockControllerLazy;
@Mock private BiometricUnlockController mBiometricUnlockController;
@@ -355,6 +355,7 @@
private final BrightnessMirrorShowingInteractor mBrightnessMirrorShowingInteractor =
mKosmos.getBrightnessMirrorShowingInteractor();
+ private ScrimController mScrimController;
@Before
public void setup() throws Exception {
@@ -472,6 +473,8 @@
when(mUserTracker.getUserHandle()).thenReturn(
UserHandle.of(ActivityManager.getCurrentUser()));
+ mScrimController = mKosmos.getScrimController();
+
createCentralSurfaces();
}
@@ -733,7 +736,7 @@
@Test
public void testFingerprintNotification_UpdatesScrims() {
mCentralSurfaces.notifyBiometricAuthModeChanged();
- verify(mScrimController).transitionTo(any(), any());
+ verify(mScrimController).legacyTransitionTo(any(), any());
}
@Test
@@ -742,7 +745,7 @@
when(mBiometricUnlockController.getMode())
.thenReturn(BiometricUnlockController.MODE_WAKE_AND_UNLOCK);
mCentralSurfaces.updateScrimController();
- verify(mScrimController).transitionTo(eq(ScrimState.UNLOCKED), any());
+ verify(mScrimController).legacyTransitionTo(eq(ScrimState.UNLOCKED), any());
}
@Test
@@ -753,7 +756,7 @@
// Starting a pulse should change the scrim controller to the pulsing state
when(mCameraLauncher.isLaunchingAffordance()).thenReturn(true);
mCentralSurfaces.updateScrimController();
- verify(mScrimController).transitionTo(eq(ScrimState.UNLOCKED), any());
+ verify(mScrimController).legacyTransitionTo(eq(ScrimState.UNLOCKED), any());
}
@Test
@@ -789,7 +792,7 @@
// Starting a pulse should change the scrim controller to the pulsing state
when(mCameraLauncher.isLaunchingAffordance()).thenReturn(false);
mCentralSurfaces.updateScrimController();
- verify(mScrimController).transitionTo(eq(ScrimState.KEYGUARD));
+ verify(mScrimController).legacyTransitionTo(eq(ScrimState.KEYGUARD));
}
@Test
@@ -817,12 +820,12 @@
// Starting a pulse should change the scrim controller to the pulsing state
when(mDozeServiceHost.isPulsing()).thenReturn(true);
mCentralSurfaces.updateScrimController();
- verify(mScrimController).transitionTo(eq(ScrimState.PULSING), any());
+ verify(mScrimController).legacyTransitionTo(eq(ScrimState.PULSING), any());
// Ending a pulse should take it back to keyguard state
when(mDozeServiceHost.isPulsing()).thenReturn(false);
mCentralSurfaces.updateScrimController();
- verify(mScrimController).transitionTo(eq(ScrimState.KEYGUARD));
+ verify(mScrimController).legacyTransitionTo(eq(ScrimState.KEYGUARD));
}
@Test
@@ -833,7 +836,7 @@
mCentralSurfaces.updateScrimController();
- verify(mScrimController, times(2)).transitionTo(eq(ScrimState.AOD));
+ verify(mScrimController, times(2)).legacyTransitionTo(eq(ScrimState.AOD));
verify(mStatusBarKeyguardViewManager).onKeyguardFadedAway();
}
@@ -845,7 +848,7 @@
mCentralSurfaces.updateScrimController();
- verify(mScrimController).transitionTo(eq(ScrimState.AUTH_SCRIMMED_SHADE));
+ verify(mScrimController).legacyTransitionTo(eq(ScrimState.AUTH_SCRIMMED_SHADE));
verify(mStatusBarKeyguardViewManager).onKeyguardFadedAway();
}
@@ -861,7 +864,7 @@
mCentralSurfaces.updateScrimController();
- verify(mScrimController).transitionTo(eq(ScrimState.AUTH_SCRIMMED));
+ verify(mScrimController).legacyTransitionTo(eq(ScrimState.AUTH_SCRIMMED));
}
@Test
@@ -877,7 +880,7 @@
mCentralSurfaces.updateScrimController();
// Tests the safeguard to reset the scrimstate
- verify(mScrimController, never()).transitionTo(any());
+ verify(mScrimController, never()).legacyTransitionTo(any());
}
@Test
@@ -893,7 +896,7 @@
mCentralSurfaces.updateScrimController();
// Tests the safeguard to reset the scrimstate
- verify(mScrimController, never()).transitionTo(eq(ScrimState.KEYGUARD));
+ verify(mScrimController, never()).legacyTransitionTo(eq(ScrimState.KEYGUARD));
}
@Test
@@ -908,7 +911,7 @@
mCentralSurfaces.updateScrimController();
- verify(mScrimController).transitionTo(eq(ScrimState.AUTH_SCRIMMED_SHADE));
+ verify(mScrimController).legacyTransitionTo(eq(ScrimState.AUTH_SCRIMMED_SHADE));
}
@Test
@@ -920,7 +923,7 @@
mTestScope.getTestScheduler().runCurrent();
// ScrimState also transitions.
- verify(mScrimController).transitionTo(ScrimState.GLANCEABLE_HUB);
+ verify(mScrimController).legacyTransitionTo(ScrimState.GLANCEABLE_HUB);
// Transition away from the glanceable hub.
mKosmos.getCommunalRepository()
@@ -929,7 +932,7 @@
mTestScope.getTestScheduler().runCurrent();
// ScrimState goes back to UNLOCKED.
- verify(mScrimController).transitionTo(eq(ScrimState.UNLOCKED), any());
+ verify(mScrimController).legacyTransitionTo(eq(ScrimState.UNLOCKED), any());
}
@Test
@@ -945,7 +948,7 @@
mTestScope.getTestScheduler().runCurrent();
// ScrimState also transitions.
- verify(mScrimController).transitionTo(ScrimState.GLANCEABLE_HUB_OVER_DREAM);
+ verify(mScrimController).legacyTransitionTo(ScrimState.GLANCEABLE_HUB_OVER_DREAM);
// Transition away from the glanceable hub.
mKosmos.getCommunalRepository()
@@ -954,7 +957,7 @@
mTestScope.getTestScheduler().runCurrent();
// ScrimState goes back to UNLOCKED.
- verify(mScrimController).transitionTo(eq(ScrimState.DREAMING));
+ verify(mScrimController).legacyTransitionTo(eq(ScrimState.DREAMING));
}
@Test
@@ -1164,6 +1167,8 @@
@EnableSceneContainer
public void brightnesShowingChanged_flagEnabled_ScrimControllerNotified() {
mCentralSurfaces.registerCallbacks();
+ final ScrimStartable scrimStartable = mKosmos.getScrimStartable();
+ scrimStartable.start();
mBrightnessMirrorShowingInteractor.setMirrorShowing(true);
mTestScope.getTestScheduler().runCurrent();
@@ -1173,7 +1178,7 @@
mTestScope.getTestScheduler().runCurrent();
ArgumentCaptor<ScrimState> captor = ArgumentCaptor.forClass(ScrimState.class);
// The default is to call the one with the callback argument
- verify(mScrimController, atLeastOnce()).transitionTo(captor.capture(), any());
+ verify(mScrimController, atLeastOnce()).transitionTo(captor.capture());
assertThat(captor.getValue()).isNotEqualTo(ScrimState.BRIGHTNESS_MIRROR);
}
@@ -1184,8 +1189,9 @@
mBrightnessMirrorShowingInteractor.setMirrorShowing(true);
mTestScope.getTestScheduler().runCurrent();
- verify(mScrimController, never()).transitionTo(ScrimState.BRIGHTNESS_MIRROR);
- verify(mScrimController, never()).transitionTo(eq(ScrimState.BRIGHTNESS_MIRROR), any());
+ verify(mScrimController, never()).legacyTransitionTo(ScrimState.BRIGHTNESS_MIRROR);
+ verify(mScrimController, never())
+ .legacyTransitionTo(eq(ScrimState.BRIGHTNESS_MIRROR), any());
}
@Test
diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/ScrimControllerTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/ScrimControllerTest.java
index 416a869..4590071 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/ScrimControllerTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/ScrimControllerTest.java
@@ -309,7 +309,7 @@
mWallpaperRepository.getWallpaperSupportsAmbientMode().setValue(false);
mTestScope.getTestScheduler().runCurrent();
- mScrimController.transitionTo(ScrimState.KEYGUARD);
+ mScrimController.legacyTransitionTo(ScrimState.KEYGUARD);
finishAnimationsImmediately();
}
@@ -327,7 +327,7 @@
@Test
public void transitionToKeyguard() {
- mScrimController.transitionTo(ScrimState.KEYGUARD);
+ mScrimController.legacyTransitionTo(ScrimState.KEYGUARD);
finishAnimationsImmediately();
assertScrimAlpha(Map.of(
@@ -342,7 +342,7 @@
@Test
public void transitionToShadeLocked() {
- mScrimController.transitionTo(SHADE_LOCKED);
+ mScrimController.legacyTransitionTo(SHADE_LOCKED);
mScrimController.setQsPosition(1f, 0);
finishAnimationsImmediately();
@@ -360,7 +360,7 @@
@Test
public void transitionToShadeLocked_clippingQs() {
mScrimController.setClipsQsScrim(true);
- mScrimController.transitionTo(SHADE_LOCKED);
+ mScrimController.legacyTransitionTo(SHADE_LOCKED);
mScrimController.setQsPosition(1f, 0);
finishAnimationsImmediately();
@@ -377,7 +377,7 @@
@Test
public void transitionToOff() {
- mScrimController.transitionTo(ScrimState.OFF);
+ mScrimController.legacyTransitionTo(ScrimState.OFF);
finishAnimationsImmediately();
assertScrimAlpha(Map.of(
@@ -394,7 +394,7 @@
@Test
public void transitionToAod_withRegularWallpaper() {
- mScrimController.transitionTo(ScrimState.AOD);
+ mScrimController.legacyTransitionTo(ScrimState.AOD);
finishAnimationsImmediately();
assertScrimAlpha(Map.of(
@@ -414,7 +414,7 @@
mWallpaperRepository.getWallpaperSupportsAmbientMode().setValue(true);
mTestScope.getTestScheduler().runCurrent();
- mScrimController.transitionTo(ScrimState.AOD);
+ mScrimController.legacyTransitionTo(ScrimState.AOD);
finishAnimationsImmediately();
assertScrimAlpha(Map.of(
@@ -423,7 +423,7 @@
assertEquals(0f, mScrimController.getState().getMaxLightRevealScrimAlpha(), 0f);
// Pulsing notification should conserve AOD wallpaper.
- mScrimController.transitionTo(ScrimState.PULSING);
+ mScrimController.legacyTransitionTo(ScrimState.PULSING);
finishAnimationsImmediately();
assertScrimAlpha(Map.of(
@@ -438,7 +438,7 @@
mWallpaperRepository.getWallpaperSupportsAmbientMode().setValue(true);
mTestScope.getTestScheduler().runCurrent();
- mScrimController.transitionTo(ScrimState.AOD);
+ mScrimController.legacyTransitionTo(ScrimState.AOD);
finishAnimationsImmediately();
assertScrimAlpha(Map.of(
@@ -457,7 +457,7 @@
mWallpaperRepository.getWallpaperSupportsAmbientMode().setValue(true);
mTestScope.getTestScheduler().runCurrent();
- mScrimController.transitionTo(ScrimState.AOD);
+ mScrimController.legacyTransitionTo(ScrimState.AOD);
finishAnimationsImmediately();
mScrimController.setHasBackdrop(true);
finishAnimationsImmediately();
@@ -476,7 +476,7 @@
@Test
public void transitionToAod_withFrontAlphaUpdates() {
// Assert that setting the AOD front scrim alpha doesn't take effect in a non-AOD state.
- mScrimController.transitionTo(ScrimState.KEYGUARD);
+ mScrimController.legacyTransitionTo(ScrimState.KEYGUARD);
mScrimController.setAodFrontScrimAlpha(0.5f);
finishAnimationsImmediately();
@@ -485,7 +485,7 @@
mScrimBehind, SEMI_TRANSPARENT));
// ... but that it does take effect once we enter the AOD state.
- mScrimController.transitionTo(ScrimState.AOD);
+ mScrimController.legacyTransitionTo(ScrimState.AOD);
finishAnimationsImmediately();
assertScrimAlpha(Map.of(
mScrimInFront, SEMI_TRANSPARENT,
@@ -501,8 +501,8 @@
// ... and make sure we recall the previous front scrim alpha even if we transition away
// for a bit.
- mScrimController.transitionTo(ScrimState.UNLOCKED);
- mScrimController.transitionTo(ScrimState.AOD);
+ mScrimController.legacyTransitionTo(ScrimState.UNLOCKED);
+ mScrimController.legacyTransitionTo(ScrimState.AOD);
finishAnimationsImmediately();
assertScrimAlpha(Map.of(
mScrimInFront, OPAQUE,
@@ -512,8 +512,8 @@
// ... and alpha updates should be completely ignored if always_on is off.
// Passing it forward would mess up the wake-up transition.
mAlwaysOnEnabled = false;
- mScrimController.transitionTo(ScrimState.UNLOCKED);
- mScrimController.transitionTo(ScrimState.AOD);
+ mScrimController.legacyTransitionTo(ScrimState.UNLOCKED);
+ mScrimController.legacyTransitionTo(ScrimState.AOD);
finishAnimationsImmediately();
mScrimController.setAodFrontScrimAlpha(0.3f);
assertEquals(ScrimState.AOD.getFrontAlpha(), mScrimInFront.getViewAlpha(), 0.001f);
@@ -523,7 +523,7 @@
@Test
public void transitionToAod_afterDocked_ignoresAlwaysOnAndUpdatesFrontAlpha() {
// Assert that setting the AOD front scrim alpha doesn't take effect in a non-AOD state.
- mScrimController.transitionTo(ScrimState.KEYGUARD);
+ mScrimController.legacyTransitionTo(ScrimState.KEYGUARD);
mScrimController.setAodFrontScrimAlpha(0.5f);
finishAnimationsImmediately();
@@ -533,7 +533,7 @@
// ... and doesn't take effect when disabled always_on
mAlwaysOnEnabled = false;
- mScrimController.transitionTo(ScrimState.AOD);
+ mScrimController.legacyTransitionTo(ScrimState.AOD);
finishAnimationsImmediately();
assertScrimAlpha(Map.of(
mScrimInFront, OPAQUE,
@@ -542,9 +542,9 @@
// ... but will take effect after docked
when(mDockManager.isDocked()).thenReturn(true);
- mScrimController.transitionTo(ScrimState.KEYGUARD);
+ mScrimController.legacyTransitionTo(ScrimState.KEYGUARD);
mScrimController.setAodFrontScrimAlpha(0.5f);
- mScrimController.transitionTo(ScrimState.AOD);
+ mScrimController.legacyTransitionTo(ScrimState.AOD);
finishAnimationsImmediately();
assertScrimAlpha(Map.of(
@@ -572,14 +572,14 @@
mWallpaperRepository.getWallpaperSupportsAmbientMode().setValue(false);
mTestScope.getTestScheduler().runCurrent();
- mScrimController.transitionTo(ScrimState.AOD);
+ mScrimController.legacyTransitionTo(ScrimState.AOD);
finishAnimationsImmediately();
assertScrimAlpha(Map.of(
mScrimInFront, TRANSPARENT,
mScrimBehind, TRANSPARENT));
assertEquals(1f, mScrimController.getState().getMaxLightRevealScrimAlpha(), 0f);
- mScrimController.transitionTo(ScrimState.PULSING);
+ mScrimController.legacyTransitionTo(ScrimState.PULSING);
finishAnimationsImmediately();
// Front scrim should be transparent, but tinted
// Back scrim should be semi-transparent so the user can see the wallpaper
@@ -617,7 +617,7 @@
@Test
public void transitionToKeyguardBouncer() {
- mScrimController.transitionTo(BOUNCER);
+ mScrimController.legacyTransitionTo(BOUNCER);
finishAnimationsImmediately();
// Front scrim should be transparent
// Back scrim should be visible and tinted to the surface color
@@ -638,7 +638,7 @@
@Test
public void lockscreenToHubTransition_setsBehindScrimAlpha() {
// Start on lockscreen.
- mScrimController.transitionTo(ScrimState.KEYGUARD);
+ mScrimController.legacyTransitionTo(ScrimState.KEYGUARD);
finishAnimationsImmediately();
// Behind scrim starts at default alpha.
@@ -684,7 +684,7 @@
@Test
public void hubToLockscreenTransition_setsViewAlpha() {
// Start on glanceable hub.
- mScrimController.transitionTo(ScrimState.GLANCEABLE_HUB);
+ mScrimController.legacyTransitionTo(ScrimState.GLANCEABLE_HUB);
finishAnimationsImmediately();
// Behind scrim starts at 0 alpha.
@@ -731,7 +731,7 @@
public void transitionToHub() {
mScrimController.setRawPanelExpansionFraction(0f);
mScrimController.setBouncerHiddenFraction(KeyguardBouncerConstants.EXPANSION_HIDDEN);
- mScrimController.transitionTo(ScrimState.GLANCEABLE_HUB);
+ mScrimController.legacyTransitionTo(ScrimState.GLANCEABLE_HUB);
finishAnimationsImmediately();
// All scrims transparent on the hub.
@@ -743,7 +743,7 @@
@Test
public void openBouncerOnHub() {
- mScrimController.transitionTo(ScrimState.GLANCEABLE_HUB);
+ mScrimController.legacyTransitionTo(ScrimState.GLANCEABLE_HUB);
// Open the bouncer.
mScrimController.setRawPanelExpansionFraction(0f);
@@ -760,7 +760,7 @@
// Bouncer is closed.
mScrimController.setBouncerHiddenFraction(KeyguardBouncerConstants.EXPANSION_HIDDEN);
- mScrimController.transitionTo(ScrimState.GLANCEABLE_HUB);
+ mScrimController.legacyTransitionTo(ScrimState.GLANCEABLE_HUB);
finishAnimationsImmediately();
// All scrims are transparent.
@@ -772,7 +772,7 @@
@Test
public void openShadeOnHub() {
- mScrimController.transitionTo(ScrimState.GLANCEABLE_HUB);
+ mScrimController.legacyTransitionTo(ScrimState.GLANCEABLE_HUB);
// Open the shade.
mScrimController.setQsPosition(1f, 0);
@@ -802,7 +802,7 @@
public void transitionToHubOverDream() {
mScrimController.setRawPanelExpansionFraction(0f);
mScrimController.setBouncerHiddenFraction(KeyguardBouncerConstants.EXPANSION_HIDDEN);
- mScrimController.transitionTo(ScrimState.GLANCEABLE_HUB_OVER_DREAM);
+ mScrimController.legacyTransitionTo(ScrimState.GLANCEABLE_HUB_OVER_DREAM);
finishAnimationsImmediately();
// All scrims transparent on the hub.
@@ -814,7 +814,7 @@
@Test
public void openBouncerOnHubOverDream() {
- mScrimController.transitionTo(ScrimState.GLANCEABLE_HUB_OVER_DREAM);
+ mScrimController.legacyTransitionTo(ScrimState.GLANCEABLE_HUB_OVER_DREAM);
// Open the bouncer.
mScrimController.setRawPanelExpansionFraction(0f);
@@ -831,7 +831,7 @@
// Bouncer is closed.
mScrimController.setBouncerHiddenFraction(KeyguardBouncerConstants.EXPANSION_HIDDEN);
- mScrimController.transitionTo(ScrimState.GLANCEABLE_HUB_OVER_DREAM);
+ mScrimController.legacyTransitionTo(ScrimState.GLANCEABLE_HUB_OVER_DREAM);
finishAnimationsImmediately();
// All scrims are transparent.
@@ -843,7 +843,7 @@
@Test
public void openShadeOnHubOverDream() {
- mScrimController.transitionTo(ScrimState.GLANCEABLE_HUB_OVER_DREAM);
+ mScrimController.legacyTransitionTo(ScrimState.GLANCEABLE_HUB_OVER_DREAM);
// Open the shade.
mScrimController.setQsPosition(1f, 0);
@@ -880,7 +880,7 @@
@Test
public void onThemeChangeWhileClipQsScrim_bouncerBehindTint_remainsBlack() {
mScrimController.setClipsQsScrim(true);
- mScrimController.transitionTo(BOUNCER);
+ mScrimController.legacyTransitionTo(BOUNCER);
finishAnimationsImmediately();
assertEquals(BOUNCER.getBehindTint(), Color.BLACK);
@@ -892,7 +892,7 @@
@Test
public void transitionToKeyguardBouncer_clippingQs() {
mScrimController.setClipsQsScrim(true);
- mScrimController.transitionTo(BOUNCER);
+ mScrimController.legacyTransitionTo(BOUNCER);
finishAnimationsImmediately();
// Front scrim should be transparent
// Back scrim should be clipping QS
@@ -912,7 +912,7 @@
@Test
public void disableClipQsScrimWithoutStateTransition_updatesTintAndAlpha() {
mScrimController.setClipsQsScrim(true);
- mScrimController.transitionTo(BOUNCER);
+ mScrimController.legacyTransitionTo(BOUNCER);
mScrimController.setClipsQsScrim(false);
@@ -934,7 +934,7 @@
@Test
public void enableClipQsScrimWithoutStateTransition_updatesTintAndAlpha() {
mScrimController.setClipsQsScrim(false);
- mScrimController.transitionTo(BOUNCER);
+ mScrimController.legacyTransitionTo(BOUNCER);
mScrimController.setClipsQsScrim(true);
@@ -955,7 +955,7 @@
@Test
public void transitionToBouncer() {
- mScrimController.transitionTo(ScrimState.BOUNCER_SCRIMMED);
+ mScrimController.legacyTransitionTo(ScrimState.BOUNCER_SCRIMMED);
finishAnimationsImmediately();
assertScrimAlpha(Map.of(
mScrimInFront, OPAQUE,
@@ -970,7 +970,7 @@
public void transitionToUnlocked_clippedQs() {
mScrimController.setClipsQsScrim(true);
mScrimController.setRawPanelExpansionFraction(0f);
- mScrimController.transitionTo(ScrimState.UNLOCKED);
+ mScrimController.legacyTransitionTo(ScrimState.UNLOCKED);
finishAnimationsImmediately();
assertScrimTinted(Map.of(
@@ -1000,7 +1000,7 @@
public void transitionToUnlocked_nonClippedQs_followsLargeScreensInterpolator() {
mScrimController.setClipsQsScrim(false);
mScrimController.setRawPanelExpansionFraction(0f);
- mScrimController.transitionTo(ScrimState.UNLOCKED);
+ mScrimController.legacyTransitionTo(ScrimState.UNLOCKED);
finishAnimationsImmediately();
assertScrimTinted(Map.of(
@@ -1037,15 +1037,15 @@
@Test
public void scrimStateCallback() {
- mScrimController.transitionTo(ScrimState.UNLOCKED);
+ mScrimController.legacyTransitionTo(ScrimState.UNLOCKED);
finishAnimationsImmediately();
assertEquals(mScrimState, ScrimState.UNLOCKED);
- mScrimController.transitionTo(BOUNCER);
+ mScrimController.legacyTransitionTo(BOUNCER);
finishAnimationsImmediately();
assertEquals(mScrimState, BOUNCER);
- mScrimController.transitionTo(ScrimState.BOUNCER_SCRIMMED);
+ mScrimController.legacyTransitionTo(ScrimState.BOUNCER_SCRIMMED);
finishAnimationsImmediately();
assertEquals(mScrimState, ScrimState.BOUNCER_SCRIMMED);
}
@@ -1054,7 +1054,7 @@
public void panelExpansion() {
mScrimController.setRawPanelExpansionFraction(0f);
mScrimController.setRawPanelExpansionFraction(0.5f);
- mScrimController.transitionTo(ScrimState.UNLOCKED);
+ mScrimController.legacyTransitionTo(ScrimState.UNLOCKED);
finishAnimationsImmediately();
reset(mScrimBehind);
@@ -1114,7 +1114,7 @@
public void panelExpansionAffectsAlpha() {
mScrimController.setRawPanelExpansionFraction(0f);
mScrimController.setRawPanelExpansionFraction(0.5f);
- mScrimController.transitionTo(ScrimState.UNLOCKED);
+ mScrimController.legacyTransitionTo(ScrimState.UNLOCKED);
finishAnimationsImmediately();
final float scrimAlpha = mScrimBehind.getViewAlpha();
@@ -1135,10 +1135,10 @@
@Test
public void transitionToUnlockedFromOff() {
// Simulate unlock with fingerprint without AOD
- mScrimController.transitionTo(ScrimState.OFF);
+ mScrimController.legacyTransitionTo(ScrimState.OFF);
mScrimController.setRawPanelExpansionFraction(0f);
finishAnimationsImmediately();
- mScrimController.transitionTo(ScrimState.UNLOCKED);
+ mScrimController.legacyTransitionTo(ScrimState.UNLOCKED);
finishAnimationsImmediately();
@@ -1157,10 +1157,10 @@
@Test
public void transitionToUnlockedFromAod() {
// Simulate unlock with fingerprint
- mScrimController.transitionTo(ScrimState.AOD);
+ mScrimController.legacyTransitionTo(ScrimState.AOD);
mScrimController.setRawPanelExpansionFraction(0f);
finishAnimationsImmediately();
- mScrimController.transitionTo(ScrimState.UNLOCKED);
+ mScrimController.legacyTransitionTo(ScrimState.UNLOCKED);
finishAnimationsImmediately();
@@ -1179,9 +1179,9 @@
@Test
public void scrimBlanksBeforeLeavingAod() {
// Simulate unlock with fingerprint
- mScrimController.transitionTo(ScrimState.AOD);
+ mScrimController.legacyTransitionTo(ScrimState.AOD);
finishAnimationsImmediately();
- mScrimController.transitionTo(ScrimState.UNLOCKED,
+ mScrimController.legacyTransitionTo(ScrimState.UNLOCKED,
new ScrimController.Callback() {
@Override
public void onDisplayBlanked() {
@@ -1203,9 +1203,9 @@
public void scrimBlankCallbackWhenUnlockingFromPulse() {
boolean[] blanked = {false};
// Simulate unlock with fingerprint
- mScrimController.transitionTo(ScrimState.PULSING);
+ mScrimController.legacyTransitionTo(ScrimState.PULSING);
finishAnimationsImmediately();
- mScrimController.transitionTo(ScrimState.UNLOCKED,
+ mScrimController.legacyTransitionTo(ScrimState.UNLOCKED,
new ScrimController.Callback() {
@Override
public void onDisplayBlanked() {
@@ -1251,16 +1251,16 @@
mScrimController.setHasBackdrop(false);
mWallpaperRepository.getWallpaperSupportsAmbientMode().setValue(false);
mTestScope.getTestScheduler().runCurrent();
- mScrimController.transitionTo(ScrimState.KEYGUARD);
+ mScrimController.legacyTransitionTo(ScrimState.KEYGUARD);
finishAnimationsImmediately();
// WHEN Simulate unlock with fingerprint
- mScrimController.transitionTo(ScrimState.AOD);
+ mScrimController.legacyTransitionTo(ScrimState.AOD);
finishAnimationsImmediately();
// WHEN transitioning to UNLOCKED, onDisplayCallbackBlanked callback called to continue
// the transition but the scrim was not actually blanked
- mScrimController.transitionTo(ScrimState.UNLOCKED,
+ mScrimController.legacyTransitionTo(ScrimState.UNLOCKED,
new ScrimController.Callback() {
@Override
public void onDisplayBlanked() {
@@ -1279,7 +1279,7 @@
public void testScrimCallback() {
int[] callOrder = {0, 0, 0};
int[] currentCall = {0};
- mScrimController.transitionTo(ScrimState.AOD, new ScrimController.Callback() {
+ mScrimController.legacyTransitionTo(ScrimState.AOD, new ScrimController.Callback() {
@Override
public void onStart() {
callOrder[0] = ++currentCall[0];
@@ -1310,19 +1310,19 @@
@Test
public void testScrimCallbackCancelled() {
boolean[] cancelledCalled = {false};
- mScrimController.transitionTo(ScrimState.AOD, new ScrimController.Callback() {
+ mScrimController.legacyTransitionTo(ScrimState.AOD, new ScrimController.Callback() {
@Override
public void onCancelled() {
cancelledCalled[0] = true;
}
});
- mScrimController.transitionTo(ScrimState.PULSING);
+ mScrimController.legacyTransitionTo(ScrimState.PULSING);
Assert.assertTrue("onCancelled should have been called", cancelledCalled[0]);
}
@Test
public void testHoldsWakeLock_whenAOD() {
- mScrimController.transitionTo(ScrimState.AOD);
+ mScrimController.legacyTransitionTo(ScrimState.AOD);
verify(mWakeLock).acquire(anyString());
verify(mWakeLock, never()).release(anyString());
finishAnimationsImmediately();
@@ -1331,24 +1331,24 @@
@Test
public void testDoesNotHoldWakeLock_whenUnlocking() {
- mScrimController.transitionTo(ScrimState.UNLOCKED);
+ mScrimController.legacyTransitionTo(ScrimState.UNLOCKED);
finishAnimationsImmediately();
verifyZeroInteractions(mWakeLock);
}
@Test
public void testCallbackInvokedOnSameStateTransition() {
- mScrimController.transitionTo(ScrimState.UNLOCKED);
+ mScrimController.legacyTransitionTo(ScrimState.UNLOCKED);
finishAnimationsImmediately();
ScrimController.Callback callback = mock(ScrimController.Callback.class);
- mScrimController.transitionTo(ScrimState.UNLOCKED, callback);
+ mScrimController.legacyTransitionTo(ScrimState.UNLOCKED, callback);
verify(callback).onFinished();
}
@Test
public void testHoldsAodWallpaperAnimationLock() {
// Pre-conditions
- mScrimController.transitionTo(ScrimState.AOD);
+ mScrimController.legacyTransitionTo(ScrimState.AOD);
finishAnimationsImmediately();
reset(mWakeLock);
@@ -1362,7 +1362,7 @@
@Test
public void testHoldsPulsingWallpaperAnimationLock() {
// Pre-conditions
- mScrimController.transitionTo(ScrimState.PULSING);
+ mScrimController.legacyTransitionTo(ScrimState.PULSING);
finishAnimationsImmediately();
reset(mWakeLock);
@@ -1378,9 +1378,9 @@
mWallpaperRepository.getWallpaperSupportsAmbientMode().setValue(true);
mTestScope.getTestScheduler().runCurrent();
- mScrimController.transitionTo(ScrimState.AOD);
+ mScrimController.legacyTransitionTo(ScrimState.AOD);
verify(mAlarmManager).setExact(anyInt(), anyLong(), any(), any(), any());
- mScrimController.transitionTo(ScrimState.KEYGUARD);
+ mScrimController.legacyTransitionTo(ScrimState.KEYGUARD);
verify(mAlarmManager).cancel(any(AlarmManager.OnAlarmListener.class));
}
@@ -1391,22 +1391,22 @@
mWallpaperRepository.getWallpaperSupportsAmbientMode().setValue(true);
mTestScope.getTestScheduler().runCurrent();
- mScrimController.transitionTo(ScrimState.AOD);
+ mScrimController.legacyTransitionTo(ScrimState.AOD);
verify(mAlarmManager).setExact(anyInt(), anyLong(), any(), any(), any());
}
@Test
public void testConservesExpansionOpacityAfterTransition() {
- mScrimController.transitionTo(ScrimState.UNLOCKED);
+ mScrimController.legacyTransitionTo(ScrimState.UNLOCKED);
mScrimController.setRawPanelExpansionFraction(0.5f);
finishAnimationsImmediately();
final float expandedAlpha = mScrimBehind.getViewAlpha();
- mScrimController.transitionTo(ScrimState.BRIGHTNESS_MIRROR);
+ mScrimController.legacyTransitionTo(ScrimState.BRIGHTNESS_MIRROR);
finishAnimationsImmediately();
- mScrimController.transitionTo(ScrimState.UNLOCKED);
+ mScrimController.legacyTransitionTo(ScrimState.UNLOCKED);
finishAnimationsImmediately();
assertEquals("Scrim expansion opacity wasn't conserved when transitioning back",
@@ -1415,12 +1415,12 @@
@Test
public void testCancelsOldAnimationBeforeBlanking() {
- mScrimController.transitionTo(ScrimState.AOD);
+ mScrimController.legacyTransitionTo(ScrimState.AOD);
finishAnimationsImmediately();
// Consume whatever value we had before
mAnimatorListener.reset();
- mScrimController.transitionTo(ScrimState.KEYGUARD);
+ mScrimController.legacyTransitionTo(ScrimState.KEYGUARD);
finishAnimationsImmediately();
Assert.assertTrue("Animators not canceled", mAnimatorListener.getNumCancels() != 0);
}
@@ -1439,13 +1439,13 @@
mTestScope.getTestScheduler().runCurrent();
mScrimController.setKeyguardOccluded(true);
- mScrimController.transitionTo(ScrimState.AOD);
+ mScrimController.legacyTransitionTo(ScrimState.AOD);
finishAnimationsImmediately();
assertScrimAlpha(Map.of(
mScrimInFront, TRANSPARENT,
mScrimBehind, OPAQUE));
- mScrimController.transitionTo(ScrimState.PULSING);
+ mScrimController.legacyTransitionTo(ScrimState.PULSING);
finishAnimationsImmediately();
assertScrimAlpha(Map.of(
mScrimInFront, TRANSPARENT,
@@ -1457,7 +1457,7 @@
mWallpaperRepository.getWallpaperSupportsAmbientMode().setValue(true);
mTestScope.getTestScheduler().runCurrent();
- mScrimController.transitionTo(ScrimState.AOD);
+ mScrimController.legacyTransitionTo(ScrimState.AOD);
finishAnimationsImmediately();
assertScrimAlpha(Map.of(
mScrimInFront, TRANSPARENT,
@@ -1478,7 +1478,7 @@
if (state == ScrimState.UNINITIALIZED) {
continue;
}
- mScrimController.transitionTo(state);
+ mScrimController.legacyTransitionTo(state);
finishAnimationsImmediately();
assertEquals("Should be clickable unless AOD or PULSING, was: " + state,
mScrimBehind.getViewAlpha() != 0 && !eatsTouches.contains(state),
@@ -1520,7 +1520,7 @@
@Test
public void testScrimsOpaque_whenShadeFullyExpanded() {
- mScrimController.transitionTo(ScrimState.UNLOCKED);
+ mScrimController.legacyTransitionTo(ScrimState.UNLOCKED);
mScrimController.setRawPanelExpansionFraction(1);
// notifications scrim alpha change require calling setQsPosition
mScrimController.setQsPosition(0, 300);
@@ -1536,7 +1536,7 @@
public void testAuthScrim_setClipQSScrimTrue_notifScrimOpaque_whenShadeFullyExpanded() {
// GIVEN device has an activity showing ('UNLOCKED' state can occur on the lock screen
// with the camera app occluding the keyguard)
- mScrimController.transitionTo(ScrimState.UNLOCKED);
+ mScrimController.legacyTransitionTo(ScrimState.UNLOCKED);
mScrimController.setClipsQsScrim(true);
mScrimController.setRawPanelExpansionFraction(1);
// notifications scrim alpha change require calling setQsPosition
@@ -1544,7 +1544,7 @@
finishAnimationsImmediately();
// WHEN the user triggers the auth bouncer
- mScrimController.transitionTo(ScrimState.AUTH_SCRIMMED_SHADE);
+ mScrimController.legacyTransitionTo(ScrimState.AUTH_SCRIMMED_SHADE);
finishAnimationsImmediately();
assertEquals("Behind scrim should be opaque",
@@ -1564,7 +1564,7 @@
public void testAuthScrim_setClipQSScrimFalse_notifScrimOpaque_whenShadeFullyExpanded() {
// GIVEN device has an activity showing ('UNLOCKED' state can occur on the lock screen
// with the camera app occluding the keyguard)
- mScrimController.transitionTo(ScrimState.UNLOCKED);
+ mScrimController.legacyTransitionTo(ScrimState.UNLOCKED);
mScrimController.setClipsQsScrim(false);
mScrimController.setRawPanelExpansionFraction(1);
// notifications scrim alpha change require calling setQsPosition
@@ -1572,7 +1572,7 @@
finishAnimationsImmediately();
// WHEN the user triggers the auth bouncer
- mScrimController.transitionTo(ScrimState.AUTH_SCRIMMED_SHADE);
+ mScrimController.legacyTransitionTo(ScrimState.AUTH_SCRIMMED_SHADE);
finishAnimationsImmediately();
assertEquals("Behind scrim should be opaque",
@@ -1590,11 +1590,11 @@
@Test
public void testAuthScrimKeyguard() {
// GIVEN device is on the keyguard
- mScrimController.transitionTo(ScrimState.KEYGUARD);
+ mScrimController.legacyTransitionTo(ScrimState.KEYGUARD);
finishAnimationsImmediately();
// WHEN the user triggers the auth bouncer
- mScrimController.transitionTo(ScrimState.AUTH_SCRIMMED);
+ mScrimController.legacyTransitionTo(ScrimState.AUTH_SCRIMMED);
finishAnimationsImmediately();
// THEN the front scrim is updated and the KEYGUARD scrims are the same as the
@@ -1608,7 +1608,7 @@
@Test
public void testScrimsVisible_whenShadeVisible() {
mScrimController.setClipsQsScrim(true);
- mScrimController.transitionTo(ScrimState.UNLOCKED);
+ mScrimController.legacyTransitionTo(ScrimState.UNLOCKED);
mScrimController.setRawPanelExpansionFraction(0.3f);
// notifications scrim alpha change require calling setQsPosition
mScrimController.setQsPosition(0, 300);
@@ -1643,7 +1643,7 @@
@Test
public void testScrimsVisible_whenShadeVisible_clippingQs() {
mScrimController.setClipsQsScrim(true);
- mScrimController.transitionTo(ScrimState.UNLOCKED);
+ mScrimController.legacyTransitionTo(ScrimState.UNLOCKED);
mScrimController.setRawPanelExpansionFraction(0.3f);
// notifications scrim alpha change require calling setQsPosition
mScrimController.setQsPosition(0.5f, 300);
@@ -1657,7 +1657,7 @@
@Test
public void testScrimsVisible_whenShadeVisibleOnLockscreen() {
- mScrimController.transitionTo(ScrimState.KEYGUARD);
+ mScrimController.legacyTransitionTo(ScrimState.KEYGUARD);
mScrimController.setQsPosition(0.25f, 300);
assertScrimAlpha(Map.of(
@@ -1668,7 +1668,7 @@
@Test
public void testNotificationScrimTransparent_whenOnLockscreen() {
- mScrimController.transitionTo(ScrimState.KEYGUARD);
+ mScrimController.legacyTransitionTo(ScrimState.KEYGUARD);
// even if shade is not pulled down, panel has expansion of 1 on the lockscreen
mScrimController.setRawPanelExpansionFraction(1);
mScrimController.setQsPosition(0f, /*qs panel bottom*/ 0);
@@ -1681,7 +1681,7 @@
@Test
public void testNotificationScrimVisible_afterOpeningShadeFromLockscreen() {
mScrimController.setRawPanelExpansionFraction(1);
- mScrimController.transitionTo(SHADE_LOCKED);
+ mScrimController.legacyTransitionTo(SHADE_LOCKED);
finishAnimationsImmediately();
assertScrimAlpha(Map.of(
@@ -1695,7 +1695,7 @@
// clipping doesn't change tested logic but allows to assert scrims more in line with
// their expected large screen behaviour
mScrimController.setClipsQsScrim(false);
- mScrimController.transitionTo(SHADE_LOCKED);
+ mScrimController.legacyTransitionTo(SHADE_LOCKED);
mScrimController.setQsPosition(1f, 100 /* value doesn't matter */);
assertTintAfterExpansion(mScrimBehind, SHADE_LOCKED.getBehindTint(), /* expansion= */ 1f);
@@ -1709,7 +1709,7 @@
public void expansionNotificationAlpha_shadeLocked_bouncerActive_usesBouncerInterpolator() {
when(mStatusBarKeyguardViewManager.isPrimaryBouncerInTransit()).thenReturn(true);
- mScrimController.transitionTo(SHADE_LOCKED);
+ mScrimController.legacyTransitionTo(SHADE_LOCKED);
float expansion = 0.8f;
float expectedAlpha =
@@ -1725,7 +1725,7 @@
public void expansionNotificationAlpha_shadeLocked_bouncerNotActive_usesShadeInterpolator() {
when(mStatusBarKeyguardViewManager.isPrimaryBouncerInTransit()).thenReturn(false);
- mScrimController.transitionTo(SHADE_LOCKED);
+ mScrimController.legacyTransitionTo(SHADE_LOCKED);
float expansion = 0.8f;
float expectedAlpha = ShadeInterpolation.getNotificationScrimAlpha(expansion);
@@ -1740,7 +1740,7 @@
public void notificationAlpha_unnocclusionAnimating_bouncerNotActive_usesKeyguardNotifAlpha() {
when(mStatusBarKeyguardViewManager.isPrimaryBouncerInTransit()).thenReturn(false);
- mScrimController.transitionTo(ScrimState.KEYGUARD);
+ mScrimController.legacyTransitionTo(ScrimState.KEYGUARD);
assertAlphaAfterExpansion(
mNotificationsScrim, ScrimState.KEYGUARD.getNotifAlpha(), /* expansion */ 0f);
@@ -1760,7 +1760,7 @@
when(mStatusBarKeyguardViewManager.isPrimaryBouncerInTransit()).thenReturn(true);
mScrimController.setClipsQsScrim(true);
- mScrimController.transitionTo(ScrimState.KEYGUARD);
+ mScrimController.legacyTransitionTo(ScrimState.KEYGUARD);
float expansion = 0.8f;
float alpha = 1 - BouncerPanelExpansionCalculator.aboutToShowBouncerProgress(expansion);
@@ -1780,7 +1780,7 @@
when(mStatusBarKeyguardViewManager.isPrimaryBouncerInTransit()).thenReturn(false);
mScrimController.setClipsQsScrim(true);
- mScrimController.transitionTo(ScrimState.KEYGUARD);
+ mScrimController.legacyTransitionTo(ScrimState.KEYGUARD);
float expansion = 0.8f;
float alpha = 1 - ShadeInterpolation.getNotificationScrimAlpha(expansion);
@@ -1800,7 +1800,7 @@
when(mStatusBarKeyguardViewManager.isPrimaryBouncerInTransit()).thenReturn(false);
mScrimController.setClipsQsScrim(false);
- mScrimController.transitionTo(ScrimState.KEYGUARD);
+ mScrimController.legacyTransitionTo(ScrimState.KEYGUARD);
finishAnimationsImmediately();
assertThat(mScrimBehind.getTint())
.isEqualTo(ScrimState.KEYGUARD.getBehindTint());
@@ -1810,7 +1810,7 @@
public void testNotificationTransparency_followsTransitionToFullShade() {
mScrimController.setClipsQsScrim(true);
- mScrimController.transitionTo(SHADE_LOCKED);
+ mScrimController.legacyTransitionTo(SHADE_LOCKED);
mScrimController.setRawPanelExpansionFraction(1.0f);
finishAnimationsImmediately();
@@ -1821,7 +1821,7 @@
));
float shadeLockedAlpha = mNotificationsScrim.getViewAlpha();
- mScrimController.transitionTo(ScrimState.KEYGUARD);
+ mScrimController.legacyTransitionTo(ScrimState.KEYGUARD);
mScrimController.setRawPanelExpansionFraction(1.0f);
finishAnimationsImmediately();
float keyguardAlpha = mNotificationsScrim.getViewAlpha();
@@ -1849,10 +1849,10 @@
@Test
public void notificationTransparency_followsNotificationScrimProgress() {
- mScrimController.transitionTo(SHADE_LOCKED);
+ mScrimController.legacyTransitionTo(SHADE_LOCKED);
mScrimController.setRawPanelExpansionFraction(1.0f);
finishAnimationsImmediately();
- mScrimController.transitionTo(ScrimState.KEYGUARD);
+ mScrimController.legacyTransitionTo(ScrimState.KEYGUARD);
mScrimController.setRawPanelExpansionFraction(1.0f);
finishAnimationsImmediately();
@@ -1866,7 +1866,7 @@
@Test
public void notificationAlpha_qsNotClipped_alphaMatchesNotificationExpansionProgress() {
mScrimController.setClipsQsScrim(false);
- mScrimController.transitionTo(ScrimState.KEYGUARD);
+ mScrimController.legacyTransitionTo(ScrimState.KEYGUARD);
// RawPanelExpansion and QsExpansion are usually used for the notification alpha
// calculation.
// Here we set them to non-zero values explicitly to make sure that in not clipped mode,
@@ -1927,7 +1927,7 @@
@Test
public void notificationBoundsTopGetsPassedToKeyguard() {
- mScrimController.transitionTo(SHADE_LOCKED);
+ mScrimController.legacyTransitionTo(SHADE_LOCKED);
mScrimController.setQsPosition(1f, 0);
finishAnimationsImmediately();
@@ -1938,7 +1938,7 @@
@Test
public void notificationBoundsTopDoesNotGetPassedToKeyguardWhenNotifScrimIsNotVisible() {
mScrimController.setKeyguardOccluded(true);
- mScrimController.transitionTo(ScrimState.KEYGUARD);
+ mScrimController.legacyTransitionTo(ScrimState.KEYGUARD);
finishAnimationsImmediately();
mScrimController.setNotificationsBounds(0f, 100f, 0f, 0f);
@@ -1949,7 +1949,7 @@
public void transitionToDreaming() {
mScrimController.setRawPanelExpansionFraction(0f);
mScrimController.setBouncerHiddenFraction(KeyguardBouncerConstants.EXPANSION_HIDDEN);
- mScrimController.transitionTo(ScrimState.DREAMING);
+ mScrimController.legacyTransitionTo(ScrimState.DREAMING);
finishAnimationsImmediately();
assertScrimAlpha(Map.of(
@@ -1975,7 +1975,7 @@
@Test
public void setUnOccludingAnimationKeyguard() {
- mScrimController.transitionTo(ScrimState.KEYGUARD);
+ mScrimController.legacyTransitionTo(ScrimState.KEYGUARD);
finishAnimationsImmediately();
assertThat(mNotificationsScrim.getViewAlpha())
.isWithin(0.01f).of(ScrimState.KEYGUARD.getNotifAlpha());
@@ -1990,14 +1990,14 @@
@Test
public void testHidesScrimFlickerInActivity() {
mScrimController.setKeyguardOccluded(true);
- mScrimController.transitionTo(ScrimState.KEYGUARD);
+ mScrimController.legacyTransitionTo(ScrimState.KEYGUARD);
finishAnimationsImmediately();
assertScrimAlpha(Map.of(
mScrimInFront, TRANSPARENT,
mScrimBehind, TRANSPARENT,
mNotificationsScrim, TRANSPARENT));
- mScrimController.transitionTo(SHADE_LOCKED);
+ mScrimController.legacyTransitionTo(SHADE_LOCKED);
finishAnimationsImmediately();
assertScrimAlpha(Map.of(
mScrimInFront, TRANSPARENT,
@@ -2008,7 +2008,7 @@
@Test
public void notificationAlpha_inKeyguardState_bouncerNotActive_clipsQsScrimFalse() {
mScrimController.setClipsQsScrim(false);
- mScrimController.transitionTo(ScrimState.KEYGUARD);
+ mScrimController.legacyTransitionTo(ScrimState.KEYGUARD);
float expansion = 0.8f;
assertAlphaAfterExpansion(mNotificationsScrim, 0f, expansion);
@@ -2016,14 +2016,14 @@
@Test
public void aodStateSetsFrontScrimToNotBlend() {
- mScrimController.transitionTo(ScrimState.AOD);
+ mScrimController.legacyTransitionTo(ScrimState.AOD);
assertFalse("Front scrim should not blend with main color",
mScrimInFront.shouldBlendWithMainColor());
}
@Test
public void applyState_unlocked_bouncerShowing() {
- mScrimController.transitionTo(ScrimState.UNLOCKED);
+ mScrimController.legacyTransitionTo(ScrimState.UNLOCKED);
mScrimController.setBouncerHiddenFraction(0.99f);
mScrimController.setRawPanelExpansionFraction(0f);
finishAnimationsImmediately();
@@ -2032,13 +2032,13 @@
@Test
public void ignoreTransitionRequestWhileKeyguardTransitionRunning() {
- mScrimController.transitionTo(ScrimState.UNLOCKED);
+ mScrimController.legacyTransitionTo(ScrimState.UNLOCKED);
mScrimController.mBouncerToGoneTransition.accept(
new TransitionStep(KeyguardState.PRIMARY_BOUNCER, KeyguardState.GONE, 0f,
TransitionState.RUNNING, "ScrimControllerTest"));
// This request should not happen
- mScrimController.transitionTo(ScrimState.BOUNCER);
+ mScrimController.legacyTransitionTo(ScrimState.BOUNCER);
assertThat(mScrimController.getState()).isEqualTo(ScrimState.UNLOCKED);
}
@@ -2055,16 +2055,16 @@
@Test
public void testDoNotAnimateChangeIfOccludeAnimationPlaying() {
mScrimController.setOccludeAnimationPlaying(true);
- mScrimController.transitionTo(ScrimState.UNLOCKED);
+ mScrimController.legacyTransitionTo(ScrimState.UNLOCKED);
assertFalse(ScrimState.UNLOCKED.mAnimateChange);
}
@Test
public void testNotifScrimAlpha_1f_afterUnlockFinishedAndExpanded() {
- mScrimController.transitionTo(ScrimState.KEYGUARD);
+ mScrimController.legacyTransitionTo(ScrimState.KEYGUARD);
when(mKeyguardUnlockAnimationController.isPlayingCannedUnlockAnimation()).thenReturn(true);
- mScrimController.transitionTo(ScrimState.UNLOCKED);
+ mScrimController.legacyTransitionTo(ScrimState.UNLOCKED);
mScrimController.onUnlockAnimationFinished();
assertAlphaAfterExpansion(mNotificationsScrim, 1f, 1f);
}
diff --git a/packages/SystemUI/tests/src/com/android/systemui/surfaceeffects/glowboxeffect/GlowBoxEffectTest.kt b/packages/SystemUI/tests/src/com/android/systemui/surfaceeffects/glowboxeffect/GlowBoxEffectTest.kt
new file mode 100644
index 0000000..16132ba
--- /dev/null
+++ b/packages/SystemUI/tests/src/com/android/systemui/surfaceeffects/glowboxeffect/GlowBoxEffectTest.kt
@@ -0,0 +1,124 @@
+/*
+ * 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.systemui.surfaceeffects.glowboxeffect
+
+import android.graphics.Color
+import android.graphics.Paint
+import android.testing.AndroidTestingRunner
+import android.testing.TestableLooper
+import androidx.test.filters.SmallTest
+import com.android.systemui.SysuiTestCase
+import com.android.systemui.animation.AnimatorTestRule
+import com.android.systemui.surfaceeffects.PaintDrawCallback
+import com.google.common.truth.Truth.assertThat
+import org.junit.Before
+import org.junit.Rule
+import org.junit.Test
+import org.junit.runner.RunWith
+
+@SmallTest
+@RunWith(AndroidTestingRunner::class)
+@TestableLooper.RunWithLooper(setAsMainLooper = true)
+class GlowBoxEffectTest : SysuiTestCase() {
+
+ @get:Rule val animatorTestRule = AnimatorTestRule(this)
+ private lateinit var config: GlowBoxConfig
+ private lateinit var glowBoxEffect: GlowBoxEffect
+ private lateinit var drawCallback: PaintDrawCallback
+
+ @Before
+ fun setup() {
+ drawCallback =
+ object : PaintDrawCallback {
+ override fun onDraw(paint: Paint) {}
+ }
+ config =
+ GlowBoxConfig(
+ startCenterX = 0f,
+ startCenterY = 0f,
+ endCenterX = 0f,
+ endCenterY = 0f,
+ width = 1f,
+ height = 1f,
+ color = Color.WHITE,
+ blurAmount = 0.1f,
+ duration = 100L,
+ easeInDuration = 100L,
+ easeOutDuration = 100L
+ )
+ glowBoxEffect = GlowBoxEffect(config, drawCallback)
+ }
+
+ @Test
+ fun play_paintCallback_triggersDrawCallback() {
+ var paintFromCallback: Paint? = null
+ drawCallback =
+ object : PaintDrawCallback {
+ override fun onDraw(paint: Paint) {
+ paintFromCallback = paint
+ }
+ }
+ glowBoxEffect = GlowBoxEffect(config, drawCallback)
+
+ assertThat(paintFromCallback).isNull()
+
+ glowBoxEffect.play()
+ animatorTestRule.advanceTimeBy(50L)
+
+ assertThat(paintFromCallback).isNotNull()
+ }
+
+ @Test
+ fun play_followsAnimationStateInOrder() {
+ assertThat(glowBoxEffect.state).isEqualTo(GlowBoxEffect.AnimationState.NOT_PLAYING)
+
+ glowBoxEffect.play()
+
+ assertThat(glowBoxEffect.state).isEqualTo(GlowBoxEffect.AnimationState.EASE_IN)
+
+ animatorTestRule.advanceTimeBy(config.easeInDuration + 50L)
+
+ assertThat(glowBoxEffect.state).isEqualTo(GlowBoxEffect.AnimationState.MAIN)
+
+ animatorTestRule.advanceTimeBy(config.duration + 50L)
+
+ assertThat(glowBoxEffect.state).isEqualTo(GlowBoxEffect.AnimationState.EASE_OUT)
+
+ animatorTestRule.advanceTimeBy(config.easeOutDuration + 50L)
+
+ assertThat(glowBoxEffect.state).isEqualTo(GlowBoxEffect.AnimationState.NOT_PLAYING)
+ }
+
+ @Test
+ fun finish_statePlaying_finishesAnimation() {
+ assertThat(glowBoxEffect.state).isEqualTo(GlowBoxEffect.AnimationState.NOT_PLAYING)
+
+ glowBoxEffect.play()
+ glowBoxEffect.finish()
+
+ assertThat(glowBoxEffect.state).isEqualTo(GlowBoxEffect.AnimationState.EASE_OUT)
+ }
+
+ @Test
+ fun finish_stateNotPlaying_doesNotFinishAnimation() {
+ assertThat(glowBoxEffect.state).isEqualTo(GlowBoxEffect.AnimationState.NOT_PLAYING)
+
+ glowBoxEffect.finish()
+
+ assertThat(glowBoxEffect.state).isEqualTo(GlowBoxEffect.AnimationState.NOT_PLAYING)
+ }
+}
diff --git a/packages/SystemUI/tests/src/com/android/systemui/surfaceeffects/loadingeffect/LoadingEffectTest.kt b/packages/SystemUI/tests/src/com/android/systemui/surfaceeffects/loadingeffect/LoadingEffectTest.kt
index 6f58941..41d7fd5 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/surfaceeffects/loadingeffect/LoadingEffectTest.kt
+++ b/packages/SystemUI/tests/src/com/android/systemui/surfaceeffects/loadingeffect/LoadingEffectTest.kt
@@ -21,8 +21,8 @@
import android.testing.AndroidTestingRunner
import android.testing.TestableLooper
import androidx.test.filters.SmallTest
+import com.android.systemui.SysuiTestCase
import com.android.systemui.animation.AnimatorTestRule
-import com.android.systemui.model.SysUiStateTest
import com.android.systemui.surfaceeffects.PaintDrawCallback
import com.android.systemui.surfaceeffects.RenderEffectDrawCallback
import com.android.systemui.surfaceeffects.turbulencenoise.TurbulenceNoiseAnimationConfig
@@ -35,7 +35,7 @@
@SmallTest
@RunWith(AndroidTestingRunner::class)
@TestableLooper.RunWithLooper(setAsMainLooper = true)
-class LoadingEffectTest : SysUiStateTest() {
+class LoadingEffectTest : SysuiTestCase() {
@get:Rule val animatorTestRule = AnimatorTestRule(this)
diff --git a/packages/SystemUI/tests/src/com/android/systemui/temporarydisplay/chipbar/ChipbarCoordinatorTest.kt b/packages/SystemUI/tests/src/com/android/systemui/temporarydisplay/chipbar/ChipbarCoordinatorTest.kt
index 1466d24..664f2df 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/temporarydisplay/chipbar/ChipbarCoordinatorTest.kt
+++ b/packages/SystemUI/tests/src/com/android/systemui/temporarydisplay/chipbar/ChipbarCoordinatorTest.kt
@@ -19,7 +19,6 @@
import android.os.PowerManager
import android.os.VibrationAttributes
import android.os.VibrationEffect
-import android.testing.AndroidTestingRunner
import android.testing.TestableLooper
import android.view.MotionEvent
import android.view.View
@@ -29,6 +28,7 @@
import android.widget.ImageView
import android.widget.TextView
import androidx.core.animation.doOnCancel
+import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.filters.SmallTest
import com.android.internal.logging.InstanceId
import com.android.internal.logging.testing.UiEventLoggerFake
@@ -68,7 +68,7 @@
import org.mockito.MockitoAnnotations
@SmallTest
-@RunWith(AndroidTestingRunner::class)
+@RunWith(AndroidJUnit4::class)
@TestableLooper.RunWithLooper
class ChipbarCoordinatorTest : SysuiTestCase() {
private lateinit var underTest: ChipbarCoordinator
diff --git a/packages/SystemUI/tests/src/com/android/systemui/theme/ThemeOverlayApplierTest.java b/packages/SystemUI/tests/src/com/android/systemui/theme/ThemeOverlayApplierTest.java
index 8f4cbaf..31ee858 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/theme/ThemeOverlayApplierTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/theme/ThemeOverlayApplierTest.java
@@ -45,9 +45,9 @@
import android.content.om.OverlayManager;
import android.content.om.OverlayManagerTransaction;
import android.os.UserHandle;
-import android.testing.AndroidTestingRunner;
import android.testing.TestableLooper;
+import androidx.test.ext.junit.runners.AndroidJUnit4;
import androidx.test.filters.SmallTest;
import com.android.systemui.SysuiTestCase;
@@ -69,7 +69,7 @@
import java.util.Set;
@SmallTest
-@RunWith(AndroidTestingRunner.class)
+@RunWith(AndroidJUnit4.class)
@TestableLooper.RunWithLooper
public class ThemeOverlayApplierTest extends SysuiTestCase {
private static final String TEST_DISABLED_PREFIX = "com.example.";
diff --git a/packages/SystemUI/tests/src/com/android/systemui/theme/ThemeOverlayControllerTest.java b/packages/SystemUI/tests/src/com/android/systemui/theme/ThemeOverlayControllerTest.java
index 5ad88ad..53e033e 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/theme/ThemeOverlayControllerTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/theme/ThemeOverlayControllerTest.java
@@ -52,9 +52,9 @@
import android.os.UserHandle;
import android.os.UserManager;
import android.provider.Settings;
-import android.testing.AndroidTestingRunner;
import androidx.annotation.VisibleForTesting;
+import androidx.test.ext.junit.runners.AndroidJUnit4;
import androidx.test.filters.SmallTest;
import com.android.systemui.SysuiTestCase;
@@ -88,7 +88,7 @@
import java.util.concurrent.Executor;
@SmallTest
-@RunWith(AndroidTestingRunner.class)
+@RunWith(AndroidJUnit4.class)
public class ThemeOverlayControllerTest extends SysuiTestCase {
private static final int USER_SYSTEM = UserHandle.USER_SYSTEM;
@@ -202,7 +202,7 @@
verify(mWakefulnessLifecycle).addObserver(mWakefulnessLifecycleObserver.capture());
verify(mDumpManager).registerDumpable(any(), any());
verify(mDeviceProvisionedController).addCallback(mDeviceProvisionedListener.capture());
- verify(mSecureSettings).registerContentObserverForUser(
+ verify(mSecureSettings).registerContentObserverForUserSync(
eq(Settings.Secure.THEME_CUSTOMIZATION_OVERLAY_PACKAGES),
eq(false), mSettingsObserver.capture(), eq(UserHandle.USER_ALL)
);
diff --git a/packages/SystemUI/tests/src/com/android/systemui/toast/ToastUITest.java b/packages/SystemUI/tests/src/com/android/systemui/toast/ToastUITest.java
index 0581e0e..8df37ce 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/toast/ToastUITest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/toast/ToastUITest.java
@@ -46,7 +46,6 @@
import android.os.Parcelable;
import android.os.RemoteException;
import android.os.UserHandle;
-import android.testing.AndroidTestingRunner;
import android.testing.TestableLooper;
import android.view.Display;
import android.view.LayoutInflater;
@@ -59,6 +58,7 @@
import android.widget.TextView;
import android.widget.Toast;
+import androidx.test.ext.junit.runners.AndroidJUnit4;
import androidx.test.filters.SmallTest;
import com.android.internal.util.IntPair;
@@ -80,7 +80,7 @@
import java.util.Arrays;
@SmallTest
-@RunWith(AndroidTestingRunner.class)
+@RunWith(AndroidJUnit4.class)
@TestableLooper.RunWithLooper
public class ToastUITest extends SysuiTestCase {
private static final int ANDROID_UID = 1000;
diff --git a/packages/SystemUI/tests/src/com/android/systemui/touch/TouchInsetManagerTest.java b/packages/SystemUI/tests/src/com/android/systemui/touch/TouchInsetManagerTest.java
index eb932d2..ce5899a 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/touch/TouchInsetManagerTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/touch/TouchInsetManagerTest.java
@@ -25,11 +25,11 @@
import android.graphics.Rect;
import android.graphics.Region;
-import android.testing.AndroidTestingRunner;
import android.view.AttachedSurfaceControl;
import android.view.View;
import android.view.ViewGroup;
+import androidx.test.ext.junit.runners.AndroidJUnit4;
import androidx.test.filters.SmallTest;
import com.android.systemui.SysuiTestCase;
@@ -45,7 +45,7 @@
import org.mockito.MockitoAnnotations;
@SmallTest
-@RunWith(AndroidTestingRunner.class)
+@RunWith(AndroidJUnit4.class)
public class TouchInsetManagerTest extends SysuiTestCase {
@Mock
private AttachedSurfaceControl mAttachedSurfaceControl;
diff --git a/packages/SystemUI/tests/src/com/android/systemui/tracing/TraceUtilsTest.kt b/packages/SystemUI/tests/src/com/android/systemui/tracing/TraceUtilsTest.kt
index bda339f..eef4e3b 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/tracing/TraceUtilsTest.kt
+++ b/packages/SystemUI/tests/src/com/android/systemui/tracing/TraceUtilsTest.kt
@@ -17,8 +17,8 @@
import android.os.Handler
import android.os.Looper
import android.os.Trace.TRACE_TAG_APP
-import android.testing.AndroidTestingRunner
import android.util.Log
+import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.filters.SmallTest
import com.android.app.tracing.TraceUtils.traceRunnable
import com.android.app.tracing.namedRunnable
@@ -30,7 +30,7 @@
import org.junit.Test
import org.junit.runner.RunWith
-@RunWith(AndroidTestingRunner::class)
+@RunWith(AndroidJUnit4::class)
@SmallTest
class TraceUtilsTest : SysuiTestCase() {
diff --git a/packages/SystemUI/tests/src/com/android/systemui/util/settings/FakeSettingsTest.java b/packages/SystemUI/tests/src/com/android/systemui/util/settings/FakeSettingsTest.java
index 99f6303..25a44e3 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/util/settings/FakeSettingsTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/util/settings/FakeSettingsTest.java
@@ -83,7 +83,7 @@
@Test
public void testRegisterContentObserver() {
- mFakeSettings.registerContentObserver("cat", mContentObserver);
+ mFakeSettings.registerContentObserverSync("cat", mContentObserver);
mFakeSettings.putString("cat", "hat");
@@ -93,7 +93,7 @@
@Test
public void testRegisterContentObserverAllUsers() {
- mFakeSettings.registerContentObserverForUser(
+ mFakeSettings.registerContentObserverForUserSync(
mFakeSettings.getUriFor("cat"), false, mContentObserver, UserHandle.USER_ALL);
mFakeSettings.putString("cat", "hat");
@@ -104,8 +104,8 @@
@Test
public void testUnregisterContentObserver() {
- mFakeSettings.registerContentObserver("cat", mContentObserver);
- mFakeSettings.unregisterContentObserver(mContentObserver);
+ mFakeSettings.registerContentObserverSync("cat", mContentObserver);
+ mFakeSettings.unregisterContentObserverSync(mContentObserver);
mFakeSettings.putString("cat", "hat");
@@ -115,9 +115,9 @@
@Test
public void testUnregisterContentObserverAllUsers() {
- mFakeSettings.registerContentObserverForUser(
+ mFakeSettings.registerContentObserverForUserSync(
mFakeSettings.getUriFor("cat"), false, mContentObserver, UserHandle.USER_ALL);
- mFakeSettings.unregisterContentObserver(mContentObserver);
+ mFakeSettings.unregisterContentObserverSync(mContentObserver);
mFakeSettings.putString("cat", "hat");
@@ -128,7 +128,7 @@
@Test
public void testContentObserverDispatchCorrectUser() {
int user = 10;
- mFakeSettings.registerContentObserverForUser(
+ mFakeSettings.registerContentObserverForUserSync(
mFakeSettings.getUriFor("cat"), false, mContentObserver, UserHandle.USER_ALL
);
diff --git a/packages/SystemUI/tests/src/com/android/systemui/util/settings/SettingsProxyTest.kt b/packages/SystemUI/tests/src/com/android/systemui/util/settings/SettingsProxyTest.kt
index ab95707..eb11e38 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/util/settings/SettingsProxyTest.kt
+++ b/packages/SystemUI/tests/src/com/android/systemui/util/settings/SettingsProxyTest.kt
@@ -52,14 +52,14 @@
@Test
fun registerContentObserver_inputString_success() {
- mSettings.registerContentObserver(TEST_SETTING, mContentObserver)
+ mSettings.registerContentObserverSync(TEST_SETTING, mContentObserver)
verify(mSettings.getContentResolver())
.registerContentObserver(eq(TEST_SETTING_URI), eq(false), eq(mContentObserver))
}
@Test
fun registerContentObserver_inputString_notifyForDescendants_true() {
- mSettings.registerContentObserver(
+ mSettings.registerContentObserverSync(
TEST_SETTING,
notifyForDescendants = true,
mContentObserver
@@ -70,14 +70,14 @@
@Test
fun registerContentObserver_inputUri_success() {
- mSettings.registerContentObserver(TEST_SETTING_URI, mContentObserver)
+ mSettings.registerContentObserverSync(TEST_SETTING_URI, mContentObserver)
verify(mSettings.getContentResolver())
.registerContentObserver(eq(TEST_SETTING_URI), eq(false), eq(mContentObserver))
}
@Test
fun registerContentObserver_inputUri_notifyForDescendants_true() {
- mSettings.registerContentObserver(
+ mSettings.registerContentObserverSync(
TEST_SETTING_URI,
notifyForDescendants = true,
mContentObserver
@@ -88,7 +88,7 @@
@Test
fun unregisterContentObserver() {
- mSettings.unregisterContentObserver(mContentObserver)
+ mSettings.unregisterContentObserverSync(mContentObserver)
verify(mSettings.getContentResolver()).unregisterContentObserver(eq(mContentObserver))
}
diff --git a/packages/SystemUI/tests/src/com/android/systemui/util/settings/UserSettingsProxyTest.kt b/packages/SystemUI/tests/src/com/android/systemui/util/settings/UserSettingsProxyTest.kt
index 56328b9..38469ee 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/util/settings/UserSettingsProxyTest.kt
+++ b/packages/SystemUI/tests/src/com/android/systemui/util/settings/UserSettingsProxyTest.kt
@@ -58,7 +58,7 @@
@Test
fun registerContentObserverForUser_inputString_success() {
- mSettings.registerContentObserverForUser(
+ mSettings.registerContentObserverForUserSync(
TEST_SETTING,
mContentObserver,
mUserTracker.userId
@@ -74,7 +74,7 @@
@Test
fun registerContentObserverForUser_inputString_notifyForDescendants_true() {
- mSettings.registerContentObserverForUser(
+ mSettings.registerContentObserverForUserSync(
TEST_SETTING,
notifyForDescendants = true,
mContentObserver,
@@ -91,7 +91,7 @@
@Test
fun registerContentObserverForUser_inputUri_success() {
- mSettings.registerContentObserverForUser(
+ mSettings.registerContentObserverForUserSync(
TEST_SETTING_URI,
mContentObserver,
mUserTracker.userId
@@ -107,7 +107,7 @@
@Test
fun registerContentObserverForUser_inputUri_notifyForDescendants_true() {
- mSettings.registerContentObserverForUser(
+ mSettings.registerContentObserverForUserSync(
TEST_SETTING_URI,
notifyForDescendants = true,
mContentObserver,
@@ -124,14 +124,14 @@
@Test
fun registerContentObserver_inputUri_success() {
- mSettings.registerContentObserver(TEST_SETTING_URI, mContentObserver)
+ mSettings.registerContentObserverSync(TEST_SETTING_URI, mContentObserver)
verify(mSettings.getContentResolver())
.registerContentObserver(eq(TEST_SETTING_URI), eq(false), eq(mContentObserver), eq(0))
}
@Test
fun registerContentObserver_inputUri_notifyForDescendants_true() {
- mSettings.registerContentObserver(
+ mSettings.registerContentObserverSync(
TEST_SETTING_URI,
notifyForDescendants = true,
mContentObserver
diff --git a/packages/SystemUI/tests/src/com/android/systemui/volume/CsdWarningDialogTest.java b/packages/SystemUI/tests/src/com/android/systemui/volume/CsdWarningDialogTest.java
index 741b2e2..c81623e 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/volume/CsdWarningDialogTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/volume/CsdWarningDialogTest.java
@@ -27,9 +27,9 @@
import android.app.Notification;
import android.app.NotificationManager;
import android.media.AudioManager;
-import android.testing.AndroidTestingRunner;
import android.testing.TestableLooper;
+import androidx.test.ext.junit.runners.AndroidJUnit4;
import androidx.test.filters.SmallTest;
import com.android.internal.messages.nano.SystemMessageProto;
@@ -42,7 +42,7 @@
import org.junit.runner.RunWith;
@SmallTest
-@RunWith(AndroidTestingRunner.class)
+@RunWith(AndroidJUnit4.class)
@TestableLooper.RunWithLooper
public class CsdWarningDialogTest extends SysuiTestCase {
diff --git a/packages/SystemUI/tests/src/com/android/systemui/volume/VolumeDialogControllerImplTest.java b/packages/SystemUI/tests/src/com/android/systemui/volume/VolumeDialogControllerImplTest.java
index 69d7586..f737148 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/volume/VolumeDialogControllerImplTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/volume/VolumeDialogControllerImplTest.java
@@ -37,10 +37,10 @@
import android.media.session.MediaSession;
import android.os.Handler;
import android.os.Process;
-import android.testing.AndroidTestingRunner;
import android.testing.TestableLooper;
import android.view.accessibility.AccessibilityManager;
+import androidx.test.ext.junit.runners.AndroidJUnit4;
import androidx.test.filters.SmallTest;
import com.android.systemui.SysuiTestCase;
@@ -65,7 +65,7 @@
import java.util.concurrent.Executor;
-@RunWith(AndroidTestingRunner.class)
+@RunWith(AndroidJUnit4.class)
@SmallTest
@TestableLooper.RunWithLooper
public class VolumeDialogControllerImplTest extends SysuiTestCase {
diff --git a/packages/SystemUI/tests/src/com/android/systemui/volume/VolumeDialogImplTest.java b/packages/SystemUI/tests/src/com/android/systemui/volume/VolumeDialogImplTest.java
index 9864439..05d07e5 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/volume/VolumeDialogImplTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/volume/VolumeDialogImplTest.java
@@ -52,7 +52,6 @@
import android.platform.test.annotations.DisableFlags;
import android.platform.test.annotations.EnableFlags;
import android.provider.Settings;
-import android.testing.AndroidTestingRunner;
import android.testing.TestableLooper;
import android.util.Log;
import android.view.Gravity;
@@ -65,6 +64,7 @@
import android.widget.SeekBar;
import androidx.test.core.view.MotionEventBuilder;
+import androidx.test.ext.junit.runners.AndroidJUnit4;
import androidx.test.filters.SmallTest;
import com.android.internal.jank.InteractionJankMonitor;
@@ -107,7 +107,7 @@
import java.util.function.Predicate;
@SmallTest
-@RunWith(AndroidTestingRunner.class)
+@RunWith(AndroidJUnit4.class)
@TestableLooper.RunWithLooper(setAsMainLooper = true)
public class VolumeDialogImplTest extends SysuiTestCase {
VolumeDialogImpl mDialog;
diff --git a/packages/SystemUI/tests/src/com/android/systemui/wallet/controller/QuickAccessWalletControllerTest.java b/packages/SystemUI/tests/src/com/android/systemui/wallet/controller/QuickAccessWalletControllerTest.java
index dc5597a..40094e5 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/wallet/controller/QuickAccessWalletControllerTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/wallet/controller/QuickAccessWalletControllerTest.java
@@ -33,9 +33,9 @@
import android.content.Intent;
import android.service.quickaccesswallet.GetWalletCardsRequest;
import android.service.quickaccesswallet.QuickAccessWalletClient;
-import android.testing.AndroidTestingRunner;
import android.testing.TestableLooper;
+import androidx.test.ext.junit.runners.AndroidJUnit4;
import androidx.test.filters.SmallTest;
import com.android.systemui.SysuiTestCase;
@@ -57,7 +57,7 @@
import java.util.List;
-@RunWith(AndroidTestingRunner.class)
+@RunWith(AndroidJUnit4.class)
@TestableLooper.RunWithLooper
@SmallTest
public class QuickAccessWalletControllerTest extends SysuiTestCase {
diff --git a/packages/SystemUI/tests/src/com/android/systemui/wallet/controller/WalletContextualLocationsServiceTest.kt b/packages/SystemUI/tests/src/com/android/systemui/wallet/controller/WalletContextualLocationsServiceTest.kt
index d2387e8..6f99cd9 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/wallet/controller/WalletContextualLocationsServiceTest.kt
+++ b/packages/SystemUI/tests/src/com/android/systemui/wallet/controller/WalletContextualLocationsServiceTest.kt
@@ -6,6 +6,7 @@
import android.graphics.drawable.Icon
import android.os.Looper
import android.service.quickaccesswallet.WalletCard
+import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.filters.SmallTest
import com.android.systemui.SysuiTestCase
import com.android.systemui.flags.FakeFeatureFlags
@@ -22,7 +23,6 @@
import org.junit.Before
import org.junit.Test
import org.junit.runner.RunWith
-import org.junit.runners.JUnit4
import org.mockito.Mock
import org.mockito.Mockito.anySet
import org.mockito.Mockito.doNothing
@@ -31,7 +31,7 @@
import org.mockito.Mockito.verify
import org.mockito.MockitoAnnotations
-@RunWith(JUnit4::class)
+@RunWith(AndroidJUnit4::class)
@SmallTest
@kotlinx.coroutines.ExperimentalCoroutinesApi
class WalletContextualLocationsServiceTest : SysuiTestCase() {
diff --git a/packages/SystemUI/tests/src/com/android/systemui/wallet/controller/WalletContextualSuggestionsControllerTest.kt b/packages/SystemUI/tests/src/com/android/systemui/wallet/controller/WalletContextualSuggestionsControllerTest.kt
index d5bdb59..4e44c4a 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/wallet/controller/WalletContextualSuggestionsControllerTest.kt
+++ b/packages/SystemUI/tests/src/com/android/systemui/wallet/controller/WalletContextualSuggestionsControllerTest.kt
@@ -22,6 +22,7 @@
import android.service.quickaccesswallet.GetWalletCardsResponse
import android.service.quickaccesswallet.QuickAccessWalletClient
import android.service.quickaccesswallet.WalletCard
+import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.filters.SmallTest
import com.android.systemui.SysuiTestCase
import com.android.systemui.broadcast.BroadcastDispatcher
@@ -42,7 +43,6 @@
import org.junit.Before
import org.junit.Test
import org.junit.runner.RunWith
-import org.junit.runners.JUnit4
import org.mockito.ArgumentCaptor
import org.mockito.Captor
import org.mockito.Mock
@@ -53,7 +53,7 @@
@OptIn(ExperimentalCoroutinesApi::class)
@SmallTest
-@RunWith(JUnit4::class)
+@RunWith(AndroidJUnit4::class)
class WalletContextualSuggestionsControllerTest : SysuiTestCase() {
@Mock private lateinit var walletController: QuickAccessWalletController
diff --git a/packages/SystemUI/tests/src/com/android/systemui/wallet/ui/WalletScreenControllerTest.java b/packages/SystemUI/tests/src/com/android/systemui/wallet/ui/WalletScreenControllerTest.java
index c1d11aa..38a61fe 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/wallet/ui/WalletScreenControllerTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/wallet/ui/WalletScreenControllerTest.java
@@ -42,9 +42,9 @@
import android.service.quickaccesswallet.QuickAccessWalletClient;
import android.service.quickaccesswallet.QuickAccessWalletService;
import android.service.quickaccesswallet.WalletCard;
-import android.testing.AndroidTestingRunner;
import android.testing.TestableLooper;
+import androidx.test.ext.junit.runners.AndroidJUnit4;
import androidx.test.filters.SmallTest;
import com.android.internal.logging.UiEventLogger;
@@ -68,7 +68,7 @@
import java.util.Collections;
import java.util.List;
-@RunWith(AndroidTestingRunner.class)
+@RunWith(AndroidJUnit4.class)
@TestableLooper.RunWithLooper
@SmallTest
public class WalletScreenControllerTest extends SysuiTestCase {
diff --git a/packages/SystemUI/tests/src/com/android/systemui/wallet/util/WalletCardUtilsTest.kt b/packages/SystemUI/tests/src/com/android/systemui/wallet/util/WalletCardUtilsTest.kt
index e46c1f5..1df781f 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/wallet/util/WalletCardUtilsTest.kt
+++ b/packages/SystemUI/tests/src/com/android/systemui/wallet/util/WalletCardUtilsTest.kt
@@ -17,8 +17,8 @@
package com.android.systemui.wallet.util
import android.service.quickaccesswallet.WalletCard
-import android.testing.AndroidTestingRunner
import android.testing.TestableLooper.RunWithLooper
+import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.filters.SmallTest
import com.android.systemui.SysuiTestCase
import com.android.systemui.util.mockito.mock
@@ -27,7 +27,7 @@
import org.junit.runner.RunWith
/** Test class for WalletCardUtils */
-@RunWith(AndroidTestingRunner::class)
+@RunWith(AndroidJUnit4::class)
@RunWithLooper
@SmallTest
class WalletCardUtilsTest : SysuiTestCase() {
diff --git a/packages/SystemUI/tests/src/com/android/systemui/wallpapers/ImageWallpaperTest.java b/packages/SystemUI/tests/src/com/android/systemui/wallpapers/ImageWallpaperTest.java
index fc2030f..6fb70de 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/wallpapers/ImageWallpaperTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/wallpapers/ImageWallpaperTest.java
@@ -44,13 +44,13 @@
import android.graphics.ColorSpace;
import android.graphics.Rect;
import android.hardware.display.DisplayManager;
-import android.testing.AndroidTestingRunner;
import android.testing.TestableLooper;
import android.view.Surface;
import android.view.SurfaceHolder;
import android.view.WindowManager;
import android.view.WindowMetrics;
+import androidx.test.ext.junit.runners.AndroidJUnit4;
import androidx.test.filters.SmallTest;
import com.android.systemui.SysuiTestCase;
@@ -65,7 +65,7 @@
import org.mockito.MockitoAnnotations;
@SmallTest
-@RunWith(AndroidTestingRunner.class)
+@RunWith(AndroidJUnit4.class)
@TestableLooper.RunWithLooper
public class ImageWallpaperTest extends SysuiTestCase {
private static final int LOW_BMP_WIDTH = 128;
diff --git a/packages/SystemUI/tests/src/com/android/systemui/wallpapers/WallpaperLocalColorExtractorTest.java b/packages/SystemUI/tests/src/com/android/systemui/wallpapers/WallpaperLocalColorExtractorTest.java
index 33d09c1..75e027e 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/wallpapers/WallpaperLocalColorExtractorTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/wallpapers/WallpaperLocalColorExtractorTest.java
@@ -36,9 +36,9 @@
import android.graphics.Rect;
import android.graphics.RectF;
import android.platform.test.annotations.EnableFlags;
-import android.testing.AndroidTestingRunner;
import android.testing.TestableLooper;
+import androidx.test.ext.junit.runners.AndroidJUnit4;
import androidx.test.filters.SmallTest;
import com.android.systemui.SysuiTestCase;
@@ -56,7 +56,7 @@
import java.util.concurrent.Executor;
@SmallTest
-@RunWith(AndroidTestingRunner.class)
+@RunWith(AndroidJUnit4.class)
@TestableLooper.RunWithLooper
public class WallpaperLocalColorExtractorTest extends SysuiTestCase {
private static final int LOW_BMP_WIDTH = 112;
diff --git a/packages/SystemUI/tests/src/com/android/systemui/wmshell/BubbleEducationControllerTest.kt b/packages/SystemUI/tests/src/com/android/systemui/wmshell/BubbleEducationControllerTest.kt
index 7801684..2021f02 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/wmshell/BubbleEducationControllerTest.kt
+++ b/packages/SystemUI/tests/src/com/android/systemui/wmshell/BubbleEducationControllerTest.kt
@@ -21,9 +21,9 @@
import android.content.pm.ShortcutInfo
import android.content.res.Resources
import android.os.UserHandle
-import android.testing.AndroidTestingRunner
import android.testing.TestableLooper
import androidx.core.content.edit
+import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.filters.SmallTest
import com.android.systemui.model.SysUiStateTest
import com.android.wm.shell.bubbles.Bubble
@@ -38,7 +38,7 @@
import org.junit.runner.RunWith
@SmallTest
-@RunWith(AndroidTestingRunner::class)
+@RunWith(AndroidJUnit4::class)
@TestableLooper.RunWithLooper(setAsMainLooper = true)
class BubbleEducationControllerTest : SysUiStateTest() {
diff --git a/packages/SystemUI/tests/utils/src/com/android/systemui/brightness/ui/viewmodel/BrightnessSliderViewModelKosmos.kt b/packages/SystemUI/tests/utils/src/com/android/systemui/brightness/ui/viewmodel/BrightnessSliderViewModelKosmos.kt
new file mode 100644
index 0000000..d208465
--- /dev/null
+++ b/packages/SystemUI/tests/utils/src/com/android/systemui/brightness/ui/viewmodel/BrightnessSliderViewModelKosmos.kt
@@ -0,0 +1,31 @@
+/*
+ * 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.systemui.brightness.ui.viewmodel
+
+import com.android.systemui.brightness.domain.interactor.brightnessPolicyEnforcementInteractor
+import com.android.systemui.brightness.domain.interactor.screenBrightnessInteractor
+import com.android.systemui.kosmos.Kosmos
+import com.android.systemui.kosmos.applicationCoroutineScope
+
+val Kosmos.brightnessSliderViewModel: BrightnessSliderViewModel by
+ Kosmos.Fixture {
+ BrightnessSliderViewModel(
+ screenBrightnessInteractor = screenBrightnessInteractor,
+ brightnessPolicyEnforcementInteractor = brightnessPolicyEnforcementInteractor,
+ applicationScope = applicationCoroutineScope,
+ )
+ }
diff --git a/packages/SystemUI/tests/utils/src/com/android/systemui/communal/domain/interactor/CommunalSettingsInteractorKosmos.kt b/packages/SystemUI/tests/utils/src/com/android/systemui/communal/domain/interactor/CommunalSettingsInteractorKosmos.kt
index cd2710e..fb983f7 100644
--- a/packages/SystemUI/tests/utils/src/com/android/systemui/communal/domain/interactor/CommunalSettingsInteractorKosmos.kt
+++ b/packages/SystemUI/tests/utils/src/com/android/systemui/communal/domain/interactor/CommunalSettingsInteractorKosmos.kt
@@ -21,6 +21,7 @@
import com.android.systemui.kosmos.Kosmos
import com.android.systemui.kosmos.Kosmos.Fixture
import com.android.systemui.kosmos.applicationCoroutineScope
+import com.android.systemui.kosmos.testDispatcher
import com.android.systemui.settings.userTracker
import com.android.systemui.user.domain.interactor.selectedUserInteractor
import com.android.systemui.util.mockito.mock
@@ -29,6 +30,7 @@
CommunalSettingsInteractor(
bgScope = applicationCoroutineScope,
bgExecutor = fakeExecutor,
+ bgDispatcher = testDispatcher,
repository = communalSettingsRepository,
userInteractor = selectedUserInteractor,
userTracker = userTracker,
diff --git a/packages/SystemUI/tests/utils/src/com/android/systemui/keyguard/data/repository/FakeKeyguardRepository.kt b/packages/SystemUI/tests/utils/src/com/android/systemui/keyguard/data/repository/FakeKeyguardRepository.kt
index 1a45c42..22b8c8db 100644
--- a/packages/SystemUI/tests/utils/src/com/android/systemui/keyguard/data/repository/FakeKeyguardRepository.kt
+++ b/packages/SystemUI/tests/utils/src/com/android/systemui/keyguard/data/repository/FakeKeyguardRepository.kt
@@ -104,7 +104,8 @@
private val _biometricUnlockState =
MutableStateFlow(BiometricUnlockModel(BiometricUnlockMode.NONE, null))
- override val biometricUnlockState: Flow<BiometricUnlockModel> = _biometricUnlockState
+ override val biometricUnlockState: StateFlow<BiometricUnlockModel> =
+ _biometricUnlockState.asStateFlow()
private val _fingerprintSensorLocation = MutableStateFlow<Point?>(null)
override val fingerprintSensorLocation: Flow<Point?> = _fingerprintSensorLocation
diff --git a/packages/SystemUI/tests/utils/src/com/android/systemui/keyguard/data/repository/FakeKeyguardTransitionRepository.kt b/packages/SystemUI/tests/utils/src/com/android/systemui/keyguard/data/repository/FakeKeyguardTransitionRepository.kt
index 2fe7438..b5ea619 100644
--- a/packages/SystemUI/tests/utils/src/com/android/systemui/keyguard/data/repository/FakeKeyguardTransitionRepository.kt
+++ b/packages/SystemUI/tests/utils/src/com/android/systemui/keyguard/data/repository/FakeKeyguardTransitionRepository.kt
@@ -54,6 +54,7 @@
private val _transitions =
MutableSharedFlow<TransitionStep>(replay = 3, onBufferOverflow = BufferOverflow.DROP_OLDEST)
override val transitions: SharedFlow<TransitionStep> = _transitions
+
@Inject constructor() : this(initInLockscreen = true)
private val _currentTransitionInfo: MutableStateFlow<TransitionInfo> =
@@ -137,6 +138,17 @@
)
)
testScheduler.runCurrent()
+
+ sendTransitionStep(
+ step =
+ TransitionStep(
+ transitionState = TransitionState.RUNNING,
+ from = from,
+ to = to,
+ value = 1f
+ )
+ )
+ testScheduler.runCurrent()
}
if (throughTransitionState == TransitionState.FINISHED) {
diff --git a/packages/SystemUI/tests/utils/src/com/android/systemui/keyguard/domain/interactor/BiometricUnlockInteractorKosmos.kt b/packages/SystemUI/tests/utils/src/com/android/systemui/keyguard/domain/interactor/BiometricUnlockInteractorKosmos.kt
new file mode 100644
index 0000000..7a3f925
--- /dev/null
+++ b/packages/SystemUI/tests/utils/src/com/android/systemui/keyguard/domain/interactor/BiometricUnlockInteractorKosmos.kt
@@ -0,0 +1,27 @@
+/*
+ * 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.systemui.keyguard.domain.interactor
+
+import com.android.systemui.keyguard.data.repository.keyguardRepository
+import com.android.systemui.kosmos.Kosmos
+import com.android.systemui.kosmos.Kosmos.Fixture
+
+val Kosmos.biometricUnlockInteractor by Fixture {
+ BiometricUnlockInteractor(
+ keyguardRepository = keyguardRepository,
+ )
+}
diff --git a/packages/SystemUI/tests/utils/src/com/android/systemui/kosmos/KosmosJavaAdapter.kt b/packages/SystemUI/tests/utils/src/com/android/systemui/kosmos/KosmosJavaAdapter.kt
index 0b28e3f..6d2d04a 100644
--- a/packages/SystemUI/tests/utils/src/com/android/systemui/kosmos/KosmosJavaAdapter.kt
+++ b/packages/SystemUI/tests/utils/src/com/android/systemui/kosmos/KosmosJavaAdapter.kt
@@ -50,6 +50,7 @@
import com.android.systemui.power.data.repository.fakePowerRepository
import com.android.systemui.power.domain.interactor.powerInteractor
import com.android.systemui.scene.domain.interactor.sceneInteractor
+import com.android.systemui.scene.domain.startable.scrimStartable
import com.android.systemui.scene.sceneContainerConfig
import com.android.systemui.scene.shared.model.sceneDataSource
import com.android.systemui.settings.brightness.domain.interactor.brightnessMirrorShowingInteractor
@@ -59,6 +60,7 @@
import com.android.systemui.statusbar.chips.ui.viewmodel.ongoingActivityChipsViewModel
import com.android.systemui.statusbar.notification.stack.domain.interactor.headsUpNotificationInteractor
import com.android.systemui.statusbar.notification.stack.domain.interactor.sharedNotificationContainerInteractor
+import com.android.systemui.statusbar.phone.scrimController
import com.android.systemui.statusbar.pipeline.mobile.data.repository.fakeMobileConnectionsRepository
import com.android.systemui.statusbar.policy.data.repository.fakeDeviceProvisioningRepository
import com.android.systemui.statusbar.policy.domain.interactor.deviceProvisioningInteractor
@@ -130,4 +132,6 @@
val shadeInteractor by lazy { kosmos.shadeInteractor }
val ongoingActivityChipsViewModel by lazy { kosmos.ongoingActivityChipsViewModel }
+ val scrimController by lazy { kosmos.scrimController }
+ val scrimStartable by lazy { kosmos.scrimStartable }
}
diff --git a/packages/SystemUI/tests/utils/src/com/android/systemui/scene/domain/startable/ScrimStartableKosmos.kt b/packages/SystemUI/tests/utils/src/com/android/systemui/scene/domain/startable/ScrimStartableKosmos.kt
new file mode 100644
index 0000000..b64c840
--- /dev/null
+++ b/packages/SystemUI/tests/utils/src/com/android/systemui/scene/domain/startable/ScrimStartableKosmos.kt
@@ -0,0 +1,50 @@
+/*
+ * 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.
+ */
+
+@file:OptIn(ExperimentalCoroutinesApi::class)
+
+package com.android.systemui.scene.domain.startable
+
+import com.android.systemui.bouncer.domain.interactor.alternateBouncerInteractor
+import com.android.systemui.deviceentry.domain.interactor.deviceEntryInteractor
+import com.android.systemui.keyguard.domain.interactor.biometricUnlockInteractor
+import com.android.systemui.keyguard.domain.interactor.keyguardInteractor
+import com.android.systemui.kosmos.Kosmos
+import com.android.systemui.kosmos.Kosmos.Fixture
+import com.android.systemui.kosmos.applicationCoroutineScope
+import com.android.systemui.scene.domain.interactor.sceneContainerOcclusionInteractor
+import com.android.systemui.scene.domain.interactor.sceneInteractor
+import com.android.systemui.settings.brightness.domain.interactor.brightnessMirrorShowingInteractor
+import com.android.systemui.statusbar.phone.dozeServiceHost
+import com.android.systemui.statusbar.phone.scrimController
+import com.android.systemui.statusbar.phone.statusBarKeyguardViewManager
+import kotlinx.coroutines.ExperimentalCoroutinesApi
+
+val Kosmos.scrimStartable by Fixture {
+ ScrimStartable(
+ applicationScope = applicationCoroutineScope,
+ scrimController = scrimController,
+ sceneInteractor = sceneInteractor,
+ deviceEntryInteractor = deviceEntryInteractor,
+ keyguardInteractor = keyguardInteractor,
+ occlusionInteractor = sceneContainerOcclusionInteractor,
+ biometricUnlockInteractor = biometricUnlockInteractor,
+ statusBarKeyguardViewManager = statusBarKeyguardViewManager,
+ alternateBouncerInteractor = alternateBouncerInteractor,
+ brightnessMirrorShowingInteractor = brightnessMirrorShowingInteractor,
+ dozeServiceHost = dozeServiceHost,
+ )
+}
diff --git a/packages/SystemUI/tests/utils/src/com/android/systemui/shade/ui/viewmodel/QuickSettingsShadeSceneViewModelKosmos.kt b/packages/SystemUI/tests/utils/src/com/android/systemui/shade/ui/viewmodel/QuickSettingsShadeSceneViewModelKosmos.kt
index 8c5ff1d..c5625e4 100644
--- a/packages/SystemUI/tests/utils/src/com/android/systemui/shade/ui/viewmodel/QuickSettingsShadeSceneViewModelKosmos.kt
+++ b/packages/SystemUI/tests/utils/src/com/android/systemui/shade/ui/viewmodel/QuickSettingsShadeSceneViewModelKosmos.kt
@@ -16,8 +16,12 @@
package com.android.systemui.shade.ui.viewmodel
+import com.android.systemui.brightness.ui.viewmodel.brightnessSliderViewModel
import com.android.systemui.kosmos.Kosmos
import com.android.systemui.kosmos.applicationCoroutineScope
+import com.android.systemui.qs.panels.ui.viewmodel.editModeViewModel
+import com.android.systemui.qs.panels.ui.viewmodel.tileGridViewModel
+import com.android.systemui.qs.ui.adapter.qsSceneAdapter
import com.android.systemui.qs.ui.viewmodel.QuickSettingsShadeSceneViewModel
val Kosmos.quickSettingsShadeSceneViewModel: QuickSettingsShadeSceneViewModel by
@@ -25,5 +29,9 @@
QuickSettingsShadeSceneViewModel(
applicationScope = applicationCoroutineScope,
overlayShadeViewModel = overlayShadeViewModel,
+ brightnessSliderViewModel = brightnessSliderViewModel,
+ tileGridViewModel = tileGridViewModel,
+ editModeViewModel = editModeViewModel,
+ qsSceneAdapter = qsSceneAdapter,
)
}
diff --git a/packages/SystemUI/tests/utils/src/com/android/systemui/util/settings/FakeGlobalSettings.java b/packages/SystemUI/tests/utils/src/com/android/systemui/util/settings/FakeGlobalSettings.java
index beabaf5..3a70cdf 100644
--- a/packages/SystemUI/tests/utils/src/com/android/systemui/util/settings/FakeGlobalSettings.java
+++ b/packages/SystemUI/tests/utils/src/com/android/systemui/util/settings/FakeGlobalSettings.java
@@ -44,7 +44,7 @@
}
@Override
- public void registerContentObserver(Uri uri, boolean notifyDescendants,
+ public void registerContentObserverSync(Uri uri, boolean notifyDescendants,
ContentObserver settingsObserver) {
List<ContentObserver> observers;
mContentObserversAllUsers.putIfAbsent(uri.toString(), new ArrayList<>());
@@ -53,7 +53,7 @@
}
@Override
- public void unregisterContentObserver(ContentObserver settingsObserver) {
+ public void unregisterContentObserverSync(ContentObserver settingsObserver) {
for (Map.Entry<String, List<ContentObserver>> entry :
mContentObserversAllUsers.entrySet()) {
entry.getValue().remove(settingsObserver);
diff --git a/packages/SystemUI/tests/utils/src/com/android/systemui/util/settings/FakeSettings.java b/packages/SystemUI/tests/utils/src/com/android/systemui/util/settings/FakeSettings.java
index a491886..cd219ec 100644
--- a/packages/SystemUI/tests/utils/src/com/android/systemui/util/settings/FakeSettings.java
+++ b/packages/SystemUI/tests/utils/src/com/android/systemui/util/settings/FakeSettings.java
@@ -66,7 +66,7 @@
}
@Override
- public void registerContentObserverForUser(Uri uri, boolean notifyDescendants,
+ public void registerContentObserverForUserSync(Uri uri, boolean notifyDescendants,
ContentObserver settingsObserver, int userHandle) {
List<ContentObserver> observers;
if (userHandle == UserHandle.USER_ALL) {
@@ -81,7 +81,7 @@
}
@Override
- public void unregisterContentObserver(ContentObserver settingsObserver) {
+ public void unregisterContentObserverSync(ContentObserver settingsObserver) {
for (SettingsKey key : mContentObservers.keySet()) {
List<ContentObserver> observers = mContentObservers.get(key);
observers.remove(settingsObserver);
diff --git a/packages/SystemUI/tests/utils/src/com/android/systemui/volume/domain/interactor/AudioOutputInteractorKosmos.kt b/packages/SystemUI/tests/utils/src/com/android/systemui/volume/domain/interactor/AudioOutputInteractorKosmos.kt
index 3f51a79..e2d414e 100644
--- a/packages/SystemUI/tests/utils/src/com/android/systemui/volume/domain/interactor/AudioOutputInteractorKosmos.kt
+++ b/packages/SystemUI/tests/utils/src/com/android/systemui/volume/domain/interactor/AudioOutputInteractorKosmos.kt
@@ -16,6 +16,7 @@
package com.android.systemui.volume.domain.interactor
+import android.content.applicationContext
import com.android.systemui.bluetooth.bluetoothAdapter
import com.android.systemui.bluetooth.localBluetoothManager
import com.android.systemui.kosmos.Kosmos
@@ -27,6 +28,7 @@
val Kosmos.audioOutputInteractor by
Kosmos.Fixture {
AudioOutputInteractor(
+ applicationContext,
audioRepository,
audioModeInteractor,
testScope.backgroundScope,
diff --git a/packages/SystemUI/tests/utils/src/com/android/systemui/volume/panel/component/mediaoutput/domain/interactor/MediaOutputComponentInteractorKosmos.kt b/packages/SystemUI/tests/utils/src/com/android/systemui/volume/panel/component/mediaoutput/domain/interactor/MediaOutputComponentInteractorKosmos.kt
new file mode 100644
index 0000000..9f11822
--- /dev/null
+++ b/packages/SystemUI/tests/utils/src/com/android/systemui/volume/panel/component/mediaoutput/domain/interactor/MediaOutputComponentInteractorKosmos.kt
@@ -0,0 +1,35 @@
+/*
+ * 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.systemui.volume.panel.component.mediaoutput.domain.interactor
+
+import com.android.systemui.kosmos.Kosmos
+import com.android.systemui.kosmos.testScope
+import com.android.systemui.volume.domain.interactor.audioModeInteractor
+import com.android.systemui.volume.domain.interactor.audioOutputInteractor
+import com.android.systemui.volume.mediaDeviceSessionInteractor
+import com.android.systemui.volume.mediaOutputInteractor
+
+val Kosmos.mediaOutputComponentInteractor by
+ Kosmos.Fixture {
+ MediaOutputComponentInteractor(
+ testScope.backgroundScope,
+ mediaDeviceSessionInteractor,
+ audioOutputInteractor,
+ audioModeInteractor,
+ mediaOutputInteractor,
+ )
+ }
diff --git a/packages/SystemUI/tests/utils/src/com/android/systemui/volume/panel/component/mediaoutput/ui/viewmodel/MediaOutputViewModelKosmos.kt b/packages/SystemUI/tests/utils/src/com/android/systemui/volume/panel/component/mediaoutput/ui/viewmodel/MediaOutputViewModelKosmos.kt
index 6d4576e..2cd6ff2 100644
--- a/packages/SystemUI/tests/utils/src/com/android/systemui/volume/panel/component/mediaoutput/ui/viewmodel/MediaOutputViewModelKosmos.kt
+++ b/packages/SystemUI/tests/utils/src/com/android/systemui/volume/panel/component/mediaoutput/ui/viewmodel/MediaOutputViewModelKosmos.kt
@@ -20,11 +20,8 @@
import com.android.internal.logging.uiEventLogger
import com.android.systemui.kosmos.Kosmos
import com.android.systemui.kosmos.testScope
-import com.android.systemui.volume.domain.interactor.audioModeInteractor
-import com.android.systemui.volume.domain.interactor.audioOutputInteractor
-import com.android.systemui.volume.mediaDeviceSessionInteractor
import com.android.systemui.volume.mediaOutputActionsInteractor
-import com.android.systemui.volume.mediaOutputInteractor
+import com.android.systemui.volume.panel.component.mediaoutput.domain.interactor.mediaOutputComponentInteractor
var Kosmos.mediaOutputViewModel by
Kosmos.Fixture {
@@ -32,10 +29,7 @@
applicationContext,
testScope.backgroundScope,
mediaOutputActionsInteractor,
- mediaDeviceSessionInteractor,
- audioOutputInteractor,
- audioModeInteractor,
- mediaOutputInteractor,
+ mediaOutputComponentInteractor,
uiEventLogger,
)
}
diff --git a/services/companion/java/com/android/server/companion/CompanionDeviceManagerService.java b/services/companion/java/com/android/server/companion/CompanionDeviceManagerService.java
index 30e4a3e..0d0c21d 100644
--- a/services/companion/java/com/android/server/companion/CompanionDeviceManagerService.java
+++ b/services/companion/java/com/android/server/companion/CompanionDeviceManagerService.java
@@ -34,7 +34,6 @@
import static com.android.server.companion.utils.PackageUtils.enforceUsesCompanionDeviceFeature;
import static com.android.server.companion.utils.PackageUtils.getPackageInfo;
import static com.android.server.companion.utils.PackageUtils.isRestrictedSettingsAllowed;
-import static com.android.server.companion.utils.PermissionsUtils.checkCallerCanManageCompanionDevice;
import static com.android.server.companion.utils.PermissionsUtils.enforceCallerCanManageAssociationsForPackage;
import static com.android.server.companion.utils.PermissionsUtils.enforceCallerIsSystemOr;
import static com.android.server.companion.utils.PermissionsUtils.enforceCallerIsSystemOrCanInteractWithUserId;
@@ -335,12 +334,6 @@
enforceCallerCanManageAssociationsForPackage(getContext(), userId, packageName,
"get associations");
- if (!checkCallerCanManageCompanionDevice(getContext())) {
- // If the caller neither is system nor holds MANAGE_COMPANION_DEVICES: it needs to
- // request the feature (also: the caller is the app itself).
- enforceUsesCompanionDeviceFeature(getContext(), userId, packageName);
- }
-
return mAssociationStore.getActiveAssociationsByPackage(userId, packageName);
}
diff --git a/services/companion/java/com/android/server/companion/association/AssociationRequestsProcessor.java b/services/companion/java/com/android/server/companion/association/AssociationRequestsProcessor.java
index d09d7e6..3fbd856 100644
--- a/services/companion/java/com/android/server/companion/association/AssociationRequestsProcessor.java
+++ b/services/companion/java/com/android/server/companion/association/AssociationRequestsProcessor.java
@@ -347,6 +347,8 @@
* Set association tag.
*/
public void setAssociationTag(int associationId, String tag) {
+ Slog.i(TAG, "Setting association tag=[" + tag + "] to id=[" + associationId + "]...");
+
AssociationInfo association = mAssociationStore.getAssociationWithCallerChecks(
associationId);
association = (new AssociationInfo.Builder(association)).setTag(tag).build();
diff --git a/services/companion/java/com/android/server/companion/association/AssociationStore.java b/services/companion/java/com/android/server/companion/association/AssociationStore.java
index 29e8095..757abd9 100644
--- a/services/companion/java/com/android/server/companion/association/AssociationStore.java
+++ b/services/companion/java/com/android/server/companion/association/AssociationStore.java
@@ -18,7 +18,7 @@
import static com.android.server.companion.utils.MetricUtils.logCreateAssociation;
import static com.android.server.companion.utils.MetricUtils.logRemoveAssociation;
-import static com.android.server.companion.utils.PermissionsUtils.checkCallerCanManageAssociationsForPackage;
+import static com.android.server.companion.utils.PermissionsUtils.enforceCallerCanManageAssociationsForPackage;
import android.annotation.IntDef;
import android.annotation.NonNull;
@@ -457,6 +457,10 @@
/**
* Get association by id with caller checks.
+ *
+ * If the association is not found, an IllegalArgumentException would be thrown.
+ *
+ * If the caller can't access the association, a SecurityException would be thrown.
*/
@NonNull
public AssociationInfo getAssociationWithCallerChecks(int associationId) {
@@ -466,13 +470,9 @@
"getAssociationWithCallerChecks() Association id=[" + associationId
+ "] doesn't exist.");
}
- if (checkCallerCanManageAssociationsForPackage(mContext, association.getUserId(),
- association.getPackageName())) {
- return association;
- }
-
- throw new IllegalArgumentException(
- "The caller can't interact with the association id=[" + associationId + "].");
+ enforceCallerCanManageAssociationsForPackage(mContext, association.getUserId(),
+ association.getPackageName(), null);
+ return association;
}
/**
diff --git a/services/companion/java/com/android/server/companion/association/DisassociationProcessor.java b/services/companion/java/com/android/server/companion/association/DisassociationProcessor.java
index 8c1116b..6f0baef 100644
--- a/services/companion/java/com/android/server/companion/association/DisassociationProcessor.java
+++ b/services/companion/java/com/android/server/companion/association/DisassociationProcessor.java
@@ -98,7 +98,6 @@
Slog.i(TAG, "Disassociating id=[" + id + "]...");
final AssociationInfo association = mAssociationStore.getAssociationWithCallerChecks(id);
-
final int userId = association.getUserId();
final String packageName = association.getPackageName();
final String deviceProfile = association.getDeviceProfile();
diff --git a/services/companion/java/com/android/server/companion/datatransfer/SystemDataTransferProcessor.java b/services/companion/java/com/android/server/companion/datatransfer/SystemDataTransferProcessor.java
index 026d29c..00e049c 100644
--- a/services/companion/java/com/android/server/companion/datatransfer/SystemDataTransferProcessor.java
+++ b/services/companion/java/com/android/server/companion/datatransfer/SystemDataTransferProcessor.java
@@ -122,7 +122,6 @@
*/
public boolean isPermissionTransferUserConsented(int associationId) {
mAssociationStore.getAssociationWithCallerChecks(associationId);
-
PermissionSyncRequest request = getPermissionSyncRequest(associationId);
if (request == null) {
return false;
@@ -147,12 +146,12 @@
return null;
}
- final AssociationInfo association = mAssociationStore.getAssociationWithCallerChecks(
- associationId);
-
Slog.i(LOG_TAG, "Creating permission sync intent for userId [" + userId
+ "] associationId [" + associationId + "]");
+ final AssociationInfo association = mAssociationStore.getAssociationWithCallerChecks(
+ associationId);
+
// Create an internal intent to launch the user consent dialog
final Bundle extras = new Bundle();
PermissionSyncRequest request = new PermissionSyncRequest(associationId);
@@ -220,7 +219,9 @@
* Enable perm sync for the association
*/
public void enablePermissionsSync(int associationId) {
- int userId = mAssociationStore.getAssociationWithCallerChecks(associationId).getUserId();
+ AssociationInfo association = mAssociationStore.getAssociationWithCallerChecks(
+ associationId);
+ int userId = association.getUserId();
PermissionSyncRequest request = new PermissionSyncRequest(associationId);
request.setUserConsented(true);
mSystemDataTransferRequestStore.writeRequest(userId, request);
@@ -230,7 +231,9 @@
* Disable perm sync for the association
*/
public void disablePermissionsSync(int associationId) {
- int userId = mAssociationStore.getAssociationWithCallerChecks(associationId).getUserId();
+ AssociationInfo association = mAssociationStore.getAssociationWithCallerChecks(
+ associationId);
+ int userId = association.getUserId();
PermissionSyncRequest request = new PermissionSyncRequest(associationId);
request.setUserConsented(false);
mSystemDataTransferRequestStore.writeRequest(userId, request);
@@ -241,8 +244,9 @@
*/
@Nullable
public PermissionSyncRequest getPermissionSyncRequest(int associationId) {
- int userId = mAssociationStore.getAssociationWithCallerChecks(associationId)
- .getUserId();
+ AssociationInfo association = mAssociationStore.getAssociationWithCallerChecks(
+ associationId);
+ int userId = association.getUserId();
List<SystemDataTransferRequest> requests =
mSystemDataTransferRequestStore.readRequestsByAssociationId(userId,
associationId);
@@ -259,7 +263,9 @@
*/
public void removePermissionSyncRequest(int associationId) {
Binder.withCleanCallingIdentity(() -> {
- int userId = mAssociationStore.getAssociationById(associationId).getUserId();
+ AssociationInfo association = mAssociationStore.getAssociationWithCallerChecks(
+ associationId);
+ int userId = association.getUserId();
mSystemDataTransferRequestStore.removeRequestsByAssociationId(userId, associationId);
});
}
diff --git a/services/companion/java/com/android/server/companion/utils/PermissionsUtils.java b/services/companion/java/com/android/server/companion/utils/PermissionsUtils.java
index f397814..796d285 100644
--- a/services/companion/java/com/android/server/companion/utils/PermissionsUtils.java
+++ b/services/companion/java/com/android/server/companion/utils/PermissionsUtils.java
@@ -149,21 +149,6 @@
}
/**
- * Check if the caller is system UID or the provided user.
- */
- public static boolean checkCallerIsSystemOr(@UserIdInt int userId,
- @NonNull String packageName) {
- final int callingUid = getCallingUid();
- if (callingUid == SYSTEM_UID) return true;
-
- if (getCallingUserId() != userId) return false;
-
- if (!checkPackage(callingUid, packageName)) return false;
-
- return true;
- }
-
- /**
* Check if the calling user id matches the userId, and if the package belongs to
* the calling uid.
*/
@@ -184,21 +169,30 @@
}
/**
- * Check if the caller holds the necessary permission to manage companion devices.
- */
- public static boolean checkCallerCanManageCompanionDevice(@NonNull Context context) {
- if (getCallingUid() == SYSTEM_UID) return true;
-
- return context.checkCallingPermission(MANAGE_COMPANION_DEVICES) == PERMISSION_GRANTED;
- }
-
- /**
* Require the caller to be able to manage the associations for the package.
*/
public static void enforceCallerCanManageAssociationsForPackage(@NonNull Context context,
@UserIdInt int userId, @NonNull String packageName,
@Nullable String actionDescription) {
- if (checkCallerCanManageAssociationsForPackage(context, userId, packageName)) return;
+ final int callingUid = getCallingUid();
+
+ // If the caller is the system
+ if (callingUid == SYSTEM_UID) {
+ return;
+ }
+
+ // If caller can manage the package or has the permissions to manage companion devices
+ boolean canInteractAcrossUsers = context.checkCallingPermission(INTERACT_ACROSS_USERS)
+ == PERMISSION_GRANTED;
+ boolean canManageCompanionDevices = context.checkCallingPermission(MANAGE_COMPANION_DEVICES)
+ == PERMISSION_GRANTED;
+ if (getCallingUserId() == userId) {
+ if (checkPackage(callingUid, packageName) || canManageCompanionDevices) {
+ return;
+ }
+ } else if (canInteractAcrossUsers && canManageCompanionDevices) {
+ return;
+ }
throw new SecurityException("Caller (uid=" + getCallingUid() + ") does not have "
+ "permissions to "
@@ -219,25 +213,6 @@
}
}
- /**
- * Check if the caller is either:
- * <ul>
- * <li> the package itself
- * <li> the System ({@link android.os.Process#SYSTEM_UID})
- * <li> holds {@link Manifest.permission#MANAGE_COMPANION_DEVICES} and, if belongs to a
- * different user, also holds {@link Manifest.permission#INTERACT_ACROSS_USERS}.
- * </ul>
- * @return whether the caller is one of the above.
- */
- public static boolean checkCallerCanManageAssociationsForPackage(@NonNull Context context,
- @UserIdInt int userId, @NonNull String packageName) {
- if (checkCallerIsSystemOr(userId, packageName)) return true;
-
- if (!checkCallerCanInteractWithUserId(context, userId)) return false;
-
- return checkCallerCanManageCompanionDevice(context);
- }
-
private static boolean checkPackage(@UserIdInt int uid, @NonNull String packageName) {
try {
return getAppOpsService().checkPackage(uid, packageName) == MODE_ALLOWED;
diff --git a/services/core/java/com/android/server/am/ActiveServices.java b/services/core/java/com/android/server/am/ActiveServices.java
index 9be0e1f..51da7f17 100644
--- a/services/core/java/com/android/server/am/ActiveServices.java
+++ b/services/core/java/com/android/server/am/ActiveServices.java
@@ -499,8 +499,6 @@
private final ServiceAnrTimer mShortFGSAnrTimer;
// ActivityManagerConstants.DEFAULT_SERVICE_START_FOREGROUND_TIMEOUT_MS
private final ServiceAnrTimer mServiceFGAnrTimer;
- // see ServiceRecord#getEarliestStopTypeAndTime()
- private final ServiceAnrTimer mFGSAnrTimer;
/**
* Mapping of uid to {fgs_type, fgs_info} for time limited fgs types such as dataSync and
@@ -784,9 +782,6 @@
this.mServiceFGAnrTimer = new ServiceAnrTimer(service,
ActivityManagerService.SERVICE_FOREGROUND_TIMEOUT_MSG,
"SERVICE_FOREGROUND_TIMEOUT");
- this.mFGSAnrTimer = new ServiceAnrTimer(service,
- ActivityManagerService.SERVICE_FGS_CRASH_TIMEOUT_MSG,
- "FGS_TIMEOUT");
}
void systemServicesReady() {
@@ -3811,8 +3806,9 @@
if (!sr.isFgsTimeLimited()) {
// Reset timers since new type does not have a timeout.
- mFGSAnrTimer.cancel(sr);
mAm.mHandler.removeMessages(ActivityManagerService.SERVICE_FGS_TIMEOUT_MSG, sr);
+ mAm.mHandler.removeMessages(
+ ActivityManagerService.SERVICE_FGS_CRASH_TIMEOUT_MSG, sr);
return;
}
}
@@ -3834,9 +3830,9 @@
}
fgsTypeInfo.noteFgsFgsStart(nowUptime);
- // We'll cancel the previous ANR timer and start a fresh one below.
- mFGSAnrTimer.cancel(sr);
+ // We'll cancel the timeout and crash messages and post a fresh one below.
mAm.mHandler.removeMessages(ActivityManagerService.SERVICE_FGS_TIMEOUT_MSG, sr);
+ mAm.mHandler.removeMessages(ActivityManagerService.SERVICE_FGS_CRASH_TIMEOUT_MSG, sr);
final Message msg = mAm.mHandler.obtainMessage(
ActivityManagerService.SERVICE_FGS_TIMEOUT_MSG, sr);
@@ -3864,8 +3860,8 @@
fgsTypeInfo.decNumParallelServices();
}
Slog.d(TAG_SERVICE, "Stop FGS timeout: " + sr);
- mFGSAnrTimer.cancel(sr);
mAm.mHandler.removeMessages(ActivityManagerService.SERVICE_FGS_TIMEOUT_MSG, sr);
+ mAm.mHandler.removeMessages(ActivityManagerService.SERVICE_FGS_CRASH_TIMEOUT_MSG, sr);
}
void onUidRemovedLocked(int uid) {
@@ -3892,7 +3888,8 @@
synchronized (mAm) {
final int fgsType = getTimeLimitedFgsType(sr.foregroundServiceType);
if (fgsType == ServiceInfo.FOREGROUND_SERVICE_TYPE_NONE || sr.app == null) {
- mFGSAnrTimer.discard(sr);
+ mAm.mHandler.removeMessages(
+ ActivityManagerService.SERVICE_FGS_CRASH_TIMEOUT_MSG, sr);
return;
}
@@ -3901,8 +3898,9 @@
final long nowUptime = SystemClock.uptimeMillis();
if (lastTopTime != Long.MIN_VALUE && constantTimeLimit > (nowUptime - lastTopTime)) {
// Discard any other messages for this service
- mFGSAnrTimer.discard(sr);
mAm.mHandler.removeMessages(ActivityManagerService.SERVICE_FGS_TIMEOUT_MSG, sr);
+ mAm.mHandler.removeMessages(
+ ActivityManagerService.SERVICE_FGS_CRASH_TIMEOUT_MSG, sr);
// The app was in the TOP state after the FGS was started so its time allowance
// should be counted from that time since this is considered a user interaction
final Message msg = mAm.mHandler.obtainMessage(
@@ -3913,7 +3911,6 @@
Slog.e(TAG_SERVICE, "FGS (" + ServiceInfo.foregroundServiceTypeToLabel(fgsType)
+ ") timed out: " + sr);
- mFGSAnrTimer.accept(sr);
traceInstant("FGS timed out: ", sr);
final TimeLimitedFgsInfo fgsTypeInfo = getFgsTimeLimitedInfo(sr.appInfo.uid, fgsType);
@@ -3940,7 +3937,9 @@
}
// Crash the service after giving the service some time to clean up.
- mFGSAnrTimer.start(sr, mAm.mConstants.mFgsCrashExtraWaitDuration);
+ final Message msg = mAm.mHandler.obtainMessage(
+ ActivityManagerService.SERVICE_FGS_CRASH_TIMEOUT_MSG, sr);
+ mAm.mHandler.sendMessageDelayed(msg, mAm.mConstants.mFgsCrashExtraWaitDuration);
}
}
@@ -3963,8 +3962,9 @@
+ ServiceInfo.foregroundServiceTypeToLabel(fgsType)
+ " did not stop within its timeout: " + sr.getComponentName();
- if (android.app.Flags.gateFgsTimeoutAnrBehavior()) {
- // Log a WTF instead of throwing an ANR while the new behavior is gated.
+ if (android.app.Flags.gateFgsTimeoutAnrBehavior()
+ || !android.app.Flags.enableFgsTimeoutCrashBehavior()) {
+ // Log a WTF instead of crashing the app while the new behavior is gated.
Slog.wtf(TAG, reason);
return;
}
@@ -3981,23 +3981,6 @@
.createExtrasForService(sr.getComponentName()));
}
}
- } else {
- // ANR the app if the new crash behavior is not enabled
- final TimeoutRecord tr = TimeoutRecord.forFgsTimeout(reason);
- tr.mLatencyTracker.waitingOnAMSLockStarted();
- synchronized (mAm) {
- tr.mLatencyTracker.waitingOnAMSLockEnded();
-
- Slog.e(TAG_SERVICE, "FGS ANR'ed: " + sr);
- traceInstant("FGS ANR: ", sr);
- if (sr.app != null) {
- mAm.appNotResponding(sr.app, tr);
- }
-
- // TODO: Can we close the ANR dialog here, if it's still shown? Currently, the ANR
- // dialog really doesn't remember the "cause" (especially if there have been
- // multiple ANRs), so it's not doable.
- }
}
}
diff --git a/services/core/java/com/android/server/audio/BtHelper.java b/services/core/java/com/android/server/audio/BtHelper.java
index 6bb3eb1..991f94b 100644
--- a/services/core/java/com/android/server/audio/BtHelper.java
+++ b/services/core/java/com/android/server/audio/BtHelper.java
@@ -15,11 +15,7 @@
*/
package com.android.server.audio;
-import static android.bluetooth.BluetoothDevice.DEVICE_TYPE_CARKIT;
import static android.bluetooth.BluetoothDevice.DEVICE_TYPE_DEFAULT;
-import static android.bluetooth.BluetoothDevice.DEVICE_TYPE_HEADSET;
-import static android.bluetooth.BluetoothDevice.DEVICE_TYPE_HEARING_AID;
-import static android.bluetooth.BluetoothDevice.DEVICE_TYPE_SPEAKER;
import static android.bluetooth.BluetoothDevice.DEVICE_TYPE_UNTETHERED_HEADSET;
import static android.bluetooth.BluetoothDevice.DEVICE_TYPE_WATCH;
import static android.media.AudioManager.AUDIO_DEVICE_CATEGORY_CARKIT;
@@ -149,6 +145,14 @@
private static final int BT_LE_AUDIO_MIN_VOL = 0;
private static final int BT_LE_AUDIO_MAX_VOL = 255;
+ // BtDevice constants currently rolling out under flag protection. Use own
+ // constants instead to avoid mainline dependency from flag library import
+ // TODO(b/335936458): remove once the BtDevice flag is rolled out
+ private static final String DEVICE_TYPE_SPEAKER = "Speaker";
+ private static final String DEVICE_TYPE_HEADSET = "Headset";
+ private static final String DEVICE_TYPE_CARKIT = "Carkit";
+ private static final String DEVICE_TYPE_HEARING_AID = "HearingAid";
+
/**
* Returns a string representation of the scoAudioMode.
*/
diff --git a/services/core/java/com/android/server/display/DisplayAdapter.java b/services/core/java/com/android/server/display/DisplayAdapter.java
index 5690a9e..69bc66f 100644
--- a/services/core/java/com/android/server/display/DisplayAdapter.java
+++ b/services/core/java/com/android/server/display/DisplayAdapter.java
@@ -135,7 +135,7 @@
float[] alternativeRefreshRates,
@Display.HdrCapabilities.HdrType int[] supportedHdrTypes) {
return new Display.Mode(NEXT_DISPLAY_MODE_ID.getAndIncrement(), width, height, refreshRate,
- vsyncRate, false, alternativeRefreshRates, supportedHdrTypes);
+ vsyncRate, /* isSynthetic= */ false, alternativeRefreshRates, supportedHdrTypes);
}
public interface Listener {
diff --git a/services/core/java/com/android/server/display/DisplayBrightnessState.java b/services/core/java/com/android/server/display/DisplayBrightnessState.java
index baa154d..184ae41 100644
--- a/services/core/java/com/android/server/display/DisplayBrightnessState.java
+++ b/services/core/java/com/android/server/display/DisplayBrightnessState.java
@@ -47,6 +47,8 @@
private final BrightnessEvent mBrightnessEvent;
private final int mBrightnessAdjustmentFlag;
+ private final boolean mIsUserInitiatedChange;
+
private DisplayBrightnessState(Builder builder) {
mBrightness = builder.getBrightness();
mSdrBrightness = builder.getSdrBrightness();
@@ -60,6 +62,7 @@
mShouldUpdateScreenBrightnessSetting = builder.shouldUpdateScreenBrightnessSetting();
mBrightnessEvent = builder.getBrightnessEvent();
mBrightnessAdjustmentFlag = builder.getBrightnessAdjustmentFlag();
+ mIsUserInitiatedChange = builder.isUserInitiatedChange();
}
/**
@@ -148,6 +151,13 @@
return mBrightnessAdjustmentFlag;
}
+ /**
+ * Gets if the current brightness changes are because of a user initiated change
+ */
+ public boolean isUserInitiatedChange() {
+ return mIsUserInitiatedChange;
+ }
+
@Override
public String toString() {
StringBuilder stringBuilder = new StringBuilder("DisplayBrightnessState:");
@@ -168,6 +178,7 @@
stringBuilder.append("\n mBrightnessEvent:")
.append(Objects.toString(mBrightnessEvent, "null"));
stringBuilder.append("\n mBrightnessAdjustmentFlag:").append(mBrightnessAdjustmentFlag);
+ stringBuilder.append("\n mIsUserInitiatedChange:").append(mIsUserInitiatedChange);
return stringBuilder.toString();
}
@@ -199,7 +210,8 @@
&& mShouldUpdateScreenBrightnessSetting
== otherState.shouldUpdateScreenBrightnessSetting()
&& Objects.equals(mBrightnessEvent, otherState.getBrightnessEvent())
- && mBrightnessAdjustmentFlag == otherState.getBrightnessAdjustmentFlag();
+ && mBrightnessAdjustmentFlag == otherState.getBrightnessAdjustmentFlag()
+ && mIsUserInitiatedChange == otherState.isUserInitiatedChange();
}
@Override
@@ -207,7 +219,8 @@
return Objects.hash(mBrightness, mSdrBrightness, mBrightnessReason,
mShouldUseAutoBrightness, mIsSlowChange, mMaxBrightness, mMinBrightness,
mCustomAnimationRate,
- mShouldUpdateScreenBrightnessSetting, mBrightnessEvent, mBrightnessAdjustmentFlag);
+ mShouldUpdateScreenBrightnessSetting, mBrightnessEvent, mBrightnessAdjustmentFlag,
+ mIsUserInitiatedChange);
}
/**
@@ -236,6 +249,8 @@
public int mBrightnessAdjustmentFlag = 0;
+ private boolean mIsUserInitiatedChange;
+
/**
* Create a builder starting with the values from the specified {@link
* DisplayBrightnessState}.
@@ -257,6 +272,7 @@
state.shouldUpdateScreenBrightnessSetting());
builder.setBrightnessEvent(state.getBrightnessEvent());
builder.setBrightnessAdjustmentFlag(state.getBrightnessAdjustmentFlag());
+ builder.setIsUserInitiatedChange(state.isUserInitiatedChange());
return builder;
}
@@ -464,5 +480,20 @@
mBrightnessAdjustmentFlag = brightnessAdjustmentFlag;
return this;
}
+
+ /**
+ * Gets if the current change is a user initiated change
+ */
+ public boolean isUserInitiatedChange() {
+ return mIsUserInitiatedChange;
+ }
+
+ /**
+ * This is used to set if the current change is a user initiated change
+ */
+ public Builder setIsUserInitiatedChange(boolean isUserInitiatedChange) {
+ mIsUserInitiatedChange = isUserInitiatedChange;
+ return this;
+ }
}
}
diff --git a/services/core/java/com/android/server/display/DisplayPowerController.java b/services/core/java/com/android/server/display/DisplayPowerController.java
index b97053b..8d71c70 100644
--- a/services/core/java/com/android/server/display/DisplayPowerController.java
+++ b/services/core/java/com/android/server/display/DisplayPowerController.java
@@ -1391,6 +1391,7 @@
// request changes.
final boolean wasShortTermModelActive =
mAutomaticBrightnessStrategy.isShortTermModelActive();
+ boolean userInitiatedChange = displayBrightnessState.isUserInitiatedChange();
boolean allowAutoBrightnessWhileDozing =
mDisplayBrightnessController.isAllowAutoBrightnessWhileDozingConfig();
if (mFlags.offloadControlsDozeAutoBrightness() && mFlags.isDisplayOffloadEnabled()
@@ -1413,13 +1414,14 @@
mPowerRequest.policy,
mDisplayBrightnessController.getLastUserSetScreenBrightness(),
userSetBrightnessChanged);
+
+ // If the brightness is already set then it's been overridden by something other than
+ // the user, or is a temporary adjustment.
+ userInitiatedChange = (Float.isNaN(brightnessState))
+ && (mAutomaticBrightnessStrategy.getAutoBrightnessAdjustmentChanged()
+ || userSetBrightnessChanged);
}
- // If the brightness is already set then it's been overridden by something other than the
- // user, or is a temporary adjustment.
- boolean userInitiatedChange = (Float.isNaN(brightnessState))
- && (mAutomaticBrightnessStrategy.getAutoBrightnessAdjustmentChanged()
- || userSetBrightnessChanged);
final int autoBrightnessState = mAutomaticBrightnessStrategy.isAutoBrightnessEnabled()
? AutomaticBrightnessController.AUTO_BRIGHTNESS_ENABLED
diff --git a/services/core/java/com/android/server/display/brightness/DisplayBrightnessController.java b/services/core/java/com/android/server/display/brightness/DisplayBrightnessController.java
index aa17df6..d567331 100644
--- a/services/core/java/com/android/server/display/brightness/DisplayBrightnessController.java
+++ b/services/core/java/com/android/server/display/brightness/DisplayBrightnessController.java
@@ -600,6 +600,7 @@
private StrategyExecutionRequest constructStrategyExecutionRequest(
DisplayManagerInternal.DisplayPowerRequest displayPowerRequest) {
float currentScreenBrightness = getCurrentBrightness();
- return new StrategyExecutionRequest(displayPowerRequest, currentScreenBrightness);
+ return new StrategyExecutionRequest(displayPowerRequest, currentScreenBrightness,
+ mUserSetScreenBrightnessUpdated);
}
}
diff --git a/services/core/java/com/android/server/display/brightness/StrategyExecutionRequest.java b/services/core/java/com/android/server/display/brightness/StrategyExecutionRequest.java
index 82c0bbf..304640b 100644
--- a/services/core/java/com/android/server/display/brightness/StrategyExecutionRequest.java
+++ b/services/core/java/com/android/server/display/brightness/StrategyExecutionRequest.java
@@ -29,10 +29,14 @@
private final float mCurrentScreenBrightness;
+ // Represents if the user set screen brightness was changed or not.
+ private boolean mUserSetBrightnessChanged;
+
public StrategyExecutionRequest(DisplayManagerInternal.DisplayPowerRequest displayPowerRequest,
- float currentScreenBrightness) {
+ float currentScreenBrightness, boolean userSetBrightnessChanged) {
mDisplayPowerRequest = displayPowerRequest;
mCurrentScreenBrightness = currentScreenBrightness;
+ mUserSetBrightnessChanged = userSetBrightnessChanged;
}
public DisplayManagerInternal.DisplayPowerRequest getDisplayPowerRequest() {
@@ -43,6 +47,10 @@
return mCurrentScreenBrightness;
}
+ public boolean isUserSetBrightnessChanged() {
+ return mUserSetBrightnessChanged;
+ }
+
@Override
public boolean equals(Object obj) {
if (!(obj instanceof StrategyExecutionRequest)) {
@@ -50,11 +58,13 @@
}
StrategyExecutionRequest other = (StrategyExecutionRequest) obj;
return Objects.equals(mDisplayPowerRequest, other.getDisplayPowerRequest())
- && mCurrentScreenBrightness == other.getCurrentScreenBrightness();
+ && mCurrentScreenBrightness == other.getCurrentScreenBrightness()
+ && mUserSetBrightnessChanged == other.isUserSetBrightnessChanged();
}
@Override
public int hashCode() {
- return Objects.hash(mDisplayPowerRequest, mCurrentScreenBrightness);
+ return Objects.hash(mDisplayPowerRequest, mCurrentScreenBrightness,
+ mUserSetBrightnessChanged);
}
}
diff --git a/services/core/java/com/android/server/display/brightness/strategy/AutomaticBrightnessStrategy.java b/services/core/java/com/android/server/display/brightness/strategy/AutomaticBrightnessStrategy.java
index 2907364..2b5241f 100644
--- a/services/core/java/com/android/server/display/brightness/strategy/AutomaticBrightnessStrategy.java
+++ b/services/core/java/com/android/server/display/brightness/strategy/AutomaticBrightnessStrategy.java
@@ -290,6 +290,8 @@
.setBrightnessAdjustmentFlag(mAutoBrightnessAdjustmentReasonsFlags)
.setShouldUpdateScreenBrightnessSetting(
brightness != strategyExecutionRequest.getCurrentScreenBrightness())
+ .setIsUserInitiatedChange(getAutoBrightnessAdjustmentChanged()
+ || strategyExecutionRequest.isUserSetBrightnessChanged())
.build();
}
diff --git a/services/core/java/com/android/server/display/brightness/strategy/FallbackBrightnessStrategy.java b/services/core/java/com/android/server/display/brightness/strategy/FallbackBrightnessStrategy.java
index 3463649a..0b92317 100644
--- a/services/core/java/com/android/server/display/brightness/strategy/FallbackBrightnessStrategy.java
+++ b/services/core/java/com/android/server/display/brightness/strategy/FallbackBrightnessStrategy.java
@@ -45,6 +45,7 @@
// The fallback brightness might change due to clamping. Make sure we tell the rest
// of the system by updating the setting
.setShouldUpdateScreenBrightnessSetting(true)
+ .setIsUserInitiatedChange(strategyExecutionRequest.isUserSetBrightnessChanged())
.build();
}
diff --git a/services/core/java/com/android/server/display/feature/DisplayManagerFlags.java b/services/core/java/com/android/server/display/feature/DisplayManagerFlags.java
index f923cbc9..f56d803 100644
--- a/services/core/java/com/android/server/display/feature/DisplayManagerFlags.java
+++ b/services/core/java/com/android/server/display/feature/DisplayManagerFlags.java
@@ -353,7 +353,7 @@
}
/**
- * @return Whether to ignore preferredRefreshRate app request or not
+ * @return Whether to ignore preferredRefreshRate app request conversion to display mode or not
*/
public boolean ignoreAppPreferredRefreshRateRequest() {
return mIgnoreAppPreferredRefreshRate.isEnabled();
diff --git a/services/core/java/com/android/server/display/mode/DisplayModeDirector.java b/services/core/java/com/android/server/display/mode/DisplayModeDirector.java
index 76a2827..d519748 100644
--- a/services/core/java/com/android/server/display/mode/DisplayModeDirector.java
+++ b/services/core/java/com/android/server/display/mode/DisplayModeDirector.java
@@ -1254,13 +1254,9 @@
* Responsible for keeping track of app requested refresh rates per display
*/
public final class AppRequestObserver {
- private final SparseArray<Display.Mode> mAppRequestedModeByDisplay;
- private final SparseArray<RefreshRateRange> mAppPreferredRefreshRateRangeByDisplay;
private final boolean mIgnorePreferredRefreshRate;
AppRequestObserver(DisplayManagerFlags flags) {
- mAppRequestedModeByDisplay = new SparseArray<>();
- mAppPreferredRefreshRateRangeByDisplay = new SparseArray<>();
mIgnorePreferredRefreshRate = flags.ignoreAppPreferredRefreshRateRequest();
}
@@ -1269,34 +1265,77 @@
*/
public void setAppRequest(int displayId, int modeId, float requestedRefreshRate,
float requestedMinRefreshRateRange, float requestedMaxRefreshRateRange) {
+ Display.Mode requestedMode;
+ synchronized (mLock) {
+ requestedMode = findModeLocked(displayId, modeId, requestedRefreshRate);
+ }
- if (modeId == 0 && requestedRefreshRate != 0 && !mIgnorePreferredRefreshRate) {
+ Vote frameRateVote = getFrameRateVote(
+ requestedMinRefreshRateRange, requestedMaxRefreshRateRange);
+ Vote baseModeRefreshRateVote = getBaseModeVote(requestedMode, requestedRefreshRate);
+ Vote sizeVote = getSizeVote(requestedMode);
+
+ mVotesStorage.updateVote(displayId, Vote.PRIORITY_APP_REQUEST_RENDER_FRAME_RATE_RANGE,
+ frameRateVote);
+ mVotesStorage.updateVote(displayId, Vote.PRIORITY_APP_REQUEST_BASE_MODE_REFRESH_RATE,
+ baseModeRefreshRateVote);
+ mVotesStorage.updateVote(displayId, Vote.PRIORITY_APP_REQUEST_SIZE, sizeVote);
+ }
+
+ private Display.Mode findModeLocked(int displayId, int modeId, float requestedRefreshRate) {
+ Display.Mode mode = null;
+ if (modeId != 0) {
+ mode = findAppModeByIdLocked(displayId, modeId);
+ } else if (requestedRefreshRate != 0 && !mIgnorePreferredRefreshRate) { // modeId == 0
// Scan supported modes returned to find a mode with the same
// size as the default display mode but with the specified refresh rate instead.
- Display.Mode mode = findDefaultModeByRefreshRate(displayId, requestedRefreshRate);
- if (mode != null) {
- modeId = mode.getModeId();
- } else {
+ mode = findDefaultModeByRefreshRateLocked(displayId, requestedRefreshRate);
+ if (mode == null) {
Slog.e(TAG, "Couldn't find a mode for the requestedRefreshRate: "
+ requestedRefreshRate + " on Display: " + displayId);
}
}
+ return mode;
+ }
- synchronized (mLock) {
- setAppRequestedModeLocked(displayId, modeId);
- setAppPreferredRefreshRateRangeLocked(displayId, requestedMinRefreshRateRange,
- requestedMaxRefreshRateRange);
+ private Vote getFrameRateVote(float minRefreshRate, float maxRefreshRate) {
+ RefreshRateRange refreshRateRange = null;
+ if (minRefreshRate > 0 || maxRefreshRate > 0) {
+ float max = maxRefreshRate > 0
+ ? maxRefreshRate : Float.POSITIVE_INFINITY;
+ refreshRateRange = new RefreshRateRange(minRefreshRate, max);
+ if (refreshRateRange.min == 0 && refreshRateRange.max == 0) {
+ // minRefreshRate/maxRefreshRate were invalid
+ refreshRateRange = null;
+ }
}
+ return refreshRateRange != null
+ ? Vote.forRenderFrameRates(refreshRateRange.min, refreshRateRange.max) : null;
+ }
+
+ private Vote getSizeVote(@Nullable Display.Mode mode) {
+ return mode != null
+ ? Vote.forSize(mode.getPhysicalWidth(), mode.getPhysicalHeight()) : null;
+ }
+
+ private Vote getBaseModeVote(@Nullable Display.Mode mode, float requestedRefreshRate) {
+ Vote vote = null;
+ if (mode != null) {
+ if (mode.isSynthetic()) {
+ vote = Vote.forRequestedRefreshRate(mode.getRefreshRate());
+ } else {
+ vote = Vote.forBaseModeRefreshRate(mode.getRefreshRate());
+ }
+ } else if (requestedRefreshRate != 0f && mIgnorePreferredRefreshRate) {
+ vote = Vote.forRequestedRefreshRate(requestedRefreshRate);
+ } // !mIgnorePreferredRefreshRate case is handled by findModeLocked
+ return vote;
}
@Nullable
- private Display.Mode findDefaultModeByRefreshRate(int displayId, float refreshRate) {
- Display.Mode[] modes;
- Display.Mode defaultMode;
- synchronized (mLock) {
- modes = mAppSupportedModesByDisplay.get(displayId);
- defaultMode = mDefaultModeByDisplay.get(displayId);
- }
+ private Display.Mode findDefaultModeByRefreshRateLocked(int displayId, float refreshRate) {
+ Display.Mode[] modes = mAppSupportedModesByDisplay.get(displayId);
+ Display.Mode defaultMode = mDefaultModeByDisplay.get(displayId);
for (int i = 0; i < modes.length; i++) {
if (modes[i].matches(defaultMode.getPhysicalWidth(),
defaultMode.getPhysicalHeight(), refreshRate)) {
@@ -1306,69 +1345,6 @@
return null;
}
- private void setAppRequestedModeLocked(int displayId, int modeId) {
- final Display.Mode requestedMode = findAppModeByIdLocked(displayId, modeId);
- if (Objects.equals(requestedMode, mAppRequestedModeByDisplay.get(displayId))) {
- return;
- }
- final Vote baseModeRefreshRateVote;
- final Vote sizeVote;
- if (requestedMode != null) {
- mAppRequestedModeByDisplay.put(displayId, requestedMode);
- sizeVote = Vote.forSize(requestedMode.getPhysicalWidth(),
- requestedMode.getPhysicalHeight());
- if (requestedMode.isSynthetic()) {
- // TODO: for synthetic mode we should not limit frame rate, we must ensure
- // that frame rate is reachable within other Votes constraints
- baseModeRefreshRateVote = Vote.forRenderFrameRates(
- requestedMode.getRefreshRate(), requestedMode.getRefreshRate());
- } else {
- baseModeRefreshRateVote =
- Vote.forBaseModeRefreshRate(requestedMode.getRefreshRate());
- }
- } else {
- mAppRequestedModeByDisplay.remove(displayId);
- baseModeRefreshRateVote = null;
- sizeVote = null;
- }
-
- mVotesStorage.updateVote(displayId, Vote.PRIORITY_APP_REQUEST_BASE_MODE_REFRESH_RATE,
- baseModeRefreshRateVote);
- mVotesStorage.updateVote(displayId, Vote.PRIORITY_APP_REQUEST_SIZE, sizeVote);
- }
-
- private void setAppPreferredRefreshRateRangeLocked(int displayId,
- float requestedMinRefreshRateRange, float requestedMaxRefreshRateRange) {
- final Vote vote;
-
- RefreshRateRange refreshRateRange = null;
- if (requestedMinRefreshRateRange > 0 || requestedMaxRefreshRateRange > 0) {
- float min = requestedMinRefreshRateRange;
- float max = requestedMaxRefreshRateRange > 0
- ? requestedMaxRefreshRateRange : Float.POSITIVE_INFINITY;
- refreshRateRange = new RefreshRateRange(min, max);
- if (refreshRateRange.min == 0 && refreshRateRange.max == 0) {
- // requestedMinRefreshRateRange/requestedMaxRefreshRateRange were invalid
- refreshRateRange = null;
- }
- }
-
- if (Objects.equals(refreshRateRange,
- mAppPreferredRefreshRateRangeByDisplay.get(displayId))) {
- return;
- }
-
- if (refreshRateRange != null) {
- mAppPreferredRefreshRateRangeByDisplay.put(displayId, refreshRateRange);
- vote = Vote.forRenderFrameRates(refreshRateRange.min, refreshRateRange.max);
- } else {
- mAppPreferredRefreshRateRangeByDisplay.remove(displayId);
- vote = null;
- }
- mVotesStorage.updateVote(displayId, Vote.PRIORITY_APP_REQUEST_RENDER_FRAME_RATE_RANGE,
- vote);
- }
-
private Display.Mode findAppModeByIdLocked(int displayId, int modeId) {
Display.Mode[] modes = mAppSupportedModesByDisplay.get(displayId);
if (modes == null) {
@@ -1384,19 +1360,7 @@
private void dumpLocked(PrintWriter pw) {
pw.println(" AppRequestObserver");
- pw.println(" mAppRequestedModeByDisplay:");
- for (int i = 0; i < mAppRequestedModeByDisplay.size(); i++) {
- final int id = mAppRequestedModeByDisplay.keyAt(i);
- final Display.Mode mode = mAppRequestedModeByDisplay.valueAt(i);
- pw.println(" " + id + " -> " + mode);
- }
- pw.println(" mAppPreferredRefreshRateRangeByDisplay:");
- for (int i = 0; i < mAppPreferredRefreshRateRangeByDisplay.size(); i++) {
- final int id = mAppPreferredRefreshRateRangeByDisplay.keyAt(i);
- final RefreshRateRange refreshRateRange =
- mAppPreferredRefreshRateRangeByDisplay.valueAt(i);
- pw.println(" " + id + " -> " + refreshRateRange);
- }
+ pw.println(" mIgnorePreferredRefreshRate: " + mIgnorePreferredRefreshRate);
}
}
diff --git a/services/core/java/com/android/server/display/mode/RequestedRefreshRateVote.java b/services/core/java/com/android/server/display/mode/RequestedRefreshRateVote.java
new file mode 100644
index 0000000..843cf88
--- /dev/null
+++ b/services/core/java/com/android/server/display/mode/RequestedRefreshRateVote.java
@@ -0,0 +1,51 @@
+/*
+ * 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.server.display.mode;
+
+import android.annotation.NonNull;
+
+import java.util.Objects;
+
+class RequestedRefreshRateVote implements Vote {
+ final float mRefreshRate;
+
+ RequestedRefreshRateVote(float refreshRate) {
+ this.mRefreshRate = refreshRate;
+ }
+
+ @Override
+ public void updateSummary(@NonNull VoteSummary summary) {
+ summary.requestedRefreshRates.add(mRefreshRate);
+ }
+
+ @Override
+ public String toString() {
+ return "RequestedRefreshRateVote{ refreshRate=" + mRefreshRate + " }";
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) return true;
+ if (!(o instanceof RequestedRefreshRateVote that)) return false;
+ return Float.compare(mRefreshRate, that.mRefreshRate) == 0;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(mRefreshRate);
+ }
+}
diff --git a/services/core/java/com/android/server/display/mode/SyntheticModeManager.java b/services/core/java/com/android/server/display/mode/SyntheticModeManager.java
index 5b6bbc5..a83b939 100644
--- a/services/core/java/com/android/server/display/mode/SyntheticModeManager.java
+++ b/services/core/java/com/android/server/display/mode/SyntheticModeManager.java
@@ -32,7 +32,9 @@
*/
public class SyntheticModeManager {
private static final float FLOAT_TOLERANCE = 0.01f;
- private static final float SYNTHETIC_MODE_HIGH_BOUNDARY = 60f + FLOAT_TOLERANCE;
+ private static final float SYNTHETIC_MODE_REFRESH_RATE = 60f;
+ private static final float SYNTHETIC_MODE_HIGH_BOUNDARY =
+ SYNTHETIC_MODE_REFRESH_RATE + FLOAT_TOLERANCE;
private final boolean mSynthetic60HzModesEnabled;
@@ -62,7 +64,7 @@
nextModeId = mode.getModeId();
}
- float divisor = mode.getVsyncRate() / 60f;
+ float divisor = mode.getVsyncRate() / SYNTHETIC_MODE_REFRESH_RATE;
boolean is60HzAchievable = Math.abs(divisor - Math.round(divisor)) < FLOAT_TOLERANCE;
if (is60HzAchievable) {
sizes.put(new Size(mode.getPhysicalWidth(), mode.getPhysicalHeight()),
diff --git a/services/core/java/com/android/server/display/mode/Vote.java b/services/core/java/com/android/server/display/mode/Vote.java
index 3e8b3c5..1ec469c 100644
--- a/services/core/java/com/android/server/display/mode/Vote.java
+++ b/services/core/java/com/android/server/display/mode/Vote.java
@@ -186,6 +186,10 @@
return new BaseModeRefreshRateVote(baseModeRefreshRate);
}
+ static Vote forRequestedRefreshRate(float refreshRate) {
+ return new RequestedRefreshRateVote(refreshRate);
+ }
+
static Vote forSupportedRefreshRates(List<SupportedModeData> supportedModes) {
if (supportedModes.isEmpty()) {
return null;
diff --git a/services/core/java/com/android/server/display/mode/VoteSummary.java b/services/core/java/com/android/server/display/mode/VoteSummary.java
index d4ce892..00a9226 100644
--- a/services/core/java/com/android/server/display/mode/VoteSummary.java
+++ b/services/core/java/com/android/server/display/mode/VoteSummary.java
@@ -23,7 +23,9 @@
import android.view.SurfaceControl;
import java.util.ArrayList;
+import java.util.HashSet;
import java.util.List;
+import java.util.Set;
final class VoteSummary {
private static final float FLOAT_TOLERANCE = SurfaceControl.RefreshRateRange.FLOAT_TOLERANCE;
@@ -38,7 +40,14 @@
public int minWidth;
public int minHeight;
public boolean disableRefreshRateSwitching;
+ /**
+ * available modes should have mode with specific refresh rate
+ */
public float appRequestBaseModeRefreshRate;
+ /**
+ * requestRefreshRate should be within [minRenderFrameRate, maxRenderFrameRate] range
+ */
+ public Set<Float> requestedRefreshRates = new HashSet<>();
@Nullable
public List<SupportedRefreshRatesVote.RefreshRates> supportedRefreshRates;
@@ -329,6 +338,21 @@
}
return false;
}
+
+ for (Float requestedRefreshRate : requestedRefreshRates) {
+ if (requestedRefreshRate < minRenderFrameRate
+ || requestedRefreshRate > maxRenderFrameRate) {
+ if (mLoggingEnabled) {
+ Slog.w(TAG, "Requested refreshRate is outside frame rate range"
+ + ": requestedRefreshRates=" + requestedRefreshRates
+ + ", requestedRefreshRate=" + requestedRefreshRate
+ + ", minRenderFrameRate=" + minRenderFrameRate
+ + ", maxRenderFrameRate=" + maxRenderFrameRate);
+ }
+ return false;
+ }
+ }
+
return true;
}
@@ -370,6 +394,7 @@
minHeight = 0;
disableRefreshRateSwitching = false;
appRequestBaseModeRefreshRate = 0f;
+ requestedRefreshRates.clear();
supportedRefreshRates = null;
supportedModeIds = null;
if (mLoggingEnabled) {
@@ -393,6 +418,7 @@
+ ", minHeight=" + minHeight
+ ", disableRefreshRateSwitching=" + disableRefreshRateSwitching
+ ", appRequestBaseModeRefreshRate=" + appRequestBaseModeRefreshRate
+ + ", requestRefreshRates=" + requestedRefreshRates
+ ", supportedRefreshRates=" + supportedRefreshRates
+ ", supportedModeIds=" + supportedModeIds
+ ", mIsDisplayResolutionRangeVotingEnabled="
diff --git a/services/core/java/com/android/server/inputmethod/InputMethodManagerService.java b/services/core/java/com/android/server/inputmethod/InputMethodManagerService.java
index d22438f..76f441c 100644
--- a/services/core/java/com/android/server/inputmethod/InputMethodManagerService.java
+++ b/services/core/java/com/android/server/inputmethod/InputMethodManagerService.java
@@ -1161,7 +1161,7 @@
synchronized (ImfLock.class) {
mService.mUserDataRepository.getOrCreate(userId);
if (mService.mExperimentalConcurrentMultiUserModeEnabled) {
- if (mService.mCurrentUserId != userId) {
+ if (mService.mCurrentUserId != userId && mService.mSystemReady) {
mService.experimentalInitializeVisibleBackgroundUserLocked(userId);
}
}
@@ -1547,6 +1547,14 @@
final var unused = SystemServerInitThreadPool.submit(
AdditionalSubtypeMapRepository::startWriterThread,
"Start AdditionalSubtypeMapRepository's writer thread");
+
+ if (mExperimentalConcurrentMultiUserModeEnabled) {
+ for (int userId : mUserManagerInternal.getUserIds()) {
+ if (userId != mCurrentUserId) {
+ experimentalInitializeVisibleBackgroundUserLocked(userId);
+ }
+ }
+ }
}
}
}
@@ -2884,10 +2892,22 @@
*/
@GuardedBy("ImfLock.class")
void experimentalInitializeVisibleBackgroundUserLocked(@UserIdInt int userId) {
- if (!mUserManagerInternal.isUserVisible(userId)) {
- return;
- }
final var settings = InputMethodSettingsRepository.get(userId);
+
+ // Until we figure out what makes most sense, we enable all the pre-installed IMEs in
+ // concurrent multi-user IME mode.
+ String enabledImeIdsStr = settings.getEnabledInputMethodsStr();
+ for (var imi : settings.getMethodList()) {
+ if (!imi.isSystem()) {
+ return;
+ }
+ enabledImeIdsStr = InputMethodUtils.concatEnabledImeIds(enabledImeIdsStr, imi.getId());
+ }
+ if (!TextUtils.equals(settings.getEnabledInputMethodsStr(), enabledImeIdsStr)) {
+ settings.putEnabledInputMethodsStr(enabledImeIdsStr);
+ }
+
+ // Also update the currently-selected IME.
String id = settings.getSelectedInputMethod();
if (TextUtils.isEmpty(id)) {
final InputMethodInfo imi = InputMethodInfoUtils.getMostApplicableDefaultIME(
diff --git a/services/core/java/com/android/server/location/contexthub/ContextHubClientBroker.java b/services/core/java/com/android/server/location/contexthub/ContextHubClientBroker.java
index 0ca4808..363a4a7 100644
--- a/services/core/java/com/android/server/location/contexthub/ContextHubClientBroker.java
+++ b/services/core/java/com/android/server/location/contexthub/ContextHubClientBroker.java
@@ -1161,7 +1161,7 @@
@Override
public String toString() {
- StringBuilder out = new StringBuilder("[ContextHubClient ");
+ StringBuilder out = new StringBuilder();
out.append("endpointID: ").append(getHostEndPointId()).append(", ");
out.append("contextHub: ").append(getAttachedContextHubId()).append(", ");
if (mAttributionTag != null) {
@@ -1170,25 +1170,26 @@
if (mPendingIntentRequest.isValid()) {
out.append("intentCreatorPackage: ").append(mPackage).append(", ");
out.append("nanoAppId: 0x")
- .append(Long.toHexString(mPendingIntentRequest.getNanoAppId()));
+ .append(Long.toHexString(mPendingIntentRequest.getNanoAppId()))
+ .append(", ");
} else {
- out.append("package: ").append(mPackage);
+ out.append("package: ").append(mPackage).append(", ");
}
if (mMessageChannelNanoappIdMap.size() > 0) {
- out.append(" messageChannelNanoappSet: (");
+ out.append("messageChannelNanoappSet: (");
Iterator<Map.Entry<Long, Integer>> it =
mMessageChannelNanoappIdMap.entrySet().iterator();
while (it.hasNext()) {
Map.Entry<Long, Integer> entry = it.next();
- out.append("0x")
+ out.append("Nanoapp 0x")
.append(Long.toHexString(entry.getKey()))
- .append(" auth state: ")
+ .append(": Auth state: ")
.append(authStateToString(entry.getValue()));
if (it.hasNext()) {
- out.append(",");
+ out.append(", ");
}
}
- out.append(")");
+ out.append(")").append(", ");
}
synchronized (mWakeLock) {
out.append("wakelock: ").append(mWakeLock);
diff --git a/services/core/java/com/android/server/notification/DefaultDeviceEffectsApplier.java b/services/core/java/com/android/server/notification/DefaultDeviceEffectsApplier.java
index 27b8574..d060f8f2 100644
--- a/services/core/java/com/android/server/notification/DefaultDeviceEffectsApplier.java
+++ b/services/core/java/com/android/server/notification/DefaultDeviceEffectsApplier.java
@@ -32,12 +32,13 @@
import android.service.notification.ZenDeviceEffects;
import android.service.notification.ZenModeConfig;
import android.service.notification.ZenModeConfig.ConfigChangeOrigin;
+import android.util.Slog;
import com.android.internal.annotations.GuardedBy;
/** Default implementation for {@link DeviceEffectsApplier}. */
class DefaultDeviceEffectsApplier implements DeviceEffectsApplier {
-
+ private static final String TAG = "DeviceEffectsApplier";
private static final String SUPPRESS_AMBIENT_DISPLAY_TOKEN =
"DefaultDeviceEffectsApplier:SuppressAmbientDisplay";
private static final int SATURATION_LEVEL_GRAYSCALE = 0;
@@ -75,28 +76,44 @@
Binder.withCleanCallingIdentity(() -> {
if (mLastAppliedEffects.shouldSuppressAmbientDisplay()
!= effects.shouldSuppressAmbientDisplay()) {
- mPowerManager.suppressAmbientDisplay(SUPPRESS_AMBIENT_DISPLAY_TOKEN,
- effects.shouldSuppressAmbientDisplay());
+ try {
+ mPowerManager.suppressAmbientDisplay(SUPPRESS_AMBIENT_DISPLAY_TOKEN,
+ effects.shouldSuppressAmbientDisplay());
+ } catch (Exception e) {
+ Slog.e(TAG, "Could not change AOD override", e);
+ }
}
if (mLastAppliedEffects.shouldDisplayGrayscale() != effects.shouldDisplayGrayscale()) {
if (mColorDisplayManager != null) {
- mColorDisplayManager.setSaturationLevel(
- effects.shouldDisplayGrayscale() ? SATURATION_LEVEL_GRAYSCALE
- : SATURATION_LEVEL_FULL_COLOR);
+ try {
+ mColorDisplayManager.setSaturationLevel(
+ effects.shouldDisplayGrayscale() ? SATURATION_LEVEL_GRAYSCALE
+ : SATURATION_LEVEL_FULL_COLOR);
+ } catch (Exception e) {
+ Slog.e(TAG, "Could not change grayscale override", e);
+ }
}
}
if (mLastAppliedEffects.shouldDimWallpaper() != effects.shouldDimWallpaper()) {
if (mWallpaperManager != null) {
- mWallpaperManager.setWallpaperDimAmount(
- effects.shouldDimWallpaper() ? WALLPAPER_DIM_AMOUNT_DIMMED
- : WALLPAPER_DIM_AMOUNT_NORMAL);
+ try {
+ mWallpaperManager.setWallpaperDimAmount(
+ effects.shouldDimWallpaper() ? WALLPAPER_DIM_AMOUNT_DIMMED
+ : WALLPAPER_DIM_AMOUNT_NORMAL);
+ } catch (Exception e) {
+ Slog.e(TAG, "Could not change wallpaper override", e);
+ }
}
}
if (mLastAppliedEffects.shouldUseNightMode() != effects.shouldUseNightMode()) {
- updateOrScheduleNightMode(effects.shouldUseNightMode(), origin);
+ try {
+ updateOrScheduleNightMode(effects.shouldUseNightMode(), origin);
+ } catch (Exception e) {
+ Slog.e(TAG, "Could not change dark theme override", e);
+ }
}
});
@@ -131,9 +148,13 @@
private void updateNightModeImmediately(boolean useNightMode) {
Binder.withCleanCallingIdentity(() -> {
- mUiModeManager.setAttentionModeThemeOverlay(
- useNightMode ? MODE_ATTENTION_THEME_OVERLAY_NIGHT
- : MODE_ATTENTION_THEME_OVERLAY_OFF);
+ try {
+ mUiModeManager.setAttentionModeThemeOverlay(
+ useNightMode ? MODE_ATTENTION_THEME_OVERLAY_NIGHT
+ : MODE_ATTENTION_THEME_OVERLAY_OFF);
+ } catch (Exception e) {
+ Slog.e(TAG, "Could not change wallpaper override", e);
+ }
});
}
diff --git a/services/core/java/com/android/server/notification/ZenModeHelper.java b/services/core/java/com/android/server/notification/ZenModeHelper.java
index ae29e1b..454bd20 100644
--- a/services/core/java/com/android/server/notification/ZenModeHelper.java
+++ b/services/core/java/com/android/server/notification/ZenModeHelper.java
@@ -149,6 +149,8 @@
private static final String IMPLICIT_RULE_ID_PREFIX = "implicit_"; // + pkg_name
+ private static final int MAX_ICON_RESOURCE_NAME_LENGTH = 1000;
+
/**
* Send new activation AutomaticZenRule statuses to apps with a min target SDK version
*/
@@ -2645,7 +2647,13 @@
requireNonNull(packageName);
try {
final Resources res = mPm.getResourcesForApplication(packageName);
- return res.getResourceName(resId);
+ String resourceName = res.getResourceName(resId);
+ if (resourceName != null && resourceName.length() > MAX_ICON_RESOURCE_NAME_LENGTH) {
+ Slog.e(TAG, "Resource name for ID=" + resId + " in package " + packageName
+ + " is too long (" + resourceName.length() + "); ignoring it");
+ return null;
+ }
+ return resourceName;
} catch (PackageManager.NameNotFoundException | Resources.NotFoundException e) {
Slog.e(TAG, "Resource name for ID=" + resId + " not found in package " + packageName
+ ". Resource IDs may change when the application is upgraded, and the system"
diff --git a/services/core/java/com/android/server/pm/PackageInstallerService.java b/services/core/java/com/android/server/pm/PackageInstallerService.java
index a5cd821..050d44e 100644
--- a/services/core/java/com/android/server/pm/PackageInstallerService.java
+++ b/services/core/java/com/android/server/pm/PackageInstallerService.java
@@ -1445,6 +1445,15 @@
.createEvent(DevicePolicyEnums.UNINSTALL_PACKAGE)
.setAdmin(callerPackageName)
.write();
+ } else if (PackageInstallerSession.isEmergencyInstallerEnabled(callerPackageName, snapshot,
+ userId, callingUid)) {
+ // Need to clear the calling identity to get DELETE_PACKAGES permission
+ final long ident = Binder.clearCallingIdentity();
+ try {
+ mPm.deletePackageVersioned(versionedPackage, adapter.getBinder(), userId, flags);
+ } finally {
+ Binder.restoreCallingIdentity(ident);
+ }
} else {
ApplicationInfo appInfo = snapshot.getApplicationInfo(callerPackageName, 0, userId);
if (appInfo.targetSdkVersion >= Build.VERSION_CODES.P) {
diff --git a/services/core/java/com/android/server/pm/PackageInstallerSession.java b/services/core/java/com/android/server/pm/PackageInstallerSession.java
index a904738..0606563 100644
--- a/services/core/java/com/android/server/pm/PackageInstallerSession.java
+++ b/services/core/java/com/android/server/pm/PackageInstallerSession.java
@@ -316,14 +316,14 @@
private static final int INCREMENTAL_STORAGE_UNHEALTHY_MONITORING_MS = 60000;
/**
- * If an app being installed targets {@link Build.VERSION_CODES#S API 31} and above, the app
- * can be installed without user action.
+ * If an app being installed targets {@link Build.VERSION_CODES#TIRAMISU API 33} and above,
+ * the app can be installed without user action.
* See {@link PackageInstaller.SessionParams#setRequireUserAction} for other conditions required
* to be satisfied for a silent install.
*/
@ChangeId
- @EnabledSince(targetSdkVersion = Build.VERSION_CODES.S)
- private static final long SILENT_INSTALL_ALLOWED = 265131695L;
+ @EnabledSince(targetSdkVersion = Build.VERSION_CODES.TIRAMISU)
+ private static final long SILENT_INSTALL_ALLOWED = 325888262L;
/**
* The system supports pre-approval and update ownership features from
@@ -966,7 +966,8 @@
getInstallSource().mInstallerPackageName, mInstallerUid);
}
- private boolean isEmergencyInstallerEnabled(String packageName, Computer snapshot) {
+ static boolean isEmergencyInstallerEnabled(String packageName, Computer snapshot, int userId,
+ int installerUid) {
final PackageStateInternal ps = snapshot.getPackageStateInternal(packageName);
if (ps == null || ps.getPkg() == null || !ps.isSystem()) {
return false;
@@ -974,7 +975,7 @@
int uid = UserHandle.getUid(userId, ps.getAppId());
String emergencyInstaller = ps.getPkg().getEmergencyInstaller();
if (emergencyInstaller == null || !ArrayUtils.contains(
- snapshot.getPackagesForUid(mInstallerUid), emergencyInstaller)) {
+ snapshot.getPackagesForUid(installerUid), emergencyInstaller)) {
return false;
}
// Only system installers can have an emergency installer
@@ -987,7 +988,7 @@
return false;
}
return (snapshot.checkUidPermission(Manifest.permission.EMERGENCY_INSTALL_PACKAGES,
- mInstallerUid) == PackageManager.PERMISSION_GRANTED);
+ installerUid) == PackageManager.PERMISSION_GRANTED);
}
private static final int USER_ACTION_NOT_NEEDED = 0;
@@ -1075,7 +1076,7 @@
getInstallerPackageName());
final boolean isSelfUpdate = targetPackageUid == mInstallerUid;
final boolean isEmergencyInstall =
- isEmergencyInstallerEnabled(packageName, snapshot);
+ isEmergencyInstallerEnabled(packageName, snapshot, userId, mInstallerUid);
final boolean isPermissionGranted = isInstallPermissionGranted
|| (isUpdatePermissionGranted && isUpdate)
|| (isSelfUpdatePermissionGranted && isSelfUpdate)
diff --git a/services/core/java/com/android/server/pm/PackageManagerShellCommand.java b/services/core/java/com/android/server/pm/PackageManagerShellCommand.java
index 0a8b2b2..c40563f 100644
--- a/services/core/java/com/android/server/pm/PackageManagerShellCommand.java
+++ b/services/core/java/com/android/server/pm/PackageManagerShellCommand.java
@@ -3380,7 +3380,7 @@
params.sessionParams = sessionParams;
// Allowlist all permissions by default
sessionParams.installFlags |= PackageManager.INSTALL_ALL_WHITELIST_RESTRICTED_PERMISSIONS;
- // Set package source to other by default
+ // Set package source to other by default. Can be overridden by "--package-source"
sessionParams.setPackageSource(PackageInstaller.PACKAGE_SOURCE_OTHER);
// Encodes one of the states:
@@ -3567,6 +3567,9 @@
case "--ignore-dexopt-profile":
sessionParams.installFlags |= PackageManager.INSTALL_IGNORE_DEXOPT_PROFILE;
break;
+ case "--package-source":
+ sessionParams.setPackageSource(Integer.parseInt(getNextArg()));
+ break;
default:
throw new IllegalArgumentException("Unknown option " + opt);
}
diff --git a/services/core/java/com/android/server/power/stats/MobileRadioPowerStatsCollector.java b/services/core/java/com/android/server/power/stats/MobileRadioPowerStatsCollector.java
index a96e01b..33ea563 100644
--- a/services/core/java/com/android/server/power/stats/MobileRadioPowerStatsCollector.java
+++ b/services/core/java/com/android/server/power/stats/MobileRadioPowerStatsCollector.java
@@ -195,6 +195,9 @@
return null;
}
+ Arrays.fill(mPowerStats.stats, 0);
+ mPowerStats.uidStats.clear();
+
collectModemActivityInfo();
collectNetworkStats();
@@ -239,16 +242,16 @@
activityInfo = null;
}
+ if (activityInfo == null) {
+ return;
+ }
+
ModemActivityInfo deltaInfo = mLastModemActivityInfo == null
- ? (activityInfo == null ? null : activityInfo.getDelta(activityInfo))
+ ? activityInfo.getDelta(activityInfo)
: mLastModemActivityInfo.getDelta(activityInfo);
mLastModemActivityInfo = activityInfo;
- if (deltaInfo == null) {
- return;
- }
-
setTimestamp(deltaInfo.getTimestampMillis());
mLayout.setDeviceSleepTime(mDeviceStats, deltaInfo.getSleepTimeMillis());
mLayout.setDeviceIdleTime(mDeviceStats, deltaInfo.getIdleTimeMillis());
@@ -293,8 +296,6 @@
}
private void collectNetworkStats() {
- mPowerStats.uidStats.clear();
-
NetworkStats networkStats = mNetworkStatsSupplier.get();
if (networkStats == null) {
return;
diff --git a/services/core/java/com/android/server/tracing/TracingServiceProxy.java b/services/core/java/com/android/server/tracing/TracingServiceProxy.java
index c1d92cf..68eb8eb 100644
--- a/services/core/java/com/android/server/tracing/TracingServiceProxy.java
+++ b/services/core/java/com/android/server/tracing/TracingServiceProxy.java
@@ -93,6 +93,7 @@
private final Context mContext;
private final PackageManager mPackageManager;
private final LruCache<ComponentName, ServiceConnector<IMessenger>> mCachedReporterServices;
+ private boolean mServicePublished = false;
private final ITracingServiceProxy.Stub mTracingServiceProxy = new ITracingServiceProxy.Stub() {
/**
@@ -122,9 +123,12 @@
public void onStart() {}
@Override
- public void onBootPhase(int phase) {
- if (phase == SystemService.PHASE_THIRD_PARTY_APPS_CAN_START) {
+ public void onUserUnlocking(@NonNull TargetUser user) {
+ // We need the device storage to be unlocked before we can accept and forward
+ // requests.
+ if (!mServicePublished) {
publishBinderService(TRACING_SERVICE_PROXY_BINDER_NAME, mTracingServiceProxy);
+ mServicePublished = true;
}
}
diff --git a/services/core/java/com/android/server/uri/UriPermission.java b/services/core/java/com/android/server/uri/UriPermission.java
index e406eb2..0d1f367 100644
--- a/services/core/java/com/android/server/uri/UriPermission.java
+++ b/services/core/java/com/android/server/uri/UriPermission.java
@@ -223,7 +223,9 @@
if (mWriteOwners != null && includingOwners) {
ownedModeFlags &= ~Intent.FLAG_GRANT_WRITE_URI_PERMISSION;
for (UriPermissionOwner r : mWriteOwners) {
- r.removeWritePermission(this);
+ if (r != null) {
+ r.removeWritePermission(this);
+ }
}
mWriteOwners = null;
}
@@ -348,7 +350,7 @@
if (mWriteOwners != null) {
pw.print(prefix);
pw.println("writeOwners:");
- for (UriPermissionOwner owner : mReadOwners) {
+ for (UriPermissionOwner owner : mWriteOwners) {
pw.print(prefix);
pw.println(" * " + owner);
}
diff --git a/services/core/java/com/android/server/vibrator/HalVibration.java b/services/core/java/com/android/server/vibrator/HalVibration.java
index 8f755f4..f9bad59 100644
--- a/services/core/java/com/android/server/vibrator/HalVibration.java
+++ b/services/core/java/com/android/server/vibrator/HalVibration.java
@@ -133,6 +133,7 @@
// Save scale values for debugging purposes.
mScaleLevel = scaler.getScaleLevel(vibrationUsage);
mAdaptiveScale = scaler.getAdaptiveHapticsScale(vibrationUsage);
+ stats.reportAdaptiveScale(mAdaptiveScale);
// Scale all VibrationEffect instances in given CombinedVibration.
CombinedVibration newEffect = mEffectToPlay.transform(scaler::scale, vibrationUsage);
diff --git a/services/core/java/com/android/server/vibrator/VibrationStats.java b/services/core/java/com/android/server/vibrator/VibrationStats.java
index 2d00351..dd66809 100644
--- a/services/core/java/com/android/server/vibrator/VibrationStats.java
+++ b/services/core/java/com/android/server/vibrator/VibrationStats.java
@@ -61,6 +61,10 @@
private int mEndedByUsage;
private int mInterruptedUsage;
+ // Vibration parameters.
+ // Set by VibrationThread only (single-threaded).
+ private float mAdaptiveScale;
+
// All following counters are set by VibrationThread only (single-threaded):
// Counts how many times the VibrationEffect was repeated.
private int mRepeatCount;
@@ -188,6 +192,14 @@
}
}
+ /** Report the adaptive scale that was applied to this vibration. */
+ void reportAdaptiveScale(float scale) {
+ // Only report adaptive scale if it was set for this vibration.
+ if (Float.compare(scale, VibrationScaler.ADAPTIVE_SCALE_NONE) != 0) {
+ mAdaptiveScale = scale;
+ }
+ }
+
/** Report the vibration has looped a few more times. */
void reportRepetition(int loops) {
mRepeatCount += loops;
@@ -287,6 +299,7 @@
public final int vibrationType;
public final int usage;
public final int status;
+ public final float adaptiveScale;
public final boolean endedBySameUid;
public final int endedByUsage;
public final int interruptedUsage;
@@ -316,6 +329,7 @@
this.vibrationType = vibrationType;
this.usage = usage;
this.status = status.getProtoEnumValue();
+ this.adaptiveScale = stats.mAdaptiveScale;
endedBySameUid = (uid == stats.mEndedByUid);
endedByUsage = stats.mEndedByUsage;
interruptedUsage = stats.mInterruptedUsage;
@@ -376,7 +390,7 @@
halOnCount, halOffCount, halPerformCount, halSetAmplitudeCount,
halSetExternalControlCount, halSupportedCompositionPrimitivesUsed,
halSupportedEffectsUsed, halUnsupportedCompositionPrimitivesUsed,
- halUnsupportedEffectsUsed, halCompositionSize, halPwleSize);
+ halUnsupportedEffectsUsed, halCompositionSize, halPwleSize, adaptiveScale);
}
private static int[] filteredKeys(SparseBooleanArray supportArray, boolean supported) {
diff --git a/services/core/java/com/android/server/vibrator/VibratorManagerService.java b/services/core/java/com/android/server/vibrator/VibratorManagerService.java
index 09c2493..3dcc7a6 100644
--- a/services/core/java/com/android/server/vibrator/VibratorManagerService.java
+++ b/services/core/java/com/android/server/vibrator/VibratorManagerService.java
@@ -1628,6 +1628,12 @@
mStatus = Vibration.Status.RUNNING;
}
+ public void scale(VibrationScaler scaler, int usage) {
+ scale.scaleLevel = scaler.getScaleLevel(usage);
+ scale.adaptiveHapticsScale = scaler.getAdaptiveHapticsScale(usage);
+ stats.reportAdaptiveScale(scale.adaptiveHapticsScale);
+ }
+
public void mute() {
externalVibration.mute();
}
@@ -2044,9 +2050,7 @@
mCurrentExternalVibration = vibHolder;
vibHolder.linkToDeath();
- vibHolder.scale.scaleLevel = mVibrationScaler.getScaleLevel(attrs.getUsage());
- vibHolder.scale.adaptiveHapticsScale =
- mVibrationScaler.getAdaptiveHapticsScale(attrs.getUsage());
+ vibHolder.scale(mVibrationScaler, attrs.getUsage());
}
if (waitForCompletion) {
diff --git a/services/core/java/com/android/server/wm/AccessibilityWindowsPopulator.java b/services/core/java/com/android/server/wm/AccessibilityWindowsPopulator.java
index 3393d3e..d8e7c77 100644
--- a/services/core/java/com/android/server/wm/AccessibilityWindowsPopulator.java
+++ b/services/core/java/com/android/server/wm/AccessibilityWindowsPopulator.java
@@ -566,32 +566,35 @@
}
void dump(PrintWriter pw, String prefix) {
- pw.print(prefix); pw.println("AccessibilityWindowsPopulator");
- String prefix2 = prefix + " ";
+ synchronized (mLock) {
+ pw.print(prefix); pw.println("AccessibilityWindowsPopulator");
+ String prefix2 = prefix + " ";
- pw.print(prefix2); pw.print("mWindowsNotificationEnabled: ");
- pw.println(mWindowsNotificationEnabled);
+ pw.print(prefix2); pw.print("mWindowsNotificationEnabled: ");
+ pw.println(mWindowsNotificationEnabled);
- if (mVisibleWindows.isEmpty()) {
- pw.print(prefix2); pw.println("No visible windows");
- } else {
- pw.print(prefix2); pw.print(mVisibleWindows.size());
- pw.print(" visible windows: "); pw.println(mVisibleWindows);
+ if (mVisibleWindows.isEmpty()) {
+ pw.print(prefix2); pw.println("No visible windows");
+ } else {
+ pw.print(prefix2); pw.print(mVisibleWindows.size());
+ pw.print(" visible windows: "); pw.println(mVisibleWindows);
+ }
+ KeyDumper noKeyDumper = (i, k) -> {}; // display id is already shown on value;
+ KeyDumper displayDumper = (i, d) -> pw.printf("%sDisplay #%d: ", prefix, d);
+ // Ideally magnificationSpecDumper should use spec.dump(pw), but there is no such method
+ ValueDumper<MagnificationSpec> magnificationSpecDumper = spec -> pw.print(spec);
+
+ dumpSparseArray(pw, prefix2, mDisplayInfos,
+ "display info", noKeyDumper, d -> pw.print(d));
+ dumpSparseArray(pw, prefix2, mInputWindowHandlesOnDisplays,
+ "window handles on display", displayDumper, list -> pw.print(list));
+ dumpSparseArray(pw, prefix2, mMagnificationSpecInverseMatrix,
+ "magnification spec matrix", noKeyDumper, matrix -> matrix.dump(pw));
+ dumpSparseArray(pw, prefix2, mCurrentMagnificationSpec,
+ "current magnification spec", noKeyDumper, magnificationSpecDumper);
+ dumpSparseArray(pw, prefix2, mPreviousMagnificationSpec,
+ "previous magnification spec", noKeyDumper, magnificationSpecDumper);
}
- KeyDumper noKeyDumper = (i, k) -> {}; // display id is already shown on value;
- KeyDumper displayDumper = (i, d) -> pw.printf("%sDisplay #%d: ", prefix, d);
- // Ideally magnificationSpecDumper should use spec.dump(pw), but there is no such method
- ValueDumper<MagnificationSpec> magnificationSpecDumper = spec -> pw.print(spec);
-
- dumpSparseArray(pw, prefix2, mDisplayInfos, "display info", noKeyDumper, d -> pw.print(d));
- dumpSparseArray(pw, prefix2, mInputWindowHandlesOnDisplays, "window handles on display",
- displayDumper, list -> pw.print(list));
- dumpSparseArray(pw, prefix2, mMagnificationSpecInverseMatrix, "magnification spec matrix",
- noKeyDumper, matrix -> matrix.dump(pw));
- dumpSparseArray(pw, prefix2, mCurrentMagnificationSpec, "current magnification spec",
- noKeyDumper, magnificationSpecDumper);
- dumpSparseArray(pw, prefix2, mPreviousMagnificationSpec, "previous magnification spec",
- noKeyDumper, magnificationSpecDumper);
}
@GuardedBy("mLock")
diff --git a/services/core/java/com/android/server/wm/ActivitySecurityModelFeatureFlags.java b/services/core/java/com/android/server/wm/ActivitySecurityModelFeatureFlags.java
index 4149bd9..351dc3a 100644
--- a/services/core/java/com/android/server/wm/ActivitySecurityModelFeatureFlags.java
+++ b/services/core/java/com/android/server/wm/ActivitySecurityModelFeatureFlags.java
@@ -41,7 +41,7 @@
static final String DOC_LINK = "go/android-asm";
/** Used to determine which version of the ASM logic was used in logs while we iterate */
- static final int ASM_VERSION = 10;
+ static final int ASM_VERSION = 11;
private static final String NAMESPACE = NAMESPACE_WINDOW_MANAGER;
private static final String KEY_ASM_PREFIX = "ActivitySecurity__";
diff --git a/services/core/java/com/android/server/wm/BackgroundActivityStartController.java b/services/core/java/com/android/server/wm/BackgroundActivityStartController.java
index ac2c886..19d7a3c 100644
--- a/services/core/java/com/android/server/wm/BackgroundActivityStartController.java
+++ b/services/core/java/com/android/server/wm/BackgroundActivityStartController.java
@@ -31,6 +31,7 @@
import static android.os.Process.ROOT_UID;
import static android.os.Process.SYSTEM_UID;
import static android.provider.DeviceConfig.NAMESPACE_WINDOW_MANAGER;
+import static android.security.Flags.asmOptSystemIntoEnforcement;
import static com.android.server.wm.ActivityStarter.ASM_RESTRICTIONS;
import static com.android.server.wm.ActivityTaskManagerDebugConfig.DEBUG_ACTIVITY_STARTS;
@@ -1462,13 +1463,18 @@
return bas.matchesSource();
}
+ if (ar.isUid(SYSTEM_UID)) {
+ if (asmOptSystemIntoEnforcement()) {
+ return bas.optedIn(ar);
+ } else {
+ return bas;
+ }
+ }
+
if (!CompatChanges.isChangeEnabled(ASM_RESTRICTIONS, ar.getUid())) {
return bas;
}
- if (ar.isUid(SYSTEM_UID)) {
- return bas.optedIn(ar);
- }
String packageName = ar.packageName;
if (packageName == null) {
@@ -1566,6 +1572,7 @@
joiner.add(prefix + "Allowed By Grace Period: " + allowedByGracePeriod);
joiner.add(prefix + "LastResumedActivity: "
+ recordToString.apply(mService.mLastResumedActivity));
+ joiner.add(prefix + "System opted into enforcement: " + asmOptSystemIntoEnforcement());
if (mTopFinishedActivity != null) {
joiner.add(prefix + "TopFinishedActivity: " + mTopFinishedActivity.mDebugInfo);
diff --git a/services/core/java/com/android/server/wm/Task.java b/services/core/java/com/android/server/wm/Task.java
index 6c48e95..69a8aed 100644
--- a/services/core/java/com/android/server/wm/Task.java
+++ b/services/core/java/com/android/server/wm/Task.java
@@ -4563,7 +4563,10 @@
}
final WindowState w = getTopVisibleAppMainWindow();
if (w != null) {
+ w.mIsSurfacePositionPaused = true;
w.applyWithNextDraw((d) -> {
+ w.mIsSurfacePositionPaused = false;
+ w.updateSurfacePosition(d);
d.merge(t);
});
} else {
diff --git a/services/core/java/com/android/server/wm/Transition.java b/services/core/java/com/android/server/wm/Transition.java
index c972eee..218334e 100644
--- a/services/core/java/com/android/server/wm/Transition.java
+++ b/services/core/java/com/android/server/wm/Transition.java
@@ -43,6 +43,7 @@
import static android.view.WindowManager.TransitionType;
import static android.view.WindowManager.transitTypeToString;
import static android.window.TaskFragmentAnimationParams.DEFAULT_ANIMATION_BACKGROUND_COLOR;
+import static android.window.TransitionInfo.AnimationOptions;
import static android.window.TransitionInfo.FLAGS_IS_OCCLUDED_NO_ANIMATION;
import static android.window.TransitionInfo.FLAG_CONFIG_AT_END;
import static android.window.TransitionInfo.FLAG_DISPLAY_HAS_ALERT_WINDOWS;
@@ -105,6 +106,7 @@
import com.android.internal.util.function.pooled.PooledLambda;
import com.android.server.inputmethod.InputMethodManagerInternal;
import com.android.server.statusbar.StatusBarManagerInternal;
+import com.android.window.flags.Flags;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
@@ -239,7 +241,8 @@
private ArrayList<Runnable> mTransitionEndedListeners = null;
/** Custom activity-level animation options and callbacks. */
- private TransitionInfo.AnimationOptions mOverrideOptions;
+ private AnimationOptions mOverrideOptions;
+
private IRemoteCallback mClientAnimationStartCallback = null;
private IRemoteCallback mClientAnimationFinishCallback = null;
@@ -320,6 +323,7 @@
*/
ArrayList<ActivityRecord> mConfigAtEndActivities = null;
+ @VisibleForTesting
Transition(@TransitionType int type, @TransitionFlags int flags,
TransitionController controller, BLASTSyncEngine syncEngine) {
mType = type;
@@ -911,7 +915,7 @@
* Set animation options for collecting transition by ActivityRecord.
* @param options AnimationOptions captured from ActivityOptions
*/
- void setOverrideAnimation(TransitionInfo.AnimationOptions options,
+ void setOverrideAnimation(@Nullable AnimationOptions options,
@Nullable IRemoteCallback startCallback, @Nullable IRemoteCallback finishCallback) {
if (!isCollecting()) return;
mOverrideOptions = options;
@@ -1754,23 +1758,7 @@
mController.mValidateDisplayVis.add(da);
}
}
-
- if (mOverrideOptions != null) {
- info.setAnimationOptions(mOverrideOptions);
- if (mOverrideOptions.getType() == ANIM_OPEN_CROSS_PROFILE_APPS) {
- for (int i = 0; i < mTargets.size(); ++i) {
- final TransitionInfo.Change c = info.getChanges().get(i);
- final ActivityRecord ar = mTargets.get(i).mContainer.asActivityRecord();
- if (ar == null || c.getMode() != TRANSIT_OPEN) continue;
- int flags = c.getFlags();
- flags |= ar.mUserId == ar.mWmService.mCurrentUserId
- ? TransitionInfo.FLAG_CROSS_PROFILE_OWNER_THUMBNAIL
- : TransitionInfo.FLAG_CROSS_PROFILE_WORK_THUMBNAIL;
- c.setFlags(flags);
- break;
- }
- }
- }
+ overrideAnimationOptionsToInfoIfNecessary(info);
// TODO(b/188669821): Move to animation impl in shell.
for (int i = 0; i < mTargetDisplays.size(); ++i) {
@@ -1893,6 +1881,49 @@
}
}
+ private void overrideAnimationOptionsToInfoIfNecessary(@NonNull TransitionInfo info) {
+ if (mOverrideOptions == null) {
+ return;
+ }
+
+ if (!Flags.moveAnimationOptionsToChange()) {
+ info.setAnimationOptions(mOverrideOptions);
+ } else {
+ final List<TransitionInfo.Change> changes = info.getChanges();
+ for (int i = changes.size() - 1; i >= 0; --i) {
+ if (mTargets.get(i).mContainer.asActivityRecord() != null) {
+ changes.get(i).setAnimationOptions(mOverrideOptions);
+ }
+ }
+ }
+ updateActivityTargetForCrossProfileAnimation(info);
+ }
+
+ /**
+ * Updates activity open target if {@link #mOverrideOptions} is
+ * {@link ANIM_OPEN_CROSS_PROFILE_APPS}.
+ */
+ private void updateActivityTargetForCrossProfileAnimation(@NonNull TransitionInfo info) {
+ if (mOverrideOptions.getType() != ANIM_OPEN_CROSS_PROFILE_APPS) {
+ return;
+ }
+ for (int i = 0; i < mTargets.size(); ++i) {
+ final ActivityRecord activity = mTargets.get(i).mContainer
+ .asActivityRecord();
+ final TransitionInfo.Change change = info.getChanges().get(i);
+ if (activity == null || change.getMode() != TRANSIT_OPEN) {
+ continue;
+ }
+
+ int flags = change.getFlags();
+ flags |= activity.mUserId == activity.mWmService.mCurrentUserId
+ ? TransitionInfo.FLAG_CROSS_PROFILE_OWNER_THUMBNAIL
+ : TransitionInfo.FLAG_CROSS_PROFILE_WORK_THUMBNAIL;
+ change.setFlags(flags);
+ break;
+ }
+ }
+
@Override
public void onTransactionCommitTimeout() {
if (mCleanupTransaction == null) return;
@@ -2697,6 +2728,12 @@
return out;
}
+ final AnimationOptions animOptions = calculateAnimationOptionsForActivityTransition(type,
+ sortedTargets);
+ if (!Flags.moveAnimationOptionsToChange() && animOptions != null) {
+ out.setAnimationOptions(animOptions);
+ }
+
// Convert all the resolved ChangeInfos into TransactionInfo.Change objects in order.
final int count = sortedTargets.size();
for (int i = 0; i < count; ++i) {
@@ -2786,6 +2823,11 @@
change.setBackgroundColor(ColorUtils.setAlphaComponent(backgroundColor, 255));
}
+ if (Flags.moveAnimationOptionsToChange() && activityRecord != null
+ && animOptions != null) {
+ change.setAnimationOptions(animOptions);
+ }
+
if (activityRecord != null) {
change.setActivityComponent(activityRecord.mActivityComponent);
}
@@ -2797,11 +2839,26 @@
out.addChange(change);
}
+ return out;
+ }
+ /**
+ * Calculates {@link AnimationOptions} for activity-to-activity transition.
+ * It returns a valid {@link AnimationOptions} if:
+ * <ul>
+ * <li>the top animation target is an Activity</li>
+ * <li>there's a {@link android.view.Window#setWindowAnimations(int)} and there's only
+ * {@link WindowState}, {@link WindowToken} and {@link ActivityRecord} target</li>
+ * </ul>
+ * Otherwise, it returns {@code null}.
+ */
+ @Nullable
+ private static AnimationOptions calculateAnimationOptionsForActivityTransition(
+ @TransitionType int type, @NonNull ArrayList<ChangeInfo> sortedTargets) {
TransitionInfo.AnimationOptions animOptions = null;
- // Check if the top-most app is an activity (ie. activity->activity). If so, make sure to
- // honor its custom transition options.
+ // Check if the top-most app is an activity (ie. activity->activity). If so, make sure
+ // to honor its custom transition options.
WindowContainer<?> topApp = null;
for (int i = 0; i < sortedTargets.size(); i++) {
if (isWallpaper(sortedTargets.get(i).mContainer)) continue;
@@ -2810,16 +2867,18 @@
}
if (topApp.asActivityRecord() != null) {
final ActivityRecord topActivity = topApp.asActivityRecord();
- animOptions = addCustomActivityTransition(topActivity, true/* open */, null);
- animOptions = addCustomActivityTransition(topActivity, false/* open */, animOptions);
+ animOptions = addCustomActivityTransition(topActivity, true/* open */,
+ null /* animOptions */);
+ animOptions = addCustomActivityTransition(topActivity, false/* open */,
+ animOptions);
}
final WindowManager.LayoutParams animLp =
getLayoutParamsForAnimationsStyle(type, sortedTargets);
if (animLp != null && animLp.type != TYPE_APPLICATION_STARTING
&& animLp.windowAnimations != 0) {
- // Don't send animation options if no windowAnimations have been set or if the we are
- // running an app starting animation, in which case we don't want the app to be able to
- // change its animation directly.
+ // Don't send animation options if no windowAnimations have been set or if the we
+ // are running an app starting animation, in which case we don't want the app to be
+ // able to change its animation directly.
if (animOptions != null) {
animOptions.addOptionsFromLayoutParameters(animLp);
} else {
@@ -2827,20 +2886,29 @@
.makeAnimOptionsFromLayoutParameters(animLp);
}
}
- if (animOptions != null) {
- out.setAnimationOptions(animOptions);
- }
- return out;
+ return animOptions;
}
- static TransitionInfo.AnimationOptions addCustomActivityTransition(ActivityRecord topActivity,
- boolean open, TransitionInfo.AnimationOptions animOptions) {
+ /**
+ * Returns {@link TransitionInfo.AnimationOptions} with custom Activity transition appended if
+ * {@code topActivity} specifies {@link ActivityRecord#getCustomAnimation(boolean)}, or
+ * {@code animOptions}, otherwise.
+ * <p>
+ * If the passed {@code animOptions} is {@code null}, this method will creates an
+ * {@link TransitionInfo.AnimationOptions} with custom animation appended
+ *
+ * @param open {@code true} to add a custom open animation, and {@false} to add a close one
+ */
+ @Nullable
+ private static TransitionInfo.AnimationOptions addCustomActivityTransition(
+ @NonNull ActivityRecord activity, boolean open,
+ @Nullable TransitionInfo.AnimationOptions animOptions) {
final ActivityRecord.CustomAppTransition customAnim =
- topActivity.getCustomAnimation(open);
+ activity.getCustomAnimation(open);
if (customAnim != null) {
if (animOptions == null) {
animOptions = TransitionInfo.AnimationOptions
- .makeCommonAnimOptions(topActivity.packageName);
+ .makeCommonAnimOptions(activity.packageName);
}
animOptions.addCustomActivityTransition(open, customAnim.mEnterAnim,
customAnim.mExitAnim, customAnim.mBackgroundColor);
diff --git a/services/core/java/com/android/server/wm/WindowManagerService.java b/services/core/java/com/android/server/wm/WindowManagerService.java
index a00b6fc4..753f481 100644
--- a/services/core/java/com/android/server/wm/WindowManagerService.java
+++ b/services/core/java/com/android/server/wm/WindowManagerService.java
@@ -2645,9 +2645,6 @@
if (displayPolicy.areSystemBarsForcedConsumedLw()) {
result |= WindowManagerGlobal.RELAYOUT_RES_CONSUME_ALWAYS_SYSTEM_BARS;
}
- if (!win.isGoneForLayout()) {
- win.mResizedWhileGone = false;
- }
if (outFrames != null && outMergedConfiguration != null) {
final boolean shouldReportActivityWindowInfo;
diff --git a/services/core/java/com/android/server/wm/WindowOrganizerController.java b/services/core/java/com/android/server/wm/WindowOrganizerController.java
index 6221d96..7eda53f 100644
--- a/services/core/java/com/android/server/wm/WindowOrganizerController.java
+++ b/services/core/java/com/android/server/wm/WindowOrganizerController.java
@@ -839,9 +839,14 @@
}
private int applyTaskChanges(Task tr, WindowContainerTransaction.Change c) {
- int effects = applyChanges(tr, c);
final SurfaceControl.Transaction t = c.getBoundsChangeTransaction();
+ // Check bounds change transaction at the beginning because it may pause updating window
+ // surface position. Then the following changes won't apply intermediate position.
+ if (t != null) {
+ tr.setMainWindowSizeChangeTransaction(t);
+ }
+ int effects = applyChanges(tr, c);
if ((c.getChangeMask() & WindowContainerTransaction.Change.CHANGE_HIDDEN) != 0) {
if (tr.setForceHidden(FLAG_FORCE_HIDDEN_FOR_TASK_ORG, c.getHidden())) {
effects |= TRANSACT_EFFECTS_LIFECYCLE;
@@ -874,10 +879,6 @@
tr.forAllActivities(a -> { a.setWindowingMode(childWindowingMode); });
}
- if (t != null) {
- tr.setMainWindowSizeChangeTransaction(t);
- }
-
Rect enterPipBounds = c.getEnterPipBounds();
if (enterPipBounds != null) {
tr.mDisplayContent.mPinnedTaskController.setEnterPipBounds(enterPipBounds);
diff --git a/services/core/java/com/android/server/wm/WindowState.java b/services/core/java/com/android/server/wm/WindowState.java
index d1efc27..5f0498b 100644
--- a/services/core/java/com/android/server/wm/WindowState.java
+++ b/services/core/java/com/android/server/wm/WindowState.java
@@ -670,9 +670,10 @@
private final Transaction mTmpTransaction;
/**
- * Whether the window was resized by us while it was gone for layout.
+ * Whether the surface position of window is paused to update. Currently it is only used for
+ * {@link Task#setMainWindowSizeChangeTransaction(Transaction)} to synchronize position.
*/
- boolean mResizedWhileGone = false;
+ boolean mIsSurfacePositionPaused;
/**
* During seamless rotation we have two phases, first the old window contents
@@ -2192,9 +2193,6 @@
ProtoLog.d(WM_DEBUG_RESIZE, "onResize: Resizing %s", this);
resizingWindows.add(this);
}
- if (isGoneForLayout()) {
- mResizedWhileGone = true;
- }
super.onResize();
}
@@ -4191,6 +4189,9 @@
pw.println(prefix + "mHasSurface=" + mHasSurface
+ " isReadyForDisplay()=" + isReadyForDisplay()
+ " mWindowRemovalAllowed=" + mWindowRemovalAllowed);
+ if (mIsSurfacePositionPaused) {
+ pw.println(prefix + "mIsSurfacePositionPaused=true");
+ }
if (mInvGlobalScale != 1f) {
pw.println(prefix + "mCompatFrame=" + mWindowFrames.mCompatFrame.toShortString(sTmpSB));
}
@@ -5283,7 +5284,7 @@
@Override
@VisibleForTesting
void updateSurfacePosition(Transaction t) {
- if (mSurfaceControl == null) {
+ if (mSurfaceControl == null || mIsSurfacePositionPaused) {
return;
}
if (mActivityRecord != null && mActivityRecord.isConfigurationDispatchPaused()) {
diff --git a/services/devicepolicy/java/com/android/server/devicepolicy/PersonalAppsSuspensionHelper.java b/services/devicepolicy/java/com/android/server/devicepolicy/PersonalAppsSuspensionHelper.java
index 7483b43..c7fd979 100644
--- a/services/devicepolicy/java/com/android/server/devicepolicy/PersonalAppsSuspensionHelper.java
+++ b/services/devicepolicy/java/com/android/server/devicepolicy/PersonalAppsSuspensionHelper.java
@@ -202,9 +202,9 @@
private String getDefaultSmsPackage() {
//TODO(b/319449037): Unflag the following change.
if (Flags.defaultSmsPersonalAppSuspensionFixEnabled()) {
- return SmsApplication.getDefaultSmsApplicationAsUser(
- mContext, /*updateIfNeeded=*/ false, mContext.getUser())
- .getPackageName();
+ ComponentName defaultSmsApp = SmsApplication.getDefaultSmsApplicationAsUser(
+ mContext, /*updateIfNeeded=*/ false, mContext.getUser());
+ return defaultSmsApp != null ? defaultSmsApp.getPackageName() : null;
} else {
return Telephony.Sms.getDefaultSmsPackage(mContext);
}
diff --git a/services/tests/displayservicetests/src/com/android/server/display/DisplayBrightnessStateTest.java b/services/tests/displayservicetests/src/com/android/server/display/DisplayBrightnessStateTest.java
index 8db896b..bba4c8d 100644
--- a/services/tests/displayservicetests/src/com/android/server/display/DisplayBrightnessStateTest.java
+++ b/services/tests/displayservicetests/src/com/android/server/display/DisplayBrightnessStateTest.java
@@ -58,6 +58,7 @@
.setShouldUseAutoBrightness(shouldUseAutoBrightness)
.setShouldUpdateScreenBrightnessSetting(shouldUpdateScreenBrightnessSetting)
.setBrightnessAdjustmentFlag(brightnessAdjustmentFlag)
+ .setIsUserInitiatedChange(true)
.build();
assertEquals(displayBrightnessState.getBrightness(), brightness, FLOAT_DELTA);
@@ -109,7 +110,9 @@
.append("\n mBrightnessEvent:")
.append(Objects.toString(displayBrightnessState.getBrightnessEvent(), "null"))
.append("\n mBrightnessAdjustmentFlag:")
- .append(displayBrightnessState.getBrightnessAdjustmentFlag());
+ .append(displayBrightnessState.getBrightnessAdjustmentFlag())
+ .append("\n mIsUserInitiatedChange:")
+ .append(displayBrightnessState.isUserInitiatedChange());
return sb.toString();
}
}
diff --git a/services/tests/displayservicetests/src/com/android/server/display/brightness/DisplayBrightnessControllerTest.java b/services/tests/displayservicetests/src/com/android/server/display/brightness/DisplayBrightnessControllerTest.java
index c5105e7..323ef6a 100644
--- a/services/tests/displayservicetests/src/com/android/server/display/brightness/DisplayBrightnessControllerTest.java
+++ b/services/tests/displayservicetests/src/com/android/server/display/brightness/DisplayBrightnessControllerTest.java
@@ -121,7 +121,8 @@
any(StrategySelectionRequest.class))).thenReturn(displayBrightnessStrategy);
mDisplayBrightnessController.updateBrightness(displayPowerRequest, targetDisplayState);
verify(displayBrightnessStrategy).updateBrightness(
- eq(new StrategyExecutionRequest(displayPowerRequest, DEFAULT_BRIGHTNESS)));
+ eq(new StrategyExecutionRequest(displayPowerRequest, DEFAULT_BRIGHTNESS,
+ /* userSetBrightnessChanged= */ false)));
assertEquals(mDisplayBrightnessController.getCurrentDisplayBrightnessStrategy(),
displayBrightnessStrategy);
}
diff --git a/services/tests/displayservicetests/src/com/android/server/display/brightness/strategy/AutoBrightnessFallbackStrategyTest.java b/services/tests/displayservicetests/src/com/android/server/display/brightness/strategy/AutoBrightnessFallbackStrategyTest.java
index 7a6a911..4d5ff55 100644
--- a/services/tests/displayservicetests/src/com/android/server/display/brightness/strategy/AutoBrightnessFallbackStrategyTest.java
+++ b/services/tests/displayservicetests/src/com/android/server/display/brightness/strategy/AutoBrightnessFallbackStrategyTest.java
@@ -115,7 +115,8 @@
.build();
DisplayBrightnessState updatedDisplayBrightnessState =
mAutoBrightnessFallbackStrategy.updateBrightness(
- new StrategyExecutionRequest(displayPowerRequest, 0.2f));
+ new StrategyExecutionRequest(displayPowerRequest, 0.2f,
+ /* userSetBrightnessChanged= */ false));
assertEquals(updatedDisplayBrightnessState, expectedDisplayBrightnessState);
}
diff --git a/services/tests/displayservicetests/src/com/android/server/display/brightness/strategy/AutomaticBrightnessStrategyTest.java b/services/tests/displayservicetests/src/com/android/server/display/brightness/strategy/AutomaticBrightnessStrategyTest.java
index afb5a5c..8a33f34 100644
--- a/services/tests/displayservicetests/src/com/android/server/display/brightness/strategy/AutomaticBrightnessStrategyTest.java
+++ b/services/tests/displayservicetests/src/com/android/server/display/brightness/strategy/AutomaticBrightnessStrategyTest.java
@@ -513,9 +513,11 @@
.setBrightnessEvent(brightnessEvent)
.setBrightnessAdjustmentFlag(BrightnessReason.ADJUSTMENT_AUTO)
.setShouldUpdateScreenBrightnessSetting(true)
+ .setIsUserInitiatedChange(true)
.build();
DisplayBrightnessState actualDisplayBrightnessState = mAutomaticBrightnessStrategy
- .updateBrightness(new StrategyExecutionRequest(displayPowerRequest, 0.6f));
+ .updateBrightness(new StrategyExecutionRequest(displayPowerRequest, 0.6f,
+ /* userSetBrightnessChanged= */ true));
assertEquals(expectedDisplayBrightnessState, actualDisplayBrightnessState);
}
@@ -560,9 +562,11 @@
.setBrightnessEvent(brightnessEvent)
.setBrightnessAdjustmentFlag(BrightnessReason.ADJUSTMENT_AUTO_TEMP)
.setShouldUpdateScreenBrightnessSetting(true)
+ .setIsUserInitiatedChange(true)
.build();
DisplayBrightnessState actualDisplayBrightnessState = mAutomaticBrightnessStrategy
- .updateBrightness(new StrategyExecutionRequest(displayPowerRequest, 0.6f));
+ .updateBrightness(new StrategyExecutionRequest(displayPowerRequest, 0.6f,
+ /* userSetBrightnessChanged= */ true));
assertEquals(expectedDisplayBrightnessState, actualDisplayBrightnessState);
}
diff --git a/services/tests/displayservicetests/src/com/android/server/display/brightness/strategy/BoostBrightnessStrategyTest.java b/services/tests/displayservicetests/src/com/android/server/display/brightness/strategy/BoostBrightnessStrategyTest.java
index 47f1746..3534325 100644
--- a/services/tests/displayservicetests/src/com/android/server/display/brightness/strategy/BoostBrightnessStrategyTest.java
+++ b/services/tests/displayservicetests/src/com/android/server/display/brightness/strategy/BoostBrightnessStrategyTest.java
@@ -60,7 +60,8 @@
.build();
DisplayBrightnessState updatedDisplayBrightnessState =
mBoostBrightnessStrategy.updateBrightness(
- new StrategyExecutionRequest(displayPowerRequest, 0.2f));
+ new StrategyExecutionRequest(displayPowerRequest, 0.2f,
+ /* userSetBrightnessChanged= */ false));
assertEquals(updatedDisplayBrightnessState, expectedDisplayBrightnessState);
}
diff --git a/services/tests/displayservicetests/src/com/android/server/display/brightness/strategy/DozeBrightnessStrategyTest.java b/services/tests/displayservicetests/src/com/android/server/display/brightness/strategy/DozeBrightnessStrategyTest.java
index 9246780..bd6d8be 100644
--- a/services/tests/displayservicetests/src/com/android/server/display/brightness/strategy/DozeBrightnessStrategyTest.java
+++ b/services/tests/displayservicetests/src/com/android/server/display/brightness/strategy/DozeBrightnessStrategyTest.java
@@ -57,7 +57,8 @@
.build();
DisplayBrightnessState updatedDisplayBrightnessState =
mDozeBrightnessModeStrategy.updateBrightness(
- new StrategyExecutionRequest(displayPowerRequest, 0.2f));
+ new StrategyExecutionRequest(displayPowerRequest, 0.2f,
+ /* userSetBrightnessChanged= */ false));
assertEquals(updatedDisplayBrightnessState, expectedDisplayBrightnessState);
}
}
diff --git a/services/tests/displayservicetests/src/com/android/server/display/brightness/strategy/FallbackBrightnessStrategyTest.java b/services/tests/displayservicetests/src/com/android/server/display/brightness/strategy/FallbackBrightnessStrategyTest.java
index c4767ae..4cae35d 100644
--- a/services/tests/displayservicetests/src/com/android/server/display/brightness/strategy/FallbackBrightnessStrategyTest.java
+++ b/services/tests/displayservicetests/src/com/android/server/display/brightness/strategy/FallbackBrightnessStrategyTest.java
@@ -57,10 +57,12 @@
.setSdrBrightness(currentBrightness)
.setDisplayBrightnessStrategyName(mFallbackBrightnessStrategy.getName())
.setShouldUpdateScreenBrightnessSetting(true)
+ .setIsUserInitiatedChange(true)
.build();
DisplayBrightnessState updatedDisplayBrightnessState =
mFallbackBrightnessStrategy.updateBrightness(
- new StrategyExecutionRequest(displayPowerRequest, currentBrightness));
+ new StrategyExecutionRequest(displayPowerRequest, currentBrightness,
+ /* userSetBrightnessChanged= */ true));
assertEquals(updatedDisplayBrightnessState, expectedDisplayBrightnessState);
}
}
diff --git a/services/tests/displayservicetests/src/com/android/server/display/brightness/strategy/FollowerBrightnessStrategyTest.java b/services/tests/displayservicetests/src/com/android/server/display/brightness/strategy/FollowerBrightnessStrategyTest.java
index 682c9cc..fdaf8f6 100644
--- a/services/tests/displayservicetests/src/com/android/server/display/brightness/strategy/FollowerBrightnessStrategyTest.java
+++ b/services/tests/displayservicetests/src/com/android/server/display/brightness/strategy/FollowerBrightnessStrategyTest.java
@@ -61,7 +61,8 @@
.build();
DisplayBrightnessState updatedDisplayBrightnessState =
mFollowerBrightnessStrategy.updateBrightness(
- new StrategyExecutionRequest(displayPowerRequest, 0.2f));
+ new StrategyExecutionRequest(displayPowerRequest, 0.2f,
+ /* userSetBrightnessChanged= */ false));
assertEquals(expectedDisplayBrightnessState, updatedDisplayBrightnessState);
}
diff --git a/services/tests/displayservicetests/src/com/android/server/display/brightness/strategy/OffloadBrightnessStrategyTest.java b/services/tests/displayservicetests/src/com/android/server/display/brightness/strategy/OffloadBrightnessStrategyTest.java
index ccf6309..e3c2760 100644
--- a/services/tests/displayservicetests/src/com/android/server/display/brightness/strategy/OffloadBrightnessStrategyTest.java
+++ b/services/tests/displayservicetests/src/com/android/server/display/brightness/strategy/OffloadBrightnessStrategyTest.java
@@ -72,7 +72,8 @@
.build();
DisplayBrightnessState updatedDisplayBrightnessState =
mOffloadBrightnessStrategy.updateBrightness(
- new StrategyExecutionRequest(displayPowerRequest, 0.2f));
+ new StrategyExecutionRequest(displayPowerRequest, 0.2f,
+ /* userSetBrightnessChanged= */ false));
assertEquals(updatedDisplayBrightnessState, expectedDisplayBrightnessState);
assertEquals(PowerManager.BRIGHTNESS_INVALID_FLOAT, mOffloadBrightnessStrategy
.getOffloadScreenBrightness(), 0.0f);
diff --git a/services/tests/displayservicetests/src/com/android/server/display/brightness/strategy/OverrideBrightnessStrategyTest.java b/services/tests/displayservicetests/src/com/android/server/display/brightness/strategy/OverrideBrightnessStrategyTest.java
index 8e7b463..ebe407b 100644
--- a/services/tests/displayservicetests/src/com/android/server/display/brightness/strategy/OverrideBrightnessStrategyTest.java
+++ b/services/tests/displayservicetests/src/com/android/server/display/brightness/strategy/OverrideBrightnessStrategyTest.java
@@ -60,7 +60,8 @@
.build();
DisplayBrightnessState updatedDisplayBrightnessState =
mOverrideBrightnessStrategy.updateBrightness(
- new StrategyExecutionRequest(displayPowerRequest, 0.2f));
+ new StrategyExecutionRequest(displayPowerRequest, 0.2f,
+ /* userSetBrightnessChanged= */ false));
assertEquals(updatedDisplayBrightnessState, expectedDisplayBrightnessState);
}
diff --git a/services/tests/displayservicetests/src/com/android/server/display/brightness/strategy/ScreenOffBrightnessStrategyTest.java b/services/tests/displayservicetests/src/com/android/server/display/brightness/strategy/ScreenOffBrightnessStrategyTest.java
index e799d0e..4bad569 100644
--- a/services/tests/displayservicetests/src/com/android/server/display/brightness/strategy/ScreenOffBrightnessStrategyTest.java
+++ b/services/tests/displayservicetests/src/com/android/server/display/brightness/strategy/ScreenOffBrightnessStrategyTest.java
@@ -58,7 +58,8 @@
.build();
DisplayBrightnessState updatedDisplayBrightnessState =
mScreenOffBrightnessModeStrategy.updateBrightness(
- new StrategyExecutionRequest(displayPowerRequest, 0.2f));
+ new StrategyExecutionRequest(displayPowerRequest, 0.2f,
+ /* userSetBrightnessChanged= */ false));
assertEquals(updatedDisplayBrightnessState, expectedDisplayBrightnessState);
}
}
diff --git a/services/tests/displayservicetests/src/com/android/server/display/brightness/strategy/TemporaryBrightnessStrategyTest.java b/services/tests/displayservicetests/src/com/android/server/display/brightness/strategy/TemporaryBrightnessStrategyTest.java
index aaada41..5410a20 100644
--- a/services/tests/displayservicetests/src/com/android/server/display/brightness/strategy/TemporaryBrightnessStrategyTest.java
+++ b/services/tests/displayservicetests/src/com/android/server/display/brightness/strategy/TemporaryBrightnessStrategyTest.java
@@ -60,7 +60,8 @@
.build();
DisplayBrightnessState updatedDisplayBrightnessState =
mTemporaryBrightnessStrategy.updateBrightness(
- new StrategyExecutionRequest(displayPowerRequest, 0.2f));
+ new StrategyExecutionRequest(displayPowerRequest, 0.2f,
+ /* userSetBrightnessChanged= */ false));
assertEquals(updatedDisplayBrightnessState, expectedDisplayBrightnessState);
}
diff --git a/services/tests/displayservicetests/src/com/android/server/display/mode/AppRequestObserverTest.kt b/services/tests/displayservicetests/src/com/android/server/display/mode/AppRequestObserverTest.kt
index cf6146f..34c6ba9 100644
--- a/services/tests/displayservicetests/src/com/android/server/display/mode/AppRequestObserverTest.kt
+++ b/services/tests/displayservicetests/src/com/android/server/display/mode/AppRequestObserverTest.kt
@@ -117,11 +117,11 @@
BaseModeRefreshRateVote(60f), SizeVote(1000, 1000, 1000, 1000), RenderVote(60f, 90f)),
PREFERRED_REFRESH_RATE(false, 0, 60f, 0f, 0f,
BaseModeRefreshRateVote(60f), SizeVote(1000, 1000, 1000, 1000), null),
- PREFERRED_REFRESH_RATE_IGNORED(true, 0, 60f, 0f, 0f,
- null, null, null),
+ PREFERRED_REFRESH_RATE_IGNORE_BASE_MODE_CONVERSION(true, 0, 60f, 0f, 0f,
+ RequestedRefreshRateVote(60f), null, null),
PREFERRED_REFRESH_RATE_INVALID(false, 0, 25f, 0f, 0f,
null, null, null),
SYNTHETIC_MODE(false, 99, 0f, 0f, 0f,
- RenderVote(45f, 45f), SizeVote(1000, 1000, 1000, 1000), null),
+ RequestedRefreshRateVote(45f), SizeVote(1000, 1000, 1000, 1000), null),
}
}
\ No newline at end of file
diff --git a/services/tests/displayservicetests/src/com/android/server/display/mode/RequestedRefreshRateVoteTest.kt b/services/tests/displayservicetests/src/com/android/server/display/mode/RequestedRefreshRateVoteTest.kt
new file mode 100644
index 0000000..dbe9e4a
--- /dev/null
+++ b/services/tests/displayservicetests/src/com/android/server/display/mode/RequestedRefreshRateVoteTest.kt
@@ -0,0 +1,58 @@
+/*
+ * 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.server.display.mode
+
+import androidx.test.ext.junit.runners.AndroidJUnit4
+import androidx.test.filters.SmallTest
+import com.google.common.truth.Truth.assertThat
+import org.junit.Test
+import org.junit.runner.RunWith
+
+
+@SmallTest
+@RunWith(AndroidJUnit4::class)
+class RequestedRefreshRateVoteTest {
+
+ @Test
+ fun `updates requestedRefreshRates`() {
+ val refreshRate = 90f
+ val vote = RequestedRefreshRateVote(refreshRate)
+ val summary = createVotesSummary()
+
+ vote.updateSummary(summary)
+
+ assertThat(summary.requestedRefreshRates).hasSize(1)
+ assertThat(summary.requestedRefreshRates).contains(refreshRate)
+ }
+
+ @Test
+ fun `updates requestedRefreshRates with multiple refresh rates`() {
+ val refreshRate1 = 90f
+ val vote1 = RequestedRefreshRateVote(refreshRate1)
+
+ val refreshRate2 = 60f
+ val vote2 = RequestedRefreshRateVote(refreshRate2)
+
+ val summary = createVotesSummary()
+
+ vote1.updateSummary(summary)
+ vote2.updateSummary(summary)
+
+ assertThat(summary.requestedRefreshRates).hasSize(2)
+ assertThat(summary.requestedRefreshRates).containsExactly(refreshRate1, refreshRate2)
+ }
+}
\ No newline at end of file
diff --git a/services/tests/displayservicetests/src/com/android/server/display/mode/VoteSummaryTest.kt b/services/tests/displayservicetests/src/com/android/server/display/mode/VoteSummaryTest.kt
index 5da1bb6..dd5e1be 100644
--- a/services/tests/displayservicetests/src/com/android/server/display/mode/VoteSummaryTest.kt
+++ b/services/tests/displayservicetests/src/com/android/server/display/mode/VoteSummaryTest.kt
@@ -152,13 +152,51 @@
assertThat(result.map { it.modeId }).containsExactlyElementsIn(testCase.expectedModeIds)
}
+
+ @Test
+ fun `summary invalid if has requestedRefreshRate less than minRenederRate`() {
+ val summary = createSummary()
+ summary.requestedRefreshRates = setOf(30f, 90f)
+ summary.minRenderFrameRate = 60f
+ summary.maxRenderFrameRate = 120f
+
+ val result = summary.filterModes(arrayOf(createMode(1, 90f, 90f)))
+
+ assertThat(result).isEmpty()
+ }
+
+ @Test
+ fun `summary invalid if has requestedRefreshRate more than maxRenderFrameRate`() {
+ val summary = createSummary()
+ summary.requestedRefreshRates = setOf(60f, 240f)
+ summary.minRenderFrameRate = 60f
+ summary.maxRenderFrameRate = 120f
+
+ val result = summary.filterModes(arrayOf(createMode(1, 90f, 90f)))
+
+ assertThat(result).isEmpty()
+ }
+
+ @Test
+ fun `summary valid if all requestedRefreshRates inside render rate limits`() {
+ val summary = createSummary()
+ summary.requestedRefreshRates = setOf(60f, 90f)
+ summary.minRenderFrameRate = 60f
+ summary.maxRenderFrameRate = 120f
+
+ val result = summary.filterModes(arrayOf(createMode(1, 90f, 90f)))
+
+ assertThat(result).hasSize(1)
+ }
}
+
+
private fun createMode(modeId: Int, refreshRate: Float, vsyncRate: Float): Display.Mode {
return Display.Mode(modeId, 600, 800, refreshRate, vsyncRate, false,
FloatArray(0), IntArray(0))
}
-private fun createSummary(supportedModesVoteEnabled: Boolean): VoteSummary {
+private fun createSummary(supportedModesVoteEnabled: Boolean = false): VoteSummary {
val summary = createVotesSummary(supportedModesVoteEnabled = supportedModesVoteEnabled)
summary.width = 600
summary.height = 800
diff --git a/services/tests/uiservicestests/src/com/android/server/notification/DefaultDeviceEffectsApplierTest.java b/services/tests/uiservicestests/src/com/android/server/notification/DefaultDeviceEffectsApplierTest.java
index bfbc81c..4bea95f 100644
--- a/services/tests/uiservicestests/src/com/android/server/notification/DefaultDeviceEffectsApplierTest.java
+++ b/services/tests/uiservicestests/src/com/android/server/notification/DefaultDeviceEffectsApplierTest.java
@@ -25,10 +25,12 @@
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyBoolean;
+import static org.mockito.ArgumentMatchers.anyFloat;
import static org.mockito.ArgumentMatchers.anyInt;
import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.ArgumentMatchers.argThat;
import static org.mockito.ArgumentMatchers.eq;
+import static org.mockito.Mockito.doThrow;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.spy;
@@ -322,4 +324,26 @@
argThat(filter -> Intent.ACTION_SCREEN_OFF.equals(filter.getAction(0))),
anyInt());
}
+
+ @Test
+ public void apply_servicesThrow_noCrash() {
+ mSetFlagsRule.enableFlags(android.app.Flags.FLAG_MODES_API);
+
+ doThrow(new RuntimeException()).when(mPowerManager)
+ .suppressAmbientDisplay(anyString(), anyBoolean());
+ doThrow(new RuntimeException()).when(mColorDisplayManager).setSaturationLevel(anyInt());
+ doThrow(new RuntimeException()).when(mWallpaperManager).setWallpaperDimAmount(anyFloat());
+ doThrow(new RuntimeException()).when(mUiModeManager).setAttentionModeThemeOverlay(anyInt());
+ mApplier = new DefaultDeviceEffectsApplier(mContext);
+
+ ZenDeviceEffects effects = new ZenDeviceEffects.Builder()
+ .setShouldSuppressAmbientDisplay(true)
+ .setShouldDimWallpaper(true)
+ .setShouldDisplayGrayscale(true)
+ .setShouldUseNightMode(true)
+ .build();
+ mApplier.apply(effects, UPDATE_ORIGIN_USER);
+
+ // No crashes
+ }
}
diff --git a/services/tests/uiservicestests/src/com/android/server/notification/ZenModeHelperTest.java b/services/tests/uiservicestests/src/com/android/server/notification/ZenModeHelperTest.java
index e4188b0..72ace84 100644
--- a/services/tests/uiservicestests/src/com/android/server/notification/ZenModeHelperTest.java
+++ b/services/tests/uiservicestests/src/com/android/server/notification/ZenModeHelperTest.java
@@ -6168,6 +6168,23 @@
.isEqualTo(previousManualZenPolicy);
}
+ @Test
+ @EnableFlags(Flags.FLAG_MODES_API)
+ public void addRule_iconIdWithResourceNameTooLong_ignoresIcon() {
+ int resourceId = 999;
+ String veryLongResourceName = "com.android.server.notification:drawable/"
+ + "omg_this_is_one_long_resource_name".repeat(100);
+ when(mResources.getResourceName(resourceId)).thenReturn(veryLongResourceName);
+ when(mResources.getIdentifier(veryLongResourceName, null, null)).thenReturn(resourceId);
+
+ String ruleId = mZenModeHelper.addAutomaticZenRule(mContext.getPackageName(),
+ new AutomaticZenRule.Builder("Rule", CONDITION_ID).setIconResId(resourceId).build(),
+ UPDATE_ORIGIN_APP, "reason", CUSTOM_PKG_UID);
+ AutomaticZenRule storedRule = mZenModeHelper.getAutomaticZenRule(ruleId);
+
+ assertThat(storedRule.getIconResId()).isEqualTo(0);
+ }
+
private static void addZenRule(ZenModeConfig config, String id, String ownerPkg, int zenMode,
@Nullable ZenPolicy zenPolicy) {
ZenRule rule = new ZenRule();
diff --git a/services/tests/wmtests/src/com/android/server/wm/TransitionTests.java b/services/tests/wmtests/src/com/android/server/wm/TransitionTests.java
index 69f2d68..95d37eb 100644
--- a/services/tests/wmtests/src/com/android/server/wm/TransitionTests.java
+++ b/services/tests/wmtests/src/com/android/server/wm/TransitionTests.java
@@ -81,7 +81,9 @@
import android.graphics.Point;
import android.graphics.Rect;
import android.os.IBinder;
+import android.platform.test.annotations.EnableFlags;
import android.platform.test.annotations.Presubmit;
+import android.platform.test.flag.junit.SetFlagsRule;
import android.util.ArrayMap;
import android.util.ArraySet;
import android.view.SurfaceControl;
@@ -100,7 +102,9 @@
import androidx.test.filters.SmallTest;
import com.android.internal.graphics.ColorUtils;
+import com.android.window.flags.Flags;
+import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.ArgumentCaptor;
@@ -116,6 +120,7 @@
* Build/Install/Run:
* atest WmTests:TransitionTests
*/
+@EnableFlags(Flags.FLAG_MOVE_ANIMATION_OPTIONS_TO_CHANGE)
@SmallTest
@Presubmit
@RunWith(WindowTestRunner.class)
@@ -123,6 +128,8 @@
final SurfaceControl.Transaction mMockT = mock(SurfaceControl.Transaction.class);
private BLASTSyncEngine mSyncEngine;
+ @Rule
+ public SetFlagsRule mRule = new SetFlagsRule();
private Transition createTestTransition(int transitType, TransitionController controller) {
final Transition transition = new Transition(transitType, 0 /* flags */, controller,
controller.mSyncEngine);