Merge "Fixed the incorrect carrier config for 5G icon timer" 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/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/net/vcn/flags.aconfig b/core/java/android/net/vcn/flags.aconfig
index dcb363c..efddd1f 100644
--- a/core/java/android/net/vcn/flags.aconfig
+++ b/core/java/android/net/vcn/flags.aconfig
@@ -21,38 +21,4 @@
namespace: "vcn"
description: "Feature flag for enabling network metric monitor"
bug: "282996138"
-}
-
-flag{
- name: "validate_network_on_ipsec_loss"
- namespace: "vcn"
- description: "Trigger network validation when IPsec packet loss exceeds the threshold"
- bug: "329139898"
-}
-
-flag{
- name: "evaluate_ipsec_loss_on_lp_nc_change"
- namespace: "vcn"
- description: "Re-evaluate IPsec packet loss on LinkProperties or NetworkCapabilities change"
- bug: "323238888"
-}
-
-flag{
- name: "enforce_main_user"
- namespace: "vcn"
- description: "Enforce main user to make VCN HSUM compatible"
- bug: "310310661"
- metadata {
- purpose: PURPOSE_BUGFIX
- }
-}
-
-flag{
- name: "handle_seq_num_leap"
- namespace: "vcn"
- description: "Do not report bad network when there is a suspected sequence number leap"
- bug: "332598276"
- metadata {
- purpose: PURPOSE_BUGFIX
- }
}
\ No newline at end of file
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/widget/RemoteCollectionItemsAdapter.java b/core/java/android/widget/RemoteCollectionItemsAdapter.java
index 9b396ae..fc09f88 100644
--- a/core/java/android/widget/RemoteCollectionItemsAdapter.java
+++ b/core/java/android/widget/RemoteCollectionItemsAdapter.java
@@ -40,13 +40,15 @@
private RemoteCollectionItems mItems;
private InteractionHandler mInteractionHandler;
private ColorResources mColorResources;
+ private boolean mOnLightBackground;
private SparseIntArray mLayoutIdToViewType;
RemoteCollectionItemsAdapter(
@NonNull RemoteCollectionItems items,
@NonNull InteractionHandler interactionHandler,
- @NonNull ColorResources colorResources) {
+ @NonNull ColorResources colorResources,
+ boolean onLightBackground) {
// View type count can never increase after an adapter has been set on a ListView.
// Additionally, decreasing it could inhibit view recycling if the count were to back and
// forth between 3-2-3-2 for example. Therefore, the view type count, should be fixed for
@@ -56,6 +58,7 @@
mItems = items;
mInteractionHandler = interactionHandler;
mColorResources = colorResources;
+ mOnLightBackground = onLightBackground;
initLayoutIdToViewType();
}
@@ -68,7 +71,8 @@
void setData(
@NonNull RemoteCollectionItems items,
@NonNull InteractionHandler interactionHandler,
- @NonNull ColorResources colorResources) {
+ @NonNull ColorResources colorResources,
+ boolean onLightBackground) {
if (mViewTypeCount < items.getViewTypeCount()) {
throw new IllegalArgumentException(
"RemoteCollectionItemsAdapter cannot increase view type count after creation");
@@ -77,6 +81,7 @@
mItems = items;
mInteractionHandler = interactionHandler;
mColorResources = colorResources;
+ mOnLightBackground = onLightBackground;
initLayoutIdToViewType();
@@ -184,6 +189,7 @@
: new AppWidgetHostView.AdapterChildHostView(parent.getContext());
newView.setInteractionHandler(mInteractionHandler);
newView.setColorResourcesNoReapply(mColorResources);
+ newView.setOnLightBackground(mOnLightBackground);
newView.updateAppWidget(item);
return newView;
}
diff --git a/core/java/android/widget/RemoteViews.java b/core/java/android/widget/RemoteViews.java
index d7b5211..9b6311f 100644
--- a/core/java/android/widget/RemoteViews.java
+++ b/core/java/android/widget/RemoteViews.java
@@ -1248,6 +1248,7 @@
AdapterView adapterView = (AdapterView) target;
Adapter adapter = adapterView.getAdapter();
+ boolean onLightBackground = hasFlags(FLAG_USE_LIGHT_BACKGROUND_LAYOUT);
// We can reuse the adapter if it's a RemoteCollectionItemsAdapter and the view type
// count hasn't increased. Note that AbsListView allocates a fixed size array for view
// recycling in setAdapter, so we must call setAdapter again if the number of view types
@@ -1255,8 +1256,12 @@
if (adapter instanceof RemoteCollectionItemsAdapter
&& adapter.getViewTypeCount() >= items.getViewTypeCount()) {
try {
- ((RemoteCollectionItemsAdapter) adapter).setData(
- items, params.handler, params.colorResources);
+ ((RemoteCollectionItemsAdapter) adapter)
+ .setData(
+ items,
+ params.handler,
+ params.colorResources,
+ onLightBackground);
} catch (Throwable throwable) {
// setData should never failed with the validation in the items builder, but if
// it does, catch and rethrow.
@@ -1266,8 +1271,9 @@
}
try {
- adapterView.setAdapter(new RemoteCollectionItemsAdapter(items,
- params.handler, params.colorResources));
+ adapterView.setAdapter(
+ new RemoteCollectionItemsAdapter(
+ items, params.handler, params.colorResources, onLightBackground));
} catch (Throwable throwable) {
// This could throw if the AdapterView somehow doesn't accept BaseAdapter due to
// a type error.
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/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/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/widget/RemoteViewsTest.java b/core/tests/coretests/src/android/widget/RemoteViewsTest.java
index 0621d82..2880ecf 100644
--- a/core/tests/coretests/src/android/widget/RemoteViewsTest.java
+++ b/core/tests/coretests/src/android/widget/RemoteViewsTest.java
@@ -16,6 +16,8 @@
package android.widget;
+import static android.appwidget.flags.Flags.remoteAdapterConversion;
+
import static com.android.internal.R.id.pending_intent_tag;
import static org.junit.Assert.assertArrayEquals;
@@ -282,7 +284,10 @@
widget.addView(view);
ListView listView = (ListView) view.findViewById(R.id.list);
- listView.onRemoteAdapterConnected();
+
+ if (!remoteAdapterConversion()) {
+ listView.onRemoteAdapterConnected();
+ }
assertNotNull(listView.getAdapter());
top.reapply(mContext, view);
@@ -414,6 +419,58 @@
assertNotNull(view.findViewById(R.id.light_background_text));
}
+ @Test
+ public void remoteCollectionItemsAdapter_lightBackgroundLayoutFlagSet() {
+ AppWidgetHostView widget = new AppWidgetHostView(mContext);
+ RemoteViews container = new RemoteViews(mPackage, R.layout.remote_view_host);
+ RemoteViews listRemoteViews = new RemoteViews(mPackage, R.layout.remote_views_list);
+ RemoteViews item = new RemoteViews(mPackage, R.layout.remote_views_text);
+ item.setLightBackgroundLayoutId(R.layout.remote_views_light_background_text);
+ listRemoteViews.setRemoteAdapter(
+ R.id.list,
+ new RemoteViews.RemoteCollectionItems.Builder().addItem(0, item).build());
+ container.addView(R.id.container, listRemoteViews);
+
+ widget.setOnLightBackground(true);
+ widget.updateAppWidget(container);
+
+ // Populate the list view
+ ListView listView = (ListView) widget.findViewById(R.id.list);
+ int measureSpec = View.MeasureSpec.makeMeasureSpec(100, View.MeasureSpec.EXACTLY);
+ listView.measure(measureSpec, measureSpec);
+ listView.layout(0, 0, 100, 100);
+
+ // Picks the light background layout id for the item
+ assertNotNull(listView.getChildAt(0).findViewById(R.id.light_background_text));
+ assertNull(listView.getChildAt(0).findViewById(R.id.text));
+ }
+
+ @Test
+ public void remoteCollectionItemsAdapter_lightBackgroundLayoutFlagNotSet() {
+ AppWidgetHostView widget = new AppWidgetHostView(mContext);
+ RemoteViews container = new RemoteViews(mPackage, R.layout.remote_view_host);
+ RemoteViews listRemoteViews = new RemoteViews(mPackage, R.layout.remote_views_list);
+ RemoteViews item = new RemoteViews(mPackage, R.layout.remote_views_text);
+ item.setLightBackgroundLayoutId(R.layout.remote_views_light_background_text);
+ listRemoteViews.setRemoteAdapter(
+ R.id.list,
+ new RemoteViews.RemoteCollectionItems.Builder().addItem(0, item).build());
+ container.addView(R.id.container, listRemoteViews);
+
+ widget.setOnLightBackground(false);
+ widget.updateAppWidget(container);
+
+ // Populate the list view
+ ListView listView = (ListView) widget.findViewById(R.id.list);
+ int measureSpec = View.MeasureSpec.makeMeasureSpec(100, View.MeasureSpec.EXACTLY);
+ listView.measure(measureSpec, measureSpec);
+ listView.layout(0, 0, 100, 100);
+
+ // Does not pick the light background layout id for the item
+ assertNotNull(listView.getChildAt(0).findViewById(R.id.text));
+ assertNull(listView.getChildAt(0).findViewById(R.id.light_background_text));
+ }
+
private RemoteViews createViewChained(int depth, String... texts) {
RemoteViews result = new RemoteViews(mPackage, R.layout.remote_view_host);
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 47c5eec..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,19 +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();
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;
@@ -328,7 +332,7 @@
mContext,
mTaskOrganizer,
mDisplayId,
- mMainStageListener,
+ this /*stageListenerCallbacks*/,
mSyncQueue,
iconProvider,
mWindowDecorViewModel);
@@ -336,7 +340,7 @@
mContext,
mTaskOrganizer,
mDisplayId,
- mSideStageListener,
+ this /*stageListenerCallbacks*/,
mSyncQueue,
iconProvider,
mWindowDecorViewModel);
@@ -411,7 +415,7 @@
}
public boolean isSplitScreenVisible() {
- return mSideStageListener.mVisible && mMainStageListener.mVisible;
+ return mSideStage.mVisible && mMainStage.mVisible;
}
private void activateSplit(WindowContainerTransaction wct, boolean includingTopTask) {
@@ -1096,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);
@@ -1317,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;
}
}
@@ -1571,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;
@@ -1706,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;
}
@@ -1732,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();
@@ -1777,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) {
@@ -1922,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,
@@ -1958,7 +1939,7 @@
}
});
}
- if (mMainStageListener.mHasChildren && mSideStageListener.mHasChildren) {
+ if (mMainStage.mHasChildren && mSideStage.mHasChildren) {
mShouldUpdateRecents = true;
clearRequestIfPresented();
updateRecentTasksSplitPair();
@@ -1974,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));
@@ -2045,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());
}
@@ -2498,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) {
@@ -3182,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);
}
@@ -3204,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;
}
/**
@@ -3255,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/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/multivalentTests/src/com/android/systemui/display/data/repository/DisplayRepositoryTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/display/data/repository/DisplayRepositoryTest.kt
index 6c6de61..cd8b2e1 100644
--- a/packages/SystemUI/multivalentTests/src/com/android/systemui/display/data/repository/DisplayRepositoryTest.kt
+++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/display/data/repository/DisplayRepositoryTest.kt
@@ -440,6 +440,28 @@
}
@Test
+ fun displayAdditionEvent_emptyByDefault() =
+ testScope.runTest {
+ setDisplays(1, 2, 3)
+
+ val lastAddedDisplay by lastDisplayAdditionEvent()
+
+ assertThat(lastAddedDisplay).isNull()
+ }
+
+ @Test
+ fun displayAdditionEvent_displaysAdded_doesNotReplayEventsToNewSubscribers() =
+ testScope.runTest {
+ val priorDisplayAdded by lastDisplayAdditionEvent()
+ setDisplays(1)
+ sendOnDisplayAdded(1)
+ assertThat(priorDisplayAdded?.displayId).isEqualTo(1)
+
+ val lastAddedDisplay by collectLastValue(displayRepository.displayAdditionEvent)
+ assertThat(lastAddedDisplay).isNull()
+ }
+
+ @Test
fun defaultDisplayOff_changes() =
testScope.runTest {
val defaultDisplayOff by latestDefaultDisplayOffFlowValue()
diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/shade/ShadeControllerImplTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/shade/ShadeControllerImplTest.kt
index 905301e..943fb62 100644
--- a/packages/SystemUI/multivalentTests/src/com/android/systemui/shade/ShadeControllerImplTest.kt
+++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/shade/ShadeControllerImplTest.kt
@@ -43,6 +43,7 @@
import com.android.systemui.statusbar.policy.HeadsUpManager
import com.android.systemui.statusbar.policy.KeyguardStateController
import com.android.systemui.statusbar.window.StatusBarWindowController
+import com.android.systemui.statusbar.window.StatusBarWindowControllerStore
import com.android.systemui.util.concurrency.FakeExecutor
import com.android.systemui.util.mockito.mock
import com.android.systemui.util.mockito.whenever
@@ -74,6 +75,7 @@
@Mock private lateinit var statusBarStateController: StatusBarStateController
@Mock private lateinit var statusBarKeyguardViewManager: StatusBarKeyguardViewManager
@Mock private lateinit var statusBarWindowController: StatusBarWindowController
+ @Mock private lateinit var statusBarWindowControllerStore: StatusBarWindowControllerStore
@Mock private lateinit var deviceProvisionedController: DeviceProvisionedController
@Mock private lateinit var notificationShadeWindowController: NotificationShadeWindowController
@Mock private lateinit var windowManager: WindowManager
@@ -105,6 +107,8 @@
MockitoAnnotations.initMocks(this)
whenever(windowManager.defaultDisplay).thenReturn(display)
whenever(deviceProvisionedController.isCurrentUserSetup).thenReturn(true)
+ whenever(statusBarWindowControllerStore.defaultDisplay)
+ .thenReturn(statusBarWindowController)
shadeController =
ShadeControllerImpl(
commandQueue,
@@ -113,7 +117,7 @@
keyguardStateController,
statusBarStateController,
statusBarKeyguardViewManager,
- statusBarWindowController,
+ statusBarWindowControllerStore,
deviceProvisionedController,
notificationShadeWindowController,
0,
diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/core/StatusBarInitializerTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/core/StatusBarInitializerTest.kt
index 9142972..f64387c 100644
--- a/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/core/StatusBarInitializerTest.kt
+++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/core/StatusBarInitializerTest.kt
@@ -27,6 +27,7 @@
import com.android.systemui.fragments.FragmentHostManager
import com.android.systemui.statusbar.phone.fragment.CollapsedStatusBarFragment
import com.android.systemui.statusbar.window.StatusBarWindowController
+import com.android.systemui.statusbar.window.StatusBarWindowControllerStore
import com.google.common.truth.Truth.assertThat
import kotlin.test.Test
import org.junit.Assert.assertThrows
@@ -39,7 +40,8 @@
@SmallTest
@RunWith(AndroidJUnit4::class)
class StatusBarInitializerTest : SysuiTestCase() {
- val windowController = mock(StatusBarWindowController::class.java)
+ private val windowController = mock(StatusBarWindowController::class.java)
+ private val windowControllerStore = mock(StatusBarWindowControllerStore::class.java)
@Before
fun setup() {
@@ -52,15 +54,16 @@
whenever(fragmentHostManager.fragmentManager).thenReturn(fragmentManager)
whenever(fragmentManager.beginTransaction()).thenReturn(transaction)
whenever(transaction.replace(any(), any(), any())).thenReturn(transaction)
-
+ whenever(windowControllerStore.defaultDisplay).thenReturn(windowController)
whenever(windowController.fragmentHostManager).thenReturn(fragmentHostManager)
}
val underTest =
StatusBarInitializerImpl(
- windowController,
- { mock(CollapsedStatusBarFragment::class.java) },
- setOf(),
+ displayId = context.displayId,
+ statusBarWindowControllerStore = windowControllerStore,
+ collapsedStatusBarFragmentProvider = { mock(CollapsedStatusBarFragment::class.java) },
+ creationListeners = setOf(),
)
@Test
diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/core/StatusBarOrchestratorTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/core/StatusBarOrchestratorTest.kt
index 5803365..bb3fb1e 100644
--- a/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/core/StatusBarOrchestratorTest.kt
+++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/core/StatusBarOrchestratorTest.kt
@@ -44,7 +44,7 @@
import com.android.systemui.statusbar.window.data.model.StatusBarWindowState
import com.android.systemui.statusbar.window.data.repository.fakeStatusBarWindowStateRepositoryStore
import com.android.systemui.statusbar.window.data.repository.statusBarWindowStateRepositoryStore
-import com.android.systemui.statusbar.window.fakeStatusBarWindowController
+import com.android.systemui.statusbar.window.fakeStatusBarWindowControllerStore
import com.android.systemui.testKosmos
import com.android.wm.shell.bubbles.bubbles
import com.google.common.truth.Truth.assertThat
@@ -67,7 +67,7 @@
}
private val testScope = kosmos.testScope
private val statusBarViewController = kosmos.mockPhoneStatusBarViewController
- private val statusBarWindowController = kosmos.fakeStatusBarWindowController
+ private val statusBarWindowControllerStore = kosmos.fakeStatusBarWindowControllerStore
private val statusBarModeRepository = kosmos.fakeStatusBarModeRepository
private val pluginDependencyProvider = kosmos.mockPluginDependencyProvider
private val notificationShadeWindowViewController =
@@ -94,7 +94,7 @@
fun start_attachesWindow() {
orchestrator.start()
- assertThat(statusBarWindowController.isAttached).isTrue()
+ assertThat(statusBarWindowControllerStore.defaultDisplay.isAttached).isTrue()
}
@Test
diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/events/SystemEventChipAnimationControllerTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/events/SystemEventChipAnimationControllerTest.kt
index 984bda1..a629b24 100644
--- a/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/events/SystemEventChipAnimationControllerTest.kt
+++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/events/SystemEventChipAnimationControllerTest.kt
@@ -30,6 +30,7 @@
import com.android.systemui.statusbar.phone.StatusBarContentInsetsChangedListener
import com.android.systemui.statusbar.phone.StatusBarContentInsetsProvider
import com.android.systemui.statusbar.window.StatusBarWindowController
+import com.android.systemui.statusbar.window.StatusBarWindowControllerStore
import com.android.systemui.util.mockito.any
import com.android.systemui.util.mockito.argumentCaptor
import com.android.systemui.util.mockito.capture
@@ -53,6 +54,7 @@
@get:Rule val animatorTestRule = AnimatorTestRule(this)
@Mock private lateinit var sbWindowController: StatusBarWindowController
+ @Mock private lateinit var sbWindowControllerStore: StatusBarWindowControllerStore
@Mock private lateinit var insetsProvider: StatusBarContentInsetsProvider
private var testView = TestView(mContext)
@@ -61,7 +63,7 @@
@Before
fun setup() {
MockitoAnnotations.initMocks(this)
-
+ whenever(sbWindowControllerStore.defaultDisplay).thenReturn(sbWindowController)
// StatusBarWindowController is mocked. The addViewToWindow function needs to be mocked to
// ensure that the chip view is added to a parent view
whenever(sbWindowController.addViewToWindow(any(), any())).then {
@@ -93,8 +95,8 @@
controller =
SystemEventChipAnimationController(
context = mContext,
- statusBarWindowController = sbWindowController,
- contentInsetsProvider = insetsProvider
+ statusBarWindowControllerStore = sbWindowControllerStore,
+ contentInsetsProvider = insetsProvider,
)
}
diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/phone/LegacyActivityStarterInternalImplTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/phone/LegacyActivityStarterInternalImplTest.kt
index 1797995..bac79a9 100644
--- a/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/phone/LegacyActivityStarterInternalImplTest.kt
+++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/phone/LegacyActivityStarterInternalImplTest.kt
@@ -56,6 +56,7 @@
import com.android.systemui.statusbar.policy.DeviceProvisionedController
import com.android.systemui.statusbar.policy.KeyguardStateController
import com.android.systemui.statusbar.window.StatusBarWindowController
+import com.android.systemui.statusbar.window.StatusBarWindowControllerStore
import com.android.systemui.util.concurrency.FakeExecutor
import com.android.systemui.util.time.FakeSystemClock
import com.google.common.truth.Truth.assertThat
@@ -94,6 +95,7 @@
@Mock private lateinit var activityTransitionAnimator: ActivityTransitionAnimator
@Mock private lateinit var lockScreenUserManager: NotificationLockscreenUserManager
@Mock private lateinit var statusBarWindowController: StatusBarWindowController
+ @Mock private lateinit var statusBarWindowControllerStore: StatusBarWindowControllerStore
@Mock private lateinit var notifShadeWindowController: NotificationShadeWindowController
@Mock private lateinit var wakefulnessLifecycle: WakefulnessLifecycle
@Mock private lateinit var keyguardStateController: KeyguardStateController
@@ -112,6 +114,7 @@
@Before
fun setUp() {
MockitoAnnotations.initMocks(this)
+ `when`(statusBarWindowControllerStore.defaultDisplay).thenReturn(statusBarWindowController)
underTest =
LegacyActivityStarterInternalImpl(
centralSurfacesOptLazy = { Optional.of(centralSurfaces) },
@@ -128,7 +131,7 @@
context = context,
displayId = DISPLAY_ID,
lockScreenUserManager = lockScreenUserManager,
- statusBarWindowController = statusBarWindowController,
+ statusBarWindowControllerStore = statusBarWindowControllerStore,
wakefulnessLifecycle = wakefulnessLifecycle,
keyguardStateController = keyguardStateController,
statusBarStateController = statusBarStateController,
diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/phone/ongoingcall/OngoingCallControllerViaListenerTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/phone/ongoingcall/OngoingCallControllerViaListenerTest.kt
index 597e2e4..e0d9fac 100644
--- a/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/phone/ongoingcall/OngoingCallControllerViaListenerTest.kt
+++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/phone/ongoingcall/OngoingCallControllerViaListenerTest.kt
@@ -50,6 +50,7 @@
import com.android.systemui.statusbar.phone.ongoingcall.data.repository.ongoingCallRepository
import com.android.systemui.statusbar.phone.ongoingcall.shared.model.OngoingCallModel
import com.android.systemui.statusbar.window.StatusBarWindowController
+import com.android.systemui.statusbar.window.StatusBarWindowControllerStore
import com.android.systemui.util.concurrency.FakeExecutor
import com.android.systemui.util.mockito.any
import com.android.systemui.util.time.FakeSystemClock
@@ -74,6 +75,7 @@
import org.mockito.Mockito.verify
import org.mockito.Mockito.`when`
import org.mockito.MockitoAnnotations
+import org.mockito.kotlin.whenever
private const val CALL_UID = 900
@@ -106,6 +108,7 @@
@Mock private lateinit var mockActivityStarter: ActivityStarter
@Mock private lateinit var mockIActivityManager: IActivityManager
@Mock private lateinit var mockStatusBarWindowController: StatusBarWindowController
+ @Mock private lateinit var mockStatusBarWindowControllerStore: StatusBarWindowControllerStore
private lateinit var chipView: View
@@ -118,6 +121,8 @@
MockitoAnnotations.initMocks(this)
val notificationCollection = mock(CommonNotifCollection::class.java)
+ whenever(mockStatusBarWindowControllerStore.defaultDisplay)
+ .thenReturn(mockStatusBarWindowController)
controller =
OngoingCallController(
@@ -131,7 +136,7 @@
mainExecutor,
mockIActivityManager,
DumpManager(),
- mockStatusBarWindowController,
+ mockStatusBarWindowControllerStore,
mockSwipeStatusBarAwayGestureHandler,
statusBarModeRepository,
logcatLogBuffer("OngoingCallControllerViaListenerTest"),
diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/phone/ongoingcall/OngoingCallControllerViaRepoTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/phone/ongoingcall/OngoingCallControllerViaRepoTest.kt
index dfe01bf..2ad50cc 100644
--- a/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/phone/ongoingcall/OngoingCallControllerViaRepoTest.kt
+++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/phone/ongoingcall/OngoingCallControllerViaRepoTest.kt
@@ -52,6 +52,7 @@
import com.android.systemui.statusbar.phone.ongoingcall.data.repository.ongoingCallRepository
import com.android.systemui.statusbar.phone.ongoingcall.shared.model.OngoingCallModel
import com.android.systemui.statusbar.window.StatusBarWindowController
+import com.android.systemui.statusbar.window.StatusBarWindowControllerStore
import com.android.systemui.util.time.fakeSystemClock
import com.google.common.truth.Truth.assertThat
import kotlinx.coroutines.ExperimentalCoroutinesApi
@@ -93,6 +94,7 @@
private val mockActivityStarter = kosmos.activityStarter
private val mockIActivityManager = mock<IActivityManager>()
private val mockStatusBarWindowController = mock<StatusBarWindowController>()
+ private val mockStatusBarWindowControllerStore = mock<StatusBarWindowControllerStore>()
private lateinit var chipView: View
@@ -103,6 +105,8 @@
chipView = LayoutInflater.from(mContext).inflate(R.layout.ongoing_activity_chip, null)
}
+ whenever(mockStatusBarWindowControllerStore.defaultDisplay)
+ .thenReturn(mockStatusBarWindowController)
controller =
OngoingCallController(
testScope.backgroundScope,
@@ -115,7 +119,7 @@
mainExecutor,
mockIActivityManager,
DumpManager(),
- mockStatusBarWindowController,
+ mockStatusBarWindowControllerStore,
mockSwipeStatusBarAwayGestureHandler,
statusBarModeRepository,
logcatLogBuffer("OngoingCallControllerViaRepoTest"),
diff --git a/packages/SystemUI/src/com/android/systemui/Dependency.java b/packages/SystemUI/src/com/android/systemui/Dependency.java
index a301155..40c1f0f9 100644
--- a/packages/SystemUI/src/com/android/systemui/Dependency.java
+++ b/packages/SystemUI/src/com/android/systemui/Dependency.java
@@ -52,7 +52,7 @@
import com.android.systemui.statusbar.phone.SystemUIDialogManager;
import com.android.systemui.statusbar.policy.BluetoothController;
import com.android.systemui.statusbar.policy.DeviceProvisionedController;
-import com.android.systemui.statusbar.window.StatusBarWindowController;
+import com.android.systemui.statusbar.window.StatusBarWindowControllerStore;
import com.android.systemui.tuner.TunerService;
import dagger.Lazy;
@@ -148,7 +148,7 @@
@Inject Lazy<SystemUIDialogManager> mSystemUIDialogManagerLazy;
@Inject Lazy<DialogTransitionAnimator> mDialogTransitionAnimatorLazy;
@Inject Lazy<UserTracker> mUserTrackerLazy;
- @Inject Lazy<StatusBarWindowController> mStatusBarWindowControllerLazy;
+ @Inject Lazy<StatusBarWindowControllerStore> mStatusBarWindowControllerStoreLazy;
@Inject
public Dependency() {
@@ -192,7 +192,8 @@
mProviders.put(SystemUIDialogManager.class, mSystemUIDialogManagerLazy::get);
mProviders.put(DialogTransitionAnimator.class, mDialogTransitionAnimatorLazy::get);
mProviders.put(UserTracker.class, mUserTrackerLazy::get);
- mProviders.put(StatusBarWindowController.class, mStatusBarWindowControllerLazy::get);
+ mProviders.put(
+ StatusBarWindowControllerStore.class, mStatusBarWindowControllerStoreLazy::get);
Dependency.setInstance(this);
}
diff --git a/packages/SystemUI/src/com/android/systemui/dagger/qualifiers/Default.java b/packages/SystemUI/src/com/android/systemui/dagger/qualifiers/Default.java
new file mode 100644
index 0000000..1950d6b
--- /dev/null
+++ b/packages/SystemUI/src/com/android/systemui/dagger/qualifiers/Default.java
@@ -0,0 +1,30 @@
+/*
+ * Copyright (C) 2024 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.systemui.dagger.qualifiers;
+
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.Retention;
+
+import javax.inject.Qualifier;
+
+@Qualifier
+@Documented
+@Retention(RUNTIME)
+public @interface Default {
+}
diff --git a/packages/SystemUI/src/com/android/systemui/display/data/repository/DisplayRepository.kt b/packages/SystemUI/src/com/android/systemui/display/data/repository/DisplayRepository.kt
index 6a69136..034cb31 100644
--- a/packages/SystemUI/src/com/android/systemui/display/data/repository/DisplayRepository.kt
+++ b/packages/SystemUI/src/com/android/systemui/display/data/repository/DisplayRepository.kt
@@ -33,6 +33,7 @@
import com.android.systemui.dagger.qualifiers.Background
import com.android.systemui.display.data.DisplayEvent
import com.android.systemui.util.Compile
+import com.android.systemui.util.kotlin.pairwiseBy
import javax.inject.Inject
import kotlinx.coroutines.CoroutineDispatcher
import kotlinx.coroutines.CoroutineScope
@@ -41,11 +42,12 @@
import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.flow.SharingStarted
import kotlinx.coroutines.flow.StateFlow
+import kotlinx.coroutines.flow.asFlow
import kotlinx.coroutines.flow.combine
import kotlinx.coroutines.flow.distinctUntilChanged
import kotlinx.coroutines.flow.filter
import kotlinx.coroutines.flow.filterIsInstance
-import kotlinx.coroutines.flow.first
+import kotlinx.coroutines.flow.flatMapLatest
import kotlinx.coroutines.flow.flowOn
import kotlinx.coroutines.flow.map
import kotlinx.coroutines.flow.onEach
@@ -146,11 +148,6 @@
override val displayChangeEvent: Flow<Int> =
allDisplayEvents.filterIsInstance<DisplayEvent.Changed>().map { event -> event.displayId }
- override val displayAdditionEvent: Flow<Display?> =
- allDisplayEvents.filterIsInstance<DisplayEvent.Added>().map {
- getDisplayFromDisplayManager(it.displayId)
- }
-
override val displayRemovalEvent: Flow<Int> =
allDisplayEvents.filterIsInstance<DisplayEvent.Removed>().map { it.displayId }
@@ -212,6 +209,17 @@
*/
override val displays: StateFlow<Set<Display>> = enabledDisplays
+ /**
+ * Implementation that maps from [displays], instead of [allDisplayEvents] for 2 reasons:
+ * 1. Guarantee that it emits __after__ [displays] emitted. This way it is guaranteed that
+ * calling [getDisplay] for the newly added display will be non-null.
+ * 2. Reuse the existing instance of [Display] without a new call to [DisplayManager].
+ */
+ override val displayAdditionEvent: Flow<Display?> =
+ displays
+ .pairwiseBy { previousDisplays, currentDisplays -> currentDisplays - previousDisplays }
+ .flatMapLatest { it.asFlow() }
+
val _ignoredDisplayIds = MutableStateFlow<Set<Int>>(emptySet())
private val ignoredDisplayIds: Flow<Set<Int>> = _ignoredDisplayIds.debugLog("ignoredDisplayIds")
diff --git a/packages/SystemUI/src/com/android/systemui/globalactions/GlobalActionsDialogLite.java b/packages/SystemUI/src/com/android/systemui/globalactions/GlobalActionsDialogLite.java
index aa1873c..162047b 100644
--- a/packages/SystemUI/src/com/android/systemui/globalactions/GlobalActionsDialogLite.java
+++ b/packages/SystemUI/src/com/android/systemui/globalactions/GlobalActionsDialogLite.java
@@ -135,6 +135,7 @@
import com.android.systemui.statusbar.policy.ConfigurationController;
import com.android.systemui.statusbar.policy.KeyguardStateController;
import com.android.systemui.statusbar.window.StatusBarWindowController;
+import com.android.systemui.statusbar.window.StatusBarWindowControllerStore;
import com.android.systemui.telephony.TelephonyListenerManager;
import com.android.systemui.user.domain.interactor.SelectedUserInteractor;
import com.android.systemui.util.EmergencyDialerConstants;
@@ -248,7 +249,7 @@
private final IStatusBarService mStatusBarService;
protected final LightBarController mLightBarController;
protected final NotificationShadeWindowController mNotificationShadeWindowController;
- private final StatusBarWindowController mStatusBarWindowController;
+ private final StatusBarWindowControllerStore mStatusBarWindowControllerStore;
private final IWindowManager mIWindowManager;
private final Executor mBackgroundExecutor;
private final RingerModeTracker mRingerModeTracker;
@@ -364,7 +365,7 @@
IStatusBarService statusBarService,
LightBarController lightBarController,
NotificationShadeWindowController notificationShadeWindowController,
- StatusBarWindowController statusBarWindowController,
+ StatusBarWindowControllerStore statusBarWindowControllerStore,
IWindowManager iWindowManager,
@Background Executor backgroundExecutor,
UiEventLogger uiEventLogger,
@@ -400,7 +401,7 @@
mStatusBarService = statusBarService;
mLightBarController = lightBarController;
mNotificationShadeWindowController = notificationShadeWindowController;
- mStatusBarWindowController = statusBarWindowController;
+ mStatusBarWindowControllerStore = statusBarWindowControllerStore;
mIWindowManager = iWindowManager;
mBackgroundExecutor = backgroundExecutor;
mRingerModeTracker = ringerModeTracker;
@@ -708,7 +709,7 @@
mLightBarController,
mKeyguardStateController,
mNotificationShadeWindowController,
- mStatusBarWindowController,
+ mStatusBarWindowControllerStore.getDefaultDisplay(),
this::onRefresh,
mKeyguardShowing,
mPowerAdapter,
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/packages/SystemUI/src/com/android/systemui/shade/ShadeControllerImpl.java b/packages/SystemUI/src/com/android/systemui/shade/ShadeControllerImpl.java
index b7a95e9..0e30f2b 100644
--- a/packages/SystemUI/src/com/android/systemui/shade/ShadeControllerImpl.java
+++ b/packages/SystemUI/src/com/android/systemui/shade/ShadeControllerImpl.java
@@ -38,7 +38,7 @@
import com.android.systemui.statusbar.phone.StatusBarKeyguardViewManager;
import com.android.systemui.statusbar.policy.DeviceProvisionedController;
import com.android.systemui.statusbar.policy.KeyguardStateController;
-import com.android.systemui.statusbar.window.StatusBarWindowController;
+import com.android.systemui.statusbar.window.StatusBarWindowControllerStore;
import dagger.Lazy;
@@ -62,7 +62,7 @@
private final NotificationShadeWindowController mNotificationShadeWindowController;
private final StatusBarStateController mStatusBarStateController;
private final StatusBarKeyguardViewManager mStatusBarKeyguardViewManager;
- private final StatusBarWindowController mStatusBarWindowController;
+ private final StatusBarWindowControllerStore mStatusBarWindowControllerStore;
private final DeviceProvisionedController mDeviceProvisionedController;
private final Lazy<NotificationShadeWindowViewController> mNotifShadeWindowViewController;
@@ -83,7 +83,7 @@
KeyguardStateController keyguardStateController,
StatusBarStateController statusBarStateController,
StatusBarKeyguardViewManager statusBarKeyguardViewManager,
- StatusBarWindowController statusBarWindowController,
+ StatusBarWindowControllerStore statusBarWindowControllerStore,
DeviceProvisionedController deviceProvisionedController,
NotificationShadeWindowController notificationShadeWindowController,
@DisplayId int displayId,
@@ -102,7 +102,7 @@
mWindowRootViewVisibilityInteractor = windowRootViewVisibilityInteractor;
mNpvc = shadeViewControllerLazy;
mStatusBarStateController = statusBarStateController;
- mStatusBarWindowController = statusBarWindowController;
+ mStatusBarWindowControllerStore = statusBarWindowControllerStore;
mDeviceProvisionedController = deviceProvisionedController;
mGutsManager = gutsManager;
mNotificationShadeWindowController = notificationShadeWindowController;
@@ -315,7 +315,7 @@
// Update the visibility of notification shade and status bar window.
mNotificationShadeWindowController.setPanelVisible(false);
- mStatusBarWindowController.setForceStatusBarVisible(false);
+ mStatusBarWindowControllerStore.getDefaultDisplay().setForceStatusBarVisible(false);
// Close any guts that might be visible
mGutsManager.get().closeAndSaveGuts(
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/core/StatusBarInitializer.kt b/packages/SystemUI/src/com/android/systemui/statusbar/core/StatusBarInitializer.kt
index 3ad76b7..7eff812 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/core/StatusBarInitializer.kt
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/core/StatusBarInitializer.kt
@@ -18,7 +18,6 @@
import android.app.Fragment
import androidx.annotation.VisibleForTesting
import com.android.systemui.CoreStartable
-import com.android.systemui.dagger.SysUISingleton
import com.android.systemui.fragments.FragmentHostManager
import com.android.systemui.res.R
import com.android.systemui.statusbar.core.StatusBarInitializer.OnStatusBarViewInitializedListener
@@ -27,9 +26,11 @@
import com.android.systemui.statusbar.phone.PhoneStatusBarViewController
import com.android.systemui.statusbar.phone.fragment.CollapsedStatusBarFragment
import com.android.systemui.statusbar.phone.fragment.dagger.StatusBarFragmentComponent
-import com.android.systemui.statusbar.window.StatusBarWindowController
+import com.android.systemui.statusbar.window.StatusBarWindowControllerStore
+import dagger.assisted.Assisted
+import dagger.assisted.AssistedFactory
+import dagger.assisted.AssistedInject
import java.lang.IllegalStateException
-import javax.inject.Inject
import javax.inject.Provider
/**
@@ -65,13 +66,17 @@
statusBarTransitions: PhoneStatusBarTransitions,
)
}
+
+ interface Factory {
+ fun create(displayId: Int): StatusBarInitializer
+ }
}
-@SysUISingleton
class StatusBarInitializerImpl
-@Inject
+@AssistedInject
constructor(
- private val windowController: StatusBarWindowController,
+ @Assisted private val displayId: Int,
+ private val statusBarWindowControllerStore: StatusBarWindowControllerStore,
private val collapsedStatusBarFragmentProvider: Provider<CollapsedStatusBarFragment>,
private val creationListeners: Set<@JvmSuppressWildcards OnStatusBarViewInitializedListener>,
) : CoreStartable, StatusBarInitializer {
@@ -106,7 +111,7 @@
private fun doStart() {
initialized = true
- windowController.fragmentHostManager
+ statusBarWindowControllerStore.defaultDisplay.fragmentHostManager
.addTagListener(
CollapsedStatusBarFragment.TAG,
object : FragmentHostManager.FragmentListener {
@@ -137,4 +142,9 @@
)
.commit()
}
+
+ @AssistedFactory
+ interface Factory : StatusBarInitializer.Factory {
+ override fun create(displayId: Int): StatusBarInitializerImpl
+ }
}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/core/StatusBarInitializerStore.kt b/packages/SystemUI/src/com/android/systemui/statusbar/core/StatusBarInitializerStore.kt
new file mode 100644
index 0000000..8d044bb
--- /dev/null
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/core/StatusBarInitializerStore.kt
@@ -0,0 +1,99 @@
+/*
+ * Copyright (C) 2024 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.systemui.statusbar.core
+
+import android.view.Display
+import com.android.systemui.CoreStartable
+import com.android.systemui.dagger.SysUISingleton
+import com.android.systemui.dagger.qualifiers.Background
+import com.android.systemui.display.data.repository.DisplayRepository
+import java.util.concurrent.ConcurrentHashMap
+import javax.inject.Inject
+import kotlinx.coroutines.CoroutineName
+import kotlinx.coroutines.CoroutineScope
+import kotlinx.coroutines.launch
+
+/** Provides per display instances of [StatusBarInitializer]. */
+interface StatusBarInitializerStore {
+ /**
+ * The instance for the default/main display of the device. For example, on a phone or a tablet,
+ * the default display is the internal/built-in display of the device.
+ *
+ * Note that the id of the default display is [Display.DEFAULT_DISPLAY].
+ */
+ val defaultDisplay: StatusBarInitializer
+
+ /**
+ * Returns an instance for a specific display id.
+ *
+ * @throws IllegalArgumentException if [displayId] doesn't match the id of any existing
+ * displays.
+ */
+ fun forDisplay(displayId: Int): StatusBarInitializer
+}
+
+@SysUISingleton
+class MultiDisplayStatusBarInitializerStore
+@Inject
+constructor(
+ @Background private val backgroundApplicationScope: CoroutineScope,
+ private val factory: StatusBarInitializer.Factory,
+ private val displayRepository: DisplayRepository,
+) : StatusBarInitializerStore, CoreStartable {
+
+ init {
+ StatusBarConnectedDisplays.assertInNewMode()
+ }
+
+ private val perDisplayInitializers = ConcurrentHashMap<Int, StatusBarInitializer>()
+
+ override val defaultDisplay: StatusBarInitializer
+ get() = forDisplay(Display.DEFAULT_DISPLAY)
+
+ override fun forDisplay(displayId: Int): StatusBarInitializer {
+ if (displayRepository.getDisplay(displayId) == null) {
+ throw IllegalArgumentException("Display with id $displayId doesn't exist.")
+ }
+ return perDisplayInitializers.computeIfAbsent(displayId) { factory.create(displayId) }
+ }
+
+ override fun start() {
+ backgroundApplicationScope.launch(
+ CoroutineName("MultiDisplayStatusBarInitializerStore#start")
+ ) {
+ displayRepository.displayRemovalEvent.collect { removedDisplayId ->
+ perDisplayInitializers.remove(removedDisplayId)
+ }
+ }
+ }
+}
+
+@SysUISingleton
+class SingleDisplayStatusBarInitializerStore
+@Inject
+constructor(factory: StatusBarInitializerImpl.Factory) : StatusBarInitializerStore {
+
+ init {
+ StatusBarConnectedDisplays.assertInLegacyMode()
+ }
+
+ private val defaultInstance = factory.create(Display.DEFAULT_DISPLAY)
+
+ override val defaultDisplay: StatusBarInitializer = defaultInstance
+
+ override fun forDisplay(displayId: Int): StatusBarInitializer = defaultDisplay
+}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/core/StatusBarOrchestrator.kt b/packages/SystemUI/src/com/android/systemui/statusbar/core/StatusBarOrchestrator.kt
index 8bd990b..d372eb2 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/core/StatusBarOrchestrator.kt
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/core/StatusBarOrchestrator.kt
@@ -36,7 +36,7 @@
import com.android.systemui.statusbar.phone.CentralSurfaces
import com.android.systemui.statusbar.phone.PhoneStatusBarTransitions
import com.android.systemui.statusbar.phone.PhoneStatusBarViewController
-import com.android.systemui.statusbar.window.StatusBarWindowController
+import com.android.systemui.statusbar.window.StatusBarWindowControllerStore
import com.android.systemui.statusbar.window.data.model.StatusBarWindowState
import com.android.systemui.statusbar.window.data.repository.StatusBarWindowStateRepositoryStore
import com.android.wm.shell.bubbles.Bubbles
@@ -63,8 +63,8 @@
constructor(
@Application private val applicationScope: CoroutineScope,
private val statusBarInitializer: StatusBarInitializer,
- private val statusBarWindowController: StatusBarWindowController,
private val statusBarModeRepository: StatusBarModeRepositoryStore,
+ private val statusBarWindowControllerStore: StatusBarWindowControllerStore,
private val demoModeController: DemoModeController,
private val pluginDependencyProvider: PluginDependencyProvider,
private val autoHideController: AutoHideController,
@@ -157,7 +157,7 @@
private fun createAndAddWindow() {
initializeStatusBarFragment()
- statusBarWindowController.attach()
+ statusBarWindowControllerStore.defaultDisplay.attach()
}
private fun initializeStatusBarFragment() {
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/dagger/StatusBarModule.kt b/packages/SystemUI/src/com/android/systemui/statusbar/dagger/StatusBarModule.kt
index cd1642e..5aad11f 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/dagger/StatusBarModule.kt
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/dagger/StatusBarModule.kt
@@ -77,16 +77,6 @@
@Provides
@SysUISingleton
- fun defaultStatusBarWindowController(
- context: Context,
- viewCaptureAwareWindowManager: ViewCaptureAwareWindowManager,
- factory: StatusBarWindowControllerImpl.Factory,
- ): StatusBarWindowController {
- return factory.create(context, viewCaptureAwareWindowManager)
- }
-
- @Provides
- @SysUISingleton
fun windowControllerStore(
multiDisplayImplLazy: Lazy<MultiDisplayStatusBarWindowControllerStore>,
singleDisplayImplLazy: Lazy<SingleDisplayStatusBarWindowControllerStore>,
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/events/SystemEventChipAnimationController.kt b/packages/SystemUI/src/com/android/systemui/statusbar/events/SystemEventChipAnimationController.kt
index 118f5f0..bf7e879 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/events/SystemEventChipAnimationController.kt
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/events/SystemEventChipAnimationController.kt
@@ -34,7 +34,7 @@
import com.android.systemui.res.R
import com.android.systemui.statusbar.phone.StatusBarContentInsetsChangedListener
import com.android.systemui.statusbar.phone.StatusBarContentInsetsProvider
-import com.android.systemui.statusbar.window.StatusBarWindowController
+import com.android.systemui.statusbar.window.StatusBarWindowControllerStore
import com.android.systemui.util.animation.AnimationUtil.Companion.frames
import javax.inject.Inject
import kotlin.math.roundToInt
@@ -44,8 +44,8 @@
*/
class SystemEventChipAnimationController @Inject constructor(
private val context: Context,
- private val statusBarWindowController: StatusBarWindowController,
- private val contentInsetsProvider: StatusBarContentInsetsProvider
+ private val statusBarWindowControllerStore: StatusBarWindowControllerStore,
+ private val contentInsetsProvider: StatusBarContentInsetsProvider,
) : SystemStatusAnimationCallback {
private lateinit var animationWindowView: FrameLayout
@@ -244,7 +244,7 @@
val height = themedContext.resources.getDimensionPixelSize(R.dimen.status_bar_height)
val lp = FrameLayout.LayoutParams(MATCH_PARENT, height)
lp.gravity = Gravity.END or Gravity.TOP
- statusBarWindowController.addViewToWindow(animationWindowView, lp)
+ statusBarWindowControllerStore.defaultDisplay.addViewToWindow(animationWindowView, lp)
animationWindowView.clipToPadding = false
animationWindowView.clipChildren = false
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/events/SystemStatusAnimationSchedulerImpl.kt b/packages/SystemUI/src/com/android/systemui/statusbar/events/SystemStatusAnimationSchedulerImpl.kt
index f0e60dd..e34f61d 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/events/SystemStatusAnimationSchedulerImpl.kt
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/events/SystemStatusAnimationSchedulerImpl.kt
@@ -23,7 +23,7 @@
import androidx.core.animation.AnimatorSet
import com.android.systemui.dagger.qualifiers.Application
import com.android.systemui.dump.DumpManager
-import com.android.systemui.statusbar.window.StatusBarWindowController
+import com.android.systemui.statusbar.window.StatusBarWindowControllerStore
import com.android.systemui.util.Assert
import com.android.systemui.util.time.SystemClock
import java.io.PrintWriter
@@ -65,7 +65,7 @@
constructor(
private val coordinator: SystemEventCoordinator,
private val chipAnimationController: SystemEventChipAnimationController,
- private val statusBarWindowController: StatusBarWindowController,
+ private val statusBarWindowControllerStore: StatusBarWindowControllerStore,
dumpManager: DumpManager,
private val systemClock: SystemClock,
@Application private val coroutineScope: CoroutineScope,
@@ -277,7 +277,7 @@
private fun runChipAppearAnimation() {
Assert.isMainThread()
if (hasPersistentDot) {
- statusBarWindowController.setForceStatusBarVisible(true)
+ statusBarWindowControllerStore.defaultDisplay.setForceStatusBarVisible(true)
}
animationState.value = ANIMATING_IN
@@ -311,7 +311,7 @@
scheduledEvent.value != null -> ANIMATION_QUEUED
else -> IDLE
}
- statusBarWindowController.setForceStatusBarVisible(false)
+ statusBarWindowControllerStore.defaultDisplay.setForceStatusBarVisible(false)
}
}
)
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/gesture/SwipeStatusBarAwayGestureHandler.kt b/packages/SystemUI/src/com/android/systemui/statusbar/gesture/SwipeStatusBarAwayGestureHandler.kt
index 693ae66..ebaa3c4 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/gesture/SwipeStatusBarAwayGestureHandler.kt
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/gesture/SwipeStatusBarAwayGestureHandler.kt
@@ -20,7 +20,7 @@
import android.view.MotionEvent
import com.android.systemui.dagger.SysUISingleton
import com.android.systemui.settings.DisplayTracker
-import com.android.systemui.statusbar.window.StatusBarWindowController
+import com.android.systemui.statusbar.window.StatusBarWindowControllerStore
import javax.inject.Inject
/** A class to detect when a user swipes away the status bar. */
@@ -31,10 +31,11 @@
context: Context,
displayTracker: DisplayTracker,
logger: SwipeUpGestureLogger,
- private val statusBarWindowController: StatusBarWindowController,
+ private val statusBarWindowControllerStore: StatusBarWindowControllerStore,
) : SwipeUpGestureHandler(context, displayTracker, logger, loggerTag = LOGGER_TAG) {
override fun startOfGestureIsWithinBounds(ev: MotionEvent): Boolean {
// Gesture starts just below the status bar
+ val statusBarWindowController = statusBarWindowControllerStore.defaultDisplay
return ev.y >= statusBarWindowController.statusBarHeight &&
ev.y <= 3 * statusBarWindowController.statusBarHeight
}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/ActivityStarterInternalImpl.kt b/packages/SystemUI/src/com/android/systemui/statusbar/phone/ActivityStarterInternalImpl.kt
index 5b37468..d1338ea 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/ActivityStarterInternalImpl.kt
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/ActivityStarterInternalImpl.kt
@@ -58,7 +58,7 @@
import com.android.systemui.statusbar.NotificationShadeWindowController
import com.android.systemui.statusbar.notification.row.ExpandableNotificationRow
import com.android.systemui.statusbar.policy.domain.interactor.DeviceProvisioningInteractor
-import com.android.systemui.statusbar.window.StatusBarWindowController
+import com.android.systemui.statusbar.window.StatusBarWindowControllerStore
import com.android.systemui.user.domain.interactor.SelectedUserInteractor
import com.android.systemui.util.concurrency.DelayableExecutor
import com.android.systemui.util.kotlin.getOrNull
@@ -93,7 +93,7 @@
@Main private val mainExecutor: DelayableExecutor,
private val shadeControllerLazy: Lazy<ShadeController>,
private val communalSceneInteractor: CommunalSceneInteractor,
- private val statusBarWindowController: StatusBarWindowController,
+ private val statusBarWindowControllerStore: StatusBarWindowControllerStore,
private val keyguardViewMediatorLazy: Lazy<KeyguardViewMediator>,
private val shadeAnimationInteractor: ShadeAnimationInteractor,
private val notifShadeWindowControllerLazy: Lazy<NotificationShadeWindowController>,
@@ -562,7 +562,7 @@
}
val rootView = animationController.transitionContainer.rootView
val controllerFromStatusBar: Optional<ActivityTransitionAnimator.Controller> =
- statusBarWindowController.wrapAnimationControllerIfInStatusBar(
+ statusBarWindowControllerStore.defaultDisplay.wrapAnimationControllerIfInStatusBar(
rootView,
animationController
)
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/CentralSurfacesImpl.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/CentralSurfacesImpl.java
index 7e5b455..cb4454d 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/CentralSurfacesImpl.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/CentralSurfacesImpl.java
@@ -226,7 +226,7 @@
import com.android.systemui.statusbar.policy.HeadsUpManager;
import com.android.systemui.statusbar.policy.KeyguardStateController;
import com.android.systemui.statusbar.policy.UserInfoControllerImpl;
-import com.android.systemui.statusbar.window.StatusBarWindowController;
+import com.android.systemui.statusbar.window.StatusBarWindowControllerStore;
import com.android.systemui.statusbar.window.StatusBarWindowStateController;
import com.android.systemui.surfaceeffects.ripple.RippleShader.RippleShape;
import com.android.systemui.util.DumpUtilsKt;
@@ -372,7 +372,7 @@
@WindowVisibleState private int mStatusBarWindowState = WINDOW_STATE_SHOWING;
private final NotificationShadeWindowController mNotificationShadeWindowController;
private final StatusBarInitializer mStatusBarInitializer;
- private final StatusBarWindowController mStatusBarWindowController;
+ private final StatusBarWindowControllerStore mStatusBarWindowControllerStore;
private final StatusBarModeRepositoryStore mStatusBarModeRepository;
private final KeyguardUpdateMonitor mKeyguardUpdateMonitor;
@VisibleForTesting
@@ -610,7 +610,7 @@
LightBarController lightBarController,
AutoHideController autoHideController,
StatusBarInitializer statusBarInitializer,
- StatusBarWindowController statusBarWindowController,
+ StatusBarWindowControllerStore statusBarWindowControllerStore,
StatusBarWindowStateController statusBarWindowStateController,
StatusBarModeRepositoryStore statusBarModeRepository,
KeyguardUpdateMonitor keyguardUpdateMonitor,
@@ -716,7 +716,7 @@
mLightBarController = lightBarController;
mAutoHideController = autoHideController;
mStatusBarInitializer = statusBarInitializer;
- mStatusBarWindowController = statusBarWindowController;
+ mStatusBarWindowControllerStore = statusBarWindowControllerStore;
mStatusBarModeRepository = statusBarModeRepository;
mKeyguardUpdateMonitor = keyguardUpdateMonitor;
mPulseExpansionHandler = pulseExpansionHandler;
@@ -1894,7 +1894,7 @@
// When the StatusBarSimpleFragment flag is enabled, this logic will be done in
// StatusBarOrchestrator
if (!StatusBarSimpleFragment.isEnabled()) {
- mStatusBarWindowController.attach();
+ mStatusBarWindowControllerStore.getDefaultDisplay().attach();
}
}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/LegacyActivityStarterInternalImpl.kt b/packages/SystemUI/src/com/android/systemui/statusbar/phone/LegacyActivityStarterInternalImpl.kt
index 4604233..1cca3ae 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/LegacyActivityStarterInternalImpl.kt
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/LegacyActivityStarterInternalImpl.kt
@@ -57,7 +57,7 @@
import com.android.systemui.statusbar.notification.row.ExpandableNotificationRow
import com.android.systemui.statusbar.policy.DeviceProvisionedController
import com.android.systemui.statusbar.policy.KeyguardStateController
-import com.android.systemui.statusbar.window.StatusBarWindowController
+import com.android.systemui.statusbar.window.StatusBarWindowControllerStore
import com.android.systemui.util.concurrency.DelayableExecutor
import com.android.systemui.util.kotlin.getOrNull
import dagger.Lazy
@@ -85,7 +85,7 @@
private val context: Context,
@DisplayId private val displayId: Int,
private val lockScreenUserManager: NotificationLockscreenUserManager,
- private val statusBarWindowController: StatusBarWindowController,
+ private val statusBarWindowControllerStore: StatusBarWindowControllerStore,
private val wakefulnessLifecycle: WakefulnessLifecycle,
private val keyguardUpdateMonitor: KeyguardUpdateMonitor,
private val deviceProvisionedController: DeviceProvisionedController,
@@ -525,7 +525,7 @@
}
val rootView = animationController.transitionContainer.rootView
val controllerFromStatusBar: Optional<ActivityTransitionAnimator.Controller> =
- statusBarWindowController.wrapAnimationControllerIfInStatusBar(
+ statusBarWindowControllerStore.defaultDisplay.wrapAnimationControllerIfInStatusBar(
rootView,
animationController
)
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBarView.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBarView.java
index d6716a0..e7d9717 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBarView.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBarView.java
@@ -40,7 +40,7 @@
import com.android.systemui.Gefingerpoken;
import com.android.systemui.res.R;
import com.android.systemui.statusbar.phone.userswitcher.StatusBarUserSwitcherContainer;
-import com.android.systemui.statusbar.window.StatusBarWindowController;
+import com.android.systemui.statusbar.window.StatusBarWindowControllerStore;
import com.android.systemui.user.ui.binder.StatusBarUserChipViewBinder;
import com.android.systemui.user.ui.viewmodel.StatusBarUserChipViewModel;
import com.android.systemui.util.leak.RotationUtils;
@@ -49,7 +49,7 @@
public class PhoneStatusBarView extends FrameLayout {
private static final String TAG = "PhoneStatusBarView";
- private final StatusBarWindowController mStatusBarWindowController;
+ private final StatusBarWindowControllerStore mStatusBarWindowControllerStore;
private int mRotationOrientation = -1;
@Nullable
@@ -75,7 +75,7 @@
public PhoneStatusBarView(Context context, AttributeSet attrs) {
super(context, attrs);
- mStatusBarWindowController = Dependency.get(StatusBarWindowController.class);
+ mStatusBarWindowControllerStore = Dependency.get(StatusBarWindowControllerStore.class);
}
void setTouchEventHandler(Gefingerpoken handler) {
@@ -326,7 +326,7 @@
if (Flags.statusBarStopUpdatingWindowHeight()) {
return;
}
- mStatusBarWindowController.refreshStatusBarHeight();
+ mStatusBarWindowControllerStore.getDefaultDisplay().refreshStatusBarHeight();
}
interface HasCornerCutoutFetcher {
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarHeadsUpChangeListener.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarHeadsUpChangeListener.java
index 8f2d4f9..7145ffe 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarHeadsUpChangeListener.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarHeadsUpChangeListener.java
@@ -28,7 +28,7 @@
import com.android.systemui.statusbar.notification.stack.NotificationStackScrollLayoutController;
import com.android.systemui.statusbar.policy.HeadsUpManager;
import com.android.systemui.statusbar.policy.OnHeadsUpChangedListener;
-import com.android.systemui.statusbar.window.StatusBarWindowController;
+import com.android.systemui.statusbar.window.StatusBarWindowControllerStore;
import javax.inject.Inject;
@@ -38,7 +38,7 @@
@SysUISingleton
public class StatusBarHeadsUpChangeListener implements OnHeadsUpChangedListener, CoreStartable {
private final NotificationShadeWindowController mNotificationShadeWindowController;
- private final StatusBarWindowController mStatusBarWindowController;
+ private final StatusBarWindowControllerStore mStatusBarWindowControllerStore;
private final ShadeViewController mShadeViewController;
private final PanelExpansionInteractor mPanelExpansionInteractor;
private final NotificationStackScrollLayoutController mNsslController;
@@ -50,7 +50,7 @@
@Inject
StatusBarHeadsUpChangeListener(
NotificationShadeWindowController notificationShadeWindowController,
- StatusBarWindowController statusBarWindowController,
+ StatusBarWindowControllerStore statusBarWindowControllerStore,
ShadeViewController shadeViewController,
PanelExpansionInteractor panelExpansionInteractor,
NotificationStackScrollLayoutController nsslController,
@@ -59,7 +59,7 @@
StatusBarStateController statusBarStateController,
NotificationRemoteInputManager notificationRemoteInputManager) {
mNotificationShadeWindowController = notificationShadeWindowController;
- mStatusBarWindowController = statusBarWindowController;
+ mStatusBarWindowControllerStore = statusBarWindowControllerStore;
mShadeViewController = shadeViewController;
mPanelExpansionInteractor = panelExpansionInteractor;
mNsslController = nsslController;
@@ -78,7 +78,7 @@
public void onHeadsUpPinnedModeChanged(boolean inPinnedMode) {
if (inPinnedMode) {
mNotificationShadeWindowController.setHeadsUpShowing(true);
- mStatusBarWindowController.setForceStatusBarVisible(true);
+ mStatusBarWindowControllerStore.getDefaultDisplay().setForceStatusBarVisible(true);
if (mPanelExpansionInteractor.isFullyCollapsed()) {
mShadeViewController.updateTouchableRegion();
}
@@ -93,7 +93,9 @@
// open artificially.
mNotificationShadeWindowController.setHeadsUpShowing(false);
if (bypassKeyguard) {
- mStatusBarWindowController.setForceStatusBarVisible(false);
+ mStatusBarWindowControllerStore
+ .getDefaultDisplay()
+ .setForceStatusBarVisible(false);
}
} else {
// we need to keep the panel open artificially, let's wait until the
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/dagger/StatusBarPhoneModule.kt b/packages/SystemUI/src/com/android/systemui/statusbar/phone/dagger/StatusBarPhoneModule.kt
index 5b03198..5f864e5 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/dagger/StatusBarPhoneModule.kt
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/dagger/StatusBarPhoneModule.kt
@@ -15,12 +15,18 @@
*/
package com.android.systemui.statusbar.phone.dagger
+import android.view.Display
import com.android.systemui.CoreStartable
import com.android.systemui.dagger.SysUISingleton
+import com.android.systemui.dagger.qualifiers.Default
import com.android.systemui.statusbar.CommandQueue
import com.android.systemui.statusbar.core.CommandQueueInitializer
+import com.android.systemui.statusbar.core.MultiDisplayStatusBarInitializerStore
+import com.android.systemui.statusbar.core.SingleDisplayStatusBarInitializerStore
+import com.android.systemui.statusbar.core.StatusBarConnectedDisplays
import com.android.systemui.statusbar.core.StatusBarInitializer
import com.android.systemui.statusbar.core.StatusBarInitializerImpl
+import com.android.systemui.statusbar.core.StatusBarInitializerStore
import com.android.systemui.statusbar.core.StatusBarOrchestrator
import com.android.systemui.statusbar.core.StatusBarSimpleFragment
import com.android.systemui.statusbar.phone.CentralSurfacesCommandQueueCallbacks
@@ -47,15 +53,31 @@
impl: CentralSurfacesCommandQueueCallbacks
): CommandQueue.Callbacks
+ @Binds
+ fun initializerFactory(
+ implFactory: StatusBarInitializerImpl.Factory
+ ): StatusBarInitializer.Factory
+
/** Binds {@link StatusBarInitializer} as a {@link CoreStartable}. */
@Binds
@IntoMap
@ClassKey(StatusBarInitializerImpl::class)
- fun bindStatusBarInitializer(impl: StatusBarInitializerImpl): CoreStartable
+ fun bindStatusBarInitializer(@Default impl: StatusBarInitializerImpl): CoreStartable
- @Binds fun statusBarInitializer(impl: StatusBarInitializerImpl): StatusBarInitializer
+ @Binds fun statusBarInitializer(@Default impl: StatusBarInitializerImpl): StatusBarInitializer
companion object {
+ // Dagger doesn't support providing AssistedInject types, without a qualifier. Using the
+ // Default qualifier for this reason.
+ @Default
+ @Provides
+ @SysUISingleton
+ fun statusBarInitializerImpl(
+ implFactory: StatusBarInitializerImpl.Factory
+ ): StatusBarInitializerImpl {
+ return implFactory.create(displayId = Display.DEFAULT_DISPLAY)
+ }
+
@Provides
@SysUISingleton
@IntoMap
@@ -83,5 +105,32 @@
CoreStartable.NOP
}
}
+
+ @Provides
+ @SysUISingleton
+ @IntoMap
+ @ClassKey(StatusBarInitializerStore::class)
+ fun initializerStoreAsCoreStartable(
+ multiDisplayStoreLazy: Lazy<MultiDisplayStatusBarInitializerStore>
+ ): CoreStartable {
+ return if (StatusBarConnectedDisplays.isEnabled) {
+ multiDisplayStoreLazy.get()
+ } else {
+ CoreStartable.NOP
+ }
+ }
+
+ @Provides
+ @SysUISingleton
+ fun initializerStore(
+ singleDisplayStoreLazy: Lazy<SingleDisplayStatusBarInitializerStore>,
+ multiDisplayStoreLazy: Lazy<MultiDisplayStatusBarInitializerStore>,
+ ): StatusBarInitializerStore {
+ return if (StatusBarConnectedDisplays.isEnabled) {
+ multiDisplayStoreLazy.get()
+ } else {
+ singleDisplayStoreLazy.get()
+ }
+ }
}
}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/fragment/dagger/StatusBarFragmentModule.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/fragment/dagger/StatusBarFragmentModule.java
index f026b99..cf877a7 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/fragment/dagger/StatusBarFragmentModule.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/fragment/dagger/StatusBarFragmentModule.java
@@ -29,6 +29,7 @@
import com.android.systemui.statusbar.phone.StatusBarLocation;
import com.android.systemui.statusbar.policy.Clock;
import com.android.systemui.statusbar.window.StatusBarWindowController;
+import com.android.systemui.statusbar.window.StatusBarWindowControllerStore;
import dagger.Module;
import dagger.Provides;
@@ -125,9 +126,9 @@
@StatusBarFragmentScope
static PhoneStatusBarTransitions providePhoneStatusBarTransitions(
@RootView PhoneStatusBarView view,
- StatusBarWindowController statusBarWindowController
- ) {
- return new PhoneStatusBarTransitions(view, statusBarWindowController.getBackgroundView());
+ StatusBarWindowControllerStore statusBarWindowControllerStore) {
+ return new PhoneStatusBarTransitions(
+ view, statusBarWindowControllerStore.getDefaultDisplay().getBackgroundView());
}
/** */
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/ongoingcall/OngoingCallController.kt b/packages/SystemUI/src/com/android/systemui/statusbar/phone/ongoingcall/OngoingCallController.kt
index bd6a1c0..3cf8c3f 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/ongoingcall/OngoingCallController.kt
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/ongoingcall/OngoingCallController.kt
@@ -52,7 +52,7 @@
import com.android.systemui.statusbar.phone.ongoingcall.data.repository.OngoingCallRepository
import com.android.systemui.statusbar.phone.ongoingcall.shared.model.OngoingCallModel
import com.android.systemui.statusbar.policy.CallbackController
-import com.android.systemui.statusbar.window.StatusBarWindowController
+import com.android.systemui.statusbar.window.StatusBarWindowControllerStore
import com.android.systemui.util.time.SystemClock
import java.io.PrintWriter
import java.util.concurrent.Executor
@@ -75,7 +75,7 @@
@Main private val mainExecutor: Executor,
private val iActivityManager: IActivityManager,
private val dumpManager: DumpManager,
- private val statusBarWindowController: StatusBarWindowController,
+ private val statusBarWindowControllerStore: StatusBarWindowControllerStore,
private val swipeStatusBarAwayGestureHandler: SwipeStatusBarAwayGestureHandler,
private val statusBarModeRepository: StatusBarModeRepositoryStore,
@OngoingCallLog private val logger: LogBuffer,
@@ -205,7 +205,9 @@
this.chipView = chipView
val backgroundView: ChipBackgroundContainer? =
chipView.findViewById(R.id.ongoing_activity_chip_background)
- backgroundView?.maxHeightFetcher = { statusBarWindowController.statusBarHeight }
+ backgroundView?.maxHeightFetcher = {
+ statusBarWindowControllerStore.defaultDisplay.statusBarHeight
+ }
if (hasOngoingCall()) {
updateChip()
}
@@ -339,7 +341,8 @@
// But, this class still needs to do the non-display logic regardless of the flag.
uidObserver.registerWithUid(currentCallNotificationInfo.uid)
if (!currentCallNotificationInfo.statusBarSwipedAway) {
- statusBarWindowController.setOngoingProcessRequiresStatusBarVisible(true)
+ statusBarWindowControllerStore.defaultDisplay
+ .setOngoingProcessRequiresStatusBarVisible(true)
}
updateGestureListening()
sendStateChangeEvent()
@@ -405,7 +408,9 @@
if (!Flags.statusBarScreenSharingChips()) {
tearDownChipView()
}
- statusBarWindowController.setOngoingProcessRequiresStatusBarVisible(false)
+ statusBarWindowControllerStore.defaultDisplay.setOngoingProcessRequiresStatusBarVisible(
+ false
+ )
swipeStatusBarAwayGestureHandler.removeOnGestureDetectedCallback(TAG)
sendStateChangeEvent()
uidObserver.unregister()
@@ -429,7 +434,9 @@
private fun onSwipeAwayGestureDetected() {
logger.log(TAG, LogLevel.DEBUG, {}, { "Swipe away gesture detected" })
callNotificationInfo = callNotificationInfo?.copy(statusBarSwipedAway = true)
- statusBarWindowController.setOngoingProcessRequiresStatusBarVisible(false)
+ statusBarWindowControllerStore.defaultDisplay.setOngoingProcessRequiresStatusBarVisible(
+ false
+ )
swipeStatusBarAwayGestureHandler.removeOnGestureDetectedCallback(TAG)
}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/window/StatusBarWindowControllerStore.kt b/packages/SystemUI/src/com/android/systemui/statusbar/window/StatusBarWindowControllerStore.kt
index 5f30b37..7d0dadc 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/window/StatusBarWindowControllerStore.kt
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/window/StatusBarWindowControllerStore.kt
@@ -16,6 +16,7 @@
package com.android.systemui.statusbar.window
+import android.content.Context
import android.view.Display
import android.view.WindowManager
import com.android.app.viewcapture.ViewCaptureAwareWindowManager
@@ -105,12 +106,19 @@
@SysUISingleton
class SingleDisplayStatusBarWindowControllerStore
@Inject
-constructor(private val controller: StatusBarWindowController) : StatusBarWindowControllerStore {
+constructor(
+ context: Context,
+ viewCaptureAwareWindowManager: ViewCaptureAwareWindowManager,
+ factory: StatusBarWindowControllerImpl.Factory,
+) : StatusBarWindowControllerStore {
init {
StatusBarConnectedDisplays.assertInLegacyMode()
}
+ private val controller: StatusBarWindowController =
+ factory.create(context, viewCaptureAwareWindowManager)
+
override val defaultDisplay = controller
override fun forDisplay(displayId: Int) = controller
diff --git a/packages/SystemUI/tests/src/com/android/systemui/globalactions/GlobalActionsDialogLiteTest.java b/packages/SystemUI/tests/src/com/android/systemui/globalactions/GlobalActionsDialogLiteTest.java
index ae635b8..df50f76 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/globalactions/GlobalActionsDialogLiteTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/globalactions/GlobalActionsDialogLiteTest.java
@@ -77,6 +77,7 @@
import com.android.systemui.statusbar.policy.ConfigurationController;
import com.android.systemui.statusbar.policy.KeyguardStateController;
import com.android.systemui.statusbar.window.StatusBarWindowController;
+import com.android.systemui.statusbar.window.StatusBarWindowControllerStore;
import com.android.systemui.telephony.TelephonyListenerManager;
import com.android.systemui.user.domain.interactor.SelectedUserInteractor;
import com.android.systemui.util.RingerModeLiveData;
@@ -125,6 +126,7 @@
@Mock private LightBarController mLightBarController;
@Mock private NotificationShadeWindowController mNotificationShadeWindowController;
@Mock private StatusBarWindowController mStatusBarWindowController;
+ @Mock private StatusBarWindowControllerStore mStatusBarWindowControllerStore;
@Mock private IWindowManager mWindowManager;
@Mock private Executor mBackgroundExecutor;
@Mock private UiEventLogger mUiEventLogger;
@@ -155,7 +157,8 @@
when(mUserContextProvider.getUserContext()).thenReturn(mContext);
when(mResources.getConfiguration()).thenReturn(
getContext().getResources().getConfiguration());
-
+ when(mStatusBarWindowControllerStore.getDefaultDisplay())
+ .thenReturn(mStatusBarWindowController);
mGlobalSettings = new FakeGlobalSettings();
mSecureSettings = new FakeSettings();
mInteractor = mKosmos.getGlobalActionsInteractor();
@@ -184,7 +187,7 @@
mStatusBarService,
mLightBarController,
mNotificationShadeWindowController,
- mStatusBarWindowController,
+ mStatusBarWindowControllerStore,
mWindowManager,
mBackgroundExecutor,
mUiEventLogger,
diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/core/MultiDisplayStatusBarInitializerStoreTest.kt b/packages/SystemUI/tests/src/com/android/systemui/statusbar/core/MultiDisplayStatusBarInitializerStoreTest.kt
new file mode 100644
index 0000000..0d1d37a
--- /dev/null
+++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/core/MultiDisplayStatusBarInitializerStoreTest.kt
@@ -0,0 +1,97 @@
+/*
+ * Copyright (C) 2024 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.systemui.statusbar.core
+
+import android.platform.test.annotations.EnableFlags
+import android.view.Display
+import androidx.test.ext.junit.runners.AndroidJUnit4
+import androidx.test.filters.SmallTest
+import com.android.systemui.SysuiTestCase
+import com.android.systemui.display.data.repository.displayRepository
+import com.android.systemui.kosmos.testDispatcher
+import com.android.systemui.kosmos.testScope
+import com.android.systemui.kosmos.unconfinedTestDispatcher
+import com.android.systemui.testKosmos
+import com.google.common.truth.Truth.assertThat
+import kotlinx.coroutines.runBlocking
+import kotlinx.coroutines.test.runTest
+import org.junit.Before
+import org.junit.Test
+import org.junit.runner.RunWith
+
+@RunWith(AndroidJUnit4::class)
+@SmallTest
+@EnableFlags(StatusBarConnectedDisplays.FLAG_NAME)
+class MultiDisplayStatusBarInitializerStoreTest : SysuiTestCase() {
+
+ private val kosmos =
+ testKosmos().also {
+ // Using unconfinedTestDispatcher to avoid having to call `runCurrent` in the tests.
+ it.testDispatcher = it.unconfinedTestDispatcher
+ }
+ private val testScope = kosmos.testScope
+ private val fakeDisplayRepository = kosmos.displayRepository
+ private val store = kosmos.multiDisplayStatusBarInitializerStore
+
+ @Before
+ fun start() {
+ store.start()
+ }
+
+ @Before
+ fun addDisplays() = runBlocking {
+ fakeDisplayRepository.addDisplay(DEFAULT_DISPLAY_ID)
+ fakeDisplayRepository.addDisplay(NON_DEFAULT_DISPLAY_ID)
+ }
+
+ @Test
+ fun forDisplay_defaultDisplay_multipleCalls_returnsSameInstance() =
+ testScope.runTest {
+ val controller = store.defaultDisplay
+
+ assertThat(store.defaultDisplay).isSameInstanceAs(controller)
+ }
+
+ @Test
+ fun forDisplay_nonDefaultDisplay_multipleCalls_returnsSameInstance() =
+ testScope.runTest {
+ val controller = store.forDisplay(NON_DEFAULT_DISPLAY_ID)
+
+ assertThat(store.forDisplay(NON_DEFAULT_DISPLAY_ID)).isSameInstanceAs(controller)
+ }
+
+ @Test
+ fun forDisplay_nonDefaultDisplay_afterDisplayRemoved_returnsNewInstance() =
+ testScope.runTest {
+ val controller = store.forDisplay(NON_DEFAULT_DISPLAY_ID)
+
+ fakeDisplayRepository.removeDisplay(NON_DEFAULT_DISPLAY_ID)
+ fakeDisplayRepository.addDisplay(NON_DEFAULT_DISPLAY_ID)
+
+ assertThat(store.forDisplay(NON_DEFAULT_DISPLAY_ID)).isNotSameInstanceAs(controller)
+ }
+
+ @Test(expected = IllegalArgumentException::class)
+ fun forDisplay_nonExistingDisplayId_throws() =
+ testScope.runTest { store.forDisplay(NON_EXISTING_DISPLAY_ID) }
+
+ companion object {
+ private const val DEFAULT_DISPLAY_ID = Display.DEFAULT_DISPLAY
+ private const val NON_DEFAULT_DISPLAY_ID = Display.DEFAULT_DISPLAY + 1
+ private const val NON_EXISTING_DISPLAY_ID = Display.DEFAULT_DISPLAY + 2
+ }
+}
diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/events/SystemStatusAnimationSchedulerImplTest.kt b/packages/SystemUI/tests/src/com/android/systemui/statusbar/events/SystemStatusAnimationSchedulerImplTest.kt
index 376873d..5d8a8fd 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/events/SystemStatusAnimationSchedulerImplTest.kt
+++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/events/SystemStatusAnimationSchedulerImplTest.kt
@@ -31,6 +31,7 @@
import com.android.systemui.statusbar.BatteryStatusChip
import com.android.systemui.statusbar.phone.StatusBarContentInsetsProvider
import com.android.systemui.statusbar.window.StatusBarWindowController
+import com.android.systemui.statusbar.window.StatusBarWindowControllerStore
import com.android.systemui.util.mockito.any
import com.android.systemui.util.mockito.eq
import com.android.systemui.util.mockito.mock
@@ -63,6 +64,7 @@
@Mock private lateinit var systemEventCoordinator: SystemEventCoordinator
@Mock private lateinit var statusBarWindowController: StatusBarWindowController
+ @Mock private lateinit var statusBarWindowControllerStore: StatusBarWindowControllerStore
@Mock private lateinit var statusBarContentInsetProvider: StatusBarContentInsetsProvider
@@ -82,12 +84,14 @@
fun setup() {
MockitoAnnotations.initMocks(this)
+ whenever(statusBarWindowControllerStore.defaultDisplay)
+ .thenReturn(statusBarWindowController)
systemClock = FakeSystemClock()
chipAnimationController =
SystemEventChipAnimationController(
mContext,
- statusBarWindowController,
- statusBarContentInsetProvider
+ statusBarWindowControllerStore,
+ statusBarContentInsetProvider,
)
// StatusBarContentInsetProvider is mocked. Ensure that it returns some mocked values.
@@ -660,7 +664,7 @@
SystemStatusAnimationSchedulerImpl(
systemEventCoordinator,
chipAnimationController,
- statusBarWindowController,
+ statusBarWindowControllerStore,
dumpManager,
systemClock,
CoroutineScope(StandardTestDispatcher(testScope.testScheduler)),
diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/CentralSurfacesImplTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/CentralSurfacesImplTest.java
index 15ea811..40b8cdaf 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/CentralSurfacesImplTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/CentralSurfacesImplTest.java
@@ -170,6 +170,7 @@
import com.android.systemui.statusbar.StatusBarStateControllerImpl;
import com.android.systemui.statusbar.core.StatusBarInitializerImpl;
import com.android.systemui.statusbar.core.StatusBarOrchestrator;
+import com.android.systemui.statusbar.core.StatusBarSimpleFragment;
import com.android.systemui.statusbar.data.repository.FakeStatusBarModeRepository;
import com.android.systemui.statusbar.notification.NotifPipelineFlags;
import com.android.systemui.statusbar.notification.NotificationActivityStarter;
@@ -194,6 +195,7 @@
import com.android.systemui.statusbar.policy.KeyguardStateController;
import com.android.systemui.statusbar.policy.UserInfoControllerImpl;
import com.android.systemui.statusbar.window.StatusBarWindowController;
+import com.android.systemui.statusbar.window.StatusBarWindowControllerStore;
import com.android.systemui.statusbar.window.StatusBarWindowStateController;
import com.android.systemui.util.FakeEventLog;
import com.android.systemui.util.WallpaperController;
@@ -292,6 +294,7 @@
@Mock private KeyguardBypassController mKeyguardBypassController;
@Mock private AutoHideController mAutoHideController;
@Mock private StatusBarWindowController mStatusBarWindowController;
+ @Mock private StatusBarWindowControllerStore mStatusBarWindowControllerStore;
@Mock private Provider<CollapsedStatusBarFragment> mCollapsedStatusBarFragmentProvider;
@Mock private StatusBarWindowStateController mStatusBarWindowStateController;
@Mock private Bubbles mBubbles;
@@ -383,6 +386,9 @@
when(mBubbles.canShowBubbleNotification()).thenReturn(true);
+ when(mStatusBarWindowControllerStore.getDefaultDisplay())
+ .thenReturn(mStatusBarWindowController);
+
mVisualInterruptionDecisionProvider =
VisualInterruptionDecisionProviderTestUtil.INSTANCE.createProviderByFlag(
mAmbientDisplayConfiguration,
@@ -465,7 +471,7 @@
mKeyguardStateController,
mStatusBarStateController,
mStatusBarKeyguardViewManager,
- mStatusBarWindowController,
+ mStatusBarWindowControllerStore,
mDeviceProvisionedController,
mNotificationShadeWindowController,
0,
@@ -507,10 +513,11 @@
mLightBarController,
mAutoHideController,
new StatusBarInitializerImpl(
- mStatusBarWindowController,
+ mContext.getDisplayId(),
+ mStatusBarWindowControllerStore,
mCollapsedStatusBarFragmentProvider,
emptySet()),
- mStatusBarWindowController,
+ mStatusBarWindowControllerStore,
mStatusBarWindowStateController,
new FakeStatusBarModeRepository(),
mKeyguardUpdateMonitor,
@@ -1149,6 +1156,7 @@
}
@Test
+ @DisableFlags(StatusBarSimpleFragment.FLAG_NAME)
public void bubbleBarVisibility() {
createCentralSurfaces();
mCentralSurfaces.onStatusBarWindowStateChanged(WINDOW_STATE_HIDDEN);
diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/PhoneStatusBarViewTest.kt b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/PhoneStatusBarViewTest.kt
index 68df748..ee79ca0 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/PhoneStatusBarViewTest.kt
+++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/PhoneStatusBarViewTest.kt
@@ -38,6 +38,7 @@
import com.android.systemui.SysuiTestCase
import com.android.systemui.res.R
import com.android.systemui.statusbar.window.StatusBarWindowController
+import com.android.systemui.statusbar.window.StatusBarWindowControllerStore
import com.android.systemui.util.mockito.mock
import com.android.systemui.util.mockito.whenever
import com.google.common.truth.Truth.assertThat
@@ -57,10 +58,15 @@
get() = view.requireViewById(R.id.system_icons)
private val windowController = mock<StatusBarWindowController>()
+ private val windowControllerStore = mock<StatusBarWindowControllerStore>()
@Before
fun setUp() {
- mDependency.injectTestDependency(StatusBarWindowController::class.java, windowController)
+ whenever(windowControllerStore.defaultDisplay).thenReturn(windowController)
+ mDependency.injectTestDependency(
+ StatusBarWindowControllerStore::class.java,
+ windowControllerStore,
+ )
context.ensureTestableResources()
view = spy(createStatusBarView())
whenever(view.rootWindowInsets).thenReturn(emptyWindowInsets())
diff --git a/packages/SystemUI/tests/utils/src/com/android/systemui/display/data/repository/FakeDisplayRepository.kt b/packages/SystemUI/tests/utils/src/com/android/systemui/display/data/repository/FakeDisplayRepository.kt
index fcc83b3..78ea700 100644
--- a/packages/SystemUI/tests/utils/src/com/android/systemui/display/data/repository/FakeDisplayRepository.kt
+++ b/packages/SystemUI/tests/utils/src/com/android/systemui/display/data/repository/FakeDisplayRepository.kt
@@ -53,6 +53,10 @@
private val displayAdditionEventFlow = MutableSharedFlow<Display?>(replay = 0)
private val displayRemovalEventFlow = MutableSharedFlow<Int>(replay = 0)
+ suspend fun addDisplay(displayId: Int, type: Int = Display.TYPE_EXTERNAL) {
+ addDisplay(display(type, id = displayId))
+ }
+
suspend fun addDisplay(display: Display) {
flow.value += display
displayAdditionEventFlow.emit(display)
diff --git a/packages/SystemUI/tests/utils/src/com/android/systemui/shade/ShadeControllerKosmos.kt b/packages/SystemUI/tests/utils/src/com/android/systemui/shade/ShadeControllerKosmos.kt
index ddcc6d6..b9f0c9a 100644
--- a/packages/SystemUI/tests/utils/src/com/android/systemui/shade/ShadeControllerKosmos.kt
+++ b/packages/SystemUI/tests/utils/src/com/android/systemui/shade/ShadeControllerKosmos.kt
@@ -37,7 +37,7 @@
import com.android.systemui.statusbar.phone.statusBarKeyguardViewManager
import com.android.systemui.statusbar.policy.KeyguardStateController
import com.android.systemui.statusbar.policy.deviceProvisionedController
-import com.android.systemui.statusbar.window.StatusBarWindowController
+import com.android.systemui.statusbar.window.StatusBarWindowControllerStore
import com.android.systemui.util.mockito.mock
import kotlinx.coroutines.ExperimentalCoroutinesApi
@@ -67,7 +67,7 @@
mock<KeyguardStateController>(),
statusBarStateController,
statusBarKeyguardViewManager,
- mock<StatusBarWindowController>(),
+ mock<StatusBarWindowControllerStore>(),
deviceProvisionedController,
mock<NotificationShadeWindowController>(),
0,
diff --git a/packages/SystemUI/tests/utils/src/com/android/systemui/statusbar/core/FakeStatusBarInitializerFactory.kt b/packages/SystemUI/tests/utils/src/com/android/systemui/statusbar/core/FakeStatusBarInitializerFactory.kt
new file mode 100644
index 0000000..73ed228
--- /dev/null
+++ b/packages/SystemUI/tests/utils/src/com/android/systemui/statusbar/core/FakeStatusBarInitializerFactory.kt
@@ -0,0 +1,29 @@
+/*
+ * Copyright (C) 2024 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.systemui.statusbar.core
+
+import com.android.systemui.statusbar.phone.PhoneStatusBarTransitions
+import com.android.systemui.statusbar.phone.PhoneStatusBarViewController
+
+class FakeStatusBarInitializerFactory(
+ private val statusBarViewController: PhoneStatusBarViewController,
+ private val statusBarTransitions: PhoneStatusBarTransitions,
+) : StatusBarInitializer.Factory {
+
+ override fun create(displayId: Int): StatusBarInitializer =
+ FakeStatusBarInitializer(statusBarViewController, statusBarTransitions)
+}
diff --git a/packages/SystemUI/tests/utils/src/com/android/systemui/statusbar/core/StatusBarInitializerKosmos.kt b/packages/SystemUI/tests/utils/src/com/android/systemui/statusbar/core/StatusBarInitializerKosmos.kt
index d103200..7ad715b 100644
--- a/packages/SystemUI/tests/utils/src/com/android/systemui/statusbar/core/StatusBarInitializerKosmos.kt
+++ b/packages/SystemUI/tests/utils/src/com/android/systemui/statusbar/core/StatusBarInitializerKosmos.kt
@@ -16,7 +16,9 @@
package com.android.systemui.statusbar.core
+import com.android.systemui.display.data.repository.displayRepository
import com.android.systemui.kosmos.Kosmos
+import com.android.systemui.kosmos.applicationCoroutineScope
import com.android.systemui.statusbar.phone.phoneStatusBarTransitions
import com.android.systemui.statusbar.phone.phoneStatusBarViewController
@@ -26,3 +28,20 @@
}
var Kosmos.statusBarInitializer by Kosmos.Fixture { fakeStatusBarInitializer }
+
+val Kosmos.fakeStatusBarInitializerFactory by
+ Kosmos.Fixture {
+ FakeStatusBarInitializerFactory(phoneStatusBarViewController, phoneStatusBarTransitions)
+ }
+
+var Kosmos.statusBarInitializerFactory: StatusBarInitializer.Factory by
+ Kosmos.Fixture { fakeStatusBarInitializerFactory }
+
+val Kosmos.multiDisplayStatusBarInitializerStore by
+ Kosmos.Fixture {
+ MultiDisplayStatusBarInitializerStore(
+ applicationCoroutineScope,
+ fakeStatusBarInitializerFactory,
+ displayRepository,
+ )
+ }
diff --git a/packages/SystemUI/tests/utils/src/com/android/systemui/statusbar/core/StatusBarOrchestratorKosmos.kt b/packages/SystemUI/tests/utils/src/com/android/systemui/statusbar/core/StatusBarOrchestratorKosmos.kt
index c53e44d..54de293 100644
--- a/packages/SystemUI/tests/utils/src/com/android/systemui/statusbar/core/StatusBarOrchestratorKosmos.kt
+++ b/packages/SystemUI/tests/utils/src/com/android/systemui/statusbar/core/StatusBarOrchestratorKosmos.kt
@@ -28,7 +28,7 @@
import com.android.systemui.statusbar.mockNotificationRemoteInputManager
import com.android.systemui.statusbar.phone.mockAutoHideController
import com.android.systemui.statusbar.window.data.repository.statusBarWindowStateRepositoryStore
-import com.android.systemui.statusbar.window.fakeStatusBarWindowController
+import com.android.systemui.statusbar.window.fakeStatusBarWindowControllerStore
import com.android.wm.shell.bubbles.bubblesOptional
val Kosmos.statusBarOrchestrator by
@@ -36,8 +36,8 @@
StatusBarOrchestrator(
applicationCoroutineScope,
fakeStatusBarInitializer,
- fakeStatusBarWindowController,
fakeStatusBarModeRepository,
+ fakeStatusBarWindowControllerStore,
mockDemoModeController,
mockPluginDependencyProvider,
mockAutoHideController,
diff --git a/packages/SystemUI/tests/utils/src/com/android/systemui/statusbar/window/FakeStatusBarWindowControllerStore.kt b/packages/SystemUI/tests/utils/src/com/android/systemui/statusbar/window/FakeStatusBarWindowControllerStore.kt
index d19e322..35f95b6 100644
--- a/packages/SystemUI/tests/utils/src/com/android/systemui/statusbar/window/FakeStatusBarWindowControllerStore.kt
+++ b/packages/SystemUI/tests/utils/src/com/android/systemui/statusbar/window/FakeStatusBarWindowControllerStore.kt
@@ -22,10 +22,10 @@
private val perDisplayControllers = mutableMapOf<Int, FakeStatusBarWindowController>()
- override val defaultDisplay
+ override val defaultDisplay: FakeStatusBarWindowController
get() = forDisplay(Display.DEFAULT_DISPLAY)
- override fun forDisplay(displayId: Int): StatusBarWindowController {
+ override fun forDisplay(displayId: Int): FakeStatusBarWindowController {
return perDisplayControllers.computeIfAbsent(displayId) { FakeStatusBarWindowController() }
}
}
diff --git a/packages/SystemUI/tests/utils/src/com/android/systemui/statusbar/window/StatusBarWindowControllerKosmos.kt b/packages/SystemUI/tests/utils/src/com/android/systemui/statusbar/window/StatusBarWindowControllerKosmos.kt
index 6c6f243..78caf93 100644
--- a/packages/SystemUI/tests/utils/src/com/android/systemui/statusbar/window/StatusBarWindowControllerKosmos.kt
+++ b/packages/SystemUI/tests/utils/src/com/android/systemui/statusbar/window/StatusBarWindowControllerKosmos.kt
@@ -20,7 +20,8 @@
val Kosmos.fakeStatusBarWindowController by Kosmos.Fixture { FakeStatusBarWindowController() }
-var Kosmos.statusBarWindowController by Kosmos.Fixture { fakeStatusBarWindowController }
+var Kosmos.statusBarWindowController: StatusBarWindowController by
+ Kosmos.Fixture { fakeStatusBarWindowController }
val Kosmos.fakeStatusBarWindowControllerStore by
Kosmos.Fixture { FakeStatusBarWindowControllerStore() }
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/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/VcnManagementService.java b/services/core/java/com/android/server/VcnManagementService.java
index 12e8c57..947f6b7 100644
--- a/services/core/java/com/android/server/VcnManagementService.java
+++ b/services/core/java/com/android/server/VcnManagementService.java
@@ -48,7 +48,6 @@
import android.net.Network;
import android.net.NetworkCapabilities;
import android.net.NetworkRequest;
-import android.net.vcn.Flags;
import android.net.vcn.IVcnManagementService;
import android.net.vcn.IVcnStatusCallback;
import android.net.vcn.IVcnUnderlyingNetworkPolicyListener;
@@ -447,22 +446,16 @@
}
final UserHandle userHandle = UserHandle.getUserHandleForUid(uid);
+ final UserManager userManager = mContext.getSystemService(UserManager.class);
- if (Flags.enforceMainUser()) {
- final UserManager userManager = mContext.getSystemService(UserManager.class);
-
- Binder.withCleanCallingIdentity(
- () -> {
- if (!Objects.equals(userManager.getMainUser(), userHandle)) {
- throw new SecurityException(
- "VcnManagementService can only be used by callers running as"
- + " the main user");
- }
- });
- } else if (!userHandle.isSystem()) {
- throw new SecurityException(
- "VcnManagementService can only be used by callers running as the primary user");
- }
+ Binder.withCleanCallingIdentity(
+ () -> {
+ if (!Objects.equals(userManager.getMainUser(), userHandle)) {
+ throw new SecurityException(
+ "VcnManagementService can only be used by callers running as"
+ + " the main user");
+ }
+ });
}
private void enforceCallingUserAndCarrierPrivilege(
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/vcn/routeselection/IpSecPacketLossDetector.java b/services/core/java/com/android/server/vcn/routeselection/IpSecPacketLossDetector.java
index 5f704a0..6f1e15b 100644
--- a/services/core/java/com/android/server/vcn/routeselection/IpSecPacketLossDetector.java
+++ b/services/core/java/com/android/server/vcn/routeselection/IpSecPacketLossDetector.java
@@ -29,7 +29,6 @@
import android.net.ConnectivityManager;
import android.net.IpSecTransformState;
import android.net.Network;
-import android.net.vcn.Flags;
import android.net.vcn.VcnManager;
import android.os.Handler;
import android.os.HandlerExecutor;
@@ -233,7 +232,7 @@
@VisibleForTesting(visibility = Visibility.PRIVATE)
static int getMaxSeqNumIncreasePerSecond(@Nullable PersistableBundleWrapper carrierConfig) {
int maxSeqNumIncrease = MAX_SEQ_NUM_INCREASE_DEFAULT_DISABLED;
- if (Flags.handleSeqNumLeap() && carrierConfig != null) {
+ if (carrierConfig != null) {
maxSeqNumIncrease =
carrierConfig.getInt(
VcnManager.VCN_NETWORK_SELECTION_MAX_SEQ_NUM_INCREASE_PER_SECOND_KEY,
@@ -287,10 +286,8 @@
// with the new interval
mPollIpSecStateIntervalMs = getPollIpSecStateIntervalMs(carrierConfig);
- if (Flags.handleSeqNumLeap()) {
- mPacketLossRatePercentThreshold = getPacketLossRatePercentThreshold(carrierConfig);
- mMaxSeqNumIncreasePerSecond = getMaxSeqNumIncreasePerSecond(carrierConfig);
- }
+ mPacketLossRatePercentThreshold = getPacketLossRatePercentThreshold(carrierConfig);
+ mMaxSeqNumIncreasePerSecond = getMaxSeqNumIncreasePerSecond(carrierConfig);
if (canStart() != isStarted()) {
if (canStart()) {
@@ -438,13 +435,10 @@
onValidationResultReceivedInternal(true /* isFailed */);
}
- // In both "valid" or "unusual_seq_num_leap" cases, trigger network validation
- if (Flags.validateNetworkOnIpsecLoss()) {
- // Trigger re-validation of the underlying network; if it fails, the VCN will
- // attempt to migrate away.
- mConnectivityManager.reportNetworkConnectivity(
- getNetwork(), false /* hasConnectivity */);
- }
+ // In both "invalid" and "unusual_seq_num_leap" cases, trigger network validation. If
+ // validation fails, the VCN will attempt to migrate away.
+ mConnectivityManager.reportNetworkConnectivity(
+ getNetwork(), false /* hasConnectivity */);
}
}
@@ -474,8 +468,7 @@
boolean isUnusualSeqNumLeap = false;
// Handle sequence number leap
- if (Flags.handleSeqNumLeap()
- && maxSeqNumIncreasePerSecond != MAX_SEQ_NUM_INCREASE_DEFAULT_DISABLED) {
+ if (maxSeqNumIncreasePerSecond != MAX_SEQ_NUM_INCREASE_DEFAULT_DISABLED) {
final long timeDiffMillis =
newState.getTimestampMillis() - oldState.getTimestampMillis();
final long maxSeqNumIncrease = timeDiffMillis * maxSeqNumIncreasePerSecond / 1000;
@@ -506,7 +499,7 @@
+ " actualPktCntDiff: "
+ actualPktCntDiff);
- if (Flags.handleSeqNumLeap() && expectedPktCntDiff < MIN_VALID_EXPECTED_RX_PACKET_NUM) {
+ if (expectedPktCntDiff < MIN_VALID_EXPECTED_RX_PACKET_NUM) {
// The sample size is too small to ensure a reliable detection result
return PacketLossCalculationResult.invalid();
}
diff --git a/services/core/java/com/android/server/vcn/routeselection/UnderlyingNetworkEvaluator.java b/services/core/java/com/android/server/vcn/routeselection/UnderlyingNetworkEvaluator.java
index 78e06d4..c852fb4 100644
--- a/services/core/java/com/android/server/vcn/routeselection/UnderlyingNetworkEvaluator.java
+++ b/services/core/java/com/android/server/vcn/routeselection/UnderlyingNetworkEvaluator.java
@@ -25,7 +25,6 @@
import android.net.LinkProperties;
import android.net.Network;
import android.net.NetworkCapabilities;
-import android.net.vcn.Flags;
import android.net.vcn.VcnManager;
import android.net.vcn.VcnUnderlyingNetworkTemplate;
import android.os.Handler;
@@ -297,10 +296,8 @@
updatePriorityClass(
underlyingNetworkTemplates, subscriptionGroup, lastSnapshot, carrierConfig);
- if (Flags.evaluateIpsecLossOnLpNcChange()) {
- for (NetworkMetricMonitor monitor : mMetricMonitors) {
- monitor.onLinkPropertiesOrCapabilitiesChanged();
- }
+ for (NetworkMetricMonitor monitor : mMetricMonitors) {
+ monitor.onLinkPropertiesOrCapabilitiesChanged();
}
}
@@ -316,10 +313,8 @@
updatePriorityClass(
underlyingNetworkTemplates, subscriptionGroup, lastSnapshot, carrierConfig);
- if (Flags.evaluateIpsecLossOnLpNcChange()) {
- for (NetworkMetricMonitor monitor : mMetricMonitors) {
- monitor.onLinkPropertiesOrCapabilitiesChanged();
- }
+ for (NetworkMetricMonitor monitor : mMetricMonitors) {
+ monitor.onLinkPropertiesOrCapabilitiesChanged();
}
}
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/telecomm/java/android/telecom/Logging/Session.java b/telecomm/java/android/telecom/Logging/Session.java
index e2fb601..ad0d4f4 100644
--- a/telecomm/java/android/telecom/Logging/Session.java
+++ b/telecomm/java/android/telecom/Logging/Session.java
@@ -16,7 +16,6 @@
package android.telecom.Logging;
-import android.annotation.NonNull;
import android.annotation.Nullable;
import android.os.Parcel;
import android.os.Parcelable;
@@ -24,8 +23,13 @@
import android.text.TextUtils;
import com.android.internal.annotations.VisibleForTesting;
+import com.android.server.telecom.flags.Flags;
+import java.util.ArrayDeque;
import java.util.ArrayList;
+import java.util.List;
+import java.util.Objects;
+import java.util.concurrent.atomic.AtomicInteger;
/**
* Stores information about a thread's point of entry into that should persist until that thread
@@ -55,7 +59,7 @@
* Initial value of mExecutionEndTimeMs and the final value of {@link #getLocalExecutionTime()}
* if the Session is canceled.
*/
- public static final int UNDEFINED = -1;
+ public static final long UNDEFINED = -1;
public static class Info implements Parcelable {
public final String sessionId;
@@ -129,46 +133,39 @@
}
}
- private String mSessionId;
- private String mShortMethodName;
+ private final String mSessionId;
+ private volatile String mShortMethodName;
private long mExecutionStartTimeMs;
private long mExecutionEndTimeMs = UNDEFINED;
- private Session mParentSession;
- private ArrayList<Session> mChildSessions;
+ private volatile Session mParentSession;
+ private final ArrayList<Session> mChildSessions = new ArrayList<>(5);
private boolean mIsCompleted = false;
- private boolean mIsExternal = false;
- private int mChildCounter = 0;
+ private final boolean mIsExternal;
+ private final AtomicInteger mChildCounter = new AtomicInteger(0);
// True if this is a subsession that has been started from the same thread as the parent
// session. This can happen if Log.startSession(...) is called multiple times on the same
// thread in the case of one Telecom entry point method calling another entry point method.
// In this case, we can just make this subsession "invisible," but still keep track of it so
// that the Log.endSession() calls match up.
- private boolean mIsStartedFromActiveSession = false;
+ private final boolean mIsStartedFromActiveSession;
// Optionally provided info about the method/class/component that started the session in order
// to make Logging easier. This info will be provided in parentheses along with the session.
- private String mOwnerInfo;
+ private final String mOwnerInfo;
// Cache Full Method path so that recursive population of the full method path only needs to
// be calculated once.
- private String mFullMethodPathCache;
+ private volatile String mFullMethodPathCache;
public Session(String sessionId, String shortMethodName, long startTimeMs,
- boolean isStartedFromActiveSession, String ownerInfo) {
- setSessionId(sessionId);
+ boolean isStartedFromActiveSession, boolean isExternal, String ownerInfo) {
+ mSessionId = (sessionId != null) ? sessionId : "???";
setShortMethodName(shortMethodName);
mExecutionStartTimeMs = startTimeMs;
mParentSession = null;
- mChildSessions = new ArrayList<>(5);
mIsStartedFromActiveSession = isStartedFromActiveSession;
+ mIsExternal = isExternal;
mOwnerInfo = ownerInfo;
}
- public void setSessionId(@NonNull String sessionId) {
- if (sessionId == null) {
- mSessionId = "?";
- }
- mSessionId = sessionId;
- }
-
public String getShortMethodName() {
return mShortMethodName;
}
@@ -180,10 +177,6 @@
mShortMethodName = shortMethodName;
}
- public void setIsExternal(boolean isExternal) {
- mIsExternal = isExternal;
- }
-
public boolean isExternal() {
return mIsExternal;
}
@@ -193,13 +186,15 @@
}
public void addChild(Session childSession) {
- if (childSession != null) {
+ if (childSession == null) return;
+ synchronized (mChildSessions) {
mChildSessions.add(childSession);
}
}
public void removeChild(Session child) {
- if (child != null) {
+ if (child == null) return;
+ synchronized (mChildSessions) {
mChildSessions.remove(child);
}
}
@@ -217,7 +212,9 @@
}
public ArrayList<Session> getChildSessions() {
- return mChildSessions;
+ synchronized (mChildSessions) {
+ return new ArrayList<>(mChildSessions);
+ }
}
public boolean isSessionCompleted() {
@@ -259,17 +256,41 @@
return mExecutionEndTimeMs - mExecutionStartTimeMs;
}
- public synchronized String getNextChildId() {
- return String.valueOf(mChildCounter++);
+ public String getNextChildId() {
+ return String.valueOf(mChildCounter.getAndIncrement());
}
- // Builds full session id recursively
+ // Builds full session ID, which incliudes the optional external indicators (E),
+ // base session ID, and the optional sub-session IDs (_X): @[E-]...[ID][_X][_Y]...
private String getFullSessionId() {
- return getFullSessionId(0);
+ if (!Flags.endSessionImprovements()) return getFullSessionIdRecursive(0);
+ int currParentCount = 0;
+ StringBuilder id = new StringBuilder();
+ Session currSession = this;
+ while (currSession != null) {
+ Session parentSession = currSession.getParentSession();
+ if (parentSession != null) {
+ if (currParentCount >= SESSION_RECURSION_LIMIT) {
+ id.insert(0, getSessionId());
+ id.insert(0, TRUNCATE_STRING);
+ android.util.Slog.w(LOG_TAG, "getFullSessionId: Hit iteration limit!");
+ return id.toString();
+ }
+ if (Log.VERBOSE) {
+ id.insert(0, currSession.getSessionId());
+ id.insert(0, SESSION_SEPARATION_CHAR_CHILD);
+ }
+ } else {
+ id.insert(0, currSession.getSessionId());
+ }
+ currSession = parentSession;
+ currParentCount++;
+ }
+ return id.toString();
}
// keep track of calls and bail if we hit the recursion limit
- private String getFullSessionId(int parentCount) {
+ private String getFullSessionIdRecursive(int parentCount) {
if (parentCount >= SESSION_RECURSION_LIMIT) {
// Don't use Telecom's Log.w here or it will cause infinite recursion because it will
// try to add session information to this logging statement, which will cause it to hit
@@ -286,12 +307,12 @@
return mSessionId;
} else {
if (Log.VERBOSE) {
- return parentSession.getFullSessionId(parentCount + 1)
+ return parentSession.getFullSessionIdRecursive(parentCount + 1)
// Append "_X" to subsession to show subsession designation.
+ SESSION_SEPARATION_CHAR_CHILD + mSessionId;
} else {
// Only worry about the base ID at the top of the tree.
- return parentSession.getFullSessionId(parentCount + 1);
+ return parentSession.getFullSessionIdRecursive(parentCount + 1);
}
}
@@ -300,16 +321,18 @@
private Session getRootSession(String callingMethod) {
int currParentCount = 0;
Session topNode = this;
- while (topNode.getParentSession() != null) {
+ Session parentNode = topNode.getParentSession();
+ while (parentNode != null) {
if (currParentCount >= SESSION_RECURSION_LIMIT) {
// Don't use Telecom's Log.w here or it will cause infinite recursion because it
// will try to add session information to this logging statement, which will cause
// it to hit this condition again and so on...
- android.util.Slog.w(LOG_TAG, "getRootSession: Hit recursion limit from "
+ android.util.Slog.w(LOG_TAG, "getRootSession: Hit iteration limit from "
+ callingMethod);
break;
}
- topNode = topNode.getParentSession();
+ topNode = parentNode;
+ parentNode = topNode.getParentSession();
currParentCount++;
}
return topNode;
@@ -320,14 +343,40 @@
return getRootSession("printFullSessionTree").printSessionTree();
}
- // Recursively move down session tree using DFS, but print out each node when it is reached.
private String printSessionTree() {
StringBuilder sb = new StringBuilder();
- printSessionTree(0, sb, 0);
+ if (!Flags.endSessionImprovements()) {
+ printSessionTreeRecursive(0, sb, 0);
+ return sb.toString();
+ }
+ int depth = 0;
+ ArrayDeque<Session> deque = new ArrayDeque<>();
+ deque.add(this);
+ while (!deque.isEmpty()) {
+ Session node = deque.pollFirst();
+ sb.append("\t".repeat(depth));
+ sb.append(node.toString());
+ sb.append("\n");
+ if (depth >= SESSION_RECURSION_LIMIT) {
+ sb.append(TRUNCATE_STRING);
+ depth -= 1;
+ continue;
+ }
+ List<Session> childSessions = node.getChildSessions().reversed();
+ if (!childSessions.isEmpty()) {
+ depth += 1;
+ for (Session child : childSessions) {
+ deque.addFirst(child);
+ }
+ } else {
+ depth -= 1;
+ }
+ }
return sb.toString();
}
- private void printSessionTree(int tabI, StringBuilder sb, int currChildCount) {
+ // Recursively move down session tree using DFS, but print out each node when it is reached.
+ private void printSessionTreeRecursive(int tabI, StringBuilder sb, int currChildCount) {
// Prevent infinite recursion.
if (currChildCount >= SESSION_RECURSION_LIMIT) {
// Don't use Telecom's Log.w here or it will cause infinite recursion because it will
@@ -343,26 +392,85 @@
for (int i = 0; i <= tabI; i++) {
sb.append("\t");
}
- child.printSessionTree(tabI + 1, sb, currChildCount + 1);
+ child.printSessionTreeRecursive(tabI + 1, sb, currChildCount + 1);
}
}
- // Recursively concatenate mShortMethodName with the parent Sessions to create full method
- // path. if truncatePath is set to true, all other external sessions (except for the most
- // recent) will be truncated to "..."
+ //
+
+ /**
+ * Concatenate the short method name with the parent Sessions to create full method path.
+ * @param truncatePath if truncatePath is set to true, all other external sessions (except for
+ * the most recent) will be truncated to "..."
+ * @return The full method path associated with this Session.
+ */
+ @VisibleForTesting
public String getFullMethodPath(boolean truncatePath) {
StringBuilder sb = new StringBuilder();
- getFullMethodPath(sb, truncatePath, 0);
+ if (!Flags.endSessionImprovements()) {
+ getFullMethodPathRecursive(sb, truncatePath, 0);
+ return sb.toString();
+ }
+ // Check to see if the session has been renamed yet. If it has not, then the session
+ // has not been continued.
+ Session parentSession = getParentSession();
+ boolean isSessionStarted = parentSession == null
+ || !getShortMethodName().equals(parentSession.getShortMethodName());
+ int depth = 0;
+ Session currSession = this;
+ while (currSession != null) {
+ String cache = currSession.mFullMethodPathCache;
+ // Return cached value for method path. When returning the truncated path, recalculate
+ // the full path without using the cached value.
+ if (!TextUtils.isEmpty(cache) && !truncatePath) {
+ sb.insert(0, cache);
+ return sb.toString();
+ }
+
+ parentSession = currSession.getParentSession();
+ // Encapsulate the external session's method name so it is obvious what part of the
+ // session is external or truncate it if we do not want the entire history.
+ if (currSession.isExternal()) {
+ if (truncatePath) {
+ sb.insert(0, TRUNCATE_STRING);
+ } else {
+ sb.insert(0, ")");
+ sb.insert(0, currSession.getShortMethodName());
+ sb.insert(0, "(");
+ }
+ } else {
+ sb.insert(0, currSession.getShortMethodName());
+ }
+ if (parentSession != null) {
+ sb.insert(0, SUBSESSION_SEPARATION_CHAR);
+ }
+
+ if (depth >= SESSION_RECURSION_LIMIT) {
+ // Don't use Telecom's Log.w here or it will cause infinite recursion because it
+ // will try to add session information to this logging statement, which will cause
+ // it to hit this condition again and so on...
+ android.util.Slog.w(LOG_TAG, "getFullMethodPath: Hit iteration limit!");
+ sb.insert(0, TRUNCATE_STRING);
+ return sb.toString();
+ }
+ currSession = parentSession;
+ depth++;
+ }
+ if (isSessionStarted && !truncatePath) {
+ // Cache the full method path for this node so that we do not need to calculate it
+ // again in the future.
+ mFullMethodPathCache = sb.toString();
+ }
return sb.toString();
}
- private synchronized void getFullMethodPath(StringBuilder sb, boolean truncatePath,
+ private synchronized void getFullMethodPathRecursive(StringBuilder sb, boolean truncatePath,
int parentCount) {
if (parentCount >= SESSION_RECURSION_LIMIT) {
// Don't use Telecom's Log.w here or it will cause infinite recursion because it will
// try to add session information to this logging statement, which will cause it to hit
// this condition again and so on...
- android.util.Slog.w(LOG_TAG, "getFullMethodPath: Hit recursion limit!");
+ android.util.Slog.w(LOG_TAG, "getFullMethodPathRecursive: Hit recursion limit!");
sb.append(TRUNCATE_STRING);
return;
}
@@ -378,7 +486,7 @@
// Check to see if the session has been renamed yet. If it has not, then the session
// has not been continued.
isSessionStarted = !mShortMethodName.equals(parentSession.mShortMethodName);
- parentSession.getFullMethodPath(sb, truncatePath, parentCount + 1);
+ parentSession.getFullMethodPathRecursive(sb, truncatePath, parentCount + 1);
sb.append(SUBSESSION_SEPARATION_CHAR);
}
// Encapsulate the external session's method name so it is obvious what part of the session
@@ -409,14 +517,14 @@
@Override
public int hashCode() {
- int result = mSessionId != null ? mSessionId.hashCode() : 0;
- result = 31 * result + (mShortMethodName != null ? mShortMethodName.hashCode() : 0);
- result = 31 * result + (int) (mExecutionStartTimeMs ^ (mExecutionStartTimeMs >>> 32));
- result = 31 * result + (int) (mExecutionEndTimeMs ^ (mExecutionEndTimeMs >>> 32));
+ int result = mSessionId.hashCode();
+ result = 31 * result + mShortMethodName.hashCode();
+ result = 31 * result + Long.hashCode(mExecutionStartTimeMs);
+ result = 31 * result + Long.hashCode(mExecutionEndTimeMs);
result = 31 * result + (mParentSession != null ? mParentSession.hashCode() : 0);
- result = 31 * result + (mChildSessions != null ? mChildSessions.hashCode() : 0);
+ result = 31 * result + mChildSessions.hashCode();
result = 31 * result + (mIsCompleted ? 1 : 0);
- result = 31 * result + mChildCounter;
+ result = 31 * result + mChildCounter.hashCode();
result = 31 * result + (mIsStartedFromActiveSession ? 1 : 0);
result = 31 * result + (mOwnerInfo != null ? mOwnerInfo.hashCode() : 0);
return result;
@@ -432,23 +540,13 @@
if (mExecutionStartTimeMs != session.mExecutionStartTimeMs) return false;
if (mExecutionEndTimeMs != session.mExecutionEndTimeMs) return false;
if (mIsCompleted != session.mIsCompleted) return false;
- if (mChildCounter != session.mChildCounter) return false;
+ if (!(mChildCounter.get() == session.mChildCounter.get())) return false;
if (mIsStartedFromActiveSession != session.mIsStartedFromActiveSession) return false;
- if (mSessionId != null ?
- !mSessionId.equals(session.mSessionId) : session.mSessionId != null)
- return false;
- if (mShortMethodName != null ? !mShortMethodName.equals(session.mShortMethodName)
- : session.mShortMethodName != null)
- return false;
- if (mParentSession != null ? !mParentSession.equals(session.mParentSession)
- : session.mParentSession != null)
- return false;
- if (mChildSessions != null ? !mChildSessions.equals(session.mChildSessions)
- : session.mChildSessions != null)
- return false;
- return mOwnerInfo != null ? mOwnerInfo.equals(session.mOwnerInfo)
- : session.mOwnerInfo == null;
-
+ if (!Objects.equals(mSessionId, session.mSessionId)) return false;
+ if (!Objects.equals(mShortMethodName, session.mShortMethodName)) return false;
+ if (!Objects.equals(mParentSession, session.mParentSession)) return false;
+ if (!Objects.equals(mChildSessions, session.mChildSessions)) return false;
+ return Objects.equals(mOwnerInfo, session.mOwnerInfo);
}
@Override
diff --git a/telecomm/java/android/telecom/Logging/SessionManager.java b/telecomm/java/android/telecom/Logging/SessionManager.java
index 9d17219..00e344c 100644
--- a/telecomm/java/android/telecom/Logging/SessionManager.java
+++ b/telecomm/java/android/telecom/Logging/SessionManager.java
@@ -27,6 +27,7 @@
import android.util.Base64;
import com.android.internal.annotations.VisibleForTesting;
+import com.android.server.telecom.flags.Flags;
import java.nio.ByteBuffer;
import java.util.ArrayList;
@@ -36,10 +37,16 @@
import java.util.concurrent.ConcurrentHashMap;
/**
- * TODO: Create better Sessions Documentation
+ * SessionManager manages the active sessions in a HashMap, which maps the active thread(s) to the
+ * associated {@link Session}s.
+ * <p>
+ * Note: Sessions assume that session structure modification is synchronized on this object - only
+ * one thread can modify the structure of any Session at one time. Printing the current session to
+ * the log is not synchronized because we should not clean up a session chain while printing from
+ * another Thread. Either the Session chain is still active and can not be cleaned up yet, or the
+ * Session chain has ended and we are cleaning up.
* @hide
*/
-
public class SessionManager {
// Currently using 3 letters, So don't exceed 64^3
@@ -54,11 +61,11 @@
private Context mContext;
@VisibleForTesting
- public ConcurrentHashMap<Integer, Session> mSessionMapper = new ConcurrentHashMap<>(100);
+ public final ConcurrentHashMap<Integer, Session> mSessionMapper = new ConcurrentHashMap<>(64);
@VisibleForTesting
public java.lang.Runnable mCleanStaleSessions = () ->
cleanupStaleSessions(getSessionCleanupTimeoutMs());
- private Handler mSessionCleanupHandler = new Handler(Looper.getMainLooper());
+ private final Handler mSessionCleanupHandler = new Handler(Looper.getMainLooper());
// Overridden in LogTest to skip query to ContentProvider
private interface ISessionCleanupTimeoutMs {
@@ -83,7 +90,7 @@
};
// Usage is synchronized on this class.
- private List<ISessionListener> mSessionListeners = new ArrayList<>();
+ private final List<ISessionListener> mSessionListeners = new ArrayList<>();
public interface ISessionListener {
/**
@@ -110,10 +117,19 @@
}
private synchronized void resetStaleSessionTimer() {
- mSessionCleanupHandler.removeCallbacksAndMessages(null);
- // Will be null in Log Testing
- if (mCleanStaleSessions != null) {
- mSessionCleanupHandler.postDelayed(mCleanStaleSessions, getSessionCleanupTimeoutMs());
+ if (!Flags.endSessionImprovements()) {
+ mSessionCleanupHandler.removeCallbacksAndMessages(null);
+ // Will be null in Log Testing
+ if (mCleanStaleSessions != null) {
+ mSessionCleanupHandler.postDelayed(mCleanStaleSessions,
+ getSessionCleanupTimeoutMs());
+ }
+ } else {
+ if (mCleanStaleSessions != null
+ && !mSessionCleanupHandler.hasCallbacks(mCleanStaleSessions)) {
+ mSessionCleanupHandler.postDelayed(mCleanStaleSessions,
+ getSessionCleanupTimeoutMs());
+ }
}
}
@@ -147,13 +163,11 @@
Session childSession = createSubsession(true);
continueSession(childSession, shortMethodName);
return;
- } else {
- // Only Log that we are starting the parent session.
- Log.d(LOGGING_TAG, Session.START_SESSION);
}
Session newSession = new Session(getNextSessionID(), shortMethodName,
- System.currentTimeMillis(), false, callerIdentification);
+ System.currentTimeMillis(), false, false, callerIdentification);
mSessionMapper.put(threadId, newSession);
+ Log.d(LOGGING_TAG, Session.START_SESSION);
}
/**
@@ -179,17 +193,16 @@
}
// Create Session from Info and add to the sessionMapper under this ID.
- Log.d(LOGGING_TAG, Session.START_EXTERNAL_SESSION);
Session externalSession = new Session(Session.EXTERNAL_INDICATOR + sessionInfo.sessionId,
- sessionInfo.methodPath, System.currentTimeMillis(),
- false /*isStartedFromActiveSession*/, sessionInfo.ownerInfo);
- externalSession.setIsExternal(true);
+ sessionInfo.methodPath, System.currentTimeMillis(), false, true,
+ sessionInfo.ownerInfo);
// Mark the external session as already completed, since we have no way of knowing when
// the external session actually has completed.
externalSession.markSessionCompleted(Session.UNDEFINED);
// Track the external session with the SessionMapper so that we can create and continue
// an active subsession based on it.
mSessionMapper.put(threadId, externalSession);
+ Log.d(LOGGING_TAG, Session.START_EXTERNAL_SESSION);
// Create a subsession from this external Session parent node
Session childSession = createSubsession();
continueSession(childSession, shortMethodName);
@@ -226,13 +239,12 @@
// Start execution time of the session will be overwritten in continueSession(...).
Session newSubsession = new Session(threadSession.getNextChildId(),
threadSession.getShortMethodName(), System.currentTimeMillis(),
- isStartedFromActiveSession, threadSession.getOwnerInfo());
+ isStartedFromActiveSession, false, threadSession.getOwnerInfo());
threadSession.addChild(newSubsession);
newSubsession.setParentSession(threadSession);
if (!isStartedFromActiveSession) {
- Log.v(LOGGING_TAG, Session.CREATE_SUBSESSION + " " +
- newSubsession.toString());
+ Log.v(LOGGING_TAG, Session.CREATE_SUBSESSION);
} else {
Log.v(LOGGING_TAG, Session.CREATE_SUBSESSION +
" (Invisible subsession)");
@@ -273,7 +285,7 @@
}
subsession.markSessionCompleted(Session.UNDEFINED);
- endParentSessions(subsession);
+ cleanupSessionTreeAndNotify(subsession);
}
/**
@@ -328,7 +340,7 @@
// Remove after completed so that reference still exists for logging the end events
Session parentSession = completedSession.getParentSession();
mSessionMapper.remove(threadId);
- endParentSessions(completedSession);
+ cleanupSessionTreeAndNotify(completedSession);
// If this subsession was started from a parent session using Log.startSession, return the
// ThreadID back to the parent after completion.
if (parentSession != null && !parentSession.isSessionCompleted() &&
@@ -337,8 +349,49 @@
}
}
+ /**
+ * Move up the session tree and remove completed sessions until we either hit a session that was
+ * not completed yet or we reach the root node. Once we reach the root node, we will report the
+ * session times to session complete listeners.
+ * @param session The Session to clean up.
+ */
+ private void cleanupSessionTreeAndNotify(Session session) {
+ if (session == null) return;
+ if (!Flags.endSessionImprovements()) {
+ endParentSessionsRecursive(session);
+ return;
+ }
+ Session currSession = session;
+ // Traverse upwards and unlink until we either hit the root node or a node that isn't
+ // complete yet.
+ while (currSession != null) {
+ if (!currSession.isSessionCompleted() || !currSession.getChildSessions().isEmpty()) {
+ // We will return once the active session is completed.
+ return;
+ }
+ Session parentSession = currSession.getParentSession();
+ currSession.setParentSession(null);
+ // The session is either complete when we have reached the top node or we have reached
+ // the node where the parent is external. We only want to report the time it took to
+ // complete the local session, so for external nodes, report finished when the sub-node
+ // completes.
+ boolean reportSessionComplete =
+ (parentSession == null && !currSession.isExternal())
+ || (parentSession != null && parentSession.isExternal());
+ if (parentSession != null) parentSession.removeChild(currSession);
+ if (reportSessionComplete) {
+ long fullSessionTimeMs = System.currentTimeMillis()
+ - currSession.getExecutionStartTimeMilliseconds();
+ Log.d(LOGGING_TAG, Session.END_SESSION + " (dur: " + fullSessionTimeMs
+ + " ms): " + currSession);
+ notifySessionCompleteListeners(currSession.getShortMethodName(), fullSessionTimeMs);
+ }
+ currSession = parentSession;
+ }
+ }
+
// Recursively deletes all complete parent sessions of the current subsession if it is a leaf.
- private void endParentSessions(Session subsession) {
+ private void endParentSessionsRecursive(Session subsession) {
// Session is not completed or not currently a leaf, so we can not remove because a child is
// still running
if (!subsession.isSessionCompleted() || subsession.getChildSessions().size() != 0) {
@@ -355,7 +408,7 @@
System.currentTimeMillis() - subsession.getExecutionStartTimeMilliseconds();
notifySessionCompleteListeners(subsession.getShortMethodName(), fullSessionTimeMs);
}
- endParentSessions(parentSession);
+ endParentSessionsRecursive(parentSession);
} else {
// All of the subsessions have been completed and it is time to report on the full
// running time of the session.
@@ -370,8 +423,10 @@
}
private void notifySessionCompleteListeners(String methodName, long sessionTimeMs) {
- for (ISessionListener l : mSessionListeners) {
- l.sessionComplete(methodName, sessionTimeMs);
+ synchronized (mSessionListeners) {
+ for (ISessionListener l : mSessionListeners) {
+ l.sessionComplete(methodName, sessionTimeMs);
+ }
}
}
@@ -380,8 +435,8 @@
return currentSession != null ? currentSession.toString() : "";
}
- public synchronized void registerSessionListener(ISessionListener l) {
- if (l != null) {
+ public void registerSessionListener(ISessionListener l) {
+ synchronized (mSessionListeners) {
mSessionListeners.add(l);
}
}
@@ -425,25 +480,30 @@
@VisibleForTesting
public synchronized void cleanupStaleSessions(long timeoutMs) {
- String logMessage = "Stale Sessions Cleaned:\n";
+ StringBuilder logMessage = new StringBuilder("Stale Sessions Cleaned:");
boolean isSessionsStale = false;
long currentTimeMs = System.currentTimeMillis();
// Remove references that are in the Session Mapper (causing GC to occur) on
- // sessions that are lasting longer than LOGGING_SESSION_TIMEOUT_MS.
+ // sessions that are lasting longer than DEFAULT_SESSION_TIMEOUT_MS.
// If this occurs, then there is most likely a Session active that never had
// Log.endSession called on it.
for (Iterator<ConcurrentHashMap.Entry<Integer, Session>> it =
mSessionMapper.entrySet().iterator(); it.hasNext(); ) {
ConcurrentHashMap.Entry<Integer, Session> entry = it.next();
Session session = entry.getValue();
- if (currentTimeMs - session.getExecutionStartTimeMilliseconds() > timeoutMs) {
+ long runTime = currentTimeMs - session.getExecutionStartTimeMilliseconds();
+ if (runTime > timeoutMs) {
it.remove();
- logMessage += session.printFullSessionTree() + "\n";
+ logMessage.append("\n");
+ logMessage.append("[");
+ logMessage.append(runTime);
+ logMessage.append("ms] ");
+ logMessage.append(session.printFullSessionTree());
isSessionsStale = true;
}
}
if (isSessionsStale) {
- Log.w(LOGGING_TAG, logMessage);
+ Log.w(LOGGING_TAG, logMessage.toString());
} else {
Log.v(LOGGING_TAG, "No stale logging sessions needed to be cleaned...");
}
diff --git a/telephony/java/android/telephony/CarrierConfigManager.java b/telephony/java/android/telephony/CarrierConfigManager.java
index 728fef3..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";
/**
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/tests/vcn/java/com/android/server/VcnManagementServiceTest.java b/tests/vcn/java/com/android/server/VcnManagementServiceTest.java
index 4cb7c91..7e0bbc4 100644
--- a/tests/vcn/java/com/android/server/VcnManagementServiceTest.java
+++ b/tests/vcn/java/com/android/server/VcnManagementServiceTest.java
@@ -70,7 +70,6 @@
import android.net.NetworkCapabilities;
import android.net.NetworkRequest;
import android.net.Uri;
-import android.net.vcn.Flags;
import android.net.vcn.IVcnStatusCallback;
import android.net.vcn.IVcnUnderlyingNetworkPolicyListener;
import android.net.vcn.VcnConfig;
@@ -85,7 +84,6 @@
import android.os.UserHandle;
import android.os.UserManager;
import android.os.test.TestLooper;
-import android.platform.test.flag.junit.SetFlagsRule;
import android.telephony.SubscriptionInfo;
import android.telephony.SubscriptionManager;
import android.telephony.TelephonyManager;
@@ -104,7 +102,6 @@
import com.android.server.vcn.util.PersistableBundleUtils.PersistableBundleWrapper;
import org.junit.Before;
-import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.ArgumentCaptor;
@@ -122,8 +119,6 @@
@RunWith(AndroidJUnit4.class)
@SmallTest
public class VcnManagementServiceTest {
- @Rule public final SetFlagsRule mSetFlagsRule = new SetFlagsRule();
-
private static final String CONTEXT_ATTRIBUTION_TAG = "VCN";
private static final String TEST_PACKAGE_NAME =
VcnManagementServiceTest.class.getPackage().getName();
@@ -285,8 +280,6 @@
@Before
public void setUp() {
- mSetFlagsRule.enableFlags(Flags.FLAG_ENFORCE_MAIN_USER);
-
doNothing()
.when(mMockContext)
.enforceCallingOrSelfPermission(
diff --git a/tests/vcn/java/com/android/server/vcn/routeselection/NetworkEvaluationTestBase.java b/tests/vcn/java/com/android/server/vcn/routeselection/NetworkEvaluationTestBase.java
index edad678..421e1ad 100644
--- a/tests/vcn/java/com/android/server/vcn/routeselection/NetworkEvaluationTestBase.java
+++ b/tests/vcn/java/com/android/server/vcn/routeselection/NetworkEvaluationTestBase.java
@@ -34,14 +34,12 @@
import android.net.NetworkCapabilities;
import android.net.TelephonyNetworkSpecifier;
import android.net.vcn.FeatureFlags;
-import android.net.vcn.Flags;
import android.os.Handler;
import android.os.IPowerManager;
import android.os.IThermalService;
import android.os.ParcelUuid;
import android.os.PowerManager;
import android.os.test.TestLooper;
-import android.platform.test.flag.junit.SetFlagsRule;
import android.telephony.TelephonyManager;
import com.android.server.vcn.TelephonySubscriptionTracker.TelephonySubscriptionSnapshot;
@@ -49,7 +47,6 @@
import com.android.server.vcn.VcnNetworkProvider;
import org.junit.Before;
-import org.junit.Rule;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
@@ -57,8 +54,6 @@
import java.util.UUID;
public abstract class NetworkEvaluationTestBase {
- @Rule public final SetFlagsRule mSetFlagsRule = new SetFlagsRule();
-
protected static final String SSID = "TestWifi";
protected static final String SSID_OTHER = "TestWifiOther";
protected static final String PLMN_ID = "123456";
@@ -120,10 +115,6 @@
public void setUp() throws Exception {
MockitoAnnotations.initMocks(this);
- mSetFlagsRule.enableFlags(Flags.FLAG_VALIDATE_NETWORK_ON_IPSEC_LOSS);
- mSetFlagsRule.enableFlags(Flags.FLAG_EVALUATE_IPSEC_LOSS_ON_LP_NC_CHANGE);
- mSetFlagsRule.enableFlags(Flags.FLAG_HANDLE_SEQ_NUM_LEAP);
-
when(mNetwork.getNetId()).thenReturn(-1);
mTestLooper = new TestLooper();
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.