Merge "Fix CombinationKeyTests failure" into udc-dev
diff --git a/core/java/android/app/admin/DevicePolicyManager.java b/core/java/android/app/admin/DevicePolicyManager.java
index 27f5545..e0364cb 100644
--- a/core/java/android/app/admin/DevicePolicyManager.java
+++ b/core/java/android/app/admin/DevicePolicyManager.java
@@ -13401,11 +13401,10 @@
/**
* Called by a device admin or holder of the permission
* {@link android.Manifest.permission#MANAGE_DEVICE_POLICY_SUPPORT_MESSAGE} to set the short
- * support message. This will be displayed to the user
- * in settings screens where funtionality has been disabled by the admin. The message should be
- * limited to a short statement such as "This setting is disabled by your administrator. Contact
- * someone@example.com for support." If the message is longer than 200 characters it may be
- * truncated.
+ * support message. This will be displayed to the user in settings screens where functionality
+ * has been disabled by the admin. The message should be limited to a short statement such as
+ * "This setting is disabled by your administrator. Contact someone@example.com for support."
+ * If the message is longer than 200 characters it may be truncated.
* <p>
* If the short support message needs to be localized, it is the responsibility of the
* {@link DeviceAdminReceiver} to listen to the {@link Intent#ACTION_LOCALE_CHANGED} broadcast
@@ -13460,7 +13459,8 @@
/**
* Called by a device admin to set the long support message. This will be displayed to the user
- * in the device administators settings screen.
+ * in the device administrators settings screen. If the message is longer than 20000 characters
+ * it may be truncated.
* <p>
* If the long support message needs to be localized, it is the responsibility of the
* {@link DeviceAdminReceiver} to listen to the {@link Intent#ACTION_LOCALE_CHANGED} broadcast
diff --git a/core/java/android/provider/Settings.java b/core/java/android/provider/Settings.java
index 3487b01..79e7574 100644
--- a/core/java/android/provider/Settings.java
+++ b/core/java/android/provider/Settings.java
@@ -11496,6 +11496,8 @@
public static final int DEVICE_STATE_ROTATION_KEY_HALF_FOLDED = 1;
/** @hide */
public static final int DEVICE_STATE_ROTATION_KEY_UNFOLDED = 2;
+ /** @hide */
+ public static final int DEVICE_STATE_ROTATION_KEY_REAR_DISPLAY = 3;
/**
* The different postures that can be used as keys with
@@ -11507,6 +11509,7 @@
DEVICE_STATE_ROTATION_KEY_FOLDED,
DEVICE_STATE_ROTATION_KEY_HALF_FOLDED,
DEVICE_STATE_ROTATION_KEY_UNFOLDED,
+ DEVICE_STATE_ROTATION_KEY_REAR_DISPLAY,
})
@Retention(RetentionPolicy.SOURCE)
public @interface DeviceStateRotationLockKey {
diff --git a/core/java/android/view/DisplayInfo.java b/core/java/android/view/DisplayInfo.java
index f2373fb..d8fa533 100644
--- a/core/java/android/view/DisplayInfo.java
+++ b/core/java/android/view/DisplayInfo.java
@@ -360,6 +360,14 @@
public SparseArray<SurfaceControl.RefreshRateRange> thermalRefreshRateThrottling =
new SparseArray<>();
+ /**
+ * The ID of the brightness throttling data that should be used. This can change e.g. in
+ * concurrent displays mode in which a stricter brightness throttling policy might need to be
+ * used.
+ */
+ @Nullable
+ public String thermalBrightnessThrottlingDataId;
+
public static final @android.annotation.NonNull Creator<DisplayInfo> CREATOR = new Creator<DisplayInfo>() {
@Override
public DisplayInfo createFromParcel(Parcel source) {
@@ -437,7 +445,9 @@
&& Objects.equals(displayShape, other.displayShape)
&& Objects.equals(layoutLimitedRefreshRate, other.layoutLimitedRefreshRate)
&& BrightnessSynchronizer.floatEquals(hdrSdrRatio, other.hdrSdrRatio)
- && thermalRefreshRateThrottling.contentEquals(other.thermalRefreshRateThrottling);
+ && thermalRefreshRateThrottling.contentEquals(other.thermalRefreshRateThrottling)
+ && Objects.equals(
+ thermalBrightnessThrottlingDataId, other.thermalBrightnessThrottlingDataId);
}
@Override
@@ -495,6 +505,7 @@
layoutLimitedRefreshRate = other.layoutLimitedRefreshRate;
hdrSdrRatio = other.hdrSdrRatio;
thermalRefreshRateThrottling = other.thermalRefreshRateThrottling;
+ thermalBrightnessThrottlingDataId = other.thermalBrightnessThrottlingDataId;
}
public void readFromParcel(Parcel source) {
@@ -559,6 +570,7 @@
hdrSdrRatio = source.readFloat();
thermalRefreshRateThrottling = source.readSparseArray(null,
SurfaceControl.RefreshRateRange.class);
+ thermalBrightnessThrottlingDataId = source.readString8();
}
@Override
@@ -620,6 +632,7 @@
dest.writeTypedObject(layoutLimitedRefreshRate, flags);
dest.writeFloat(hdrSdrRatio);
dest.writeSparseArray(thermalRefreshRateThrottling);
+ dest.writeString8(thermalBrightnessThrottlingDataId);
}
@Override
@@ -889,6 +902,8 @@
}
sb.append(", thermalRefreshRateThrottling ");
sb.append(thermalRefreshRateThrottling);
+ sb.append(", thermalBrightnessThrottlingDataId ");
+ sb.append(thermalBrightnessThrottlingDataId);
sb.append("}");
return sb.toString();
}
diff --git a/core/java/com/android/internal/app/ResolverActivity.java b/core/java/com/android/internal/app/ResolverActivity.java
index 499d38c..50f393b 100644
--- a/core/java/com/android/internal/app/ResolverActivity.java
+++ b/core/java/com/android/internal/app/ResolverActivity.java
@@ -1725,16 +1725,17 @@
if (inWorkProfile) {
((TextView) findViewById(R.id.open_cross_profile)).setText(
- devicePolicyResourcesManager.getString(MINIRESOLVER_OPEN_IN_WORK,
- () -> getString(R.string.miniresolver_open_in_work, targetDisplayLabel),
+ devicePolicyResourcesManager.getString(MINIRESOLVER_OPEN_IN_PERSONAL,
+ () -> getString(R.string.miniresolver_open_in_personal,
+ targetDisplayLabel),
targetDisplayLabel));
((Button) findViewById(R.id.use_same_profile_browser)).setText(
devicePolicyResourcesManager.getString(MINIRESOLVER_USE_WORK_BROWSER,
() -> getString(R.string.miniresolver_use_work_browser)));
} else {
((TextView) findViewById(R.id.open_cross_profile)).setText(
- devicePolicyResourcesManager.getString(MINIRESOLVER_OPEN_IN_PERSONAL,
- () -> getString(R.string.miniresolver_open_in_personal,
+ devicePolicyResourcesManager.getString(MINIRESOLVER_OPEN_IN_WORK,
+ () -> getString(R.string.miniresolver_open_in_work,
targetDisplayLabel),
targetDisplayLabel));
((Button) findViewById(R.id.use_same_profile_browser)).setText(
diff --git a/core/java/com/android/internal/util/TraceBuffer.java b/core/java/com/android/internal/util/TraceBuffer.java
index bfcd65d..fcc77bd4 100644
--- a/core/java/com/android/internal/util/TraceBuffer.java
+++ b/core/java/com/android/internal/util/TraceBuffer.java
@@ -103,6 +103,10 @@
this(bufferCapacity, new ProtoOutputStreamProvider(), null);
}
+ public TraceBuffer(int bufferCapacity, Consumer<T> protoDequeuedCallback) {
+ this(bufferCapacity, new ProtoOutputStreamProvider(), protoDequeuedCallback);
+ }
+
public TraceBuffer(int bufferCapacity, ProtoProvider protoProvider,
Consumer<T> protoDequeuedCallback) {
mBufferCapacity = bufferCapacity;
diff --git a/core/tests/bugreports/src/com/android/os/bugreports/tests/BugreportManagerTest.java b/core/tests/bugreports/src/com/android/os/bugreports/tests/BugreportManagerTest.java
index bf8c7c6..72969f7 100644
--- a/core/tests/bugreports/src/com/android/os/bugreports/tests/BugreportManagerTest.java
+++ b/core/tests/bugreports/src/com/android/os/bugreports/tests/BugreportManagerTest.java
@@ -112,6 +112,7 @@
Paths.get("/data/misc/wmtrace/layers_trace.winscope"),
Paths.get("/data/misc/wmtrace/transactions_trace.winscope"),
Paths.get("/data/misc/wmtrace/transition_trace.winscope"),
+ Paths.get("/data/misc/wmtrace/shell_transition_trace.winscope"),
};
private static final Path[] UI_TRACES_GENERATED_DURING_BUGREPORT = {
Paths.get("/data/misc/wmtrace/layers_trace_from_transactions.winscope"),
diff --git a/core/tests/coretests/src/android/view/ImeInsetsSourceConsumerTest.java b/core/tests/coretests/src/android/view/ImeInsetsSourceConsumerTest.java
index a3eda8d..f45db23 100644
--- a/core/tests/coretests/src/android/view/ImeInsetsSourceConsumerTest.java
+++ b/core/tests/coretests/src/android/view/ImeInsetsSourceConsumerTest.java
@@ -39,7 +39,6 @@
import android.widget.TextView;
import androidx.test.ext.junit.runners.AndroidJUnit4;
-import androidx.test.filters.FlakyTest;
import androidx.test.platform.app.InstrumentationRegistry;
import org.junit.Before;
@@ -55,7 +54,6 @@
* atest FrameworksCoreTests:ImeInsetsSourceConsumerTest
*/
@Presubmit
-@FlakyTest(detail = "Promote once confirmed non-flaky")
@RunWith(AndroidJUnit4.class)
public class ImeInsetsSourceConsumerTest {
diff --git a/libs/WindowManager/Shell/Android.bp b/libs/WindowManager/Shell/Android.bp
index 54978bd..6a79bc1 100644
--- a/libs/WindowManager/Shell/Android.bp
+++ b/libs/WindowManager/Shell/Android.bp
@@ -125,6 +125,34 @@
// End ProtoLog
+gensrcs {
+ name: "wm-shell-protos",
+
+ tools: [
+ "aprotoc",
+ "protoc-gen-javastream",
+ "soong_zip",
+ ],
+
+ tool_files: [
+ ":libprotobuf-internal-protos",
+ ],
+
+ cmd: "mkdir -p $(genDir)/$(in) " +
+ "&& $(location aprotoc) " +
+ " --plugin=$(location protoc-gen-javastream) " +
+ " --javastream_out=$(genDir)/$(in) " +
+ " -Iexternal/protobuf/src " +
+ " -I . " +
+ " $(in) " +
+ "&& $(location soong_zip) -jar -o $(out) -C $(genDir)/$(in) -D $(genDir)/$(in)",
+
+ srcs: [
+ "proto/**/*.proto",
+ ],
+ output_extension: "srcjar",
+}
+
java_library {
name: "WindowManager-Shell-proto",
@@ -142,6 +170,7 @@
// TODO(b/168581922) protologtool do not support kotlin(*.kt)
":wm_shell-sources-kt",
":wm_shell-aidls",
+ ":wm-shell-protos",
],
resource_dirs: [
"res",
diff --git a/libs/WindowManager/Shell/proto/wm_shell_transition_trace.proto b/libs/WindowManager/Shell/proto/wm_shell_transition_trace.proto
new file mode 100644
index 0000000..6e01101
--- /dev/null
+++ b/libs/WindowManager/Shell/proto/wm_shell_transition_trace.proto
@@ -0,0 +1,55 @@
+/*
+ * Copyright (C) 2020 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.
+ */
+
+syntax = "proto2";
+
+package com.android.wm.shell;
+
+option java_multiple_files = true;
+
+/* Represents a file full of transition entries.
+ Encoded, it should start with 0x09 0x57 0x4D 0x53 0x54 0x52 0x41 0x43 0x45 (.WMSTRACE), such
+ that it can be easily identified. */
+message WmShellTransitionTraceProto {
+ /* constant; MAGIC_NUMBER = (long) MAGIC_NUMBER_H << 32 | MagicNumber.MAGIC_NUMBER_L
+ (this is needed because enums have to be 32 bits and there's no nice way to put 64bit
+ constants into .proto files. */
+ enum MagicNumber {
+ INVALID = 0;
+ MAGIC_NUMBER_L = 0x54534D57; /* WMST (little-endian ASCII) */
+ MAGIC_NUMBER_H = 0x45434152; /* RACE (little-endian ASCII) */
+ }
+
+ // Must be the first field, set to value in MagicNumber
+ required fixed64 magic_number = 1;
+ repeated Transition transitions = 2;
+ repeated HandlerMapping handlerMappings = 3;
+}
+
+message Transition {
+ required int32 id = 1;
+ optional int64 dispatch_time_ns = 2;
+ optional int32 handler = 3;
+ optional int64 merge_time_ns = 4;
+ optional int64 merge_request_time_ns = 5;
+ optional int32 merged_into = 6;
+ optional int64 abort_time_ns = 7;
+}
+
+message HandlerMapping {
+ required int32 id = 1;
+ required string name = 2;
+}
diff --git a/libs/WindowManager/Shell/res/layout/letterbox_restart_dialog_layout.xml b/libs/WindowManager/Shell/res/layout/letterbox_restart_dialog_layout.xml
index 5aff415..7f1aac3 100644
--- a/libs/WindowManager/Shell/res/layout/letterbox_restart_dialog_layout.xml
+++ b/libs/WindowManager/Shell/res/layout/letterbox_restart_dialog_layout.xml
@@ -73,11 +73,13 @@
android:textAlignment="center"/>
<LinearLayout
+ android:id="@+id/letterbox_restart_dialog_checkbox_container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
+ android:paddingVertical="14dp"
android:orientation="horizontal"
android:layout_gravity="center_vertical"
- android:layout_marginVertical="32dp">
+ android:layout_marginVertical="18dp">
<CheckBox
android:id="@+id/letterbox_restart_dialog_checkbox"
diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/common/split/SplitLayout.java b/libs/WindowManager/Shell/src/com/android/wm/shell/common/split/SplitLayout.java
index 9eba5ec..e7dede7 100644
--- a/libs/WindowManager/Shell/src/com/android/wm/shell/common/split/SplitLayout.java
+++ b/libs/WindowManager/Shell/src/com/android/wm/shell/common/split/SplitLayout.java
@@ -738,10 +738,6 @@
getRefBounds2(mTempRect);
t.setPosition(leash2, mTempRect.left, mTempRect.top)
.setWindowCrop(leash2, mTempRect.width(), mTempRect.height());
- // Make right or bottom side surface always higher than left or top side to avoid weird
- // animation when dismiss split. e.g. App surface fling above on decor surface.
- t.setLayer(leash1, 1);
- t.setLayer(leash2, 2);
if (mImePositionProcessor.adjustSurfaceLayoutForIme(
t, dividerLeash, leash1, leash2, dimLayer1, dimLayer2)) {
diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/compatui/RestartDialogLayout.java b/libs/WindowManager/Shell/src/com/android/wm/shell/compatui/RestartDialogLayout.java
index c53e638..05fd5f1 100644
--- a/libs/WindowManager/Shell/src/com/android/wm/shell/compatui/RestartDialogLayout.java
+++ b/libs/WindowManager/Shell/src/com/android/wm/shell/compatui/RestartDialogLayout.java
@@ -95,6 +95,9 @@
@Override
protected void onFinishInflate() {
super.onFinishInflate();
+ final View checkboxContainer = findViewById(
+ R.id.letterbox_restart_dialog_checkbox_container);
+ final CheckBox checkbox = findViewById(R.id.letterbox_restart_dialog_checkbox);
mDialogContainer = findViewById(R.id.letterbox_restart_dialog_container);
mDialogTitle = findViewById(R.id.letterbox_restart_dialog_title);
mBackgroundDim = getBackground().mutate();
@@ -103,5 +106,6 @@
// We add a no-op on-click listener to the dialog container so that clicks on it won't
// propagate to the listener of the layout (which represents the background dim).
mDialogContainer.setOnClickListener(view -> {});
+ checkboxContainer.setOnClickListener(view -> checkbox.performClick());
}
}
diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/dagger/WMShellBaseModule.java b/libs/WindowManager/Shell/src/com/android/wm/shell/dagger/WMShellBaseModule.java
index 36d941b..80e920f 100644
--- a/libs/WindowManager/Shell/src/com/android/wm/shell/dagger/WMShellBaseModule.java
+++ b/libs/WindowManager/Shell/src/com/android/wm/shell/dagger/WMShellBaseModule.java
@@ -544,13 +544,14 @@
DisplayController displayController,
@ShellMainThread ShellExecutor mainExecutor,
@ShellMainThread Handler mainHandler,
- @ShellAnimationThread ShellExecutor animExecutor) {
+ @ShellAnimationThread ShellExecutor animExecutor,
+ ShellCommandHandler shellCommandHandler) {
if (!context.getResources().getBoolean(R.bool.config_registerShellTransitionsOnInit)) {
// TODO(b/238217847): Force override shell init if registration is disabled
shellInit = new ShellInit(mainExecutor);
}
return new Transitions(context, shellInit, shellController, organizer, pool,
- displayController, mainExecutor, mainHandler, animExecutor);
+ displayController, mainExecutor, mainHandler, animExecutor, shellCommandHandler);
}
@WMSingleton
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 eb4d2a1..bffc51c 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
@@ -549,6 +549,14 @@
// are in mOpening.
for (int i = 0; i < closingTasks.size(); ++i) {
final TransitionInfo.Change change = closingTasks.get(i);
+ final int pausingIdx = TaskState.indexOf(mPausingTasks, change);
+ if (pausingIdx >= 0) {
+ mPausingTasks.remove(pausingIdx);
+ didMergeThings = true;
+ ProtoLog.v(ShellProtoLogGroup.WM_SHELL_RECENTS_TRANSITION,
+ " closing pausing taskId=%d", change.getTaskInfo().taskId);
+ continue;
+ }
int openingIdx = TaskState.indexOf(mOpeningTasks, change);
if (openingIdx < 0) {
Slog.w(TAG, "Closing a task that wasn't opening, this may be split or"
@@ -601,6 +609,11 @@
didMergeThings = true;
mState = STATE_NEW_TASK;
}
+ if (mPausingTasks.isEmpty()) {
+ // The pausing tasks may be removed by the incoming closing tasks.
+ ProtoLog.v(ShellProtoLogGroup.WM_SHELL_RECENTS_TRANSITION,
+ "[%d] RecentsController.merge: empty pausing tasks", mInstanceId);
+ }
if (!hasTaskChange) {
// Activity only transition, so consume the merge as it doesn't affect the rest of
// recents.
diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/splitscreen/SplitScreenTransitions.java b/libs/WindowManager/Shell/src/com/android/wm/shell/splitscreen/SplitScreenTransitions.java
index 51b8000..a2af93f 100644
--- a/libs/WindowManager/Shell/src/com/android/wm/shell/splitscreen/SplitScreenTransitions.java
+++ b/libs/WindowManager/Shell/src/com/android/wm/shell/splitscreen/SplitScreenTransitions.java
@@ -30,8 +30,6 @@
import static com.android.wm.shell.splitscreen.SplitScreenController.exitReasonToString;
import static com.android.wm.shell.transition.Transitions.TRANSIT_SPLIT_DISMISS;
import static com.android.wm.shell.transition.Transitions.TRANSIT_SPLIT_DISMISS_SNAP;
-import static com.android.wm.shell.transition.Transitions.TRANSIT_SPLIT_SCREEN_OPEN_TO_SIDE;
-import static com.android.wm.shell.transition.Transitions.TRANSIT_SPLIT_SCREEN_PAIR_OPEN;
import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
@@ -165,7 +163,7 @@
t.setLayer(leash, Integer.MAX_VALUE);
t.show(leash);
}
- boolean isOpening = isOpeningTransition(info);
+ boolean isOpening = TransitionUtil.isOpeningType(info.getType());
if (isOpening && (mode == TRANSIT_OPEN || mode == TRANSIT_TO_FRONT)) {
// fade in
startExampleAnimation(leash, true /* show */);
@@ -295,14 +293,16 @@
@Nullable RemoteTransition remoteTransition,
Transitions.TransitionHandler handler,
@Nullable TransitionConsumedCallback consumedCallback,
- @Nullable TransitionFinishedCallback finishedCallback) {
+ @Nullable TransitionFinishedCallback finishedCallback,
+ int extraTransitType) {
if (mPendingEnter != null) {
ProtoLog.v(ShellProtoLogGroup.WM_SHELL_TRANSITIONS, " splitTransition "
+ " skip to start enter split transition since it already exist. ");
return null;
}
final IBinder transition = mTransitions.startTransition(transitType, wct, handler);
- setEnterTransition(transition, remoteTransition, consumedCallback, finishedCallback);
+ setEnterTransition(transition, remoteTransition, consumedCallback, finishedCallback,
+ extraTransitType);
return transition;
}
@@ -310,9 +310,10 @@
void setEnterTransition(@NonNull IBinder transition,
@Nullable RemoteTransition remoteTransition,
@Nullable TransitionConsumedCallback consumedCallback,
- @Nullable TransitionFinishedCallback finishedCallback) {
+ @Nullable TransitionFinishedCallback finishedCallback,
+ int extraTransitType) {
mPendingEnter = new TransitSession(
- transition, consumedCallback, finishedCallback, remoteTransition);
+ transition, consumedCallback, finishedCallback, remoteTransition, extraTransitType);
ProtoLog.v(ShellProtoLogGroup.WM_SHELL_TRANSITIONS, " splitTransition "
+ " deduced Enter split screen");
@@ -513,12 +514,6 @@
mTransitions.getAnimExecutor().execute(va::start);
}
- private boolean isOpeningTransition(TransitionInfo info) {
- return TransitionUtil.isOpeningType(info.getType())
- || info.getType() == TRANSIT_SPLIT_SCREEN_OPEN_TO_SIDE
- || info.getType() == TRANSIT_SPLIT_SCREEN_PAIR_OPEN;
- }
-
/** Calls when the transition got consumed. */
interface TransitionConsumedCallback {
void onConsumed(boolean aborted);
@@ -539,16 +534,19 @@
/** Whether the transition was canceled. */
boolean mCanceled;
+ /** A note for extra transit type, to help indicate custom transition. */
+ final int mExtraTransitType;
+
TransitSession(IBinder transition,
@Nullable TransitionConsumedCallback consumedCallback,
@Nullable TransitionFinishedCallback finishedCallback) {
- this(transition, consumedCallback, finishedCallback, null /* remoteTransition */);
+ this(transition, consumedCallback, finishedCallback, null /* remoteTransition */, 0);
}
TransitSession(IBinder transition,
@Nullable TransitionConsumedCallback consumedCallback,
@Nullable TransitionFinishedCallback finishedCallback,
- @Nullable RemoteTransition remoteTransition) {
+ @Nullable RemoteTransition remoteTransition, int extraTransitType) {
mTransition = transition;
mConsumedCallback = consumedCallback;
mFinishedCallback = finishedCallback;
@@ -560,6 +558,7 @@
mTransitions.getMainExecutor(), remoteTransition);
mRemoteHandler.setTransition(transition);
}
+ mExtraTransitType = extraTransitType;
}
/** Sets transition consumed callback. */
diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/splitscreen/StageCoordinator.java b/libs/WindowManager/Shell/src/com/android/wm/shell/splitscreen/StageCoordinator.java
index 4c903f5..0ef26fc 100644
--- a/libs/WindowManager/Shell/src/com/android/wm/shell/splitscreen/StageCoordinator.java
+++ b/libs/WindowManager/Shell/src/com/android/wm/shell/splitscreen/StageCoordinator.java
@@ -446,26 +446,10 @@
RemoteAnimationTarget[] wallpapers,
RemoteAnimationTarget[] nonApps,
final IRemoteAnimationFinishedCallback finishedCallback) {
- boolean openingToSide = false;
- if (apps != null) {
- for (int i = 0; i < apps.length; ++i) {
- if (apps[i].mode == MODE_OPENING
- && mSideStage.containsTask(apps[i].taskId)) {
- openingToSide = true;
- break;
- }
- }
- } else if (mSideStage.getChildCount() != 0) {
- // There are chances the entering app transition got canceled by performing
- // rotation transition. Checks if there is any child task existed in split
- // screen before fallback to cancel entering flow.
- openingToSide = true;
- }
-
- if (isEnteringSplit && !openingToSide) {
+ if (isEnteringSplit && mSideStage.getChildCount() == 0) {
mMainExecutor.execute(() -> exitSplitScreen(
- mSideStage.getChildCount() == 0 ? mMainStage : mSideStage,
- EXIT_REASON_UNKNOWN));
+ null /* childrenToTop */, EXIT_REASON_UNKNOWN));
+ mSplitUnsupportedToast.show();
}
if (finishedCallback != null) {
@@ -526,17 +510,17 @@
wct.sendPendingIntent(intent, fillInIntent, options);
// If split screen is not activated, we're expecting to open a pair of apps to split.
- final int transitType = mMainStage.isActive()
+ final int extraTransitType = mMainStage.isActive()
? TRANSIT_SPLIT_SCREEN_OPEN_TO_SIDE : TRANSIT_SPLIT_SCREEN_PAIR_OPEN;
prepareEnterSplitScreen(wct, null /* taskInfo */, position);
- mSplitTransitions.startEnterTransition(transitType, wct, null, this,
+ mSplitTransitions.startEnterTransition(TRANSIT_TO_FRONT, wct, null, this,
null /* consumedCallback */,
(finishWct, finishT) -> {
if (!evictWct.isEmpty()) {
finishWct.merge(evictWct, true);
}
- } /* finishedCallback */);
+ } /* finishedCallback */, extraTransitType);
}
/** Launches an activity into split by legacy transition. */
@@ -550,26 +534,10 @@
RemoteAnimationTarget[] wallpapers, RemoteAnimationTarget[] nonApps,
IRemoteAnimationFinishedCallback finishedCallback,
SurfaceControl.Transaction t) {
- boolean openingToSide = false;
- if (apps != null) {
- for (int i = 0; i < apps.length; ++i) {
- if (apps[i].mode == MODE_OPENING
- && mSideStage.containsTask(apps[i].taskId)) {
- openingToSide = true;
- break;
- }
- }
- } else if (mSideStage.getChildCount() != 0) {
- // There are chances the entering app transition got canceled by performing
- // rotation transition. Checks if there is any child task existed in split
- // screen before fallback to cancel entering flow.
- openingToSide = true;
- }
-
- if (isEnteringSplit && !openingToSide && apps != null) {
+ if (isEnteringSplit && mSideStage.getChildCount() == 0) {
mMainExecutor.execute(() -> exitSplitScreen(
- mSideStage.getChildCount() == 0 ? mMainStage : mSideStage,
- EXIT_REASON_UNKNOWN));
+ null /* childrenToTop */, EXIT_REASON_UNKNOWN));
+ mSplitUnsupportedToast.show();
}
if (apps != null) {
@@ -709,7 +677,8 @@
wct.startTask(mainTaskId, mainOptions);
mSplitTransitions.startEnterTransition(
- TRANSIT_SPLIT_SCREEN_PAIR_OPEN, wct, remoteTransition, this, null, null);
+ TRANSIT_TO_FRONT, wct, remoteTransition, this, null, null,
+ TRANSIT_SPLIT_SCREEN_PAIR_OPEN);
setEnterInstanceId(instanceId);
}
@@ -760,7 +729,8 @@
}
mSplitTransitions.startEnterTransition(
- TRANSIT_SPLIT_SCREEN_PAIR_OPEN, wct, remoteTransition, this, null, null);
+ TRANSIT_TO_FRONT, wct, remoteTransition, this, null, null,
+ TRANSIT_SPLIT_SCREEN_PAIR_OPEN);
setEnterInstanceId(instanceId);
}
@@ -1088,7 +1058,7 @@
private void onRemoteAnimationFinishedOrCancelled(WindowContainerTransaction evictWct) {
mIsDividerRemoteAnimating = false;
mShouldUpdateRecents = true;
- mSplitRequest = null;
+ clearRequestIfPresented();
// If any stage has no child after animation finished, it means that split will display
// nothing, such status will happen if task and intent is same app but not support
// multi-instance, we should exit split and expand that app as full screen.
@@ -1108,7 +1078,7 @@
private void onRemoteAnimationFinished(RemoteAnimationTarget[] apps) {
mIsDividerRemoteAnimating = false;
mShouldUpdateRecents = true;
- mSplitRequest = null;
+ clearRequestIfPresented();
// If any stage has no child after finished animation, that side of the split will display
// nothing. This might happen if starting the same app on the both sides while not
// supporting multi-instance. Exit the split screen and expand that app to full screen.
@@ -1381,6 +1351,7 @@
});
mShouldUpdateRecents = false;
mIsDividerRemoteAnimating = false;
+ mSplitRequest = null;
mSplitLayout.getInvisibleBounds(mTempRect1);
if (childrenToTop == null || childrenToTop.getTopVisibleChildTaskId() == INVALID_TASK_ID) {
@@ -1473,6 +1444,13 @@
}
}
+ private void clearRequestIfPresented() {
+ if (mSideStageListener.mVisible && mSideStageListener.mHasChildren
+ && mMainStageListener.mVisible && mSideStageListener.mHasChildren) {
+ mSplitRequest = null;
+ }
+ }
+
/**
* Returns whether the split pair in the recent tasks list should be broken.
*/
@@ -1851,6 +1829,7 @@
true /* setReparentLeafTaskIfRelaunch */);
setRootForceTranslucent(true, wct);
} else {
+ clearRequestIfPresented();
wct.setReparentLeafTaskIfRelaunch(mRootTaskInfo.token,
false /* setReparentLeafTaskIfRelaunch */);
setRootForceTranslucent(false, wct);
@@ -2010,7 +1989,7 @@
}
if (mMainStageListener.mHasChildren && mSideStageListener.mHasChildren) {
mShouldUpdateRecents = true;
- mSplitRequest = null;
+ clearRequestIfPresented();
updateRecentTasksSplitPair();
if (!mLogger.hasStartedSession()) {
@@ -2334,7 +2313,8 @@
out = new WindowContainerTransaction();
prepareEnterSplitScreen(out);
mSplitTransitions.setEnterTransition(transition, request.getRemoteTransition(),
- null /* consumedCallback */, null /* finishedCallback */);
+ null /* consumedCallback */, null /* finishedCallback */,
+ 0 /* extraTransitType */);
}
}
return out;
@@ -2573,7 +2553,8 @@
}
}
- if (info.getType() == TRANSIT_SPLIT_SCREEN_OPEN_TO_SIDE) {
+ if (mSplitTransitions.mPendingEnter.mExtraTransitType
+ == TRANSIT_SPLIT_SCREEN_OPEN_TO_SIDE) {
if (mainChild == null && sideChild == null) {
Log.w(TAG, "Launched a task in split, but didn't receive any task in transition.");
mSplitTransitions.mPendingEnter.cancel(null /* finishedCb */);
@@ -2716,6 +2697,7 @@
}
});
mShouldUpdateRecents = false;
+ mSplitRequest = null;
// Update local states.
setSplitsVisible(false);
diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/splitscreen/StageTaskListener.java b/libs/WindowManager/Shell/src/com/android/wm/shell/splitscreen/StageTaskListener.java
index ead0bcd..a841b7f 100644
--- a/libs/WindowManager/Shell/src/com/android/wm/shell/splitscreen/StageTaskListener.java
+++ b/libs/WindowManager/Shell/src/com/android/wm/shell/splitscreen/StageTaskListener.java
@@ -220,20 +220,12 @@
mCallbacks.onNoLongerSupportMultiWindow();
return;
}
- if (taskInfo.topActivity == null && mChildrenTaskInfo.contains(taskInfo.taskId)
- && mChildrenTaskInfo.get(taskInfo.taskId).topActivity != null) {
- // If top activity become null, it means the task is about to vanish, we use this
- // signal to remove it from children list earlier for smooth dismiss transition.
- mChildrenTaskInfo.remove(taskInfo.taskId);
- mChildrenLeashes.remove(taskInfo.taskId);
- } else {
- mChildrenTaskInfo.put(taskInfo.taskId, taskInfo);
- }
+ mChildrenTaskInfo.put(taskInfo.taskId, taskInfo);
mCallbacks.onChildTaskStatusChanged(taskInfo.taskId, true /* present */,
taskInfo.isVisible);
- if (!ENABLE_SHELL_TRANSITIONS && mChildrenLeashes.contains(taskInfo.taskId)) {
- updateChildTaskSurface(taskInfo, mChildrenLeashes.get(taskInfo.taskId),
- false /* firstAppeared */);
+ if (!ENABLE_SHELL_TRANSITIONS) {
+ updateChildTaskSurface(
+ taskInfo, mChildrenLeashes.get(taskInfo.taskId), false /* firstAppeared */);
}
} else {
throw new IllegalArgumentException(this + "\n Unknown task: " + taskInfo
@@ -267,6 +259,9 @@
return;
}
sendStatusChanged();
+ } else {
+ throw new IllegalArgumentException(this + "\n Unknown task: " + taskInfo
+ + "\n mRootTaskInfo: " + mRootTaskInfo);
}
}
diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/transition/Tracer.java b/libs/WindowManager/Shell/src/com/android/wm/shell/transition/Tracer.java
new file mode 100644
index 0000000..9d7c39f
--- /dev/null
+++ b/libs/WindowManager/Shell/src/com/android/wm/shell/transition/Tracer.java
@@ -0,0 +1,327 @@
+/*
+ * 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.wm.shell.transition;
+
+import static android.os.Build.IS_USER;
+
+import static com.android.wm.shell.WmShellTransitionTraceProto.MAGIC_NUMBER;
+import static com.android.wm.shell.WmShellTransitionTraceProto.MAGIC_NUMBER_H;
+import static com.android.wm.shell.WmShellTransitionTraceProto.MAGIC_NUMBER_L;
+
+import android.annotation.NonNull;
+import android.annotation.Nullable;
+import android.os.SystemClock;
+import android.os.Trace;
+import android.util.Log;
+import android.util.proto.ProtoOutputStream;
+
+import com.android.internal.util.TraceBuffer;
+import com.android.wm.shell.sysui.ShellCommandHandler;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * Helper class to collect and dump transition traces.
+ */
+public class Tracer implements ShellCommandHandler.ShellCommandActionHandler {
+ private static final int ALWAYS_ON_TRACING_CAPACITY = 15 * 1024; // 15 KB
+ private static final int ACTIVE_TRACING_BUFFER_CAPACITY = 5000 * 1024; // 5 MB
+
+ private static final long MAGIC_NUMBER_VALUE = ((long) MAGIC_NUMBER_H << 32) | MAGIC_NUMBER_L;
+
+ static final String WINSCOPE_EXT = ".winscope";
+ private static final String TRACE_FILE =
+ "/data/misc/wmtrace/shell_transition_trace" + WINSCOPE_EXT;
+
+ private final Object mEnabledLock = new Object();
+ private boolean mActiveTracingEnabled = false;
+
+ private final TraceBuffer mTraceBuffer = new TraceBuffer(ALWAYS_ON_TRACING_CAPACITY,
+ (proto) -> handleOnEntryRemovedFromTrace(proto));
+ private final Map<Object, Runnable> mRemovedFromTraceCallbacks = new HashMap<>();
+
+ private final Map<Transitions.TransitionHandler, Integer> mHandlerIds = new HashMap<>();
+ private final Map<Transitions.TransitionHandler, Integer> mHandlerUseCountInTrace =
+ new HashMap<>();
+
+ /**
+ * Adds an entry in the trace to log that a transition has been dispatched to a handler.
+ *
+ * @param transitionId The id of the transition being dispatched.
+ * @param handler The handler the transition is being dispatched to.
+ */
+ public void logDispatched(int transitionId, Transitions.TransitionHandler handler) {
+ final int handlerId;
+ if (mHandlerIds.containsKey(handler)) {
+ handlerId = mHandlerIds.get(handler);
+ } else {
+ handlerId = mHandlerIds.size();
+ mHandlerIds.put(handler, handlerId);
+ }
+
+ ProtoOutputStream outputStream = new ProtoOutputStream();
+ final long protoToken =
+ outputStream.start(com.android.wm.shell.WmShellTransitionTraceProto.TRANSITIONS);
+
+ outputStream.write(com.android.wm.shell.Transition.ID, transitionId);
+ outputStream.write(com.android.wm.shell.Transition.DISPATCH_TIME_NS,
+ SystemClock.elapsedRealtimeNanos());
+ outputStream.write(com.android.wm.shell.Transition.HANDLER, handlerId);
+
+ outputStream.end(protoToken);
+
+ final int useCountAfterAdd = mHandlerUseCountInTrace.getOrDefault(handler, 0) + 1;
+ mHandlerUseCountInTrace.put(handler, useCountAfterAdd);
+
+ mRemovedFromTraceCallbacks.put(outputStream, () -> {
+ final int useCountAfterRemove = mHandlerUseCountInTrace.get(handler) - 1;
+ mHandlerUseCountInTrace.put(handler, useCountAfterRemove);
+ });
+
+ mTraceBuffer.add(outputStream);
+ }
+
+ /**
+ * Adds an entry in the trace to log that a request to merge a transition was made.
+ *
+ * @param mergeRequestedTransitionId The id of the transition we are requesting to be merged.
+ * @param playingTransitionId The id of the transition we was to merge the transition into.
+ */
+ public void logMergeRequested(int mergeRequestedTransitionId, int playingTransitionId) {
+ ProtoOutputStream outputStream = new ProtoOutputStream();
+ final long protoToken =
+ outputStream.start(com.android.wm.shell.WmShellTransitionTraceProto.TRANSITIONS);
+
+ outputStream.write(com.android.wm.shell.Transition.ID, mergeRequestedTransitionId);
+ outputStream.write(com.android.wm.shell.Transition.MERGE_REQUEST_TIME_NS,
+ SystemClock.elapsedRealtimeNanos());
+ outputStream.write(com.android.wm.shell.Transition.MERGED_INTO, playingTransitionId);
+
+ outputStream.end(protoToken);
+
+ mTraceBuffer.add(outputStream);
+ }
+
+ /**
+ * Adds an entry in the trace to log that a transition was merged by the handler.
+ *
+ * @param mergedTransitionId The id of the transition that was merged.
+ * @param playingTransitionId The id of the transition the transition was merged into.
+ */
+ public void logMerged(int mergedTransitionId, int playingTransitionId) {
+ ProtoOutputStream outputStream = new ProtoOutputStream();
+ final long protoToken =
+ outputStream.start(com.android.wm.shell.WmShellTransitionTraceProto.TRANSITIONS);
+
+ outputStream.write(com.android.wm.shell.Transition.ID, mergedTransitionId);
+ outputStream.write(
+ com.android.wm.shell.Transition.MERGE_TIME_NS, SystemClock.elapsedRealtimeNanos());
+ outputStream.write(com.android.wm.shell.Transition.MERGED_INTO, playingTransitionId);
+
+ outputStream.end(protoToken);
+
+ mTraceBuffer.add(outputStream);
+ }
+
+ /**
+ * Adds an entry in the trace to log that a transition was aborted.
+ *
+ * @param transitionId The id of the transition that was aborted.
+ */
+ public void logAborted(int transitionId) {
+ ProtoOutputStream outputStream = new ProtoOutputStream();
+ final long protoToken =
+ outputStream.start(com.android.wm.shell.WmShellTransitionTraceProto.TRANSITIONS);
+
+ outputStream.write(com.android.wm.shell.Transition.ID, transitionId);
+ outputStream.write(
+ com.android.wm.shell.Transition.ABORT_TIME_NS, SystemClock.elapsedRealtimeNanos());
+
+ outputStream.end(protoToken);
+
+ mTraceBuffer.add(outputStream);
+ }
+
+ /**
+ * Starts collecting transitions for the trace.
+ * If called while a trace is already running, this will reset the trace.
+ */
+ public void startTrace(@Nullable PrintWriter pw) {
+ if (IS_USER) {
+ LogAndPrintln.e(pw, "Tracing is not supported on user builds.");
+ return;
+ }
+ Trace.beginSection("Tracer#startTrace");
+ LogAndPrintln.i(pw, "Starting shell transition trace.");
+ synchronized (mEnabledLock) {
+ mActiveTracingEnabled = true;
+ mTraceBuffer.resetBuffer();
+ mTraceBuffer.setCapacity(ACTIVE_TRACING_BUFFER_CAPACITY);
+ }
+ Trace.endSection();
+ }
+
+ /**
+ * Stops collecting the transition trace and dump to trace to file.
+ *
+ * Dumps the trace to @link{TRACE_FILE}.
+ */
+ public void stopTrace(@Nullable PrintWriter pw) {
+ stopTrace(pw, new File(TRACE_FILE));
+ }
+
+ /**
+ * Stops collecting the transition trace and dump to trace to file.
+ * @param outputFile The file to dump the transition trace to.
+ */
+ public void stopTrace(@Nullable PrintWriter pw, File outputFile) {
+ if (IS_USER) {
+ LogAndPrintln.e(pw, "Tracing is not supported on user builds.");
+ return;
+ }
+ Trace.beginSection("Tracer#stopTrace");
+ LogAndPrintln.i(pw, "Stopping shell transition trace.");
+ synchronized (mEnabledLock) {
+ mActiveTracingEnabled = false;
+ writeTraceToFileLocked(pw, outputFile);
+ mTraceBuffer.resetBuffer();
+ mTraceBuffer.setCapacity(ALWAYS_ON_TRACING_CAPACITY);
+ }
+ Trace.endSection();
+ }
+
+ /**
+ * Being called while taking a bugreport so that tracing files can be included in the bugreport.
+ *
+ * @param pw Print writer
+ */
+ public void saveForBugreport(@Nullable PrintWriter pw) {
+ if (IS_USER) {
+ LogAndPrintln.e(pw, "Tracing is not supported on user builds.");
+ return;
+ }
+ Trace.beginSection("TransitionTracer#saveForBugreport");
+ synchronized (mEnabledLock) {
+ final File outputFile = new File(TRACE_FILE);
+ writeTraceToFileLocked(pw, outputFile);
+ }
+ Trace.endSection();
+ }
+
+ private void writeTraceToFileLocked(@Nullable PrintWriter pw, File file) {
+ Trace.beginSection("TransitionTracer#writeTraceToFileLocked");
+ try {
+ ProtoOutputStream proto = new ProtoOutputStream();
+ proto.write(MAGIC_NUMBER, MAGIC_NUMBER_VALUE);
+ writeHandlerMappingToProto(proto);
+ int pid = android.os.Process.myPid();
+ LogAndPrintln.i(pw, "Writing file to " + file.getAbsolutePath()
+ + " from process " + pid);
+ mTraceBuffer.writeTraceToFile(file, proto);
+ } catch (IOException e) {
+ LogAndPrintln.e(pw, "Unable to write buffer to file", e);
+ }
+ Trace.endSection();
+ }
+
+ private void writeHandlerMappingToProto(ProtoOutputStream outputStream) {
+ for (Transitions.TransitionHandler handler : mHandlerUseCountInTrace.keySet()) {
+ final int count = mHandlerUseCountInTrace.get(handler);
+ if (count > 0) {
+ final long protoToken = outputStream.start(
+ com.android.wm.shell.WmShellTransitionTraceProto.HANDLER_MAPPINGS);
+ outputStream.write(com.android.wm.shell.HandlerMapping.ID,
+ mHandlerIds.get(handler));
+ outputStream.write(com.android.wm.shell.HandlerMapping.NAME,
+ handler.getClass().getName());
+ outputStream.end(protoToken);
+ }
+ }
+ }
+
+ private void handleOnEntryRemovedFromTrace(Object proto) {
+ if (mRemovedFromTraceCallbacks.containsKey(proto)) {
+ mRemovedFromTraceCallbacks.get(proto).run();
+ mRemovedFromTraceCallbacks.remove(proto);
+ }
+ }
+
+ @Override
+ public boolean onShellCommand(String[] args, PrintWriter pw) {
+ switch (args[0]) {
+ case "start": {
+ startTrace(pw);
+ return true;
+ }
+ case "stop": {
+ stopTrace(pw);
+ return true;
+ }
+ case "save-for-bugreport": {
+ saveForBugreport(pw);
+ return true;
+ }
+ default: {
+ pw.println("Invalid command: " + args[0]);
+ printShellCommandHelp(pw, "");
+ return false;
+ }
+ }
+ }
+
+ @Override
+ public void printShellCommandHelp(PrintWriter pw, String prefix) {
+ pw.println(prefix + "start");
+ pw.println(prefix + " Start tracing the transitions.");
+ pw.println(prefix + "stop");
+ pw.println(prefix + " Stop tracing the transitions.");
+ pw.println(prefix + "save-for-bugreport");
+ pw.println(prefix + " Flush in memory transition trace to file.");
+ }
+
+ private static class LogAndPrintln {
+ private static final String LOG_TAG = "ShellTransitionTracer";
+
+ private static void i(@Nullable PrintWriter pw, String msg) {
+ Log.i(LOG_TAG, msg);
+ if (pw != null) {
+ pw.println(msg);
+ pw.flush();
+ }
+ }
+
+ private static void e(@Nullable PrintWriter pw, String msg) {
+ Log.e(LOG_TAG, msg);
+ if (pw != null) {
+ pw.println("ERROR: " + msg);
+ pw.flush();
+ }
+ }
+
+ private static void e(@Nullable PrintWriter pw, String msg, @NonNull Exception e) {
+ Log.e(LOG_TAG, msg, e);
+ if (pw != null) {
+ pw.println("ERROR: " + msg + " ::\n " + e);
+ pw.flush();
+ }
+ }
+ }
+}
diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/transition/Transitions.java b/libs/WindowManager/Shell/src/com/android/wm/shell/transition/Transitions.java
index a4057b1..f79f1f7 100644
--- a/libs/WindowManager/Shell/src/com/android/wm/shell/transition/Transitions.java
+++ b/libs/WindowManager/Shell/src/com/android/wm/shell/transition/Transitions.java
@@ -74,10 +74,12 @@
import com.android.wm.shell.common.TransactionPool;
import com.android.wm.shell.common.annotations.ExternalThread;
import com.android.wm.shell.protolog.ShellProtoLogGroup;
+import com.android.wm.shell.sysui.ShellCommandHandler;
import com.android.wm.shell.sysui.ShellController;
import com.android.wm.shell.sysui.ShellInit;
import com.android.wm.shell.util.TransitionUtil;
+import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
@@ -106,7 +108,8 @@
* track, it will be marked as SYNC. This means that all currently active tracks must be flushed
* before the SYNC transition can play.
*/
-public class Transitions implements RemoteCallable<Transitions> {
+public class Transitions implements RemoteCallable<Transitions>,
+ ShellCommandHandler.ShellCommandActionHandler {
static final String TAG = "ShellTransitions";
/** Set to {@code true} to enable shell transitions. */
@@ -165,12 +168,15 @@
private final ShellController mShellController;
private final ShellTransitionImpl mImpl = new ShellTransitionImpl();
private final SleepHandler mSleepHandler = new SleepHandler();
-
+ private final Tracer mTracer = new Tracer();
private boolean mIsRegistered = false;
/** List of possible handlers. Ordered by specificity (eg. tapped back to front). */
private final ArrayList<TransitionHandler> mHandlers = new ArrayList<>();
+ @Nullable
+ private final ShellCommandHandler mShellCommandHandler;
+
private final ArrayList<TransitionObserver> mObservers = new ArrayList<>();
/** List of {@link Runnable} instances to run when the last active transition has finished. */
@@ -246,8 +252,23 @@
@NonNull WindowOrganizer organizer,
@NonNull TransactionPool pool,
@NonNull DisplayController displayController,
- @NonNull ShellExecutor mainExecutor, @NonNull Handler mainHandler,
+ @NonNull ShellExecutor mainExecutor,
+ @NonNull Handler mainHandler,
@NonNull ShellExecutor animExecutor) {
+ this(context, shellInit, shellController, organizer, pool, displayController, mainExecutor,
+ mainHandler, animExecutor, null);
+ }
+
+ public Transitions(@NonNull Context context,
+ @NonNull ShellInit shellInit,
+ @NonNull ShellController shellController,
+ @NonNull WindowOrganizer organizer,
+ @NonNull TransactionPool pool,
+ @NonNull DisplayController displayController,
+ @NonNull ShellExecutor mainExecutor,
+ @NonNull Handler mainHandler,
+ @NonNull ShellExecutor animExecutor,
+ @Nullable ShellCommandHandler shellCommandHandler) {
mOrganizer = organizer;
mContext = context;
mMainExecutor = mainExecutor;
@@ -263,6 +284,7 @@
ProtoLog.v(ShellProtoLogGroup.WM_SHELL_TRANSITIONS, "addHandler: Default");
// Next lowest priority is remote transitions.
mHandlers.add(mRemoteTransitionHandler);
+ mShellCommandHandler = shellCommandHandler;
ProtoLog.v(ShellProtoLogGroup.WM_SHELL_TRANSITIONS, "addHandler: Remote");
shellInit.addInitCallback(this::onInit, this);
}
@@ -294,6 +316,10 @@
// Pre-load the instance.
TransitionMetrics.getInstance();
}
+
+ if (mShellCommandHandler != null) {
+ mShellCommandHandler.addCommandCallback("transitions", this, this);
+ }
}
public boolean isRegistered() {
@@ -766,6 +792,7 @@
ProtoLog.v(ShellProtoLogGroup.WM_SHELL_TRANSITIONS, "Transition %s ready while"
+ " %s is still animating. Notify the animating transition"
+ " in case they can be merged", ready, playing);
+ mTracer.logMergeRequested(ready.mInfo.getDebugId(), playing.mInfo.getDebugId());
playing.mHandler.mergeAnimation(ready.mToken, ready.mInfo, ready.mStartT,
playing.mToken, (wct, cb) -> onMerged(playing, ready));
}
@@ -799,6 +826,7 @@
for (int i = 0; i < mObservers.size(); ++i) {
mObservers.get(i).onTransitionMerged(merged.mToken, playing.mToken);
}
+ mTracer.logMerged(merged.mInfo.getDebugId(), playing.mInfo.getDebugId());
// See if we should merge another transition.
processReadyQueue(track);
}
@@ -825,6 +853,8 @@
// Otherwise give every other handler a chance
active.mHandler = dispatchTransition(active.mToken, active.mInfo, active.mStartT,
active.mFinishT, (wct, cb) -> onFinish(active, wct, cb), active.mHandler);
+
+ mTracer.logDispatched(active.mInfo.getDebugId(), active.mHandler);
}
/**
@@ -876,6 +906,8 @@
transition.mFinishT.apply();
transition.mAborted = true;
+ mTracer.logAborted(transition.mInfo.getDebugId());
+
if (transition.mHandler != null) {
// Notifies to clean-up the aborted transition.
transition.mHandler.onTransitionConsumed(
@@ -1350,4 +1382,26 @@
mMainExecutor.execute(() -> dispatchAnimScaleSetting(mTransitionAnimationScaleSetting));
}
}
+
+
+ @Override
+ public boolean onShellCommand(String[] args, PrintWriter pw) {
+ switch (args[0]) {
+ case "tracing": {
+ mTracer.onShellCommand(Arrays.copyOfRange(args, 1, args.length), pw);
+ return true;
+ }
+ default: {
+ pw.println("Invalid command: " + args[0]);
+ printShellCommandHelp(pw, "");
+ return false;
+ }
+ }
+ }
+
+ @Override
+ public void printShellCommandHelp(PrintWriter pw, String prefix) {
+ pw.println(prefix + "tracing");
+ mTracer.printShellCommandHelp(pw, prefix + " ");
+ }
}
diff --git a/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/splitscreen/SplitTransitionTests.java b/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/splitscreen/SplitTransitionTests.java
index a9f311f..92cbf7f 100644
--- a/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/splitscreen/SplitTransitionTests.java
+++ b/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/splitscreen/SplitTransitionTests.java
@@ -180,8 +180,9 @@
TestRemoteTransition testRemote = new TestRemoteTransition();
IBinder transition = mSplitScreenTransitions.startEnterTransition(
- TRANSIT_SPLIT_SCREEN_PAIR_OPEN, new WindowContainerTransaction(),
- new RemoteTransition(testRemote, "Test"), mStageCoordinator, null, null);
+ TRANSIT_OPEN, new WindowContainerTransaction(),
+ new RemoteTransition(testRemote, "Test"), mStageCoordinator, null, null,
+ TRANSIT_SPLIT_SCREEN_PAIR_OPEN);
mMainStage.onTaskAppeared(mMainChild, createMockSurface());
mSideStage.onTaskAppeared(mSideChild, createMockSurface());
boolean accepted = mStageCoordinator.startAnimation(transition, info,
@@ -397,7 +398,7 @@
}
private TransitionInfo createEnterPairInfo() {
- return new TransitionInfoBuilder(TRANSIT_SPLIT_SCREEN_PAIR_OPEN, 0)
+ return new TransitionInfoBuilder(TRANSIT_OPEN, 0)
.addChange(TRANSIT_OPEN, mMainChild)
.addChange(TRANSIT_OPEN, mSideChild)
.build();
@@ -406,9 +407,9 @@
private void enterSplit() {
TransitionInfo enterInfo = createEnterPairInfo();
IBinder enterTransit = mSplitScreenTransitions.startEnterTransition(
- TRANSIT_SPLIT_SCREEN_PAIR_OPEN, new WindowContainerTransaction(),
+ TRANSIT_OPEN, new WindowContainerTransaction(),
new RemoteTransition(new TestRemoteTransition(), "Test"),
- mStageCoordinator, null, null);
+ mStageCoordinator, null, null, TRANSIT_SPLIT_SCREEN_PAIR_OPEN);
mMainStage.onTaskAppeared(mMainChild, createMockSurface());
mSideStage.onTaskAppeared(mSideChild, createMockSurface());
mStageCoordinator.startAnimation(enterTransit, enterInfo,
diff --git a/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/splitscreen/StageTaskListenerTests.java b/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/splitscreen/StageTaskListenerTests.java
index 784ad9b..1a1bebd 100644
--- a/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/splitscreen/StageTaskListenerTests.java
+++ b/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/splitscreen/StageTaskListenerTests.java
@@ -126,6 +126,12 @@
verify(mCallbacks).onStatusChanged(eq(mRootTask.isVisible), eq(true));
}
+ @Test(expected = IllegalArgumentException.class)
+ public void testUnknownTaskVanished() {
+ final ActivityManager.RunningTaskInfo task = new TestRunningTaskInfoBuilder().build();
+ mStageTaskListener.onTaskVanished(task);
+ }
+
@Test
public void testTaskVanished() {
// With shell transitions, the transition manages status changes, so skip this test.
diff --git a/packages/SettingsLib/DeviceStateRotationLock/src/com.android.settingslib.devicestate/PosturesHelper.kt b/packages/SettingsLib/DeviceStateRotationLock/src/com.android.settingslib.devicestate/PosturesHelper.kt
index 9c70be9..6a13eb8 100644
--- a/packages/SettingsLib/DeviceStateRotationLock/src/com.android.settingslib.devicestate/PosturesHelper.kt
+++ b/packages/SettingsLib/DeviceStateRotationLock/src/com.android.settingslib.devicestate/PosturesHelper.kt
@@ -19,6 +19,7 @@
import android.content.Context
import android.provider.Settings.Secure.DEVICE_STATE_ROTATION_KEY_FOLDED
import android.provider.Settings.Secure.DEVICE_STATE_ROTATION_KEY_HALF_FOLDED
+import android.provider.Settings.Secure.DEVICE_STATE_ROTATION_KEY_REAR_DISPLAY
import android.provider.Settings.Secure.DEVICE_STATE_ROTATION_KEY_UNFOLDED
import android.provider.Settings.Secure.DEVICE_STATE_ROTATION_KEY_UNKNOWN
import android.provider.Settings.Secure.DeviceStateRotationLockKey
@@ -33,6 +34,8 @@
context.resources.getIntArray(R.array.config_halfFoldedDeviceStates)
private val unfoldedDeviceStates =
context.resources.getIntArray(R.array.config_openDeviceStates)
+ private val rearDisplayDeviceStates =
+ context.resources.getIntArray(R.array.config_rearDisplayDeviceStates)
@DeviceStateRotationLockKey
fun deviceStateToPosture(deviceState: Int): Int {
@@ -40,6 +43,7 @@
in foldedDeviceStates -> DEVICE_STATE_ROTATION_KEY_FOLDED
in halfFoldedDeviceStates -> DEVICE_STATE_ROTATION_KEY_HALF_FOLDED
in unfoldedDeviceStates -> DEVICE_STATE_ROTATION_KEY_UNFOLDED
+ in rearDisplayDeviceStates -> DEVICE_STATE_ROTATION_KEY_REAR_DISPLAY
else -> DEVICE_STATE_ROTATION_KEY_UNKNOWN
}
}
@@ -49,6 +53,7 @@
DEVICE_STATE_ROTATION_KEY_FOLDED -> foldedDeviceStates.firstOrNull()
DEVICE_STATE_ROTATION_KEY_HALF_FOLDED -> halfFoldedDeviceStates.firstOrNull()
DEVICE_STATE_ROTATION_KEY_UNFOLDED -> unfoldedDeviceStates.firstOrNull()
+ DEVICE_STATE_ROTATION_KEY_REAR_DISPLAY -> rearDisplayDeviceStates.firstOrNull()
else -> null
}
}
diff --git a/packages/SettingsLib/MainSwitchPreference/res/drawable/settingslib_ic_info.xml b/packages/SettingsLib/MainSwitchPreference/res/drawable/settingslib_ic_info.xml
deleted file mode 100644
index c8037c8..0000000
--- a/packages/SettingsLib/MainSwitchPreference/res/drawable/settingslib_ic_info.xml
+++ /dev/null
@@ -1,26 +0,0 @@
-<!--
- Copyright (C) 2021 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.
--->
-<!-- copy from frameworks/base/core/res/res/drawable/ic_info.xml-->
-<vector xmlns:android="http://schemas.android.com/apk/res/android"
- android:width="24dp"
- android:height="24dp"
- android:viewportWidth="24"
- android:viewportHeight="24"
- android:tint="?attr/colorControlNormal">
- <path
- android:fillColor="@android:color/white"
- android:pathData="M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm1 15h-2v-6h2v6zm0-8h-2V7h2v2z"/>
-</vector>
\ No newline at end of file
diff --git a/packages/SettingsLib/MainSwitchPreference/res/layout-v31/settingslib_main_switch_bar.xml b/packages/SettingsLib/MainSwitchPreference/res/layout-v31/settingslib_main_switch_bar.xml
index ca84db8..b1c26e8 100644
--- a/packages/SettingsLib/MainSwitchPreference/res/layout-v31/settingslib_main_switch_bar.xml
+++ b/packages/SettingsLib/MainSwitchPreference/res/layout-v31/settingslib_main_switch_bar.xml
@@ -46,16 +46,6 @@
android:textAppearance="?android:attr/textAppearanceListItem"
style="@style/MainSwitchText.Settingslib" />
- <ImageView
- android:id="@+id/restricted_icon"
- android:layout_width="@dimen/settingslib_restricted_icon_size"
- android:layout_height="@dimen/settingslib_restricted_icon_size"
- android:tint="?android:attr/colorAccent"
- android:layout_gravity="center_vertical"
- android:layout_marginEnd="@dimen/settingslib_restricted_icon_margin_end"
- android:src="@drawable/settingslib_ic_info"
- android:visibility="gone" />
-
<Switch
android:id="@android:id/switch_widget"
android:layout_width="wrap_content"
diff --git a/packages/SettingsLib/MainSwitchPreference/res/layout-v33/settingslib_main_switch_bar.xml b/packages/SettingsLib/MainSwitchPreference/res/layout-v33/settingslib_main_switch_bar.xml
index 2c2ad92..ab0cf31 100644
--- a/packages/SettingsLib/MainSwitchPreference/res/layout-v33/settingslib_main_switch_bar.xml
+++ b/packages/SettingsLib/MainSwitchPreference/res/layout-v33/settingslib_main_switch_bar.xml
@@ -49,16 +49,6 @@
android:lineBreakWordStyle="phrase"
style="@style/MainSwitchText.Settingslib" />
- <ImageView
- android:id="@+id/restricted_icon"
- android:layout_width="@dimen/settingslib_restricted_icon_size"
- android:layout_height="@dimen/settingslib_restricted_icon_size"
- android:tint="@color/settingslib_accent_primary_variant"
- android:layout_gravity="center_vertical"
- android:layout_marginEnd="@dimen/settingslib_restricted_icon_margin_end"
- android:src="@drawable/settingslib_ic_info"
- android:visibility="gone" />
-
<Switch
android:id="@android:id/switch_widget"
android:layout_width="wrap_content"
diff --git a/packages/SettingsLib/MainSwitchPreference/res/layout/settingslib_main_switch_bar.xml b/packages/SettingsLib/MainSwitchPreference/res/layout/settingslib_main_switch_bar.xml
index b39d09f..bf34db9 100644
--- a/packages/SettingsLib/MainSwitchPreference/res/layout/settingslib_main_switch_bar.xml
+++ b/packages/SettingsLib/MainSwitchPreference/res/layout/settingslib_main_switch_bar.xml
@@ -38,17 +38,6 @@
android:layout_marginStart="@dimen/settingslib_switchbar_subsettings_margin_start"
android:textAlignment="viewStart"/>
- <ImageView
- android:id="@+id/restricted_icon"
- android:layout_width="@dimen/settingslib_restricted_icon_size"
- android:layout_height="@dimen/settingslib_restricted_icon_size"
- android:tint="?android:attr/colorAccent"
- android:theme="@android:style/Theme.Material"
- android:layout_gravity="center_vertical"
- android:layout_marginEnd="@dimen/settingslib_restricted_icon_margin_end"
- android:src="@drawable/settingslib_ic_info"
- android:visibility="gone"/>
-
<Switch
android:id="@android:id/switch_widget"
android:layout_width="wrap_content"
diff --git a/packages/SettingsLib/MainSwitchPreference/res/values-v31/styles.xml b/packages/SettingsLib/MainSwitchPreference/res/values-v31/styles.xml
index a50fc7c..ad888e5 100644
--- a/packages/SettingsLib/MainSwitchPreference/res/values-v31/styles.xml
+++ b/packages/SettingsLib/MainSwitchPreference/res/values-v31/styles.xml
@@ -17,9 +17,8 @@
<resources>
- <style name="MainSwitchText.Settingslib" parent="@android:style/TextAppearance.DeviceDefault.Widget.ActionBar.Title">
+ <style name="MainSwitchText.Settingslib" parent="@android:style/TextAppearance.DeviceDefault.Widget.ActionBar.Title.Inverse">
<item name="android:textSize">20sp</item>
<item name="android:fontFamily">@string/settingslib_config_headlineFontFamily</item>
- <item name="android:textColor">@android:color/black</item>
</style>
</resources>
diff --git a/packages/SettingsLib/MainSwitchPreference/res/values/dimens.xml b/packages/SettingsLib/MainSwitchPreference/res/values/dimens.xml
index 88b2c87..0d9ffff 100644
--- a/packages/SettingsLib/MainSwitchPreference/res/values/dimens.xml
+++ b/packages/SettingsLib/MainSwitchPreference/res/values/dimens.xml
@@ -17,16 +17,9 @@
<resources>
- <!-- Restricted icon size in switch bar -->
- <dimen name="settingslib_restricted_icon_size">@android:dimen/config_restrictedIconSize</dimen>
-
- <!-- Restricted icon in switch bar -->
- <dimen name="settingslib_restricted_icon_margin_end">16dp</dimen>
-
<!-- Size of title margin -->
<dimen name="settingslib_switch_title_margin">24dp</dimen>
- <!-- SwitchBar sub settings margin start / end -->
+ <!-- SwitchBar sub settings margin start -->
<dimen name="settingslib_switchbar_subsettings_margin_start">56dp</dimen>
- <dimen name="settingslib_switchbar_subsettings_margin_end">16dp</dimen>
</resources>
diff --git a/packages/SettingsLib/tests/integ/Android.bp b/packages/SettingsLib/tests/integ/Android.bp
index d463170..ff3eeec 100644
--- a/packages/SettingsLib/tests/integ/Android.bp
+++ b/packages/SettingsLib/tests/integ/Android.bp
@@ -30,7 +30,10 @@
certificate: "platform",
- srcs: ["src/**/*.java"],
+ srcs: [
+ "src/**/*.java",
+ "src/**/*.kt",
+ ],
libs: [
"android.test.runner",
diff --git a/packages/SettingsLib/tests/integ/src/com/android/settingslib/devicestate/PosturesHelperTest.kt b/packages/SettingsLib/tests/integ/src/com/android/settingslib/devicestate/PosturesHelperTest.kt
new file mode 100644
index 0000000..d91c2fa
--- /dev/null
+++ b/packages/SettingsLib/tests/integ/src/com/android/settingslib/devicestate/PosturesHelperTest.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.settingslib.devicestate
+
+import android.content.Context
+import android.content.res.Resources
+import android.provider.Settings.Secure.DEVICE_STATE_ROTATION_KEY_FOLDED
+import android.provider.Settings.Secure.DEVICE_STATE_ROTATION_KEY_HALF_FOLDED
+import android.provider.Settings.Secure.DEVICE_STATE_ROTATION_KEY_REAR_DISPLAY
+import android.provider.Settings.Secure.DEVICE_STATE_ROTATION_KEY_UNFOLDED
+import android.provider.Settings.Secure.DEVICE_STATE_ROTATION_KEY_UNKNOWN
+import androidx.test.filters.SmallTest
+import androidx.test.runner.AndroidJUnit4
+import com.android.internal.R
+import com.google.common.truth.Expect
+import org.junit.Before
+import org.junit.Rule
+import org.junit.Test
+import org.junit.runner.RunWith
+import org.mockito.Mock
+import org.mockito.Mockito.`when` as whenever
+import org.mockito.MockitoAnnotations
+
+private const val DEVICE_STATE_UNKNOWN = 0
+private const val DEVICE_STATE_CLOSED = 1
+private const val DEVICE_STATE_HALF_FOLDED = 2
+private const val DEVICE_STATE_OPEN = 3
+private const val DEVICE_STATE_REAR_DISPLAY = 4
+
+@SmallTest
+@RunWith(AndroidJUnit4::class)
+class PosturesHelperTest {
+
+ @get:Rule val expect: Expect = Expect.create()
+
+ @Mock private lateinit var context: Context
+
+ @Mock private lateinit var resources: Resources
+
+ private lateinit var posturesHelper: PosturesHelper
+
+ @Before
+ fun setUp() {
+ MockitoAnnotations.initMocks(this)
+
+ whenever(context.resources).thenReturn(resources)
+ whenever(resources.getIntArray(R.array.config_foldedDeviceStates))
+ .thenReturn(intArrayOf(DEVICE_STATE_CLOSED))
+ whenever(resources.getIntArray(R.array.config_halfFoldedDeviceStates))
+ .thenReturn(intArrayOf(DEVICE_STATE_HALF_FOLDED))
+ whenever(resources.getIntArray(R.array.config_openDeviceStates))
+ .thenReturn(intArrayOf(DEVICE_STATE_OPEN))
+ whenever(resources.getIntArray(R.array.config_rearDisplayDeviceStates))
+ .thenReturn(intArrayOf(DEVICE_STATE_REAR_DISPLAY))
+
+ posturesHelper = PosturesHelper(context)
+ }
+
+ @Test
+ fun deviceStateToPosture_mapsCorrectly() {
+ expect
+ .that(posturesHelper.deviceStateToPosture(DEVICE_STATE_CLOSED))
+ .isEqualTo(DEVICE_STATE_ROTATION_KEY_FOLDED)
+ expect
+ .that(posturesHelper.deviceStateToPosture(DEVICE_STATE_HALF_FOLDED))
+ .isEqualTo(DEVICE_STATE_ROTATION_KEY_HALF_FOLDED)
+ expect
+ .that(posturesHelper.deviceStateToPosture(DEVICE_STATE_OPEN))
+ .isEqualTo(DEVICE_STATE_ROTATION_KEY_UNFOLDED)
+ expect
+ .that(posturesHelper.deviceStateToPosture(DEVICE_STATE_REAR_DISPLAY))
+ .isEqualTo(DEVICE_STATE_ROTATION_KEY_REAR_DISPLAY)
+ expect
+ .that(posturesHelper.deviceStateToPosture(DEVICE_STATE_UNKNOWN))
+ .isEqualTo(DEVICE_STATE_ROTATION_KEY_UNKNOWN)
+ }
+
+ @Test
+ fun postureToDeviceState_mapsCorrectly() {
+ expect
+ .that(posturesHelper.postureToDeviceState(DEVICE_STATE_ROTATION_KEY_FOLDED))
+ .isEqualTo(DEVICE_STATE_CLOSED)
+ expect
+ .that(posturesHelper.postureToDeviceState(DEVICE_STATE_ROTATION_KEY_HALF_FOLDED))
+ .isEqualTo(DEVICE_STATE_HALF_FOLDED)
+ expect
+ .that(posturesHelper.postureToDeviceState(DEVICE_STATE_ROTATION_KEY_UNFOLDED))
+ .isEqualTo(DEVICE_STATE_OPEN)
+ expect
+ .that(posturesHelper.postureToDeviceState(DEVICE_STATE_ROTATION_KEY_REAR_DISPLAY))
+ .isEqualTo(DEVICE_STATE_REAR_DISPLAY)
+ expect.that(posturesHelper.postureToDeviceState(DEVICE_STATE_ROTATION_KEY_UNKNOWN)).isNull()
+ }
+}
diff --git a/packages/SystemUI/AndroidManifest.xml b/packages/SystemUI/AndroidManifest.xml
index 32d6b70..6e55000 100644
--- a/packages/SystemUI/AndroidManifest.xml
+++ b/packages/SystemUI/AndroidManifest.xml
@@ -695,7 +695,9 @@
android:relinquishTaskIdentity="true"
android:configChanges=
"screenSize|smallestScreenSize|screenLayout|orientation|keyboard|keyboardHidden"
- android:visibleToInstantApps="true"/>
+ android:visibleToInstantApps="true"
+ android:exported="false"
+ android:permission="android.permission.MANAGE_MEDIA_PROJECTION"/>
<!-- started from TvNotificationPanel -->
<activity
diff --git a/packages/SystemUI/monet/src/com/android/systemui/monet/dynamiccolor/DynamicColor.java b/packages/SystemUI/monet/src/com/android/systemui/monet/dynamiccolor/DynamicColor.java
index e6b2c2f..e839d9b 100644
--- a/packages/SystemUI/monet/src/com/android/systemui/monet/dynamiccolor/DynamicColor.java
+++ b/packages/SystemUI/monet/src/com/android/systemui/monet/dynamiccolor/DynamicColor.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2023 The Android Open Source Project
+ * Copyright (C) 2022 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.
@@ -71,12 +71,11 @@
* The base constructor for DynamicColor.
*
* <p>Functional arguments allow overriding without risks that come with subclasses. _Strongly_
- * prefer using one of the static convenience constructors. This class is arguably too flexible
- * to
+ * prefer using one of the static convenience constructors. This class is arguably too
+ * flexible to
* ensure it can support any scenario.
*
- * <p>For example, the default behavior of adjust tone at max contrast to be at a 7.0 ratio
- * with
+ * <p>For example, the default behavior of adjust tone at max contrast to be at a 7.0 ratio with
* its background is principled and matches a11y guidance. That does not mean it's the desired
* approach for _every_ design system, and every color pairing, always, in every case.
*
@@ -89,23 +88,23 @@
* lower and raise contrast are
* made.
* @param toneMinContrast given DynamicScheme, return tone in HCT/L* in L*a*b* this color
- * should
- * be at minimum contrast. See toneMinContrastDefault for the default
- * behavior, and strongly
+ * should
+ * be at minimum contrast. See toneMinContrastDefault for the
+ * default behavior, and strongly
* consider using it unless you have strong opinions on a11y. The
* static constructors use it.
* @param toneMaxContrast given DynamicScheme, return tone in HCT/L* in L*a*b* this color
- * should
- * be at maximum contrast. See toneMaxContrastDefault for the default
- * behavior, and strongly
+ * should
+ * be at maximum contrast. See toneMaxContrastDefault for the
+ * default behavior, and strongly
* consider using it unless you have strong opinions on a11y. The
* static constructors use it.
* @param toneDeltaConstraint given DynamicScheme, return a ToneDeltaConstraint instance that
* describes a requirement that this DynamicColor must always have
* some difference in tone/L*
* from another DynamicColor.<br>
- * Unlikely to be useful unless a design system has some distortions
- * where colors that don't
+ * Unlikely to be useful unless a design system has some
+ * distortions where colors that don't
* have a background/foreground relationship must have _some_
* difference in tone, yet, not
* enough difference to create meaningful contrast.
@@ -164,8 +163,8 @@
* <p>If the design system uses the same hex code on multiple backgrounds, define that in
* multiple
* DynamicColors so that the background is accurate for each one. If you define a DynamicColor
- * with one background, and actually use it on another, DynamicColor can't guarantee contrast.
- * For
+ * with one background, and actually use it on another, DynamicColor can't guarantee contrast
+ * . For
* example, if you use a color on both black and white, increasing the contrast on one
* necessarily
* decreases contrast of the other.
@@ -195,8 +194,8 @@
* for contrast, given a background, colors can adjust to
* increase/decrease contrast.
* @param toneDeltaConstraint Function that provides a ToneDeltaConstraint given DynamicScheme.
- * Useful for ensuring lightness difference between colors that don't
- * _require_ contrast or
+ * Useful for ensuring lightness difference between colors that
+ * don't _require_ contrast or
* have a formal background/foreground relationship.
*/
public static DynamicColor fromArgb(
@@ -212,17 +211,17 @@
* Create a DynamicColor.
*
* @param palette Function that provides a TonalPalette given DynamicScheme. A TonalPalette is
- * defined by a hue and chroma, so this replaces the need to specify hue/chroma.
- * By providing
+ * defined by a hue and chroma, so this replaces the need to specify
+ * hue/chroma. By providing
* a tonal palette, when contrast adjustments are made, intended chroma can be
* preserved. For
* example, at T/L* 90, there is a significant limit to the amount of chroma.
* There is no
- * colorful red, a red that light is pink. By preserving the _intended_ chroma if
- * lightness
+ * colorful red, a red that light is pink. By preserving the _intended_ chroma
+ * if lightness
* lowers for contrast adjustments, the intended chroma is restored.
- * @param tone Function that provides a tone given DynamicScheme. (useful for dark vs. light
- * mode)
+ * @param tone Function that provides a tone given DynamicScheme. (useful for dark vs.
+ * light mode)
*/
public static DynamicColor fromPalette(
Function<DynamicScheme, TonalPalette> palette, Function<DynamicScheme, Double> tone) {
@@ -232,16 +231,16 @@
/**
* Create a DynamicColor.
*
- * @param palette Function that provides a TonalPalette given DynamicScheme. A TonalPalette
- * is
+ * @param palette Function that provides a TonalPalette given DynamicScheme. A
+ * TonalPalette is
* defined by a hue and chroma, so this replaces the need to specify
* hue/chroma. By providing
- * a tonal palette, when contrast adjustments are made, intended chroma can be
- * preserved. For
- * example, at T/L* 90, there is a significant limit to the amount of chroma.
- * There is no
- * colorful red, a red that light is pink. By preserving the _intended_ chroma
- * if lightness
+ * a tonal palette, when contrast adjustments are made, intended chroma can
+ * be preserved. For
+ * example, at T/L* 90, there is a significant limit to the amount of
+ * chroma. There is no
+ * colorful red, a red that light is pink. By preserving the _intended_
+ * chroma if lightness
* lowers for contrast adjustments, the intended chroma is restored.
* @param tone Function that provides a tone given DynamicScheme. (useful for dark vs.
* light mode)
@@ -261,12 +260,12 @@
*
* @param palette Function that provides a TonalPalette given DynamicScheme. A
* TonalPalette is
- * defined by a hue and chroma, so this replaces the need to specify
- * hue/chroma. By providing
+ * defined by a hue and chroma, so this replaces the need to
+ * specify hue/chroma. By providing
* a tonal palette, when contrast adjustments are made, intended
* chroma can be preserved. For
- * example, at T/L* 90, there is a significant limit to the amount of
- * chroma. There is no
+ * example, at T/L* 90, there is a significant limit to the amount
+ * of chroma. There is no
* colorful red, a red that light is pink. By preserving the
* _intended_ chroma if lightness
* lowers for contrast adjustments, the intended chroma is restored.
@@ -277,8 +276,8 @@
* for contrast, given a background, colors can adjust to
* increase/decrease contrast.
* @param toneDeltaConstraint Function that provides a ToneDeltaConstraint given DynamicScheme.
- * Useful for ensuring lightness difference between colors that don't
- * _require_ contrast or
+ * Useful for ensuring lightness difference between colors that
+ * don't _require_ contrast or
* have a formal background/foreground relationship.
*/
public static DynamicColor fromPalette(
@@ -297,96 +296,6 @@
toneDeltaConstraint);
}
- /** Returns the ARGB (i.e. hex code) representation of the resolved color given scheme. */
- public int getArgb(DynamicScheme scheme) {
- final int argb = getHct(scheme).toInt();
- if (opacity == null) {
- return argb;
- }
- final double percentage = opacity.apply(scheme);
- final int alpha = MathUtils.clampInt(0, 255, (int) Math.round(percentage * 255));
- return (argb & 0x00ffffff) | (alpha << 24);
- }
-
- /** Returns the HCT representation of the resolved color given scheme. */
- public Hct getHct(DynamicScheme scheme) {
- final Hct cachedAnswer = hctCache.get(scheme);
- if (cachedAnswer != null) {
- return cachedAnswer;
- }
- // This is crucial for aesthetics: we aren't simply the taking the standard color
- // and changing its tone for contrast. Rather, we find the tone for contrast, then
- // use the specified chroma from the palette to construct a new color.
- //
- // For example, this enables colors with standard tone of T90, which has limited chroma, to
- // "recover" intended chroma as contrast increases.
- final Hct answer = Hct.from(hue.apply(scheme), chroma.apply(scheme), getTone(scheme));
- // NOMUTANTS--trivial test with onerous dependency injection requirement.
- if (hctCache.size() > 4) {
- hctCache.clear();
- }
- // NOMUTANTS--trivial test with onerous dependency injection requirement.
- hctCache.put(scheme, answer);
- return answer;
- }
-
- /** Returns the tone in HCT, ranging from 0 to 100, of the resolved color given scheme. */
- public double getTone(DynamicScheme scheme) {
- double answer = tone.apply(scheme);
-
- final boolean decreasingContrast = scheme.contrastLevel < 0.0;
- if (scheme.contrastLevel != 0.0) {
- final double startTone = tone.apply(scheme);
- final double endTone =
- decreasingContrast ? toneMinContrast.apply(scheme) : toneMaxContrast.apply(
- scheme);
- final double delta = (endTone - startTone) * Math.abs(scheme.contrastLevel);
- answer = delta + startTone;
- }
-
- final DynamicColor bgDynamicColor = background == null ? null : background.apply(scheme);
- double minRatio = Contrast.RATIO_MIN;
- double maxRatio = Contrast.RATIO_MAX;
- if (bgDynamicColor != null) {
- final boolean bgHasBg =
- bgDynamicColor.background != null && bgDynamicColor.background.apply(scheme)
- != null;
- final double standardRatio =
- Contrast.ratioOfTones(tone.apply(scheme), bgDynamicColor.tone.apply(scheme));
- if (decreasingContrast) {
- final double minContrastRatio =
- Contrast.ratioOfTones(
- toneMinContrast.apply(scheme),
- bgDynamicColor.toneMinContrast.apply(scheme));
- minRatio = bgHasBg ? minContrastRatio : 1.0;
- maxRatio = standardRatio;
- } else {
- final double maxContrastRatio =
- Contrast.ratioOfTones(
- toneMaxContrast.apply(scheme),
- bgDynamicColor.toneMaxContrast.apply(scheme));
- minRatio = bgHasBg ? min(maxContrastRatio, standardRatio) : 1.0;
- maxRatio = bgHasBg ? max(maxContrastRatio, standardRatio) : 21.0;
- }
- }
-
- final double finalMinRatio = minRatio;
- final double finalMaxRatio = maxRatio;
- final double finalAnswer = answer;
- answer =
- calculateDynamicTone(
- scheme,
- this.tone,
- (dynamicColor) -> dynamicColor.getTone(scheme),
- (a, b) -> finalAnswer,
- (s) -> bgDynamicColor,
- toneDeltaConstraint,
- (s) -> finalMinRatio,
- (s) -> finalMaxRatio);
-
- return answer;
- }
-
/**
* The default algorithm for calculating the tone of a color at minimum contrast.<br>
* If the original contrast ratio was >= 7.0, reach contrast 4.5.<br>
@@ -475,8 +384,8 @@
* <p>It enforces important properties:<br>
* #1. Desired contrast ratio is reached.<br>
* As contrast increases from standard to max, the tones involved should always be at least the
- * standard ratio. For example, if a button is T90, and button text is T0, and the button is T0
- * at
+ * standard ratio. For example, if a button is T90, and button text is T0, and the button is
+ * T0 at
* max contrast, the button text cannot simply linearly interpolate from T0 to T100, or at some
* point they'll both be at the same tone.
*
@@ -489,8 +398,7 @@
*
* <p>#3. Ensure tone delta with another color.<br>
* In design systems, there may be colors that don't have a pure background/foreground
- * relationship, but, do require different tones for visual differentiation.
- * ToneDeltaConstraint
+ * relationship, but, do require different tones for visual differentiation. ToneDeltaConstraint
* models this requirement, and DynamicColor enforces it.
*/
public static double calculateDynamicTone(
@@ -596,13 +504,16 @@
final boolean preferLighter = tonePrefersLightForeground(bgTone);
if (preferLighter) {
- // "Negligible difference" handles an edge case where the initial contrast ratio is high
+ // "Neglible difference" handles an edge case where the initial contrast ratio is high
// (ex. 13.0), and the ratio passed to the function is that high ratio, and both the
- // lighter and darker ratio fails to pass that ratio.
+ // lighter
+ // and darker ratio fails to pass that ratio.
//
// This was observed with Tonal Spot's On Primary Container turning black momentarily
- // between high and max contrast in light mode. PC's standard tone was T90, OPC's was
- // T10, it was light mode, and the contrast level was 0.6568521221032331.
+ // between
+ // high and max contrast in light mode. PC's standard tone was T90, OPC's was T10, it
+ // was
+ // light mode, and the contrast level was 0.6568521221032331.
final boolean negligibleDifference =
Math.abs(lighterRatio - darkerRatio) < 0.1 && lighterRatio < ratio
&& darkerRatio < ratio;
@@ -634,13 +545,109 @@
* <p>T60 used as to create the smallest discontinuity possible when skipping down to T49 in
* order
* to ensure light foregrounds.
+ *
+ * <p>Since `tertiaryContainer` in dark monochrome scheme requires a tone of 60, it should
+ * not be
+ * adjusted. Therefore, 60 is excluded here.
*/
public static boolean tonePrefersLightForeground(double tone) {
- return Math.round(tone) <= 60;
+ return Math.round(tone) < 60;
}
- /** Tones less than ~T50 always permit white at 4.5 contrast. */
+ /**
+ * Tones less than ~T50 always permit white at 4.5 contrast.
+ */
public static boolean toneAllowsLightForeground(double tone) {
return Math.round(tone) <= 49;
}
+
+ public int getArgb(DynamicScheme scheme) {
+ final int argb = getHct(scheme).toInt();
+ if (opacity == null) {
+ return argb;
+ }
+ final double percentage = opacity.apply(scheme);
+ final int alpha = MathUtils.clampInt(0, 255, (int) Math.round(percentage * 255));
+ return (argb & 0x00ffffff) | (alpha << 24);
+ }
+
+ public Hct getHct(DynamicScheme scheme) {
+ final Hct cachedAnswer = hctCache.get(scheme);
+ if (cachedAnswer != null) {
+ return cachedAnswer;
+ }
+ // This is crucial for aesthetics: we aren't simply the taking the standard color
+ // and changing its tone for contrast. Rather, we find the tone for contrast, then
+ // use the specified chroma from the palette to construct a new color.
+ //
+ // For example, this enables colors with standard tone of T90, which has limited chroma, to
+ // "recover" intended chroma as contrast increases.
+ final Hct answer = Hct.from(hue.apply(scheme), chroma.apply(scheme), getTone(scheme));
+ // NOMUTANTS--trivial test with onerous dependency injection requirement.
+ if (hctCache.size() > 4) {
+ hctCache.clear();
+ }
+ // NOMUTANTS--trivial test with onerous dependency injection requirement.
+ hctCache.put(scheme, answer);
+ return answer;
+ }
+
+ /**
+ * Returns the tone in HCT, ranging from 0 to 100, of the resolved color given scheme.
+ */
+ public double getTone(DynamicScheme scheme) {
+ double answer = tone.apply(scheme);
+
+ final boolean decreasingContrast = scheme.contrastLevel < 0.0;
+ if (scheme.contrastLevel != 0.0) {
+ final double startTone = tone.apply(scheme);
+ final double endTone =
+ decreasingContrast ? toneMinContrast.apply(scheme) : toneMaxContrast.apply(
+ scheme);
+ final double delta = (endTone - startTone) * Math.abs(scheme.contrastLevel);
+ answer = delta + startTone;
+ }
+
+ final DynamicColor bgDynamicColor = background == null ? null : background.apply(scheme);
+ double minRatio = Contrast.RATIO_MIN;
+ double maxRatio = Contrast.RATIO_MAX;
+ if (bgDynamicColor != null) {
+ final boolean bgHasBg =
+ bgDynamicColor.background != null && bgDynamicColor.background.apply(scheme)
+ != null;
+ final double standardRatio =
+ Contrast.ratioOfTones(tone.apply(scheme), bgDynamicColor.tone.apply(scheme));
+ if (decreasingContrast) {
+ final double minContrastRatio =
+ Contrast.ratioOfTones(
+ toneMinContrast.apply(scheme),
+ bgDynamicColor.toneMinContrast.apply(scheme));
+ minRatio = bgHasBg ? minContrastRatio : 1.0;
+ maxRatio = standardRatio;
+ } else {
+ final double maxContrastRatio =
+ Contrast.ratioOfTones(
+ toneMaxContrast.apply(scheme),
+ bgDynamicColor.toneMaxContrast.apply(scheme));
+ minRatio = bgHasBg ? min(maxContrastRatio, standardRatio) : 1.0;
+ maxRatio = bgHasBg ? max(maxContrastRatio, standardRatio) : 21.0;
+ }
+ }
+
+ final double finalMinRatio = minRatio;
+ final double finalMaxRatio = maxRatio;
+ final double finalAnswer = answer;
+ answer =
+ calculateDynamicTone(
+ scheme,
+ this.tone,
+ (dynamicColor) -> dynamicColor.getTone(scheme),
+ (a, b) -> finalAnswer,
+ (s) -> bgDynamicColor,
+ toneDeltaConstraint,
+ (s) -> finalMinRatio,
+ (s) -> finalMaxRatio);
+
+ return answer;
+ }
}
diff --git a/packages/SystemUI/monet/src/com/android/systemui/monet/dynamiccolor/MaterialDynamicColors.java b/packages/SystemUI/monet/src/com/android/systemui/monet/dynamiccolor/MaterialDynamicColors.java
index 5212e8e..21218a2 100644
--- a/packages/SystemUI/monet/src/com/android/systemui/monet/dynamiccolor/MaterialDynamicColors.java
+++ b/packages/SystemUI/monet/src/com/android/systemui/monet/dynamiccolor/MaterialDynamicColors.java
@@ -22,7 +22,7 @@
import com.android.systemui.monet.scheme.DynamicScheme;
import com.android.systemui.monet.scheme.Variant;
-/** Named colors, otherwise known as tokens, or roles, in the Material Design system. */
+/** Named colors, otherwise known as tokens, or roles, in the Material Design system.*/
// Prevent lint for Function.apply not being available on Android before API level 14 (4.0.1).
// "AndroidJdkLibsChecker" for Function, "NewApi" for Function.apply().
// A java_library Bazel rule with an Android constraint cannot skip these warnings without this
@@ -33,341 +33,54 @@
private static final double CONTAINER_ACCENT_TONE_DELTA = 15.0;
- private MaterialDynamicColors() {
+ public MaterialDynamicColors() {
}
- public static DynamicColor highestSurface(DynamicScheme s) {
- return s.isDark ? surfaceBright : surfaceDim;
- }
-
- public static final DynamicColor background =
- DynamicColor.fromPalette((s) -> s.neutralPalette, (s) -> s.isDark ? 6.0 : 98.0);
-
- public static final DynamicColor onBackground =
- DynamicColor.fromPalette(
- (s) -> s.neutralPalette, (s) -> s.isDark ? 90.0 : 10.0, (s) -> background);
-
- public static final DynamicColor surface =
- DynamicColor.fromPalette((s) -> s.neutralPalette, (s) -> s.isDark ? 6.0 : 98.0);
-
- public static final DynamicColor surfaceInverse =
- DynamicColor.fromPalette((s) -> s.neutralPalette, (s) -> s.isDark ? 90.0 : 30.0);
-
- public static final DynamicColor surfaceBright =
- DynamicColor.fromPalette((s) -> s.neutralPalette, (s) -> s.isDark ? 24.0 : 98.0);
-
- public static final DynamicColor surfaceDim =
- DynamicColor.fromPalette((s) -> s.neutralPalette, (s) -> s.isDark ? 6.0 : 87.0);
-
- public static final DynamicColor surfaceSub2 =
- DynamicColor.fromPalette((s) -> s.neutralPalette, (s) -> s.isDark ? 4.0 : 100.0);
-
- public static final DynamicColor surfaceSub1 =
- DynamicColor.fromPalette((s) -> s.neutralPalette, (s) -> s.isDark ? 10.0 : 96.0);
-
- public static final DynamicColor surfaceContainer =
- DynamicColor.fromPalette((s) -> s.neutralPalette, (s) -> s.isDark ? 12.0 : 94.0);
-
- public static final DynamicColor surfaceAdd1 =
- DynamicColor.fromPalette((s) -> s.neutralPalette, (s) -> s.isDark ? 17.0 : 92.0);
-
- public static final DynamicColor surfaceAdd2 =
- DynamicColor.fromPalette((s) -> s.neutralPalette, (s) -> s.isDark ? 22.0 : 90.0);
-
- public static final DynamicColor onSurface =
- DynamicColor.fromPalette(
- (s) -> s.neutralPalette, (s) -> s.isDark ? 90.0 : 10.0,
- (s) -> highestSurface(s));
-
- public static final DynamicColor onSurfaceInverse =
- DynamicColor.fromPalette(
- (s) -> s.neutralPalette, (s) -> s.isDark ? 20.0 : 95.0, (s) -> surfaceInverse);
-
- public static final DynamicColor surfaceVariant =
- DynamicColor.fromPalette((s) -> s.neutralVariantPalette, (s) -> s.isDark ? 30.0 : 90.0);
-
- public static final DynamicColor onSurfaceVariant =
- DynamicColor.fromPalette(
- (s) -> s.neutralVariantPalette, (s) -> s.isDark ? 80.0 : 30.0,
- (s) -> surfaceVariant);
-
- public static final DynamicColor outline =
- DynamicColor.fromPalette(
- (s) -> s.neutralVariantPalette, (s) -> 50.0, (s) -> highestSurface(s));
-
- public static final DynamicColor outlineVariant =
- DynamicColor.fromPalette(
- (s) -> s.neutralVariantPalette, (s) -> s.isDark ? 30.0 : 80.0,
- (s) -> highestSurface(s));
-
- public static final DynamicColor primaryContainer =
- DynamicColor.fromPalette(
- (s) -> s.primaryPalette,
- (s) -> {
- if (!isFidelity(s)) {
- return s.isDark ? 30.0 : 90.0;
- }
- return performAlbers(s.sourceColorHct, s);
- },
- (s) -> highestSurface(s));
-
- public static final DynamicColor onPrimaryContainer =
- DynamicColor.fromPalette(
- (s) -> s.primaryPalette,
- (s) -> {
- if (!isFidelity(s)) {
- return s.isDark ? 90.0 : 10.0;
- }
- return DynamicColor.contrastingTone(primaryContainer.tone.apply(s), 4.5);
- },
- (s) -> primaryContainer,
- null);
-
- public static final DynamicColor primary =
- DynamicColor.fromPalette(
- (s) -> s.primaryPalette,
- (s) -> s.isDark ? 80.0 : 40.0,
- (s) -> highestSurface(s),
- (s) ->
- new ToneDeltaConstraint(
- CONTAINER_ACCENT_TONE_DELTA,
- primaryContainer,
- s.isDark ? TonePolarity.DARKER : TonePolarity.LIGHTER));
-
- public static final DynamicColor primaryInverse =
- DynamicColor.fromPalette(
- (s) -> s.primaryPalette, (s) -> s.isDark ? 40.0 : 80.0, (s) -> surfaceInverse);
-
- public static final DynamicColor onPrimary =
- DynamicColor.fromPalette(
- (s) -> s.primaryPalette, (s) -> s.isDark ? 20.0 : 100.0, (s) -> primary);
-
- public static final DynamicColor secondaryContainer =
- DynamicColor.fromPalette(
- (s) -> s.secondaryPalette,
- (s) -> {
- final double initialTone = s.isDark ? 30.0 : 90.0;
- if (!isFidelity(s)) {
- return initialTone;
- }
- double answer =
- findDesiredChromaByTone(
- s.secondaryPalette.getHue(),
- s.secondaryPalette.getChroma(),
- initialTone,
- !s.isDark);
- answer = performAlbers(s.secondaryPalette.getHct(answer), s);
- return answer;
- },
- (s) -> highestSurface(s));
-
- public static final DynamicColor onSecondaryContainer =
- DynamicColor.fromPalette(
- (s) -> s.secondaryPalette,
- (s) -> {
- if (!isFidelity(s)) {
- return s.isDark ? 90.0 : 10.0;
- }
- return DynamicColor.contrastingTone(secondaryContainer.tone.apply(s), 4.5);
- },
- (s) -> secondaryContainer);
-
- public static final DynamicColor secondary =
- DynamicColor.fromPalette(
- (s) -> s.secondaryPalette,
- (s) -> s.isDark ? 80.0 : 40.0,
- (s) -> highestSurface(s),
- (s) ->
- new ToneDeltaConstraint(
- CONTAINER_ACCENT_TONE_DELTA,
- secondaryContainer,
- s.isDark ? TonePolarity.DARKER : TonePolarity.LIGHTER));
-
- public static final DynamicColor onSecondary =
- DynamicColor.fromPalette(
- (s) -> s.secondaryPalette, (s) -> s.isDark ? 20.0 : 100.0, (s) -> secondary);
-
- public static final DynamicColor tertiaryContainer =
- DynamicColor.fromPalette(
- (s) -> s.tertiaryPalette,
- (s) -> {
- if (!isFidelity(s)) {
- return s.isDark ? 30.0 : 90.0;
- }
- final double albersTone =
- performAlbers(s.tertiaryPalette.getHct(s.sourceColorHct.getTone()),
- s);
- final Hct proposedHct = s.tertiaryPalette.getHct(albersTone);
- return DislikeAnalyzer.fixIfDisliked(proposedHct).getTone();
- },
- (s) -> highestSurface(s));
-
- public static final DynamicColor onTertiaryContainer =
- DynamicColor.fromPalette(
- (s) -> s.tertiaryPalette,
- (s) -> {
- if (!isFidelity(s)) {
- return s.isDark ? 90.0 : 10.0;
- }
- return DynamicColor.contrastingTone(tertiaryContainer.tone.apply(s), 4.5);
- },
- (s) -> tertiaryContainer);
-
- public static final DynamicColor tertiary =
- DynamicColor.fromPalette(
- (s) -> s.tertiaryPalette,
- (s) -> s.isDark ? 80.0 : 40.0,
- (s) -> highestSurface(s),
- (s) ->
- new ToneDeltaConstraint(
- CONTAINER_ACCENT_TONE_DELTA,
- tertiaryContainer,
- s.isDark ? TonePolarity.DARKER : TonePolarity.LIGHTER));
-
- public static final DynamicColor onTertiary =
- DynamicColor.fromPalette(
- (s) -> s.tertiaryPalette, (s) -> s.isDark ? 20.0 : 100.0, (s) -> tertiary);
-
- public static final DynamicColor errorContainer =
- DynamicColor.fromPalette(
- (s) -> s.errorPalette, (s) -> s.isDark ? 30.0 : 90.0, (s) -> highestSurface(s));
-
- public static final DynamicColor onErrorContainer =
- DynamicColor.fromPalette(
- (s) -> s.errorPalette, (s) -> s.isDark ? 90.0 : 10.0, (s) -> errorContainer);
-
- public static final DynamicColor error =
- DynamicColor.fromPalette(
- (s) -> s.errorPalette,
- (s) -> s.isDark ? 80.0 : 40.0,
- (s) -> highestSurface(s),
- (s) ->
- new ToneDeltaConstraint(
- CONTAINER_ACCENT_TONE_DELTA,
- errorContainer,
- s.isDark ? TonePolarity.DARKER : TonePolarity.LIGHTER));
-
- public static final DynamicColor onError =
- DynamicColor.fromPalette((s) -> s.errorPalette, (s) -> s.isDark ? 20.0 : 100.0,
- (s) -> error);
-
- public static final DynamicColor primaryFixed =
- DynamicColor.fromPalette((s) -> s.primaryPalette, (s) -> 90.0,
- (s) -> highestSurface(s));
-
- public static final DynamicColor primaryFixedDarker =
- DynamicColor.fromPalette((s) -> s.primaryPalette, (s) -> 80.0,
- (s) -> highestSurface(s));
-
- public static final DynamicColor onPrimaryFixed =
- DynamicColor.fromPalette((s) -> s.primaryPalette, (s) -> 10.0,
- (s) -> primaryFixedDarker);
-
- public static final DynamicColor onPrimaryFixedVariant =
- DynamicColor.fromPalette((s) -> s.primaryPalette, (s) -> 30.0,
- (s) -> primaryFixedDarker);
-
- public static final DynamicColor secondaryFixed =
- DynamicColor.fromPalette((s) -> s.secondaryPalette, (s) -> 90.0,
- (s) -> highestSurface(s));
-
- public static final DynamicColor secondaryFixedDarker =
- DynamicColor.fromPalette((s) -> s.secondaryPalette, (s) -> 80.0,
- (s) -> highestSurface(s));
-
- public static final DynamicColor onSecondaryFixed =
- DynamicColor.fromPalette((s) -> s.secondaryPalette, (s) -> 10.0,
- (s) -> secondaryFixedDarker);
-
- public static final DynamicColor onSecondaryFixedVariant =
- DynamicColor.fromPalette((s) -> s.secondaryPalette, (s) -> 30.0,
- (s) -> secondaryFixedDarker);
-
- public static final DynamicColor tertiaryFixed =
- DynamicColor.fromPalette((s) -> s.tertiaryPalette, (s) -> 90.0,
- (s) -> highestSurface(s));
-
- public static final DynamicColor tertiaryFixedDarker =
- DynamicColor.fromPalette((s) -> s.tertiaryPalette, (s) -> 80.0,
- (s) -> highestSurface(s));
-
- public static final DynamicColor onTertiaryFixed =
- DynamicColor.fromPalette((s) -> s.tertiaryPalette, (s) -> 10.0,
- (s) -> tertiaryFixedDarker);
-
- public static final DynamicColor onTertiaryFixedVariant =
- DynamicColor.fromPalette((s) -> s.tertiaryPalette, (s) -> 30.0,
- (s) -> tertiaryFixedDarker);
-
/**
* These colors were present in Android framework before Android U, and used by MDC controls.
* They
* should be avoided, if possible. It's unclear if they're used on multiple backgrounds, and if
- * they are, they can't be adjusted for contrast.* For now, they will be set with no
- * background,
+ * they are, they can't be adjusted for contrast.* For now, they will be set with no background,
* and those won't adjust for contrast, avoiding issues.
*
- * <p>* For example, if the same color is on a white background _and_ black background, there's
- * no
+ * <p>* For example, if the same color is on a white background _and_ black background,
+ * there's no
* way to increase contrast with either without losing contrast with the other.
*/
// colorControlActivated documented as colorAccent in M3 & GM3.
// colorAccent documented as colorSecondary in M3 and colorPrimary in GM3.
// Android used Material's Container as Primary/Secondary/Tertiary at launch.
// Therefore, this is a duplicated version of Primary Container.
- public static final DynamicColor controlActivated =
- DynamicColor.fromPalette((s) -> s.primaryPalette, (s) -> s.isDark ? 30.0 : 90.0, null);
+ public static DynamicColor controlActivated() {
+ return DynamicColor.fromPalette((s) -> s.primaryPalette, (s) -> s.isDark ? 30.0 : 90.0, null);
+ }
- // colorControlNormal documented as textColorSecondary in M3 & GM3.
- // In Material, textColorSecondary points to onSurfaceVariant in the non-disabled state,
- // which is Neutral Variant T30/80 in light/dark.
- public static final DynamicColor controlNormal =
- DynamicColor.fromPalette((s) -> s.neutralVariantPalette, (s) -> s.isDark ? 80.0 : 30.0);
+ // Compatibility Keys Colors for Android
+ public static DynamicColor primaryPaletteKeyColor() {
+ return DynamicColor.fromPalette(
+ (s) -> s.primaryPalette, (s) -> s.primaryPalette.getKeyColor().getTone());
+ }
- // colorControlHighlight documented, in both M3 & GM3:
- // Light mode: #1f000000 dark mode: #33ffffff.
- // These are black and white with some alpha.
- // 1F hex = 31 decimal; 31 / 255 = 12% alpha.
- // 33 hex = 51 decimal; 51 / 255 = 20% alpha.
- // DynamicColors do not support alpha currently, and _may_ not need it for this use case,
- // depending on how MDC resolved alpha for the other cases.
- // Returning black in dark mode, white in light mode.
- public static final DynamicColor controlHighlight =
- new DynamicColor(
- s -> 0.0,
- s -> 0.0,
- s -> s.isDark ? 100.0 : 0.0,
- s -> s.isDark ? 0.20 : 0.12,
- null,
- scheme ->
- DynamicColor.toneMinContrastDefault(
- (s) -> s.isDark ? 100.0 : 0.0, null, scheme, null),
- scheme ->
- DynamicColor.toneMaxContrastDefault(
- (s) -> s.isDark ? 100.0 : 0.0, null, scheme, null),
- null);
+ public static DynamicColor secondaryPaletteKeyColor() {
+ return DynamicColor.fromPalette(
+ (s) -> s.secondaryPalette, (s) -> s.secondaryPalette.getKeyColor().getTone());
+ }
- // textColorPrimaryInverse documented, in both M3 & GM3, documented as N10/N90.
- public static final DynamicColor textPrimaryInverse =
- DynamicColor.fromPalette((s) -> s.neutralPalette, (s) -> s.isDark ? 10.0 : 90.0);
+ public static DynamicColor tertiaryPaletteKeyColor() {
+ return DynamicColor.fromPalette(
+ (s) -> s.tertiaryPalette, (s) -> s.tertiaryPalette.getKeyColor().getTone());
+ }
- // textColorSecondaryInverse and textColorTertiaryInverse both documented, in both M3 & GM3, as
- // NV30/NV80
- public static final DynamicColor textSecondaryAndTertiaryInverse =
- DynamicColor.fromPalette((s) -> s.neutralVariantPalette, (s) -> s.isDark ? 30.0 : 80.0);
+ public static DynamicColor neutralPaletteKeyColor() {
+ return DynamicColor.fromPalette(
+ (s) -> s.neutralPalette, (s) -> s.neutralPalette.getKeyColor().getTone());
+ }
- // textColorPrimaryInverseDisableOnly documented, in both M3 & GM3, as N10/N90
- public static final DynamicColor textPrimaryInverseDisableOnly =
- DynamicColor.fromPalette((s) -> s.neutralPalette, (s) -> s.isDark ? 10.0 : 90.0);
-
- // textColorSecondaryInverse and textColorTertiaryInverse in disabled state both documented,
- // in both M3 & GM3, as N10/N90
- public static final DynamicColor textSecondaryAndTertiaryInverseDisabled =
- DynamicColor.fromPalette((s) -> s.neutralPalette, (s) -> s.isDark ? 10.0 : 90.0);
-
- // textColorHintInverse documented, in both M3 & GM3, as N10/N90
- public static final DynamicColor textHintInverse =
- DynamicColor.fromPalette((s) -> s.neutralPalette, (s) -> s.isDark ? 10.0 : 90.0);
+ public static DynamicColor neutralVariantPaletteKeyColor() {
+ return DynamicColor.fromPalette(
+ (s) -> s.neutralVariantPalette,
+ (s) -> s.neutralVariantPalette.getKeyColor().getTone());
+ }
private static ViewingConditions viewingConditionsForAlbers(DynamicScheme scheme) {
return ViewingConditions.defaultWithBackgroundLstar(scheme.isDark ? 30.0 : 80.0);
@@ -377,6 +90,10 @@
return scheme.variant == Variant.FIDELITY || scheme.variant == Variant.CONTENT;
}
+ private static boolean isMonochrome(DynamicScheme scheme) {
+ return scheme.variant == Variant.MONOCHROME;
+ }
+
static double findDesiredChromaByTone(
double hue, double chroma, double tone, boolean byDecreasingTone) {
double answer = tone;
@@ -416,34 +133,456 @@
}
}
- // Compatibility mappings for Android
- public static final DynamicColor surfaceContainerLow = surfaceSub1;
- public static final DynamicColor surfaceContainerLowest = surfaceSub2;
- public static final DynamicColor surfaceContainerHigh = surfaceAdd1;
- public static final DynamicColor surfaceContainerHighest = surfaceAdd2;
- public static final DynamicColor primaryFixedDim = primaryFixedDarker;
- public static final DynamicColor secondaryFixedDim = secondaryFixedDarker;
- public static final DynamicColor tertiaryFixedDim = tertiaryFixedDarker;
+ public static DynamicColor highestSurface(DynamicScheme s) {
+ return s.isDark ? surfaceBright() : surfaceDim();
+ }
- // Compatibility Keys Colors for Android
- public static final DynamicColor primaryPaletteKeyColor =
- DynamicColor.fromPalette(
- (s) -> s.primaryPalette, (s) -> s.primaryPalette.getKeyColor().getTone());
+ public static DynamicColor background() {
+ return DynamicColor.fromPalette((s) -> s.neutralPalette, (s) -> s.isDark ? 6.0 : 98.0);
+ }
- public static final DynamicColor secondaryPaletteKeyColor =
- DynamicColor.fromPalette(
- (s) -> s.secondaryPalette, (s) -> s.secondaryPalette.getKeyColor().getTone());
+ public static DynamicColor onBackground() {
+ return DynamicColor.fromPalette(
+ (s) -> s.neutralPalette, (s) -> s.isDark ? 90.0 : 10.0, (s) -> background());
+ }
- public static final DynamicColor tertiaryPaletteKeyColor =
- DynamicColor.fromPalette(
- (s) -> s.tertiaryPalette, (s) -> s.tertiaryPalette.getKeyColor().getTone());
+ public static DynamicColor surface() {
+ return DynamicColor.fromPalette((s) -> s.neutralPalette, (s) -> s.isDark ? 6.0 : 98.0);
+ }
- public static final DynamicColor neutralPaletteKeyColor =
- DynamicColor.fromPalette(
- (s) -> s.neutralPalette, (s) -> s.neutralPalette.getKeyColor().getTone());
+ public static DynamicColor inverseSurface() {
+ return DynamicColor.fromPalette((s) -> s.neutralPalette, (s) -> s.isDark ? 90.0 : 20.0);
+ }
- public static final DynamicColor neutralVariantPaletteKeyColor =
- DynamicColor.fromPalette(
- (s) -> s.neutralVariantPalette,
- (s) -> s.neutralVariantPalette.getKeyColor().getTone());
+ public static DynamicColor surfaceBright() {
+ return DynamicColor.fromPalette((s) -> s.neutralPalette, (s) -> s.isDark ? 24.0 : 98.0);
+ }
+
+ public static DynamicColor surfaceDim() {
+ return DynamicColor.fromPalette((s) -> s.neutralPalette, (s) -> s.isDark ? 6.0 : 87.0);
+ }
+
+ public static DynamicColor surfaceContainerLowest() {
+ return DynamicColor.fromPalette((s) -> s.neutralPalette, (s) -> s.isDark ? 4.0 : 100.0);
+ }
+
+ public static DynamicColor surfaceContainerLow() {
+ return DynamicColor.fromPalette((s) -> s.neutralPalette, (s) -> s.isDark ? 10.0 : 96.0);
+ }
+
+ public static DynamicColor surfaceContainer() {
+ return DynamicColor.fromPalette((s) -> s.neutralPalette, (s) -> s.isDark ? 12.0 : 94.0);
+ }
+
+ public static DynamicColor surfaceContainerHigh() {
+ return DynamicColor.fromPalette((s) -> s.neutralPalette, (s) -> s.isDark ? 17.0 : 92.0);
+ }
+
+ public static DynamicColor surfaceContainerHighest() {
+ return DynamicColor.fromPalette((s) -> s.neutralPalette, (s) -> s.isDark ? 22.0 : 90.0);
+ }
+
+ public static DynamicColor onSurface() {
+ return DynamicColor.fromPalette(
+ (s) -> s.neutralPalette, (s) -> s.isDark ? 90.0 : 10.0,
+ MaterialDynamicColors::highestSurface);
+ }
+
+ public static DynamicColor inverseOnSurface() {
+ return DynamicColor.fromPalette(
+ (s) -> s.neutralPalette, (s) -> s.isDark ? 20.0 : 95.0, (s) -> inverseSurface());
+ }
+
+ public static DynamicColor surfaceVariant() {
+ return DynamicColor.fromPalette((s) -> s.neutralVariantPalette,
+ (s) -> s.isDark ? 30.0 : 90.0);
+ }
+
+ public static DynamicColor onSurfaceVariant() {
+ return DynamicColor.fromPalette(
+ (s) -> s.neutralVariantPalette, (s) -> s.isDark ? 80.0 : 30.0,
+ (s) -> surfaceVariant());
+ }
+
+ public static DynamicColor outline() {
+ return DynamicColor.fromPalette(
+ (s) -> s.neutralVariantPalette, (s) -> 50.0, MaterialDynamicColors::highestSurface);
+ }
+
+ public static DynamicColor outlineVariant() {
+ return DynamicColor.fromPalette(
+ (s) -> s.neutralVariantPalette, (s) -> s.isDark ? 30.0 : 80.0,
+ MaterialDynamicColors::highestSurface);
+ }
+
+ public static DynamicColor primaryContainer() {
+ return DynamicColor.fromPalette(
+ (s) -> s.primaryPalette,
+ (s) -> {
+ if (isFidelity(s)) {
+ return performAlbers(s.sourceColorHct, s);
+ }
+ if (isMonochrome(s)) {
+ return s.isDark ? 85.0 : 25.0;
+ }
+ return s.isDark ? 30.0 : 90.0;
+ },
+ MaterialDynamicColors::highestSurface);
+ }
+
+ public static DynamicColor onPrimaryContainer() {
+ return DynamicColor.fromPalette(
+ (s) -> s.primaryPalette,
+ (s) -> {
+ if (isFidelity(s)) {
+ return DynamicColor.contrastingTone(primaryContainer().tone.apply(s), 4.5);
+ }
+ if (isMonochrome(s)) {
+ return s.isDark ? 0.0 : 100.0;
+ }
+ return s.isDark ? 90.0 : 10.0;
+ },
+ (s) -> primaryContainer(),
+ null);
+ }
+
+ public static DynamicColor primary() {
+ return DynamicColor.fromPalette(
+ (s) -> s.primaryPalette,
+ (s) -> {
+ if (isMonochrome(s)) {
+ return s.isDark ? 100.0 : 0.0;
+ }
+ return s.isDark ? 80.0 : 40.0;
+ },
+ MaterialDynamicColors::highestSurface,
+ (s) ->
+ new ToneDeltaConstraint(
+ CONTAINER_ACCENT_TONE_DELTA,
+ primaryContainer(),
+ s.isDark ? TonePolarity.DARKER : TonePolarity.LIGHTER));
+ }
+
+ public static DynamicColor inversePrimary() {
+ return DynamicColor.fromPalette(
+ (s) -> s.primaryPalette, (s) -> s.isDark ? 40.0 : 80.0, (s) -> inverseSurface());
+ }
+
+ public static DynamicColor onPrimary() {
+ return DynamicColor.fromPalette(
+ (s) -> s.primaryPalette,
+ (s) -> {
+ if (isMonochrome(s)) {
+ return s.isDark ? 10.0 : 90.0;
+ }
+ return s.isDark ? 20.0 : 100.0;
+ },
+ (s) -> primary());
+ }
+
+ public static DynamicColor secondaryContainer() {
+ return DynamicColor.fromPalette(
+ (s) -> s.secondaryPalette,
+ (s) -> {
+ if (isMonochrome(s)) {
+ return s.isDark ? 30.0 : 85.0;
+ }
+ final double initialTone = s.isDark ? 30.0 : 90.0;
+ if (!isFidelity(s)) {
+ return initialTone;
+ }
+ double answer =
+ findDesiredChromaByTone(
+ s.secondaryPalette.getHue(),
+ s.secondaryPalette.getChroma(),
+ initialTone,
+ !s.isDark);
+ answer = performAlbers(s.secondaryPalette.getHct(answer), s);
+ return answer;
+ },
+ MaterialDynamicColors::highestSurface);
+ }
+
+ public static DynamicColor onSecondaryContainer() {
+ return DynamicColor.fromPalette(
+ (s) -> s.secondaryPalette,
+ (s) -> {
+ if (!isFidelity(s)) {
+ return s.isDark ? 90.0 : 10.0;
+ }
+ return DynamicColor.contrastingTone(secondaryContainer().tone.apply(s), 4.5);
+ },
+ (s) -> secondaryContainer());
+ }
+
+ public static DynamicColor secondary() {
+ return DynamicColor.fromPalette(
+ (s) -> s.secondaryPalette,
+ (s) -> s.isDark ? 80.0 : 40.0,
+ MaterialDynamicColors::highestSurface,
+ (s) ->
+ new ToneDeltaConstraint(
+ CONTAINER_ACCENT_TONE_DELTA,
+ secondaryContainer(),
+ s.isDark ? TonePolarity.DARKER : TonePolarity.LIGHTER));
+ }
+
+ public static DynamicColor onSecondary() {
+ return DynamicColor.fromPalette(
+ (s) -> s.secondaryPalette,
+ (s) -> {
+ if (isMonochrome(s)) {
+ return s.isDark ? 10.0 : 100.0;
+ }
+ return s.isDark ? 20.0 : 100.0;
+ },
+ (s) -> secondary());
+ }
+
+ public static DynamicColor tertiaryContainer() {
+ return DynamicColor.fromPalette(
+ (s) -> s.tertiaryPalette,
+ (s) -> {
+ if (isMonochrome(s)) {
+ return s.isDark ? 60.0 : 49.0;
+ }
+ if (!isFidelity(s)) {
+ return s.isDark ? 30.0 : 90.0;
+ }
+ final double albersTone =
+ performAlbers(s.tertiaryPalette.getHct(s.sourceColorHct.getTone()), s);
+ final Hct proposedHct = s.tertiaryPalette.getHct(albersTone);
+ return DislikeAnalyzer.fixIfDisliked(proposedHct).getTone();
+ },
+ MaterialDynamicColors::highestSurface);
+ }
+
+ public static DynamicColor onTertiaryContainer() {
+ return DynamicColor.fromPalette(
+ (s) -> s.tertiaryPalette,
+ (s) -> {
+ if (isMonochrome(s)) {
+ return s.isDark ? 0.0 : 100.0;
+ }
+ if (!isFidelity(s)) {
+ return s.isDark ? 90.0 : 10.0;
+ }
+ return DynamicColor.contrastingTone(tertiaryContainer().tone.apply(s), 4.5);
+ },
+ (s) -> tertiaryContainer());
+ }
+
+ public static DynamicColor tertiary() {
+ return DynamicColor.fromPalette(
+ (s) -> s.tertiaryPalette,
+ (s) -> {
+ if (isMonochrome(s)) {
+ return s.isDark ? 90.0 : 25.0;
+ }
+ return s.isDark ? 80.0 : 40.0;
+ },
+ MaterialDynamicColors::highestSurface,
+ (s) ->
+ new ToneDeltaConstraint(
+ CONTAINER_ACCENT_TONE_DELTA,
+ tertiaryContainer(),
+ s.isDark ? TonePolarity.DARKER : TonePolarity.LIGHTER));
+ }
+
+ public static DynamicColor onTertiary() {
+ return DynamicColor.fromPalette(
+ (s) -> s.tertiaryPalette,
+ (s) -> {
+ if (isMonochrome(s)) {
+ return s.isDark ? 10.0 : 90.0;
+ }
+ return s.isDark ? 20.0 : 100.0;
+ },
+ (s) -> tertiary());
+ }
+
+ public static DynamicColor errorContainer() {
+ return DynamicColor.fromPalette(
+ (s) -> s.errorPalette, (s) -> s.isDark ? 30.0 : 90.0,
+ MaterialDynamicColors::highestSurface);
+ }
+
+ public static DynamicColor onErrorContainer() {
+ return DynamicColor.fromPalette(
+ (s) -> s.errorPalette, (s) -> s.isDark ? 90.0 : 10.0, (s) -> errorContainer());
+ }
+
+ public static DynamicColor error() {
+ return DynamicColor.fromPalette(
+ (s) -> s.errorPalette,
+ (s) -> s.isDark ? 80.0 : 40.0,
+ MaterialDynamicColors::highestSurface,
+ (s) ->
+ new ToneDeltaConstraint(
+ CONTAINER_ACCENT_TONE_DELTA,
+ errorContainer(),
+ s.isDark ? TonePolarity.DARKER : TonePolarity.LIGHTER));
+ }
+
+ public static DynamicColor onError() {
+ return DynamicColor.fromPalette(
+ (s) -> s.errorPalette, (s) -> s.isDark ? 20.0 : 100.0, (s) -> error());
+ }
+
+ public static DynamicColor primaryFixed() {
+ return DynamicColor.fromPalette(
+ (s) -> s.primaryPalette,
+ (s) -> {
+ if (isMonochrome(s)) {
+ return s.isDark ? 100.0 : 10.0;
+ }
+ return 90.0;
+ },
+ MaterialDynamicColors::highestSurface);
+ }
+
+ public static DynamicColor primaryFixedDim() {
+ return DynamicColor.fromPalette(
+ (s) -> s.primaryPalette,
+ (s) -> {
+ if (isMonochrome(s)) {
+ return s.isDark ? 90.0 : 20.0;
+ }
+ return 80.0;
+ },
+ MaterialDynamicColors::highestSurface);
+ }
+
+ public static DynamicColor onPrimaryFixed() {
+ return DynamicColor.fromPalette(
+ (s) -> s.primaryPalette,
+ (s) -> {
+ if (isMonochrome(s)) {
+ return s.isDark ? 10.0 : 90.0;
+ }
+ return 10.0;
+ },
+ (s) -> primaryFixedDim());
+ }
+
+ public static DynamicColor onPrimaryFixedVariant() {
+ return DynamicColor.fromPalette(
+ (s) -> s.primaryPalette,
+ (s) -> {
+ if (isMonochrome(s)) {
+ return s.isDark ? 30.0 : 70.0;
+ }
+ return 30.0;
+ },
+ (s) -> primaryFixedDim());
+ }
+
+ public static DynamicColor secondaryFixed() {
+ return DynamicColor.fromPalette(
+ (s) -> s.secondaryPalette, (s) -> isMonochrome(s) ? 80.0 : 90.0,
+ MaterialDynamicColors::highestSurface);
+ }
+
+ public static DynamicColor secondaryFixedDim() {
+ return DynamicColor.fromPalette(
+ (s) -> s.secondaryPalette, (s) -> isMonochrome(s) ? 70.0 : 80.0,
+ MaterialDynamicColors::highestSurface);
+ }
+
+ public static DynamicColor onSecondaryFixed() {
+ return DynamicColor.fromPalette(
+ (s) -> s.secondaryPalette, (s) -> 10.0, (s) -> secondaryFixedDim());
+ }
+
+ public static DynamicColor onSecondaryFixedVariant() {
+ return DynamicColor.fromPalette(
+ (s) -> s.secondaryPalette,
+ (s) -> isMonochrome(s) ? 25.0 : 30.0,
+ (s) -> secondaryFixedDim());
+ }
+
+ public static DynamicColor tertiaryFixed() {
+ return DynamicColor.fromPalette(
+ (s) -> s.tertiaryPalette, (s) -> isMonochrome(s) ? 40.0 : 90.0,
+ MaterialDynamicColors::highestSurface);
+ }
+
+ public static DynamicColor tertiaryFixedDim() {
+ return DynamicColor.fromPalette(
+ (s) -> s.tertiaryPalette, (s) -> isMonochrome(s) ? 30.0 : 80.0,
+ MaterialDynamicColors::highestSurface);
+ }
+
+ public static DynamicColor onTertiaryFixed() {
+ return DynamicColor.fromPalette(
+ (s) -> s.tertiaryPalette, (s) -> isMonochrome(s) ? 90.0 : 10.0,
+ (s) -> tertiaryFixedDim());
+ }
+
+ public static DynamicColor onTertiaryFixedVariant() {
+ return DynamicColor.fromPalette(
+ (s) -> s.tertiaryPalette, (s) -> isMonochrome(s) ? 70.0 : 30.0,
+ (s) -> tertiaryFixedDim());
+ }
+
+ // colorControlNormal documented as textColorSecondary in M3 & GM3.
+ // In Material, textColorSecondary points to onSurfaceVariant in the non-disabled state,
+ // which is Neutral Variant T30/80 in light/dark.
+ public static DynamicColor controlNormal() {
+ return DynamicColor.fromPalette((s) -> s.neutralVariantPalette,
+ (s) -> s.isDark ? 80.0 : 30.0);
+ }
+
+ // colorControlHighlight documented, in both M3 & GM3:
+ // Light mode: #1f000000 dark mode: #33ffffff.
+ // These are black and white with some alpha.
+ // 1F hex = 31 decimal; 31 / 255 = 12% alpha.
+ // 33 hex = 51 decimal; 51 / 255 = 20% alpha.
+ // DynamicColors do not support alpha currently, and _may_ not need it for this use case,
+ // depending on how MDC resolved alpha for the other cases.
+ // Returning black in dark mode, white in light mode.
+ public static DynamicColor controlHighlight() {
+ return new DynamicColor(
+ s -> 0.0,
+ s -> 0.0,
+ s -> s.isDark ? 100.0 : 0.0,
+ s -> s.isDark ? 0.20 : 0.12,
+ null,
+ scheme ->
+
+ DynamicColor.toneMinContrastDefault((s) -> s.isDark ? 100.0 : 0.0, null,
+ scheme, null),
+ scheme ->
+ DynamicColor.toneMaxContrastDefault((s) -> s.isDark ? 100.0 : 0.0, null,
+ scheme, null),
+ null);
+ }
+
+ // textColorPrimaryInverse documented, in both M3 & GM3, documented as N10/N90.
+ public static DynamicColor textPrimaryInverse() {
+ return DynamicColor.fromPalette((s) -> s.neutralPalette, (s) -> s.isDark ? 10.0 : 90.0);
+ }
+
+ // textColorSecondaryInverse and textColorTertiaryInverse both documented, in both M3 & GM3, as
+ // NV30/NV80
+ public static DynamicColor textSecondaryAndTertiaryInverse() {
+ return DynamicColor.fromPalette((s) -> s.neutralVariantPalette,
+ (s) -> s.isDark ? 30.0 : 80.0);
+ }
+
+ // textColorPrimaryInverseDisableOnly documented, in both M3 & GM3, as N10/N90
+ public static DynamicColor textPrimaryInverseDisableOnly() {
+ return DynamicColor.fromPalette((s) -> s.neutralPalette, (s) -> s.isDark ? 10.0 : 90.0);
+ }
+
+ // textColorSecondaryInverse and textColorTertiaryInverse in disabled state both documented,
+ // in both M3 & GM3, as N10/N90
+ public static DynamicColor textSecondaryAndTertiaryInverseDisabled() {
+ return DynamicColor.fromPalette((s) -> s.neutralPalette, (s) -> s.isDark ? 10.0 : 90.0);
+ }
+
+ // textColorHintInverse documented, in both M3 & GM3, as N10/N90
+ public static DynamicColor textHintInverse() {
+ return DynamicColor.fromPalette((s) -> s.neutralPalette, (s) -> s.isDark ? 10.0 : 90.0);
+ }
}
diff --git a/packages/SystemUI/monet/src/com/android/systemui/monet/scheme/SchemeTonalSpot.java b/packages/SystemUI/monet/src/com/android/systemui/monet/scheme/SchemeTonalSpot.java
index 8480684..cc6b492 100644
--- a/packages/SystemUI/monet/src/com/android/systemui/monet/scheme/SchemeTonalSpot.java
+++ b/packages/SystemUI/monet/src/com/android/systemui/monet/scheme/SchemeTonalSpot.java
@@ -32,7 +32,7 @@
TonalPalette.fromHueAndChroma(sourceColorHct.getHue(), 16.0),
TonalPalette.fromHueAndChroma(
MathUtils.sanitizeDegreesDouble(sourceColorHct.getHue() + 60.0), 24.0),
- TonalPalette.fromHueAndChroma(sourceColorHct.getHue(), 4.0),
+ TonalPalette.fromHueAndChroma(sourceColorHct.getHue(), 6.0),
TonalPalette.fromHueAndChroma(sourceColorHct.getHue(), 8.0));
}
}
diff --git a/packages/SystemUI/res/layout/screen_share_dialog.xml b/packages/SystemUI/res/layout/screen_share_dialog.xml
index 7dbe059..0d86e0a 100644
--- a/packages/SystemUI/res/layout/screen_share_dialog.xml
+++ b/packages/SystemUI/res/layout/screen_share_dialog.xml
@@ -76,7 +76,7 @@
android:orientation="horizontal"
android:layout_marginTop="@dimen/screenrecord_buttons_margin_top">
<TextView
- android:id="@+id/button_cancel"
+ android:id="@android:id/button2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="0"
@@ -87,7 +87,7 @@
android:layout_height="match_parent"
android:layout_weight="1"/>
<TextView
- android:id="@+id/button_start"
+ android:id="@android:id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="0"
diff --git a/packages/SystemUI/src/com/android/systemui/controls/ui/DetailDialog.kt b/packages/SystemUI/src/com/android/systemui/controls/ui/DetailDialog.kt
index 5d608c3..7cbd1f5 100644
--- a/packages/SystemUI/src/com/android/systemui/controls/ui/DetailDialog.kt
+++ b/packages/SystemUI/src/com/android/systemui/controls/ui/DetailDialog.kt
@@ -16,9 +16,11 @@
package com.android.systemui.controls.ui
+import android.app.Activity
import android.app.ActivityOptions
import android.app.ActivityTaskManager
import android.app.ActivityTaskManager.INVALID_TASK_ID
+import android.app.ComponentOptions.MODE_BACKGROUND_ACTIVITY_START_ALLOWED
import android.app.Dialog
import android.app.PendingIntent
import android.content.ComponentName
@@ -96,7 +98,9 @@
activityContext,
0 /* enterResId */,
0 /* exitResId */
- )
+ ).setPendingIntentBackgroundActivityStartMode(MODE_BACKGROUND_ACTIVITY_START_ALLOWED)
+ options.isPendingIntentBackgroundActivityLaunchAllowedByPermission = true
+
taskView.startActivity(
pendingIntent,
fillInIntent,
@@ -214,6 +218,12 @@
if (!isShowing()) return
taskView.release()
+ val isActivityFinishing =
+ (activityContext as? Activity)?.let { it.isFinishing || it.isDestroyed }
+ if (isActivityFinishing == true) {
+ // Don't dismiss the dialog if the activity is finishing, it will get removed
+ return
+ }
super.dismiss()
}
}
diff --git a/packages/SystemUI/src/com/android/systemui/flags/Flags.kt b/packages/SystemUI/src/com/android/systemui/flags/Flags.kt
index cd2bf13..75eab82 100644
--- a/packages/SystemUI/src/com/android/systemui/flags/Flags.kt
+++ b/packages/SystemUI/src/com/android/systemui/flags/Flags.kt
@@ -222,6 +222,11 @@
val LOCK_SCREEN_LONG_PRESS_DIRECT_TO_WPP =
unreleasedFlag(232, "lock_screen_long_press_directly_opens_wallpaper_picker")
+ /** Whether to run the new udfps keyguard refactor code. */
+ // TODO(b/279440316): Tracking bug.
+ @JvmField
+ val REFACTOR_UDFPS_KEYGUARD_VIEWS = unreleasedFlag(233, "refactor_udfps_keyguard_views")
+
/** Provide new auth messages on the bouncer. */
// TODO(b/277961132): Tracking bug.
@JvmField
diff --git a/packages/SystemUI/src/com/android/systemui/navigationbar/gestural/EdgeBackGestureHandler.java b/packages/SystemUI/src/com/android/systemui/navigationbar/gestural/EdgeBackGestureHandler.java
index 41e3e6d..9a1efc3 100644
--- a/packages/SystemUI/src/com/android/systemui/navigationbar/gestural/EdgeBackGestureHandler.java
+++ b/packages/SystemUI/src/com/android/systemui/navigationbar/gestural/EdgeBackGestureHandler.java
@@ -15,6 +15,8 @@
*/
package com.android.systemui.navigationbar.gestural;
+import static android.view.InputDevice.SOURCE_MOUSE;
+import static android.view.InputDevice.SOURCE_TOUCHPAD;
import static android.view.WindowManager.LayoutParams.PRIVATE_FLAG_EXCLUDE_FROM_SCREEN_MAGNIFICATION;
import static com.android.systemui.classifier.Classifier.BACK_GESTURE;
@@ -937,10 +939,12 @@
mMLResults = 0;
mLogGesture = false;
mInRejectedExclusion = false;
- boolean isWithinInsets = isWithinInsets((int) ev.getX(), (int) ev.getY());
// Trackpad back gestures don't have zones, so we don't need to check if the down event
- // is within insets.
+ // is within insets. Also we don't allow back for button press from the trackpad, and
+ // yet we do with a mouse.
+ boolean isWithinInsets = isWithinInsets((int) ev.getX(), (int) ev.getY());
mAllowGesture = !mDisabledForQuickstep && mIsBackGestureAllowed
+ && !isButtonPressFromTrackpad(ev)
&& (isTrackpadMultiFingerSwipe || isWithinInsets)
&& !mGestureBlockingActivityRunning
&& !QuickStepContract.isBackGestureDisabled(mSysUiFlags)
@@ -1047,6 +1051,11 @@
mProtoTracer.scheduleFrameUpdate();
}
+ private boolean isButtonPressFromTrackpad(MotionEvent ev) {
+ int sources = InputManager.getInstance().getInputDevice(ev.getDeviceId()).getSources();
+ return (sources & (SOURCE_MOUSE | SOURCE_TOUCHPAD)) == sources && ev.getButtonState() != 0;
+ }
+
private void dispatchToBackAnimation(MotionEvent event) {
if (mBackAnimation != null) {
mVelocityTracker.addMovement(event);
diff --git a/packages/SystemUI/src/com/android/systemui/qs/tileimpl/QSTileViewImpl.kt b/packages/SystemUI/src/com/android/systemui/qs/tileimpl/QSTileViewImpl.kt
index 4a31998..b806683 100644
--- a/packages/SystemUI/src/com/android/systemui/qs/tileimpl/QSTileViewImpl.kt
+++ b/packages/SystemUI/src/com/android/systemui/qs/tileimpl/QSTileViewImpl.kt
@@ -385,6 +385,11 @@
super.onInitializeAccessibilityNodeInfo(info)
// Clear selected state so it is not announce by talkback.
info.isSelected = false
+ info.text = if (TextUtils.isEmpty(secondaryLabel.text)) {
+ "${label.text}"
+ } else {
+ "${label.text}, ${secondaryLabel.text}"
+ }
if (lastDisabledByPolicy) {
info.addAction(
AccessibilityNodeInfo.AccessibilityAction(
@@ -402,12 +407,6 @@
accessibilityClass
}
if (Switch::class.java.name == accessibilityClass) {
- val label = resources.getString(
- if (tileState) R.string.switch_bar_on else R.string.switch_bar_off)
- // Set the text here for tests in
- // android.platform.test.scenario.sysui.quicksettings. Can be removed when
- // UiObject2 has a new getStateDescription() API and tests are updated.
- info.text = label
info.isChecked = tileState
info.isCheckable = true
if (isLongClickable) {
diff --git a/packages/SystemUI/src/com/android/systemui/screenrecord/BaseScreenSharePermissionDialog.kt b/packages/SystemUI/src/com/android/systemui/screenrecord/BaseScreenSharePermissionDialog.kt
index f63bf07..b340043 100644
--- a/packages/SystemUI/src/com/android/systemui/screenrecord/BaseScreenSharePermissionDialog.kt
+++ b/packages/SystemUI/src/com/android/systemui/screenrecord/BaseScreenSharePermissionDialog.kt
@@ -57,8 +57,8 @@
setContentView(R.layout.screen_share_dialog)
dialogTitle = findViewById(R.id.screen_share_dialog_title)
warning = findViewById(R.id.text_warning)
- startButton = findViewById(R.id.button_start)
- cancelButton = findViewById(R.id.button_cancel)
+ startButton = findViewById(android.R.id.button1)
+ cancelButton = findViewById(android.R.id.button2)
updateIcon()
initScreenShareOptions()
createOptionsView(getOptionsViewLayoutId())
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/LegacyNotificationShelfControllerImpl.java b/packages/SystemUI/src/com/android/systemui/statusbar/LegacyNotificationShelfControllerImpl.java
index 505f45d..dcd9dc3 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/LegacyNotificationShelfControllerImpl.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/LegacyNotificationShelfControllerImpl.java
@@ -52,7 +52,6 @@
mActivatableNotificationViewController = activatableNotificationViewController;
mKeyguardBypassController = keyguardBypassController;
mStatusBarStateController = statusBarStateController;
- mView.useRoundnessSourceTypes(true);
mView.setSensitiveRevealAnimEndabled(featureFlags.isEnabled(Flags.SENSITIVE_REVEAL_ANIM));
mOnAttachStateChangeListener = new View.OnAttachStateChangeListener() {
@Override
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/NotificationShelf.java b/packages/SystemUI/src/com/android/systemui/statusbar/NotificationShelf.java
index 7eb63da..49c7950 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/NotificationShelf.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/NotificationShelf.java
@@ -44,7 +44,6 @@
import com.android.systemui.flags.Flags;
import com.android.systemui.plugins.statusbar.StatusBarStateController.StateListener;
import com.android.systemui.shade.transition.LargeScreenShadeInterpolator;
-import com.android.systemui.statusbar.notification.LegacySourceType;
import com.android.systemui.statusbar.notification.NotificationUtils;
import com.android.systemui.statusbar.notification.SourceType;
import com.android.systemui.statusbar.notification.row.ActivatableNotificationView;
@@ -128,13 +127,6 @@
setClipToPadding(false);
mShelfIcons.setIsStaticLayout(false);
requestRoundness(/* top = */ 1f, /* bottom = */ 1f, BASE_VALUE, /* animate = */ false);
-
- if (!mUseRoundnessSourceTypes) {
- // Setting this to first in section to get the clipping to the top roundness correct.
- // This value determines the way we are clipping to the top roundness of the overall
- // shade
- setFirstInSection(true);
- }
updateResources();
}
@@ -569,17 +561,8 @@
* mAmbientState.getExpansionFraction();
final float cornerAnimationTop = shelfStart - cornerAnimationDistance;
- final SourceType sourceType;
- if (mUseRoundnessSourceTypes) {
- sourceType = SHELF_SCROLL;
- } else {
- sourceType = LegacySourceType.OnScroll;
- }
-
final float topValue;
- if (!mUseRoundnessSourceTypes && anv.isFirstInSection()) {
- topValue = 1f;
- } else if (viewStart >= cornerAnimationTop) {
+ if (viewStart >= cornerAnimationTop) {
// Round top corners within animation bounds
topValue = MathUtils.saturate(
(viewStart - cornerAnimationTop) / cornerAnimationDistance);
@@ -588,12 +571,10 @@
// Reset top and bottom corners outside of animation bounds.
topValue = 0f;
}
- anv.requestTopRoundness(topValue, sourceType, /* animate = */ false);
+ anv.requestTopRoundness(topValue, SHELF_SCROLL, /* animate = */ false);
final float bottomValue;
- if (!mUseRoundnessSourceTypes && anv.isLastInSection()) {
- bottomValue = 1f;
- } else if (viewEnd >= cornerAnimationTop) {
+ if (viewEnd >= cornerAnimationTop) {
// Round bottom corners within animation bounds
bottomValue = MathUtils.saturate(
(viewEnd - cornerAnimationTop) / cornerAnimationDistance);
@@ -602,7 +583,7 @@
// Reset top and bottom corners outside of animation bounds.
bottomValue = 0f;
}
- anv.requestBottomRoundness(bottomValue, sourceType, /* animate = */ false);
+ anv.requestBottomRoundness(bottomValue, SHELF_SCROLL, /* animate = */ false);
}
private boolean isViewAffectedBySwipe(ExpandableView expandableView) {
@@ -1100,15 +1081,6 @@
child.requestRoundnessReset(SHELF_SCROLL);
}
- /**
- * This method resets the OnScroll roundness of a view to 0f
- * <p>
- * Note: This should be the only class that handles roundness {@code SourceType.OnScroll}
- */
- public static void resetLegacyOnScrollRoundness(ExpandableView expandableView) {
- expandableView.requestRoundnessReset(LegacySourceType.OnScroll);
- }
-
@Override
public void dump(PrintWriter pwOriginal, String[] args) {
IndentingPrintWriter pw = DumpUtilsKt.asIndenting(pwOriginal);
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/PulseExpansionHandler.kt b/packages/SystemUI/src/com/android/systemui/statusbar/PulseExpansionHandler.kt
index 976924a..821a172 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/PulseExpansionHandler.kt
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/PulseExpansionHandler.kt
@@ -87,13 +87,8 @@
bypassController.isPulseExpanding = value
if (changed) {
if (value) {
- val topEntry = headsUpManager.topEntry
- topEntry?.let {
- roundnessManager.setTrackingHeadsUp(it.row)
- }
lockscreenShadeTransitionController.onPulseExpansionStarted()
} else {
- roundnessManager.setTrackingHeadsUp(null)
if (!leavingLockscreen) {
bypassController.maybePerformPendingUnlock()
pulseExpandAbortListener?.run()
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/Roundable.kt b/packages/SystemUI/src/com/android/systemui/statusbar/notification/Roundable.kt
index 76ff97d..212f2c215 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/Roundable.kt
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/Roundable.kt
@@ -448,10 +448,3 @@
}
}
}
-
-@Deprecated("Use SourceType.from() instead", ReplaceWith("SourceType.from()"))
-enum class LegacySourceType : SourceType {
- DefaultValue,
- OnDismissAnimation,
- OnScroll,
-}
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 766ad88..66d4c3a9 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
@@ -110,7 +110,6 @@
protected Point mTargetPoint;
private boolean mDismissed;
private boolean mRefocusOnDismiss;
- protected boolean mUseRoundnessSourceTypes;
public ActivatableNotificationView(Context context, AttributeSet attrs) {
super(context, attrs);
@@ -709,18 +708,10 @@
mTouchHandler = touchHandler;
}
- /**
- * Enable the support for rounded corner based on the SourceType
- * @param enabled true if is supported
- */
- public void useRoundnessSourceTypes(boolean enabled) {
- mUseRoundnessSourceTypes = enabled;
- }
-
@Override
protected void onDetachedFromWindow() {
super.onDetachedFromWindow();
- if (mUseRoundnessSourceTypes && !mOnDetachResetRoundness.isEmpty()) {
+ if (!mOnDetachResetRoundness.isEmpty()) {
for (SourceType sourceType : mOnDetachResetRoundness) {
requestRoundnessReset(sourceType);
}
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 e468a59..5978133 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
@@ -87,7 +87,6 @@
import com.android.systemui.statusbar.notification.AboveShelfChangedListener;
import com.android.systemui.statusbar.notification.FeedbackIcon;
import com.android.systemui.statusbar.notification.LaunchAnimationParameters;
-import com.android.systemui.statusbar.notification.LegacySourceType;
import com.android.systemui.statusbar.notification.NotificationFadeAware;
import com.android.systemui.statusbar.notification.NotificationLaunchAnimatorController;
import com.android.systemui.statusbar.notification.NotificationUtils;
@@ -866,9 +865,6 @@
}
onAttachedChildrenCountChanged();
row.setIsChildInGroup(false, null);
- if (!mUseRoundnessSourceTypes) {
- row.requestBottomRoundness(0.0f, LegacySourceType.DefaultValue, /* animate = */ false);
- }
}
/**
@@ -884,10 +880,6 @@
if (child.keepInParentForDismissAnimation()) {
mChildrenContainer.removeNotification(child);
child.setIsChildInGroup(false, null);
- if (!mUseRoundnessSourceTypes) {
- LegacySourceType sourceType = LegacySourceType.DefaultValue;
- child.requestBottomRoundness(0f, sourceType, /* animate = */ false);
- }
child.setKeepInParentForDismissAnimation(false);
logKeepInParentChildDetached(child);
childCountChanged = true;
@@ -942,9 +934,7 @@
mNotificationParent.updateBackgroundForGroupState();
}
updateBackgroundClipping();
- if (mUseRoundnessSourceTypes) {
- updateBaseRoundness();
- }
+ updateBaseRoundness();
}
@Override
@@ -1054,15 +1044,13 @@
if (isAboveShelf() != wasAboveShelf) {
mAboveShelfChangedListener.onAboveShelfStateChanged(!wasAboveShelf);
}
- if (mUseRoundnessSourceTypes) {
- if (pinned) {
- // Should be animated if someone explicitly set it to 0 and the row is shown.
- boolean animated = mAnimatePinnedRoundness && isShown();
- requestRoundness(/* top = */ 1f, /* bottom = */ 1f, PINNED, animated);
- } else {
- requestRoundnessReset(PINNED);
- mAnimatePinnedRoundness = true;
- }
+ if (pinned) {
+ // Should be animated if someone explicitly set it to 0 and the row is shown.
+ boolean animated = mAnimatePinnedRoundness && isShown();
+ requestRoundness(/* top = */ 1f, /* bottom = */ 1f, PINNED, animated);
+ } else {
+ requestRoundnessReset(PINNED);
+ mAnimatePinnedRoundness = true;
}
}
@@ -1879,7 +1867,6 @@
mChildrenContainer.setIsLowPriority(mIsLowPriority);
mChildrenContainer.setContainingNotification(ExpandableNotificationRow.this);
mChildrenContainer.onNotificationUpdated();
- mChildrenContainer.useRoundnessSourceTypes(mUseRoundnessSourceTypes);
mTranslateableViews.add(mChildrenContainer);
});
@@ -2308,24 +2295,6 @@
mBackgroundNormal.setExpandAnimationSize(params.getWidth(), actualHeight);
}
- @Override
- public float getTopRoundness() {
- if (!mUseRoundnessSourceTypes && mExpandAnimationRunning) {
- return mTopRoundnessDuringLaunchAnimation;
- }
-
- return super.getTopRoundness();
- }
-
- @Override
- public float getBottomRoundness() {
- if (!mUseRoundnessSourceTypes && mExpandAnimationRunning) {
- return mBottomRoundnessDuringLaunchAnimation;
- }
-
- return super.getBottomRoundness();
- }
-
public void setExpandAnimationRunning(boolean expandAnimationRunning) {
if (expandAnimationRunning) {
setAboveShelf(true);
@@ -3481,18 +3450,11 @@
private void applyChildrenRoundness() {
if (mIsSummaryWithChildren) {
- if (mUseRoundnessSourceTypes) {
- mChildrenContainer.requestRoundness(
- /* top = */ getTopRoundness(),
- /* bottom = */ getBottomRoundness(),
- /* sourceType = */ FROM_PARENT,
- /* animate = */ false);
- } else {
- mChildrenContainer.requestBottomRoundness(
- getBottomRoundness(),
- LegacySourceType.DefaultValue,
- /* animate = */ false);
- }
+ mChildrenContainer.requestRoundness(
+ /* top = */ getTopRoundness(),
+ /* bottom = */ getBottomRoundness(),
+ /* sourceType = */ FROM_PARENT,
+ /* animate = */ false);
}
}
@@ -3709,24 +3671,10 @@
}
}
- /**
- * Enable the support for rounded corner based on the SourceType
- * @param enabled true if is supported
- */
- @Override
- public void useRoundnessSourceTypes(boolean enabled) {
- super.useRoundnessSourceTypes(enabled);
- if (mChildrenContainer != null) {
- mChildrenContainer.useRoundnessSourceTypes(mUseRoundnessSourceTypes);
- }
- }
-
@Override
protected void onAttachedToWindow() {
super.onAttachedToWindow();
- if (mUseRoundnessSourceTypes) {
- updateBaseRoundness();
- }
+ updateBaseRoundness();
}
/** Set whether this notification may show a snooze action. */
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/ExpandableNotificationRowController.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/ExpandableNotificationRowController.java
index 19c612e..1acc9f9 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/ExpandableNotificationRowController.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/ExpandableNotificationRowController.java
@@ -261,7 +261,6 @@
mStatusBarStateController.removeCallback(mStatusBarStateListener);
}
});
- mView.useRoundnessSourceTypes(true);
}
private final StatusBarStateController.StateListener mStatusBarStateListener =
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/wrapper/NotificationHeaderViewWrapper.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/wrapper/NotificationHeaderViewWrapper.java
index 9a777ea..2c59c2e 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/wrapper/NotificationHeaderViewWrapper.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/wrapper/NotificationHeaderViewWrapper.java
@@ -72,7 +72,6 @@
private View mFeedbackIcon;
private boolean mIsLowPriority;
private boolean mTransformLowPriorityTitle;
- private boolean mUseRoundnessSourceTypes;
private RoundnessChangedListener mRoundnessChangedListener;
protected NotificationHeaderViewWrapper(Context ctx, View view, ExpandableNotificationRow row) {
@@ -122,7 +121,7 @@
@Override
public void applyRoundnessAndInvalidate() {
- if (mUseRoundnessSourceTypes && mRoundnessChangedListener != null) {
+ if (mRoundnessChangedListener != null) {
// We cannot apply the rounded corner to this View, so our parents (in drawChild()) will
// clip our canvas. So we should invalidate our parent.
mRoundnessChangedListener.applyRoundnessAndInvalidate();
@@ -377,15 +376,6 @@
}
/**
- * Enable the support for rounded corner based on the SourceType
- *
- * @param enabled true if is supported
- */
- public void useRoundnessSourceTypes(boolean enabled) {
- mUseRoundnessSourceTypes = enabled;
- }
-
- /**
* Interface that handle the Roundness changes
*/
public interface RoundnessChangedListener {
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/shelf/ui/viewbinder/NotificationShelfViewBinder.kt b/packages/SystemUI/src/com/android/systemui/statusbar/notification/shelf/ui/viewbinder/NotificationShelfViewBinder.kt
index 8106715..12956ab 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/shelf/ui/viewbinder/NotificationShelfViewBinder.kt
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/shelf/ui/viewbinder/NotificationShelfViewBinder.kt
@@ -81,7 +81,6 @@
ActivatableNotificationViewBinder.bind(viewModel, shelf, falsingManager)
shelf.apply {
setRefactorFlagEnabled(true)
- useRoundnessSourceTypes(true)
setSensitiveRevealAnimEndabled(featureFlags.isEnabled(Flags.SENSITIVE_REVEAL_ANIM))
// TODO(278765923): Replace with eventual NotificationIconContainerViewBinder#bind()
notificationIconAreaController.setShelfIcons(shelfIcons)
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationChildrenContainer.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationChildrenContainer.java
index 160a230..d18757d 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationChildrenContainer.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationChildrenContainer.java
@@ -45,9 +45,7 @@
import com.android.systemui.R;
import com.android.systemui.statusbar.CrossFadeHelper;
import com.android.systemui.statusbar.NotificationGroupingUtil;
-import com.android.systemui.statusbar.NotificationShelf;
import com.android.systemui.statusbar.notification.FeedbackIcon;
-import com.android.systemui.statusbar.notification.LegacySourceType;
import com.android.systemui.statusbar.notification.NotificationFadeAware;
import com.android.systemui.statusbar.notification.NotificationUtils;
import com.android.systemui.statusbar.notification.Roundable;
@@ -133,7 +131,6 @@
private int mUntruncatedChildCount;
private boolean mContainingNotificationIsFaded = false;
private RoundableState mRoundableState;
- private boolean mUseRoundnessSourceTypes;
public NotificationChildrenContainer(Context context) {
this(context, null);
@@ -328,13 +325,6 @@
row.setContentTransformationAmount(0, false /* isLastChild */);
row.setNotificationFaded(mContainingNotificationIsFaded);
- if (!mUseRoundnessSourceTypes) {
- // This is a workaround, the NotificationShelf should be the owner of `OnScroll`
- // roundness.
- // Here we should reset the `OnScroll` roundness only on top-level rows.
- NotificationShelf.resetLegacyOnScrollRoundness(row);
- }
-
// It doesn't make sense to keep old animations around, lets cancel them!
ExpandableViewState viewState = row.getViewState();
if (viewState != null) {
@@ -342,9 +332,7 @@
row.cancelAppearDrawing();
}
- if (mUseRoundnessSourceTypes) {
- applyRoundnessAndInvalidate();
- }
+ applyRoundnessAndInvalidate();
}
private void ensureRemovedFromTransientContainer(View v) {
@@ -379,10 +367,8 @@
mGroupingUtil.restoreChildNotification(row);
}
- if (mUseRoundnessSourceTypes) {
- row.requestRoundnessReset(FROM_PARENT, /* animate = */ false);
- applyRoundnessAndInvalidate();
- }
+ row.requestRoundnessReset(FROM_PARENT, /* animate = */ false);
+ applyRoundnessAndInvalidate();
}
/**
@@ -409,10 +395,7 @@
getContext(),
mNotificationHeader,
mContainingNotification);
- mNotificationHeaderWrapper.useRoundnessSourceTypes(mUseRoundnessSourceTypes);
- if (mUseRoundnessSourceTypes) {
- mNotificationHeaderWrapper.setOnRoundnessChangedListener(this::invalidate);
- }
+ mNotificationHeaderWrapper.setOnRoundnessChangedListener(this::invalidate);
addView(mNotificationHeader, 0);
invalidate();
} else {
@@ -450,12 +433,7 @@
getContext(),
mNotificationHeaderLowPriority,
mContainingNotification);
- mNotificationHeaderWrapperLowPriority.useRoundnessSourceTypes(
- mUseRoundnessSourceTypes
- );
- if (mUseRoundnessSourceTypes) {
- mNotificationHeaderWrapper.setOnRoundnessChangedListener(this::invalidate);
- }
+ mNotificationHeaderWrapper.setOnRoundnessChangedListener(this::invalidate);
addView(mNotificationHeaderLowPriority, 0);
invalidate();
} else {
@@ -891,7 +869,7 @@
isCanvasChanged = true;
canvas.save();
- if (mUseRoundnessSourceTypes && translation != 0f) {
+ if (translation != 0f) {
clipPath.offset(translation, 0f);
canvas.clipPath(clipPath);
clipPath.offset(-translation, 0f);
@@ -1444,40 +1422,30 @@
@Override
public void applyRoundnessAndInvalidate() {
boolean last = true;
- if (mUseRoundnessSourceTypes) {
- if (mNotificationHeaderWrapper != null) {
- mNotificationHeaderWrapper.requestTopRoundness(
- /* value = */ getTopRoundness(),
- /* sourceType = */ FROM_PARENT,
- /* animate = */ false
- );
- }
- if (mNotificationHeaderWrapperLowPriority != null) {
- mNotificationHeaderWrapperLowPriority.requestTopRoundness(
- /* value = */ getTopRoundness(),
- /* sourceType = */ FROM_PARENT,
- /* animate = */ false
- );
- }
+ if (mNotificationHeaderWrapper != null) {
+ mNotificationHeaderWrapper.requestTopRoundness(
+ /* value = */ getTopRoundness(),
+ /* sourceType = */ FROM_PARENT,
+ /* animate = */ false
+ );
+ }
+ if (mNotificationHeaderWrapperLowPriority != null) {
+ mNotificationHeaderWrapperLowPriority.requestTopRoundness(
+ /* value = */ getTopRoundness(),
+ /* sourceType = */ FROM_PARENT,
+ /* animate = */ false
+ );
}
for (int i = mAttachedChildren.size() - 1; i >= 0; i--) {
ExpandableNotificationRow child = mAttachedChildren.get(i);
if (child.getVisibility() == View.GONE) {
continue;
}
- if (mUseRoundnessSourceTypes) {
- child.requestRoundness(
- /* top = */ 0f,
- /* bottom = */ last ? getBottomRoundness() : 0f,
- /* sourceType = */ FROM_PARENT,
- /* animate = */ false);
- } else {
- child.requestRoundness(
- /* top = */ 0f,
- /* bottom = */ last ? getBottomRoundness() : 0f,
- LegacySourceType.DefaultValue,
- /* animate = */ isShown());
- }
+ child.requestRoundness(
+ /* top = */ 0f,
+ /* bottom = */ last ? getBottomRoundness() : 0f,
+ /* sourceType = */ FROM_PARENT,
+ /* animate = */ false);
last = false;
}
Roundable.super.applyRoundnessAndInvalidate();
@@ -1537,15 +1505,6 @@
return mNotificationHeaderWrapper;
}
- /**
- * Enable the support for rounded corner based on the SourceType
- *
- * @param enabled true if is supported
- */
- public void useRoundnessSourceTypes(boolean enabled) {
- mUseRoundnessSourceTypes = enabled;
- }
-
public String debugString() {
return TAG + " { "
+ "visibility: " + getVisibility()
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationRoundnessManager.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationRoundnessManager.java
index b6aec83ae..fa1843e 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationRoundnessManager.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationRoundnessManager.java
@@ -16,22 +16,13 @@
package com.android.systemui.statusbar.notification.stack;
-import android.content.res.Resources;
-import android.util.MathUtils;
-
import androidx.annotation.NonNull;
import com.android.systemui.Dumpable;
-import com.android.systemui.R;
import com.android.systemui.dagger.SysUISingleton;
import com.android.systemui.dump.DumpManager;
-import com.android.systemui.statusbar.notification.LegacySourceType;
-import com.android.systemui.statusbar.notification.NotificationSectionsFeatureManager;
import com.android.systemui.statusbar.notification.Roundable;
import com.android.systemui.statusbar.notification.SourceType;
-import com.android.systemui.statusbar.notification.collection.NotificationEntry;
-import com.android.systemui.statusbar.notification.logging.NotificationRoundnessLogger;
-import com.android.systemui.statusbar.notification.row.ExpandableNotificationRow;
import com.android.systemui.statusbar.notification.row.ExpandableView;
import java.io.PrintWriter;
@@ -48,63 +39,27 @@
private static final String TAG = "NotificationRoundnessManager";
private static final SourceType DISMISS_ANIMATION = SourceType.from("DismissAnimation");
- private final ExpandableView[] mFirstInSectionViews;
- private final ExpandableView[] mLastInSectionViews;
- private final ExpandableView[] mTmpFirstInSectionViews;
- private final ExpandableView[] mTmpLastInSectionViews;
- private final NotificationRoundnessLogger mNotifLogger;
private final DumpManager mDumpManager;
- private boolean mExpanded;
private HashSet<ExpandableView> mAnimatedChildren;
- private Runnable mRoundingChangedCallback;
- private ExpandableNotificationRow mTrackedHeadsUp;
- private float mAppearFraction;
private boolean mRoundForPulsingViews;
private boolean mIsClearAllInProgress;
private ExpandableView mSwipedView = null;
private Roundable mViewBeforeSwipedView = null;
private Roundable mViewAfterSwipedView = null;
- private boolean mUseRoundnessSourceTypes;
@Inject
- NotificationRoundnessManager(
- NotificationSectionsFeatureManager sectionsFeatureManager,
- NotificationRoundnessLogger notifLogger,
- DumpManager dumpManager) {
- int numberOfSections = sectionsFeatureManager.getNumberOfBuckets();
- mFirstInSectionViews = new ExpandableView[numberOfSections];
- mLastInSectionViews = new ExpandableView[numberOfSections];
- mTmpFirstInSectionViews = new ExpandableView[numberOfSections];
- mTmpLastInSectionViews = new ExpandableView[numberOfSections];
- mNotifLogger = notifLogger;
+ NotificationRoundnessManager(DumpManager dumpManager) {
mDumpManager = dumpManager;
- mUseRoundnessSourceTypes = true;
-
mDumpManager.registerDumpable(TAG, this);
}
@Override
public void dump(@NonNull PrintWriter pw, @NonNull String[] args) {
- pw.println("mFirstInSectionViews: length=" + mFirstInSectionViews.length);
- pw.println(dumpViews(mFirstInSectionViews));
- pw.println("mLastInSectionViews: length=" + mLastInSectionViews.length);
- pw.println(dumpViews(mFirstInSectionViews));
- if (mTrackedHeadsUp != null) {
- pw.println("trackedHeadsUp=" + mTrackedHeadsUp.getEntry());
- }
pw.println("roundForPulsingViews=" + mRoundForPulsingViews);
pw.println("isClearAllInProgress=" + mIsClearAllInProgress);
}
- public void updateView(ExpandableView view, boolean animate) {
- if (mUseRoundnessSourceTypes) return;
- boolean changed = updateViewWithoutCallback(view, animate);
- if (changed) {
- mRoundingChangedCallback.run();
- }
- }
-
public boolean isViewAffectedBySwipe(ExpandableView expandableView) {
return expandableView != null
&& (expandableView == mSwipedView
@@ -112,58 +67,6 @@
|| expandableView == mViewAfterSwipedView);
}
- boolean updateViewWithoutCallback(
- ExpandableView view,
- boolean animate) {
- if (mUseRoundnessSourceTypes) return false;
- if (view == null
- || view == mViewBeforeSwipedView
- || view == mViewAfterSwipedView) {
- return false;
- }
-
- final boolean isTopChanged = view.requestTopRoundness(
- getRoundnessDefaultValue(view, true /* top */),
- LegacySourceType.DefaultValue,
- animate);
-
- final boolean isBottomChanged = view.requestBottomRoundness(
- getRoundnessDefaultValue(view, /* top = */ false),
- LegacySourceType.DefaultValue,
- animate);
-
- final boolean isFirstInSection = isFirstInSection(view);
- final boolean isLastInSection = isLastInSection(view);
-
- view.setFirstInSection(isFirstInSection);
- view.setLastInSection(isLastInSection);
-
- mNotifLogger.onCornersUpdated(view, isFirstInSection,
- isLastInSection, isTopChanged, isBottomChanged);
-
- return (isFirstInSection || isLastInSection) && (isTopChanged || isBottomChanged);
- }
-
- private boolean isFirstInSection(ExpandableView view) {
- if (mUseRoundnessSourceTypes) return false;
- for (int i = 0; i < mFirstInSectionViews.length; i++) {
- if (view == mFirstInSectionViews[i]) {
- return true;
- }
- }
- return false;
- }
-
- private boolean isLastInSection(ExpandableView view) {
- if (mUseRoundnessSourceTypes) return false;
- for (int i = mLastInSectionViews.length - 1; i >= 0; i--) {
- if (view == mLastInSectionViews[i]) {
- return true;
- }
- }
- return false;
- }
-
void setViewsAffectedBySwipe(
Roundable viewBefore,
ExpandableView viewSwiped,
@@ -177,34 +80,27 @@
if (mSwipedView != null) oldViews.add(mSwipedView);
if (mViewAfterSwipedView != null) oldViews.add(mViewAfterSwipedView);
- final SourceType source;
- if (mUseRoundnessSourceTypes) {
- source = DISMISS_ANIMATION;
- } else {
- source = LegacySourceType.OnDismissAnimation;
- }
-
mViewBeforeSwipedView = viewBefore;
if (viewBefore != null) {
oldViews.remove(viewBefore);
- viewBefore.requestRoundness(/* top = */ 0f, /* bottom = */ 1f, source);
+ viewBefore.requestRoundness(/* top = */ 0f, /* bottom = */ 1f, DISMISS_ANIMATION);
}
mSwipedView = viewSwiped;
if (viewSwiped != null) {
oldViews.remove(viewSwiped);
- viewSwiped.requestRoundness(/* top = */ 1f, /* bottom = */ 1f, source);
+ viewSwiped.requestRoundness(/* top = */ 1f, /* bottom = */ 1f, DISMISS_ANIMATION);
}
mViewAfterSwipedView = viewAfter;
if (viewAfter != null) {
oldViews.remove(viewAfter);
- viewAfter.requestRoundness(/* top = */ 1f, /* bottom = */ 0f, source);
+ viewAfter.requestRoundness(/* top = */ 1f, /* bottom = */ 0f, DISMISS_ANIMATION);
}
// After setting the current Views, reset the views that are still present in the set.
for (Roundable oldView : oldViews) {
- oldView.requestRoundnessReset(source);
+ oldView.requestRoundnessReset(DISMISS_ANIMATION);
}
}
@@ -226,143 +122,6 @@
return mRoundForPulsingViews;
}
- private float getRoundnessDefaultValue(Roundable view, boolean top) {
- if (mUseRoundnessSourceTypes) return 0f;
-
- if (view == null) {
- return 0f;
- }
- if (view == mViewBeforeSwipedView
- || view == mSwipedView
- || view == mViewAfterSwipedView) {
- return 1f;
- }
- if (view instanceof ExpandableNotificationRow
- && ((ExpandableNotificationRow) view).canViewBeCleared()
- && mIsClearAllInProgress) {
- return 1.0f;
- }
- if (view instanceof ExpandableView) {
- ExpandableView expandableView = (ExpandableView) view;
- if ((expandableView.isPinned()
- || (expandableView.isHeadsUpAnimatingAway()) && !mExpanded)) {
- return 1.0f;
- }
- if (isFirstInSection(expandableView) && top) {
- return 1.0f;
- }
- if (isLastInSection(expandableView) && !top) {
- return 1.0f;
- }
-
- if (view == mTrackedHeadsUp) {
- // If we're pushing up on a headsup the appear fraction is < 0 and it needs to
- // still be rounded.
- return MathUtils.saturate(1.0f - mAppearFraction);
- }
- if (expandableView.showingPulsing() && mRoundForPulsingViews) {
- return 1.0f;
- }
- if (expandableView.isChildInGroup()) {
- return 0f;
- }
- final Resources resources = expandableView.getResources();
- return resources.getDimension(R.dimen.notification_corner_radius_small)
- / resources.getDimension(R.dimen.notification_corner_radius);
- }
- return 0f;
- }
-
- public void setExpanded(float expandedHeight, float appearFraction) {
- if (mUseRoundnessSourceTypes) return;
- mExpanded = expandedHeight != 0.0f;
- mAppearFraction = appearFraction;
- if (mTrackedHeadsUp != null) {
- updateView(mTrackedHeadsUp, false /* animate */);
- }
- }
-
- public void updateRoundedChildren(NotificationSection[] sections) {
- if (mUseRoundnessSourceTypes) return;
- boolean anyChanged = false;
- for (int i = 0; i < sections.length; i++) {
- mTmpFirstInSectionViews[i] = mFirstInSectionViews[i];
- mTmpLastInSectionViews[i] = mLastInSectionViews[i];
- mFirstInSectionViews[i] = sections[i].getFirstVisibleChild();
- mLastInSectionViews[i] = sections[i].getLastVisibleChild();
- }
- anyChanged |= handleRemovedOldViews(sections, mTmpFirstInSectionViews, true);
- anyChanged |= handleRemovedOldViews(sections, mTmpLastInSectionViews, false);
- anyChanged |= handleAddedNewViews(sections, mTmpFirstInSectionViews, true);
- anyChanged |= handleAddedNewViews(sections, mTmpLastInSectionViews, false);
- if (anyChanged) {
- mRoundingChangedCallback.run();
- }
-
- mNotifLogger.onSectionCornersUpdated(sections, anyChanged);
- }
-
- private boolean handleRemovedOldViews(
- NotificationSection[] sections,
- ExpandableView[] oldViews,
- boolean first) {
- if (mUseRoundnessSourceTypes) return false;
- boolean anyChanged = false;
- for (ExpandableView oldView : oldViews) {
- if (oldView != null) {
- boolean isStillPresent = false;
- boolean adjacentSectionChanged = false;
- for (NotificationSection section : sections) {
- ExpandableView newView =
- (first ? section.getFirstVisibleChild()
- : section.getLastVisibleChild());
- if (newView == oldView) {
- isStillPresent = true;
- if (oldView.isFirstInSection() != isFirstInSection(oldView)
- || oldView.isLastInSection() != isLastInSection(oldView)) {
- adjacentSectionChanged = true;
- }
- break;
- }
- }
- if (!isStillPresent || adjacentSectionChanged) {
- anyChanged = true;
- if (!oldView.isRemoved()) {
- updateViewWithoutCallback(oldView, oldView.isShown());
- }
- }
- }
- }
- return anyChanged;
- }
-
- private boolean handleAddedNewViews(
- NotificationSection[] sections,
- ExpandableView[] oldViews,
- boolean first) {
- if (mUseRoundnessSourceTypes) return false;
- boolean anyChanged = false;
- for (NotificationSection section : sections) {
- ExpandableView newView =
- (first ? section.getFirstVisibleChild() : section.getLastVisibleChild());
- if (newView != null) {
- boolean wasAlreadyPresent = false;
- for (ExpandableView oldView : oldViews) {
- if (oldView == newView) {
- wasAlreadyPresent = true;
- break;
- }
- }
- if (!wasAlreadyPresent) {
- anyChanged = true;
- updateViewWithoutCallback(newView,
- newView.isShown() && !mAnimatedChildren.contains(newView));
- }
- }
- }
- return anyChanged;
- }
-
public void setAnimatedChildren(HashSet<ExpandableView> animatedChildren) {
mAnimatedChildren = animatedChildren;
}
@@ -376,51 +135,7 @@
return mAnimatedChildren.contains(view);
}
- public void setOnRoundingChangedCallback(Runnable roundingChangedCallback) {
- mRoundingChangedCallback = roundingChangedCallback;
- }
-
- public void setTrackingHeadsUp(ExpandableNotificationRow row) {
- ExpandableNotificationRow previous = mTrackedHeadsUp;
- mTrackedHeadsUp = row;
- if (previous != null) {
- updateView(previous, true /* animate */);
- }
- }
-
public void setShouldRoundPulsingViews(boolean shouldRoundPulsingViews) {
mRoundForPulsingViews = shouldRoundPulsingViews;
}
-
- private String dumpViews(ExpandableView[] views) {
- StringBuilder sb = new StringBuilder();
- for (int i = 0; i < views.length; i++) {
- if (views[i] == null) continue;
-
- sb.append("\t")
- .append("[").append(i).append("] ")
- .append("isPinned=").append(views[i].isPinned()).append(" ")
- .append("isFirstInSection=").append(views[i].isFirstInSection()).append(" ")
- .append("isLastInSection=").append(views[i].isLastInSection()).append(" ");
-
- if (views[i] instanceof ExpandableNotificationRow) {
- sb.append("entry=");
- dumpEntry(((ExpandableNotificationRow) views[i]).getEntry(), sb);
- }
-
- sb.append("\n");
- }
- return sb.toString();
- }
-
- private void dumpEntry(NotificationEntry entry, StringBuilder sb) {
- sb.append("NotificationEntry{key=").append(entry.getKey()).append(" ");
-
- if (entry.getSection() != null) {
- sb.append(" section=")
- .append(entry.getSection().getLabel());
- }
-
- sb.append("}");
- }
}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationSectionsManager.kt b/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationSectionsManager.kt
index 57b6dbc..fd064ee 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationSectionsManager.kt
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationSectionsManager.kt
@@ -52,8 +52,6 @@
@SilentHeader private val silentHeaderController: SectionHeaderController
) : SectionProvider {
- private val useRoundnessSourceTypes = true
-
private val configurationListener = object : ConfigurationController.ConfigurationListener {
override fun onLocaleListChanged() {
reinflateViews()
@@ -193,35 +191,33 @@
isSectionChanged || changed
}
- if (useRoundnessSourceTypes) {
- val newFirstChildren = sections.mapNotNull { it.firstVisibleChild }
- val newLastChildren = sections.mapNotNull { it.lastVisibleChild }
+ val newFirstChildren = sections.mapNotNull { it.firstVisibleChild }
+ val newLastChildren = sections.mapNotNull { it.lastVisibleChild }
- // Update the roundness of Views that weren't already in the first/last position
- newFirstChildren.forEach { firstChild ->
- val wasFirstChild = oldFirstChildren.remove(firstChild)
- if (!wasFirstChild) {
- val notAnimatedChild = !notificationRoundnessManager.isAnimatedChild(firstChild)
- val animated = firstChild.isShown && notAnimatedChild
- firstChild.requestTopRoundness(1f, SECTION, animated)
- }
+ // Update the roundness of Views that weren't already in the first/last position
+ newFirstChildren.forEach { firstChild ->
+ val wasFirstChild = oldFirstChildren.remove(firstChild)
+ if (!wasFirstChild) {
+ val notAnimatedChild = !notificationRoundnessManager.isAnimatedChild(firstChild)
+ val animated = firstChild.isShown && notAnimatedChild
+ firstChild.requestTopRoundness(1f, SECTION, animated)
}
- newLastChildren.forEach { lastChild ->
- val wasLastChild = oldLastChildren.remove(lastChild)
- if (!wasLastChild) {
- val notAnimatedChild = !notificationRoundnessManager.isAnimatedChild(lastChild)
- val animated = lastChild.isShown && notAnimatedChild
- lastChild.requestBottomRoundness(1f, SECTION, animated)
- }
+ }
+ newLastChildren.forEach { lastChild ->
+ val wasLastChild = oldLastChildren.remove(lastChild)
+ if (!wasLastChild) {
+ val notAnimatedChild = !notificationRoundnessManager.isAnimatedChild(lastChild)
+ val animated = lastChild.isShown && notAnimatedChild
+ lastChild.requestBottomRoundness(1f, SECTION, animated)
}
+ }
- // The Views left in the set are no longer in the first/last position
- oldFirstChildren.forEach { noMoreFirstChild ->
- noMoreFirstChild.requestTopRoundness(0f, SECTION)
- }
- oldLastChildren.forEach { noMoreLastChild ->
- noMoreLastChild.requestBottomRoundness(0f, SECTION)
- }
+ // The Views left in the set are no longer in the first/last position
+ oldFirstChildren.forEach { noMoreFirstChild ->
+ noMoreFirstChild.requestTopRoundness(0f, SECTION)
+ }
+ oldLastChildren.forEach { noMoreLastChild ->
+ noMoreLastChild.requestBottomRoundness(0f, SECTION)
}
if (DEBUG) {
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayout.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayout.java
index abcb825..edff877 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayout.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayout.java
@@ -200,7 +200,6 @@
private Set<Integer> mDebugTextUsedYPositions;
private final boolean mDebugRemoveAnimation;
private final boolean mSimplifiedAppearFraction;
- private final boolean mUseRoundnessSourceTypes;
private final boolean mSensitiveRevealAnimEndabled;
private boolean mAnimatedInsets;
@@ -625,7 +624,6 @@
mDebugLines = featureFlags.isEnabled(Flags.NSSL_DEBUG_LINES);
mDebugRemoveAnimation = featureFlags.isEnabled(Flags.NSSL_DEBUG_REMOVE_ANIMATION);
mSimplifiedAppearFraction = featureFlags.isEnabled(Flags.SIMPLIFIED_APPEAR_FRACTION);
- mUseRoundnessSourceTypes = true;
mSensitiveRevealAnimEndabled = featureFlags.isEnabled(Flags.SENSITIVE_REVEAL_ANIM);
setAnimatedInsetsEnabled(featureFlags.isEnabled(Flags.ANIMATED_NOTIFICATION_SHADE_INSETS));
mSectionsManager = Dependency.get(NotificationSectionsManager.class);
@@ -3134,10 +3132,6 @@
mAnimateNextSectionBoundsChange = false;
}
mAmbientState.setLastVisibleBackgroundChild(lastChild);
- if (!mUseRoundnessSourceTypes) {
- // TODO: Refactor SectionManager and put the RoundnessManager there.
- mController.getNotificationRoundnessManager().updateRoundedChildren(mSections);
- }
mAnimateBottomOnLayout = false;
invalidate();
}
@@ -3584,9 +3578,7 @@
@ShadeViewRefactor(RefactorComponent.LAYOUT_ALGORITHM)
protected StackScrollAlgorithm createStackScrollAlgorithm(Context context) {
- StackScrollAlgorithm stackScrollAlgorithm = new StackScrollAlgorithm(context, this);
- stackScrollAlgorithm.useRoundnessSourceTypes(mUseRoundnessSourceTypes);
- return stackScrollAlgorithm;
+ return new StackScrollAlgorithm(context, this);
}
/**
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayoutController.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayoutController.java
index d96a2cd..7b046d6 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayoutController.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayoutController.java
@@ -192,7 +192,6 @@
private int mBarState;
private HeadsUpAppearanceController mHeadsUpAppearanceController;
private final FeatureFlags mFeatureFlags;
- private final boolean mUseRoundnessSourceTypes;
private final NotificationTargetsHelper mNotificationTargetsHelper;
private final SecureSettings mSecureSettings;
private final NotificationDismissibilityProvider mDismissibilityProvider;
@@ -591,36 +590,12 @@
}
@Override
- public void onHeadsUpPinned(NotificationEntry entry) {
- if (!mUseRoundnessSourceTypes) {
- mNotificationRoundnessManager.updateView(
- entry.getRow(),
- /* animate = */ false);
- }
- }
-
- @Override
- public void onHeadsUpUnPinned(NotificationEntry entry) {
- if (!mUseRoundnessSourceTypes) {
- ExpandableNotificationRow row = entry.getRow();
- // update the roundedness posted, because we might be animating away the
- // headsup soon, so no need to set the roundedness to 0 and then back to 1.
- row.post(() -> mNotificationRoundnessManager.updateView(row,
- true /* animate */));
- }
- }
-
- @Override
public void onHeadsUpStateChanged(NotificationEntry entry, boolean isHeadsUp) {
long numEntries = mHeadsUpManager.getAllEntries().count();
NotificationEntry topEntry = mHeadsUpManager.getTopEntry();
mView.setNumHeadsUp(numEntries);
mView.setTopHeadsUpEntry(topEntry);
generateHeadsUpAnimation(entry, isHeadsUp);
- if (!mUseRoundnessSourceTypes) {
- ExpandableNotificationRow row = entry.getRow();
- mNotificationRoundnessManager.updateView(row, true /* animate */);
- }
}
};
@@ -720,7 +695,6 @@
mShadeController = shadeController;
mNotifIconAreaController = notifIconAreaController;
mFeatureFlags = featureFlags;
- mUseRoundnessSourceTypes = true;
mNotificationTargetsHelper = notificationTargetsHelper;
mSecureSettings = secureSettings;
mDismissibilityProvider = dismissibilityProvider;
@@ -788,11 +762,6 @@
mLockscreenUserManager.addUserChangedListener(mLockscreenUserChangeListener);
- if (!mUseRoundnessSourceTypes) {
- mNotificationRoundnessManager.setOnRoundingChangedCallback(mView::invalidate);
- mView.addOnExpandedHeightChangedListener(mNotificationRoundnessManager::setExpanded);
- }
-
mVisibilityLocationProviderDelegator.setDelegate(this::isInVisibleLocation);
mTunerService.addTunable(
@@ -958,7 +927,6 @@
public void setTrackingHeadsUp(ExpandableNotificationRow expandableNotificationRow) {
mView.setTrackingHeadsUp(expandableNotificationRow);
- mNotificationRoundnessManager.setTrackingHeadsUp(expandableNotificationRow);
}
public void wakeUpFromPulse() {
@@ -1776,9 +1744,6 @@
@Override
public void bindRow(ExpandableNotificationRow row) {
row.setHeadsUpAnimatingAwayListener(animatingAway -> {
- if (!mUseRoundnessSourceTypes) {
- mNotificationRoundnessManager.updateView(row, false);
- }
NotificationEntry entry = row.getEntry();
mHeadsUpAppearanceController.updateHeader(entry);
mHeadsUpAppearanceController.updateHeadsUpAndPulsingRoundness(entry);
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationSwipeHelper.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationSwipeHelper.java
index 2d0a6cf..993c3801 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationSwipeHelper.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationSwipeHelper.java
@@ -68,7 +68,6 @@
private boolean mIsExpanded;
private boolean mPulsing;
private final NotificationRoundnessManager mNotificationRoundnessManager;
- private final boolean mUseRoundnessSourceTypes;
NotificationSwipeHelper(
Resources resources,
@@ -80,7 +79,6 @@
NotificationRoundnessManager notificationRoundnessManager) {
super(callback, resources, viewConfiguration, falsingManager, featureFlags);
mNotificationRoundnessManager = notificationRoundnessManager;
- mUseRoundnessSourceTypes = true;
mMenuListener = menuListener;
mCallback = callback;
mFalsingCheck = () -> resetExposedMenuView(true /* animate */, true /* force */);
@@ -322,8 +320,7 @@
protected void prepareDismissAnimation(View view, Animator anim) {
super.prepareDismissAnimation(view, anim);
- if (mUseRoundnessSourceTypes
- && view instanceof ExpandableNotificationRow
+ if (view instanceof ExpandableNotificationRow
&& mNotificationRoundnessManager.isClearAllInProgress()) {
ExpandableNotificationRow row = (ExpandableNotificationRow) view;
anim.addListener(new AnimatorListenerAdapter() {
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationTargetsHelper.kt b/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationTargetsHelper.kt
index cd0c1b1..02662f4 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationTargetsHelper.kt
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationTargetsHelper.kt
@@ -4,7 +4,6 @@
import androidx.core.view.isVisible
import com.android.systemui.dagger.SysUISingleton
import com.android.systemui.flags.FeatureFlags
-import com.android.systemui.flags.Flags
import com.android.systemui.statusbar.notification.Roundable
import com.android.systemui.statusbar.notification.row.ExpandableNotificationRow
import com.android.systemui.statusbar.notification.row.ExpandableView
@@ -20,7 +19,6 @@
constructor(
featureFlags: FeatureFlags,
) {
- private val useRoundnessSourceTypes = true
/**
* This method looks for views that can be rounded (and implement [Roundable]) during a
@@ -48,10 +46,6 @@
if (notificationParent != null && childrenContainer != null) {
// We are inside a notification group
- if (!useRoundnessSourceTypes) {
- return RoundableTargets(null, null, null)
- }
-
val visibleGroupChildren = childrenContainer.attachedChildren.filter { it.isVisible }
val indexOfParentSwipedView = visibleGroupChildren.indexOf(viewSwiped)
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/StackScrollAlgorithm.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/StackScrollAlgorithm.java
index 3060473..92d767a 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/StackScrollAlgorithm.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/StackScrollAlgorithm.java
@@ -34,7 +34,6 @@
import com.android.systemui.shade.transition.LargeScreenShadeInterpolator;
import com.android.systemui.statusbar.EmptyShadeView;
import com.android.systemui.statusbar.NotificationShelf;
-import com.android.systemui.statusbar.notification.LegacySourceType;
import com.android.systemui.statusbar.notification.SourceType;
import com.android.systemui.statusbar.notification.row.ActivatableNotificationView;
import com.android.systemui.statusbar.notification.row.ExpandableNotificationRow;
@@ -75,7 +74,6 @@
private float mQuickQsOffsetHeight;
private float mSmallCornerRadius;
private float mLargeCornerRadius;
- private boolean mUseRoundnessSourceTypes;
public StackScrollAlgorithm(
Context context,
@@ -836,12 +834,8 @@
row.isLastInSection() ? 1f : (mSmallCornerRadius / mLargeCornerRadius);
final float bottomValue = computeCornerRoundnessForPinnedHun(mHostView.getHeight(),
ambientState.getStackY(), getMaxAllowedChildHeight(row), originalCornerRadius);
- if (mUseRoundnessSourceTypes) {
- row.requestBottomRoundness(bottomValue, STACK_SCROLL_ALGO);
- row.addOnDetachResetRoundness(STACK_SCROLL_ALGO);
- } else {
- row.requestBottomRoundness(bottomValue, LegacySourceType.OnScroll);
- }
+ row.requestBottomRoundness(bottomValue, STACK_SCROLL_ALGO);
+ row.addOnDetachResetRoundness(STACK_SCROLL_ALGO);
}
@VisibleForTesting
@@ -979,14 +973,6 @@
this.mIsExpanded = isExpanded;
}
- /**
- * Enable the support for rounded corner based on the SourceType
- * @param enabled true if is supported
- */
- public void useRoundnessSourceTypes(boolean enabled) {
- mUseRoundnessSourceTypes = enabled;
- }
-
public static class StackScrollAlgorithmState {
/**
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/HeadsUpAppearanceController.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/HeadsUpAppearanceController.java
index 0c4821c..f15dcc3 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/HeadsUpAppearanceController.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/HeadsUpAppearanceController.java
@@ -76,7 +76,6 @@
private final DarkIconDispatcher mDarkIconDispatcher;
private final ShadeViewController mShadeViewController;
private final NotificationRoundnessManager mNotificationRoundnessManager;
- private final boolean mUseRoundnessSourceTypes;
private final Consumer<ExpandableNotificationRow>
mSetTrackingHeadsUp = this::setTrackingHeadsUp;
private final BiConsumer<Float, Float> mSetExpandedHeight = this::setAppearFraction;
@@ -124,7 +123,6 @@
super(headsUpStatusBarView);
mNotificationIconAreaController = notificationIconAreaController;
mNotificationRoundnessManager = notificationRoundnessManager;
- mUseRoundnessSourceTypes = true;
mHeadsUpManager = headsUpManager;
// We may be mid-HUN-expansion when this controller is re-created (for example, if the user
@@ -405,21 +403,19 @@
* @param entry target notification
*/
public void updateHeadsUpAndPulsingRoundness(NotificationEntry entry) {
- if (mUseRoundnessSourceTypes) {
- ExpandableNotificationRow row = entry.getRow();
- boolean isTrackedChild = row == mTrackedChild;
- if (row.isPinned() || row.isHeadsUpAnimatingAway() || isTrackedChild) {
- float roundness = MathUtils.saturate(1f - mAppearFraction);
- row.requestRoundness(roundness, roundness, HEADS_UP);
+ ExpandableNotificationRow row = entry.getRow();
+ boolean isTrackedChild = row == mTrackedChild;
+ if (row.isPinned() || row.isHeadsUpAnimatingAway() || isTrackedChild) {
+ float roundness = MathUtils.saturate(1f - mAppearFraction);
+ row.requestRoundness(roundness, roundness, HEADS_UP);
+ } else {
+ row.requestRoundnessReset(HEADS_UP);
+ }
+ if (mNotificationRoundnessManager.shouldRoundNotificationPulsing()) {
+ if (row.showingPulsing()) {
+ row.requestRoundness(/* top = */ 1f, /* bottom = */ 1f, PULSING);
} else {
- row.requestRoundnessReset(HEADS_UP);
- }
- if (mNotificationRoundnessManager.shouldRoundNotificationPulsing()) {
- if (row.showingPulsing()) {
- row.requestRoundness(/* top = */ 1f, /* bottom = */ 1f, PULSING);
- } else {
- row.requestRoundnessReset(PULSING);
- }
+ row.requestRoundnessReset(PULSING);
}
}
}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/policy/DeviceStateRotationLockSettingControllerLogger.kt b/packages/SystemUI/src/com/android/systemui/statusbar/policy/DeviceStateRotationLockSettingControllerLogger.kt
index aa502bc..f61f3b7 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/policy/DeviceStateRotationLockSettingControllerLogger.kt
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/policy/DeviceStateRotationLockSettingControllerLogger.kt
@@ -34,6 +34,8 @@
private val halfFoldedStates =
context.resources.getIntArray(R.array.config_halfFoldedDeviceStates)
private val unfoldedStates = context.resources.getIntArray(R.array.config_openDeviceStates)
+ private val rearDisplayStates =
+ context.resources.getIntArray(R.array.config_rearDisplayDeviceStates)
fun logListeningChange(listening: Boolean) {
logBuffer.log(TAG, VERBOSE, { bool1 = listening }, { "setListening: $bool1" })
@@ -122,6 +124,7 @@
in foldedStates -> "Folded"
in unfoldedStates -> "Unfolded"
in halfFoldedStates -> "Half-Folded"
+ in rearDisplayStates -> "Rear display"
-1 -> "Uninitialized"
else -> "Unknown"
}
diff --git a/packages/SystemUI/src/com/android/systemui/theme/DynamicColors.kt b/packages/SystemUI/src/com/android/systemui/theme/DynamicColors.kt
index 6026d2c..f0fa779 100644
--- a/packages/SystemUI/src/com/android/systemui/theme/DynamicColors.kt
+++ b/packages/SystemUI/src/com/android/systemui/theme/DynamicColors.kt
@@ -13,6 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+
package com.android.systemui.theme
import android.util.Pair
@@ -24,68 +25,73 @@
@JvmField
val ALL_DYNAMIC_COLORS_MAPPED: List<Pair<String, DynamicColor>> =
arrayListOf(
- Pair.create("primary_container", MDC.primaryContainer),
- Pair.create("on_primary_container", MDC.onPrimaryContainer),
- Pair.create("primary", MDC.primary),
- Pair.create("on_primary", MDC.onPrimary),
- Pair.create("secondary_container", MDC.secondaryContainer),
- Pair.create("on_secondary_container", MDC.onSecondaryContainer),
- Pair.create("secondary", MDC.secondary),
- Pair.create("on_secondary", MDC.onSecondary),
- Pair.create("tertiary_container", MDC.tertiaryContainer),
- Pair.create("on_tertiary_container", MDC.onTertiaryContainer),
- Pair.create("tertiary", MDC.tertiary),
- Pair.create("on_tertiary", MDC.onTertiary),
- Pair.create("background", MDC.background),
- Pair.create("on_background", MDC.onBackground),
- Pair.create("surface", MDC.surface),
- Pair.create("on_surface", MDC.onSurface),
- Pair.create("surface_container_low", MDC.surfaceContainerLow),
- Pair.create("surface_container_lowest", MDC.surfaceContainerLowest),
- Pair.create("surface_container", MDC.surfaceContainer),
- Pair.create("surface_container_high", MDC.surfaceContainerHigh),
- Pair.create("surface_container_highest", MDC.surfaceContainerHighest),
- Pair.create("surface_bright", MDC.surfaceBright),
- Pair.create("surface_dim", MDC.surfaceDim),
- Pair.create("surface_variant", MDC.surfaceVariant),
- Pair.create("on_surface_variant", MDC.onSurfaceVariant),
- Pair.create("outline", MDC.outline),
- Pair.create("outline_variant", MDC.outlineVariant),
- Pair.create("error", MDC.error),
- Pair.create("on_error", MDC.onError),
- Pair.create("error_container", MDC.errorContainer),
- Pair.create("on_error_container", MDC.onErrorContainer),
- Pair.create("primary_fixed", MDC.primaryFixed),
- Pair.create("primary_fixed_dim", MDC.primaryFixedDim),
- Pair.create("on_primary_fixed", MDC.onPrimaryFixed),
- Pair.create("on_primary_fixed_variant", MDC.onPrimaryFixedVariant),
- Pair.create("secondary_fixed", MDC.secondaryFixed),
- Pair.create("secondary_fixed_dim", MDC.secondaryFixedDim),
- Pair.create("on_secondary_fixed", MDC.onSecondaryFixed),
- Pair.create("on_secondary_fixed_variant", MDC.onSecondaryFixedVariant),
- Pair.create("tertiary_fixed", MDC.tertiaryFixed),
- Pair.create("tertiary_fixed_dim", MDC.tertiaryFixedDim),
- Pair.create("on_tertiary_fixed", MDC.onTertiaryFixed),
- Pair.create("on_tertiary_fixed_variant", MDC.onTertiaryFixedVariant),
- Pair.create("control_activated", MDC.controlActivated),
- Pair.create("control_normal", MDC.controlNormal),
- Pair.create("control_highlight", MDC.controlHighlight),
- Pair.create("text_primary_inverse", MDC.textPrimaryInverse),
+ Pair.create("primary_container", MDC.primaryContainer()),
+ Pair.create("on_primary_container", MDC.onPrimaryContainer()),
+ Pair.create("primary", MDC.primary()),
+ Pair.create("on_primary", MDC.onPrimary()),
+ Pair.create("secondary_container", MDC.secondaryContainer()),
+ Pair.create("on_secondary_container", MDC.onSecondaryContainer()),
+ Pair.create("secondary", MDC.secondary()),
+ Pair.create("on_secondary", MDC.onSecondary()),
+ Pair.create("tertiary_container", MDC.tertiaryContainer()),
+ Pair.create("on_tertiary_container", MDC.onTertiaryContainer()),
+ Pair.create("tertiary", MDC.tertiary()),
+ Pair.create("on_tertiary", MDC.onTertiary()),
+ Pair.create("background", MDC.background()),
+ Pair.create("on_background", MDC.onBackground()),
+ Pair.create("surface", MDC.surface()),
+ Pair.create("on_surface", MDC.onSurface()),
+ Pair.create("surface_container_low", MDC.surfaceContainerLow()),
+ Pair.create("surface_container_lowest", MDC.surfaceContainerLowest()),
+ Pair.create("surface_container", MDC.surfaceContainer()),
+ Pair.create("surface_container_high", MDC.surfaceContainerHigh()),
+ Pair.create("surface_container_highest", MDC.surfaceContainerHighest()),
+ Pair.create("surface_bright", MDC.surfaceBright()),
+ Pair.create("surface_dim", MDC.surfaceDim()),
+ Pair.create("surface_variant", MDC.surfaceVariant()),
+ Pair.create("on_surface_variant", MDC.onSurfaceVariant()),
+ Pair.create("outline", MDC.outline()),
+ Pair.create("error", MDC.error()),
+ Pair.create("on_error", MDC.onError()),
+ Pair.create("error_container", MDC.errorContainer()),
+ Pair.create("on_error_container", MDC.onErrorContainer()),
+ Pair.create("primary_fixed", MDC.primaryFixed()),
+ Pair.create("primary_fixed_dim", MDC.primaryFixedDim()),
+ Pair.create("on_primary_fixed", MDC.onPrimaryFixed()),
+ Pair.create("on_primary_fixed_variant", MDC.onPrimaryFixedVariant()),
+ Pair.create("secondary_fixed", MDC.secondaryFixed()),
+ Pair.create("secondary_fixed_dim", MDC.secondaryFixedDim()),
+ Pair.create("on_secondary_fixed", MDC.onSecondaryFixed()),
+ Pair.create("on_secondary_fixed_variant", MDC.onSecondaryFixedVariant()),
+ Pair.create("tertiary_fixed", MDC.tertiaryFixed()),
+ Pair.create("tertiary_fixed_dim", MDC.tertiaryFixedDim()),
+ Pair.create("on_tertiary_fixed", MDC.onTertiaryFixed()),
+ Pair.create("on_tertiary_fixed_variant", MDC.onTertiaryFixedVariant()),
+ Pair.create("control_activated", MDC.controlActivated()),
+ Pair.create("control_normal", MDC.controlNormal()),
+ Pair.create("control_highlight", MDC.controlHighlight()),
+ Pair.create("text_primary_inverse", MDC.textPrimaryInverse()),
Pair.create(
"text_secondary_and_tertiary_inverse",
- MDC.textSecondaryAndTertiaryInverse
+ MDC.textSecondaryAndTertiaryInverse()
),
- Pair.create("text_primary_inverse_disable_only", MDC.textPrimaryInverseDisableOnly),
+ Pair.create(
+ "text_primary_inverse_disable_only",
+ MDC.textPrimaryInverseDisableOnly()
+ ),
Pair.create(
"text_secondary_and_tertiary_inverse_disabled",
- MDC.textSecondaryAndTertiaryInverseDisabled
+ MDC.textSecondaryAndTertiaryInverseDisabled()
),
- Pair.create("text_hint_inverse", MDC.textHintInverse),
- Pair.create("palette_key_color_primary", MDC.primaryPaletteKeyColor),
- Pair.create("palette_key_color_secondary", MDC.secondaryPaletteKeyColor),
- Pair.create("palette_key_color_tertiary", MDC.tertiaryPaletteKeyColor),
- Pair.create("palette_key_color_neutral", MDC.neutralPaletteKeyColor),
- Pair.create("palette_key_color_neutral_variant", MDC.neutralVariantPaletteKeyColor)
+ Pair.create("text_hint_inverse", MDC.textHintInverse()),
+ Pair.create("palette_key_color_primary", MDC.primaryPaletteKeyColor()),
+ Pair.create("palette_key_color_secondary", MDC.secondaryPaletteKeyColor()),
+ Pair.create("palette_key_color_tertiary", MDC.tertiaryPaletteKeyColor()),
+ Pair.create("palette_key_color_neutral", MDC.neutralPaletteKeyColor()),
+ Pair.create(
+ "palette_key_color_neutral_variant",
+ MDC.neutralVariantPaletteKeyColor()
+ )
)
}
}
diff --git a/packages/SystemUI/src/com/android/systemui/theme/ThemeOverlayController.java b/packages/SystemUI/src/com/android/systemui/theme/ThemeOverlayController.java
index faae8df..43d15bc 100644
--- a/packages/SystemUI/src/com/android/systemui/theme/ThemeOverlayController.java
+++ b/packages/SystemUI/src/com/android/systemui/theme/ThemeOverlayController.java
@@ -13,6 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+
package com.android.systemui.theme;
import static android.util.TypedValue.TYPE_INT_COLOR_ARGB8;
@@ -659,9 +660,9 @@
&& res.getColor(android.R.color.system_neutral2_500, theme)
== mColorScheme.getNeutral2().getS500()
&& res.getColor(android.R.color.system_primary_container_dark, theme)
- == MaterialDynamicColors.primaryContainer.getArgb(mDynamicSchemeDark)
+ == MaterialDynamicColors.primaryContainer().getArgb(mDynamicSchemeDark)
&& res.getColor(android.R.color.system_primary_container_light, theme)
- == MaterialDynamicColors.primaryContainer.getArgb(mDynamicSchemeLight))) {
+ == MaterialDynamicColors.primaryContainer().getArgb(mDynamicSchemeLight))) {
return false;
}
}
diff --git a/packages/SystemUI/tests/src/com/android/systemui/controls/ui/DetailDialogTest.kt b/packages/SystemUI/tests/src/com/android/systemui/controls/ui/DetailDialogTest.kt
index c3506e8..5414259 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/controls/ui/DetailDialogTest.kt
+++ b/packages/SystemUI/tests/src/com/android/systemui/controls/ui/DetailDialogTest.kt
@@ -16,6 +16,7 @@
package com.android.systemui.controls.ui
+import android.app.ActivityOptions
import android.app.PendingIntent
import android.testing.AndroidTestingRunner
import android.testing.TestableLooper
@@ -24,7 +25,10 @@
import com.android.systemui.broadcast.BroadcastSender
import com.android.systemui.plugins.ActivityStarter
import com.android.systemui.statusbar.policy.KeyguardStateController
+import com.android.systemui.util.mockito.argumentCaptor
+import com.android.systemui.util.mockito.capture
import com.android.wm.shell.taskview.TaskView
+import com.google.common.truth.Truth.assertThat
import org.junit.Before
import org.junit.Test
import org.junit.runner.RunWith
@@ -69,6 +73,25 @@
verify(taskView).startActivity(eq(pendingIntent), any(), any(), any())
}
+ @Test
+ fun testActivityOptionsAllowBal() {
+ // GIVEN the dialog is created with a PendingIntent
+ val dialog = createDialog(pendingIntent)
+
+ // WHEN the TaskView is initialized
+ dialog.stateCallback.onInitialized()
+
+ val optionsCaptor = argumentCaptor<ActivityOptions>()
+
+ // THEN the ActivityOptions have the correct flags
+ verify(taskView).startActivity(any(), any(), capture(optionsCaptor), any())
+
+ assertThat(optionsCaptor.value.pendingIntentBackgroundActivityStartMode)
+ .isEqualTo(ActivityOptions.MODE_BACKGROUND_ACTIVITY_START_ALLOWED)
+ assertThat(optionsCaptor.value.isPendingIntentBackgroundActivityLaunchAllowedByPermission)
+ .isTrue()
+ }
+
private fun createDialog(pendingIntent: PendingIntent): DetailDialog {
return DetailDialog(
mContext,
diff --git a/packages/SystemUI/tests/src/com/android/systemui/monet/DynamicColorTest.java b/packages/SystemUI/tests/src/com/android/systemui/monet/DynamicColorTest.java
index fb5197e..4ce32d2 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/monet/DynamicColorTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/monet/DynamicColorTest.java
@@ -17,18 +17,16 @@
package com.android.systemui.monet;
import static com.android.systemui.monet.utils.ArgbSubject.assertThat;
-
import static org.junit.Assert.assertTrue;
-
import androidx.test.filters.SmallTest;
-import com.android.systemui.SysuiTestCase;
import com.android.systemui.monet.contrast.Contrast;
import com.android.systemui.monet.dynamiccolor.DynamicColor;
import com.android.systemui.monet.dynamiccolor.MaterialDynamicColors;
import com.android.systemui.monet.dynamiccolor.ToneDeltaConstraint;
import com.android.systemui.monet.dynamiccolor.TonePolarity;
+import com.android.systemui.SysuiTestCase;
import com.android.systemui.monet.hct.Hct;
import com.android.systemui.monet.scheme.DynamicScheme;
import com.android.systemui.monet.scheme.SchemeContent;
@@ -36,182 +34,174 @@
import com.android.systemui.monet.scheme.SchemeMonochrome;
import com.android.systemui.monet.scheme.SchemeTonalSpot;
+import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
+@Ignore("b/279581953")
@SmallTest
@RunWith(JUnit4.class)
-public final class DynamicColorTest extends SysuiTestCase {
+public final class DynamicColorTest extends SysuiTestCase{
- @Test
- public void fromArgbNoBackground_doesntChangeForContrast() {
- final int blueArgb = 0xff0000ff;
- final DynamicColor dynamicColor = DynamicColor.fromArgb(blueArgb);
+ private final MaterialDynamicColors dynamicColors = new MaterialDynamicColors();
- final SchemeTonalSpot standardContrast = new SchemeTonalSpot(Hct.fromInt(blueArgb), false,
- 0.0);
- assertThat(dynamicColor.getArgb(standardContrast)).isSameColorAs(blueArgb);
+ @Test
+ public void fromArgbNoBackground_doesntChangeForContrast() {
+ final int blueArgb = 0xff0000ff;
+ final DynamicColor dynamicColor = DynamicColor.fromArgb(blueArgb);
- final SchemeTonalSpot minContrast = new SchemeTonalSpot(Hct.fromInt(blueArgb), false, -1.0);
- assertThat(dynamicColor.getArgb(minContrast)).isSameColorAs(blueArgb);
+ final SchemeTonalSpot standardContrast = new SchemeTonalSpot(Hct.fromInt(blueArgb), false, 0.0);
+ assertThat(dynamicColor.getArgb(standardContrast)).isSameColorAs(blueArgb);
- final SchemeTonalSpot maxContrast = new SchemeTonalSpot(Hct.fromInt(blueArgb), false, 1.0);
- assertThat(dynamicColor.getArgb(maxContrast)).isSameColorAs(blueArgb);
- }
+ final SchemeTonalSpot minContrast = new SchemeTonalSpot(Hct.fromInt(blueArgb), false, -1.0);
+ assertThat(dynamicColor.getArgb(minContrast)).isSameColorAs(blueArgb);
- @Test
- public void toneDeltaConstraintNoPreference_evaluatesCorrectly() {
- final int blueArgb = 0xff0000ff;
- final int redArgb = 0xffff0000;
- final DynamicColor otherDynamicColor = DynamicColor.fromArgb(redArgb);
- final DynamicColor dynamicColor =
- DynamicColor.fromArgb(
- blueArgb,
- (s) -> 30.0,
- null,
- (s) -> new ToneDeltaConstraint(30, otherDynamicColor,
- TonePolarity.NO_PREFERENCE));
- final SchemeTonalSpot scheme = new SchemeTonalSpot(Hct.fromInt(blueArgb), false, 0.0);
- assertThat(dynamicColor.getArgb(scheme)).isSameColorAs(0xff0000ef);
- }
+ final SchemeTonalSpot maxContrast = new SchemeTonalSpot(Hct.fromInt(blueArgb), false, 1.0);
+ assertThat(dynamicColor.getArgb(maxContrast)).isSameColorAs(blueArgb);
+ }
- @Test
- public void dynamicColor_withOpacity() {
- final DynamicColor dynamicColor =
- new DynamicColor(
- s -> 0.0,
- s -> 0.0,
- s -> s.isDark ? 100.0 : 0.0,
- s -> s.isDark ? 0.20 : 0.12,
- null,
- scheme ->
- DynamicColor.toneMinContrastDefault(
- (s) -> s.isDark ? 100.0 : 0.0, null, scheme, null),
- scheme ->
- DynamicColor.toneMaxContrastDefault(
- (s) -> s.isDark ? 100.0 : 0.0, null, scheme, null),
- null);
- final SchemeTonalSpot lightScheme = new SchemeTonalSpot(Hct.fromInt(0xff4285f4), false,
- 0.0);
- assertThat(dynamicColor.getArgb(lightScheme)).isSameColorAs(0x1f000000);
+ @Test
+ public void toneDeltaConstraintNoPreference_evaluatesCorrectly() {
+ final int blueArgb = 0xff0000ff;
+ final int redArgb = 0xffff0000;
+ final DynamicColor otherDynamicColor = DynamicColor.fromArgb(redArgb);
+ final DynamicColor dynamicColor =
+ DynamicColor.fromArgb(
+ blueArgb,
+ (s) -> 30.0,
+ null,
+ (s) -> new ToneDeltaConstraint(30, otherDynamicColor, TonePolarity.NO_PREFERENCE));
+ final SchemeTonalSpot scheme = new SchemeTonalSpot(Hct.fromInt(blueArgb), false, 0.0);
+ assertThat(dynamicColor.getArgb(scheme)).isSameColorAs(0xff0000ef);
+ }
- final SchemeTonalSpot darkScheme = new SchemeTonalSpot(Hct.fromInt(0xff4285f4), true, 0.0);
- assertThat(dynamicColor.getArgb(darkScheme)).isSameColorAs(0x33ffffff);
- }
+ @Test
+ public void dynamicColor_withOpacity() {
+ final DynamicColor dynamicColor =
+ new DynamicColor(
+ s -> 0.0,
+ s -> 0.0,
+ s -> s.isDark ? 100.0 : 0.0,
+ s -> s.isDark ? 0.20 : 0.12,
+ null,
+ scheme ->
+ DynamicColor.toneMinContrastDefault(
+ (s) -> s.isDark ? 100.0 : 0.0, null, scheme, null),
+ scheme ->
+ DynamicColor.toneMaxContrastDefault(
+ (s) -> s.isDark ? 100.0 : 0.0, null, scheme, null),
+ null);
+ final SchemeTonalSpot lightScheme = new SchemeTonalSpot(Hct.fromInt(0xff4285f4), false, 0.0);
+ assertThat(dynamicColor.getArgb(lightScheme)).isSameColorAs(0x1f000000);
- @Test
- public void respectsContrast() {
- final Hct[] seedColors =
- new Hct[]{
- Hct.fromInt(0xFFFF0000),
- Hct.fromInt(0xFFFFFF00),
- Hct.fromInt(0xFF00FF00),
- Hct.fromInt(0xFF0000FF)
- };
+ final SchemeTonalSpot darkScheme = new SchemeTonalSpot(Hct.fromInt(0xff4285f4), true, 0.0);
+ assertThat(dynamicColor.getArgb(darkScheme)).isSameColorAs(0x33ffffff);
+ }
- final double[] contrastLevels = {-1.0, -0.5, 0.0, 0.5, 1.0};
+ @Test
+ public void respectsContrast() {
+ final Hct[] seedColors =
+ new Hct[] {
+ Hct.fromInt(0xFFFF0000),
+ Hct.fromInt(0xFFFFFF00),
+ Hct.fromInt(0xFF00FF00),
+ Hct.fromInt(0xFF0000FF)
+ };
- for (Hct seedColor : seedColors) {
- for (double contrastLevel : contrastLevels) {
- for (boolean isDark : new boolean[]{false, true}) {
- final DynamicScheme[] schemes =
- new DynamicScheme[]{
- new SchemeContent(seedColor, isDark, contrastLevel),
- new SchemeMonochrome(seedColor, isDark, contrastLevel),
- new SchemeTonalSpot(seedColor, isDark, contrastLevel),
- new SchemeFidelity(seedColor, isDark, contrastLevel)
- };
- for (final DynamicScheme scheme : schemes) {
- assertTrue(
- pairSatisfiesContrast(
- scheme, MaterialDynamicColors.onPrimary,
- MaterialDynamicColors.primary));
- assertTrue(
- pairSatisfiesContrast(
- scheme,
- MaterialDynamicColors.onPrimaryContainer,
- MaterialDynamicColors.primaryContainer));
- assertTrue(
- pairSatisfiesContrast(
- scheme, MaterialDynamicColors.onSecondary,
- MaterialDynamicColors.secondary));
- assertTrue(
- pairSatisfiesContrast(
- scheme,
- MaterialDynamicColors.onSecondaryContainer,
- MaterialDynamicColors.secondaryContainer));
- assertTrue(
- pairSatisfiesContrast(
- scheme, MaterialDynamicColors.onTertiary,
- MaterialDynamicColors.tertiary));
- assertTrue(
- pairSatisfiesContrast(
- scheme,
- MaterialDynamicColors.onTertiaryContainer,
- MaterialDynamicColors.tertiaryContainer));
- assertTrue(
- pairSatisfiesContrast(
- scheme, MaterialDynamicColors.onError,
- MaterialDynamicColors.error));
- assertTrue(
- pairSatisfiesContrast(
- scheme,
- MaterialDynamicColors.onErrorContainer,
- MaterialDynamicColors.errorContainer));
- assertTrue(
- pairSatisfiesContrast(
- scheme, MaterialDynamicColors.onBackground,
- MaterialDynamicColors.background));
- assertTrue(
- pairSatisfiesContrast(
- scheme,
- MaterialDynamicColors.onSurfaceVariant,
- MaterialDynamicColors.surfaceVariant));
- assertTrue(
- pairSatisfiesContrast(
- scheme,
- MaterialDynamicColors.onSurfaceInverse,
- MaterialDynamicColors.surfaceInverse));
- }
- }
- }
+ final double[] contrastLevels = {-1.0, -0.5, 0.0, 0.5, 1.0};
+
+ for (Hct seedColor : seedColors) {
+ for (double contrastLevel : contrastLevels) {
+ for (boolean isDark : new boolean[] {false, true}) {
+ final DynamicScheme[] schemes =
+ new DynamicScheme[] {
+ new SchemeContent(seedColor, isDark, contrastLevel),
+ new SchemeMonochrome(seedColor, isDark, contrastLevel),
+ new SchemeTonalSpot(seedColor, isDark, contrastLevel),
+ new SchemeFidelity(seedColor, isDark, contrastLevel)
+ };
+ for (final DynamicScheme scheme : schemes) {
+ assertTrue(
+ pairSatisfiesContrast(scheme, dynamicColors.onPrimary(), dynamicColors.primary()));
+ assertTrue(
+ pairSatisfiesContrast(
+ scheme, dynamicColors.onPrimaryContainer(), dynamicColors.primaryContainer()));
+ assertTrue(
+ pairSatisfiesContrast(
+ scheme, dynamicColors.onSecondary(), dynamicColors.secondary()));
+ assertTrue(
+ pairSatisfiesContrast(
+ scheme,
+ dynamicColors.onSecondaryContainer(),
+ dynamicColors.secondaryContainer()));
+ assertTrue(
+ pairSatisfiesContrast(
+ scheme, dynamicColors.onTertiary(), dynamicColors.tertiary()));
+ assertTrue(
+ pairSatisfiesContrast(
+ scheme,
+ dynamicColors.onTertiaryContainer(),
+ dynamicColors.tertiaryContainer()));
+ assertTrue(
+ pairSatisfiesContrast(scheme, dynamicColors.onError(), dynamicColors.error()));
+ assertTrue(
+ pairSatisfiesContrast(
+ scheme, dynamicColors.onErrorContainer(), dynamicColors.errorContainer()));
+ assertTrue(
+ pairSatisfiesContrast(
+ scheme, dynamicColors.onBackground(), dynamicColors.background()));
+ assertTrue(
+ pairSatisfiesContrast(
+ scheme, dynamicColors.onSurfaceVariant(), dynamicColors.surfaceVariant()));
+ assertTrue(
+ pairSatisfiesContrast(
+ scheme, dynamicColors.inverseOnSurface(), dynamicColors.inverseSurface()));
+ }
}
+ }
}
+ }
- @Test
- public void valuesAreCorrect() {
- // Checks that the values of certain dynamic colors match Dart results.
- assertThat(
- MaterialDynamicColors.onPrimaryContainer.getArgb(
- new SchemeFidelity(Hct.fromInt(0xFFFF0000), false, 0.5)))
- .isSameColorAs(0xFFFFE5E1);
- assertThat(
- MaterialDynamicColors.onSecondaryContainer.getArgb(
- new SchemeContent(Hct.fromInt(0xFF0000FF), false, 0.5)))
- .isSameColorAs(0xFFFFFCFF);
- assertThat(
- MaterialDynamicColors.onTertiaryContainer.getArgb(
- new SchemeContent(Hct.fromInt(0xFFFFFF00), true, -0.5)))
- .isSameColorAs(0xFF616600);
- assertThat(
- MaterialDynamicColors.surfaceInverse.getArgb(
- new SchemeContent(Hct.fromInt(0xFF0000FF), false, 0.0)))
- .isSameColorAs(0xFF464652);
- assertThat(
- MaterialDynamicColors.primaryInverse.getArgb(
- new SchemeContent(Hct.fromInt(0xFFFF0000), false, -0.5)))
- .isSameColorAs(0xFFFF8C7A);
- assertThat(
- MaterialDynamicColors.outlineVariant.getArgb(
- new SchemeContent(Hct.fromInt(0xFFFFFF00), true, 0.0)))
- .isSameColorAs(0xFF484831);
- }
+ @Test
+ public void valuesAreCorrect() {
+ // Checks that the values of certain dynamic colors match Dart results.
+ assertThat(
+ dynamicColors
+ .onPrimaryContainer()
+ .getArgb(new SchemeFidelity(Hct.fromInt(0xFFFF0000), false, 0.5)))
+ .isSameColorAs(0xFFFFE5E1);
+ assertThat(
+ dynamicColors
+ .onSecondaryContainer()
+ .getArgb(new SchemeContent(Hct.fromInt(0xFF0000FF), false, 0.5)))
+ .isSameColorAs(0xFFFFFCFF);
+ assertThat(
+ dynamicColors
+ .onTertiaryContainer()
+ .getArgb(new SchemeContent(Hct.fromInt(0xFFFFFF00), true, -0.5)))
+ .isSameColorAs(0xFF616600);
+ assertThat(
+ dynamicColors
+ .inverseSurface()
+ .getArgb(new SchemeContent(Hct.fromInt(0xFF0000FF), false, 0.0)))
+ .isSameColorAs(0xFF2F2F3B);
+ assertThat(
+ dynamicColors
+ .inversePrimary()
+ .getArgb(new SchemeContent(Hct.fromInt(0xFFFF0000), false, -0.5)))
+ .isSameColorAs(0xFFFF907F);
+ assertThat(
+ dynamicColors
+ .outlineVariant()
+ .getArgb(new SchemeContent(Hct.fromInt(0xFFFFFF00), true, 0.0)))
+ .isSameColorAs(0xFF484831);
+ }
- private boolean pairSatisfiesContrast(DynamicScheme scheme, DynamicColor fg, DynamicColor bg) {
- double fgTone = fg.getHct(scheme).getTone();
- double bgTone = bg.getHct(scheme).getTone();
- double minimumRequirement = scheme.contrastLevel >= 0.0 ? 4.5 : 3.0;
- return Contrast.ratioOfTones(fgTone, bgTone) >= minimumRequirement;
- }
+ private boolean pairSatisfiesContrast(DynamicScheme scheme, DynamicColor fg, DynamicColor bg) {
+ double fgTone = fg.getHct(scheme).getTone();
+ double bgTone = bg.getHct(scheme).getTone();
+ double minimumRequirement = scheme.contrastLevel >= 0.0 ? 4.5 : 3.0;
+ return Contrast.ratioOfTones(fgTone, bgTone) >= minimumRequirement;
+ }
}
diff --git a/packages/SystemUI/tests/src/com/android/systemui/monet/SchemeContentTest.java b/packages/SystemUI/tests/src/com/android/systemui/monet/SchemeContentTest.java
index 1ddfc4d..704aed8 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/monet/SchemeContentTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/monet/SchemeContentTest.java
@@ -25,246 +25,229 @@
import com.android.systemui.monet.hct.Hct;
import com.android.systemui.monet.scheme.SchemeContent;
+import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
+@Ignore("b/279581953")
@SmallTest
@RunWith(JUnit4.class)
public final class SchemeContentTest extends SysuiTestCase {
+ private final MaterialDynamicColors dynamicColors = new MaterialDynamicColors();
+
@Test
public void testKeyColors() {
SchemeContent scheme = new SchemeContent(Hct.fromInt(0xff0000ff), false, 0.0);
- assertThat(MaterialDynamicColors.primaryPaletteKeyColor.getArgb(scheme))
+ assertThat(dynamicColors.primaryPaletteKeyColor().getArgb(scheme))
.isSameColorAs(0xff080CFF);
- assertThat(MaterialDynamicColors.secondaryPaletteKeyColor.getArgb(scheme))
+ assertThat(dynamicColors.secondaryPaletteKeyColor().getArgb(scheme))
.isSameColorAs(0xff656DD3);
- assertThat(MaterialDynamicColors.tertiaryPaletteKeyColor.getArgb(scheme))
+ assertThat(dynamicColors.tertiaryPaletteKeyColor().getArgb(scheme))
.isSameColorAs(0xff81009F);
- assertThat(MaterialDynamicColors.neutralPaletteKeyColor.getArgb(scheme))
+ assertThat(dynamicColors.neutralPaletteKeyColor().getArgb(scheme))
.isSameColorAs(0xff767684);
- assertThat(MaterialDynamicColors.neutralVariantPaletteKeyColor.getArgb(scheme))
+ assertThat(dynamicColors.neutralVariantPaletteKeyColor().getArgb(scheme))
.isSameColorAs(0xff757589);
}
@Test
public void lightTheme_minContrast_primary() {
SchemeContent scheme = new SchemeContent(Hct.fromInt(0xFF0000ff), false, -1.0);
- assertThat(MaterialDynamicColors.primary.getArgb(scheme)).isSameColorAs(0xFF1218FF);
+ assertThat(dynamicColors.primary().getArgb(scheme)).isSameColorAs(0xFF1218FF);
}
@Test
public void lightTheme_standardContrast_primary() {
SchemeContent scheme = new SchemeContent(Hct.fromInt(0xFF0000ff), false, 0.0);
- assertThat(MaterialDynamicColors.primary.getArgb(scheme)).isSameColorAs(0xFF0001C3);
+ assertThat(dynamicColors.primary().getArgb(scheme)).isSameColorAs(0xFF0001C3);
}
@Test
public void lightTheme_maxContrast_primary() {
SchemeContent scheme = new SchemeContent(Hct.fromInt(0xFF0000ff), false, 1.0);
- assertThat(MaterialDynamicColors.primary.getArgb(scheme)).isSameColorAs(0xFF000181);
+ assertThat(dynamicColors.primary().getArgb(scheme)).isSameColorAs(0xFF000181);
}
@Test
public void lightTheme_minContrast_primaryContainer() {
SchemeContent scheme = new SchemeContent(Hct.fromInt(0xFF0000ff), false, -1.0);
- assertThat(MaterialDynamicColors.primaryContainer.getArgb(scheme)).isSameColorAs(
- 0xFF5660FF);
+ assertThat(dynamicColors.primaryContainer().getArgb(scheme)).isSameColorAs(0xFF5660FF);
}
@Test
public void lightTheme_standardContrast_primaryContainer() {
SchemeContent scheme = new SchemeContent(Hct.fromInt(0xFF0000ff), false, 0.0);
- assertThat(MaterialDynamicColors.primaryContainer.getArgb(scheme)).isSameColorAs(
- 0xFF2D36FF);
+ assertThat(dynamicColors.primaryContainer().getArgb(scheme)).isSameColorAs(0xFF2D36FF);
}
@Test
public void lightTheme_maxContrast_primaryContainer() {
SchemeContent scheme = new SchemeContent(Hct.fromInt(0xFF0000ff), false, 1.0);
- assertThat(MaterialDynamicColors.primaryContainer.getArgb(scheme)).isSameColorAs(
- 0xFF0000E3);
+ assertThat(dynamicColors.primaryContainer().getArgb(scheme)).isSameColorAs(0xFF0000E3);
}
@Test
public void lightTheme_minContrast_tertiaryContainer() {
SchemeContent scheme = new SchemeContent(Hct.fromInt(0xFF0000ff), false, -1.0);
- assertThat(MaterialDynamicColors.tertiaryContainer.getArgb(scheme)).isSameColorAs(
- 0xFFB042CC);
+ assertThat(dynamicColors.tertiaryContainer().getArgb(scheme)).isSameColorAs(0xFFB042CC);
}
@Test
public void lightTheme_standardContrast_tertiaryContainer() {
SchemeContent scheme = new SchemeContent(Hct.fromInt(0xFF0000ff), false, 0.0);
- assertThat(MaterialDynamicColors.tertiaryContainer.getArgb(scheme)).isSameColorAs(
- 0xFF9221AF);
+ assertThat(dynamicColors.tertiaryContainer().getArgb(scheme)).isSameColorAs(0xFF9221AF);
}
@Test
public void lightTheme_maxContrast_tertiaryContainer() {
SchemeContent scheme = new SchemeContent(Hct.fromInt(0xFF0000ff), false, 1.0);
- assertThat(MaterialDynamicColors.tertiaryContainer.getArgb(scheme)).isSameColorAs(
- 0xFF73008E);
+ assertThat(dynamicColors.tertiaryContainer().getArgb(scheme)).isSameColorAs(0xFF73008E);
}
@Test
public void lightTheme_minContrast_objectionableTertiaryContainerLightens() {
SchemeContent scheme = new SchemeContent(Hct.fromInt(0xFF850096), false, -1.0);
- assertThat(MaterialDynamicColors.tertiaryContainer.getArgb(scheme)).isSameColorAs(
- 0xFFD03A71);
+ assertThat(dynamicColors.tertiaryContainer().getArgb(scheme)).isSameColorAs(0xFFD03A71);
}
@Test
public void lightTheme_standardContrast_objectionableTertiaryContainerLightens() {
SchemeContent scheme = new SchemeContent(Hct.fromInt(0xFF850096), false, 0.0);
- assertThat(MaterialDynamicColors.tertiaryContainer.getArgb(scheme)).isSameColorAs(
- 0xFFAC1B57);
+ assertThat(dynamicColors.tertiaryContainer().getArgb(scheme)).isSameColorAs(0xFFAC1B57);
}
@Test
public void lightTheme_maxContrast_objectionableTertiaryContainerDarkens() {
SchemeContent scheme = new SchemeContent(Hct.fromInt(0xFF850096), false, 1.0);
- assertThat(MaterialDynamicColors.tertiaryContainer.getArgb(scheme)).isSameColorAs(
- 0xFF870040);
+ assertThat(dynamicColors.tertiaryContainer().getArgb(scheme)).isSameColorAs(0xFF870040);
}
@Test
public void lightTheme_minContrast_onPrimaryContainer() {
SchemeContent scheme = new SchemeContent(Hct.fromInt(0xFF0000ff), false, -1.0);
- assertThat(MaterialDynamicColors.onPrimaryContainer.getArgb(scheme)).isSameColorAs(
- 0xFFCBCDFF);
+ assertThat(dynamicColors.onPrimaryContainer().getArgb(scheme)).isSameColorAs(0xFFCBCDFF);
}
@Test
public void lightTheme_standardContrast_onPrimaryContainer() {
SchemeContent scheme = new SchemeContent(Hct.fromInt(0xFF0000ff), false, 0.0);
- assertThat(MaterialDynamicColors.onPrimaryContainer.getArgb(scheme)).isSameColorAs(
- 0xFFCECFFF);
+ assertThat(dynamicColors.onPrimaryContainer().getArgb(scheme)).isSameColorAs(0xFFCECFFF);
}
@Test
public void lightTheme_maxContrast_onPrimaryContainer() {
SchemeContent scheme = new SchemeContent(Hct.fromInt(0xFF0000ff), false, 1.0);
- assertThat(MaterialDynamicColors.onPrimaryContainer.getArgb(scheme)).isSameColorAs(
- 0xFFD6D6FF);
+ assertThat(dynamicColors.onPrimaryContainer().getArgb(scheme)).isSameColorAs(0xFFD6D6FF);
}
@Test
public void lightTheme_minContrast_surface() {
SchemeContent scheme = new SchemeContent(Hct.fromInt(0xFF0000ff), false, -1);
- assertThat(MaterialDynamicColors.surface.getArgb(scheme)).isSameColorAs(0xFFFBF8FF);
+ assertThat(dynamicColors.surface().getArgb(scheme)).isSameColorAs(0xFFFBF8FF);
}
@Test
public void lightTheme_standardContrast_surface() {
SchemeContent scheme = new SchemeContent(Hct.fromInt(0xFF0000ff), false, 0.0);
- assertThat(MaterialDynamicColors.surface.getArgb(scheme)).isSameColorAs(0xFFFBF8FF);
+ assertThat(dynamicColors.surface().getArgb(scheme)).isSameColorAs(0xFFFBF8FF);
}
@Test
public void lightTheme_maxContrast_surface() {
SchemeContent scheme = new SchemeContent(Hct.fromInt(0xFF0000ff), false, 1.0);
- assertThat(MaterialDynamicColors.surface.getArgb(scheme)).isSameColorAs(0xFFFBF8FF);
+ assertThat(dynamicColors.surface().getArgb(scheme)).isSameColorAs(0xFFFBF8FF);
}
@Test
public void darkTheme_minContrast_primary() {
SchemeContent scheme = new SchemeContent(Hct.fromInt(0xFF0000ff), true, -1.0);
- assertThat(MaterialDynamicColors.primary.getArgb(scheme)).isSameColorAs(0xFF5660FF);
+ assertThat(dynamicColors.primary().getArgb(scheme)).isSameColorAs(0xFF5660FF);
}
@Test
public void darkTheme_standardContrast_primary() {
SchemeContent scheme = new SchemeContent(Hct.fromInt(0xFF0000ff), true, 0.0);
- assertThat(MaterialDynamicColors.primary.getArgb(scheme)).isSameColorAs(0xFFBEC2FF);
+ assertThat(dynamicColors.primary().getArgb(scheme)).isSameColorAs(0xFFBEC2FF);
}
@Test
public void darkTheme_maxContrast_primary() {
SchemeContent scheme = new SchemeContent(Hct.fromInt(0xFF0000ff), true, 1.0);
- assertThat(MaterialDynamicColors.primary.getArgb(scheme)).isSameColorAs(0xFFF6F4FF);
+ assertThat(dynamicColors.primary().getArgb(scheme)).isSameColorAs(0xFFF6F4FF);
}
@Test
public void darkTheme_minContrast_primaryContainer() {
SchemeContent scheme = new SchemeContent(Hct.fromInt(0xFF0000ff), true, -1.0);
- assertThat(MaterialDynamicColors.primaryContainer.getArgb(scheme)).isSameColorAs(
- 0xFF0000E6);
+ assertThat(dynamicColors.primaryContainer().getArgb(scheme)).isSameColorAs(0xFF0000E6);
}
@Test
public void darkTheme_standardContrast_primaryContainer() {
SchemeContent scheme = new SchemeContent(Hct.fromInt(0xFF0000ff), true, 0.0);
- assertThat(MaterialDynamicColors.primaryContainer.getArgb(scheme)).isSameColorAs(
- 0xFF0000E6);
+ assertThat(dynamicColors.primaryContainer().getArgb(scheme)).isSameColorAs(0xFF0000E6);
}
@Test
public void darkTheme_maxContrast_primaryContainer() {
SchemeContent scheme = new SchemeContent(Hct.fromInt(0xFF0000ff), true, 1.0);
- assertThat(MaterialDynamicColors.primaryContainer.getArgb(scheme)).isSameColorAs(
- 0xFFC4C6FF);
+ assertThat(dynamicColors.primaryContainer().getArgb(scheme)).isSameColorAs(0xFFC4C6FF);
}
@Test
public void darkTheme_minContrast_onPrimaryContainer() {
SchemeContent scheme = new SchemeContent(Hct.fromInt(0xFF0000ff), true, -1.0);
- assertThat(MaterialDynamicColors.onPrimaryContainer.getArgb(scheme)).isSameColorAs(
- 0xFF7A83FF);
+ assertThat(dynamicColors.onPrimaryContainer().getArgb(scheme)).isSameColorAs(0xFF7A83FF);
}
@Test
public void darkTheme_standardContrast_onPrimaryContainer() {
SchemeContent scheme = new SchemeContent(Hct.fromInt(0xFF0000ff), true, 0.0);
- assertThat(MaterialDynamicColors.onPrimaryContainer.getArgb(scheme)).isSameColorAs(
- 0xFFA4AAFF);
+ assertThat(dynamicColors.onPrimaryContainer().getArgb(scheme)).isSameColorAs(0xFFA4AAFF);
}
@Test
public void darkTheme_maxContrast_onPrimaryContainer() {
SchemeContent scheme = new SchemeContent(Hct.fromInt(0xFF0000ff), true, 1.0);
- assertThat(MaterialDynamicColors.onPrimaryContainer.getArgb(scheme)).isSameColorAs(
- 0xFF0001C6);
+ assertThat(dynamicColors.onPrimaryContainer().getArgb(scheme)).isSameColorAs(0xFF0001C6);
}
@Test
public void darkTheme_minContrast_onTertiaryContainer() {
SchemeContent scheme = new SchemeContent(Hct.fromInt(0xFF0000ff), true, -1.0);
- assertThat(MaterialDynamicColors.onTertiaryContainer.getArgb(scheme)).isSameColorAs(
- 0xFFCF60EA);
+ assertThat(dynamicColors.onTertiaryContainer().getArgb(scheme)).isSameColorAs(0xFFCF60EA);
}
@Test
public void darkTheme_standardContrast_onTertiaryContainer() {
SchemeContent scheme = new SchemeContent(Hct.fromInt(0xFF0000ff), true, 0.0);
- assertThat(MaterialDynamicColors.onTertiaryContainer.getArgb(scheme)).isSameColorAs(
- 0xFFEB8CFF);
+ assertThat(dynamicColors.onTertiaryContainer().getArgb(scheme)).isSameColorAs(0xFFEB8CFF);
}
@Test
public void darkTheme_maxContrast_onTertiaryContainer() {
SchemeContent scheme = new SchemeContent(Hct.fromInt(0xFF0000ff), true, 1.0);
- assertThat(MaterialDynamicColors.onTertiaryContainer.getArgb(scheme)).isSameColorAs(
- 0xFF63007B);
+ assertThat(dynamicColors.onTertiaryContainer().getArgb(scheme)).isSameColorAs(0xFF63007B);
}
@Test
public void darkTheme_minContrast_surface() {
SchemeContent scheme = new SchemeContent(Hct.fromInt(0xFF0000ff), true, -1.0);
- assertThat(MaterialDynamicColors.surface.getArgb(scheme)).isSameColorAs(0xFF12121D);
+ assertThat(dynamicColors.surface().getArgb(scheme)).isSameColorAs(0xFF12121D);
}
@Test
public void darkTheme_standardContrast_surface() {
SchemeContent scheme = new SchemeContent(Hct.fromInt(0xFF0000ff), true, 0.0);
- assertThat(MaterialDynamicColors.surface.getArgb(scheme)).isSameColorAs(0xFF12121D);
+ assertThat(dynamicColors.surface().getArgb(scheme)).isSameColorAs(0xFF12121D);
}
@Test
public void darkTheme_maxContrast_surface() {
SchemeContent scheme = new SchemeContent(Hct.fromInt(0xFF0000ff), true, 1.0);
- assertThat(MaterialDynamicColors.surface.getArgb(scheme)).isSameColorAs(0xFF12121D);
+ assertThat(dynamicColors.surface().getArgb(scheme)).isSameColorAs(0xFF12121D);
}
}
diff --git a/packages/SystemUI/tests/src/com/android/systemui/monet/SchemeExpressiveTest.java b/packages/SystemUI/tests/src/com/android/systemui/monet/SchemeExpressiveTest.java
index 31e8711..32a589d 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/monet/SchemeExpressiveTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/monet/SchemeExpressiveTest.java
@@ -25,183 +25,175 @@
import com.android.systemui.monet.hct.Hct;
import com.android.systemui.monet.scheme.SchemeExpressive;
+import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
+@Ignore("b/279581953")
@SmallTest
@RunWith(JUnit4.class)
public final class SchemeExpressiveTest extends SysuiTestCase {
+ private final MaterialDynamicColors dynamicColors = new MaterialDynamicColors();
+
@Test
public void testKeyColors() {
SchemeExpressive scheme = new SchemeExpressive(Hct.fromInt(0xff0000ff), false, 0.0);
- assertThat(MaterialDynamicColors.primaryPaletteKeyColor.getArgb(scheme))
+ assertThat(dynamicColors.primaryPaletteKeyColor().getArgb(scheme))
.isSameColorAs(0xff35855F);
- assertThat(MaterialDynamicColors.secondaryPaletteKeyColor.getArgb(scheme))
+ assertThat(dynamicColors.secondaryPaletteKeyColor().getArgb(scheme))
.isSameColorAs(0xff8C6D8C);
- assertThat(MaterialDynamicColors.tertiaryPaletteKeyColor.getArgb(scheme))
+ assertThat(dynamicColors.tertiaryPaletteKeyColor().getArgb(scheme))
.isSameColorAs(0xff806EA1);
- assertThat(MaterialDynamicColors.neutralPaletteKeyColor.getArgb(scheme))
+ assertThat(dynamicColors.neutralPaletteKeyColor().getArgb(scheme))
.isSameColorAs(0xff79757F);
- assertThat(MaterialDynamicColors.neutralVariantPaletteKeyColor.getArgb(scheme))
+ assertThat(dynamicColors.neutralVariantPaletteKeyColor().getArgb(scheme))
.isSameColorAs(0xff7A7585);
}
@Test
public void lightTheme_minContrast_primary() {
SchemeExpressive scheme = new SchemeExpressive(Hct.fromInt(0xff0000ff), false, -1.0);
- assertThat(MaterialDynamicColors.primary.getArgb(scheme)).isSameColorAs(0xff32835D);
+ assertThat(dynamicColors.primary().getArgb(scheme)).isSameColorAs(0xffad603c);
}
@Test
public void lightTheme_standardContrast_primary() {
SchemeExpressive scheme = new SchemeExpressive(Hct.fromInt(0xff0000ff), false, 0.0);
- assertThat(MaterialDynamicColors.primary.getArgb(scheme)).isSameColorAs(0xff146C48);
+ assertThat(dynamicColors.primary().getArgb(scheme)).isSameColorAs(0xff924b28);
}
@Test
public void lightTheme_maxContrast_primary() {
SchemeExpressive scheme = new SchemeExpressive(Hct.fromInt(0xff0000ff), false, 1.0);
- assertThat(MaterialDynamicColors.primary.getArgb(scheme)).isSameColorAs(0xff002818);
+ assertThat(dynamicColors.primary().getArgb(scheme)).isSameColorAs(0xff401400);
}
@Test
public void lightTheme_minContrast_primaryContainer() {
SchemeExpressive scheme = new SchemeExpressive(Hct.fromInt(0xff0000ff), false, -1.0);
- assertThat(MaterialDynamicColors.primaryContainer.getArgb(scheme)).isSameColorAs(
- 0xffA2F4C6);
+ assertThat(dynamicColors.primaryContainer().getArgb(scheme)).isSameColorAs(0xffffdbcc);
}
@Test
public void lightTheme_standardContrast_primaryContainer() {
SchemeExpressive scheme = new SchemeExpressive(Hct.fromInt(0xff0000ff), false, 0.0);
- assertThat(MaterialDynamicColors.primaryContainer.getArgb(scheme)).isSameColorAs(
- 0xffA2F4C6);
+ assertThat(dynamicColors.primaryContainer().getArgb(scheme)).isSameColorAs(0xffffdbcc);
}
@Test
public void lightTheme_maxContrast_primaryContainer() {
SchemeExpressive scheme = new SchemeExpressive(Hct.fromInt(0xff0000ff), false, 1.0);
- assertThat(MaterialDynamicColors.primaryContainer.getArgb(scheme)).isSameColorAs(
- 0xff004D31);
+ assertThat(dynamicColors.primaryContainer().getArgb(scheme)).isSameColorAs(0xff6f3010);
}
@Test
public void lightTheme_minContrast_onPrimaryContainer() {
SchemeExpressive scheme = new SchemeExpressive(Hct.fromInt(0xff0000ff), false, -1.0);
- assertThat(MaterialDynamicColors.onPrimaryContainer.getArgb(scheme)).isSameColorAs(
- 0xff1e724e);
+ assertThat(dynamicColors.onPrimaryContainer().getArgb(scheme)).isSameColorAs(0xff99512e);
}
@Test
public void lightTheme_standardContrast_onPrimaryContainer() {
SchemeExpressive scheme = new SchemeExpressive(Hct.fromInt(0xff0000ff), false, 0.0);
- assertThat(MaterialDynamicColors.onPrimaryContainer.getArgb(scheme)).isSameColorAs(
- 0xff002112);
+ assertThat(dynamicColors.onPrimaryContainer().getArgb(scheme)).isSameColorAs(0xff351000);
}
@Test
public void lightTheme_maxContrast_onPrimaryContainer() {
SchemeExpressive scheme = new SchemeExpressive(Hct.fromInt(0xff0000ff), false, 1.0);
- assertThat(MaterialDynamicColors.onPrimaryContainer.getArgb(scheme)).isSameColorAs(
- 0xff9aebbe);
+ assertThat(dynamicColors.onPrimaryContainer().getArgb(scheme)).isSameColorAs(0xffffd0bc);
}
@Test
public void lightTheme_minContrast_surface() {
SchemeExpressive scheme = new SchemeExpressive(Hct.fromInt(0xff0000ff), false, -1.0);
- assertThat(MaterialDynamicColors.surface.getArgb(scheme)).isSameColorAs(0xfffdf7ff);
+ assertThat(dynamicColors.surface().getArgb(scheme)).isSameColorAs(0xfffbf8ff);
}
@Test
public void lightTheme_standardContrast_surface() {
SchemeExpressive scheme = new SchemeExpressive(Hct.fromInt(0xff0000ff), false, 0.0);
- assertThat(MaterialDynamicColors.surface.getArgb(scheme)).isSameColorAs(0xfffdf7ff);
+ assertThat(dynamicColors.surface().getArgb(scheme)).isSameColorAs(0xfffbf8ff);
}
@Test
public void lightTheme_maxContrast_surface() {
SchemeExpressive scheme = new SchemeExpressive(Hct.fromInt(0xff0000ff), false, 1.0);
- assertThat(MaterialDynamicColors.surface.getArgb(scheme)).isSameColorAs(0xfffdf7ff);
+ assertThat(dynamicColors.surface().getArgb(scheme)).isSameColorAs(0xfffbf8ff);
}
@Test
public void darkTheme_minContrast_primary() {
SchemeExpressive scheme = new SchemeExpressive(Hct.fromInt(0xff0000ff), true, -1.0);
- assertThat(MaterialDynamicColors.primary.getArgb(scheme)).isSameColorAs(0xff32835d);
+ assertThat(dynamicColors.primary().getArgb(scheme)).isSameColorAs(0xffad603c);
}
@Test
public void darkTheme_standardContrast_primary() {
SchemeExpressive scheme = new SchemeExpressive(Hct.fromInt(0xff0000ff), true, 0.0);
- assertThat(MaterialDynamicColors.primary.getArgb(scheme)).isSameColorAs(0xff87d7ab);
+ assertThat(dynamicColors.primary().getArgb(scheme)).isSameColorAs(0xffffb595);
}
@Test
public void darkTheme_maxContrast_primary() {
SchemeExpressive scheme = new SchemeExpressive(Hct.fromInt(0xff0000ff), true, 1.0);
- assertThat(MaterialDynamicColors.primary.getArgb(scheme)).isSameColorAs(0xffd5ffe4);
+ assertThat(dynamicColors.primary().getArgb(scheme)).isSameColorAs(0xfffff3ee);
}
@Test
public void darkTheme_minContrast_primaryContainer() {
SchemeExpressive scheme = new SchemeExpressive(Hct.fromInt(0xff0000ff), true, -1.0);
- assertThat(MaterialDynamicColors.primaryContainer.getArgb(scheme)).isSameColorAs(
- 0xff005234);
+ assertThat(dynamicColors.primaryContainer().getArgb(scheme)).isSameColorAs(0xff743413);
}
@Test
public void darkTheme_standardContrast_primaryContainer() {
SchemeExpressive scheme = new SchemeExpressive(Hct.fromInt(0xff0000ff), true, 0.0);
- assertThat(MaterialDynamicColors.primaryContainer.getArgb(scheme)).isSameColorAs(
- 0xff005234);
+ assertThat(dynamicColors.primaryContainer().getArgb(scheme)).isSameColorAs(0xff743413);
}
@Test
public void darkTheme_maxContrast_primaryContainer() {
SchemeExpressive scheme = new SchemeExpressive(Hct.fromInt(0xff0000ff), true, 1.0);
- assertThat(MaterialDynamicColors.primaryContainer.getArgb(scheme)).isSameColorAs(
- 0xff8bdbaf);
+ assertThat(dynamicColors.primaryContainer().getArgb(scheme)).isSameColorAs(0xffffbb9e);
}
@Test
public void darkTheme_minContrast_onPrimaryContainer() {
SchemeExpressive scheme = new SchemeExpressive(Hct.fromInt(0xff0000ff), true, -1.0);
- assertThat(MaterialDynamicColors.onPrimaryContainer.getArgb(scheme)).isSameColorAs(
- 0xff76c59b);
+ assertThat(dynamicColors.onPrimaryContainer().getArgb(scheme)).isSameColorAs(0xfff99f75);
}
@Test
public void darkTheme_standardContrast_onPrimaryContainer() {
SchemeExpressive scheme = new SchemeExpressive(Hct.fromInt(0xff0000ff), true, 0.0);
- assertThat(MaterialDynamicColors.onPrimaryContainer.getArgb(scheme)).isSameColorAs(
- 0xffa2f4c6);
+ assertThat(dynamicColors.onPrimaryContainer().getArgb(scheme)).isSameColorAs(0xffffdbcc);
}
@Test
public void darkTheme_maxContrast_onPrimaryContainer() {
SchemeExpressive scheme = new SchemeExpressive(Hct.fromInt(0xff0000ff), true, 1.0);
- assertThat(MaterialDynamicColors.onPrimaryContainer.getArgb(scheme)).isSameColorAs(
- 0xff004229);
+ assertThat(dynamicColors.onPrimaryContainer().getArgb(scheme)).isSameColorAs(0xff622706);
}
@Test
public void darkTheme_minContrast_surface() {
SchemeExpressive scheme = new SchemeExpressive(Hct.fromInt(0xff0000ff), true, -1.0);
- assertThat(MaterialDynamicColors.surface.getArgb(scheme)).isSameColorAs(0xff14121a);
+ assertThat(dynamicColors.surface().getArgb(scheme)).isSameColorAs(0xff12131a);
}
@Test
public void darkTheme_standardContrast_surface() {
SchemeExpressive scheme = new SchemeExpressive(Hct.fromInt(0xff0000ff), true, 0.0);
- assertThat(MaterialDynamicColors.surface.getArgb(scheme)).isSameColorAs(0xff14121a);
+ assertThat(dynamicColors.surface().getArgb(scheme)).isSameColorAs(0xff12131a);
}
@Test
public void darkTheme_maxContrast_surface() {
SchemeExpressive scheme = new SchemeExpressive(Hct.fromInt(0xff0000ff), true, 1.0);
- assertThat(MaterialDynamicColors.surface.getArgb(scheme)).isSameColorAs(0xff14121a);
+ assertThat(dynamicColors.surface().getArgb(scheme)).isSameColorAs(0xff12131a);
}
}
diff --git a/packages/SystemUI/tests/src/com/android/systemui/monet/SchemeFidelityTest.java b/packages/SystemUI/tests/src/com/android/systemui/monet/SchemeFidelityTest.java
index 511f83b..6844a92 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/monet/SchemeFidelityTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/monet/SchemeFidelityTest.java
@@ -25,245 +25,230 @@
import com.android.systemui.monet.hct.Hct;
import com.android.systemui.monet.scheme.SchemeFidelity;
+import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
+@Ignore("b/279581953")
@SmallTest
@RunWith(JUnit4.class)
public final class SchemeFidelityTest extends SysuiTestCase {
+
+ private final MaterialDynamicColors dynamicColors = new MaterialDynamicColors();
+
@Test
public void testKeyColors() {
SchemeFidelity scheme = new SchemeFidelity(Hct.fromInt(0xff0000ff), false, 0.0);
- assertThat(MaterialDynamicColors.primaryPaletteKeyColor.getArgb(scheme))
+ assertThat(dynamicColors.primaryPaletteKeyColor().getArgb(scheme))
.isSameColorAs(0xff080CFF);
- assertThat(MaterialDynamicColors.secondaryPaletteKeyColor.getArgb(scheme))
+ assertThat(dynamicColors.secondaryPaletteKeyColor().getArgb(scheme))
.isSameColorAs(0xff656DD3);
- assertThat(MaterialDynamicColors.tertiaryPaletteKeyColor.getArgb(scheme))
+ assertThat(dynamicColors.tertiaryPaletteKeyColor().getArgb(scheme))
.isSameColorAs(0xff9D0002);
- assertThat(MaterialDynamicColors.neutralPaletteKeyColor.getArgb(scheme))
+ assertThat(dynamicColors.neutralPaletteKeyColor().getArgb(scheme))
.isSameColorAs(0xff767684);
- assertThat(MaterialDynamicColors.neutralVariantPaletteKeyColor.getArgb(scheme))
+ assertThat(dynamicColors.neutralVariantPaletteKeyColor().getArgb(scheme))
.isSameColorAs(0xff757589);
}
@Test
public void lightTheme_minContrast_primary() {
SchemeFidelity scheme = new SchemeFidelity(Hct.fromInt(0xff0000ff), false, -1.0);
- assertThat(MaterialDynamicColors.primary.getArgb(scheme)).isSameColorAs(0xff1218ff);
+ assertThat(dynamicColors.primary().getArgb(scheme)).isSameColorAs(0xff1218ff);
}
@Test
public void lightTheme_standardContrast_primary() {
SchemeFidelity scheme = new SchemeFidelity(Hct.fromInt(0xff0000ff), false, 0.0);
- assertThat(MaterialDynamicColors.primary.getArgb(scheme)).isSameColorAs(0xff0001c3);
+ assertThat(dynamicColors.primary().getArgb(scheme)).isSameColorAs(0xff0001c3);
}
@Test
public void lightTheme_maxContrast_primary() {
SchemeFidelity scheme = new SchemeFidelity(Hct.fromInt(0xff0000ff), false, 1.0);
- assertThat(MaterialDynamicColors.primary.getArgb(scheme)).isSameColorAs(0xff000181);
+ assertThat(dynamicColors.primary().getArgb(scheme)).isSameColorAs(0xff000181);
}
@Test
public void lightTheme_minContrast_primaryContainer() {
SchemeFidelity scheme = new SchemeFidelity(Hct.fromInt(0xff0000ff), false, -1.0);
- assertThat(MaterialDynamicColors.primaryContainer.getArgb(scheme)).isSameColorAs(
- 0xff5660ff);
+ assertThat(dynamicColors.primaryContainer().getArgb(scheme)).isSameColorAs(0xff5660ff);
}
@Test
public void lightTheme_standardContrast_primaryContainer() {
SchemeFidelity scheme = new SchemeFidelity(Hct.fromInt(0xff0000ff), false, 0.0);
- assertThat(MaterialDynamicColors.primaryContainer.getArgb(scheme)).isSameColorAs(
- 0xff2d36ff);
+ assertThat(dynamicColors.primaryContainer().getArgb(scheme)).isSameColorAs(0xff2d36ff);
}
@Test
public void lightTheme_maxContrast_primaryContainer() {
SchemeFidelity scheme = new SchemeFidelity(Hct.fromInt(0xff0000ff), false, 1.0);
- assertThat(MaterialDynamicColors.primaryContainer.getArgb(scheme)).isSameColorAs(
- 0xff0000e3);
+ assertThat(dynamicColors.primaryContainer().getArgb(scheme)).isSameColorAs(0xff0000e3);
}
@Test
public void lightTheme_minContrast_tertiaryContainer() {
SchemeFidelity scheme = new SchemeFidelity(Hct.fromInt(0xff0000ff), false, -1.0);
- assertThat(MaterialDynamicColors.tertiaryContainer.getArgb(scheme)).isSameColorAs(
- 0xffd93628);
+ assertThat(dynamicColors.tertiaryContainer().getArgb(scheme)).isSameColorAs(0xffd93628);
}
@Test
public void lightTheme_standardContrast_tertiaryContainer() {
SchemeFidelity scheme = new SchemeFidelity(Hct.fromInt(0xff0000ff), false, 0.0);
- assertThat(MaterialDynamicColors.tertiaryContainer.getArgb(scheme)).isSameColorAs(
- 0xffb31910);
+ assertThat(dynamicColors.tertiaryContainer().getArgb(scheme)).isSameColorAs(0xffb31910);
}
@Test
public void lightTheme_maxContrast_tertiaryContainer() {
SchemeFidelity scheme = new SchemeFidelity(Hct.fromInt(0xff0000ff), false, 1.0);
- assertThat(MaterialDynamicColors.tertiaryContainer.getArgb(scheme)).isSameColorAs(
- 0xff8c0002);
+ assertThat(dynamicColors.tertiaryContainer().getArgb(scheme)).isSameColorAs(0xff8c0002);
}
@Test
public void lightTheme_minContrast_objectionableTertiaryContainerLightens() {
SchemeFidelity scheme = new SchemeFidelity(Hct.fromInt(0xff850096), false, -1.0);
- assertThat(MaterialDynamicColors.tertiaryContainer.getArgb(scheme)).isSameColorAs(
- 0xffbcac5a);
+ assertThat(dynamicColors.tertiaryContainer().getArgb(scheme)).isSameColorAs(0xffbcac5a);
}
@Test
public void lightTheme_standardContrast_objectionableTertiaryContainerLightens() {
SchemeFidelity scheme = new SchemeFidelity(Hct.fromInt(0xff850096), false, 0.0);
- assertThat(MaterialDynamicColors.tertiaryContainer.getArgb(scheme)).isSameColorAs(
- 0xffbcac5a);
+ assertThat(dynamicColors.tertiaryContainer().getArgb(scheme)).isSameColorAs(0xffbcac5a);
}
@Test
public void lightTheme_maxContrast_objectionableTertiaryContainerDarkens() {
SchemeFidelity scheme = new SchemeFidelity(Hct.fromInt(0xff850096), false, 1.0);
- assertThat(MaterialDynamicColors.tertiaryContainer.getArgb(scheme)).isSameColorAs(
- 0xff4d4300);
+ assertThat(dynamicColors.tertiaryContainer().getArgb(scheme)).isSameColorAs(0xff4d4300);
}
@Test
public void lightTheme_minContrast_onPrimaryContainer() {
SchemeFidelity scheme = new SchemeFidelity(Hct.fromInt(0xff0000ff), false, -1.0);
- assertThat(MaterialDynamicColors.onPrimaryContainer.getArgb(scheme)).isSameColorAs(
- 0xffcbcdff);
+ assertThat(dynamicColors.onPrimaryContainer().getArgb(scheme)).isSameColorAs(0xffcbcdff);
}
@Test
public void lightTheme_standardContrast_onPrimaryContainer() {
SchemeFidelity scheme = new SchemeFidelity(Hct.fromInt(0xff0000ff), false, 0.0);
- assertThat(MaterialDynamicColors.onPrimaryContainer.getArgb(scheme)).isSameColorAs(
- 0xffcecfff);
+ assertThat(dynamicColors.onPrimaryContainer().getArgb(scheme)).isSameColorAs(0xffcecfff);
}
@Test
public void lightTheme_maxContrast_onPrimaryContainer() {
SchemeFidelity scheme = new SchemeFidelity(Hct.fromInt(0xff0000ff), false, 1.0);
- assertThat(MaterialDynamicColors.onPrimaryContainer.getArgb(scheme)).isSameColorAs(
- 0xffd6d6ff);
+ assertThat(dynamicColors.onPrimaryContainer().getArgb(scheme)).isSameColorAs(0xffd6d6ff);
}
@Test
public void lightTheme_minContrast_surface() {
SchemeFidelity scheme = new SchemeFidelity(Hct.fromInt(0xff0000ff), false, -1.0);
- assertThat(MaterialDynamicColors.surface.getArgb(scheme)).isSameColorAs(0xfffbf8ff);
+ assertThat(dynamicColors.surface().getArgb(scheme)).isSameColorAs(0xfffbf8ff);
}
@Test
public void lightTheme_standardContrast_surface() {
SchemeFidelity scheme = new SchemeFidelity(Hct.fromInt(0xff0000ff), false, 0.0);
- assertThat(MaterialDynamicColors.surface.getArgb(scheme)).isSameColorAs(0xfffbf8ff);
+ assertThat(dynamicColors.surface().getArgb(scheme)).isSameColorAs(0xfffbf8ff);
}
@Test
public void lightTheme_maxContrast_surface() {
SchemeFidelity scheme = new SchemeFidelity(Hct.fromInt(0xff0000ff), false, 1.0);
- assertThat(MaterialDynamicColors.surface.getArgb(scheme)).isSameColorAs(0xfffbf8ff);
+ assertThat(dynamicColors.surface().getArgb(scheme)).isSameColorAs(0xfffbf8ff);
}
@Test
public void darkTheme_minContrast_primary() {
SchemeFidelity scheme = new SchemeFidelity(Hct.fromInt(0xff0000ff), true, -1.0);
- assertThat(MaterialDynamicColors.primary.getArgb(scheme)).isSameColorAs(0xff5660ff);
+ assertThat(dynamicColors.primary().getArgb(scheme)).isSameColorAs(0xff5660ff);
}
@Test
public void darkTheme_standardContrast_primary() {
SchemeFidelity scheme = new SchemeFidelity(Hct.fromInt(0xff0000ff), true, 0.0);
- assertThat(MaterialDynamicColors.primary.getArgb(scheme)).isSameColorAs(0xffbec2ff);
+ assertThat(dynamicColors.primary().getArgb(scheme)).isSameColorAs(0xffbec2ff);
}
@Test
public void darkTheme_maxContrast_primary() {
SchemeFidelity scheme = new SchemeFidelity(Hct.fromInt(0xff0000ff), true, 1.0);
- assertThat(MaterialDynamicColors.primary.getArgb(scheme)).isSameColorAs(0xfff6f4ff);
+ assertThat(dynamicColors.primary().getArgb(scheme)).isSameColorAs(0xfff6f4ff);
}
@Test
public void darkTheme_minContrast_primaryContainer() {
SchemeFidelity scheme = new SchemeFidelity(Hct.fromInt(0xff0000ff), true, -1.0);
- assertThat(MaterialDynamicColors.primaryContainer.getArgb(scheme)).isSameColorAs(
- 0xff0000e6);
+ assertThat(dynamicColors.primaryContainer().getArgb(scheme)).isSameColorAs(0xff0000e6);
}
@Test
public void darkTheme_standardContrast_primaryContainer() {
SchemeFidelity scheme = new SchemeFidelity(Hct.fromInt(0xff0000ff), true, 0.0);
- assertThat(MaterialDynamicColors.primaryContainer.getArgb(scheme)).isSameColorAs(
- 0xff0000e6);
+ assertThat(dynamicColors.primaryContainer().getArgb(scheme)).isSameColorAs(0xff0000e6);
}
@Test
public void darkTheme_maxContrast_primaryContainer() {
SchemeFidelity scheme = new SchemeFidelity(Hct.fromInt(0xff0000ff), true, 1.0);
- assertThat(MaterialDynamicColors.primaryContainer.getArgb(scheme)).isSameColorAs(
- 0xffc4c6ff);
+ assertThat(dynamicColors.primaryContainer().getArgb(scheme)).isSameColorAs(0xffc4c6ff);
}
@Test
public void darkTheme_minContrast_onPrimaryContainer() {
SchemeFidelity scheme = new SchemeFidelity(Hct.fromInt(0xff0000ff), true, -1.0);
- assertThat(MaterialDynamicColors.onPrimaryContainer.getArgb(scheme)).isSameColorAs(
- 0xff7a83ff);
+ assertThat(dynamicColors.onPrimaryContainer().getArgb(scheme)).isSameColorAs(0xff7a83ff);
}
@Test
public void darkTheme_standardContrast_onPrimaryContainer() {
SchemeFidelity scheme = new SchemeFidelity(Hct.fromInt(0xff0000ff), true, 0.0);
- assertThat(MaterialDynamicColors.onPrimaryContainer.getArgb(scheme)).isSameColorAs(
- 0xffa4aaff);
+ assertThat(dynamicColors.onPrimaryContainer().getArgb(scheme)).isSameColorAs(0xffa4aaff);
}
@Test
public void darkTheme_maxContrast_onPrimaryContainer() {
SchemeFidelity scheme = new SchemeFidelity(Hct.fromInt(0xff0000ff), true, 1.0);
- assertThat(MaterialDynamicColors.onPrimaryContainer.getArgb(scheme)).isSameColorAs(
- 0xff0001c6);
+ assertThat(dynamicColors.onPrimaryContainer().getArgb(scheme)).isSameColorAs(0xff0001c6);
}
@Test
public void darkTheme_minContrast_onTertiaryContainer() {
SchemeFidelity scheme = new SchemeFidelity(Hct.fromInt(0xff0000ff), true, -1.0);
- assertThat(MaterialDynamicColors.onTertiaryContainer.getArgb(scheme)).isSameColorAs(
- 0xfffe513e);
+ assertThat(dynamicColors.onTertiaryContainer().getArgb(scheme)).isSameColorAs(0xfffe513e);
}
@Test
public void darkTheme_standardContrast_onTertiaryContainer() {
SchemeFidelity scheme = new SchemeFidelity(Hct.fromInt(0xff0000ff), true, 0.0);
- assertThat(MaterialDynamicColors.onTertiaryContainer.getArgb(scheme)).isSameColorAs(
- 0xffFF9181);
+ assertThat(dynamicColors.onTertiaryContainer().getArgb(scheme)).isSameColorAs(0xffFF9181);
}
@Test
public void darkTheme_maxContrast_onTertiaryContainer() {
SchemeFidelity scheme = new SchemeFidelity(Hct.fromInt(0xff0000ff), true, 1.0);
- assertThat(MaterialDynamicColors.onTertiaryContainer.getArgb(scheme)).isSameColorAs(
- 0xff790001);
+ assertThat(dynamicColors.onTertiaryContainer().getArgb(scheme)).isSameColorAs(0xff790001);
}
@Test
public void darkTheme_minContrast_surface() {
SchemeFidelity scheme = new SchemeFidelity(Hct.fromInt(0xff0000ff), true, -1.0);
- assertThat(MaterialDynamicColors.surface.getArgb(scheme)).isSameColorAs(0xff12121d);
+ assertThat(dynamicColors.surface().getArgb(scheme)).isSameColorAs(0xff12121d);
}
@Test
public void darkTheme_standardContrast_surface() {
SchemeFidelity scheme = new SchemeFidelity(Hct.fromInt(0xff0000ff), true, 0.0);
- assertThat(MaterialDynamicColors.surface.getArgb(scheme)).isSameColorAs(0xff12121d);
+ assertThat(dynamicColors.surface().getArgb(scheme)).isSameColorAs(0xff12121d);
}
@Test
public void darkTheme_maxContrast_surface() {
SchemeFidelity scheme = new SchemeFidelity(Hct.fromInt(0xff0000ff), true, 1.0);
- assertThat(MaterialDynamicColors.surface.getArgb(scheme)).isSameColorAs(0xff12121d);
+ assertThat(dynamicColors.surface().getArgb(scheme)).isSameColorAs(0xff12121d);
}
+
}
diff --git a/packages/SystemUI/tests/src/com/android/systemui/monet/SchemeFruitSaladTest.java b/packages/SystemUI/tests/src/com/android/systemui/monet/SchemeFruitSaladTest.java
index 4cf14d5..4bca2c4 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/monet/SchemeFruitSaladTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/monet/SchemeFruitSaladTest.java
@@ -25,226 +25,230 @@
import com.android.systemui.monet.hct.Hct;
import com.android.systemui.monet.scheme.SchemeFruitSalad;
+import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
+@Ignore("b/279581953")
@SmallTest
@RunWith(JUnit4.class)
public final class SchemeFruitSaladTest extends SysuiTestCase {
+ private final MaterialDynamicColors dynamicColors = new MaterialDynamicColors();
+
@Test
public void testKeyColors() {
SchemeFruitSalad scheme = new SchemeFruitSalad(Hct.fromInt(0xff0000ff), false, 0.0);
- assertThat(MaterialDynamicColors.primaryPaletteKeyColor.getArgb(scheme))
+ assertThat(dynamicColors.primaryPaletteKeyColor().getArgb(scheme))
.isSameColorAs(0xff0091C0);
- assertThat(MaterialDynamicColors.secondaryPaletteKeyColor.getArgb(scheme))
+ assertThat(dynamicColors.secondaryPaletteKeyColor().getArgb(scheme))
.isSameColorAs(0xff3A7E9E);
- assertThat(MaterialDynamicColors.tertiaryPaletteKeyColor.getArgb(scheme))
+ assertThat(dynamicColors.tertiaryPaletteKeyColor().getArgb(scheme))
.isSameColorAs(0xff6E72AC);
- assertThat(MaterialDynamicColors.neutralPaletteKeyColor.getArgb(scheme))
+ assertThat(dynamicColors.neutralPaletteKeyColor().getArgb(scheme))
.isSameColorAs(0xff777682);
- assertThat(MaterialDynamicColors.neutralVariantPaletteKeyColor.getArgb(scheme))
+ assertThat(dynamicColors.neutralVariantPaletteKeyColor().getArgb(scheme))
.isSameColorAs(0xff75758B);
}
@Test
public void lightTheme_minContrast_primary() {
SchemeFruitSalad scheme = new SchemeFruitSalad(Hct.fromInt(0xff0000ff), false, -1.0);
- assertThat(MaterialDynamicColors.primary.getArgb(scheme)).isSameColorAs(0xff007ea7);
+ assertThat(dynamicColors.primary().getArgb(scheme)).isSameColorAs(0xff007ea7);
}
@Test
public void lightTheme_standardContrast_primary() {
SchemeFruitSalad scheme = new SchemeFruitSalad(Hct.fromInt(0xff0000ff), false, 0.0);
- assertThat(MaterialDynamicColors.primary.getArgb(scheme)).isSameColorAs(0xff006688);
+ assertThat(dynamicColors.primary().getArgb(scheme)).isSameColorAs(0xff006688);
}
@Test
public void lightTheme_maxContrast_primary() {
SchemeFruitSalad scheme = new SchemeFruitSalad(Hct.fromInt(0xff0000ff), false, 1.0);
- assertThat(MaterialDynamicColors.primary.getArgb(scheme)).isSameColorAs(0xff002635);
+ assertThat(dynamicColors.primary().getArgb(scheme)).isSameColorAs(0xff002635);
}
@Test
public void lightTheme_minContrast_primaryContainer() {
SchemeFruitSalad scheme = new SchemeFruitSalad(Hct.fromInt(0xff0000ff), false, -1.0);
- assertThat(MaterialDynamicColors.primaryContainer.getArgb(scheme)).isSameColorAs(
+ assertThat(dynamicColors.primaryContainer().getArgb(scheme)).isSameColorAs(
0xffC2E8FF);
}
@Test
public void lightTheme_standardContrast_primaryContainer() {
SchemeFruitSalad scheme = new SchemeFruitSalad(Hct.fromInt(0xff0000ff), false, 0.0);
- assertThat(MaterialDynamicColors.primaryContainer.getArgb(scheme)).isSameColorAs(
+ assertThat(dynamicColors.primaryContainer().getArgb(scheme)).isSameColorAs(
0xffC2E8FF);
}
@Test
public void lightTheme_maxContrast_primaryContainer() {
SchemeFruitSalad scheme = new SchemeFruitSalad(Hct.fromInt(0xff0000ff), false, 1.0);
- assertThat(MaterialDynamicColors.primaryContainer.getArgb(scheme)).isSameColorAs(
+ assertThat(dynamicColors.primaryContainer().getArgb(scheme)).isSameColorAs(
0xff004862);
}
@Test
public void lightTheme_minContrast_tertiaryContainer() {
SchemeFruitSalad scheme = new SchemeFruitSalad(Hct.fromInt(0xff0000ff), false, -1.0);
- assertThat(MaterialDynamicColors.tertiaryContainer.getArgb(scheme)).isSameColorAs(
+ assertThat(dynamicColors.tertiaryContainer().getArgb(scheme)).isSameColorAs(
0xffE0E0FF);
}
@Test
public void lightTheme_standardContrast_tertiaryContainer() {
SchemeFruitSalad scheme = new SchemeFruitSalad(Hct.fromInt(0xff0000ff), false, 0.0);
- assertThat(MaterialDynamicColors.tertiaryContainer.getArgb(scheme)).isSameColorAs(
+ assertThat(dynamicColors.tertiaryContainer().getArgb(scheme)).isSameColorAs(
0xffE0E0FF);
}
@Test
public void lightTheme_maxContrast_tertiaryContainer() {
SchemeFruitSalad scheme = new SchemeFruitSalad(Hct.fromInt(0xff0000ff), false, 1.0);
- assertThat(MaterialDynamicColors.tertiaryContainer.getArgb(scheme)).isSameColorAs(
+ assertThat(dynamicColors.tertiaryContainer().getArgb(scheme)).isSameColorAs(
0xFF3A3E74);
}
@Test
public void lightTheme_minContrast_onPrimaryContainer() {
SchemeFruitSalad scheme = new SchemeFruitSalad(Hct.fromInt(0xff0000ff), false, -1.0);
- assertThat(MaterialDynamicColors.onPrimaryContainer.getArgb(scheme)).isSameColorAs(
+ assertThat(dynamicColors.onPrimaryContainer().getArgb(scheme)).isSameColorAs(
0xff006C90);
}
@Test
public void lightTheme_standardContrast_onPrimaryContainer() {
SchemeFruitSalad scheme = new SchemeFruitSalad(Hct.fromInt(0xff0000ff), false, 0.0);
- assertThat(MaterialDynamicColors.onPrimaryContainer.getArgb(scheme)).isSameColorAs(
+ assertThat(dynamicColors.onPrimaryContainer().getArgb(scheme)).isSameColorAs(
0xff001E2B);
}
@Test
public void lightTheme_maxContrast_onPrimaryContainer() {
SchemeFruitSalad scheme = new SchemeFruitSalad(Hct.fromInt(0xff0000ff), false, 1.0);
- assertThat(MaterialDynamicColors.onPrimaryContainer.getArgb(scheme)).isSameColorAs(
+ assertThat(dynamicColors.onPrimaryContainer().getArgb(scheme)).isSameColorAs(
0xffACE1FF);
}
@Test
public void lightTheme_minContrast_surface() {
SchemeFruitSalad scheme = new SchemeFruitSalad(Hct.fromInt(0xff0000ff), false, -1.0);
- assertThat(MaterialDynamicColors.surface.getArgb(scheme)).isSameColorAs(0xfffbf8ff);
+ assertThat(dynamicColors.surface().getArgb(scheme)).isSameColorAs(0xfffbf8ff);
}
@Test
public void lightTheme_standardContrast_surface() {
SchemeFruitSalad scheme = new SchemeFruitSalad(Hct.fromInt(0xff0000ff), false, 0.0);
- assertThat(MaterialDynamicColors.surface.getArgb(scheme)).isSameColorAs(0xfffbf8ff);
+ assertThat(dynamicColors.surface().getArgb(scheme)).isSameColorAs(0xfffbf8ff);
}
@Test
public void lightTheme_maxContrast_surface() {
SchemeFruitSalad scheme = new SchemeFruitSalad(Hct.fromInt(0xff0000ff), false, 1.0);
- assertThat(MaterialDynamicColors.surface.getArgb(scheme)).isSameColorAs(0xfffbf8ff);
+ assertThat(dynamicColors.surface().getArgb(scheme)).isSameColorAs(0xfffbf8ff);
}
@Test
public void darkTheme_minContrast_primary() {
SchemeFruitSalad scheme = new SchemeFruitSalad(Hct.fromInt(0xff0000ff), true, -1.0);
- assertThat(MaterialDynamicColors.primary.getArgb(scheme)).isSameColorAs(0xff007EA7);
+ assertThat(dynamicColors.primary().getArgb(scheme)).isSameColorAs(0xff007EA7);
}
@Test
public void darkTheme_standardContrast_primary() {
SchemeFruitSalad scheme = new SchemeFruitSalad(Hct.fromInt(0xff0000ff), true, 0.0);
- assertThat(MaterialDynamicColors.primary.getArgb(scheme)).isSameColorAs(0xFF76D1FF);
+ assertThat(dynamicColors.primary().getArgb(scheme)).isSameColorAs(0xFF76D1FF);
}
@Test
public void darkTheme_maxContrast_primary() {
SchemeFruitSalad scheme = new SchemeFruitSalad(Hct.fromInt(0xff0000ff), true, 1.0);
- assertThat(MaterialDynamicColors.primary.getArgb(scheme)).isSameColorAs(0xFFECF7FF);
+ assertThat(dynamicColors.primary().getArgb(scheme)).isSameColorAs(0xFFECF7FF);
}
@Test
public void darkTheme_minContrast_primaryContainer() {
SchemeFruitSalad scheme = new SchemeFruitSalad(Hct.fromInt(0xff0000ff), true, -1.0);
- assertThat(MaterialDynamicColors.primaryContainer.getArgb(scheme)).isSameColorAs(
+ assertThat(dynamicColors.primaryContainer().getArgb(scheme)).isSameColorAs(
0xFF004D67);
}
@Test
public void darkTheme_standardContrast_primaryContainer() {
SchemeFruitSalad scheme = new SchemeFruitSalad(Hct.fromInt(0xff0000ff), true, 0.0);
- assertThat(MaterialDynamicColors.primaryContainer.getArgb(scheme)).isSameColorAs(
+ assertThat(dynamicColors.primaryContainer().getArgb(scheme)).isSameColorAs(
0xFF004D67);
}
@Test
public void darkTheme_maxContrast_primaryContainer() {
SchemeFruitSalad scheme = new SchemeFruitSalad(Hct.fromInt(0xff0000ff), true, 1.0);
- assertThat(MaterialDynamicColors.primaryContainer.getArgb(scheme)).isSameColorAs(
+ assertThat(dynamicColors.primaryContainer().getArgb(scheme)).isSameColorAs(
0xFF83D5FF);
}
@Test
public void darkTheme_minContrast_onPrimaryContainer() {
SchemeFruitSalad scheme = new SchemeFruitSalad(Hct.fromInt(0xff0000ff), true, -1.0);
- assertThat(MaterialDynamicColors.onPrimaryContainer.getArgb(scheme)).isSameColorAs(
+ assertThat(dynamicColors.onPrimaryContainer().getArgb(scheme)).isSameColorAs(
0xff55C0F2);
}
@Test
public void darkTheme_standardContrast_onPrimaryContainer() {
SchemeFruitSalad scheme = new SchemeFruitSalad(Hct.fromInt(0xff0000ff), true, 0.0);
- assertThat(MaterialDynamicColors.onPrimaryContainer.getArgb(scheme)).isSameColorAs(
+ assertThat(dynamicColors.onPrimaryContainer().getArgb(scheme)).isSameColorAs(
0xffC2E8FF);
}
@Test
public void darkTheme_maxContrast_onPrimaryContainer() {
SchemeFruitSalad scheme = new SchemeFruitSalad(Hct.fromInt(0xff0000ff), true, 1.0);
- assertThat(MaterialDynamicColors.onPrimaryContainer.getArgb(scheme)).isSameColorAs(
+ assertThat(dynamicColors.onPrimaryContainer().getArgb(scheme)).isSameColorAs(
0xff003E54);
}
@Test
public void darkTheme_minContrast_onTertiaryContainer() {
SchemeFruitSalad scheme = new SchemeFruitSalad(Hct.fromInt(0xff0000ff), true, -1.0);
- assertThat(MaterialDynamicColors.onTertiaryContainer.getArgb(scheme)).isSameColorAs(
+ assertThat(dynamicColors.onTertiaryContainer().getArgb(scheme)).isSameColorAs(
0xffADB0EF);
}
@Test
public void darkTheme_standardContrast_onTertiaryContainer() {
SchemeFruitSalad scheme = new SchemeFruitSalad(Hct.fromInt(0xff0000ff), true, 0.0);
- assertThat(MaterialDynamicColors.onTertiaryContainer.getArgb(scheme)).isSameColorAs(
+ assertThat(dynamicColors.onTertiaryContainer().getArgb(scheme)).isSameColorAs(
0xffe0e0ff);
}
@Test
public void darkTheme_maxContrast_onTertiaryContainer() {
SchemeFruitSalad scheme = new SchemeFruitSalad(Hct.fromInt(0xff0000ff), true, 1.0);
- assertThat(MaterialDynamicColors.onTertiaryContainer.getArgb(scheme)).isSameColorAs(
+ assertThat(dynamicColors.onTertiaryContainer().getArgb(scheme)).isSameColorAs(
0xff30346A);
}
@Test
public void darkTheme_minContrast_surface() {
SchemeFruitSalad scheme = new SchemeFruitSalad(Hct.fromInt(0xff0000ff), true, -1.0);
- assertThat(MaterialDynamicColors.surface.getArgb(scheme)).isSameColorAs(0xff12131c);
+ assertThat(dynamicColors.surface().getArgb(scheme)).isSameColorAs(0xff12131c);
}
@Test
public void darkTheme_standardContrast_surface() {
SchemeFruitSalad scheme = new SchemeFruitSalad(Hct.fromInt(0xff0000ff), true, 0.0);
- assertThat(MaterialDynamicColors.surface.getArgb(scheme)).isSameColorAs(0xff12131c);
+ assertThat(dynamicColors.surface().getArgb(scheme)).isSameColorAs(0xff12131c);
}
@Test
public void darkTheme_maxContrast_surface() {
SchemeFruitSalad scheme = new SchemeFruitSalad(Hct.fromInt(0xff0000ff), true, 1.0);
- assertThat(MaterialDynamicColors.surface.getArgb(scheme)).isSameColorAs(0xff12131c);
+ assertThat(dynamicColors.surface().getArgb(scheme)).isSameColorAs(0xff12131c);
}
}
diff --git a/packages/SystemUI/tests/src/com/android/systemui/monet/SchemeMonochromeTest.java b/packages/SystemUI/tests/src/com/android/systemui/monet/SchemeMonochromeTest.java
index 3eca4dc..d511422 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/monet/SchemeMonochromeTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/monet/SchemeMonochromeTest.java
@@ -16,6 +16,7 @@
package com.android.systemui.monet;
+import static com.google.common.truth.Truth.assertThat;
import static com.android.systemui.monet.utils.ArgbSubject.assertThat;
import androidx.test.filters.SmallTest;
@@ -25,204 +26,227 @@
import com.android.systemui.monet.hct.Hct;
import com.android.systemui.monet.scheme.SchemeMonochrome;
+import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
+@Ignore("b/279581953")
@SmallTest
@RunWith(JUnit4.class)
public final class SchemeMonochromeTest extends SysuiTestCase {
+ private final MaterialDynamicColors dynamicColors = new MaterialDynamicColors();
+
@Test
public void testKeyColors() {
SchemeMonochrome scheme = new SchemeMonochrome(Hct.fromInt(0xff0000ff), false, 0.0);
- assertThat(MaterialDynamicColors.primaryPaletteKeyColor.getArgb(scheme))
+ assertThat(dynamicColors.primaryPaletteKeyColor().getArgb(scheme))
.isSameColorAs(0xff070707);
- assertThat(MaterialDynamicColors.secondaryPaletteKeyColor.getArgb(scheme))
+ assertThat(dynamicColors.secondaryPaletteKeyColor().getArgb(scheme))
.isSameColorAs(0xff070707);
- assertThat(MaterialDynamicColors.tertiaryPaletteKeyColor.getArgb(scheme))
+ assertThat(dynamicColors.tertiaryPaletteKeyColor().getArgb(scheme))
.isSameColorAs(0xff070707);
- assertThat(MaterialDynamicColors.neutralPaletteKeyColor.getArgb(scheme))
+ assertThat(dynamicColors.neutralPaletteKeyColor().getArgb(scheme))
.isSameColorAs(0xff070707);
- assertThat(MaterialDynamicColors.neutralVariantPaletteKeyColor.getArgb(scheme))
+ assertThat(dynamicColors.neutralVariantPaletteKeyColor().getArgb(scheme))
.isSameColorAs(0xff070707);
}
@Test
public void lightTheme_minContrast_primary() {
- SchemeMonochrome scheme = new SchemeMonochrome(Hct.fromInt(0xff0000ff), false, -1.0);
- assertThat(MaterialDynamicColors.primary.getArgb(scheme)).isSameColorAs(0xff747474);
+ SchemeMonochrome scheme = new SchemeMonochrome(Hct.fromInt(0xff0000ff), false, -1);
+ assertThat(dynamicColors.primary().getArgb(scheme)).isSameColorAs(0xff3c3c3c);
}
@Test
public void lightTheme_standardContrast_primary() {
SchemeMonochrome scheme = new SchemeMonochrome(Hct.fromInt(0xff0000ff), false, 0.0);
- assertThat(MaterialDynamicColors.primary.getArgb(scheme)).isSameColorAs(0xff5e5e5e);
+ assertThat(dynamicColors.primary().getArgb(scheme)).isSameColorAs(0xff000000);
}
@Test
public void lightTheme_maxContrast_primary() {
- SchemeMonochrome scheme = new SchemeMonochrome(Hct.fromInt(0xff0000ff), false, 1.0);
- assertThat(MaterialDynamicColors.primary.getArgb(scheme)).isSameColorAs(0xff222222);
+ SchemeMonochrome scheme = new SchemeMonochrome(Hct.fromInt(0xff0000ff), false, 1);
+ assertThat(dynamicColors.primary().getArgb(scheme)).isSameColorAs(0xff000000);
}
@Test
public void lightTheme_minContrast_primaryContainer() {
- SchemeMonochrome scheme = new SchemeMonochrome(Hct.fromInt(0xff0000ff), false, -1.0);
- assertThat(MaterialDynamicColors.primaryContainer.getArgb(scheme)).isSameColorAs(
- 0xffe2e2e2);
+ SchemeMonochrome scheme = new SchemeMonochrome(Hct.fromInt(0xff0000ff), false, -1);
+ assertThat(dynamicColors.primaryContainer().getArgb(scheme)).isSameColorAs(0xff5f5f5f);
}
@Test
public void lightTheme_standardContrast_primaryContainer() {
SchemeMonochrome scheme = new SchemeMonochrome(Hct.fromInt(0xff0000ff), false, 0.0);
- assertThat(MaterialDynamicColors.primaryContainer.getArgb(scheme)).isSameColorAs(
- 0xffe2e2e2);
+ assertThat(dynamicColors.primaryContainer().getArgb(scheme)).isSameColorAs(0xff3b3b3b);
}
@Test
public void lightTheme_maxContrast_primaryContainer() {
- SchemeMonochrome scheme = new SchemeMonochrome(Hct.fromInt(0xff0000ff), false, 1.0);
- assertThat(MaterialDynamicColors.primaryContainer.getArgb(scheme)).isSameColorAs(
- 0xff434343);
+ SchemeMonochrome scheme = new SchemeMonochrome(Hct.fromInt(0xff0000ff), false, 1);
+ assertThat(dynamicColors.primaryContainer().getArgb(scheme)).isSameColorAs(0xff3a3a3a);
}
@Test
public void lightTheme_minContrast_onPrimaryContainer() {
- SchemeMonochrome scheme = new SchemeMonochrome(Hct.fromInt(0xff0000ff), false, -1.0);
- assertThat(MaterialDynamicColors.onPrimaryContainer.getArgb(scheme)).isSameColorAs(
- 0xff646464);
+ SchemeMonochrome scheme = new SchemeMonochrome(Hct.fromInt(0xff0000ff), false, -1);
+ assertThat(dynamicColors.onPrimaryContainer().getArgb(scheme)).isSameColorAs(0xffd9d9d9);
}
@Test
public void lightTheme_standardContrast_onPrimaryContainer() {
SchemeMonochrome scheme = new SchemeMonochrome(Hct.fromInt(0xff0000ff), false, 0.0);
- assertThat(MaterialDynamicColors.onPrimaryContainer.getArgb(scheme)).isSameColorAs(
- 0xff1b1b1b);
+ assertThat(dynamicColors.onPrimaryContainer().getArgb(scheme)).isSameColorAs(0xffffffff);
}
@Test
public void lightTheme_maxContrast_onPrimaryContainer() {
- SchemeMonochrome scheme = new SchemeMonochrome(Hct.fromInt(0xff0000ff), false, 1.0);
- assertThat(MaterialDynamicColors.onPrimaryContainer.getArgb(scheme)).isSameColorAs(
- 0xffdadada);
+ SchemeMonochrome scheme = new SchemeMonochrome(Hct.fromInt(0xff0000ff), false, 1);
+ assertThat(dynamicColors.onPrimaryContainer().getArgb(scheme)).isSameColorAs(0xffcdcdcd);
}
@Test
public void lightTheme_minContrast_surface() {
- SchemeMonochrome scheme = new SchemeMonochrome(Hct.fromInt(0xff0000ff), false, -1.0);
- assertThat(MaterialDynamicColors.surface.getArgb(scheme)).isSameColorAs(0xfff9f9f9);
+ SchemeMonochrome scheme = new SchemeMonochrome(Hct.fromInt(0xff0000ff), false, -1);
+ assertThat(dynamicColors.surface().getArgb(scheme)).isSameColorAs(0xfff9f9f9);
}
@Test
public void lightTheme_standardContrast_surface() {
SchemeMonochrome scheme = new SchemeMonochrome(Hct.fromInt(0xff0000ff), false, 0.0);
- assertThat(MaterialDynamicColors.surface.getArgb(scheme)).isSameColorAs(0xfff9f9f9);
+ assertThat(dynamicColors.surface().getArgb(scheme)).isSameColorAs(0xfff9f9f9);
}
@Test
public void lightTheme_maxContrast_surface() {
- SchemeMonochrome scheme = new SchemeMonochrome(Hct.fromInt(0xff0000ff), false, 1.0);
- assertThat(MaterialDynamicColors.surface.getArgb(scheme)).isSameColorAs(0xfff9f9f9);
+ SchemeMonochrome scheme = new SchemeMonochrome(Hct.fromInt(0xff0000ff), false, 1);
+ assertThat(dynamicColors.surface().getArgb(scheme)).isSameColorAs(0xfff9f9f9);
}
@Test
public void darkTheme_minContrast_primary() {
- SchemeMonochrome scheme = new SchemeMonochrome(Hct.fromInt(0xff0000ff), true, -1.0);
- assertThat(MaterialDynamicColors.primary.getArgb(scheme)).isSameColorAs(0xff747474);
+ SchemeMonochrome scheme = new SchemeMonochrome(Hct.fromInt(0xff0000ff), true, -1);
+ assertThat(dynamicColors.primary().getArgb(scheme)).isSameColorAs(0xffcccccc);
}
@Test
public void darkTheme_standardContrast_primary() {
SchemeMonochrome scheme = new SchemeMonochrome(Hct.fromInt(0xff0000ff), true, 0.0);
- assertThat(MaterialDynamicColors.primary.getArgb(scheme)).isSameColorAs(0xffc6c6c6);
+ assertThat(dynamicColors.primary().getArgb(scheme)).isSameColorAs(0xffffffff);
}
@Test
public void darkTheme_maxContrast_primary() {
- SchemeMonochrome scheme = new SchemeMonochrome(Hct.fromInt(0xff0000ff), true, 1.0);
- assertThat(MaterialDynamicColors.primary.getArgb(scheme)).isSameColorAs(0xfff5f5f5);
+ SchemeMonochrome scheme = new SchemeMonochrome(Hct.fromInt(0xff0000ff), true, 1);
+ assertThat(dynamicColors.primary().getArgb(scheme)).isSameColorAs(0xffffffff);
}
@Test
public void darkTheme_minContrast_primaryContainer() {
- SchemeMonochrome scheme = new SchemeMonochrome(Hct.fromInt(0xff0000ff), true, -1.0);
- assertThat(MaterialDynamicColors.primaryContainer.getArgb(scheme)).isSameColorAs(
- 0xff474747);
+ SchemeMonochrome scheme = new SchemeMonochrome(Hct.fromInt(0xff0000ff), true, -1);
+ assertThat(dynamicColors.primaryContainer().getArgb(scheme)).isSameColorAs(0xffa3a3a3);
}
@Test
public void darkTheme_standardContrast_primaryContainer() {
SchemeMonochrome scheme = new SchemeMonochrome(Hct.fromInt(0xff0000ff), true, 0.0);
- assertThat(MaterialDynamicColors.primaryContainer.getArgb(scheme)).isSameColorAs(
- 0xff474747);
+ assertThat(dynamicColors.primaryContainer().getArgb(scheme)).isSameColorAs(0xffd4d4d4);
}
@Test
public void darkTheme_maxContrast_primaryContainer() {
- SchemeMonochrome scheme = new SchemeMonochrome(Hct.fromInt(0xff0000ff), true, 1.0);
- assertThat(MaterialDynamicColors.primaryContainer.getArgb(scheme)).isSameColorAs(
- 0xffcbcbcb);
+ SchemeMonochrome scheme = new SchemeMonochrome(Hct.fromInt(0xff0000ff), true, 1);
+ assertThat(dynamicColors.primaryContainer().getArgb(scheme)).isSameColorAs(0xffd5d5d5);
}
@Test
public void darkTheme_minContrast_onPrimaryContainer() {
- SchemeMonochrome scheme = new SchemeMonochrome(Hct.fromInt(0xff0000ff), true, -1.0);
- assertThat(MaterialDynamicColors.onPrimaryContainer.getArgb(scheme)).isSameColorAs(
- 0xffb5b5b5);
+ SchemeMonochrome scheme = new SchemeMonochrome(Hct.fromInt(0xff0000ff), true, -1);
+ assertThat(dynamicColors.onPrimaryContainer().getArgb(scheme)).isSameColorAs(0xff393939);
}
@Test
public void darkTheme_standardContrast_onPrimaryContainer() {
SchemeMonochrome scheme = new SchemeMonochrome(Hct.fromInt(0xff0000ff), true, 0.0);
- assertThat(MaterialDynamicColors.onPrimaryContainer.getArgb(scheme)).isSameColorAs(
- 0xffe2e2e2);
+ assertThat(dynamicColors.onPrimaryContainer().getArgb(scheme)).isSameColorAs(0xff000000);
}
@Test
public void darkTheme_maxContrast_onPrimaryContainer() {
- SchemeMonochrome scheme = new SchemeMonochrome(Hct.fromInt(0xff0000ff), true, 1.0);
- assertThat(MaterialDynamicColors.onPrimaryContainer.getArgb(scheme)).isSameColorAs(
- 0xff393939);
+ SchemeMonochrome scheme = new SchemeMonochrome(Hct.fromInt(0xff0000ff), true, 1);
+ assertThat(dynamicColors.onPrimaryContainer().getArgb(scheme)).isSameColorAs(0xff404040);
}
@Test
public void darkTheme_minContrast_onTertiaryContainer() {
- SchemeMonochrome scheme = new SchemeMonochrome(Hct.fromInt(0xff0000ff), true, -1.0);
- assertThat(MaterialDynamicColors.onTertiaryContainer.getArgb(scheme)).isSameColorAs(
- 0xffb5b5b5);
+ SchemeMonochrome scheme = new SchemeMonochrome(Hct.fromInt(0xff0000ff), true, -1);
+ assertThat(dynamicColors.onTertiaryContainer().getArgb(scheme)).isSameColorAs(0xffd1d1d1);
}
@Test
public void darkTheme_standardContrast_onTertiaryContainer() {
SchemeMonochrome scheme = new SchemeMonochrome(Hct.fromInt(0xff0000ff), true, 0.0);
- assertThat(MaterialDynamicColors.onTertiaryContainer.getArgb(scheme)).isSameColorAs(
- 0xffe2e2e2);
+ assertThat(dynamicColors.onTertiaryContainer().getArgb(scheme)).isSameColorAs(0xff000000);
}
@Test
public void darkTheme_maxContrast_onTertiaryContainer() {
- SchemeMonochrome scheme = new SchemeMonochrome(Hct.fromInt(0xff0000ff), true, 1.0);
- assertThat(MaterialDynamicColors.onTertiaryContainer.getArgb(scheme)).isSameColorAs(
- 0xff393939);
+ SchemeMonochrome scheme = new SchemeMonochrome(Hct.fromInt(0xff0000ff), true, 1);
+ assertThat(dynamicColors.onTertiaryContainer().getArgb(scheme)).isSameColorAs(0xff393939);
}
@Test
public void darkTheme_minContrast_surface() {
- SchemeMonochrome scheme = new SchemeMonochrome(Hct.fromInt(0xff0000ff), true, -1.0);
- assertThat(MaterialDynamicColors.surface.getArgb(scheme)).isSameColorAs(0xff131313);
+ SchemeMonochrome scheme = new SchemeMonochrome(Hct.fromInt(0xff0000ff), true, -1);
+ assertThat(dynamicColors.surface().getArgb(scheme)).isSameColorAs(0xff131313);
}
@Test
public void darkTheme_standardContrast_surface() {
SchemeMonochrome scheme = new SchemeMonochrome(Hct.fromInt(0xff0000ff), true, 0.0);
- assertThat(MaterialDynamicColors.surface.getArgb(scheme)).isSameColorAs(0xff131313);
+ assertThat(dynamicColors.surface().getArgb(scheme)).isSameColorAs(0xff131313);
}
@Test
public void darkTheme_maxContrast_surface() {
- SchemeMonochrome scheme = new SchemeMonochrome(Hct.fromInt(0xff0000ff), true, 1.0);
- assertThat(MaterialDynamicColors.surface.getArgb(scheme)).isSameColorAs(0xff131313);
+ SchemeMonochrome scheme = new SchemeMonochrome(Hct.fromInt(0xff0000ff), true, 1);
+ assertThat(dynamicColors.surface().getArgb(scheme)).isSameColorAs(0xff131313);
+ }
+
+ @Test
+ public void darkTheme_monochromeSpec() {
+ SchemeMonochrome scheme = new SchemeMonochrome(Hct.fromInt(0xff0000ff), true, 0.0);
+ assertThat(dynamicColors.primary().getHct(scheme).getTone()).isWithin(1).of(100);
+ assertThat(dynamicColors.onPrimary().getHct(scheme).getTone()).isWithin(1).of(10);
+ assertThat(dynamicColors.primaryContainer().getHct(scheme).getTone()).isWithin(1).of(85);
+ assertThat(dynamicColors.onPrimaryContainer().getHct(scheme).getTone()).isWithin(1).of(0);
+ assertThat(dynamicColors.secondary().getHct(scheme).getTone()).isWithin(1).of(80);
+ assertThat(dynamicColors.onSecondary().getHct(scheme).getTone()).isWithin(1).of(10);
+ assertThat(dynamicColors.secondaryContainer().getHct(scheme).getTone()).isWithin(1).of(30);
+ assertThat(dynamicColors.onSecondaryContainer().getHct(scheme).getTone()).isWithin(1).of(90);
+ assertThat(dynamicColors.tertiary().getHct(scheme).getTone()).isWithin(1).of(90);
+ assertThat(dynamicColors.onTertiary().getHct(scheme).getTone()).isWithin(1).of(10);
+ assertThat(dynamicColors.tertiaryContainer().getHct(scheme).getTone()).isWithin(1).of(60);
+ assertThat(dynamicColors.onTertiaryContainer().getHct(scheme).getTone()).isWithin(1).of(0);
+ }
+
+ @Test
+ public void lightTheme_monochromeSpec() {
+ SchemeMonochrome scheme = new SchemeMonochrome(Hct.fromInt(0xff0000ff), false, 0.0);
+ assertThat(dynamicColors.primary().getHct(scheme).getTone()).isWithin(1).of(0);
+ assertThat(dynamicColors.onPrimary().getHct(scheme).getTone()).isWithin(1).of(90);
+ assertThat(dynamicColors.primaryContainer().getHct(scheme).getTone()).isWithin(1).of(25);
+ assertThat(dynamicColors.onPrimaryContainer().getHct(scheme).getTone()).isWithin(1).of(100);
+ assertThat(dynamicColors.secondary().getHct(scheme).getTone()).isWithin(1).of(40);
+ assertThat(dynamicColors.onSecondary().getHct(scheme).getTone()).isWithin(1).of(100);
+ assertThat(dynamicColors.secondaryContainer().getHct(scheme).getTone()).isWithin(1).of(85);
+ assertThat(dynamicColors.onSecondaryContainer().getHct(scheme).getTone()).isWithin(1).of(10);
+ assertThat(dynamicColors.tertiary().getHct(scheme).getTone()).isWithin(1).of(25);
+ assertThat(dynamicColors.onTertiary().getHct(scheme).getTone()).isWithin(1).of(90);
+ assertThat(dynamicColors.tertiaryContainer().getHct(scheme).getTone()).isWithin(1).of(49);
+ assertThat(dynamicColors.onTertiaryContainer().getHct(scheme).getTone()).isWithin(1).of(100);
}
}
diff --git a/packages/SystemUI/tests/src/com/android/systemui/monet/SchemeNeutralTest.java b/packages/SystemUI/tests/src/com/android/systemui/monet/SchemeNeutralTest.java
index 71e9f4d..4f3fc7d 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/monet/SchemeNeutralTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/monet/SchemeNeutralTest.java
@@ -25,204 +25,193 @@
import com.android.systemui.monet.hct.Hct;
import com.android.systemui.monet.scheme.SchemeNeutral;
+import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
+@Ignore("b/279581953")
@SmallTest
@RunWith(JUnit4.class)
public final class SchemeNeutralTest extends SysuiTestCase {
+ private final MaterialDynamicColors dynamicColors = new MaterialDynamicColors();
+
@Test
public void testKeyColors() {
SchemeNeutral scheme = new SchemeNeutral(Hct.fromInt(0xff0000ff), false, 0.0);
- assertThat(MaterialDynamicColors.primaryPaletteKeyColor.getArgb(scheme))
+ assertThat(dynamicColors.primaryPaletteKeyColor().getArgb(scheme))
.isSameColorAs(0xff767685);
- assertThat(MaterialDynamicColors.secondaryPaletteKeyColor.getArgb(scheme))
+ assertThat(dynamicColors.secondaryPaletteKeyColor().getArgb(scheme))
.isSameColorAs(0xff777680);
- assertThat(MaterialDynamicColors.tertiaryPaletteKeyColor.getArgb(scheme))
+ assertThat(dynamicColors.tertiaryPaletteKeyColor().getArgb(scheme))
.isSameColorAs(0xff75758B);
- assertThat(MaterialDynamicColors.neutralPaletteKeyColor.getArgb(scheme))
+ assertThat(dynamicColors.neutralPaletteKeyColor().getArgb(scheme))
.isSameColorAs(0xff787678);
- assertThat(MaterialDynamicColors.neutralVariantPaletteKeyColor.getArgb(scheme))
+ assertThat(dynamicColors.neutralVariantPaletteKeyColor().getArgb(scheme))
.isSameColorAs(0xff787678);
}
@Test
public void lightTheme_minContrast_primary() {
SchemeNeutral scheme = new SchemeNeutral(Hct.fromInt(0xff0000ff), false, -1.0);
- assertThat(MaterialDynamicColors.primary.getArgb(scheme)).isSameColorAs(0xff737383);
+ assertThat(dynamicColors.primary().getArgb(scheme)).isSameColorAs(0xff737383);
}
@Test
public void lightTheme_standardContrast_primary() {
SchemeNeutral scheme = new SchemeNeutral(Hct.fromInt(0xff0000ff), false, 0.0);
- assertThat(MaterialDynamicColors.primary.getArgb(scheme)).isSameColorAs(0xff5d5d6c);
+ assertThat(dynamicColors.primary().getArgb(scheme)).isSameColorAs(0xff5d5d6c);
}
@Test
public void lightTheme_maxContrast_primary() {
SchemeNeutral scheme = new SchemeNeutral(Hct.fromInt(0xff0000ff), false, 1.0);
- assertThat(MaterialDynamicColors.primary.getArgb(scheme)).isSameColorAs(0xff21212e);
+ assertThat(dynamicColors.primary().getArgb(scheme)).isSameColorAs(0xff21212e);
}
@Test
public void lightTheme_minContrast_primaryContainer() {
SchemeNeutral scheme = new SchemeNeutral(Hct.fromInt(0xff0000ff), false, -1.0);
- assertThat(MaterialDynamicColors.primaryContainer.getArgb(scheme)).isSameColorAs(
- 0xffe2e1f3);
+ assertThat(dynamicColors.primaryContainer().getArgb(scheme)).isSameColorAs(0xffe2e1f3);
}
@Test
public void lightTheme_standardContrast_primaryContainer() {
SchemeNeutral scheme = new SchemeNeutral(Hct.fromInt(0xff0000ff), false, 0.0);
- assertThat(MaterialDynamicColors.primaryContainer.getArgb(scheme)).isSameColorAs(
- 0xffe2e1f3);
+ assertThat(dynamicColors.primaryContainer().getArgb(scheme)).isSameColorAs(0xffe2e1f3);
}
@Test
public void lightTheme_maxContrast_primaryContainer() {
SchemeNeutral scheme = new SchemeNeutral(Hct.fromInt(0xff0000ff), false, 1.0);
- assertThat(MaterialDynamicColors.primaryContainer.getArgb(scheme)).isSameColorAs(
- 0xff414250);
+ assertThat(dynamicColors.primaryContainer().getArgb(scheme)).isSameColorAs(0xff414250);
}
@Test
public void lightTheme_minContrast_onPrimaryContainer() {
SchemeNeutral scheme = new SchemeNeutral(Hct.fromInt(0xff0000ff), false, -1.0);
- assertThat(MaterialDynamicColors.onPrimaryContainer.getArgb(scheme)).isSameColorAs(
- 0xff636372);
+ assertThat(dynamicColors.onPrimaryContainer().getArgb(scheme)).isSameColorAs(0xff636372);
}
@Test
public void lightTheme_standardContrast_onPrimaryContainer() {
SchemeNeutral scheme = new SchemeNeutral(Hct.fromInt(0xff0000ff), false, 0.0);
- assertThat(MaterialDynamicColors.onPrimaryContainer.getArgb(scheme)).isSameColorAs(
- 0xff1a1b27);
+ assertThat(dynamicColors.onPrimaryContainer().getArgb(scheme)).isSameColorAs(0xff1a1b27);
}
@Test
public void lightTheme_maxContrast_onPrimaryContainer() {
SchemeNeutral scheme = new SchemeNeutral(Hct.fromInt(0xff0000ff), false, 1.0);
- assertThat(MaterialDynamicColors.onPrimaryContainer.getArgb(scheme)).isSameColorAs(
- 0xffd9d8ea);
+ assertThat(dynamicColors.onPrimaryContainer().getArgb(scheme)).isSameColorAs(0xffd9d8ea);
}
@Test
public void lightTheme_minContrast_surface() {
SchemeNeutral scheme = new SchemeNeutral(Hct.fromInt(0xff0000ff), false, -1.0);
- assertThat(MaterialDynamicColors.surface.getArgb(scheme)).isSameColorAs(0xfffcf8fa);
+ assertThat(dynamicColors.surface().getArgb(scheme)).isSameColorAs(0xfffcf8fa);
}
@Test
public void lightTheme_standardContrast_surface() {
SchemeNeutral scheme = new SchemeNeutral(Hct.fromInt(0xff0000ff), false, 0.0);
- assertThat(MaterialDynamicColors.surface.getArgb(scheme)).isSameColorAs(0xfffcf8fa);
+ assertThat(dynamicColors.surface().getArgb(scheme)).isSameColorAs(0xfffcf8fa);
}
@Test
public void lightTheme_maxContrast_surface() {
SchemeNeutral scheme = new SchemeNeutral(Hct.fromInt(0xff0000ff), false, 1.0);
- assertThat(MaterialDynamicColors.surface.getArgb(scheme)).isSameColorAs(0xfffcf8fa);
+ assertThat(dynamicColors.surface().getArgb(scheme)).isSameColorAs(0xfffcf8fa);
}
@Test
public void darkTheme_minContrast_primary() {
SchemeNeutral scheme = new SchemeNeutral(Hct.fromInt(0xff0000ff), true, -1.0);
- assertThat(MaterialDynamicColors.primary.getArgb(scheme)).isSameColorAs(0xff737383);
+ assertThat(dynamicColors.primary().getArgb(scheme)).isSameColorAs(0xff737383);
}
@Test
public void darkTheme_standardContrast_primary() {
SchemeNeutral scheme = new SchemeNeutral(Hct.fromInt(0xff0000ff), true, 0.0);
- assertThat(MaterialDynamicColors.primary.getArgb(scheme)).isSameColorAs(0xffc6c5d6);
+ assertThat(dynamicColors.primary().getArgb(scheme)).isSameColorAs(0xffc6c5d6);
}
@Test
public void darkTheme_maxContrast_primary() {
SchemeNeutral scheme = new SchemeNeutral(Hct.fromInt(0xff0000ff), true, 1.0);
- assertThat(MaterialDynamicColors.primary.getArgb(scheme)).isSameColorAs(0xfff6f4ff);
+ assertThat(dynamicColors.primary().getArgb(scheme)).isSameColorAs(0xfff6f4ff);
}
@Test
public void darkTheme_minContrast_primaryContainer() {
SchemeNeutral scheme = new SchemeNeutral(Hct.fromInt(0xff0000ff), true, -1.0);
- assertThat(MaterialDynamicColors.primaryContainer.getArgb(scheme)).isSameColorAs(
- 0xff454654);
+ assertThat(dynamicColors.primaryContainer().getArgb(scheme)).isSameColorAs(0xff454654);
}
@Test
public void darkTheme_standardContrast_primaryContainer() {
SchemeNeutral scheme = new SchemeNeutral(Hct.fromInt(0xff0000ff), true, 0.0);
- assertThat(MaterialDynamicColors.primaryContainer.getArgb(scheme)).isSameColorAs(
- 0xff454654);
+ assertThat(dynamicColors.primaryContainer().getArgb(scheme)).isSameColorAs(0xff454654);
}
@Test
public void darkTheme_maxContrast_primaryContainer() {
SchemeNeutral scheme = new SchemeNeutral(Hct.fromInt(0xff0000ff), true, 1.0);
- assertThat(MaterialDynamicColors.primaryContainer.getArgb(scheme)).isSameColorAs(
- 0xffcac9da);
+ assertThat(dynamicColors.primaryContainer().getArgb(scheme)).isSameColorAs(0xffcac9da);
}
@Test
public void darkTheme_minContrast_onPrimaryContainer() {
SchemeNeutral scheme = new SchemeNeutral(Hct.fromInt(0xff0000ff), true, -1.0);
- assertThat(MaterialDynamicColors.onPrimaryContainer.getArgb(scheme)).isSameColorAs(
- 0xffb5b3c4);
+ assertThat(dynamicColors.onPrimaryContainer().getArgb(scheme)).isSameColorAs(0xffb5b3c4);
}
@Test
public void darkTheme_standardContrast_onPrimaryContainer() {
SchemeNeutral scheme = new SchemeNeutral(Hct.fromInt(0xff0000ff), true, 0.0);
- assertThat(MaterialDynamicColors.onPrimaryContainer.getArgb(scheme)).isSameColorAs(
- 0xffe2e1f3);
+ assertThat(dynamicColors.onPrimaryContainer().getArgb(scheme)).isSameColorAs(0xffe2e1f3);
}
@Test
public void darkTheme_maxContrast_onPrimaryContainer() {
SchemeNeutral scheme = new SchemeNeutral(Hct.fromInt(0xff0000ff), true, 1.0);
- assertThat(MaterialDynamicColors.onPrimaryContainer.getArgb(scheme)).isSameColorAs(
- 0xff373846);
+ assertThat(dynamicColors.onPrimaryContainer().getArgb(scheme)).isSameColorAs(0xff373846);
}
@Test
public void darkTheme_minContrast_onTertiaryContainer() {
SchemeNeutral scheme = new SchemeNeutral(Hct.fromInt(0xff0000ff), true, -1.0);
- assertThat(MaterialDynamicColors.onTertiaryContainer.getArgb(scheme)).isSameColorAs(
- 0xffb3b3cb);
+ assertThat(dynamicColors.onTertiaryContainer().getArgb(scheme)).isSameColorAs(0xffb3b3cb);
}
@Test
public void darkTheme_standardContrast_onTertiaryContainer() {
SchemeNeutral scheme = new SchemeNeutral(Hct.fromInt(0xff0000ff), true, 0.0);
- assertThat(MaterialDynamicColors.onTertiaryContainer.getArgb(scheme)).isSameColorAs(
- 0xffe1e0f9);
+ assertThat(dynamicColors.onTertiaryContainer().getArgb(scheme)).isSameColorAs(0xffe1e0f9);
}
@Test
public void darkTheme_maxContrast_onTertiaryContainer() {
SchemeNeutral scheme = new SchemeNeutral(Hct.fromInt(0xff0000ff), true, 1.0);
- assertThat(MaterialDynamicColors.onTertiaryContainer.getArgb(scheme)).isSameColorAs(
- 0xff37374b);
+ assertThat(dynamicColors.onTertiaryContainer().getArgb(scheme)).isSameColorAs(0xff37374b);
}
@Test
public void darkTheme_minContrast_surface() {
SchemeNeutral scheme = new SchemeNeutral(Hct.fromInt(0xff0000ff), true, -1.0);
- assertThat(MaterialDynamicColors.surface.getArgb(scheme)).isSameColorAs(0xff131315);
+ assertThat(dynamicColors.surface().getArgb(scheme)).isSameColorAs(0xff131315);
}
@Test
public void darkTheme_standardContrast_surface() {
SchemeNeutral scheme = new SchemeNeutral(Hct.fromInt(0xff0000ff), true, 0.0);
- assertThat(MaterialDynamicColors.surface.getArgb(scheme)).isSameColorAs(0xff131315);
+ assertThat(dynamicColors.surface().getArgb(scheme)).isSameColorAs(0xff131315);
}
@Test
public void darkTheme_maxContrast_surface() {
SchemeNeutral scheme = new SchemeNeutral(Hct.fromInt(0xff0000ff), true, 1.0);
- assertThat(MaterialDynamicColors.surface.getArgb(scheme)).isSameColorAs(0xff131315);
+ assertThat(dynamicColors.surface().getArgb(scheme)).isSameColorAs(0xff131315);
}
}
diff --git a/packages/SystemUI/tests/src/com/android/systemui/monet/SchemeRainbowTest.java b/packages/SystemUI/tests/src/com/android/systemui/monet/SchemeRainbowTest.java
index cc6f044..ece3f9a 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/monet/SchemeRainbowTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/monet/SchemeRainbowTest.java
@@ -25,225 +25,229 @@
import com.android.systemui.monet.hct.Hct;
import com.android.systemui.monet.scheme.SchemeRainbow;
+import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
+@Ignore("b/279581953")
@SmallTest
@RunWith(JUnit4.class)
public final class SchemeRainbowTest extends SysuiTestCase {
+ private final MaterialDynamicColors dynamicColors = new MaterialDynamicColors();
+
@Test
public void testKeyColors() {
SchemeRainbow scheme = new SchemeRainbow(Hct.fromInt(0xff0000ff), false, 0.0);
- assertThat(MaterialDynamicColors.primaryPaletteKeyColor.getArgb(scheme))
+ assertThat(dynamicColors.primaryPaletteKeyColor().getArgb(scheme))
.isSameColorAs(0xff696FC4);
- assertThat(MaterialDynamicColors.secondaryPaletteKeyColor.getArgb(scheme))
+ assertThat(dynamicColors.secondaryPaletteKeyColor().getArgb(scheme))
.isSameColorAs(0xff75758B);
- assertThat(MaterialDynamicColors.tertiaryPaletteKeyColor.getArgb(scheme))
+ assertThat(dynamicColors.tertiaryPaletteKeyColor().getArgb(scheme))
.isSameColorAs(0xff936B84);
- assertThat(MaterialDynamicColors.neutralPaletteKeyColor.getArgb(scheme))
+ assertThat(dynamicColors.neutralPaletteKeyColor().getArgb(scheme))
.isSameColorAs(0xff070707);
- assertThat(MaterialDynamicColors.neutralVariantPaletteKeyColor.getArgb(scheme))
+ assertThat(dynamicColors.neutralVariantPaletteKeyColor().getArgb(scheme))
.isSameColorAs(0xff070707);
}
@Test
public void lightTheme_minContrast_primary() {
SchemeRainbow scheme = new SchemeRainbow(Hct.fromInt(0xff0000ff), false, -1.0);
- assertThat(MaterialDynamicColors.primary.getArgb(scheme)).isSameColorAs(0xff676DC1);
+ assertThat(dynamicColors.primary().getArgb(scheme)).isSameColorAs(0xff676DC1);
}
@Test
public void lightTheme_standardContrast_primary() {
SchemeRainbow scheme = new SchemeRainbow(Hct.fromInt(0xff0000ff), false, 0.0);
- assertThat(MaterialDynamicColors.primary.getArgb(scheme)).isSameColorAs(0xff5056A9);
+ assertThat(dynamicColors.primary().getArgb(scheme)).isSameColorAs(0xff5056A9);
}
@Test
public void lightTheme_maxContrast_primary() {
SchemeRainbow scheme = new SchemeRainbow(Hct.fromInt(0xff0000ff), false, 1.0);
- assertThat(MaterialDynamicColors.primary.getArgb(scheme)).isSameColorAs(0xff0F136A);
+ assertThat(dynamicColors.primary().getArgb(scheme)).isSameColorAs(0xff0F136A);
}
@Test
public void lightTheme_minContrast_primaryContainer() {
SchemeRainbow scheme = new SchemeRainbow(Hct.fromInt(0xff0000ff), false, -1.0);
- assertThat(MaterialDynamicColors.primaryContainer.getArgb(scheme)).isSameColorAs(
+ assertThat(dynamicColors.primaryContainer().getArgb(scheme)).isSameColorAs(
0xffE0E0FF);
}
@Test
public void lightTheme_standardContrast_primaryContainer() {
SchemeRainbow scheme = new SchemeRainbow(Hct.fromInt(0xff0000ff), false, 0.0);
- assertThat(MaterialDynamicColors.primaryContainer.getArgb(scheme)).isSameColorAs(
+ assertThat(dynamicColors.primaryContainer().getArgb(scheme)).isSameColorAs(
0xffE0E0FF);
}
@Test
public void lightTheme_maxContrast_primaryContainer() {
SchemeRainbow scheme = new SchemeRainbow(Hct.fromInt(0xff0000ff), false, 1.0);
- assertThat(MaterialDynamicColors.primaryContainer.getArgb(scheme)).isSameColorAs(
+ assertThat(dynamicColors.primaryContainer().getArgb(scheme)).isSameColorAs(
0xff34398B);
}
@Test
public void lightTheme_minContrast_tertiaryContainer() {
SchemeRainbow scheme = new SchemeRainbow(Hct.fromInt(0xff0000ff), false, -1.0);
- assertThat(MaterialDynamicColors.tertiaryContainer.getArgb(scheme)).isSameColorAs(
+ assertThat(dynamicColors.tertiaryContainer().getArgb(scheme)).isSameColorAs(
0xffffd8ee);
}
@Test
public void lightTheme_standardContrast_tertiaryContainer() {
SchemeRainbow scheme = new SchemeRainbow(Hct.fromInt(0xff0000ff), false, 0.0);
- assertThat(MaterialDynamicColors.tertiaryContainer.getArgb(scheme)).isSameColorAs(
+ assertThat(dynamicColors.tertiaryContainer().getArgb(scheme)).isSameColorAs(
0xffffd8ee);
}
@Test
public void lightTheme_maxContrast_tertiaryContainer() {
SchemeRainbow scheme = new SchemeRainbow(Hct.fromInt(0xff0000ff), false, 1.0);
- assertThat(MaterialDynamicColors.tertiaryContainer.getArgb(scheme)).isSameColorAs(
+ assertThat(dynamicColors.tertiaryContainer().getArgb(scheme)).isSameColorAs(
0xff5A384E);
}
@Test
public void lightTheme_minContrast_onPrimaryContainer() {
SchemeRainbow scheme = new SchemeRainbow(Hct.fromInt(0xff0000ff), false, -1.0);
- assertThat(MaterialDynamicColors.onPrimaryContainer.getArgb(scheme)).isSameColorAs(
+ assertThat(dynamicColors.onPrimaryContainer().getArgb(scheme)).isSameColorAs(
0xff565CB0);
}
@Test
public void lightTheme_standardContrast_onPrimaryContainer() {
SchemeRainbow scheme = new SchemeRainbow(Hct.fromInt(0xff0000ff), false, 0.0);
- assertThat(MaterialDynamicColors.onPrimaryContainer.getArgb(scheme)).isSameColorAs(
+ assertThat(dynamicColors.onPrimaryContainer().getArgb(scheme)).isSameColorAs(
0xff050865);
}
@Test
public void lightTheme_maxContrast_onPrimaryContainer() {
SchemeRainbow scheme = new SchemeRainbow(Hct.fromInt(0xff0000ff), false, 1.0);
- assertThat(MaterialDynamicColors.onPrimaryContainer.getArgb(scheme)).isSameColorAs(
+ assertThat(dynamicColors.onPrimaryContainer().getArgb(scheme)).isSameColorAs(
0xffd6d6ff);
}
@Test
public void lightTheme_minContrast_surface() {
SchemeRainbow scheme = new SchemeRainbow(Hct.fromInt(0xff0000ff), false, -1.0);
- assertThat(MaterialDynamicColors.surface.getArgb(scheme)).isSameColorAs(0xfff9f9f9);
+ assertThat(dynamicColors.surface().getArgb(scheme)).isSameColorAs(0xfff9f9f9);
}
@Test
public void lightTheme_standardContrast_surface() {
SchemeRainbow scheme = new SchemeRainbow(Hct.fromInt(0xff0000ff), false, 0.0);
- assertThat(MaterialDynamicColors.surface.getArgb(scheme)).isSameColorAs(0xfff9f9f9);
+ assertThat(dynamicColors.surface().getArgb(scheme)).isSameColorAs(0xfff9f9f9);
}
@Test
public void lightTheme_maxContrast_surface() {
SchemeRainbow scheme = new SchemeRainbow(Hct.fromInt(0xff0000ff), false, 1.0);
- assertThat(MaterialDynamicColors.surface.getArgb(scheme)).isSameColorAs(0xfff9f9f9);
+ assertThat(dynamicColors.surface().getArgb(scheme)).isSameColorAs(0xfff9f9f9);
}
@Test
public void darkTheme_minContrast_primary() {
SchemeRainbow scheme = new SchemeRainbow(Hct.fromInt(0xff0000ff), true, -1.0);
- assertThat(MaterialDynamicColors.primary.getArgb(scheme)).isSameColorAs(0xff676DC1);
+ assertThat(dynamicColors.primary().getArgb(scheme)).isSameColorAs(0xff676DC1);
}
@Test
public void darkTheme_standardContrast_primary() {
SchemeRainbow scheme = new SchemeRainbow(Hct.fromInt(0xff0000ff), true, 0.0);
- assertThat(MaterialDynamicColors.primary.getArgb(scheme)).isSameColorAs(0xffbec2ff);
+ assertThat(dynamicColors.primary().getArgb(scheme)).isSameColorAs(0xffbec2ff);
}
@Test
public void darkTheme_maxContrast_primary() {
SchemeRainbow scheme = new SchemeRainbow(Hct.fromInt(0xff0000ff), true, 1.0);
- assertThat(MaterialDynamicColors.primary.getArgb(scheme)).isSameColorAs(0xfff6f4ff);
+ assertThat(dynamicColors.primary().getArgb(scheme)).isSameColorAs(0xfff6f4ff);
}
@Test
public void darkTheme_minContrast_primaryContainer() {
SchemeRainbow scheme = new SchemeRainbow(Hct.fromInt(0xff0000ff), true, -1.0);
- assertThat(MaterialDynamicColors.primaryContainer.getArgb(scheme)).isSameColorAs(
+ assertThat(dynamicColors.primaryContainer().getArgb(scheme)).isSameColorAs(
0xff383E8F);
}
@Test
public void darkTheme_standardContrast_primaryContainer() {
SchemeRainbow scheme = new SchemeRainbow(Hct.fromInt(0xff0000ff), true, 0.0);
- assertThat(MaterialDynamicColors.primaryContainer.getArgb(scheme)).isSameColorAs(
+ assertThat(dynamicColors.primaryContainer().getArgb(scheme)).isSameColorAs(
0xff383E8F);
}
@Test
public void darkTheme_maxContrast_primaryContainer() {
SchemeRainbow scheme = new SchemeRainbow(Hct.fromInt(0xff0000ff), true, 1.0);
- assertThat(MaterialDynamicColors.primaryContainer.getArgb(scheme)).isSameColorAs(
+ assertThat(dynamicColors.primaryContainer().getArgb(scheme)).isSameColorAs(
0xffc4c6ff);
}
@Test
public void darkTheme_minContrast_onPrimaryContainer() {
SchemeRainbow scheme = new SchemeRainbow(Hct.fromInt(0xff0000ff), true, -1.0);
- assertThat(MaterialDynamicColors.onPrimaryContainer.getArgb(scheme)).isSameColorAs(
+ assertThat(dynamicColors.onPrimaryContainer().getArgb(scheme)).isSameColorAs(
0xffa9afff);
}
@Test
public void darkTheme_standardContrast_onPrimaryContainer() {
SchemeRainbow scheme = new SchemeRainbow(Hct.fromInt(0xff0000ff), true, 0.0);
- assertThat(MaterialDynamicColors.onPrimaryContainer.getArgb(scheme)).isSameColorAs(
+ assertThat(dynamicColors.onPrimaryContainer().getArgb(scheme)).isSameColorAs(
0xffe0e0ff);
}
@Test
public void darkTheme_maxContrast_onPrimaryContainer() {
SchemeRainbow scheme = new SchemeRainbow(Hct.fromInt(0xff0000ff), true, 1.0);
- assertThat(MaterialDynamicColors.onPrimaryContainer.getArgb(scheme)).isSameColorAs(
+ assertThat(dynamicColors.onPrimaryContainer().getArgb(scheme)).isSameColorAs(
0xff292f81);
}
@Test
public void darkTheme_minContrast_onTertiaryContainer() {
SchemeRainbow scheme = new SchemeRainbow(Hct.fromInt(0xff0000ff), true, -1.0);
- assertThat(MaterialDynamicColors.onTertiaryContainer.getArgb(scheme)).isSameColorAs(
+ assertThat(dynamicColors.onTertiaryContainer().getArgb(scheme)).isSameColorAs(
0xffd5a8c3);
}
@Test
public void darkTheme_standardContrast_onTertiaryContainer() {
SchemeRainbow scheme = new SchemeRainbow(Hct.fromInt(0xff0000ff), true, 0.0);
- assertThat(MaterialDynamicColors.onTertiaryContainer.getArgb(scheme)).isSameColorAs(
+ assertThat(dynamicColors.onTertiaryContainer().getArgb(scheme)).isSameColorAs(
0xffffd8ee);
}
@Test
public void darkTheme_maxContrast_onTertiaryContainer() {
SchemeRainbow scheme = new SchemeRainbow(Hct.fromInt(0xff0000ff), true, 1.0);
- assertThat(MaterialDynamicColors.onTertiaryContainer.getArgb(scheme)).isSameColorAs(
+ assertThat(dynamicColors.onTertiaryContainer().getArgb(scheme)).isSameColorAs(
0xff4f2e44);
}
@Test
public void darkTheme_minContrast_surface() {
SchemeRainbow scheme = new SchemeRainbow(Hct.fromInt(0xff0000ff), true, -1.0);
- assertThat(MaterialDynamicColors.surface.getArgb(scheme)).isSameColorAs(0xff131313);
+ assertThat(dynamicColors.surface().getArgb(scheme)).isSameColorAs(0xff131313);
}
@Test
public void darkTheme_standardContrast_surface() {
SchemeRainbow scheme = new SchemeRainbow(Hct.fromInt(0xff0000ff), true, 0.0);
- assertThat(MaterialDynamicColors.surface.getArgb(scheme)).isSameColorAs(0xff131313);
+ assertThat(dynamicColors.surface().getArgb(scheme)).isSameColorAs(0xff131313);
}
@Test
public void darkTheme_maxContrast_surface() {
SchemeRainbow scheme = new SchemeRainbow(Hct.fromInt(0xff0000ff), true, 1.0);
- assertThat(MaterialDynamicColors.surface.getArgb(scheme)).isSameColorAs(0xff131313);
+ assertThat(dynamicColors.surface().getArgb(scheme)).isSameColorAs(0xff131313);
}
}
diff --git a/packages/SystemUI/tests/src/com/android/systemui/monet/SchemeTonalSpotTest.java b/packages/SystemUI/tests/src/com/android/systemui/monet/SchemeTonalSpotTest.java
index e4880d9..01d199b 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/monet/SchemeTonalSpotTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/monet/SchemeTonalSpotTest.java
@@ -25,348 +25,338 @@
import com.android.systemui.monet.hct.Hct;
import com.android.systemui.monet.scheme.SchemeTonalSpot;
+import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
+@Ignore("b/279581953")
@SmallTest
@RunWith(JUnit4.class)
public final class SchemeTonalSpotTest extends SysuiTestCase {
+ private final MaterialDynamicColors dynamicColors = new MaterialDynamicColors();
+
@Test
public void testKeyColors() {
SchemeTonalSpot scheme = new SchemeTonalSpot(Hct.fromInt(0xff0000ff), false, 0.0);
- assertThat(MaterialDynamicColors.primaryPaletteKeyColor.getArgb(scheme))
+ assertThat(dynamicColors.primaryPaletteKeyColor().getArgb(scheme))
.isSameColorAs(0xff6E72AC);
- assertThat(MaterialDynamicColors.secondaryPaletteKeyColor.getArgb(scheme))
+ assertThat(dynamicColors.secondaryPaletteKeyColor().getArgb(scheme))
.isSameColorAs(0xff75758B);
- assertThat(MaterialDynamicColors.tertiaryPaletteKeyColor.getArgb(scheme))
+ assertThat(dynamicColors.tertiaryPaletteKeyColor().getArgb(scheme))
.isSameColorAs(0xff936B84);
- assertThat(MaterialDynamicColors.neutralPaletteKeyColor.getArgb(scheme))
+ assertThat(dynamicColors.neutralPaletteKeyColor().getArgb(scheme))
.isSameColorAs(0xff78767A);
- assertThat(MaterialDynamicColors.neutralVariantPaletteKeyColor.getArgb(scheme))
+ assertThat(dynamicColors.neutralVariantPaletteKeyColor().getArgb(scheme))
.isSameColorAs(0xff777680);
}
+
@Test
public void lightTheme_minContrast_primary() {
SchemeTonalSpot scheme = new SchemeTonalSpot(Hct.fromInt(0xff0000ff), false, -1.0);
- assertThat(MaterialDynamicColors.primary.getArgb(scheme)).isSameColorAs(0xff6c70aa);
+ assertThat(dynamicColors.primary().getArgb(scheme)).isSameColorAs(0xff6a6fb1);
}
@Test
public void lightTheme_standardContrast_primary() {
SchemeTonalSpot scheme = new SchemeTonalSpot(Hct.fromInt(0xff0000ff), false, 0.0);
- assertThat(MaterialDynamicColors.primary.getArgb(scheme)).isSameColorAs(0xff555992);
+ assertThat(dynamicColors.primary().getArgb(scheme)).isSameColorAs(0xff545999);
}
@Test
public void lightTheme_maxContrast_primary() {
SchemeTonalSpot scheme = new SchemeTonalSpot(Hct.fromInt(0xff0000ff), false, 1.0);
- assertThat(MaterialDynamicColors.primary.getArgb(scheme)).isSameColorAs(0xff181c51);
+ assertThat(dynamicColors.primary().getArgb(scheme)).isSameColorAs(0xff161a59);
}
@Test
public void lightTheme_minContrast_primaryContainer() {
SchemeTonalSpot scheme = new SchemeTonalSpot(Hct.fromInt(0xff0000ff), false, -1.0);
- assertThat(MaterialDynamicColors.primaryContainer.getArgb(scheme)).isSameColorAs(
- 0xffe0e0ff);
+ assertThat(dynamicColors.primaryContainer().getArgb(scheme)).isSameColorAs(0xffe0e0ff);
}
@Test
public void lightTheme_standardContrast_primaryContainer() {
SchemeTonalSpot scheme = new SchemeTonalSpot(Hct.fromInt(0xff0000ff), false, 0.0);
- assertThat(MaterialDynamicColors.primaryContainer.getArgb(scheme)).isSameColorAs(
- 0xffe0e0ff);
+ assertThat(dynamicColors.primaryContainer().getArgb(scheme)).isSameColorAs(0xffe0e0ff);
}
@Test
public void lightTheme_maxContrast_primaryContainer() {
SchemeTonalSpot scheme = new SchemeTonalSpot(Hct.fromInt(0xff0000ff), false, 1.0);
- assertThat(MaterialDynamicColors.primaryContainer.getArgb(scheme)).isSameColorAs(
- 0xff3a3e74);
+ assertThat(dynamicColors.primaryContainer().getArgb(scheme)).isSameColorAs(0xff383c7c);
}
@Test
public void lightTheme_minContrast_onPrimaryContainer() {
SchemeTonalSpot scheme = new SchemeTonalSpot(Hct.fromInt(0xff0000ff), false, -1.0);
- assertThat(MaterialDynamicColors.onPrimaryContainer.getArgb(scheme)).isSameColorAs(
- 0xff5C5F98);
+ assertThat(dynamicColors.onPrimaryContainer().getArgb(scheme)).isSameColorAs(0xff5a5fa0);
}
@Test
public void lightTheme_standardContrast_onPrimaryContainer() {
SchemeTonalSpot scheme = new SchemeTonalSpot(Hct.fromInt(0xff0000ff), false, 0.0);
- assertThat(MaterialDynamicColors.onPrimaryContainer.getArgb(scheme)).isSameColorAs(
- 0xff11144B);
+ assertThat(dynamicColors.onPrimaryContainer().getArgb(scheme)).isSameColorAs(0xff0e1253);
}
@Test
public void lightTheme_maxContrast_onPrimaryContainer() {
SchemeTonalSpot scheme = new SchemeTonalSpot(Hct.fromInt(0xff0000ff), false, 1.0);
- assertThat(MaterialDynamicColors.onPrimaryContainer.getArgb(scheme)).isSameColorAs(
- 0xffd6d6ff);
+ assertThat(dynamicColors.onPrimaryContainer().getArgb(scheme)).isSameColorAs(0xffd6d6ff);
}
@Test
public void lightTheme_minContrast_surface() {
SchemeTonalSpot scheme = new SchemeTonalSpot(Hct.fromInt(0xff0000ff), false, -1.0);
- assertThat(MaterialDynamicColors.surface.getArgb(scheme)).isSameColorAs(0xffFCF8FD);
+ assertThat(dynamicColors.surface().getArgb(scheme)).isSameColorAs(0xfffbf8ff);
}
@Test
public void lightTheme_standardContrast_surface() {
SchemeTonalSpot scheme = new SchemeTonalSpot(Hct.fromInt(0xff0000ff), false, 0.0);
- assertThat(MaterialDynamicColors.surface.getArgb(scheme)).isSameColorAs(0xffFCF8FD);
+ assertThat(dynamicColors.surface().getArgb(scheme)).isSameColorAs(0xfffbf8ff);
}
@Test
public void lightTheme_maxContrast_surface() {
SchemeTonalSpot scheme = new SchemeTonalSpot(Hct.fromInt(0xff0000ff), false, 1.0);
- assertThat(MaterialDynamicColors.surface.getArgb(scheme)).isSameColorAs(0xffFCF8FD);
+ assertThat(dynamicColors.surface().getArgb(scheme)).isSameColorAs(0xfffbf8ff);
}
@Test
public void lightTheme_minContrast_onSurface() {
SchemeTonalSpot scheme = new SchemeTonalSpot(Hct.fromInt(0xff0000ff), false, -1.0);
- assertThat(MaterialDynamicColors.onSurface.getArgb(scheme)).isSameColorAs(0xff605E62);
+ assertThat(dynamicColors.onSurface().getArgb(scheme)).isSameColorAs(0xff5f5e65);
}
@Test
public void lightTheme_standardContrast_onSurface() {
SchemeTonalSpot scheme = new SchemeTonalSpot(Hct.fromInt(0xff0000ff), false, 0.0);
- assertThat(MaterialDynamicColors.onSurface.getArgb(scheme)).isSameColorAs(0xff1B1B1F);
+ assertThat(dynamicColors.onSurface().getArgb(scheme)).isSameColorAs(0xff1b1b21);
}
@Test
public void lightTheme_maxContrast_onSurface() {
SchemeTonalSpot scheme = new SchemeTonalSpot(Hct.fromInt(0xff0000ff), false, 1.0);
- assertThat(MaterialDynamicColors.onSurface.getArgb(scheme)).isSameColorAs(0xff1B1A1E);
+ assertThat(dynamicColors.onSurface().getArgb(scheme)).isSameColorAs(0xff1a1a20);
}
@Test
public void lightTheme_minContrast_onSecondary() {
SchemeTonalSpot scheme = new SchemeTonalSpot(Hct.fromInt(0xff0000ff), false, -1.0);
- assertThat(MaterialDynamicColors.onSecondary.getArgb(scheme)).isSameColorAs(0xffcfcfe7);
+ assertThat(dynamicColors.onSecondary().getArgb(scheme)).isSameColorAs(0xffcfcfe7);
}
@Test
public void lightTheme_standardContrast_onSecondary() {
SchemeTonalSpot scheme = new SchemeTonalSpot(Hct.fromInt(0xff0000ff), false, 0.0);
- assertThat(MaterialDynamicColors.onSecondary.getArgb(scheme)).isSameColorAs(0xffffffff);
+ assertThat(dynamicColors.onSecondary().getArgb(scheme)).isSameColorAs(0xffffffff);
}
@Test
public void lightTheme_maxContrast_onSecondary() {
SchemeTonalSpot scheme = new SchemeTonalSpot(Hct.fromInt(0xff0000ff), false, 1.0);
- assertThat(MaterialDynamicColors.onSecondary.getArgb(scheme)).isSameColorAs(0xffababc3);
+ assertThat(dynamicColors.onSecondary().getArgb(scheme)).isSameColorAs(0xffababc3);
}
@Test
public void lightTheme_minContrast_onTertiary() {
SchemeTonalSpot scheme = new SchemeTonalSpot(Hct.fromInt(0xff0000ff), false, -1.0);
- assertThat(MaterialDynamicColors.onTertiary.getArgb(scheme)).isSameColorAs(0xfff3c3df);
+ assertThat(dynamicColors.onTertiary().getArgb(scheme)).isSameColorAs(0xfff3c3df);
}
@Test
public void lightTheme_standardContrast_onTertiary() {
SchemeTonalSpot scheme = new SchemeTonalSpot(Hct.fromInt(0xff0000ff), false, 0.0);
- assertThat(MaterialDynamicColors.onTertiary.getArgb(scheme)).isSameColorAs(0xffffffff);
+ assertThat(dynamicColors.onTertiary().getArgb(scheme)).isSameColorAs(0xffffffff);
}
@Test
public void lightTheme_maxContrast_onTertiary() {
SchemeTonalSpot scheme = new SchemeTonalSpot(Hct.fromInt(0xff0000ff), false, 1.0);
- assertThat(MaterialDynamicColors.onTertiary.getArgb(scheme)).isSameColorAs(0xffcda0bb);
+ assertThat(dynamicColors.onTertiary().getArgb(scheme)).isSameColorAs(0xffcda0bb);
}
@Test
public void lightTheme_minContrast_onError() {
SchemeTonalSpot scheme = new SchemeTonalSpot(Hct.fromInt(0xff0000ff), false, -1.0);
- assertThat(MaterialDynamicColors.onError.getArgb(scheme)).isSameColorAs(0xffffc2bb);
+ assertThat(dynamicColors.onError().getArgb(scheme)).isSameColorAs(0xffffc2bb);
}
@Test
public void lightTheme_standardContrast_onError() {
SchemeTonalSpot scheme = new SchemeTonalSpot(Hct.fromInt(0xff0000ff), false, 0.0);
- assertThat(MaterialDynamicColors.onError.getArgb(scheme)).isSameColorAs(0xffffffff);
+ assertThat(dynamicColors.onError().getArgb(scheme)).isSameColorAs(0xffffffff);
}
@Test
public void lightTheme_maxContrast_onError() {
SchemeTonalSpot scheme = new SchemeTonalSpot(Hct.fromInt(0xff0000ff), false, 1.0);
- assertThat(MaterialDynamicColors.onError.getArgb(scheme)).isSameColorAs(0xffff8d80);
+ assertThat(dynamicColors.onError().getArgb(scheme)).isSameColorAs(0xffff8d80);
}
@Test
public void darkTheme_minContrast_primary() {
SchemeTonalSpot scheme = new SchemeTonalSpot(Hct.fromInt(0xff0000ff), true, -1.0);
- assertThat(MaterialDynamicColors.primary.getArgb(scheme)).isSameColorAs(0xff6C70AA);
+ assertThat(dynamicColors.primary().getArgb(scheme)).isSameColorAs(0xff6a6fb1);
}
@Test
public void darkTheme_standardContrast_primary() {
SchemeTonalSpot scheme = new SchemeTonalSpot(Hct.fromInt(0xff0000ff), true, 0.0);
- assertThat(MaterialDynamicColors.primary.getArgb(scheme)).isSameColorAs(0xffbec2ff);
+ assertThat(dynamicColors.primary().getArgb(scheme)).isSameColorAs(0xffbec2ff);
}
@Test
public void darkTheme_maxContrast_primary() {
SchemeTonalSpot scheme = new SchemeTonalSpot(Hct.fromInt(0xff0000ff), true, 1.0);
- assertThat(MaterialDynamicColors.primary.getArgb(scheme)).isSameColorAs(0xfff6f4ff);
+ assertThat(dynamicColors.primary().getArgb(scheme)).isSameColorAs(0xfff6f4ff);
}
@Test
public void darkTheme_minContrast_primaryContainer() {
SchemeTonalSpot scheme = new SchemeTonalSpot(Hct.fromInt(0xff0000ff), true, -1.0);
- assertThat(MaterialDynamicColors.primaryContainer.getArgb(scheme)).isSameColorAs(
- 0xff3E4278);
+ assertThat(dynamicColors.primaryContainer().getArgb(scheme)).isSameColorAs(0xff3c4180);
}
@Test
public void darkTheme_standardContrast_primaryContainer() {
SchemeTonalSpot scheme = new SchemeTonalSpot(Hct.fromInt(0xff0000ff), true, 0.0);
- assertThat(MaterialDynamicColors.primaryContainer.getArgb(scheme)).isSameColorAs(
- 0xff3E4278);
+ assertThat(dynamicColors.primaryContainer().getArgb(scheme)).isSameColorAs(0xff3c4180);
}
@Test
public void darkTheme_maxContrast_primaryContainer() {
SchemeTonalSpot scheme = new SchemeTonalSpot(Hct.fromInt(0xff0000ff), true, 1.0);
- assertThat(MaterialDynamicColors.primaryContainer.getArgb(scheme)).isSameColorAs(
- 0xffc4c6ff);
+ assertThat(dynamicColors.primaryContainer().getArgb(scheme)).isSameColorAs(0xffc4c6ff);
}
@Test
public void darkTheme_minContrast_onPrimaryContainer() {
SchemeTonalSpot scheme = new SchemeTonalSpot(Hct.fromInt(0xff0000ff), true, -1.0);
- assertThat(MaterialDynamicColors.onPrimaryContainer.getArgb(scheme)).isSameColorAs(
- 0xffadb0ef);
+ assertThat(dynamicColors.onPrimaryContainer().getArgb(scheme)).isSameColorAs(0xffabaff7);
}
@Test
public void darkTheme_standardContrast_onPrimaryContainer() {
SchemeTonalSpot scheme = new SchemeTonalSpot(Hct.fromInt(0xff0000ff), true, 0.0);
- assertThat(MaterialDynamicColors.onPrimaryContainer.getArgb(scheme)).isSameColorAs(
- 0xffe0e0ff);
+ assertThat(dynamicColors.onPrimaryContainer().getArgb(scheme)).isSameColorAs(0xffe0e0ff);
}
@Test
public void darkTheme_maxContrast_onPrimaryContainer() {
SchemeTonalSpot scheme = new SchemeTonalSpot(Hct.fromInt(0xff0000ff), true, 1.0);
- assertThat(MaterialDynamicColors.onPrimaryContainer.getArgb(scheme)).isSameColorAs(
- 0xff30346A);
+ assertThat(dynamicColors.onPrimaryContainer().getArgb(scheme)).isSameColorAs(0xff2e3271);
}
@Test
public void darkTheme_minContrast_onTertiaryContainer() {
SchemeTonalSpot scheme = new SchemeTonalSpot(Hct.fromInt(0xff0000ff), true, -1.0);
- assertThat(MaterialDynamicColors.onTertiaryContainer.getArgb(scheme)).isSameColorAs(
- 0xffd5a8c3);
+ assertThat(dynamicColors.onTertiaryContainer().getArgb(scheme)).isSameColorAs(0xffd5a8c3);
}
@Test
public void darkTheme_standardContrast_onTertiaryContainer() {
SchemeTonalSpot scheme = new SchemeTonalSpot(Hct.fromInt(0xff0000ff), true, 0.0);
- assertThat(MaterialDynamicColors.onTertiaryContainer.getArgb(scheme)).isSameColorAs(
- 0xffffd8ee);
+ assertThat(dynamicColors.onTertiaryContainer().getArgb(scheme)).isSameColorAs(0xffffd8ee);
}
@Test
public void darkTheme_maxContrast_onTertiaryContainer() {
SchemeTonalSpot scheme = new SchemeTonalSpot(Hct.fromInt(0xff0000ff), true, 1.0);
- assertThat(MaterialDynamicColors.onTertiaryContainer.getArgb(scheme)).isSameColorAs(
- 0xff4f2e44);
+ assertThat(dynamicColors.onTertiaryContainer().getArgb(scheme)).isSameColorAs(0xff4f2e44);
}
@Test
public void darkTheme_minContrast_onSecondary() {
SchemeTonalSpot scheme = new SchemeTonalSpot(Hct.fromInt(0xff0000ff), true, -1.0);
- assertThat(MaterialDynamicColors.onSecondary.getArgb(scheme)).isSameColorAs(0xfffffbff);
+ assertThat(dynamicColors.onSecondary().getArgb(scheme)).isSameColorAs(0xfffffbff);
}
@Test
public void darkTheme_standardContrast_onSecondary() {
SchemeTonalSpot scheme = new SchemeTonalSpot(Hct.fromInt(0xff0000ff), true, 0.0);
- assertThat(MaterialDynamicColors.onSecondary.getArgb(scheme)).isSameColorAs(0xff2e2f42);
+ assertThat(dynamicColors.onSecondary().getArgb(scheme)).isSameColorAs(0xff2e2f42);
}
@Test
public void darkTheme_maxContrast_onSecondary() {
SchemeTonalSpot scheme = new SchemeTonalSpot(Hct.fromInt(0xff0000ff), true, 1.0);
- assertThat(MaterialDynamicColors.onSecondary.getArgb(scheme)).isSameColorAs(0xff505165);
+ assertThat(dynamicColors.onSecondary().getArgb(scheme)).isSameColorAs(0xff505165);
}
@Test
public void darkTheme_minContrast_onTertiary() {
SchemeTonalSpot scheme = new SchemeTonalSpot(Hct.fromInt(0xff0000ff), true, -1.0);
- assertThat(MaterialDynamicColors.onTertiary.getArgb(scheme)).isSameColorAs(0xfffffbff);
+ assertThat(dynamicColors.onTertiary().getArgb(scheme)).isSameColorAs(0xfffffbff);
}
@Test
public void darkTheme_standardContrast_onTertiary() {
SchemeTonalSpot scheme = new SchemeTonalSpot(Hct.fromInt(0xff0000ff), true, 0.0);
- assertThat(MaterialDynamicColors.onTertiary.getArgb(scheme)).isSameColorAs(0xff46263b);
+ assertThat(dynamicColors.onTertiary().getArgb(scheme)).isSameColorAs(0xff46263b);
}
@Test
public void darkTheme_maxContrast_onTertiary() {
SchemeTonalSpot scheme = new SchemeTonalSpot(Hct.fromInt(0xff0000ff), true, 1.0);
- assertThat(MaterialDynamicColors.onTertiary.getArgb(scheme)).isSameColorAs(0xff6b485f);
+ assertThat(dynamicColors.onTertiary().getArgb(scheme)).isSameColorAs(0xff6b485f);
}
@Test
public void darkTheme_minContrast_onError() {
SchemeTonalSpot scheme = new SchemeTonalSpot(Hct.fromInt(0xff0000ff), true, -1.0);
- assertThat(MaterialDynamicColors.onError.getArgb(scheme)).isSameColorAs(0xfffffbff);
+ assertThat(dynamicColors.onError().getArgb(scheme)).isSameColorAs(0xfffffbff);
}
@Test
public void darkTheme_standardContrast_onError() {
SchemeTonalSpot scheme = new SchemeTonalSpot(Hct.fromInt(0xff0000ff), true, 0.0);
- assertThat(MaterialDynamicColors.onError.getArgb(scheme)).isSameColorAs(0xff690005);
+ assertThat(dynamicColors.onError().getArgb(scheme)).isSameColorAs(0xff690005);
}
@Test
public void darkTheme_maxContrast_onError() {
SchemeTonalSpot scheme = new SchemeTonalSpot(Hct.fromInt(0xff0000ff), true, 1.0);
- assertThat(MaterialDynamicColors.onError.getArgb(scheme)).isSameColorAs(0xffa80710);
+ assertThat(dynamicColors.onError().getArgb(scheme)).isSameColorAs(0xffa80710);
}
@Test
public void darkTheme_minContrast_surface() {
SchemeTonalSpot scheme = new SchemeTonalSpot(Hct.fromInt(0xff0000ff), true, -1.0);
- assertThat(MaterialDynamicColors.surface.getArgb(scheme)).isSameColorAs(0xff131316);
+ assertThat(dynamicColors.surface().getArgb(scheme)).isSameColorAs(0xff131318);
}
@Test
public void darkTheme_standardContrast_surface() {
SchemeTonalSpot scheme = new SchemeTonalSpot(Hct.fromInt(0xff0000ff), true, 0.0);
- assertThat(MaterialDynamicColors.surface.getArgb(scheme)).isSameColorAs(0xff131316);
+ assertThat(dynamicColors.surface().getArgb(scheme)).isSameColorAs(0xff131318);
}
@Test
public void darkTheme_maxContrast_surface() {
SchemeTonalSpot scheme = new SchemeTonalSpot(Hct.fromInt(0xff0000ff), true, 1.0);
- assertThat(MaterialDynamicColors.surface.getArgb(scheme)).isSameColorAs(0xff131316);
+ assertThat(dynamicColors.surface().getArgb(scheme)).isSameColorAs(0xff131318);
}
@Test
public void darkTheme_minContrast_onSurface() {
SchemeTonalSpot scheme = new SchemeTonalSpot(Hct.fromInt(0xff0000ff), true, -1.0);
- assertThat(MaterialDynamicColors.onSurface.getArgb(scheme)).isSameColorAs(0xffa4a2a6);
+ assertThat(dynamicColors.onSurface().getArgb(scheme)).isSameColorAs(0xffa4a2a9);
}
@Test
public void darkTheme_standardContrast_onSurface() {
SchemeTonalSpot scheme = new SchemeTonalSpot(Hct.fromInt(0xff0000ff), true, 0.0);
- assertThat(MaterialDynamicColors.onSurface.getArgb(scheme)).isSameColorAs(0xffe5e1e6);
+ assertThat(dynamicColors.onSurface().getArgb(scheme)).isSameColorAs(0xffe4e1e9);
}
@Test
public void darkTheme_maxContrast_onSurface() {
SchemeTonalSpot scheme = new SchemeTonalSpot(Hct.fromInt(0xff0000ff), true, 1.0);
- assertThat(MaterialDynamicColors.onSurface.getArgb(scheme)).isSameColorAs(0xffe6e2e7);
+ assertThat(dynamicColors.onSurface().getArgb(scheme)).isSameColorAs(0xffe5e2ea);
}
}
diff --git a/packages/SystemUI/tests/src/com/android/systemui/monet/SchemeVibrantTest.java b/packages/SystemUI/tests/src/com/android/systemui/monet/SchemeVibrantTest.java
index e5963a2..0fb53eb 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/monet/SchemeVibrantTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/monet/SchemeVibrantTest.java
@@ -25,204 +25,193 @@
import com.android.systemui.monet.hct.Hct;
import com.android.systemui.monet.scheme.SchemeVibrant;
+import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
+@Ignore("b/279581953")
@SmallTest
@RunWith(JUnit4.class)
public final class SchemeVibrantTest extends SysuiTestCase {
+ private final MaterialDynamicColors dynamicColors = new MaterialDynamicColors();
+
@Test
public void testKeyColors() {
SchemeVibrant scheme = new SchemeVibrant(Hct.fromInt(0xff0000ff), false, 0.0);
- assertThat(MaterialDynamicColors.primaryPaletteKeyColor.getArgb(scheme))
+ assertThat(dynamicColors.primaryPaletteKeyColor().getArgb(scheme))
.isSameColorAs(0xff080CFF);
- assertThat(MaterialDynamicColors.secondaryPaletteKeyColor.getArgb(scheme))
+ assertThat(dynamicColors.secondaryPaletteKeyColor().getArgb(scheme))
.isSameColorAs(0xff7B7296);
- assertThat(MaterialDynamicColors.tertiaryPaletteKeyColor.getArgb(scheme))
+ assertThat(dynamicColors.tertiaryPaletteKeyColor().getArgb(scheme))
.isSameColorAs(0xff886C9D);
- assertThat(MaterialDynamicColors.neutralPaletteKeyColor.getArgb(scheme))
+ assertThat(dynamicColors.neutralPaletteKeyColor().getArgb(scheme))
.isSameColorAs(0xff777682);
- assertThat(MaterialDynamicColors.neutralVariantPaletteKeyColor.getArgb(scheme))
+ assertThat(dynamicColors.neutralVariantPaletteKeyColor().getArgb(scheme))
.isSameColorAs(0xff767685);
}
@Test
public void lightTheme_minContrast_primary() {
SchemeVibrant scheme = new SchemeVibrant(Hct.fromInt(0xff0000ff), false, -1.0);
- assertThat(MaterialDynamicColors.primary.getArgb(scheme)).isSameColorAs(0xff5660ff);
+ assertThat(dynamicColors.primary().getArgb(scheme)).isSameColorAs(0xff5660ff);
}
@Test
public void lightTheme_standardContrast_primary() {
SchemeVibrant scheme = new SchemeVibrant(Hct.fromInt(0xff0000ff), false, 0.0);
- assertThat(MaterialDynamicColors.primary.getArgb(scheme)).isSameColorAs(0xff343dff);
+ assertThat(dynamicColors.primary().getArgb(scheme)).isSameColorAs(0xff343dff);
}
@Test
public void lightTheme_maxContrast_primary() {
SchemeVibrant scheme = new SchemeVibrant(Hct.fromInt(0xff0000ff), false, 1.0);
- assertThat(MaterialDynamicColors.primary.getArgb(scheme)).isSameColorAs(0xff000181);
+ assertThat(dynamicColors.primary().getArgb(scheme)).isSameColorAs(0xff000181);
}
@Test
public void lightTheme_minContrast_primaryContainer() {
SchemeVibrant scheme = new SchemeVibrant(Hct.fromInt(0xff0000ff), false, -1.0);
- assertThat(MaterialDynamicColors.primaryContainer.getArgb(scheme)).isSameColorAs(
- 0xffe0e0ff);
+ assertThat(dynamicColors.primaryContainer().getArgb(scheme)).isSameColorAs(0xffe0e0ff);
}
@Test
public void lightTheme_standardContrast_primaryContainer() {
SchemeVibrant scheme = new SchemeVibrant(Hct.fromInt(0xff0000ff), false, 0.0);
- assertThat(MaterialDynamicColors.primaryContainer.getArgb(scheme)).isSameColorAs(
- 0xffe0e0ff);
+ assertThat(dynamicColors.primaryContainer().getArgb(scheme)).isSameColorAs(0xffe0e0ff);
}
@Test
public void lightTheme_maxContrast_primaryContainer() {
SchemeVibrant scheme = new SchemeVibrant(Hct.fromInt(0xff0000ff), false, 1.0);
- assertThat(MaterialDynamicColors.primaryContainer.getArgb(scheme)).isSameColorAs(
- 0xff0000e3);
+ assertThat(dynamicColors.primaryContainer().getArgb(scheme)).isSameColorAs(0xff0000e3);
}
@Test
public void lightTheme_minContrast_onPrimaryContainer() {
SchemeVibrant scheme = new SchemeVibrant(Hct.fromInt(0xff0000ff), false, -1.0);
- assertThat(MaterialDynamicColors.onPrimaryContainer.getArgb(scheme)).isSameColorAs(
- 0xff3e47ff);
+ assertThat(dynamicColors.onPrimaryContainer().getArgb(scheme)).isSameColorAs(0xff3e47ff);
}
@Test
public void lightTheme_standardContrast_onPrimaryContainer() {
SchemeVibrant scheme = new SchemeVibrant(Hct.fromInt(0xff0000ff), false, 0.0);
- assertThat(MaterialDynamicColors.onPrimaryContainer.getArgb(scheme)).isSameColorAs(
- 0xff00006e);
+ assertThat(dynamicColors.onPrimaryContainer().getArgb(scheme)).isSameColorAs(0xff00006e);
}
@Test
public void lightTheme_maxContrast_onPrimaryContainer() {
SchemeVibrant scheme = new SchemeVibrant(Hct.fromInt(0xff0000ff), false, 1.0);
- assertThat(MaterialDynamicColors.onPrimaryContainer.getArgb(scheme)).isSameColorAs(
- 0xffd6d6ff);
+ assertThat(dynamicColors.onPrimaryContainer().getArgb(scheme)).isSameColorAs(0xffd6d6ff);
}
@Test
public void lightTheme_minContrast_surface() {
SchemeVibrant scheme = new SchemeVibrant(Hct.fromInt(0xff0000ff), false, -1.0);
- assertThat(MaterialDynamicColors.surface.getArgb(scheme)).isSameColorAs(0xfffbf8ff);
+ assertThat(dynamicColors.surface().getArgb(scheme)).isSameColorAs(0xfffbf8ff);
}
@Test
public void lightTheme_standardContrast_surface() {
SchemeVibrant scheme = new SchemeVibrant(Hct.fromInt(0xff0000ff), false, 0.0);
- assertThat(MaterialDynamicColors.surface.getArgb(scheme)).isSameColorAs(0xfffbf8ff);
+ assertThat(dynamicColors.surface().getArgb(scheme)).isSameColorAs(0xfffbf8ff);
}
@Test
public void lightTheme_maxContrast_surface() {
SchemeVibrant scheme = new SchemeVibrant(Hct.fromInt(0xff0000ff), false, 1.0);
- assertThat(MaterialDynamicColors.surface.getArgb(scheme)).isSameColorAs(0xfffbf8ff);
+ assertThat(dynamicColors.surface().getArgb(scheme)).isSameColorAs(0xfffbf8ff);
}
@Test
public void darkTheme_minContrast_primary() {
SchemeVibrant scheme = new SchemeVibrant(Hct.fromInt(0xff0000ff), true, -1.0);
- assertThat(MaterialDynamicColors.primary.getArgb(scheme)).isSameColorAs(0xff5660ff);
+ assertThat(dynamicColors.primary().getArgb(scheme)).isSameColorAs(0xff5660ff);
}
@Test
public void darkTheme_standardContrast_primary() {
SchemeVibrant scheme = new SchemeVibrant(Hct.fromInt(0xff0000ff), true, 0.0);
- assertThat(MaterialDynamicColors.primary.getArgb(scheme)).isSameColorAs(0xffbec2ff);
+ assertThat(dynamicColors.primary().getArgb(scheme)).isSameColorAs(0xffbec2ff);
}
@Test
public void darkTheme_maxContrast_primary() {
SchemeVibrant scheme = new SchemeVibrant(Hct.fromInt(0xff0000ff), true, 1.0);
- assertThat(MaterialDynamicColors.primary.getArgb(scheme)).isSameColorAs(0xfff6f4ff);
+ assertThat(dynamicColors.primary().getArgb(scheme)).isSameColorAs(0xfff6f4ff);
}
@Test
public void darkTheme_minContrast_primaryContainer() {
SchemeVibrant scheme = new SchemeVibrant(Hct.fromInt(0xff0000ff), true, -1.0);
- assertThat(MaterialDynamicColors.primaryContainer.getArgb(scheme)).isSameColorAs(
- 0xff0000ef);
+ assertThat(dynamicColors.primaryContainer().getArgb(scheme)).isSameColorAs(0xff0000ef);
}
@Test
public void darkTheme_standardContrast_primaryContainer() {
SchemeVibrant scheme = new SchemeVibrant(Hct.fromInt(0xff0000ff), true, 0.0);
- assertThat(MaterialDynamicColors.primaryContainer.getArgb(scheme)).isSameColorAs(
- 0xff0000ef);
+ assertThat(dynamicColors.primaryContainer().getArgb(scheme)).isSameColorAs(0xff0000ef);
}
@Test
public void darkTheme_maxContrast_primaryContainer() {
SchemeVibrant scheme = new SchemeVibrant(Hct.fromInt(0xff0000ff), true, 1.0);
- assertThat(MaterialDynamicColors.primaryContainer.getArgb(scheme)).isSameColorAs(
- 0xffc4c6ff);
+ assertThat(dynamicColors.primaryContainer().getArgb(scheme)).isSameColorAs(0xffc4c6ff);
}
@Test
public void darkTheme_minContrast_onPrimaryContainer() {
SchemeVibrant scheme = new SchemeVibrant(Hct.fromInt(0xff0000ff), true, -1.0);
- assertThat(MaterialDynamicColors.onPrimaryContainer.getArgb(scheme)).isSameColorAs(
- 0xffa9afff);
+ assertThat(dynamicColors.onPrimaryContainer().getArgb(scheme)).isSameColorAs(0xffa9afff);
}
@Test
public void darkTheme_standardContrast_onPrimaryContainer() {
SchemeVibrant scheme = new SchemeVibrant(Hct.fromInt(0xff0000ff), true, 0.0);
- assertThat(MaterialDynamicColors.onPrimaryContainer.getArgb(scheme)).isSameColorAs(
- 0xffe0e0ff);
+ assertThat(dynamicColors.onPrimaryContainer().getArgb(scheme)).isSameColorAs(0xffe0e0ff);
}
@Test
public void darkTheme_maxContrast_onPrimaryContainer() {
SchemeVibrant scheme = new SchemeVibrant(Hct.fromInt(0xff0000ff), true, 1.0);
- assertThat(MaterialDynamicColors.onPrimaryContainer.getArgb(scheme)).isSameColorAs(
- 0xff0001c6);
+ assertThat(dynamicColors.onPrimaryContainer().getArgb(scheme)).isSameColorAs(0xff0001c6);
}
@Test
public void darkTheme_minContrast_onTertiaryContainer() {
SchemeVibrant scheme = new SchemeVibrant(Hct.fromInt(0xff0000ff), true, -1.0);
- assertThat(MaterialDynamicColors.onTertiaryContainer.getArgb(scheme)).isSameColorAs(
- 0xffc9a9df);
+ assertThat(dynamicColors.onTertiaryContainer().getArgb(scheme)).isSameColorAs(0xffc9a9df);
}
@Test
public void darkTheme_standardContrast_onTertiaryContainer() {
SchemeVibrant scheme = new SchemeVibrant(Hct.fromInt(0xff0000ff), true, 0.0);
- assertThat(MaterialDynamicColors.onTertiaryContainer.getArgb(scheme)).isSameColorAs(
- 0xfff2daff);
+ assertThat(dynamicColors.onTertiaryContainer().getArgb(scheme)).isSameColorAs(0xfff2daff);
}
@Test
public void darkTheme_maxContrast_onTertiaryContainer() {
SchemeVibrant scheme = new SchemeVibrant(Hct.fromInt(0xff0000ff), true, 1.0);
- assertThat(MaterialDynamicColors.onTertiaryContainer.getArgb(scheme)).isSameColorAs(
- 0xff472e5b);
+ assertThat(dynamicColors.onTertiaryContainer().getArgb(scheme)).isSameColorAs(0xff472e5b);
}
@Test
public void darkTheme_minContrast_surface() {
SchemeVibrant scheme = new SchemeVibrant(Hct.fromInt(0xff0000ff), true, -1.0);
- assertThat(MaterialDynamicColors.surface.getArgb(scheme)).isSameColorAs(0xff12131C);
+ assertThat(dynamicColors.surface().getArgb(scheme)).isSameColorAs(0xff12131a);
}
@Test
public void darkTheme_standardContrast_surface() {
SchemeVibrant scheme = new SchemeVibrant(Hct.fromInt(0xff0000ff), true, 0.0);
- assertThat(MaterialDynamicColors.surface.getArgb(scheme)).isSameColorAs(0xff12131C);
+ assertThat(dynamicColors.surface().getArgb(scheme)).isSameColorAs(0xff12131a);
}
@Test
public void darkTheme_maxContrast_surface() {
SchemeVibrant scheme = new SchemeVibrant(Hct.fromInt(0xff0000ff), true, 1.0);
- assertThat(MaterialDynamicColors.surface.getArgb(scheme)).isSameColorAs(0xff12131C);
+ assertThat(dynamicColors.surface().getArgb(scheme)).isSameColorAs(0xff12131a);
}
}
diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/row/ExpandableNotificationRowTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/row/ExpandableNotificationRowTest.java
index 9186c35..4c83194 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/row/ExpandableNotificationRowTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/row/ExpandableNotificationRowTest.java
@@ -617,24 +617,9 @@
}
@Test
- public void applyRoundnessAndInv_should_be_immediately_applied_on_childrenContainer_legacy()
- throws Exception {
- ExpandableNotificationRow group = mNotificationTestHelper.createGroup();
- group.useRoundnessSourceTypes(false);
- Assert.assertEquals(0f, group.getBottomRoundness(), 0.001f);
- Assert.assertEquals(0f, group.getChildrenContainer().getBottomRoundness(), 0.001f);
-
- group.requestBottomRoundness(1f, SourceType.from(""), false);
-
- Assert.assertEquals(1f, group.getBottomRoundness(), 0.001f);
- Assert.assertEquals(1f, group.getChildrenContainer().getBottomRoundness(), 0.001f);
- }
-
- @Test
public void applyRoundnessAndInvalidate_should_be_immediately_applied_on_childrenContainer()
throws Exception {
ExpandableNotificationRow group = mNotificationTestHelper.createGroup();
- group.useRoundnessSourceTypes(true);
Assert.assertEquals(0f, group.getBottomRoundness(), 0.001f);
Assert.assertEquals(0f, group.getChildrenContainer().getBottomRoundness(), 0.001f);
diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/stack/NotificationChildrenContainerTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/stack/NotificationChildrenContainerTest.java
index e41929f..be976a1c 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/stack/NotificationChildrenContainerTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/stack/NotificationChildrenContainerTest.java
@@ -25,7 +25,6 @@
import androidx.test.filters.SmallTest;
import com.android.systemui.SysuiTestCase;
-import com.android.systemui.statusbar.notification.LegacySourceType;
import com.android.systemui.statusbar.notification.SourceType;
import com.android.systemui.statusbar.notification.row.ExpandableNotificationRow;
import com.android.systemui.statusbar.notification.row.NotificationTestHelper;
@@ -158,55 +157,7 @@
}
@Test
- public void addNotification_shouldResetOnScrollRoundness() throws Exception {
- ExpandableNotificationRow row = mNotificationTestHelper.createRowWithRoundness(
- /* topRoundness = */ 1f,
- /* bottomRoundness = */ 1f,
- /* sourceType = */ LegacySourceType.OnScroll);
-
- mChildrenContainer.addNotification(row, 0);
-
- Assert.assertEquals(0f, row.getTopRoundness(), /* delta = */ 0f);
- Assert.assertEquals(0f, row.getBottomRoundness(), /* delta = */ 0f);
- }
-
- @Test
- public void addNotification_shouldNotResetOtherRoundness() throws Exception {
- ExpandableNotificationRow row1 = mNotificationTestHelper.createRowWithRoundness(
- /* topRoundness = */ 1f,
- /* bottomRoundness = */ 1f,
- /* sourceType = */ LegacySourceType.DefaultValue);
- ExpandableNotificationRow row2 = mNotificationTestHelper.createRowWithRoundness(
- /* topRoundness = */ 1f,
- /* bottomRoundness = */ 1f,
- /* sourceType = */ LegacySourceType.OnDismissAnimation);
-
- mChildrenContainer.addNotification(row1, 0);
- mChildrenContainer.addNotification(row2, 0);
-
- Assert.assertEquals(1f, row1.getTopRoundness(), /* delta = */ 0f);
- Assert.assertEquals(1f, row1.getBottomRoundness(), /* delta = */ 0f);
- Assert.assertEquals(1f, row2.getTopRoundness(), /* delta = */ 0f);
- Assert.assertEquals(1f, row2.getBottomRoundness(), /* delta = */ 0f);
- }
-
- @Test
- public void applyRoundnessAndInvalidate_should_be_immediately_applied_on_last_child_legacy() {
- mChildrenContainer.useRoundnessSourceTypes(false);
- List<ExpandableNotificationRow> children = mChildrenContainer.getAttachedChildren();
- ExpandableNotificationRow notificationRow = children.get(children.size() - 1);
- Assert.assertEquals(0f, mChildrenContainer.getBottomRoundness(), 0.001f);
- Assert.assertEquals(0f, notificationRow.getBottomRoundness(), 0.001f);
-
- mChildrenContainer.requestBottomRoundness(1f, SourceType.from(""), false);
-
- Assert.assertEquals(1f, mChildrenContainer.getBottomRoundness(), 0.001f);
- Assert.assertEquals(1f, notificationRow.getBottomRoundness(), 0.001f);
- }
-
- @Test
public void applyRoundnessAndInvalidate_should_be_immediately_applied_on_last_child() {
- mChildrenContainer.useRoundnessSourceTypes(true);
List<ExpandableNotificationRow> children = mChildrenContainer.getAttachedChildren();
ExpandableNotificationRow notificationRow = children.get(children.size() - 1);
Assert.assertEquals(0f, mChildrenContainer.getBottomRoundness(), 0.001f);
@@ -220,8 +171,6 @@
@Test
public void applyRoundnessAndInvalidate_should_be_immediately_applied_on_header() {
- mChildrenContainer.useRoundnessSourceTypes(true);
-
NotificationHeaderViewWrapper header = mChildrenContainer.getNotificationHeaderWrapper();
Assert.assertEquals(0f, header.getTopRoundness(), 0.001f);
@@ -232,7 +181,6 @@
@Test
public void applyRoundnessAndInvalidate_should_be_immediately_applied_on_headerLowPriority() {
- mChildrenContainer.useRoundnessSourceTypes(true);
mChildrenContainer.setIsLowPriority(true);
NotificationHeaderViewWrapper header = mChildrenContainer.getNotificationHeaderWrapper();
diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/stack/NotificationShelfTest.kt b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/stack/NotificationShelfTest.kt
index b1d3daa..05b70eb 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/stack/NotificationShelfTest.kt
+++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/stack/NotificationShelfTest.kt
@@ -12,7 +12,6 @@
import com.android.systemui.shade.transition.LargeScreenShadeInterpolator
import com.android.systemui.statusbar.NotificationShelf
import com.android.systemui.statusbar.StatusBarIconView
-import com.android.systemui.statusbar.notification.LegacySourceType
import com.android.systemui.statusbar.notification.row.ExpandableNotificationRow
import com.android.systemui.statusbar.notification.row.ExpandableView
import com.android.systemui.statusbar.notification.row.NotificationTestHelper
@@ -359,39 +358,6 @@
)
}
- @Test
- fun resetOnScrollRoundness_shouldSetOnScrollTo0() {
- val row: ExpandableNotificationRow = notificationTestHelper.createRowWithRoundness(
- /* topRoundness = */ 1f,
- /* bottomRoundness = */ 1f,
- /* sourceType = */ LegacySourceType.OnScroll)
-
- NotificationShelf.resetLegacyOnScrollRoundness(row)
-
- assertEquals(0f, row.topRoundness)
- assertEquals(0f, row.bottomRoundness)
- }
-
- @Test
- fun resetOnScrollRoundness_shouldNotResetOtherRoundness() {
- val row1: ExpandableNotificationRow = notificationTestHelper.createRowWithRoundness(
- /* topRoundness = */ 1f,
- /* bottomRoundness = */ 1f,
- /* sourceType = */ LegacySourceType.DefaultValue)
- val row2: ExpandableNotificationRow = notificationTestHelper.createRowWithRoundness(
- /* topRoundness = */ 1f,
- /* bottomRoundness = */ 1f,
- /* sourceType = */ LegacySourceType.OnDismissAnimation)
-
- NotificationShelf.resetLegacyOnScrollRoundness(row1)
- NotificationShelf.resetLegacyOnScrollRoundness(row2)
-
- assertEquals(1f, row1.topRoundness)
- assertEquals(1f, row1.bottomRoundness)
- assertEquals(1f, row2.topRoundness)
- assertEquals(1f, row2.bottomRoundness)
- }
-
private fun setFractionToShade(fraction: Float) {
whenever(ambientState.fractionToShade).thenReturn(fraction)
}
diff --git a/services/core/java/com/android/server/display/AutomaticBrightnessController.java b/services/core/java/com/android/server/display/AutomaticBrightnessController.java
index 378363c..774087c 100644
--- a/services/core/java/com/android/server/display/AutomaticBrightnessController.java
+++ b/services/core/java/com/android/server/display/AutomaticBrightnessController.java
@@ -366,7 +366,12 @@
return getAutomaticScreenBrightness(null);
}
- float getAutomaticScreenBrightness(BrightnessEvent brightnessEvent) {
+ /**
+ * @return The current brightness recommendation calculated from the current conditions.
+ * @param brightnessEvent Event object to populate with details about why the specific
+ * brightness was chosen.
+ */
+ public float getAutomaticScreenBrightness(BrightnessEvent brightnessEvent) {
if (brightnessEvent != null) {
brightnessEvent.setLux(
mAmbientLuxValid ? mAmbientLux : PowerManager.BRIGHTNESS_INVALID_FLOAT);
diff --git a/services/core/java/com/android/server/display/ColorFade.java b/services/core/java/com/android/server/display/ColorFade.java
index a4bd6a6..46cd496 100644
--- a/services/core/java/com/android/server/display/ColorFade.java
+++ b/services/core/java/com/android/server/display/ColorFade.java
@@ -191,7 +191,7 @@
}
if (!(createEglContext(isProtected) && createEglSurface(isProtected, isWideColor)
- && setScreenshotTextureAndSetViewport(hardwareBuffer))) {
+ && setScreenshotTextureAndSetViewport(hardwareBuffer, displayInfo.rotation))) {
dismiss();
return false;
}
@@ -500,7 +500,8 @@
}
private boolean setScreenshotTextureAndSetViewport(
- ScreenCapture.ScreenshotHardwareBuffer screenshotBuffer) {
+ ScreenCapture.ScreenshotHardwareBuffer screenshotBuffer,
+ @Surface.Rotation int rotation) {
if (!attachEglContext()) {
return false;
}
@@ -525,14 +526,22 @@
s.release();
st.release();
}
+ // if screen is rotated, map texture starting different corner
+ int indexDelta = (rotation == Surface.ROTATION_90) ? 2
+ : (rotation == Surface.ROTATION_180) ? 4
+ : (rotation == Surface.ROTATION_270) ? 6 : 0;
// Set up texture coordinates for a quad.
// We might need to change this if the texture ends up being
// a different size from the display for some reason.
- mTexCoordBuffer.put(0, 0f); mTexCoordBuffer.put(1, 0f);
- mTexCoordBuffer.put(2, 0f); mTexCoordBuffer.put(3, 1f);
- mTexCoordBuffer.put(4, 1f); mTexCoordBuffer.put(5, 1f);
- mTexCoordBuffer.put(6, 1f); mTexCoordBuffer.put(7, 0f);
+ mTexCoordBuffer.put(indexDelta, 0f);
+ mTexCoordBuffer.put(indexDelta + 1, 0f);
+ mTexCoordBuffer.put((indexDelta + 2) % 8, 0f);
+ mTexCoordBuffer.put((indexDelta + 3) % 8, 1f);
+ mTexCoordBuffer.put((indexDelta + 4) % 8, 1f);
+ mTexCoordBuffer.put((indexDelta + 5) % 8, 1f);
+ mTexCoordBuffer.put((indexDelta + 6) % 8, 1f);
+ mTexCoordBuffer.put((indexDelta + 7) % 8, 0f);
// Set up our viewport.
GLES20.glViewport(0, 0, mDisplayWidth, mDisplayHeight);
diff --git a/services/core/java/com/android/server/display/DisplayManagerService.java b/services/core/java/com/android/server/display/DisplayManagerService.java
index 26b6cb0..5771a04 100644
--- a/services/core/java/com/android/server/display/DisplayManagerService.java
+++ b/services/core/java/com/android/server/display/DisplayManagerService.java
@@ -2548,7 +2548,6 @@
final DisplayInfo displayInfo = logicalDisplay.getDisplayInfoLocked();
captureArgs = new ScreenCapture.DisplayCaptureArgs.Builder(token)
.setSize(displayInfo.getNaturalWidth(), displayInfo.getNaturalHeight())
- .setUseIdentityTransform(true)
.setCaptureSecureLayers(true)
.setAllowProtected(true)
.build();
diff --git a/services/core/java/com/android/server/display/DisplayPowerController.java b/services/core/java/com/android/server/display/DisplayPowerController.java
index 0d89ba8..0861cb5 100644
--- a/services/core/java/com/android/server/display/DisplayPowerController.java
+++ b/services/core/java/com/android/server/display/DisplayPowerController.java
@@ -83,6 +83,7 @@
import com.android.server.policy.WindowManagerPolicy;
import java.io.PrintWriter;
+import java.util.Objects;
/**
* Controls the power state of the display.
@@ -605,7 +606,7 @@
mLastBrightnessEvent = new BrightnessEvent(mDisplayId);
mTempBrightnessEvent = new BrightnessEvent(mDisplayId);
mThermalBrightnessThrottlingDataId =
- logicalDisplay.getThermalBrightnessThrottlingDataIdLocked();
+ logicalDisplay.getDisplayInfoLocked().thermalBrightnessThrottlingDataId;
if (mDisplayId == Display.DEFAULT_DISPLAY) {
mBatteryStats = BatteryStatsService.getService();
@@ -955,7 +956,7 @@
&& mLogicalDisplay.getPrimaryDisplayDeviceLocked()
.getDisplayDeviceInfoLocked().type == Display.TYPE_INTERNAL;
final String thermalBrightnessThrottlingDataId =
- mLogicalDisplay.getThermalBrightnessThrottlingDataIdLocked();
+ mLogicalDisplay.getDisplayInfoLocked().thermalBrightnessThrottlingDataId;
mHandler.postAtTime(() -> {
boolean changed = false;
if (mDisplayDevice != device) {
@@ -972,8 +973,8 @@
// last command that was sent to change it's state. Let's assume it is unknown so
// that we trigger a change immediately.
mPowerState.resetScreenState();
- } else if (
- !mThermalBrightnessThrottlingDataId.equals(thermalBrightnessThrottlingDataId)) {
+ } else if (!Objects.equals(mThermalBrightnessThrottlingDataId,
+ thermalBrightnessThrottlingDataId)) {
changed = true;
mThermalBrightnessThrottlingDataId = thermalBrightnessThrottlingDataId;
mBrightnessThrottler.loadThermalBrightnessThrottlingDataFromDisplayDeviceConfig(
@@ -2189,7 +2190,8 @@
() -> {
sendUpdatePowerState();
postBrightnessChangeRunnable();
- }, mUniqueDisplayId, mLogicalDisplay.getThermalBrightnessThrottlingDataIdLocked(),
+ }, mUniqueDisplayId,
+ mLogicalDisplay.getDisplayInfoLocked().thermalBrightnessThrottlingDataId,
ddConfig.getThermalBrightnessThrottlingDataMapByThrottlingId());
}
diff --git a/services/core/java/com/android/server/display/DisplayPowerController2.java b/services/core/java/com/android/server/display/DisplayPowerController2.java
index 9e8c47f..3b3d5da 100644
--- a/services/core/java/com/android/server/display/DisplayPowerController2.java
+++ b/services/core/java/com/android/server/display/DisplayPowerController2.java
@@ -85,6 +85,7 @@
import com.android.server.policy.WindowManagerPolicy;
import java.io.PrintWriter;
+import java.util.Objects;
/**
* Controls the power state of the display.
@@ -488,7 +489,7 @@
mAutomaticBrightnessStrategy = new AutomaticBrightnessStrategy(context, mDisplayId);
mTag = "DisplayPowerController2[" + mDisplayId + "]";
mThermalBrightnessThrottlingDataId =
- logicalDisplay.getThermalBrightnessThrottlingDataIdLocked();
+ logicalDisplay.getDisplayInfoLocked().thermalBrightnessThrottlingDataId;
mDisplayDevice = mLogicalDisplay.getPrimaryDisplayDeviceLocked();
mUniqueDisplayId = logicalDisplay.getPrimaryDisplayDeviceLocked().getUniqueId();
@@ -760,7 +761,7 @@
&& mLogicalDisplay.getPrimaryDisplayDeviceLocked()
.getDisplayDeviceInfoLocked().type == Display.TYPE_INTERNAL;
final String thermalBrightnessThrottlingDataId =
- mLogicalDisplay.getThermalBrightnessThrottlingDataIdLocked();
+ mLogicalDisplay.getDisplayInfoLocked().thermalBrightnessThrottlingDataId;
mHandler.postAtTime(() -> {
boolean changed = false;
@@ -778,8 +779,8 @@
// last command that was sent to change it's state. Let's assume it is unknown so
// that we trigger a change immediately.
mPowerState.resetScreenState();
- } else if (
- !mThermalBrightnessThrottlingDataId.equals(thermalBrightnessThrottlingDataId)) {
+ } else if (!Objects.equals(mThermalBrightnessThrottlingDataId,
+ thermalBrightnessThrottlingDataId)) {
changed = true;
mThermalBrightnessThrottlingDataId = thermalBrightnessThrottlingDataId;
mBrightnessThrottler.loadThermalBrightnessThrottlingDataFromDisplayDeviceConfig(
@@ -1301,7 +1302,8 @@
int brightnessAdjustmentFlags = 0;
if (Float.isNaN(brightnessState)) {
if (mAutomaticBrightnessStrategy.isAutoBrightnessEnabled()) {
- brightnessState = mAutomaticBrightnessStrategy.getAutomaticScreenBrightness();
+ brightnessState = mAutomaticBrightnessStrategy.getAutomaticScreenBrightness(
+ mTempBrightnessEvent);
if (BrightnessUtils.isValidBrightnessValue(brightnessState)
|| brightnessState == PowerManager.BRIGHTNESS_OFF_FLOAT) {
rawBrightnessState = mAutomaticBrightnessController
@@ -1820,7 +1822,8 @@
() -> {
sendUpdatePowerState();
postBrightnessChangeRunnable();
- }, mUniqueDisplayId, mLogicalDisplay.getThermalBrightnessThrottlingDataIdLocked(),
+ }, mUniqueDisplayId,
+ mLogicalDisplay.getDisplayInfoLocked().thermalBrightnessThrottlingDataId,
ddConfig.getThermalBrightnessThrottlingDataMapByThrottlingId());
}
diff --git a/services/core/java/com/android/server/display/LogicalDisplay.java b/services/core/java/com/android/server/display/LogicalDisplay.java
index 0b6d1c8..e5c50e6 100644
--- a/services/core/java/com/android/server/display/LogicalDisplay.java
+++ b/services/core/java/com/android/server/display/LogicalDisplay.java
@@ -203,6 +203,7 @@
mIsEnabled = true;
mIsInTransition = false;
mThermalBrightnessThrottlingDataId = DisplayDeviceConfig.DEFAULT_ID;
+ mBaseDisplayInfo.thermalBrightnessThrottlingDataId = mThermalBrightnessThrottlingDataId;
}
public void setDevicePositionLocked(int position) {
@@ -514,6 +515,7 @@
mBaseDisplayInfo.layoutLimitedRefreshRate = mLayoutLimitedRefreshRate;
mBaseDisplayInfo.thermalRefreshRateThrottling = mThermalRefreshRateThrottling;
+ mBaseDisplayInfo.thermalBrightnessThrottlingDataId = mThermalBrightnessThrottlingDataId;
mPrimaryDisplayDeviceInfo = deviceInfo;
mInfo.set(null);
@@ -886,19 +888,14 @@
}
/**
- * @return The ID of the brightness throttling data that this display should use.
- */
- public String getThermalBrightnessThrottlingDataIdLocked() {
- return mThermalBrightnessThrottlingDataId;
- }
-
- /**
* @param brightnessThrottlingDataId The ID of the brightness throttling data that this
* display should use.
*/
public void setThermalBrightnessThrottlingDataIdLocked(String brightnessThrottlingDataId) {
- mThermalBrightnessThrottlingDataId =
- brightnessThrottlingDataId;
+ if (!Objects.equals(brightnessThrottlingDataId, mThermalBrightnessThrottlingDataId)) {
+ mThermalBrightnessThrottlingDataId = brightnessThrottlingDataId;
+ mDirty = true;
+ }
}
/**
diff --git a/services/core/java/com/android/server/display/brightness/strategy/AutomaticBrightnessStrategy.java b/services/core/java/com/android/server/display/brightness/strategy/AutomaticBrightnessStrategy.java
index f6cf866..95cbf98 100644
--- a/services/core/java/com/android/server/display/brightness/strategy/AutomaticBrightnessStrategy.java
+++ b/services/core/java/com/android/server/display/brightness/strategy/AutomaticBrightnessStrategy.java
@@ -25,6 +25,7 @@
import com.android.internal.annotations.VisibleForTesting;
import com.android.server.display.AutomaticBrightnessController;
+import com.android.server.display.brightness.BrightnessEvent;
import com.android.server.display.brightness.BrightnessReason;
import com.android.server.display.brightness.BrightnessUtils;
@@ -252,10 +253,12 @@
/**
* Evaluates the target automatic brightness of the associated display.
+ * @param brightnessEvent Event object to populate with details about why the specific
+ * brightness was chosen.
*/
- public float getAutomaticScreenBrightness() {
+ public float getAutomaticScreenBrightness(BrightnessEvent brightnessEvent) {
float brightness = (mAutomaticBrightnessController != null)
- ? mAutomaticBrightnessController.getAutomaticScreenBrightness()
+ ? mAutomaticBrightnessController.getAutomaticScreenBrightness(brightnessEvent)
: PowerManager.BRIGHTNESS_INVALID_FLOAT;
adjustAutomaticBrightnessStateIfValid(brightness);
return brightness;
diff --git a/services/core/java/com/android/server/pm/DefaultCrossProfileIntentFiltersUtils.java b/services/core/java/com/android/server/pm/DefaultCrossProfileIntentFiltersUtils.java
index 48ee64f..8a28888 100644
--- a/services/core/java/com/android/server/pm/DefaultCrossProfileIntentFiltersUtils.java
+++ b/services/core/java/com/android/server/pm/DefaultCrossProfileIntentFiltersUtils.java
@@ -437,6 +437,16 @@
.addCategory(Intent.CATEGORY_DEFAULT)
.build();
+ private static final DefaultCrossProfileIntentFilter CLONE_TO_PARENT_PHOTOPICKER_SELECTION =
+ new DefaultCrossProfileIntentFilter.Builder(
+ DefaultCrossProfileIntentFilter.Direction.TO_PARENT,
+ /* flags= */ 0x00000018, // 0x00000018 means FLAG_IS_PACKAGE_FOR_FILTER
+ // and FLAG_ALLOW_CHAINED_RESOLUTION set
+ /* letsPersonalDataIntoProfile= */ false)
+ .addAction(MediaStore.ACTION_USER_SELECT_IMAGES_FOR_APP)
+ .addCategory(Intent.CATEGORY_DEFAULT)
+ .build();
+
/*
Allowing send action from clone to parent profile to share content from clone apps to parent
apps
@@ -611,7 +621,8 @@
CLONE_TO_PARENT_VIEW_ACTION,
CLONE_TO_PARENT_PICK_INSERT_ACTION,
CLONE_TO_PARENT_DIAL_DATA,
- CLONE_TO_PARENT_SMS_MMS
+ CLONE_TO_PARENT_SMS_MMS,
+ CLONE_TO_PARENT_PHOTOPICKER_SELECTION
);
}
}
diff --git a/services/core/java/com/android/server/tv/TvInputHardwareManager.java b/services/core/java/com/android/server/tv/TvInputHardwareManager.java
index 580b4d6..077f8d5 100755
--- a/services/core/java/com/android/server/tv/TvInputHardwareManager.java
+++ b/services/core/java/com/android/server/tv/TvInputHardwareManager.java
@@ -1124,18 +1124,6 @@
}
}
- private boolean setTvMessageEnabled(int deviceId, TvStreamConfig streamConfig, int type,
- boolean enabled) {
- synchronized (mImplLock) {
- if (mReleased) {
- return false;
- }
-
- return mHal.setTvMessageEnabled(deviceId, streamConfig, type, enabled)
- == TvInputHal.SUCCESS;
- }
- }
-
private boolean startCapture(Surface surface, TvStreamConfig config) {
synchronized (mImplLock) {
if (mReleased) {
diff --git a/services/core/java/com/android/server/wm/WindowContainer.java b/services/core/java/com/android/server/wm/WindowContainer.java
index 510e675..a5cdd0b 100644
--- a/services/core/java/com/android/server/wm/WindowContainer.java
+++ b/services/core/java/com/android/server/wm/WindowContainer.java
@@ -3594,8 +3594,11 @@
&& !mTransitionController.useShellTransitionsRotation()) {
if (deltaRotation != Surface.ROTATION_0) {
updateSurfaceRotation(t, deltaRotation, null /* positionLeash */);
+ t.setFixedTransformHint(mSurfaceControl,
+ getWindowConfiguration().getDisplayRotation());
} else if (deltaRotation != mLastDeltaRotation) {
t.setMatrix(mSurfaceControl, 1, 0, 0, 1);
+ t.unsetFixedTransformHint(mSurfaceControl);
}
}
mLastDeltaRotation = deltaRotation;
diff --git a/services/core/java/com/android/server/wm/WindowState.java b/services/core/java/com/android/server/wm/WindowState.java
index 6f07b77..032f08a 100644
--- a/services/core/java/com/android/server/wm/WindowState.java
+++ b/services/core/java/com/android/server/wm/WindowState.java
@@ -1980,19 +1980,16 @@
/**
* Like isOnScreen(), but we don't return true if the window is part
- * of a transition but has not yet started animating.
+ * of a transition that has not yet been started.
*/
boolean isReadyForDisplay() {
- if (!mHasSurface || mDestroying || !isVisibleByPolicy()) {
- return false;
- }
- if (mToken.waitingToShow && getDisplayContent().mAppTransition.isTransitionSet()
- && !isAnimating(TRANSITION | PARENTS, ANIMATION_TYPE_APP_TRANSITION)) {
+ if (mToken.waitingToShow && getDisplayContent().mAppTransition.isTransitionSet()) {
return false;
}
final boolean parentAndClientVisible = !isParentWindowHidden()
&& mViewVisibility == View.VISIBLE && mToken.isVisible();
- return parentAndClientVisible || isAnimating(TRANSITION | PARENTS, ANIMATION_TYPE_ALL);
+ return mHasSurface && isVisibleByPolicy() && !mDestroying
+ && (parentAndClientVisible || isAnimating(TRANSITION | PARENTS));
}
boolean isFullyTransparent() {
diff --git a/services/core/java/com/android/server/wm/WindowToken.java b/services/core/java/com/android/server/wm/WindowToken.java
index da54b15..4c5efef 100644
--- a/services/core/java/com/android/server/wm/WindowToken.java
+++ b/services/core/java/com/android/server/wm/WindowToken.java
@@ -596,6 +596,7 @@
.build();
t.setPosition(leash, mLastSurfacePosition.x, mLastSurfacePosition.y);
t.reparent(getSurfaceControl(), leash);
+ t.setFixedTransformHint(leash, getWindowConfiguration().getDisplayRotation());
mFixedRotationTransformLeash = leash;
updateSurfaceRotation(t, rotation, mFixedRotationTransformLeash);
return mFixedRotationTransformLeash;
diff --git a/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java b/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java
index a35f34d..231fee3 100644
--- a/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java
+++ b/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java
@@ -39,7 +39,6 @@
import static android.Manifest.permission.MANAGE_DEVICE_POLICY_DISPLAY;
import static android.Manifest.permission.MANAGE_DEVICE_POLICY_FACTORY_RESET;
import static android.Manifest.permission.MANAGE_DEVICE_POLICY_FUN;
-import static android.Manifest.permission.MANAGE_DEVICE_POLICY_INPUT_METHODS;
import static android.Manifest.permission.MANAGE_DEVICE_POLICY_INSTALL_UNKNOWN_SOURCES;
import static android.Manifest.permission.MANAGE_DEVICE_POLICY_KEYGUARD;
import static android.Manifest.permission.MANAGE_DEVICE_POLICY_LOCALE;
@@ -521,6 +520,7 @@
import java.security.cert.X509Certificate;
import java.text.DateFormat;
import java.time.LocalDate;
+import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
@@ -533,6 +533,7 @@
import java.util.Locale;
import java.util.Map;
import java.util.Objects;
+import java.util.Queue;
import java.util.Set;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutionException;
@@ -568,7 +569,15 @@
private static final int REQUEST_PROFILE_OFF_DEADLINE = 5572;
+ // Binary XML serializer doesn't support longer strings
+ private static final int MAX_POLICY_STRING_LENGTH = 65535;
+ // FrameworkParsingPackageUtils#MAX_FILE_NAME_SIZE, Android packages are used in dir names.
+ private static final int MAX_PACKAGE_NAME_LENGTH = 223;
+
private static final int MAX_PROFILE_NAME_LENGTH = 200;
+ private static final int MAX_LONG_SUPPORT_MESSAGE_LENGTH = 20000;
+ private static final int MAX_SHORT_SUPPORT_MESSAGE_LENGTH = 200;
+ private static final int MAX_ORG_NAME_LENGTH = 200;
private static final long MS_PER_DAY = TimeUnit.DAYS.toMillis(1);
@@ -6041,7 +6050,7 @@
@Override
public void lockNow(int flags, String callerPackageName, boolean parent) {
CallerIdentity caller;
- if (isPolicyEngineForFinanceFlagEnabled()) {
+ if (isPermissionCheckFlagEnabled()) {
caller = getCallerIdentity(callerPackageName);
} else {
caller = getCallerIdentity();
@@ -6053,7 +6062,7 @@
ActiveAdmin admin;
// Make sure the caller has any active admin with the right policy or
// the required permission.
- if (isPolicyEngineForFinanceFlagEnabled()) {
+ if (isPermissionCheckFlagEnabled()) {
admin = enforcePermissionAndGetEnforcingAdmin(
/* admin= */ null,
/* permission= */ MANAGE_DEVICE_POLICY_LOCK,
@@ -8907,13 +8916,13 @@
}
CallerIdentity caller;
- if (isPolicyEngineForFinanceFlagEnabled()) {
+ if (isPermissionCheckFlagEnabled()) {
caller = getCallerIdentity(who, callerPackageName);
} else {
caller = getCallerIdentity(who);
}
- if (isPolicyEngineForFinanceFlagEnabled()) {
+ if (isPermissionCheckFlagEnabled()) {
// The effect of this policy is device-wide.
enforcePermission(SET_TIME, caller.getPackageName(), UserHandle.USER_ALL);
} else {
@@ -8941,13 +8950,13 @@
return false;
}
CallerIdentity caller;
- if (isPolicyEngineForFinanceFlagEnabled()) {
+ if (isPermissionCheckFlagEnabled()) {
caller = getCallerIdentity(who, callerPackageName);
} else {
caller = getCallerIdentity(who);
}
- if (isPolicyEngineForFinanceFlagEnabled()) {
+ if (isPermissionCheckFlagEnabled()) {
enforceCanQuery(SET_TIME, caller.getPackageName(), UserHandle.USER_ALL);
} else {
Objects.requireNonNull(who, "ComponentName is null");
@@ -8976,7 +8985,7 @@
caller = getCallerIdentity(who);
}
- if (isPolicyEngineForFinanceFlagEnabled()) {
+ if (isPermissionCheckFlagEnabled()) {
// The effect of this policy is device-wide.
EnforcingAdmin enforcingAdmin = enforcePermissionAndGetEnforcingAdmin(
who,
@@ -9016,13 +9025,13 @@
}
CallerIdentity caller;
- if (isPolicyEngineForFinanceFlagEnabled()) {
+ if (isPermissionCheckFlagEnabled()) {
caller = getCallerIdentity(who, callerPackageName);
} else {
caller = getCallerIdentity(who);
}
- if (isPolicyEngineForFinanceFlagEnabled()) {
+ if (isPermissionCheckFlagEnabled()) {
// The effect of this policy is device-wide.
enforceCanQuery(SET_TIME_ZONE, caller.getPackageName(), UserHandle.USER_ALL);
} else {
@@ -9325,7 +9334,7 @@
}
CallerIdentity caller;
- if (isPolicyEngineForFinanceFlagEnabled()) {
+ if (isPermissionCheckFlagEnabled()) {
caller = getCallerIdentity(who, callerPackageName);
} else {
caller = getCallerIdentity(who);
@@ -9335,7 +9344,7 @@
final int userHandle = caller.getUserId();
int affectedUserId = parent ? getProfileParentId(userHandle) : userHandle;
synchronized (getLockObject()) {
- if (isPolicyEngineForFinanceFlagEnabled()) {
+ if (isPermissionCheckFlagEnabled()) {
// SUPPORT USES_POLICY_DISABLE_KEYGUARD_FEATURES
EnforcingAdmin admin = enforcePermissionAndGetEnforcingAdmin(
who, MANAGE_DEVICE_POLICY_KEYGUARD, caller.getPackageName(),
@@ -9414,7 +9423,7 @@
synchronized (getLockObject()) {
if (who != null) {
- if (isPolicyEngineForFinanceFlagEnabled()) {
+ if (isPermissionCheckFlagEnabled()) {
EnforcingAdmin admin = getEnforcingAdminForCaller(
who, who.getPackageName());
Integer features = mDevicePolicyEngine.getLocalPolicySetByAdmin(
@@ -9428,7 +9437,7 @@
}
}
- if (isPolicyEngineForFinanceFlagEnabled()) {
+ if (isPermissionCheckFlagEnabled()) {
Integer features = mDevicePolicyEngine.getResolvedPolicy(
PolicyDefinition.KEYGUARD_DISABLED_FEATURES,
affectedUserId);
@@ -11625,7 +11634,7 @@
final CallerIdentity caller = getCallerIdentity(who, callerPackage);
checkCanExecuteOrThrowUnsafe(DevicePolicyManager.OPERATION_SET_APPLICATION_RESTRICTIONS);
- if (isPolicyEngineForFinanceFlagEnabled()) {
+ if (isPermissionCheckFlagEnabled()) {
EnforcingAdmin enforcingAdmin = enforcePermissionAndGetEnforcingAdmin(
who,
MANAGE_DEVICE_POLICY_APP_RESTRICTIONS,
@@ -11730,7 +11739,15 @@
}
Objects.requireNonNull(agent, "agent is null");
- int userHandle = UserHandle.getCallingUserId();
+
+ enforceMaxPackageNameLength(agent.getPackageName());
+ final String agentAsString = agent.flattenToString();
+ enforceMaxStringLength(agentAsString, "agent name");
+ if (args != null) {
+ enforceMaxStringLength(args, "args");
+ }
+
+ int userHandle = mInjector.userHandleGetCallingUserId();
synchronized (getLockObject()) {
ActiveAdmin ap;
if (isPermissionCheckFlagEnabled()) {
@@ -11747,7 +11764,7 @@
checkCanExecuteOrThrowUnsafe(
DevicePolicyManager.OPERATION_SET_TRUST_AGENT_CONFIGURATION);
- ap.trustAgentInfos.put(agent.flattenToString(), new TrustAgentInfo(args));
+ ap.trustAgentInfos.put(agentAsString, new TrustAgentInfo(args));
saveSettingsLocked(userHandle);
}
}
@@ -12017,6 +12034,10 @@
isDeviceOwner(caller) || isProfileOwner(caller));
if (packageList != null) {
+ for (String pkg : packageList) {
+ enforceMaxPackageNameLength(pkg);
+ }
+
int userId = caller.getUserId();
final List<AccessibilityServiceInfo> enabledServices;
long id = mInjector.binderClearCallingIdentity();
@@ -12198,6 +12219,10 @@
}
if (packageList != null) {
+ for (String pkg : packageList) {
+ enforceMaxPackageNameLength(pkg);
+ }
+
List<InputMethodInfo> enabledImes = mInjector.binderWithCleanCallingIdentity(() ->
InputMethodManagerInternal.get().getEnabledInputMethodListAsUser(userId));
if (enabledImes != null) {
@@ -13034,7 +13059,7 @@
String packageName) {
final CallerIdentity caller = getCallerIdentity(who, callerPackage);
- if (isPolicyEngineForFinanceFlagEnabled()) {
+ if (isPermissionCheckFlagEnabled()) {
EnforcingAdmin enforcingAdmin = enforceCanQueryAndGetEnforcingAdmin(
who,
MANAGE_DEVICE_POLICY_APP_RESTRICTIONS,
@@ -13104,7 +13129,7 @@
final CallerIdentity caller = getCallerIdentity(who, callerPackage);
ActiveAdmin admin;
- if (isPolicyEngineForFinanceFlagEnabled()) {
+ if (isPermissionCheckFlagEnabled()) {
EnforcingAdmin enforcingAdmin = enforcePermissionAndGetEnforcingAdmin(
who,
MANAGE_DEVICE_POLICY_PACKAGE_STATE,
@@ -13201,7 +13226,7 @@
public boolean isPackageSuspended(ComponentName who, String callerPackage, String packageName) {
final CallerIdentity caller = getCallerIdentity(who, callerPackage);
- if (isPolicyEngineForFinanceFlagEnabled()) {
+ if (isPermissionCheckFlagEnabled()) {
enforcePermission(
MANAGE_DEVICE_POLICY_PACKAGE_STATE,
caller.getPackageName(),
@@ -13807,7 +13832,7 @@
boolean hidden, boolean parent) {
CallerIdentity caller = getCallerIdentity(who, callerPackage);
final int userId = parent ? getProfileParentId(caller.getUserId()) : caller.getUserId();
- if (isPolicyEngineForFinanceFlagEnabled()) {
+ if (isPermissionCheckFlagEnabled()) {
// TODO: We need to ensure the delegate with DELEGATION_PACKAGE_ACCESS can do this
enforcePermission(MANAGE_DEVICE_POLICY_PACKAGE_STATE, caller.getPackageName(), userId);
} else {
@@ -13826,7 +13851,7 @@
boolean result;
synchronized (getLockObject()) {
if (parent) {
- if (!isPolicyEngineForFinanceFlagEnabled()) {
+ if (!isPermissionCheckFlagEnabled()) {
Preconditions.checkCallAuthorization(
isProfileOwnerOfOrganizationOwnedDevice(
caller.getUserId()) && isManagedProfile(caller.getUserId()));
@@ -13843,7 +13868,7 @@
Slogf.v(LOG_TAG, "calling pm.setApplicationHiddenSettingAsUser(%s, %b, %d)",
packageName, hidden, userId);
}
- if (isPolicyEngineForFinanceFlagEnabled()) {
+ if (isPermissionCheckFlagEnabled()) {
EnforcingAdmin admin = getEnforcingAdminForCaller(who, callerPackage);
mDevicePolicyEngine.setLocalPolicy(
PolicyDefinition.APPLICATION_HIDDEN(packageName),
@@ -13882,7 +13907,7 @@
String packageName, boolean parent) {
CallerIdentity caller = getCallerIdentity(who, callerPackage);
int userId = parent ? getProfileParentId(caller.getUserId()) : caller.getUserId();
- if (isPolicyEngineForFinanceFlagEnabled()) {
+ if (isPermissionCheckFlagEnabled()) {
// TODO: Also support DELEGATION_PACKAGE_ACCESS
enforcePermission(MANAGE_DEVICE_POLICY_PACKAGE_STATE, caller.getPackageName(), userId);
} else {
@@ -13894,7 +13919,7 @@
synchronized (getLockObject()) {
if (parent) {
- if (!isPolicyEngineForFinanceFlagEnabled()) {
+ if (!isPermissionCheckFlagEnabled()) {
Preconditions.checkCallAuthorization(
isProfileOwnerOfOrganizationOwnedDevice(caller.getUserId())
&& isManagedProfile(caller.getUserId()));
@@ -14082,14 +14107,17 @@
if (!mHasFeature) {
return;
}
+
+ enforceMaxStringLength(accountType, "account type");
+
CallerIdentity caller;
- if (isPolicyEngineForFinanceFlagEnabled()) {
+ if (isPermissionCheckFlagEnabled()) {
caller = getCallerIdentity(who, callerPackageName);
} else {
caller = getCallerIdentity(who);
}
synchronized (getLockObject()) {
- if (isPolicyEngineForFinanceFlagEnabled()) {
+ if (isPermissionCheckFlagEnabled()) {
int affectedUser = getAffectedUser(parent);
EnforcingAdmin enforcingAdmin = enforcePermissionAndGetEnforcingAdmin(
who,
@@ -14152,7 +14180,7 @@
CallerIdentity caller;
Preconditions.checkArgumentNonnegative(userId, "Invalid userId");
final ArraySet<String> resultSet = new ArraySet<>();
- if (isPolicyEngineForFinanceFlagEnabled()) {
+ if (isPermissionCheckFlagEnabled()) {
int affectedUser = parent ? getProfileParentId(userId) : userId;
caller = getCallerIdentity(callerPackageName);
if (!hasPermission(MANAGE_DEVICE_POLICY_ACCOUNT_MANAGEMENT,
@@ -14772,6 +14800,10 @@
public void setLockTaskPackages(ComponentName who, String callerPackageName, String[] packages)
throws SecurityException {
Objects.requireNonNull(packages, "packages is null");
+ for (String pkg : packages) {
+ enforceMaxPackageNameLength(pkg);
+ }
+
CallerIdentity caller;
if (isPolicyEngineForFinanceFlagEnabled()) {
caller = getCallerIdentity(who, callerPackageName);
@@ -15519,12 +15551,12 @@
public boolean setStatusBarDisabled(ComponentName who, String callerPackageName,
boolean disabled) {
CallerIdentity caller;
- if (isPolicyEngineForFinanceFlagEnabled()) {
+ if (isPermissionCheckFlagEnabled()) {
caller = getCallerIdentity(who, callerPackageName);
} else {
caller = getCallerIdentity(who);
}
- if (isPolicyEngineForFinanceFlagEnabled()) {
+ if (isPermissionCheckFlagEnabled()) {
enforcePermission(MANAGE_DEVICE_POLICY_STATUS_BAR, caller.getPackageName(),
UserHandle.USER_ALL);
} else {
@@ -15535,7 +15567,7 @@
int userId = caller.getUserId();
synchronized (getLockObject()) {
- if (!isPolicyEngineForFinanceFlagEnabled()) {
+ if (!isPermissionCheckFlagEnabled()) {
Preconditions.checkCallAuthorization(isUserAffiliatedWithDeviceLocked(userId),
"Admin " + who + " is neither the device owner or affiliated "
+ "user's profile owner.");
@@ -15594,7 +15626,7 @@
@Override
public boolean isStatusBarDisabled(String callerPackage) {
final CallerIdentity caller = getCallerIdentity(callerPackage);
- if (isPolicyEngineForFinanceFlagEnabled()) {
+ if (isPermissionCheckFlagEnabled()) {
enforceCanQuery(
MANAGE_DEVICE_POLICY_STATUS_BAR, caller.getPackageName(), caller.getUserId());
} else {
@@ -15604,7 +15636,7 @@
int userId = caller.getUserId();
synchronized (getLockObject()) {
- if (!isPolicyEngineForFinanceFlagEnabled()) {
+ if (!isPermissionCheckFlagEnabled()) {
Preconditions.checkCallAuthorization(isUserAffiliatedWithDeviceLocked(userId),
"Admin " + callerPackage
+ " is neither the device owner or affiliated user's profile owner.");
@@ -16764,7 +16796,7 @@
}
}
EnforcingAdmin enforcingAdmin;
- if (isPolicyEngineForFinanceFlagEnabled()) {
+ if (isPermissionCheckFlagEnabled()) {
enforcingAdmin = enforcePermissionAndGetEnforcingAdmin(
admin,
MANAGE_DEVICE_POLICY_RUNTIME_PERMISSIONS,
@@ -16935,7 +16967,7 @@
public int getPermissionGrantState(ComponentName admin, String callerPackage,
String packageName, String permission) throws RemoteException {
final CallerIdentity caller = getCallerIdentity(admin, callerPackage);
- if (isPolicyEngineForFinanceFlagEnabled()) {
+ if (isPermissionCheckFlagEnabled()) {
enforceCanQuery(MANAGE_DEVICE_POLICY_RUNTIME_PERMISSIONS, caller.getPackageName(),
caller.getUserId());
} else {
@@ -17374,6 +17406,8 @@
CallerIdentity caller;
ActiveAdmin admin;
+ message = truncateIfLonger(message, MAX_SHORT_SUPPORT_MESSAGE_LENGTH);
+
if (isPermissionCheckFlagEnabled()) {
caller = getCallerIdentity(who, callerPackageName);
EnforcingAdmin enforcingAdmin = enforcePermissionAndGetEnforcingAdmin(
@@ -17434,6 +17468,9 @@
if (!mHasFeature) {
return;
}
+
+ message = truncateIfLonger(message, MAX_LONG_SUPPORT_MESSAGE_LENGTH);
+
Objects.requireNonNull(who, "ComponentName is null");
final CallerIdentity caller = getCallerIdentity(who);
synchronized (getLockObject()) {
@@ -17598,6 +17635,8 @@
Preconditions.checkCallAuthorization(isDeviceOwner(caller) || isProfileOwner(caller));
}
+ text = truncateIfLonger(text, MAX_ORG_NAME_LENGTH);
+
synchronized (getLockObject()) {
if (!isPermissionCheckFlagEnabled()) {
admin = getProfileOwnerOrDeviceOwnerLocked(caller.getUserId());
@@ -17878,9 +17917,8 @@
throw new IllegalArgumentException("ids must not be null");
}
for (String id : ids) {
- if (TextUtils.isEmpty(id)) {
- throw new IllegalArgumentException("ids must not contain empty string");
- }
+ Preconditions.checkArgument(!TextUtils.isEmpty(id), "ids must not have empty string");
+ enforceMaxStringLength(id, "affiliation id");
}
final Set<String> affiliationIds = new ArraySet<>(ids);
@@ -19067,14 +19105,14 @@
throw new IllegalArgumentException("token must be at least 32-byte long");
}
CallerIdentity caller;
- if (isPolicyEngineForFinanceFlagEnabled()) {
+ if (isPermissionCheckFlagEnabled()) {
caller = getCallerIdentity(admin, callerPackageName);
} else {
caller = getCallerIdentity(admin);
}
final int userId = caller.getUserId();
- if (isPolicyEngineForFinanceFlagEnabled()) {
+ if (isPermissionCheckFlagEnabled()) {
EnforcingAdmin enforcingAdmin = enforcePermissionAndGetEnforcingAdmin(
admin,
MANAGE_DEVICE_POLICY_RESET_PASSWORD,
@@ -19130,7 +19168,7 @@
return false;
}
CallerIdentity caller;
- if (isPolicyEngineForFinanceFlagEnabled()) {
+ if (isPermissionCheckFlagEnabled()) {
caller = getCallerIdentity(admin, callerPackageName);
} else {
caller = getCallerIdentity(admin);
@@ -19138,7 +19176,7 @@
final int userId = caller.getUserId();
boolean result = false;
- if (isPolicyEngineForFinanceFlagEnabled()) {
+ if (isPermissionCheckFlagEnabled()) {
EnforcingAdmin enforcingAdmin = enforcePermissionAndGetEnforcingAdmin(
admin,
MANAGE_DEVICE_POLICY_RESET_PASSWORD,
@@ -19177,14 +19215,14 @@
return false;
}
CallerIdentity caller;
- if (isPolicyEngineForFinanceFlagEnabled()) {
+ if (isPermissionCheckFlagEnabled()) {
caller = getCallerIdentity(admin, callerPackageName);
} else {
caller = getCallerIdentity(admin);
}
int userId = caller.getUserId();
- if (isPolicyEngineForFinanceFlagEnabled()) {
+ if (isPermissionCheckFlagEnabled()) {
EnforcingAdmin enforcingAdmin = enforcePermissionAndGetEnforcingAdmin(
admin,
MANAGE_DEVICE_POLICY_RESET_PASSWORD,
@@ -19393,6 +19431,9 @@
"Provided administrator and target are the same object.");
Preconditions.checkArgument(!admin.getPackageName().equals(target.getPackageName()),
"Provided administrator and target have the same package name.");
+ if (bundle != null) {
+ enforceMaxStringLength(bundle, "bundle");
+ }
final CallerIdentity caller = getCallerIdentity(admin);
Preconditions.checkCallAuthorization(
@@ -24137,6 +24178,53 @@
});
}
+ /**
+ * Truncates char sequence to maximum length, nulls are ignored.
+ */
+ private static CharSequence truncateIfLonger(CharSequence input, int maxLength) {
+ return input == null || input.length() <= maxLength
+ ? input
+ : input.subSequence(0, maxLength);
+ }
+
+ /**
+ * Throw if string argument is too long to be serialized.
+ */
+ private static void enforceMaxStringLength(String str, String argName) {
+ Preconditions.checkArgument(
+ str.length() <= MAX_POLICY_STRING_LENGTH, argName + " loo long");
+ }
+
+ private static void enforceMaxPackageNameLength(String pkg) {
+ Preconditions.checkArgument(
+ pkg.length() <= MAX_PACKAGE_NAME_LENGTH, "Package name too long");
+ }
+
+ /**
+ * Throw if persistable bundle contains any string that we can't serialize.
+ */
+ private static void enforceMaxStringLength(PersistableBundle bundle, String argName) {
+ // Persistable bundles can have other persistable bundles as values, traverse with a queue.
+ Queue<PersistableBundle> queue = new ArrayDeque<>();
+ queue.add(bundle);
+ while (!queue.isEmpty()) {
+ PersistableBundle current = queue.remove();
+ for (String key : current.keySet()) {
+ enforceMaxStringLength(key, "key in " + argName);
+ Object value = current.get(key);
+ if (value instanceof String) {
+ enforceMaxStringLength((String) value, "string value in " + argName);
+ } else if (value instanceof String[]) {
+ for (String str : (String[]) value) {
+ enforceMaxStringLength(str, "string value in " + argName);
+ }
+ } else if (value instanceof PersistableBundle) {
+ queue.add((PersistableBundle) value);
+ }
+ }
+ }
+ }
+
private ActiveAdmin getActiveAdminForCaller(@Nullable ComponentName who,
CallerIdentity caller) {
synchronized (getLockObject()) {
diff --git a/services/tests/mockingservicestests/src/com/android/server/display/DisplayPowerController2Test.java b/services/tests/mockingservicestests/src/com/android/server/display/DisplayPowerController2Test.java
index c4aa0bb..8dc0ac6 100644
--- a/services/tests/mockingservicestests/src/com/android/server/display/DisplayPowerController2Test.java
+++ b/services/tests/mockingservicestests/src/com/android/server/display/DisplayPowerController2Test.java
@@ -64,6 +64,7 @@
import com.android.server.LocalServices;
import com.android.server.am.BatteryStatsService;
import com.android.server.display.RampAnimator.DualRampAnimator;
+import com.android.server.display.brightness.BrightnessEvent;
import com.android.server.display.color.ColorDisplayService;
import com.android.server.display.layout.Layout;
import com.android.server.display.whitebalance.DisplayWhiteBalanceController;
@@ -596,17 +597,17 @@
// We should still set screen state for the default display
DisplayPowerRequest dpr = new DisplayPowerRequest();
mHolder.dpc.requestPowerState(dpr, /* waitForNegativeProximity= */ false);
- advanceTime(1);
+ advanceTime(1); // Run updatePowerState
verify(mHolder.displayPowerState, times(2)).setScreenState(anyInt());
mHolder = createDisplayPowerController(42, UNIQUE_ID);
mHolder.dpc.requestPowerState(dpr, /* waitForNegativeProximity= */ false);
- advanceTime(1);
+ advanceTime(1); // Run updatePowerState
verify(mHolder.displayPowerState, never()).setScreenState(anyInt());
mHolder.dpc.onBootCompleted();
- advanceTime(1);
+ advanceTime(1); // Run updatePowerState
verify(mHolder.displayPowerState).setScreenState(anyInt());
}
@@ -632,8 +633,8 @@
.thenReturn(brightness);
dpr.policy = DisplayPowerRequest.POLICY_BRIGHT;
when(mHolder.displayPowerState.getScreenState()).thenReturn(Display.STATE_ON);
- when(mHolder.automaticBrightnessController.getAutomaticScreenBrightness())
- .thenReturn(PowerManager.BRIGHTNESS_INVALID_FLOAT);
+ when(mHolder.automaticBrightnessController.getAutomaticScreenBrightness(
+ any(BrightnessEvent.class))).thenReturn(PowerManager.BRIGHTNESS_INVALID_FLOAT);
mHolder.dpc.requestPowerState(dpr, /* waitForNegativeProximity= */ false);
advanceTime(1); // Run updatePowerState
@@ -667,8 +668,8 @@
.thenReturn(brightness);
dpr.policy = DisplayPowerRequest.POLICY_BRIGHT;
when(mHolder.displayPowerState.getScreenState()).thenReturn(Display.STATE_ON);
- when(mHolder.automaticBrightnessController.getAutomaticScreenBrightness())
- .thenReturn(PowerManager.BRIGHTNESS_INVALID_FLOAT);
+ when(mHolder.automaticBrightnessController.getAutomaticScreenBrightness(
+ any(BrightnessEvent.class))).thenReturn(PowerManager.BRIGHTNESS_INVALID_FLOAT);
mHolder.dpc.requestPowerState(dpr, /* waitForNegativeProximity= */ false);
advanceTime(1); // Run updatePowerState
@@ -822,6 +823,21 @@
);
}
+ @Test
+ public void testUpdateBrightnessThrottlingDataId() {
+ mHolder.display.getDisplayInfoLocked().thermalBrightnessThrottlingDataId =
+ "throttling-data-id";
+ clearInvocations(mHolder.display.getPrimaryDisplayDeviceLocked().getDisplayDeviceConfig());
+
+ mHolder.dpc.onDisplayChanged(mHolder.hbmMetadata, Layout.NO_LEAD_DISPLAY);
+ DisplayPowerRequest dpr = new DisplayPowerRequest();
+ mHolder.dpc.requestPowerState(dpr, /* waitForNegativeProximity= */ false);
+ advanceTime(1); // Run updatePowerState
+
+ verify(mHolder.display.getPrimaryDisplayDeviceLocked().getDisplayDeviceConfig())
+ .getThermalBrightnessThrottlingDataMapByThrottlingId();
+ }
+
/**
* Creates a mock and registers it to {@link LocalServices}.
*/
@@ -862,8 +878,6 @@
when(logicalDisplayMock.getDisplayInfoLocked()).thenReturn(info);
when(logicalDisplayMock.isEnabledLocked()).thenReturn(isEnabled);
when(logicalDisplayMock.isInTransitionLocked()).thenReturn(false);
- when(logicalDisplayMock.getThermalBrightnessThrottlingDataIdLocked()).thenReturn(
- DisplayDeviceConfig.DEFAULT_ID);
when(displayDeviceMock.getDisplayDeviceInfoLocked()).thenReturn(deviceInfo);
when(displayDeviceMock.getUniqueId()).thenReturn(uniqueId);
when(displayDeviceMock.getDisplayDeviceConfig()).thenReturn(displayDeviceConfigMock);
diff --git a/services/tests/mockingservicestests/src/com/android/server/display/DisplayPowerControllerTest.java b/services/tests/mockingservicestests/src/com/android/server/display/DisplayPowerControllerTest.java
index 415adbb..5c0810f 100644
--- a/services/tests/mockingservicestests/src/com/android/server/display/DisplayPowerControllerTest.java
+++ b/services/tests/mockingservicestests/src/com/android/server/display/DisplayPowerControllerTest.java
@@ -829,6 +829,21 @@
);
}
+ @Test
+ public void testUpdateBrightnessThrottlingDataId() {
+ mHolder.display.getDisplayInfoLocked().thermalBrightnessThrottlingDataId =
+ "throttling-data-id";
+ clearInvocations(mHolder.display.getPrimaryDisplayDeviceLocked().getDisplayDeviceConfig());
+
+ mHolder.dpc.onDisplayChanged(mHolder.hbmMetadata, Layout.NO_LEAD_DISPLAY);
+ DisplayPowerRequest dpr = new DisplayPowerRequest();
+ mHolder.dpc.requestPowerState(dpr, /* waitForNegativeProximity= */ false);
+ advanceTime(1); // Run updatePowerState
+
+ verify(mHolder.display.getPrimaryDisplayDeviceLocked().getDisplayDeviceConfig())
+ .getThermalBrightnessThrottlingDataMapByThrottlingId();
+ }
+
/**
* Creates a mock and registers it to {@link LocalServices}.
*/
@@ -869,8 +884,6 @@
when(logicalDisplayMock.getDisplayInfoLocked()).thenReturn(info);
when(logicalDisplayMock.isEnabledLocked()).thenReturn(isEnabled);
when(logicalDisplayMock.isInTransitionLocked()).thenReturn(false);
- when(logicalDisplayMock.getThermalBrightnessThrottlingDataIdLocked()).thenReturn(
- DisplayDeviceConfig.DEFAULT_ID);
when(displayDeviceMock.getDisplayDeviceInfoLocked()).thenReturn(deviceInfo);
when(displayDeviceMock.getUniqueId()).thenReturn(uniqueId);
when(displayDeviceMock.getDisplayDeviceConfig()).thenReturn(displayDeviceConfigMock);
diff --git a/services/tests/servicestests/src/com/android/server/devicepolicy/DevicePolicyManagerTest.java b/services/tests/servicestests/src/com/android/server/devicepolicy/DevicePolicyManagerTest.java
index 34b88b0..1e342f5 100644
--- a/services/tests/servicestests/src/com/android/server/devicepolicy/DevicePolicyManagerTest.java
+++ b/services/tests/servicestests/src/com/android/server/devicepolicy/DevicePolicyManagerTest.java
@@ -130,6 +130,7 @@
import android.os.Build.VERSION_CODES;
import android.os.Bundle;
import android.os.IpcDataCache;
+import android.os.PersistableBundle;
import android.os.Process;
import android.os.UserHandle;
import android.os.UserManager;
@@ -1511,7 +1512,6 @@
* Validates that when the device owner is removed, the reset password token is cleared
*/
@Test
- @Ignore("b/277916462")
public void testClearDeviceOwner_clearResetPasswordToken() throws Exception {
mContext.callerPermissions.add(android.Manifest.permission.MANAGE_DEVICE_ADMINS);
mContext.callerPermissions.add(permission.MANAGE_PROFILE_AND_DEVICE_OWNERS);
@@ -2602,7 +2602,6 @@
}
@Test
- @Ignore("b/277916462")
public void testSetApplicationHiddenWithDO() throws Exception {
mContext.binder.callingUid = DpmMockContext.CALLER_SYSTEM_USER_UID;
setupDeviceOwner();
@@ -2628,7 +2627,6 @@
}
@Test
- @Ignore("b/277916462")
public void testSetApplicationHiddenWithPOOfOrganizationOwnedDevice() throws Exception {
final int MANAGED_PROFILE_USER_ID = CALLER_USER_HANDLE;
final int MANAGED_PROFILE_ADMIN_UID =
@@ -4375,7 +4373,6 @@
}
@Test
- @Ignore("b/277916462")
public void testSetAutoTimeZoneEnabledModifiesSetting() throws Exception {
mContext.binder.callingUid = DpmMockContext.CALLER_SYSTEM_USER_UID;
setupDeviceOwner();
@@ -4387,7 +4384,6 @@
}
@Test
- @Ignore("b/277916462")
public void testSetAutoTimeZoneEnabledWithPOOnUser0() throws Exception {
mContext.binder.callingUid = DpmMockContext.SYSTEM_UID;
setupProfileOwnerOnUser0();
@@ -4399,7 +4395,6 @@
}
@Test
- @Ignore("b/277916462")
public void testSetAutoTimeZoneEnabledFailWithPONotOnUser0() throws Exception {
setupProfileOwner();
assertExpectException(SecurityException.class, null,
@@ -4409,7 +4404,6 @@
}
@Test
- @Ignore("b/277916462")
public void testSetAutoTimeZoneEnabledWithPOOfOrganizationOwnedDevice() throws Exception {
setupProfileOwner();
configureProfileOwnerOfOrgOwnedDevice(admin1, CALLER_USER_HANDLE);
@@ -5383,7 +5377,6 @@
}
@Test
- @Ignore("b/277916462")
public void testResetPasswordWithToken() throws Exception {
mContext.binder.callingUid = DpmMockContext.CALLER_SYSTEM_USER_UID;
setupDeviceOwner();
@@ -5418,7 +5411,6 @@
}
@Test
- @Ignore("b/277916462")
public void resetPasswordWithToken_NumericPin() throws Exception {
mContext.binder.callingUid = DpmMockContext.CALLER_SYSTEM_USER_UID;
setupDeviceOwner();
@@ -5439,7 +5431,6 @@
}
@Test
- @Ignore("b/277916462")
public void resetPasswordWithToken_EmptyPassword() throws Exception {
mContext.binder.callingUid = DpmMockContext.CALLER_SYSTEM_USER_UID;
setupDeviceOwner();
@@ -7260,7 +7251,6 @@
}
@Test
- @Ignore("b/277916462")
public void testCanProfileOwnerResetPasswordWhenLocked() throws Exception {
setDeviceEncryptionPerUser();
setupProfileOwner();
@@ -7324,7 +7314,6 @@
}
@Test
- @Ignore("b/277916462")
public void testSetAccountTypesWithManagementDisabledOnManagedProfile() throws Exception {
setupProfileOwner();
@@ -7344,7 +7333,6 @@
}
@Test
- @Ignore("b/277916462")
public void testSetAccountTypesWithManagementDisabledOnOrgOwnedManagedProfile()
throws Exception {
mContext.callerPermissions.add(permission.INTERACT_ACROSS_USERS);
@@ -8539,6 +8527,46 @@
eq(FUSED_PROVIDER), any(), eq(getServices().executor), any());
}
+ /**
+ * Verifies that bundles with tons of moderately long strings are persisted correctly.
+ *
+ * Policy is serialized into binary XML and there is a limit on the max string length: 65535.
+ * This test ensures that as long as each string in the trust agent configuration is below this
+ * limit, the policy can be serialized and deserialized correctly, even when the total length
+ * of the configuration is above that limit. This should be the case because PersistableBundle
+ * contents are stored as XML subtrees rather than as strings.
+ */
+ @Test
+ public void testSetTrustAgentConfiguration_largeBundlePersisted() {
+ setAsProfileOwner(admin1);
+
+ ComponentName agent = new ComponentName("some.trust.agent", "some.trust.agent.Agent");
+ PersistableBundle configIn = new PersistableBundle();
+ String kilobyteString = new String(new char[1024]).replace('\0', 'A');
+ for (int i = 0; i < 1024; i++) {
+ configIn.putString("key-" + i, kilobyteString);
+ }
+
+ runAsCaller(mAdmin1Context, dpms, dpm -> {
+ dpm.setTrustAgentConfiguration(admin1, agent, configIn);
+ });
+
+ // Re-read policies to see if they were serialized/deserialized correctly.
+ initializeDpms();
+
+ List<PersistableBundle> configsOut = new ArrayList<>();
+ runAsCaller(mAdmin1Context, dpms, dpm -> {
+ configsOut.addAll(dpm.getTrustAgentConfiguration(admin1, agent));
+ });
+
+ assertThat(configsOut.size()).isEqualTo(1);
+ PersistableBundle configOut = configsOut.get(0);
+ assertThat(configOut.size()).isEqualTo(1024);
+ for (int i = 0; i < 1024; i++) {
+ assertThat(configOut.getString("key-" + i, null)).isEqualTo(kilobyteString);
+ }
+ }
+
private void setupVpnAuthorization(String userVpnPackage, int userVpnUid) {
final AppOpsManager.PackageOps vpnOp = new AppOpsManager.PackageOps(userVpnPackage,
userVpnUid, List.of(new AppOpsManager.OpEntry(
diff --git a/services/tests/servicestests/src/com/android/server/display/LogicalDisplayMapperTest.java b/services/tests/servicestests/src/com/android/server/display/LogicalDisplayMapperTest.java
index 7536c79..1eec70d 100644
--- a/services/tests/servicestests/src/com/android/server/display/LogicalDisplayMapperTest.java
+++ b/services/tests/servicestests/src/com/android/server/display/LogicalDisplayMapperTest.java
@@ -649,9 +649,9 @@
assertEquals(0, mLogicalDisplayMapper.getDisplayLocked(device2)
.getLeadDisplayIdLocked());
assertEquals("concurrent", mLogicalDisplayMapper.getDisplayLocked(device1)
- .getThermalBrightnessThrottlingDataIdLocked());
+ .getDisplayInfoLocked().thermalBrightnessThrottlingDataId);
assertEquals("concurrent", mLogicalDisplayMapper.getDisplayLocked(device2)
- .getThermalBrightnessThrottlingDataIdLocked());
+ .getDisplayInfoLocked().thermalBrightnessThrottlingDataId);
mLogicalDisplayMapper.setDeviceStateLocked(1, false);
advanceTime(1000);
@@ -661,10 +661,10 @@
assertFalse(mLogicalDisplayMapper.getDisplayLocked(device2).isInTransitionLocked());
assertEquals(DisplayDeviceConfig.DEFAULT_ID,
mLogicalDisplayMapper.getDisplayLocked(device1)
- .getThermalBrightnessThrottlingDataIdLocked());
+ .getDisplayInfoLocked().thermalBrightnessThrottlingDataId);
assertEquals(DisplayDeviceConfig.DEFAULT_ID,
mLogicalDisplayMapper.getDisplayLocked(device2)
- .getThermalBrightnessThrottlingDataIdLocked());
+ .getDisplayInfoLocked().thermalBrightnessThrottlingDataId);
mLogicalDisplayMapper.setDeviceStateLocked(2, false);
advanceTime(1000);
@@ -674,10 +674,10 @@
assertFalse(mLogicalDisplayMapper.getDisplayLocked(device2).isInTransitionLocked());
assertEquals(DisplayDeviceConfig.DEFAULT_ID,
mLogicalDisplayMapper.getDisplayLocked(device1)
- .getThermalBrightnessThrottlingDataIdLocked());
+ .getDisplayInfoLocked().thermalBrightnessThrottlingDataId);
assertEquals(DisplayDeviceConfig.DEFAULT_ID,
mLogicalDisplayMapper.getDisplayLocked(device2)
- .getThermalBrightnessThrottlingDataIdLocked());
+ .getDisplayInfoLocked().thermalBrightnessThrottlingDataId);
}
@Test
diff --git a/services/tests/servicestests/src/com/android/server/display/LogicalDisplayTest.java b/services/tests/servicestests/src/com/android/server/display/LogicalDisplayTest.java
index 5ea3029..f6cf571 100644
--- a/services/tests/servicestests/src/com/android/server/display/LogicalDisplayTest.java
+++ b/services/tests/servicestests/src/com/android/server/display/LogicalDisplayTest.java
@@ -205,4 +205,19 @@
assertNotEquals(info3, info2);
assertTrue(refreshRanges.contentEquals(info3.thermalRefreshRateThrottling));
}
+
+ @Test
+ public void testSetThermalBrightnessThrottlingDataId() {
+ String brightnessThrottlingDataId = "throttling_data_id";
+ DisplayInfo info1 = mLogicalDisplay.getDisplayInfoLocked();
+ mLogicalDisplay.setThermalBrightnessThrottlingDataIdLocked(brightnessThrottlingDataId);
+ DisplayInfo info2 = mLogicalDisplay.getDisplayInfoLocked();
+ // Display info should only be updated when updateLocked is called
+ assertEquals(info2, info1);
+
+ mLogicalDisplay.updateLocked(mDeviceRepo);
+ DisplayInfo info3 = mLogicalDisplay.getDisplayInfoLocked();
+ assertNotEquals(info3, info2);
+ assertEquals(brightnessThrottlingDataId, info3.thermalBrightnessThrottlingDataId);
+ }
}
diff --git a/services/tests/servicestests/src/com/android/server/display/brightness/strategy/AutomaticBrightnessStrategyTest.java b/services/tests/servicestests/src/com/android/server/display/brightness/strategy/AutomaticBrightnessStrategyTest.java
index eb208d2..d9cf15b 100644
--- a/services/tests/servicestests/src/com/android/server/display/brightness/strategy/AutomaticBrightnessStrategyTest.java
+++ b/services/tests/servicestests/src/com/android/server/display/brightness/strategy/AutomaticBrightnessStrategyTest.java
@@ -18,6 +18,7 @@
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
+import static org.mockito.Mockito.any;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.verify;
@@ -40,6 +41,7 @@
import com.android.internal.util.test.FakeSettingsProvider;
import com.android.internal.util.test.FakeSettingsProviderRule;
import com.android.server.display.AutomaticBrightnessController;
+import com.android.server.display.brightness.BrightnessEvent;
import com.android.server.display.brightness.BrightnessReason;
import org.junit.After;
@@ -262,12 +264,13 @@
float automaticScreenBrightness = 0.3f;
AutomaticBrightnessController automaticBrightnessController = mock(
AutomaticBrightnessController.class);
- when(automaticBrightnessController.getAutomaticScreenBrightness()).thenReturn(
- automaticScreenBrightness);
+ when(automaticBrightnessController.getAutomaticScreenBrightness(any(BrightnessEvent.class)))
+ .thenReturn(automaticScreenBrightness);
mAutomaticBrightnessStrategy.setAutomaticBrightnessController(
automaticBrightnessController);
assertEquals(automaticScreenBrightness,
- mAutomaticBrightnessStrategy.getAutomaticScreenBrightness(), 0.0f);
+ mAutomaticBrightnessStrategy.getAutomaticScreenBrightness(
+ new BrightnessEvent(DISPLAY_ID)), 0.0f);
}
@Test
diff --git a/services/tests/servicestests/src/com/android/server/net/NetworkManagementServiceTest.java b/services/tests/servicestests/src/com/android/server/net/NetworkManagementServiceTest.java
index d9cd77d..af144cf 100644
--- a/services/tests/servicestests/src/com/android/server/net/NetworkManagementServiceTest.java
+++ b/services/tests/servicestests/src/com/android/server/net/NetworkManagementServiceTest.java
@@ -37,7 +37,6 @@
import static org.mockito.Mockito.verifyNoMoreInteractions;
import android.annotation.NonNull;
-import android.content.AttributionSource;
import android.content.Context;
import android.net.ConnectivityManager;
import android.net.INetd;
@@ -50,7 +49,7 @@
import android.os.PermissionEnforcer;
import android.os.Process;
import android.os.RemoteException;
-import android.permission.PermissionCheckerManager;
+import android.os.test.FakePermissionEnforcer;
import android.platform.test.annotations.Presubmit;
import android.test.suitebuilder.annotation.SmallTest;
import android.util.ArrayMap;
@@ -90,7 +89,6 @@
private ArgumentCaptor<INetdUnsolicitedEventListener> mUnsolListenerCaptor;
private final MockDependencies mDeps = new MockDependencies();
- private final MockPermissionEnforcer mPermissionEnforcer = new MockPermissionEnforcer();
private final class MockDependencies extends NetworkManagementService.Dependencies {
@Override
@@ -118,24 +116,6 @@
}
}
- private static final class MockPermissionEnforcer extends PermissionEnforcer {
- @Override
- protected int checkPermission(@NonNull String permission,
- @NonNull AttributionSource source) {
- String[] granted = new String [] {
- android.Manifest.permission.NETWORK_SETTINGS,
- android.Manifest.permission.OBSERVE_NETWORK_POLICY,
- android.Manifest.permission.SHUTDOWN
- };
- for (String p : granted) {
- if (p.equals(permission)) {
- return PermissionCheckerManager.PERMISSION_GRANTED;
- }
- }
- return PermissionCheckerManager.PERMISSION_HARD_DENIED;
- }
- }
-
@Before
public void setUp() throws Exception {
MockitoAnnotations.initMocks(this);
@@ -145,12 +125,15 @@
eq(ConnectivityManager.class));
doReturn(mCm).when(mContext).getSystemService(eq(Context.CONNECTIVITY_SERVICE));
// The AIDL stub will use PermissionEnforcer to check permission from the caller.
- // Mock the service. See MockPermissionEnforcer above.
+ // Mock the service and grant the expected permissions.
+ FakePermissionEnforcer permissionEnforcer = new FakePermissionEnforcer();
+ permissionEnforcer.grant(android.Manifest.permission.NETWORK_SETTINGS);
+ permissionEnforcer.grant(android.Manifest.permission.OBSERVE_NETWORK_POLICY);
+ permissionEnforcer.grant(android.Manifest.permission.SHUTDOWN);
doReturn(Context.PERMISSION_ENFORCER_SERVICE).when(mContext).getSystemServiceName(
eq(PermissionEnforcer.class));
- doReturn(mPermissionEnforcer).when(mContext).getSystemService(
+ doReturn(permissionEnforcer).when(mContext).getSystemService(
eq(Context.PERMISSION_ENFORCER_SERVICE));
-
// Start the service and wait until it connects to our socket.
mNMService = NetworkManagementService.create(mContext, mDeps);
}
diff --git a/services/tests/wmtests/src/com/android/server/wm/SurfaceControlTests.java b/services/tests/wmtests/src/com/android/server/wm/SurfaceControlTests.java
index 342ab83..4f45d5c 100644
--- a/services/tests/wmtests/src/com/android/server/wm/SurfaceControlTests.java
+++ b/services/tests/wmtests/src/com/android/server/wm/SurfaceControlTests.java
@@ -125,9 +125,10 @@
public void testSurfaceChangedOnRotation() {
final Instrumentation instrumentation = getInstrumentation();
final Context context = instrumentation.getContext();
- final Activity activity = instrumentation.startActivitySync(new Intent().setComponent(
+ final Intent intent = new Intent().setComponent(
new ComponentName(context, ActivityOptionsTest.MainActivity.class))
- .setFlags(Intent.FLAG_ACTIVITY_NEW_TASK));
+ .setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_SINGLE_TOP);
+ final Activity activity = instrumentation.startActivitySync(intent);
final SurfaceView sv = new SurfaceView(activity);
final AtomicInteger surfaceChangedCount = new AtomicInteger();
instrumentation.runOnMainSync(() -> activity.setContentView(sv));
@@ -157,12 +158,27 @@
instrumentation.waitForIdleSync();
final int newRotation = activity.getResources().getConfiguration()
.windowConfiguration.getRotation();
+ if (rotation == newRotation) {
+ // The device might not support requested orientation.
+ activity.finishAndRemoveTask();
+ return;
+ }
final int count = surfaceChangedCount.get();
+ activity.moveTaskToBack(true /* nonRoot */);
+ instrumentation.getUiAutomation().syncInputTransactions();
+ context.startActivity(intent);
+ instrumentation.getUiAutomation().syncInputTransactions();
+ final int countAfterToFront = count - surfaceChangedCount.get();
activity.finishAndRemoveTask();
+
// The first count is triggered from creation, so the target number is 2.
- if (rotation != newRotation && count > 2) {
+ if (count > 2) {
fail("More than once surfaceChanged for rotation change: " + count);
}
+ if (countAfterToFront > 1) {
+ fail("More than once surfaceChanged for app transition with rotation change: "
+ + countAfterToFront);
+ }
}
private SurfaceControl buildTestSurface() {
diff --git a/telephony/java/android/telephony/CarrierConfigManager.java b/telephony/java/android/telephony/CarrierConfigManager.java
index f27c23b..1888943 100644
--- a/telephony/java/android/telephony/CarrierConfigManager.java
+++ b/telephony/java/android/telephony/CarrierConfigManager.java
@@ -5773,14 +5773,15 @@
* </ul>
* @hide
*/
- public static final String KEY_SA_DISABLE_POLICY_INT = KEY_PREFIX + "sa_disable_policy_int";
+ public static final String KEY_NR_SA_DISABLE_POLICY_INT =
+ KEY_PREFIX + "sa_disable_policy_int";
/** @hide */
@IntDef({
- SA_DISABLE_POLICY_NONE,
- SA_DISABLE_POLICY_WFC_ESTABLISHED,
- SA_DISABLE_POLICY_WFC_ESTABLISHED_WHEN_VONR_DISABLED,
- SA_DISABLE_POLICY_VOWIFI_REGISTERED
+ NR_SA_DISABLE_POLICY_NONE,
+ NR_SA_DISABLE_POLICY_WFC_ESTABLISHED,
+ NR_SA_DISABLE_POLICY_WFC_ESTABLISHED_WHEN_VONR_DISABLED,
+ NR_SA_DISABLE_POLICY_VOWIFI_REGISTERED
})
public @interface NrSaDisablePolicy {}
@@ -5788,14 +5789,14 @@
* Do not disables NR SA mode.
* @hide
*/
- public static final int SA_DISABLE_POLICY_NONE = 0;
+ public static final int NR_SA_DISABLE_POLICY_NONE = 0;
/**
* Disables NR SA mode when VoWiFi call is established in order to improve the delay or
* voice mute when the handover from ePDG to NR is not supported in UE or network.
* @hide
*/
- public static final int SA_DISABLE_POLICY_WFC_ESTABLISHED = 1;
+ public static final int NR_SA_DISABLE_POLICY_WFC_ESTABLISHED = 1;
/**
* Disables NR SA mode when VoWiFi call is established when VoNR is disabled in order to
@@ -5803,14 +5804,14 @@
* in UE or network.
* @hide
*/
- public static final int SA_DISABLE_POLICY_WFC_ESTABLISHED_WHEN_VONR_DISABLED = 2;
+ public static final int NR_SA_DISABLE_POLICY_WFC_ESTABLISHED_WHEN_VONR_DISABLED = 2;
/**
* Disables NR SA mode when IMS is registered over WiFi in order to improve the delay or
* voice mute when the handover from ePDG to NR is not supported in UE or network.
* @hide
*/
- public static final int SA_DISABLE_POLICY_VOWIFI_REGISTERED = 3;
+ public static final int NR_SA_DISABLE_POLICY_VOWIFI_REGISTERED = 3;
private Ims() {}
@@ -5883,7 +5884,7 @@
defaults.putInt(KEY_REGISTRATION_RETRY_BASE_TIMER_MILLIS_INT, 30000);
defaults.putInt(KEY_REGISTRATION_RETRY_MAX_TIMER_MILLIS_INT, 1800000);
defaults.putInt(KEY_REGISTRATION_SUBSCRIBE_EXPIRY_TIMER_SEC_INT, 600000);
- defaults.putInt(KEY_SA_DISABLE_POLICY_INT, SA_DISABLE_POLICY_NONE);
+ defaults.putInt(KEY_NR_SA_DISABLE_POLICY_INT, NR_SA_DISABLE_POLICY_NONE);
defaults.putIntArray(
KEY_IPSEC_AUTHENTICATION_ALGORITHMS_INT_ARRAY,