Merge "Protect setPermissionGrantState coexistence code." into main
diff --git a/cmds/bootanimation/OWNERS b/cmds/bootanimation/OWNERS
index b6fb007..2eda44d 100644
--- a/cmds/bootanimation/OWNERS
+++ b/cmds/bootanimation/OWNERS
@@ -1,3 +1,4 @@
dupin@google.com
shanh@google.com
jreck@google.com
+rahulbanerjee@google.com
\ No newline at end of file
diff --git a/core/api/current.txt b/core/api/current.txt
index c3cb17c..035f823 100644
--- a/core/api/current.txt
+++ b/core/api/current.txt
@@ -43851,8 +43851,8 @@
field public static final String KEY_5G_NR_SSRSRQ_THRESHOLDS_INT_ARRAY = "5g_nr_ssrsrq_thresholds_int_array";
field public static final String KEY_5G_NR_SSSINR_THRESHOLDS_INT_ARRAY = "5g_nr_sssinr_thresholds_int_array";
field public static final String KEY_ADDITIONAL_CALL_SETTING_BOOL = "additional_call_setting_bool";
- field @FlaggedApi("com.android.internal.telephony.flags.show_call_id_and_call_waiting_in_additional_settings_menu") public static final String KEY_ADDITIONAL_SETTINGS_CALLER_ID_VISIBILITY_BOOL = "additional_settings_caller_id_visibility_bool";
- field @FlaggedApi("com.android.internal.telephony.flags.show_call_id_and_call_waiting_in_additional_settings_menu") public static final String KEY_ADDITIONAL_SETTINGS_CALL_WAITING_VISIBILITY_BOOL = "additional_settings_call_waiting_visibility_bool";
+ field public static final String KEY_ADDITIONAL_SETTINGS_CALLER_ID_VISIBILITY_BOOL = "additional_settings_caller_id_visibility_bool";
+ field public static final String KEY_ADDITIONAL_SETTINGS_CALL_WAITING_VISIBILITY_BOOL = "additional_settings_call_waiting_visibility_bool";
field public static final String KEY_ALLOW_ADDING_APNS_BOOL = "allow_adding_apns_bool";
field public static final String KEY_ALLOW_ADD_CALL_DURING_VIDEO_CALL_BOOL = "allow_add_call_during_video_call";
field public static final String KEY_ALLOW_EMERGENCY_NUMBERS_IN_CALL_LOG_BOOL = "allow_emergency_numbers_in_call_log_bool";
@@ -43935,7 +43935,7 @@
field public static final String KEY_CDMA_NONROAMING_NETWORKS_STRING_ARRAY = "cdma_nonroaming_networks_string_array";
field public static final String KEY_CDMA_ROAMING_MODE_INT = "cdma_roaming_mode_int";
field public static final String KEY_CDMA_ROAMING_NETWORKS_STRING_ARRAY = "cdma_roaming_networks_string_array";
- field @FlaggedApi("com.android.internal.telephony.flags.data_only_cellular_service") public static final String KEY_CELLULAR_SERVICE_CAPABILITIES_INT_ARRAY = "cellular_service_capabilities_int_array";
+ field public static final String KEY_CELLULAR_SERVICE_CAPABILITIES_INT_ARRAY = "cellular_service_capabilities_int_array";
field public static final String KEY_CELLULAR_USAGE_SETTING_INT = "cellular_usage_setting_int";
field public static final String KEY_CHECK_PRICING_WITH_CARRIER_FOR_DATA_ROAMING_BOOL = "check_pricing_with_carrier_data_roaming_bool";
field public static final String KEY_CI_ACTION_ON_SYS_UPDATE_BOOL = "ci_action_on_sys_update_bool";
@@ -45973,7 +45973,7 @@
method @Nullable public String getMncString();
method @Deprecated public String getNumber();
method public int getPortIndex();
- method @FlaggedApi("com.android.internal.telephony.flags.data_only_cellular_service") @NonNull public java.util.Set<java.lang.Integer> getServiceCapabilities();
+ method @NonNull public java.util.Set<java.lang.Integer> getServiceCapabilities();
method public int getSimSlotIndex();
method public int getSubscriptionId();
method public int getSubscriptionType();
@@ -46056,9 +46056,9 @@
field public static final int PHONE_NUMBER_SOURCE_CARRIER = 2; // 0x2
field public static final int PHONE_NUMBER_SOURCE_IMS = 3; // 0x3
field public static final int PHONE_NUMBER_SOURCE_UICC = 1; // 0x1
- field @FlaggedApi("com.android.internal.telephony.flags.data_only_cellular_service") public static final int SERVICE_CAPABILITY_DATA = 3; // 0x3
- field @FlaggedApi("com.android.internal.telephony.flags.data_only_cellular_service") public static final int SERVICE_CAPABILITY_SMS = 2; // 0x2
- field @FlaggedApi("com.android.internal.telephony.flags.data_only_cellular_service") public static final int SERVICE_CAPABILITY_VOICE = 1; // 0x1
+ field public static final int SERVICE_CAPABILITY_DATA = 3; // 0x3
+ field public static final int SERVICE_CAPABILITY_SMS = 2; // 0x2
+ field public static final int SERVICE_CAPABILITY_VOICE = 1; // 0x1
field public static final int SUBSCRIPTION_TYPE_LOCAL_SIM = 0; // 0x0
field public static final int SUBSCRIPTION_TYPE_REMOTE_SIM = 1; // 0x1
field public static final int USAGE_SETTING_DATA_CENTRIC = 2; // 0x2
@@ -46307,8 +46307,8 @@
method @RequiresPermission(anyOf={android.Manifest.permission.ACCESS_NETWORK_STATE, android.Manifest.permission.MODIFY_PHONE_STATE, android.Manifest.permission.READ_PHONE_STATE, android.Manifest.permission.READ_BASIC_PHONE_STATE}) public boolean isDataEnabled();
method @RequiresPermission(anyOf={android.Manifest.permission.ACCESS_NETWORK_STATE, android.Manifest.permission.READ_PHONE_STATE, android.Manifest.permission.MODIFY_PHONE_STATE, android.Manifest.permission.READ_BASIC_PHONE_STATE}) public boolean isDataEnabledForReason(int);
method @RequiresPermission(anyOf={android.Manifest.permission.ACCESS_NETWORK_STATE, android.Manifest.permission.READ_PHONE_STATE, android.Manifest.permission.READ_BASIC_PHONE_STATE}) public boolean isDataRoamingEnabled();
- method @FlaggedApi("com.android.internal.telephony.flags.data_only_cellular_service") public boolean isDeviceSmsCapable();
- method @FlaggedApi("com.android.internal.telephony.flags.data_only_cellular_service") public boolean isDeviceVoiceCapable();
+ method public boolean isDeviceSmsCapable();
+ method public boolean isDeviceVoiceCapable();
method public boolean isEmergencyNumber(@NonNull String);
method public boolean isHearingAidCompatibilitySupported();
method @RequiresPermission(anyOf={android.Manifest.permission.READ_PRECISE_PHONE_STATE, "android.permission.READ_PRIVILEGED_PHONE_STATE"}) public boolean isManualNetworkSelectionAllowed();
diff --git a/core/api/system-current.txt b/core/api/system-current.txt
index cab836e..fa4fc43 100644
--- a/core/api/system-current.txt
+++ b/core/api/system-current.txt
@@ -7319,6 +7319,7 @@
field @RequiresPermission(android.Manifest.permission.MODIFY_AUDIO_ROUTING) public static final int MUTED_BY_APP_OPS = 8; // 0x8
field @RequiresPermission(android.Manifest.permission.MODIFY_AUDIO_ROUTING) public static final int MUTED_BY_CLIENT_VOLUME = 16; // 0x10
field @RequiresPermission(android.Manifest.permission.MODIFY_AUDIO_ROUTING) public static final int MUTED_BY_MASTER = 1; // 0x1
+ field @FlaggedApi("android.media.audio.muted_by_port_volume_api") @RequiresPermission(android.Manifest.permission.MODIFY_AUDIO_ROUTING) public static final int MUTED_BY_PORT_VOLUME = 64; // 0x40
field @RequiresPermission(android.Manifest.permission.MODIFY_AUDIO_ROUTING) public static final int MUTED_BY_STREAM_MUTED = 4; // 0x4
field @RequiresPermission(android.Manifest.permission.MODIFY_AUDIO_ROUTING) public static final int MUTED_BY_STREAM_VOLUME = 2; // 0x2
field @RequiresPermission(android.Manifest.permission.MODIFY_AUDIO_ROUTING) public static final int MUTED_BY_VOLUME_SHAPER = 32; // 0x20
diff --git a/core/api/test-current.txt b/core/api/test-current.txt
index c79fc51..1ff8c51 100644
--- a/core/api/test-current.txt
+++ b/core/api/test-current.txt
@@ -1101,6 +1101,7 @@
field public static final long OVERRIDE_UNDEFINED_ORIENTATION_TO_PORTRAIT = 265452344L; // 0xfd27b38L
field public static final long OVERRIDE_USE_DISPLAY_LANDSCAPE_NATURAL_ORIENTATION = 255940284L; // 0xf4156bcL
field public static final int RESIZE_MODE_RESIZEABLE = 2; // 0x2
+ field public static final long UNIVERSAL_RESIZABLE_BY_DEFAULT = 357141415L; // 0x15498ba7L
}
public class ApplicationInfo extends android.content.pm.PackageItemInfo implements android.os.Parcelable {
diff --git a/core/java/android/app/Notification.java b/core/java/android/app/Notification.java
index 8b33417..4ef5b51 100644
--- a/core/java/android/app/Notification.java
+++ b/core/java/android/app/Notification.java
@@ -11296,7 +11296,11 @@
* @see Segment
*/
public @NonNull ProgressStyle setProgressSegments(@NonNull List<Segment> progressSegments) {
- mProgressSegments = new ArrayList<>(progressSegments.size());
+ if (mProgressSegments == null) {
+ mProgressSegments = new ArrayList<>();
+ }
+ mProgressSegments.clear();
+ mProgressSegments.addAll(progressSegments);
return this;
}
diff --git a/core/java/android/app/contextualsearch/ContextualSearchManager.java b/core/java/android/app/contextualsearch/ContextualSearchManager.java
index cfbe741..3438cc8 100644
--- a/core/java/android/app/contextualsearch/ContextualSearchManager.java
+++ b/core/java/android/app/contextualsearch/ContextualSearchManager.java
@@ -102,6 +102,7 @@
* Only supposed to be used with ACTON_LAUNCH_CONTEXTUAL_SEARCH.
*/
public static final String EXTRA_TOKEN = "android.app.contextualsearch.extra.TOKEN";
+
/**
* Intent action for contextual search invocation. The app providing the contextual search
* experience must add this intent filter action to the activity it wants to be launched.
@@ -111,6 +112,14 @@
public static final String ACTION_LAUNCH_CONTEXTUAL_SEARCH =
"android.app.contextualsearch.action.LAUNCH_CONTEXTUAL_SEARCH";
+ /**
+ * System feature declaring that the device supports Contextual Search.
+ *
+ * @hide
+ */
+ public static final String FEATURE_CONTEXTUAL_SEARCH =
+ "com.google.android.feature.CONTEXTUAL_SEARCH";
+
/** Entrypoint to be used when a user long presses on the nav handle. */
public static final int ENTRYPOINT_LONG_PRESS_NAV_HANDLE = 1;
/** Entrypoint to be used when a user long presses on the home button. */
diff --git a/core/java/android/content/pm/ActivityInfo.java b/core/java/android/content/pm/ActivityInfo.java
index 481e6b5..ce52825 100644
--- a/core/java/android/content/pm/ActivityInfo.java
+++ b/core/java/android/content/pm/ActivityInfo.java
@@ -21,10 +21,12 @@
import android.annotation.IntDef;
import android.annotation.NonNull;
import android.annotation.Nullable;
+import android.annotation.SuppressLint;
import android.annotation.TestApi;
import android.app.Activity;
import android.compat.annotation.ChangeId;
import android.compat.annotation.Disabled;
+import android.compat.annotation.EnabledAfter;
import android.compat.annotation.EnabledSince;
import android.compat.annotation.Overridable;
import android.compat.annotation.UnsupportedAppUsage;
@@ -1204,6 +1206,18 @@
public @interface SizeChangesSupportMode {}
/**
+ * This change id makes the restriction of fixed orientation, aspect ratio, and resizability
+ * of the app to be ignored, which means making the app fill the given available area.
+ * @hide
+ */
+ @ChangeId
+ @Overridable
+ @TestApi
+ @SuppressLint("UnflaggedApi") // @TestApi without associated public API.
+ @EnabledAfter(targetSdkVersion = Build.VERSION_CODES.VANILLA_ICE_CREAM)
+ public static final long UNIVERSAL_RESIZABLE_BY_DEFAULT = 357141415L; // buganizer id
+
+ /**
* This change id enables compat policy that ignores app requested orientation in
* response to an app calling {@link android.app.Activity#setRequestedOrientation}. See
* com.android.server.wm.LetterboxUiController#shouldIgnoreRequestedOrientation for
diff --git a/core/java/android/view/ViewRootImpl.java b/core/java/android/view/ViewRootImpl.java
index b921213..3be9a82 100644
--- a/core/java/android/view/ViewRootImpl.java
+++ b/core/java/android/view/ViewRootImpl.java
@@ -6971,9 +6971,7 @@
handleScrollCaptureRequest((IScrollCaptureResponseListener) msg.obj);
break;
case MSG_PAUSED_FOR_SYNC_TIMEOUT:
- Log.e(mTag, "Timedout waiting to unpause for sync");
- mNumPausedForSync = 0;
- scheduleTraversals();
+ resumeAfterSyncTimeout();
break;
case MSG_CHECK_INVALIDATION_IDLE: {
long delta;
@@ -12777,6 +12775,15 @@
activeSurfaceSyncGroup.addTransaction(t);
}
+ /**
+ * Resume rendering after being paused for sync due to a timeout.
+ */
+ private void resumeAfterSyncTimeout() {
+ Log.e(mTag, "Timedout waiting to unpause for sync mNumPausedForSync=" + mNumPausedForSync);
+ mNumPausedForSync = 0;
+ scheduleTraversals();
+ }
+
@Override
public SurfaceSyncGroup getOrCreateSurfaceSyncGroup() {
boolean newSyncGroup = false;
@@ -12804,6 +12811,16 @@
}
});
newSyncGroup = true;
+
+ // If the sync group is marked ready by a timeout, check if rendering is paused and
+ // if it is, resume rendering and trigger a traversal.
+ mActiveSurfaceSyncGroup.addSyncCompleteCallback(mExecutor, () -> {
+ if (mActiveSurfaceSyncGroup != null
+ && mActiveSurfaceSyncGroup.isComplete() && mNumPausedForSync > 0) {
+ mHandler.removeMessages(MSG_PAUSED_FOR_SYNC_TIMEOUT);
+ resumeAfterSyncTimeout();
+ }
+ });
}
Trace.instant(Trace.TRACE_TAG_VIEW,
@@ -12818,12 +12835,20 @@
}
}
- mNumPausedForSync++;
- mHandler.removeMessages(MSG_PAUSED_FOR_SYNC_TIMEOUT);
- mHandler.sendEmptyMessageDelayed(MSG_PAUSED_FOR_SYNC_TIMEOUT,
- 1000 * Build.HW_TIMEOUT_MULTIPLIER);
+ // The sync group can be marked ready by a timeout. This makes incrementing
+ // mNumPausedForSync racy. Here we check if the sync group is complete and
+ // if it is then we don't pause for syncing.
+ if (!mActiveSurfaceSyncGroup.isComplete()) {
+ mNumPausedForSync++;
+ mHandler.removeMessages(MSG_PAUSED_FOR_SYNC_TIMEOUT);
+ mHandler.sendEmptyMessageDelayed(MSG_PAUSED_FOR_SYNC_TIMEOUT,
+ 1000 * Build.HW_TIMEOUT_MULTIPLIER);
+ } else {
+ Log.d(mTag, "Active sync group is already completed "
+ + mActiveSurfaceSyncGroup.getName());
+ }
return mActiveSurfaceSyncGroup;
- };
+ }
private final Executor mSimpleExecutor = Runnable::run;
diff --git a/core/java/android/window/BackEvent.java b/core/java/android/window/BackEvent.java
index 1c3f201c..23e572f 100644
--- a/core/java/android/window/BackEvent.java
+++ b/core/java/android/window/BackEvent.java
@@ -156,6 +156,22 @@
}
@Override
+ public boolean equals(Object other) {
+ if (this == other) {
+ return true;
+ }
+ if (!(other instanceof BackEvent)) {
+ return false;
+ }
+ final BackEvent that = (BackEvent) other;
+ return mTouchX == that.mTouchX
+ && mTouchY == that.mTouchY
+ && mProgress == that.mProgress
+ && mSwipeEdge == that.mSwipeEdge
+ && mFrameTime == that.mFrameTime;
+ }
+
+ @Override
public String toString() {
return "BackEvent{"
+ "mTouchX=" + mTouchX
diff --git a/core/java/android/window/SurfaceSyncGroup.java b/core/java/android/window/SurfaceSyncGroup.java
index 5d14698..a68bdc0 100644
--- a/core/java/android/window/SurfaceSyncGroup.java
+++ b/core/java/android/window/SurfaceSyncGroup.java
@@ -839,6 +839,16 @@
}
/**
+ * Returns true if the SurfaceSyncGroup has completed its sync.
+ * @hide
+ */
+ public boolean isComplete() {
+ synchronized (mLock) {
+ return mFinished;
+ }
+ }
+
+ /**
* A frame callback that is used to synchronize SurfaceViews. The owner of the SurfaceView must
* implement onFrameStarted when trying to sync the SurfaceView. This is to ensure the sync
* knows when the frame is ready to add to the sync.
diff --git a/core/java/android/window/TaskSnapshot.java b/core/java/android/window/TaskSnapshot.java
index 20d1b3b..a37bef8 100644
--- a/core/java/android/window/TaskSnapshot.java
+++ b/core/java/android/window/TaskSnapshot.java
@@ -83,13 +83,16 @@
public static final int REFERENCE_CACHE = 1 << 1;
/** This snapshot object is being persistent. */
public static final int REFERENCE_PERSIST = 1 << 2;
+ /** This snapshot object is being used for content suggestion. */
+ public static final int REFERENCE_CONTENT_SUGGESTION = 1 << 3;
@IntDef(flag = true, prefix = { "REFERENCE_" }, value = {
REFERENCE_BROADCAST,
REFERENCE_CACHE,
- REFERENCE_PERSIST
+ REFERENCE_PERSIST,
+ REFERENCE_CONTENT_SUGGESTION
})
@Retention(RetentionPolicy.SOURCE)
- @interface ReferenceFlags {}
+ public @interface ReferenceFlags {}
public TaskSnapshot(long id, long captureTime,
@NonNull ComponentName topActivityComponent, HardwareBuffer snapshot,
diff --git a/core/java/android/window/WindowContainerTransaction.java b/core/java/android/window/WindowContainerTransaction.java
index 34abf31..8e495ec 100644
--- a/core/java/android/window/WindowContainerTransaction.java
+++ b/core/java/android/window/WindowContainerTransaction.java
@@ -525,22 +525,6 @@
}
/**
- * Disables or enables activities to be started in adjacent tasks (see
- * {@link FLAG_ACTIVITY_LAUNCH_ADJACENT}) for the specified root of any child tasks. This
- * differs from {@link #setLaunchAdjacentFlagRoot(WindowContainerToken)} which controls the
- * preferred launch-adjacent target and allows for selectively setting which root tasks can
- * support launch-adjacent.
- * @hide
- */
- @NonNull
- public WindowContainerTransaction setDisableLaunchAdjacent(
- @NonNull WindowContainerToken container, boolean disabled) {
- mHierarchyOps.add(HierarchyOp.createForSetDisableLaunchAdjacent(container.asBinder(),
- disabled));
- return this;
- }
-
- /**
* Starts a task by id. The task is expected to already exist (eg. as a recent task).
* @param taskId Id of task to start.
* @param options bundle containing ActivityOptions for the task's top activity.
@@ -1504,7 +1488,6 @@
public static final int HIERARCHY_OP_TYPE_RESTORE_BACK_NAVIGATION = 20;
public static final int HIERARCHY_OP_TYPE_SET_EXCLUDE_INSETS_TYPES = 21;
public static final int HIERARCHY_OP_TYPE_SET_KEYGUARD_STATE = 22;
- public static final int HIERARCHY_OP_TYPE_SET_DISABLE_LAUNCH_ADJACENT = 23;
// The following key(s) are for use with mLaunchOptions:
// When launching a task (eg. from recents), this is the taskId to be launched.
@@ -1573,8 +1556,6 @@
private @InsetsType int mExcludeInsetsTypes;
- private boolean mLaunchAdjacentDisabled;
-
public static HierarchyOp createForReparent(
@NonNull IBinder container, @Nullable IBinder reparent, boolean toTop) {
return new HierarchyOp.Builder(HIERARCHY_OP_TYPE_REPARENT)
@@ -1663,15 +1644,6 @@
.build();
}
- /** Create a hierarchy op for disabling launch adjacent. */
- public static HierarchyOp createForSetDisableLaunchAdjacent(IBinder container,
- boolean disabled) {
- return new HierarchyOp.Builder(HIERARCHY_OP_TYPE_SET_DISABLE_LAUNCH_ADJACENT)
- .setContainer(container)
- .setLaunchAdjacentDisabled(disabled)
- .build();
- }
-
/** create a hierarchy op for deleting a task **/
public static HierarchyOp createForRemoveTask(@NonNull IBinder container) {
return new HierarchyOp.Builder(HIERARCHY_OP_TYPE_REMOVE_TASK)
@@ -1723,7 +1695,6 @@
mReparentLeafTaskIfRelaunch = copy.mReparentLeafTaskIfRelaunch;
mIsTrimmableFromRecents = copy.mIsTrimmableFromRecents;
mExcludeInsetsTypes = copy.mExcludeInsetsTypes;
- mLaunchAdjacentDisabled = copy.mLaunchAdjacentDisabled;
}
protected HierarchyOp(Parcel in) {
@@ -1748,7 +1719,6 @@
mReparentLeafTaskIfRelaunch = in.readBoolean();
mIsTrimmableFromRecents = in.readBoolean();
mExcludeInsetsTypes = in.readInt();
- mLaunchAdjacentDisabled = in.readBoolean();
}
public int getType() {
@@ -1844,11 +1814,13 @@
}
/** Denotes whether the parents should also be included in the op. */
+ @NonNull
public boolean includingParents() {
return mIncludingParents;
}
- /** Denotes whether the task can be trimmable from recents */
+ /** Set the task to be trimmable */
+ @NonNull
public boolean isTrimmableFromRecents() {
return mIsTrimmableFromRecents;
}
@@ -1857,11 +1829,6 @@
return mExcludeInsetsTypes;
}
- /** Denotes whether launch-adjacent flag is respected from this task or its children */
- public boolean isLaunchAdjacentDisabled() {
- return mLaunchAdjacentDisabled;
- }
-
/** Gets a string representation of a hierarchy-op type. */
public static String hopToString(int type) {
switch (type) {
@@ -1872,8 +1839,6 @@
case HIERARCHY_OP_TYPE_SET_ADJACENT_ROOTS: return "SetAdjacentRoot";
case HIERARCHY_OP_TYPE_LAUNCH_TASK: return "LaunchTask";
case HIERARCHY_OP_TYPE_SET_LAUNCH_ADJACENT_FLAG_ROOT: return "SetAdjacentFlagRoot";
- case HIERARCHY_OP_TYPE_SET_DISABLE_LAUNCH_ADJACENT:
- return "SetDisableLaunchAdjacent";
case HIERARCHY_OP_TYPE_PENDING_INTENT: return "PendingIntent";
case HIERARCHY_OP_TYPE_START_SHORTCUT: return "StartShortcut";
case HIERARCHY_OP_TYPE_ADD_INSETS_FRAME_PROVIDER: return "addInsetsFrameProvider";
@@ -1926,10 +1891,6 @@
case HIERARCHY_OP_TYPE_SET_LAUNCH_ADJACENT_FLAG_ROOT:
sb.append("container=").append(mContainer).append(" clearRoot=").append(mToTop);
break;
- case HIERARCHY_OP_TYPE_SET_DISABLE_LAUNCH_ADJACENT:
- sb.append("container=").append(mContainer).append(" disabled=")
- .append(mLaunchAdjacentDisabled);
- break;
case HIERARCHY_OP_TYPE_START_SHORTCUT:
sb.append("options=").append(mLaunchOptions)
.append(" info=").append(mShortcutInfo);
@@ -2010,7 +1971,6 @@
dest.writeBoolean(mReparentLeafTaskIfRelaunch);
dest.writeBoolean(mIsTrimmableFromRecents);
dest.writeInt(mExcludeInsetsTypes);
- dest.writeBoolean(mLaunchAdjacentDisabled);
}
@Override
@@ -2087,8 +2047,6 @@
private @InsetsType int mExcludeInsetsTypes;
- private boolean mLaunchAdjacentDisabled;
-
Builder(int type) {
mType = type;
}
@@ -2195,11 +2153,6 @@
return this;
}
- Builder setLaunchAdjacentDisabled(boolean disabled) {
- mLaunchAdjacentDisabled = disabled;
- return this;
- }
-
HierarchyOp build() {
final HierarchyOp hierarchyOp = new HierarchyOp(mType);
hierarchyOp.mContainer = mContainer;
@@ -2226,7 +2179,6 @@
hierarchyOp.mReparentLeafTaskIfRelaunch = mReparentLeafTaskIfRelaunch;
hierarchyOp.mIsTrimmableFromRecents = mIsTrimmableFromRecents;
hierarchyOp.mExcludeInsetsTypes = mExcludeInsetsTypes;
- hierarchyOp.mLaunchAdjacentDisabled = mLaunchAdjacentDisabled;
return hierarchyOp;
}
diff --git a/core/java/android/window/WindowOnBackInvokedDispatcher.java b/core/java/android/window/WindowOnBackInvokedDispatcher.java
index 44a374f..c9d458f 100644
--- a/core/java/android/window/WindowOnBackInvokedDispatcher.java
+++ b/core/java/android/window/WindowOnBackInvokedDispatcher.java
@@ -17,6 +17,7 @@
package android.window;
import static com.android.window.flags.Flags.predictiveBackPrioritySystemNavigationObserver;
+import static com.android.window.flags.Flags.predictiveBackTimestampApi;
import android.annotation.NonNull;
import android.annotation.Nullable;
@@ -563,7 +564,8 @@
}
OnBackAnimationCallback animationCallback = getBackAnimationCallback();
if (animationCallback != null
- && !(callback instanceof ImeBackAnimationController)) {
+ && !(callback instanceof ImeBackAnimationController)
+ && !predictiveBackTimestampApi()) {
mProgressAnimator.onBackInvoked(() -> {
if (mIsSystemCallback) {
mSystemNavigationObserverCallbackRunnable.run();
diff --git a/core/java/android/window/flags/lse_desktop_experience.aconfig b/core/java/android/window/flags/lse_desktop_experience.aconfig
index 155494f..1812953 100644
--- a/core/java/android/window/flags/lse_desktop_experience.aconfig
+++ b/core/java/android/window/flags/lse_desktop_experience.aconfig
@@ -239,6 +239,13 @@
}
flag {
+ name: "enable_desktop_windowing_enter_transitions"
+ namespace: "lse_desktop_experience"
+ description: "Enables enter desktop windowing transition & motion polish changes"
+ bug: "369763947"
+}
+
+flag {
name: "enable_desktop_windowing_exit_transitions"
namespace: "lse_desktop_experience"
description: "Enables exit desktop windowing transition & motion polish changes"
diff --git a/core/java/android/window/flags/windowing_frontend.aconfig b/core/java/android/window/flags/windowing_frontend.aconfig
index 460469c..0d235ff 100644
--- a/core/java/android/window/flags/windowing_frontend.aconfig
+++ b/core/java/android/window/flags/windowing_frontend.aconfig
@@ -70,17 +70,6 @@
}
flag {
- name: "common_surface_animator"
- namespace: "windowing_frontend"
- description: "A reusable surface animator for default transition"
- bug: "326331384"
- is_fixed_read_only: true
- metadata {
- purpose: PURPOSE_BUGFIX
- }
-}
-
-flag {
name: "reduce_keyguard_transitions"
namespace: "windowing_frontend"
description: "Avoid setting keyguard transitions ready unless there are no other changes"
diff --git a/core/java/com/android/internal/protolog/ProtoLogViewerConfigReader.java b/core/java/com/android/internal/protolog/ProtoLogViewerConfigReader.java
index 0a80e00..dd6c879 100644
--- a/core/java/com/android/internal/protolog/ProtoLogViewerConfigReader.java
+++ b/core/java/com/android/internal/protolog/ProtoLogViewerConfigReader.java
@@ -39,7 +39,7 @@
* or the viewer config is not loaded into memory.
*/
@Nullable
- public synchronized String getViewerString(long messageHash) {
+ public String getViewerString(long messageHash) {
return mLogMessageMap.get(messageHash);
}
diff --git a/core/jni/android_media_AudioSystem.cpp b/core/jni/android_media_AudioSystem.cpp
index 9bccf5a..8eaa7aa 100644
--- a/core/jni/android_media_AudioSystem.cpp
+++ b/core/jni/android_media_AudioSystem.cpp
@@ -747,16 +747,12 @@
indexMax));
}
-static jint
-android_media_AudioSystem_setStreamVolumeIndex(JNIEnv *env,
- jobject thiz,
- jint stream,
- jint index,
- jint device)
-{
+static jint android_media_AudioSystem_setStreamVolumeIndex(JNIEnv *env, jobject thiz, jint stream,
+ jint index, jboolean muted,
+ jint device) {
return check_AudioSystem_Command(
AudioSystem::setStreamVolumeIndex(static_cast<audio_stream_type_t>(stream), index,
- static_cast<audio_devices_t>(device)));
+ muted, static_cast<audio_devices_t>(device)));
}
static jint
@@ -773,13 +769,9 @@
return index;
}
-static jint
-android_media_AudioSystem_setVolumeIndexForAttributes(JNIEnv *env,
- jobject thiz,
- jobject jaa,
- jint index,
- jint device)
-{
+static jint android_media_AudioSystem_setVolumeIndexForAttributes(JNIEnv *env, jobject thiz,
+ jobject jaa, jint index,
+ jboolean muted, jint device) {
// read the AudioAttributes values
JNIAudioAttributeHelper::UniqueAaPtr paa = JNIAudioAttributeHelper::makeUnique();
jint jStatus = JNIAudioAttributeHelper::nativeFromJava(env, jaa, paa.get());
@@ -787,7 +779,7 @@
return jStatus;
}
return check_AudioSystem_Command(
- AudioSystem::setVolumeIndexForAttributes(*(paa.get()), index,
+ AudioSystem::setVolumeIndexForAttributes(*(paa.get()), index, muted,
static_cast<audio_devices_t>(device)));
}
@@ -3448,182 +3440,179 @@
#define MAKE_AUDIO_SYSTEM_METHOD(x) \
MAKE_JNI_NATIVE_METHOD_AUTOSIG(#x, android_media_AudioSystem_##x)
-static const JNINativeMethod gMethods[] =
- {MAKE_AUDIO_SYSTEM_METHOD(setParameters),
- MAKE_AUDIO_SYSTEM_METHOD(getParameters),
- MAKE_AUDIO_SYSTEM_METHOD(muteMicrophone),
- MAKE_AUDIO_SYSTEM_METHOD(isMicrophoneMuted),
- MAKE_AUDIO_SYSTEM_METHOD(isStreamActive),
- MAKE_AUDIO_SYSTEM_METHOD(isStreamActiveRemotely),
- MAKE_AUDIO_SYSTEM_METHOD(isSourceActive),
- MAKE_AUDIO_SYSTEM_METHOD(newAudioSessionId),
- MAKE_AUDIO_SYSTEM_METHOD(newAudioPlayerId),
- MAKE_AUDIO_SYSTEM_METHOD(newAudioRecorderId),
- MAKE_JNI_NATIVE_METHOD("setDeviceConnectionState", "(ILandroid/os/Parcel;I)I",
- android_media_AudioSystem_setDeviceConnectionState),
- MAKE_AUDIO_SYSTEM_METHOD(getDeviceConnectionState),
- MAKE_AUDIO_SYSTEM_METHOD(handleDeviceConfigChange),
- MAKE_AUDIO_SYSTEM_METHOD(setPhoneState),
- MAKE_AUDIO_SYSTEM_METHOD(setForceUse),
- MAKE_AUDIO_SYSTEM_METHOD(getForceUse),
- MAKE_AUDIO_SYSTEM_METHOD(setDeviceAbsoluteVolumeEnabled),
- MAKE_AUDIO_SYSTEM_METHOD(initStreamVolume),
- MAKE_AUDIO_SYSTEM_METHOD(setStreamVolumeIndex),
- MAKE_AUDIO_SYSTEM_METHOD(getStreamVolumeIndex),
- MAKE_JNI_NATIVE_METHOD("setVolumeIndexForAttributes",
- "(Landroid/media/AudioAttributes;II)I",
- android_media_AudioSystem_setVolumeIndexForAttributes),
- MAKE_JNI_NATIVE_METHOD("getVolumeIndexForAttributes",
- "(Landroid/media/AudioAttributes;I)I",
- android_media_AudioSystem_getVolumeIndexForAttributes),
- MAKE_JNI_NATIVE_METHOD("getMinVolumeIndexForAttributes",
- "(Landroid/media/AudioAttributes;)I",
- android_media_AudioSystem_getMinVolumeIndexForAttributes),
- MAKE_JNI_NATIVE_METHOD("getMaxVolumeIndexForAttributes",
- "(Landroid/media/AudioAttributes;)I",
- android_media_AudioSystem_getMaxVolumeIndexForAttributes),
- MAKE_AUDIO_SYSTEM_METHOD(setMasterVolume),
- MAKE_AUDIO_SYSTEM_METHOD(getMasterVolume),
- MAKE_AUDIO_SYSTEM_METHOD(setMasterMute),
- MAKE_AUDIO_SYSTEM_METHOD(getMasterMute),
- MAKE_AUDIO_SYSTEM_METHOD(setMasterMono),
- MAKE_AUDIO_SYSTEM_METHOD(getMasterMono),
- MAKE_AUDIO_SYSTEM_METHOD(setMasterBalance),
- MAKE_AUDIO_SYSTEM_METHOD(getMasterBalance),
- MAKE_AUDIO_SYSTEM_METHOD(getPrimaryOutputSamplingRate),
- MAKE_AUDIO_SYSTEM_METHOD(getPrimaryOutputFrameCount),
- MAKE_AUDIO_SYSTEM_METHOD(getOutputLatency),
- MAKE_AUDIO_SYSTEM_METHOD(setLowRamDevice),
- MAKE_AUDIO_SYSTEM_METHOD(checkAudioFlinger),
- MAKE_JNI_NATIVE_METHOD("setAudioFlingerBinder", "(Landroid/os/IBinder;)V",
- android_media_AudioSystem_setAudioFlingerBinder),
- MAKE_JNI_NATIVE_METHOD("listAudioPorts", "(Ljava/util/ArrayList;[I)I",
- android_media_AudioSystem_listAudioPorts),
- MAKE_JNI_NATIVE_METHOD("getSupportedDeviceTypes", "(ILandroid/util/IntArray;)I",
- android_media_AudioSystem_getSupportedDeviceTypes),
- MAKE_JNI_NATIVE_METHOD("createAudioPatch",
- "([Landroid/media/AudioPatch;[Landroid/media/"
- "AudioPortConfig;[Landroid/media/AudioPortConfig;)I",
- android_media_AudioSystem_createAudioPatch),
- MAKE_JNI_NATIVE_METHOD("releaseAudioPatch", "(Landroid/media/AudioPatch;)I",
- android_media_AudioSystem_releaseAudioPatch),
- MAKE_JNI_NATIVE_METHOD("listAudioPatches", "(Ljava/util/ArrayList;[I)I",
- android_media_AudioSystem_listAudioPatches),
- MAKE_JNI_NATIVE_METHOD("setAudioPortConfig", "(Landroid/media/AudioPortConfig;)I",
- android_media_AudioSystem_setAudioPortConfig),
- MAKE_JNI_NATIVE_METHOD("startAudioSource",
- "(Landroid/media/AudioPortConfig;Landroid/media/AudioAttributes;)I",
- android_media_AudioSystem_startAudioSource),
- MAKE_AUDIO_SYSTEM_METHOD(stopAudioSource),
- MAKE_AUDIO_SYSTEM_METHOD(getAudioHwSyncForSession),
- MAKE_JNI_NATIVE_METHOD("registerPolicyMixes", "(Ljava/util/ArrayList;Z)I",
- android_media_AudioSystem_registerPolicyMixes),
- MAKE_JNI_NATIVE_METHOD("getRegisteredPolicyMixes", "(Ljava/util/List;)I",
- android_media_AudioSystem_getRegisteredPolicyMixes),
- MAKE_JNI_NATIVE_METHOD("updatePolicyMixes",
- "([Landroid/media/audiopolicy/AudioMix;[Landroid/media/audiopolicy/"
- "AudioMixingRule;)I",
- android_media_AudioSystem_updatePolicyMixes),
- MAKE_JNI_NATIVE_METHOD("setUidDeviceAffinities", "(I[I[Ljava/lang/String;)I",
- android_media_AudioSystem_setUidDeviceAffinities),
- MAKE_AUDIO_SYSTEM_METHOD(removeUidDeviceAffinities),
- MAKE_JNI_NATIVE_METHOD_AUTOSIG("native_register_dynamic_policy_callback",
- android_media_AudioSystem_registerDynPolicyCallback),
- MAKE_JNI_NATIVE_METHOD_AUTOSIG("native_register_recording_callback",
- android_media_AudioSystem_registerRecordingCallback),
- MAKE_JNI_NATIVE_METHOD_AUTOSIG("native_register_routing_callback",
- android_media_AudioSystem_registerRoutingCallback),
- MAKE_JNI_NATIVE_METHOD_AUTOSIG("native_register_vol_range_init_req_callback",
- android_media_AudioSystem_registerVolRangeInitReqCallback),
- MAKE_AUDIO_SYSTEM_METHOD(systemReady),
- MAKE_AUDIO_SYSTEM_METHOD(getStreamVolumeDB),
- MAKE_JNI_NATIVE_METHOD_AUTOSIG("native_get_offload_support",
- android_media_AudioSystem_getOffloadSupport),
- MAKE_JNI_NATIVE_METHOD("getMicrophones", "(Ljava/util/ArrayList;)I",
- android_media_AudioSystem_getMicrophones),
- MAKE_JNI_NATIVE_METHOD("getSurroundFormats", "(Ljava/util/Map;)I",
- android_media_AudioSystem_getSurroundFormats),
- MAKE_JNI_NATIVE_METHOD("getReportedSurroundFormats", "(Ljava/util/ArrayList;)I",
- android_media_AudioSystem_getReportedSurroundFormats),
- MAKE_AUDIO_SYSTEM_METHOD(setSurroundFormatEnabled),
- MAKE_AUDIO_SYSTEM_METHOD(setAssistantServicesUids),
- MAKE_AUDIO_SYSTEM_METHOD(setActiveAssistantServicesUids),
- MAKE_AUDIO_SYSTEM_METHOD(setA11yServicesUids),
- MAKE_AUDIO_SYSTEM_METHOD(isHapticPlaybackSupported),
- MAKE_AUDIO_SYSTEM_METHOD(isUltrasoundSupported),
- MAKE_JNI_NATIVE_METHOD(
- "getHwOffloadFormatsSupportedForBluetoothMedia", "(ILjava/util/ArrayList;)I",
- android_media_AudioSystem_getHwOffloadFormatsSupportedForBluetoothMedia),
- MAKE_AUDIO_SYSTEM_METHOD(setSupportedSystemUsages),
- MAKE_AUDIO_SYSTEM_METHOD(setAllowedCapturePolicy),
- MAKE_AUDIO_SYSTEM_METHOD(setRttEnabled),
- MAKE_AUDIO_SYSTEM_METHOD(setAudioHalPids),
- MAKE_AUDIO_SYSTEM_METHOD(isCallScreeningModeSupported),
- MAKE_JNI_NATIVE_METHOD("setDevicesRoleForStrategy", "(II[I[Ljava/lang/String;)I",
- android_media_AudioSystem_setDevicesRoleForStrategy),
- MAKE_JNI_NATIVE_METHOD("removeDevicesRoleForStrategy", "(II[I[Ljava/lang/String;)I",
- android_media_AudioSystem_removeDevicesRoleForStrategy),
- MAKE_AUDIO_SYSTEM_METHOD(clearDevicesRoleForStrategy),
- MAKE_JNI_NATIVE_METHOD("getDevicesForRoleAndStrategy", "(IILjava/util/List;)I",
- android_media_AudioSystem_getDevicesForRoleAndStrategy),
- MAKE_JNI_NATIVE_METHOD("setDevicesRoleForCapturePreset", "(II[I[Ljava/lang/String;)I",
- android_media_AudioSystem_setDevicesRoleForCapturePreset),
- MAKE_JNI_NATIVE_METHOD("addDevicesRoleForCapturePreset", "(II[I[Ljava/lang/String;)I",
- android_media_AudioSystem_addDevicesRoleForCapturePreset),
- MAKE_JNI_NATIVE_METHOD("removeDevicesRoleForCapturePreset", "(II[I[Ljava/lang/String;)I",
- android_media_AudioSystem_removeDevicesRoleForCapturePreset),
- MAKE_AUDIO_SYSTEM_METHOD(clearDevicesRoleForCapturePreset),
- MAKE_JNI_NATIVE_METHOD("getDevicesForRoleAndCapturePreset", "(IILjava/util/List;)I",
- android_media_AudioSystem_getDevicesForRoleAndCapturePreset),
- MAKE_JNI_NATIVE_METHOD("getDevicesForAttributes",
- "(Landroid/media/AudioAttributes;[Landroid/media/"
- "AudioDeviceAttributes;Z)I",
- android_media_AudioSystem_getDevicesForAttributes),
- MAKE_JNI_NATIVE_METHOD("setUserIdDeviceAffinities", "(I[I[Ljava/lang/String;)I",
- android_media_AudioSystem_setUserIdDeviceAffinities),
- MAKE_AUDIO_SYSTEM_METHOD(removeUserIdDeviceAffinities),
- MAKE_AUDIO_SYSTEM_METHOD(setCurrentImeUid),
- MAKE_JNI_NATIVE_METHOD("setVibratorInfos", "(Ljava/util/List;)I",
- android_media_AudioSystem_setVibratorInfos),
- MAKE_JNI_NATIVE_METHOD("nativeGetSpatializer",
- "(Landroid/media/INativeSpatializerCallback;)Landroid/os/IBinder;",
- android_media_AudioSystem_getSpatializer),
- MAKE_JNI_NATIVE_METHOD("canBeSpatialized",
- "(Landroid/media/AudioAttributes;Landroid/media/AudioFormat;"
- "[Landroid/media/AudioDeviceAttributes;)Z",
- android_media_AudioSystem_canBeSpatialized),
- MAKE_JNI_NATIVE_METHOD("nativeGetSoundDose",
- "(Landroid/media/ISoundDoseCallback;)Landroid/os/IBinder;",
- android_media_AudioSystem_nativeGetSoundDose),
- MAKE_JNI_NATIVE_METHOD("getDirectPlaybackSupport",
- "(Landroid/media/AudioFormat;Landroid/media/AudioAttributes;)I",
- android_media_AudioSystem_getDirectPlaybackSupport),
- MAKE_JNI_NATIVE_METHOD("getDirectProfilesForAttributes",
- "(Landroid/media/AudioAttributes;Ljava/util/ArrayList;)I",
- android_media_AudioSystem_getDirectProfilesForAttributes),
- MAKE_JNI_NATIVE_METHOD("getSupportedMixerAttributes", "(ILjava/util/List;)I",
- android_media_AudioSystem_getSupportedMixerAttributes),
- MAKE_JNI_NATIVE_METHOD("setPreferredMixerAttributes",
- "(Landroid/media/AudioAttributes;IILandroid/media/"
- "AudioMixerAttributes;)I",
- android_media_AudioSystem_setPreferredMixerAttributes),
- MAKE_JNI_NATIVE_METHOD("getPreferredMixerAttributes",
- "(Landroid/media/AudioAttributes;ILjava/util/List;)I",
- android_media_AudioSystem_getPreferredMixerAttributes),
- MAKE_JNI_NATIVE_METHOD("clearPreferredMixerAttributes",
- "(Landroid/media/AudioAttributes;II)I",
- android_media_AudioSystem_clearPreferredMixerAttributes),
- MAKE_AUDIO_SYSTEM_METHOD(supportsBluetoothVariableLatency),
- MAKE_AUDIO_SYSTEM_METHOD(setBluetoothVariableLatencyEnabled),
- MAKE_AUDIO_SYSTEM_METHOD(isBluetoothVariableLatencyEnabled),
- MAKE_JNI_NATIVE_METHOD("listenForSystemPropertyChange",
- "(Ljava/lang/String;Ljava/lang/Runnable;)J",
- android_media_AudioSystem_listenForSystemPropertyChange),
- MAKE_JNI_NATIVE_METHOD("triggerSystemPropertyUpdate",
- "(J)V",
- android_media_AudioSystem_triggerSystemPropertyUpdate),
-
- };
+static const JNINativeMethod gMethods[] = {
+ MAKE_AUDIO_SYSTEM_METHOD(setParameters),
+ MAKE_AUDIO_SYSTEM_METHOD(getParameters),
+ MAKE_AUDIO_SYSTEM_METHOD(muteMicrophone),
+ MAKE_AUDIO_SYSTEM_METHOD(isMicrophoneMuted),
+ MAKE_AUDIO_SYSTEM_METHOD(isStreamActive),
+ MAKE_AUDIO_SYSTEM_METHOD(isStreamActiveRemotely),
+ MAKE_AUDIO_SYSTEM_METHOD(isSourceActive),
+ MAKE_AUDIO_SYSTEM_METHOD(newAudioSessionId),
+ MAKE_AUDIO_SYSTEM_METHOD(newAudioPlayerId),
+ MAKE_AUDIO_SYSTEM_METHOD(newAudioRecorderId),
+ MAKE_JNI_NATIVE_METHOD("setDeviceConnectionState", "(ILandroid/os/Parcel;I)I",
+ android_media_AudioSystem_setDeviceConnectionState),
+ MAKE_AUDIO_SYSTEM_METHOD(getDeviceConnectionState),
+ MAKE_AUDIO_SYSTEM_METHOD(handleDeviceConfigChange),
+ MAKE_AUDIO_SYSTEM_METHOD(setPhoneState),
+ MAKE_AUDIO_SYSTEM_METHOD(setForceUse),
+ MAKE_AUDIO_SYSTEM_METHOD(getForceUse),
+ MAKE_AUDIO_SYSTEM_METHOD(setDeviceAbsoluteVolumeEnabled),
+ MAKE_AUDIO_SYSTEM_METHOD(initStreamVolume),
+ MAKE_AUDIO_SYSTEM_METHOD(setStreamVolumeIndex),
+ MAKE_AUDIO_SYSTEM_METHOD(getStreamVolumeIndex),
+ MAKE_JNI_NATIVE_METHOD("setVolumeIndexForAttributes",
+ "(Landroid/media/AudioAttributes;IZI)I",
+ android_media_AudioSystem_setVolumeIndexForAttributes),
+ MAKE_JNI_NATIVE_METHOD("getVolumeIndexForAttributes", "(Landroid/media/AudioAttributes;I)I",
+ android_media_AudioSystem_getVolumeIndexForAttributes),
+ MAKE_JNI_NATIVE_METHOD("getMinVolumeIndexForAttributes",
+ "(Landroid/media/AudioAttributes;)I",
+ android_media_AudioSystem_getMinVolumeIndexForAttributes),
+ MAKE_JNI_NATIVE_METHOD("getMaxVolumeIndexForAttributes",
+ "(Landroid/media/AudioAttributes;)I",
+ android_media_AudioSystem_getMaxVolumeIndexForAttributes),
+ MAKE_AUDIO_SYSTEM_METHOD(setMasterVolume),
+ MAKE_AUDIO_SYSTEM_METHOD(getMasterVolume),
+ MAKE_AUDIO_SYSTEM_METHOD(setMasterMute),
+ MAKE_AUDIO_SYSTEM_METHOD(getMasterMute),
+ MAKE_AUDIO_SYSTEM_METHOD(setMasterMono),
+ MAKE_AUDIO_SYSTEM_METHOD(getMasterMono),
+ MAKE_AUDIO_SYSTEM_METHOD(setMasterBalance),
+ MAKE_AUDIO_SYSTEM_METHOD(getMasterBalance),
+ MAKE_AUDIO_SYSTEM_METHOD(getPrimaryOutputSamplingRate),
+ MAKE_AUDIO_SYSTEM_METHOD(getPrimaryOutputFrameCount),
+ MAKE_AUDIO_SYSTEM_METHOD(getOutputLatency),
+ MAKE_AUDIO_SYSTEM_METHOD(setLowRamDevice),
+ MAKE_AUDIO_SYSTEM_METHOD(checkAudioFlinger),
+ MAKE_JNI_NATIVE_METHOD("setAudioFlingerBinder", "(Landroid/os/IBinder;)V",
+ android_media_AudioSystem_setAudioFlingerBinder),
+ MAKE_JNI_NATIVE_METHOD("listAudioPorts", "(Ljava/util/ArrayList;[I)I",
+ android_media_AudioSystem_listAudioPorts),
+ MAKE_JNI_NATIVE_METHOD("getSupportedDeviceTypes", "(ILandroid/util/IntArray;)I",
+ android_media_AudioSystem_getSupportedDeviceTypes),
+ MAKE_JNI_NATIVE_METHOD("createAudioPatch",
+ "([Landroid/media/AudioPatch;[Landroid/media/"
+ "AudioPortConfig;[Landroid/media/AudioPortConfig;)I",
+ android_media_AudioSystem_createAudioPatch),
+ MAKE_JNI_NATIVE_METHOD("releaseAudioPatch", "(Landroid/media/AudioPatch;)I",
+ android_media_AudioSystem_releaseAudioPatch),
+ MAKE_JNI_NATIVE_METHOD("listAudioPatches", "(Ljava/util/ArrayList;[I)I",
+ android_media_AudioSystem_listAudioPatches),
+ MAKE_JNI_NATIVE_METHOD("setAudioPortConfig", "(Landroid/media/AudioPortConfig;)I",
+ android_media_AudioSystem_setAudioPortConfig),
+ MAKE_JNI_NATIVE_METHOD("startAudioSource",
+ "(Landroid/media/AudioPortConfig;Landroid/media/AudioAttributes;)I",
+ android_media_AudioSystem_startAudioSource),
+ MAKE_AUDIO_SYSTEM_METHOD(stopAudioSource),
+ MAKE_AUDIO_SYSTEM_METHOD(getAudioHwSyncForSession),
+ MAKE_JNI_NATIVE_METHOD("registerPolicyMixes", "(Ljava/util/ArrayList;Z)I",
+ android_media_AudioSystem_registerPolicyMixes),
+ MAKE_JNI_NATIVE_METHOD("getRegisteredPolicyMixes", "(Ljava/util/List;)I",
+ android_media_AudioSystem_getRegisteredPolicyMixes),
+ MAKE_JNI_NATIVE_METHOD("updatePolicyMixes",
+ "([Landroid/media/audiopolicy/AudioMix;[Landroid/media/audiopolicy/"
+ "AudioMixingRule;)I",
+ android_media_AudioSystem_updatePolicyMixes),
+ MAKE_JNI_NATIVE_METHOD("setUidDeviceAffinities", "(I[I[Ljava/lang/String;)I",
+ android_media_AudioSystem_setUidDeviceAffinities),
+ MAKE_AUDIO_SYSTEM_METHOD(removeUidDeviceAffinities),
+ MAKE_JNI_NATIVE_METHOD_AUTOSIG("native_register_dynamic_policy_callback",
+ android_media_AudioSystem_registerDynPolicyCallback),
+ MAKE_JNI_NATIVE_METHOD_AUTOSIG("native_register_recording_callback",
+ android_media_AudioSystem_registerRecordingCallback),
+ MAKE_JNI_NATIVE_METHOD_AUTOSIG("native_register_routing_callback",
+ android_media_AudioSystem_registerRoutingCallback),
+ MAKE_JNI_NATIVE_METHOD_AUTOSIG("native_register_vol_range_init_req_callback",
+ android_media_AudioSystem_registerVolRangeInitReqCallback),
+ MAKE_AUDIO_SYSTEM_METHOD(systemReady),
+ MAKE_AUDIO_SYSTEM_METHOD(getStreamVolumeDB),
+ MAKE_JNI_NATIVE_METHOD_AUTOSIG("native_get_offload_support",
+ android_media_AudioSystem_getOffloadSupport),
+ MAKE_JNI_NATIVE_METHOD("getMicrophones", "(Ljava/util/ArrayList;)I",
+ android_media_AudioSystem_getMicrophones),
+ MAKE_JNI_NATIVE_METHOD("getSurroundFormats", "(Ljava/util/Map;)I",
+ android_media_AudioSystem_getSurroundFormats),
+ MAKE_JNI_NATIVE_METHOD("getReportedSurroundFormats", "(Ljava/util/ArrayList;)I",
+ android_media_AudioSystem_getReportedSurroundFormats),
+ MAKE_AUDIO_SYSTEM_METHOD(setSurroundFormatEnabled),
+ MAKE_AUDIO_SYSTEM_METHOD(setAssistantServicesUids),
+ MAKE_AUDIO_SYSTEM_METHOD(setActiveAssistantServicesUids),
+ MAKE_AUDIO_SYSTEM_METHOD(setA11yServicesUids),
+ MAKE_AUDIO_SYSTEM_METHOD(isHapticPlaybackSupported),
+ MAKE_AUDIO_SYSTEM_METHOD(isUltrasoundSupported),
+ MAKE_JNI_NATIVE_METHOD(
+ "getHwOffloadFormatsSupportedForBluetoothMedia", "(ILjava/util/ArrayList;)I",
+ android_media_AudioSystem_getHwOffloadFormatsSupportedForBluetoothMedia),
+ MAKE_AUDIO_SYSTEM_METHOD(setSupportedSystemUsages),
+ MAKE_AUDIO_SYSTEM_METHOD(setAllowedCapturePolicy),
+ MAKE_AUDIO_SYSTEM_METHOD(setRttEnabled),
+ MAKE_AUDIO_SYSTEM_METHOD(setAudioHalPids),
+ MAKE_AUDIO_SYSTEM_METHOD(isCallScreeningModeSupported),
+ MAKE_JNI_NATIVE_METHOD("setDevicesRoleForStrategy", "(II[I[Ljava/lang/String;)I",
+ android_media_AudioSystem_setDevicesRoleForStrategy),
+ MAKE_JNI_NATIVE_METHOD("removeDevicesRoleForStrategy", "(II[I[Ljava/lang/String;)I",
+ android_media_AudioSystem_removeDevicesRoleForStrategy),
+ MAKE_AUDIO_SYSTEM_METHOD(clearDevicesRoleForStrategy),
+ MAKE_JNI_NATIVE_METHOD("getDevicesForRoleAndStrategy", "(IILjava/util/List;)I",
+ android_media_AudioSystem_getDevicesForRoleAndStrategy),
+ MAKE_JNI_NATIVE_METHOD("setDevicesRoleForCapturePreset", "(II[I[Ljava/lang/String;)I",
+ android_media_AudioSystem_setDevicesRoleForCapturePreset),
+ MAKE_JNI_NATIVE_METHOD("addDevicesRoleForCapturePreset", "(II[I[Ljava/lang/String;)I",
+ android_media_AudioSystem_addDevicesRoleForCapturePreset),
+ MAKE_JNI_NATIVE_METHOD("removeDevicesRoleForCapturePreset", "(II[I[Ljava/lang/String;)I",
+ android_media_AudioSystem_removeDevicesRoleForCapturePreset),
+ MAKE_AUDIO_SYSTEM_METHOD(clearDevicesRoleForCapturePreset),
+ MAKE_JNI_NATIVE_METHOD("getDevicesForRoleAndCapturePreset", "(IILjava/util/List;)I",
+ android_media_AudioSystem_getDevicesForRoleAndCapturePreset),
+ MAKE_JNI_NATIVE_METHOD("getDevicesForAttributes",
+ "(Landroid/media/AudioAttributes;[Landroid/media/"
+ "AudioDeviceAttributes;Z)I",
+ android_media_AudioSystem_getDevicesForAttributes),
+ MAKE_JNI_NATIVE_METHOD("setUserIdDeviceAffinities", "(I[I[Ljava/lang/String;)I",
+ android_media_AudioSystem_setUserIdDeviceAffinities),
+ MAKE_AUDIO_SYSTEM_METHOD(removeUserIdDeviceAffinities),
+ MAKE_AUDIO_SYSTEM_METHOD(setCurrentImeUid),
+ MAKE_JNI_NATIVE_METHOD("setVibratorInfos", "(Ljava/util/List;)I",
+ android_media_AudioSystem_setVibratorInfos),
+ MAKE_JNI_NATIVE_METHOD("nativeGetSpatializer",
+ "(Landroid/media/INativeSpatializerCallback;)Landroid/os/IBinder;",
+ android_media_AudioSystem_getSpatializer),
+ MAKE_JNI_NATIVE_METHOD("canBeSpatialized",
+ "(Landroid/media/AudioAttributes;Landroid/media/AudioFormat;"
+ "[Landroid/media/AudioDeviceAttributes;)Z",
+ android_media_AudioSystem_canBeSpatialized),
+ MAKE_JNI_NATIVE_METHOD("nativeGetSoundDose",
+ "(Landroid/media/ISoundDoseCallback;)Landroid/os/IBinder;",
+ android_media_AudioSystem_nativeGetSoundDose),
+ MAKE_JNI_NATIVE_METHOD("getDirectPlaybackSupport",
+ "(Landroid/media/AudioFormat;Landroid/media/AudioAttributes;)I",
+ android_media_AudioSystem_getDirectPlaybackSupport),
+ MAKE_JNI_NATIVE_METHOD("getDirectProfilesForAttributes",
+ "(Landroid/media/AudioAttributes;Ljava/util/ArrayList;)I",
+ android_media_AudioSystem_getDirectProfilesForAttributes),
+ MAKE_JNI_NATIVE_METHOD("getSupportedMixerAttributes", "(ILjava/util/List;)I",
+ android_media_AudioSystem_getSupportedMixerAttributes),
+ MAKE_JNI_NATIVE_METHOD("setPreferredMixerAttributes",
+ "(Landroid/media/AudioAttributes;IILandroid/media/"
+ "AudioMixerAttributes;)I",
+ android_media_AudioSystem_setPreferredMixerAttributes),
+ MAKE_JNI_NATIVE_METHOD("getPreferredMixerAttributes",
+ "(Landroid/media/AudioAttributes;ILjava/util/List;)I",
+ android_media_AudioSystem_getPreferredMixerAttributes),
+ MAKE_JNI_NATIVE_METHOD("clearPreferredMixerAttributes",
+ "(Landroid/media/AudioAttributes;II)I",
+ android_media_AudioSystem_clearPreferredMixerAttributes),
+ MAKE_AUDIO_SYSTEM_METHOD(supportsBluetoothVariableLatency),
+ MAKE_AUDIO_SYSTEM_METHOD(setBluetoothVariableLatencyEnabled),
+ MAKE_AUDIO_SYSTEM_METHOD(isBluetoothVariableLatencyEnabled),
+ MAKE_JNI_NATIVE_METHOD("listenForSystemPropertyChange",
+ "(Ljava/lang/String;Ljava/lang/Runnable;)J",
+ android_media_AudioSystem_listenForSystemPropertyChange),
+ MAKE_JNI_NATIVE_METHOD("triggerSystemPropertyUpdate", "(J)V",
+ android_media_AudioSystem_triggerSystemPropertyUpdate),
+};
static const JNINativeMethod gEventHandlerMethods[] =
{MAKE_JNI_NATIVE_METHOD("native_setup", "(Ljava/lang/Object;)V",
diff --git a/core/res/res/color-watch-v36/btn_material_filled_background_color.xml b/core/res/res/color-watch-v36/btn_material_filled_background_color.xml
deleted file mode 100644
index 8b2afa8..0000000
--- a/core/res/res/color-watch-v36/btn_material_filled_background_color.xml
+++ /dev/null
@@ -1,23 +0,0 @@
-<!--
- ~ Copyright (C) 2024 The Android Open Source Project
- ~
- ~ Licensed under the Apache License, Version 2.0 (the "License");
- ~ you may not use this file except in compliance with the License.
- ~ You may obtain a copy of the License at
- ~
- ~ http://www.apache.org/licenses/LICENSE-2.0
- ~
- ~ Unless required by applicable law or agreed to in writing, software
- ~ distributed under the License is distributed on an "AS IS" BASIS,
- ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- ~ See the License for the specific language governing permissions and
- ~ limitations under the License.
- -->
-
-<selector xmlns:android="http://schemas.android.com/apk/res/android">
- <item android:state_enabled="false"
- android:alpha="?attr/disabledAlpha"
- android:color="?attr/materialColorOnSurface" />
- <item android:state_enabled="true"
- android:color="?attr/materialColorPrimary" />
-</selector>
\ No newline at end of file
diff --git a/core/res/res/color-watch-v36/btn_material_filled_text_color.xml b/core/res/res/color-watch-v36/btn_material_filled_text_color.xml
deleted file mode 100644
index cefc912..0000000
--- a/core/res/res/color-watch-v36/btn_material_filled_text_color.xml
+++ /dev/null
@@ -1,23 +0,0 @@
-<!--
- ~ Copyright (C) 2024 The Android Open Source Project
- ~
- ~ Licensed under the Apache License, Version 2.0 (the "License");
- ~ you may not use this file except in compliance with the License.
- ~ You may obtain a copy of the License at
- ~
- ~ http://www.apache.org/licenses/LICENSE-2.0
- ~
- ~ Unless required by applicable law or agreed to in writing, software
- ~ distributed under the License is distributed on an "AS IS" BASIS,
- ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- ~ See the License for the specific language governing permissions and
- ~ limitations under the License.
- -->
-
-<selector xmlns:android="http://schemas.android.com/apk/res/android">
- <item android:state_enabled="false"
- android:alpha="?attr/primaryContentAlpha"
- android:color="?attr/materialColorOnSurface" />
- <item android:state_enabled="true"
- android:color="?attr/materialColorOnPrimary" />
-</selector>
\ No newline at end of file
diff --git a/core/res/res/color-watch-v36/btn_material_filled_tonal_background_color.xml b/core/res/res/color-watch-v36/btn_material_filled_tonal_background_color.xml
deleted file mode 100644
index eaf9e7d..0000000
--- a/core/res/res/color-watch-v36/btn_material_filled_tonal_background_color.xml
+++ /dev/null
@@ -1,23 +0,0 @@
-<!--
- ~ Copyright (C) 2024 The Android Open Source Project
- ~
- ~ Licensed under the Apache License, Version 2.0 (the "License");
- ~ you may not use this file except in compliance with the License.
- ~ You may obtain a copy of the License at
- ~
- ~ http://www.apache.org/licenses/LICENSE-2.0
- ~
- ~ Unless required by applicable law or agreed to in writing, software
- ~ distributed under the License is distributed on an "AS IS" BASIS,
- ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- ~ See the License for the specific language governing permissions and
- ~ limitations under the License.
- -->
-
-<selector xmlns:android="http://schemas.android.com/apk/res/android">
- <item android:state_enabled="false"
- android:alpha="?attr/disabledAlpha"
- android:color="?attr/materialColorOnSurface" />
- <item android:state_enabled="true"
- android:color="?attr/materialColorSurfaceContainer" />
-</selector>
\ No newline at end of file
diff --git a/core/res/res/color-watch-v36/btn_material_filled_tonal_text_color.xml b/core/res/res/color-watch-v36/btn_material_filled_tonal_text_color.xml
deleted file mode 100644
index 94e50fb..0000000
--- a/core/res/res/color-watch-v36/btn_material_filled_tonal_text_color.xml
+++ /dev/null
@@ -1,23 +0,0 @@
-<!--
- ~ Copyright (C) 2024 The Android Open Source Project
- ~
- ~ Licensed under the Apache License, Version 2.0 (the "License");
- ~ you may not use this file except in compliance with the License.
- ~ You may obtain a copy of the License at
- ~
- ~ http://www.apache.org/licenses/LICENSE-2.0
- ~
- ~ Unless required by applicable law or agreed to in writing, software
- ~ distributed under the License is distributed on an "AS IS" BASIS,
- ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- ~ See the License for the specific language governing permissions and
- ~ limitations under the License.
- -->
-
-<selector xmlns:android="http://schemas.android.com/apk/res/android">
- <item android:state_enabled="false"
- android:alpha="?attr/primaryContentAlpha"
- android:color="?attr/materialColorOnSurface" />
- <item android:state_enabled="true"
- android:color="?attr/materialColorOnSurface" />
-</selector>
\ No newline at end of file
diff --git a/core/res/res/drawable-watch-v36/btn_background_material_filled.xml b/core/res/res/drawable-watch-v36/btn_background_material_filled.xml
deleted file mode 100644
index 0029de1..0000000
--- a/core/res/res/drawable-watch-v36/btn_background_material_filled.xml
+++ /dev/null
@@ -1,28 +0,0 @@
-<!--
- ~ Copyright (C) 2024 The Android Open Source Project
- ~
- ~ Licensed under the Apache License, Version 2.0 (the "License");
- ~ you may not use this file except in compliance with the License.
- ~ You may obtain a copy of the License at
- ~
- ~ http://www.apache.org/licenses/LICENSE-2.0
- ~
- ~ Unless required by applicable law or agreed to in writing, software
- ~ distributed under the License is distributed on an "AS IS" BASIS,
- ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- ~ See the License for the specific language governing permissions and
- ~ limitations under the License.
- -->
-
-<ripple xmlns:android="http://schemas.android.com/apk/res/android"
- android:color="?attr/colorControlHighlight">
- <item>
- <shape android:shape="rectangle">
- <solid android:color="@color/btn_material_filled_background_color"/>
- <corners android:radius="?android:attr/buttonCornerRadius"/>
- <size
- android:width="@dimen/btn_material_width"
- android:height="@dimen/btn_material_height" />
- </shape>
- </item>
-</ripple>
\ No newline at end of file
diff --git a/core/res/res/drawable-watch-v36/btn_background_material_filled_tonal.xml b/core/res/res/drawable-watch-v36/btn_background_material_filled_tonal.xml
deleted file mode 100644
index 105f077..0000000
--- a/core/res/res/drawable-watch-v36/btn_background_material_filled_tonal.xml
+++ /dev/null
@@ -1,28 +0,0 @@
-<!--
- ~ Copyright (C) 2024 The Android Open Source Project
- ~
- ~ Licensed under the Apache License, Version 2.0 (the "License");
- ~ you may not use this file except in compliance with the License.
- ~ You may obtain a copy of the License at
- ~
- ~ http://www.apache.org/licenses/LICENSE-2.0
- ~
- ~ Unless required by applicable law or agreed to in writing, software
- ~ distributed under the License is distributed on an "AS IS" BASIS,
- ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- ~ See the License for the specific language governing permissions and
- ~ limitations under the License.
- -->
-
-<ripple xmlns:android="http://schemas.android.com/apk/res/android"
- android:color="?attr/colorControlHighlight">
- <item>
- <shape android:shape="rectangle">
- <solid android:color="@color/btn_material_filled_tonal_background_color"/>
- <corners android:radius="?android:attr/buttonCornerRadius"/>
- <size
- android:width="@dimen/btn_material_width"
- android:height="@dimen/btn_material_height" />
- </shape>
- </item>
-</ripple>
\ No newline at end of file
diff --git a/core/res/res/values-watch-v36/colors.xml b/core/res/res/values-watch-v36/colors.xml
deleted file mode 100644
index 4bc2a66..0000000
--- a/core/res/res/values-watch-v36/colors.xml
+++ /dev/null
@@ -1,18 +0,0 @@
-<!--
- ~ Copyright (C) 2024 The Android Open Source Project
- ~
- ~ Licensed under the Apache License, Version 2.0 (the "License");
- ~ you may not use this file except in compliance with the License.
- ~ You may obtain a copy of the License at
- ~
- ~ http://www.apache.org/licenses/LICENSE-2.0
- ~
- ~ Unless required by applicable law or agreed to in writing, software
- ~ distributed under the License is distributed on an "AS IS" BASIS,
- ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- ~ See the License for the specific language governing permissions and
- ~ limitations under the License.
- -->
-<!-- TODO(b/372524566): update color token's value to match material3 design. -->
-<resources>
-</resources>
\ No newline at end of file
diff --git a/core/res/res/values-watch-v36/config.xml b/core/res/res/values-watch-v36/config.xml
deleted file mode 100644
index c8f347af..0000000
--- a/core/res/res/values-watch-v36/config.xml
+++ /dev/null
@@ -1,20 +0,0 @@
-<!--
- ~ Copyright (C) 2024 The Android Open Source Project
- ~
- ~ Licensed under the Apache License, Version 2.0 (the "License");
- ~ you may not use this file except in compliance with the License.
- ~ You may obtain a copy of the License at
- ~
- ~ http://www.apache.org/licenses/LICENSE-2.0
- ~
- ~ Unless required by applicable law or agreed to in writing, software
- ~ distributed under the License is distributed on an "AS IS" BASIS,
- ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- ~ See the License for the specific language governing permissions and
- ~ limitations under the License.
- -->
-
-<resources>
- <!-- Overrides system value -->
- <dimen name="config_buttonCornerRadius">26dp</dimen>
-</resources>
diff --git a/core/res/res/values-watch-v36/dimens_material.xml b/core/res/res/values-watch-v36/dimens_material.xml
deleted file mode 100644
index ad3c1a3..0000000
--- a/core/res/res/values-watch-v36/dimens_material.xml
+++ /dev/null
@@ -1,28 +0,0 @@
-<!--
- ~ Copyright (C) 2024 The Android Open Source Project
- ~
- ~ Licensed under the Apache License, Version 2.0 (the "License");
- ~ you may not use this file except in compliance with the License.
- ~ You may obtain a copy of the License at
- ~
- ~ http://www.apache.org/licenses/LICENSE-2.0
- ~
- ~ Unless required by applicable law or agreed to in writing, software
- ~ distributed under the License is distributed on an "AS IS" BASIS,
- ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- ~ See the License for the specific language governing permissions and
- ~ limitations under the License.
- -->
-<resources>
- <!-- values for material3 button -->
- <dimen name="btn_material_width">172dp</dimen>
- <dimen name="btn_material_height">52dp</dimen>
- <dimen name="btn_horizontal_edge_padding">14dp</dimen>
- <dimen name="btn_drawable_padding">6dp</dimen>
- <dimen name="btn_lineHeight">18sp</dimen>
- <dimen name="btn_textSize">15sp</dimen>
-
- <!-- Opacity factor for disabled material3 widget -->
- <dimen name="disabled_alpha_device_default">0.12</dimen>
- <dimen name="primary_content_alpha_device_default">0.38</dimen>
-</resources>
diff --git a/core/res/res/values-watch-v36/styles_material.xml b/core/res/res/values-watch-v36/styles_material.xml
deleted file mode 100644
index 32a22bb..0000000
--- a/core/res/res/values-watch-v36/styles_material.xml
+++ /dev/null
@@ -1,58 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
- ~ Copyright (C) 2024 The Android Open Source Project
- ~
- ~ Licensed under the Apache License, Version 2.0 (the "License");
- ~ you may not use this file except in compliance with the License.
- ~ You may obtain a copy of the License at
- ~
- ~ http://www.apache.org/licenses/LICENSE-2.0
- ~
- ~ Unless required by applicable law or agreed to in writing, software
- ~ distributed under the License is distributed on an "AS IS" BASIS,
- ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- ~ See the License for the specific language governing permissions and
- ~ limitations under the License.
- -->
-
-<resources>
- <!-- Button Styles -->
- <!-- Material Button - Filled -->
- <style name="Widget.DeviceDefault.Button.Filled" parent="Widget.DeviceDefault.Button">
- <item name="android:background">@drawable/btn_background_material_filled</item>
- <item name="textAppearance">@style/TextAppearance.Widget.Button.Material.Filled</item>
- </style>
-
- <!-- Material Button - Filled Tonal(Override system default button styles) -->
- <style name="Widget.DeviceDefault.Button">
- <item name="background">@drawable/btn_background_material_filled_tonal</item>
- <item name="textAppearance">@style/TextAppearance.Widget.Button.Material</item>
- <item name="minHeight">@dimen/btn_material_height</item>
- <item name="maxWidth">@dimen/btn_material_width</item>
- <item name="android:paddingStart">@dimen/btn_horizontal_edge_padding</item>
- <item name="android:paddingEnd">@dimen/btn_horizontal_edge_padding</item>
- <item name="android:drawablePadding">@dimen/btn_drawable_padding</item>
- <item name="android:maxLines">2</item>
- <item name="android:ellipsize">end</item>
- <item name="android:breakStrategy">simple</item>
- <item name="stateListAnimator">@anim/button_state_list_anim_material</item>
- <item name="focusable">true</item>
- <item name="clickable">true</item>
- <item name="gravity">center_vertical</item>
- </style>
-
- <!-- Text Styles -->
- <!-- TextAppearance for Material Button - Filled -->
- <style name="TextAppearance.Widget.Button.Material.Filled" parent="TextAppearance.Widget.Button.Material">
- <item name="textColor">@color/btn_material_filled_text_color</item>
- </style>
-
- <!-- TextAppearance for Material Button - Filled Tonal -->
- <style name="TextAppearance.Widget.Button.Material" parent="TextAppearance.DeviceDefault">
- <item name="android:fontFamily">font-family-flex-device-default</item>
- <item name="android:fontVariationSettings">"'wdth' 90, 'wght' 500, 'ROND' 100, 'opsz' 15, 'GRAD' 0"</item>
- <item name="textSize">@dimen/btn_textSize</item>
- <item name="textColor">@color/btn_material_filled_tonal_text_color</item>
- <item name="lineHeight">@dimen/btn_lineHeight</item>
- </style>
-</resources>
\ No newline at end of file
diff --git a/core/tests/coretests/src/android/app/NotificationTest.java b/core/tests/coretests/src/android/app/NotificationTest.java
index 48e2620..23a0985 100644
--- a/core/tests/coretests/src/android/app/NotificationTest.java
+++ b/core/tests/coretests/src/android/app/NotificationTest.java
@@ -2397,10 +2397,25 @@
public void progressStyle_getProgressMax_returnsSumOfSegmentLength() {
final Notification.ProgressStyle progressStyle = new Notification.ProgressStyle();
progressStyle
+ .setProgressSegments(List.of(new Notification.ProgressStyle.Segment(15),
+ new Notification.ProgressStyle.Segment(25)))
.addProgressSegment(new Notification.ProgressStyle.Segment(10))
.addProgressSegment(new Notification.ProgressStyle.Segment(20));
- assertThat(progressStyle.getProgressMax()).isEqualTo(30);
+ assertThat(progressStyle.getProgressMax()).isEqualTo(70);
+ }
+
+ @Test
+ @EnableFlags(Flags.FLAG_API_RICH_ONGOING)
+ public void progressStyle_getProgressMax_onSetProgressSegments_resets() {
+ final Notification.ProgressStyle progressStyle = new Notification.ProgressStyle();
+ progressStyle
+ .addProgressSegment(new Notification.ProgressStyle.Segment(10))
+ .addProgressSegment(new Notification.ProgressStyle.Segment(20))
+ .setProgressSegments(List.of(new Notification.ProgressStyle.Segment(15),
+ new Notification.ProgressStyle.Segment(25)));
+
+ assertThat(progressStyle.getProgressMax()).isEqualTo(40);
}
@Test
diff --git a/libs/WindowManager/Shell/shared/src/com/android/wm/shell/shared/split/SplitScreenConstants.java b/libs/WindowManager/Shell/shared/src/com/android/wm/shell/shared/split/SplitScreenConstants.java
index 61cd1c3..5a2a723 100644
--- a/libs/WindowManager/Shell/shared/src/com/android/wm/shell/shared/split/SplitScreenConstants.java
+++ b/libs/WindowManager/Shell/shared/src/com/android/wm/shell/shared/split/SplitScreenConstants.java
@@ -61,11 +61,30 @@
@IntDef(prefix = {"SPLIT_POSITION_"}, value = {
SPLIT_POSITION_UNDEFINED,
SPLIT_POSITION_TOP_OR_LEFT,
- SPLIT_POSITION_BOTTOM_OR_RIGHT
+ SPLIT_POSITION_BOTTOM_OR_RIGHT,
})
public @interface SplitPosition {
}
+ // These SPLIT_INDEX constants will be used in the same way as the above SPLIT_POSITION ints,
+ // but scalable to n apps. Eventually, SPLIT_POSITION can be deprecated and only the below
+ // will be used.
+ public static final int SPLIT_INDEX_UNDEFINED = -1;
+ public static final int SPLIT_INDEX_0 = 0;
+ public static final int SPLIT_INDEX_1 = 1;
+ public static final int SPLIT_INDEX_2 = 2;
+ public static final int SPLIT_INDEX_3 = 3;
+
+ @IntDef(prefix = {"SPLIT_INDEX_"}, value = {
+ SPLIT_INDEX_UNDEFINED,
+ SPLIT_INDEX_0,
+ SPLIT_INDEX_1,
+ SPLIT_INDEX_2,
+ SPLIT_INDEX_3
+ })
+ public @interface SplitIndex {
+ }
+
/**
* A snap target for two apps, where the split is 33-66. With FLAG_ENABLE_FLEXIBLE_SPLIT,
* only used on tablets.
diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/common/split/DividerSnapAlgorithm.java b/libs/WindowManager/Shell/src/com/android/wm/shell/common/split/DividerSnapAlgorithm.java
index 9f100fa..0b2b3e7 100644
--- a/libs/WindowManager/Shell/src/com/android/wm/shell/common/split/DividerSnapAlgorithm.java
+++ b/libs/WindowManager/Shell/src/com/android/wm/shell/common/split/DividerSnapAlgorithm.java
@@ -19,9 +19,11 @@
import static android.view.WindowManager.DOCKED_LEFT;
import static android.view.WindowManager.DOCKED_RIGHT;
+import static com.android.wm.shell.shared.split.SplitScreenConstants.SNAP_TO_2_10_90;
import static com.android.wm.shell.shared.split.SplitScreenConstants.SNAP_TO_2_33_66;
import static com.android.wm.shell.shared.split.SplitScreenConstants.SNAP_TO_2_50_50;
import static com.android.wm.shell.shared.split.SplitScreenConstants.SNAP_TO_2_66_33;
+import static com.android.wm.shell.shared.split.SplitScreenConstants.SNAP_TO_2_90_10;
import static com.android.wm.shell.shared.split.SplitScreenConstants.SNAP_TO_END_AND_DISMISS;
import static com.android.wm.shell.shared.split.SplitScreenConstants.SNAP_TO_MINIMIZE;
import static com.android.wm.shell.shared.split.SplitScreenConstants.SNAP_TO_NONE;
@@ -33,6 +35,9 @@
import androidx.annotation.Nullable;
+import com.android.wm.shell.Flags;
+import com.android.wm.shell.shared.split.SplitScreenConstants.PersistentSnapPosition;
+
import java.util.ArrayList;
/**
@@ -79,7 +84,9 @@
private final int mTaskHeightInMinimizedMode;
private final float mFixedRatio;
/** Allows split ratios to calculated dynamically instead of using {@link #mFixedRatio}. */
- private final boolean mAllowFlexibleSplitRatios;
+ private final boolean mCalculateRatiosBasedOnAvailableSpace;
+ /** Allows split ratios that go offscreen (a.k.a. "flexible split") */
+ private final boolean mAllowOffscreenRatios;
private final boolean mIsHorizontalDivision;
/** The first target which is still splitting the screen */
@@ -119,8 +126,11 @@
com.android.internal.R.fraction.docked_stack_divider_fixed_ratio, 1, 1);
mMinimalSizeResizableTask = res.getDimensionPixelSize(
com.android.internal.R.dimen.default_minimal_size_resizable_task);
- mAllowFlexibleSplitRatios = res.getBoolean(
+ mCalculateRatiosBasedOnAvailableSpace = res.getBoolean(
com.android.internal.R.bool.config_flexibleSplitRatios);
+ // If this is a small screen or a foldable, use offscreen ratios
+ mAllowOffscreenRatios =
+ Flags.enableFlexibleTwoAppSplit() && SplitScreenUtils.allowOffscreenRatios(res);
mTaskHeightInMinimizedMode = isHomeResizable ? res.getDimensionPixelSize(
com.android.internal.R.dimen.task_height_of_minimized_mode) : 0;
calculateTargets(isHorizontalDivision, dockSide);
@@ -233,6 +243,11 @@
return mFirstSplitTarget.position < position && position < mLastSplitTarget.position;
}
+ /** Returns if we are currently on a device/screen that supports split apps going offscreen. */
+ public boolean areOffscreenRatiosSupported() {
+ return mAllowOffscreenRatios;
+ }
+
private SnapTarget snap(int position, boolean hardDismiss) {
if (shouldApplyFreeSnapMode(position)) {
return new SnapTarget(position, SNAP_TO_NONE);
@@ -283,10 +298,14 @@
private void addNonDismissingTargets(boolean isHorizontalDivision, int topPosition,
int bottomPosition, int dividerMax) {
- maybeAddTarget(topPosition, topPosition - getStartInset(), SNAP_TO_2_33_66);
+ @PersistentSnapPosition int firstTarget =
+ mAllowOffscreenRatios ? SNAP_TO_2_10_90 : SNAP_TO_2_33_66;
+ @PersistentSnapPosition int lastTarget =
+ mAllowOffscreenRatios ? SNAP_TO_2_90_10 : SNAP_TO_2_66_33;
+ maybeAddTarget(topPosition, topPosition - getStartInset(), firstTarget);
addMiddleTarget(isHorizontalDivision);
maybeAddTarget(bottomPosition,
- dividerMax - getEndInset() - (bottomPosition + mDividerSize), SNAP_TO_2_66_33);
+ dividerMax - getEndInset() - (bottomPosition + mDividerSize), lastTarget);
}
private void addFixedDivisionTargets(boolean isHorizontalDivision, int dividerMax) {
@@ -295,7 +314,11 @@
? mDisplayHeight - mInsets.bottom
: mDisplayWidth - mInsets.right;
int size = (int) (mFixedRatio * (end - start)) - mDividerSize / 2;
- if (mAllowFlexibleSplitRatios) {
+
+ if (mAllowOffscreenRatios) {
+ // TODO (b/349828130): This is a placeholder value, real measurements to come
+ size = (int) (0.3f * (end - start)) - mDividerSize / 2;
+ } else if (mCalculateRatiosBasedOnAvailableSpace) {
size = Math.max(size, mMinimalSizeResizableTask);
}
int topPosition = start + size;
@@ -324,7 +347,7 @@
* meets the minimal size requirement.
*/
private void maybeAddTarget(int position, int smallerSize, @SnapPosition int snapPosition) {
- if (smallerSize >= mMinimalSizeResizableTask) {
+ if (smallerSize >= mMinimalSizeResizableTask || mAllowOffscreenRatios) {
mTargets.add(new SnapTarget(position, snapPosition));
}
}
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 83ffaf4..c9c3aa0 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
@@ -30,6 +30,8 @@
import static com.android.wm.shell.shared.animation.Interpolators.EMPHASIZED;
import static com.android.wm.shell.shared.animation.Interpolators.LINEAR;
import static com.android.wm.shell.shared.animation.Interpolators.SLOWDOWN_INTERPOLATOR;
+import static com.android.wm.shell.shared.split.SplitScreenConstants.SNAP_TO_2_10_90;
+import static com.android.wm.shell.shared.split.SplitScreenConstants.SNAP_TO_2_90_10;
import static com.android.wm.shell.shared.split.SplitScreenConstants.SNAP_TO_END_AND_DISMISS;
import static com.android.wm.shell.shared.split.SplitScreenConstants.SNAP_TO_START_AND_DISMISS;
import static com.android.wm.shell.shared.split.SplitScreenConstants.SPLIT_POSITION_BOTTOM_OR_RIGHT;
@@ -438,12 +440,31 @@
dividerBounds.right = dividerBounds.left + mDividerWindowWidth;
bounds1.right = position;
bounds2.left = bounds1.right + mDividerSize;
+
+ // For flexible split, expand app offscreen as well
+ if (mDividerSnapAlgorithm.areOffscreenRatiosSupported()) {
+ if (position <= mDividerSnapAlgorithm.getMiddleTarget().position) {
+ bounds1.left = bounds1.right - bounds2.width();
+ } else {
+ bounds2.right = bounds2.left + bounds1.width();
+ }
+ }
+
} else {
position += mRootBounds.top;
dividerBounds.top = position - mDividerInsets;
dividerBounds.bottom = dividerBounds.top + mDividerWindowWidth;
bounds1.bottom = position;
bounds2.top = bounds1.bottom + mDividerSize;
+
+ // For flexible split, expand app offscreen as well
+ if (mDividerSnapAlgorithm.areOffscreenRatiosSupported()) {
+ if (position <= mDividerSnapAlgorithm.getMiddleTarget().position) {
+ bounds1.top = bounds1.bottom - bounds2.width();
+ } else {
+ bounds2.bottom = bounds2.top + bounds1.width();
+ }
+ }
}
DockedDividerUtils.sanitizeStackBounds(bounds1, true /** topLeft */);
DockedDividerUtils.sanitizeStackBounds(bounds2, false /** topLeft */);
@@ -669,6 +690,21 @@
});
}
+ /**
+ * Moves the divider to the other side of the screen. Does nothing if the divider is in the
+ * center.
+ * TODO (b/349828130): Currently only supports the two-app case. For n-apps,
+ * DividerSnapAlgorithm will need to be refactored, and this function will change as well.
+ */
+ public void flingDividerToOtherSide(@PersistentSnapPosition int currentSnapPosition) {
+ switch (currentSnapPosition) {
+ case SNAP_TO_2_10_90 ->
+ snapToTarget(mDividerPosition, mDividerSnapAlgorithm.getLastSplitTarget());
+ case SNAP_TO_2_90_10 ->
+ snapToTarget(mDividerPosition, mDividerSnapAlgorithm.getFirstSplitTarget());
+ }
+ }
+
@VisibleForTesting
void flingDividerPosition(int from, int to, int duration,
@Nullable Runnable flingFinishedCallback) {
diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/common/split/SplitScreenUtils.java b/libs/WindowManager/Shell/src/com/android/wm/shell/common/split/SplitScreenUtils.java
index bdbcb46..65bf389 100644
--- a/libs/WindowManager/Shell/src/com/android/wm/shell/common/split/SplitScreenUtils.java
+++ b/libs/WindowManager/Shell/src/com/android/wm/shell/common/split/SplitScreenUtils.java
@@ -18,6 +18,10 @@
import static com.android.wm.shell.shared.split.SplitScreenConstants.CONTROLLED_ACTIVITY_TYPES;
import static com.android.wm.shell.shared.split.SplitScreenConstants.CONTROLLED_WINDOWING_MODES;
+import static com.android.wm.shell.shared.split.SplitScreenConstants.SNAP_TO_2_10_90;
+import static com.android.wm.shell.shared.split.SplitScreenConstants.SNAP_TO_2_90_10;
+import static com.android.wm.shell.shared.split.SplitScreenConstants.SNAP_TO_3_10_45_45;
+import static com.android.wm.shell.shared.split.SplitScreenConstants.SNAP_TO_3_45_45_10;
import static com.android.wm.shell.shared.split.SplitScreenConstants.SPLIT_POSITION_BOTTOM_OR_RIGHT;
import static com.android.wm.shell.shared.split.SplitScreenConstants.SPLIT_POSITION_TOP_OR_LEFT;
import static com.android.wm.shell.shared.split.SplitScreenConstants.SPLIT_POSITION_UNDEFINED;
@@ -38,6 +42,8 @@
/** Helper utility class for split screen components to use. */
public class SplitScreenUtils {
+ private static final int LARGE_SCREEN_MIN_EDGE_DP = 600;
+
/** Reverse the split position. */
@SplitScreenConstants.SplitPosition
public static int reverseSplitPosition(@SplitScreenConstants.SplitPosition int position) {
@@ -110,10 +116,9 @@
Configuration config) {
// Compare the max bounds sizes as on near-square devices, the insets may result in a
// configuration in the other orientation
- final boolean isLargeScreen = config.smallestScreenWidthDp >= 600;
final Rect maxBounds = config.windowConfiguration.getMaxBounds();
final boolean isLandscape = maxBounds.width() >= maxBounds.height();
- return isLeftRightSplit(allowLeftRightSplitInPortrait, isLargeScreen, isLandscape);
+ return isLeftRightSplit(allowLeftRightSplitInPortrait, isLargeScreen(config), isLandscape);
}
/**
@@ -128,4 +133,41 @@
return isLandscape;
}
}
+
+ /**
+ * Returns whether the current config is a large screen (tablet or unfolded foldable)
+ */
+ public static boolean isLargeScreen(Configuration config) {
+ return config.smallestScreenWidthDp >= LARGE_SCREEN_MIN_EDGE_DP;
+ }
+
+ /**
+ * Returns whether we should allow split ratios to go offscreen or not. If the device is a phone
+ * or a foldable (either screen), we allow it.
+ */
+ public static boolean allowOffscreenRatios(Resources res) {
+ return !isLargeScreen(res.getConfiguration())
+ ||
+ res.getIntArray(com.android.internal.R.array.config_foldedDeviceStates).length != 0;
+ }
+
+ /**
+ * Within a particular split layout, we label the stages numerically: 0, 1, 2... from left to
+ * right (or top to bottom). This function takes in a stage index (0th, 1st, 2nd...) and a
+ * PersistentSnapPosition and returns if that particular stage is offscreen in that layout.
+ */
+ public static boolean isPartiallyOffscreen(int stageIndex,
+ @SplitScreenConstants.PersistentSnapPosition int snapPosition) {
+ switch(snapPosition) {
+ case SNAP_TO_2_10_90:
+ case SNAP_TO_3_10_45_45:
+ return stageIndex == 0;
+ case SNAP_TO_2_90_10:
+ return stageIndex == 1;
+ case SNAP_TO_3_45_45_10:
+ return stageIndex == 2;
+ default:
+ return false;
+ }
+ }
}
diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/desktopmode/DragToDesktopTransitionHandler.kt b/libs/WindowManager/Shell/src/com/android/wm/shell/desktopmode/DragToDesktopTransitionHandler.kt
index 8e264b2..34c2f1e 100644
--- a/libs/WindowManager/Shell/src/com/android/wm/shell/desktopmode/DragToDesktopTransitionHandler.kt
+++ b/libs/WindowManager/Shell/src/com/android/wm/shell/desktopmode/DragToDesktopTransitionHandler.kt
@@ -648,7 +648,13 @@
state.startAborted = true
// The start-transition (DRAG_HOLD) is aborted, cancel its jank interaction.
interactionJankMonitor.cancel(CUJ_DESKTOP_MODE_ENTER_APP_HANDLE_DRAG_HOLD)
- } else if (state.cancelTransitionToken != transition) {
+ } else if (state.cancelTransitionToken == transition) {
+ state.draggedTaskChange?.leash?.let {
+ state.startTransitionFinishTransaction?.show(it)
+ }
+ state.startTransitionFinishCb?.onTransitionFinished(null /* wct */)
+ clearState()
+ } else {
// This transition being aborted is neither the start, nor the cancel transition, so
// it must be the finish transition (DRAG_RELEASE); cancel its jank interaction.
interactionJankMonitor.cancel(CUJ_DESKTOP_MODE_ENTER_APP_HANDLE_DRAG_RELEASE)
@@ -863,7 +869,8 @@
companion object {
/** The duration of the animation to commit or cancel the drag-to-desktop gesture. */
- internal const val DRAG_TO_DESKTOP_FINISH_ANIM_DURATION_MS = 336L
+ @VisibleForTesting(visibility = VisibleForTesting.Visibility.PACKAGE)
+ const val DRAG_TO_DESKTOP_FINISH_ANIM_DURATION_MS = 336L
}
}
diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/pip2/phone/PipMotionHelper.java b/libs/WindowManager/Shell/src/com/android/wm/shell/pip2/phone/PipMotionHelper.java
index 268c3a2..537ef18 100644
--- a/libs/WindowManager/Shell/src/com/android/wm/shell/pip2/phone/PipMotionHelper.java
+++ b/libs/WindowManager/Shell/src/com/android/wm/shell/pip2/phone/PipMotionHelper.java
@@ -350,7 +350,7 @@
}
cancelPhysicsAnimation();
mMenuController.hideMenu(ANIM_TYPE_DISMISS, false /* resize */);
- // mPipTaskOrganizer.removePip();
+ mPipScheduler.removePipAfterAnimation();
}
/** Sets the movement bounds to use to constrain PIP position animations. */
diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/pip2/phone/PipScheduler.java b/libs/WindowManager/Shell/src/com/android/wm/shell/pip2/phone/PipScheduler.java
index d4f190e..fbbf6f3 100644
--- a/libs/WindowManager/Shell/src/com/android/wm/shell/pip2/phone/PipScheduler.java
+++ b/libs/WindowManager/Shell/src/com/android/wm/shell/pip2/phone/PipScheduler.java
@@ -19,81 +19,40 @@
import static android.app.WindowConfiguration.WINDOWING_MODE_UNDEFINED;
import static com.android.wm.shell.transition.Transitions.TRANSIT_EXIT_PIP;
+import static com.android.wm.shell.transition.Transitions.TRANSIT_REMOVE_PIP;
-import android.content.BroadcastReceiver;
import android.content.Context;
-import android.content.Intent;
-import android.content.IntentFilter;
import android.graphics.Matrix;
import android.graphics.Rect;
import android.view.SurfaceControl;
import android.window.WindowContainerTransaction;
-import androidx.annotation.IntDef;
import androidx.annotation.Nullable;
-import androidx.core.content.ContextCompat;
import com.android.internal.protolog.ProtoLog;
import com.android.wm.shell.common.ShellExecutor;
import com.android.wm.shell.common.pip.PipBoundsState;
-import com.android.wm.shell.common.pip.PipUtils;
import com.android.wm.shell.pip.PipTransitionController;
+import com.android.wm.shell.pip2.PipSurfaceTransactionHelper;
+import com.android.wm.shell.pip2.animation.PipAlphaAnimator;
import com.android.wm.shell.protolog.ShellProtoLogGroup;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-
/**
* Scheduler for Shell initiated PiP transitions and animations.
*/
public class PipScheduler {
private static final String TAG = PipScheduler.class.getSimpleName();
- private static final String BROADCAST_FILTER = PipScheduler.class.getCanonicalName();
private final Context mContext;
private final PipBoundsState mPipBoundsState;
private final ShellExecutor mMainExecutor;
private final PipTransitionState mPipTransitionState;
- private PipSchedulerReceiver mSchedulerReceiver;
private PipTransitionController mPipTransitionController;
+ private final PipSurfaceTransactionHelper.SurfaceControlTransactionFactory
+ mSurfaceControlTransactionFactory;
@Nullable private Runnable mUpdateMovementBoundsRunnable;
- /**
- * Temporary PiP CUJ codes to schedule PiP related transitions directly from Shell.
- * This is used for a broadcast receiver to resolve intents. This should be removed once
- * there is an equivalent of PipTouchHandler and PipResizeGestureHandler for PiP2.
- */
- private static final int PIP_EXIT_VIA_EXPAND_CODE = 0;
- private static final int PIP_DOUBLE_TAP = 1;
-
- @IntDef(value = {
- PIP_EXIT_VIA_EXPAND_CODE,
- PIP_DOUBLE_TAP
- })
- @Retention(RetentionPolicy.SOURCE)
- @interface PipUserJourneyCode {}
-
- /**
- * A temporary broadcast receiver to initiate PiP CUJs.
- */
- private class PipSchedulerReceiver extends BroadcastReceiver {
- @Override
- public void onReceive(Context context, Intent intent) {
- int userJourneyCode = intent.getIntExtra("cuj_code_extra", 0);
- switch (userJourneyCode) {
- case PIP_EXIT_VIA_EXPAND_CODE:
- scheduleExitPipViaExpand();
- break;
- case PIP_DOUBLE_TAP:
- scheduleDoubleTapToResize();
- break;
- default:
- throw new IllegalStateException("unexpected CUJ code=" + userJourneyCode);
- }
- }
- }
-
public PipScheduler(Context context,
PipBoundsState pipBoundsState,
ShellExecutor mainExecutor,
@@ -103,12 +62,8 @@
mMainExecutor = mainExecutor;
mPipTransitionState = pipTransitionState;
- if (PipUtils.isPip2ExperimentEnabled()) {
- // temporary broadcast receiver to initiate exit PiP via expand
- mSchedulerReceiver = new PipSchedulerReceiver();
- ContextCompat.registerReceiver(mContext, mSchedulerReceiver,
- new IntentFilter(BROADCAST_FILTER), ContextCompat.RECEIVER_EXPORTED);
- }
+ mSurfaceControlTransactionFactory =
+ new PipSurfaceTransactionHelper.VsyncSurfaceControlTransactionFactory();
}
ShellExecutor getMainExecutor() {
@@ -133,6 +88,18 @@
return wct;
}
+ @Nullable
+ private WindowContainerTransaction getRemovePipTransaction() {
+ if (mPipTransitionState.mPipTaskToken == null) {
+ return null;
+ }
+ WindowContainerTransaction wct = new WindowContainerTransaction();
+ wct.setBounds(mPipTransitionState.mPipTaskToken, null);
+ wct.setWindowingMode(mPipTransitionState.mPipTaskToken, WINDOWING_MODE_UNDEFINED);
+ wct.reorder(mPipTransitionState.mPipTaskToken, false);
+ return wct;
+ }
+
/**
* Schedules exit PiP via expand transition.
*/
@@ -146,10 +113,26 @@
}
}
- /**
- * Schedules resize PiP via double tap.
- */
- public void scheduleDoubleTapToResize() {}
+ // TODO: Optimize this by running the animation as part of the transition
+ /** Runs remove PiP animation and schedules remove PiP transition after the animation ends. */
+ public void removePipAfterAnimation() {
+ SurfaceControl.Transaction tx = mSurfaceControlTransactionFactory.getTransaction();
+ PipAlphaAnimator animator = new PipAlphaAnimator(mContext,
+ mPipTransitionState.mPinnedTaskLeash, tx, PipAlphaAnimator.FADE_OUT);
+ animator.setAnimationEndCallback(this::scheduleRemovePipImmediately);
+ animator.start();
+ }
+
+ /** Schedules remove PiP transition. */
+ private void scheduleRemovePipImmediately() {
+ WindowContainerTransaction wct = getRemovePipTransaction();
+ if (wct != null) {
+ mMainExecutor.execute(() -> {
+ mPipTransitionController.startExitTransition(TRANSIT_REMOVE_PIP, wct,
+ null /* destinationBounds */);
+ });
+ }
+ }
/**
* Animates resizing of the pinned stack given the duration.
diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/pip2/phone/PipTaskListener.java b/libs/WindowManager/Shell/src/com/android/wm/shell/pip2/phone/PipTaskListener.java
index c58de2c..373ec80 100644
--- a/libs/WindowManager/Shell/src/com/android/wm/shell/pip2/phone/PipTaskListener.java
+++ b/libs/WindowManager/Shell/src/com/android/wm/shell/pip2/phone/PipTaskListener.java
@@ -90,9 +90,10 @@
if (mPictureInPictureParams.equals(params)) {
return;
}
- if (PipUtils.remoteActionsChanged(params.getActions(), mPictureInPictureParams.getActions())
+ if (params != null && (PipUtils.remoteActionsChanged(params.getActions(),
+ mPictureInPictureParams.getActions())
|| !PipUtils.remoteActionsMatch(params.getCloseAction(),
- mPictureInPictureParams.getCloseAction())) {
+ mPictureInPictureParams.getCloseAction()))) {
for (PipParamsChangedCallback listener : mPipParamsChangedListeners) {
listener.onActionsChanged(params.getActions(), params.getCloseAction());
}
diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/pip2/phone/PipTransition.java b/libs/WindowManager/Shell/src/com/android/wm/shell/pip2/phone/PipTransition.java
index b57f51a..ac1567a 100644
--- a/libs/WindowManager/Shell/src/com/android/wm/shell/pip2/phone/PipTransition.java
+++ b/libs/WindowManager/Shell/src/com/android/wm/shell/pip2/phone/PipTransition.java
@@ -25,6 +25,7 @@
import static android.view.WindowManager.TRANSIT_TO_FRONT;
import static com.android.wm.shell.transition.Transitions.TRANSIT_EXIT_PIP;
+import static com.android.wm.shell.transition.Transitions.TRANSIT_REMOVE_PIP;
import static com.android.wm.shell.transition.Transitions.TRANSIT_RESIZE_PIP;
import android.animation.Animator;
@@ -605,8 +606,11 @@
&& pipChange.getMode() == TRANSIT_TO_BACK;
boolean isPipClosed = info.getType() == TRANSIT_CLOSE
&& pipChange.getMode() == TRANSIT_CLOSE;
- // PiP is being removed if the pinned task is either moved to back or closed.
- return isPipMovedToBack || isPipClosed;
+ // If PiP is dismissed by user (i.e. via dismiss button in PiP menu)
+ boolean isPipDismissed = info.getType() == TRANSIT_REMOVE_PIP
+ && pipChange.getMode() == TRANSIT_TO_BACK;
+ // PiP is being removed if the pinned task is either moved to back, closed, or dismissed.
+ return isPipMovedToBack || isPipClosed || isPipDismissed;
}
//
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 dc9ed91..fea987a 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
@@ -35,12 +35,19 @@
import static android.window.WindowContainerTransaction.HierarchyOp.HIERARCHY_OP_TYPE_REORDER;
import static com.android.wm.shell.common.split.SplitLayout.PARALLAX_ALIGN_CENTER;
+import static com.android.wm.shell.common.split.SplitScreenUtils.isPartiallyOffscreen;
import static com.android.wm.shell.common.split.SplitScreenUtils.reverseSplitPosition;
import static com.android.wm.shell.common.split.SplitScreenUtils.splitFailureMessage;
import static com.android.wm.shell.protolog.ShellProtoLogGroup.WM_SHELL_SPLIT_SCREEN;
import static com.android.wm.shell.shared.TransitionUtil.isClosingType;
import static com.android.wm.shell.shared.TransitionUtil.isOpeningType;
+import static com.android.wm.shell.shared.TransitionUtil.isOrderOnly;
import static com.android.wm.shell.shared.split.SplitScreenConstants.FLAG_IS_DIVIDER_BAR;
+import static com.android.wm.shell.shared.split.SplitScreenConstants.SNAP_TO_2_10_90;
+import static com.android.wm.shell.shared.split.SplitScreenConstants.SNAP_TO_2_90_10;
+import static com.android.wm.shell.shared.split.SplitScreenConstants.SPLIT_INDEX_0;
+import static com.android.wm.shell.shared.split.SplitScreenConstants.SPLIT_INDEX_1;
+import static com.android.wm.shell.shared.split.SplitScreenConstants.SPLIT_INDEX_UNDEFINED;
import static com.android.wm.shell.shared.split.SplitScreenConstants.SPLIT_POSITION_BOTTOM_OR_RIGHT;
import static com.android.wm.shell.shared.split.SplitScreenConstants.SPLIT_POSITION_TOP_OR_LEFT;
import static com.android.wm.shell.shared.split.SplitScreenConstants.SPLIT_POSITION_UNDEFINED;
@@ -117,6 +124,7 @@
import com.android.internal.policy.FoldLockSettingsObserver;
import com.android.internal.protolog.ProtoLog;
import com.android.launcher3.icons.IconProvider;
+import com.android.wm.shell.Flags;
import com.android.wm.shell.R;
import com.android.wm.shell.ShellTaskOrganizer;
import com.android.wm.shell.common.DisplayController;
@@ -160,23 +168,15 @@
* - The {@link SplitLayout} divider is only visible if multiple {@link StageTaskListener}s are
* visible
* - Both stages are put under a single-top root task.
- * This rules are mostly implemented in {@link #onStageVisibilityChanged(StageListenerImpl)} and
- * {@link #onStageHasChildrenChanged(StageListenerImpl).}
*/
public class StageCoordinator implements SplitLayout.SplitLayoutHandler,
DisplayController.OnDisplaysChangedListener, Transitions.TransitionHandler,
- ShellTaskOrganizer.TaskListener {
+ ShellTaskOrganizer.TaskListener, StageTaskListener.StageListenerCallbacks {
private static final String TAG = StageCoordinator.class.getSimpleName();
- // The duration in ms to prevent launch-adjacent from working after split screen is first
- // entered
- private static final int DISABLE_LAUNCH_ADJACENT_AFTER_ENTER_TIMEOUT_MS = 1000;
-
private final StageTaskListener mMainStage;
- private final StageListenerImpl mMainStageListener = new StageListenerImpl();
private final StageTaskListener mSideStage;
- private final StageListenerImpl mSideStageListener = new StageListenerImpl();
@SplitPosition
private int mSideStagePosition = SPLIT_POSITION_BOTTOM_OR_RIGHT;
@@ -239,10 +239,6 @@
private SplitScreen.SplitInvocationListener mSplitInvocationListener;
private Executor mSplitInvocationListenerExecutor;
- // Re-enables launch-adjacent handling on the split root task. This needs to be a member
- // because we will be posting and removing it from the handler.
- private final Runnable mReEnableLaunchAdjacentOnRoot = () -> setLaunchAdjacentDisabled(false);
-
/**
* Since StageCoordinator only coordinates MainStage and SideStage, it shouldn't support
* CompatUI layouts. CompatUI is handled separately by MainStage and SideStage.
@@ -336,7 +332,7 @@
mContext,
mTaskOrganizer,
mDisplayId,
- mMainStageListener,
+ this /*stageListenerCallbacks*/,
mSyncQueue,
iconProvider,
mWindowDecorViewModel);
@@ -344,7 +340,7 @@
mContext,
mTaskOrganizer,
mDisplayId,
- mSideStageListener,
+ this /*stageListenerCallbacks*/,
mSyncQueue,
iconProvider,
mWindowDecorViewModel);
@@ -419,7 +415,7 @@
}
public boolean isSplitScreenVisible() {
- return mSideStageListener.mVisible && mMainStageListener.mVisible;
+ return mSideStage.mVisible && mMainStage.mVisible;
}
private void activateSplit(WindowContainerTransaction wct, boolean includingTopTask) {
@@ -1104,7 +1100,7 @@
mSideStagePosition = sideStagePosition;
sendOnStagePositionChanged();
- if (mSideStageListener.mVisible && updateBounds) {
+ if (mSideStage.mVisible && updateBounds) {
if (wct == null) {
// onLayoutChanged builds/applies a wct with the contents of updateWindowBounds.
onLayoutSizeChanged(mSplitLayout);
@@ -1325,8 +1321,8 @@
private void clearRequestIfPresented() {
ProtoLog.d(WM_SHELL_SPLIT_SCREEN, "clearRequestIfPresented");
- if (mSideStageListener.mVisible && mSideStageListener.mHasChildren
- && mMainStageListener.mVisible && mSideStageListener.mHasChildren) {
+ if (mSideStage.mVisible && mSideStage.mHasChildren
+ && mMainStage.mVisible && mSideStage.mHasChildren) {
mSplitRequest = null;
}
}
@@ -1579,11 +1575,12 @@
}
}
- private void onStageChildTaskStatusChanged(StageListenerImpl stageListener, int taskId,
+ @Override
+ public void onChildTaskStatusChanged(StageTaskListener stageListener, int taskId,
boolean present, boolean visible) {
int stage;
if (present) {
- stage = stageListener == mSideStageListener ? STAGE_TYPE_SIDE : STAGE_TYPE_MAIN;
+ stage = stageListener == mSideStage ? STAGE_TYPE_SIDE : STAGE_TYPE_MAIN;
} else {
// No longer on any stage
stage = STAGE_TYPE_UNDEFINED;
@@ -1714,13 +1711,14 @@
@VisibleForTesting
- void onRootTaskAppeared() {
+ @Override
+ public void onRootTaskAppeared() {
ProtoLog.d(WM_SHELL_SPLIT_SCREEN, "onRootTaskAppeared: rootTask=%s mainRoot=%b sideRoot=%b",
- mRootTaskInfo, mMainStageListener.mHasRootTask, mSideStageListener.mHasRootTask);
+ mRootTaskInfo, mMainStage.mHasRootTask, mSideStage.mHasRootTask);
// Wait unit all root tasks appeared.
if (mRootTaskInfo == null
- || !mMainStageListener.mHasRootTask
- || !mSideStageListener.mHasRootTask) {
+ || !mMainStage.mHasRootTask
+ || !mSideStage.mHasRootTask) {
return;
}
@@ -1740,35 +1738,8 @@
mLaunchAdjacentController.setLaunchAdjacentRoot(mSideStage.mRootTaskInfo.token);
}
- /** Callback when split roots have child task appeared under it, this is a little different from
- * #onStageHasChildrenChanged because this would be called every time child task appeared.
- * NOTICE: This only be called on legacy transition. */
- private void onChildTaskAppeared(StageListenerImpl stageListener, int taskId) {
- ProtoLog.d(WM_SHELL_SPLIT_SCREEN, "onChildTaskAppeared: isMainStage=%b task=%d",
- stageListener == mMainStageListener, taskId);
- // Handle entering split screen while there is a split pair running in the background.
- if (stageListener == mSideStageListener && !isSplitScreenVisible() && isSplitActive()
- && mSplitRequest == null) {
- final WindowContainerTransaction wct = new WindowContainerTransaction();
- prepareEnterSplitScreen(wct);
- mMainStage.evictAllChildren(wct);
- mSideStage.evictOtherChildren(wct, taskId);
-
- mSyncQueue.queue(wct);
- mSyncQueue.runInSync(t -> {
- if (mIsDropEntering) {
- updateSurfaceBounds(mSplitLayout, t, false /* applyResizingOffset */);
- mIsDropEntering = false;
- mSkipEvictingMainStageChildren = false;
- } else {
- mShowDecorImmediately = true;
- mSplitLayout.flingDividerToCenter(/*finishCallback*/ null);
- }
- });
- }
- }
-
- private void onRootTaskVanished() {
+ @Override
+ public void onRootTaskVanished() {
ProtoLog.d(WM_SHELL_SPLIT_SCREEN, "onRootTaskVanished");
final WindowContainerTransaction wct = new WindowContainerTransaction();
mLaunchAdjacentController.clearLaunchAdjacentRoot();
@@ -1785,15 +1756,16 @@
/** Callback when split roots visiblility changed.
* NOTICE: This only be called on legacy transition. */
- private void onStageVisibilityChanged(StageListenerImpl stageListener) {
+ @Override
+ public void onStageVisibilityChanged(StageTaskListener stageListener) {
// If split didn't active, just ignore this callback because we should already did these
// on #applyExitSplitScreen.
if (!isSplitActive()) {
return;
}
- final boolean sideStageVisible = mSideStageListener.mVisible;
- final boolean mainStageVisible = mMainStageListener.mVisible;
+ final boolean sideStageVisible = mSideStage.mVisible;
+ final boolean mainStageVisible = mMainStage.mVisible;
// Wait for both stages having the same visibility to prevent causing flicker.
if (mainStageVisible != sideStageVisible) {
@@ -1930,18 +1902,19 @@
/** Callback when split roots have child or haven't under it.
* NOTICE: This only be called on legacy transition. */
- private void onStageHasChildrenChanged(StageListenerImpl stageListener) {
+ @Override
+ public void onStageHasChildrenChanged(StageTaskListener stageListener) {
ProtoLog.d(WM_SHELL_SPLIT_SCREEN, "onStageHasChildrenChanged: isMainStage=%b",
- stageListener == mMainStageListener);
+ stageListener == mMainStage);
final boolean hasChildren = stageListener.mHasChildren;
- final boolean isSideStage = stageListener == mSideStageListener;
+ final boolean isSideStage = stageListener == mSideStage;
if (!hasChildren && !mIsExiting && isSplitActive()) {
- if (isSideStage && mMainStageListener.mVisible) {
+ if (isSideStage && mMainStage.mVisible) {
// Exit to main stage if side stage no longer has children.
mSplitLayout.flingDividerToDismiss(
mSideStagePosition == SPLIT_POSITION_BOTTOM_OR_RIGHT,
EXIT_REASON_APP_FINISHED);
- } else if (!isSideStage && mSideStageListener.mVisible) {
+ } else if (!isSideStage && mSideStage.mVisible) {
// Exit to side stage if main stage no longer has children.
mSplitLayout.flingDividerToDismiss(
mSideStagePosition != SPLIT_POSITION_BOTTOM_OR_RIGHT,
@@ -1966,7 +1939,7 @@
}
});
}
- if (mMainStageListener.mHasChildren && mSideStageListener.mHasChildren) {
+ if (mMainStage.mHasChildren && mSideStage.mHasChildren) {
mShouldUpdateRecents = true;
clearRequestIfPresented();
updateRecentTasksSplitPair();
@@ -1982,6 +1955,35 @@
}
@Override
+ public void onNoLongerSupportMultiWindow(StageTaskListener stageTaskListener,
+ ActivityManager.RunningTaskInfo taskInfo) {
+ ProtoLog.d(WM_SHELL_SPLIT_SCREEN, "onNoLongerSupportMultiWindow: task=%s", taskInfo);
+ if (isSplitActive()) {
+ final boolean isMainStage = mMainStage == stageTaskListener;
+
+ // If visible, we preserve the app and keep it running. If an app becomes
+ // unsupported in the bg, break split without putting anything on top
+ boolean splitScreenVisible = isSplitScreenVisible();
+ int stageType = STAGE_TYPE_UNDEFINED;
+ if (splitScreenVisible) {
+ stageType = isMainStage ? STAGE_TYPE_MAIN : STAGE_TYPE_SIDE;
+ }
+ final WindowContainerTransaction wct = new WindowContainerTransaction();
+ prepareExitSplitScreen(stageType, wct);
+ clearSplitPairedInRecents(EXIT_REASON_APP_DOES_NOT_SUPPORT_MULTIWINDOW);
+ mSplitTransitions.startDismissTransition(wct, StageCoordinator.this, stageType,
+ EXIT_REASON_APP_DOES_NOT_SUPPORT_MULTIWINDOW);
+ Log.w(TAG, splitFailureMessage("onNoLongerSupportMultiWindow",
+ "app package " + taskInfo.baseIntent.getComponent()
+ + " does not support splitscreen, or is a controlled activity"
+ + " type"));
+ if (splitScreenVisible) {
+ handleUnsupportedSplitStart();
+ }
+ }
+ }
+
+ @Override
public void onSnappedToDismiss(boolean bottomOrRight, @ExitReason int exitReason) {
ProtoLog.d(WM_SHELL_SPLIT_SCREEN, "onSnappedToDismiss: bottomOrRight=%b reason=%s",
bottomOrRight, exitReasonToString(exitReason));
@@ -2053,6 +2055,13 @@
mSplitLayout.setDividerInteractive(true, false, "onSplitResizeFinish");
}, mMainStage.getSplitDecorManager(), mSideStage.getSplitDecorManager());
+ if (Flags.enableFlexibleTwoAppSplit()) {
+ switch (layout.calculateCurrentSnapPosition()) {
+ case SNAP_TO_2_10_90 -> grantFocusToPosition(false /* leftOrTop */);
+ case SNAP_TO_2_90_10 -> grantFocusToPosition(true /* leftOrTop */);
+ }
+ }
+
mLogger.logResize(mSplitLayout.getDividerPositionAsFraction());
}
@@ -2506,6 +2515,26 @@
mTaskOrganizer.applyTransaction(wct);
}
continue;
+ } else if (Flags.enableFlexibleTwoAppSplit() && isOrderOnly(change)) {
+ int focusedStageIndex = SPLIT_INDEX_UNDEFINED;
+ if (taskInfo.token.equals(mMainStage.mRootTaskInfo.token)) {
+ focusedStageIndex = mSideStagePosition == SPLIT_POSITION_BOTTOM_OR_RIGHT
+ ? SPLIT_INDEX_0 : SPLIT_INDEX_1;
+ } else if (taskInfo.token.equals(mSideStage.mRootTaskInfo.token)) {
+ focusedStageIndex = mSideStagePosition == SPLIT_POSITION_BOTTOM_OR_RIGHT
+ ? SPLIT_INDEX_1 : SPLIT_INDEX_0;
+ }
+
+ if (focusedStageIndex != SPLIT_INDEX_UNDEFINED) {
+ @PersistentSnapPosition int currentSnapPosition =
+ mSplitLayout.calculateCurrentSnapPosition();
+ boolean offscreenTaskFocused =
+ isPartiallyOffscreen(focusedStageIndex, currentSnapPosition);
+
+ if (offscreenTaskFocused) {
+ mSplitLayout.flingDividerToOtherSide(currentSnapPosition);
+ }
+ }
}
final StageTaskListener stage = getStageOfTask(taskInfo);
if (stage == null) {
@@ -2670,16 +2699,6 @@
}
}
- /**
- * Sets whether launch-adjacent is disabled or enabled.
- */
- private void setLaunchAdjacentDisabled(boolean disabled) {
- ProtoLog.d(WM_SHELL_SPLIT_SCREEN, "setLaunchAdjacentDisabled: disabled=%b", disabled);
- final WindowContainerTransaction wct = new WindowContainerTransaction();
- wct.setDisableLaunchAdjacent(mRootTaskInfo.token, disabled);
- mTaskOrganizer.applyTransaction(wct);
- }
-
/** Starts the pending transition animation. */
public boolean startPendingAnimation(@NonNull IBinder transition,
@NonNull TransitionInfo info,
@@ -2692,14 +2711,6 @@
if (mSplitTransitions.isPendingEnter(transition)) {
shouldAnimate = startPendingEnterAnimation(transition,
mSplitTransitions.mPendingEnter, info, startTransaction, finishTransaction);
-
- // Disable launch adjacent after an enter animation to prevent cases where apps are
- // incorrectly trampolining and incorrectly triggering a double launch-adjacent task
- // launch (ie. main -> split -> main). See b/344216031
- setLaunchAdjacentDisabled(true);
- mMainHandler.removeCallbacks(mReEnableLaunchAdjacentOnRoot);
- mMainHandler.postDelayed(mReEnableLaunchAdjacentOnRoot,
- DISABLE_LAUNCH_ADJACENT_AFTER_ENTER_TIMEOUT_MS);
} else if (mSplitTransitions.isPendingDismiss(transition)) {
final SplitScreenTransitions.DismissSession dismiss = mSplitTransitions.mPendingDismiss;
shouldAnimate = startPendingDismissAnimation(
@@ -3208,13 +3219,9 @@
pw.println(childPrefix + "stagePosition=" + splitPositionToString(getMainStagePosition()));
pw.println(childPrefix + "isActive=" + isSplitActive());
mMainStage.dump(pw, childPrefix);
- pw.println(innerPrefix + "MainStageListener");
- mMainStageListener.dump(pw, childPrefix);
pw.println(innerPrefix + "SideStage");
pw.println(childPrefix + "stagePosition=" + splitPositionToString(getSideStagePosition()));
mSideStage.dump(pw, childPrefix);
- pw.println(innerPrefix + "SideStageListener");
- mSideStageListener.dump(pw, childPrefix);
if (mSplitLayout != null) {
mSplitLayout.dump(pw, childPrefix);
}
@@ -3230,8 +3237,8 @@
*/
private void setSplitsVisible(boolean visible) {
ProtoLog.d(WM_SHELL_SPLIT_SCREEN, "setSplitsVisible: visible=%b", visible);
- mMainStageListener.mVisible = mSideStageListener.mVisible = visible;
- mMainStageListener.mHasChildren = mSideStageListener.mHasChildren = visible;
+ mMainStage.mVisible = mSideStage.mVisible = visible;
+ mMainStage.mHasChildren = mSideStage.mHasChildren = visible;
}
/**
@@ -3281,86 +3288,4 @@
!toMainStage ? mSideStage.getTopChildTaskUid() : 0 /* sideStageUid */,
mSplitLayout.isLeftRightSplit());
}
-
- class StageListenerImpl implements StageTaskListener.StageListenerCallbacks {
- boolean mHasRootTask = false;
- boolean mVisible = false;
- boolean mHasChildren = false;
-
- @Override
- public void onRootTaskAppeared() {
- mHasRootTask = true;
- StageCoordinator.this.onRootTaskAppeared();
- }
-
- @Override
- public void onChildTaskAppeared(int taskId) {
- StageCoordinator.this.onChildTaskAppeared(this, taskId);
- }
-
- @Override
- public void onStatusChanged(boolean visible, boolean hasChildren) {
- if (!mHasRootTask) return;
-
- if (mHasChildren != hasChildren) {
- mHasChildren = hasChildren;
- StageCoordinator.this.onStageHasChildrenChanged(this);
- }
- if (mVisible != visible) {
- mVisible = visible;
- StageCoordinator.this.onStageVisibilityChanged(this);
- }
- }
-
- @Override
- public void onChildTaskStatusChanged(int taskId, boolean present, boolean visible) {
- StageCoordinator.this.onStageChildTaskStatusChanged(this, taskId, present, visible);
- }
-
- @Override
- public void onRootTaskVanished() {
- reset();
- StageCoordinator.this.onRootTaskVanished();
- }
-
- @Override
- public void onNoLongerSupportMultiWindow(ActivityManager.RunningTaskInfo taskInfo) {
- ProtoLog.d(WM_SHELL_SPLIT_SCREEN, "onNoLongerSupportMultiWindow: task=%s", taskInfo);
- if (isSplitActive()) {
- final boolean isMainStage = mMainStageListener == this;
-
- // If visible, we preserve the app and keep it running. If an app becomes
- // unsupported in the bg, break split without putting anything on top
- boolean splitScreenVisible = isSplitScreenVisible();
- int stageType = STAGE_TYPE_UNDEFINED;
- if (splitScreenVisible) {
- stageType = isMainStage ? STAGE_TYPE_MAIN : STAGE_TYPE_SIDE;
- }
- final WindowContainerTransaction wct = new WindowContainerTransaction();
- prepareExitSplitScreen(stageType, wct);
- clearSplitPairedInRecents(EXIT_REASON_APP_DOES_NOT_SUPPORT_MULTIWINDOW);
- mSplitTransitions.startDismissTransition(wct, StageCoordinator.this, stageType,
- EXIT_REASON_APP_DOES_NOT_SUPPORT_MULTIWINDOW);
- Log.w(TAG, splitFailureMessage("onNoLongerSupportMultiWindow",
- "app package " + taskInfo.baseIntent.getComponent()
- + " does not support splitscreen, or is a controlled activity"
- + " type"));
- if (splitScreenVisible) {
- handleUnsupportedSplitStart();
- }
- }
- }
-
- private void reset() {
- mHasRootTask = false;
- mVisible = false;
- mHasChildren = false;
- }
-
- public void dump(@NonNull PrintWriter pw, String prefix) {
- pw.println(prefix + "mHasRootTask=" + mHasRootTask);
- pw.println(prefix + "mVisible=" + mVisible);
- pw.println(prefix + "mHasChildren=" + mHasChildren);
- }
- }
}
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 d64c0a2..ae4bd16 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
@@ -22,20 +22,17 @@
import static android.content.res.Configuration.SMALLEST_SCREEN_WIDTH_DP_UNDEFINED;
import static android.view.RemoteAnimationTarget.MODE_OPENING;
+import static com.android.wm.shell.protolog.ShellProtoLogGroup.WM_SHELL_SPLIT_SCREEN;
import static com.android.wm.shell.shared.split.SplitScreenConstants.CONTROLLED_ACTIVITY_TYPES;
import static com.android.wm.shell.shared.split.SplitScreenConstants.CONTROLLED_WINDOWING_MODES;
import static com.android.wm.shell.shared.split.SplitScreenConstants.CONTROLLED_WINDOWING_MODES_WHEN_ACTIVE;
-import static com.android.wm.shell.protolog.ShellProtoLogGroup.WM_SHELL_SPLIT_SCREEN;
-import static com.android.wm.shell.transition.Transitions.ENABLE_SHELL_TRANSITIONS;
import android.annotation.CallSuper;
import android.annotation.Nullable;
import android.app.ActivityManager;
import android.content.Context;
-import android.graphics.Point;
import android.graphics.Rect;
import android.os.IBinder;
-import android.util.Slog;
import android.util.SparseArray;
import android.view.RemoteAnimationTarget;
import android.view.SurfaceControl;
@@ -74,20 +71,21 @@
// No current way to enforce this but if enableFlexibleSplit() is enabled, then only 1 of the
// stages should have this be set/being used
private boolean mIsActive;
-
/** Callback interface for listening to changes in a split-screen stage. */
public interface StageListenerCallbacks {
void onRootTaskAppeared();
- void onChildTaskAppeared(int taskId);
+ void onStageHasChildrenChanged(StageTaskListener stageTaskListener);
- void onStatusChanged(boolean visible, boolean hasChildren);
+ void onStageVisibilityChanged(StageTaskListener stageTaskListener);
- void onChildTaskStatusChanged(int taskId, boolean present, boolean visible);
+ void onChildTaskStatusChanged(StageTaskListener stage, int taskId, boolean present,
+ boolean visible);
void onRootTaskVanished();
- void onNoLongerSupportMultiWindow(ActivityManager.RunningTaskInfo taskInfo);
+ void onNoLongerSupportMultiWindow(StageTaskListener stageTaskListener,
+ ActivityManager.RunningTaskInfo taskInfo);
}
private final Context mContext;
@@ -96,6 +94,12 @@
private final IconProvider mIconProvider;
private final Optional<WindowDecorViewModel> mWindowDecorViewModel;
+ /** Whether or not the root task has been created. */
+ boolean mHasRootTask = false;
+ /** Whether or not the root task is visible. */
+ boolean mVisible = false;
+ /** Whether or not the root task has any children or not. */
+ boolean mHasChildren = false;
protected ActivityManager.RunningTaskInfo mRootTaskInfo;
protected SurfaceControl mRootLeash;
protected SurfaceControl mDimLayer;
@@ -201,6 +205,7 @@
mSplitDecorManager = new SplitDecorManager(
mRootTaskInfo.configuration,
mIconProvider);
+ mHasRootTask = true;
mCallbacks.onRootTaskAppeared();
sendStatusChanged();
mSyncQueue.runInSync(t -> mDimLayer =
@@ -209,15 +214,8 @@
final int taskId = taskInfo.taskId;
mChildrenLeashes.put(taskId, leash);
mChildrenTaskInfo.put(taskId, taskInfo);
- mCallbacks.onChildTaskStatusChanged(taskId, true /* present */,
+ mCallbacks.onChildTaskStatusChanged(this, taskId, true /* present */,
taskInfo.isVisible && taskInfo.isVisibleRequested);
- if (ENABLE_SHELL_TRANSITIONS) {
- // Status is managed/synchronized by the transition lifecycle.
- return;
- }
- updateChildTaskSurface(taskInfo, leash, true /* firstAppeared */);
- mCallbacks.onChildTaskAppeared(taskId);
- sendStatusChanged();
} else {
throw new IllegalArgumentException(this + "\n Unknown task: " + taskInfo
+ "\n mRootTaskInfo: " + mRootTaskInfo);
@@ -231,14 +229,6 @@
taskInfo.taskId, taskInfo.baseActivity);
mWindowDecorViewModel.ifPresent(viewModel -> viewModel.onTaskInfoChanged(taskInfo));
if (mRootTaskInfo.taskId == taskInfo.taskId) {
- // Inflates split decor view only when the root task is visible.
- if (!ENABLE_SHELL_TRANSITIONS && mRootTaskInfo.isVisible != taskInfo.isVisible) {
- if (taskInfo.isVisible) {
- mSplitDecorManager.inflate(mContext, mRootLeash);
- } else {
- mSyncQueue.runInSync(t -> mSplitDecorManager.release(t));
- }
- }
mRootTaskInfo = taskInfo;
} else if (taskInfo.parentTaskId == mRootTaskInfo.taskId) {
if (!taskInfo.supportsMultiWindow
@@ -250,25 +240,16 @@
taskInfo.taskId);
// Leave split screen if the task no longer supports multi window or have
// uncontrolled task.
- mCallbacks.onNoLongerSupportMultiWindow(taskInfo);
+ mCallbacks.onNoLongerSupportMultiWindow(this, taskInfo);
return;
}
mChildrenTaskInfo.put(taskInfo.taskId, taskInfo);
- mCallbacks.onChildTaskStatusChanged(taskInfo.taskId, true /* present */,
+ mCallbacks.onChildTaskStatusChanged(this, taskInfo.taskId, true /* present */,
taskInfo.isVisible && taskInfo.isVisibleRequested);
- if (!ENABLE_SHELL_TRANSITIONS) {
- updateChildTaskSurface(
- taskInfo, mChildrenLeashes.get(taskInfo.taskId), false /* firstAppeared */);
- }
} else {
throw new IllegalArgumentException(this + "\n Unknown task: " + taskInfo
+ "\n mRootTaskInfo: " + mRootTaskInfo);
}
- if (ENABLE_SHELL_TRANSITIONS) {
- // Status is managed/synchronized by the transition lifecycle.
- return;
- }
- sendStatusChanged();
}
@Override
@@ -278,6 +259,9 @@
final int taskId = taskInfo.taskId;
mWindowDecorViewModel.ifPresent(vm -> vm.onTaskVanished(taskInfo));
if (mRootTaskInfo.taskId == taskId) {
+ mHasRootTask = false;
+ mVisible = false;
+ mHasChildren = false;
mCallbacks.onRootTaskVanished();
mRootTaskInfo = null;
mRootLeash = null;
@@ -288,12 +272,8 @@
} else if (mChildrenTaskInfo.contains(taskId)) {
mChildrenTaskInfo.remove(taskId);
mChildrenLeashes.remove(taskId);
- mCallbacks.onChildTaskStatusChanged(taskId, false /* present */, taskInfo.isVisible);
- if (ENABLE_SHELL_TRANSITIONS) {
- // Status is managed/synchronized by the transition lifecycle.
- return;
- }
- sendStatusChanged();
+ mCallbacks.onChildTaskStatusChanged(this, taskId, false /* present */,
+ taskInfo.isVisible);
} else {
throw new IllegalArgumentException(this + "\n Unknown task: " + taskInfo
+ "\n mRootTaskInfo: " + mRootTaskInfo);
@@ -455,26 +435,6 @@
}
}
- private void updateChildTaskSurface(ActivityManager.RunningTaskInfo taskInfo,
- SurfaceControl leash, boolean firstAppeared) {
- final Point taskPositionInParent = taskInfo.positionInParent;
- mSyncQueue.runInSync(t -> {
- // The task surface might be released before running in the sync queue for the case like
- // trampoline launch, so check if the surface is valid before processing it.
- if (!leash.isValid()) {
- Slog.w(TAG, "Skip updating invalid child task surface of task#" + taskInfo.taskId);
- return;
- }
- t.setCrop(leash, null);
- t.setPosition(leash, taskPositionInParent.x, taskPositionInParent.y);
- if (firstAppeared) {
- t.setAlpha(leash, 1f);
- t.setMatrix(leash, 1, 0, 0, 1);
- t.show(leash);
- }
- });
- }
-
// ---------
// Previously only used in MainStage
boolean isActive() {
@@ -538,7 +498,19 @@
}
private void sendStatusChanged() {
- mCallbacks.onStatusChanged(mRootTaskInfo.isVisible, mChildrenTaskInfo.size() > 0);
+ boolean hasChildren = mChildrenTaskInfo.size() > 0;
+ boolean visible = mRootTaskInfo.isVisible;
+ if (!mHasRootTask) return;
+
+ if (mHasChildren != hasChildren) {
+ mHasChildren = hasChildren;
+ mCallbacks.onStageHasChildrenChanged(this);
+ }
+
+ if (mVisible != visible) {
+ mVisible = visible;
+ mCallbacks.onStageVisibilityChanged(this);
+ }
}
@Override
@@ -554,5 +526,8 @@
+ " baseActivity=" + taskInfo.baseActivity);
}
}
+ pw.println(prefix + "mHasRootTask=" + mHasRootTask);
+ pw.println(prefix + "mVisible=" + mVisible);
+ pw.println(prefix + "mHasChildren=" + mHasChildren);
}
}
diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/transition/DefaultTransitionHandler.java b/libs/WindowManager/Shell/src/com/android/wm/shell/transition/DefaultTransitionHandler.java
index a2439a9..5437167 100644
--- a/libs/WindowManager/Shell/src/com/android/wm/shell/transition/DefaultTransitionHandler.java
+++ b/libs/WindowManager/Shell/src/com/android/wm/shell/transition/DefaultTransitionHandler.java
@@ -61,6 +61,7 @@
import static com.android.internal.policy.TransitionAnimation.WALLPAPER_TRANSITION_INTRA_OPEN;
import static com.android.internal.policy.TransitionAnimation.WALLPAPER_TRANSITION_NONE;
import static com.android.internal.policy.TransitionAnimation.WALLPAPER_TRANSITION_OPEN;
+import static com.android.wm.shell.transition.DefaultSurfaceAnimator.buildSurfaceAnimation;
import static com.android.wm.shell.transition.TransitionAnimationHelper.edgeExtendWindow;
import static com.android.wm.shell.transition.TransitionAnimationHelper.getTransitionBackgroundColorIfSet;
import static com.android.wm.shell.transition.TransitionAnimationHelper.getTransitionTypeFromInfo;
@@ -68,8 +69,6 @@
import static com.android.wm.shell.transition.TransitionAnimationHelper.loadAttributeAnimation;
import android.animation.Animator;
-import android.animation.AnimatorListenerAdapter;
-import android.animation.ValueAnimator;
import android.annotation.ColorInt;
import android.annotation.NonNull;
import android.annotation.Nullable;
@@ -81,7 +80,6 @@
import android.content.Intent;
import android.content.IntentFilter;
import android.graphics.Color;
-import android.graphics.Insets;
import android.graphics.Point;
import android.graphics.Rect;
import android.graphics.drawable.Drawable;
@@ -90,12 +88,10 @@
import android.os.IBinder;
import android.os.UserHandle;
import android.util.ArrayMap;
-import android.view.Choreographer;
import android.view.SurfaceControl;
import android.view.WindowManager;
import android.view.animation.AlphaAnimation;
import android.view.animation.Animation;
-import android.view.animation.Transformation;
import android.window.TransitionInfo;
import android.window.TransitionMetrics;
import android.window.TransitionRequestInfo;
@@ -362,7 +358,6 @@
isSeamlessDisplayChange = anim == ROTATION_ANIMATION_SEAMLESS;
if (!(isSeamlessDisplayChange || anim == ROTATION_ANIMATION_JUMPCUT)) {
final int flags = wallpaperTransit != WALLPAPER_TRANSITION_NONE
- && Flags.commonSurfaceAnimator()
? ScreenRotationAnimation.FLAG_HAS_WALLPAPER : 0;
startRotationAnimation(startTransaction, change, info, anim, flags,
animations, onAnimFinish);
@@ -823,72 +818,6 @@
return a;
}
- /** Builds an animator for the surface and adds it to the `animations` list. */
- static void buildSurfaceAnimation(@NonNull ArrayList<Animator> animations,
- @NonNull Animation anim, @NonNull SurfaceControl leash,
- @NonNull Runnable finishCallback, @NonNull TransactionPool pool,
- @NonNull ShellExecutor mainExecutor, @Nullable Point position, float cornerRadius,
- @Nullable Rect clipRect, boolean isActivity) {
- if (Flags.commonSurfaceAnimator()) {
- DefaultSurfaceAnimator.buildSurfaceAnimation(animations, anim, leash, finishCallback,
- pool, mainExecutor, position, cornerRadius, clipRect, isActivity);
- return;
- }
- final SurfaceControl.Transaction transaction = pool.acquire();
- final ValueAnimator va = ValueAnimator.ofFloat(0f, 1f);
- final Transformation transformation = new Transformation();
- final float[] matrix = new float[9];
- // Animation length is already expected to be scaled.
- va.overrideDurationScale(1.0f);
- va.setDuration(anim.computeDurationHint());
- final ValueAnimator.AnimatorUpdateListener updateListener = animation -> {
- final long currentPlayTime = Math.min(va.getDuration(), va.getCurrentPlayTime());
-
- applyTransformation(currentPlayTime, transaction, leash, anim, transformation, matrix,
- position, cornerRadius, clipRect, isActivity);
- };
- va.addUpdateListener(updateListener);
-
- final Runnable finisher = () -> {
- applyTransformation(va.getDuration(), transaction, leash, anim, transformation, matrix,
- position, cornerRadius, clipRect, isActivity);
-
- pool.release(transaction);
- mainExecutor.execute(() -> {
- animations.remove(va);
- finishCallback.run();
- });
- };
- va.addListener(new AnimatorListenerAdapter() {
- // It is possible for the end/cancel to be called more than once, which may cause
- // issues if the animating surface has already been released. Track the finished
- // state here to skip duplicate callbacks. See b/252872225.
- private boolean mFinished = false;
-
- @Override
- public void onAnimationEnd(Animator animation) {
- onFinish();
- }
-
- @Override
- public void onAnimationCancel(Animator animation) {
- onFinish();
- }
-
- private void onFinish() {
- if (mFinished) return;
- mFinished = true;
- finisher.run();
- // The update listener can continue to be called after the animation has ended if
- // end() is called manually again before the finisher removes the animation.
- // Remove it manually here to prevent animating a released surface.
- // See b/252872225.
- va.removeUpdateListener(updateListener);
- }
- });
- animations.add(va);
- }
-
private void attachThumbnail(@NonNull ArrayList<Animator> animations,
@NonNull Runnable finishCallback, TransitionInfo.Change change,
TransitionInfo.AnimationOptions options, float cornerRadius) {
@@ -1014,38 +943,4 @@
|| animType == ANIM_CLIP_REVEAL || animType == ANIM_OPEN_CROSS_PROFILE_APPS
|| animType == ANIM_FROM_STYLE;
}
-
- private static void applyTransformation(long time, SurfaceControl.Transaction t,
- SurfaceControl leash, Animation anim, Transformation tmpTransformation, float[] matrix,
- Point position, float cornerRadius, @Nullable Rect immutableClipRect,
- boolean isActivity) {
- tmpTransformation.clear();
- anim.getTransformation(time, tmpTransformation);
- if (com.android.graphics.libgui.flags.Flags.edgeExtensionShader()
- && anim.getExtensionEdges() != 0x0 && isActivity) {
- t.setEdgeExtensionEffect(leash, anim.getExtensionEdges());
- }
- if (position != null) {
- tmpTransformation.getMatrix().postTranslate(position.x, position.y);
- }
- t.setMatrix(leash, tmpTransformation.getMatrix(), matrix);
- t.setAlpha(leash, tmpTransformation.getAlpha());
-
- final Rect clipRect = immutableClipRect == null ? null : new Rect(immutableClipRect);
- Insets extensionInsets = Insets.min(tmpTransformation.getInsets(), Insets.NONE);
- if (!extensionInsets.equals(Insets.NONE) && clipRect != null && !clipRect.isEmpty()) {
- // Clip out any overflowing edge extension
- clipRect.inset(extensionInsets);
- t.setCrop(leash, clipRect);
- }
-
- if (anim.hasRoundedCorners() && cornerRadius > 0 && clipRect != null) {
- // We can only apply rounded corner if a crop is set
- t.setCrop(leash, clipRect);
- t.setCornerRadius(leash, cornerRadius);
- }
-
- t.setFrameTimelineVsync(Choreographer.getInstance().getVsyncId());
- t.apply();
- }
}
diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/transition/ScreenRotationAnimation.java b/libs/WindowManager/Shell/src/com/android/wm/shell/transition/ScreenRotationAnimation.java
index 1a04997..6f3aa11 100644
--- a/libs/WindowManager/Shell/src/com/android/wm/shell/transition/ScreenRotationAnimation.java
+++ b/libs/WindowManager/Shell/src/com/android/wm/shell/transition/ScreenRotationAnimation.java
@@ -21,7 +21,7 @@
import static android.view.WindowManager.LayoutParams.ROTATION_ANIMATION_JUMPCUT;
import static android.view.WindowManagerPolicyConstants.SCREEN_FREEZE_LAYER_BASE;
-import static com.android.wm.shell.transition.DefaultTransitionHandler.buildSurfaceAnimation;
+import static com.android.wm.shell.transition.DefaultSurfaceAnimator.buildSurfaceAnimation;
import static com.android.wm.shell.transition.Transitions.TAG;
import android.animation.Animator;
diff --git a/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/desktopmode/DragToDesktopTransitionHandlerTest.kt b/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/desktopmode/DragToDesktopTransitionHandlerTest.kt
index 230f7e6..0bd3e08 100644
--- a/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/desktopmode/DragToDesktopTransitionHandlerTest.kt
+++ b/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/desktopmode/DragToDesktopTransitionHandlerTest.kt
@@ -1,5 +1,6 @@
package com.android.wm.shell.desktopmode
+import android.animation.AnimatorTestRule
import android.app.ActivityManager.RunningTaskInfo
import android.app.WindowConfiguration.ACTIVITY_TYPE_HOME
import android.app.WindowConfiguration.ACTIVITY_TYPE_STANDARD
@@ -24,6 +25,7 @@
import com.android.wm.shell.RootTaskDisplayAreaOrganizer
import com.android.wm.shell.ShellTestCase
import com.android.wm.shell.TestRunningTaskInfoBuilder
+import com.android.wm.shell.desktopmode.DragToDesktopTransitionHandler.Companion.DRAG_TO_DESKTOP_FINISH_ANIM_DURATION_MS
import com.android.wm.shell.shared.split.SplitScreenConstants.SPLIT_POSITION_BOTTOM_OR_RIGHT
import com.android.wm.shell.shared.split.SplitScreenConstants.SPLIT_POSITION_TOP_OR_LEFT
import com.android.wm.shell.splitscreen.SplitScreenController
@@ -38,6 +40,7 @@
import junit.framework.Assert.assertTrue
import org.junit.After
import org.junit.Before
+import org.junit.Rule
import org.junit.Test
import org.junit.runner.RunWith
import org.mockito.ArgumentMatchers.any
@@ -58,6 +61,9 @@
@RunWithLooper
@RunWith(AndroidTestingRunner::class)
class DragToDesktopTransitionHandlerTest : ShellTestCase() {
+ @JvmField
+ @Rule
+ val mAnimatorTestRule = AnimatorTestRule(this)
@Mock private lateinit var transitions: Transitions
@Mock private lateinit var taskDisplayAreaOrganizer: RootTaskDisplayAreaOrganizer
@@ -267,16 +273,36 @@
}
@Test
- fun cancelDragToDesktop_startWasReady_cancel() {
- startDrag(defaultHandler)
+ fun cancelDragToDesktop_startWasReady_cancel_merged() {
+ val startToken = startDrag(defaultHandler)
// Then user cancelled after it had already started.
- defaultHandler.cancelDragToDesktopTransition(
- DragToDesktopTransitionHandler.CancelState.STANDARD_CANCEL
- )
+ val cancelToken = cancelDragToDesktopTransition(
+ defaultHandler, DragToDesktopTransitionHandler.CancelState.STANDARD_CANCEL)
+ defaultHandler.mergeAnimation(
+ cancelToken,
+ TransitionInfo(TRANSIT_DESKTOP_MODE_CANCEL_DRAG_TO_DESKTOP, 0),
+ mock<SurfaceControl.Transaction>(),
+ startToken,
+ mock<Transitions.TransitionFinishCallback>())
// Cancel animation should run since it had already started.
verify(dragAnimator).cancelAnimator()
+ assertFalse("Drag should not be in progress after cancelling", defaultHandler.inProgress)
+ }
+
+ @Test
+ fun cancelDragToDesktop_startWasReady_cancel_aborted() {
+ val startToken = startDrag(defaultHandler)
+
+ // Then user cancelled after it had already started.
+ val cancelToken = cancelDragToDesktopTransition(
+ defaultHandler, DragToDesktopTransitionHandler.CancelState.STANDARD_CANCEL)
+ defaultHandler.onTransitionConsumed(cancelToken, aborted = true, null)
+
+ // Cancel animation should run since it had already started.
+ verify(dragAnimator).cancelAnimator()
+ assertFalse("Drag should not be in progress after cancelling", defaultHandler.inProgress)
}
@Test
@@ -585,6 +611,23 @@
return token
}
+ private fun cancelDragToDesktopTransition(
+ handler: DragToDesktopTransitionHandler,
+ cancelState: DragToDesktopTransitionHandler.CancelState): IBinder {
+ val token = mock<IBinder>()
+ whenever(
+ transitions.startTransition(
+ eq(TRANSIT_DESKTOP_MODE_CANCEL_DRAG_TO_DESKTOP),
+ any(),
+ eq(handler)
+ )
+ )
+ .thenReturn(token)
+ handler.cancelDragToDesktopTransition(cancelState)
+ mAnimatorTestRule.advanceTimeBy(DRAG_TO_DESKTOP_FINISH_ANIM_DURATION_MS)
+ return token
+ }
+
private fun performEarlyCancel(
handler: DragToDesktopTransitionHandler,
cancelState: DragToDesktopTransitionHandler.CancelState
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 b7b7d0d..189684d 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
@@ -23,10 +23,9 @@
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
-import static org.junit.Assume.assumeFalse;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.ArgumentMatchers.isNull;
-import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.never;
import static org.mockito.Mockito.verify;
import android.app.ActivityManager;
@@ -64,8 +63,6 @@
@SmallTest
@RunWith(AndroidJUnit4.class)
public final class StageTaskListenerTests extends ShellTestCase {
- private static final boolean ENABLE_SHELL_TRANSITIONS =
- SystemProperties.getBoolean("persist.wm.debug.shell_transit", true);
@Mock
private ShellTaskOrganizer mTaskOrganizer;
@@ -117,20 +114,20 @@
public void testRootTaskAppeared() {
assertThat(mStageTaskListener.mRootTaskInfo.taskId).isEqualTo(mRootTask.taskId);
verify(mCallbacks).onRootTaskAppeared();
- verify(mCallbacks).onStatusChanged(eq(mRootTask.isVisible), eq(false));
+ verify(mCallbacks, never()).onStageHasChildrenChanged(mStageTaskListener);
+ verify(mCallbacks, never()).onStageVisibilityChanged(mStageTaskListener);
}
@Test
- public void testChildTaskAppeared() {
- // With shell transitions, the transition manages status changes, so skip this test.
- assumeFalse(ENABLE_SHELL_TRANSITIONS);
- final ActivityManager.RunningTaskInfo childTask =
- new TestRunningTaskInfoBuilder().setParentTaskId(mRootTask.taskId).build();
+ public void testRootTaskVisible() {
+ mStageTaskListener.onTaskVanished(mRootTask);
+ mRootTask = new TestRunningTaskInfoBuilder().setVisible(true).build();
+ mRootTask.parentTaskId = INVALID_TASK_ID;
+ mSurfaceControl = new SurfaceControl.Builder().setName("test").build();
+ mStageTaskListener.onTaskAppeared(mRootTask, mSurfaceControl);
- mStageTaskListener.onTaskAppeared(childTask, mSurfaceControl);
+ verify(mCallbacks).onStageVisibilityChanged(mStageTaskListener);
- assertThat(mStageTaskListener.mChildrenTaskInfo.contains(childTask.taskId)).isTrue();
- verify(mCallbacks).onStatusChanged(eq(mRootTask.isVisible), eq(true));
}
@Test(expected = IllegalArgumentException.class)
@@ -140,29 +137,13 @@
}
@Test
- public void testTaskVanished() {
- // With shell transitions, the transition manages status changes, so skip this test.
- assumeFalse(ENABLE_SHELL_TRANSITIONS);
- final ActivityManager.RunningTaskInfo childTask =
- new TestRunningTaskInfoBuilder().setParentTaskId(mRootTask.taskId).build();
- mStageTaskListener.mRootTaskInfo = mRootTask;
- mStageTaskListener.mChildrenTaskInfo.put(childTask.taskId, childTask);
-
- mStageTaskListener.onTaskVanished(childTask);
- verify(mCallbacks, times(2)).onStatusChanged(eq(mRootTask.isVisible), eq(false));
-
- mStageTaskListener.onTaskVanished(mRootTask);
- verify(mCallbacks).onRootTaskVanished();
- }
-
- @Test
public void testTaskInfoChanged_notSupportsMultiWindow() {
final ActivityManager.RunningTaskInfo childTask =
new TestRunningTaskInfoBuilder().setParentTaskId(mRootTask.taskId).build();
childTask.supportsMultiWindow = false;
mStageTaskListener.onTaskInfoChanged(childTask);
- verify(mCallbacks).onNoLongerSupportMultiWindow(childTask);
+ verify(mCallbacks).onNoLongerSupportMultiWindow(mStageTaskListener, childTask);
}
@Test
diff --git a/media/java/android/media/AudioPlaybackConfiguration.java b/media/java/android/media/AudioPlaybackConfiguration.java
index 4d6ddfd..3cd5f52 100644
--- a/media/java/android/media/AudioPlaybackConfiguration.java
+++ b/media/java/android/media/AudioPlaybackConfiguration.java
@@ -18,7 +18,9 @@
import static android.media.AudioAttributes.ALLOW_CAPTURE_BY_ALL;
import static android.media.AudioAttributes.ALLOW_CAPTURE_BY_NONE;
+import static android.media.audio.Flags.FLAG_MUTED_BY_PORT_VOLUME_API;
+import android.annotation.FlaggedApi;
import android.annotation.IntDef;
import android.annotation.IntRange;
import android.annotation.NonNull;
@@ -291,12 +293,24 @@
@SystemApi
@RequiresPermission(android.Manifest.permission.MODIFY_AUDIO_ROUTING)
public static final int MUTED_BY_VOLUME_SHAPER = (1 << 5);
+ /**
+ * @hide
+ * Flag used when muted by the track's port volume.
+ *
+ * <p>Note: this will replace the stream volume mute when using the AudioFlinger port volume
+ * APIs
+ */
+ @SystemApi
+ @FlaggedApi(FLAG_MUTED_BY_PORT_VOLUME_API)
+ @RequiresPermission(android.Manifest.permission.MODIFY_AUDIO_ROUTING)
+ public static final int MUTED_BY_PORT_VOLUME = (1 << 6);
/** @hide */
@IntDef(
flag = true,
value = {MUTED_BY_MASTER, MUTED_BY_STREAM_VOLUME, MUTED_BY_STREAM_MUTED,
- MUTED_BY_APP_OPS, MUTED_BY_CLIENT_VOLUME, MUTED_BY_VOLUME_SHAPER})
+ MUTED_BY_APP_OPS, MUTED_BY_CLIENT_VOLUME, MUTED_BY_VOLUME_SHAPER,
+ MUTED_BY_PORT_VOLUME})
@Retention(RetentionPolicy.SOURCE)
public @interface PlayerMuteEvent {
}
@@ -858,6 +872,9 @@
if ((mMutedState & MUTED_BY_VOLUME_SHAPER) != 0) {
apcToString.append("volumeShaper ");
}
+ if ((mMutedState & MUTED_BY_PORT_VOLUME) != 0) {
+ apcToString.append("portVolume ");
+ }
}
apcToString.append(" ").append(mFormatInfo);
}
diff --git a/media/java/android/media/AudioSystem.java b/media/java/android/media/AudioSystem.java
index a8b863b..bf09cb0 100644
--- a/media/java/android/media/AudioSystem.java
+++ b/media/java/android/media/AudioSystem.java
@@ -1698,12 +1698,12 @@
}
/** @hide Wrapper for native methods called from AudioService */
- public static int setStreamVolumeIndexAS(int stream, int index, int device) {
+ public static int setStreamVolumeIndexAS(int stream, int index, boolean muted, int device) {
if (DEBUG_VOLUME) {
Log.i(TAG, "setStreamVolumeIndex: " + STREAM_NAMES[stream]
- + " dev=" + Integer.toHexString(device) + " idx=" + index);
+ + " dev=" + Integer.toHexString(device) + " idx=" + index + " muted=" + muted);
}
- return setStreamVolumeIndex(stream, index, device);
+ return setStreamVolumeIndex(stream, index, muted, device);
}
// usage for AudioRecord.startRecordingSync(), must match AudioSystem::sync_event_t
@@ -1774,7 +1774,8 @@
@UnsupportedAppUsage
public static native int initStreamVolume(int stream, int indexMin, int indexMax);
@UnsupportedAppUsage
- private static native int setStreamVolumeIndex(int stream, int index, int device);
+ private static native int setStreamVolumeIndex(int stream, int index, boolean muted,
+ int device);
/** @hide */
public static native int getStreamVolumeIndex(int stream, int device);
/**
@@ -1787,7 +1788,7 @@
* @return command completion status.
*/
public static native int setVolumeIndexForAttributes(@NonNull AudioAttributes attributes,
- int index, int device);
+ int index, boolean muted, int device);
/**
* @hide
* get the volume index for the given {@link AudioAttributes}.
diff --git a/packages/SettingsLib/Graph/src/com/android/settingslib/graph/PreferenceGraphBuilder.kt b/packages/SettingsLib/Graph/src/com/android/settingslib/graph/PreferenceGraphBuilder.kt
index 8c5d877..8fb16d8 100644
--- a/packages/SettingsLib/Graph/src/com/android/settingslib/graph/PreferenceGraphBuilder.kt
+++ b/packages/SettingsLib/Graph/src/com/android/settingslib/graph/PreferenceGraphBuilder.kt
@@ -78,6 +78,10 @@
for (activityClass in request.activityClasses) {
add(activityClass)
}
+ // Temporarily add all screens
+ for (key in PreferenceScreenRegistry.preferenceScreens.keys) {
+ addPreferenceScreenFromRegistry(key, Activity::class.java)
+ }
}
fun build() = builder.build()
diff --git a/packages/SettingsLib/Metadata/src/com/android/settingslib/metadata/PreferenceScreenRegistry.kt b/packages/SettingsLib/Metadata/src/com/android/settingslib/metadata/PreferenceScreenRegistry.kt
index 48798da..6646d6c3 100644
--- a/packages/SettingsLib/Metadata/src/com/android/settingslib/metadata/PreferenceScreenRegistry.kt
+++ b/packages/SettingsLib/Metadata/src/com/android/settingslib/metadata/PreferenceScreenRegistry.kt
@@ -34,7 +34,7 @@
ImmutableMap.of()
}
- private val preferenceScreens: PreferenceScreenMap
+ val preferenceScreens: PreferenceScreenMap
get() = preferenceScreensSupplier.get()
private var readWritePermitProvider: ReadWritePermitProvider? = null
diff --git a/packages/SettingsLib/Spa/build.gradle.kts b/packages/SettingsLib/Spa/build.gradle.kts
index b69912a..73d0bec 100644
--- a/packages/SettingsLib/Spa/build.gradle.kts
+++ b/packages/SettingsLib/Spa/build.gradle.kts
@@ -29,7 +29,7 @@
allprojects {
extra["androidTop"] = androidTop
- extra["jetpackComposeVersion"] = "1.7.0"
+ extra["jetpackComposeVersion"] = "1.7.3"
}
subprojects {
diff --git a/packages/SettingsLib/Spa/spa/build.gradle.kts b/packages/SettingsLib/Spa/spa/build.gradle.kts
index 8f8275b..914f06c 100644
--- a/packages/SettingsLib/Spa/spa/build.gradle.kts
+++ b/packages/SettingsLib/Spa/spa/build.gradle.kts
@@ -54,7 +54,7 @@
dependencies {
api(project(":SettingsLibColor"))
api("androidx.appcompat:appcompat:1.7.0")
- api("androidx.compose.material3:material3:1.3.0")
+ api("androidx.compose.material3:material3:1.4.0-alpha01")
api("androidx.compose.material:material-icons-extended:$jetpackComposeVersion")
api("androidx.compose.runtime:runtime-livedata:$jetpackComposeVersion")
api("androidx.compose.ui:ui-tooling-preview:$jetpackComposeVersion")
diff --git a/packages/SettingsLib/Spa/spa/src/com/android/settingslib/spa/widget/scaffold/CustomizedAppBar.kt b/packages/SettingsLib/Spa/spa/src/com/android/settingslib/spa/widget/scaffold/CustomizedAppBar.kt
index 2c55779..693fb35 100644
--- a/packages/SettingsLib/Spa/spa/src/com/android/settingslib/spa/widget/scaffold/CustomizedAppBar.kt
+++ b/packages/SettingsLib/Spa/spa/src/com/android/settingslib/spa/widget/scaffold/CustomizedAppBar.kt
@@ -46,6 +46,7 @@
import androidx.compose.material3.TopAppBarState
import androidx.compose.runtime.Composable
import androidx.compose.runtime.CompositionLocalProvider
+import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.NonRestartableComposable
import androidx.compose.runtime.Stable
import androidx.compose.runtime.derivedStateOf
@@ -326,6 +327,9 @@
// Sets the app bar's height offset limit to hide just the bottom title area and keep top title
// visible when collapsed.
scrollBehavior?.state?.heightOffsetLimit = pinnedHeightPx - maxHeightPx.floatValue
+ if (isSpaExpressiveEnabled) {
+ LaunchedEffect(scrollBehavior?.state?.heightOffsetLimit) { scrollBehavior?.collapse() }
+ }
// Obtain the container Color from the TopAppBarColors using the `collapsedFraction`, as the
// bottom part of this TwoRowsTopAppBar changes color at the same rate the app bar expands or
diff --git a/packages/SettingsLib/Spa/spa/src/com/android/settingslib/spa/widget/scaffold/SettingsScaffold.kt b/packages/SettingsLib/Spa/spa/src/com/android/settingslib/spa/widget/scaffold/SettingsScaffold.kt
index 7d8ee79..60b1e639 100644
--- a/packages/SettingsLib/Spa/spa/src/com/android/settingslib/spa/widget/scaffold/SettingsScaffold.kt
+++ b/packages/SettingsLib/Spa/spa/src/com/android/settingslib/spa/widget/scaffold/SettingsScaffold.kt
@@ -39,7 +39,6 @@
import com.android.settingslib.spa.framework.compose.horizontalValues
import com.android.settingslib.spa.framework.compose.verticalValues
import com.android.settingslib.spa.framework.theme.SettingsTheme
-import com.android.settingslib.spa.framework.theme.isSpaExpressiveEnabled
import com.android.settingslib.spa.framework.theme.settingsBackground
import com.android.settingslib.spa.widget.preference.Preference
import com.android.settingslib.spa.widget.preference.PreferenceModel
@@ -56,9 +55,6 @@
) {
ActivityTitle(title)
val scrollBehavior = TopAppBarDefaults.exitUntilCollapsedScrollBehavior()
- if (isSpaExpressiveEnabled) {
- LaunchedEffect(scrollBehavior.state.heightOffsetLimit) { scrollBehavior.collapse() }
- }
Scaffold(
modifier = Modifier.nestedScroll(scrollBehavior.nestedScrollConnection),
diff --git a/packages/SettingsProvider/Android.bp b/packages/SettingsProvider/Android.bp
index 1a99d25..65b2275 100644
--- a/packages/SettingsProvider/Android.bp
+++ b/packages/SettingsProvider/Android.bp
@@ -39,6 +39,7 @@
"configinfra_framework_flags_java_lib",
"device_config_service_flags_java",
"libaconfig_java_proto_lite",
+ "notification_flags_lib",
"SettingsLibDeviceStateRotationLock",
"SettingsLibDisplayUtils",
],
diff --git a/packages/SettingsProvider/src/com/android/providers/settings/SettingsHelper.java b/packages/SettingsProvider/src/com/android/providers/settings/SettingsHelper.java
index 6c31831..ebeee85 100644
--- a/packages/SettingsProvider/src/com/android/providers/settings/SettingsHelper.java
+++ b/packages/SettingsProvider/src/com/android/providers/settings/SettingsHelper.java
@@ -29,6 +29,7 @@
import android.icu.util.ULocale;
import android.media.AudioManager;
import android.media.RingtoneManager;
+import android.media.Utils;
import android.net.Uri;
import android.os.LocaleList;
import android.os.RemoteException;
@@ -309,6 +310,13 @@
return SILENT_RINGTONE;
}
} else {
+ // If the ringtone/notification support the vibration, use the original value.
+ final int ringtoneType = getRingtoneType(name);
+ if ((ringtoneType == RingtoneManager.TYPE_RINGTONE
+ || ringtoneType == RingtoneManager.TYPE_NOTIFICATION)
+ && hasVibrationSettings(value, ringtoneType)) {
+ return value;
+ }
return getCanonicalRingtoneValue(value);
}
}
@@ -362,6 +370,15 @@
return;
}
+ // If the ringtone/notification has vibration, we backup original value in onBackupValue.
+ // So use the value directly for restoring.
+ if ((ringtoneType == RingtoneManager.TYPE_RINGTONE
+ || ringtoneType == RingtoneManager.TYPE_NOTIFICATION)
+ && hasVibrationSettings(value, ringtoneType)) {
+ RingtoneManager.setActualDefaultRingtoneUri(mContext, ringtoneType, Uri.parse(value));
+ return;
+ }
+
Uri ringtoneUri = null;
try {
ringtoneUri =
@@ -617,6 +634,19 @@
return allLocales.remove(toFullLocale(filteredLocale));
}
+ private boolean hasVibrationSettings(String value, int type) {
+ if (Utils.hasVibration(Uri.parse(value)) && mContext.getResources().getBoolean(
+ com.android.internal.R.bool.config_ringtoneVibrationSettingsSupported)) {
+ if (type == RingtoneManager.TYPE_RINGTONE) {
+ return android.media.audio.Flags.enableRingtoneHapticsCustomization();
+ }
+ if (type == RingtoneManager.TYPE_NOTIFICATION) {
+ return com.android.server.notification.Flags.notificationVibrationInSoundUri();
+ }
+ }
+ return false;
+ }
+
/**
* Sets the locale specified. Input data is the byte representation of comma separated
* multiple BCP-47 language tags. For backwards compatibility, strings of the form
diff --git a/packages/SettingsProvider/test/src/com/android/providers/settings/SettingsHelperTest.java b/packages/SettingsProvider/test/src/com/android/providers/settings/SettingsHelperTest.java
index 4b10b56..cea2bbc 100644
--- a/packages/SettingsProvider/test/src/com/android/providers/settings/SettingsHelperTest.java
+++ b/packages/SettingsProvider/test/src/com/android/providers/settings/SettingsHelperTest.java
@@ -37,9 +37,12 @@
import android.database.Cursor;
import android.database.MatrixCursor;
import android.media.AudioManager;
+import android.media.Utils;
import android.net.Uri;
import android.os.Bundle;
import android.os.LocaleList;
+import android.platform.test.annotations.EnableFlags;
+import android.platform.test.flag.junit.SetFlagsRule;
import android.provider.BaseColumns;
import android.provider.MediaStore;
import android.provider.Settings;
@@ -54,8 +57,11 @@
import org.junit.After;
import org.junit.Before;
+import org.junit.FixMethodOrder;
+import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
+import org.junit.runners.MethodSorters;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
@@ -63,6 +69,7 @@
* Tests for the SettingsHelperTest
*/
@RunWith(AndroidJUnit4.class)
+@FixMethodOrder(MethodSorters.NAME_ASCENDING)
public class SettingsHelperTest {
private static final String SETTING_KEY = "setting_key";
private static final String SETTING_VALUE = "setting_value";
@@ -74,9 +81,13 @@
"content://media/internal/audio/media/20?title=DefaultNotification&canonical=1";
private static final String DEFAULT_ALARM_VALUE =
"content://media/internal/audio/media/30?title=DefaultAlarm&canonical=1";
+ private static final String VIBRATION_FILE_NAME = "haptics.xml";
private SettingsHelper mSettingsHelper;
+ @Rule
+ public final SetFlagsRule mSetFlagsRule = new SetFlagsRule();
+
@Mock private Context mContext;
@Mock private Resources mResources;
@Mock private AudioManager mAudioManager;
@@ -120,6 +131,22 @@
}
@Test
+ @EnableFlags({android.media.audio.Flags.FLAG_ENABLE_RINGTONE_HAPTICS_CUSTOMIZATION,
+ com.android.server.notification.Flags.FLAG_NOTIFICATION_VIBRATION_IN_SOUND_URI})
+ public void testOnBackupValue_ringtoneVibrationSupport_returnsSameValue() {
+ when(mResources.getBoolean(
+ com.android.internal.R.bool.config_ringtoneVibrationSettingsSupported)).thenReturn(
+ true);
+ String testRingtoneVibrationValue = createUriWithVibration(DEFAULT_RINGTONE_VALUE);
+ String testNotificationVibrationValue = createUriWithVibration(DEFAULT_NOTIFICATION_VALUE);
+
+ assertEquals(testRingtoneVibrationValue, mSettingsHelper.onBackupValue(
+ Settings.System.RINGTONE, testRingtoneVibrationValue));
+ assertEquals(testNotificationVibrationValue, mSettingsHelper.onBackupValue(
+ Settings.System.NOTIFICATION_SOUND, testNotificationVibrationValue));
+ }
+
+ @Test
public void testGetRealValue_settingNotReplaced_returnsSameValue() {
when(mSettingsHelper.isReplacedSystemSetting(eq(SETTING_KEY))).thenReturn(false);
@@ -675,6 +702,30 @@
.isEqualTo(null);
}
+ @Test
+ @EnableFlags({android.media.audio.Flags.FLAG_ENABLE_RINGTONE_HAPTICS_CUSTOMIZATION,
+ com.android.server.notification.Flags.FLAG_NOTIFICATION_VIBRATION_IN_SOUND_URI})
+ public void testRestoreValue_ringtoneVibrationSupport_restoreValue() {
+ when(mResources.getBoolean(
+ com.android.internal.R.bool.config_ringtoneVibrationSettingsSupported)).thenReturn(
+ true);
+ String testRingtoneVibrationValue = createUriWithVibration(DEFAULT_RINGTONE_VALUE);
+ String testNotificationVibrationValue = createUriWithVibration(DEFAULT_NOTIFICATION_VALUE);
+ ContentProvider mockMediaContentProvider =
+ new MockContentProvider(mContext) {
+ @Override
+ public String getType(Uri url) {
+ return "audio/ogg";
+ }
+ };
+ mContentResolver.addProvider(MediaStore.AUTHORITY, mockMediaContentProvider);
+ resetRingtoneSettingsToDefault();
+
+ assertRingtoneSettingsRestoring(Settings.System.RINGTONE, testRingtoneVibrationValue);
+ assertRingtoneSettingsRestoring(
+ Settings.System.NOTIFICATION_SOUND, testNotificationVibrationValue);
+ }
+
private static class MockSettingsProvider extends MockContentProvider {
private final ArrayMap<String, String> mKeyValueStore = new ArrayMap<>();
MockSettingsProvider(Context context) {
@@ -766,4 +817,25 @@
assertThat(Settings.System.getString(mContentResolver, Settings.System.ALARM_ALERT))
.isEqualTo(DEFAULT_ALARM_VALUE);
}
+
+ private String createUriWithVibration(String defaultUriString) {
+ return Uri.parse(defaultUriString).buildUpon()
+ .appendQueryParameter(
+ Utils.VIBRATION_URI_PARAM, VIBRATION_FILE_NAME).build().toString();
+ }
+
+ private void assertRingtoneSettingsRestoring(
+ String settings, String testRingtoneSettingsValue) {
+ mSettingsHelper.restoreValue(
+ mContext,
+ mContentResolver,
+ new ContentValues(),
+ Uri.EMPTY,
+ settings,
+ testRingtoneSettingsValue,
+ 0);
+
+ assertThat(Settings.System.getString(mContentResolver, settings))
+ .isEqualTo(testRingtoneSettingsValue);
+ }
}
diff --git a/packages/SystemUI/animation/src/com/android/systemui/animation/ActivityTransitionAnimator.kt b/packages/SystemUI/animation/src/com/android/systemui/animation/ActivityTransitionAnimator.kt
index 93a99bd..18f40c9 100644
--- a/packages/SystemUI/animation/src/com/android/systemui/animation/ActivityTransitionAnimator.kt
+++ b/packages/SystemUI/animation/src/com/android/systemui/animation/ActivityTransitionAnimator.kt
@@ -136,20 +136,16 @@
)
/**
- * The timings when animating a View into an app using a spring animator.
- *
- * Important: since springs don't have fixed durations, these timings represent fractions of
- * the progress between the spring's initial value and its final value.
- *
- * TODO(b/372858592): make this a separate class explicitly using percentages.
+ * The timings when animating a View into an app using a spring animator. These timings
+ * represent fractions of the progress between the spring's initial value and its final
+ * value.
*/
val SPRING_TIMINGS =
- TransitionAnimator.Timings(
- totalDuration = 1000L,
- contentBeforeFadeOutDelay = 0L,
- contentBeforeFadeOutDuration = 800L,
- contentAfterFadeInDelay = 850L,
- contentAfterFadeInDuration = 135L,
+ TransitionAnimator.SpringTimings(
+ contentBeforeFadeOutDelay = 0f,
+ contentBeforeFadeOutDuration = 0.8f,
+ contentAfterFadeInDelay = 0.85f,
+ contentAfterFadeInDuration = 0.135f,
)
/**
diff --git a/packages/SystemUI/animation/src/com/android/systemui/animation/TransitionAnimator.kt b/packages/SystemUI/animation/src/com/android/systemui/animation/TransitionAnimator.kt
index 1d8ff77..9dc9348 100644
--- a/packages/SystemUI/animation/src/com/android/systemui/animation/TransitionAnimator.kt
+++ b/packages/SystemUI/animation/src/com/android/systemui/animation/TransitionAnimator.kt
@@ -52,7 +52,7 @@
private val interpolators: Interpolators,
/** [springTimings] and [springInterpolators] must either both be null or both not null. */
- private val springTimings: Timings? = null,
+ private val springTimings: SpringTimings? = null,
private val springInterpolators: Interpolators? = null,
private val springParams: SpringParams = DEFAULT_SPRING_PARAMS,
) {
@@ -83,8 +83,22 @@
delay: Long,
duration: Long,
): Float {
+ return getProgressInternal(
+ timings.totalDuration.toFloat(),
+ linearProgress,
+ delay.toFloat(),
+ duration.toFloat(),
+ )
+ }
+
+ private fun getProgressInternal(
+ totalDuration: Float,
+ linearProgress: Float,
+ delay: Float,
+ duration: Float,
+ ): Float {
return MathUtils.constrain(
- (linearProgress * timings.totalDuration - delay) / duration,
+ (linearProgress * totalDuration - delay) / duration,
0.0f,
1.0f,
)
@@ -367,6 +381,25 @@
val contentAfterFadeInDuration: Long,
)
+ /**
+ * The timings (durations and delays) used by the multi-spring animator. These are expressed as
+ * fractions of 1, similar to how the progress of an animator can be expressed as a float value
+ * between 0 and 1.
+ */
+ class SpringTimings(
+ /** The portion of animation to wait before fading out the expanding content. */
+ val contentBeforeFadeOutDelay: Float,
+
+ /** The portion of animation during which the expanding content fades out. */
+ val contentBeforeFadeOutDuration: Float,
+
+ /** The portion of animation to wait before fading in the expanded content. */
+ val contentAfterFadeInDelay: Float,
+
+ /** The portion of animation during which the expanded content fades in. */
+ val contentAfterFadeInDuration: Float,
+ )
+
/** The interpolators used by this animator. */
data class Interpolators(
/** The interpolator used for the Y position, width, height and corner radius. */
@@ -576,18 +609,14 @@
}
override fun onAnimationEnd(animation: Animator) {
- if (DEBUG) {
- Log.d(TAG, "Animation ended")
- }
-
- // TODO(b/330672236): Post this to the main thread instead so that it does not
- // flicker with Flexiglass enabled.
- controller.onTransitionAnimationEnd(isExpandingFullyAbove)
- transitionContainerOverlay.remove(windowBackgroundLayer)
-
- if (moveBackgroundLayerWhenAppVisibilityChanges && controller.isLaunching) {
- openingWindowSyncViewOverlay?.remove(windowBackgroundLayer)
- }
+ onAnimationEnd(
+ controller,
+ isExpandingFullyAbove,
+ windowBackgroundLayer,
+ transitionContainerOverlay,
+ openingWindowSyncViewOverlay,
+ moveBackgroundLayerWhenAppVisibilityChanges,
+ )
}
}
)
@@ -1021,34 +1050,47 @@
cornerRadii[7] = state.bottomCornerRadius
drawable.cornerRadii = cornerRadii
- val timings: Timings
val interpolators: Interpolators
+ val fadeInProgress: Float
+ val fadeOutProgress: Float
if (useSpring) {
- timings = springTimings!!
interpolators = springInterpolators!!
+ val timings = springTimings!!
+ fadeInProgress =
+ getProgressInternal(
+ totalDuration = 1f,
+ linearProgress,
+ timings.contentBeforeFadeOutDelay,
+ timings.contentBeforeFadeOutDuration,
+ )
+ fadeOutProgress =
+ getProgressInternal(
+ totalDuration = 1f,
+ linearProgress,
+ timings.contentAfterFadeInDelay,
+ timings.contentAfterFadeInDuration,
+ )
} else {
- timings = this.timings
interpolators = this.interpolators
+ fadeInProgress =
+ getProgress(
+ timings,
+ linearProgress,
+ timings.contentBeforeFadeOutDelay,
+ timings.contentBeforeFadeOutDuration,
+ )
+ fadeOutProgress =
+ getProgress(
+ timings,
+ linearProgress,
+ timings.contentAfterFadeInDelay,
+ timings.contentAfterFadeInDuration,
+ )
}
// We first fade in the background layer to hide the expanding view, then fade it out with
// SRC mode to draw a hole punch in the status bar and reveal the opening window (if
// needed). If !isLaunching, the reverse happens.
- val fadeInProgress =
- getProgress(
- timings,
- linearProgress,
- timings.contentBeforeFadeOutDelay,
- timings.contentBeforeFadeOutDuration,
- )
- val fadeOutProgress =
- getProgress(
- timings,
- linearProgress,
- timings.contentAfterFadeInDelay,
- timings.contentAfterFadeInDuration,
- )
-
if (isLaunching) {
if (fadeInProgress < 1) {
val alpha =
diff --git a/packages/SystemUI/compose/features/src/com/android/systemui/notifications/ui/composable/NotificationScrimNestedScrollConnection.kt b/packages/SystemUI/compose/features/src/com/android/systemui/notifications/ui/composable/NotificationScrimNestedScrollConnection.kt
index 8b9e927..e4c60e1 100644
--- a/packages/SystemUI/compose/features/src/com/android/systemui/notifications/ui/composable/NotificationScrimNestedScrollConnection.kt
+++ b/packages/SystemUI/compose/features/src/com/android/systemui/notifications/ui/composable/NotificationScrimNestedScrollConnection.kt
@@ -18,6 +18,8 @@
import androidx.compose.foundation.gestures.Orientation
import androidx.compose.ui.input.nestedscroll.NestedScrollConnection
+import androidx.compose.ui.util.fastCoerceAtLeast
+import androidx.compose.ui.util.fastCoerceAtMost
import com.android.compose.nestedscroll.PriorityNestedScrollConnection
/**
@@ -44,7 +46,7 @@
orientation = Orientation.Vertical,
// scrolling up and inner content is taller than the scrim, so scrim needs to
// expand; content can scroll once scrim is at the minScrimOffset.
- canStartPreScroll = { offsetAvailable, offsetBeforeStart ->
+ canStartPreScroll = { offsetAvailable, offsetBeforeStart, _ ->
offsetAvailable < 0 &&
offsetBeforeStart == 0f &&
contentHeight() > minVisibleScrimHeight() &&
@@ -52,36 +54,38 @@
},
// scrolling down and content is done scrolling to top. After that, the scrim
// needs to collapse; collapse the scrim until it is at the maxScrimOffset.
- canStartPostScroll = { offsetAvailable, _ ->
+ canStartPostScroll = { offsetAvailable, _, _ ->
offsetAvailable > 0 && (scrimOffset() < maxScrimOffset || isCurrentGestureOverscroll())
},
canStartPostFling = { false },
- canContinueScroll = {
- val currentHeight = scrimOffset()
- minScrimOffset() < currentHeight && currentHeight < maxScrimOffset
- },
- canScrollOnFling = true,
+ canStopOnPreFling = { false },
onStart = { offsetAvailable -> onStart(offsetAvailable) },
- onScroll = { offsetAvailable ->
+ onScroll = { offsetAvailable, _ ->
val currentHeight = scrimOffset()
val amountConsumed =
if (offsetAvailable > 0) {
val amountLeft = maxScrimOffset - currentHeight
- offsetAvailable.coerceAtMost(amountLeft)
+ offsetAvailable.fastCoerceAtMost(amountLeft)
} else {
val amountLeft = minScrimOffset() - currentHeight
- offsetAvailable.coerceAtLeast(amountLeft)
+ offsetAvailable.fastCoerceAtLeast(amountLeft)
}
snapScrimOffset(currentHeight + amountConsumed)
amountConsumed
},
- // Don't consume the velocity on pre/post fling
onStop = { velocityAvailable ->
onStop(velocityAvailable)
if (scrimOffset() < minScrimOffset()) {
animateScrimOffset(minScrimOffset())
}
- { 0f }
+ // Don't consume the velocity on pre/post fling
+ 0f
+ },
+ onCancel = {
+ onStop(0f)
+ if (scrimOffset() < minScrimOffset()) {
+ animateScrimOffset(minScrimOffset())
+ }
},
)
}
diff --git a/packages/SystemUI/compose/features/src/com/android/systemui/notifications/ui/composable/NotificationStackNestedScrollConnection.kt b/packages/SystemUI/compose/features/src/com/android/systemui/notifications/ui/composable/NotificationStackNestedScrollConnection.kt
index a706585..edb05eb 100644
--- a/packages/SystemUI/compose/features/src/com/android/systemui/notifications/ui/composable/NotificationStackNestedScrollConnection.kt
+++ b/packages/SystemUI/compose/features/src/com/android/systemui/notifications/ui/composable/NotificationStackNestedScrollConnection.kt
@@ -28,6 +28,7 @@
import androidx.compose.ui.platform.LocalDensity
import androidx.compose.ui.unit.IntOffset
import androidx.compose.ui.unit.dp
+import androidx.compose.ui.util.fastCoerceAtLeast
import com.android.compose.nestedscroll.PriorityNestedScrollConnection
import kotlin.math.max
import kotlin.math.roundToInt
@@ -86,21 +87,25 @@
): PriorityNestedScrollConnection {
return PriorityNestedScrollConnection(
orientation = Orientation.Vertical,
- canStartPreScroll = { _, _ -> false },
- canStartPostScroll = { offsetAvailable, offsetBeforeStart ->
+ canStartPreScroll = { _, _, _ -> false },
+ canStartPostScroll = { offsetAvailable, offsetBeforeStart, _ ->
offsetAvailable < 0f && offsetBeforeStart < 0f && !canScrollForward()
},
canStartPostFling = { velocityAvailable -> velocityAvailable < 0f && !canScrollForward() },
- canContinueScroll = { stackOffset() > 0f },
- canScrollOnFling = true,
+ canStopOnPreFling = { false },
onStart = { offsetAvailable -> onStart(offsetAvailable) },
- onScroll = { offsetAvailable ->
- onScroll(offsetAvailable)
- offsetAvailable
+ onScroll = { offsetAvailable, _ ->
+ val minOffset = 0f
+ val consumed = offsetAvailable.fastCoerceAtLeast(minOffset - stackOffset())
+ if (consumed != 0f) {
+ onScroll(consumed)
+ }
+ consumed
},
onStop = { velocityAvailable ->
onStop(velocityAvailable)
- suspend { velocityAvailable }
+ velocityAvailable
},
+ onCancel = { onStop(0f) },
)
}
diff --git a/packages/SystemUI/compose/scene/src/com/android/compose/animation/scene/DraggableHandler.kt b/packages/SystemUI/compose/scene/src/com/android/compose/animation/scene/DraggableHandler.kt
index 085157a..7e288dd 100644
--- a/packages/SystemUI/compose/scene/src/com/android/compose/animation/scene/DraggableHandler.kt
+++ b/packages/SystemUI/compose/scene/src/com/android/compose/animation/scene/DraggableHandler.kt
@@ -27,9 +27,10 @@
import com.android.compose.animation.scene.content.state.TransitionState
import com.android.compose.animation.scene.content.state.TransitionState.HasOverscrollProperties.Companion.DistanceUnspecified
import com.android.compose.nestedscroll.PriorityNestedScrollConnection
-import com.android.compose.nestedscroll.SuspendedValue
import kotlin.math.absoluteValue
+internal typealias SuspendedValue<T> = suspend () -> T
+
internal interface DraggableHandler {
/**
* Start a drag in the given [startedPosition], with the given [overSlop] and number of
@@ -612,7 +613,7 @@
return PriorityNestedScrollConnection(
orientation = orientation,
- canStartPreScroll = { offsetAvailable, offsetBeforeStart ->
+ canStartPreScroll = { offsetAvailable, offsetBeforeStart, _ ->
canChangeScene =
if (isExternalOverscrollGesture()) false else offsetBeforeStart == 0f
@@ -638,7 +639,7 @@
isIntercepting = true
true
},
- canStartPostScroll = { offsetAvailable, offsetBeforeStart ->
+ canStartPostScroll = { offsetAvailable, offsetBeforeStart, _ ->
val behavior: NestedScrollBehavior =
when {
offsetAvailable > 0f -> topOrLeftBehavior
@@ -693,8 +694,7 @@
canStart
},
- canContinueScroll = { true },
- canScrollOnFling = false,
+ canStopOnPreFling = { true },
onStart = { offsetAvailable ->
val pointersInfo = pointersInfo()
dragController =
@@ -704,7 +704,7 @@
overSlop = if (isIntercepting) 0f else offsetAvailable,
)
},
- onScroll = { offsetAvailable ->
+ onScroll = { offsetAvailable, _ ->
val controller = dragController ?: error("Should be called after onStart")
// TODO(b/297842071) We should handle the overscroll or slow drag if the gesture is
@@ -713,10 +713,18 @@
},
onStop = { velocityAvailable ->
val controller = dragController ?: error("Should be called after onStart")
-
- controller
- .onStop(velocity = velocityAvailable, canChangeContent = canChangeScene)
- .also { dragController = null }
+ try {
+ controller
+ .onStop(velocity = velocityAvailable, canChangeContent = canChangeScene)
+ .invoke()
+ } finally {
+ dragController = null
+ }
+ },
+ onCancel = {
+ val controller = dragController ?: error("Should be called after onStart")
+ controller.onStop(velocity = 0f, canChangeContent = canChangeScene)
+ dragController = null
},
)
}
diff --git a/packages/SystemUI/compose/scene/src/com/android/compose/animation/scene/SwipeAnimation.kt b/packages/SystemUI/compose/scene/src/com/android/compose/animation/scene/SwipeAnimation.kt
index 205267d..f0043e1 100644
--- a/packages/SystemUI/compose/scene/src/com/android/compose/animation/scene/SwipeAnimation.kt
+++ b/packages/SystemUI/compose/scene/src/com/android/compose/animation/scene/SwipeAnimation.kt
@@ -27,7 +27,6 @@
import androidx.compose.ui.unit.IntSize
import com.android.compose.animation.scene.content.state.TransitionState
import com.android.compose.animation.scene.content.state.TransitionState.HasOverscrollProperties.Companion.DistanceUnspecified
-import com.android.compose.nestedscroll.SuspendedValue
import kotlin.math.absoluteValue
import kotlinx.coroutines.CompletableDeferred
diff --git a/packages/SystemUI/compose/scene/src/com/android/compose/nestedscroll/LargeTopAppBarNestedScrollConnection.kt b/packages/SystemUI/compose/scene/src/com/android/compose/nestedscroll/LargeTopAppBarNestedScrollConnection.kt
index 4ae3235..ecf64b7 100644
--- a/packages/SystemUI/compose/scene/src/com/android/compose/nestedscroll/LargeTopAppBarNestedScrollConnection.kt
+++ b/packages/SystemUI/compose/scene/src/com/android/compose/nestedscroll/LargeTopAppBarNestedScrollConnection.kt
@@ -18,6 +18,8 @@
import androidx.compose.foundation.gestures.Orientation
import androidx.compose.ui.input.nestedscroll.NestedScrollConnection
+import androidx.compose.ui.util.fastCoerceAtLeast
+import androidx.compose.ui.util.fastCoerceAtMost
/**
* A [NestedScrollConnection] that listens for all vertical scroll events and responds in the
@@ -43,35 +45,32 @@
orientation = Orientation.Vertical,
// When swiping up, the LargeTopAppBar will shrink (to [minHeight]) and the content will
// expand. Then, you can then scroll down the content.
- canStartPreScroll = { offsetAvailable, offsetBeforeStart ->
+ canStartPreScroll = { offsetAvailable, offsetBeforeStart, _ ->
offsetAvailable < 0 && offsetBeforeStart == 0f && height() > minHeight()
},
// When swiping down, the content will scroll up until it reaches the top. Then, the
// LargeTopAppBar will expand until it reaches its [maxHeight].
- canStartPostScroll = { offsetAvailable, _ ->
+ canStartPostScroll = { offsetAvailable, _, _ ->
offsetAvailable > 0 && height() < maxHeight()
},
canStartPostFling = { false },
- canContinueScroll = {
- val currentHeight = height()
- minHeight() < currentHeight && currentHeight < maxHeight()
- },
- canScrollOnFling = true,
+ canStopOnPreFling = { false },
onStart = { /* do nothing */ },
- onScroll = { offsetAvailable ->
+ onScroll = { offsetAvailable, _ ->
val currentHeight = height()
val amountConsumed =
if (offsetAvailable > 0) {
val amountLeft = maxHeight() - currentHeight
- offsetAvailable.coerceAtMost(amountLeft)
+ offsetAvailable.fastCoerceAtMost(amountLeft)
} else {
val amountLeft = minHeight() - currentHeight
- offsetAvailable.coerceAtLeast(amountLeft)
+ offsetAvailable.fastCoerceAtLeast(amountLeft)
}
onHeightChanged(currentHeight + amountConsumed)
amountConsumed
},
// Don't consume the velocity on pre/post fling
- onStop = { { 0f } },
+ onStop = { 0f },
+ onCancel = { /* do nothing */ },
)
}
diff --git a/packages/SystemUI/compose/scene/src/com/android/compose/nestedscroll/PriorityNestedScrollConnection.kt b/packages/SystemUI/compose/scene/src/com/android/compose/nestedscroll/PriorityNestedScrollConnection.kt
index a3641e6..636c557 100644
--- a/packages/SystemUI/compose/scene/src/com/android/compose/nestedscroll/PriorityNestedScrollConnection.kt
+++ b/packages/SystemUI/compose/scene/src/com/android/compose/nestedscroll/PriorityNestedScrollConnection.kt
@@ -16,37 +16,59 @@
package com.android.compose.nestedscroll
+import androidx.compose.animation.core.AnimationState
+import androidx.compose.animation.core.DecayAnimationSpec
+import androidx.compose.animation.core.animateDecay
import androidx.compose.foundation.gestures.Orientation
import androidx.compose.ui.geometry.Offset
import androidx.compose.ui.input.nestedscroll.NestedScrollConnection
import androidx.compose.ui.input.nestedscroll.NestedScrollSource
import androidx.compose.ui.unit.Velocity
import com.android.compose.ui.util.SpaceVectorConverter
+import kotlin.math.abs
import kotlin.math.sign
-
-internal typealias SuspendedValue<T> = suspend () -> T
+import kotlinx.coroutines.CompletableDeferred
+import kotlinx.coroutines.Deferred
+import kotlinx.coroutines.async
+import kotlinx.coroutines.coroutineScope
/**
- * This [NestedScrollConnection] waits for a child to scroll ([onPreScroll] or [onPostScroll]), and
- * then decides (via [canStartPreScroll] or [canStartPostScroll]) if it should take over scrolling.
- * If it does, it will scroll before its children, until [canContinueScroll] allows it.
+ * A [NestedScrollConnection] that intercepts scroll events in priority mode.
*
- * Note: Call [reset] before destroying this object to make sure you always get a call to [onStop]
- * after [onStart].
+ * Priority mode allows this connection to take control over scroll events within a nested scroll
+ * hierarchy. When in priority mode, this connection consumes scroll events before its children,
+ * enabling custom scrolling behaviors like sticky headers.
*
+ * @param orientation The orientation of the scroll.
+ * @param canStartPreScroll lambda that returns true if the connection can start consuming scroll
+ * events in pre-scroll mode.
+ * @param canStartPostScroll lambda that returns true if the connection can start consuming scroll
+ * events in post-scroll mode.
+ * @param canStartPostFling lambda that returns true if the connection can start consuming scroll
+ * events in post-fling mode.
+ * @param canStopOnPreFling lambda that returns true if the connection can stop consuming scroll
+ * events in pre-fling (i.e. as soon as the user lifts their fingers).
+ * @param onStart lambda that is called when the connection starts consuming scroll events.
+ * @param onScroll lambda that is called when the connection consumes a scroll event and returns the
+ * consumed amount.
+ * @param onStop lambda that is called when the connection stops consuming scroll events and returns
+ * the consumed velocity.
+ * @param onCancel lambda that is called when the connection is cancelled.
* @sample LargeTopAppBarNestedScrollConnection
* @sample com.android.compose.animation.scene.NestedScrollHandlerImpl.nestedScrollConnection
*/
class PriorityNestedScrollConnection(
orientation: Orientation,
- private val canStartPreScroll: (offsetAvailable: Float, offsetBeforeStart: Float) -> Boolean,
- private val canStartPostScroll: (offsetAvailable: Float, offsetBeforeStart: Float) -> Boolean,
+ private val canStartPreScroll:
+ (offsetAvailable: Float, offsetBeforeStart: Float, source: NestedScrollSource) -> Boolean,
+ private val canStartPostScroll:
+ (offsetAvailable: Float, offsetBeforeStart: Float, source: NestedScrollSource) -> Boolean,
private val canStartPostFling: (velocityAvailable: Float) -> Boolean,
- private val canContinueScroll: (source: NestedScrollSource) -> Boolean,
- private val canScrollOnFling: Boolean,
+ private val canStopOnPreFling: () -> Boolean,
private val onStart: (offsetAvailable: Float) -> Unit,
- private val onScroll: (offsetAvailable: Float) -> Float,
- private val onStop: (velocityAvailable: Float) -> SuspendedValue<Float>,
+ private val onScroll: (offsetAvailable: Float, source: NestedScrollSource) -> Float,
+ private val onStop: suspend (velocityAvailable: Float) -> Float,
+ private val onCancel: () -> Unit,
) : NestedScrollConnection, SpaceVectorConverter by SpaceVectorConverter(orientation) {
/** In priority mode [onPreScroll] events are first consumed by the parent, via [onScroll]. */
@@ -54,6 +76,9 @@
private var offsetScrolledBeforePriorityMode = 0f
+ /** This job allows us to interrupt the onStop animation */
+ private var onStopJob: Deferred<Float> = CompletableDeferred(0f)
+
override fun onPostScroll(
consumed: Offset,
available: Offset,
@@ -64,62 +89,48 @@
// the beginning or from the last fling gesture.
val offsetBeforeStart = offsetScrolledBeforePriorityMode - availableFloat
- if (
- isPriorityMode ||
- (source == NestedScrollSource.SideEffect && !canScrollOnFling) ||
- !canStartPostScroll(availableFloat, offsetBeforeStart)
- ) {
+ if (isPriorityMode || !canStartPostScroll(availableFloat, offsetBeforeStart, source)) {
// The priority mode cannot start so we won't consume the available offset.
return Offset.Zero
}
- return onPriorityStart(availableFloat).toOffset()
+ return start(availableFloat, source).toOffset()
}
override fun onPreScroll(available: Offset, source: NestedScrollSource): Offset {
if (!isPriorityMode) {
- if (source == NestedScrollSource.UserInput || canScrollOnFling) {
- val availableFloat = available.toFloat()
- if (canStartPreScroll(availableFloat, offsetScrolledBeforePriorityMode)) {
- return onPriorityStart(availableFloat).toOffset()
- }
- // We want to track the amount of offset consumed before entering priority mode
- offsetScrolledBeforePriorityMode += availableFloat
+ val availableFloat = available.toFloat()
+ if (canStartPreScroll(availableFloat, offsetScrolledBeforePriorityMode, source)) {
+ return start(availableFloat, source).toOffset()
}
-
- return Offset.Zero
- }
-
- val availableFloat = available.toFloat()
- if (!canContinueScroll(source)) {
- // Step 3a: We have lost priority and we no longer need to intercept scroll events.
- onPriorityStop(velocity = 0f)
-
- // We've just reset offsetScrolledBeforePriorityMode to 0f
// We want to track the amount of offset consumed before entering priority mode
offsetScrolledBeforePriorityMode += availableFloat
-
return Offset.Zero
}
- // Step 2: We have the priority and can consume the scroll events.
- return onScroll(availableFloat).toOffset()
+ return scroll(available.toFloat(), source).toOffset()
}
override suspend fun onPreFling(available: Velocity): Velocity {
- if (isPriorityMode && canScrollOnFling) {
- // We don't want to consume the velocity, we prefer to continue receiving scroll events.
+ if (!isPriorityMode) {
+ resetOffsetTracker()
return Velocity.Zero
}
- // Step 3b: The finger is lifted, we can stop intercepting scroll events and use the speed
- // of the fling gesture.
- return onPriorityStop(velocity = available.toFloat()).invoke().toVelocity()
+
+ if (canStopOnPreFling()) {
+ // Step 3b: The finger is lifted, we can stop intercepting scroll events and use the
+ // velocity of the fling gesture.
+ return stop(velocityAvailable = available.toFloat()).toVelocity()
+ }
+
+ // We don't want to consume the velocity, we prefer to continue receiving scroll events.
+ return Velocity.Zero
}
override suspend fun onPostFling(consumed: Velocity, available: Velocity): Velocity {
val availableFloat = available.toFloat()
if (isPriorityMode) {
- return onPriorityStop(velocity = availableFloat).invoke().toVelocity()
+ return stop(velocityAvailable = availableFloat).toVelocity()
}
if (!canStartPostFling(availableFloat)) {
@@ -131,10 +142,14 @@
// TODO(b/291053278): Remove canStartPostFling() and instead make it possible to define the
// overscroll behavior on the Scene level.
val smallOffset = availableFloat.sign
- onPriorityStart(availableOffset = smallOffset)
+ start(
+ availableOffset = smallOffset,
+ source = NestedScrollSource.SideEffect,
+ skipScroll = true,
+ )
// This is the last event of a scroll gesture.
- return onPriorityStop(availableFloat).invoke().toVelocity()
+ return stop(availableFloat).toVelocity()
}
/**
@@ -143,36 +158,76 @@
* TODO(b/303224944) This method should be removed.
*/
fun reset() {
- // Step 3c: To ensure that an onStop is always called for every onStart.
- onPriorityStop(velocity = 0f)
+ if (isPriorityMode) {
+ // Step 3c: To ensure that an onStop (or onCancel) is always called for every onStart.
+ cancel()
+ } else {
+ resetOffsetTracker()
+ }
}
- private fun onPriorityStart(availableOffset: Float): Float {
- if (isPriorityMode) {
- error("This should never happen, onPriorityStart() was called when isPriorityMode")
+ private fun shouldStop(consumed: Float): Boolean {
+ return consumed == 0f
+ }
+
+ private fun start(
+ availableOffset: Float,
+ source: NestedScrollSource,
+ skipScroll: Boolean = false,
+ ): Float {
+ check(!isPriorityMode) {
+ "This should never happen, start() was called when isPriorityMode"
}
// Step 1: It's our turn! We start capturing scroll events when one of our children has an
// available offset following a scroll event.
isPriorityMode = true
+ onStopJob.cancel()
+
// Note: onStop will be called if we cannot continue to scroll (step 3a), or the finger is
// lifted (step 3b), or this object has been destroyed (step 3c).
onStart(availableOffset)
- return onScroll(availableOffset)
+ return if (skipScroll) 0f else scroll(availableOffset, source)
}
- private fun onPriorityStop(velocity: Float): SuspendedValue<Float> {
- // We can restart tracking the consumed offsets from scratch.
- offsetScrolledBeforePriorityMode = 0f
+ private fun scroll(offsetAvailable: Float, source: NestedScrollSource): Float {
+ // Step 2: We have the priority and can consume the scroll events.
+ val consumedByScroll = onScroll(offsetAvailable, source)
- if (!isPriorityMode) {
- return { 0f }
+ if (shouldStop(consumedByScroll)) {
+ // Step 3a: We have lost priority and we no longer need to intercept scroll events.
+ cancel()
+
+ // We've just reset offsetScrolledBeforePriorityMode to 0f
+ // We want to track the amount of offset consumed before entering priority mode
+ offsetScrolledBeforePriorityMode += offsetAvailable - consumedByScroll
}
- isPriorityMode = false
+ return consumedByScroll
+ }
- return onStop(velocity)
+ /** Reset the tracking of consumed offsets before entering in priority mode. */
+ private fun resetOffsetTracker() {
+ offsetScrolledBeforePriorityMode = 0f
+ }
+
+ private suspend fun stop(velocityAvailable: Float): Float {
+ check(isPriorityMode) { "This should never happen, stop() was called before start()" }
+ isPriorityMode = false
+ resetOffsetTracker()
+
+ return coroutineScope {
+ onStopJob = async { onStop(velocityAvailable) }
+ onStopJob.await()
+ }
+ }
+
+ private fun cancel() {
+ check(isPriorityMode) { "This should never happen, cancel() was called before start()" }
+ isPriorityMode = false
+ resetOffsetTracker()
+ onCancel()
}
}
diff --git a/packages/SystemUI/compose/scene/tests/src/com/android/compose/animation/scene/DraggableHandlerTest.kt b/packages/SystemUI/compose/scene/tests/src/com/android/compose/animation/scene/DraggableHandlerTest.kt
index ecef6be..57b9423 100644
--- a/packages/SystemUI/compose/scene/tests/src/com/android/compose/animation/scene/DraggableHandlerTest.kt
+++ b/packages/SystemUI/compose/scene/tests/src/com/android/compose/animation/scene/DraggableHandlerTest.kt
@@ -39,7 +39,6 @@
import com.android.compose.animation.scene.content.state.TransitionState
import com.android.compose.animation.scene.content.state.TransitionState.Transition
import com.android.compose.animation.scene.subjects.assertThat
-import com.android.compose.nestedscroll.SuspendedValue
import com.android.compose.test.MonotonicClockTestScope
import com.android.compose.test.runMonotonicClockTest
import com.android.compose.test.transition
diff --git a/packages/SystemUI/compose/scene/tests/src/com/android/compose/animation/scene/MultiPointerDraggableTest.kt b/packages/SystemUI/compose/scene/tests/src/com/android/compose/animation/scene/MultiPointerDraggableTest.kt
index c8f6e6d..3df6087 100644
--- a/packages/SystemUI/compose/scene/tests/src/com/android/compose/animation/scene/MultiPointerDraggableTest.kt
+++ b/packages/SystemUI/compose/scene/tests/src/com/android/compose/animation/scene/MultiPointerDraggableTest.kt
@@ -46,7 +46,6 @@
import androidx.compose.ui.unit.Velocity
import androidx.test.ext.junit.runners.AndroidJUnit4
import com.android.compose.modifiers.thenIf
-import com.android.compose.nestedscroll.SuspendedValue
import com.google.common.truth.Truth.assertThat
import kotlin.properties.Delegates
import kotlinx.coroutines.coroutineScope
diff --git a/packages/SystemUI/compose/scene/tests/src/com/android/compose/nestedscroll/PriorityNestedScrollConnectionTest.kt b/packages/SystemUI/compose/scene/tests/src/com/android/compose/nestedscroll/PriorityNestedScrollConnectionTest.kt
index badc43b..1a3b86b 100644
--- a/packages/SystemUI/compose/scene/tests/src/com/android/compose/nestedscroll/PriorityNestedScrollConnectionTest.kt
+++ b/packages/SystemUI/compose/scene/tests/src/com/android/compose/nestedscroll/PriorityNestedScrollConnectionTest.kt
@@ -34,30 +34,31 @@
private var canStartPreScroll = false
private var canStartPostScroll = false
private var canStartPostFling = false
- private var canContinueScroll = false
+ private var canStopOnPreFling = true
private var isStarted = false
private var lastScroll: Float? = null
- private var returnOnScroll = 0f
+ private var consumeScroll = true
private var lastStop: Float? = null
- private var returnOnStop = 0f
+ private var isCancelled: Boolean = false
+ private var consumeStop = true
private val scrollConnection =
PriorityNestedScrollConnection(
orientation = Orientation.Vertical,
- canStartPreScroll = { _, _ -> canStartPreScroll },
- canStartPostScroll = { _, _ -> canStartPostScroll },
+ canStartPreScroll = { _, _, _ -> canStartPreScroll },
+ canStartPostScroll = { _, _, _ -> canStartPostScroll },
canStartPostFling = { canStartPostFling },
- canContinueScroll = { canContinueScroll },
- canScrollOnFling = false,
+ canStopOnPreFling = { canStopOnPreFling },
onStart = { isStarted = true },
- onScroll = {
- lastScroll = it
- returnOnScroll
+ onScroll = { offsetAvailable, _ ->
+ lastScroll = offsetAvailable
+ if (consumeScroll) offsetAvailable else 0f
},
onStop = {
lastStop = it
- { returnOnStop }
+ if (consumeStop) it else 0f
},
+ onCancel = { isCancelled = true },
)
@Test
@@ -85,7 +86,7 @@
canStartPostScroll = true
scrollConnection.onPostScroll(
consumed = Offset.Zero,
- available = Offset.Zero,
+ available = Offset(1f, 1f),
source = UserInput,
)
}
@@ -136,45 +137,55 @@
@Test
fun step2_onPriorityMode_shouldContinueIfAllowed() {
startPriorityModePostScroll()
- canContinueScroll = true
- scrollConnection.onPreScroll(available = Offset(1f, 1f), source = UserInput)
+ val scroll1 = scrollConnection.onPreScroll(available = Offset(0f, 1f), source = UserInput)
assertThat(lastScroll).isEqualTo(1f)
+ assertThat(scroll1.y).isEqualTo(1f)
- canContinueScroll = false
- scrollConnection.onPreScroll(available = Offset(2f, 2f), source = UserInput)
- assertThat(lastScroll).isNotEqualTo(2f)
- assertThat(lastScroll).isEqualTo(1f)
+ consumeScroll = false
+ val scroll2 = scrollConnection.onPreScroll(available = Offset(0f, 2f), source = UserInput)
+ assertThat(lastScroll).isEqualTo(2f)
+ assertThat(scroll2.y).isEqualTo(0f)
}
@Test
- fun step3a_onPriorityMode_shouldStopIfCannotContinue() {
+ fun step3a_onPriorityMode_shouldCancelIfCannotContinue() {
startPriorityModePostScroll()
- canContinueScroll = false
+ consumeScroll = false
- scrollConnection.onPreScroll(available = Offset.Zero, source = UserInput)
+ scrollConnection.onPreScroll(available = Offset(0f, 1f), source = UserInput)
- assertThat(lastStop).isNotNull()
+ assertThat(isCancelled).isTrue()
}
@Test
fun step3b_onPriorityMode_shouldStopOnFling() = runTest {
startPriorityModePostScroll()
- canContinueScroll = true
scrollConnection.onPreFling(available = Velocity.Zero)
- assertThat(lastStop).isNotNull()
+ assertThat(lastStop).isEqualTo(0f)
}
@Test
- fun step3c_onPriorityMode_shouldStopOnReset() {
+ fun ifCannotStopOnPreFling_shouldStopOnPostFling() = runTest {
startPriorityModePostScroll()
- canContinueScroll = true
+ canStopOnPreFling = false
+
+ scrollConnection.onPreFling(available = Velocity.Zero)
+ assertThat(lastStop).isNull()
+
+ scrollConnection.onPostFling(consumed = Velocity.Zero, available = Velocity.Zero)
+ assertThat(lastStop).isEqualTo(0f)
+ }
+
+ @Test
+ fun step3c_onPriorityMode_shouldCancelOnReset() {
+ startPriorityModePostScroll()
scrollConnection.reset()
- assertThat(lastStop).isNotNull()
+ assertThat(isCancelled).isTrue()
}
@Test
diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/notification/NotificationScrimNestedScrollConnectionTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/notification/NotificationScrimNestedScrollConnectionTest.kt
index 35e4047..97fa6eb 100644
--- a/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/notification/NotificationScrimNestedScrollConnectionTest.kt
+++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/notification/NotificationScrimNestedScrollConnectionTest.kt
@@ -31,6 +31,7 @@
@RunWith(AndroidJUnit4::class)
class NotificationScrimNestedScrollConnectionTest : SysuiTestCase() {
private var isStarted = false
+ private var wasStarted = false
private var scrimOffset = 0f
private var contentHeight = 0f
private var isCurrentGestureOverscroll = false
@@ -46,7 +47,10 @@
minVisibleScrimHeight = { MIN_VISIBLE_SCRIM_HEIGHT },
isCurrentGestureOverscroll = { isCurrentGestureOverscroll },
onStart = { isStarted = true },
- onStop = { isStarted = false },
+ onStop = {
+ wasStarted = true
+ isStarted = false
+ },
)
@Test
@@ -180,6 +184,7 @@
)
assertThat(offsetConsumed).isEqualTo(Offset.Zero)
+ assertThat(wasStarted).isEqualTo(false)
assertThat(isStarted).isEqualTo(false)
}
@@ -196,7 +201,9 @@
)
assertThat(offsetConsumed).isEqualTo(Offset.Zero)
- assertThat(isStarted).isEqualTo(true)
+ // Returning 0 offset will immediately stop the connection
+ assertThat(wasStarted).isEqualTo(true)
+ assertThat(isStarted).isEqualTo(false)
}
@Test
diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewConfigurator.kt b/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewConfigurator.kt
index 063adc8..3230285 100644
--- a/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewConfigurator.kt
+++ b/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewConfigurator.kt
@@ -30,8 +30,6 @@
import com.android.internal.jank.InteractionJankMonitor
import com.android.keyguard.KeyguardStatusView
import com.android.keyguard.KeyguardStatusViewController
-import com.android.keyguard.LegacyLockIconViewController
-import com.android.keyguard.LockIconView
import com.android.keyguard.dagger.KeyguardStatusViewComponent
import com.android.systemui.CoreStartable
import com.android.systemui.biometrics.ui.binder.DeviceEntryUnlockTrackerViewBinder
@@ -39,7 +37,6 @@
import com.android.systemui.dagger.SysUISingleton
import com.android.systemui.dagger.qualifiers.Main
import com.android.systemui.deviceentry.domain.interactor.DeviceEntryHapticsInteractor
-import com.android.systemui.deviceentry.shared.DeviceEntryUdfpsRefactor
import com.android.systemui.keyguard.domain.interactor.KeyguardClockInteractor
import com.android.systemui.keyguard.shared.model.LockscreenSceneBlueprint
import com.android.systemui.keyguard.ui.binder.KeyguardBlueprintViewBinder
@@ -94,7 +91,6 @@
private val configuration: ConfigurationState,
private val context: Context,
private val keyguardIndicationController: KeyguardIndicationController,
- private val lockIconViewController: Lazy<LegacyLockIconViewController>,
private val shadeInteractor: ShadeInteractor,
private val interactionJankMonitor: InteractionJankMonitor,
private val deviceEntryHapticsInteractor: DeviceEntryHapticsInteractor,
@@ -171,10 +167,6 @@
private fun initializeViews() {
val indicationArea = KeyguardIndicationArea(context, null)
keyguardIndicationController.setIndicationArea(indicationArea)
-
- if (!DeviceEntryUdfpsRefactor.isEnabled) {
- lockIconViewController.get().setLockIconView(LockIconView(context, null))
- }
}
private fun bindKeyguardRootView() {
diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewMediator.java b/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewMediator.java
index d28b08f..fbc76c5 100644
--- a/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewMediator.java
+++ b/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewMediator.java
@@ -139,7 +139,6 @@
import com.android.systemui.communal.ui.viewmodel.CommunalTransitionViewModel;
import com.android.systemui.dagger.qualifiers.Main;
import com.android.systemui.dagger.qualifiers.UiBackground;
-import com.android.systemui.deviceentry.shared.DeviceEntryUdfpsRefactor;
import com.android.systemui.dreams.DreamOverlayStateController;
import com.android.systemui.dreams.ui.viewmodel.DreamViewModel;
import com.android.systemui.dump.DumpManager;
@@ -3569,9 +3568,7 @@
}
// Ensure that keyguard becomes visible if the going away animation is canceled
- if (showKeyguard && !KeyguardWmStateRefactor.isEnabled()
- && (MigrateClocksToBlueprint.isEnabled()
- || DeviceEntryUdfpsRefactor.isEnabled())) {
+ if (showKeyguard && !KeyguardWmStateRefactor.isEnabled()) {
mKeyguardInteractor.showKeyguard();
}
}
diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/ui/binder/AlternateBouncerUdfpsViewBinder.kt b/packages/SystemUI/src/com/android/systemui/keyguard/ui/binder/AlternateBouncerUdfpsViewBinder.kt
index fb97191..7ca2c20 100644
--- a/packages/SystemUI/src/com/android/systemui/keyguard/ui/binder/AlternateBouncerUdfpsViewBinder.kt
+++ b/packages/SystemUI/src/com/android/systemui/keyguard/ui/binder/AlternateBouncerUdfpsViewBinder.kt
@@ -22,7 +22,6 @@
import androidx.lifecycle.Lifecycle
import androidx.lifecycle.repeatOnLifecycle
import com.android.app.tracing.coroutines.launch
-import com.android.systemui.deviceentry.shared.DeviceEntryUdfpsRefactor
import com.android.systemui.keyguard.ui.view.DeviceEntryIconView
import com.android.systemui.keyguard.ui.viewmodel.AlternateBouncerUdfpsIconViewModel
import com.android.systemui.lifecycle.repeatWhenAttached
@@ -34,13 +33,7 @@
/** Updates UI for the UDFPS icon on the alternate bouncer. */
@JvmStatic
- fun bind(
- view: DeviceEntryIconView,
- viewModel: AlternateBouncerUdfpsIconViewModel,
- ) {
- if (DeviceEntryUdfpsRefactor.isUnexpectedlyInLegacyMode()) {
- return
- }
+ fun bind(view: DeviceEntryIconView, viewModel: AlternateBouncerUdfpsIconViewModel) {
val fgIconView = view.iconView
val bgView = view.bgView
@@ -66,7 +59,7 @@
viewModel.fgViewModel.collect { fgViewModel ->
fgIconView.setImageState(
view.getIconState(fgViewModel.type, fgViewModel.useAodVariant),
- /* merge */ false
+ /* merge */ false,
)
fgIconView.imageTintList = ColorStateList.valueOf(fgViewModel.tint)
fgIconView.setPadding(
diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/ui/binder/AlternateBouncerViewBinder.kt b/packages/SystemUI/src/com/android/systemui/keyguard/ui/binder/AlternateBouncerViewBinder.kt
index 7696273..1891af2 100644
--- a/packages/SystemUI/src/com/android/systemui/keyguard/ui/binder/AlternateBouncerViewBinder.kt
+++ b/packages/SystemUI/src/com/android/systemui/keyguard/ui/binder/AlternateBouncerViewBinder.kt
@@ -33,7 +33,6 @@
import com.android.systemui.CoreStartable
import com.android.systemui.dagger.SysUISingleton
import com.android.systemui.dagger.qualifiers.Application
-import com.android.systemui.deviceentry.shared.DeviceEntryUdfpsRefactor
import com.android.systemui.deviceentry.ui.binder.UdfpsAccessibilityOverlayBinder
import com.android.systemui.deviceentry.ui.view.UdfpsAccessibilityOverlay
import com.android.systemui.deviceentry.ui.viewmodel.AlternateBouncerUdfpsAccessibilityOverlayViewModel
@@ -95,7 +94,7 @@
private var alternateBouncerView: ConstraintLayout? = null
override fun start() {
- if (!DeviceEntryUdfpsRefactor.isEnabled || SceneContainerFlag.isEnabled) {
+ if (SceneContainerFlag.isEnabled) {
return
}
@@ -182,14 +181,7 @@
}
/** Binds the view to the view-model, continuing to update the former based on the latter. */
- fun bind(
- view: ConstraintLayout,
- alternateBouncerDependencies: AlternateBouncerDependencies,
- ) {
- if (DeviceEntryUdfpsRefactor.isUnexpectedlyInLegacyMode()) {
- return
- }
-
+ fun bind(view: ConstraintLayout, alternateBouncerDependencies: AlternateBouncerDependencies) {
optionallyAddUdfpsViews(
view = view,
logger = alternateBouncerDependencies.logger,
@@ -287,10 +279,7 @@
)
}
view.addView(udfpsView)
- AlternateBouncerUdfpsViewBinder.bind(
- udfpsView,
- udfpsIconViewModel,
- )
+ AlternateBouncerUdfpsViewBinder.bind(udfpsView, udfpsIconViewModel)
}
val constraintSet = ConstraintSet().apply { clone(view) }
@@ -310,17 +299,17 @@
ConstraintSet.START,
ConstraintSet.PARENT_ID,
ConstraintSet.START,
- iconLocation.left
+ iconLocation.left,
)
// udfpsA11yOverlayView:
constrainWidth(
udfpsA11yOverlayViewId,
- ViewGroup.LayoutParams.MATCH_PARENT
+ ViewGroup.LayoutParams.MATCH_PARENT,
)
constrainHeight(
udfpsA11yOverlayViewId,
- ViewGroup.LayoutParams.MATCH_PARENT
+ ViewGroup.LayoutParams.MATCH_PARENT,
)
}
constraintSet.applyTo(view)
diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/ui/binder/DeviceEntryIconViewBinder.kt b/packages/SystemUI/src/com/android/systemui/keyguard/ui/binder/DeviceEntryIconViewBinder.kt
index b951b73..a3f3342 100644
--- a/packages/SystemUI/src/com/android/systemui/keyguard/ui/binder/DeviceEntryIconViewBinder.kt
+++ b/packages/SystemUI/src/com/android/systemui/keyguard/ui/binder/DeviceEntryIconViewBinder.kt
@@ -30,7 +30,6 @@
import androidx.lifecycle.repeatOnLifecycle
import com.android.app.tracing.coroutines.launch
import com.android.systemui.common.ui.view.LongPressHandlingView
-import com.android.systemui.deviceentry.shared.DeviceEntryUdfpsRefactor
import com.android.systemui.keyguard.ui.view.DeviceEntryIconView
import com.android.systemui.keyguard.ui.viewmodel.DeviceEntryBackgroundViewModel
import com.android.systemui.keyguard.ui.viewmodel.DeviceEntryForegroundViewModel
@@ -68,7 +67,6 @@
vibratorHelper: VibratorHelper,
overrideColor: Color? = null,
): DisposableHandle {
- DeviceEntryUdfpsRefactor.isUnexpectedlyInLegacyMode()
val disposables = DisposableHandles()
val longPressHandlingView = view.longPressHandlingView
val fgIconView = view.iconView
@@ -79,7 +77,7 @@
view: View,
x: Int,
y: Int,
- isA11yAction: Boolean
+ isA11yAction: Boolean,
) {
if (
!isA11yAction && falsingManager.isFalseLongTap(FalsingManager.LOW_PENALTY)
@@ -87,14 +85,11 @@
Log.d(
TAG,
"Long press rejected because it is not a11yAction " +
- "and it is a falseLongTap"
+ "and it is a falseLongTap",
)
return
}
- vibratorHelper.performHapticFeedback(
- view,
- HapticFeedbackConstants.CONFIRM,
- )
+ vibratorHelper.performHapticFeedback(view, HapticFeedbackConstants.CONFIRM)
applicationScope.launch {
view.clearFocus()
view.clearAccessibilityFocus()
@@ -192,7 +187,7 @@
fgViewModel.viewModel.collect { viewModel ->
fgIconView.setImageState(
view.getIconState(viewModel.type, viewModel.useAodVariant),
- /* merge */ false
+ /* merge */ false,
)
if (viewModel.type.contentDescriptionResId != -1) {
fgIconView.contentDescription =
diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/ui/binder/KeyguardPreviewClockViewBinder.kt b/packages/SystemUI/src/com/android/systemui/keyguard/ui/binder/KeyguardPreviewClockViewBinder.kt
index 17b929d..2d22556 100644
--- a/packages/SystemUI/src/com/android/systemui/keyguard/ui/binder/KeyguardPreviewClockViewBinder.kt
+++ b/packages/SystemUI/src/com/android/systemui/keyguard/ui/binder/KeyguardPreviewClockViewBinder.kt
@@ -50,6 +50,8 @@
/** Binder for the small clock view, large clock view. */
object KeyguardPreviewClockViewBinder {
+ val lockId = View.generateViewId()
+
@JvmStatic
fun bind(
largeClockHostView: View,
@@ -144,12 +146,12 @@
ConstraintSet.END,
)
- // In preview, we'll show UDFPS icon for UDFPS devices
- // and nothing for non-UDFPS devices,
- // but we need position of device entry icon to constrain clock
- if (getConstraint(R.id.lock_icon_view) != null) {
- connect(customR.id.lockscreen_clock_view_large, BOTTOM, R.id.lock_icon_view, TOP)
- } else {
+
+ // In preview, we'll show UDFPS icon for UDFPS devices and nothing for non-UDFPS
+ // devices, but we need position of device entry icon to constrain clock
+ if (getConstraint(lockId) != null) {
+ connect(customR.id.lockscreen_clock_view_large, BOTTOM, lockId, TOP)
+ } else {
// Copied calculation codes from applyConstraints in DefaultDeviceEntrySection
val bottomPaddingPx =
context.resources.getDimensionPixelSize(R.dimen.lock_icon_margin_bottom)
diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/ui/binder/KeyguardRootViewBinder.kt b/packages/SystemUI/src/com/android/systemui/keyguard/ui/binder/KeyguardRootViewBinder.kt
index 447ee9d..ea70fd0 100644
--- a/packages/SystemUI/src/com/android/systemui/keyguard/ui/binder/KeyguardRootViewBinder.kt
+++ b/packages/SystemUI/src/com/android/systemui/keyguard/ui/binder/KeyguardRootViewBinder.kt
@@ -54,7 +54,6 @@
import com.android.systemui.common.ui.view.onTouchListener
import com.android.systemui.customization.R as customR
import com.android.systemui.deviceentry.domain.interactor.DeviceEntryHapticsInteractor
-import com.android.systemui.deviceentry.shared.DeviceEntryUdfpsRefactor
import com.android.systemui.keyguard.KeyguardBottomAreaRefactor
import com.android.systemui.keyguard.KeyguardViewMediator
import com.android.systemui.keyguard.MigrateClocksToBlueprint
@@ -181,16 +180,12 @@
}
}
- if (
- KeyguardBottomAreaRefactor.isEnabled || DeviceEntryUdfpsRefactor.isEnabled
- ) {
- launch("$TAG#alpha") {
- viewModel.alpha(viewState).collect { alpha ->
- view.alpha = alpha
- if (KeyguardBottomAreaRefactor.isEnabled) {
- childViews[statusViewId]?.alpha = alpha
- childViews[burnInLayerId]?.alpha = alpha
- }
+ launch("$TAG#alpha") {
+ viewModel.alpha(viewState).collect { alpha ->
+ view.alpha = alpha
+ if (KeyguardBottomAreaRefactor.isEnabled) {
+ childViews[statusViewId]?.alpha = alpha
+ childViews[burnInLayerId]?.alpha = alpha
}
}
}
@@ -224,7 +219,6 @@
indicationArea,
startButton,
endButton,
- lockIcon,
deviceEntryIcon -> {
// Do not move these views
}
@@ -628,7 +622,6 @@
private val indicationArea = R.id.keyguard_indication_area
private val startButton = R.id.start_button
private val endButton = R.id.end_button
- private val lockIcon = R.id.lock_icon_view
private val deviceEntryIcon = R.id.device_entry_icon_view
private val nsslPlaceholderId = R.id.nssl_placeholder
private val authInteractionProperties = AuthInteractionProperties()
diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/ui/preview/KeyguardPreviewRenderer.kt b/packages/SystemUI/src/com/android/systemui/keyguard/ui/preview/KeyguardPreviewRenderer.kt
index cef9a4e..dd8980d 100644
--- a/packages/SystemUI/src/com/android/systemui/keyguard/ui/preview/KeyguardPreviewRenderer.kt
+++ b/packages/SystemUI/src/com/android/systemui/keyguard/ui/preview/KeyguardPreviewRenderer.kt
@@ -17,7 +17,6 @@
package com.android.systemui.keyguard.ui.preview
-import com.android.app.tracing.coroutines.createCoroutineTracingContext
import android.app.WallpaperColors
import android.content.BroadcastReceiver
import android.content.Context
@@ -48,6 +47,7 @@
import androidx.constraintlayout.widget.ConstraintSet.START
import androidx.constraintlayout.widget.ConstraintSet.TOP
import androidx.core.view.isInvisible
+import com.android.app.tracing.coroutines.createCoroutineTracingContext
import com.android.internal.policy.SystemBarUtils
import com.android.keyguard.ClockEventController
import com.android.keyguard.KeyguardClockSwitch
@@ -151,10 +151,7 @@
private val width: Int = bundle.getInt(KEY_VIEW_WIDTH)
private val height: Int = bundle.getInt(KEY_VIEW_HEIGHT)
private val shouldHighlightSelectedAffordance: Boolean =
- bundle.getBoolean(
- KeyguardPreviewConstants.KEY_HIGHLIGHT_QUICK_AFFORDANCES,
- false,
- )
+ bundle.getBoolean(KeyguardPreviewConstants.KEY_HIGHLIGHT_QUICK_AFFORDANCES, false)
private val displayId = bundle.getInt(KEY_DISPLAY_ID, DEFAULT_DISPLAY)
private val display: Display? = displayManager.getDisplay(displayId)
@@ -188,24 +185,26 @@
private var themeStyle: Style? = null
init {
- coroutineScope = CoroutineScope(applicationScope.coroutineContext + Job() + createCoroutineTracingContext("KeyguardPreviewRenderer"))
+ coroutineScope =
+ CoroutineScope(
+ applicationScope.coroutineContext +
+ Job() +
+ createCoroutineTracingContext("KeyguardPreviewRenderer")
+ )
disposables += DisposableHandle { coroutineScope.cancel() }
clockController.setFallbackWeatherData(WeatherData.getPlaceholderWeatherData())
if (KeyguardBottomAreaRefactor.isEnabled) {
quickAffordancesCombinedViewModel.enablePreviewMode(
initiallySelectedSlotId =
- bundle.getString(
- KeyguardPreviewConstants.KEY_INITIALLY_SELECTED_SLOT_ID,
- ) ?: KeyguardQuickAffordanceSlots.SLOT_ID_BOTTOM_START,
+ bundle.getString(KeyguardPreviewConstants.KEY_INITIALLY_SELECTED_SLOT_ID)
+ ?: KeyguardQuickAffordanceSlots.SLOT_ID_BOTTOM_START,
shouldHighlightSelectedAffordance = shouldHighlightSelectedAffordance,
)
} else {
bottomAreaViewModel.enablePreviewMode(
initiallySelectedSlotId =
- bundle.getString(
- KeyguardPreviewConstants.KEY_INITIALLY_SELECTED_SLOT_ID,
- ),
+ bundle.getString(KeyguardPreviewConstants.KEY_INITIALLY_SELECTED_SLOT_ID),
shouldHighlightSelectedAffordance = shouldHighlightSelectedAffordance,
)
}
@@ -218,7 +217,7 @@
context,
displayManager.getDisplay(DEFAULT_DISPLAY),
if (hostToken == null) null else InputTransferToken(hostToken),
- "KeyguardPreviewRenderer"
+ "KeyguardPreviewRenderer",
)
disposables += DisposableHandle { host.release() }
}
@@ -247,12 +246,12 @@
rootView.measure(
View.MeasureSpec.makeMeasureSpec(
displayInfo?.logicalWidth ?: windowManager.currentWindowMetrics.bounds.width(),
- View.MeasureSpec.EXACTLY
+ View.MeasureSpec.EXACTLY,
),
View.MeasureSpec.makeMeasureSpec(
displayInfo?.logicalHeight
?: windowManager.currentWindowMetrics.bounds.height(),
- View.MeasureSpec.EXACTLY
+ View.MeasureSpec.EXACTLY,
),
)
rootView.layout(0, 0, rootView.measuredWidth, rootView.measuredHeight)
@@ -278,9 +277,7 @@
}
}
- fun onStartCustomizingQuickAffordances(
- initiallySelectedSlotId: String?,
- ) {
+ fun onStartCustomizingQuickAffordances(initiallySelectedSlotId: String?) {
quickAffordancesCombinedViewModel.enablePreviewMode(
initiallySelectedSlotId = initiallySelectedSlotId,
shouldHighlightSelectedAffordance = true,
@@ -379,15 +376,9 @@
@Deprecated("Deprecated as part of b/278057014")
private fun setUpBottomArea(parentView: ViewGroup) {
val bottomAreaView =
- LayoutInflater.from(context)
- .inflate(
- R.layout.keyguard_bottom_area,
- parentView,
- false,
- ) as KeyguardBottomAreaView
- bottomAreaView.init(
- viewModel = bottomAreaViewModel,
- )
+ LayoutInflater.from(context).inflate(R.layout.keyguard_bottom_area, parentView, false)
+ as KeyguardBottomAreaView
+ bottomAreaView.init(viewModel = bottomAreaViewModel)
parentView.addView(
bottomAreaView,
FrameLayout.LayoutParams(
@@ -433,7 +424,7 @@
setUpUdfps(
previewContext,
- if (MigrateClocksToBlueprint.isEnabled) keyguardRootView else rootView
+ if (MigrateClocksToBlueprint.isEnabled) keyguardRootView else rootView,
)
if (KeyguardBottomAreaRefactor.isEnabled) {
@@ -466,7 +457,7 @@
previewContext,
it,
previewInSplitShade(),
- smartspaceViewModel
+ smartspaceViewModel,
)
}
setupCommunalTutorialIndicator(keyguardRootView)
@@ -515,23 +506,20 @@
val finger =
LayoutInflater.from(previewContext)
- .inflate(
- R.layout.udfps_keyguard_preview,
- parentView,
- false,
- ) as View
+ .inflate(R.layout.udfps_keyguard_preview, parentView, false) as View
// Place the UDFPS view in the proper sensor location
if (MigrateClocksToBlueprint.isEnabled) {
- finger.id = R.id.lock_icon_view
+ val lockId = KeyguardPreviewClockViewBinder.lockId
+ finger.id = lockId
parentView.addView(finger)
val cs = ConstraintSet()
cs.clone(parentView as ConstraintLayout)
cs.apply {
- constrainWidth(R.id.lock_icon_view, sensorBounds.width())
- constrainHeight(R.id.lock_icon_view, sensorBounds.height())
- connect(R.id.lock_icon_view, TOP, PARENT_ID, TOP, sensorBounds.top)
- connect(R.id.lock_icon_view, START, PARENT_ID, START, sensorBounds.left)
+ constrainWidth(lockId, sensorBounds.width())
+ constrainHeight(lockId, sensorBounds.height())
+ connect(lockId, TOP, PARENT_ID, TOP, sensorBounds.top)
+ connect(lockId, START, PARENT_ID, START, sensorBounds.left)
}
cs.applyTo(parentView)
} else {
@@ -541,7 +529,7 @@
sensorBounds.left,
sensorBounds.top,
sensorBounds.right,
- sensorBounds.bottom
+ sensorBounds.bottom,
)
parentView.addView(finger, fingerprintLayoutParams)
}
@@ -565,7 +553,7 @@
FrameLayout.LayoutParams.WRAP_CONTENT,
resources.getDimensionPixelSize(
com.android.systemui.customization.R.dimen.small_clock_height
- )
+ ),
)
layoutParams.topMargin =
SystemBarUtils.getStatusBarHeight(previewContext) +
@@ -579,7 +567,7 @@
),
/* top = */ 0,
/* end = */ 0,
- /* bottom = */ 0
+ /* bottom = */ 0,
)
smallClockHostView.clipChildren = false
parentView.addView(smallClockHostView)
@@ -703,9 +691,7 @@
private suspend fun fetchThemeStyleFromSetting(): Style {
val overlayPackageJson =
withContext(backgroundDispatcher) {
- secureSettings.getString(
- Settings.Secure.THEME_CUSTOMIZATION_OVERLAY_PACKAGES,
- )
+ secureSettings.getString(Settings.Secure.THEME_CUSTOMIZATION_OVERLAY_PACKAGES)
}
return if (!overlayPackageJson.isNullOrEmpty()) {
try {
diff --git a/ravenwood/Android.bp b/ravenwood/Android.bp
index 8896d77..bfa801f 100644
--- a/ravenwood/Android.bp
+++ b/ravenwood/Android.bp
@@ -8,7 +8,7 @@
// OWNER: g/ravenwood
// Bug component: 25698
- default_team: "trendy_team_framework_backstage_power",
+ default_team: "trendy_team_ravenwood",
}
filegroup {
diff --git a/ravenwood/junit-impl-src/android/platform/test/ravenwood/RavenwoodRuntimeEnvironmentController.java b/ravenwood/junit-impl-src/android/platform/test/ravenwood/RavenwoodRuntimeEnvironmentController.java
index 908e590..5894476 100644
--- a/ravenwood/junit-impl-src/android/platform/test/ravenwood/RavenwoodRuntimeEnvironmentController.java
+++ b/ravenwood/junit-impl-src/android/platform/test/ravenwood/RavenwoodRuntimeEnvironmentController.java
@@ -335,7 +335,11 @@
}
android.os.Process.reset$ravenwood();
- ResourcesManager.setInstance(null); // Better structure needed.
+ try {
+ ResourcesManager.setInstance(null); // Better structure needed.
+ } catch (Exception e) {
+ // AOSP-CHANGE: AOSP doesn't support resources yet.
+ }
if (ENABLE_UNCAUGHT_EXCEPTION_DETECTION) {
maybeThrowPendingUncaughtException(true);
diff --git a/services/contentsuggestions/java/com/android/server/contentsuggestions/ContentSuggestionsManagerService.java b/services/contentsuggestions/java/com/android/server/contentsuggestions/ContentSuggestionsManagerService.java
index 57c643b..a7aab49 100644
--- a/services/contentsuggestions/java/com/android/server/contentsuggestions/ContentSuggestionsManagerService.java
+++ b/services/contentsuggestions/java/com/android/server/contentsuggestions/ContentSuggestionsManagerService.java
@@ -160,11 +160,13 @@
HardwareBuffer snapshotBuffer = null;
int colorSpaceId = 0;
+ TaskSnapshot snapshot = null;
// Skip taking TaskSnapshot when bitmap is provided.
if (!imageContextRequestExtras.containsKey(ContentSuggestionsManager.EXTRA_BITMAP)) {
// Can block, so call before acquiring the lock.
- TaskSnapshot snapshot =
- mActivityTaskManagerInternal.getTaskSnapshotBlocking(taskId, false);
+ snapshot = mActivityTaskManagerInternal.getTaskSnapshotBlocking(
+ taskId, false /* isLowResolution */,
+ TaskSnapshot.REFERENCE_CONTENT_SUGGESTION);
if (snapshot != null) {
snapshotBuffer = snapshot.getHardwareBuffer();
ColorSpace colorSpace = snapshot.getColorSpace();
@@ -185,6 +187,9 @@
}
}
}
+ if (snapshot != null) {
+ snapshot.removeReference(TaskSnapshot.REFERENCE_CONTENT_SUGGESTION);
+ }
}
@Override
diff --git a/services/core/java/com/android/server/BinaryTransparencyService.java b/services/core/java/com/android/server/BinaryTransparencyService.java
index 05d07ae..485bf31 100644
--- a/services/core/java/com/android/server/BinaryTransparencyService.java
+++ b/services/core/java/com/android/server/BinaryTransparencyService.java
@@ -1523,7 +1523,7 @@
@Override
public void onApexStaged(ApexStagedEvent event) throws RemoteException {
Slog.d(TAG, "A new APEX has been staged for update. There are currently "
- + event.stagedApexModuleNames.length + " APEX(s) staged for update. "
+ + event.stagedApexInfos.length + " APEX(s) staged for update. "
+ "Scheduling measurement...");
UpdateMeasurementsJobService.scheduleBinaryMeasurements(mContext,
BinaryTransparencyService.this);
diff --git a/services/core/java/com/android/server/audio/AudioService.java b/services/core/java/com/android/server/audio/AudioService.java
index 020cef1..37a2fba 100644
--- a/services/core/java/com/android/server/audio/AudioService.java
+++ b/services/core/java/com/android/server/audio/AudioService.java
@@ -69,6 +69,7 @@
import static com.android.media.audio.Flags.equalScoLeaVcIndexRange;
import static com.android.media.audio.Flags.replaceStreamBtSco;
import static com.android.media.audio.Flags.ringerModeAffectsAlarm;
+import static com.android.media.audio.Flags.ringMyCar;
import static com.android.media.audio.Flags.setStreamVolumeOrder;
import static com.android.media.audio.Flags.vgsVssSyncMuteOrder;
import static com.android.server.audio.SoundDoseHelper.ACTION_CHECK_MUSIC_ACTIVE;
@@ -761,7 +762,7 @@
/** Streams that can be muted by system. Do not resolve to aliases when checking.
* @see System#MUTE_STREAMS_AFFECTED */
- private int mMuteAffectedStreams;
+ protected int mMuteAffectedStreams;
/** Streams that can be muted by user. Do not resolve to aliases when checking.
* @see System#MUTE_STREAMS_AFFECTED */
@@ -1465,7 +1466,8 @@
mPlaybackMonitor =
new PlaybackActivityMonitor(context, MAX_STREAM_VOLUME[AudioSystem.STREAM_ALARM],
- device -> onMuteAwaitConnectionTimeout(device));
+ device -> onMuteAwaitConnectionTimeout(device),
+ stream -> isStreamMute(stream));
mPlaybackMonitor.registerPlaybackCallback(mPlaybackActivityMonitor, true);
mMediaFocusControl = new MediaFocusControl(mContext, mPlaybackMonitor);
@@ -4846,6 +4848,8 @@
+ replaceStreamBtSco());
pw.println("\tcom.android.media.audio.equalScoLeaVcIndexRange:"
+ equalScoLeaVcIndexRange());
+ pw.println("\tcom.android.media.audio.ringMyCar:"
+ + ringMyCar());
}
private void dumpAudioMode(PrintWriter pw) {
@@ -8695,9 +8699,14 @@
// Only set audio policy BT SCO stream volume to 0 when the stream is actually muted.
// This allows RX path muting by the audio HAL only when explicitly muted but not when
// index is just set to 0 to repect BT requirements
+ boolean muted = false;
if (mHasValidStreamType && isVssMuteBijective(mPublicStreamType)
&& getVssForStreamOrDefault(mPublicStreamType).isFullyMuted()) {
- index = 0;
+ if (ringMyCar()) {
+ muted = true;
+ } else {
+ index = 0;
+ }
} else if (isStreamBluetoothSco(mPublicStreamType) && index == 0) {
index = 1;
}
@@ -8707,13 +8716,14 @@
/ getVssForStreamOrDefault(mPublicStreamType).getIndexStepFactor());
}
+
if (DEBUG_VOL) {
Log.d(TAG, "setVolumeIndexInt(" + mAudioVolumeGroup.getId() + ", " + index + ", "
- + device + ")");
+ + muted + ", " + device + ")");
}
// Set the volume index
- mAudioSystem.setVolumeIndexForAttributes(mAudioAttributes, index, device);
+ mAudioSystem.setVolumeIndexForAttributes(mAudioAttributes, index, muted, device);
}
@GuardedBy("AudioService.VolumeStreamState.class")
@@ -9297,6 +9307,13 @@
}
}
+ /**
+ * Sends the new volume index on the given device to native.
+ *
+ * <p>Make sure the index is consistent with the muting state. When ringMyCar is enabled
+ * will send the non-zero index together with muted state. Otherwise, index 0 will be sent
+ * to native for signalising a muted stream.
+ **/
@GuardedBy("VolumeStreamState.class")
private void setStreamVolumeIndex(int index, int device) {
// Only set audio policy BT SCO stream volume to 0 when the stream is actually muted.
@@ -9311,18 +9328,19 @@
/ 10;
}
+ boolean muted = ringMyCar() ? isFullyMuted() : false;
if (DEBUG_VOL) {
- Log.d(TAG, "setStreamVolumeIndexAS(" + mStreamType + ", " + index + ", " + device
- + ")");
+ Log.d(TAG, "setStreamVolumeIndexAS(streamType=" + mStreamType + ", index=" + index
+ + ", muted=" + muted + ", device=" + device + ")");
}
- mAudioSystem.setStreamVolumeIndexAS(mStreamType, index, device);
+ mAudioSystem.setStreamVolumeIndexAS(mStreamType, index, muted, device);
}
// must be called while synchronized VolumeStreamState.class
@GuardedBy("VolumeStreamState.class")
/*package*/ void applyDeviceVolume_syncVSS(int device) {
int index;
- if (isFullyMuted()) {
+ if (isFullyMuted() && !ringMyCar()) {
index = 0;
} else if (isAbsoluteVolumeDevice(device)
|| isA2dpAbsoluteVolumeDevice(device)
@@ -9356,7 +9374,7 @@
for (int i = 0; i < mIndexMap.size(); i++) {
final int device = mIndexMap.keyAt(i);
if (device != AudioSystem.DEVICE_OUT_DEFAULT) {
- if (isFullyMuted()) {
+ if (isFullyMuted() && !ringMyCar()) {
index = 0;
} else if (isAbsoluteVolumeDevice(device)
|| isA2dpAbsoluteVolumeDevice(device)
@@ -9391,7 +9409,7 @@
}
// apply default volume last: by convention , default device volume will be used
// by audio policy manager if no explicit volume is present for a given device type
- if (isFullyMuted()) {
+ if (isFullyMuted() && !ringMyCar()) {
index = 0;
} else {
index = (getIndex(AudioSystem.DEVICE_OUT_DEFAULT) + 5)/10;
diff --git a/services/core/java/com/android/server/audio/AudioSystemAdapter.java b/services/core/java/com/android/server/audio/AudioSystemAdapter.java
index 5cabdde..e86c34c 100644
--- a/services/core/java/com/android/server/audio/AudioSystemAdapter.java
+++ b/services/core/java/com/android/server/audio/AudioSystemAdapter.java
@@ -547,13 +547,14 @@
* @param device
* @return
*/
- public int setStreamVolumeIndexAS(int stream, int index, int device) {
- return AudioSystem.setStreamVolumeIndexAS(stream, index, device);
+ public int setStreamVolumeIndexAS(int stream, int index, boolean muted, int device) {
+ return AudioSystem.setStreamVolumeIndexAS(stream, index, muted, device);
}
/** Same as {@link AudioSystem#setVolumeIndexForAttributes(AudioAttributes, int, int)} */
- public int setVolumeIndexForAttributes(AudioAttributes attributes, int index, int device) {
- return AudioSystem.setVolumeIndexForAttributes(attributes, index, device);
+ public int setVolumeIndexForAttributes(AudioAttributes attributes, int index, boolean muted,
+ int device) {
+ return AudioSystem.setVolumeIndexForAttributes(attributes, index, muted, device);
}
/**
diff --git a/services/core/java/com/android/server/audio/PlaybackActivityMonitor.java b/services/core/java/com/android/server/audio/PlaybackActivityMonitor.java
index a734e73..b63b07f 100644
--- a/services/core/java/com/android/server/audio/PlaybackActivityMonitor.java
+++ b/services/core/java/com/android/server/audio/PlaybackActivityMonitor.java
@@ -72,6 +72,7 @@
import java.util.Set;
import java.util.concurrent.ConcurrentLinkedQueue;
import java.util.function.Consumer;
+import java.util.function.Function;
/**
* Class to receive and dispatch updates from AudioSystem about recording configurations.
@@ -160,18 +161,22 @@
private final Context mContext;
private int mSavedAlarmVolume = -1;
+ private boolean mSavedAlarmMuted = false;
+ private final Function<Integer, Boolean> mIsStreamMutedCb;
private final int mMaxAlarmVolume;
private int mPrivilegedAlarmActiveCount = 0;
private final Consumer<AudioDeviceAttributes> mMuteAwaitConnectionTimeoutCb;
private final FadeOutManager mFadeOutManager = new FadeOutManager();
PlaybackActivityMonitor(Context context, int maxAlarmVolume,
- Consumer<AudioDeviceAttributes> muteTimeoutCallback) {
+ Consumer<AudioDeviceAttributes> muteTimeoutCallback,
+ Function<Integer, Boolean> isStreamMutedCb) {
mContext = context;
mMaxAlarmVolume = maxAlarmVolume;
PlayMonitorClient.sListenerDeathMonitor = this;
AudioPlaybackConfiguration.sPlayerDeathMonitor = this;
mMuteAwaitConnectionTimeoutCb = muteTimeoutCallback;
+ mIsStreamMutedCb = isStreamMutedCb;
initEventHandler();
}
@@ -332,8 +337,9 @@
if (mPrivilegedAlarmActiveCount++ == 0) {
mSavedAlarmVolume = AudioSystem.getStreamVolumeIndex(
AudioSystem.STREAM_ALARM, AudioSystem.DEVICE_OUT_SPEAKER);
+ mSavedAlarmMuted = mIsStreamMutedCb.apply(AudioSystem.STREAM_ALARM);
AudioSystem.setStreamVolumeIndexAS(AudioSystem.STREAM_ALARM,
- mMaxAlarmVolume, AudioSystem.DEVICE_OUT_SPEAKER);
+ mMaxAlarmVolume, /*muted=*/false, AudioSystem.DEVICE_OUT_SPEAKER);
}
} else if (event != AudioPlaybackConfiguration.PLAYER_STATE_STARTED &&
apc.getPlayerState() == AudioPlaybackConfiguration.PLAYER_STATE_STARTED) {
@@ -342,7 +348,8 @@
AudioSystem.STREAM_ALARM, AudioSystem.DEVICE_OUT_SPEAKER) ==
mMaxAlarmVolume) {
AudioSystem.setStreamVolumeIndexAS(AudioSystem.STREAM_ALARM,
- mSavedAlarmVolume, AudioSystem.DEVICE_OUT_SPEAKER);
+ mSavedAlarmVolume, mSavedAlarmMuted,
+ AudioSystem.DEVICE_OUT_SPEAKER);
}
}
}
diff --git a/services/core/java/com/android/server/notification/NotificationRecord.java b/services/core/java/com/android/server/notification/NotificationRecord.java
index 3ba9384..93f512b 100644
--- a/services/core/java/com/android/server/notification/NotificationRecord.java
+++ b/services/core/java/com/android/server/notification/NotificationRecord.java
@@ -334,7 +334,7 @@
return helper.createWaveformVibration(vibrationPattern, insistent);
}
- if (com.android.server.notification.Flags.notificationVibrationInSoundUri()) {
+ if (com.android.server.notification.Flags.notificationVibrationInSoundUriForChannel()) {
final VibrationEffect vibrationEffectFromSoundUri =
helper.createVibrationEffectFromSoundUri(channel.getSound());
if (vibrationEffectFromSoundUri != null) {
diff --git a/services/core/java/com/android/server/pm/DexOptHelper.java b/services/core/java/com/android/server/pm/DexOptHelper.java
index 02afdd6..9e8598a 100644
--- a/services/core/java/com/android/server/pm/DexOptHelper.java
+++ b/services/core/java/com/android/server/pm/DexOptHelper.java
@@ -89,6 +89,7 @@
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.Comparator;
@@ -893,7 +894,8 @@
@Override
public void onApexStaged(@NonNull ApexStagedEvent event) {
- mArtManager.onApexStaged(event.stagedApexModuleNames);
+ mArtManager.onApexStaged(Arrays.stream(event.stagedApexInfos)
+ .map(info -> info.moduleName).toArray(String[]::new));
}
}
}
diff --git a/services/core/java/com/android/server/pm/PackageManagerNative.java b/services/core/java/com/android/server/pm/PackageManagerNative.java
index 66ecd6e..7d8573e 100644
--- a/services/core/java/com/android/server/pm/PackageManagerNative.java
+++ b/services/core/java/com/android/server/pm/PackageManagerNative.java
@@ -20,7 +20,6 @@
import static com.android.server.pm.PackageManagerService.TAG;
-import android.annotation.Nullable;
import android.content.pm.ApplicationInfo;
import android.content.pm.IPackageManagerNative;
import android.content.pm.IStagedApexObserver;
@@ -184,14 +183,8 @@
}
@Override
- public String[] getStagedApexModuleNames() {
- return mPm.mInstallerService.getStagingManager()
- .getStagedApexModuleNames().toArray(new String[0]);
- }
-
- @Override
- @Nullable
- public StagedApexInfo getStagedApexInfo(String moduleName) {
- return mPm.mInstallerService.getStagingManager().getStagedApexInfo(moduleName);
+ public StagedApexInfo[] getStagedApexInfos() {
+ return mPm.mInstallerService.getStagingManager().getStagedApexInfos().toArray(
+ new StagedApexInfo[0]);
}
}
diff --git a/services/core/java/com/android/server/pm/StagingManager.java b/services/core/java/com/android/server/pm/StagingManager.java
index 94bdfbd..38cf0b9 100644
--- a/services/core/java/com/android/server/pm/StagingManager.java
+++ b/services/core/java/com/android/server/pm/StagingManager.java
@@ -17,7 +17,6 @@
package com.android.server.pm;
import android.annotation.NonNull;
-import android.annotation.Nullable;
import android.apex.ApexInfo;
import android.apex.ApexSessionInfo;
import android.apex.ApexSessionParams;
@@ -38,7 +37,6 @@
import android.os.Trace;
import android.os.UserHandle;
import android.text.TextUtils;
-import android.util.ArrayMap;
import android.util.ArraySet;
import android.util.IntArray;
import android.util.Slog;
@@ -65,9 +63,9 @@
import java.io.FileReader;
import java.io.FileWriter;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.Collections;
import java.util.List;
-import java.util.Map;
import java.util.Set;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutionException;
@@ -807,14 +805,13 @@
}
/**
- * Returns ApexInfo about APEX contained inside the session as a {@code Map<String, ApexInfo>},
- * where the key of the map is the module name of the ApexInfo.
+ * Returns ApexInfo about APEX contained inside the session.
*
- * Returns an empty map if there is any error.
+ * Returns an empty list if there is any error.
*/
@VisibleForTesting
@NonNull
- Map<String, ApexInfo> getStagedApexInfos(@NonNull StagedSession session) {
+ List<ApexInfo> getStagedApexInfos(@NonNull StagedSession session) {
Preconditions.checkArgument(session != null, "Session is null");
Preconditions.checkArgument(!session.hasParentSessionId(),
session.sessionId() + " session has parent session");
@@ -824,7 +821,7 @@
// Even if caller calls this method on ready session, the session could be abandoned
// right after this method is called.
if (!session.isSessionReady() || session.isDestroyed()) {
- return Collections.emptyMap();
+ return Collections.emptyList();
}
ApexSessionParams params = new ApexSessionParams();
@@ -838,20 +835,17 @@
}
}
params.childSessionIds = childSessionIds.toArray();
-
- ApexInfo[] infos = mApexManager.getStagedApexInfos(params);
- Map<String, ApexInfo> result = new ArrayMap<>();
- for (ApexInfo info : infos) {
- result.put(info.moduleName, info);
- }
- return result;
+ return Arrays.asList(mApexManager.getStagedApexInfos(params));
}
/**
- * Returns apex module names of all packages that are staged ready
+ * Returns ApexInfo list about APEXes contained inside all staged sessions.
+ *
+ * Returns an empty list if there is any error.
*/
- List<String> getStagedApexModuleNames() {
- List<String> result = new ArrayList<>();
+ @NonNull
+ List<StagedApexInfo> getStagedApexInfos() {
+ List<StagedApexInfo> result = new ArrayList<>();
synchronized (mStagedSessions) {
for (int i = 0; i < mStagedSessions.size(); i++) {
final StagedSession session = mStagedSessions.valueAt(i);
@@ -859,26 +853,7 @@
|| session.hasParentSessionId() || !session.containsApexSession()) {
continue;
}
- result.addAll(getStagedApexInfos(session).keySet());
- }
- }
- return result;
- }
-
- /**
- * Returns ApexInfo of the {@code moduleInfo} provided if it is staged, otherwise returns null.
- */
- @Nullable
- StagedApexInfo getStagedApexInfo(String moduleName) {
- synchronized (mStagedSessions) {
- for (int i = 0; i < mStagedSessions.size(); i++) {
- final StagedSession session = mStagedSessions.valueAt(i);
- if (!session.isSessionReady() || session.isDestroyed()
- || session.hasParentSessionId() || !session.containsApexSession()) {
- continue;
- }
- ApexInfo ai = getStagedApexInfos(session).get(moduleName);
- if (ai != null) {
+ getStagedApexInfos(session).stream().map(ai -> {
StagedApexInfo info = new StagedApexInfo();
info.moduleName = ai.moduleName;
info.diskImagePath = ai.modulePath;
@@ -886,17 +861,19 @@
info.versionName = ai.versionName;
info.hasClassPathJars = ai.hasClassPathJars;
return info;
- }
+ }).forEach(result::add);
}
}
- return null;
+ return result;
}
private void notifyStagedApexObservers() {
synchronized (mStagedApexObservers) {
+ List<StagedApexInfo> stagedApexInfos = getStagedApexInfos();
+ ApexStagedEvent event = new ApexStagedEvent();
+ event.stagedApexInfos =
+ stagedApexInfos.toArray(new StagedApexInfo[stagedApexInfos.size()]);
for (IStagedApexObserver observer : mStagedApexObservers) {
- ApexStagedEvent event = new ApexStagedEvent();
- event.stagedApexModuleNames = getStagedApexModuleNames().toArray(new String[0]);
try {
observer.onApexStaged(event);
} catch (RemoteException re) {
diff --git a/services/core/java/com/android/server/wm/ActivityRecord.java b/services/core/java/com/android/server/wm/ActivityRecord.java
index a44eb48..460de01 100644
--- a/services/core/java/com/android/server/wm/ActivityRecord.java
+++ b/services/core/java/com/android/server/wm/ActivityRecord.java
@@ -285,9 +285,6 @@
import android.app.servertransaction.TopResumedActivityChangeItem;
import android.app.servertransaction.TransferSplashScreenViewStateItem;
import android.app.usage.UsageEvents.Event;
-import android.compat.annotation.ChangeId;
-import android.compat.annotation.EnabledAfter;
-import android.compat.annotation.Overridable;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
@@ -467,11 +464,6 @@
// finished destroying itself.
private static final int DESTROY_TIMEOUT = 10 * 1000;
- @ChangeId
- @Overridable
- @EnabledAfter(targetSdkVersion = Build.VERSION_CODES.VANILLA_ICE_CREAM)
- static final long UNIVERSAL_RESIZABLE_BY_DEFAULT = 357141415;
-
final ActivityTaskManagerService mAtmService;
final ActivityCallerState mCallerState;
@NonNull
@@ -3192,7 +3184,7 @@
&& mDisplayContent != null && mDisplayContent.getConfiguration()
.smallestScreenWidthDp >= WindowManager.LARGE_SCREEN_SMALLEST_SCREEN_WIDTH_DP
&& mDisplayContent.getIgnoreOrientationRequest()
- && info.isChangeEnabled(UNIVERSAL_RESIZABLE_BY_DEFAULT);
+ && info.isChangeEnabled(ActivityInfo.UNIVERSAL_RESIZABLE_BY_DEFAULT);
if (!compatEnabled && !mWmService.mConstants.mIgnoreActivityOrientationRequest) {
return false;
}
diff --git a/services/core/java/com/android/server/wm/ActivityStarter.java b/services/core/java/com/android/server/wm/ActivityStarter.java
index 5b5bb88..87fa62a 100644
--- a/services/core/java/com/android/server/wm/ActivityStarter.java
+++ b/services/core/java/com/android/server/wm/ActivityStarter.java
@@ -86,7 +86,6 @@
import static com.android.server.wm.TaskFragment.EMBEDDING_DISALLOWED_NEW_TASK;
import static com.android.server.wm.TaskFragment.EMBEDDING_DISALLOWED_UNTRUSTED_HOST;
import static com.android.server.wm.WindowContainer.POSITION_TOP;
-import static com.android.server.wm.WindowManagerDebugConfig.TAG_WM;
import static com.android.window.flags.Flags.balDontBringExistingBackgroundTaskStackToFg;
import android.annotation.IntDef;
@@ -2787,22 +2786,10 @@
}
}
- if ((mLaunchFlags & FLAG_ACTIVITY_LAUNCH_ADJACENT) != 0) {
- final boolean hasNewTaskFlag = (mLaunchFlags & FLAG_ACTIVITY_NEW_TASK) != 0;
- if (!hasNewTaskFlag || mSourceRecord == null) {
- // ignore the flag if there is no the sourceRecord or without new_task flag
- Slog.w(TAG_WM, !hasNewTaskFlag
- ? "Launch adjacent ignored due to missing NEW_TASK"
- : "Launch adjacent ignored due to missing source activity");
- mLaunchFlags &= ~FLAG_ACTIVITY_LAUNCH_ADJACENT;
- }
- // Ensure that the source task or its parents has not disabled launch-adjacent
- if (mSourceRecord != null && mSourceRecord.getTask() != null &&
- mSourceRecord.getTask().isLaunchAdjacentDisabled()) {
- Slog.w(TAG_WM, "Launch adjacent blocked by source task or ancestor");
- mLaunchFlags &= ~FLAG_ACTIVITY_LAUNCH_ADJACENT;
- }
-
+ if ((mLaunchFlags & FLAG_ACTIVITY_LAUNCH_ADJACENT) != 0
+ && ((mLaunchFlags & FLAG_ACTIVITY_NEW_TASK) == 0 || mSourceRecord == null)) {
+ // ignore the flag if there is no the sourceRecord or without new_task flag
+ mLaunchFlags &= ~FLAG_ACTIVITY_LAUNCH_ADJACENT;
}
}
diff --git a/services/core/java/com/android/server/wm/ActivityTaskManagerInternal.java b/services/core/java/com/android/server/wm/ActivityTaskManagerInternal.java
index 3d6b64b..3560565 100644
--- a/services/core/java/com/android/server/wm/ActivityTaskManagerInternal.java
+++ b/services/core/java/com/android/server/wm/ActivityTaskManagerInternal.java
@@ -589,7 +589,7 @@
* sensitive environment.
*/
public abstract TaskSnapshot getTaskSnapshotBlocking(int taskId,
- boolean isLowResolution);
+ boolean isLowResolution, @TaskSnapshot.ReferenceFlags int usage);
/** Returns true if uid is considered foreground for activity start purposes. */
public abstract boolean isUidForeground(int uid);
diff --git a/services/core/java/com/android/server/wm/ActivityTaskManagerService.java b/services/core/java/com/android/server/wm/ActivityTaskManagerService.java
index 3dfc8f4..4db478a 100644
--- a/services/core/java/com/android/server/wm/ActivityTaskManagerService.java
+++ b/services/core/java/com/android/server/wm/ActivityTaskManagerService.java
@@ -3946,6 +3946,28 @@
}
}
+ private TaskSnapshot getTaskSnapshotInner(int taskId, boolean isLowResolution,
+ @TaskSnapshot.ReferenceFlags int usage) {
+ final Task task;
+ synchronized (mGlobalLock) {
+ task = mRootWindowContainer.anyTaskForId(taskId, MATCH_ATTACHED_TASK_OR_RECENT_TASKS);
+ if (task == null) {
+ Slog.w(TAG, "getTaskSnapshot: taskId=" + taskId + " not found");
+ return null;
+ }
+ // Try to load snapshot from cache first, and add reference if the snapshot is in cache.
+ final TaskSnapshot snapshot = mWindowManager.mTaskSnapshotController.getSnapshot(taskId,
+ task.mUserId, false /* restoreFromDisk */, isLowResolution);
+ if (snapshot != null) {
+ snapshot.addReference(usage);
+ return snapshot;
+ }
+ }
+ // Don't call this while holding the lock as this operation might hit the disk.
+ return mWindowManager.mTaskSnapshotController.getSnapshot(taskId,
+ task.mUserId, true /* restoreFromDisk */, isLowResolution);
+ }
+
@Override
public TaskSnapshot getTaskSnapshot(int taskId, boolean isLowResolution) {
mAmInternal.enforceCallingPermission(READ_FRAME_BUFFER, "getTaskSnapshot()");
@@ -7274,8 +7296,9 @@
@Override
public TaskSnapshot getTaskSnapshotBlocking(
- int taskId, boolean isLowResolution) {
- return ActivityTaskManagerService.this.getTaskSnapshot(taskId, isLowResolution);
+ int taskId, boolean isLowResolution, @TaskSnapshot.ReferenceFlags int usage) {
+ return ActivityTaskManagerService.this.getTaskSnapshotInner(
+ taskId, isLowResolution, usage);
}
@Override
diff --git a/services/core/java/com/android/server/wm/Task.java b/services/core/java/com/android/server/wm/Task.java
index a4e4deb..00704b3 100644
--- a/services/core/java/com/android/server/wm/Task.java
+++ b/services/core/java/com/android/server/wm/Task.java
@@ -503,11 +503,6 @@
boolean mIsTrimmableFromRecents;
/**
- * Sets whether the launch-adjacent flag is respected or not for this task or its child tasks.
- */
- private boolean mLaunchAdjacentDisabled;
-
- /**
* Bounds offset should be applied when calculating compatible configuration for apps targeting
* SDK level 34 or before.
*/
@@ -3807,9 +3802,6 @@
pw.print(prefix); pw.print("lastActiveTime="); pw.print(lastActiveTime);
pw.println(" (inactive for " + (getInactiveDuration() / 1000) + "s)");
pw.print(prefix); pw.println(" isTrimmable=" + mIsTrimmableFromRecents);
- if (mLaunchAdjacentDisabled) {
- pw.println(prefix + "mLaunchAdjacentDisabled=true");
- }
}
@Override
@@ -6282,28 +6274,6 @@
}
/**
- * Sets this task and its children to disable respecting launch-adjacent.
- */
- void setLaunchAdjacentDisabled(boolean disabled) {
- mLaunchAdjacentDisabled = disabled;
- }
-
- /**
- * Returns whether this task or any of its ancestors have disabled respecting the
- * launch-adjacent flag.
- */
- boolean isLaunchAdjacentDisabled() {
- Task t = this;
- while (t != null) {
- if (t.mLaunchAdjacentDisabled) {
- return true;
- }
- t = t.getParent().asTask();
- }
- return false;
- }
-
- /**
* Return true if the activityInfo has the same requiredDisplayCategory as this task.
*/
boolean isSameRequiredDisplayCategory(@NonNull ActivityInfo info) {
diff --git a/services/core/java/com/android/server/wm/TaskDisplayArea.java b/services/core/java/com/android/server/wm/TaskDisplayArea.java
index 2c71c1a..5dd3bbc 100644
--- a/services/core/java/com/android/server/wm/TaskDisplayArea.java
+++ b/services/core/java/com/android/server/wm/TaskDisplayArea.java
@@ -1074,8 +1074,6 @@
final Task launchRootTask = Task.fromWindowContainerToken(options.getLaunchRootTask());
// We only allow this for created by organizer tasks.
if (launchRootTask != null && launchRootTask.mCreatedByOrganizer) {
- Slog.i(TAG_WM, "Using launch root task from activity options: taskId="
- + launchRootTask.mTaskId);
return launchRootTask;
}
}
@@ -1083,25 +1081,19 @@
// Use launch-adjacent-flag-root if launching with launch-adjacent flag.
if ((launchFlags & FLAG_ACTIVITY_LAUNCH_ADJACENT) != 0
&& mLaunchAdjacentFlagRootTask != null) {
- final Task launchAdjacentRootAdjacentTask =
- mLaunchAdjacentFlagRootTask.getAdjacentTask();
if (sourceTask != null && (sourceTask == candidateTask
|| sourceTask.topRunningActivity() == null)) {
// Do nothing when task that is getting opened is same as the source or when
// the source is no-longer valid.
Slog.w(TAG_WM, "Ignoring LAUNCH_ADJACENT because adjacent source is gone.");
} else if (sourceTask != null
- && launchAdjacentRootAdjacentTask != null
+ && mLaunchAdjacentFlagRootTask.getAdjacentTask() != null
&& (sourceTask == mLaunchAdjacentFlagRootTask
|| sourceTask.isDescendantOf(mLaunchAdjacentFlagRootTask))) {
- // If the adjacent launch is coming from the same root that was specified as the
- // launch-adjacent task, so instead we launch to its adjacent root instead.
- Slog.i(TAG_WM, "Using adjacent-to specified launch-adjacent task: taskId="
- + launchAdjacentRootAdjacentTask.mTaskId);
- return launchAdjacentRootAdjacentTask;
+ // If the adjacent launch is coming from the same root, launch to
+ // adjacent root instead.
+ return mLaunchAdjacentFlagRootTask.getAdjacentTask();
} else {
- Slog.i(TAG_WM, "Using specified launch-adjacent task: taskId="
- + mLaunchAdjacentFlagRootTask.mTaskId);
return mLaunchAdjacentFlagRootTask;
}
}
diff --git a/services/core/java/com/android/server/wm/WindowOrganizerController.java b/services/core/java/com/android/server/wm/WindowOrganizerController.java
index 166d74b..82c7a93 100644
--- a/services/core/java/com/android/server/wm/WindowOrganizerController.java
+++ b/services/core/java/com/android/server/wm/WindowOrganizerController.java
@@ -69,7 +69,6 @@
import static android.window.WindowContainerTransaction.HierarchyOp.HIERARCHY_OP_TYPE_SET_ADJACENT_ROOTS;
import static android.window.WindowContainerTransaction.HierarchyOp.HIERARCHY_OP_TYPE_SET_ALWAYS_ON_TOP;
import static android.window.WindowContainerTransaction.HierarchyOp.HIERARCHY_OP_TYPE_SET_EXCLUDE_INSETS_TYPES;
-import static android.window.WindowContainerTransaction.HierarchyOp.HIERARCHY_OP_TYPE_SET_DISABLE_LAUNCH_ADJACENT;
import static android.window.WindowContainerTransaction.HierarchyOp.HIERARCHY_OP_TYPE_SET_IS_TRIMMABLE;
import static android.window.WindowContainerTransaction.HierarchyOp.HIERARCHY_OP_TYPE_SET_LAUNCH_ADJACENT_FLAG_ROOT;
import static android.window.WindowContainerTransaction.HierarchyOp.HIERARCHY_OP_TYPE_SET_LAUNCH_ROOT;
@@ -1451,17 +1450,6 @@
task.setTrimmableFromRecents(hop.isTrimmableFromRecents());
break;
}
- case HIERARCHY_OP_TYPE_SET_DISABLE_LAUNCH_ADJACENT: {
- final WindowContainer container = WindowContainer.fromBinder(hop.getContainer());
- final Task task = container != null ? container.asTask() : null;
- if (task == null || !task.isAttached()) {
- Slog.e(TAG, "Attempt to operate on unknown or detached container: "
- + container);
- break;
- }
- task.setLaunchAdjacentDisabled(hop.isLaunchAdjacentDisabled());
- break;
- }
case HIERARCHY_OP_TYPE_RESTORE_BACK_NAVIGATION: {
if (mService.mBackNavigationController.restoreBackNavigation()) {
effects |= TRANSACT_EFFECTS_LIFECYCLE;
diff --git a/services/tests/mockingservicestests/src/com/android/server/pm/StagingManagerTest.java b/services/tests/mockingservicestests/src/com/android/server/pm/StagingManagerTest.java
index 39acd8d..43a8aa9 100644
--- a/services/tests/mockingservicestests/src/com/android/server/pm/StagingManagerTest.java
+++ b/services/tests/mockingservicestests/src/com/android/server/pm/StagingManagerTest.java
@@ -72,7 +72,6 @@
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
-import java.util.Map;
import java.util.concurrent.CompletableFuture;
import java.util.function.Predicate;
@@ -486,7 +485,7 @@
FakeStagedSession session = new FakeStagedSession(239);
session.setIsApex(true);
// Call and verify
- Map<String, ApexInfo> result = mStagingManager.getStagedApexInfos(session);
+ var result = mStagingManager.getStagedApexInfos(session);
assertThat(result).isEmpty();
}
// Invalid session: destroyed
@@ -496,7 +495,7 @@
session.setIsApex(true);
session.setDestroyed(true);
// Call and verify
- Map<String, ApexInfo> result = mStagingManager.getStagedApexInfos(session);
+ var result = mStagingManager.getStagedApexInfos(session);
assertThat(result).isEmpty();
}
}
@@ -520,8 +519,8 @@
when(mApexManager.getStagedApexInfos(any())).thenReturn(fakeApexInfos);
// Call and verify
- Map<String, ApexInfo> result = mStagingManager.getStagedApexInfos(validSession);
- assertThat(result).containsExactly(fakeApexInfos[0].moduleName, fakeApexInfos[0]);
+ List<ApexInfo> result = mStagingManager.getStagedApexInfos(validSession);
+ assertThat(result).containsExactly(fakeApexInfos[0]);
ArgumentCaptor<ApexSessionParams> argumentCaptor =
ArgumentCaptor.forClass(ApexSessionParams.class);
@@ -544,9 +543,8 @@
when(mApexManager.getStagedApexInfos(any())).thenReturn(fakeApexInfos);
// Call and verify
- Map<String, ApexInfo> result = mStagingManager.getStagedApexInfos(parentSession);
- assertThat(result).containsExactly(fakeApexInfos[0].moduleName, fakeApexInfos[0],
- fakeApexInfos[1].moduleName, fakeApexInfos[1]);
+ List<ApexInfo> result = mStagingManager.getStagedApexInfos(parentSession);
+ assertThat(result).containsExactly(fakeApexInfos[0], fakeApexInfos[1]);
ArgumentCaptor<ApexSessionParams> argumentCaptor =
ArgumentCaptor.forClass(ApexSessionParams.class);
@@ -557,7 +555,7 @@
}
@Test
- public void getStagedApexModuleNames_returnsStagedApexModules() throws Exception {
+ public void getStagedApexInfos_returnsStagedApexModules() throws Exception {
FakeStagedSession validSession1 = new FakeStagedSession(239);
validSession1.setIsApex(true);
validSession1.setSessionReady();
@@ -575,8 +573,8 @@
mockApexManagerGetStagedApexInfoWithSessionId();
- List<String> result = mStagingManager.getStagedApexModuleNames();
- assertThat(result).containsExactly("239", "123", "124");
+ List<StagedApexInfo> result = mStagingManager.getStagedApexInfos();
+ assertThat(result).containsExactly((Object[]) fakeStagedApexInfos("239", "123", "124"));
verify(mApexManager, times(2)).getStagedApexInfos(any());
}
@@ -605,26 +603,12 @@
});
}
- @Test
- public void getStagedApexInfo() throws Exception {
- FakeStagedSession validSession1 = new FakeStagedSession(239);
- validSession1.setIsApex(true);
- validSession1.setSessionReady();
- mStagingManager.createSession(validSession1);
- ApexInfo[] fakeApexInfos = getFakeApexInfo(Arrays.asList("module1"));
- when(mApexManager.getStagedApexInfos(any())).thenReturn(fakeApexInfos);
-
- // Verify null is returned if module name is not found
- StagedApexInfo result = mStagingManager.getStagedApexInfo("not found");
- assertThat(result).isNull();
- verify(mApexManager, times(1)).getStagedApexInfos(any());
- // Otherwise, the correct object is returned
- result = mStagingManager.getStagedApexInfo("module1");
- assertThat(result.moduleName).isEqualTo(fakeApexInfos[0].moduleName);
- assertThat(result.diskImagePath).isEqualTo(fakeApexInfos[0].modulePath);
- assertThat(result.versionCode).isEqualTo(fakeApexInfos[0].versionCode);
- assertThat(result.versionName).isEqualTo(fakeApexInfos[0].versionName);
- verify(mApexManager, times(2)).getStagedApexInfos(any());
+ private StagedApexInfo[] fakeStagedApexInfos(String... moduleNames) {
+ return Arrays.stream(moduleNames).map(moduleName -> {
+ StagedApexInfo info = new StagedApexInfo();
+ info.moduleName = moduleName;
+ return info;
+ }).toArray(StagedApexInfo[]::new);
}
@Test
@@ -646,8 +630,8 @@
ArgumentCaptor<ApexStagedEvent> argumentCaptor = ArgumentCaptor.forClass(
ApexStagedEvent.class);
verify(observer, times(1)).onApexStaged(argumentCaptor.capture());
- assertThat(argumentCaptor.getValue().stagedApexModuleNames).isEqualTo(
- new String[]{"239"});
+ assertThat(argumentCaptor.getValue().stagedApexInfos).isEqualTo(
+ fakeStagedApexInfos("239"));
}
// Create another staged session and verify observers are notified of union
@@ -662,8 +646,8 @@
ArgumentCaptor<ApexStagedEvent> argumentCaptor = ArgumentCaptor.forClass(
ApexStagedEvent.class);
verify(observer, times(1)).onApexStaged(argumentCaptor.capture());
- assertThat(argumentCaptor.getValue().stagedApexModuleNames).isEqualTo(
- new String[]{"239", "240"});
+ assertThat(argumentCaptor.getValue().stagedApexInfos).isEqualTo(
+ fakeStagedApexInfos("239", "240"));
}
// Finally, verify that once unregistered, observer is not notified
@@ -699,7 +683,7 @@
ArgumentCaptor<ApexStagedEvent> argumentCaptor = ArgumentCaptor.forClass(
ApexStagedEvent.class);
verify(observer, times(1)).onApexStaged(argumentCaptor.capture());
- assertThat(argumentCaptor.getValue().stagedApexModuleNames).hasLength(0);
+ assertThat(argumentCaptor.getValue().stagedApexInfos).hasLength(0);
}
@Test
diff --git a/services/tests/servicestests/src/com/android/server/audio/AudioDeviceVolumeManagerTest.java b/services/tests/servicestests/src/com/android/server/audio/AudioDeviceVolumeManagerTest.java
index 3e2949d6..de5564c 100644
--- a/services/tests/servicestests/src/com/android/server/audio/AudioDeviceVolumeManagerTest.java
+++ b/services/tests/servicestests/src/com/android/server/audio/AudioDeviceVolumeManagerTest.java
@@ -20,6 +20,8 @@
import static com.android.media.audio.Flags.FLAG_DISABLE_PRESCALE_ABSOLUTE_VOLUME;
import static com.android.media.audio.Flags.absVolumeIndexFix;
+import static org.mockito.ArgumentMatchers.anyBoolean;
+import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.atLeast;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.spy;
@@ -109,12 +111,13 @@
mAudioService.setDeviceVolume(volMin, usbDevice, mPackageName);
mTestLooper.dispatchAll();
verify(mSpyAudioSystem, atLeast(1)).setStreamVolumeIndexAS(
- AudioManager.STREAM_MUSIC, minIndex, AudioSystem.DEVICE_OUT_USB_DEVICE);
+ eq(AudioManager.STREAM_MUSIC), eq(minIndex), anyBoolean(),
+ eq(AudioSystem.DEVICE_OUT_USB_DEVICE));
mAudioService.setDeviceVolume(volMid, usbDevice, mPackageName);
mTestLooper.dispatchAll();
verify(mSpyAudioSystem, atLeast(1)).setStreamVolumeIndexAS(
- AudioManager.STREAM_MUSIC, midIndex, AudioSystem.DEVICE_OUT_USB_DEVICE);
+ AudioManager.STREAM_MUSIC, midIndex, false, AudioSystem.DEVICE_OUT_USB_DEVICE);
}
@Test
@@ -151,7 +154,7 @@
// Stream volume changes
verify(mSpyAudioSystem, atLeast(1)).setStreamVolumeIndexAS(
- AudioManager.STREAM_MUSIC, targetIndex,
+ AudioManager.STREAM_MUSIC, targetIndex, false,
AudioSystem.DEVICE_OUT_BLE_HEADSET);
}
@@ -162,7 +165,7 @@
mTestLooper.dispatchAll();
verify(mSpyAudioSystem, atLeast(1)).setStreamVolumeIndexAS(
- AudioManager.STREAM_MUSIC, maxIndex,
+ AudioManager.STREAM_MUSIC, maxIndex, false,
AudioSystem.DEVICE_OUT_BLE_HEADSET);
}
@@ -193,8 +196,8 @@
}
// Stream volume changes
verify(mSpyAudioSystem, atLeast(1)).setStreamVolumeIndexAS(
- AudioManager.STREAM_MUSIC, passedIndex,
- AudioSystem.DEVICE_OUT_BLE_HEADSET);
+ AudioManager.STREAM_MUSIC, passedIndex, false,
+ AudioSystem.DEVICE_OUT_BLE_HEADSET);
}
// Adjust stream volume with FLAG_ABSOLUTE_VOLUME set (index:4)
@@ -207,7 +210,7 @@
passedIndex = 4;
}
verify(mSpyAudioSystem, atLeast(1)).setStreamVolumeIndexAS(
- AudioManager.STREAM_MUSIC, passedIndex,
- AudioSystem.DEVICE_OUT_BLE_HEADSET);
+ AudioManager.STREAM_MUSIC, passedIndex, false,
+ AudioSystem.DEVICE_OUT_BLE_HEADSET);
}
}
diff --git a/services/tests/servicestests/src/com/android/server/audio/NoOpAudioSystemAdapter.java b/services/tests/servicestests/src/com/android/server/audio/NoOpAudioSystemAdapter.java
index 96ac5d2..ce59a86 100644
--- a/services/tests/servicestests/src/com/android/server/audio/NoOpAudioSystemAdapter.java
+++ b/services/tests/servicestests/src/com/android/server/audio/NoOpAudioSystemAdapter.java
@@ -132,12 +132,13 @@
}
@Override
- public int setStreamVolumeIndexAS(int stream, int index, int device) {
+ public int setStreamVolumeIndexAS(int stream, int index, boolean muted, int device) {
return AudioSystem.AUDIO_STATUS_OK;
}
@Override
- public int setVolumeIndexForAttributes(AudioAttributes attributes, int index, int device) {
+ public int setVolumeIndexForAttributes(AudioAttributes attributes, int index, boolean muted,
+ int device) {
return AudioSystem.AUDIO_STATUS_OK;
}
diff --git a/services/tests/servicestests/src/com/android/server/audio/VolumeHelperTest.java b/services/tests/servicestests/src/com/android/server/audio/VolumeHelperTest.java
index dc8c1b9..6b41c43 100644
--- a/services/tests/servicestests/src/com/android/server/audio/VolumeHelperTest.java
+++ b/services/tests/servicestests/src/com/android/server/audio/VolumeHelperTest.java
@@ -18,6 +18,7 @@
import static android.media.AudioManager.ADJUST_LOWER;
import static android.media.AudioManager.ADJUST_MUTE;
import static android.media.AudioManager.ADJUST_RAISE;
+import static android.media.AudioManager.ADJUST_UNMUTE;
import static android.media.AudioManager.DEVICE_OUT_BLE_SPEAKER;
import static android.media.AudioManager.DEVICE_OUT_BLUETOOTH_SCO;
import static android.media.AudioManager.DEVICE_OUT_SPEAKER;
@@ -41,13 +42,13 @@
import static com.android.media.audio.Flags.FLAG_ABS_VOLUME_INDEX_FIX;
import static com.android.media.audio.Flags.FLAG_DISABLE_PRESCALE_ABSOLUTE_VOLUME;
+import static com.android.media.audio.Flags.FLAG_RING_MY_CAR;
import static com.android.media.audio.Flags.absVolumeIndexFix;
import static com.google.common.truth.Truth.assertThat;
import static com.google.common.truth.Truth.assertWithMessage;
import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotEquals;
import static org.junit.Assert.assertTrue;
import static org.junit.Assume.assumeFalse;
@@ -180,6 +181,10 @@
}
return mStreamDevice.get(stream);
}
+
+ public void setMuteAffectedStreams(int muteAffectedStreams) {
+ mMuteAffectedStreams = muteAffectedStreams;
+ }
}
private static class TestDeviceVolumeBehaviorDispatcherStub
@@ -223,6 +228,7 @@
mSettingsAdapter, mAudioVolumeGroupHelper, mMockAudioPolicy,
mTestLooper.getLooper(), mMockAppOpsManager, mMockPermissionEnforcer,
mMockPermissionProvider);
+ mAudioService.setMuteAffectedStreams(AudioSystem.DEFAULT_MUTE_STREAMS_AFFECTED);
mTestLooper.dispatchAll();
prepareAudioServiceState();
@@ -258,6 +264,8 @@
for (int streamType : usedStreamTypes) {
mAudioService.setStreamVolume(streamType, DEFAULT_STREAM_VOLUME, /*flags=*/0,
mContext.getOpPackageName());
+ mAudioService.adjustStreamVolume(streamType, ADJUST_UNMUTE, /*flags=*/0,
+ mContext.getOpPackageName());
}
if (!mIsAutomotive) {
@@ -301,7 +309,20 @@
mTestLooper.dispatchAll();
verify(mSpyAudioSystem).setStreamVolumeIndexAS(
- eq(STREAM_MUSIC), eq(newIndex), eq(DEVICE_OUT_USB_DEVICE));
+ STREAM_MUSIC, newIndex, /*muted=*/false, DEVICE_OUT_USB_DEVICE);
+ }
+
+ @Test
+ @RequiresFlagsEnabled(FLAG_RING_MY_CAR)
+ public void adjustStreamVolume_adjustMute_callsASSetStreamVolumeIndex() throws Exception {
+ int currentIndex = mAudioService.getStreamVolume(STREAM_MUSIC);
+
+ mAudioService.adjustStreamVolume(STREAM_MUSIC, ADJUST_MUTE, /*flags=*/0,
+ mContext.getOpPackageName());
+ mTestLooper.dispatchAll();
+
+ verify(mSpyAudioSystem).setStreamVolumeIndexAS(
+ eq(STREAM_MUSIC), eq(currentIndex), /*muted=*/eq(true), anyInt());
}
@Test
@@ -325,7 +346,7 @@
mTestLooper.dispatchAll();
verify(mSpyAudioSystem, atLeast(1)).setStreamVolumeIndexAS(
- eq(STREAM_MUSIC), anyInt(), eq(DEVICE_OUT_USB_DEVICE));
+ eq(STREAM_MUSIC), anyInt(), anyBoolean(), eq(DEVICE_OUT_USB_DEVICE));
}
@Test
@@ -341,7 +362,7 @@
mTestLooper.dispatchAll();
verify(mSpyAudioSystem).setStreamVolumeIndexAS(
- eq(STREAM_MUSIC), anyInt(), eq(DEVICE_OUT_USB_DEVICE));
+ eq(STREAM_MUSIC), anyInt(), eq(false), eq(DEVICE_OUT_USB_DEVICE));
}
// --------------- Volume Group APIs ---------------
@@ -356,15 +377,15 @@
mAudioService.setDeviceForStream(STREAM_MUSIC, DEVICE_OUT_USB_DEVICE);
mAudioService.setVolumeGroupVolumeIndex(mAudioMusicVolumeGroup.getId(),
circularNoMinMaxIncrementVolume(STREAM_MUSIC), /*flags=*/0,
- mContext.getOpPackageName(), /*attributionTag*/null);
+ mContext.getOpPackageName(), /*attributionTag*/null);
mTestLooper.dispatchAll();
- verify(mSpyAudioSystem).setVolumeIndexForAttributes(any(), anyInt(),
+ verify(mSpyAudioSystem).setVolumeIndexForAttributes(any(), anyInt(), eq(false),
eq(DEVICE_OUT_USB_DEVICE));
}
@Test
- public void adjustVolumeGroupVolume_callsASSetVolumeIndexForAttributes() throws Exception {
+ public void adjustVolumeGroupVolume_callsASSetStreamVolumeIndexAS() throws Exception {
assumeNotNull(mAudioMusicVolumeGroup);
mAudioService.setDeviceForStream(STREAM_MUSIC, DEVICE_OUT_USB_DEVICE);
@@ -372,8 +393,24 @@
ADJUST_LOWER, /*flags=*/0, mContext.getOpPackageName());
mTestLooper.dispatchAll();
- verify(mSpyAudioSystem).setVolumeIndexForAttributes(
- any(), anyInt(), eq(DEVICE_OUT_USB_DEVICE));
+ // adjust calls setStreamVolumeIndexAS instead of setVolumeIndexForAttributes
+ verify(mSpyAudioSystem, atLeast(1)).setStreamVolumeIndexAS(
+ anyInt(), anyInt(), anyBoolean(), eq(DEVICE_OUT_USB_DEVICE));
+ }
+
+ @Test
+ @RequiresFlagsEnabled(FLAG_RING_MY_CAR)
+ public void adjustVolumeGroupVolume_adjustMute_callsASSetStreamVolumeIndexAS()
+ throws Exception {
+ assumeNotNull(mAudioMusicVolumeGroup);
+
+ mAudioService.adjustVolumeGroupVolume(mAudioMusicVolumeGroup.getId(),
+ ADJUST_MUTE, /*flags=*/0, mContext.getOpPackageName());
+ mTestLooper.dispatchAll();
+
+ // adjust calls setStreamVolumeIndexAS instead of setVolumeIndexForAttributes
+ verify(mSpyAudioSystem, atLeast(1)).setStreamVolumeIndexAS(
+ anyInt(), anyInt(), eq(true), anyInt());
}
@Test
@@ -437,7 +474,7 @@
@Test
public void check_isStreamAffectedByMute() {
- assertFalse(mAudioService.isStreamAffectedByMute(STREAM_VOICE_CALL));
+ assertTrue(mAudioService.isStreamAffectedByMute(STREAM_VOICE_CALL));
}
// --------------------- Volume Flag Check --------------------
@@ -452,14 +489,14 @@
mContext.getOpPackageName());
mTestLooper.dispatchAll();
verify(mSpyAudioSystem).setStreamVolumeIndexAS(
- eq(STREAM_NOTIFICATION), anyInt(), eq(DEVICE_OUT_BLE_SPEAKER));
+ eq(STREAM_NOTIFICATION), anyInt(), eq(false), eq(DEVICE_OUT_BLE_SPEAKER));
reset(mSpyAudioSystem);
mAudioService.adjustStreamVolume(STREAM_NOTIFICATION, ADJUST_LOWER,
FLAG_BLUETOOTH_ABS_VOLUME, mContext.getOpPackageName());
mTestLooper.dispatchAll();
verify(mSpyAudioSystem).setStreamVolumeIndexAS(
- eq(STREAM_NOTIFICATION), anyInt(), eq(DEVICE_OUT_BLE_SPEAKER));
+ eq(STREAM_NOTIFICATION), anyInt(), eq(false), eq(DEVICE_OUT_BLE_SPEAKER));
}
@Test
@@ -471,13 +508,13 @@
mContext.getOpPackageName());
mTestLooper.dispatchAll();
verify(mSpyAudioSystem, times(0)).setStreamVolumeIndexAS(
- eq(STREAM_NOTIFICATION), eq(newIndex), eq(DEVICE_OUT_BLE_SPEAKER));
+ eq(STREAM_NOTIFICATION), eq(newIndex), eq(false), eq(DEVICE_OUT_BLE_SPEAKER));
mAudioService.adjustStreamVolume(STREAM_NOTIFICATION, ADJUST_LOWER,
FLAG_BLUETOOTH_ABS_VOLUME, mContext.getOpPackageName());
mTestLooper.dispatchAll();
verify(mSpyAudioSystem, times(0)).setStreamVolumeIndexAS(
- eq(STREAM_NOTIFICATION), anyInt(), eq(DEVICE_OUT_BLE_SPEAKER));
+ eq(STREAM_NOTIFICATION), anyInt(), eq(false), eq(DEVICE_OUT_BLE_SPEAKER));
}
@Test
@@ -523,7 +560,7 @@
mTestLooper.dispatchAll();
verify(mSpyAudioSystem, times(0)).setStreamVolumeIndexAS(
- eq(STREAM_MUSIC), anyInt(), anyInt());
+ eq(STREAM_MUSIC), anyInt(), eq(false), anyInt());
}
@Test
@@ -537,7 +574,7 @@
mTestLooper.dispatchAll();
verify(mSpyAudioSystem, times(0)).setStreamVolumeIndexAS(
- eq(STREAM_VOICE_CALL), anyInt(), eq(DEVICE_OUT_USB_DEVICE));
+ eq(STREAM_VOICE_CALL), anyInt(), eq(false), eq(DEVICE_OUT_USB_DEVICE));
mAudioService.setDeviceForStream(STREAM_BLUETOOTH_SCO, DEVICE_OUT_BLUETOOTH_SCO);
mAudioService.adjustStreamVolume(STREAM_BLUETOOTH_SCO, ADJUST_MUTE, /*flags=*/0,
@@ -545,7 +582,7 @@
mTestLooper.dispatchAll();
verify(mSpyAudioSystem, times(0)).setStreamVolumeIndexAS(
- eq(STREAM_BLUETOOTH_SCO), anyInt(), eq(DEVICE_OUT_USB_DEVICE));
+ eq(STREAM_BLUETOOTH_SCO), anyInt(), eq(false), eq(DEVICE_OUT_USB_DEVICE));
}
// ----------------- AudioDeviceVolumeManager -----------------
@@ -568,18 +605,18 @@
mTestLooper.dispatchAll();
// there is a min/max index mismatch in automotive
- assertEquals(volMin, mAudioService.getDeviceVolume(volMin, usbDevice,
- mContext.getOpPackageName()));
+ assertEquals(volMin.getVolumeIndex(), mAudioService.getDeviceVolume(volMin, usbDevice,
+ mContext.getOpPackageName()).getVolumeIndex());
verify(mSpyAudioSystem, atLeast(1)).setStreamVolumeIndexAS(
- eq(STREAM_MUSIC), anyInt(), eq(AudioSystem.DEVICE_OUT_USB_DEVICE));
+ eq(STREAM_MUSIC), anyInt(), anyBoolean(), eq(AudioSystem.DEVICE_OUT_USB_DEVICE));
mAudioService.setDeviceVolume(volMid, usbDevice, mContext.getOpPackageName());
mTestLooper.dispatchAll();
// there is a min/max index mismatch in automotive
- assertEquals(volMid, mAudioService.getDeviceVolume(volMid, usbDevice,
- mContext.getOpPackageName()));
+ assertEquals(volMid.getVolumeIndex(), mAudioService.getDeviceVolume(volMid, usbDevice,
+ mContext.getOpPackageName()).getVolumeIndex());
verify(mSpyAudioSystem, atLeast(1)).setStreamVolumeIndexAS(
- eq(STREAM_MUSIC), anyInt(), eq(AudioSystem.DEVICE_OUT_USB_DEVICE));
+ eq(STREAM_MUSIC), anyInt(), anyBoolean(), eq(AudioSystem.DEVICE_OUT_USB_DEVICE));
}
@Test
@@ -617,8 +654,7 @@
mAudioService.getDeviceVolume(volCur, bleDevice, mContext.getOpPackageName()));
// Stream volume changes
verify(mSpyAudioSystem, atLeast(1)).setStreamVolumeIndexAS(
- STREAM_MUSIC, targetIndex,
- AudioSystem.DEVICE_OUT_BLE_HEADSET);
+ STREAM_MUSIC, targetIndex, false, AudioSystem.DEVICE_OUT_BLE_HEADSET);
}
// Adjust stream volume with FLAG_ABSOLUTE_VOLUME set (index:4)
@@ -630,8 +666,7 @@
assertEquals(volIndex4,
mAudioService.getDeviceVolume(volIndex4, bleDevice, mContext.getOpPackageName()));
verify(mSpyAudioSystem, atLeast(1)).setStreamVolumeIndexAS(
- STREAM_MUSIC, maxIndex,
- AudioSystem.DEVICE_OUT_BLE_HEADSET);
+ STREAM_MUSIC, maxIndex, false, AudioSystem.DEVICE_OUT_BLE_HEADSET);
}
@Test
@@ -660,8 +695,7 @@
}
// Stream volume changes
verify(mSpyAudioSystem, atLeast(1)).setStreamVolumeIndexAS(
- STREAM_MUSIC, passedIndex,
- AudioSystem.DEVICE_OUT_BLE_HEADSET);
+ STREAM_MUSIC, passedIndex, false, AudioSystem.DEVICE_OUT_BLE_HEADSET);
}
// Adjust stream volume with FLAG_ABSOLUTE_VOLUME set (index:4)
@@ -674,8 +708,7 @@
passedIndex = 4;
}
verify(mSpyAudioSystem, atLeast(1)).setStreamVolumeIndexAS(
- STREAM_MUSIC, passedIndex,
- AudioSystem.DEVICE_OUT_BLE_HEADSET);
+ STREAM_MUSIC, passedIndex, false, AudioSystem.DEVICE_OUT_BLE_HEADSET);
}
// ---------------- DeviceVolumeBehaviorTest ----------------
diff --git a/services/tests/uiservicestests/src/com/android/server/notification/NotificationRecordTest.java b/services/tests/uiservicestests/src/com/android/server/notification/NotificationRecordTest.java
index 50a5f65..4391152 100644
--- a/services/tests/uiservicestests/src/com/android/server/notification/NotificationRecordTest.java
+++ b/services/tests/uiservicestests/src/com/android/server/notification/NotificationRecordTest.java
@@ -546,7 +546,8 @@
}
@Test
- @EnableFlags(com.android.server.notification.Flags.FLAG_NOTIFICATION_VIBRATION_IN_SOUND_URI)
+ @EnableFlags(com.android.server.notification.Flags
+ .FLAG_NOTIFICATION_VIBRATION_IN_SOUND_URI_FOR_CHANNEL)
public void testVibration_customVibrationForSound_withVibrationUri() throws IOException {
defaultChannel.enableVibration(true);
VibrationInfo vibration = getTestingVibration(mVibrator);
diff --git a/services/tests/wmtests/src/com/android/server/wm/ActivityStarterTests.java b/services/tests/wmtests/src/com/android/server/wm/ActivityStarterTests.java
index d5f86b6..d0080d2 100644
--- a/services/tests/wmtests/src/com/android/server/wm/ActivityStarterTests.java
+++ b/services/tests/wmtests/src/com/android/server/wm/ActivityStarterTests.java
@@ -1261,33 +1261,6 @@
}
@Test
- public void testLaunchAdjacentDisabled() {
- final ActivityStarter starter =
- prepareStarter(FLAG_ACTIVITY_LAUNCH_ADJACENT, false /* mockGetRootTask */);
- final ActivityRecord top = new ActivityBuilder(mAtm).setCreateTask(true).build();
- final ActivityOptions options = ActivityOptions.makeBasic();
- final ActivityRecord[] outActivity = new ActivityRecord[1];
-
- // Activity must not land on split-screen task if currently not in split-screen mode.
- starter.setActivityOptions(options.toBundle())
- .setReason("testLaunchAdjacentDisabled")
- .setOutActivity(outActivity).execute();
- assertThat(outActivity[0].inMultiWindowMode()).isFalse();
-
- // Move activity to split-screen-primary task and make sure it has the focus.
- TestSplitOrganizer splitOrg = new TestSplitOrganizer(mAtm, top.getDisplayContent());
- top.getRootTask().reparent(splitOrg.mPrimary, POSITION_BOTTOM);
- top.getRootTask().moveToFront("testLaunchAdjacentDisabled");
- top.getRootTask().setLaunchAdjacentDisabled(true);
-
- // Ensure activity does not launch into split-screen-secondary when launch adjacent is
- // disabled
- startActivityInner(starter, outActivity[0], top, options, null /* inTask */,
- null /* taskFragment*/);
- assertThat(outActivity[0].isDescendantOf(splitOrg.mSecondary)).isFalse();
- }
-
- @Test
public void testTransientLaunchWithKeyguard() {
final ActivityStarter starter = prepareStarter(0 /* flags */);
final ActivityRecord target = new ActivityBuilder(mAtm).setCreateTask(true).build();
diff --git a/services/tests/wmtests/src/com/android/server/wm/SizeCompatTests.java b/services/tests/wmtests/src/com/android/server/wm/SizeCompatTests.java
index 72f4fa91..c1edae9 100644
--- a/services/tests/wmtests/src/com/android/server/wm/SizeCompatTests.java
+++ b/services/tests/wmtests/src/com/android/server/wm/SizeCompatTests.java
@@ -4883,7 +4883,7 @@
@Test
- @EnableCompatChanges({ActivityRecord.UNIVERSAL_RESIZABLE_BY_DEFAULT})
+ @EnableCompatChanges({ActivityInfo.UNIVERSAL_RESIZABLE_BY_DEFAULT})
public void testUniversalResizeableByDefault() {
mSetFlagsRule.enableFlags(Flags.FLAG_UNIVERSAL_RESIZABLE_BY_DEFAULT);
mDisplayContent.setIgnoreOrientationRequest(false);
diff --git a/telephony/java/android/telephony/CarrierConfigManager.java b/telephony/java/android/telephony/CarrierConfigManager.java
index 47f6764..02999c8 100644
--- a/telephony/java/android/telephony/CarrierConfigManager.java
+++ b/telephony/java/android/telephony/CarrierConfigManager.java
@@ -253,7 +253,6 @@
*
* The default value is true.
*/
- @FlaggedApi(Flags.FLAG_SHOW_CALL_ID_AND_CALL_WAITING_IN_ADDITIONAL_SETTINGS_MENU)
public static final String KEY_ADDITIONAL_SETTINGS_CALLER_ID_VISIBILITY_BOOL =
"additional_settings_caller_id_visibility_bool";
@@ -263,7 +262,6 @@
*
* The default value is true.
*/
- @FlaggedApi(Flags.FLAG_SHOW_CALL_ID_AND_CALL_WAITING_IN_ADDITIONAL_SETTINGS_MENU)
public static final String KEY_ADDITIONAL_SETTINGS_CALL_WAITING_VISIBILITY_BOOL =
"additional_settings_call_waiting_visibility_bool";
@@ -10558,7 +10556,6 @@
* @see SubscriptionInfo#getServiceCapabilities()
* @see SubscriptionManager.OnSubscriptionsChangedListener
*/
- @FlaggedApi(Flags.FLAG_DATA_ONLY_CELLULAR_SERVICE)
public static final String KEY_CELLULAR_SERVICE_CAPABILITIES_INT_ARRAY =
"cellular_service_capabilities_int_array";
/**
@@ -11110,7 +11107,7 @@
sDefaults.putString(KEY_5G_ICON_DISPLAY_SECONDARY_GRACE_PERIOD_STRING, "");
sDefaults.putInt(KEY_NR_ADVANCED_BANDS_SECONDARY_TIMER_SECONDS_INT, 0);
sDefaults.putBoolean(KEY_NR_TIMERS_RESET_IF_NON_ENDC_AND_RRC_IDLE_BOOL, false);
- sDefaults.putBoolean(KEY_NR_TIMERS_RESET_ON_VOICE_QOS_BOOL, true);
+ sDefaults.putBoolean(KEY_NR_TIMERS_RESET_ON_VOICE_QOS_BOOL, false);
sDefaults.putBoolean(KEY_NR_TIMERS_RESET_ON_PLMN_CHANGE_BOOL, false);
/* Default value is 1 hour. */
sDefaults.putLong(KEY_5G_WATCHDOG_TIME_MS_LONG, 3600000);
diff --git a/telephony/java/android/telephony/SubscriptionInfo.java b/telephony/java/android/telephony/SubscriptionInfo.java
index 1089602..d164c88 100644
--- a/telephony/java/android/telephony/SubscriptionInfo.java
+++ b/telephony/java/android/telephony/SubscriptionInfo.java
@@ -951,7 +951,6 @@
* @see SubscriptionManager#SERVICE_CAPABILITY_DATA
*/
@NonNull
- @FlaggedApi(Flags.FLAG_DATA_ONLY_CELLULAR_SERVICE)
public @SubscriptionManager.ServiceCapability Set<Integer> getServiceCapabilities() {
return SubscriptionManager.getServiceCapabilitiesSet(mServiceCapabilities);
}
@@ -1829,7 +1828,6 @@
* @throws IllegalArgumentException when any capability is not supported.
*/
@NonNull
- @FlaggedApi(Flags.FLAG_DATA_ONLY_CELLULAR_SERVICE)
public Builder setServiceCapabilities(
@NonNull @SubscriptionManager.ServiceCapability Set<Integer> capabilities) {
int combinedCapabilities = 0;
diff --git a/telephony/java/android/telephony/SubscriptionManager.java b/telephony/java/android/telephony/SubscriptionManager.java
index 6faef7e..377e5f2 100644
--- a/telephony/java/android/telephony/SubscriptionManager.java
+++ b/telephony/java/android/telephony/SubscriptionManager.java
@@ -1422,7 +1422,6 @@
*
* @see TelephonyManager#isDeviceVoiceCapable()
*/
- @FlaggedApi(Flags.FLAG_DATA_ONLY_CELLULAR_SERVICE)
public static final int SERVICE_CAPABILITY_VOICE = 1;
/**
@@ -1440,13 +1439,11 @@
*
* @see TelephonyManager#isDeviceSmsCapable()
*/
- @FlaggedApi(Flags.FLAG_DATA_ONLY_CELLULAR_SERVICE)
public static final int SERVICE_CAPABILITY_SMS = 2;
/**
* Represents a value indicating the data calling capabilities of a subscription.
*/
- @FlaggedApi(Flags.FLAG_DATA_ONLY_CELLULAR_SERVICE)
public static final int SERVICE_CAPABILITY_DATA = 3;
/**
@@ -3474,14 +3471,62 @@
@SystemApi
public boolean canManageSubscription(@NonNull SubscriptionInfo info,
@NonNull String packageName) {
+ if (Flags.hsumPackageManager()) {
+ return canManageSubscriptionAsUser(info, packageName, mContext.getUser());
+ } else {
+ if (info == null || info.getAccessRules() == null || packageName == null) {
+ return false;
+ }
+ PackageManager packageManager = mContext.getPackageManager();
+ PackageInfo packageInfo;
+ try {
+ packageInfo = packageManager.getPackageInfo(packageName,
+ PackageManager.GET_SIGNING_CERTIFICATES);
+ } catch (PackageManager.NameNotFoundException e) {
+ logd("Unknown package: " + packageName);
+ return false;
+ }
+ for (UiccAccessRule rule : info.getAccessRules()) {
+ if (rule.getCarrierPrivilegeStatus(packageInfo)
+ == TelephonyManager.CARRIER_PRIVILEGE_STATUS_HAS_ACCESS) {
+ return true;
+ }
+ }
+ return false;
+ }
+ }
+
+ /**
+ * Checks whether the given app is authorized to manage the given subscription for given user.
+ *
+ * <p>An app can only be authorized if it is available to the given user and included in the
+ * {@link android.telephony.UiccAccessRule} of the {@link android.telephony.SubscriptionInfo}
+ * with the access status.
+ *
+ * <p>Only supported for embedded subscriptions (if {@link SubscriptionInfo#isEmbedded} returns
+ * true). To check for permissions for non-embedded subscription as well,
+ * see {@link android.telephony.TelephonyManager#hasCarrierPrivileges}.
+ *
+ * @param info The subscription to check.
+ * @param packageName Package name of the app to check.
+ * @param user UserHandle to check
+ * @return whether the app is authorized to manage this subscription per its access rules.
+ *
+ * @see android.telephony.TelephonyManager#hasCarrierPrivileges
+ * @hide
+ */
+ public boolean canManageSubscriptionAsUser(@NonNull SubscriptionInfo info,
+ @NonNull String packageName, @NonNull UserHandle user) {
if (info == null || info.getAccessRules() == null || packageName == null) {
return false;
}
- PackageManager packageManager = mContext.getPackageManager();
+ PackageManager pm = mContext.getUser().equals(user)
+ ? mContext.getPackageManager()
+ : mContext.createContextAsUser(user, 0).getPackageManager();
PackageInfo packageInfo;
try {
- packageInfo = packageManager.getPackageInfo(packageName,
- PackageManager.GET_SIGNING_CERTIFICATES);
+ packageInfo = pm.getPackageInfo(packageName,
+ PackageManager.GET_SIGNING_CERTIFICATES);
} catch (PackageManager.NameNotFoundException e) {
logd("Unknown package: " + packageName);
return false;
diff --git a/telephony/java/android/telephony/TelephonyManager.java b/telephony/java/android/telephony/TelephonyManager.java
index fee4587..c8aa61c 100644
--- a/telephony/java/android/telephony/TelephonyManager.java
+++ b/telephony/java/android/telephony/TelephonyManager.java
@@ -6934,7 +6934,6 @@
*
* @see SubscriptionInfo#getServiceCapabilities()
*/
- @FlaggedApi(Flags.FLAG_DATA_ONLY_CELLULAR_SERVICE)
public boolean isDeviceVoiceCapable() {
return isVoiceCapable();
}
@@ -6974,7 +6973,6 @@
*
* @see SubscriptionInfo#getServiceCapabilities()
*/
- @FlaggedApi(Flags.FLAG_DATA_ONLY_CELLULAR_SERVICE)
public boolean isDeviceSmsCapable() {
return isSmsCapable();
}
diff --git a/tests/StagedInstallTest/app/src/com/android/tests/stagedinstallinternal/StagedInstallInternalTest.java b/tests/StagedInstallTest/app/src/com/android/tests/stagedinstallinternal/StagedInstallInternalTest.java
index 0375f66..d9295dd 100644
--- a/tests/StagedInstallTest/app/src/com/android/tests/stagedinstallinternal/StagedInstallInternalTest.java
+++ b/tests/StagedInstallTest/app/src/com/android/tests/stagedinstallinternal/StagedInstallInternalTest.java
@@ -515,33 +515,27 @@
Install.single(APEX_V2));
}
- @Test
- public void testGetStagedModuleNames() throws Exception {
- // Before staging a session
- String[] result = getPackageManagerNative().getStagedApexModuleNames();
- assertThat(result).hasLength(0);
- // Stage an apex
- int sessionId = Install.single(APEX_V2).setStaged().commit();
- result = getPackageManagerNative().getStagedApexModuleNames();
- assertThat(result).hasLength(1);
- assertThat(result).isEqualTo(new String[]{SHIM_APEX_PACKAGE_NAME});
- // Abandon the session
- InstallUtils.openPackageInstallerSession(sessionId).abandon();
- result = getPackageManagerNative().getStagedApexModuleNames();
- assertThat(result).hasLength(0);
+ private StagedApexInfo findStagedApexInfo(StagedApexInfo[] infos, String moduleName) {
+ for (StagedApexInfo info: infos) {
+ if (info.moduleName.equals(moduleName)) {
+ return info;
+ }
+ }
+ return null;
}
@Test
- public void testGetStagedApexInfo() throws Exception {
- // Ask for non-existing module
- StagedApexInfo result = getPackageManagerNative().getStagedApexInfo("not found");
- assertThat(result).isNull();
+ public void testGetStagedApexInfos() throws Exception {
+ // Not found before staging
+ StagedApexInfo[] result = getPackageManagerNative().getStagedApexInfos();
+ assertThat(findStagedApexInfo(result, TEST_APEX_PACKAGE_NAME)).isNull();
// Stage an apex
int sessionId = Install.single(TEST_APEX_CLASSPATH).setStaged().commit();
// Query proper module name
- result = getPackageManagerNative().getStagedApexInfo(TEST_APEX_PACKAGE_NAME);
- assertThat(result.moduleName).isEqualTo(TEST_APEX_PACKAGE_NAME);
- assertThat(result.hasClassPathJars).isTrue();
+ result = getPackageManagerNative().getStagedApexInfos();
+ StagedApexInfo found = findStagedApexInfo(result, TEST_APEX_PACKAGE_NAME);
+ assertThat(found).isNotNull();
+ assertThat(found.hasClassPathJars).isTrue();
InstallUtils.openPackageInstallerSession(sessionId).abandon();
}
@@ -573,14 +567,15 @@
int sessionId = Install.single(APEX_V2).setStaged().commit();
ArgumentCaptor<ApexStagedEvent> captor = ArgumentCaptor.forClass(ApexStagedEvent.class);
verify(observer, timeout(5000)).onApexStaged(captor.capture());
- assertThat(captor.getValue().stagedApexModuleNames).isEqualTo(
- new String[] {SHIM_APEX_PACKAGE_NAME});
+ StagedApexInfo found =
+ findStagedApexInfo(captor.getValue().stagedApexInfos, SHIM_APEX_PACKAGE_NAME);
+ assertThat(found).isNotNull();
// Abandon and verify observer is called
Mockito.clearInvocations(observer);
InstallUtils.openPackageInstallerSession(sessionId).abandon();
verify(observer, timeout(5000)).onApexStaged(captor.capture());
- assertThat(captor.getValue().stagedApexModuleNames).hasLength(0);
+ assertThat(captor.getValue().stagedApexInfos).hasLength(0);
}
@Test
diff --git a/tests/StagedInstallTest/src/com/android/tests/stagedinstallinternal/host/StagedInstallInternalTest.java b/tests/StagedInstallTest/src/com/android/tests/stagedinstallinternal/host/StagedInstallInternalTest.java
index f1fc503..97abcd7 100644
--- a/tests/StagedInstallTest/src/com/android/tests/stagedinstallinternal/host/StagedInstallInternalTest.java
+++ b/tests/StagedInstallTest/src/com/android/tests/stagedinstallinternal/host/StagedInstallInternalTest.java
@@ -592,23 +592,15 @@
}
@Test
- public void testGetStagedModuleNames() throws Exception {
- assumeTrue("Device does not support updating APEX",
- mHostUtils.isApexUpdateSupported());
-
- runPhase("testGetStagedModuleNames");
- }
-
- @Test
@LargeTest
- public void testGetStagedApexInfo() throws Exception {
+ public void testGetStagedApexInfos() throws Exception {
assumeTrue("Device does not support updating APEX",
mHostUtils.isApexUpdateSupported());
pushTestApex(APEXD_TEST_APEX);
getDevice().reboot();
- runPhase("testGetStagedApexInfo");
+ runPhase("testGetStagedApexInfos");
}
@Test
diff --git a/tools/hoststubgen/hoststubgen/Android.bp b/tools/hoststubgen/hoststubgen/Android.bp
index 4920f7b4..a5ff496 100644
--- a/tools/hoststubgen/hoststubgen/Android.bp
+++ b/tools/hoststubgen/hoststubgen/Android.bp
@@ -8,7 +8,7 @@
// OWNER: g/ravenwood
// Bug component: 25698
- default_team: "trendy_team_framework_backstage_power",
+ default_team: "trendy_team_ravenwood",
}
// Visibility only for ravenwood prototype uses.