Merge "Add metrics coverage to Cred Reg flow." into udc-dev
diff --git a/core/java/android/app/ActivityManager.java b/core/java/android/app/ActivityManager.java
index 521bf05..e2ef005 100644
--- a/core/java/android/app/ActivityManager.java
+++ b/core/java/android/app/ActivityManager.java
@@ -771,6 +771,7 @@
/**
* The set of flags for process capability.
+ * Keep it in sync with ProcessCapability in atoms.proto.
* @hide
*/
@IntDef(flag = true, prefix = { "PROCESS_CAPABILITY_" }, value = {
diff --git a/core/java/android/app/WallpaperColors.java b/core/java/android/app/WallpaperColors.java
index a34a50c..be1d8b8 100644
--- a/core/java/android/app/WallpaperColors.java
+++ b/core/java/android/app/WallpaperColors.java
@@ -213,9 +213,17 @@
.resizeBitmapArea(MAX_WALLPAPER_EXTRACTION_AREA)
.generate();
} else {
+ // in any case, always use between 5 and 128 clusters
+ int minClusters = 5;
+ int maxClusters = 128;
+
+ // if the bitmap is very small, use bitmapArea/16 clusters instead of 128
+ int minPixelsPerCluster = 16;
+ int numberOfColors = Math.max(minClusters,
+ Math.min(maxClusters, bitmapArea / minPixelsPerCluster));
palette = Palette
.from(bitmap, new CelebiQuantizer())
- .maximumColorCount(128)
+ .maximumColorCount(numberOfColors)
.resizeBitmapArea(MAX_WALLPAPER_EXTRACTION_AREA)
.generate();
}
diff --git a/data/etc/com.android.systemui.xml b/data/etc/com.android.systemui.xml
index 922dbb5..43683ff 100644
--- a/data/etc/com.android.systemui.xml
+++ b/data/etc/com.android.systemui.xml
@@ -31,6 +31,7 @@
<permission name="android.permission.DUMP"/>
<permission name="android.permission.GET_APP_OPS_STATS"/>
<permission name="android.permission.INTERACT_ACROSS_USERS"/>
+ <permission name="android.permission.LOCATION_HARDWARE"/>
<permission name="android.permission.MANAGE_DEBUGGING"/>
<permission name="android.permission.MANAGE_GAME_MODE" />
<permission name="android.permission.MANAGE_SENSOR_PRIVACY"/>
diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/recents/RecentsTransitionHandler.java b/libs/WindowManager/Shell/src/com/android/wm/shell/recents/RecentsTransitionHandler.java
index bffc51c..3e568e9 100644
--- a/libs/WindowManager/Shell/src/com/android/wm/shell/recents/RecentsTransitionHandler.java
+++ b/libs/WindowManager/Shell/src/com/android/wm/shell/recents/RecentsTransitionHandler.java
@@ -48,6 +48,7 @@
import android.window.WindowContainerToken;
import android.window.WindowContainerTransaction;
+import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.protolog.common.ProtoLog;
import com.android.wm.shell.common.ShellExecutor;
import com.android.wm.shell.protolog.ShellProtoLogGroup;
@@ -97,7 +98,8 @@
mMixers.remove(mixer);
}
- void startRecentsTransition(PendingIntent intent, Intent fillIn, Bundle options,
+ @VisibleForTesting
+ public IBinder startRecentsTransition(PendingIntent intent, Intent fillIn, Bundle options,
IApplicationThread appThread, IRecentsAnimationRunner listener) {
ProtoLog.v(ShellProtoLogGroup.WM_SHELL_RECENTS_TRANSITION,
"RecentsTransitionHandler.startRecentsTransition");
@@ -121,12 +123,13 @@
if (mixer != null) {
mixer.setRecentsTransition(transition);
}
- if (transition == null) {
+ if (transition != null) {
+ controller.setTransition(transition);
+ mControllers.add(controller);
+ } else {
controller.cancel("startRecentsTransition");
- return;
}
- controller.setTransition(transition);
- mControllers.add(controller);
+ return transition;
}
@Override
diff --git a/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/pip/AutoEnterPipOnGoToHomeTest.kt b/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/pip/AutoEnterPipOnGoToHomeTest.kt
index 93ee699..a4ac261 100644
--- a/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/pip/AutoEnterPipOnGoToHomeTest.kt
+++ b/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/pip/AutoEnterPipOnGoToHomeTest.kt
@@ -54,7 +54,6 @@
@RunWith(Parameterized::class)
@Parameterized.UseParametersRunnerFactory(FlickerParametersRunnerFactory::class)
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
-@FlakyTest(bugId = 238367575)
class AutoEnterPipOnGoToHomeTest(flicker: FlickerTest) : EnterPipViaAppUiButtonTest(flicker) {
/** Defines the transition used to run the test */
override val transition: FlickerBuilder.() -> Unit
@@ -71,7 +70,7 @@
transitions { tapl.goHome() }
}
- @FlakyTest(bugId = 256863309)
+ @Presubmit
@Test
override fun pipLayerReduces() {
flicker.assertLayers {
diff --git a/libs/WindowManager/Shell/tests/unittest/Android.bp b/libs/WindowManager/Shell/tests/unittest/Android.bp
index 57a6981..ad4d97f 100644
--- a/libs/WindowManager/Shell/tests/unittest/Android.bp
+++ b/libs/WindowManager/Shell/tests/unittest/Android.bp
@@ -47,7 +47,7 @@
"truth-prebuilt",
"testables",
"platform-test-annotations",
- "frameworks-base-testutils",
+ "servicestests-utils",
],
libs: [
diff --git a/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/transition/ShellTransitionTests.java b/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/transition/ShellTransitionTests.java
index 8eb5c6a..963632b 100644
--- a/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/transition/ShellTransitionTests.java
+++ b/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/transition/ShellTransitionTests.java
@@ -17,6 +17,7 @@
package com.android.wm.shell.transition;
import static android.app.WindowConfiguration.ACTIVITY_TYPE_HOME;
+import static android.app.WindowConfiguration.ACTIVITY_TYPE_RECENTS;
import static android.app.WindowConfiguration.ACTIVITY_TYPE_STANDARD;
import static android.app.WindowConfiguration.WINDOWING_MODE_FULLSCREEN;
import static android.app.WindowConfiguration.WINDOWING_MODE_MULTI_WINDOW;
@@ -50,6 +51,7 @@
import static org.mockito.ArgumentMatchers.anyInt;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.ArgumentMatchers.isNull;
+import static org.mockito.Mockito.after;
import static org.mockito.Mockito.clearInvocations;
import static org.mockito.Mockito.doAnswer;
import static org.mockito.Mockito.inOrder;
@@ -58,14 +60,19 @@
import static org.mockito.Mockito.verify;
import android.app.ActivityManager.RunningTaskInfo;
+import android.app.IApplicationThread;
+import android.app.PendingIntent;
import android.content.Context;
+import android.content.Intent;
import android.os.Binder;
+import android.os.Bundle;
import android.os.Handler;
import android.os.IBinder;
import android.os.Looper;
import android.os.RemoteException;
import android.util.ArraySet;
import android.util.Pair;
+import android.view.IRecentsAnimationRunner;
import android.view.Surface;
import android.view.SurfaceControl;
import android.view.WindowManager;
@@ -86,6 +93,7 @@
import androidx.test.filters.SmallTest;
import androidx.test.platform.app.InstrumentationRegistry;
+import com.android.server.testutils.StubTransaction;
import com.android.wm.shell.ShellTestCase;
import com.android.wm.shell.TestShellExecutor;
import com.android.wm.shell.TransitionInfoBuilder;
@@ -93,6 +101,7 @@
import com.android.wm.shell.common.DisplayLayout;
import com.android.wm.shell.common.ShellExecutor;
import com.android.wm.shell.common.TransactionPool;
+import com.android.wm.shell.recents.RecentsTransitionHandler;
import com.android.wm.shell.sysui.ShellController;
import com.android.wm.shell.sysui.ShellInit;
import com.android.wm.shell.sysui.ShellSharedConstants;
@@ -100,6 +109,7 @@
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
+import org.mockito.Answers;
import org.mockito.InOrder;
import java.util.ArrayList;
@@ -162,8 +172,8 @@
verify(mOrganizer, times(1)).startTransition(eq(transitToken), any());
TransitionInfo info = new TransitionInfoBuilder(TRANSIT_OPEN)
.addChange(TRANSIT_OPEN).addChange(TRANSIT_CLOSE).build();
- transitions.onTransitionReady(transitToken, info, mock(SurfaceControl.Transaction.class),
- mock(SurfaceControl.Transaction.class));
+ transitions.onTransitionReady(transitToken, info, new StubTransaction(),
+ new StubTransaction());
assertEquals(1, mDefaultHandler.activeCount());
mDefaultHandler.finishAll();
mMainExecutor.flushAll();
@@ -212,8 +222,8 @@
transitions.requestStartTransition(transitToken,
new TransitionRequestInfo(TRANSIT_OPEN, null /* trigger */, null /* remote */));
verify(mOrganizer, times(1)).startTransition(eq(transitToken), isNull());
- transitions.onTransitionReady(transitToken, open, mock(SurfaceControl.Transaction.class),
- mock(SurfaceControl.Transaction.class));
+ transitions.onTransitionReady(transitToken, open, new StubTransaction(),
+ new StubTransaction());
assertEquals(1, mDefaultHandler.activeCount());
assertEquals(0, testHandler.activeCount());
mDefaultHandler.finishAll();
@@ -228,8 +238,8 @@
new TransitionRequestInfo(TRANSIT_OPEN, mwTaskInfo, null /* remote */));
verify(mOrganizer, times(1)).startTransition(
eq(transitToken), eq(handlerWCT));
- transitions.onTransitionReady(transitToken, open, mock(SurfaceControl.Transaction.class),
- mock(SurfaceControl.Transaction.class));
+ transitions.onTransitionReady(transitToken, open, new StubTransaction(),
+ new StubTransaction());
assertEquals(1, mDefaultHandler.activeCount());
assertEquals(0, testHandler.activeCount());
mDefaultHandler.finishAll();
@@ -246,8 +256,8 @@
eq(transitToken), eq(handlerWCT));
TransitionInfo change = new TransitionInfoBuilder(TRANSIT_CHANGE)
.addChange(TRANSIT_CHANGE).build();
- transitions.onTransitionReady(transitToken, change, mock(SurfaceControl.Transaction.class),
- mock(SurfaceControl.Transaction.class));
+ transitions.onTransitionReady(transitToken, change, new StubTransaction(),
+ new StubTransaction());
assertEquals(0, mDefaultHandler.activeCount());
assertEquals(1, testHandler.activeCount());
assertEquals(0, topHandler.activeCount());
@@ -284,8 +294,8 @@
verify(mOrganizer, times(1)).startTransition(eq(transitToken), any());
TransitionInfo info = new TransitionInfoBuilder(TRANSIT_OPEN)
.addChange(TRANSIT_OPEN).addChange(TRANSIT_CLOSE).build();
- transitions.onTransitionReady(transitToken, info, mock(SurfaceControl.Transaction.class),
- mock(SurfaceControl.Transaction.class));
+ transitions.onTransitionReady(transitToken, info, new StubTransaction(),
+ new StubTransaction());
assertEquals(0, mDefaultHandler.activeCount());
assertTrue(remoteCalled[0]);
mDefaultHandler.finishAll();
@@ -434,8 +444,8 @@
verify(mOrganizer, times(1)).startTransition(eq(transitToken), any());
TransitionInfo info = new TransitionInfoBuilder(TRANSIT_OPEN)
.addChange(TRANSIT_OPEN).addChange(TRANSIT_CLOSE).build();
- transitions.onTransitionReady(transitToken, info, mock(SurfaceControl.Transaction.class),
- mock(SurfaceControl.Transaction.class));
+ transitions.onTransitionReady(transitToken, info, new StubTransaction(),
+ new StubTransaction());
assertEquals(0, mDefaultHandler.activeCount());
assertTrue(remoteCalled[0]);
mDefaultHandler.finishAll();
@@ -484,10 +494,10 @@
oneShot.setTransition(transitToken);
IBinder anotherToken = new Binder();
assertFalse(oneShot.startAnimation(anotherToken, new TransitionInfo(transitType, 0),
- mock(SurfaceControl.Transaction.class), mock(SurfaceControl.Transaction.class),
+ new StubTransaction(), new StubTransaction(),
testFinish));
assertTrue(oneShot.startAnimation(transitToken, new TransitionInfo(transitType, 0),
- mock(SurfaceControl.Transaction.class), mock(SurfaceControl.Transaction.class),
+ new StubTransaction(), new StubTransaction(),
testFinish));
}
@@ -501,8 +511,8 @@
new TransitionRequestInfo(TRANSIT_OPEN, null /* trigger */, null /* remote */));
TransitionInfo info1 = new TransitionInfoBuilder(TRANSIT_OPEN)
.addChange(TRANSIT_OPEN).addChange(TRANSIT_CLOSE).build();
- transitions.onTransitionReady(transitToken1, info1, mock(SurfaceControl.Transaction.class),
- mock(SurfaceControl.Transaction.class));
+ transitions.onTransitionReady(transitToken1, info1, new StubTransaction(),
+ new StubTransaction());
assertEquals(1, mDefaultHandler.activeCount());
IBinder transitToken2 = new Binder();
@@ -510,8 +520,8 @@
new TransitionRequestInfo(TRANSIT_CLOSE, null /* trigger */, null /* remote */));
TransitionInfo info2 = new TransitionInfoBuilder(TRANSIT_CLOSE)
.addChange(TRANSIT_OPEN).addChange(TRANSIT_CLOSE).build();
- transitions.onTransitionReady(transitToken2, info2, mock(SurfaceControl.Transaction.class),
- mock(SurfaceControl.Transaction.class));
+ transitions.onTransitionReady(transitToken2, info2, new StubTransaction(),
+ new StubTransaction());
// default handler doesn't merge by default, so it shouldn't increment active count.
assertEquals(1, mDefaultHandler.activeCount());
assertEquals(0, mDefaultHandler.mergeCount());
@@ -542,8 +552,8 @@
new TransitionRequestInfo(TRANSIT_OPEN, null /* trigger */, null /* remote */));
TransitionInfo info1 = new TransitionInfoBuilder(TRANSIT_OPEN)
.addChange(TRANSIT_OPEN).addChange(TRANSIT_CLOSE).build();
- transitions.onTransitionReady(transitToken1, info1, mock(SurfaceControl.Transaction.class),
- mock(SurfaceControl.Transaction.class));
+ transitions.onTransitionReady(transitToken1, info1, new StubTransaction(),
+ new StubTransaction());
assertEquals(1, mDefaultHandler.activeCount());
IBinder transitToken2 = new Binder();
@@ -551,8 +561,8 @@
new TransitionRequestInfo(TRANSIT_CLOSE, null /* trigger */, null /* remote */));
TransitionInfo info2 = new TransitionInfoBuilder(TRANSIT_CLOSE)
.addChange(TRANSIT_OPEN).addChange(TRANSIT_CLOSE).build();
- transitions.onTransitionReady(transitToken2, info2, mock(SurfaceControl.Transaction.class),
- mock(SurfaceControl.Transaction.class));
+ transitions.onTransitionReady(transitToken2, info2, new StubTransaction(),
+ new StubTransaction());
// it should still only have 1 active, but then show 1 merged
assertEquals(1, mDefaultHandler.activeCount());
assertEquals(1, mDefaultHandler.mergeCount());
@@ -611,8 +621,8 @@
new TransitionRequestInfo(TRANSIT_OPEN, null /* trigger */, null /* remote */));
TransitionInfo info = new TransitionInfoBuilder(TRANSIT_OPEN)
.addChange(TRANSIT_OPEN).addChange(TRANSIT_CLOSE).build();
- transitions.onTransitionReady(token, info, mock(SurfaceControl.Transaction.class),
- mock(SurfaceControl.Transaction.class));
+ transitions.onTransitionReady(token, info, new StubTransaction(),
+ new StubTransaction());
return token;
};
@@ -678,8 +688,8 @@
// queued), so continue the transition lifecycle for that.
TransitionInfo info = new TransitionInfoBuilder(TRANSIT_OPEN)
.addChange(TRANSIT_OPEN).addChange(TRANSIT_CLOSE).build();
- transitions.onTransitionReady(transitToken, info, mock(SurfaceControl.Transaction.class),
- mock(SurfaceControl.Transaction.class));
+ transitions.onTransitionReady(transitToken, info, new StubTransaction(),
+ new StubTransaction());
// At this point, if things are not working, we'd get an NPE due to attempting to merge
// into the shellInit transition which hasn't started yet.
assertEquals(1, mDefaultHandler.activeCount());
@@ -791,8 +801,8 @@
new TransitionRequestInfo(TRANSIT_OPEN, null /* trigger */, null /* remote */));
TransitionInfo info1 = new TransitionInfoBuilder(TRANSIT_OPEN)
.addChange(TRANSIT_OPEN).addChange(TRANSIT_CLOSE).build();
- transitions.onTransitionReady(transitToken1, info1, mock(SurfaceControl.Transaction.class),
- mock(SurfaceControl.Transaction.class));
+ transitions.onTransitionReady(transitToken1, info1, new StubTransaction(),
+ new StubTransaction());
assertEquals(1, mDefaultHandler.activeCount());
transitions.runOnIdle(runnable2);
@@ -806,8 +816,8 @@
new TransitionRequestInfo(TRANSIT_CLOSE, null /* trigger */, null /* remote */));
TransitionInfo info2 = new TransitionInfoBuilder(TRANSIT_CLOSE)
.addChange(TRANSIT_OPEN).addChange(TRANSIT_CLOSE).build();
- transitions.onTransitionReady(transitToken2, info2, mock(SurfaceControl.Transaction.class),
- mock(SurfaceControl.Transaction.class));
+ transitions.onTransitionReady(transitToken2, info2, new StubTransaction(),
+ new StubTransaction());
assertEquals(1, mDefaultHandler.activeCount());
mDefaultHandler.finishAll();
@@ -858,8 +868,8 @@
new TransitionRequestInfo(TRANSIT_OPEN, null /* trigger */, null /* remote */));
TransitionInfo info = new TransitionInfoBuilder(TRANSIT_OPEN)
.addChange(TRANSIT_OPEN).addChange(TRANSIT_CLOSE).build();
- SurfaceControl.Transaction startT = mock(SurfaceControl.Transaction.class);
- SurfaceControl.Transaction finishT = mock(SurfaceControl.Transaction.class);
+ SurfaceControl.Transaction startT = new StubTransaction();
+ SurfaceControl.Transaction finishT = new StubTransaction();
transitions.onTransitionReady(transitToken, info, startT, finishT);
InOrder observerOrder = inOrder(observer);
@@ -883,8 +893,8 @@
new TransitionRequestInfo(TRANSIT_OPEN, null /* trigger */, null /* remote */));
TransitionInfo info1 = new TransitionInfoBuilder(TRANSIT_OPEN)
.addChange(TRANSIT_OPEN).addChange(TRANSIT_CLOSE).build();
- SurfaceControl.Transaction startT1 = mock(SurfaceControl.Transaction.class);
- SurfaceControl.Transaction finishT1 = mock(SurfaceControl.Transaction.class);
+ SurfaceControl.Transaction startT1 = new StubTransaction();
+ SurfaceControl.Transaction finishT1 = new StubTransaction();
transitions.onTransitionReady(transitToken1, info1, startT1, finishT1);
verify(observer).onTransitionReady(transitToken1, info1, startT1, finishT1);
@@ -893,8 +903,8 @@
new TransitionRequestInfo(TRANSIT_CLOSE, null /* trigger */, null /* remote */));
TransitionInfo info2 = new TransitionInfoBuilder(TRANSIT_CLOSE)
.addChange(TRANSIT_OPEN).addChange(TRANSIT_CLOSE).build();
- SurfaceControl.Transaction startT2 = mock(SurfaceControl.Transaction.class);
- SurfaceControl.Transaction finishT2 = mock(SurfaceControl.Transaction.class);
+ SurfaceControl.Transaction startT2 = new StubTransaction();
+ SurfaceControl.Transaction finishT2 = new StubTransaction();
transitions.onTransitionReady(transitToken2, info2, startT2, finishT2);
verify(observer, times(1)).onTransitionReady(transitToken2, info2, startT2, finishT2);
verify(observer, times(0)).onTransitionStarting(transitToken2);
@@ -927,8 +937,8 @@
new TransitionRequestInfo(TRANSIT_OPEN, null /* trigger */, null /* remote */));
TransitionInfo info1 = new TransitionInfoBuilder(TRANSIT_OPEN)
.addChange(TRANSIT_OPEN).addChange(TRANSIT_CLOSE).build();
- SurfaceControl.Transaction startT1 = mock(SurfaceControl.Transaction.class);
- SurfaceControl.Transaction finishT1 = mock(SurfaceControl.Transaction.class);
+ SurfaceControl.Transaction startT1 = new StubTransaction();
+ SurfaceControl.Transaction finishT1 = new StubTransaction();
transitions.onTransitionReady(transitToken1, info1, startT1, finishT1);
IBinder transitToken2 = new Binder();
@@ -936,8 +946,8 @@
new TransitionRequestInfo(TRANSIT_CLOSE, null /* trigger */, null /* remote */));
TransitionInfo info2 = new TransitionInfoBuilder(TRANSIT_CLOSE)
.addChange(TRANSIT_OPEN).addChange(TRANSIT_CLOSE).build();
- SurfaceControl.Transaction startT2 = mock(SurfaceControl.Transaction.class);
- SurfaceControl.Transaction finishT2 = mock(SurfaceControl.Transaction.class);
+ SurfaceControl.Transaction startT2 = new StubTransaction();
+ SurfaceControl.Transaction finishT2 = new StubTransaction();
transitions.onTransitionReady(transitToken2, info2, startT2, finishT2);
InOrder observerOrder = inOrder(observer);
@@ -999,8 +1009,8 @@
new TransitionRequestInfo(TRANSIT_CHANGE, mwTaskInfo, null /* remote */));
TransitionInfo change = new TransitionInfoBuilder(TRANSIT_CHANGE)
.addChange(TRANSIT_CHANGE).build();
- SurfaceControl.Transaction startT1 = mock(SurfaceControl.Transaction.class);
- SurfaceControl.Transaction finishT1 = mock(SurfaceControl.Transaction.class);
+ SurfaceControl.Transaction startT1 = new StubTransaction();
+ SurfaceControl.Transaction finishT1 = new StubTransaction();
transitions.onTransitionReady(transitToken1, change, startT1, finishT1);
// Request the second transition that should be handled by the default handler
@@ -1009,8 +1019,8 @@
.addChange(TRANSIT_OPEN).addChange(TRANSIT_CLOSE).build();
transitions.requestStartTransition(transitToken2,
new TransitionRequestInfo(TRANSIT_OPEN, null /* trigger */, null /* remote */));
- SurfaceControl.Transaction startT2 = mock(SurfaceControl.Transaction.class);
- SurfaceControl.Transaction finishT2 = mock(SurfaceControl.Transaction.class);
+ SurfaceControl.Transaction startT2 = new StubTransaction();
+ SurfaceControl.Transaction finishT2 = new StubTransaction();
transitions.onTransitionReady(transitToken2, open, startT2, finishT2);
verify(observer).onTransitionReady(transitToken2, open, startT2, finishT2);
verify(observer, times(0)).onTransitionStarting(transitToken2);
@@ -1019,8 +1029,8 @@
IBinder transitToken3 = new Binder();
transitions.requestStartTransition(transitToken3,
new TransitionRequestInfo(TRANSIT_OPEN, null /* trigger */, null /* remote */));
- SurfaceControl.Transaction startT3 = mock(SurfaceControl.Transaction.class);
- SurfaceControl.Transaction finishT3 = mock(SurfaceControl.Transaction.class);
+ SurfaceControl.Transaction startT3 = new StubTransaction();
+ SurfaceControl.Transaction finishT3 = new StubTransaction();
transitions.onTransitionReady(transitToken3, open, startT3, finishT3);
verify(observer, times(0)).onTransitionStarting(transitToken2);
verify(observer).onTransitionReady(transitToken3, open, startT3, finishT3);
@@ -1045,6 +1055,104 @@
}
@Test
+ public void testTransitSleep_squashesRecents() {
+ ShellInit shellInit = new ShellInit(mMainExecutor);
+ final Transitions transitions =
+ new Transitions(mContext, shellInit, mock(ShellController.class), mOrganizer,
+ mTransactionPool, createTestDisplayController(), mMainExecutor,
+ mMainHandler, mAnimExecutor);
+ final RecentsTransitionHandler recentsHandler =
+ new RecentsTransitionHandler(shellInit, transitions, null);
+ transitions.replaceDefaultHandlerForTest(mDefaultHandler);
+ shellInit.init();
+
+ Transitions.TransitionObserver observer = mock(Transitions.TransitionObserver.class);
+ transitions.registerObserver(observer);
+
+ RunningTaskInfo task1 = createTaskInfo(1, WINDOWING_MODE_FULLSCREEN, ACTIVITY_TYPE_RECENTS);
+ RunningTaskInfo task2 = createTaskInfo(2);
+
+ // Start an open transition for the purpose of occupying the ready queue
+ final IBinder transitOpen1 = new Binder("transitOpen1");
+ final TransitionInfo infoOpen1 =
+ new TransitionInfoBuilder(TRANSIT_OPEN)
+ .addChange(TRANSIT_OPEN, task1)
+ .build();
+ mMainExecutor.execute(() -> {
+ transitions.requestStartTransition(transitOpen1, new TransitionRequestInfo(
+ TRANSIT_OPEN, task1 /* trigger */, null /* remote */));
+ onTransitionReady(transitions, transitOpen1, infoOpen1);
+ });
+
+ // First transition on the queue should start immediately.
+ mMainExecutor.flushAll();
+ verify(observer).onTransitionReady(eq(transitOpen1), any(), any(), any());
+ verify(observer).onTransitionStarting(eq(transitOpen1));
+
+ // Start recents
+ final IRecentsAnimationRunner recentsListener =
+ mock(IRecentsAnimationRunner.class, Answers.RETURNS_DEEP_STUBS);
+ final IBinder transitRecents = recentsHandler.startRecentsTransition(
+ mock(PendingIntent.class) /* intent */,
+ mock(Intent.class) /* fillIn */,
+ new Bundle() /* options */,
+ mock(IApplicationThread.class) /* appThread */,
+ recentsListener);
+ final TransitionInfo infoRecents =
+ new TransitionInfoBuilder(TRANSIT_TO_FRONT)
+ .addChange(TRANSIT_TO_FRONT, task1)
+ .addChange(TRANSIT_CLOSE, task2)
+ .build();
+ onTransitionReady(transitions, transitRecents, infoRecents);
+
+ // Start another open transition during recents
+ final IBinder transitOpen2 = new Binder("transitOpen2");
+ final TransitionInfo infoOpen2 =
+ new TransitionInfoBuilder(TRANSIT_OPEN)
+ .addChange(TRANSIT_OPEN, task2)
+ .addChange(TRANSIT_TO_BACK, task1)
+ .build();
+ mMainExecutor.execute(() -> {
+ transitions.requestStartTransition(transitOpen2, new TransitionRequestInfo(
+ TRANSIT_OPEN, task2 /* trigger */, null /* remote */));
+ onTransitionReady(transitions, transitOpen2, infoOpen2);
+ });
+
+ // Finish testOpen1 to start processing the other transitions
+ mMainExecutor.execute(() -> {
+ mDefaultHandler.finishOne();
+ });
+ mMainExecutor.flushAll();
+
+ // Recents transition SHOULD start, and merge the open transition, which should NOT start.
+ verify(observer).onTransitionFinished(eq(transitOpen1), eq(false) /* aborted */);
+ verify(observer).onTransitionReady(eq(transitRecents), any(), any(), any());
+ verify(observer).onTransitionStarting(eq(transitRecents));
+ verify(observer).onTransitionReady(eq(transitOpen2), any(), any(), any());
+ verify(observer).onTransitionMerged(eq(transitOpen2), eq(transitRecents));
+ // verify(observer).onTransitionFinished(eq(transitOpen2), eq(true) /* aborted */);
+
+ // Go to sleep
+ final IBinder transitSleep = new Binder("transitSleep");
+ final TransitionInfo infoSleep = new TransitionInfoBuilder(TRANSIT_SLEEP).build();
+ mMainExecutor.execute(() -> {
+ transitions.requestStartTransition(transitSleep, new TransitionRequestInfo(
+ TRANSIT_SLEEP, null /* trigger */, null /* remote */));
+ onTransitionReady(transitions, transitSleep, infoSleep);
+ });
+ mMainExecutor.flushAll();
+
+ // Recents transition should finish itself when it sees the sleep transition coming.
+ verify(observer).onTransitionFinished(eq(transitRecents), eq(false));
+ verify(observer).onTransitionFinished(eq(transitSleep), eq(false));
+ }
+
+ private void onTransitionReady(Transitions transitions, IBinder token, TransitionInfo info) {
+ transitions.onTransitionReady(token, info, new StubTransaction(),
+ new StubTransaction());
+ }
+
+ @Test
public void testEmptyTransitionStillReportsKeyguardGoingAway() {
Transitions transitions = createTestTransitions();
transitions.replaceDefaultHandlerForTest(mDefaultHandler);
@@ -1056,8 +1164,8 @@
// Make a no-op transition
TransitionInfo info = new TransitionInfoBuilder(
TRANSIT_OPEN, TRANSIT_FLAG_KEYGUARD_GOING_AWAY, true /* noOp */).build();
- transitions.onTransitionReady(transitToken, info, mock(SurfaceControl.Transaction.class),
- mock(SurfaceControl.Transaction.class));
+ transitions.onTransitionReady(transitToken, info, new StubTransaction(),
+ new StubTransaction());
// If keyguard-going-away flag set, then it shouldn't be aborted.
assertEquals(1, mDefaultHandler.activeCount());
@@ -1397,7 +1505,7 @@
private static void onTransitionReady(Transitions transitions, IBinder token) {
transitions.onTransitionReady(token, createTransitionInfo(),
- mock(SurfaceControl.Transaction.class), mock(SurfaceControl.Transaction.class));
+ new StubTransaction(), new StubTransaction());
}
private static TransitionInfo createTransitionInfo() {
@@ -1414,15 +1522,15 @@
private static RunningTaskInfo createTaskInfo(int taskId, int windowingMode, int activityType) {
RunningTaskInfo taskInfo = new RunningTaskInfo();
taskInfo.taskId = taskId;
+ taskInfo.topActivityType = activityType;
taskInfo.configuration.windowConfiguration.setWindowingMode(windowingMode);
taskInfo.configuration.windowConfiguration.setActivityType(activityType);
+ taskInfo.token = mock(WindowContainerToken.class);
return taskInfo;
}
private static RunningTaskInfo createTaskInfo(int taskId) {
- RunningTaskInfo taskInfo = new RunningTaskInfo();
- taskInfo.taskId = taskId;
- return taskInfo;
+ return createTaskInfo(taskId, WINDOWING_MODE_FULLSCREEN, ACTIVITY_TYPE_STANDARD);
}
private DisplayController createTestDisplayController() {
diff --git a/libs/hwui/renderthread/VulkanManager.cpp b/libs/hwui/renderthread/VulkanManager.cpp
index 96bfc10..f198bca 100644
--- a/libs/hwui/renderthread/VulkanManager.cpp
+++ b/libs/hwui/renderthread/VulkanManager.cpp
@@ -42,7 +42,7 @@
namespace uirenderer {
namespace renderthread {
-static std::array<std::string_view, 18> sEnableExtensions{
+static std::array<std::string_view, 19> sEnableExtensions{
VK_KHR_BIND_MEMORY_2_EXTENSION_NAME,
VK_KHR_DEDICATED_ALLOCATION_EXTENSION_NAME,
VK_KHR_EXTERNAL_MEMORY_CAPABILITIES_EXTENSION_NAME,
@@ -56,6 +56,7 @@
VK_KHR_SURFACE_EXTENSION_NAME,
VK_KHR_SWAPCHAIN_EXTENSION_NAME,
VK_EXT_BLEND_OPERATION_ADVANCED_EXTENSION_NAME,
+ VK_KHR_IMAGE_FORMAT_LIST_EXTENSION_NAME,
VK_EXT_IMAGE_DRM_FORMAT_MODIFIER_EXTENSION_NAME,
VK_ANDROID_EXTERNAL_MEMORY_ANDROID_HARDWARE_BUFFER_EXTENSION_NAME,
VK_EXT_QUEUE_FAMILY_FOREIGN_EXTENSION_NAME,
diff --git a/packages/SystemUI/AndroidManifest.xml b/packages/SystemUI/AndroidManifest.xml
index c8eb4b4..a27f113 100644
--- a/packages/SystemUI/AndroidManifest.xml
+++ b/packages/SystemUI/AndroidManifest.xml
@@ -82,6 +82,7 @@
<uses-permission android:name="android.permission.CONTROL_VPN" />
<uses-permission android:name="android.permission.PEERS_MAC_ADDRESS"/>
<uses-permission android:name="android.permission.READ_WIFI_CREDENTIAL"/>
+ <uses-permission android:name="android.permission.LOCATION_HARDWARE" />
<!-- Physical hardware -->
<uses-permission android:name="android.permission.MANAGE_USB" />
<uses-permission android:name="android.permission.CONTROL_DISPLAY_BRIGHTNESS" />
diff --git a/packages/SystemUI/plugin/Android.bp b/packages/SystemUI/plugin/Android.bp
index e306d4a..22bcba4 100644
--- a/packages/SystemUI/plugin/Android.bp
+++ b/packages/SystemUI/plugin/Android.bp
@@ -32,6 +32,8 @@
"bcsmartspace/src/**/*.kt",
],
+ // If you add a static lib here, you may need to also add the package to the ClassLoaderFilter
+ // in PluginInstance. That will ensure that loaded plugins have access to the related classes.
static_libs: [
"androidx.annotation_annotation",
"error_prone_annotations",
diff --git a/packages/SystemUI/src/com/android/systemui/dump/DumpManager.kt b/packages/SystemUI/src/com/android/systemui/dump/DumpManager.kt
index 7d1ffca..ab8052c 100644
--- a/packages/SystemUI/src/com/android/systemui/dump/DumpManager.kt
+++ b/packages/SystemUI/src/com/android/systemui/dump/DumpManager.kt
@@ -16,12 +16,12 @@
package com.android.systemui.dump
-import android.util.ArrayMap
import com.android.systemui.Dumpable
import com.android.systemui.ProtoDumpable
import com.android.systemui.dump.nano.SystemUIProtoDump
import com.android.systemui.plugins.log.LogBuffer
import java.io.PrintWriter
+import java.util.TreeMap
import javax.inject.Inject
import javax.inject.Singleton
@@ -36,8 +36,9 @@
*/
@Singleton
open class DumpManager @Inject constructor() {
- private val dumpables: MutableMap<String, RegisteredDumpable<Dumpable>> = ArrayMap()
- private val buffers: MutableMap<String, RegisteredDumpable<LogBuffer>> = ArrayMap()
+ // NOTE: Using TreeMap ensures that iteration is in a predictable & alphabetical order.
+ private val dumpables: MutableMap<String, RegisteredDumpable<Dumpable>> = TreeMap()
+ private val buffers: MutableMap<String, RegisteredDumpable<LogBuffer>> = TreeMap()
/** See [registerCriticalDumpable]. */
fun registerCriticalDumpable(module: Dumpable) {
@@ -132,7 +133,8 @@
}
/**
- * Dumps the first dumpable or buffer whose registered name ends with [target]
+ * Dumps the alphabetically first, shortest-named dumpable or buffer whose registered name ends
+ * with [target].
*/
@Synchronized
fun dumpTarget(
@@ -141,19 +143,14 @@
args: Array<String>,
tailLength: Int,
) {
- for (dumpable in dumpables.values) {
- if (dumpable.name.endsWith(target)) {
- dumpDumpable(dumpable, pw, args)
- return
+ sequence {
+ findBestTargetMatch(dumpables, target)?.let {
+ yield(it.name to { dumpDumpable(it, pw, args) })
}
- }
-
- for (buffer in buffers.values) {
- if (buffer.name.endsWith(target)) {
- dumpBuffer(buffer, pw, tailLength)
- return
+ findBestTargetMatch(buffers, target)?.let {
+ yield(it.name to { dumpBuffer(it, pw, tailLength) })
}
- }
+ }.sortedBy { it.first }.minByOrNull { it.first.length }?.second?.invoke()
}
@Synchronized
@@ -162,11 +159,8 @@
protoDump: SystemUIProtoDump,
args: Array<String>
) {
- for (dumpable in dumpables.values) {
- if (dumpable.dumpable is ProtoDumpable && dumpable.name.endsWith(target)) {
- dumpProtoDumpable(dumpable.dumpable, protoDump, args)
- return
- }
+ findBestProtoTargetMatch(dumpables, target)?.let {
+ dumpProtoDumpable(it, protoDump, args)
}
}
@@ -303,6 +297,22 @@
val existingDumpable = dumpables[name]?.dumpable ?: buffers[name]?.dumpable
return existingDumpable == null || newDumpable == existingDumpable
}
+
+ private fun <V : Any> findBestTargetMatch(map: Map<String, V>, target: String): V? = map
+ .asSequence()
+ .filter { it.key.endsWith(target) }
+ .minByOrNull { it.key.length }
+ ?.value
+
+ private fun findBestProtoTargetMatch(
+ map: Map<String, RegisteredDumpable<Dumpable>>,
+ target: String
+ ): ProtoDumpable? = map
+ .asSequence()
+ .filter { it.key.endsWith(target) }
+ .filter { it.value.dumpable is ProtoDumpable }
+ .minByOrNull { it.key.length }
+ ?.value?.dumpable as? ProtoDumpable
}
private data class RegisteredDumpable<T>(
diff --git a/packages/SystemUI/src/com/android/systemui/log/dagger/LogModule.java b/packages/SystemUI/src/com/android/systemui/log/dagger/LogModule.java
index 658f6a0..6988bd8 100644
--- a/packages/SystemUI/src/com/android/systemui/log/dagger/LogModule.java
+++ b/packages/SystemUI/src/com/android/systemui/log/dagger/LogModule.java
@@ -209,7 +209,7 @@
@SysUISingleton
@CollapsedSbFragmentLog
public static LogBuffer provideCollapsedSbFragmentLogBuffer(LogBufferFactory factory) {
- return factory.create("CollapsedSbFragmentLog", 20);
+ return factory.create("CollapsedSbFragmentLog", 40);
}
/**
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/ActivatableNotificationView.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/ActivatableNotificationView.java
index 66d4c3a9..285dd97 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/ActivatableNotificationView.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/ActivatableNotificationView.java
@@ -733,12 +733,16 @@
super.dump(pw, args);
if (DUMP_VERBOSE) {
DumpUtilsKt.withIncreasedIndent(pw, () -> {
- pw.println("mBackgroundNormal: " + mBackgroundNormal);
- if (mBackgroundNormal != null) {
- DumpUtilsKt.withIncreasedIndent(pw, () -> {
- mBackgroundNormal.dump(pw, args);
- });
- }
+ dumpBackgroundView(pw, args);
+ });
+ }
+ }
+
+ protected void dumpBackgroundView(IndentingPrintWriter pw, String[] args) {
+ pw.println("Background View: " + mBackgroundNormal);
+ if (DUMP_VERBOSE && mBackgroundNormal != null) {
+ DumpUtilsKt.withIncreasedIndent(pw, () -> {
+ mBackgroundNormal.dump(pw, args);
});
}
}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/ExpandableNotificationRow.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/ExpandableNotificationRow.java
index 5978133..1dc58b5 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/ExpandableNotificationRow.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/ExpandableNotificationRow.java
@@ -3593,6 +3593,7 @@
// Skip super call; dump viewState ourselves
pw.println("Notification: " + mEntry.getKey());
DumpUtilsKt.withIncreasedIndent(pw, () -> {
+ pw.println(this);
pw.print("visibility: " + getVisibility());
pw.print(", alpha: " + getAlpha());
pw.print(", translation: " + getTranslation());
@@ -3612,6 +3613,7 @@
pw.println("no viewState!!!");
}
pw.println(getRoundableState().debugString());
+ dumpBackgroundView(pw, args);
int transientViewCount = mChildrenContainer == null
? 0 : mChildrenContainer.getTransientViewCount();
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/ExpandableView.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/ExpandableView.java
index 5edff5f..3e01dd3 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/ExpandableView.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/ExpandableView.java
@@ -40,6 +40,7 @@
import com.android.systemui.statusbar.notification.RoundableState;
import com.android.systemui.statusbar.notification.stack.ExpandableViewState;
import com.android.systemui.statusbar.notification.stack.NotificationStackScrollLayout;
+import com.android.systemui.util.Compile;
import com.android.systemui.util.DumpUtilsKt;
import java.io.PrintWriter;
@@ -52,7 +53,8 @@
public abstract class ExpandableView extends FrameLayout implements Dumpable, Roundable {
private static final String TAG = "ExpandableView";
/** whether the dump() for this class should include verbose details */
- protected static final boolean DUMP_VERBOSE = false;
+ protected static final boolean DUMP_VERBOSE =
+ Compile.IS_DEBUG && Log.isLoggable(TAG, Log.VERBOSE);
private RoundableState mRoundableState = null;
protected OnHeightChangedListener mOnHeightChangedListener;
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/NotificationBackgroundView.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/NotificationBackgroundView.java
index da8d2d5..647505c 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/NotificationBackgroundView.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/NotificationBackgroundView.java
@@ -16,6 +16,8 @@
package com.android.systemui.statusbar.notification.row;
+import static com.android.systemui.util.ColorUtilKt.hexColorString;
+
import android.content.Context;
import android.content.res.ColorStateList;
import android.graphics.Canvas;
@@ -27,6 +29,9 @@
import android.util.AttributeSet;
import android.view.View;
+import androidx.annotation.NonNull;
+import androidx.annotation.Nullable;
+
import com.android.internal.util.ArrayUtils;
import com.android.systemui.Dumpable;
import com.android.systemui.R;
@@ -44,6 +49,7 @@
private int mClipTopAmount;
private int mClipBottomAmount;
private int mTintColor;
+ @Nullable private Integer mRippleColor;
private final float[] mCornerRadii = new float[8];
private boolean mBottomIsRounded;
private boolean mBottomAmountClips = true;
@@ -127,6 +133,7 @@
unscheduleDrawable(mBackground);
}
mBackground = background;
+ mRippleColor = null;
mBackground.mutate();
if (mBackground != null) {
mBackground.setCallback(this);
@@ -215,6 +222,9 @@
if (mBackground instanceof RippleDrawable) {
RippleDrawable ripple = (RippleDrawable) mBackground;
ripple.setColor(ColorStateList.valueOf(color));
+ mRippleColor = color;
+ } else {
+ mRippleColor = null;
}
}
@@ -290,7 +300,7 @@
}
@Override
- public void dump(PrintWriter pw, String[] args) {
+ public void dump(PrintWriter pw, @NonNull String[] args) {
pw.println("mDontModifyCorners: " + mDontModifyCorners);
pw.println("mClipTopAmount: " + mClipTopAmount);
pw.println("mClipBottomAmount: " + mClipBottomAmount);
@@ -299,5 +309,8 @@
pw.println("mBottomAmountClips: " + mBottomAmountClips);
pw.println("mActualWidth: " + mActualWidth);
pw.println("mActualHeight: " + mActualHeight);
+ pw.println("mTintColor: " + hexColorString(mTintColor));
+ pw.println("mRippleColor: " + hexColorString(mRippleColor));
+ pw.println("mBackground: " + mBackground);
}
}
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 453dd1b..620d282 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
@@ -14,11 +14,7 @@
package com.android.systemui.statusbar.phone.fragment;
-import static android.app.StatusBarManager.DISABLE2_SYSTEM_ICONS;
-import static android.app.StatusBarManager.DISABLE_CLOCK;
-import static android.app.StatusBarManager.DISABLE_NOTIFICATION_ICONS;
-import static android.app.StatusBarManager.DISABLE_ONGOING_CALL_CHIP;
-import static android.app.StatusBarManager.DISABLE_SYSTEM_INFO;
+
import static com.android.systemui.statusbar.events.SystemStatusAnimationSchedulerKt.IDLE;
import static com.android.systemui.statusbar.events.SystemStatusAnimationSchedulerKt.SHOWING_PERSISTENT_DOT;
@@ -112,8 +108,13 @@
private View mClockView;
private View mOngoingCallChip;
private View mNotificationIconAreaInner;
- private int mDisabled1;
- private int mDisabled2;
+ // Visibilities come in from external system callers via disable flags, but we also sometimes
+ // modify the visibilities internally. We need to store both so that we don't accidentally
+ // propagate our internally modified flags for too long.
+ private StatusBarVisibilityModel mLastSystemVisibility =
+ StatusBarVisibilityModel.createDefaultModel();
+ private StatusBarVisibilityModel mLastModifiedVisibility =
+ StatusBarVisibilityModel.createDefaultModel();
private DarkIconManager mDarkIconManager;
private final StatusBarFragmentComponent.Factory mStatusBarFragmentComponentFactory;
private final CommandQueue mCommandQueue;
@@ -141,7 +142,7 @@
private final OngoingCallListener mOngoingCallListener = new OngoingCallListener() {
@Override
public void onOngoingCallStateChanged(boolean animate) {
- disable(getContext().getDisplayId(), mDisabled1, mDisabled2, animate);
+ updateStatusBarVisibilities(animate);
}
};
private OperatorNameViewController mOperatorNameViewController;
@@ -388,8 +389,7 @@
}
notificationIconArea.addView(mNotificationIconAreaInner);
- // #disable should have already been called, so use the disable values to set visibility.
- updateNotificationIconAreaAndCallChip(mDisabled1, false);
+ updateNotificationIconAreaAndCallChip(/* animate= */ false);
}
/**
@@ -408,49 +408,50 @@
if (displayId != getContext().getDisplayId()) {
return;
}
+ mCollapsedStatusBarFragmentLogger
+ .logDisableFlagChange(new DisableState(state1, state2));
+ mLastSystemVisibility =
+ StatusBarVisibilityModel.createModelFromFlags(state1, state2);
+ updateStatusBarVisibilities(animate);
+ }
- int state1BeforeAdjustment = state1;
- state1 = adjustDisableFlags(state1);
+ private void updateStatusBarVisibilities(boolean animate) {
+ StatusBarVisibilityModel previousModel = mLastModifiedVisibility;
+ StatusBarVisibilityModel newModel = calculateInternalModel(mLastSystemVisibility);
+ mCollapsedStatusBarFragmentLogger.logVisibilityModel(newModel);
+ mLastModifiedVisibility = newModel;
- mCollapsedStatusBarFragmentLogger.logDisableFlagChange(
- /* new= */ new DisableState(state1BeforeAdjustment, state2),
- /* newAfterLocalModification= */ new DisableState(state1, state2));
-
- final int old1 = mDisabled1;
- final int diff1 = state1 ^ old1;
- final int old2 = mDisabled2;
- final int diff2 = state2 ^ old2;
- mDisabled1 = state1;
- mDisabled2 = state2;
- if ((diff1 & DISABLE_SYSTEM_INFO) != 0 || ((diff2 & DISABLE2_SYSTEM_ICONS) != 0)) {
- if ((state1 & DISABLE_SYSTEM_INFO) != 0 || ((state2 & DISABLE2_SYSTEM_ICONS) != 0)) {
- hideEndSideContent(animate);
- hideOperatorName(animate);
- } else {
+ if (newModel.getShowSystemInfo() != previousModel.getShowSystemInfo()) {
+ if (newModel.getShowSystemInfo()) {
showEndSideContent(animate);
showOperatorName(animate);
+ } else {
+ hideEndSideContent(animate);
+ hideOperatorName(animate);
}
}
// The ongoing call chip and notification icon visibilities are intertwined, so update both
// if either change.
- if (((diff1 & DISABLE_ONGOING_CALL_CHIP) != 0)
- || ((diff1 & DISABLE_NOTIFICATION_ICONS) != 0)) {
- updateNotificationIconAreaAndCallChip(state1, animate);
+ if (newModel.getShowNotificationIcons() != previousModel.getShowNotificationIcons()
+ || newModel.getShowOngoingCallChip() != previousModel.getShowOngoingCallChip()) {
+ updateNotificationIconAreaAndCallChip(animate);
}
// The clock may have already been hidden, but we might want to shift its
// visibility to GONE from INVISIBLE or vice versa
- if ((diff1 & DISABLE_CLOCK) != 0 || mClockView.getVisibility() != clockHiddenMode()) {
- if ((state1 & DISABLE_CLOCK) != 0) {
- hideClock(animate);
- } else {
+ if (newModel.getShowClock() != previousModel.getShowClock()
+ || mClockView.getVisibility() != clockHiddenMode()) {
+ if (newModel.getShowClock()) {
showClock(animate);
+ } else {
+ hideClock(animate);
}
}
}
- protected int adjustDisableFlags(int state) {
+ private StatusBarVisibilityModel calculateInternalModel(
+ StatusBarVisibilityModel externalModel) {
boolean headsUpVisible =
mStatusBarFragmentComponent.getHeadsUpAppearanceController().shouldBeVisible();
@@ -459,34 +460,31 @@
&& shouldHideNotificationIcons()
&& !(mStatusBarStateController.getState() == StatusBarState.KEYGUARD
&& headsUpVisible)) {
- state |= DISABLE_NOTIFICATION_ICONS;
- state |= DISABLE_SYSTEM_INFO;
- state |= DISABLE_CLOCK;
+ // Hide everything
+ return new StatusBarVisibilityModel(
+ /* showClock= */ false,
+ /* showNotificationIcons= */ false,
+ /* showOngoingCallChip= */ false,
+ /* showSystemInfo= */ false);
}
- if (mOngoingCallController.hasOngoingCall()) {
- state &= ~DISABLE_ONGOING_CALL_CHIP;
- } else {
- state |= DISABLE_ONGOING_CALL_CHIP;
- }
-
- if (headsUpVisible) {
- // Disable everything on the left side of the status bar, since the app name for the
- // heads up notification appears there instead.
- state |= DISABLE_CLOCK;
- state |= DISABLE_ONGOING_CALL_CHIP;
- }
-
- return state;
+ boolean showClock = externalModel.getShowClock() && !headsUpVisible;
+ boolean showOngoingCallChip = mOngoingCallController.hasOngoingCall() && !headsUpVisible;
+ return new StatusBarVisibilityModel(
+ showClock,
+ externalModel.getShowNotificationIcons(),
+ showOngoingCallChip,
+ externalModel.getShowSystemInfo());
}
/**
* Updates the visibility of the notification icon area and ongoing call chip based on disabled1
* state.
*/
- private void updateNotificationIconAreaAndCallChip(int state1, boolean animate) {
- boolean disableNotifications = (state1 & DISABLE_NOTIFICATION_ICONS) != 0;
- boolean hasOngoingCall = (state1 & DISABLE_ONGOING_CALL_CHIP) == 0;
+ private void updateNotificationIconAreaAndCallChip(boolean animate) {
+ StatusBarVisibilityModel visibilityModel = mLastModifiedVisibility;
+ boolean disableNotifications = !visibilityModel.getShowNotificationIcons();
+ boolean hasOngoingCall = visibilityModel.getShowOngoingCallChip();
// Hide notifications if the disable flag is set or we have an ongoing call.
if (disableNotifications || hasOngoingCall) {
@@ -683,7 +681,7 @@
@Override
public void onDozingChanged(boolean isDozing) {
- disable(getContext().getDisplayId(), mDisabled1, mDisabled2, false /* animate */);
+ updateStatusBarVisibilities(/* animate= */ false);
}
@Nullable
@@ -698,10 +696,6 @@
return mSystemEventAnimator.onSystemEventAnimationFinish(hasPersistentDot);
}
- private boolean isSystemIconAreaDisabled() {
- return (mDisabled1 & DISABLE_SYSTEM_INFO) != 0 || (mDisabled2 & DISABLE2_SYSTEM_ICONS) != 0;
- }
-
private void updateStatusBarLocation(int left, int right) {
int leftMargin = left - mStatusBar.getLeft();
int rightMargin = mStatusBar.getRight() - right;
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/fragment/CollapsedStatusBarFragmentLogger.kt b/packages/SystemUI/src/com/android/systemui/statusbar/phone/fragment/CollapsedStatusBarFragmentLogger.kt
index d64bc58..59f74ec 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/fragment/CollapsedStatusBarFragmentLogger.kt
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/fragment/CollapsedStatusBarFragmentLogger.kt
@@ -37,7 +37,6 @@
*/
fun logDisableFlagChange(
new: DisableFlagsLogger.DisableState,
- newAfterLocalModification: DisableFlagsLogger.DisableState
) {
buffer.log(
TAG,
@@ -45,19 +44,34 @@
{
int1 = new.disable1
int2 = new.disable2
- long1 = newAfterLocalModification.disable1.toLong()
- long2 = newAfterLocalModification.disable2.toLong()
},
{
disableFlagsLogger.getDisableFlagsString(
old = null,
new = DisableFlagsLogger.DisableState(int1, int2),
- newAfterLocalModification =
- DisableFlagsLogger.DisableState(long1.toInt(), long2.toInt())
)
}
)
}
+
+ fun logVisibilityModel(model: StatusBarVisibilityModel) {
+ buffer.log(
+ TAG,
+ LogLevel.INFO,
+ {
+ bool1 = model.showClock
+ bool2 = model.showNotificationIcons
+ bool3 = model.showOngoingCallChip
+ bool4 = model.showSystemInfo
+ },
+ { "New visibilities calculated internally. " +
+ "showClock=$bool1 " +
+ "showNotificationIcons=$bool2 " +
+ "showOngoingCallChip=$bool3 " +
+ "showSystemInfo=$bool4"
+ }
+ )
+ }
}
private const val TAG = "CollapsedSbFragment"
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/fragment/StatusBarVisibilityModel.kt b/packages/SystemUI/src/com/android/systemui/statusbar/phone/fragment/StatusBarVisibilityModel.kt
new file mode 100644
index 0000000..cf54cb7
--- /dev/null
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/fragment/StatusBarVisibilityModel.kt
@@ -0,0 +1,58 @@
+/*
+ * Copyright (C) 2023 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the
+ * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the specific language governing
+ * permissions and limitations under the License.
+ */
+
+package com.android.systemui.statusbar.phone.fragment
+
+import android.app.StatusBarManager.DISABLE2_NONE
+import android.app.StatusBarManager.DISABLE2_SYSTEM_ICONS
+import android.app.StatusBarManager.DISABLE_CLOCK
+import android.app.StatusBarManager.DISABLE_NONE
+import android.app.StatusBarManager.DISABLE_NOTIFICATION_ICONS
+import android.app.StatusBarManager.DISABLE_ONGOING_CALL_CHIP
+import android.app.StatusBarManager.DISABLE_SYSTEM_INFO
+
+/** A model for which parts of the status bar should be visible or not visible. */
+data class StatusBarVisibilityModel(
+ val showClock: Boolean,
+ val showNotificationIcons: Boolean,
+ val showOngoingCallChip: Boolean,
+ val showSystemInfo: Boolean,
+) {
+ companion object {
+ /** Creates the default model. */
+ @JvmStatic
+ fun createDefaultModel(): StatusBarVisibilityModel {
+ return createModelFromFlags(DISABLE_NONE, DISABLE2_NONE)
+ }
+
+ /**
+ * Given a set of disabled flags, converts them into the correct visibility statuses.
+ *
+ * See [CommandQueue.Callbacks.disable].
+ */
+ @JvmStatic
+ fun createModelFromFlags(disabled1: Int, disabled2: Int): StatusBarVisibilityModel {
+ return StatusBarVisibilityModel(
+ showClock = (disabled1 and DISABLE_CLOCK) == 0,
+ showNotificationIcons = (disabled1 and DISABLE_NOTIFICATION_ICONS) == 0,
+ // TODO(b/279899176): [CollapsedStatusBarFragment] always overwrites this with the
+ // value of [OngoingCallController]. Do we need to process the flag here?
+ showOngoingCallChip = (disabled1 and DISABLE_ONGOING_CALL_CHIP) == 0,
+ showSystemInfo =
+ (disabled1 and DISABLE_SYSTEM_INFO) == 0 &&
+ (disabled2 and DISABLE2_SYSTEM_ICONS) == 0
+ )
+ }
+ }
+}
diff --git a/packages/SystemUI/src/com/android/systemui/util/ColorUtil.kt b/packages/SystemUI/src/com/android/systemui/util/ColorUtil.kt
index 27a53bf..41b3145 100644
--- a/packages/SystemUI/src/com/android/systemui/util/ColorUtil.kt
+++ b/packages/SystemUI/src/com/android/systemui/util/ColorUtil.kt
@@ -19,6 +19,7 @@
import android.content.res.TypedArray
import android.graphics.Color
import android.view.ContextThemeWrapper
+import androidx.annotation.ColorInt
/** Returns an ARGB color version of [color] at the given [alpha]. */
fun getColorWithAlpha(color: Int, alpha: Float): Int =
@@ -35,8 +36,11 @@
* otherwise, returns the color from the private attribute {@param privAttrId}.
*/
fun getPrivateAttrColorIfUnset(
- ctw: ContextThemeWrapper, attrArray: TypedArray,
- attrIndex: Int, defColor: Int, privAttrId: Int
+ ctw: ContextThemeWrapper,
+ attrArray: TypedArray,
+ attrIndex: Int,
+ defColor: Int,
+ privAttrId: Int
): Int {
// If the index is specified, use that value
var a = attrArray
@@ -51,3 +55,8 @@
a.recycle()
return color
}
+
+/** Returns the color as a HTML hex color (or null) */
+fun hexColorString(@ColorInt color: Int?): String = color
+ ?.let { String.format("#%08x", it) }
+ ?: "null"
diff --git a/packages/SystemUI/tests/src/com/android/systemui/dump/DumpManagerTest.kt b/packages/SystemUI/tests/src/com/android/systemui/dump/DumpManagerTest.kt
index 0c5a74c..5582614 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/dump/DumpManagerTest.kt
+++ b/packages/SystemUI/tests/src/com/android/systemui/dump/DumpManagerTest.kt
@@ -60,16 +60,14 @@
// WHEN a dumpable is dumped explicitly
val args = arrayOf<String>()
- dumpManager.dumpTarget("dumpable2", pw, arrayOf(), tailLength = 0)
+ dumpManager.dumpTarget("dumpable2", pw, args, tailLength = 0)
// THEN only the requested one has their dump() method called
- verify(dumpable1, never())
- .dump(any(PrintWriter::class.java), any(Array<String>::class.java))
+ verify(dumpable1, never()).dump(any(), any())
verify(dumpable2).dump(pw, args)
- verify(dumpable3, never())
- .dump(any(PrintWriter::class.java), any(Array<String>::class.java))
- verify(buffer1, never()).dump(any(PrintWriter::class.java), anyInt())
- verify(buffer2, never()).dump(any(PrintWriter::class.java), anyInt())
+ verify(dumpable3, never()).dump(any(), any())
+ verify(buffer1, never()).dump(any(), anyInt())
+ verify(buffer2, never()).dump(any(), anyInt())
}
@Test
@@ -82,17 +80,15 @@
dumpManager.registerBuffer("buffer2", buffer2)
// WHEN a buffer is dumped explicitly
- dumpManager.dumpTarget("buffer1", pw, arrayOf(), tailLength = 14)
+ val args = arrayOf<String>()
+ dumpManager.dumpTarget("buffer1", pw, args, tailLength = 14)
// THEN only the requested one has their dump() method called
- verify(dumpable1, never())
- .dump(any(PrintWriter::class.java), any(Array<String>::class.java))
- verify(dumpable2, never())
- .dump(any(PrintWriter::class.java), any(Array<String>::class.java))
- verify(dumpable2, never())
- .dump(any(PrintWriter::class.java), any(Array<String>::class.java))
+ verify(dumpable1, never()).dump(any(), any())
+ verify(dumpable2, never()).dump(any(), any())
+ verify(dumpable3, never()).dump(any(), any())
verify(buffer1).dump(pw, tailLength = 14)
- verify(buffer2, never()).dump(any(PrintWriter::class.java), anyInt())
+ verify(buffer2, never()).dump(any(), anyInt())
}
@Test
@@ -109,6 +105,122 @@
}
@Test
+ fun testDumpTarget_selectsShortestNamedDumpable() {
+ // GIVEN a variety of registered dumpables and buffers
+ dumpManager.registerCriticalDumpable("first-dumpable", dumpable1)
+ dumpManager.registerCriticalDumpable("scnd-dumpable", dumpable2)
+ dumpManager.registerCriticalDumpable("third-dumpable", dumpable3)
+
+ // WHEN a dumpable is dumped by a suffix that matches multiple options
+ val args = arrayOf<String>()
+ dumpManager.dumpTarget("dumpable", pw, args, tailLength = 0)
+
+ // THEN the matching dumpable with the shorter name is dumped
+ verify(dumpable1, never()).dump(any(), any())
+ verify(dumpable2).dump(pw, args)
+ verify(dumpable3, never()).dump(any(), any())
+ }
+
+ @Test
+ fun testDumpTarget_selectsShortestNamedBuffer() {
+ // GIVEN a variety of registered dumpables and buffers
+ dumpManager.registerBuffer("first-buffer", buffer1)
+ dumpManager.registerBuffer("scnd-buffer", buffer2)
+
+ // WHEN a dumpable is dumped by a suffix that matches multiple options
+ val args = arrayOf<String>()
+ dumpManager.dumpTarget("buffer", pw, args, tailLength = 14)
+
+ // THEN the matching buffer with the shorter name is dumped
+ verify(buffer1, never()).dump(any(), anyInt())
+ verify(buffer2).dump(pw, tailLength = 14)
+ }
+
+ @Test
+ fun testDumpTarget_selectsShortestNamedMatch_dumpable() {
+ // GIVEN a variety of registered dumpables and buffers
+ dumpManager.registerCriticalDumpable("dumpable1", dumpable1)
+ dumpManager.registerCriticalDumpable("dumpable2", dumpable2)
+ dumpManager.registerCriticalDumpable("dumpable3", dumpable3)
+ dumpManager.registerBuffer("big-buffer1", buffer1)
+ dumpManager.registerBuffer("big-buffer2", buffer2)
+
+ // WHEN a dumpable is dumped by a suffix that matches multiple options
+ val args = arrayOf<String>()
+ dumpManager.dumpTarget("2", pw, args, tailLength = 14)
+
+ // THEN the matching dumpable with the shorter name is dumped
+ verify(dumpable1, never()).dump(any(), any())
+ verify(dumpable2).dump(pw, args)
+ verify(dumpable3, never()).dump(any(), any())
+ verify(buffer1, never()).dump(any(), anyInt())
+ verify(buffer2, never()).dump(any(), anyInt())
+ }
+
+ @Test
+ fun testDumpTarget_selectsShortestNamedMatch_buffer() {
+ // GIVEN a variety of registered dumpables and buffers
+ dumpManager.registerCriticalDumpable("dumpable1", dumpable1)
+ dumpManager.registerCriticalDumpable("dumpable2", dumpable2)
+ dumpManager.registerCriticalDumpable("dumpable3", dumpable3)
+ dumpManager.registerBuffer("buffer1", buffer1)
+ dumpManager.registerBuffer("buffer2", buffer2)
+
+ // WHEN a dumpable is dumped by a suffix that matches multiple options
+ val args = arrayOf<String>()
+ dumpManager.dumpTarget("2", pw, args, tailLength = 14)
+
+ // THEN the matching buffer with the shorter name is dumped
+ verify(dumpable1, never()).dump(any(), any())
+ verify(dumpable2, never()).dump(any(), any())
+ verify(dumpable3, never()).dump(any(), any())
+ verify(buffer1, never()).dump(any(), anyInt())
+ verify(buffer2).dump(pw, tailLength = 14)
+ }
+
+ @Test
+ fun testDumpTarget_selectsTheAlphabeticallyFirstShortestMatch_dumpable() {
+ // GIVEN a variety of registered dumpables and buffers
+ dumpManager.registerCriticalDumpable("d1x", dumpable1)
+ dumpManager.registerCriticalDumpable("d2x", dumpable2)
+ dumpManager.registerCriticalDumpable("a3x", dumpable3)
+ dumpManager.registerBuffer("ab1x", buffer1)
+ dumpManager.registerBuffer("b2x", buffer2)
+
+ // WHEN a dumpable is dumped by a suffix that matches multiple options
+ val args = arrayOf<String>()
+ dumpManager.dumpTarget("x", pw, args, tailLength = 14)
+
+ // THEN the alphabetically first dumpable/buffer (of the 3 letter names) is dumped
+ verify(dumpable1, never()).dump(any(), any())
+ verify(dumpable2, never()).dump(any(), any())
+ verify(dumpable3).dump(pw, args)
+ verify(buffer1, never()).dump(any(), anyInt())
+ verify(buffer2, never()).dump(any(), anyInt())
+ }
+
+ @Test
+ fun testDumpTarget_selectsTheAlphabeticallyFirstShortestMatch_buffer() {
+ // GIVEN a variety of registered dumpables and buffers
+ dumpManager.registerCriticalDumpable("d1x", dumpable1)
+ dumpManager.registerCriticalDumpable("d2x", dumpable2)
+ dumpManager.registerCriticalDumpable("az1x", dumpable3)
+ dumpManager.registerBuffer("b1x", buffer1)
+ dumpManager.registerBuffer("b2x", buffer2)
+
+ // WHEN a dumpable is dumped by a suffix that matches multiple options
+ val args = arrayOf<String>()
+ dumpManager.dumpTarget("x", pw, args, tailLength = 14)
+
+ // THEN the alphabetically first dumpable/buffer (of the 3 letter names) is dumped
+ verify(dumpable1, never()).dump(any(), any())
+ verify(dumpable2, never()).dump(any(), any())
+ verify(dumpable3, never()).dump(any(), any())
+ verify(buffer1).dump(pw, tailLength = 14)
+ verify(buffer2, never()).dump(any(), anyInt())
+ }
+
+ @Test
fun testDumpDumpables() {
// GIVEN a variety of registered dumpables and buffers
dumpManager.registerCriticalDumpable("dumpable1", dumpable1)
@@ -125,8 +237,8 @@
verify(dumpable1).dump(pw, args)
verify(dumpable2).dump(pw, args)
verify(dumpable3).dump(pw, args)
- verify(buffer1, never()).dump(any(PrintWriter::class.java), anyInt())
- verify(buffer2, never()).dump(any(PrintWriter::class.java), anyInt())
+ verify(buffer1, never()).dump(any(), anyInt())
+ verify(buffer2, never()).dump(any(), anyInt())
}
@Test
@@ -142,12 +254,9 @@
dumpManager.dumpBuffers(pw, tailLength = 1)
// THEN all buffers are dumped (and no dumpables)
- verify(dumpable1, never())
- .dump(any(PrintWriter::class.java), any(Array<String>::class.java))
- verify(dumpable2, never())
- .dump(any(PrintWriter::class.java), any(Array<String>::class.java))
- verify(dumpable3, never())
- .dump(any(PrintWriter::class.java), any(Array<String>::class.java))
+ verify(dumpable1, never()).dump(any(), any())
+ verify(dumpable2, never()).dump(any(), any())
+ verify(dumpable3, never()).dump(any(), any())
verify(buffer1).dump(pw, tailLength = 1)
verify(buffer2).dump(pw, tailLength = 1)
}
@@ -168,10 +277,9 @@
// THEN only critical modules are dumped (and no buffers)
verify(dumpable1).dump(pw, args)
verify(dumpable2).dump(pw, args)
- verify(dumpable3, never())
- .dump(any(PrintWriter::class.java), any(Array<String>::class.java))
- verify(buffer1, never()).dump(any(PrintWriter::class.java), anyInt())
- verify(buffer2, never()).dump(any(PrintWriter::class.java), anyInt())
+ verify(dumpable3, never()).dump(any(), any())
+ verify(buffer1, never()).dump(any(), anyInt())
+ verify(buffer2, never()).dump(any(), anyInt())
}
@Test
@@ -188,10 +296,8 @@
dumpManager.dumpNormal(pw, args, tailLength = 2)
// THEN the normal module and all buffers are dumped
- verify(dumpable1, never())
- .dump(any(PrintWriter::class.java), any(Array<String>::class.java))
- verify(dumpable2, never())
- .dump(any(PrintWriter::class.java), any(Array<String>::class.java))
+ verify(dumpable1, never()).dump(any(), any())
+ verify(dumpable2, never()).dump(any(), any())
verify(dumpable3).dump(pw, args)
verify(buffer1).dump(pw, tailLength = 2)
verify(buffer2).dump(pw, tailLength = 2)
@@ -213,9 +319,7 @@
// THEN the unregistered dumpables (both normal and critical) are not dumped
verify(dumpable1).dump(pw, args)
- verify(dumpable2, never())
- .dump(any(PrintWriter::class.java), any(Array<String>::class.java))
- verify(dumpable3, never())
- .dump(any(PrintWriter::class.java), any(Array<String>::class.java))
+ verify(dumpable2, never()).dump(any(), any())
+ verify(dumpable3, never()).dump(any(), any())
}
}
diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/fragment/CollapsedStatusBarFragmentLoggerTest.kt b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/fragment/CollapsedStatusBarFragmentLoggerTest.kt
index 3a0a94d..ac3b28c 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/fragment/CollapsedStatusBarFragmentLoggerTest.kt
+++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/fragment/CollapsedStatusBarFragmentLoggerTest.kt
@@ -43,15 +43,39 @@
fun logDisableFlagChange_bufferHasStates() {
val state = DisableFlagsLogger.DisableState(0, 1)
- logger.logDisableFlagChange(state, state)
+ logger.logDisableFlagChange(state)
val stringWriter = StringWriter()
buffer.dump(PrintWriter(stringWriter), tailLength = 0)
val actualString = stringWriter.toString()
- val expectedLogString = disableFlagsLogger.getDisableFlagsString(
- old = null, new = state, newAfterLocalModification = state
- )
+ val expectedLogString =
+ disableFlagsLogger.getDisableFlagsString(
+ old = null,
+ new = state,
+ newAfterLocalModification = null,
+ )
assertThat(actualString).contains(expectedLogString)
}
+
+ @Test
+ fun logVisibilityModel_bufferCorrect() {
+ logger.logVisibilityModel(
+ StatusBarVisibilityModel(
+ showClock = false,
+ showNotificationIcons = true,
+ showOngoingCallChip = false,
+ showSystemInfo = true,
+ )
+ )
+
+ val stringWriter = StringWriter()
+ buffer.dump(PrintWriter(stringWriter), tailLength = 0)
+ val actualString = stringWriter.toString()
+
+ assertThat(actualString).contains("showClock=false")
+ assertThat(actualString).contains("showNotificationIcons=true")
+ assertThat(actualString).contains("showOngoingCallChip=false")
+ assertThat(actualString).contains("showSystemInfo=true")
+ }
}
diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/fragment/CollapsedStatusBarFragmentTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/fragment/CollapsedStatusBarFragmentTest.java
index 2a3c775..03fafcb 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/fragment/CollapsedStatusBarFragmentTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/fragment/CollapsedStatusBarFragmentTest.java
@@ -16,6 +16,8 @@
import static android.view.Display.DEFAULT_DISPLAY;
+import static com.android.systemui.shade.ShadeExpansionStateManagerKt.STATE_CLOSED;
+import static com.android.systemui.shade.ShadeExpansionStateManagerKt.STATE_OPEN;
import static com.android.systemui.statusbar.events.SystemStatusAnimationSchedulerKt.ANIMATING_IN;
import static com.android.systemui.statusbar.events.SystemStatusAnimationSchedulerKt.ANIMATING_OUT;
import static com.android.systemui.statusbar.events.SystemStatusAnimationSchedulerKt.IDLE;
@@ -93,6 +95,7 @@
public class CollapsedStatusBarFragmentTest extends SysuiBaseFragmentTest {
private NotificationIconAreaController mMockNotificationAreaController;
+ private ShadeExpansionStateManager mShadeExpansionStateManager;
private View mNotificationAreaInner;
private OngoingCallController mOngoingCallController;
private SystemStatusAnimationScheduler mAnimationScheduler;
@@ -173,6 +176,10 @@
fragment.disable(DEFAULT_DISPLAY, 0, 0, false);
assertEquals(View.VISIBLE, getEndSideContentView().getVisibility());
+
+ fragment.disable(DEFAULT_DISPLAY, StatusBarManager.DISABLE_SYSTEM_INFO, 0, false);
+
+ assertEquals(View.INVISIBLE, getEndSideContentView().getVisibility());
}
@Test
@@ -278,6 +285,10 @@
fragment.disable(DEFAULT_DISPLAY, 0, 0, false);
Mockito.verify(mNotificationAreaInner, atLeast(1)).setVisibility(eq(View.VISIBLE));
+
+ fragment.disable(DEFAULT_DISPLAY, StatusBarManager.DISABLE_NOTIFICATION_ICONS, 0, false);
+
+ Mockito.verify(mNotificationAreaInner, atLeast(1)).setVisibility(eq(View.INVISIBLE));
}
@Test
@@ -291,6 +302,70 @@
fragment.disable(DEFAULT_DISPLAY, 0, 0, false);
assertEquals(View.VISIBLE, getClockView().getVisibility());
+
+ fragment.disable(DEFAULT_DISPLAY, StatusBarManager.DISABLE_CLOCK, 0, false);
+
+ assertEquals(View.GONE, getClockView().getVisibility());
+ }
+
+ @Test
+ public void disable_shadeOpenAndShouldHide_everythingHidden() {
+ CollapsedStatusBarFragment fragment = resumeAndGetFragment();
+
+ // WHEN the shade is open and configured to hide the status bar icons
+ mShadeExpansionStateManager.updateState(STATE_OPEN);
+ when(mShadeViewController.shouldHideStatusBarIconsWhenExpanded()).thenReturn(true);
+
+ fragment.disable(DEFAULT_DISPLAY, 0, 0, false);
+
+ // THEN all views are hidden
+ assertEquals(View.INVISIBLE, getClockView().getVisibility());
+ Mockito.verify(mNotificationAreaInner, atLeast(1)).setVisibility(eq(View.INVISIBLE));
+ assertEquals(View.INVISIBLE, getEndSideContentView().getVisibility());
+ }
+
+ @Test
+ public void disable_shadeOpenButNotShouldHide_everythingShown() {
+ CollapsedStatusBarFragment fragment = resumeAndGetFragment();
+
+ // WHEN the shade is open but *not* configured to hide the status bar icons
+ mShadeExpansionStateManager.updateState(STATE_OPEN);
+ when(mShadeViewController.shouldHideStatusBarIconsWhenExpanded()).thenReturn(false);
+
+ fragment.disable(DEFAULT_DISPLAY, 0, 0, false);
+
+ // THEN all views are shown
+ assertEquals(View.VISIBLE, getClockView().getVisibility());
+ Mockito.verify(mNotificationAreaInner, atLeast(1)).setVisibility(eq(View.VISIBLE));
+ assertEquals(View.VISIBLE, getEndSideContentView().getVisibility());
+ }
+
+ /** Regression test for b/279790651. */
+ @Test
+ public void disable_shadeOpenAndShouldHide_thenShadeNotOpenAndDozingUpdate_everythingShown() {
+ CollapsedStatusBarFragment fragment = resumeAndGetFragment();
+
+ // WHEN the shade is open and configured to hide the status bar icons
+ mShadeExpansionStateManager.updateState(STATE_OPEN);
+ when(mShadeViewController.shouldHideStatusBarIconsWhenExpanded()).thenReturn(true);
+
+ fragment.disable(DEFAULT_DISPLAY, 0, 0, false);
+
+ // THEN all views are hidden
+ assertEquals(View.INVISIBLE, getClockView().getVisibility());
+ Mockito.verify(mNotificationAreaInner, atLeast(1)).setVisibility(eq(View.INVISIBLE));
+ assertEquals(View.INVISIBLE, getEndSideContentView().getVisibility());
+
+ // WHEN the shade is updated to no longer be open
+ mShadeExpansionStateManager.updateState(STATE_CLOSED);
+
+ // AND we internally request an update via dozing change
+ fragment.onDozingChanged(true);
+
+ // THEN all views are shown
+ assertEquals(View.VISIBLE, getClockView().getVisibility());
+ Mockito.verify(mNotificationAreaInner, atLeast(1)).setVisibility(eq(View.VISIBLE));
+ assertEquals(View.VISIBLE, getEndSideContentView().getVisibility());
}
@Test
@@ -323,7 +398,6 @@
assertEquals(View.VISIBLE,
mFragment.getView().findViewById(R.id.ongoing_call_chip).getVisibility());
Mockito.verify(mNotificationAreaInner, atLeast(1)).setVisibility(eq(View.INVISIBLE));
-
}
@Test
@@ -356,20 +430,26 @@
public void disable_ongoingCallEnded_chipHidden() {
CollapsedStatusBarFragment fragment = resumeAndGetFragment();
- when(mOngoingCallController.hasOngoingCall()).thenReturn(true);
-
// Ongoing call started
+ when(mOngoingCallController.hasOngoingCall()).thenReturn(true);
fragment.disable(DEFAULT_DISPLAY, 0, 0, false);
+
assertEquals(View.VISIBLE,
mFragment.getView().findViewById(R.id.ongoing_call_chip).getVisibility());
// Ongoing call ended
when(mOngoingCallController.hasOngoingCall()).thenReturn(false);
-
fragment.disable(DEFAULT_DISPLAY, 0, 0, false);
assertEquals(View.GONE,
mFragment.getView().findViewById(R.id.ongoing_call_chip).getVisibility());
+
+ // Ongoing call started
+ when(mOngoingCallController.hasOngoingCall()).thenReturn(true);
+ fragment.disable(DEFAULT_DISPLAY, 0, 0, false);
+
+ assertEquals(View.VISIBLE,
+ mFragment.getView().findViewById(R.id.ongoing_call_chip).getVisibility());
}
@Test
@@ -494,6 +574,8 @@
when(mIconManagerFactory.create(any(), any())).thenReturn(mIconManager);
mSecureSettings = mock(SecureSettings.class);
+ mShadeExpansionStateManager = new ShadeExpansionStateManager();
+
setUpNotificationIconAreaController();
return new CollapsedStatusBarFragment(
mStatusBarFragmentComponentFactory,
@@ -501,7 +583,7 @@
mAnimationScheduler,
mLocationPublisher,
mMockNotificationAreaController,
- new ShadeExpansionStateManager(),
+ mShadeExpansionStateManager,
mock(FeatureFlags.class),
mStatusBarIconController,
mIconManagerFactory,
diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/fragment/StatusBarVisibilityModelTest.kt b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/fragment/StatusBarVisibilityModelTest.kt
new file mode 100644
index 0000000..8e789cb
--- /dev/null
+++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/fragment/StatusBarVisibilityModelTest.kt
@@ -0,0 +1,108 @@
+/*
+ * Copyright (C) 2023 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the
+ * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the specific language governing
+ * permissions and limitations under the License.
+ */
+
+package com.android.systemui.statusbar.phone.fragment
+
+import android.app.StatusBarManager.DISABLE2_SYSTEM_ICONS
+import android.app.StatusBarManager.DISABLE_CLOCK
+import android.app.StatusBarManager.DISABLE_NOTIFICATION_ICONS
+import android.app.StatusBarManager.DISABLE_ONGOING_CALL_CHIP
+import android.app.StatusBarManager.DISABLE_SYSTEM_INFO
+import androidx.test.filters.SmallTest
+import com.android.systemui.SysuiTestCase
+import com.android.systemui.statusbar.phone.fragment.StatusBarVisibilityModel.Companion.createDefaultModel
+import com.android.systemui.statusbar.phone.fragment.StatusBarVisibilityModel.Companion.createModelFromFlags
+import com.google.common.truth.Truth.assertThat
+import org.junit.Test
+
+@SmallTest
+class StatusBarVisibilityModelTest : SysuiTestCase() {
+ @Test
+ fun createDefaultModel_everythingEnabled() {
+ val result = createDefaultModel()
+
+ val expected =
+ StatusBarVisibilityModel(
+ showClock = true,
+ showNotificationIcons = true,
+ showOngoingCallChip = true,
+ showSystemInfo = true,
+ )
+
+ assertThat(result).isEqualTo(expected)
+ }
+
+ @Test
+ fun createModelFromFlags_clockNotDisabled_showClockTrue() {
+ val result = createModelFromFlags(disabled1 = 0, disabled2 = 0)
+
+ assertThat(result.showClock).isTrue()
+ }
+
+ @Test
+ fun createModelFromFlags_clockDisabled_showClockFalse() {
+ val result = createModelFromFlags(disabled1 = DISABLE_CLOCK, disabled2 = 0)
+
+ assertThat(result.showClock).isFalse()
+ }
+
+ @Test
+ fun createModelFromFlags_notificationIconsNotDisabled_showNotificationIconsTrue() {
+ val result = createModelFromFlags(disabled1 = 0, disabled2 = 0)
+
+ assertThat(result.showNotificationIcons).isTrue()
+ }
+
+ @Test
+ fun createModelFromFlags_notificationIconsDisabled_showNotificationIconsFalse() {
+ val result = createModelFromFlags(disabled1 = DISABLE_NOTIFICATION_ICONS, disabled2 = 0)
+
+ assertThat(result.showNotificationIcons).isFalse()
+ }
+
+ @Test
+ fun createModelFromFlags_ongoingCallChipNotDisabled_showOngoingCallChipTrue() {
+ val result = createModelFromFlags(disabled1 = 0, disabled2 = 0)
+
+ assertThat(result.showOngoingCallChip).isTrue()
+ }
+
+ @Test
+ fun createModelFromFlags_ongoingCallChipDisabled_showOngoingCallChipFalse() {
+ val result = createModelFromFlags(disabled1 = DISABLE_ONGOING_CALL_CHIP, disabled2 = 0)
+
+ assertThat(result.showOngoingCallChip).isFalse()
+ }
+
+ @Test
+ fun createModelFromFlags_systemInfoAndIconsNotDisabled_showSystemInfoTrue() {
+ val result = createModelFromFlags(disabled1 = 0, disabled2 = 0)
+
+ assertThat(result.showSystemInfo).isTrue()
+ }
+
+ @Test
+ fun createModelFromFlags_disable1SystemInfoDisabled_showSystemInfoFalse() {
+ val result = createModelFromFlags(disabled1 = DISABLE_SYSTEM_INFO, disabled2 = 0)
+
+ assertThat(result.showSystemInfo).isFalse()
+ }
+
+ @Test
+ fun createModelFromFlags_disable2SystemIconsDisabled_showSystemInfoFalse() {
+ val result = createModelFromFlags(disabled1 = 0, disabled2 = DISABLE2_SYSTEM_ICONS)
+
+ assertThat(result.showSystemInfo).isFalse()
+ }
+}
diff --git a/services/core/java/com/android/server/am/ActiveServices.java b/services/core/java/com/android/server/am/ActiveServices.java
index 1f1f0e9..ca50af8 100644
--- a/services/core/java/com/android/server/am/ActiveServices.java
+++ b/services/core/java/com/android/server/am/ActiveServices.java
@@ -8240,7 +8240,11 @@
: ForegroundServiceDelegationOptions.DELEGATION_SERVICE_DEFAULT,
0 /* api_sate */,
null /* api_type */,
- null /* api_timestamp */);
+ null /* api_timestamp */,
+ mAm.getUidStateLocked(r.appInfo.uid),
+ mAm.getUidProcessCapabilityLocked(r.appInfo.uid),
+ mAm.getUidStateLocked(r.mRecentCallingUid),
+ mAm.getUidProcessCapabilityLocked(r.mRecentCallingUid));
int event = 0;
if (state == FOREGROUND_SERVICE_STATE_CHANGED__STATE__ENTER) {
diff --git a/services/core/java/com/android/server/am/ForegroundServiceTypeLoggerModule.java b/services/core/java/com/android/server/am/ForegroundServiceTypeLoggerModule.java
index 8f84b08..490a023 100644
--- a/services/core/java/com/android/server/am/ForegroundServiceTypeLoggerModule.java
+++ b/services/core/java/com/android/server/am/ForegroundServiceTypeLoggerModule.java
@@ -28,6 +28,7 @@
import static android.os.Process.INVALID_UID;
import android.annotation.IntDef;
+import android.app.ActivityManager;
import android.app.ActivityManager.ForegroundServiceApiType;
import android.app.ForegroundServiceDelegationOptions;
import android.content.ComponentName;
@@ -466,7 +467,11 @@
: ForegroundServiceDelegationOptions.DELEGATION_SERVICE_DEFAULT,
apiState,
apiType,
- timestamp);
+ timestamp,
+ ActivityManager.PROCESS_STATE_UNKNOWN,
+ ActivityManager.PROCESS_CAPABILITY_NONE,
+ ActivityManager.PROCESS_STATE_UNKNOWN,
+ ActivityManager.PROCESS_CAPABILITY_NONE);
}
/**
@@ -500,7 +505,11 @@
0,
apiState,
apiType,
- timestamp);
+ timestamp,
+ ActivityManager.PROCESS_STATE_UNKNOWN,
+ ActivityManager.PROCESS_CAPABILITY_NONE,
+ ActivityManager.PROCESS_STATE_UNKNOWN,
+ ActivityManager.PROCESS_CAPABILITY_NONE);
}
/**
diff --git a/services/core/java/com/android/server/biometrics/sensors/SensorList.java b/services/core/java/com/android/server/biometrics/sensors/SensorList.java
new file mode 100644
index 0000000..1cff92f
--- /dev/null
+++ b/services/core/java/com/android/server/biometrics/sensors/SensorList.java
@@ -0,0 +1,97 @@
+/*
+ * Copyright (C) 2023 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.server.biometrics.sensors;
+
+import android.app.IActivityManager;
+import android.app.SynchronousUserSwitchObserver;
+import android.os.RemoteException;
+import android.os.UserHandle;
+import android.util.Slog;
+import android.util.SparseArray;
+
+/**
+ * Keep track of the sensors that is supported by the HAL.
+ * @param <T> T is either face sensor or fingerprint sensor.
+ */
+public class SensorList<T> {
+ private static final String TAG = "SensorList";
+ private final SparseArray<T> mSensors;
+ private final IActivityManager mActivityManager;
+
+ public SensorList(IActivityManager activityManager) {
+ mSensors = new SparseArray<T>();
+ mActivityManager = activityManager;
+ }
+
+ /**
+ * Adding sensor to the map with the sensor id as key. Also, starts a session if the user Id is
+ * NULL.
+ */
+ public void addSensor(int sensorId, T sensor, int sessionUserId,
+ SynchronousUserSwitchObserver userSwitchObserver) {
+ mSensors.put(sensorId, sensor);
+ registerUserSwitchObserver(sessionUserId, userSwitchObserver);
+ }
+
+ private void registerUserSwitchObserver(int sessionUserId,
+ SynchronousUserSwitchObserver userSwitchObserver) {
+ try {
+ mActivityManager.registerUserSwitchObserver(userSwitchObserver,
+ TAG);
+ if (sessionUserId == UserHandle.USER_NULL) {
+ userSwitchObserver.onUserSwitching(UserHandle.USER_SYSTEM);
+ }
+ } catch (RemoteException e) {
+ Slog.e(TAG, "Unable to register user switch observer");
+ }
+ }
+
+ /**
+ * Returns the sensor corresponding to the key at a specific position.
+ */
+ public T valueAt(int position) {
+ return mSensors.valueAt(position);
+ }
+
+ /**
+ * Returns the sensor associated with sensorId as key.
+ */
+ public T get(int sensorId) {
+ return mSensors.get(sensorId);
+ }
+
+ /**
+ * Returns the sensorId at the specified position.
+ */
+ public int keyAt(int position) {
+ return mSensors.keyAt(position);
+ }
+
+ /**
+ * Returns the number of sensors added.
+ */
+ public int size() {
+ return mSensors.size();
+ }
+
+ /**
+ * Returns true if a sensor exists for the specified sensorId.
+ */
+ public boolean contains(int sensorId) {
+ return mSensors.contains(sensorId);
+ }
+}
diff --git a/services/core/java/com/android/server/biometrics/sensors/face/aidl/FaceProvider.java b/services/core/java/com/android/server/biometrics/sensors/face/aidl/FaceProvider.java
index c5037b7..a501647 100644
--- a/services/core/java/com/android/server/biometrics/sensors/face/aidl/FaceProvider.java
+++ b/services/core/java/com/android/server/biometrics/sensors/face/aidl/FaceProvider.java
@@ -20,6 +20,7 @@
import android.annotation.Nullable;
import android.app.ActivityManager;
import android.app.ActivityTaskManager;
+import android.app.SynchronousUserSwitchObserver;
import android.app.TaskStackListener;
import android.content.Context;
import android.content.pm.UserInfo;
@@ -41,9 +42,9 @@
import android.os.Looper;
import android.os.RemoteException;
import android.os.ServiceManager;
+import android.os.UserHandle;
import android.os.UserManager;
import android.util.Slog;
-import android.util.SparseArray;
import android.util.proto.ProtoOutputStream;
import android.view.Surface;
@@ -62,6 +63,7 @@
import com.android.server.biometrics.sensors.InvalidationRequesterClient;
import com.android.server.biometrics.sensors.LockoutResetDispatcher;
import com.android.server.biometrics.sensors.PerformanceTracker;
+import com.android.server.biometrics.sensors.SensorList;
import com.android.server.biometrics.sensors.face.FaceUtils;
import com.android.server.biometrics.sensors.face.ServiceProvider;
import com.android.server.biometrics.sensors.face.UsageStats;
@@ -86,7 +88,7 @@
@NonNull
@VisibleForTesting
- final SparseArray<Sensor> mSensors; // Map of sensors that this HAL supports
+ final SensorList<Sensor> mFaceSensors;
@NonNull
private final Context mContext;
@NonNull
@@ -117,8 +119,8 @@
@Override
public void onTaskStackChanged() {
mHandler.post(() -> {
- for (int i = 0; i < mSensors.size(); i++) {
- final BaseClientMonitor client = mSensors.valueAt(i).getScheduler()
+ for (int i = 0; i < mFaceSensors.size(); i++) {
+ final BaseClientMonitor client = mFaceSensors.valueAt(i).getScheduler()
.getCurrentClient();
if (!(client instanceof AuthenticationClient)) {
Slog.e(getTag(), "Task stack changed for client: " + client);
@@ -133,7 +135,7 @@
&& !client.isAlreadyDone()) {
Slog.e(getTag(), "Stopping background authentication,"
+ " currentClient: " + client);
- mSensors.valueAt(i).getScheduler().cancelAuthenticationOrDetection(
+ mFaceSensors.valueAt(i).getScheduler().cancelAuthenticationOrDetection(
client.getToken(), client.getRequestId());
}
}
@@ -150,7 +152,7 @@
mContext = context;
mBiometricStateCallback = biometricStateCallback;
mHalInstanceName = halInstanceName;
- mSensors = new SparseArray<>();
+ mFaceSensors = new SensorList<>(ActivityManager.getService());
mHandler = new Handler(Looper.getMainLooper());
mUsageStats = new UsageStats(context);
mLockoutResetDispatcher = lockoutResetDispatcher;
@@ -178,8 +180,15 @@
false /* resetLockoutRequiresChallenge */);
final Sensor sensor = new Sensor(getTag() + "/" + sensorId, this, mContext, mHandler,
internalProp, lockoutResetDispatcher, mBiometricContext);
-
- mSensors.put(sensorId, sensor);
+ final int userId = sensor.getLazySession().get() == null ? UserHandle.USER_NULL :
+ sensor.getLazySession().get().getUserId();
+ mFaceSensors.addSensor(sensorId, sensor, userId,
+ new SynchronousUserSwitchObserver() {
+ @Override
+ public void onUserSwitching(int newUserId) {
+ scheduleInternalCleanup(sensorId, newUserId, null /* callback */);
+ }
+ });
Slog.d(getTag(), "Added: " + internalProp);
}
}
@@ -223,8 +232,8 @@
Slog.e(getTag(), "Unable to linkToDeath", e);
}
- for (int i = 0; i < mSensors.size(); i++) {
- final int sensorId = mSensors.keyAt(i);
+ for (int i = 0; i < mFaceSensors.size(); i++) {
+ final int sensorId = mFaceSensors.keyAt(i);
scheduleLoadAuthenticatorIds(sensorId);
scheduleInternalCleanup(sensorId, ActivityManager.getCurrentUser(),
null /* callback */);
@@ -234,20 +243,20 @@
}
private void scheduleForSensor(int sensorId, @NonNull BaseClientMonitor client) {
- if (!mSensors.contains(sensorId)) {
+ if (!mFaceSensors.contains(sensorId)) {
throw new IllegalStateException("Unable to schedule client: " + client
+ " for sensor: " + sensorId);
}
- mSensors.get(sensorId).getScheduler().scheduleClientMonitor(client);
+ mFaceSensors.get(sensorId).getScheduler().scheduleClientMonitor(client);
}
private void scheduleForSensor(int sensorId, @NonNull BaseClientMonitor client,
ClientMonitorCallback callback) {
- if (!mSensors.contains(sensorId)) {
+ if (!mFaceSensors.contains(sensorId)) {
throw new IllegalStateException("Unable to schedule client: " + client
+ " for sensor: " + sensorId);
}
- mSensors.get(sensorId).getScheduler().scheduleClientMonitor(client, callback);
+ mFaceSensors.get(sensorId).getScheduler().scheduleClientMonitor(client, callback);
}
private void scheduleLoadAuthenticatorIds(int sensorId) {
@@ -259,12 +268,12 @@
private void scheduleLoadAuthenticatorIdsForUser(int sensorId, int userId) {
mHandler.post(() -> {
final FaceGetAuthenticatorIdClient client = new FaceGetAuthenticatorIdClient(
- mContext, mSensors.get(sensorId).getLazySession(), userId,
+ mContext, mFaceSensors.get(sensorId).getLazySession(), userId,
mContext.getOpPackageName(), sensorId,
createLogger(BiometricsProtoEnums.ACTION_UNKNOWN,
BiometricsProtoEnums.CLIENT_UNKNOWN),
mBiometricContext,
- mSensors.get(sensorId).getAuthenticatorIds());
+ mFaceSensors.get(sensorId).getAuthenticatorIds());
scheduleForSensor(sensorId, client);
});
@@ -283,15 +292,15 @@
@Override
public boolean containsSensor(int sensorId) {
- return mSensors.contains(sensorId);
+ return mFaceSensors.contains(sensorId);
}
@NonNull
@Override
public List<FaceSensorPropertiesInternal> getSensorProperties() {
final List<FaceSensorPropertiesInternal> props = new ArrayList<>();
- for (int i = 0; i < mSensors.size(); ++i) {
- props.add(mSensors.valueAt(i).getSensorProperties());
+ for (int i = 0; i < mFaceSensors.size(); ++i) {
+ props.add(mFaceSensors.valueAt(i).getSensorProperties());
}
return props;
}
@@ -299,7 +308,7 @@
@NonNull
@Override
public FaceSensorPropertiesInternal getSensorProperties(int sensorId) {
- return mSensors.get(sensorId).getSensorProperties();
+ return mFaceSensors.get(sensorId).getSensorProperties();
}
@NonNull
@@ -318,11 +327,11 @@
@NonNull IInvalidationCallback callback) {
mHandler.post(() -> {
final FaceInvalidationClient client = new FaceInvalidationClient(mContext,
- mSensors.get(sensorId).getLazySession(), userId, sensorId,
+ mFaceSensors.get(sensorId).getLazySession(), userId, sensorId,
createLogger(BiometricsProtoEnums.ACTION_UNKNOWN,
BiometricsProtoEnums.CLIENT_UNKNOWN),
mBiometricContext,
- mSensors.get(sensorId).getAuthenticatorIds(), callback);
+ mFaceSensors.get(sensorId).getAuthenticatorIds(), callback);
scheduleForSensor(sensorId, client);
});
}
@@ -335,7 +344,7 @@
@Override
public long getAuthenticatorId(int sensorId, int userId) {
- return mSensors.get(sensorId).getAuthenticatorIds().getOrDefault(userId, 0L);
+ return mFaceSensors.get(sensorId).getAuthenticatorIds().getOrDefault(userId, 0L);
}
@Override
@@ -348,7 +357,7 @@
@NonNull IFaceServiceReceiver receiver, String opPackageName) {
mHandler.post(() -> {
final FaceGenerateChallengeClient client = new FaceGenerateChallengeClient(mContext,
- mSensors.get(sensorId).getLazySession(), token,
+ mFaceSensors.get(sensorId).getLazySession(), token,
new ClientMonitorCallbackConverter(receiver), userId, opPackageName, sensorId,
createLogger(BiometricsProtoEnums.ACTION_UNKNOWN,
BiometricsProtoEnums.CLIENT_UNKNOWN),
@@ -362,7 +371,8 @@
@NonNull String opPackageName, long challenge) {
mHandler.post(() -> {
final FaceRevokeChallengeClient client = new FaceRevokeChallengeClient(mContext,
- mSensors.get(sensorId).getLazySession(), token, userId, opPackageName, sensorId,
+ mFaceSensors.get(sensorId).getLazySession(), token, userId,
+ opPackageName, sensorId,
createLogger(BiometricsProtoEnums.ACTION_UNKNOWN,
BiometricsProtoEnums.CLIENT_UNKNOWN),
mBiometricContext, challenge);
@@ -377,10 +387,10 @@
@Nullable Surface previewSurface, boolean debugConsent) {
final long id = mRequestCounter.incrementAndGet();
mHandler.post(() -> {
- final int maxTemplatesPerUser = mSensors.get(
+ final int maxTemplatesPerUser = mFaceSensors.get(
sensorId).getSensorProperties().maxEnrollmentsPerUser;
final FaceEnrollClient client = new FaceEnrollClient(mContext,
- mSensors.get(sensorId).getLazySession(), token,
+ mFaceSensors.get(sensorId).getLazySession(), token,
new ClientMonitorCallbackConverter(receiver), userId, hardwareAuthToken,
opPackageName, id, FaceUtils.getInstance(sensorId), disabledFeatures,
ENROLL_TIMEOUT_SEC, previewSurface, sensorId,
@@ -406,7 +416,7 @@
@Override
public void cancelEnrollment(int sensorId, @NonNull IBinder token, long requestId) {
mHandler.post(() ->
- mSensors.get(sensorId).getScheduler().cancelEnrollment(token, requestId));
+ mFaceSensors.get(sensorId).getScheduler().cancelEnrollment(token, requestId));
}
@Override
@@ -419,7 +429,7 @@
mHandler.post(() -> {
final boolean isStrongBiometric = Utils.isStrongBiometric(sensorId);
final FaceDetectClient client = new FaceDetectClient(mContext,
- mSensors.get(sensorId).getLazySession(),
+ mFaceSensors.get(sensorId).getLazySession(),
token, id, callback, options,
createLogger(BiometricsProtoEnums.ACTION_AUTHENTICATE, statsClient),
mBiometricContext, isStrongBiometric);
@@ -431,7 +441,7 @@
@Override
public void cancelFaceDetect(int sensorId, @NonNull IBinder token, long requestId) {
- mHandler.post(() -> mSensors.get(sensorId).getScheduler()
+ mHandler.post(() -> mFaceSensors.get(sensorId).getScheduler()
.cancelAuthenticationOrDetection(token, requestId));
}
@@ -446,12 +456,12 @@
final int sensorId = options.getSensorId();
final boolean isStrongBiometric = Utils.isStrongBiometric(sensorId);
final FaceAuthenticationClient client = new FaceAuthenticationClient(
- mContext, mSensors.get(sensorId).getLazySession(), token, requestId, callback,
- operationId, restricted, options, cookie,
+ mContext, mFaceSensors.get(sensorId).getLazySession(), token, requestId,
+ callback, operationId, restricted, options, cookie,
false /* requireConfirmation */,
createLogger(BiometricsProtoEnums.ACTION_AUTHENTICATE, statsClient),
mBiometricContext, isStrongBiometric,
- mUsageStats, mSensors.get(sensorId).getLockoutCache(),
+ mUsageStats, mFaceSensors.get(sensorId).getLockoutCache(),
allowBackgroundAuthentication, Utils.getCurrentStrength(sensorId));
scheduleForSensor(sensorId, client, new ClientMonitorCallback() {
@Override
@@ -486,7 +496,7 @@
@Override
public void cancelAuthentication(int sensorId, @NonNull IBinder token, long requestId) {
- mHandler.post(() -> mSensors.get(sensorId).getScheduler()
+ mHandler.post(() -> mFaceSensors.get(sensorId).getScheduler()
.cancelAuthenticationOrDetection(token, requestId));
}
@@ -514,13 +524,13 @@
int userId, @NonNull IFaceServiceReceiver receiver, @NonNull String opPackageName) {
mHandler.post(() -> {
final FaceRemovalClient client = new FaceRemovalClient(mContext,
- mSensors.get(sensorId).getLazySession(), token,
+ mFaceSensors.get(sensorId).getLazySession(), token,
new ClientMonitorCallbackConverter(receiver), faceIds, userId,
opPackageName, FaceUtils.getInstance(sensorId), sensorId,
createLogger(BiometricsProtoEnums.ACTION_REMOVE,
BiometricsProtoEnums.CLIENT_UNKNOWN),
mBiometricContext,
- mSensors.get(sensorId).getAuthenticatorIds());
+ mFaceSensors.get(sensorId).getAuthenticatorIds());
scheduleForSensor(sensorId, client, mBiometricStateCallback);
});
}
@@ -529,12 +539,12 @@
public void scheduleResetLockout(int sensorId, int userId, @NonNull byte[] hardwareAuthToken) {
mHandler.post(() -> {
final FaceResetLockoutClient client = new FaceResetLockoutClient(
- mContext, mSensors.get(sensorId).getLazySession(), userId,
+ mContext, mFaceSensors.get(sensorId).getLazySession(), userId,
mContext.getOpPackageName(), sensorId,
createLogger(BiometricsProtoEnums.ACTION_UNKNOWN,
BiometricsProtoEnums.CLIENT_UNKNOWN),
mBiometricContext, hardwareAuthToken,
- mSensors.get(sensorId).getLockoutCache(), mLockoutResetDispatcher,
+ mFaceSensors.get(sensorId).getLockoutCache(), mLockoutResetDispatcher,
Utils.getCurrentStrength(sensorId));
scheduleForSensor(sensorId, client);
@@ -553,7 +563,7 @@
return;
}
final FaceSetFeatureClient client = new FaceSetFeatureClient(mContext,
- mSensors.get(sensorId).getLazySession(), token,
+ mFaceSensors.get(sensorId).getLazySession(), token,
new ClientMonitorCallbackConverter(receiver), userId,
mContext.getOpPackageName(), sensorId,
BiometricLogger.ofUnknown(mContext), mBiometricContext,
@@ -573,7 +583,7 @@
return;
}
final FaceGetFeatureClient client = new FaceGetFeatureClient(mContext,
- mSensors.get(sensorId).getLazySession(), token, callback, userId,
+ mFaceSensors.get(sensorId).getLazySession(), token, callback, userId,
mContext.getOpPackageName(), sensorId, BiometricLogger.ofUnknown(mContext),
mBiometricContext);
scheduleForSensor(sensorId, client);
@@ -583,7 +593,7 @@
@Override
public void startPreparedClient(int sensorId, int cookie) {
mHandler.post(() -> {
- mSensors.get(sensorId).getScheduler().startPreparedClient(cookie);
+ mFaceSensors.get(sensorId).getScheduler().startPreparedClient(cookie);
});
}
@@ -599,13 +609,13 @@
mHandler.post(() -> {
final FaceInternalCleanupClient client =
new FaceInternalCleanupClient(mContext,
- mSensors.get(sensorId).getLazySession(), userId,
+ mFaceSensors.get(sensorId).getLazySession(), userId,
mContext.getOpPackageName(), sensorId,
createLogger(BiometricsProtoEnums.ACTION_ENUMERATE,
BiometricsProtoEnums.CLIENT_UNKNOWN),
mBiometricContext,
FaceUtils.getInstance(sensorId),
- mSensors.get(sensorId).getAuthenticatorIds());
+ mFaceSensors.get(sensorId).getAuthenticatorIds());
if (favorHalEnrollments) {
client.setFavorHalEnrollments();
}
@@ -622,8 +632,8 @@
@Override
public void dumpProtoState(int sensorId, @NonNull ProtoOutputStream proto,
boolean clearSchedulerBuffer) {
- if (mSensors.contains(sensorId)) {
- mSensors.get(sensorId).dumpProtoState(sensorId, proto, clearSchedulerBuffer);
+ if (mFaceSensors.contains(sensorId)) {
+ mFaceSensors.get(sensorId).dumpProtoState(sensorId, proto, clearSchedulerBuffer);
}
}
@@ -672,7 +682,7 @@
pw.println(mBiometricContext.getAuthSessionCoordinator());
pw.println("---AuthSessionCoordinator logs end ---");
- mSensors.get(sensorId).getScheduler().dump(pw);
+ mFaceSensors.get(sensorId).getScheduler().dump(pw);
mUsageStats.print(pw);
}
@@ -680,7 +690,7 @@
@Override
public ITestSession createTestSession(int sensorId, @NonNull ITestSessionCallback callback,
@NonNull String opPackageName) {
- return mSensors.get(sensorId).createTestSession(callback);
+ return mFaceSensors.get(sensorId).createTestSession(callback);
}
@Override
@@ -692,9 +702,9 @@
Slog.e(getTag(), "HAL died");
mHandler.post(() -> {
mDaemon = null;
- for (int i = 0; i < mSensors.size(); i++) {
- final Sensor sensor = mSensors.valueAt(i);
- final int sensorId = mSensors.keyAt(i);
+ for (int i = 0; i < mFaceSensors.size(); i++) {
+ final Sensor sensor = mFaceSensors.valueAt(i);
+ final int sensorId = mFaceSensors.keyAt(i);
PerformanceTracker.getInstanceForSensorId(sensorId).incrementHALDeathCount();
sensor.onBinderDied();
}
@@ -708,7 +718,7 @@
@Override
public void scheduleWatchdog(int sensorId) {
Slog.d(getTag(), "Starting watchdog for face");
- final BiometricScheduler biometricScheduler = mSensors.get(sensorId).getScheduler();
+ final BiometricScheduler biometricScheduler = mFaceSensors.get(sensorId).getScheduler();
if (biometricScheduler == null) {
return;
}
diff --git a/services/core/java/com/android/server/biometrics/sensors/face/aidl/Sensor.java b/services/core/java/com/android/server/biometrics/sensors/face/aidl/Sensor.java
index 468bf55..ffbf4e1 100644
--- a/services/core/java/com/android/server/biometrics/sensors/face/aidl/Sensor.java
+++ b/services/core/java/com/android/server/biometrics/sensors/face/aidl/Sensor.java
@@ -18,9 +18,6 @@
import android.annotation.NonNull;
import android.annotation.Nullable;
-import android.app.ActivityManager;
-import android.app.SynchronousUserSwitchObserver;
-import android.app.UserSwitchObserver;
import android.content.Context;
import android.content.pm.UserInfo;
import android.hardware.biometrics.BiometricsProtoEnums;
@@ -94,14 +91,6 @@
@NonNull private final Supplier<AidlSession> mLazySession;
@Nullable private AidlSession mCurrentSession;
- private final UserSwitchObserver mUserSwitchObserver = new SynchronousUserSwitchObserver() {
- @Override
- public void onUserSwitching(int newUserId) {
- mProvider.scheduleInternalCleanup(
- mSensorProperties.sensorId, newUserId, null /* callback */);
- }
- };
-
@VisibleForTesting
public static class HalSessionCallback extends ISessionCallback.Stub {
/**
@@ -558,12 +547,6 @@
mLockoutCache = new LockoutCache();
mAuthenticatorIds = new HashMap<>();
mLazySession = () -> mCurrentSession != null ? mCurrentSession : null;
-
- try {
- ActivityManager.getService().registerUserSwitchObserver(mUserSwitchObserver, mTag);
- } catch (RemoteException e) {
- Slog.e(mTag, "Unable to register user switch observer");
- }
}
@NonNull Supplier<AidlSession> getLazySession() {
diff --git a/services/core/java/com/android/server/biometrics/sensors/fingerprint/aidl/FingerprintProvider.java b/services/core/java/com/android/server/biometrics/sensors/fingerprint/aidl/FingerprintProvider.java
index 23b6f84..58ece89 100644
--- a/services/core/java/com/android/server/biometrics/sensors/fingerprint/aidl/FingerprintProvider.java
+++ b/services/core/java/com/android/server/biometrics/sensors/fingerprint/aidl/FingerprintProvider.java
@@ -22,6 +22,7 @@
import android.annotation.Nullable;
import android.app.ActivityManager;
import android.app.ActivityTaskManager;
+import android.app.SynchronousUserSwitchObserver;
import android.app.TaskStackListener;
import android.content.Context;
import android.content.pm.UserInfo;
@@ -51,9 +52,9 @@
import android.os.RemoteException;
import android.os.ServiceManager;
import android.os.SystemClock;
+import android.os.UserHandle;
import android.os.UserManager;
import android.util.Slog;
-import android.util.SparseArray;
import android.util.proto.ProtoOutputStream;
import com.android.internal.annotations.VisibleForTesting;
@@ -71,6 +72,7 @@
import com.android.server.biometrics.sensors.InvalidationRequesterClient;
import com.android.server.biometrics.sensors.LockoutResetDispatcher;
import com.android.server.biometrics.sensors.PerformanceTracker;
+import com.android.server.biometrics.sensors.SensorList;
import com.android.server.biometrics.sensors.fingerprint.FingerprintUtils;
import com.android.server.biometrics.sensors.fingerprint.GestureAvailabilityDispatcher;
import com.android.server.biometrics.sensors.fingerprint.PowerPressHandler;
@@ -99,7 +101,7 @@
@NonNull
@VisibleForTesting
- final SparseArray<Sensor> mSensors; // Map of sensors that this HAL supports
+ final SensorList<Sensor> mFingerprintSensors;
@NonNull
private final Context mContext;
@NonNull
@@ -127,8 +129,8 @@
@Override
public void onTaskStackChanged() {
mHandler.post(() -> {
- for (int i = 0; i < mSensors.size(); i++) {
- final BaseClientMonitor client = mSensors.valueAt(i).getScheduler()
+ for (int i = 0; i < mFingerprintSensors.size(); i++) {
+ final BaseClientMonitor client = mFingerprintSensors.valueAt(i).getScheduler()
.getCurrentClient();
if (!(client instanceof AuthenticationClient)) {
Slog.e(getTag(), "Task stack changed for client: " + client);
@@ -143,8 +145,9 @@
&& !client.isAlreadyDone()) {
Slog.e(getTag(), "Stopping background authentication,"
+ " currentClient: " + client);
- mSensors.valueAt(i).getScheduler().cancelAuthenticationOrDetection(
- client.getToken(), client.getRequestId());
+ mFingerprintSensors.valueAt(i).getScheduler()
+ .cancelAuthenticationOrDetection(
+ client.getToken(), client.getRequestId());
}
}
});
@@ -160,7 +163,7 @@
mContext = context;
mBiometricStateCallback = biometricStateCallback;
mHalInstanceName = halInstanceName;
- mSensors = new SparseArray<>();
+ mFingerprintSensors = new SensorList<>(ActivityManager.getService());
mHandler = new Handler(Looper.getMainLooper());
mLockoutResetDispatcher = lockoutResetDispatcher;
mActivityTaskManager = ActivityTaskManager.getInstance();
@@ -201,8 +204,15 @@
final Sensor sensor = new Sensor(getTag() + "/" + sensorId, this, mContext, mHandler,
internalProp, lockoutResetDispatcher, gestureAvailabilityDispatcher,
mBiometricContext);
-
- mSensors.put(sensorId, sensor);
+ final int sessionUserId = sensor.getLazySession().get() == null ? UserHandle.USER_NULL :
+ sensor.getLazySession().get().getUserId();
+ mFingerprintSensors.addSensor(sensorId, sensor, sessionUserId,
+ new SynchronousUserSwitchObserver() {
+ @Override
+ public void onUserSwitching(int newUserId) {
+ scheduleInternalCleanup(sensorId, newUserId, null /* callback */);
+ }
+ });
Slog.d(getTag(), "Added: " + internalProp);
}
}
@@ -250,8 +260,8 @@
Slog.e(getTag(), "Unable to linkToDeath", e);
}
- for (int i = 0; i < mSensors.size(); i++) {
- final int sensorId = mSensors.keyAt(i);
+ for (int i = 0; i < mFingerprintSensors.size(); i++) {
+ final int sensorId = mFingerprintSensors.keyAt(i);
scheduleLoadAuthenticatorIds(sensorId);
scheduleInternalCleanup(sensorId, ActivityManager.getCurrentUser(),
null /* callback */);
@@ -261,33 +271,33 @@
}
private void scheduleForSensor(int sensorId, @NonNull BaseClientMonitor client) {
- if (!mSensors.contains(sensorId)) {
+ if (!mFingerprintSensors.contains(sensorId)) {
throw new IllegalStateException("Unable to schedule client: " + client
+ " for sensor: " + sensorId);
}
- mSensors.get(sensorId).getScheduler().scheduleClientMonitor(client);
+ mFingerprintSensors.get(sensorId).getScheduler().scheduleClientMonitor(client);
}
private void scheduleForSensor(int sensorId, @NonNull BaseClientMonitor client,
ClientMonitorCallback callback) {
- if (!mSensors.contains(sensorId)) {
+ if (!mFingerprintSensors.contains(sensorId)) {
throw new IllegalStateException("Unable to schedule client: " + client
+ " for sensor: " + sensorId);
}
- mSensors.get(sensorId).getScheduler().scheduleClientMonitor(client, callback);
+ mFingerprintSensors.get(sensorId).getScheduler().scheduleClientMonitor(client, callback);
}
@Override
public boolean containsSensor(int sensorId) {
- return mSensors.contains(sensorId);
+ return mFingerprintSensors.contains(sensorId);
}
@NonNull
@Override
public List<FingerprintSensorPropertiesInternal> getSensorProperties() {
final List<FingerprintSensorPropertiesInternal> props = new ArrayList<>();
- for (int i = 0; i < mSensors.size(); i++) {
- props.add(mSensors.valueAt(i).getSensorProperties());
+ for (int i = 0; i < mFingerprintSensors.size(); i++) {
+ props.add(mFingerprintSensors.valueAt(i).getSensorProperties());
}
return props;
}
@@ -295,12 +305,12 @@
@Nullable
@Override
public FingerprintSensorPropertiesInternal getSensorProperties(int sensorId) {
- if (mSensors.size() == 0) {
+ if (mFingerprintSensors.size() == 0) {
return null;
} else if (sensorId == SENSOR_ID_ANY) {
- return mSensors.valueAt(0).getSensorProperties();
+ return mFingerprintSensors.valueAt(0).getSensorProperties();
} else {
- final Sensor sensor = mSensors.get(sensorId);
+ final Sensor sensor = mFingerprintSensors.get(sensorId);
return sensor != null ? sensor.getSensorProperties() : null;
}
}
@@ -315,12 +325,12 @@
mHandler.post(() -> {
final FingerprintGetAuthenticatorIdClient client =
new FingerprintGetAuthenticatorIdClient(mContext,
- mSensors.get(sensorId).getLazySession(), userId,
+ mFingerprintSensors.get(sensorId).getLazySession(), userId,
mContext.getOpPackageName(), sensorId,
createLogger(BiometricsProtoEnums.ACTION_UNKNOWN,
BiometricsProtoEnums.CLIENT_UNKNOWN),
mBiometricContext,
- mSensors.get(sensorId).getAuthenticatorIds());
+ mFingerprintSensors.get(sensorId).getAuthenticatorIds());
scheduleForSensor(sensorId, client);
});
}
@@ -340,12 +350,12 @@
public void scheduleResetLockout(int sensorId, int userId, @Nullable byte[] hardwareAuthToken) {
mHandler.post(() -> {
final FingerprintResetLockoutClient client = new FingerprintResetLockoutClient(
- mContext, mSensors.get(sensorId).getLazySession(), userId,
+ mContext, mFingerprintSensors.get(sensorId).getLazySession(), userId,
mContext.getOpPackageName(), sensorId,
createLogger(BiometricsProtoEnums.ACTION_UNKNOWN,
BiometricsProtoEnums.CLIENT_UNKNOWN),
mBiometricContext, hardwareAuthToken,
- mSensors.get(sensorId).getLockoutCache(), mLockoutResetDispatcher,
+ mFingerprintSensors.get(sensorId).getLockoutCache(), mLockoutResetDispatcher,
Utils.getCurrentStrength(sensorId));
scheduleForSensor(sensorId, client);
});
@@ -357,7 +367,7 @@
mHandler.post(() -> {
final FingerprintGenerateChallengeClient client =
new FingerprintGenerateChallengeClient(mContext,
- mSensors.get(sensorId).getLazySession(), token,
+ mFingerprintSensors.get(sensorId).getLazySession(), token,
new ClientMonitorCallbackConverter(receiver), userId, opPackageName,
sensorId, createLogger(BiometricsProtoEnums.ACTION_UNKNOWN,
BiometricsProtoEnums.CLIENT_UNKNOWN),
@@ -372,7 +382,7 @@
mHandler.post(() -> {
final FingerprintRevokeChallengeClient client =
new FingerprintRevokeChallengeClient(mContext,
- mSensors.get(sensorId).getLazySession(), token,
+ mFingerprintSensors.get(sensorId).getLazySession(), token,
userId, opPackageName, sensorId,
createLogger(BiometricsProtoEnums.ACTION_UNKNOWN,
BiometricsProtoEnums.CLIENT_UNKNOWN),
@@ -388,16 +398,16 @@
@FingerprintManager.EnrollReason int enrollReason) {
final long id = mRequestCounter.incrementAndGet();
mHandler.post(() -> {
- final int maxTemplatesPerUser = mSensors.get(sensorId).getSensorProperties()
+ final int maxTemplatesPerUser = mFingerprintSensors.get(sensorId).getSensorProperties()
.maxEnrollmentsPerUser;
final FingerprintEnrollClient client = new FingerprintEnrollClient(mContext,
- mSensors.get(sensorId).getLazySession(), token, id,
+ mFingerprintSensors.get(sensorId).getLazySession(), token, id,
new ClientMonitorCallbackConverter(receiver), userId, hardwareAuthToken,
opPackageName, FingerprintUtils.getInstance(sensorId), sensorId,
createLogger(BiometricsProtoEnums.ACTION_ENROLL,
BiometricsProtoEnums.CLIENT_UNKNOWN),
mBiometricContext,
- mSensors.get(sensorId).getSensorProperties(),
+ mFingerprintSensors.get(sensorId).getSensorProperties(),
mUdfpsOverlayController, mSidefpsController, mUdfpsOverlay,
maxTemplatesPerUser, enrollReason);
scheduleForSensor(sensorId, client, new ClientMonitorCompositeCallback(
@@ -419,7 +429,8 @@
@Override
public void cancelEnrollment(int sensorId, @NonNull IBinder token, long requestId) {
mHandler.post(() ->
- mSensors.get(sensorId).getScheduler().cancelEnrollment(token, requestId));
+ mFingerprintSensors.get(sensorId).getScheduler()
+ .cancelEnrollment(token, requestId));
}
@Override
@@ -432,7 +443,7 @@
final int sensorId = options.getSensorId();
final boolean isStrongBiometric = Utils.isStrongBiometric(sensorId);
final FingerprintDetectClient client = new FingerprintDetectClient(mContext,
- mSensors.get(sensorId).getLazySession(), token, id, callback,
+ mFingerprintSensors.get(sensorId).getLazySession(), token, id, callback,
options,
createLogger(BiometricsProtoEnums.ACTION_AUTHENTICATE, statsClient),
mBiometricContext,
@@ -454,15 +465,15 @@
final int sensorId = options.getSensorId();
final boolean isStrongBiometric = Utils.isStrongBiometric(sensorId);
final FingerprintAuthenticationClient client = new FingerprintAuthenticationClient(
- mContext, mSensors.get(sensorId).getLazySession(), token, requestId, callback,
- operationId, restricted, options, cookie,
+ mContext, mFingerprintSensors.get(sensorId).getLazySession(), token, requestId,
+ callback, operationId, restricted, options, cookie,
false /* requireConfirmation */,
createLogger(BiometricsProtoEnums.ACTION_AUTHENTICATE, statsClient),
mBiometricContext, isStrongBiometric,
- mTaskStackListener, mSensors.get(sensorId).getLockoutCache(),
+ mTaskStackListener, mFingerprintSensors.get(sensorId).getLockoutCache(),
mUdfpsOverlayController, mSidefpsController, mUdfpsOverlay,
allowBackgroundAuthentication,
- mSensors.get(sensorId).getSensorProperties(), mHandler,
+ mFingerprintSensors.get(sensorId).getSensorProperties(), mHandler,
Utils.getCurrentStrength(sensorId),
SystemClock.elapsedRealtimeClock());
scheduleForSensor(sensorId, client, new ClientMonitorCallback() {
@@ -505,12 +516,13 @@
@Override
public void startPreparedClient(int sensorId, int cookie) {
- mHandler.post(() -> mSensors.get(sensorId).getScheduler().startPreparedClient(cookie));
+ mHandler.post(() -> mFingerprintSensors.get(sensorId).getScheduler()
+ .startPreparedClient(cookie));
}
@Override
public void cancelAuthentication(int sensorId, @NonNull IBinder token, long requestId) {
- mHandler.post(() -> mSensors.get(sensorId).getScheduler()
+ mHandler.post(() -> mFingerprintSensors.get(sensorId).getScheduler()
.cancelAuthenticationOrDetection(token, requestId));
}
@@ -541,13 +553,13 @@
@NonNull String opPackageName) {
mHandler.post(() -> {
final FingerprintRemovalClient client = new FingerprintRemovalClient(mContext,
- mSensors.get(sensorId).getLazySession(), token,
+ mFingerprintSensors.get(sensorId).getLazySession(), token,
new ClientMonitorCallbackConverter(receiver), fingerprintIds, userId,
opPackageName, FingerprintUtils.getInstance(sensorId), sensorId,
createLogger(BiometricsProtoEnums.ACTION_REMOVE,
BiometricsProtoEnums.CLIENT_UNKNOWN),
mBiometricContext,
- mSensors.get(sensorId).getAuthenticatorIds());
+ mFingerprintSensors.get(sensorId).getAuthenticatorIds());
scheduleForSensor(sensorId, client, mBiometricStateCallback);
});
}
@@ -564,13 +576,13 @@
mHandler.post(() -> {
final FingerprintInternalCleanupClient client =
new FingerprintInternalCleanupClient(mContext,
- mSensors.get(sensorId).getLazySession(), userId,
+ mFingerprintSensors.get(sensorId).getLazySession(), userId,
mContext.getOpPackageName(), sensorId,
createLogger(BiometricsProtoEnums.ACTION_ENUMERATE,
BiometricsProtoEnums.CLIENT_UNKNOWN),
mBiometricContext,
FingerprintUtils.getInstance(sensorId),
- mSensors.get(sensorId).getAuthenticatorIds());
+ mFingerprintSensors.get(sensorId).getAuthenticatorIds());
if (favorHalEnrollments) {
client.setFavorHalEnrollments();
}
@@ -612,11 +624,11 @@
mHandler.post(() -> {
final FingerprintInvalidationClient client =
new FingerprintInvalidationClient(mContext,
- mSensors.get(sensorId).getLazySession(), userId, sensorId,
+ mFingerprintSensors.get(sensorId).getLazySession(), userId, sensorId,
createLogger(BiometricsProtoEnums.ACTION_UNKNOWN,
BiometricsProtoEnums.CLIENT_UNKNOWN),
mBiometricContext,
- mSensors.get(sensorId).getAuthenticatorIds(), callback);
+ mFingerprintSensors.get(sensorId).getAuthenticatorIds(), callback);
scheduleForSensor(sensorId, client);
});
}
@@ -629,40 +641,43 @@
@Override
public long getAuthenticatorId(int sensorId, int userId) {
- return mSensors.get(sensorId).getAuthenticatorIds().getOrDefault(userId, 0L);
+ return mFingerprintSensors.get(sensorId).getAuthenticatorIds().getOrDefault(userId, 0L);
}
@Override
public void onPointerDown(long requestId, int sensorId, PointerContext pc) {
- mSensors.get(sensorId).getScheduler().getCurrentClientIfMatches(requestId, (client) -> {
- if (!(client instanceof Udfps)) {
- Slog.e(getTag(), "onPointerDown received during client: " + client);
- return;
- }
- ((Udfps) client).onPointerDown(pc);
- });
+ mFingerprintSensors.get(sensorId).getScheduler().getCurrentClientIfMatches(
+ requestId, (client) -> {
+ if (!(client instanceof Udfps)) {
+ Slog.e(getTag(), "onPointerDown received during client: " + client);
+ return;
+ }
+ ((Udfps) client).onPointerDown(pc);
+ });
}
@Override
public void onPointerUp(long requestId, int sensorId, PointerContext pc) {
- mSensors.get(sensorId).getScheduler().getCurrentClientIfMatches(requestId, (client) -> {
- if (!(client instanceof Udfps)) {
- Slog.e(getTag(), "onPointerUp received during client: " + client);
- return;
- }
- ((Udfps) client).onPointerUp(pc);
- });
+ mFingerprintSensors.get(sensorId).getScheduler().getCurrentClientIfMatches(
+ requestId, (client) -> {
+ if (!(client instanceof Udfps)) {
+ Slog.e(getTag(), "onPointerUp received during client: " + client);
+ return;
+ }
+ ((Udfps) client).onPointerUp(pc);
+ });
}
@Override
public void onUiReady(long requestId, int sensorId) {
- mSensors.get(sensorId).getScheduler().getCurrentClientIfMatches(requestId, (client) -> {
- if (!(client instanceof Udfps)) {
- Slog.e(getTag(), "onUiReady received during client: " + client);
- return;
- }
- ((Udfps) client).onUiReady();
- });
+ mFingerprintSensors.get(sensorId).getScheduler().getCurrentClientIfMatches(
+ requestId, (client) -> {
+ if (!(client instanceof Udfps)) {
+ Slog.e(getTag(), "onUiReady received during client: " + client);
+ return;
+ }
+ ((Udfps) client).onUiReady();
+ });
}
@Override
@@ -672,8 +687,8 @@
@Override
public void onPowerPressed() {
- for (int i = 0; i < mSensors.size(); i++) {
- final Sensor sensor = mSensors.valueAt(i);
+ for (int i = 0; i < mFingerprintSensors.size(); i++) {
+ final Sensor sensor = mFingerprintSensors.valueAt(i);
BaseClientMonitor client = sensor.getScheduler().getCurrentClient();
if (client == null) {
return;
@@ -698,8 +713,8 @@
@Override
public void dumpProtoState(int sensorId, @NonNull ProtoOutputStream proto,
boolean clearSchedulerBuffer) {
- if (mSensors.contains(sensorId)) {
- mSensors.get(sensorId).dumpProtoState(sensorId, proto, clearSchedulerBuffer);
+ if (mFingerprintSensors.contains(sensorId)) {
+ mFingerprintSensors.get(sensorId).dumpProtoState(sensorId, proto, clearSchedulerBuffer);
}
}
@@ -748,14 +763,15 @@
pw.println(mBiometricContext.getAuthSessionCoordinator());
pw.println("---AuthSessionCoordinator logs end ---");
- mSensors.get(sensorId).getScheduler().dump(pw);
+ mFingerprintSensors.get(sensorId).getScheduler().dump(pw);
}
@NonNull
@Override
public ITestSession createTestSession(int sensorId, @NonNull ITestSessionCallback callback,
@NonNull String opPackageName) {
- return mSensors.get(sensorId).createTestSession(callback, mBiometricStateCallback);
+ return mFingerprintSensors.get(sensorId).createTestSession(callback,
+ mBiometricStateCallback);
}
@Override
@@ -764,9 +780,9 @@
mHandler.post(() -> {
mDaemon = null;
- for (int i = 0; i < mSensors.size(); i++) {
- final Sensor sensor = mSensors.valueAt(i);
- final int sensorId = mSensors.keyAt(i);
+ for (int i = 0; i < mFingerprintSensors.size(); i++) {
+ final Sensor sensor = mFingerprintSensors.valueAt(i);
+ final int sensorId = mFingerprintSensors.keyAt(i);
PerformanceTracker.getInstanceForSensorId(sensorId).incrementHALDeathCount();
sensor.onBinderDied();
}
@@ -821,7 +837,8 @@
@Override
public void scheduleWatchdog(int sensorId) {
Slog.d(getTag(), "Starting watchdog for fingerprint");
- final BiometricScheduler biometricScheduler = mSensors.get(sensorId).getScheduler();
+ final BiometricScheduler biometricScheduler = mFingerprintSensors.get(sensorId)
+ .getScheduler();
if (biometricScheduler == null) {
return;
}
diff --git a/services/core/java/com/android/server/biometrics/sensors/fingerprint/aidl/Sensor.java b/services/core/java/com/android/server/biometrics/sensors/fingerprint/aidl/Sensor.java
index 22ca816..c0dde72 100644
--- a/services/core/java/com/android/server/biometrics/sensors/fingerprint/aidl/Sensor.java
+++ b/services/core/java/com/android/server/biometrics/sensors/fingerprint/aidl/Sensor.java
@@ -18,9 +18,6 @@
import android.annotation.NonNull;
import android.annotation.Nullable;
-import android.app.ActivityManager;
-import android.app.SynchronousUserSwitchObserver;
-import android.app.UserSwitchObserver;
import android.content.Context;
import android.content.pm.UserInfo;
import android.hardware.biometrics.BiometricsProtoEnums;
@@ -96,14 +93,6 @@
@Nullable private AidlSession mCurrentSession;
@NonNull private final Supplier<AidlSession> mLazySession;
- private final UserSwitchObserver mUserSwitchObserver = new SynchronousUserSwitchObserver() {
- @Override
- public void onUserSwitching(int newUserId) {
- mProvider.scheduleInternalCleanup(
- mSensorProperties.sensorId, newUserId, null /* callback */);
- }
- };
-
@VisibleForTesting
public static class HalSessionCallback extends ISessionCallback.Stub {
@@ -512,12 +501,6 @@
});
mAuthenticatorIds = new HashMap<>();
mLazySession = () -> mCurrentSession != null ? mCurrentSession : null;
-
- try {
- ActivityManager.getService().registerUserSwitchObserver(mUserSwitchObserver, mTag);
- } catch (RemoteException e) {
- Slog.e(mTag, "Unable to register user switch observer");
- }
}
@NonNull Supplier<AidlSession> getLazySession() {
diff --git a/services/core/java/com/android/server/wm/ActivityStartController.java b/services/core/java/com/android/server/wm/ActivityStartController.java
index bfe2986..a6e5040 100644
--- a/services/core/java/com/android/server/wm/ActivityStartController.java
+++ b/services/core/java/com/android/server/wm/ActivityStartController.java
@@ -45,6 +45,7 @@
import android.os.Binder;
import android.os.Bundle;
import android.os.IBinder;
+import android.os.Trace;
import android.os.UserHandle;
import android.provider.Settings;
import android.util.Slog;
@@ -554,7 +555,25 @@
.execute();
}
+ /**
+ * A quick path (skip general intent/task resolving) to start recents animation if the recents
+ * (or home) activity is available in background.
+ * @return {@code true} if the recents activity is moved to front.
+ */
boolean startExistingRecentsIfPossible(Intent intent, ActivityOptions options) {
+ try {
+ Trace.traceBegin(Trace.TRACE_TAG_WINDOW_MANAGER, "startExistingRecents");
+ if (startExistingRecents(intent, options)) {
+ return true;
+ }
+ // Else follow the standard launch procedure.
+ } finally {
+ Trace.traceEnd(Trace.TRACE_TAG_WINDOW_MANAGER);
+ }
+ return false;
+ }
+
+ private boolean startExistingRecents(Intent intent, ActivityOptions options) {
final int activityType = mService.getRecentTasks().getRecentsComponent()
.equals(intent.getComponent()) ? ACTIVITY_TYPE_RECENTS : ACTIVITY_TYPE_HOME;
final Task rootTask = mService.mRootWindowContainer.getDefaultTaskDisplayArea()
@@ -563,6 +582,7 @@
final ActivityRecord r = rootTask.topRunningActivity();
if (r == null || r.isVisibleRequested() || !r.attachedToProcess()
|| !r.mActivityComponent.equals(intent.getComponent())
+ || !mService.isCallerRecents(r.getUid())
// Recents keeps invisible while device is locked.
|| r.mDisplayContent.isKeyguardLocked()) {
return false;
diff --git a/services/core/java/com/android/server/wm/ActivityTaskManagerService.java b/services/core/java/com/android/server/wm/ActivityTaskManagerService.java
index 1f4606b..a0ea1c3 100644
--- a/services/core/java/com/android/server/wm/ActivityTaskManagerService.java
+++ b/services/core/java/com/android/server/wm/ActivityTaskManagerService.java
@@ -5753,23 +5753,6 @@
boolean validateIncomingUser, PendingIntentRecord originatingPendingIntent,
BackgroundStartPrivileges backgroundStartPrivileges) {
assertPackageMatchesCallingUid(callingPackage);
- // A quick path (skip general intent/task resolving) to start recents animation if the
- // recents (or home) activity is available in background.
- if (options != null && options.getOriginalOptions() != null
- && options.getOriginalOptions().getTransientLaunch() && isCallerRecents(uid)) {
- try {
- synchronized (mGlobalLock) {
- Trace.traceBegin(TRACE_TAG_WINDOW_MANAGER, "startExistingRecents");
- if (mActivityStartController.startExistingRecentsIfPossible(
- intent, options.getOriginalOptions())) {
- return ActivityManager.START_TASK_TO_FRONT;
- }
- // Else follow the standard launch procedure.
- }
- } finally {
- Trace.traceEnd(TRACE_TAG_WINDOW_MANAGER);
- }
- }
return getActivityStartController().startActivityInPackage(uid, realCallingPid,
realCallingUid, callingPackage, callingFeatureId, intent, resolvedType,
resultTo, resultWho, requestCode, startFlags, options, userId, inTask,
diff --git a/services/core/java/com/android/server/wm/WindowOrganizerController.java b/services/core/java/com/android/server/wm/WindowOrganizerController.java
index d5aa520..09312ba 100644
--- a/services/core/java/com/android/server/wm/WindowOrganizerController.java
+++ b/services/core/java/com/android/server/wm/WindowOrganizerController.java
@@ -972,19 +972,30 @@
switch (type) {
case HIERARCHY_OP_TYPE_PENDING_INTENT: {
+ final Bundle launchOpts = hop.getLaunchOptions();
+ ActivityOptions activityOptions = launchOpts != null
+ ? new ActivityOptions(launchOpts) : null;
+ if (activityOptions != null && activityOptions.getTransientLaunch()
+ && mService.isCallerRecents(hop.getPendingIntent().getCreatorUid())) {
+ if (mService.getActivityStartController().startExistingRecentsIfPossible(
+ hop.getActivityIntent(), activityOptions)) {
+ // Start recents successfully.
+ break;
+ }
+ }
+
String resolvedType = hop.getActivityIntent() != null
? hop.getActivityIntent().resolveTypeIfNeeded(
mService.mContext.getContentResolver())
: null;
- ActivityOptions activityOptions = null;
if (hop.getPendingIntent().isActivity()) {
// Set the context display id as preferred for this activity launches, so that
// it can land on caller's display. Or just brought the task to front at the
// display where it was on since it has higher preference.
- activityOptions = hop.getLaunchOptions() != null
- ? new ActivityOptions(hop.getLaunchOptions())
- : ActivityOptions.makeBasic();
+ if (activityOptions == null) {
+ activityOptions = ActivityOptions.makeBasic();
+ }
activityOptions.setCallerDisplayId(DEFAULT_DISPLAY);
}
final Bundle options = activityOptions != null ? activityOptions.toBundle() : null;
diff --git a/services/java/com/android/server/SystemServer.java b/services/java/com/android/server/SystemServer.java
index b1d6131..a8a1c03 100644
--- a/services/java/com/android/server/SystemServer.java
+++ b/services/java/com/android/server/SystemServer.java
@@ -593,8 +593,8 @@
* Spawn a thread that monitors for fd leaks.
*/
private static void spawnFdLeakCheckThread() {
- final int enableThreshold = SystemProperties.getInt(SYSPROP_FDTRACK_ENABLE_THRESHOLD, 1024);
- final int abortThreshold = SystemProperties.getInt(SYSPROP_FDTRACK_ABORT_THRESHOLD, 2048);
+ final int enableThreshold = SystemProperties.getInt(SYSPROP_FDTRACK_ENABLE_THRESHOLD, 1600);
+ final int abortThreshold = SystemProperties.getInt(SYSPROP_FDTRACK_ABORT_THRESHOLD, 3000);
final int checkInterval = SystemProperties.getInt(SYSPROP_FDTRACK_INTERVAL, 120);
new Thread(() -> {
diff --git a/services/tests/servicestests/src/com/android/server/biometrics/sensors/SensorListTest.java b/services/tests/servicestests/src/com/android/server/biometrics/sensors/SensorListTest.java
new file mode 100644
index 0000000..3d80916b
--- /dev/null
+++ b/services/tests/servicestests/src/com/android/server/biometrics/sensors/SensorListTest.java
@@ -0,0 +1,66 @@
+/*
+ * Copyright (C) 2023 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.server.biometrics.sensors;
+
+import static org.mockito.ArgumentMatchers.anyString;
+import static org.mockito.ArgumentMatchers.eq;
+import static org.mockito.Mockito.verify;
+
+import android.app.IActivityManager;
+import android.app.SynchronousUserSwitchObserver;
+import android.os.RemoteException;
+import android.os.UserHandle;
+import android.platform.test.annotations.Presubmit;
+
+import androidx.test.filters.SmallTest;
+
+import com.android.server.biometrics.sensors.face.aidl.Sensor;
+
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+import org.mockito.Mock;
+import org.mockito.junit.MockitoJUnit;
+import org.mockito.junit.MockitoRule;
+
+@Presubmit
+@SmallTest
+public class SensorListTest {
+ @Rule
+ public MockitoRule mMockitoRule = MockitoJUnit.rule();
+ @Mock
+ Sensor mSensor;
+ @Mock
+ IActivityManager mActivityManager;
+ @Mock
+ SynchronousUserSwitchObserver mUserSwitchObserver;
+
+ SensorList<Sensor> mSensorList;
+
+ @Before
+ public void setUp() throws RemoteException {
+ mSensorList = new SensorList<>(mActivityManager);
+ }
+
+ @Test
+ public void testAddingSensor() throws RemoteException {
+ mSensorList.addSensor(0, mSensor, UserHandle.USER_NULL, mUserSwitchObserver);
+
+ verify(mUserSwitchObserver).onUserSwitching(UserHandle.USER_SYSTEM);
+ verify(mActivityManager).registerUserSwitchObserver(eq(mUserSwitchObserver), anyString());
+ }
+}
diff --git a/services/tests/servicestests/src/com/android/server/biometrics/sensors/face/aidl/FaceProviderTest.java b/services/tests/servicestests/src/com/android/server/biometrics/sensors/face/aidl/FaceProviderTest.java
index 41f7433..31a58cd 100644
--- a/services/tests/servicestests/src/com/android/server/biometrics/sensors/face/aidl/FaceProviderTest.java
+++ b/services/tests/servicestests/src/com/android/server/biometrics/sensors/face/aidl/FaceProviderTest.java
@@ -16,6 +16,8 @@
package com.android.server.biometrics.sensors.face.aidl;
+import static com.google.common.truth.Truth.assertThat;
+
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
@@ -30,6 +32,7 @@
import android.hardware.biometrics.face.ISession;
import android.hardware.biometrics.face.SensorProps;
import android.os.RemoteException;
+import android.os.UserHandle;
import android.os.UserManager;
import android.platform.test.annotations.Presubmit;
@@ -38,6 +41,7 @@
import androidx.test.filters.SmallTest;
import com.android.server.biometrics.log.BiometricContext;
+import com.android.server.biometrics.sensors.BaseClientMonitor;
import com.android.server.biometrics.sensors.BiometricScheduler;
import com.android.server.biometrics.sensors.BiometricStateCallback;
import com.android.server.biometrics.sensors.HalClientMonitor;
@@ -98,16 +102,34 @@
mSensorProps, TAG, mLockoutResetDispatcher, mBiometricContext);
}
+ @Test
+ public void testAddingSensors() {
+ waitForIdle();
+
+ for (SensorProps prop : mSensorProps) {
+ final BiometricScheduler scheduler =
+ mFaceProvider.mFaceSensors.get(prop.commonProps.sensorId)
+ .getScheduler();
+ BaseClientMonitor currentClient = scheduler.getCurrentClient();
+
+ assertThat(currentClient).isInstanceOf(FaceInternalCleanupClient.class);
+ assertThat(currentClient.getSensorId()).isEqualTo(prop.commonProps.sensorId);
+ assertThat(currentClient.getTargetUserId()).isEqualTo(UserHandle.USER_SYSTEM);
+ }
+ }
+
@SuppressWarnings("rawtypes")
@Test
public void halServiceDied_resetsAllSchedulers() {
+ waitForIdle();
+
assertEquals(mSensorProps.length, mFaceProvider.getSensorProperties().size());
// Schedule N operations on each sensor
final int numFakeOperations = 10;
for (SensorProps prop : mSensorProps) {
final BiometricScheduler scheduler =
- mFaceProvider.mSensors.get(prop.commonProps.sensorId).getScheduler();
+ mFaceProvider.mFaceSensors.get(prop.commonProps.sensorId).getScheduler();
for (int i = 0; i < numFakeOperations; i++) {
final HalClientMonitor testMonitor = mock(HalClientMonitor.class);
when(testMonitor.getFreshDaemon()).thenReturn(new Object());
@@ -119,8 +141,8 @@
// The right amount of pending and current operations are scheduled
for (SensorProps prop : mSensorProps) {
final BiometricScheduler scheduler =
- mFaceProvider.mSensors.get(prop.commonProps.sensorId).getScheduler();
- assertEquals(numFakeOperations - 1, scheduler.getCurrentPendingCount());
+ mFaceProvider.mFaceSensors.get(prop.commonProps.sensorId).getScheduler();
+ assertEquals(numFakeOperations, scheduler.getCurrentPendingCount());
assertNotNull(scheduler.getCurrentClient());
}
@@ -132,7 +154,7 @@
// No pending operations, no current operation.
for (SensorProps prop : mSensorProps) {
final BiometricScheduler scheduler =
- mFaceProvider.mSensors.get(prop.commonProps.sensorId).getScheduler();
+ mFaceProvider.mFaceSensors.get(prop.commonProps.sensorId).getScheduler();
assertNull(scheduler.getCurrentClient());
assertEquals(0, scheduler.getCurrentPendingCount());
}
diff --git a/services/tests/servicestests/src/com/android/server/biometrics/sensors/face/aidl/SensorTest.java b/services/tests/servicestests/src/com/android/server/biometrics/sensors/face/aidl/SensorTest.java
index 9c9d3f8..25bd9bc 100644
--- a/services/tests/servicestests/src/com/android/server/biometrics/sensors/face/aidl/SensorTest.java
+++ b/services/tests/servicestests/src/com/android/server/biometrics/sensors/face/aidl/SensorTest.java
@@ -29,9 +29,9 @@
import android.content.Context;
import android.hardware.biometrics.IBiometricService;
import android.hardware.biometrics.common.CommonProps;
-import android.hardware.biometrics.face.IFace;
import android.hardware.biometrics.face.ISession;
import android.hardware.biometrics.face.SensorProps;
+import android.hardware.face.FaceSensorPropertiesInternal;
import android.os.Handler;
import android.os.test.TestLooper;
import android.platform.test.annotations.Presubmit;
@@ -42,7 +42,6 @@
import com.android.server.biometrics.log.BiometricLogger;
import com.android.server.biometrics.sensors.AuthSessionCoordinator;
import com.android.server.biometrics.sensors.BiometricScheduler;
-import com.android.server.biometrics.sensors.BiometricStateCallback;
import com.android.server.biometrics.sensors.LockoutCache;
import com.android.server.biometrics.sensors.LockoutResetDispatcher;
import com.android.server.biometrics.sensors.LockoutTracker;
@@ -82,17 +81,13 @@
@Mock
private AuthSessionCoordinator mAuthSessionCoordinator;
@Mock
- private IFace mDaemon;
- @Mock
- private BiometricStateCallback mBiometricStateCallback;
+ FaceProvider mFaceProvider;
private final TestLooper mLooper = new TestLooper();
private final LockoutCache mLockoutCache = new LockoutCache();
private UserAwareBiometricScheduler mScheduler;
private Sensor.HalSessionCallback mHalCallback;
- private FaceProvider mFaceProvider;
- private SensorProps[] mSensorProps;
@Before
public void setUp() {
@@ -113,16 +108,6 @@
TAG, mScheduler, SENSOR_ID,
USER_ID, mLockoutCache, mLockoutResetDispatcher, mAuthSessionCoordinator,
mHalSessionCallback);
-
- final SensorProps sensor1 = new SensorProps();
- sensor1.commonProps = new CommonProps();
- sensor1.commonProps.sensorId = 0;
- final SensorProps sensor2 = new SensorProps();
- sensor2.commonProps = new CommonProps();
- sensor2.commonProps.sensorId = 1;
- mSensorProps = new SensorProps[]{sensor1, sensor2};
- mFaceProvider = new FaceProvider(mContext, mBiometricStateCallback,
- mSensorProps, TAG, mLockoutResetDispatcher, mBiometricContext);
}
@Test
@@ -154,14 +139,26 @@
@Test
public void onBinderDied_noErrorOnNullClient() {
- mScheduler.reset();
- assertNull(mScheduler.getCurrentClient());
- mFaceProvider.binderDied();
+ mLooper.dispatchAll();
- for (int i = 0; i < mFaceProvider.mSensors.size(); i++) {
- final Sensor sensor = mFaceProvider.mSensors.valueAt(i);
- assertNull(sensor.getSessionForUser(USER_ID));
- }
+ final SensorProps sensorProps = new SensorProps();
+ sensorProps.commonProps = new CommonProps();
+ sensorProps.commonProps.sensorId = 1;
+ final FaceSensorPropertiesInternal internalProp = new FaceSensorPropertiesInternal(
+ sensorProps.commonProps.sensorId, sensorProps.commonProps.sensorStrength,
+ sensorProps.commonProps.maxEnrollmentsPerUser, null,
+ sensorProps.sensorType, sensorProps.supportsDetectInteraction,
+ sensorProps.halControlsPreview, false /* resetLockoutRequiresChallenge */);
+ final Sensor sensor = new Sensor("SensorTest", mFaceProvider, mContext, null,
+ internalProp, mLockoutResetDispatcher, mBiometricContext);
+
+ mScheduler.reset();
+
+ assertNull(mScheduler.getCurrentClient());
+
+ sensor.onBinderDied();
+
+ assertNull(sensor.getSessionForUser(USER_ID));
}
private void verifyNotLocked() {
diff --git a/services/tests/servicestests/src/com/android/server/biometrics/sensors/fingerprint/aidl/FingerprintProviderTest.java b/services/tests/servicestests/src/com/android/server/biometrics/sensors/fingerprint/aidl/FingerprintProviderTest.java
index c6ddf27..9c01de6 100644
--- a/services/tests/servicestests/src/com/android/server/biometrics/sensors/fingerprint/aidl/FingerprintProviderTest.java
+++ b/services/tests/servicestests/src/com/android/server/biometrics/sensors/fingerprint/aidl/FingerprintProviderTest.java
@@ -16,6 +16,8 @@
package com.android.server.biometrics.sensors.fingerprint.aidl;
+import static com.google.common.truth.Truth.assertThat;
+
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
@@ -33,6 +35,7 @@
import android.hardware.biometrics.fingerprint.SensorLocation;
import android.hardware.biometrics.fingerprint.SensorProps;
import android.os.RemoteException;
+import android.os.UserHandle;
import android.os.UserManager;
import android.platform.test.annotations.Presubmit;
@@ -41,6 +44,7 @@
import androidx.test.filters.SmallTest;
import com.android.server.biometrics.log.BiometricContext;
+import com.android.server.biometrics.sensors.BaseClientMonitor;
import com.android.server.biometrics.sensors.BiometricScheduler;
import com.android.server.biometrics.sensors.BiometricStateCallback;
import com.android.server.biometrics.sensors.HalClientMonitor;
@@ -111,16 +115,38 @@
mGestureAvailabilityDispatcher, mBiometricContext);
}
+ @Test
+ public void testAddingSensors() {
+ mFingerprintProvider = new TestableFingerprintProvider(mDaemon, mContext,
+ mBiometricStateCallback, mSensorProps, TAG, mLockoutResetDispatcher,
+ mGestureAvailabilityDispatcher, mBiometricContext);
+
+ waitForIdle();
+
+ for (SensorProps prop : mSensorProps) {
+ final BiometricScheduler scheduler =
+ mFingerprintProvider.mFingerprintSensors.get(prop.commonProps.sensorId)
+ .getScheduler();
+ BaseClientMonitor currentClient = scheduler.getCurrentClient();
+
+ assertThat(currentClient).isInstanceOf(FingerprintInternalCleanupClient.class);
+ assertThat(currentClient.getSensorId()).isEqualTo(prop.commonProps.sensorId);
+ assertThat(currentClient.getTargetUserId()).isEqualTo(UserHandle.USER_SYSTEM);
+ }
+ }
+
@SuppressWarnings("rawtypes")
@Test
public void halServiceDied_resetsAllSchedulers() {
+ waitForIdle();
assertEquals(mSensorProps.length, mFingerprintProvider.getSensorProperties().size());
// Schedule N operations on each sensor
final int numFakeOperations = 10;
for (SensorProps prop : mSensorProps) {
final BiometricScheduler scheduler =
- mFingerprintProvider.mSensors.get(prop.commonProps.sensorId).getScheduler();
+ mFingerprintProvider.mFingerprintSensors.get(prop.commonProps.sensorId)
+ .getScheduler();
for (int i = 0; i < numFakeOperations; i++) {
final HalClientMonitor testMonitor = mock(HalClientMonitor.class);
when(testMonitor.getFreshDaemon()).thenReturn(new Object());
@@ -132,8 +158,9 @@
// The right amount of pending and current operations are scheduled
for (SensorProps prop : mSensorProps) {
final BiometricScheduler scheduler =
- mFingerprintProvider.mSensors.get(prop.commonProps.sensorId).getScheduler();
- assertEquals(numFakeOperations - 1, scheduler.getCurrentPendingCount());
+ mFingerprintProvider.mFingerprintSensors.get(prop.commonProps.sensorId)
+ .getScheduler();
+ assertEquals(numFakeOperations, scheduler.getCurrentPendingCount());
assertNotNull(scheduler.getCurrentClient());
}
@@ -145,7 +172,8 @@
// No pending operations, no current operation.
for (SensorProps prop : mSensorProps) {
final BiometricScheduler scheduler =
- mFingerprintProvider.mSensors.get(prop.commonProps.sensorId).getScheduler();
+ mFingerprintProvider.mFingerprintSensors.get(prop.commonProps.sensorId)
+ .getScheduler();
assertNull(scheduler.getCurrentClient());
assertEquals(0, scheduler.getCurrentPendingCount());
}
diff --git a/services/tests/servicestests/utils/com/android/server/testutils/OWNERS b/services/tests/servicestests/utils/com/android/server/testutils/OWNERS
new file mode 100644
index 0000000..bdacf7f
--- /dev/null
+++ b/services/tests/servicestests/utils/com/android/server/testutils/OWNERS
@@ -0,0 +1 @@
+per-file *Transaction.java = file:/services/core/java/com/android/server/wm/OWNERS
\ No newline at end of file
diff --git a/services/tests/wmtests/src/com/android/server/wm/StubTransaction.java b/services/tests/servicestests/utils/com/android/server/testutils/StubTransaction.java
similarity index 98%
rename from services/tests/wmtests/src/com/android/server/wm/StubTransaction.java
rename to services/tests/servicestests/utils/com/android/server/testutils/StubTransaction.java
index 31546e8..34e8ff2 100644
--- a/services/tests/wmtests/src/com/android/server/wm/StubTransaction.java
+++ b/services/tests/servicestests/utils/com/android/server/testutils/StubTransaction.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package com.android.server.wm;
+package com.android.server.testutils;
import android.annotation.NonNull;
import android.annotation.Nullable;
@@ -30,6 +30,8 @@
import android.view.Surface;
import android.view.SurfaceControl;
+import com.android.server.testutils.StubTransaction;
+
import java.util.HashSet;
import java.util.concurrent.Executor;
diff --git a/services/tests/wmtests/src/com/android/server/wm/DimmerTests.java b/services/tests/wmtests/src/com/android/server/wm/DimmerTests.java
index 5282585e9..f235d15 100644
--- a/services/tests/wmtests/src/com/android/server/wm/DimmerTests.java
+++ b/services/tests/wmtests/src/com/android/server/wm/DimmerTests.java
@@ -36,6 +36,7 @@
import android.view.SurfaceSession;
import com.android.server.wm.SurfaceAnimator.AnimationType;
+import com.android.server.testutils.StubTransaction;
import org.junit.Before;
import org.junit.Test;
diff --git a/services/tests/wmtests/src/com/android/server/wm/LetterboxTest.java b/services/tests/wmtests/src/com/android/server/wm/LetterboxTest.java
index d400a4c..d2494ff 100644
--- a/services/tests/wmtests/src/com/android/server/wm/LetterboxTest.java
+++ b/services/tests/wmtests/src/com/android/server/wm/LetterboxTest.java
@@ -37,6 +37,8 @@
import androidx.test.filters.SmallTest;
+import com.android.server.testutils.StubTransaction;
+
import org.junit.Before;
import org.junit.Test;
import org.mockito.invocation.InvocationOnMock;
diff --git a/services/tests/wmtests/src/com/android/server/wm/SurfaceSyncGroupTest.java b/services/tests/wmtests/src/com/android/server/wm/SurfaceSyncGroupTest.java
index e30206e..c8fc6b8 100644
--- a/services/tests/wmtests/src/com/android/server/wm/SurfaceSyncGroupTest.java
+++ b/services/tests/wmtests/src/com/android/server/wm/SurfaceSyncGroupTest.java
@@ -30,6 +30,8 @@
import androidx.test.filters.SmallTest;
+import com.android.server.testutils.StubTransaction;
+
import org.junit.Before;
import org.junit.Test;
diff --git a/services/tests/wmtests/src/com/android/server/wm/SyncEngineTests.java b/services/tests/wmtests/src/com/android/server/wm/SyncEngineTests.java
index ddd630e..a3a3684 100644
--- a/services/tests/wmtests/src/com/android/server/wm/SyncEngineTests.java
+++ b/services/tests/wmtests/src/com/android/server/wm/SyncEngineTests.java
@@ -42,6 +42,7 @@
import androidx.test.filters.SmallTest;
+import com.android.server.testutils.StubTransaction;
import com.android.server.testutils.TestHandler;
import org.junit.Before;
diff --git a/services/tests/wmtests/src/com/android/server/wm/SystemServicesTestRule.java b/services/tests/wmtests/src/com/android/server/wm/SystemServicesTestRule.java
index 013c6d5..7edfd9a 100644
--- a/services/tests/wmtests/src/com/android/server/wm/SystemServicesTestRule.java
+++ b/services/tests/wmtests/src/com/android/server/wm/SystemServicesTestRule.java
@@ -88,6 +88,7 @@
import com.android.server.policy.PermissionPolicyInternal;
import com.android.server.policy.WindowManagerPolicy;
import com.android.server.statusbar.StatusBarManagerInternal;
+import com.android.server.testutils.StubTransaction;
import com.android.server.uri.UriGrantsManagerInternal;
import org.junit.rules.TestRule;
diff --git a/services/tests/wmtests/src/com/android/server/wm/WindowAnimationSpecTest.java b/services/tests/wmtests/src/com/android/server/wm/WindowAnimationSpecTest.java
index e2f1334..608d7c9 100644
--- a/services/tests/wmtests/src/com/android/server/wm/WindowAnimationSpecTest.java
+++ b/services/tests/wmtests/src/com/android/server/wm/WindowAnimationSpecTest.java
@@ -38,6 +38,8 @@
import androidx.test.filters.SmallTest;
+import com.android.server.testutils.StubTransaction;
+
import org.junit.Test;
/**
diff --git a/services/tests/wmtests/src/com/android/server/wm/WindowContainerThumbnailTest.java b/services/tests/wmtests/src/com/android/server/wm/WindowContainerThumbnailTest.java
index 2ae1172..849072e 100644
--- a/services/tests/wmtests/src/com/android/server/wm/WindowContainerThumbnailTest.java
+++ b/services/tests/wmtests/src/com/android/server/wm/WindowContainerThumbnailTest.java
@@ -28,6 +28,8 @@
import androidx.test.filters.SmallTest;
+import com.android.server.testutils.StubTransaction;
+
import org.junit.Test;
import org.junit.runner.RunWith;
diff --git a/services/tests/wmtests/src/com/android/server/wm/WindowStateTests.java b/services/tests/wmtests/src/com/android/server/wm/WindowStateTests.java
index 460a603..ee1afcf 100644
--- a/services/tests/wmtests/src/com/android/server/wm/WindowStateTests.java
+++ b/services/tests/wmtests/src/com/android/server/wm/WindowStateTests.java
@@ -110,6 +110,8 @@
import androidx.test.filters.SmallTest;
+import com.android.server.testutils.StubTransaction;
+
import org.junit.Test;
import org.junit.runner.RunWith;
diff --git a/telephony/java/android/telephony/DisconnectCause.java b/telephony/java/android/telephony/DisconnectCause.java
index 2704418..6997f3c7 100644
--- a/telephony/java/android/telephony/DisconnectCause.java
+++ b/telephony/java/android/telephony/DisconnectCause.java
@@ -360,6 +360,11 @@
*/
public static final int INCOMING_AUTO_REJECTED = 81;
+ /**
+ * Indicates that the call was unable to be made because the satellite modem is enabled.
+ * @hide
+ */
+ public static final int SATELLITE_ENABLED = 82;
//*********************************************************************************************
// When adding a disconnect type:
@@ -379,168 +384,170 @@
@UnsupportedAppUsage
public static @NonNull String toString(int cause) {
switch (cause) {
- case NOT_DISCONNECTED:
- return "NOT_DISCONNECTED";
- case INCOMING_MISSED:
- return "INCOMING_MISSED";
- case NORMAL:
- return "NORMAL";
- case LOCAL:
- return "LOCAL";
- case BUSY:
- return "BUSY";
- case CONGESTION:
- return "CONGESTION";
- case INVALID_NUMBER:
- return "INVALID_NUMBER";
- case NUMBER_UNREACHABLE:
- return "NUMBER_UNREACHABLE";
- case SERVER_UNREACHABLE:
- return "SERVER_UNREACHABLE";
- case INVALID_CREDENTIALS:
- return "INVALID_CREDENTIALS";
- case OUT_OF_NETWORK:
- return "OUT_OF_NETWORK";
- case SERVER_ERROR:
- return "SERVER_ERROR";
- case TIMED_OUT:
- return "TIMED_OUT";
- case LOST_SIGNAL:
- return "LOST_SIGNAL";
- case LIMIT_EXCEEDED:
- return "LIMIT_EXCEEDED";
- case INCOMING_REJECTED:
- return "INCOMING_REJECTED";
- case POWER_OFF:
- return "POWER_OFF";
- case OUT_OF_SERVICE:
- return "OUT_OF_SERVICE";
- case ICC_ERROR:
- return "ICC_ERROR";
- case CALL_BARRED:
- return "CALL_BARRED";
- case FDN_BLOCKED:
- return "FDN_BLOCKED";
- case CS_RESTRICTED:
- return "CS_RESTRICTED";
- case CS_RESTRICTED_NORMAL:
- return "CS_RESTRICTED_NORMAL";
- case CS_RESTRICTED_EMERGENCY:
- return "CS_RESTRICTED_EMERGENCY";
- case UNOBTAINABLE_NUMBER:
- return "UNOBTAINABLE_NUMBER";
- case CDMA_LOCKED_UNTIL_POWER_CYCLE:
- return "CDMA_LOCKED_UNTIL_POWER_CYCLE";
- case CDMA_DROP:
- return "CDMA_DROP";
- case CDMA_INTERCEPT:
- return "CDMA_INTERCEPT";
- case CDMA_REORDER:
- return "CDMA_REORDER";
- case CDMA_SO_REJECT:
- return "CDMA_SO_REJECT";
- case CDMA_RETRY_ORDER:
- return "CDMA_RETRY_ORDER";
- case CDMA_ACCESS_FAILURE:
- return "CDMA_ACCESS_FAILURE";
- case CDMA_PREEMPTED:
- return "CDMA_PREEMPTED";
- case CDMA_NOT_EMERGENCY:
- return "CDMA_NOT_EMERGENCY";
- case CDMA_ACCESS_BLOCKED:
- return "CDMA_ACCESS_BLOCKED";
- case EMERGENCY_ONLY:
- return "EMERGENCY_ONLY";
- case NO_PHONE_NUMBER_SUPPLIED:
- return "NO_PHONE_NUMBER_SUPPLIED";
- case DIALED_MMI:
- return "DIALED_MMI";
- case VOICEMAIL_NUMBER_MISSING:
- return "VOICEMAIL_NUMBER_MISSING";
- case CDMA_CALL_LOST:
- return "CDMA_CALL_LOST";
- case EXITED_ECM:
- return "EXITED_ECM";
- case DIAL_MODIFIED_TO_USSD:
- return "DIAL_MODIFIED_TO_USSD";
- case DIAL_MODIFIED_TO_SS:
- return "DIAL_MODIFIED_TO_SS";
- case DIAL_MODIFIED_TO_DIAL:
- return "DIAL_MODIFIED_TO_DIAL";
- case DIAL_MODIFIED_TO_DIAL_VIDEO:
- return "DIAL_MODIFIED_TO_DIAL_VIDEO";
- case DIAL_VIDEO_MODIFIED_TO_SS:
- return "DIAL_VIDEO_MODIFIED_TO_SS";
- case DIAL_VIDEO_MODIFIED_TO_USSD:
- return "DIAL_VIDEO_MODIFIED_TO_USSD";
- case DIAL_VIDEO_MODIFIED_TO_DIAL:
- return "DIAL_VIDEO_MODIFIED_TO_DIAL";
- case DIAL_VIDEO_MODIFIED_TO_DIAL_VIDEO:
- return "DIAL_VIDEO_MODIFIED_TO_DIAL_VIDEO";
- case ERROR_UNSPECIFIED:
- return "ERROR_UNSPECIFIED";
- case OUTGOING_FAILURE:
- return "OUTGOING_FAILURE";
- case OUTGOING_CANCELED:
- return "OUTGOING_CANCELED";
- case IMS_MERGED_SUCCESSFULLY:
- return "IMS_MERGED_SUCCESSFULLY";
- case CDMA_ALREADY_ACTIVATED:
- return "CDMA_ALREADY_ACTIVATED";
- case VIDEO_CALL_NOT_ALLOWED_WHILE_TTY_ENABLED:
- return "VIDEO_CALL_NOT_ALLOWED_WHILE_TTY_ENABLED";
- case CALL_PULLED:
- return "CALL_PULLED";
- case ANSWERED_ELSEWHERE:
- return "ANSWERED_ELSEWHERE";
- case MAXIMUM_NUMBER_OF_CALLS_REACHED:
- return "MAXIMUM_NUMER_OF_CALLS_REACHED";
- case DATA_DISABLED:
- return "DATA_DISABLED";
- case DATA_LIMIT_REACHED:
- return "DATA_LIMIT_REACHED";
- case DIALED_CALL_FORWARDING_WHILE_ROAMING:
- return "DIALED_CALL_FORWARDING_WHILE_ROAMING";
- case IMEI_NOT_ACCEPTED:
- return "IMEI_NOT_ACCEPTED";
- case WIFI_LOST:
- return "WIFI_LOST";
- case IMS_ACCESS_BLOCKED:
- return "IMS_ACCESS_BLOCKED";
- case LOW_BATTERY:
- return "LOW_BATTERY";
- case DIAL_LOW_BATTERY:
- return "DIAL_LOW_BATTERY";
- case EMERGENCY_TEMP_FAILURE:
- return "EMERGENCY_TEMP_FAILURE";
- case EMERGENCY_PERM_FAILURE:
- return "EMERGENCY_PERM_FAILURE";
- case NORMAL_UNSPECIFIED:
- return "NORMAL_UNSPECIFIED";
- case IMS_SIP_ALTERNATE_EMERGENCY_CALL:
- return "IMS_SIP_ALTERNATE_EMERGENCY_CALL";
- case ALREADY_DIALING:
- return "ALREADY_DIALING";
- case CANT_CALL_WHILE_RINGING:
- return "CANT_CALL_WHILE_RINGING";
- case CALLING_DISABLED:
- return "CALLING_DISABLED";
- case TOO_MANY_ONGOING_CALLS:
- return "TOO_MANY_ONGOING_CALLS";
- case OTASP_PROVISIONING_IN_PROCESS:
- return "OTASP_PROVISIONING_IN_PROCESS";
- case MEDIA_TIMEOUT:
- return "MEDIA_TIMEOUT";
- case EMERGENCY_CALL_OVER_WFC_NOT_AVAILABLE:
- return "EMERGENCY_CALL_OVER_WFC_NOT_AVAILABLE";
- case WFC_SERVICE_NOT_AVAILABLE_IN_THIS_LOCATION:
- return "WFC_SERVICE_NOT_AVAILABLE_IN_THIS_LOCATION";
- case OUTGOING_EMERGENCY_CALL_PLACED:
- return "OUTGOING_EMERGENCY_CALL_PLACED";
+ case NOT_DISCONNECTED:
+ return "NOT_DISCONNECTED";
+ case INCOMING_MISSED:
+ return "INCOMING_MISSED";
+ case NORMAL:
+ return "NORMAL";
+ case LOCAL:
+ return "LOCAL";
+ case BUSY:
+ return "BUSY";
+ case CONGESTION:
+ return "CONGESTION";
+ case INVALID_NUMBER:
+ return "INVALID_NUMBER";
+ case NUMBER_UNREACHABLE:
+ return "NUMBER_UNREACHABLE";
+ case SERVER_UNREACHABLE:
+ return "SERVER_UNREACHABLE";
+ case INVALID_CREDENTIALS:
+ return "INVALID_CREDENTIALS";
+ case OUT_OF_NETWORK:
+ return "OUT_OF_NETWORK";
+ case SERVER_ERROR:
+ return "SERVER_ERROR";
+ case TIMED_OUT:
+ return "TIMED_OUT";
+ case LOST_SIGNAL:
+ return "LOST_SIGNAL";
+ case LIMIT_EXCEEDED:
+ return "LIMIT_EXCEEDED";
+ case INCOMING_REJECTED:
+ return "INCOMING_REJECTED";
+ case POWER_OFF:
+ return "POWER_OFF";
+ case OUT_OF_SERVICE:
+ return "OUT_OF_SERVICE";
+ case ICC_ERROR:
+ return "ICC_ERROR";
+ case CALL_BARRED:
+ return "CALL_BARRED";
+ case FDN_BLOCKED:
+ return "FDN_BLOCKED";
+ case CS_RESTRICTED:
+ return "CS_RESTRICTED";
+ case CS_RESTRICTED_NORMAL:
+ return "CS_RESTRICTED_NORMAL";
+ case CS_RESTRICTED_EMERGENCY:
+ return "CS_RESTRICTED_EMERGENCY";
+ case UNOBTAINABLE_NUMBER:
+ return "UNOBTAINABLE_NUMBER";
+ case CDMA_LOCKED_UNTIL_POWER_CYCLE:
+ return "CDMA_LOCKED_UNTIL_POWER_CYCLE";
+ case CDMA_DROP:
+ return "CDMA_DROP";
+ case CDMA_INTERCEPT:
+ return "CDMA_INTERCEPT";
+ case CDMA_REORDER:
+ return "CDMA_REORDER";
+ case CDMA_SO_REJECT:
+ return "CDMA_SO_REJECT";
+ case CDMA_RETRY_ORDER:
+ return "CDMA_RETRY_ORDER";
+ case CDMA_ACCESS_FAILURE:
+ return "CDMA_ACCESS_FAILURE";
+ case CDMA_PREEMPTED:
+ return "CDMA_PREEMPTED";
+ case CDMA_NOT_EMERGENCY:
+ return "CDMA_NOT_EMERGENCY";
+ case CDMA_ACCESS_BLOCKED:
+ return "CDMA_ACCESS_BLOCKED";
+ case EMERGENCY_ONLY:
+ return "EMERGENCY_ONLY";
+ case NO_PHONE_NUMBER_SUPPLIED:
+ return "NO_PHONE_NUMBER_SUPPLIED";
+ case DIALED_MMI:
+ return "DIALED_MMI";
+ case VOICEMAIL_NUMBER_MISSING:
+ return "VOICEMAIL_NUMBER_MISSING";
+ case CDMA_CALL_LOST:
+ return "CDMA_CALL_LOST";
+ case EXITED_ECM:
+ return "EXITED_ECM";
+ case DIAL_MODIFIED_TO_USSD:
+ return "DIAL_MODIFIED_TO_USSD";
+ case DIAL_MODIFIED_TO_SS:
+ return "DIAL_MODIFIED_TO_SS";
+ case DIAL_MODIFIED_TO_DIAL:
+ return "DIAL_MODIFIED_TO_DIAL";
+ case DIAL_MODIFIED_TO_DIAL_VIDEO:
+ return "DIAL_MODIFIED_TO_DIAL_VIDEO";
+ case DIAL_VIDEO_MODIFIED_TO_SS:
+ return "DIAL_VIDEO_MODIFIED_TO_SS";
+ case DIAL_VIDEO_MODIFIED_TO_USSD:
+ return "DIAL_VIDEO_MODIFIED_TO_USSD";
+ case DIAL_VIDEO_MODIFIED_TO_DIAL:
+ return "DIAL_VIDEO_MODIFIED_TO_DIAL";
+ case DIAL_VIDEO_MODIFIED_TO_DIAL_VIDEO:
+ return "DIAL_VIDEO_MODIFIED_TO_DIAL_VIDEO";
+ case ERROR_UNSPECIFIED:
+ return "ERROR_UNSPECIFIED";
+ case OUTGOING_FAILURE:
+ return "OUTGOING_FAILURE";
+ case OUTGOING_CANCELED:
+ return "OUTGOING_CANCELED";
+ case IMS_MERGED_SUCCESSFULLY:
+ return "IMS_MERGED_SUCCESSFULLY";
+ case CDMA_ALREADY_ACTIVATED:
+ return "CDMA_ALREADY_ACTIVATED";
+ case VIDEO_CALL_NOT_ALLOWED_WHILE_TTY_ENABLED:
+ return "VIDEO_CALL_NOT_ALLOWED_WHILE_TTY_ENABLED";
+ case CALL_PULLED:
+ return "CALL_PULLED";
+ case ANSWERED_ELSEWHERE:
+ return "ANSWERED_ELSEWHERE";
+ case MAXIMUM_NUMBER_OF_CALLS_REACHED:
+ return "MAXIMUM_NUMER_OF_CALLS_REACHED";
+ case DATA_DISABLED:
+ return "DATA_DISABLED";
+ case DATA_LIMIT_REACHED:
+ return "DATA_LIMIT_REACHED";
+ case DIALED_CALL_FORWARDING_WHILE_ROAMING:
+ return "DIALED_CALL_FORWARDING_WHILE_ROAMING";
+ case IMEI_NOT_ACCEPTED:
+ return "IMEI_NOT_ACCEPTED";
+ case WIFI_LOST:
+ return "WIFI_LOST";
+ case IMS_ACCESS_BLOCKED:
+ return "IMS_ACCESS_BLOCKED";
+ case LOW_BATTERY:
+ return "LOW_BATTERY";
+ case DIAL_LOW_BATTERY:
+ return "DIAL_LOW_BATTERY";
+ case EMERGENCY_TEMP_FAILURE:
+ return "EMERGENCY_TEMP_FAILURE";
+ case EMERGENCY_PERM_FAILURE:
+ return "EMERGENCY_PERM_FAILURE";
+ case NORMAL_UNSPECIFIED:
+ return "NORMAL_UNSPECIFIED";
+ case IMS_SIP_ALTERNATE_EMERGENCY_CALL:
+ return "IMS_SIP_ALTERNATE_EMERGENCY_CALL";
+ case ALREADY_DIALING:
+ return "ALREADY_DIALING";
+ case CANT_CALL_WHILE_RINGING:
+ return "CANT_CALL_WHILE_RINGING";
+ case CALLING_DISABLED:
+ return "CALLING_DISABLED";
+ case TOO_MANY_ONGOING_CALLS:
+ return "TOO_MANY_ONGOING_CALLS";
+ case OTASP_PROVISIONING_IN_PROCESS:
+ return "OTASP_PROVISIONING_IN_PROCESS";
+ case MEDIA_TIMEOUT:
+ return "MEDIA_TIMEOUT";
+ case EMERGENCY_CALL_OVER_WFC_NOT_AVAILABLE:
+ return "EMERGENCY_CALL_OVER_WFC_NOT_AVAILABLE";
+ case WFC_SERVICE_NOT_AVAILABLE_IN_THIS_LOCATION:
+ return "WFC_SERVICE_NOT_AVAILABLE_IN_THIS_LOCATION";
+ case OUTGOING_EMERGENCY_CALL_PLACED:
+ return "OUTGOING_EMERGENCY_CALL_PLACED";
case INCOMING_AUTO_REJECTED:
return "INCOMING_AUTO_REJECTED";
- default:
- return "INVALID: " + cause;
+ case SATELLITE_ENABLED:
+ return "SATELLITE_ENABLED";
+ default:
+ return "INVALID: " + cause;
}
}
}
diff --git a/tests/SilkFX/res/layout/gainmap_image.xml b/tests/SilkFX/res/layout/gainmap_image.xml
index 89bbb70..b0ed914 100644
--- a/tests/SilkFX/res/layout/gainmap_image.xml
+++ b/tests/SilkFX/res/layout/gainmap_image.xml
@@ -34,7 +34,7 @@
android:layout_width="wrap_content"
android:layout_weight="1"
android:layout_height="wrap_content"
- android:text="SDR original" />
+ android:text="SDR" />
<RadioButton android:id="@+id/output_gainmap"
android:layout_width="wrap_content"
@@ -46,13 +46,34 @@
android:layout_width="wrap_content"
android:layout_weight="1"
android:layout_height="wrap_content"
- android:text="HDR (sdr+gainmap)" />
+ android:text="HDR" />
+
+ <RadioButton android:id="@+id/output_hdr_test"
+ android:layout_width="wrap_content"
+ android:layout_weight="1"
+ android:layout_height="wrap_content"
+ android:text="HDR (test)" />
</RadioGroup>
- <Spinner
- android:id="@+id/image_selection"
+ <LinearLayout
android:layout_width="match_parent"
- android:layout_height="wrap_content" />
+ android:layout_height="wrap_content"
+ android:orientation="horizontal">
+
+ <Spinner
+ android:id="@+id/image_selection"
+ android:layout_width="match_parent"
+ android:layout_weight="1"
+ android:layout_height="wrap_content" />
+
+ <Button
+ android:id="@+id/gainmap_metadata"
+ android:layout_width="match_parent"
+ android:layout_weight="1"
+ android:layout_height="wrap_content"
+ android:text="Gainmap Metadata..." />
+
+ </LinearLayout>
<TextView
android:id="@+id/error_msg"
@@ -67,4 +88,4 @@
</LinearLayout>
-</com.android.test.silkfx.hdr.GainmapImage>
\ No newline at end of file
+</com.android.test.silkfx.hdr.GainmapImage>
diff --git a/tests/SilkFX/res/layout/gainmap_metadata.xml b/tests/SilkFX/res/layout/gainmap_metadata.xml
new file mode 100644
index 0000000..0dabaca
--- /dev/null
+++ b/tests/SilkFX/res/layout/gainmap_metadata.xml
@@ -0,0 +1,264 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ ~ Copyright (C) 2023 The Android Open Source Project
+ ~
+ ~ Licensed under the Apache License, Version 2.0 (the "License");
+ ~ you may not use this file except in compliance with the License.
+ ~ You may obtain a copy of the License at
+ ~
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~
+ ~ Unless required by applicable law or agreed to in writing, software
+ ~ distributed under the License is distributed on an "AS IS" BASIS,
+ ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ ~ See the License for the specific language governing permissions and
+ ~ limitations under the License.
+ -->
+
+<RelativeLayout
+ xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content">
+
+ <LinearLayout
+ android:layout_width="350dp"
+ android:layout_height="300dp"
+ android:layout_centerHorizontal="true"
+ android:padding="8dp"
+ android:orientation="vertical"
+ android:background="#444444">
+
+ <TextView
+ android:id="@+id/gainmap_metadata_title"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_marginBottom="10dp"
+ android:text="Metadata for "HDR (test)" (values in linear space):" />
+
+ <LinearLayout
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_marginBottom="10dp"
+ android:orientation="horizontal">
+
+ <TextView
+ android:id="@+id/gainmap_metadata_gainmapmin_text"
+ android:layout_width="match_parent"
+ android:layout_weight="1"
+ android:layout_height="wrap_content"
+ android:text="Gain Map Min:" />
+
+ <TextView
+ android:id="@+id/gainmap_metadata_gainmapmin_val"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:ems="4"
+ android:text="TODO" />
+
+ <SeekBar
+ android:id="@+id/gainmap_metadata_gainmapmin"
+ android:min="0"
+ android:max="100"
+ android:layout_width="150dp"
+ android:layout_height="wrap_content" />
+
+ </LinearLayout>
+
+ <LinearLayout
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_marginBottom="10dp"
+ android:orientation="horizontal">
+
+ <TextView
+ android:id="@+id/gainmap_metadata_gainmapmax_text"
+ android:layout_width="match_parent"
+ android:layout_weight="1"
+ android:layout_height="wrap_content"
+ android:text="Gain Map Max:" />
+
+ <TextView
+ android:id="@+id/gainmap_metadata_gainmapmax_val"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:ems="4"
+ android:text="TODO" />
+
+ <SeekBar
+ android:id="@+id/gainmap_metadata_gainmapmax"
+ android:min="0"
+ android:max="100"
+ android:layout_width="150dp"
+ android:layout_height="wrap_content" />
+
+ </LinearLayout>
+
+ <LinearLayout
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_marginBottom="10dp"
+ android:orientation="horizontal">
+
+ <TextView
+ android:id="@+id/gainmap_metadata_capacitymin_text"
+ android:layout_width="match_parent"
+ android:layout_weight="1"
+ android:layout_height="wrap_content"
+ android:text="Capacity Min:" />
+
+ <TextView
+ android:id="@+id/gainmap_metadata_capacitymin_val"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:ems="4"
+ android:text="TODO" />
+
+ <SeekBar
+ android:id="@+id/gainmap_metadata_capacitymin"
+ android:min="0"
+ android:max="100"
+ android:layout_width="150dp"
+ android:layout_height="wrap_content" />
+
+ </LinearLayout>
+
+ <LinearLayout
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_marginBottom="10dp"
+ android:orientation="horizontal">
+
+ <TextView
+ android:id="@+id/gainmap_metadata_capacitymax_text"
+ android:layout_width="match_parent"
+ android:layout_weight="1"
+ android:layout_height="wrap_content"
+ android:text="Capacity Max:" />
+
+ <TextView
+ android:id="@+id/gainmap_metadata_capacitymax_val"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:ems="4"
+ android:text="TODO" />
+
+ <SeekBar
+ android:id="@+id/gainmap_metadata_capacitymax"
+ android:min="0"
+ android:max="100"
+ android:layout_width="150dp"
+ android:layout_height="wrap_content" />
+
+ </LinearLayout>
+
+ <LinearLayout
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_marginBottom="10dp"
+ android:orientation="horizontal">
+
+ <TextView
+ android:id="@+id/gainmap_metadata_gamma_text"
+ android:layout_width="match_parent"
+ android:layout_weight="1"
+ android:layout_height="wrap_content"
+ android:text="Gamma:" />
+
+ <TextView
+ android:id="@+id/gainmap_metadata_gamma_val"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:ems="4"
+ android:text="TODO" />
+
+ <SeekBar
+ android:id="@+id/gainmap_metadata_gamma"
+ android:min="0"
+ android:max="100"
+ android:layout_width="150dp"
+ android:layout_height="wrap_content" />
+
+ </LinearLayout>
+
+ <LinearLayout
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_marginBottom="10dp"
+ android:orientation="horizontal">
+
+ <TextView
+ android:id="@+id/gainmap_metadata_offsetsdr_text"
+ android:layout_width="match_parent"
+ android:layout_weight="1"
+ android:layout_height="wrap_content"
+ android:text="Offset SDR:" />
+
+ <TextView
+ android:id="@+id/gainmap_metadata_offsetsdr_val"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:ems="4"
+ android:text="TODO" />
+
+ <SeekBar
+ android:id="@+id/gainmap_metadata_offsetsdr"
+ android:min="0"
+ android:max="100"
+ android:layout_width="150dp"
+ android:layout_height="wrap_content" />
+
+ </LinearLayout>
+
+ <LinearLayout
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_marginBottom="10dp"
+ android:orientation="horizontal">
+
+ <TextView
+ android:id="@+id/gainmap_metadata_offsethdr_text"
+ android:layout_width="match_parent"
+ android:layout_weight="1"
+ android:layout_height="wrap_content"
+ android:text="Offset HDR:" />
+
+ <TextView
+ android:id="@+id/gainmap_metadata_offsethdr_val"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:ems="4"
+ android:text="TODO" />
+
+ <SeekBar
+ android:id="@+id/gainmap_metadata_offsethdr"
+ android:min="0"
+ android:max="100"
+ android:layout_width="150dp"
+ android:layout_height="wrap_content" />
+
+ </LinearLayout>
+
+ <LinearLayout
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:orientation="horizontal">
+
+ <Button
+ android:id="@+id/gainmap_metadata_reset"
+ android:layout_width="match_parent"
+ android:layout_weight="1"
+ android:layout_height="wrap_content"
+ android:text="Reset" />
+
+ <Button
+ android:id="@+id/gainmap_metadata_done"
+ android:layout_width="match_parent"
+ android:layout_weight="1"
+ android:layout_height="wrap_content"
+ android:text="Done" />
+
+ </LinearLayout>
+
+ </LinearLayout>
+
+</RelativeLayout>
diff --git a/tests/SilkFX/src/com/android/test/silkfx/hdr/GainmapImage.kt b/tests/SilkFX/src/com/android/test/silkfx/hdr/GainmapImage.kt
index 78bc4c4..7cf69b7 100644
--- a/tests/SilkFX/src/com/android/test/silkfx/hdr/GainmapImage.kt
+++ b/tests/SilkFX/src/com/android/test/silkfx/hdr/GainmapImage.kt
@@ -27,6 +27,7 @@
import android.view.View
import android.widget.AdapterView
import android.widget.ArrayAdapter
+import android.widget.Button
import android.widget.FrameLayout
import android.widget.RadioGroup
import android.widget.Spinner
@@ -44,6 +45,7 @@
private var gainmap: Gainmap? = null
private var gainmapVisualizer: Bitmap? = null
private lateinit var imageView: SubsamplingScaleImageView
+ private lateinit var gainmapMetadataEditor: GainmapMetadataEditor
init {
gainmapImages = context.assets.list("gainmaps")!!
@@ -58,6 +60,7 @@
super.onFinishInflate()
imageView = findViewById(R.id.image)!!
+ gainmapMetadataEditor = GainmapMetadataEditor(this, imageView)
findViewById<RadioGroup>(R.id.output_mode)!!.also {
it.check(outputMode)
@@ -92,6 +95,10 @@
}
}
+ findViewById<Button>(R.id.gainmap_metadata)!!.setOnClickListener {
+ gainmapMetadataEditor.openEditor()
+ }
+
setImage(0)
imageView.apply {
@@ -132,6 +139,7 @@
findViewById<RadioGroup>(R.id.output_mode)!!.visibility = View.VISIBLE
gainmap = bitmap!!.gainmap
+ gainmapMetadataEditor.setGainmap(gainmap)
val map = gainmap!!.gainmapContents
if (map.config != Bitmap.Config.ALPHA_8) {
gainmapVisualizer = map
@@ -175,7 +183,15 @@
imageView.setImage(ImageSource.cachedBitmap(when (outputMode) {
R.id.output_hdr -> {
- bitmap!!.gainmap = gainmap; bitmap!!
+ gainmapMetadataEditor.useOriginalMetadata()
+ bitmap!!.gainmap = gainmap
+ bitmap!!
+ }
+
+ R.id.output_hdr_test -> {
+ gainmapMetadataEditor.useEditMetadata()
+ bitmap!!.gainmap = gainmap
+ bitmap!!
}
R.id.output_sdr -> {
@@ -186,4 +202,4 @@
else -> throw IllegalStateException()
}))
}
-}
\ No newline at end of file
+}
diff --git a/tests/SilkFX/src/com/android/test/silkfx/hdr/GainmapMetadataEditor.kt b/tests/SilkFX/src/com/android/test/silkfx/hdr/GainmapMetadataEditor.kt
new file mode 100644
index 0000000..8a65304
--- /dev/null
+++ b/tests/SilkFX/src/com/android/test/silkfx/hdr/GainmapMetadataEditor.kt
@@ -0,0 +1,284 @@
+/*
+ * Copyright (C) 2023 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.test.silkfx.hdr
+
+import android.graphics.Gainmap
+import android.view.Gravity
+import android.view.LayoutInflater
+import android.view.View
+import android.view.ViewGroup
+import android.widget.Button
+import android.widget.PopupWindow
+import android.widget.SeekBar
+import android.widget.TextView
+import com.android.test.silkfx.R
+
+data class GainmapMetadata(
+ var ratioMin: Float,
+ var ratioMax: Float,
+ var capacityMin: Float,
+ var capacityMax: Float,
+ var gamma: Float,
+ var offsetSdr: Float,
+ var offsetHdr: Float
+)
+
+class GainmapMetadataEditor(val parent: ViewGroup, val renderView: View) {
+ private var gainmap: Gainmap? = null
+ private var showingEdits = false
+
+ private var metadataPopup: PopupWindow? = null
+
+ private var originalMetadata: GainmapMetadata = GainmapMetadata(
+ 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 0.0f, 0.0f)
+ private var currentMetadata: GainmapMetadata = originalMetadata.copy()
+
+ private val maxProgress = 100.0f
+
+ private val minRatioMin = .001f
+ private val maxRatioMin = 1.0f
+ private val minRatioMax = 1.0f
+ private val maxRatioMax = 16.0f
+ private val minCapacityMin = 1.0f
+ private val maxCapacityMin = maxRatioMax
+ private val minCapacityMax = 1.001f
+ private val maxCapacityMax = maxRatioMax
+ private val minGamma = 0.1f
+ private val maxGamma = 3.0f
+ // Min and max offsets are 0.0 and 1.0 respectively
+
+ fun setGainmap(newGainmap: Gainmap?) {
+ gainmap = newGainmap
+ originalMetadata = GainmapMetadata(gainmap!!.getRatioMin()[0],
+ gainmap!!.getRatioMax()[0], gainmap!!.getMinDisplayRatioForHdrTransition(),
+ gainmap!!.getDisplayRatioForFullHdr(), gainmap!!.getGamma()[0],
+ gainmap!!.getEpsilonSdr()[0], gainmap!!.getEpsilonHdr()[0])
+ currentMetadata = originalMetadata.copy()
+ }
+
+ fun useOriginalMetadata() {
+ showingEdits = false
+ applyMetadata(originalMetadata)
+ }
+
+ fun useEditMetadata() {
+ showingEdits = true
+ applyMetadata(currentMetadata)
+ }
+
+ fun closeEditor() {
+ metadataPopup?.let {
+ it.dismiss()
+ metadataPopup = null
+ }
+ }
+
+ fun openEditor() {
+ if (metadataPopup != null) return
+
+ val view = LayoutInflater.from(parent.getContext()).inflate(R.layout.gainmap_metadata, null)
+
+ metadataPopup = PopupWindow(view, ViewGroup.LayoutParams.WRAP_CONTENT,
+ ViewGroup.LayoutParams.WRAP_CONTENT)
+ metadataPopup!!.showAtLocation(view, Gravity.CENTER, 0, 0)
+
+ (view.getParent() as ViewGroup).removeView(view)
+ parent.addView(view)
+
+ view.findViewById<Button>(R.id.gainmap_metadata_done)!!.setOnClickListener {
+ closeEditor()
+ }
+
+ view.findViewById<Button>(R.id.gainmap_metadata_reset)!!.setOnClickListener {
+ resetGainmapMetadata()
+ }
+
+ updateMetadataUi()
+
+ val gainmapMinSeek = view.findViewById<SeekBar>(R.id.gainmap_metadata_gainmapmin)
+ val gainmapMaxSeek = view.findViewById<SeekBar>(R.id.gainmap_metadata_gainmapmax)
+ val capacityMinSeek = view.findViewById<SeekBar>(R.id.gainmap_metadata_capacitymin)
+ val capacityMaxSeek = view.findViewById<SeekBar>(R.id.gainmap_metadata_capacitymax)
+ val gammaSeek = view.findViewById<SeekBar>(R.id.gainmap_metadata_gamma)
+ val offsetSdrSeek = view.findViewById<SeekBar>(R.id.gainmap_metadata_offsetsdr)
+ val offsetHdrSeek = view.findViewById<SeekBar>(R.id.gainmap_metadata_offsethdr)
+ arrayOf(gainmapMinSeek, gainmapMaxSeek, capacityMinSeek, capacityMaxSeek, gammaSeek,
+ offsetSdrSeek, offsetHdrSeek).forEach {
+ it.setOnSeekBarChangeListener(object : SeekBar.OnSeekBarChangeListener{
+ override fun onProgressChanged(seekBar: SeekBar, progress: Int, fromUser: Boolean) {
+ if (!fromUser) return
+ val normalized = progress.toFloat() / maxProgress
+ when (seekBar) {
+ gainmapMinSeek -> updateGainmapMin(normalized)
+ gainmapMaxSeek -> updateGainmapMax(normalized)
+ capacityMinSeek -> updateCapacityMin(normalized)
+ capacityMaxSeek -> updateCapacityMax(normalized)
+ gammaSeek -> updateGamma(normalized)
+ offsetSdrSeek -> updateOffsetSdr(normalized)
+ offsetHdrSeek -> updateOffsetHdr(normalized)
+ }
+ }
+
+ override fun onStartTrackingTouch(seekBar: SeekBar) {}
+ override fun onStopTrackingTouch(seekBar: SeekBar) {}
+ })
+ }
+ }
+
+ private fun updateMetadataUi() {
+ val gainmapMinSeek = parent.findViewById<SeekBar>(R.id.gainmap_metadata_gainmapmin)
+ val gainmapMaxSeek = parent.findViewById<SeekBar>(R.id.gainmap_metadata_gainmapmax)
+ val capacityMinSeek = parent.findViewById<SeekBar>(R.id.gainmap_metadata_capacitymin)
+ val capacityMaxSeek = parent.findViewById<SeekBar>(R.id.gainmap_metadata_capacitymax)
+ val gammaSeek = parent.findViewById<SeekBar>(R.id.gainmap_metadata_gamma)
+ val offsetSdrSeek = parent.findViewById<SeekBar>(R.id.gainmap_metadata_offsetsdr)
+ val offsetHdrSeek = parent.findViewById<SeekBar>(R.id.gainmap_metadata_offsethdr)
+
+ gainmapMinSeek.setProgress(
+ ((currentMetadata.ratioMin - minRatioMin) / maxRatioMin * maxProgress).toInt())
+ gainmapMaxSeek.setProgress(
+ ((currentMetadata.ratioMax - minRatioMax) / maxRatioMax * maxProgress).toInt())
+ capacityMinSeek.setProgress(
+ ((currentMetadata.capacityMin - minCapacityMin) / maxCapacityMin * maxProgress).toInt())
+ capacityMaxSeek.setProgress(
+ ((currentMetadata.capacityMax - minCapacityMax) / maxCapacityMax * maxProgress).toInt())
+ gammaSeek.setProgress(
+ ((currentMetadata.gamma - minGamma) / maxGamma * maxProgress).toInt())
+ // Log base 3 via: log_b(x) = log_y(x) / log_y(b)
+ offsetSdrSeek.setProgress(
+ ((1.0 - Math.log(currentMetadata.offsetSdr.toDouble() / Math.log(3.0)) / -11.0)
+ .toFloat() * maxProgress).toInt())
+ offsetHdrSeek.setProgress(
+ ((1.0 - Math.log(currentMetadata.offsetHdr.toDouble() / Math.log(3.0)) / -11.0)
+ .toFloat() * maxProgress).toInt())
+
+ parent.findViewById<TextView>(R.id.gainmap_metadata_gainmapmin_val)!!.setText(
+ "%.3f".format(currentMetadata.ratioMin))
+ parent.findViewById<TextView>(R.id.gainmap_metadata_gainmapmax_val)!!.setText(
+ "%.3f".format(currentMetadata.ratioMax))
+ parent.findViewById<TextView>(R.id.gainmap_metadata_capacitymin_val)!!.setText(
+ "%.3f".format(currentMetadata.capacityMin))
+ parent.findViewById<TextView>(R.id.gainmap_metadata_capacitymax_val)!!.setText(
+ "%.3f".format(currentMetadata.capacityMax))
+ parent.findViewById<TextView>(R.id.gainmap_metadata_gamma_val)!!.setText(
+ "%.3f".format(currentMetadata.gamma))
+ parent.findViewById<TextView>(R.id.gainmap_metadata_offsetsdr_val)!!.setText(
+ "%.5f".format(currentMetadata.offsetSdr))
+ parent.findViewById<TextView>(R.id.gainmap_metadata_offsethdr_val)!!.setText(
+ "%.5f".format(currentMetadata.offsetHdr))
+ }
+
+ private fun resetGainmapMetadata() {
+ currentMetadata = originalMetadata.copy()
+ applyMetadata(currentMetadata)
+ updateMetadataUi()
+ }
+
+ private fun applyMetadata(newMetadata: GainmapMetadata) {
+ gainmap!!.setRatioMin(newMetadata.ratioMin, newMetadata.ratioMin, newMetadata.ratioMin)
+ gainmap!!.setRatioMax(newMetadata.ratioMax, newMetadata.ratioMax, newMetadata.ratioMax)
+ gainmap!!.setMinDisplayRatioForHdrTransition(newMetadata.capacityMin)
+ gainmap!!.setDisplayRatioForFullHdr(newMetadata.capacityMax)
+ gainmap!!.setGamma(newMetadata.gamma, newMetadata.gamma, newMetadata.gamma)
+ gainmap!!.setEpsilonSdr(newMetadata.offsetSdr, newMetadata.offsetSdr, newMetadata.offsetSdr)
+ gainmap!!.setEpsilonHdr(newMetadata.offsetHdr, newMetadata.offsetHdr, newMetadata.offsetHdr)
+ renderView.invalidate()
+ }
+
+ private fun updateGainmapMin(normalized: Float) {
+ val newValue = minRatioMin + normalized * (maxRatioMin - minRatioMin)
+ parent.findViewById<TextView>(R.id.gainmap_metadata_gainmapmin_val)!!.setText(
+ "%.3f".format(newValue))
+ currentMetadata.ratioMin = newValue
+ if (showingEdits) {
+ gainmap!!.setRatioMin(newValue, newValue, newValue)
+ renderView.invalidate()
+ }
+ }
+
+ private fun updateGainmapMax(normalized: Float) {
+ val newValue = minRatioMax + normalized * (maxRatioMax - minRatioMax)
+ parent.findViewById<TextView>(R.id.gainmap_metadata_gainmapmax_val)!!.setText(
+ "%.3f".format(newValue))
+ currentMetadata.ratioMax = newValue
+ if (showingEdits) {
+ gainmap!!.setRatioMax(newValue, newValue, newValue)
+ renderView.invalidate()
+ }
+ }
+
+ private fun updateCapacityMin(normalized: Float) {
+ val newValue = minCapacityMin + normalized * (maxCapacityMin - minCapacityMin)
+ parent.findViewById<TextView>(R.id.gainmap_metadata_capacitymin_val)!!.setText(
+ "%.3f".format(newValue))
+ currentMetadata.capacityMin = newValue
+ if (showingEdits) {
+ gainmap!!.setMinDisplayRatioForHdrTransition(newValue)
+ renderView.invalidate()
+ }
+ }
+
+ private fun updateCapacityMax(normalized: Float) {
+ val newValue = minCapacityMax + normalized * (maxCapacityMax - minCapacityMax)
+ parent.findViewById<TextView>(R.id.gainmap_metadata_capacitymax_val)!!.setText(
+ "%.3f".format(newValue))
+ currentMetadata.capacityMax = newValue
+ if (showingEdits) {
+ gainmap!!.setDisplayRatioForFullHdr(newValue)
+ renderView.invalidate()
+ }
+ }
+
+ private fun updateGamma(normalized: Float) {
+ val newValue = minGamma + normalized * (maxGamma - minGamma)
+ parent.findViewById<TextView>(R.id.gainmap_metadata_gamma_val)!!.setText(
+ "%.3f".format(newValue))
+ currentMetadata.gamma = newValue
+ if (showingEdits) {
+ gainmap!!.setGamma(newValue, newValue, newValue)
+ renderView.invalidate()
+ }
+ }
+
+ private fun updateOffsetSdr(normalized: Float) {
+ var newValue = 0.0f
+ if (normalized > 0.0f ) {
+ newValue = Math.pow(3.0, (1.0 - normalized.toDouble()) * -11.0).toFloat()
+ }
+ parent.findViewById<TextView>(R.id.gainmap_metadata_offsetsdr_val)!!.setText(
+ "%.5f".format(newValue))
+ currentMetadata.offsetSdr = newValue
+ if (showingEdits) {
+ gainmap!!.setEpsilonSdr(newValue, newValue, newValue)
+ renderView.invalidate()
+ }
+ }
+
+ private fun updateOffsetHdr(normalized: Float) {
+ var newValue = 0.0f
+ if (normalized > 0.0f ) {
+ newValue = Math.pow(3.0, (1.0 - normalized.toDouble()) * -11.0).toFloat()
+ }
+ parent.findViewById<TextView>(R.id.gainmap_metadata_offsethdr_val)!!.setText(
+ "%.5f".format(newValue))
+ currentMetadata.offsetHdr = newValue
+ if (showingEdits) {
+ gainmap!!.setEpsilonHdr(newValue, newValue, newValue)
+ renderView.invalidate()
+ }
+ }
+}