Merge "Log when bubble is dismissed via drag" 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..6f60378 100644
--- a/core/api/current.txt
+++ b/core/api/current.txt
@@ -32880,6 +32880,41 @@
}
@FlaggedApi("android.sdk.major_minor_versioning_scheme") public static class Build.VERSION_CODES_FULL {
+ field public static final int BASE = 100000; // 0x186a0
+ field public static final int BASE_1_1 = 200000; // 0x30d40
+ field public static final int CUPCAKE = 300000; // 0x493e0
+ field public static final int DONUT = 400000; // 0x61a80
+ field public static final int ECLAIR = 500000; // 0x7a120
+ field public static final int ECLAIR_0_1 = 600000; // 0x927c0
+ field public static final int ECLAIR_MR1 = 700000; // 0xaae60
+ field public static final int FROYO = 800000; // 0xc3500
+ field public static final int GINGERBREAD = 900000; // 0xdbba0
+ field public static final int GINGERBREAD_MR1 = 1000000; // 0xf4240
+ field public static final int HONEYCOMB = 1100000; // 0x10c8e0
+ field public static final int HONEYCOMB_MR1 = 1200000; // 0x124f80
+ field public static final int HONEYCOMB_MR2 = 1300000; // 0x13d620
+ field public static final int ICE_CREAM_SANDWICH = 1400000; // 0x155cc0
+ field public static final int ICE_CREAM_SANDWICH_MR1 = 1500000; // 0x16e360
+ field public static final int JELLY_BEAN = 1600000; // 0x186a00
+ field public static final int JELLY_BEAN_MR1 = 1700000; // 0x19f0a0
+ field public static final int JELLY_BEAN_MR2 = 1800000; // 0x1b7740
+ field public static final int KITKAT = 1900000; // 0x1cfde0
+ field public static final int KITKAT_WATCH = 2000000; // 0x1e8480
+ field public static final int LOLLIPOP = 2100000; // 0x200b20
+ field public static final int LOLLIPOP_MR1 = 2200000; // 0x2191c0
+ field public static final int M = 2300000; // 0x231860
+ field public static final int N = 2400000; // 0x249f00
+ field public static final int N_MR1 = 2500000; // 0x2625a0
+ field public static final int O = 2600000; // 0x27ac40
+ field public static final int O_MR1 = 2700000; // 0x2932e0
+ field public static final int P = 2800000; // 0x2ab980
+ field public static final int Q = 2900000; // 0x2c4020
+ field public static final int R = 3000000; // 0x2dc6c0
+ field public static final int S = 3100000; // 0x2f4d60
+ field public static final int S_V2 = 3200000; // 0x30d400
+ field public static final int TIRAMISU = 3300000; // 0x325aa0
+ field public static final int UPSIDE_DOWN_CAKE = 3400000; // 0x33e140
+ field public static final int VANILLA_ICE_CREAM = 3500000; // 0x3567e0
}
public final class Bundle extends android.os.BaseBundle implements java.lang.Cloneable android.os.Parcelable {
@@ -33933,12 +33968,9 @@
public class RemoteCallbackList<E extends android.os.IInterface> {
ctor public RemoteCallbackList();
method public int beginBroadcast();
- method @FlaggedApi("android.os.binder_frozen_state_change_callback") public void broadcast(@NonNull java.util.function.Consumer<E>);
method public void finishBroadcast();
method public Object getBroadcastCookie(int);
method public E getBroadcastItem(int);
- method @FlaggedApi("android.os.binder_frozen_state_change_callback") public int getFrozenCalleePolicy();
- method @FlaggedApi("android.os.binder_frozen_state_change_callback") public int getMaxQueueSize();
method public Object getRegisteredCallbackCookie(int);
method public int getRegisteredCallbackCount();
method public E getRegisteredCallbackItem(int);
@@ -33948,16 +33980,6 @@
method public boolean register(E);
method public boolean register(E, Object);
method public boolean unregister(E);
- field @FlaggedApi("android.os.binder_frozen_state_change_callback") public static final int FROZEN_CALLEE_POLICY_DROP = 3; // 0x3
- field @FlaggedApi("android.os.binder_frozen_state_change_callback") public static final int FROZEN_CALLEE_POLICY_ENQUEUE_ALL = 1; // 0x1
- field @FlaggedApi("android.os.binder_frozen_state_change_callback") public static final int FROZEN_CALLEE_POLICY_ENQUEUE_MOST_RECENT = 2; // 0x2
- field @FlaggedApi("android.os.binder_frozen_state_change_callback") public static final int FROZEN_CALLEE_POLICY_UNSET = 0; // 0x0
- }
-
- @FlaggedApi("android.os.binder_frozen_state_change_callback") public static final class RemoteCallbackList.Builder<E extends android.os.IInterface> {
- ctor public RemoteCallbackList.Builder(int);
- method @NonNull public android.os.RemoteCallbackList<E> build();
- method @NonNull public android.os.RemoteCallbackList.Builder setMaxQueueSize(int);
}
public class RemoteException extends android.util.AndroidException {
@@ -43851,8 +43873,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 +43957,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 +45995,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 +46078,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 +46329,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();
@@ -46367,7 +46389,7 @@
field public static final String ACTION_MULTI_SIM_CONFIG_CHANGED = "android.telephony.action.MULTI_SIM_CONFIG_CHANGED";
field public static final String ACTION_NETWORK_COUNTRY_CHANGED = "android.telephony.action.NETWORK_COUNTRY_CHANGED";
field @RequiresPermission(android.Manifest.permission.READ_PHONE_STATE) public static final String ACTION_PHONE_STATE_CHANGED = "android.intent.action.PHONE_STATE";
- field @FlaggedApi("com.android.internal.telephony.flags.reset_mobile_network_settings") public static final String ACTION_RESET_MOBILE_NETWORK_SETTINGS = "android.telephony.action.RESET_MOBILE_NETWORK_SETTINGS";
+ field public static final String ACTION_RESET_MOBILE_NETWORK_SETTINGS = "android.telephony.action.RESET_MOBILE_NETWORK_SETTINGS";
field public static final String ACTION_RESPOND_VIA_MESSAGE = "android.intent.action.RESPOND_VIA_MESSAGE";
field public static final String ACTION_SECRET_CODE = "android.telephony.action.SECRET_CODE";
field public static final String ACTION_SHOW_VOICEMAIL_NOTIFICATION = "android.telephony.action.SHOW_VOICEMAIL_NOTIFICATION";
diff --git a/core/api/system-current.txt b/core/api/system-current.txt
index cab836e..fa4fc43 100644
--- a/core/api/system-current.txt
+++ b/core/api/system-current.txt
@@ -7319,6 +7319,7 @@
field @RequiresPermission(android.Manifest.permission.MODIFY_AUDIO_ROUTING) public static final int MUTED_BY_APP_OPS = 8; // 0x8
field @RequiresPermission(android.Manifest.permission.MODIFY_AUDIO_ROUTING) public static final int MUTED_BY_CLIENT_VOLUME = 16; // 0x10
field @RequiresPermission(android.Manifest.permission.MODIFY_AUDIO_ROUTING) public static final int MUTED_BY_MASTER = 1; // 0x1
+ field @FlaggedApi("android.media.audio.muted_by_port_volume_api") @RequiresPermission(android.Manifest.permission.MODIFY_AUDIO_ROUTING) public static final int MUTED_BY_PORT_VOLUME = 64; // 0x40
field @RequiresPermission(android.Manifest.permission.MODIFY_AUDIO_ROUTING) public static final int MUTED_BY_STREAM_MUTED = 4; // 0x4
field @RequiresPermission(android.Manifest.permission.MODIFY_AUDIO_ROUTING) public static final int MUTED_BY_STREAM_VOLUME = 2; // 0x2
field @RequiresPermission(android.Manifest.permission.MODIFY_AUDIO_ROUTING) public static final int MUTED_BY_VOLUME_SHAPER = 32; // 0x20
diff --git a/core/api/test-current.txt b/core/api/test-current.txt
index c79fc51..1ff8c51 100644
--- a/core/api/test-current.txt
+++ b/core/api/test-current.txt
@@ -1101,6 +1101,7 @@
field public static final long OVERRIDE_UNDEFINED_ORIENTATION_TO_PORTRAIT = 265452344L; // 0xfd27b38L
field public static final long OVERRIDE_USE_DISPLAY_LANDSCAPE_NATURAL_ORIENTATION = 255940284L; // 0xf4156bcL
field public static final int RESIZE_MODE_RESIZEABLE = 2; // 0x2
+ field public static final long UNIVERSAL_RESIZABLE_BY_DEFAULT = 357141415L; // 0x15498ba7L
}
public class ApplicationInfo extends android.content.pm.PackageItemInfo implements android.os.Parcelable {
diff --git a/core/java/android/app/Notification.java b/core/java/android/app/Notification.java
index 8b33417..4ef5b51 100644
--- a/core/java/android/app/Notification.java
+++ b/core/java/android/app/Notification.java
@@ -11296,7 +11296,11 @@
* @see Segment
*/
public @NonNull ProgressStyle setProgressSegments(@NonNull List<Segment> progressSegments) {
- mProgressSegments = new ArrayList<>(progressSegments.size());
+ if (mProgressSegments == null) {
+ mProgressSegments = new ArrayList<>();
+ }
+ mProgressSegments.clear();
+ mProgressSegments.addAll(progressSegments);
return this;
}
diff --git a/core/java/android/app/appfunctions/AppFunctionRuntimeMetadata.java b/core/java/android/app/appfunctions/AppFunctionRuntimeMetadata.java
index 08ecced..06d95f5 100644
--- a/core/java/android/app/appfunctions/AppFunctionRuntimeMetadata.java
+++ b/core/java/android/app/appfunctions/AppFunctionRuntimeMetadata.java
@@ -137,8 +137,10 @@
.TOKENIZER_TYPE_VERBATIM)
.build())
.addProperty(
- new AppSearchSchema.BooleanPropertyConfig.Builder(PROPERTY_ENABLED)
+ new AppSearchSchema.LongPropertyConfig.Builder(PROPERTY_ENABLED)
.setCardinality(AppSearchSchema.PropertyConfig.CARDINALITY_OPTIONAL)
+ .setIndexingType(
+ AppSearchSchema.LongPropertyConfig.INDEXING_TYPE_RANGE)
.build())
.addProperty(
new AppSearchSchema.StringPropertyConfig.Builder(
@@ -212,19 +214,14 @@
}
/**
- * Sets an indicator specifying if the function is enabled or not. This would override the
- * default enabled state in the static metadata ({@link
- * AppFunctionStaticMetadataHelper#STATIC_PROPERTY_ENABLED_BY_DEFAULT}). Sets this to null
- * to clear the override.
- * TODO(369683073) Replace the tristate Boolean with IntDef EnabledState.
+ * Sets an indicator specifying the function enabled state.
*/
@NonNull
public Builder setEnabled(@EnabledState int enabledState) {
if (enabledState != APP_FUNCTION_STATE_DEFAULT
&& enabledState != APP_FUNCTION_STATE_ENABLED
&& enabledState != APP_FUNCTION_STATE_DISABLED) {
- throw new IllegalArgumentException(
- "Value of EnabledState is unsupported.");
+ throw new IllegalArgumentException("Value of EnabledState is unsupported.");
}
setPropertyLong(PROPERTY_ENABLED, enabledState);
return this;
diff --git a/core/java/android/app/contextualsearch/ContextualSearchManager.java b/core/java/android/app/contextualsearch/ContextualSearchManager.java
index cfbe741..3438cc8 100644
--- a/core/java/android/app/contextualsearch/ContextualSearchManager.java
+++ b/core/java/android/app/contextualsearch/ContextualSearchManager.java
@@ -102,6 +102,7 @@
* Only supposed to be used with ACTON_LAUNCH_CONTEXTUAL_SEARCH.
*/
public static final String EXTRA_TOKEN = "android.app.contextualsearch.extra.TOKEN";
+
/**
* Intent action for contextual search invocation. The app providing the contextual search
* experience must add this intent filter action to the activity it wants to be launched.
@@ -111,6 +112,14 @@
public static final String ACTION_LAUNCH_CONTEXTUAL_SEARCH =
"android.app.contextualsearch.action.LAUNCH_CONTEXTUAL_SEARCH";
+ /**
+ * System feature declaring that the device supports Contextual Search.
+ *
+ * @hide
+ */
+ public static final String FEATURE_CONTEXTUAL_SEARCH =
+ "com.google.android.feature.CONTEXTUAL_SEARCH";
+
/** Entrypoint to be used when a user long presses on the nav handle. */
public static final int ENTRYPOINT_LONG_PRESS_NAV_HANDLE = 1;
/** Entrypoint to be used when a user long presses on the home button. */
diff --git a/core/java/android/app/notification.aconfig b/core/java/android/app/notification.aconfig
index 11e8850..37fa9a26 100644
--- a/core/java/android/app/notification.aconfig
+++ b/core/java/android/app/notification.aconfig
@@ -6,6 +6,14 @@
# flag relates to.
flag {
+ name: "notifications_redesign_app_icons"
+ namespace: "systemui"
+ description: "Notifications Redesign: Use app icons in notification rows (not to be confused with"
+ " notifications_use_app_icons, notifications_use_app_icon_in_row which are just experiments)."
+ bug: "371174789"
+}
+
+flag {
name: "modes_api"
is_exported: true
namespace: "systemui"
diff --git a/core/java/android/content/pm/ActivityInfo.java b/core/java/android/content/pm/ActivityInfo.java
index 481e6b5..ce52825 100644
--- a/core/java/android/content/pm/ActivityInfo.java
+++ b/core/java/android/content/pm/ActivityInfo.java
@@ -21,10 +21,12 @@
import android.annotation.IntDef;
import android.annotation.NonNull;
import android.annotation.Nullable;
+import android.annotation.SuppressLint;
import android.annotation.TestApi;
import android.app.Activity;
import android.compat.annotation.ChangeId;
import android.compat.annotation.Disabled;
+import android.compat.annotation.EnabledAfter;
import android.compat.annotation.EnabledSince;
import android.compat.annotation.Overridable;
import android.compat.annotation.UnsupportedAppUsage;
@@ -1204,6 +1206,18 @@
public @interface SizeChangesSupportMode {}
/**
+ * This change id makes the restriction of fixed orientation, aspect ratio, and resizability
+ * of the app to be ignored, which means making the app fill the given available area.
+ * @hide
+ */
+ @ChangeId
+ @Overridable
+ @TestApi
+ @SuppressLint("UnflaggedApi") // @TestApi without associated public API.
+ @EnabledAfter(targetSdkVersion = Build.VERSION_CODES.VANILLA_ICE_CREAM)
+ public static final long UNIVERSAL_RESIZABLE_BY_DEFAULT = 357141415L; // buganizer id
+
+ /**
* This change id enables compat policy that ignores app requested orientation in
* response to an app calling {@link android.app.Activity#setRequestedOrientation}. See
* com.android.server.wm.LetterboxUiController#shouldIgnoreRequestedOrientation for
diff --git a/core/java/android/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/os/Build.java b/core/java/android/os/Build.java
index d3ba73e..a894833 100644
--- a/core/java/android/os/Build.java
+++ b/core/java/android/os/Build.java
@@ -1278,6 +1278,41 @@
/** @hide */
@IntDef(value = {
+ VERSION_CODES_FULL.BASE,
+ VERSION_CODES_FULL.BASE_1_1,
+ VERSION_CODES_FULL.CUPCAKE,
+ VERSION_CODES_FULL.DONUT,
+ VERSION_CODES_FULL.ECLAIR,
+ VERSION_CODES_FULL.ECLAIR_0_1,
+ VERSION_CODES_FULL.ECLAIR_MR1,
+ VERSION_CODES_FULL.FROYO,
+ VERSION_CODES_FULL.GINGERBREAD,
+ VERSION_CODES_FULL.GINGERBREAD_MR1,
+ VERSION_CODES_FULL.HONEYCOMB,
+ VERSION_CODES_FULL.HONEYCOMB_MR1,
+ VERSION_CODES_FULL.HONEYCOMB_MR2,
+ VERSION_CODES_FULL.ICE_CREAM_SANDWICH,
+ VERSION_CODES_FULL.ICE_CREAM_SANDWICH_MR1,
+ VERSION_CODES_FULL.JELLY_BEAN,
+ VERSION_CODES_FULL.JELLY_BEAN_MR1,
+ VERSION_CODES_FULL.JELLY_BEAN_MR2,
+ VERSION_CODES_FULL.KITKAT,
+ VERSION_CODES_FULL.KITKAT_WATCH,
+ VERSION_CODES_FULL.LOLLIPOP,
+ VERSION_CODES_FULL.LOLLIPOP_MR1,
+ VERSION_CODES_FULL.M,
+ VERSION_CODES_FULL.N,
+ VERSION_CODES_FULL.N_MR1,
+ VERSION_CODES_FULL.O,
+ VERSION_CODES_FULL.O_MR1,
+ VERSION_CODES_FULL.P,
+ VERSION_CODES_FULL.Q,
+ VERSION_CODES_FULL.R,
+ VERSION_CODES_FULL.S,
+ VERSION_CODES_FULL.S_V2,
+ VERSION_CODES_FULL.TIRAMISU,
+ VERSION_CODES_FULL.UPSIDE_DOWN_CAKE,
+ VERSION_CODES_FULL.VANILLA_ICE_CREAM,
})
@Retention(RetentionPolicy.SOURCE)
public @interface SdkIntFull {}
@@ -1299,6 +1334,186 @@
// Use the last 5 digits for the minor version. This allows the
// minor version to be set to CUR_DEVELOPMENT.
private static final int SDK_INT_MULTIPLIER = 100000;
+
+ /**
+ * Android 1.0.
+ */
+ public static final int BASE = VERSION_CODES.BASE * SDK_INT_MULTIPLIER;
+
+ /**
+ * Android 2.0.
+ */
+ public static final int BASE_1_1 = VERSION_CODES.BASE_1_1 * SDK_INT_MULTIPLIER;
+
+ /**
+ * Android 3.0.
+ */
+ public static final int CUPCAKE = VERSION_CODES.CUPCAKE * SDK_INT_MULTIPLIER;
+
+ /**
+ * Android 4.0.
+ */
+ public static final int DONUT = VERSION_CODES.DONUT * SDK_INT_MULTIPLIER;
+
+ /**
+ * Android 5.0.
+ */
+ public static final int ECLAIR = VERSION_CODES.ECLAIR * SDK_INT_MULTIPLIER;
+
+ /**
+ * Android 6.0.
+ */
+ public static final int ECLAIR_0_1 = VERSION_CODES.ECLAIR_0_1 * SDK_INT_MULTIPLIER;
+
+ /**
+ * Android 7.0.
+ */
+ public static final int ECLAIR_MR1 = VERSION_CODES.ECLAIR_MR1 * SDK_INT_MULTIPLIER;
+
+ /**
+ * Android 8.0.
+ */
+ public static final int FROYO = VERSION_CODES.FROYO * SDK_INT_MULTIPLIER;
+
+ /**
+ * Android 9.0.
+ */
+ public static final int GINGERBREAD = VERSION_CODES.GINGERBREAD * SDK_INT_MULTIPLIER;
+
+ /**
+ * Android 10.0.
+ */
+ public static final int GINGERBREAD_MR1 =
+ VERSION_CODES.GINGERBREAD_MR1 * SDK_INT_MULTIPLIER;
+
+ /**
+ * Android 11.0.
+ */
+ public static final int HONEYCOMB = VERSION_CODES.HONEYCOMB * SDK_INT_MULTIPLIER;
+
+ /**
+ * Android 12.0.
+ */
+ public static final int HONEYCOMB_MR1 = VERSION_CODES.HONEYCOMB_MR1 * SDK_INT_MULTIPLIER;
+
+ /**
+ * Android 13.0.
+ */
+ public static final int HONEYCOMB_MR2 = VERSION_CODES.HONEYCOMB_MR2 * SDK_INT_MULTIPLIER;
+
+ /**
+ * Android 14.0.
+ */
+ public static final int ICE_CREAM_SANDWICH =
+ VERSION_CODES.ICE_CREAM_SANDWICH * SDK_INT_MULTIPLIER;
+
+ /**
+ * Android 15.0.
+ */
+ public static final int ICE_CREAM_SANDWICH_MR1 =
+ VERSION_CODES.ICE_CREAM_SANDWICH_MR1 * SDK_INT_MULTIPLIER;
+
+ /**
+ * Android 16.0.
+ */
+ public static final int JELLY_BEAN = VERSION_CODES.JELLY_BEAN * SDK_INT_MULTIPLIER;
+
+ /**
+ * Android 17.0.
+ */
+ public static final int JELLY_BEAN_MR1 = VERSION_CODES.JELLY_BEAN_MR1 * SDK_INT_MULTIPLIER;
+
+ /**
+ * Android 18.0.
+ */
+ public static final int JELLY_BEAN_MR2 = VERSION_CODES.JELLY_BEAN_MR2 * SDK_INT_MULTIPLIER;
+
+ /**
+ * Android 19.0.
+ */
+ public static final int KITKAT = VERSION_CODES.KITKAT * SDK_INT_MULTIPLIER;
+
+ /**
+ * Android 20.0.
+ */
+ public static final int KITKAT_WATCH = VERSION_CODES.KITKAT_WATCH * SDK_INT_MULTIPLIER;
+
+ /**
+ * Android 21.0.
+ */
+ public static final int LOLLIPOP = VERSION_CODES.LOLLIPOP * SDK_INT_MULTIPLIER;
+
+ /**
+ * Android 22.0.
+ */
+ public static final int LOLLIPOP_MR1 = VERSION_CODES.LOLLIPOP_MR1 * SDK_INT_MULTIPLIER;
+
+ /**
+ * Android 23.0.
+ */
+ public static final int M = VERSION_CODES.M * SDK_INT_MULTIPLIER;
+
+ /**
+ * Android 24.0.
+ */
+ public static final int N = VERSION_CODES.N * SDK_INT_MULTIPLIER;
+
+ /**
+ * Android 25.0.
+ */
+ public static final int N_MR1 = VERSION_CODES.N_MR1 * SDK_INT_MULTIPLIER;
+
+ /**
+ * Android 26.0.
+ */
+ public static final int O = VERSION_CODES.O * SDK_INT_MULTIPLIER;
+
+ /**
+ * Android 27.0.
+ */
+ public static final int O_MR1 = VERSION_CODES.O_MR1 * SDK_INT_MULTIPLIER;
+
+ /**
+ * Android 28.0.
+ */
+ public static final int P = VERSION_CODES.P * SDK_INT_MULTIPLIER;
+
+ /**
+ * Android 29.0.
+ */
+ public static final int Q = VERSION_CODES.Q * SDK_INT_MULTIPLIER;
+
+ /**
+ * Android 30.0.
+ */
+ public static final int R = VERSION_CODES.R * SDK_INT_MULTIPLIER;
+
+ /**
+ * Android 31.0.
+ */
+ public static final int S = VERSION_CODES.S * SDK_INT_MULTIPLIER;
+
+ /**
+ * Android 32.0.
+ */
+ public static final int S_V2 = VERSION_CODES.S_V2 * SDK_INT_MULTIPLIER;
+
+ /**
+ * Android 33.0.
+ */
+ public static final int TIRAMISU = VERSION_CODES.TIRAMISU * SDK_INT_MULTIPLIER;
+
+ /**
+ * Android 34.0.
+ */
+ public static final int UPSIDE_DOWN_CAKE =
+ VERSION_CODES.UPSIDE_DOWN_CAKE * SDK_INT_MULTIPLIER;
+
+ /**
+ * Android 35.0.
+ */
+ public static final int VANILLA_ICE_CREAM =
+ VERSION_CODES.VANILLA_ICE_CREAM * SDK_INT_MULTIPLIER;
}
/**
diff --git a/core/java/android/os/RemoteCallbackList.java b/core/java/android/os/RemoteCallbackList.java
index f82c822..769cbdd 100644
--- a/core/java/android/os/RemoteCallbackList.java
+++ b/core/java/android/os/RemoteCallbackList.java
@@ -16,18 +16,11 @@
package android.os;
-import android.annotation.FlaggedApi;
-import android.annotation.IntDef;
-import android.annotation.NonNull;
import android.compat.annotation.UnsupportedAppUsage;
import android.util.ArrayMap;
import android.util.Slog;
import java.io.PrintWriter;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.util.Queue;
-import java.util.concurrent.ConcurrentLinkedQueue;
import java.util.function.BiConsumer;
import java.util.function.Consumer;
@@ -37,7 +30,7 @@
* {@link android.app.Service} to its clients. In particular, this:
*
* <ul>
- * <li> Keeps track of a set of registered {@link IInterface} objects,
+ * <li> Keeps track of a set of registered {@link IInterface} callbacks,
* taking care to identify them through their underlying unique {@link IBinder}
* (by calling {@link IInterface#asBinder IInterface.asBinder()}.
* <li> Attaches a {@link IBinder.DeathRecipient IBinder.DeathRecipient} to
@@ -54,7 +47,7 @@
* the registered clients, use {@link #beginBroadcast},
* {@link #getBroadcastItem}, and {@link #finishBroadcast}.
*
- * <p>If a registered interface's process goes away, this class will take
+ * <p>If a registered callback's process goes away, this class will take
* care of automatically removing it from the list. If you want to do
* additional work in this situation, you can create a subclass that
* implements the {@link #onCallbackDied} method.
@@ -63,310 +56,78 @@
public class RemoteCallbackList<E extends IInterface> {
private static final String TAG = "RemoteCallbackList";
- private static final int DEFAULT_MAX_QUEUE_SIZE = 1000;
-
-
- /**
- * @hide
- */
- @IntDef(prefix = {"FROZEN_CALLEE_POLICY_"}, value = {
- FROZEN_CALLEE_POLICY_UNSET,
- FROZEN_CALLEE_POLICY_ENQUEUE_ALL,
- FROZEN_CALLEE_POLICY_ENQUEUE_MOST_RECENT,
- FROZEN_CALLEE_POLICY_DROP,
- })
- @Retention(RetentionPolicy.SOURCE)
- @interface FrozenCalleePolicy {
- }
-
- /**
- * Callbacks are invoked immediately regardless of the frozen state of the target process.
- *
- * Not recommended. Only exists for backward-compatibility. This represents the behavior up to
- * SDK 35. Starting with SDK 36, clients should set a policy to govern callback invocations when
- * recipients are frozen.
- */
- @FlaggedApi(Flags.FLAG_BINDER_FROZEN_STATE_CHANGE_CALLBACK)
- public static final int FROZEN_CALLEE_POLICY_UNSET = 0;
-
- /**
- * When the callback recipient's process is frozen, callbacks are enqueued so they're invoked
- * after the recipient is unfrozen.
- *
- * This is commonly used when the recipient wants to receive all callbacks without losing any
- * history, e.g. the recipient maintains a running count of events that occurred.
- *
- * Queued callbacks are invoked in the order they were originally broadcasted.
- */
- @FlaggedApi(Flags.FLAG_BINDER_FROZEN_STATE_CHANGE_CALLBACK)
- public static final int FROZEN_CALLEE_POLICY_ENQUEUE_ALL = 1;
-
- /**
- * When the callback recipient's process is frozen, only the most recent callback is enqueued,
- * which is later invoked after the recipient is unfrozen.
- *
- * This can be used when only the most recent state matters, for instance when clients are
- * listening to screen brightness changes.
- */
- @FlaggedApi(Flags.FLAG_BINDER_FROZEN_STATE_CHANGE_CALLBACK)
- public static final int FROZEN_CALLEE_POLICY_ENQUEUE_MOST_RECENT = 2;
-
- /**
- * When the callback recipient's process is frozen, callbacks are suppressed as if they never
- * happened.
- *
- * This could be useful in the case where the recipient wishes to react to callbacks only when
- * they occur while the recipient is not frozen. For example, certain network events are only
- * worth responding to if the response can be immediate. Another example is recipients having
- * another way of getting the latest state once it's unfrozen. Therefore there is no need to
- * save callbacks that happened while the recipient was frozen.
- */
- @FlaggedApi(Flags.FLAG_BINDER_FROZEN_STATE_CHANGE_CALLBACK)
- public static final int FROZEN_CALLEE_POLICY_DROP = 3;
-
@UnsupportedAppUsage
- /*package*/ ArrayMap<IBinder, Interface> mInterfaces = new ArrayMap<IBinder, Interface>();
+ /*package*/ ArrayMap<IBinder, Callback> mCallbacks
+ = new ArrayMap<IBinder, Callback>();
private Object[] mActiveBroadcast;
private int mBroadcastCount = -1;
private boolean mKilled = false;
private StringBuilder mRecentCallers;
- private final @FrozenCalleePolicy int mFrozenCalleePolicy;
- private final int mMaxQueueSize;
-
- private final class Interface implements IBinder.DeathRecipient,
- IBinder.FrozenStateChangeCallback {
- final IBinder mBinder;
- final E mInterface;
+ private final class Callback implements IBinder.DeathRecipient {
+ final E mCallback;
final Object mCookie;
- final Queue<Consumer<E>> mCallbackQueue;
- int mCurrentState = IBinder.FrozenStateChangeCallback.STATE_UNFROZEN;
- Interface(E callbackInterface, Object cookie) {
- mBinder = callbackInterface.asBinder();
- mInterface = callbackInterface;
+ Callback(E callback, Object cookie) {
+ mCallback = callback;
mCookie = cookie;
- mCallbackQueue = mFrozenCalleePolicy == FROZEN_CALLEE_POLICY_ENQUEUE_ALL
- || mFrozenCalleePolicy == FROZEN_CALLEE_POLICY_ENQUEUE_MOST_RECENT
- ? new ConcurrentLinkedQueue<>() : null;
- }
-
- @Override
- public synchronized void onFrozenStateChanged(@NonNull IBinder who, int state) {
- if (state == STATE_UNFROZEN && mCallbackQueue != null) {
- while (!mCallbackQueue.isEmpty()) {
- Consumer<E> callback = mCallbackQueue.poll();
- callback.accept(mInterface);
- }
- }
- mCurrentState = state;
- }
-
- void addCallback(@NonNull Consumer<E> callback) {
- if (mFrozenCalleePolicy == FROZEN_CALLEE_POLICY_UNSET) {
- callback.accept(mInterface);
- return;
- }
- synchronized (this) {
- if (mCurrentState == STATE_UNFROZEN) {
- callback.accept(mInterface);
- return;
- }
- switch (mFrozenCalleePolicy) {
- case FROZEN_CALLEE_POLICY_ENQUEUE_ALL:
- if (mCallbackQueue.size() >= mMaxQueueSize) {
- mCallbackQueue.poll();
- }
- mCallbackQueue.offer(callback);
- break;
- case FROZEN_CALLEE_POLICY_ENQUEUE_MOST_RECENT:
- mCallbackQueue.clear();
- mCallbackQueue.offer(callback);
- break;
- case FROZEN_CALLEE_POLICY_DROP:
- // Do nothing. Just ignore the callback.
- break;
- case FROZEN_CALLEE_POLICY_UNSET:
- // Do nothing. Should have returned at the start of the method.
- break;
- }
- }
- }
-
- public void maybeSubscribeToFrozenCallback() throws RemoteException {
- if (mFrozenCalleePolicy != FROZEN_CALLEE_POLICY_UNSET) {
- mBinder.addFrozenStateChangeCallback(this);
- }
- }
-
- public void maybeUnsubscribeFromFrozenCallback() {
- if (mFrozenCalleePolicy != FROZEN_CALLEE_POLICY_UNSET) {
- mBinder.removeFrozenStateChangeCallback(this);
- }
}
public void binderDied() {
- synchronized (mInterfaces) {
- mInterfaces.remove(mBinder);
- maybeUnsubscribeFromFrozenCallback();
+ synchronized (mCallbacks) {
+ mCallbacks.remove(mCallback.asBinder());
}
- onCallbackDied(mInterface, mCookie);
+ onCallbackDied(mCallback, mCookie);
}
}
/**
- * Builder for {@link RemoteCallbackList}.
- *
- * @param <E> The remote callback interface type.
- */
- @FlaggedApi(Flags.FLAG_BINDER_FROZEN_STATE_CHANGE_CALLBACK)
- public static final class Builder<E extends IInterface> {
- private @FrozenCalleePolicy int mFrozenCalleePolicy;
- private int mMaxQueueSize = DEFAULT_MAX_QUEUE_SIZE;
-
- /**
- * Creates a Builder for {@link RemoteCallbackList}.
- *
- * @param frozenCalleePolicy When the callback recipient's process is frozen, this parameter
- * specifies when/whether callbacks are invoked. It's important to choose a strategy that's
- * right for the use case. Leaving the policy unset with {@link #FROZEN_CALLEE_POLICY_UNSET}
- * is not recommended as it allows callbacks to be invoked while the recipient is frozen.
- */
- public Builder(@FrozenCalleePolicy int frozenCalleePolicy) {
- mFrozenCalleePolicy = frozenCalleePolicy;
- }
-
- /**
- * Sets the max queue size.
- *
- * @param maxQueueSize The max size limit on the queue that stores callbacks added when the
- * recipient's process is frozen. Once the limit is reached, the oldest callback is dropped
- * to keep the size under the limit. Should only be called for
- * {@link #FROZEN_CALLEE_POLICY_ENQUEUE_ALL}.
- *
- * @return This builder.
- * @throws IllegalArgumentException if the maxQueueSize is not positive.
- * @throws UnsupportedOperationException if frozenCalleePolicy is not
- * {@link #FROZEN_CALLEE_POLICY_ENQUEUE_ALL}.
- */
- public @NonNull Builder setMaxQueueSize(int maxQueueSize) {
- if (maxQueueSize <= 0) {
- throw new IllegalArgumentException("maxQueueSize must be positive");
- }
- if (mFrozenCalleePolicy != FROZEN_CALLEE_POLICY_ENQUEUE_ALL) {
- throw new UnsupportedOperationException(
- "setMaxQueueSize can only be called for FROZEN_CALLEE_POLICY_ENQUEUE_ALL");
- }
- mMaxQueueSize = maxQueueSize;
- return this;
- }
-
- /**
- * Builds and returns a {@link RemoteCallbackList}.
- *
- * @return The built {@link RemoteCallbackList} object.
- */
- public @NonNull RemoteCallbackList<E> build() {
- return new RemoteCallbackList<E>(mFrozenCalleePolicy, mMaxQueueSize);
- }
- }
-
- /**
- * Returns the frozen callee policy.
- *
- * @return The frozen callee policy.
- */
- @FlaggedApi(Flags.FLAG_BINDER_FROZEN_STATE_CHANGE_CALLBACK)
- public @FrozenCalleePolicy int getFrozenCalleePolicy() {
- return mFrozenCalleePolicy;
- }
-
- /**
- * Returns the max queue size.
- *
- * @return The max queue size.
- */
- @FlaggedApi(Flags.FLAG_BINDER_FROZEN_STATE_CHANGE_CALLBACK)
- public int getMaxQueueSize() {
- return mMaxQueueSize;
- }
-
- /**
- * Creates a RemoteCallbackList with {@link #FROZEN_CALLEE_POLICY_UNSET}. This is equivalent to
- * <pre>
- * new RemoteCallbackList.Build(RemoteCallbackList.FROZEN_CALLEE_POLICY_UNSET).build()
- * </pre>
- */
- public RemoteCallbackList() {
- this(FROZEN_CALLEE_POLICY_UNSET, DEFAULT_MAX_QUEUE_SIZE);
- }
-
- /**
- * Creates a RemoteCallbackList with the specified frozen callee policy.
- *
- * @param frozenCalleePolicy When the callback recipient's process is frozen, this parameter
- * specifies when/whether callbacks are invoked. It's important to choose a strategy that's
- * right for the use case. Leaving the policy unset with {@link #FROZEN_CALLEE_POLICY_UNSET}
- * is not recommended as it allows callbacks to be invoked while the recipient is frozen.
- *
- * @param maxQueueSize The max size limit on the queue that stores callbacks added when the
- * recipient's process is frozen. Once the limit is reached, the oldest callbacks would be
- * dropped to keep the size under limit. Ignored except for
- * {@link #FROZEN_CALLEE_POLICY_ENQUEUE_ALL}.
- */
- private RemoteCallbackList(@FrozenCalleePolicy int frozenCalleePolicy, int maxQueueSize) {
- mFrozenCalleePolicy = frozenCalleePolicy;
- mMaxQueueSize = maxQueueSize;
- }
-
- /**
* Simple version of {@link RemoteCallbackList#register(E, Object)}
* that does not take a cookie object.
*/
- public boolean register(E callbackInterface) {
- return register(callbackInterface, null);
+ public boolean register(E callback) {
+ return register(callback, null);
}
/**
- * Add a new interface to the list. This interface will remain in the list
+ * Add a new callback to the list. This callback will remain in the list
* until a corresponding call to {@link #unregister} or its hosting process
- * goes away. If the interface was already registered (determined by
- * checking to see if the {@link IInterface#asBinder callbackInterface.asBinder()}
- * object is already in the list), then it will be replaced with the new interface.
+ * goes away. If the callback was already registered (determined by
+ * checking to see if the {@link IInterface#asBinder callback.asBinder()}
+ * object is already in the list), then it will be replaced with the new callback.
* Registrations are not counted; a single call to {@link #unregister}
- * will remove an interface after any number calls to register it.
+ * will remove a callback after any number calls to register it.
*
- * @param callbackInterface The callback interface to be added to the list. Must
+ * @param callback The callback interface to be added to the list. Must
* not be null -- passing null here will cause a NullPointerException.
* Most services will want to check for null before calling this with
* an object given from a client, so that clients can't crash the
* service with bad data.
*
* @param cookie Optional additional data to be associated with this
- * interface.
+ * callback.
*
- * @return Returns true if the interface was successfully added to the list.
+ * @return Returns true if the callback was successfully added to the list.
* Returns false if it was not added, either because {@link #kill} had
- * previously been called or the interface's process has gone away.
+ * previously been called or the callback's process has gone away.
*
* @see #unregister
* @see #kill
* @see #onCallbackDied
*/
- public boolean register(E callbackInterface, Object cookie) {
- synchronized (mInterfaces) {
+ public boolean register(E callback, Object cookie) {
+ synchronized (mCallbacks) {
if (mKilled) {
return false;
}
// Flag unusual case that could be caused by a leak. b/36778087
- logExcessiveInterfaces();
- IBinder binder = callbackInterface.asBinder();
+ logExcessiveCallbacks();
+ IBinder binder = callback.asBinder();
try {
- Interface i = new Interface(callbackInterface, cookie);
- unregister(callbackInterface);
- binder.linkToDeath(i, 0);
- i.maybeSubscribeToFrozenCallback();
- mInterfaces.put(binder, i);
+ Callback cb = new Callback(callback, cookie);
+ unregister(callback);
+ binder.linkToDeath(cb, 0);
+ mCallbacks.put(binder, cb);
return true;
} catch (RemoteException e) {
return false;
@@ -375,28 +136,27 @@
}
/**
- * Remove from the list an interface that was previously added with
+ * Remove from the list a callback that was previously added with
* {@link #register}. This uses the
- * {@link IInterface#asBinder callbackInterface.asBinder()} object to correctly
+ * {@link IInterface#asBinder callback.asBinder()} object to correctly
* find the previous registration.
* Registrations are not counted; a single unregister call will remove
- * an interface after any number calls to {@link #register} for it.
+ * a callback after any number calls to {@link #register} for it.
*
- * @param callbackInterface The interface to be removed from the list. Passing
+ * @param callback The callback to be removed from the list. Passing
* null here will cause a NullPointerException, so you will generally want
* to check for null before calling.
*
- * @return Returns true if the interface was found and unregistered. Returns
- * false if the given interface was not found on the list.
+ * @return Returns true if the callback was found and unregistered. Returns
+ * false if the given callback was not found on the list.
*
* @see #register
*/
- public boolean unregister(E callbackInterface) {
- synchronized (mInterfaces) {
- Interface i = mInterfaces.remove(callbackInterface.asBinder());
- if (i != null) {
- i.mInterface.asBinder().unlinkToDeath(i, 0);
- i.maybeUnsubscribeFromFrozenCallback();
+ public boolean unregister(E callback) {
+ synchronized (mCallbacks) {
+ Callback cb = mCallbacks.remove(callback.asBinder());
+ if (cb != null) {
+ cb.mCallback.asBinder().unlinkToDeath(cb, 0);
return true;
}
return false;
@@ -404,21 +164,20 @@
}
/**
- * Disable this interface list. All registered interfaces are unregistered,
+ * Disable this callback list. All registered callbacks are unregistered,
* and the list is disabled so that future calls to {@link #register} will
* fail. This should be used when a Service is stopping, to prevent clients
- * from registering interfaces after it is stopped.
+ * from registering callbacks after it is stopped.
*
* @see #register
*/
public void kill() {
- synchronized (mInterfaces) {
- for (int cbi = mInterfaces.size() - 1; cbi >= 0; cbi--) {
- Interface i = mInterfaces.valueAt(cbi);
- i.mInterface.asBinder().unlinkToDeath(i, 0);
- i.maybeUnsubscribeFromFrozenCallback();
+ synchronized (mCallbacks) {
+ for (int cbi=mCallbacks.size()-1; cbi>=0; cbi--) {
+ Callback cb = mCallbacks.valueAt(cbi);
+ cb.mCallback.asBinder().unlinkToDeath(cb, 0);
}
- mInterfaces.clear();
+ mCallbacks.clear();
mKilled = true;
}
}
@@ -427,15 +186,15 @@
* Old version of {@link #onCallbackDied(E, Object)} that
* does not provide a cookie.
*/
- public void onCallbackDied(E callbackInterface) {
+ public void onCallbackDied(E callback) {
}
/**
- * Called when the process hosting an interface in the list has gone away.
+ * Called when the process hosting a callback in the list has gone away.
* The default implementation calls {@link #onCallbackDied(E)}
* for backwards compatibility.
*
- * @param callbackInterface The interface whose process has died. Note that, since
+ * @param callback The callback whose process has died. Note that, since
* its process has died, you can not make any calls on to this interface.
* You can, however, retrieve its IBinder and compare it with another
* IBinder to see if it is the same object.
@@ -444,15 +203,13 @@
*
* @see #register
*/
- public void onCallbackDied(E callbackInterface, Object cookie) {
- onCallbackDied(callbackInterface);
+ public void onCallbackDied(E callback, Object cookie) {
+ onCallbackDied(callback);
}
/**
- * Use {@link #broadcast(Consumer)} instead to ensure proper handling of frozen processes.
- *
- * Prepare to start making calls to the currently registered interfaces.
- * This creates a copy of the interface list, which you can retrieve items
+ * Prepare to start making calls to the currently registered callbacks.
+ * This creates a copy of the callback list, which you can retrieve items
* from using {@link #getBroadcastItem}. Note that only one broadcast can
* be active at a time, so you must be sure to always call this from the
* same thread (usually by scheduling with {@link Handler}) or
@@ -462,56 +219,44 @@
* <p>A typical loop delivering a broadcast looks like this:
*
* <pre>
- * int i = interfaces.beginBroadcast();
+ * int i = callbacks.beginBroadcast();
* while (i > 0) {
* i--;
* try {
- * interfaces.getBroadcastItem(i).somethingHappened();
+ * callbacks.getBroadcastItem(i).somethingHappened();
* } catch (RemoteException e) {
* // The RemoteCallbackList will take care of removing
* // the dead object for us.
* }
* }
- * interfaces.finishBroadcast();</pre>
+ * callbacks.finishBroadcast();</pre>
*
- * Note that this method is only supported for {@link #FROZEN_CALLEE_POLICY_UNSET}. For other
- * policies use {@link #broadcast(Consumer)} instead.
- *
- * @return Returns the number of interfaces in the broadcast, to be used
+ * @return Returns the number of callbacks in the broadcast, to be used
* with {@link #getBroadcastItem} to determine the range of indices you
* can supply.
*
- * @throws UnsupportedOperationException if an frozen callee policy is set.
- *
* @see #getBroadcastItem
* @see #finishBroadcast
*/
public int beginBroadcast() {
- if (mFrozenCalleePolicy != FROZEN_CALLEE_POLICY_UNSET) {
- throw new UnsupportedOperationException();
- }
- return beginBroadcastInternal();
- }
-
- private int beginBroadcastInternal() {
- synchronized (mInterfaces) {
+ synchronized (mCallbacks) {
if (mBroadcastCount > 0) {
throw new IllegalStateException(
"beginBroadcast() called while already in a broadcast");
}
- final int n = mBroadcastCount = mInterfaces.size();
- if (n <= 0) {
+ final int N = mBroadcastCount = mCallbacks.size();
+ if (N <= 0) {
return 0;
}
Object[] active = mActiveBroadcast;
- if (active == null || active.length < n) {
- mActiveBroadcast = active = new Object[n];
+ if (active == null || active.length < N) {
+ mActiveBroadcast = active = new Object[N];
}
- for (int i = 0; i < n; i++) {
- active[i] = mInterfaces.valueAt(i);
+ for (int i=0; i<N; i++) {
+ active[i] = mCallbacks.valueAt(i);
}
- return n;
+ return N;
}
}
@@ -522,23 +267,24 @@
* calling {@link #finishBroadcast}.
*
* <p>Note that it is possible for the process of one of the returned
- * interfaces to go away before you call it, so you will need to catch
+ * callbacks to go away before you call it, so you will need to catch
* {@link RemoteException} when calling on to the returned object.
- * The interface list itself, however, will take care of unregistering
+ * The callback list itself, however, will take care of unregistering
* these objects once it detects that it is no longer valid, so you can
* handle such an exception by simply ignoring it.
*
- * @param index Which of the registered interfaces you would like to
+ * @param index Which of the registered callbacks you would like to
* retrieve. Ranges from 0 to {@link #beginBroadcast}-1, inclusive.
*
- * @return Returns the interface that you can call. This will always be non-null.
+ * @return Returns the callback interface that you can call. This will
+ * always be non-null.
*
* @see #beginBroadcast
*/
public E getBroadcastItem(int index) {
- return ((Interface) mActiveBroadcast[index]).mInterface;
+ return ((Callback)mActiveBroadcast[index]).mCallback;
}
-
+
/**
* Retrieve the cookie associated with the item
* returned by {@link #getBroadcastItem(int)}.
@@ -546,7 +292,7 @@
* @see #getBroadcastItem
*/
public Object getBroadcastCookie(int index) {
- return ((Interface) mActiveBroadcast[index]).mCookie;
+ return ((Callback)mActiveBroadcast[index]).mCookie;
}
/**
@@ -557,7 +303,7 @@
* @see #beginBroadcast
*/
public void finishBroadcast() {
- synchronized (mInterfaces) {
+ synchronized (mCallbacks) {
if (mBroadcastCount < 0) {
throw new IllegalStateException(
"finishBroadcast() called outside of a broadcast");
@@ -576,35 +322,16 @@
}
/**
- * Performs {@code callback} on each registered interface.
- *
- * This is equivalent to #beginBroadcast, followed by iterating over the items using
- * #getBroadcastItem and then @finishBroadcast, except that this method supports
- * frozen callee policies.
- */
- @FlaggedApi(Flags.FLAG_BINDER_FROZEN_STATE_CHANGE_CALLBACK)
- public void broadcast(@NonNull Consumer<E> callback) {
- int itemCount = beginBroadcastInternal();
- try {
- for (int i = 0; i < itemCount; i++) {
- ((Interface) mActiveBroadcast[i]).addCallback(callback);
- }
- } finally {
- finishBroadcast();
- }
- }
-
- /**
- * Performs {@code callback} for each cookie associated with an interface, calling
+ * Performs {@code action} on each callback, calling
* {@link #beginBroadcast()}/{@link #finishBroadcast()} before/after looping
*
* @hide
*/
- public <C> void broadcastForEachCookie(Consumer<C> callback) {
+ public void broadcast(Consumer<E> action) {
int itemCount = beginBroadcast();
try {
for (int i = 0; i < itemCount; i++) {
- callback.accept((C) getBroadcastCookie(i));
+ action.accept(getBroadcastItem(i));
}
} finally {
finishBroadcast();
@@ -612,16 +339,33 @@
}
/**
- * Performs {@code callback} on each interface and associated cookie, calling {@link
+ * Performs {@code action} for each cookie associated with a callback, calling
+ * {@link #beginBroadcast()}/{@link #finishBroadcast()} before/after looping
+ *
+ * @hide
+ */
+ public <C> void broadcastForEachCookie(Consumer<C> action) {
+ int itemCount = beginBroadcast();
+ try {
+ for (int i = 0; i < itemCount; i++) {
+ action.accept((C) getBroadcastCookie(i));
+ }
+ } finally {
+ finishBroadcast();
+ }
+ }
+
+ /**
+ * Performs {@code action} on each callback and associated cookie, calling {@link
* #beginBroadcast()}/{@link #finishBroadcast()} before/after looping.
*
* @hide
*/
- public <C> void broadcast(BiConsumer<E, C> callback) {
+ public <C> void broadcast(BiConsumer<E, C> action) {
int itemCount = beginBroadcast();
try {
for (int i = 0; i < itemCount; i++) {
- callback.accept(getBroadcastItem(i), (C) getBroadcastCookie(i));
+ action.accept(getBroadcastItem(i), (C) getBroadcastCookie(i));
}
} finally {
finishBroadcast();
@@ -629,10 +373,10 @@
}
/**
- * Returns the number of registered interfaces. Note that the number of registered
- * interfaces may differ from the value returned by {@link #beginBroadcast()} since
- * the former returns the number of interfaces registered at the time of the call
- * and the second the number of interfaces to which the broadcast will be delivered.
+ * Returns the number of registered callbacks. Note that the number of registered
+ * callbacks may differ from the value returned by {@link #beginBroadcast()} since
+ * the former returns the number of callbacks registered at the time of the call
+ * and the second the number of callback to which the broadcast will be delivered.
* <p>
* This function is useful to decide whether to schedule a broadcast if this
* requires doing some work which otherwise would not be performed.
@@ -641,39 +385,39 @@
* @return The size.
*/
public int getRegisteredCallbackCount() {
- synchronized (mInterfaces) {
+ synchronized (mCallbacks) {
if (mKilled) {
return 0;
}
- return mInterfaces.size();
+ return mCallbacks.size();
}
}
/**
- * Return a currently registered interface. Note that this is
+ * Return a currently registered callback. Note that this is
* <em>not</em> the same as {@link #getBroadcastItem} and should not be used
- * interchangeably with it. This method returns the registered interface at the given
+ * interchangeably with it. This method returns the registered callback at the given
* index, not the current broadcast state. This means that it is not itself thread-safe:
* any call to {@link #register} or {@link #unregister} will change these indices, so you
* must do your own thread safety between these to protect from such changes.
*
- * @param index Index of which interface registration to return, from 0 to
+ * @param index Index of which callback registration to return, from 0 to
* {@link #getRegisteredCallbackCount()} - 1.
*
- * @return Returns whatever interface is associated with this index, or null if
+ * @return Returns whatever callback is associated with this index, or null if
* {@link #kill()} has been called.
*/
public E getRegisteredCallbackItem(int index) {
- synchronized (mInterfaces) {
+ synchronized (mCallbacks) {
if (mKilled) {
return null;
}
- return mInterfaces.valueAt(index).mInterface;
+ return mCallbacks.valueAt(index).mCallback;
}
}
/**
- * Return any cookie associated with a currently registered interface. Note that this is
+ * Return any cookie associated with a currently registered callback. Note that this is
* <em>not</em> the same as {@link #getBroadcastCookie} and should not be used
* interchangeably with it. This method returns the current cookie registered at the given
* index, not the current broadcast state. This means that it is not itself thread-safe:
@@ -687,25 +431,25 @@
* {@link #kill()} has been called.
*/
public Object getRegisteredCallbackCookie(int index) {
- synchronized (mInterfaces) {
+ synchronized (mCallbacks) {
if (mKilled) {
return null;
}
- return mInterfaces.valueAt(index).mCookie;
+ return mCallbacks.valueAt(index).mCookie;
}
}
/** @hide */
public void dump(PrintWriter pw, String prefix) {
- synchronized (mInterfaces) {
- pw.print(prefix); pw.print("callbacks: "); pw.println(mInterfaces.size());
+ synchronized (mCallbacks) {
+ pw.print(prefix); pw.print("callbacks: "); pw.println(mCallbacks.size());
pw.print(prefix); pw.print("killed: "); pw.println(mKilled);
pw.print(prefix); pw.print("broadcasts count: "); pw.println(mBroadcastCount);
}
}
- private void logExcessiveInterfaces() {
- final long size = mInterfaces.size();
+ private void logExcessiveCallbacks() {
+ final long size = mCallbacks.size();
final long TOO_MANY = 3000;
final long MAX_CHARS = 1000;
if (size >= TOO_MANY) {
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/BackEvent.java b/core/java/android/window/BackEvent.java
index 1c3f201c..23e572f 100644
--- a/core/java/android/window/BackEvent.java
+++ b/core/java/android/window/BackEvent.java
@@ -156,6 +156,22 @@
}
@Override
+ public boolean equals(Object other) {
+ if (this == other) {
+ return true;
+ }
+ if (!(other instanceof BackEvent)) {
+ return false;
+ }
+ final BackEvent that = (BackEvent) other;
+ return mTouchX == that.mTouchX
+ && mTouchY == that.mTouchY
+ && mProgress == that.mProgress
+ && mSwipeEdge == that.mSwipeEdge
+ && mFrameTime == that.mFrameTime;
+ }
+
+ @Override
public String toString() {
return "BackEvent{"
+ "mTouchX=" + mTouchX
diff --git a/core/java/android/window/SurfaceSyncGroup.java b/core/java/android/window/SurfaceSyncGroup.java
index 5d14698..a68bdc0 100644
--- a/core/java/android/window/SurfaceSyncGroup.java
+++ b/core/java/android/window/SurfaceSyncGroup.java
@@ -839,6 +839,16 @@
}
/**
+ * Returns true if the SurfaceSyncGroup has completed its sync.
+ * @hide
+ */
+ public boolean isComplete() {
+ synchronized (mLock) {
+ return mFinished;
+ }
+ }
+
+ /**
* A frame callback that is used to synchronize SurfaceViews. The owner of the SurfaceView must
* implement onFrameStarted when trying to sync the SurfaceView. This is to ensure the sync
* knows when the frame is ready to add to the sync.
diff --git a/core/java/android/window/TaskSnapshot.java b/core/java/android/window/TaskSnapshot.java
index 20d1b3b..a37bef8 100644
--- a/core/java/android/window/TaskSnapshot.java
+++ b/core/java/android/window/TaskSnapshot.java
@@ -83,13 +83,16 @@
public static final int REFERENCE_CACHE = 1 << 1;
/** This snapshot object is being persistent. */
public static final int REFERENCE_PERSIST = 1 << 2;
+ /** This snapshot object is being used for content suggestion. */
+ public static final int REFERENCE_CONTENT_SUGGESTION = 1 << 3;
@IntDef(flag = true, prefix = { "REFERENCE_" }, value = {
REFERENCE_BROADCAST,
REFERENCE_CACHE,
- REFERENCE_PERSIST
+ REFERENCE_PERSIST,
+ REFERENCE_CONTENT_SUGGESTION
})
@Retention(RetentionPolicy.SOURCE)
- @interface ReferenceFlags {}
+ public @interface ReferenceFlags {}
public TaskSnapshot(long id, long captureTime,
@NonNull ComponentName topActivityComponent, HardwareBuffer snapshot,
diff --git a/core/java/android/window/WindowContainerTransaction.java b/core/java/android/window/WindowContainerTransaction.java
index 8e495ec..34abf31 100644
--- a/core/java/android/window/WindowContainerTransaction.java
+++ b/core/java/android/window/WindowContainerTransaction.java
@@ -525,6 +525,22 @@
}
/**
+ * Disables or enables activities to be started in adjacent tasks (see
+ * {@link FLAG_ACTIVITY_LAUNCH_ADJACENT}) for the specified root of any child tasks. This
+ * differs from {@link #setLaunchAdjacentFlagRoot(WindowContainerToken)} which controls the
+ * preferred launch-adjacent target and allows for selectively setting which root tasks can
+ * support launch-adjacent.
+ * @hide
+ */
+ @NonNull
+ public WindowContainerTransaction setDisableLaunchAdjacent(
+ @NonNull WindowContainerToken container, boolean disabled) {
+ mHierarchyOps.add(HierarchyOp.createForSetDisableLaunchAdjacent(container.asBinder(),
+ disabled));
+ return this;
+ }
+
+ /**
* Starts a task by id. The task is expected to already exist (eg. as a recent task).
* @param taskId Id of task to start.
* @param options bundle containing ActivityOptions for the task's top activity.
@@ -1488,6 +1504,7 @@
public static final int HIERARCHY_OP_TYPE_RESTORE_BACK_NAVIGATION = 20;
public static final int HIERARCHY_OP_TYPE_SET_EXCLUDE_INSETS_TYPES = 21;
public static final int HIERARCHY_OP_TYPE_SET_KEYGUARD_STATE = 22;
+ public static final int HIERARCHY_OP_TYPE_SET_DISABLE_LAUNCH_ADJACENT = 23;
// The following key(s) are for use with mLaunchOptions:
// When launching a task (eg. from recents), this is the taskId to be launched.
@@ -1556,6 +1573,8 @@
private @InsetsType int mExcludeInsetsTypes;
+ private boolean mLaunchAdjacentDisabled;
+
public static HierarchyOp createForReparent(
@NonNull IBinder container, @Nullable IBinder reparent, boolean toTop) {
return new HierarchyOp.Builder(HIERARCHY_OP_TYPE_REPARENT)
@@ -1644,6 +1663,15 @@
.build();
}
+ /** Create a hierarchy op for disabling launch adjacent. */
+ public static HierarchyOp createForSetDisableLaunchAdjacent(IBinder container,
+ boolean disabled) {
+ return new HierarchyOp.Builder(HIERARCHY_OP_TYPE_SET_DISABLE_LAUNCH_ADJACENT)
+ .setContainer(container)
+ .setLaunchAdjacentDisabled(disabled)
+ .build();
+ }
+
/** create a hierarchy op for deleting a task **/
public static HierarchyOp createForRemoveTask(@NonNull IBinder container) {
return new HierarchyOp.Builder(HIERARCHY_OP_TYPE_REMOVE_TASK)
@@ -1695,6 +1723,7 @@
mReparentLeafTaskIfRelaunch = copy.mReparentLeafTaskIfRelaunch;
mIsTrimmableFromRecents = copy.mIsTrimmableFromRecents;
mExcludeInsetsTypes = copy.mExcludeInsetsTypes;
+ mLaunchAdjacentDisabled = copy.mLaunchAdjacentDisabled;
}
protected HierarchyOp(Parcel in) {
@@ -1719,6 +1748,7 @@
mReparentLeafTaskIfRelaunch = in.readBoolean();
mIsTrimmableFromRecents = in.readBoolean();
mExcludeInsetsTypes = in.readInt();
+ mLaunchAdjacentDisabled = in.readBoolean();
}
public int getType() {
@@ -1814,13 +1844,11 @@
}
/** Denotes whether the parents should also be included in the op. */
- @NonNull
public boolean includingParents() {
return mIncludingParents;
}
- /** Set the task to be trimmable */
- @NonNull
+ /** Denotes whether the task can be trimmable from recents */
public boolean isTrimmableFromRecents() {
return mIsTrimmableFromRecents;
}
@@ -1829,6 +1857,11 @@
return mExcludeInsetsTypes;
}
+ /** Denotes whether launch-adjacent flag is respected from this task or its children */
+ public boolean isLaunchAdjacentDisabled() {
+ return mLaunchAdjacentDisabled;
+ }
+
/** Gets a string representation of a hierarchy-op type. */
public static String hopToString(int type) {
switch (type) {
@@ -1839,6 +1872,8 @@
case HIERARCHY_OP_TYPE_SET_ADJACENT_ROOTS: return "SetAdjacentRoot";
case HIERARCHY_OP_TYPE_LAUNCH_TASK: return "LaunchTask";
case HIERARCHY_OP_TYPE_SET_LAUNCH_ADJACENT_FLAG_ROOT: return "SetAdjacentFlagRoot";
+ case HIERARCHY_OP_TYPE_SET_DISABLE_LAUNCH_ADJACENT:
+ return "SetDisableLaunchAdjacent";
case HIERARCHY_OP_TYPE_PENDING_INTENT: return "PendingIntent";
case HIERARCHY_OP_TYPE_START_SHORTCUT: return "StartShortcut";
case HIERARCHY_OP_TYPE_ADD_INSETS_FRAME_PROVIDER: return "addInsetsFrameProvider";
@@ -1891,6 +1926,10 @@
case HIERARCHY_OP_TYPE_SET_LAUNCH_ADJACENT_FLAG_ROOT:
sb.append("container=").append(mContainer).append(" clearRoot=").append(mToTop);
break;
+ case HIERARCHY_OP_TYPE_SET_DISABLE_LAUNCH_ADJACENT:
+ sb.append("container=").append(mContainer).append(" disabled=")
+ .append(mLaunchAdjacentDisabled);
+ break;
case HIERARCHY_OP_TYPE_START_SHORTCUT:
sb.append("options=").append(mLaunchOptions)
.append(" info=").append(mShortcutInfo);
@@ -1971,6 +2010,7 @@
dest.writeBoolean(mReparentLeafTaskIfRelaunch);
dest.writeBoolean(mIsTrimmableFromRecents);
dest.writeInt(mExcludeInsetsTypes);
+ dest.writeBoolean(mLaunchAdjacentDisabled);
}
@Override
@@ -2047,6 +2087,8 @@
private @InsetsType int mExcludeInsetsTypes;
+ private boolean mLaunchAdjacentDisabled;
+
Builder(int type) {
mType = type;
}
@@ -2153,6 +2195,11 @@
return this;
}
+ Builder setLaunchAdjacentDisabled(boolean disabled) {
+ mLaunchAdjacentDisabled = disabled;
+ return this;
+ }
+
HierarchyOp build() {
final HierarchyOp hierarchyOp = new HierarchyOp(mType);
hierarchyOp.mContainer = mContainer;
@@ -2179,6 +2226,7 @@
hierarchyOp.mReparentLeafTaskIfRelaunch = mReparentLeafTaskIfRelaunch;
hierarchyOp.mIsTrimmableFromRecents = mIsTrimmableFromRecents;
hierarchyOp.mExcludeInsetsTypes = mExcludeInsetsTypes;
+ hierarchyOp.mLaunchAdjacentDisabled = mLaunchAdjacentDisabled;
return hierarchyOp;
}
diff --git a/core/java/android/window/WindowOnBackInvokedDispatcher.java b/core/java/android/window/WindowOnBackInvokedDispatcher.java
index 44a374f..c9d458f 100644
--- a/core/java/android/window/WindowOnBackInvokedDispatcher.java
+++ b/core/java/android/window/WindowOnBackInvokedDispatcher.java
@@ -17,6 +17,7 @@
package android.window;
import static com.android.window.flags.Flags.predictiveBackPrioritySystemNavigationObserver;
+import static com.android.window.flags.Flags.predictiveBackTimestampApi;
import android.annotation.NonNull;
import android.annotation.Nullable;
@@ -563,7 +564,8 @@
}
OnBackAnimationCallback animationCallback = getBackAnimationCallback();
if (animationCallback != null
- && !(callback instanceof ImeBackAnimationController)) {
+ && !(callback instanceof ImeBackAnimationController)
+ && !predictiveBackTimestampApi()) {
mProgressAnimator.onBackInvoked(() -> {
if (mIsSystemCallback) {
mSystemNavigationObserverCallbackRunnable.run();
diff --git a/core/java/android/window/flags/lse_desktop_experience.aconfig b/core/java/android/window/flags/lse_desktop_experience.aconfig
index 155494f..1812953 100644
--- a/core/java/android/window/flags/lse_desktop_experience.aconfig
+++ b/core/java/android/window/flags/lse_desktop_experience.aconfig
@@ -239,6 +239,13 @@
}
flag {
+ name: "enable_desktop_windowing_enter_transitions"
+ namespace: "lse_desktop_experience"
+ description: "Enables enter desktop windowing transition & motion polish changes"
+ bug: "369763947"
+}
+
+flag {
name: "enable_desktop_windowing_exit_transitions"
namespace: "lse_desktop_experience"
description: "Enables exit desktop windowing transition & motion polish changes"
diff --git a/core/java/android/window/flags/windowing_frontend.aconfig b/core/java/android/window/flags/windowing_frontend.aconfig
index 460469c..0d235ff 100644
--- a/core/java/android/window/flags/windowing_frontend.aconfig
+++ b/core/java/android/window/flags/windowing_frontend.aconfig
@@ -70,17 +70,6 @@
}
flag {
- name: "common_surface_animator"
- namespace: "windowing_frontend"
- description: "A reusable surface animator for default transition"
- bug: "326331384"
- is_fixed_read_only: true
- metadata {
- purpose: PURPOSE_BUGFIX
- }
-}
-
-flag {
name: "reduce_keyguard_transitions"
namespace: "windowing_frontend"
description: "Avoid setting keyguard transitions ready unless there are no other changes"
diff --git a/core/java/com/android/internal/protolog/ProtoLogViewerConfigReader.java b/core/java/com/android/internal/protolog/ProtoLogViewerConfigReader.java
index 0a80e00..dd6c879 100644
--- a/core/java/com/android/internal/protolog/ProtoLogViewerConfigReader.java
+++ b/core/java/com/android/internal/protolog/ProtoLogViewerConfigReader.java
@@ -39,7 +39,7 @@
* or the viewer config is not loaded into memory.
*/
@Nullable
- public synchronized String getViewerString(long messageHash) {
+ public String getViewerString(long messageHash) {
return mLogMessageMap.get(messageHash);
}
diff --git a/core/java/com/android/internal/widget/NotificationRowIconView.java b/core/java/com/android/internal/widget/NotificationRowIconView.java
index 98e6e85..adcc0f6 100644
--- a/core/java/com/android/internal/widget/NotificationRowIconView.java
+++ b/core/java/com/android/internal/widget/NotificationRowIconView.java
@@ -39,17 +39,24 @@
/**
* An image view that holds the icon displayed at the start of a notification row.
+ * This can generally either display the "small icon" of a notification set via
+ * {@link this#setImageIcon(Icon)}, or an app icon controlled and fetched by the provider set
+ * through {@link this#setIconProvider(NotificationIconProvider)}.
*/
@RemoteViews.RemoteView
public class NotificationRowIconView extends CachingIconView {
+ private NotificationIconProvider mIconProvider;
+
private boolean mApplyCircularCrop = false;
private boolean mShouldShowAppIcon = false;
+ private Drawable mAppIcon = null;
- // Padding and background set on the view prior to being changed by setShouldShowAppIcon(true),
- // to be restored if shouldShowAppIcon becomes false again.
+ // Padding, background and colors set on the view prior to being overridden when showing the app
+ // icon, to be restored if we're showing the small icon again.
private Rect mOriginalPadding = null;
private Drawable mOriginalBackground = null;
-
+ private int mOriginalBackgroundColor = ColoredIconHelper.COLOR_INVALID;
+ private int mOriginalIconColor = ColoredIconHelper.COLOR_INVALID;
public NotificationRowIconView(Context context) {
super(context);
@@ -81,6 +88,71 @@
super.onFinishInflate();
}
+ /**
+ * Sets the icon provider for this view. This is used to determine whether we should show the
+ * app icon instead of the small icon, and to fetch the app icon if needed.
+ */
+ public void setIconProvider(NotificationIconProvider iconProvider) {
+ mIconProvider = iconProvider;
+ }
+
+ private Drawable loadAppIcon() {
+ if (mIconProvider != null && mIconProvider.shouldShowAppIcon()) {
+ return mIconProvider.getAppIcon();
+ }
+ return null;
+ }
+
+ @RemotableViewMethod(asyncImpl = "setImageIconAsync")
+ @Override
+ public void setImageIcon(Icon icon) {
+ if (Flags.notificationsRedesignAppIcons()) {
+ if (mAppIcon != null) {
+ // We already know that we should be using the app icon, and we already loaded it.
+ // We assume that cannot change throughout the lifetime of a notification, so
+ // there's nothing to do here.
+ return;
+ }
+ mAppIcon = loadAppIcon();
+ if (mAppIcon != null) {
+ setImageDrawable(mAppIcon);
+ adjustViewForAppIcon();
+ } else {
+ super.setImageIcon(icon);
+ restoreViewForSmallIcon();
+ }
+ return;
+ }
+ super.setImageIcon(icon);
+ }
+
+ @RemotableViewMethod
+ @Override
+ public Runnable setImageIconAsync(Icon icon) {
+ if (Flags.notificationsRedesignAppIcons()) {
+ if (mAppIcon != null) {
+ // We already know that we should be using the app icon, and we already loaded it.
+ // We assume that cannot change throughout the lifetime of a notification, so
+ // there's nothing to do here.
+ return () -> {
+ };
+ }
+ mAppIcon = loadAppIcon();
+ if (mAppIcon != null) {
+ return () -> {
+ setImageDrawable(mAppIcon);
+ adjustViewForAppIcon();
+ };
+ } else {
+ return () -> {
+ super.setImageIcon(icon);
+ restoreViewForSmallIcon();
+ };
+ }
+ }
+ return super.setImageIconAsync(icon);
+ }
+
/** Whether the icon represents the app icon (instead of the small icon). */
@RemotableViewMethod
public void setShouldShowAppIcon(boolean shouldShowAppIcon) {
@@ -91,35 +163,122 @@
mShouldShowAppIcon = shouldShowAppIcon;
if (mShouldShowAppIcon) {
- if (mOriginalPadding == null && mOriginalBackground == null) {
- mOriginalPadding = new Rect(getPaddingLeft(), getPaddingTop(),
- getPaddingRight(), getPaddingBottom());
- mOriginalBackground = getBackground();
- }
-
- setPadding(0, 0, 0, 0);
-
- // Make the background white in case the icon itself doesn't have one.
- ColorFilter colorFilter = new PorterDuffColorFilter(Color.WHITE,
- PorterDuff.Mode.SRC_ATOP);
-
- if (mOriginalBackground == null) {
- setBackground(getContext().getDrawable(R.drawable.notification_icon_circle));
- }
- getBackground().mutate().setColorFilter(colorFilter);
+ adjustViewForAppIcon();
} else {
// Restore original padding and background if needed
- if (mOriginalPadding != null) {
- setPadding(mOriginalPadding.left, mOriginalPadding.top, mOriginalPadding.right,
- mOriginalPadding.bottom);
- mOriginalPadding = null;
- }
- setBackground(mOriginalBackground);
- mOriginalBackground = null;
+ restoreViewForSmallIcon();
}
}
}
+ /**
+ * Override padding and background from the view to display the app icon.
+ */
+ private void adjustViewForAppIcon() {
+ removePadding();
+
+ if (Flags.notificationsUseAppIconInRow()) {
+ addWhiteBackground();
+ } else {
+ // No need to set the background for notification redesign, since the icon
+ // factory already does that for us.
+ removeBackground();
+ }
+ }
+
+ /**
+ * Restore padding and background overridden by {@link this#adjustViewForAppIcon}.
+ * Does nothing if they were not overridden.
+ */
+ private void restoreViewForSmallIcon() {
+ restorePadding();
+ restoreBackground();
+ restoreColors();
+ }
+
+ private void removePadding() {
+ if (mOriginalPadding == null) {
+ mOriginalPadding = new Rect(getPaddingLeft(), getPaddingTop(),
+ getPaddingRight(), getPaddingBottom());
+ }
+ setPadding(0, 0, 0, 0);
+ }
+
+ private void restorePadding() {
+ if (mOriginalPadding != null) {
+ setPadding(mOriginalPadding.left, mOriginalPadding.top,
+ mOriginalPadding.right,
+ mOriginalPadding.bottom);
+ mOriginalPadding = null;
+ }
+ }
+
+ private void removeBackground() {
+ if (mOriginalBackground == null) {
+ mOriginalBackground = getBackground();
+ }
+
+ setBackground(null);
+ }
+
+ private void addWhiteBackground() {
+ if (mOriginalBackground == null) {
+ mOriginalBackground = getBackground();
+ }
+
+ // Make the background white in case the icon itself doesn't have one.
+ ColorFilter colorFilter = new PorterDuffColorFilter(Color.WHITE,
+ PorterDuff.Mode.SRC_ATOP);
+
+ if (mOriginalBackground == null) {
+ setBackground(getContext().getDrawable(R.drawable.notification_icon_circle));
+ }
+ getBackground().mutate().setColorFilter(colorFilter);
+ }
+
+ private void restoreBackground() {
+ // NOTE: This will not work if the original background was null, but that's better than
+ // accidentally clearing the background. We expect that there's generally going to be one
+ // anyway unless we manually clear it.
+ if (mOriginalBackground != null) {
+ setBackground(mOriginalBackground);
+ mOriginalBackground = null;
+ }
+ }
+
+ private void restoreColors() {
+ if (mOriginalBackgroundColor != ColoredIconHelper.COLOR_INVALID) {
+ super.setBackgroundColor(mOriginalBackgroundColor);
+ mOriginalBackgroundColor = ColoredIconHelper.COLOR_INVALID;
+ }
+ if (mOriginalIconColor != ColoredIconHelper.COLOR_INVALID) {
+ super.setOriginalIconColor(mOriginalIconColor);
+ mOriginalIconColor = ColoredIconHelper.COLOR_INVALID;
+ }
+ }
+
+ @RemotableViewMethod
+ @Override
+ public void setBackgroundColor(int color) {
+ // Ignore color overrides if we're showing the app icon.
+ if (mAppIcon == null) {
+ super.setBackgroundColor(color);
+ } else {
+ mOriginalBackgroundColor = color;
+ }
+ }
+
+ @RemotableViewMethod
+ @Override
+ public void setOriginalIconColor(int color) {
+ // Ignore color overrides if we're showing the app icon.
+ if (mAppIcon == null) {
+ super.setOriginalIconColor(color);
+ } else {
+ mOriginalIconColor = color;
+ }
+ }
+
@Nullable
@Override
Drawable loadSizeRestrictedIcon(@Nullable Icon icon) {
@@ -197,4 +356,17 @@
return bitmap;
}
+
+ /**
+ * A provider that allows this view to verify whether it should use the app icon instead of the
+ * icon provided to it via setImageIcon, as well as actually fetching the app icon. It should
+ * primarily be called on the background thread.
+ */
+ public interface NotificationIconProvider {
+ /** Whether this notification should use the app icon instead of the small icon. */
+ boolean shouldShowAppIcon();
+
+ /** Get the app icon for this notification. */
+ Drawable getAppIcon();
+ }
}
diff --git a/core/jni/android_hardware_camera2_CameraMetadata.cpp b/core/jni/android_hardware_camera2_CameraMetadata.cpp
index 68d49cd..041fed7 100644
--- a/core/jni/android_hardware_camera2_CameraMetadata.cpp
+++ b/core/jni/android_hardware_camera2_CameraMetadata.cpp
@@ -336,7 +336,7 @@
static jbyteArray CameraMetadata_readValues(JNIEnv *env, jclass thiz, jint tag, jlong ptr) {
ALOGV("%s (tag = %d)", __FUNCTION__, tag);
- const CameraMetadata *metadata = CameraMetadata_getPointerThrow(env, ptr);
+ CameraMetadata* metadata = CameraMetadata_getPointerThrow(env, ptr);
if (metadata == NULL) return NULL;
const camera_metadata_t *metaBuffer = metadata->getAndLock();
@@ -349,14 +349,16 @@
}
size_t tagSize = Helpers::getTypeSize(tagType);
- camera_metadata_ro_entry entry = metadata->find(tag);
+ camera_metadata_entry entry = metadata->find(tag);
if (entry.count == 0) {
- if (!metadata->exists(tag)) {
- ALOGV("%s: Tag %d does not have any entries", __FUNCTION__, tag);
- } else {
- ALOGV("%s: Tag %d had an entry, but it had 0 data", __FUNCTION__, tag);
- }
- return NULL;
+ if (!metadata->exists(tag)) {
+ ALOGV("%s: Tag %d does not have any entries", __FUNCTION__, tag);
+ return NULL;
+ } else {
+ // OK: we will return a 0-sized array.
+ ALOGV("%s: Tag %d had an entry, but it had 0 data", __FUNCTION__,
+ tag);
+ }
}
jsize byteCount = entry.count * tagSize;
diff --git a/core/jni/android_media_AudioSystem.cpp b/core/jni/android_media_AudioSystem.cpp
index 9bccf5a..8eaa7aa 100644
--- a/core/jni/android_media_AudioSystem.cpp
+++ b/core/jni/android_media_AudioSystem.cpp
@@ -747,16 +747,12 @@
indexMax));
}
-static jint
-android_media_AudioSystem_setStreamVolumeIndex(JNIEnv *env,
- jobject thiz,
- jint stream,
- jint index,
- jint device)
-{
+static jint android_media_AudioSystem_setStreamVolumeIndex(JNIEnv *env, jobject thiz, jint stream,
+ jint index, jboolean muted,
+ jint device) {
return check_AudioSystem_Command(
AudioSystem::setStreamVolumeIndex(static_cast<audio_stream_type_t>(stream), index,
- static_cast<audio_devices_t>(device)));
+ muted, static_cast<audio_devices_t>(device)));
}
static jint
@@ -773,13 +769,9 @@
return index;
}
-static jint
-android_media_AudioSystem_setVolumeIndexForAttributes(JNIEnv *env,
- jobject thiz,
- jobject jaa,
- jint index,
- jint device)
-{
+static jint android_media_AudioSystem_setVolumeIndexForAttributes(JNIEnv *env, jobject thiz,
+ jobject jaa, jint index,
+ jboolean muted, jint device) {
// read the AudioAttributes values
JNIAudioAttributeHelper::UniqueAaPtr paa = JNIAudioAttributeHelper::makeUnique();
jint jStatus = JNIAudioAttributeHelper::nativeFromJava(env, jaa, paa.get());
@@ -787,7 +779,7 @@
return jStatus;
}
return check_AudioSystem_Command(
- AudioSystem::setVolumeIndexForAttributes(*(paa.get()), index,
+ AudioSystem::setVolumeIndexForAttributes(*(paa.get()), index, muted,
static_cast<audio_devices_t>(device)));
}
@@ -3448,182 +3440,179 @@
#define MAKE_AUDIO_SYSTEM_METHOD(x) \
MAKE_JNI_NATIVE_METHOD_AUTOSIG(#x, android_media_AudioSystem_##x)
-static const JNINativeMethod gMethods[] =
- {MAKE_AUDIO_SYSTEM_METHOD(setParameters),
- MAKE_AUDIO_SYSTEM_METHOD(getParameters),
- MAKE_AUDIO_SYSTEM_METHOD(muteMicrophone),
- MAKE_AUDIO_SYSTEM_METHOD(isMicrophoneMuted),
- MAKE_AUDIO_SYSTEM_METHOD(isStreamActive),
- MAKE_AUDIO_SYSTEM_METHOD(isStreamActiveRemotely),
- MAKE_AUDIO_SYSTEM_METHOD(isSourceActive),
- MAKE_AUDIO_SYSTEM_METHOD(newAudioSessionId),
- MAKE_AUDIO_SYSTEM_METHOD(newAudioPlayerId),
- MAKE_AUDIO_SYSTEM_METHOD(newAudioRecorderId),
- MAKE_JNI_NATIVE_METHOD("setDeviceConnectionState", "(ILandroid/os/Parcel;I)I",
- android_media_AudioSystem_setDeviceConnectionState),
- MAKE_AUDIO_SYSTEM_METHOD(getDeviceConnectionState),
- MAKE_AUDIO_SYSTEM_METHOD(handleDeviceConfigChange),
- MAKE_AUDIO_SYSTEM_METHOD(setPhoneState),
- MAKE_AUDIO_SYSTEM_METHOD(setForceUse),
- MAKE_AUDIO_SYSTEM_METHOD(getForceUse),
- MAKE_AUDIO_SYSTEM_METHOD(setDeviceAbsoluteVolumeEnabled),
- MAKE_AUDIO_SYSTEM_METHOD(initStreamVolume),
- MAKE_AUDIO_SYSTEM_METHOD(setStreamVolumeIndex),
- MAKE_AUDIO_SYSTEM_METHOD(getStreamVolumeIndex),
- MAKE_JNI_NATIVE_METHOD("setVolumeIndexForAttributes",
- "(Landroid/media/AudioAttributes;II)I",
- android_media_AudioSystem_setVolumeIndexForAttributes),
- MAKE_JNI_NATIVE_METHOD("getVolumeIndexForAttributes",
- "(Landroid/media/AudioAttributes;I)I",
- android_media_AudioSystem_getVolumeIndexForAttributes),
- MAKE_JNI_NATIVE_METHOD("getMinVolumeIndexForAttributes",
- "(Landroid/media/AudioAttributes;)I",
- android_media_AudioSystem_getMinVolumeIndexForAttributes),
- MAKE_JNI_NATIVE_METHOD("getMaxVolumeIndexForAttributes",
- "(Landroid/media/AudioAttributes;)I",
- android_media_AudioSystem_getMaxVolumeIndexForAttributes),
- MAKE_AUDIO_SYSTEM_METHOD(setMasterVolume),
- MAKE_AUDIO_SYSTEM_METHOD(getMasterVolume),
- MAKE_AUDIO_SYSTEM_METHOD(setMasterMute),
- MAKE_AUDIO_SYSTEM_METHOD(getMasterMute),
- MAKE_AUDIO_SYSTEM_METHOD(setMasterMono),
- MAKE_AUDIO_SYSTEM_METHOD(getMasterMono),
- MAKE_AUDIO_SYSTEM_METHOD(setMasterBalance),
- MAKE_AUDIO_SYSTEM_METHOD(getMasterBalance),
- MAKE_AUDIO_SYSTEM_METHOD(getPrimaryOutputSamplingRate),
- MAKE_AUDIO_SYSTEM_METHOD(getPrimaryOutputFrameCount),
- MAKE_AUDIO_SYSTEM_METHOD(getOutputLatency),
- MAKE_AUDIO_SYSTEM_METHOD(setLowRamDevice),
- MAKE_AUDIO_SYSTEM_METHOD(checkAudioFlinger),
- MAKE_JNI_NATIVE_METHOD("setAudioFlingerBinder", "(Landroid/os/IBinder;)V",
- android_media_AudioSystem_setAudioFlingerBinder),
- MAKE_JNI_NATIVE_METHOD("listAudioPorts", "(Ljava/util/ArrayList;[I)I",
- android_media_AudioSystem_listAudioPorts),
- MAKE_JNI_NATIVE_METHOD("getSupportedDeviceTypes", "(ILandroid/util/IntArray;)I",
- android_media_AudioSystem_getSupportedDeviceTypes),
- MAKE_JNI_NATIVE_METHOD("createAudioPatch",
- "([Landroid/media/AudioPatch;[Landroid/media/"
- "AudioPortConfig;[Landroid/media/AudioPortConfig;)I",
- android_media_AudioSystem_createAudioPatch),
- MAKE_JNI_NATIVE_METHOD("releaseAudioPatch", "(Landroid/media/AudioPatch;)I",
- android_media_AudioSystem_releaseAudioPatch),
- MAKE_JNI_NATIVE_METHOD("listAudioPatches", "(Ljava/util/ArrayList;[I)I",
- android_media_AudioSystem_listAudioPatches),
- MAKE_JNI_NATIVE_METHOD("setAudioPortConfig", "(Landroid/media/AudioPortConfig;)I",
- android_media_AudioSystem_setAudioPortConfig),
- MAKE_JNI_NATIVE_METHOD("startAudioSource",
- "(Landroid/media/AudioPortConfig;Landroid/media/AudioAttributes;)I",
- android_media_AudioSystem_startAudioSource),
- MAKE_AUDIO_SYSTEM_METHOD(stopAudioSource),
- MAKE_AUDIO_SYSTEM_METHOD(getAudioHwSyncForSession),
- MAKE_JNI_NATIVE_METHOD("registerPolicyMixes", "(Ljava/util/ArrayList;Z)I",
- android_media_AudioSystem_registerPolicyMixes),
- MAKE_JNI_NATIVE_METHOD("getRegisteredPolicyMixes", "(Ljava/util/List;)I",
- android_media_AudioSystem_getRegisteredPolicyMixes),
- MAKE_JNI_NATIVE_METHOD("updatePolicyMixes",
- "([Landroid/media/audiopolicy/AudioMix;[Landroid/media/audiopolicy/"
- "AudioMixingRule;)I",
- android_media_AudioSystem_updatePolicyMixes),
- MAKE_JNI_NATIVE_METHOD("setUidDeviceAffinities", "(I[I[Ljava/lang/String;)I",
- android_media_AudioSystem_setUidDeviceAffinities),
- MAKE_AUDIO_SYSTEM_METHOD(removeUidDeviceAffinities),
- MAKE_JNI_NATIVE_METHOD_AUTOSIG("native_register_dynamic_policy_callback",
- android_media_AudioSystem_registerDynPolicyCallback),
- MAKE_JNI_NATIVE_METHOD_AUTOSIG("native_register_recording_callback",
- android_media_AudioSystem_registerRecordingCallback),
- MAKE_JNI_NATIVE_METHOD_AUTOSIG("native_register_routing_callback",
- android_media_AudioSystem_registerRoutingCallback),
- MAKE_JNI_NATIVE_METHOD_AUTOSIG("native_register_vol_range_init_req_callback",
- android_media_AudioSystem_registerVolRangeInitReqCallback),
- MAKE_AUDIO_SYSTEM_METHOD(systemReady),
- MAKE_AUDIO_SYSTEM_METHOD(getStreamVolumeDB),
- MAKE_JNI_NATIVE_METHOD_AUTOSIG("native_get_offload_support",
- android_media_AudioSystem_getOffloadSupport),
- MAKE_JNI_NATIVE_METHOD("getMicrophones", "(Ljava/util/ArrayList;)I",
- android_media_AudioSystem_getMicrophones),
- MAKE_JNI_NATIVE_METHOD("getSurroundFormats", "(Ljava/util/Map;)I",
- android_media_AudioSystem_getSurroundFormats),
- MAKE_JNI_NATIVE_METHOD("getReportedSurroundFormats", "(Ljava/util/ArrayList;)I",
- android_media_AudioSystem_getReportedSurroundFormats),
- MAKE_AUDIO_SYSTEM_METHOD(setSurroundFormatEnabled),
- MAKE_AUDIO_SYSTEM_METHOD(setAssistantServicesUids),
- MAKE_AUDIO_SYSTEM_METHOD(setActiveAssistantServicesUids),
- MAKE_AUDIO_SYSTEM_METHOD(setA11yServicesUids),
- MAKE_AUDIO_SYSTEM_METHOD(isHapticPlaybackSupported),
- MAKE_AUDIO_SYSTEM_METHOD(isUltrasoundSupported),
- MAKE_JNI_NATIVE_METHOD(
- "getHwOffloadFormatsSupportedForBluetoothMedia", "(ILjava/util/ArrayList;)I",
- android_media_AudioSystem_getHwOffloadFormatsSupportedForBluetoothMedia),
- MAKE_AUDIO_SYSTEM_METHOD(setSupportedSystemUsages),
- MAKE_AUDIO_SYSTEM_METHOD(setAllowedCapturePolicy),
- MAKE_AUDIO_SYSTEM_METHOD(setRttEnabled),
- MAKE_AUDIO_SYSTEM_METHOD(setAudioHalPids),
- MAKE_AUDIO_SYSTEM_METHOD(isCallScreeningModeSupported),
- MAKE_JNI_NATIVE_METHOD("setDevicesRoleForStrategy", "(II[I[Ljava/lang/String;)I",
- android_media_AudioSystem_setDevicesRoleForStrategy),
- MAKE_JNI_NATIVE_METHOD("removeDevicesRoleForStrategy", "(II[I[Ljava/lang/String;)I",
- android_media_AudioSystem_removeDevicesRoleForStrategy),
- MAKE_AUDIO_SYSTEM_METHOD(clearDevicesRoleForStrategy),
- MAKE_JNI_NATIVE_METHOD("getDevicesForRoleAndStrategy", "(IILjava/util/List;)I",
- android_media_AudioSystem_getDevicesForRoleAndStrategy),
- MAKE_JNI_NATIVE_METHOD("setDevicesRoleForCapturePreset", "(II[I[Ljava/lang/String;)I",
- android_media_AudioSystem_setDevicesRoleForCapturePreset),
- MAKE_JNI_NATIVE_METHOD("addDevicesRoleForCapturePreset", "(II[I[Ljava/lang/String;)I",
- android_media_AudioSystem_addDevicesRoleForCapturePreset),
- MAKE_JNI_NATIVE_METHOD("removeDevicesRoleForCapturePreset", "(II[I[Ljava/lang/String;)I",
- android_media_AudioSystem_removeDevicesRoleForCapturePreset),
- MAKE_AUDIO_SYSTEM_METHOD(clearDevicesRoleForCapturePreset),
- MAKE_JNI_NATIVE_METHOD("getDevicesForRoleAndCapturePreset", "(IILjava/util/List;)I",
- android_media_AudioSystem_getDevicesForRoleAndCapturePreset),
- MAKE_JNI_NATIVE_METHOD("getDevicesForAttributes",
- "(Landroid/media/AudioAttributes;[Landroid/media/"
- "AudioDeviceAttributes;Z)I",
- android_media_AudioSystem_getDevicesForAttributes),
- MAKE_JNI_NATIVE_METHOD("setUserIdDeviceAffinities", "(I[I[Ljava/lang/String;)I",
- android_media_AudioSystem_setUserIdDeviceAffinities),
- MAKE_AUDIO_SYSTEM_METHOD(removeUserIdDeviceAffinities),
- MAKE_AUDIO_SYSTEM_METHOD(setCurrentImeUid),
- MAKE_JNI_NATIVE_METHOD("setVibratorInfos", "(Ljava/util/List;)I",
- android_media_AudioSystem_setVibratorInfos),
- MAKE_JNI_NATIVE_METHOD("nativeGetSpatializer",
- "(Landroid/media/INativeSpatializerCallback;)Landroid/os/IBinder;",
- android_media_AudioSystem_getSpatializer),
- MAKE_JNI_NATIVE_METHOD("canBeSpatialized",
- "(Landroid/media/AudioAttributes;Landroid/media/AudioFormat;"
- "[Landroid/media/AudioDeviceAttributes;)Z",
- android_media_AudioSystem_canBeSpatialized),
- MAKE_JNI_NATIVE_METHOD("nativeGetSoundDose",
- "(Landroid/media/ISoundDoseCallback;)Landroid/os/IBinder;",
- android_media_AudioSystem_nativeGetSoundDose),
- MAKE_JNI_NATIVE_METHOD("getDirectPlaybackSupport",
- "(Landroid/media/AudioFormat;Landroid/media/AudioAttributes;)I",
- android_media_AudioSystem_getDirectPlaybackSupport),
- MAKE_JNI_NATIVE_METHOD("getDirectProfilesForAttributes",
- "(Landroid/media/AudioAttributes;Ljava/util/ArrayList;)I",
- android_media_AudioSystem_getDirectProfilesForAttributes),
- MAKE_JNI_NATIVE_METHOD("getSupportedMixerAttributes", "(ILjava/util/List;)I",
- android_media_AudioSystem_getSupportedMixerAttributes),
- MAKE_JNI_NATIVE_METHOD("setPreferredMixerAttributes",
- "(Landroid/media/AudioAttributes;IILandroid/media/"
- "AudioMixerAttributes;)I",
- android_media_AudioSystem_setPreferredMixerAttributes),
- MAKE_JNI_NATIVE_METHOD("getPreferredMixerAttributes",
- "(Landroid/media/AudioAttributes;ILjava/util/List;)I",
- android_media_AudioSystem_getPreferredMixerAttributes),
- MAKE_JNI_NATIVE_METHOD("clearPreferredMixerAttributes",
- "(Landroid/media/AudioAttributes;II)I",
- android_media_AudioSystem_clearPreferredMixerAttributes),
- MAKE_AUDIO_SYSTEM_METHOD(supportsBluetoothVariableLatency),
- MAKE_AUDIO_SYSTEM_METHOD(setBluetoothVariableLatencyEnabled),
- MAKE_AUDIO_SYSTEM_METHOD(isBluetoothVariableLatencyEnabled),
- MAKE_JNI_NATIVE_METHOD("listenForSystemPropertyChange",
- "(Ljava/lang/String;Ljava/lang/Runnable;)J",
- android_media_AudioSystem_listenForSystemPropertyChange),
- MAKE_JNI_NATIVE_METHOD("triggerSystemPropertyUpdate",
- "(J)V",
- android_media_AudioSystem_triggerSystemPropertyUpdate),
-
- };
+static const JNINativeMethod gMethods[] = {
+ MAKE_AUDIO_SYSTEM_METHOD(setParameters),
+ MAKE_AUDIO_SYSTEM_METHOD(getParameters),
+ MAKE_AUDIO_SYSTEM_METHOD(muteMicrophone),
+ MAKE_AUDIO_SYSTEM_METHOD(isMicrophoneMuted),
+ MAKE_AUDIO_SYSTEM_METHOD(isStreamActive),
+ MAKE_AUDIO_SYSTEM_METHOD(isStreamActiveRemotely),
+ MAKE_AUDIO_SYSTEM_METHOD(isSourceActive),
+ MAKE_AUDIO_SYSTEM_METHOD(newAudioSessionId),
+ MAKE_AUDIO_SYSTEM_METHOD(newAudioPlayerId),
+ MAKE_AUDIO_SYSTEM_METHOD(newAudioRecorderId),
+ MAKE_JNI_NATIVE_METHOD("setDeviceConnectionState", "(ILandroid/os/Parcel;I)I",
+ android_media_AudioSystem_setDeviceConnectionState),
+ MAKE_AUDIO_SYSTEM_METHOD(getDeviceConnectionState),
+ MAKE_AUDIO_SYSTEM_METHOD(handleDeviceConfigChange),
+ MAKE_AUDIO_SYSTEM_METHOD(setPhoneState),
+ MAKE_AUDIO_SYSTEM_METHOD(setForceUse),
+ MAKE_AUDIO_SYSTEM_METHOD(getForceUse),
+ MAKE_AUDIO_SYSTEM_METHOD(setDeviceAbsoluteVolumeEnabled),
+ MAKE_AUDIO_SYSTEM_METHOD(initStreamVolume),
+ MAKE_AUDIO_SYSTEM_METHOD(setStreamVolumeIndex),
+ MAKE_AUDIO_SYSTEM_METHOD(getStreamVolumeIndex),
+ MAKE_JNI_NATIVE_METHOD("setVolumeIndexForAttributes",
+ "(Landroid/media/AudioAttributes;IZI)I",
+ android_media_AudioSystem_setVolumeIndexForAttributes),
+ MAKE_JNI_NATIVE_METHOD("getVolumeIndexForAttributes", "(Landroid/media/AudioAttributes;I)I",
+ android_media_AudioSystem_getVolumeIndexForAttributes),
+ MAKE_JNI_NATIVE_METHOD("getMinVolumeIndexForAttributes",
+ "(Landroid/media/AudioAttributes;)I",
+ android_media_AudioSystem_getMinVolumeIndexForAttributes),
+ MAKE_JNI_NATIVE_METHOD("getMaxVolumeIndexForAttributes",
+ "(Landroid/media/AudioAttributes;)I",
+ android_media_AudioSystem_getMaxVolumeIndexForAttributes),
+ MAKE_AUDIO_SYSTEM_METHOD(setMasterVolume),
+ MAKE_AUDIO_SYSTEM_METHOD(getMasterVolume),
+ MAKE_AUDIO_SYSTEM_METHOD(setMasterMute),
+ MAKE_AUDIO_SYSTEM_METHOD(getMasterMute),
+ MAKE_AUDIO_SYSTEM_METHOD(setMasterMono),
+ MAKE_AUDIO_SYSTEM_METHOD(getMasterMono),
+ MAKE_AUDIO_SYSTEM_METHOD(setMasterBalance),
+ MAKE_AUDIO_SYSTEM_METHOD(getMasterBalance),
+ MAKE_AUDIO_SYSTEM_METHOD(getPrimaryOutputSamplingRate),
+ MAKE_AUDIO_SYSTEM_METHOD(getPrimaryOutputFrameCount),
+ MAKE_AUDIO_SYSTEM_METHOD(getOutputLatency),
+ MAKE_AUDIO_SYSTEM_METHOD(setLowRamDevice),
+ MAKE_AUDIO_SYSTEM_METHOD(checkAudioFlinger),
+ MAKE_JNI_NATIVE_METHOD("setAudioFlingerBinder", "(Landroid/os/IBinder;)V",
+ android_media_AudioSystem_setAudioFlingerBinder),
+ MAKE_JNI_NATIVE_METHOD("listAudioPorts", "(Ljava/util/ArrayList;[I)I",
+ android_media_AudioSystem_listAudioPorts),
+ MAKE_JNI_NATIVE_METHOD("getSupportedDeviceTypes", "(ILandroid/util/IntArray;)I",
+ android_media_AudioSystem_getSupportedDeviceTypes),
+ MAKE_JNI_NATIVE_METHOD("createAudioPatch",
+ "([Landroid/media/AudioPatch;[Landroid/media/"
+ "AudioPortConfig;[Landroid/media/AudioPortConfig;)I",
+ android_media_AudioSystem_createAudioPatch),
+ MAKE_JNI_NATIVE_METHOD("releaseAudioPatch", "(Landroid/media/AudioPatch;)I",
+ android_media_AudioSystem_releaseAudioPatch),
+ MAKE_JNI_NATIVE_METHOD("listAudioPatches", "(Ljava/util/ArrayList;[I)I",
+ android_media_AudioSystem_listAudioPatches),
+ MAKE_JNI_NATIVE_METHOD("setAudioPortConfig", "(Landroid/media/AudioPortConfig;)I",
+ android_media_AudioSystem_setAudioPortConfig),
+ MAKE_JNI_NATIVE_METHOD("startAudioSource",
+ "(Landroid/media/AudioPortConfig;Landroid/media/AudioAttributes;)I",
+ android_media_AudioSystem_startAudioSource),
+ MAKE_AUDIO_SYSTEM_METHOD(stopAudioSource),
+ MAKE_AUDIO_SYSTEM_METHOD(getAudioHwSyncForSession),
+ MAKE_JNI_NATIVE_METHOD("registerPolicyMixes", "(Ljava/util/ArrayList;Z)I",
+ android_media_AudioSystem_registerPolicyMixes),
+ MAKE_JNI_NATIVE_METHOD("getRegisteredPolicyMixes", "(Ljava/util/List;)I",
+ android_media_AudioSystem_getRegisteredPolicyMixes),
+ MAKE_JNI_NATIVE_METHOD("updatePolicyMixes",
+ "([Landroid/media/audiopolicy/AudioMix;[Landroid/media/audiopolicy/"
+ "AudioMixingRule;)I",
+ android_media_AudioSystem_updatePolicyMixes),
+ MAKE_JNI_NATIVE_METHOD("setUidDeviceAffinities", "(I[I[Ljava/lang/String;)I",
+ android_media_AudioSystem_setUidDeviceAffinities),
+ MAKE_AUDIO_SYSTEM_METHOD(removeUidDeviceAffinities),
+ MAKE_JNI_NATIVE_METHOD_AUTOSIG("native_register_dynamic_policy_callback",
+ android_media_AudioSystem_registerDynPolicyCallback),
+ MAKE_JNI_NATIVE_METHOD_AUTOSIG("native_register_recording_callback",
+ android_media_AudioSystem_registerRecordingCallback),
+ MAKE_JNI_NATIVE_METHOD_AUTOSIG("native_register_routing_callback",
+ android_media_AudioSystem_registerRoutingCallback),
+ MAKE_JNI_NATIVE_METHOD_AUTOSIG("native_register_vol_range_init_req_callback",
+ android_media_AudioSystem_registerVolRangeInitReqCallback),
+ MAKE_AUDIO_SYSTEM_METHOD(systemReady),
+ MAKE_AUDIO_SYSTEM_METHOD(getStreamVolumeDB),
+ MAKE_JNI_NATIVE_METHOD_AUTOSIG("native_get_offload_support",
+ android_media_AudioSystem_getOffloadSupport),
+ MAKE_JNI_NATIVE_METHOD("getMicrophones", "(Ljava/util/ArrayList;)I",
+ android_media_AudioSystem_getMicrophones),
+ MAKE_JNI_NATIVE_METHOD("getSurroundFormats", "(Ljava/util/Map;)I",
+ android_media_AudioSystem_getSurroundFormats),
+ MAKE_JNI_NATIVE_METHOD("getReportedSurroundFormats", "(Ljava/util/ArrayList;)I",
+ android_media_AudioSystem_getReportedSurroundFormats),
+ MAKE_AUDIO_SYSTEM_METHOD(setSurroundFormatEnabled),
+ MAKE_AUDIO_SYSTEM_METHOD(setAssistantServicesUids),
+ MAKE_AUDIO_SYSTEM_METHOD(setActiveAssistantServicesUids),
+ MAKE_AUDIO_SYSTEM_METHOD(setA11yServicesUids),
+ MAKE_AUDIO_SYSTEM_METHOD(isHapticPlaybackSupported),
+ MAKE_AUDIO_SYSTEM_METHOD(isUltrasoundSupported),
+ MAKE_JNI_NATIVE_METHOD(
+ "getHwOffloadFormatsSupportedForBluetoothMedia", "(ILjava/util/ArrayList;)I",
+ android_media_AudioSystem_getHwOffloadFormatsSupportedForBluetoothMedia),
+ MAKE_AUDIO_SYSTEM_METHOD(setSupportedSystemUsages),
+ MAKE_AUDIO_SYSTEM_METHOD(setAllowedCapturePolicy),
+ MAKE_AUDIO_SYSTEM_METHOD(setRttEnabled),
+ MAKE_AUDIO_SYSTEM_METHOD(setAudioHalPids),
+ MAKE_AUDIO_SYSTEM_METHOD(isCallScreeningModeSupported),
+ MAKE_JNI_NATIVE_METHOD("setDevicesRoleForStrategy", "(II[I[Ljava/lang/String;)I",
+ android_media_AudioSystem_setDevicesRoleForStrategy),
+ MAKE_JNI_NATIVE_METHOD("removeDevicesRoleForStrategy", "(II[I[Ljava/lang/String;)I",
+ android_media_AudioSystem_removeDevicesRoleForStrategy),
+ MAKE_AUDIO_SYSTEM_METHOD(clearDevicesRoleForStrategy),
+ MAKE_JNI_NATIVE_METHOD("getDevicesForRoleAndStrategy", "(IILjava/util/List;)I",
+ android_media_AudioSystem_getDevicesForRoleAndStrategy),
+ MAKE_JNI_NATIVE_METHOD("setDevicesRoleForCapturePreset", "(II[I[Ljava/lang/String;)I",
+ android_media_AudioSystem_setDevicesRoleForCapturePreset),
+ MAKE_JNI_NATIVE_METHOD("addDevicesRoleForCapturePreset", "(II[I[Ljava/lang/String;)I",
+ android_media_AudioSystem_addDevicesRoleForCapturePreset),
+ MAKE_JNI_NATIVE_METHOD("removeDevicesRoleForCapturePreset", "(II[I[Ljava/lang/String;)I",
+ android_media_AudioSystem_removeDevicesRoleForCapturePreset),
+ MAKE_AUDIO_SYSTEM_METHOD(clearDevicesRoleForCapturePreset),
+ MAKE_JNI_NATIVE_METHOD("getDevicesForRoleAndCapturePreset", "(IILjava/util/List;)I",
+ android_media_AudioSystem_getDevicesForRoleAndCapturePreset),
+ MAKE_JNI_NATIVE_METHOD("getDevicesForAttributes",
+ "(Landroid/media/AudioAttributes;[Landroid/media/"
+ "AudioDeviceAttributes;Z)I",
+ android_media_AudioSystem_getDevicesForAttributes),
+ MAKE_JNI_NATIVE_METHOD("setUserIdDeviceAffinities", "(I[I[Ljava/lang/String;)I",
+ android_media_AudioSystem_setUserIdDeviceAffinities),
+ MAKE_AUDIO_SYSTEM_METHOD(removeUserIdDeviceAffinities),
+ MAKE_AUDIO_SYSTEM_METHOD(setCurrentImeUid),
+ MAKE_JNI_NATIVE_METHOD("setVibratorInfos", "(Ljava/util/List;)I",
+ android_media_AudioSystem_setVibratorInfos),
+ MAKE_JNI_NATIVE_METHOD("nativeGetSpatializer",
+ "(Landroid/media/INativeSpatializerCallback;)Landroid/os/IBinder;",
+ android_media_AudioSystem_getSpatializer),
+ MAKE_JNI_NATIVE_METHOD("canBeSpatialized",
+ "(Landroid/media/AudioAttributes;Landroid/media/AudioFormat;"
+ "[Landroid/media/AudioDeviceAttributes;)Z",
+ android_media_AudioSystem_canBeSpatialized),
+ MAKE_JNI_NATIVE_METHOD("nativeGetSoundDose",
+ "(Landroid/media/ISoundDoseCallback;)Landroid/os/IBinder;",
+ android_media_AudioSystem_nativeGetSoundDose),
+ MAKE_JNI_NATIVE_METHOD("getDirectPlaybackSupport",
+ "(Landroid/media/AudioFormat;Landroid/media/AudioAttributes;)I",
+ android_media_AudioSystem_getDirectPlaybackSupport),
+ MAKE_JNI_NATIVE_METHOD("getDirectProfilesForAttributes",
+ "(Landroid/media/AudioAttributes;Ljava/util/ArrayList;)I",
+ android_media_AudioSystem_getDirectProfilesForAttributes),
+ MAKE_JNI_NATIVE_METHOD("getSupportedMixerAttributes", "(ILjava/util/List;)I",
+ android_media_AudioSystem_getSupportedMixerAttributes),
+ MAKE_JNI_NATIVE_METHOD("setPreferredMixerAttributes",
+ "(Landroid/media/AudioAttributes;IILandroid/media/"
+ "AudioMixerAttributes;)I",
+ android_media_AudioSystem_setPreferredMixerAttributes),
+ MAKE_JNI_NATIVE_METHOD("getPreferredMixerAttributes",
+ "(Landroid/media/AudioAttributes;ILjava/util/List;)I",
+ android_media_AudioSystem_getPreferredMixerAttributes),
+ MAKE_JNI_NATIVE_METHOD("clearPreferredMixerAttributes",
+ "(Landroid/media/AudioAttributes;II)I",
+ android_media_AudioSystem_clearPreferredMixerAttributes),
+ MAKE_AUDIO_SYSTEM_METHOD(supportsBluetoothVariableLatency),
+ MAKE_AUDIO_SYSTEM_METHOD(setBluetoothVariableLatencyEnabled),
+ MAKE_AUDIO_SYSTEM_METHOD(isBluetoothVariableLatencyEnabled),
+ MAKE_JNI_NATIVE_METHOD("listenForSystemPropertyChange",
+ "(Ljava/lang/String;Ljava/lang/Runnable;)J",
+ android_media_AudioSystem_listenForSystemPropertyChange),
+ MAKE_JNI_NATIVE_METHOD("triggerSystemPropertyUpdate", "(J)V",
+ android_media_AudioSystem_triggerSystemPropertyUpdate),
+};
static const JNINativeMethod gEventHandlerMethods[] =
{MAKE_JNI_NATIVE_METHOD("native_setup", "(Ljava/lang/Object;)V",
diff --git a/core/res/res/color-watch-v36/btn_material_filled_background_color.xml b/core/res/res/color-watch-v36/btn_material_filled_background_color.xml
deleted file mode 100644
index 8b2afa8..0000000
--- a/core/res/res/color-watch-v36/btn_material_filled_background_color.xml
+++ /dev/null
@@ -1,23 +0,0 @@
-<!--
- ~ Copyright (C) 2024 The Android Open Source Project
- ~
- ~ Licensed under the Apache License, Version 2.0 (the "License");
- ~ you may not use this file except in compliance with the License.
- ~ You may obtain a copy of the License at
- ~
- ~ http://www.apache.org/licenses/LICENSE-2.0
- ~
- ~ Unless required by applicable law or agreed to in writing, software
- ~ distributed under the License is distributed on an "AS IS" BASIS,
- ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- ~ See the License for the specific language governing permissions and
- ~ limitations under the License.
- -->
-
-<selector xmlns:android="http://schemas.android.com/apk/res/android">
- <item android:state_enabled="false"
- android:alpha="?attr/disabledAlpha"
- android:color="?attr/materialColorOnSurface" />
- <item android:state_enabled="true"
- android:color="?attr/materialColorPrimary" />
-</selector>
\ No newline at end of file
diff --git a/core/res/res/color-watch-v36/btn_material_filled_text_color.xml b/core/res/res/color-watch-v36/btn_material_filled_text_color.xml
deleted file mode 100644
index cefc912..0000000
--- a/core/res/res/color-watch-v36/btn_material_filled_text_color.xml
+++ /dev/null
@@ -1,23 +0,0 @@
-<!--
- ~ Copyright (C) 2024 The Android Open Source Project
- ~
- ~ Licensed under the Apache License, Version 2.0 (the "License");
- ~ you may not use this file except in compliance with the License.
- ~ You may obtain a copy of the License at
- ~
- ~ http://www.apache.org/licenses/LICENSE-2.0
- ~
- ~ Unless required by applicable law or agreed to in writing, software
- ~ distributed under the License is distributed on an "AS IS" BASIS,
- ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- ~ See the License for the specific language governing permissions and
- ~ limitations under the License.
- -->
-
-<selector xmlns:android="http://schemas.android.com/apk/res/android">
- <item android:state_enabled="false"
- android:alpha="?attr/primaryContentAlpha"
- android:color="?attr/materialColorOnSurface" />
- <item android:state_enabled="true"
- android:color="?attr/materialColorOnPrimary" />
-</selector>
\ No newline at end of file
diff --git a/core/res/res/color-watch-v36/btn_material_filled_tonal_background_color.xml b/core/res/res/color-watch-v36/btn_material_filled_tonal_background_color.xml
deleted file mode 100644
index eaf9e7d..0000000
--- a/core/res/res/color-watch-v36/btn_material_filled_tonal_background_color.xml
+++ /dev/null
@@ -1,23 +0,0 @@
-<!--
- ~ Copyright (C) 2024 The Android Open Source Project
- ~
- ~ Licensed under the Apache License, Version 2.0 (the "License");
- ~ you may not use this file except in compliance with the License.
- ~ You may obtain a copy of the License at
- ~
- ~ http://www.apache.org/licenses/LICENSE-2.0
- ~
- ~ Unless required by applicable law or agreed to in writing, software
- ~ distributed under the License is distributed on an "AS IS" BASIS,
- ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- ~ See the License for the specific language governing permissions and
- ~ limitations under the License.
- -->
-
-<selector xmlns:android="http://schemas.android.com/apk/res/android">
- <item android:state_enabled="false"
- android:alpha="?attr/disabledAlpha"
- android:color="?attr/materialColorOnSurface" />
- <item android:state_enabled="true"
- android:color="?attr/materialColorSurfaceContainer" />
-</selector>
\ No newline at end of file
diff --git a/core/res/res/color-watch-v36/btn_material_filled_tonal_text_color.xml b/core/res/res/color-watch-v36/btn_material_filled_tonal_text_color.xml
deleted file mode 100644
index 94e50fb..0000000
--- a/core/res/res/color-watch-v36/btn_material_filled_tonal_text_color.xml
+++ /dev/null
@@ -1,23 +0,0 @@
-<!--
- ~ Copyright (C) 2024 The Android Open Source Project
- ~
- ~ Licensed under the Apache License, Version 2.0 (the "License");
- ~ you may not use this file except in compliance with the License.
- ~ You may obtain a copy of the License at
- ~
- ~ http://www.apache.org/licenses/LICENSE-2.0
- ~
- ~ Unless required by applicable law or agreed to in writing, software
- ~ distributed under the License is distributed on an "AS IS" BASIS,
- ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- ~ See the License for the specific language governing permissions and
- ~ limitations under the License.
- -->
-
-<selector xmlns:android="http://schemas.android.com/apk/res/android">
- <item android:state_enabled="false"
- android:alpha="?attr/primaryContentAlpha"
- android:color="?attr/materialColorOnSurface" />
- <item android:state_enabled="true"
- android:color="?attr/materialColorOnSurface" />
-</selector>
\ No newline at end of file
diff --git a/core/res/res/drawable-watch-v36/btn_background_material_filled.xml b/core/res/res/drawable-watch-v36/btn_background_material_filled.xml
deleted file mode 100644
index 0029de1..0000000
--- a/core/res/res/drawable-watch-v36/btn_background_material_filled.xml
+++ /dev/null
@@ -1,28 +0,0 @@
-<!--
- ~ Copyright (C) 2024 The Android Open Source Project
- ~
- ~ Licensed under the Apache License, Version 2.0 (the "License");
- ~ you may not use this file except in compliance with the License.
- ~ You may obtain a copy of the License at
- ~
- ~ http://www.apache.org/licenses/LICENSE-2.0
- ~
- ~ Unless required by applicable law or agreed to in writing, software
- ~ distributed under the License is distributed on an "AS IS" BASIS,
- ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- ~ See the License for the specific language governing permissions and
- ~ limitations under the License.
- -->
-
-<ripple xmlns:android="http://schemas.android.com/apk/res/android"
- android:color="?attr/colorControlHighlight">
- <item>
- <shape android:shape="rectangle">
- <solid android:color="@color/btn_material_filled_background_color"/>
- <corners android:radius="?android:attr/buttonCornerRadius"/>
- <size
- android:width="@dimen/btn_material_width"
- android:height="@dimen/btn_material_height" />
- </shape>
- </item>
-</ripple>
\ No newline at end of file
diff --git a/core/res/res/drawable-watch-v36/btn_background_material_filled_tonal.xml b/core/res/res/drawable-watch-v36/btn_background_material_filled_tonal.xml
deleted file mode 100644
index 105f077..0000000
--- a/core/res/res/drawable-watch-v36/btn_background_material_filled_tonal.xml
+++ /dev/null
@@ -1,28 +0,0 @@
-<!--
- ~ Copyright (C) 2024 The Android Open Source Project
- ~
- ~ Licensed under the Apache License, Version 2.0 (the "License");
- ~ you may not use this file except in compliance with the License.
- ~ You may obtain a copy of the License at
- ~
- ~ http://www.apache.org/licenses/LICENSE-2.0
- ~
- ~ Unless required by applicable law or agreed to in writing, software
- ~ distributed under the License is distributed on an "AS IS" BASIS,
- ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- ~ See the License for the specific language governing permissions and
- ~ limitations under the License.
- -->
-
-<ripple xmlns:android="http://schemas.android.com/apk/res/android"
- android:color="?attr/colorControlHighlight">
- <item>
- <shape android:shape="rectangle">
- <solid android:color="@color/btn_material_filled_tonal_background_color"/>
- <corners android:radius="?android:attr/buttonCornerRadius"/>
- <size
- android:width="@dimen/btn_material_width"
- android:height="@dimen/btn_material_height" />
- </shape>
- </item>
-</ripple>
\ No newline at end of file
diff --git a/core/res/res/values-watch-v36/colors.xml b/core/res/res/values-watch-v36/colors.xml
deleted file mode 100644
index 4bc2a66..0000000
--- a/core/res/res/values-watch-v36/colors.xml
+++ /dev/null
@@ -1,18 +0,0 @@
-<!--
- ~ Copyright (C) 2024 The Android Open Source Project
- ~
- ~ Licensed under the Apache License, Version 2.0 (the "License");
- ~ you may not use this file except in compliance with the License.
- ~ You may obtain a copy of the License at
- ~
- ~ http://www.apache.org/licenses/LICENSE-2.0
- ~
- ~ Unless required by applicable law or agreed to in writing, software
- ~ distributed under the License is distributed on an "AS IS" BASIS,
- ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- ~ See the License for the specific language governing permissions and
- ~ limitations under the License.
- -->
-<!-- TODO(b/372524566): update color token's value to match material3 design. -->
-<resources>
-</resources>
\ No newline at end of file
diff --git a/core/res/res/values-watch-v36/config.xml b/core/res/res/values-watch-v36/config.xml
deleted file mode 100644
index c8f347af..0000000
--- a/core/res/res/values-watch-v36/config.xml
+++ /dev/null
@@ -1,20 +0,0 @@
-<!--
- ~ Copyright (C) 2024 The Android Open Source Project
- ~
- ~ Licensed under the Apache License, Version 2.0 (the "License");
- ~ you may not use this file except in compliance with the License.
- ~ You may obtain a copy of the License at
- ~
- ~ http://www.apache.org/licenses/LICENSE-2.0
- ~
- ~ Unless required by applicable law or agreed to in writing, software
- ~ distributed under the License is distributed on an "AS IS" BASIS,
- ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- ~ See the License for the specific language governing permissions and
- ~ limitations under the License.
- -->
-
-<resources>
- <!-- Overrides system value -->
- <dimen name="config_buttonCornerRadius">26dp</dimen>
-</resources>
diff --git a/core/res/res/values-watch-v36/dimens_material.xml b/core/res/res/values-watch-v36/dimens_material.xml
deleted file mode 100644
index ad3c1a3..0000000
--- a/core/res/res/values-watch-v36/dimens_material.xml
+++ /dev/null
@@ -1,28 +0,0 @@
-<!--
- ~ Copyright (C) 2024 The Android Open Source Project
- ~
- ~ Licensed under the Apache License, Version 2.0 (the "License");
- ~ you may not use this file except in compliance with the License.
- ~ You may obtain a copy of the License at
- ~
- ~ http://www.apache.org/licenses/LICENSE-2.0
- ~
- ~ Unless required by applicable law or agreed to in writing, software
- ~ distributed under the License is distributed on an "AS IS" BASIS,
- ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- ~ See the License for the specific language governing permissions and
- ~ limitations under the License.
- -->
-<resources>
- <!-- values for material3 button -->
- <dimen name="btn_material_width">172dp</dimen>
- <dimen name="btn_material_height">52dp</dimen>
- <dimen name="btn_horizontal_edge_padding">14dp</dimen>
- <dimen name="btn_drawable_padding">6dp</dimen>
- <dimen name="btn_lineHeight">18sp</dimen>
- <dimen name="btn_textSize">15sp</dimen>
-
- <!-- Opacity factor for disabled material3 widget -->
- <dimen name="disabled_alpha_device_default">0.12</dimen>
- <dimen name="primary_content_alpha_device_default">0.38</dimen>
-</resources>
diff --git a/core/res/res/values-watch-v36/styles_material.xml b/core/res/res/values-watch-v36/styles_material.xml
deleted file mode 100644
index 32a22bb..0000000
--- a/core/res/res/values-watch-v36/styles_material.xml
+++ /dev/null
@@ -1,58 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
- ~ Copyright (C) 2024 The Android Open Source Project
- ~
- ~ Licensed under the Apache License, Version 2.0 (the "License");
- ~ you may not use this file except in compliance with the License.
- ~ You may obtain a copy of the License at
- ~
- ~ http://www.apache.org/licenses/LICENSE-2.0
- ~
- ~ Unless required by applicable law or agreed to in writing, software
- ~ distributed under the License is distributed on an "AS IS" BASIS,
- ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- ~ See the License for the specific language governing permissions and
- ~ limitations under the License.
- -->
-
-<resources>
- <!-- Button Styles -->
- <!-- Material Button - Filled -->
- <style name="Widget.DeviceDefault.Button.Filled" parent="Widget.DeviceDefault.Button">
- <item name="android:background">@drawable/btn_background_material_filled</item>
- <item name="textAppearance">@style/TextAppearance.Widget.Button.Material.Filled</item>
- </style>
-
- <!-- Material Button - Filled Tonal(Override system default button styles) -->
- <style name="Widget.DeviceDefault.Button">
- <item name="background">@drawable/btn_background_material_filled_tonal</item>
- <item name="textAppearance">@style/TextAppearance.Widget.Button.Material</item>
- <item name="minHeight">@dimen/btn_material_height</item>
- <item name="maxWidth">@dimen/btn_material_width</item>
- <item name="android:paddingStart">@dimen/btn_horizontal_edge_padding</item>
- <item name="android:paddingEnd">@dimen/btn_horizontal_edge_padding</item>
- <item name="android:drawablePadding">@dimen/btn_drawable_padding</item>
- <item name="android:maxLines">2</item>
- <item name="android:ellipsize">end</item>
- <item name="android:breakStrategy">simple</item>
- <item name="stateListAnimator">@anim/button_state_list_anim_material</item>
- <item name="focusable">true</item>
- <item name="clickable">true</item>
- <item name="gravity">center_vertical</item>
- </style>
-
- <!-- Text Styles -->
- <!-- TextAppearance for Material Button - Filled -->
- <style name="TextAppearance.Widget.Button.Material.Filled" parent="TextAppearance.Widget.Button.Material">
- <item name="textColor">@color/btn_material_filled_text_color</item>
- </style>
-
- <!-- TextAppearance for Material Button - Filled Tonal -->
- <style name="TextAppearance.Widget.Button.Material" parent="TextAppearance.DeviceDefault">
- <item name="android:fontFamily">font-family-flex-device-default</item>
- <item name="android:fontVariationSettings">"'wdth' 90, 'wght' 500, 'ROND' 100, 'opsz' 15, 'GRAD' 0"</item>
- <item name="textSize">@dimen/btn_textSize</item>
- <item name="textColor">@color/btn_material_filled_tonal_text_color</item>
- <item name="lineHeight">@dimen/btn_lineHeight</item>
- </style>
-</resources>
\ No newline at end of file
diff --git a/core/tests/coretests/src/android/app/NotificationTest.java b/core/tests/coretests/src/android/app/NotificationTest.java
index 48e2620..23a0985 100644
--- a/core/tests/coretests/src/android/app/NotificationTest.java
+++ b/core/tests/coretests/src/android/app/NotificationTest.java
@@ -2397,10 +2397,25 @@
public void progressStyle_getProgressMax_returnsSumOfSegmentLength() {
final Notification.ProgressStyle progressStyle = new Notification.ProgressStyle();
progressStyle
+ .setProgressSegments(List.of(new Notification.ProgressStyle.Segment(15),
+ new Notification.ProgressStyle.Segment(25)))
.addProgressSegment(new Notification.ProgressStyle.Segment(10))
.addProgressSegment(new Notification.ProgressStyle.Segment(20));
- assertThat(progressStyle.getProgressMax()).isEqualTo(30);
+ assertThat(progressStyle.getProgressMax()).isEqualTo(70);
+ }
+
+ @Test
+ @EnableFlags(Flags.FLAG_API_RICH_ONGOING)
+ public void progressStyle_getProgressMax_onSetProgressSegments_resets() {
+ final Notification.ProgressStyle progressStyle = new Notification.ProgressStyle();
+ progressStyle
+ .addProgressSegment(new Notification.ProgressStyle.Segment(10))
+ .addProgressSegment(new Notification.ProgressStyle.Segment(20))
+ .setProgressSegments(List.of(new Notification.ProgressStyle.Segment(15),
+ new Notification.ProgressStyle.Segment(25)));
+
+ assertThat(progressStyle.getProgressMax()).isEqualTo(40);
}
@Test
diff --git a/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/DesktopTasksController.kt b/libs/WindowManager/Shell/src/com/android/wm/shell/desktopmode/DesktopTasksController.kt
index 57a59c9..b723337 100644
--- a/libs/WindowManager/Shell/src/com/android/wm/shell/desktopmode/DesktopTasksController.kt
+++ b/libs/WindowManager/Shell/src/com/android/wm/shell/desktopmode/DesktopTasksController.kt
@@ -659,6 +659,7 @@
}
val wct = WindowContainerTransaction()
+ if (!task.isFreeform) addMoveToDesktopChanges(wct, task, displayId)
wct.reparent(task.token, displayAreaInfo.token, true /* onTop */)
transitions.startTransition(TRANSIT_CHANGE, wct, null /* handler */)
@@ -1245,7 +1246,7 @@
val bounds = when (newTaskWindowingMode) {
WINDOWING_MODE_FREEFORM -> {
displayController.getDisplayLayout(callingTask.displayId)
- ?.let { getInitialBounds(it, callingTask) }
+ ?.let { getInitialBounds(it, callingTask, callingTask.displayId) }
}
WINDOWING_MODE_MULTI_WINDOW -> {
Rect()
@@ -1311,7 +1312,7 @@
val displayLayout = displayController.getDisplayLayout(task.displayId)
if (displayLayout != null) {
val initialBounds = Rect(task.configuration.windowConfiguration.bounds)
- cascadeWindow(task, initialBounds, displayLayout)
+ cascadeWindow(initialBounds, displayLayout, task.displayId)
wct.setBounds(task.token, initialBounds)
}
}
@@ -1399,13 +1400,19 @@
return if (wct.isEmpty) null else wct
}
+ /**
+ * Apply all changes required when task is first added to desktop. Uses the task's current
+ * display by default to apply initial bounds and placement relative to the display.
+ * Use a different [displayId] if the task should be moved to a different display.
+ */
@VisibleForTesting
fun addMoveToDesktopChanges(
wct: WindowContainerTransaction,
- taskInfo: RunningTaskInfo
+ taskInfo: RunningTaskInfo,
+ displayId: Int = taskInfo.displayId,
) {
- val displayLayout = displayController.getDisplayLayout(taskInfo.displayId) ?: return
- val tdaInfo = rootTaskDisplayAreaOrganizer.getDisplayAreaInfo(taskInfo.displayId)!!
+ val displayLayout = displayController.getDisplayLayout(displayId) ?: return
+ val tdaInfo = rootTaskDisplayAreaOrganizer.getDisplayAreaInfo(displayId)!!
val tdaWindowingMode = tdaInfo.configuration.windowConfiguration.windowingMode
val targetWindowingMode =
if (tdaWindowingMode == WINDOWING_MODE_FREEFORM) {
@@ -1414,7 +1421,7 @@
} else {
WINDOWING_MODE_FREEFORM
}
- val initialBounds = getInitialBounds(displayLayout, taskInfo)
+ val initialBounds = getInitialBounds(displayLayout, taskInfo, displayId)
if (canChangeTaskPosition(taskInfo)) {
wct.setBounds(taskInfo.token, initialBounds)
@@ -1428,7 +1435,8 @@
private fun getInitialBounds(
displayLayout: DisplayLayout,
- taskInfo: RunningTaskInfo
+ taskInfo: RunningTaskInfo,
+ displayId: Int,
): Rect {
val bounds = if (ENABLE_WINDOWING_DYNAMIC_INITIAL_BOUNDS.isTrue) {
calculateInitialBounds(displayLayout, taskInfo)
@@ -1437,7 +1445,7 @@
}
if (DesktopModeFlags.ENABLE_CASCADING_WINDOWS.isTrue) {
- cascadeWindow(taskInfo, bounds, displayLayout)
+ cascadeWindow(bounds, displayLayout, displayId)
}
return bounds
}
@@ -1466,11 +1474,11 @@
}
}
- private fun cascadeWindow(task: TaskInfo, bounds: Rect, displayLayout: DisplayLayout) {
+ private fun cascadeWindow(bounds: Rect, displayLayout: DisplayLayout, displayId: Int) {
val stableBounds = Rect()
displayLayout.getStableBoundsForDesktopMode(stableBounds)
- val activeTasks = taskRepository.getActiveNonMinimizedOrderedTasks(task.displayId)
+ val activeTasks = taskRepository.getActiveNonMinimizedOrderedTasks(displayId)
activeTasks.firstOrNull()?.let { activeTask ->
shellTaskOrganizer.getRunningTaskInfo(activeTask)?.let {
cascadeWindow(context.resources, stableBounds,
@@ -2069,6 +2077,12 @@
c.removeDesktop(displayId)
}
}
+
+ override fun moveToExternalDisplay(taskId: Int) {
+ executeRemoteCallWithTaskPermission(controller, "moveTaskToExternalDisplay") { c ->
+ c.moveToNextDisplay(taskId)
+ }
+ }
}
private fun logV(msg: String, vararg arguments: Any?) {
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/desktopmode/IDesktopMode.aidl b/libs/WindowManager/Shell/src/com/android/wm/shell/desktopmode/IDesktopMode.aidl
index 86351e3..c27813d 100644
--- a/libs/WindowManager/Shell/src/com/android/wm/shell/desktopmode/IDesktopMode.aidl
+++ b/libs/WindowManager/Shell/src/com/android/wm/shell/desktopmode/IDesktopMode.aidl
@@ -52,4 +52,7 @@
/** Remove desktop on the given display */
oneway void removeDesktop(int displayId);
+
+ /** Move a task with given `taskId` to external display */
+ void moveToExternalDisplay(int taskId);
}
\ No newline at end of file
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..3e76403 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,19 @@
* - The {@link SplitLayout} divider is only visible if multiple {@link StageTaskListener}s are
* visible
* - Both stages are put under a single-top root task.
- * This rules are mostly implemented in {@link #onStageVisibilityChanged(StageListenerImpl)} and
- * {@link #onStageHasChildrenChanged(StageListenerImpl).}
*/
public class StageCoordinator implements SplitLayout.SplitLayoutHandler,
DisplayController.OnDisplaysChangedListener, Transitions.TransitionHandler,
- ShellTaskOrganizer.TaskListener {
+ ShellTaskOrganizer.TaskListener, StageTaskListener.StageListenerCallbacks {
private static final String TAG = StageCoordinator.class.getSimpleName();
+ // The duration in ms to prevent launch-adjacent from working after split screen is first
+ // entered
+ private static final int DISABLE_LAUNCH_ADJACENT_AFTER_ENTER_TIMEOUT_MS = 1000;
+
private final StageTaskListener mMainStage;
- private final StageListenerImpl mMainStageListener = new StageListenerImpl();
private final StageTaskListener mSideStage;
- private final StageListenerImpl mSideStageListener = new StageListenerImpl();
@SplitPosition
private int mSideStagePosition = SPLIT_POSITION_BOTTOM_OR_RIGHT;
@@ -235,6 +243,10 @@
private SplitScreen.SplitInvocationListener mSplitInvocationListener;
private Executor mSplitInvocationListenerExecutor;
+ // Re-enables launch-adjacent handling on the split root task. This needs to be a member
+ // because we will be posting and removing it from the handler.
+ private final Runnable mReEnableLaunchAdjacentOnRoot = () -> setLaunchAdjacentDisabled(false);
+
/**
* Since StageCoordinator only coordinates MainStage and SideStage, it shouldn't support
* CompatUI layouts. CompatUI is handled separately by MainStage and SideStage.
@@ -328,7 +340,7 @@
mContext,
mTaskOrganizer,
mDisplayId,
- mMainStageListener,
+ this /*stageListenerCallbacks*/,
mSyncQueue,
iconProvider,
mWindowDecorViewModel);
@@ -336,7 +348,7 @@
mContext,
mTaskOrganizer,
mDisplayId,
- mSideStageListener,
+ this /*stageListenerCallbacks*/,
mSyncQueue,
iconProvider,
mWindowDecorViewModel);
@@ -411,7 +423,7 @@
}
public boolean isSplitScreenVisible() {
- return mSideStageListener.mVisible && mMainStageListener.mVisible;
+ return mSideStage.mVisible && mMainStage.mVisible;
}
private void activateSplit(WindowContainerTransaction wct, boolean includingTopTask) {
@@ -1096,7 +1108,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 +1329,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 +1583,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 +1719,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 +1746,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 +1764,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 +1910,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 +1947,7 @@
}
});
}
- if (mMainStageListener.mHasChildren && mSideStageListener.mHasChildren) {
+ if (mMainStage.mHasChildren && mSideStage.mHasChildren) {
mShouldUpdateRecents = true;
clearRequestIfPresented();
updateRecentTasksSplitPair();
@@ -1974,6 +1963,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 +2063,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 +2523,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) {
@@ -2662,6 +2707,16 @@
}
}
+ /**
+ * Sets whether launch-adjacent is disabled or enabled.
+ */
+ private void setLaunchAdjacentDisabled(boolean disabled) {
+ ProtoLog.d(WM_SHELL_SPLIT_SCREEN, "setLaunchAdjacentDisabled: disabled=%b", disabled);
+ final WindowContainerTransaction wct = new WindowContainerTransaction();
+ wct.setDisableLaunchAdjacent(mRootTaskInfo.token, disabled);
+ mTaskOrganizer.applyTransaction(wct);
+ }
+
/** Starts the pending transition animation. */
public boolean startPendingAnimation(@NonNull IBinder transition,
@NonNull TransitionInfo info,
@@ -2674,6 +2729,14 @@
if (mSplitTransitions.isPendingEnter(transition)) {
shouldAnimate = startPendingEnterAnimation(transition,
mSplitTransitions.mPendingEnter, info, startTransaction, finishTransaction);
+
+ // Disable launch adjacent after an enter animation to prevent cases where apps are
+ // incorrectly trampolining and incorrectly triggering a double launch-adjacent task
+ // launch (ie. main -> split -> main). See b/344216031
+ setLaunchAdjacentDisabled(true);
+ mMainHandler.removeCallbacks(mReEnableLaunchAdjacentOnRoot);
+ mMainHandler.postDelayed(mReEnableLaunchAdjacentOnRoot,
+ DISABLE_LAUNCH_ADJACENT_AFTER_ENTER_TIMEOUT_MS);
} else if (mSplitTransitions.isPendingDismiss(transition)) {
final SplitScreenTransitions.DismissSession dismiss = mSplitTransitions.mPendingDismiss;
shouldAnimate = startPendingDismissAnimation(
@@ -3182,13 +3245,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 +3263,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 +3314,4 @@
!toMainStage ? mSideStage.getTopChildTaskUid() : 0 /* sideStageUid */,
mSplitLayout.isLeftRightSplit());
}
-
- class StageListenerImpl implements StageTaskListener.StageListenerCallbacks {
- boolean mHasRootTask = false;
- boolean mVisible = false;
- boolean mHasChildren = false;
-
- @Override
- public void onRootTaskAppeared() {
- mHasRootTask = true;
- StageCoordinator.this.onRootTaskAppeared();
- }
-
- @Override
- public void onChildTaskAppeared(int taskId) {
- StageCoordinator.this.onChildTaskAppeared(this, taskId);
- }
-
- @Override
- public void onStatusChanged(boolean visible, boolean hasChildren) {
- if (!mHasRootTask) return;
-
- if (mHasChildren != hasChildren) {
- mHasChildren = hasChildren;
- StageCoordinator.this.onStageHasChildrenChanged(this);
- }
- if (mVisible != visible) {
- mVisible = visible;
- StageCoordinator.this.onStageVisibilityChanged(this);
- }
- }
-
- @Override
- public void onChildTaskStatusChanged(int taskId, boolean present, boolean visible) {
- StageCoordinator.this.onStageChildTaskStatusChanged(this, taskId, present, visible);
- }
-
- @Override
- public void onRootTaskVanished() {
- reset();
- StageCoordinator.this.onRootTaskVanished();
- }
-
- @Override
- public void onNoLongerSupportMultiWindow(ActivityManager.RunningTaskInfo taskInfo) {
- ProtoLog.d(WM_SHELL_SPLIT_SCREEN, "onNoLongerSupportMultiWindow: task=%s", taskInfo);
- if (isSplitActive()) {
- final boolean isMainStage = mMainStageListener == this;
-
- // If visible, we preserve the app and keep it running. If an app becomes
- // unsupported in the bg, break split without putting anything on top
- boolean splitScreenVisible = isSplitScreenVisible();
- int stageType = STAGE_TYPE_UNDEFINED;
- if (splitScreenVisible) {
- stageType = isMainStage ? STAGE_TYPE_MAIN : STAGE_TYPE_SIDE;
- }
- final WindowContainerTransaction wct = new WindowContainerTransaction();
- prepareExitSplitScreen(stageType, wct);
- clearSplitPairedInRecents(EXIT_REASON_APP_DOES_NOT_SUPPORT_MULTIWINDOW);
- mSplitTransitions.startDismissTransition(wct, StageCoordinator.this, stageType,
- EXIT_REASON_APP_DOES_NOT_SUPPORT_MULTIWINDOW);
- Log.w(TAG, splitFailureMessage("onNoLongerSupportMultiWindow",
- "app package " + taskInfo.baseIntent.getComponent()
- + " does not support splitscreen, or is a controlled activity"
- + " type"));
- if (splitScreenVisible) {
- handleUnsupportedSplitStart();
- }
- }
- }
-
- private void reset() {
- mHasRootTask = false;
- mVisible = false;
- mHasChildren = false;
- }
-
- public void dump(@NonNull PrintWriter pw, String prefix) {
- pw.println(prefix + "mHasRootTask=" + mHasRootTask);
- pw.println(prefix + "mVisible=" + mVisible);
- pw.println(prefix + "mHasChildren=" + mHasChildren);
- }
- }
}
diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/splitscreen/StageTaskListener.java b/libs/WindowManager/Shell/src/com/android/wm/shell/splitscreen/StageTaskListener.java
index d64c0a2..ae4bd16 100644
--- a/libs/WindowManager/Shell/src/com/android/wm/shell/splitscreen/StageTaskListener.java
+++ b/libs/WindowManager/Shell/src/com/android/wm/shell/splitscreen/StageTaskListener.java
@@ -22,20 +22,17 @@
import static android.content.res.Configuration.SMALLEST_SCREEN_WIDTH_DP_UNDEFINED;
import static android.view.RemoteAnimationTarget.MODE_OPENING;
+import static com.android.wm.shell.protolog.ShellProtoLogGroup.WM_SHELL_SPLIT_SCREEN;
import static com.android.wm.shell.shared.split.SplitScreenConstants.CONTROLLED_ACTIVITY_TYPES;
import static com.android.wm.shell.shared.split.SplitScreenConstants.CONTROLLED_WINDOWING_MODES;
import static com.android.wm.shell.shared.split.SplitScreenConstants.CONTROLLED_WINDOWING_MODES_WHEN_ACTIVE;
-import static com.android.wm.shell.protolog.ShellProtoLogGroup.WM_SHELL_SPLIT_SCREEN;
-import static com.android.wm.shell.transition.Transitions.ENABLE_SHELL_TRANSITIONS;
import android.annotation.CallSuper;
import android.annotation.Nullable;
import android.app.ActivityManager;
import android.content.Context;
-import android.graphics.Point;
import android.graphics.Rect;
import android.os.IBinder;
-import android.util.Slog;
import android.util.SparseArray;
import android.view.RemoteAnimationTarget;
import android.view.SurfaceControl;
@@ -74,20 +71,21 @@
// No current way to enforce this but if enableFlexibleSplit() is enabled, then only 1 of the
// stages should have this be set/being used
private boolean mIsActive;
-
/** Callback interface for listening to changes in a split-screen stage. */
public interface StageListenerCallbacks {
void onRootTaskAppeared();
- void onChildTaskAppeared(int taskId);
+ void onStageHasChildrenChanged(StageTaskListener stageTaskListener);
- void onStatusChanged(boolean visible, boolean hasChildren);
+ void onStageVisibilityChanged(StageTaskListener stageTaskListener);
- void onChildTaskStatusChanged(int taskId, boolean present, boolean visible);
+ void onChildTaskStatusChanged(StageTaskListener stage, int taskId, boolean present,
+ boolean visible);
void onRootTaskVanished();
- void onNoLongerSupportMultiWindow(ActivityManager.RunningTaskInfo taskInfo);
+ void onNoLongerSupportMultiWindow(StageTaskListener stageTaskListener,
+ ActivityManager.RunningTaskInfo taskInfo);
}
private final Context mContext;
@@ -96,6 +94,12 @@
private final IconProvider mIconProvider;
private final Optional<WindowDecorViewModel> mWindowDecorViewModel;
+ /** Whether or not the root task has been created. */
+ boolean mHasRootTask = false;
+ /** Whether or not the root task is visible. */
+ boolean mVisible = false;
+ /** Whether or not the root task has any children or not. */
+ boolean mHasChildren = false;
protected ActivityManager.RunningTaskInfo mRootTaskInfo;
protected SurfaceControl mRootLeash;
protected SurfaceControl mDimLayer;
@@ -201,6 +205,7 @@
mSplitDecorManager = new SplitDecorManager(
mRootTaskInfo.configuration,
mIconProvider);
+ mHasRootTask = true;
mCallbacks.onRootTaskAppeared();
sendStatusChanged();
mSyncQueue.runInSync(t -> mDimLayer =
@@ -209,15 +214,8 @@
final int taskId = taskInfo.taskId;
mChildrenLeashes.put(taskId, leash);
mChildrenTaskInfo.put(taskId, taskInfo);
- mCallbacks.onChildTaskStatusChanged(taskId, true /* present */,
+ mCallbacks.onChildTaskStatusChanged(this, taskId, true /* present */,
taskInfo.isVisible && taskInfo.isVisibleRequested);
- if (ENABLE_SHELL_TRANSITIONS) {
- // Status is managed/synchronized by the transition lifecycle.
- return;
- }
- updateChildTaskSurface(taskInfo, leash, true /* firstAppeared */);
- mCallbacks.onChildTaskAppeared(taskId);
- sendStatusChanged();
} else {
throw new IllegalArgumentException(this + "\n Unknown task: " + taskInfo
+ "\n mRootTaskInfo: " + mRootTaskInfo);
@@ -231,14 +229,6 @@
taskInfo.taskId, taskInfo.baseActivity);
mWindowDecorViewModel.ifPresent(viewModel -> viewModel.onTaskInfoChanged(taskInfo));
if (mRootTaskInfo.taskId == taskInfo.taskId) {
- // Inflates split decor view only when the root task is visible.
- if (!ENABLE_SHELL_TRANSITIONS && mRootTaskInfo.isVisible != taskInfo.isVisible) {
- if (taskInfo.isVisible) {
- mSplitDecorManager.inflate(mContext, mRootLeash);
- } else {
- mSyncQueue.runInSync(t -> mSplitDecorManager.release(t));
- }
- }
mRootTaskInfo = taskInfo;
} else if (taskInfo.parentTaskId == mRootTaskInfo.taskId) {
if (!taskInfo.supportsMultiWindow
@@ -250,25 +240,16 @@
taskInfo.taskId);
// Leave split screen if the task no longer supports multi window or have
// uncontrolled task.
- mCallbacks.onNoLongerSupportMultiWindow(taskInfo);
+ mCallbacks.onNoLongerSupportMultiWindow(this, taskInfo);
return;
}
mChildrenTaskInfo.put(taskInfo.taskId, taskInfo);
- mCallbacks.onChildTaskStatusChanged(taskInfo.taskId, true /* present */,
+ mCallbacks.onChildTaskStatusChanged(this, taskInfo.taskId, true /* present */,
taskInfo.isVisible && taskInfo.isVisibleRequested);
- if (!ENABLE_SHELL_TRANSITIONS) {
- updateChildTaskSurface(
- taskInfo, mChildrenLeashes.get(taskInfo.taskId), false /* firstAppeared */);
- }
} else {
throw new IllegalArgumentException(this + "\n Unknown task: " + taskInfo
+ "\n mRootTaskInfo: " + mRootTaskInfo);
}
- if (ENABLE_SHELL_TRANSITIONS) {
- // Status is managed/synchronized by the transition lifecycle.
- return;
- }
- sendStatusChanged();
}
@Override
@@ -278,6 +259,9 @@
final int taskId = taskInfo.taskId;
mWindowDecorViewModel.ifPresent(vm -> vm.onTaskVanished(taskInfo));
if (mRootTaskInfo.taskId == taskId) {
+ mHasRootTask = false;
+ mVisible = false;
+ mHasChildren = false;
mCallbacks.onRootTaskVanished();
mRootTaskInfo = null;
mRootLeash = null;
@@ -288,12 +272,8 @@
} else if (mChildrenTaskInfo.contains(taskId)) {
mChildrenTaskInfo.remove(taskId);
mChildrenLeashes.remove(taskId);
- mCallbacks.onChildTaskStatusChanged(taskId, false /* present */, taskInfo.isVisible);
- if (ENABLE_SHELL_TRANSITIONS) {
- // Status is managed/synchronized by the transition lifecycle.
- return;
- }
- sendStatusChanged();
+ mCallbacks.onChildTaskStatusChanged(this, taskId, false /* present */,
+ taskInfo.isVisible);
} else {
throw new IllegalArgumentException(this + "\n Unknown task: " + taskInfo
+ "\n mRootTaskInfo: " + mRootTaskInfo);
@@ -455,26 +435,6 @@
}
}
- private void updateChildTaskSurface(ActivityManager.RunningTaskInfo taskInfo,
- SurfaceControl leash, boolean firstAppeared) {
- final Point taskPositionInParent = taskInfo.positionInParent;
- mSyncQueue.runInSync(t -> {
- // The task surface might be released before running in the sync queue for the case like
- // trampoline launch, so check if the surface is valid before processing it.
- if (!leash.isValid()) {
- Slog.w(TAG, "Skip updating invalid child task surface of task#" + taskInfo.taskId);
- return;
- }
- t.setCrop(leash, null);
- t.setPosition(leash, taskPositionInParent.x, taskPositionInParent.y);
- if (firstAppeared) {
- t.setAlpha(leash, 1f);
- t.setMatrix(leash, 1, 0, 0, 1);
- t.show(leash);
- }
- });
- }
-
// ---------
// Previously only used in MainStage
boolean isActive() {
@@ -538,7 +498,19 @@
}
private void sendStatusChanged() {
- mCallbacks.onStatusChanged(mRootTaskInfo.isVisible, mChildrenTaskInfo.size() > 0);
+ boolean hasChildren = mChildrenTaskInfo.size() > 0;
+ boolean visible = mRootTaskInfo.isVisible;
+ if (!mHasRootTask) return;
+
+ if (mHasChildren != hasChildren) {
+ mHasChildren = hasChildren;
+ mCallbacks.onStageHasChildrenChanged(this);
+ }
+
+ if (mVisible != visible) {
+ mVisible = visible;
+ mCallbacks.onStageVisibilityChanged(this);
+ }
}
@Override
@@ -554,5 +526,8 @@
+ " baseActivity=" + taskInfo.baseActivity);
}
}
+ pw.println(prefix + "mHasRootTask=" + mHasRootTask);
+ pw.println(prefix + "mVisible=" + mVisible);
+ pw.println(prefix + "mHasChildren=" + mHasChildren);
}
}
diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/transition/DefaultTransitionHandler.java b/libs/WindowManager/Shell/src/com/android/wm/shell/transition/DefaultTransitionHandler.java
index a2439a9..5437167 100644
--- a/libs/WindowManager/Shell/src/com/android/wm/shell/transition/DefaultTransitionHandler.java
+++ b/libs/WindowManager/Shell/src/com/android/wm/shell/transition/DefaultTransitionHandler.java
@@ -61,6 +61,7 @@
import static com.android.internal.policy.TransitionAnimation.WALLPAPER_TRANSITION_INTRA_OPEN;
import static com.android.internal.policy.TransitionAnimation.WALLPAPER_TRANSITION_NONE;
import static com.android.internal.policy.TransitionAnimation.WALLPAPER_TRANSITION_OPEN;
+import static com.android.wm.shell.transition.DefaultSurfaceAnimator.buildSurfaceAnimation;
import static com.android.wm.shell.transition.TransitionAnimationHelper.edgeExtendWindow;
import static com.android.wm.shell.transition.TransitionAnimationHelper.getTransitionBackgroundColorIfSet;
import static com.android.wm.shell.transition.TransitionAnimationHelper.getTransitionTypeFromInfo;
@@ -68,8 +69,6 @@
import static com.android.wm.shell.transition.TransitionAnimationHelper.loadAttributeAnimation;
import android.animation.Animator;
-import android.animation.AnimatorListenerAdapter;
-import android.animation.ValueAnimator;
import android.annotation.ColorInt;
import android.annotation.NonNull;
import android.annotation.Nullable;
@@ -81,7 +80,6 @@
import android.content.Intent;
import android.content.IntentFilter;
import android.graphics.Color;
-import android.graphics.Insets;
import android.graphics.Point;
import android.graphics.Rect;
import android.graphics.drawable.Drawable;
@@ -90,12 +88,10 @@
import android.os.IBinder;
import android.os.UserHandle;
import android.util.ArrayMap;
-import android.view.Choreographer;
import android.view.SurfaceControl;
import android.view.WindowManager;
import android.view.animation.AlphaAnimation;
import android.view.animation.Animation;
-import android.view.animation.Transformation;
import android.window.TransitionInfo;
import android.window.TransitionMetrics;
import android.window.TransitionRequestInfo;
@@ -362,7 +358,6 @@
isSeamlessDisplayChange = anim == ROTATION_ANIMATION_SEAMLESS;
if (!(isSeamlessDisplayChange || anim == ROTATION_ANIMATION_JUMPCUT)) {
final int flags = wallpaperTransit != WALLPAPER_TRANSITION_NONE
- && Flags.commonSurfaceAnimator()
? ScreenRotationAnimation.FLAG_HAS_WALLPAPER : 0;
startRotationAnimation(startTransaction, change, info, anim, flags,
animations, onAnimFinish);
@@ -823,72 +818,6 @@
return a;
}
- /** Builds an animator for the surface and adds it to the `animations` list. */
- static void buildSurfaceAnimation(@NonNull ArrayList<Animator> animations,
- @NonNull Animation anim, @NonNull SurfaceControl leash,
- @NonNull Runnable finishCallback, @NonNull TransactionPool pool,
- @NonNull ShellExecutor mainExecutor, @Nullable Point position, float cornerRadius,
- @Nullable Rect clipRect, boolean isActivity) {
- if (Flags.commonSurfaceAnimator()) {
- DefaultSurfaceAnimator.buildSurfaceAnimation(animations, anim, leash, finishCallback,
- pool, mainExecutor, position, cornerRadius, clipRect, isActivity);
- return;
- }
- final SurfaceControl.Transaction transaction = pool.acquire();
- final ValueAnimator va = ValueAnimator.ofFloat(0f, 1f);
- final Transformation transformation = new Transformation();
- final float[] matrix = new float[9];
- // Animation length is already expected to be scaled.
- va.overrideDurationScale(1.0f);
- va.setDuration(anim.computeDurationHint());
- final ValueAnimator.AnimatorUpdateListener updateListener = animation -> {
- final long currentPlayTime = Math.min(va.getDuration(), va.getCurrentPlayTime());
-
- applyTransformation(currentPlayTime, transaction, leash, anim, transformation, matrix,
- position, cornerRadius, clipRect, isActivity);
- };
- va.addUpdateListener(updateListener);
-
- final Runnable finisher = () -> {
- applyTransformation(va.getDuration(), transaction, leash, anim, transformation, matrix,
- position, cornerRadius, clipRect, isActivity);
-
- pool.release(transaction);
- mainExecutor.execute(() -> {
- animations.remove(va);
- finishCallback.run();
- });
- };
- va.addListener(new AnimatorListenerAdapter() {
- // It is possible for the end/cancel to be called more than once, which may cause
- // issues if the animating surface has already been released. Track the finished
- // state here to skip duplicate callbacks. See b/252872225.
- private boolean mFinished = false;
-
- @Override
- public void onAnimationEnd(Animator animation) {
- onFinish();
- }
-
- @Override
- public void onAnimationCancel(Animator animation) {
- onFinish();
- }
-
- private void onFinish() {
- if (mFinished) return;
- mFinished = true;
- finisher.run();
- // The update listener can continue to be called after the animation has ended if
- // end() is called manually again before the finisher removes the animation.
- // Remove it manually here to prevent animating a released surface.
- // See b/252872225.
- va.removeUpdateListener(updateListener);
- }
- });
- animations.add(va);
- }
-
private void attachThumbnail(@NonNull ArrayList<Animator> animations,
@NonNull Runnable finishCallback, TransitionInfo.Change change,
TransitionInfo.AnimationOptions options, float cornerRadius) {
@@ -1014,38 +943,4 @@
|| animType == ANIM_CLIP_REVEAL || animType == ANIM_OPEN_CROSS_PROFILE_APPS
|| animType == ANIM_FROM_STYLE;
}
-
- private static void applyTransformation(long time, SurfaceControl.Transaction t,
- SurfaceControl leash, Animation anim, Transformation tmpTransformation, float[] matrix,
- Point position, float cornerRadius, @Nullable Rect immutableClipRect,
- boolean isActivity) {
- tmpTransformation.clear();
- anim.getTransformation(time, tmpTransformation);
- if (com.android.graphics.libgui.flags.Flags.edgeExtensionShader()
- && anim.getExtensionEdges() != 0x0 && isActivity) {
- t.setEdgeExtensionEffect(leash, anim.getExtensionEdges());
- }
- if (position != null) {
- tmpTransformation.getMatrix().postTranslate(position.x, position.y);
- }
- t.setMatrix(leash, tmpTransformation.getMatrix(), matrix);
- t.setAlpha(leash, tmpTransformation.getAlpha());
-
- final Rect clipRect = immutableClipRect == null ? null : new Rect(immutableClipRect);
- Insets extensionInsets = Insets.min(tmpTransformation.getInsets(), Insets.NONE);
- if (!extensionInsets.equals(Insets.NONE) && clipRect != null && !clipRect.isEmpty()) {
- // Clip out any overflowing edge extension
- clipRect.inset(extensionInsets);
- t.setCrop(leash, clipRect);
- }
-
- if (anim.hasRoundedCorners() && cornerRadius > 0 && clipRect != null) {
- // We can only apply rounded corner if a crop is set
- t.setCrop(leash, clipRect);
- t.setCornerRadius(leash, cornerRadius);
- }
-
- t.setFrameTimelineVsync(Choreographer.getInstance().getVsyncId());
- t.apply();
- }
}
diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/transition/ScreenRotationAnimation.java b/libs/WindowManager/Shell/src/com/android/wm/shell/transition/ScreenRotationAnimation.java
index 1a04997..6f3aa11 100644
--- a/libs/WindowManager/Shell/src/com/android/wm/shell/transition/ScreenRotationAnimation.java
+++ b/libs/WindowManager/Shell/src/com/android/wm/shell/transition/ScreenRotationAnimation.java
@@ -21,7 +21,7 @@
import static android.view.WindowManager.LayoutParams.ROTATION_ANIMATION_JUMPCUT;
import static android.view.WindowManagerPolicyConstants.SCREEN_FREEZE_LAYER_BASE;
-import static com.android.wm.shell.transition.DefaultTransitionHandler.buildSurfaceAnimation;
+import static com.android.wm.shell.transition.DefaultSurfaceAnimator.buildSurfaceAnimation;
import static com.android.wm.shell.transition.Transitions.TAG;
import android.animation.Animator;
diff --git a/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/desktopmode/DragToDesktopTransitionHandlerTest.kt b/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/desktopmode/DragToDesktopTransitionHandlerTest.kt
index 230f7e6..0bd3e08 100644
--- a/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/desktopmode/DragToDesktopTransitionHandlerTest.kt
+++ b/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/desktopmode/DragToDesktopTransitionHandlerTest.kt
@@ -1,5 +1,6 @@
package com.android.wm.shell.desktopmode
+import android.animation.AnimatorTestRule
import android.app.ActivityManager.RunningTaskInfo
import android.app.WindowConfiguration.ACTIVITY_TYPE_HOME
import android.app.WindowConfiguration.ACTIVITY_TYPE_STANDARD
@@ -24,6 +25,7 @@
import com.android.wm.shell.RootTaskDisplayAreaOrganizer
import com.android.wm.shell.ShellTestCase
import com.android.wm.shell.TestRunningTaskInfoBuilder
+import com.android.wm.shell.desktopmode.DragToDesktopTransitionHandler.Companion.DRAG_TO_DESKTOP_FINISH_ANIM_DURATION_MS
import com.android.wm.shell.shared.split.SplitScreenConstants.SPLIT_POSITION_BOTTOM_OR_RIGHT
import com.android.wm.shell.shared.split.SplitScreenConstants.SPLIT_POSITION_TOP_OR_LEFT
import com.android.wm.shell.splitscreen.SplitScreenController
@@ -38,6 +40,7 @@
import junit.framework.Assert.assertTrue
import org.junit.After
import org.junit.Before
+import org.junit.Rule
import org.junit.Test
import org.junit.runner.RunWith
import org.mockito.ArgumentMatchers.any
@@ -58,6 +61,9 @@
@RunWithLooper
@RunWith(AndroidTestingRunner::class)
class DragToDesktopTransitionHandlerTest : ShellTestCase() {
+ @JvmField
+ @Rule
+ val mAnimatorTestRule = AnimatorTestRule(this)
@Mock private lateinit var transitions: Transitions
@Mock private lateinit var taskDisplayAreaOrganizer: RootTaskDisplayAreaOrganizer
@@ -267,16 +273,36 @@
}
@Test
- fun cancelDragToDesktop_startWasReady_cancel() {
- startDrag(defaultHandler)
+ fun cancelDragToDesktop_startWasReady_cancel_merged() {
+ val startToken = startDrag(defaultHandler)
// Then user cancelled after it had already started.
- defaultHandler.cancelDragToDesktopTransition(
- DragToDesktopTransitionHandler.CancelState.STANDARD_CANCEL
- )
+ val cancelToken = cancelDragToDesktopTransition(
+ defaultHandler, DragToDesktopTransitionHandler.CancelState.STANDARD_CANCEL)
+ defaultHandler.mergeAnimation(
+ cancelToken,
+ TransitionInfo(TRANSIT_DESKTOP_MODE_CANCEL_DRAG_TO_DESKTOP, 0),
+ mock<SurfaceControl.Transaction>(),
+ startToken,
+ mock<Transitions.TransitionFinishCallback>())
// Cancel animation should run since it had already started.
verify(dragAnimator).cancelAnimator()
+ assertFalse("Drag should not be in progress after cancelling", defaultHandler.inProgress)
+ }
+
+ @Test
+ fun cancelDragToDesktop_startWasReady_cancel_aborted() {
+ val startToken = startDrag(defaultHandler)
+
+ // Then user cancelled after it had already started.
+ val cancelToken = cancelDragToDesktopTransition(
+ defaultHandler, DragToDesktopTransitionHandler.CancelState.STANDARD_CANCEL)
+ defaultHandler.onTransitionConsumed(cancelToken, aborted = true, null)
+
+ // Cancel animation should run since it had already started.
+ verify(dragAnimator).cancelAnimator()
+ assertFalse("Drag should not be in progress after cancelling", defaultHandler.inProgress)
}
@Test
@@ -585,6 +611,23 @@
return token
}
+ private fun cancelDragToDesktopTransition(
+ handler: DragToDesktopTransitionHandler,
+ cancelState: DragToDesktopTransitionHandler.CancelState): IBinder {
+ val token = mock<IBinder>()
+ whenever(
+ transitions.startTransition(
+ eq(TRANSIT_DESKTOP_MODE_CANCEL_DRAG_TO_DESKTOP),
+ any(),
+ eq(handler)
+ )
+ )
+ .thenReturn(token)
+ handler.cancelDragToDesktopTransition(cancelState)
+ mAnimatorTestRule.advanceTimeBy(DRAG_TO_DESKTOP_FINISH_ANIM_DURATION_MS)
+ return token
+ }
+
private fun performEarlyCancel(
handler: DragToDesktopTransitionHandler,
cancelState: DragToDesktopTransitionHandler.CancelState
diff --git a/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/splitscreen/StageTaskListenerTests.java b/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/splitscreen/StageTaskListenerTests.java
index b7b7d0d..189684d 100644
--- a/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/splitscreen/StageTaskListenerTests.java
+++ b/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/splitscreen/StageTaskListenerTests.java
@@ -23,10 +23,9 @@
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
-import static org.junit.Assume.assumeFalse;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.ArgumentMatchers.isNull;
-import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.never;
import static org.mockito.Mockito.verify;
import android.app.ActivityManager;
@@ -64,8 +63,6 @@
@SmallTest
@RunWith(AndroidJUnit4.class)
public final class StageTaskListenerTests extends ShellTestCase {
- private static final boolean ENABLE_SHELL_TRANSITIONS =
- SystemProperties.getBoolean("persist.wm.debug.shell_transit", true);
@Mock
private ShellTaskOrganizer mTaskOrganizer;
@@ -117,20 +114,20 @@
public void testRootTaskAppeared() {
assertThat(mStageTaskListener.mRootTaskInfo.taskId).isEqualTo(mRootTask.taskId);
verify(mCallbacks).onRootTaskAppeared();
- verify(mCallbacks).onStatusChanged(eq(mRootTask.isVisible), eq(false));
+ verify(mCallbacks, never()).onStageHasChildrenChanged(mStageTaskListener);
+ verify(mCallbacks, never()).onStageVisibilityChanged(mStageTaskListener);
}
@Test
- public void testChildTaskAppeared() {
- // With shell transitions, the transition manages status changes, so skip this test.
- assumeFalse(ENABLE_SHELL_TRANSITIONS);
- final ActivityManager.RunningTaskInfo childTask =
- new TestRunningTaskInfoBuilder().setParentTaskId(mRootTask.taskId).build();
+ public void testRootTaskVisible() {
+ mStageTaskListener.onTaskVanished(mRootTask);
+ mRootTask = new TestRunningTaskInfoBuilder().setVisible(true).build();
+ mRootTask.parentTaskId = INVALID_TASK_ID;
+ mSurfaceControl = new SurfaceControl.Builder().setName("test").build();
+ mStageTaskListener.onTaskAppeared(mRootTask, mSurfaceControl);
- mStageTaskListener.onTaskAppeared(childTask, mSurfaceControl);
+ verify(mCallbacks).onStageVisibilityChanged(mStageTaskListener);
- assertThat(mStageTaskListener.mChildrenTaskInfo.contains(childTask.taskId)).isTrue();
- verify(mCallbacks).onStatusChanged(eq(mRootTask.isVisible), eq(true));
}
@Test(expected = IllegalArgumentException.class)
@@ -140,29 +137,13 @@
}
@Test
- public void testTaskVanished() {
- // With shell transitions, the transition manages status changes, so skip this test.
- assumeFalse(ENABLE_SHELL_TRANSITIONS);
- final ActivityManager.RunningTaskInfo childTask =
- new TestRunningTaskInfoBuilder().setParentTaskId(mRootTask.taskId).build();
- mStageTaskListener.mRootTaskInfo = mRootTask;
- mStageTaskListener.mChildrenTaskInfo.put(childTask.taskId, childTask);
-
- mStageTaskListener.onTaskVanished(childTask);
- verify(mCallbacks, times(2)).onStatusChanged(eq(mRootTask.isVisible), eq(false));
-
- mStageTaskListener.onTaskVanished(mRootTask);
- verify(mCallbacks).onRootTaskVanished();
- }
-
- @Test
public void testTaskInfoChanged_notSupportsMultiWindow() {
final ActivityManager.RunningTaskInfo childTask =
new TestRunningTaskInfoBuilder().setParentTaskId(mRootTask.taskId).build();
childTask.supportsMultiWindow = false;
mStageTaskListener.onTaskInfoChanged(childTask);
- verify(mCallbacks).onNoLongerSupportMultiWindow(childTask);
+ verify(mCallbacks).onNoLongerSupportMultiWindow(mStageTaskListener, childTask);
}
@Test
diff --git a/media/java/android/media/AudioPlaybackConfiguration.java b/media/java/android/media/AudioPlaybackConfiguration.java
index 4d6ddfd..3cd5f52 100644
--- a/media/java/android/media/AudioPlaybackConfiguration.java
+++ b/media/java/android/media/AudioPlaybackConfiguration.java
@@ -18,7 +18,9 @@
import static android.media.AudioAttributes.ALLOW_CAPTURE_BY_ALL;
import static android.media.AudioAttributes.ALLOW_CAPTURE_BY_NONE;
+import static android.media.audio.Flags.FLAG_MUTED_BY_PORT_VOLUME_API;
+import android.annotation.FlaggedApi;
import android.annotation.IntDef;
import android.annotation.IntRange;
import android.annotation.NonNull;
@@ -291,12 +293,24 @@
@SystemApi
@RequiresPermission(android.Manifest.permission.MODIFY_AUDIO_ROUTING)
public static final int MUTED_BY_VOLUME_SHAPER = (1 << 5);
+ /**
+ * @hide
+ * Flag used when muted by the track's port volume.
+ *
+ * <p>Note: this will replace the stream volume mute when using the AudioFlinger port volume
+ * APIs
+ */
+ @SystemApi
+ @FlaggedApi(FLAG_MUTED_BY_PORT_VOLUME_API)
+ @RequiresPermission(android.Manifest.permission.MODIFY_AUDIO_ROUTING)
+ public static final int MUTED_BY_PORT_VOLUME = (1 << 6);
/** @hide */
@IntDef(
flag = true,
value = {MUTED_BY_MASTER, MUTED_BY_STREAM_VOLUME, MUTED_BY_STREAM_MUTED,
- MUTED_BY_APP_OPS, MUTED_BY_CLIENT_VOLUME, MUTED_BY_VOLUME_SHAPER})
+ MUTED_BY_APP_OPS, MUTED_BY_CLIENT_VOLUME, MUTED_BY_VOLUME_SHAPER,
+ MUTED_BY_PORT_VOLUME})
@Retention(RetentionPolicy.SOURCE)
public @interface PlayerMuteEvent {
}
@@ -858,6 +872,9 @@
if ((mMutedState & MUTED_BY_VOLUME_SHAPER) != 0) {
apcToString.append("volumeShaper ");
}
+ if ((mMutedState & MUTED_BY_PORT_VOLUME) != 0) {
+ apcToString.append("portVolume ");
+ }
}
apcToString.append(" ").append(mFormatInfo);
}
diff --git a/media/java/android/media/AudioSystem.java b/media/java/android/media/AudioSystem.java
index a8b863b..bf09cb0 100644
--- a/media/java/android/media/AudioSystem.java
+++ b/media/java/android/media/AudioSystem.java
@@ -1698,12 +1698,12 @@
}
/** @hide Wrapper for native methods called from AudioService */
- public static int setStreamVolumeIndexAS(int stream, int index, int device) {
+ public static int setStreamVolumeIndexAS(int stream, int index, boolean muted, int device) {
if (DEBUG_VOLUME) {
Log.i(TAG, "setStreamVolumeIndex: " + STREAM_NAMES[stream]
- + " dev=" + Integer.toHexString(device) + " idx=" + index);
+ + " dev=" + Integer.toHexString(device) + " idx=" + index + " muted=" + muted);
}
- return setStreamVolumeIndex(stream, index, device);
+ return setStreamVolumeIndex(stream, index, muted, device);
}
// usage for AudioRecord.startRecordingSync(), must match AudioSystem::sync_event_t
@@ -1774,7 +1774,8 @@
@UnsupportedAppUsage
public static native int initStreamVolume(int stream, int indexMin, int indexMax);
@UnsupportedAppUsage
- private static native int setStreamVolumeIndex(int stream, int index, int device);
+ private static native int setStreamVolumeIndex(int stream, int index, boolean muted,
+ int device);
/** @hide */
public static native int getStreamVolumeIndex(int stream, int device);
/**
@@ -1787,7 +1788,7 @@
* @return command completion status.
*/
public static native int setVolumeIndexForAttributes(@NonNull AudioAttributes attributes,
- int index, int device);
+ int index, boolean muted, int device);
/**
* @hide
* get the volume index for the given {@link AudioAttributes}.
diff --git a/packages/SettingsLib/Graph/src/com/android/settingslib/graph/PreferenceGraphBuilder.kt b/packages/SettingsLib/Graph/src/com/android/settingslib/graph/PreferenceGraphBuilder.kt
index 8c5d877..8fb16d8 100644
--- a/packages/SettingsLib/Graph/src/com/android/settingslib/graph/PreferenceGraphBuilder.kt
+++ b/packages/SettingsLib/Graph/src/com/android/settingslib/graph/PreferenceGraphBuilder.kt
@@ -78,6 +78,10 @@
for (activityClass in request.activityClasses) {
add(activityClass)
}
+ // Temporarily add all screens
+ for (key in PreferenceScreenRegistry.preferenceScreens.keys) {
+ addPreferenceScreenFromRegistry(key, Activity::class.java)
+ }
}
fun build() = builder.build()
diff --git a/packages/SettingsLib/Metadata/src/com/android/settingslib/metadata/PreferenceScreenRegistry.kt b/packages/SettingsLib/Metadata/src/com/android/settingslib/metadata/PreferenceScreenRegistry.kt
index 48798da..6646d6c3 100644
--- a/packages/SettingsLib/Metadata/src/com/android/settingslib/metadata/PreferenceScreenRegistry.kt
+++ b/packages/SettingsLib/Metadata/src/com/android/settingslib/metadata/PreferenceScreenRegistry.kt
@@ -34,7 +34,7 @@
ImmutableMap.of()
}
- private val preferenceScreens: PreferenceScreenMap
+ val preferenceScreens: PreferenceScreenMap
get() = preferenceScreensSupplier.get()
private var readWritePermitProvider: ReadWritePermitProvider? = null
diff --git a/packages/SettingsLib/Spa/build.gradle.kts b/packages/SettingsLib/Spa/build.gradle.kts
index b69912a..73d0bec 100644
--- a/packages/SettingsLib/Spa/build.gradle.kts
+++ b/packages/SettingsLib/Spa/build.gradle.kts
@@ -29,7 +29,7 @@
allprojects {
extra["androidTop"] = androidTop
- extra["jetpackComposeVersion"] = "1.7.0"
+ extra["jetpackComposeVersion"] = "1.7.3"
}
subprojects {
diff --git a/packages/SettingsLib/Spa/spa/build.gradle.kts b/packages/SettingsLib/Spa/spa/build.gradle.kts
index 8f8275b..914f06c 100644
--- a/packages/SettingsLib/Spa/spa/build.gradle.kts
+++ b/packages/SettingsLib/Spa/spa/build.gradle.kts
@@ -54,7 +54,7 @@
dependencies {
api(project(":SettingsLibColor"))
api("androidx.appcompat:appcompat:1.7.0")
- api("androidx.compose.material3:material3:1.3.0")
+ api("androidx.compose.material3:material3:1.4.0-alpha01")
api("androidx.compose.material:material-icons-extended:$jetpackComposeVersion")
api("androidx.compose.runtime:runtime-livedata:$jetpackComposeVersion")
api("androidx.compose.ui:ui-tooling-preview:$jetpackComposeVersion")
diff --git a/packages/SettingsLib/Spa/spa/src/com/android/settingslib/spa/widget/scaffold/CustomizedAppBar.kt b/packages/SettingsLib/Spa/spa/src/com/android/settingslib/spa/widget/scaffold/CustomizedAppBar.kt
index 2c55779..693fb35 100644
--- a/packages/SettingsLib/Spa/spa/src/com/android/settingslib/spa/widget/scaffold/CustomizedAppBar.kt
+++ b/packages/SettingsLib/Spa/spa/src/com/android/settingslib/spa/widget/scaffold/CustomizedAppBar.kt
@@ -46,6 +46,7 @@
import androidx.compose.material3.TopAppBarState
import androidx.compose.runtime.Composable
import androidx.compose.runtime.CompositionLocalProvider
+import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.NonRestartableComposable
import androidx.compose.runtime.Stable
import androidx.compose.runtime.derivedStateOf
@@ -326,6 +327,9 @@
// Sets the app bar's height offset limit to hide just the bottom title area and keep top title
// visible when collapsed.
scrollBehavior?.state?.heightOffsetLimit = pinnedHeightPx - maxHeightPx.floatValue
+ if (isSpaExpressiveEnabled) {
+ LaunchedEffect(scrollBehavior?.state?.heightOffsetLimit) { scrollBehavior?.collapse() }
+ }
// Obtain the container Color from the TopAppBarColors using the `collapsedFraction`, as the
// bottom part of this TwoRowsTopAppBar changes color at the same rate the app bar expands or
diff --git a/packages/SettingsLib/Spa/spa/src/com/android/settingslib/spa/widget/scaffold/SettingsScaffold.kt b/packages/SettingsLib/Spa/spa/src/com/android/settingslib/spa/widget/scaffold/SettingsScaffold.kt
index 7d8ee79..60b1e639 100644
--- a/packages/SettingsLib/Spa/spa/src/com/android/settingslib/spa/widget/scaffold/SettingsScaffold.kt
+++ b/packages/SettingsLib/Spa/spa/src/com/android/settingslib/spa/widget/scaffold/SettingsScaffold.kt
@@ -39,7 +39,6 @@
import com.android.settingslib.spa.framework.compose.horizontalValues
import com.android.settingslib.spa.framework.compose.verticalValues
import com.android.settingslib.spa.framework.theme.SettingsTheme
-import com.android.settingslib.spa.framework.theme.isSpaExpressiveEnabled
import com.android.settingslib.spa.framework.theme.settingsBackground
import com.android.settingslib.spa.widget.preference.Preference
import com.android.settingslib.spa.widget.preference.PreferenceModel
@@ -56,9 +55,6 @@
) {
ActivityTitle(title)
val scrollBehavior = TopAppBarDefaults.exitUntilCollapsedScrollBehavior()
- if (isSpaExpressiveEnabled) {
- LaunchedEffect(scrollBehavior.state.heightOffsetLimit) { scrollBehavior.collapse() }
- }
Scaffold(
modifier = Modifier.nestedScroll(scrollBehavior.nestedScrollConnection),
diff --git a/packages/SettingsProvider/Android.bp b/packages/SettingsProvider/Android.bp
index 1a99d25..65b2275 100644
--- a/packages/SettingsProvider/Android.bp
+++ b/packages/SettingsProvider/Android.bp
@@ -39,6 +39,7 @@
"configinfra_framework_flags_java_lib",
"device_config_service_flags_java",
"libaconfig_java_proto_lite",
+ "notification_flags_lib",
"SettingsLibDeviceStateRotationLock",
"SettingsLibDisplayUtils",
],
diff --git a/packages/SettingsProvider/src/com/android/providers/settings/SettingsHelper.java b/packages/SettingsProvider/src/com/android/providers/settings/SettingsHelper.java
index 6c31831..ebeee85 100644
--- a/packages/SettingsProvider/src/com/android/providers/settings/SettingsHelper.java
+++ b/packages/SettingsProvider/src/com/android/providers/settings/SettingsHelper.java
@@ -29,6 +29,7 @@
import android.icu.util.ULocale;
import android.media.AudioManager;
import android.media.RingtoneManager;
+import android.media.Utils;
import android.net.Uri;
import android.os.LocaleList;
import android.os.RemoteException;
@@ -309,6 +310,13 @@
return SILENT_RINGTONE;
}
} else {
+ // If the ringtone/notification support the vibration, use the original value.
+ final int ringtoneType = getRingtoneType(name);
+ if ((ringtoneType == RingtoneManager.TYPE_RINGTONE
+ || ringtoneType == RingtoneManager.TYPE_NOTIFICATION)
+ && hasVibrationSettings(value, ringtoneType)) {
+ return value;
+ }
return getCanonicalRingtoneValue(value);
}
}
@@ -362,6 +370,15 @@
return;
}
+ // If the ringtone/notification has vibration, we backup original value in onBackupValue.
+ // So use the value directly for restoring.
+ if ((ringtoneType == RingtoneManager.TYPE_RINGTONE
+ || ringtoneType == RingtoneManager.TYPE_NOTIFICATION)
+ && hasVibrationSettings(value, ringtoneType)) {
+ RingtoneManager.setActualDefaultRingtoneUri(mContext, ringtoneType, Uri.parse(value));
+ return;
+ }
+
Uri ringtoneUri = null;
try {
ringtoneUri =
@@ -617,6 +634,19 @@
return allLocales.remove(toFullLocale(filteredLocale));
}
+ private boolean hasVibrationSettings(String value, int type) {
+ if (Utils.hasVibration(Uri.parse(value)) && mContext.getResources().getBoolean(
+ com.android.internal.R.bool.config_ringtoneVibrationSettingsSupported)) {
+ if (type == RingtoneManager.TYPE_RINGTONE) {
+ return android.media.audio.Flags.enableRingtoneHapticsCustomization();
+ }
+ if (type == RingtoneManager.TYPE_NOTIFICATION) {
+ return com.android.server.notification.Flags.notificationVibrationInSoundUri();
+ }
+ }
+ return false;
+ }
+
/**
* Sets the locale specified. Input data is the byte representation of comma separated
* multiple BCP-47 language tags. For backwards compatibility, strings of the form
diff --git a/packages/SettingsProvider/test/src/com/android/providers/settings/SettingsHelperTest.java b/packages/SettingsProvider/test/src/com/android/providers/settings/SettingsHelperTest.java
index 4b10b56..cea2bbc 100644
--- a/packages/SettingsProvider/test/src/com/android/providers/settings/SettingsHelperTest.java
+++ b/packages/SettingsProvider/test/src/com/android/providers/settings/SettingsHelperTest.java
@@ -37,9 +37,12 @@
import android.database.Cursor;
import android.database.MatrixCursor;
import android.media.AudioManager;
+import android.media.Utils;
import android.net.Uri;
import android.os.Bundle;
import android.os.LocaleList;
+import android.platform.test.annotations.EnableFlags;
+import android.platform.test.flag.junit.SetFlagsRule;
import android.provider.BaseColumns;
import android.provider.MediaStore;
import android.provider.Settings;
@@ -54,8 +57,11 @@
import org.junit.After;
import org.junit.Before;
+import org.junit.FixMethodOrder;
+import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
+import org.junit.runners.MethodSorters;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
@@ -63,6 +69,7 @@
* Tests for the SettingsHelperTest
*/
@RunWith(AndroidJUnit4.class)
+@FixMethodOrder(MethodSorters.NAME_ASCENDING)
public class SettingsHelperTest {
private static final String SETTING_KEY = "setting_key";
private static final String SETTING_VALUE = "setting_value";
@@ -74,9 +81,13 @@
"content://media/internal/audio/media/20?title=DefaultNotification&canonical=1";
private static final String DEFAULT_ALARM_VALUE =
"content://media/internal/audio/media/30?title=DefaultAlarm&canonical=1";
+ private static final String VIBRATION_FILE_NAME = "haptics.xml";
private SettingsHelper mSettingsHelper;
+ @Rule
+ public final SetFlagsRule mSetFlagsRule = new SetFlagsRule();
+
@Mock private Context mContext;
@Mock private Resources mResources;
@Mock private AudioManager mAudioManager;
@@ -120,6 +131,22 @@
}
@Test
+ @EnableFlags({android.media.audio.Flags.FLAG_ENABLE_RINGTONE_HAPTICS_CUSTOMIZATION,
+ com.android.server.notification.Flags.FLAG_NOTIFICATION_VIBRATION_IN_SOUND_URI})
+ public void testOnBackupValue_ringtoneVibrationSupport_returnsSameValue() {
+ when(mResources.getBoolean(
+ com.android.internal.R.bool.config_ringtoneVibrationSettingsSupported)).thenReturn(
+ true);
+ String testRingtoneVibrationValue = createUriWithVibration(DEFAULT_RINGTONE_VALUE);
+ String testNotificationVibrationValue = createUriWithVibration(DEFAULT_NOTIFICATION_VALUE);
+
+ assertEquals(testRingtoneVibrationValue, mSettingsHelper.onBackupValue(
+ Settings.System.RINGTONE, testRingtoneVibrationValue));
+ assertEquals(testNotificationVibrationValue, mSettingsHelper.onBackupValue(
+ Settings.System.NOTIFICATION_SOUND, testNotificationVibrationValue));
+ }
+
+ @Test
public void testGetRealValue_settingNotReplaced_returnsSameValue() {
when(mSettingsHelper.isReplacedSystemSetting(eq(SETTING_KEY))).thenReturn(false);
@@ -675,6 +702,30 @@
.isEqualTo(null);
}
+ @Test
+ @EnableFlags({android.media.audio.Flags.FLAG_ENABLE_RINGTONE_HAPTICS_CUSTOMIZATION,
+ com.android.server.notification.Flags.FLAG_NOTIFICATION_VIBRATION_IN_SOUND_URI})
+ public void testRestoreValue_ringtoneVibrationSupport_restoreValue() {
+ when(mResources.getBoolean(
+ com.android.internal.R.bool.config_ringtoneVibrationSettingsSupported)).thenReturn(
+ true);
+ String testRingtoneVibrationValue = createUriWithVibration(DEFAULT_RINGTONE_VALUE);
+ String testNotificationVibrationValue = createUriWithVibration(DEFAULT_NOTIFICATION_VALUE);
+ ContentProvider mockMediaContentProvider =
+ new MockContentProvider(mContext) {
+ @Override
+ public String getType(Uri url) {
+ return "audio/ogg";
+ }
+ };
+ mContentResolver.addProvider(MediaStore.AUTHORITY, mockMediaContentProvider);
+ resetRingtoneSettingsToDefault();
+
+ assertRingtoneSettingsRestoring(Settings.System.RINGTONE, testRingtoneVibrationValue);
+ assertRingtoneSettingsRestoring(
+ Settings.System.NOTIFICATION_SOUND, testNotificationVibrationValue);
+ }
+
private static class MockSettingsProvider extends MockContentProvider {
private final ArrayMap<String, String> mKeyValueStore = new ArrayMap<>();
MockSettingsProvider(Context context) {
@@ -766,4 +817,25 @@
assertThat(Settings.System.getString(mContentResolver, Settings.System.ALARM_ALERT))
.isEqualTo(DEFAULT_ALARM_VALUE);
}
+
+ private String createUriWithVibration(String defaultUriString) {
+ return Uri.parse(defaultUriString).buildUpon()
+ .appendQueryParameter(
+ Utils.VIBRATION_URI_PARAM, VIBRATION_FILE_NAME).build().toString();
+ }
+
+ private void assertRingtoneSettingsRestoring(
+ String settings, String testRingtoneSettingsValue) {
+ mSettingsHelper.restoreValue(
+ mContext,
+ mContentResolver,
+ new ContentValues(),
+ Uri.EMPTY,
+ settings,
+ testRingtoneSettingsValue,
+ 0);
+
+ assertThat(Settings.System.getString(mContentResolver, settings))
+ .isEqualTo(testRingtoneSettingsValue);
+ }
}
diff --git a/packages/SystemUI/aconfig/systemui.aconfig b/packages/SystemUI/aconfig/systemui.aconfig
index a21a805..1892944 100644
--- a/packages/SystemUI/aconfig/systemui.aconfig
+++ b/packages/SystemUI/aconfig/systemui.aconfig
@@ -1481,3 +1481,9 @@
bug: "370863642"
}
+flag {
+ name: "notes_role_qs_tile"
+ namespace: "systemui"
+ description: "Enables notes role qs tile which opens default notes role app in app bubbles"
+ bug: "357863750"
+}
diff --git a/packages/SystemUI/animation/src/com/android/systemui/animation/ActivityTransitionAnimator.kt b/packages/SystemUI/animation/src/com/android/systemui/animation/ActivityTransitionAnimator.kt
index 93a99bd..18f40c9 100644
--- a/packages/SystemUI/animation/src/com/android/systemui/animation/ActivityTransitionAnimator.kt
+++ b/packages/SystemUI/animation/src/com/android/systemui/animation/ActivityTransitionAnimator.kt
@@ -136,20 +136,16 @@
)
/**
- * The timings when animating a View into an app using a spring animator.
- *
- * Important: since springs don't have fixed durations, these timings represent fractions of
- * the progress between the spring's initial value and its final value.
- *
- * TODO(b/372858592): make this a separate class explicitly using percentages.
+ * The timings when animating a View into an app using a spring animator. These timings
+ * represent fractions of the progress between the spring's initial value and its final
+ * value.
*/
val SPRING_TIMINGS =
- TransitionAnimator.Timings(
- totalDuration = 1000L,
- contentBeforeFadeOutDelay = 0L,
- contentBeforeFadeOutDuration = 800L,
- contentAfterFadeInDelay = 850L,
- contentAfterFadeInDuration = 135L,
+ TransitionAnimator.SpringTimings(
+ contentBeforeFadeOutDelay = 0f,
+ contentBeforeFadeOutDuration = 0.8f,
+ contentAfterFadeInDelay = 0.85f,
+ contentAfterFadeInDuration = 0.135f,
)
/**
diff --git a/packages/SystemUI/animation/src/com/android/systemui/animation/TransitionAnimator.kt b/packages/SystemUI/animation/src/com/android/systemui/animation/TransitionAnimator.kt
index 1d8ff77..9dc9348 100644
--- a/packages/SystemUI/animation/src/com/android/systemui/animation/TransitionAnimator.kt
+++ b/packages/SystemUI/animation/src/com/android/systemui/animation/TransitionAnimator.kt
@@ -52,7 +52,7 @@
private val interpolators: Interpolators,
/** [springTimings] and [springInterpolators] must either both be null or both not null. */
- private val springTimings: Timings? = null,
+ private val springTimings: SpringTimings? = null,
private val springInterpolators: Interpolators? = null,
private val springParams: SpringParams = DEFAULT_SPRING_PARAMS,
) {
@@ -83,8 +83,22 @@
delay: Long,
duration: Long,
): Float {
+ return getProgressInternal(
+ timings.totalDuration.toFloat(),
+ linearProgress,
+ delay.toFloat(),
+ duration.toFloat(),
+ )
+ }
+
+ private fun getProgressInternal(
+ totalDuration: Float,
+ linearProgress: Float,
+ delay: Float,
+ duration: Float,
+ ): Float {
return MathUtils.constrain(
- (linearProgress * timings.totalDuration - delay) / duration,
+ (linearProgress * totalDuration - delay) / duration,
0.0f,
1.0f,
)
@@ -367,6 +381,25 @@
val contentAfterFadeInDuration: Long,
)
+ /**
+ * The timings (durations and delays) used by the multi-spring animator. These are expressed as
+ * fractions of 1, similar to how the progress of an animator can be expressed as a float value
+ * between 0 and 1.
+ */
+ class SpringTimings(
+ /** The portion of animation to wait before fading out the expanding content. */
+ val contentBeforeFadeOutDelay: Float,
+
+ /** The portion of animation during which the expanding content fades out. */
+ val contentBeforeFadeOutDuration: Float,
+
+ /** The portion of animation to wait before fading in the expanded content. */
+ val contentAfterFadeInDelay: Float,
+
+ /** The portion of animation during which the expanded content fades in. */
+ val contentAfterFadeInDuration: Float,
+ )
+
/** The interpolators used by this animator. */
data class Interpolators(
/** The interpolator used for the Y position, width, height and corner radius. */
@@ -576,18 +609,14 @@
}
override fun onAnimationEnd(animation: Animator) {
- if (DEBUG) {
- Log.d(TAG, "Animation ended")
- }
-
- // TODO(b/330672236): Post this to the main thread instead so that it does not
- // flicker with Flexiglass enabled.
- controller.onTransitionAnimationEnd(isExpandingFullyAbove)
- transitionContainerOverlay.remove(windowBackgroundLayer)
-
- if (moveBackgroundLayerWhenAppVisibilityChanges && controller.isLaunching) {
- openingWindowSyncViewOverlay?.remove(windowBackgroundLayer)
- }
+ onAnimationEnd(
+ controller,
+ isExpandingFullyAbove,
+ windowBackgroundLayer,
+ transitionContainerOverlay,
+ openingWindowSyncViewOverlay,
+ moveBackgroundLayerWhenAppVisibilityChanges,
+ )
}
}
)
@@ -1021,34 +1050,47 @@
cornerRadii[7] = state.bottomCornerRadius
drawable.cornerRadii = cornerRadii
- val timings: Timings
val interpolators: Interpolators
+ val fadeInProgress: Float
+ val fadeOutProgress: Float
if (useSpring) {
- timings = springTimings!!
interpolators = springInterpolators!!
+ val timings = springTimings!!
+ fadeInProgress =
+ getProgressInternal(
+ totalDuration = 1f,
+ linearProgress,
+ timings.contentBeforeFadeOutDelay,
+ timings.contentBeforeFadeOutDuration,
+ )
+ fadeOutProgress =
+ getProgressInternal(
+ totalDuration = 1f,
+ linearProgress,
+ timings.contentAfterFadeInDelay,
+ timings.contentAfterFadeInDuration,
+ )
} else {
- timings = this.timings
interpolators = this.interpolators
+ fadeInProgress =
+ getProgress(
+ timings,
+ linearProgress,
+ timings.contentBeforeFadeOutDelay,
+ timings.contentBeforeFadeOutDuration,
+ )
+ fadeOutProgress =
+ getProgress(
+ timings,
+ linearProgress,
+ timings.contentAfterFadeInDelay,
+ timings.contentAfterFadeInDuration,
+ )
}
// We first fade in the background layer to hide the expanding view, then fade it out with
// SRC mode to draw a hole punch in the status bar and reveal the opening window (if
// needed). If !isLaunching, the reverse happens.
- val fadeInProgress =
- getProgress(
- timings,
- linearProgress,
- timings.contentBeforeFadeOutDelay,
- timings.contentBeforeFadeOutDuration,
- )
- val fadeOutProgress =
- getProgress(
- timings,
- linearProgress,
- timings.contentAfterFadeInDelay,
- timings.contentAfterFadeInDuration,
- )
-
if (isLaunching) {
if (fadeInProgress < 1) {
val alpha =
diff --git a/packages/SystemUI/compose/features/src/com/android/systemui/notifications/ui/composable/NotificationScrimNestedScrollConnection.kt b/packages/SystemUI/compose/features/src/com/android/systemui/notifications/ui/composable/NotificationScrimNestedScrollConnection.kt
index 8b9e927..e4c60e1 100644
--- a/packages/SystemUI/compose/features/src/com/android/systemui/notifications/ui/composable/NotificationScrimNestedScrollConnection.kt
+++ b/packages/SystemUI/compose/features/src/com/android/systemui/notifications/ui/composable/NotificationScrimNestedScrollConnection.kt
@@ -18,6 +18,8 @@
import androidx.compose.foundation.gestures.Orientation
import androidx.compose.ui.input.nestedscroll.NestedScrollConnection
+import androidx.compose.ui.util.fastCoerceAtLeast
+import androidx.compose.ui.util.fastCoerceAtMost
import com.android.compose.nestedscroll.PriorityNestedScrollConnection
/**
@@ -44,7 +46,7 @@
orientation = Orientation.Vertical,
// scrolling up and inner content is taller than the scrim, so scrim needs to
// expand; content can scroll once scrim is at the minScrimOffset.
- canStartPreScroll = { offsetAvailable, offsetBeforeStart ->
+ canStartPreScroll = { offsetAvailable, offsetBeforeStart, _ ->
offsetAvailable < 0 &&
offsetBeforeStart == 0f &&
contentHeight() > minVisibleScrimHeight() &&
@@ -52,36 +54,38 @@
},
// scrolling down and content is done scrolling to top. After that, the scrim
// needs to collapse; collapse the scrim until it is at the maxScrimOffset.
- canStartPostScroll = { offsetAvailable, _ ->
+ canStartPostScroll = { offsetAvailable, _, _ ->
offsetAvailable > 0 && (scrimOffset() < maxScrimOffset || isCurrentGestureOverscroll())
},
canStartPostFling = { false },
- canContinueScroll = {
- val currentHeight = scrimOffset()
- minScrimOffset() < currentHeight && currentHeight < maxScrimOffset
- },
- canScrollOnFling = true,
+ canStopOnPreFling = { false },
onStart = { offsetAvailable -> onStart(offsetAvailable) },
- onScroll = { offsetAvailable ->
+ onScroll = { offsetAvailable, _ ->
val currentHeight = scrimOffset()
val amountConsumed =
if (offsetAvailable > 0) {
val amountLeft = maxScrimOffset - currentHeight
- offsetAvailable.coerceAtMost(amountLeft)
+ offsetAvailable.fastCoerceAtMost(amountLeft)
} else {
val amountLeft = minScrimOffset() - currentHeight
- offsetAvailable.coerceAtLeast(amountLeft)
+ offsetAvailable.fastCoerceAtLeast(amountLeft)
}
snapScrimOffset(currentHeight + amountConsumed)
amountConsumed
},
- // Don't consume the velocity on pre/post fling
onStop = { velocityAvailable ->
onStop(velocityAvailable)
if (scrimOffset() < minScrimOffset()) {
animateScrimOffset(minScrimOffset())
}
- { 0f }
+ // Don't consume the velocity on pre/post fling
+ 0f
+ },
+ onCancel = {
+ onStop(0f)
+ if (scrimOffset() < minScrimOffset()) {
+ animateScrimOffset(minScrimOffset())
+ }
},
)
}
diff --git a/packages/SystemUI/compose/features/src/com/android/systemui/notifications/ui/composable/NotificationStackNestedScrollConnection.kt b/packages/SystemUI/compose/features/src/com/android/systemui/notifications/ui/composable/NotificationStackNestedScrollConnection.kt
index a706585..edb05eb 100644
--- a/packages/SystemUI/compose/features/src/com/android/systemui/notifications/ui/composable/NotificationStackNestedScrollConnection.kt
+++ b/packages/SystemUI/compose/features/src/com/android/systemui/notifications/ui/composable/NotificationStackNestedScrollConnection.kt
@@ -28,6 +28,7 @@
import androidx.compose.ui.platform.LocalDensity
import androidx.compose.ui.unit.IntOffset
import androidx.compose.ui.unit.dp
+import androidx.compose.ui.util.fastCoerceAtLeast
import com.android.compose.nestedscroll.PriorityNestedScrollConnection
import kotlin.math.max
import kotlin.math.roundToInt
@@ -86,21 +87,25 @@
): PriorityNestedScrollConnection {
return PriorityNestedScrollConnection(
orientation = Orientation.Vertical,
- canStartPreScroll = { _, _ -> false },
- canStartPostScroll = { offsetAvailable, offsetBeforeStart ->
+ canStartPreScroll = { _, _, _ -> false },
+ canStartPostScroll = { offsetAvailable, offsetBeforeStart, _ ->
offsetAvailable < 0f && offsetBeforeStart < 0f && !canScrollForward()
},
canStartPostFling = { velocityAvailable -> velocityAvailable < 0f && !canScrollForward() },
- canContinueScroll = { stackOffset() > 0f },
- canScrollOnFling = true,
+ canStopOnPreFling = { false },
onStart = { offsetAvailable -> onStart(offsetAvailable) },
- onScroll = { offsetAvailable ->
- onScroll(offsetAvailable)
- offsetAvailable
+ onScroll = { offsetAvailable, _ ->
+ val minOffset = 0f
+ val consumed = offsetAvailable.fastCoerceAtLeast(minOffset - stackOffset())
+ if (consumed != 0f) {
+ onScroll(consumed)
+ }
+ consumed
},
onStop = { velocityAvailable ->
onStop(velocityAvailable)
- suspend { velocityAvailable }
+ velocityAvailable
},
+ onCancel = { onStop(0f) },
)
}
diff --git a/packages/SystemUI/compose/scene/src/com/android/compose/animation/scene/DraggableHandler.kt b/packages/SystemUI/compose/scene/src/com/android/compose/animation/scene/DraggableHandler.kt
index 085157a..7e288dd 100644
--- a/packages/SystemUI/compose/scene/src/com/android/compose/animation/scene/DraggableHandler.kt
+++ b/packages/SystemUI/compose/scene/src/com/android/compose/animation/scene/DraggableHandler.kt
@@ -27,9 +27,10 @@
import com.android.compose.animation.scene.content.state.TransitionState
import com.android.compose.animation.scene.content.state.TransitionState.HasOverscrollProperties.Companion.DistanceUnspecified
import com.android.compose.nestedscroll.PriorityNestedScrollConnection
-import com.android.compose.nestedscroll.SuspendedValue
import kotlin.math.absoluteValue
+internal typealias SuspendedValue<T> = suspend () -> T
+
internal interface DraggableHandler {
/**
* Start a drag in the given [startedPosition], with the given [overSlop] and number of
@@ -612,7 +613,7 @@
return PriorityNestedScrollConnection(
orientation = orientation,
- canStartPreScroll = { offsetAvailable, offsetBeforeStart ->
+ canStartPreScroll = { offsetAvailable, offsetBeforeStart, _ ->
canChangeScene =
if (isExternalOverscrollGesture()) false else offsetBeforeStart == 0f
@@ -638,7 +639,7 @@
isIntercepting = true
true
},
- canStartPostScroll = { offsetAvailable, offsetBeforeStart ->
+ canStartPostScroll = { offsetAvailable, offsetBeforeStart, _ ->
val behavior: NestedScrollBehavior =
when {
offsetAvailable > 0f -> topOrLeftBehavior
@@ -693,8 +694,7 @@
canStart
},
- canContinueScroll = { true },
- canScrollOnFling = false,
+ canStopOnPreFling = { true },
onStart = { offsetAvailable ->
val pointersInfo = pointersInfo()
dragController =
@@ -704,7 +704,7 @@
overSlop = if (isIntercepting) 0f else offsetAvailable,
)
},
- onScroll = { offsetAvailable ->
+ onScroll = { offsetAvailable, _ ->
val controller = dragController ?: error("Should be called after onStart")
// TODO(b/297842071) We should handle the overscroll or slow drag if the gesture is
@@ -713,10 +713,18 @@
},
onStop = { velocityAvailable ->
val controller = dragController ?: error("Should be called after onStart")
-
- controller
- .onStop(velocity = velocityAvailable, canChangeContent = canChangeScene)
- .also { dragController = null }
+ try {
+ controller
+ .onStop(velocity = velocityAvailable, canChangeContent = canChangeScene)
+ .invoke()
+ } finally {
+ dragController = null
+ }
+ },
+ onCancel = {
+ val controller = dragController ?: error("Should be called after onStart")
+ controller.onStop(velocity = 0f, canChangeContent = canChangeScene)
+ dragController = null
},
)
}
diff --git a/packages/SystemUI/compose/scene/src/com/android/compose/animation/scene/SwipeAnimation.kt b/packages/SystemUI/compose/scene/src/com/android/compose/animation/scene/SwipeAnimation.kt
index 205267d..f0043e1 100644
--- a/packages/SystemUI/compose/scene/src/com/android/compose/animation/scene/SwipeAnimation.kt
+++ b/packages/SystemUI/compose/scene/src/com/android/compose/animation/scene/SwipeAnimation.kt
@@ -27,7 +27,6 @@
import androidx.compose.ui.unit.IntSize
import com.android.compose.animation.scene.content.state.TransitionState
import com.android.compose.animation.scene.content.state.TransitionState.HasOverscrollProperties.Companion.DistanceUnspecified
-import com.android.compose.nestedscroll.SuspendedValue
import kotlin.math.absoluteValue
import kotlinx.coroutines.CompletableDeferred
diff --git a/packages/SystemUI/compose/scene/src/com/android/compose/nestedscroll/LargeTopAppBarNestedScrollConnection.kt b/packages/SystemUI/compose/scene/src/com/android/compose/nestedscroll/LargeTopAppBarNestedScrollConnection.kt
index 4ae3235..ecf64b7 100644
--- a/packages/SystemUI/compose/scene/src/com/android/compose/nestedscroll/LargeTopAppBarNestedScrollConnection.kt
+++ b/packages/SystemUI/compose/scene/src/com/android/compose/nestedscroll/LargeTopAppBarNestedScrollConnection.kt
@@ -18,6 +18,8 @@
import androidx.compose.foundation.gestures.Orientation
import androidx.compose.ui.input.nestedscroll.NestedScrollConnection
+import androidx.compose.ui.util.fastCoerceAtLeast
+import androidx.compose.ui.util.fastCoerceAtMost
/**
* A [NestedScrollConnection] that listens for all vertical scroll events and responds in the
@@ -43,35 +45,32 @@
orientation = Orientation.Vertical,
// When swiping up, the LargeTopAppBar will shrink (to [minHeight]) and the content will
// expand. Then, you can then scroll down the content.
- canStartPreScroll = { offsetAvailable, offsetBeforeStart ->
+ canStartPreScroll = { offsetAvailable, offsetBeforeStart, _ ->
offsetAvailable < 0 && offsetBeforeStart == 0f && height() > minHeight()
},
// When swiping down, the content will scroll up until it reaches the top. Then, the
// LargeTopAppBar will expand until it reaches its [maxHeight].
- canStartPostScroll = { offsetAvailable, _ ->
+ canStartPostScroll = { offsetAvailable, _, _ ->
offsetAvailable > 0 && height() < maxHeight()
},
canStartPostFling = { false },
- canContinueScroll = {
- val currentHeight = height()
- minHeight() < currentHeight && currentHeight < maxHeight()
- },
- canScrollOnFling = true,
+ canStopOnPreFling = { false },
onStart = { /* do nothing */ },
- onScroll = { offsetAvailable ->
+ onScroll = { offsetAvailable, _ ->
val currentHeight = height()
val amountConsumed =
if (offsetAvailable > 0) {
val amountLeft = maxHeight() - currentHeight
- offsetAvailable.coerceAtMost(amountLeft)
+ offsetAvailable.fastCoerceAtMost(amountLeft)
} else {
val amountLeft = minHeight() - currentHeight
- offsetAvailable.coerceAtLeast(amountLeft)
+ offsetAvailable.fastCoerceAtLeast(amountLeft)
}
onHeightChanged(currentHeight + amountConsumed)
amountConsumed
},
// Don't consume the velocity on pre/post fling
- onStop = { { 0f } },
+ onStop = { 0f },
+ onCancel = { /* do nothing */ },
)
}
diff --git a/packages/SystemUI/compose/scene/src/com/android/compose/nestedscroll/PriorityNestedScrollConnection.kt b/packages/SystemUI/compose/scene/src/com/android/compose/nestedscroll/PriorityNestedScrollConnection.kt
index a3641e6..636c557 100644
--- a/packages/SystemUI/compose/scene/src/com/android/compose/nestedscroll/PriorityNestedScrollConnection.kt
+++ b/packages/SystemUI/compose/scene/src/com/android/compose/nestedscroll/PriorityNestedScrollConnection.kt
@@ -16,37 +16,59 @@
package com.android.compose.nestedscroll
+import androidx.compose.animation.core.AnimationState
+import androidx.compose.animation.core.DecayAnimationSpec
+import androidx.compose.animation.core.animateDecay
import androidx.compose.foundation.gestures.Orientation
import androidx.compose.ui.geometry.Offset
import androidx.compose.ui.input.nestedscroll.NestedScrollConnection
import androidx.compose.ui.input.nestedscroll.NestedScrollSource
import androidx.compose.ui.unit.Velocity
import com.android.compose.ui.util.SpaceVectorConverter
+import kotlin.math.abs
import kotlin.math.sign
-
-internal typealias SuspendedValue<T> = suspend () -> T
+import kotlinx.coroutines.CompletableDeferred
+import kotlinx.coroutines.Deferred
+import kotlinx.coroutines.async
+import kotlinx.coroutines.coroutineScope
/**
- * This [NestedScrollConnection] waits for a child to scroll ([onPreScroll] or [onPostScroll]), and
- * then decides (via [canStartPreScroll] or [canStartPostScroll]) if it should take over scrolling.
- * If it does, it will scroll before its children, until [canContinueScroll] allows it.
+ * A [NestedScrollConnection] that intercepts scroll events in priority mode.
*
- * Note: Call [reset] before destroying this object to make sure you always get a call to [onStop]
- * after [onStart].
+ * Priority mode allows this connection to take control over scroll events within a nested scroll
+ * hierarchy. When in priority mode, this connection consumes scroll events before its children,
+ * enabling custom scrolling behaviors like sticky headers.
*
+ * @param orientation The orientation of the scroll.
+ * @param canStartPreScroll lambda that returns true if the connection can start consuming scroll
+ * events in pre-scroll mode.
+ * @param canStartPostScroll lambda that returns true if the connection can start consuming scroll
+ * events in post-scroll mode.
+ * @param canStartPostFling lambda that returns true if the connection can start consuming scroll
+ * events in post-fling mode.
+ * @param canStopOnPreFling lambda that returns true if the connection can stop consuming scroll
+ * events in pre-fling (i.e. as soon as the user lifts their fingers).
+ * @param onStart lambda that is called when the connection starts consuming scroll events.
+ * @param onScroll lambda that is called when the connection consumes a scroll event and returns the
+ * consumed amount.
+ * @param onStop lambda that is called when the connection stops consuming scroll events and returns
+ * the consumed velocity.
+ * @param onCancel lambda that is called when the connection is cancelled.
* @sample LargeTopAppBarNestedScrollConnection
* @sample com.android.compose.animation.scene.NestedScrollHandlerImpl.nestedScrollConnection
*/
class PriorityNestedScrollConnection(
orientation: Orientation,
- private val canStartPreScroll: (offsetAvailable: Float, offsetBeforeStart: Float) -> Boolean,
- private val canStartPostScroll: (offsetAvailable: Float, offsetBeforeStart: Float) -> Boolean,
+ private val canStartPreScroll:
+ (offsetAvailable: Float, offsetBeforeStart: Float, source: NestedScrollSource) -> Boolean,
+ private val canStartPostScroll:
+ (offsetAvailable: Float, offsetBeforeStart: Float, source: NestedScrollSource) -> Boolean,
private val canStartPostFling: (velocityAvailable: Float) -> Boolean,
- private val canContinueScroll: (source: NestedScrollSource) -> Boolean,
- private val canScrollOnFling: Boolean,
+ private val canStopOnPreFling: () -> Boolean,
private val onStart: (offsetAvailable: Float) -> Unit,
- private val onScroll: (offsetAvailable: Float) -> Float,
- private val onStop: (velocityAvailable: Float) -> SuspendedValue<Float>,
+ private val onScroll: (offsetAvailable: Float, source: NestedScrollSource) -> Float,
+ private val onStop: suspend (velocityAvailable: Float) -> Float,
+ private val onCancel: () -> Unit,
) : NestedScrollConnection, SpaceVectorConverter by SpaceVectorConverter(orientation) {
/** In priority mode [onPreScroll] events are first consumed by the parent, via [onScroll]. */
@@ -54,6 +76,9 @@
private var offsetScrolledBeforePriorityMode = 0f
+ /** This job allows us to interrupt the onStop animation */
+ private var onStopJob: Deferred<Float> = CompletableDeferred(0f)
+
override fun onPostScroll(
consumed: Offset,
available: Offset,
@@ -64,62 +89,48 @@
// the beginning or from the last fling gesture.
val offsetBeforeStart = offsetScrolledBeforePriorityMode - availableFloat
- if (
- isPriorityMode ||
- (source == NestedScrollSource.SideEffect && !canScrollOnFling) ||
- !canStartPostScroll(availableFloat, offsetBeforeStart)
- ) {
+ if (isPriorityMode || !canStartPostScroll(availableFloat, offsetBeforeStart, source)) {
// The priority mode cannot start so we won't consume the available offset.
return Offset.Zero
}
- return onPriorityStart(availableFloat).toOffset()
+ return start(availableFloat, source).toOffset()
}
override fun onPreScroll(available: Offset, source: NestedScrollSource): Offset {
if (!isPriorityMode) {
- if (source == NestedScrollSource.UserInput || canScrollOnFling) {
- val availableFloat = available.toFloat()
- if (canStartPreScroll(availableFloat, offsetScrolledBeforePriorityMode)) {
- return onPriorityStart(availableFloat).toOffset()
- }
- // We want to track the amount of offset consumed before entering priority mode
- offsetScrolledBeforePriorityMode += availableFloat
+ val availableFloat = available.toFloat()
+ if (canStartPreScroll(availableFloat, offsetScrolledBeforePriorityMode, source)) {
+ return start(availableFloat, source).toOffset()
}
-
- return Offset.Zero
- }
-
- val availableFloat = available.toFloat()
- if (!canContinueScroll(source)) {
- // Step 3a: We have lost priority and we no longer need to intercept scroll events.
- onPriorityStop(velocity = 0f)
-
- // We've just reset offsetScrolledBeforePriorityMode to 0f
// We want to track the amount of offset consumed before entering priority mode
offsetScrolledBeforePriorityMode += availableFloat
-
return Offset.Zero
}
- // Step 2: We have the priority and can consume the scroll events.
- return onScroll(availableFloat).toOffset()
+ return scroll(available.toFloat(), source).toOffset()
}
override suspend fun onPreFling(available: Velocity): Velocity {
- if (isPriorityMode && canScrollOnFling) {
- // We don't want to consume the velocity, we prefer to continue receiving scroll events.
+ if (!isPriorityMode) {
+ resetOffsetTracker()
return Velocity.Zero
}
- // Step 3b: The finger is lifted, we can stop intercepting scroll events and use the speed
- // of the fling gesture.
- return onPriorityStop(velocity = available.toFloat()).invoke().toVelocity()
+
+ if (canStopOnPreFling()) {
+ // Step 3b: The finger is lifted, we can stop intercepting scroll events and use the
+ // velocity of the fling gesture.
+ return stop(velocityAvailable = available.toFloat()).toVelocity()
+ }
+
+ // We don't want to consume the velocity, we prefer to continue receiving scroll events.
+ return Velocity.Zero
}
override suspend fun onPostFling(consumed: Velocity, available: Velocity): Velocity {
val availableFloat = available.toFloat()
if (isPriorityMode) {
- return onPriorityStop(velocity = availableFloat).invoke().toVelocity()
+ return stop(velocityAvailable = availableFloat).toVelocity()
}
if (!canStartPostFling(availableFloat)) {
@@ -131,10 +142,14 @@
// TODO(b/291053278): Remove canStartPostFling() and instead make it possible to define the
// overscroll behavior on the Scene level.
val smallOffset = availableFloat.sign
- onPriorityStart(availableOffset = smallOffset)
+ start(
+ availableOffset = smallOffset,
+ source = NestedScrollSource.SideEffect,
+ skipScroll = true,
+ )
// This is the last event of a scroll gesture.
- return onPriorityStop(availableFloat).invoke().toVelocity()
+ return stop(availableFloat).toVelocity()
}
/**
@@ -143,36 +158,76 @@
* TODO(b/303224944) This method should be removed.
*/
fun reset() {
- // Step 3c: To ensure that an onStop is always called for every onStart.
- onPriorityStop(velocity = 0f)
+ if (isPriorityMode) {
+ // Step 3c: To ensure that an onStop (or onCancel) is always called for every onStart.
+ cancel()
+ } else {
+ resetOffsetTracker()
+ }
}
- private fun onPriorityStart(availableOffset: Float): Float {
- if (isPriorityMode) {
- error("This should never happen, onPriorityStart() was called when isPriorityMode")
+ private fun shouldStop(consumed: Float): Boolean {
+ return consumed == 0f
+ }
+
+ private fun start(
+ availableOffset: Float,
+ source: NestedScrollSource,
+ skipScroll: Boolean = false,
+ ): Float {
+ check(!isPriorityMode) {
+ "This should never happen, start() was called when isPriorityMode"
}
// Step 1: It's our turn! We start capturing scroll events when one of our children has an
// available offset following a scroll event.
isPriorityMode = true
+ onStopJob.cancel()
+
// Note: onStop will be called if we cannot continue to scroll (step 3a), or the finger is
// lifted (step 3b), or this object has been destroyed (step 3c).
onStart(availableOffset)
- return onScroll(availableOffset)
+ return if (skipScroll) 0f else scroll(availableOffset, source)
}
- private fun onPriorityStop(velocity: Float): SuspendedValue<Float> {
- // We can restart tracking the consumed offsets from scratch.
- offsetScrolledBeforePriorityMode = 0f
+ private fun scroll(offsetAvailable: Float, source: NestedScrollSource): Float {
+ // Step 2: We have the priority and can consume the scroll events.
+ val consumedByScroll = onScroll(offsetAvailable, source)
- if (!isPriorityMode) {
- return { 0f }
+ if (shouldStop(consumedByScroll)) {
+ // Step 3a: We have lost priority and we no longer need to intercept scroll events.
+ cancel()
+
+ // We've just reset offsetScrolledBeforePriorityMode to 0f
+ // We want to track the amount of offset consumed before entering priority mode
+ offsetScrolledBeforePriorityMode += offsetAvailable - consumedByScroll
}
- isPriorityMode = false
+ return consumedByScroll
+ }
- return onStop(velocity)
+ /** Reset the tracking of consumed offsets before entering in priority mode. */
+ private fun resetOffsetTracker() {
+ offsetScrolledBeforePriorityMode = 0f
+ }
+
+ private suspend fun stop(velocityAvailable: Float): Float {
+ check(isPriorityMode) { "This should never happen, stop() was called before start()" }
+ isPriorityMode = false
+ resetOffsetTracker()
+
+ return coroutineScope {
+ onStopJob = async { onStop(velocityAvailable) }
+ onStopJob.await()
+ }
+ }
+
+ private fun cancel() {
+ check(isPriorityMode) { "This should never happen, cancel() was called before start()" }
+ isPriorityMode = false
+ resetOffsetTracker()
+ onCancel()
}
}
diff --git a/packages/SystemUI/compose/scene/tests/src/com/android/compose/animation/scene/DraggableHandlerTest.kt b/packages/SystemUI/compose/scene/tests/src/com/android/compose/animation/scene/DraggableHandlerTest.kt
index ecef6be..57b9423 100644
--- a/packages/SystemUI/compose/scene/tests/src/com/android/compose/animation/scene/DraggableHandlerTest.kt
+++ b/packages/SystemUI/compose/scene/tests/src/com/android/compose/animation/scene/DraggableHandlerTest.kt
@@ -39,7 +39,6 @@
import com.android.compose.animation.scene.content.state.TransitionState
import com.android.compose.animation.scene.content.state.TransitionState.Transition
import com.android.compose.animation.scene.subjects.assertThat
-import com.android.compose.nestedscroll.SuspendedValue
import com.android.compose.test.MonotonicClockTestScope
import com.android.compose.test.runMonotonicClockTest
import com.android.compose.test.transition
diff --git a/packages/SystemUI/compose/scene/tests/src/com/android/compose/animation/scene/MultiPointerDraggableTest.kt b/packages/SystemUI/compose/scene/tests/src/com/android/compose/animation/scene/MultiPointerDraggableTest.kt
index c8f6e6d..3df6087 100644
--- a/packages/SystemUI/compose/scene/tests/src/com/android/compose/animation/scene/MultiPointerDraggableTest.kt
+++ b/packages/SystemUI/compose/scene/tests/src/com/android/compose/animation/scene/MultiPointerDraggableTest.kt
@@ -46,7 +46,6 @@
import androidx.compose.ui.unit.Velocity
import androidx.test.ext.junit.runners.AndroidJUnit4
import com.android.compose.modifiers.thenIf
-import com.android.compose.nestedscroll.SuspendedValue
import com.google.common.truth.Truth.assertThat
import kotlin.properties.Delegates
import kotlinx.coroutines.coroutineScope
diff --git a/packages/SystemUI/compose/scene/tests/src/com/android/compose/animation/scene/SwipeToSceneTest.kt b/packages/SystemUI/compose/scene/tests/src/com/android/compose/animation/scene/SwipeToSceneTest.kt
index 28d0a47..1711f31 100644
--- a/packages/SystemUI/compose/scene/tests/src/com/android/compose/animation/scene/SwipeToSceneTest.kt
+++ b/packages/SystemUI/compose/scene/tests/src/com/android/compose/animation/scene/SwipeToSceneTest.kt
@@ -102,26 +102,22 @@
modifier = Modifier.size(LayoutWidth, LayoutHeight).testTag(TestElements.Foo.debugName),
) {
scene(
- SceneA,
+ key = SceneA,
userActions =
if (swipesEnabled())
- mapOf(
- Swipe.Left to SceneB,
- Swipe.Down to TestScenes.SceneC,
- Swipe.Up to SceneB,
- )
+ mapOf(Swipe.Left to SceneB, Swipe.Down to SceneC, Swipe.Up to SceneB)
else emptyMap(),
) {
Box(Modifier.fillMaxSize())
}
scene(
- SceneB,
+ key = SceneB,
userActions = if (swipesEnabled()) mapOf(Swipe.Right to SceneA) else emptyMap(),
) {
Box(Modifier.fillMaxSize())
}
scene(
- TestScenes.SceneC,
+ key = SceneC,
userActions =
if (swipesEnabled())
mapOf(
@@ -196,7 +192,7 @@
// Drag is in progress, so currentScene = SceneA and progress = 56dp / LayoutHeight
transition = assertThat(layoutState.transitionState).isSceneTransition()
assertThat(transition).hasFromScene(SceneA)
- assertThat(transition).hasToScene(TestScenes.SceneC)
+ assertThat(transition).hasToScene(SceneC)
assertThat(transition).hasCurrentScene(SceneA)
assertThat(transition).hasProgress(56.dp / LayoutHeight)
assertThat(transition).isInitiatedByUserInput()
@@ -206,15 +202,15 @@
rule.onRoot().performTouchInput { up() }
transition = assertThat(layoutState.transitionState).isSceneTransition()
assertThat(transition).hasFromScene(SceneA)
- assertThat(transition).hasToScene(TestScenes.SceneC)
- assertThat(transition).hasCurrentScene(TestScenes.SceneC)
+ assertThat(transition).hasToScene(SceneC)
+ assertThat(transition).hasCurrentScene(SceneC)
assertThat(transition).hasProgress(56.dp / LayoutHeight)
assertThat(transition).isInitiatedByUserInput()
// Wait for the animation to finish. We should now be in scene C.
rule.waitForIdle()
assertThat(layoutState.transitionState).isIdle()
- assertThat(layoutState.transitionState).hasCurrentScene(TestScenes.SceneC)
+ assertThat(layoutState.transitionState).hasCurrentScene(SceneC)
}
@Test
@@ -271,20 +267,20 @@
// We should be animating to C (currentScene = SceneC).
transition = assertThat(layoutState.transitionState).isSceneTransition()
assertThat(transition).hasFromScene(SceneA)
- assertThat(transition).hasToScene(TestScenes.SceneC)
- assertThat(transition).hasCurrentScene(TestScenes.SceneC)
+ assertThat(transition).hasToScene(SceneC)
+ assertThat(transition).hasCurrentScene(SceneC)
assertThat(transition).hasProgress(55.dp / LayoutHeight)
// Wait for the animation to finish. We should now be in scene C.
rule.waitForIdle()
assertThat(layoutState.transitionState).isIdle()
- assertThat(layoutState.transitionState).hasCurrentScene(TestScenes.SceneC)
+ assertThat(layoutState.transitionState).hasCurrentScene(SceneC)
}
@Test
fun multiPointerSwipe() {
// Start at scene C.
- val layoutState = layoutState(TestScenes.SceneC)
+ val layoutState = layoutState(SceneC)
// The draggable touch slop, i.e. the min px distance a touch pointer must move before it is
// detected as a drag event.
@@ -295,7 +291,7 @@
}
assertThat(layoutState.transitionState).isIdle()
- assertThat(layoutState.transitionState).hasCurrentScene(TestScenes.SceneC)
+ assertThat(layoutState.transitionState).hasCurrentScene(SceneC)
// Swipe down with two fingers.
rule.onRoot().performTouchInput {
@@ -307,7 +303,7 @@
// We are transitioning to B because we used 2 fingers.
val transition = assertThat(layoutState.transitionState).isSceneTransition()
- assertThat(transition).hasFromScene(TestScenes.SceneC)
+ assertThat(transition).hasFromScene(SceneC)
assertThat(transition).hasToScene(SceneB)
// Release the fingers and wait for the animation to end. We are back to C because we only
@@ -315,13 +311,13 @@
rule.onRoot().performTouchInput { repeat(2) { i -> up(pointerId = i) } }
rule.waitForIdle()
assertThat(layoutState.transitionState).isIdle()
- assertThat(layoutState.transitionState).hasCurrentScene(TestScenes.SceneC)
+ assertThat(layoutState.transitionState).hasCurrentScene(SceneC)
}
@Test
fun defaultEdgeSwipe() {
// Start at scene C.
- val layoutState = layoutState(TestScenes.SceneC)
+ val layoutState = layoutState(SceneC)
// The draggable touch slop, i.e. the min px distance a touch pointer must move before it is
// detected as a drag event.
@@ -332,7 +328,7 @@
}
assertThat(layoutState.transitionState).isIdle()
- assertThat(layoutState.transitionState).hasCurrentScene(TestScenes.SceneC)
+ assertThat(layoutState.transitionState).hasCurrentScene(SceneC)
// Swipe down from the top edge.
rule.onRoot().performTouchInput {
@@ -342,7 +338,7 @@
// We are transitioning to B (and not A) because we started from the top edge.
var transition = assertThat(layoutState.transitionState).isSceneTransition()
- assertThat(transition).hasFromScene(TestScenes.SceneC)
+ assertThat(transition).hasFromScene(SceneC)
assertThat(transition).hasToScene(SceneB)
// Release the fingers and wait for the animation to end. We are back to C because we only
@@ -350,7 +346,7 @@
rule.onRoot().performTouchInput { up() }
rule.waitForIdle()
assertThat(layoutState.transitionState).isIdle()
- assertThat(layoutState.transitionState).hasCurrentScene(TestScenes.SceneC)
+ assertThat(layoutState.transitionState).hasCurrentScene(SceneC)
// Swipe right from the left edge.
rule.onRoot().performTouchInput {
@@ -360,7 +356,7 @@
// We are transitioning to B (and not A) because we started from the left edge.
transition = assertThat(layoutState.transitionState).isSceneTransition()
- assertThat(transition).hasFromScene(TestScenes.SceneC)
+ assertThat(transition).hasFromScene(SceneC)
assertThat(transition).hasToScene(SceneB)
// Release the fingers and wait for the animation to end. We are back to C because we only
@@ -368,7 +364,7 @@
rule.onRoot().performTouchInput { up() }
rule.waitForIdle()
assertThat(layoutState.transitionState).isIdle()
- assertThat(layoutState.transitionState).hasCurrentScene(TestScenes.SceneC)
+ assertThat(layoutState.transitionState).hasCurrentScene(SceneC)
}
@Test
@@ -434,7 +430,7 @@
// We should still correctly compute that we are swiping down to scene C.
var transition = assertThat(layoutState.transitionState).isSceneTransition()
- assertThat(transition).hasToScene(TestScenes.SceneC)
+ assertThat(transition).hasToScene(SceneC)
// Release the finger, animating back to scene A.
rule.onRoot().performTouchInput { up() }
diff --git a/packages/SystemUI/compose/scene/tests/src/com/android/compose/nestedscroll/PriorityNestedScrollConnectionTest.kt b/packages/SystemUI/compose/scene/tests/src/com/android/compose/nestedscroll/PriorityNestedScrollConnectionTest.kt
index badc43b..1a3b86b 100644
--- a/packages/SystemUI/compose/scene/tests/src/com/android/compose/nestedscroll/PriorityNestedScrollConnectionTest.kt
+++ b/packages/SystemUI/compose/scene/tests/src/com/android/compose/nestedscroll/PriorityNestedScrollConnectionTest.kt
@@ -34,30 +34,31 @@
private var canStartPreScroll = false
private var canStartPostScroll = false
private var canStartPostFling = false
- private var canContinueScroll = false
+ private var canStopOnPreFling = true
private var isStarted = false
private var lastScroll: Float? = null
- private var returnOnScroll = 0f
+ private var consumeScroll = true
private var lastStop: Float? = null
- private var returnOnStop = 0f
+ private var isCancelled: Boolean = false
+ private var consumeStop = true
private val scrollConnection =
PriorityNestedScrollConnection(
orientation = Orientation.Vertical,
- canStartPreScroll = { _, _ -> canStartPreScroll },
- canStartPostScroll = { _, _ -> canStartPostScroll },
+ canStartPreScroll = { _, _, _ -> canStartPreScroll },
+ canStartPostScroll = { _, _, _ -> canStartPostScroll },
canStartPostFling = { canStartPostFling },
- canContinueScroll = { canContinueScroll },
- canScrollOnFling = false,
+ canStopOnPreFling = { canStopOnPreFling },
onStart = { isStarted = true },
- onScroll = {
- lastScroll = it
- returnOnScroll
+ onScroll = { offsetAvailable, _ ->
+ lastScroll = offsetAvailable
+ if (consumeScroll) offsetAvailable else 0f
},
onStop = {
lastStop = it
- { returnOnStop }
+ if (consumeStop) it else 0f
},
+ onCancel = { isCancelled = true },
)
@Test
@@ -85,7 +86,7 @@
canStartPostScroll = true
scrollConnection.onPostScroll(
consumed = Offset.Zero,
- available = Offset.Zero,
+ available = Offset(1f, 1f),
source = UserInput,
)
}
@@ -136,45 +137,55 @@
@Test
fun step2_onPriorityMode_shouldContinueIfAllowed() {
startPriorityModePostScroll()
- canContinueScroll = true
- scrollConnection.onPreScroll(available = Offset(1f, 1f), source = UserInput)
+ val scroll1 = scrollConnection.onPreScroll(available = Offset(0f, 1f), source = UserInput)
assertThat(lastScroll).isEqualTo(1f)
+ assertThat(scroll1.y).isEqualTo(1f)
- canContinueScroll = false
- scrollConnection.onPreScroll(available = Offset(2f, 2f), source = UserInput)
- assertThat(lastScroll).isNotEqualTo(2f)
- assertThat(lastScroll).isEqualTo(1f)
+ consumeScroll = false
+ val scroll2 = scrollConnection.onPreScroll(available = Offset(0f, 2f), source = UserInput)
+ assertThat(lastScroll).isEqualTo(2f)
+ assertThat(scroll2.y).isEqualTo(0f)
}
@Test
- fun step3a_onPriorityMode_shouldStopIfCannotContinue() {
+ fun step3a_onPriorityMode_shouldCancelIfCannotContinue() {
startPriorityModePostScroll()
- canContinueScroll = false
+ consumeScroll = false
- scrollConnection.onPreScroll(available = Offset.Zero, source = UserInput)
+ scrollConnection.onPreScroll(available = Offset(0f, 1f), source = UserInput)
- assertThat(lastStop).isNotNull()
+ assertThat(isCancelled).isTrue()
}
@Test
fun step3b_onPriorityMode_shouldStopOnFling() = runTest {
startPriorityModePostScroll()
- canContinueScroll = true
scrollConnection.onPreFling(available = Velocity.Zero)
- assertThat(lastStop).isNotNull()
+ assertThat(lastStop).isEqualTo(0f)
}
@Test
- fun step3c_onPriorityMode_shouldStopOnReset() {
+ fun ifCannotStopOnPreFling_shouldStopOnPostFling() = runTest {
startPriorityModePostScroll()
- canContinueScroll = true
+ canStopOnPreFling = false
+
+ scrollConnection.onPreFling(available = Velocity.Zero)
+ assertThat(lastStop).isNull()
+
+ scrollConnection.onPostFling(consumed = Velocity.Zero, available = Velocity.Zero)
+ assertThat(lastStop).isEqualTo(0f)
+ }
+
+ @Test
+ fun step3c_onPriorityMode_shouldCancelOnReset() {
+ startPriorityModePostScroll()
scrollConnection.reset()
- assertThat(lastStop).isNotNull()
+ assertThat(isCancelled).isTrue()
}
@Test
diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/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/qs/panels/data/repository/PaginatedGridRepositoryTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/panels/data/repository/PaginatedGridRepositoryTest.kt
index 14d6094..e5bdc2e 100644
--- a/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/panels/data/repository/PaginatedGridRepositoryTest.kt
+++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/panels/data/repository/PaginatedGridRepositoryTest.kt
@@ -54,7 +54,7 @@
private fun setRowsInConfig(rows: Int) =
with(kosmos) {
testCase.context.orCreateTestableResources.addOverride(
- R.integer.quick_settings_max_rows,
+ R.integer.quick_settings_paginated_grid_num_rows,
rows,
)
fakeConfigurationRepository.onConfigurationChange()
diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/panels/data/repository/QuickQuickSettingsRowRepositoryTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/panels/data/repository/QuickQuickSettingsRowRepositoryTest.kt
index ae6f576..cda3d48 100644
--- a/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/panels/data/repository/QuickQuickSettingsRowRepositoryTest.kt
+++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/panels/data/repository/QuickQuickSettingsRowRepositoryTest.kt
@@ -54,7 +54,7 @@
private fun setRowsInConfig(rows: Int) =
with(kosmos) {
testCase.context.orCreateTestableResources.addOverride(
- R.integer.quick_qs_panel_max_rows,
+ R.integer.quick_qs_paginated_grid_num_rows,
rows,
)
fakeConfigurationRepository.onConfigurationChange()
diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/panels/ui/viewmodel/QuickQuickSettingsViewModelTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/panels/ui/viewmodel/QuickQuickSettingsViewModelTest.kt
index a1c0ef2..2c894f9 100644
--- a/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/panels/ui/viewmodel/QuickQuickSettingsViewModelTest.kt
+++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/panels/ui/viewmodel/QuickQuickSettingsViewModelTest.kt
@@ -151,7 +151,7 @@
private fun Kosmos.setRows(rows: Int) {
testCase.context.orCreateTestableResources.addOverride(
- R.integer.quick_qs_panel_max_rows,
+ R.integer.quick_qs_paginated_grid_num_rows,
rows,
)
fakeConfigurationRepository.onConfigurationChange()
diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/shade/NotificationPanelViewControllerBaseTest.java b/packages/SystemUI/multivalentTests/src/com/android/systemui/shade/NotificationPanelViewControllerBaseTest.java
index 0454317..06d19d7 100644
--- a/packages/SystemUI/multivalentTests/src/com/android/systemui/shade/NotificationPanelViewControllerBaseTest.java
+++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/shade/NotificationPanelViewControllerBaseTest.java
@@ -68,13 +68,13 @@
import com.android.internal.logging.testing.UiEventLoggerFake;
import com.android.internal.statusbar.IStatusBarService;
import com.android.internal.util.LatencyTracker;
+import com.android.keyguard.EmptyLockIconViewController;
import com.android.keyguard.KeyguardClockSwitch;
import com.android.keyguard.KeyguardClockSwitchController;
import com.android.keyguard.KeyguardSliceViewController;
import com.android.keyguard.KeyguardStatusView;
import com.android.keyguard.KeyguardStatusViewController;
import com.android.keyguard.KeyguardUpdateMonitor;
-import com.android.keyguard.LegacyLockIconViewController;
import com.android.keyguard.dagger.KeyguardQsUserSwitchComponent;
import com.android.keyguard.dagger.KeyguardStatusBarViewComponent;
import com.android.keyguard.dagger.KeyguardStatusViewComponent;
@@ -271,6 +271,7 @@
@Mock protected KeyguardUserSwitcherController mKeyguardUserSwitcherController;
@Mock protected KeyguardStatusViewComponent mKeyguardStatusViewComponent;
@Mock protected KeyguardStatusBarViewComponent.Factory mKeyguardStatusBarViewComponentFactory;
+ @Mock protected EmptyLockIconViewController mLockIconViewController;
@Mock protected KeyguardStatusBarViewComponent mKeyguardStatusBarViewComponent;
@Mock protected KeyguardClockSwitchController mKeyguardClockSwitchController;
@Mock protected KeyguardStatusBarViewController mKeyguardStatusBarViewController;
@@ -285,7 +286,6 @@
@Mock protected AmbientState mAmbientState;
@Mock protected UserManager mUserManager;
@Mock protected UiEventLogger mUiEventLogger;
- @Mock protected LegacyLockIconViewController mLockIconViewController;
@Mock protected KeyguardViewConfigurator mKeyguardViewConfigurator;
@Mock protected KeyguardRootView mKeyguardRootView;
@Mock protected View mKeyguardRootViewChild;
@@ -397,7 +397,6 @@
mFeatureFlags.set(Flags.QS_USER_DETAIL_SHORTCUT, false);
mSetFlagsRule.disableFlags(com.android.systemui.Flags.FLAG_KEYGUARD_BOTTOM_AREA_REFACTOR);
- mSetFlagsRule.disableFlags(com.android.systemui.Flags.FLAG_DEVICE_ENTRY_UDFPS_REFACTOR);
mMainDispatcher = getMainDispatcher();
KeyguardInteractorFactory.WithDependencies keyguardInteractorDeps =
@@ -687,6 +686,9 @@
when(longPressHandlingView.getResources()).thenReturn(longPressHandlingViewRes);
when(longPressHandlingViewRes.getString(anyInt())).thenReturn("");
+ when(mKeyguardRootView.findViewById(anyInt())).thenReturn(mKeyguardRootViewChild);
+ when(mKeyguardViewConfigurator.getKeyguardRootView()).thenReturn(mKeyguardRootView);
+
mNotificationPanelViewController = new NotificationPanelViewController(
mView,
mMainHandler,
@@ -852,7 +854,7 @@
mNotificationPanelViewController.mBottomAreaShadeAlphaAnimator.cancel();
mNotificationPanelViewController.cancelHeightAnimator();
leakedAnimators = mNotificationPanelViewController.mTestSetOfAnimatorsUsed.stream()
- .filter(Animator::isRunning).toList();
+ .filter(Animator::isRunning).toList();
mNotificationPanelViewController.mTestSetOfAnimatorsUsed.forEach(Animator::cancel);
}
if (mMainHandler != null) {
@@ -869,11 +871,7 @@
when(mNotificationStackScrollLayoutController.getTop()).thenReturn(0);
when(mNotificationStackScrollLayoutController.getHeight()).thenReturn(stackBottom);
when(mNotificationStackScrollLayoutController.getBottom()).thenReturn(stackBottom);
- when(mLockIconViewController.getTop()).thenReturn((float) (stackBottom - lockIconPadding));
-
when(mKeyguardRootViewChild.getTop()).thenReturn((int) (stackBottom - lockIconPadding));
- when(mKeyguardRootView.findViewById(anyInt())).thenReturn(mKeyguardRootViewChild);
- when(mKeyguardViewConfigurator.getKeyguardRootView()).thenReturn(mKeyguardRootView);
when(mResources.getDimensionPixelSize(R.dimen.keyguard_indication_bottom_padding))
.thenReturn(indicationPadding);
diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/shade/NotificationPanelViewControllerTest.java b/packages/SystemUI/multivalentTests/src/com/android/systemui/shade/NotificationPanelViewControllerTest.java
index 43dbb40..ec75972 100644
--- a/packages/SystemUI/multivalentTests/src/com/android/systemui/shade/NotificationPanelViewControllerTest.java
+++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/shade/NotificationPanelViewControllerTest.java
@@ -217,7 +217,6 @@
assertThat(mNotificationPanelViewController.getVerticalSpaceForLockscreenShelf())
.isEqualTo(5);
- mSetFlagsRule.enableFlags(com.android.systemui.Flags.FLAG_DEVICE_ENTRY_UDFPS_REFACTOR);
assertThat(mNotificationPanelViewController.getVerticalSpaceForLockscreenShelf())
.isEqualTo(5);
}
@@ -235,7 +234,6 @@
assertThat(mNotificationPanelViewController.getVerticalSpaceForLockscreenShelf())
.isEqualTo(0);
- mSetFlagsRule.enableFlags(com.android.systemui.Flags.FLAG_DEVICE_ENTRY_UDFPS_REFACTOR);
assertThat(mNotificationPanelViewController.getVerticalSpaceForLockscreenShelf())
.isEqualTo(0);
}
@@ -253,7 +251,6 @@
assertThat(mNotificationPanelViewController.getVerticalSpaceForLockscreenShelf())
.isEqualTo(0);
- mSetFlagsRule.enableFlags(com.android.systemui.Flags.FLAG_DEVICE_ENTRY_UDFPS_REFACTOR);
assertThat(mNotificationPanelViewController.getVerticalSpaceForLockscreenShelf())
.isEqualTo(0);
}
@@ -271,7 +268,6 @@
assertThat(mNotificationPanelViewController.getVerticalSpaceForLockscreenShelf())
.isEqualTo(2);
- mSetFlagsRule.enableFlags(com.android.systemui.Flags.FLAG_DEVICE_ENTRY_UDFPS_REFACTOR);
assertThat(mNotificationPanelViewController.getVerticalSpaceForLockscreenShelf())
.isEqualTo(2);
}
@@ -289,7 +285,6 @@
assertThat(mNotificationPanelViewController.getVerticalSpaceForLockscreenShelf())
.isEqualTo(0);
- mSetFlagsRule.enableFlags(com.android.systemui.Flags.FLAG_DEVICE_ENTRY_UDFPS_REFACTOR);
assertThat(mNotificationPanelViewController.getVerticalSpaceForLockscreenShelf())
.isEqualTo(0);
}
@@ -389,7 +384,6 @@
@Test
@DisableFlags(com.android.systemui.Flags.FLAG_MIGRATE_CLOCKS_TO_BLUEPRINT)
public void alternateBouncerVisible_onTouchEvent_notHandled() {
- mSetFlagsRule.enableFlags(com.android.systemui.Flags.FLAG_DEVICE_ENTRY_UDFPS_REFACTOR);
// GIVEN alternate bouncer is visible
when(mAlternateBouncerInteractor.isVisibleState()).thenReturn(true);
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/notification/NotificationScrimNestedScrollConnectionTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/notification/NotificationScrimNestedScrollConnectionTest.kt
index 35e4047..97fa6eb 100644
--- a/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/notification/NotificationScrimNestedScrollConnectionTest.kt
+++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/notification/NotificationScrimNestedScrollConnectionTest.kt
@@ -31,6 +31,7 @@
@RunWith(AndroidJUnit4::class)
class NotificationScrimNestedScrollConnectionTest : SysuiTestCase() {
private var isStarted = false
+ private var wasStarted = false
private var scrimOffset = 0f
private var contentHeight = 0f
private var isCurrentGestureOverscroll = false
@@ -46,7 +47,10 @@
minVisibleScrimHeight = { MIN_VISIBLE_SCRIM_HEIGHT },
isCurrentGestureOverscroll = { isCurrentGestureOverscroll },
onStart = { isStarted = true },
- onStop = { isStarted = false },
+ onStop = {
+ wasStarted = true
+ isStarted = false
+ },
)
@Test
@@ -180,6 +184,7 @@
)
assertThat(offsetConsumed).isEqualTo(Offset.Zero)
+ assertThat(wasStarted).isEqualTo(false)
assertThat(isStarted).isEqualTo(false)
}
@@ -196,7 +201,9 @@
)
assertThat(offsetConsumed).isEqualTo(Offset.Zero)
- assertThat(isStarted).isEqualTo(true)
+ // Returning 0 offset will immediately stop the connection
+ assertThat(wasStarted).isEqualTo(true)
+ assertThat(isStarted).isEqualTo(false)
}
@Test
diff --git a/packages/SystemUI/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/res/values-land/config.xml b/packages/SystemUI/res/values-land/config.xml
index b5efeb5..5d5b955 100644
--- a/packages/SystemUI/res/values-land/config.xml
+++ b/packages/SystemUI/res/values-land/config.xml
@@ -25,6 +25,12 @@
<integer name="quick_settings_num_columns">4</integer>
+ <!-- The number of rows in the paginated grid QuickSettings -->
+ <integer name="quick_settings_paginated_grid_num_rows">2</integer>
+
+ <!-- The number of rows in the paginated grid QuickQuickSettings -->
+ <integer name="quick_qs_paginated_grid_num_rows">1</integer>
+
<!-- The number of columns in the infinite grid QuickSettings -->
<integer name="quick_settings_infinite_grid_num_columns">8</integer>
diff --git a/packages/SystemUI/res/values-sw600dp-land/config.xml b/packages/SystemUI/res/values-sw600dp-land/config.xml
index fc6d20e..c661846 100644
--- a/packages/SystemUI/res/values-sw600dp-land/config.xml
+++ b/packages/SystemUI/res/values-sw600dp-land/config.xml
@@ -27,6 +27,12 @@
<!-- Whether to use the split 2-column notification shade -->
<bool name="config_use_split_notification_shade">true</bool>
+ <!-- The number of rows in the paginated grid QuickSettings -->
+ <integer name="quick_settings_paginated_grid_num_rows">3</integer>
+
+ <!-- The number of rows in the paginated grid QuickQuickSettings -->
+ <integer name="quick_qs_paginated_grid_num_rows">2</integer>
+
<!-- The number of columns in the QuickSettings -->
<integer name="quick_settings_num_columns">2</integer>
diff --git a/packages/SystemUI/res/values-sw600dp-port/config.xml b/packages/SystemUI/res/values-sw600dp-port/config.xml
index 7daad1a..f556b97 100644
--- a/packages/SystemUI/res/values-sw600dp-port/config.xml
+++ b/packages/SystemUI/res/values-sw600dp-port/config.xml
@@ -21,6 +21,12 @@
<!-- The maximum number of rows in the QuickSettings -->
<integer name="quick_settings_max_rows">3</integer>
+ <!-- The number of rows in the paginated grid QuickSettings -->
+ <integer name="quick_settings_paginated_grid_num_rows">3</integer>
+
+ <!-- The number of rows in the paginated grid QuickQuickSettings -->
+ <integer name="quick_qs_paginated_grid_num_rows">2</integer>
+
<!-- The number of columns in the QuickSettings -->
<integer name="quick_settings_num_columns">3</integer>
diff --git a/packages/SystemUI/res/values/config.xml b/packages/SystemUI/res/values/config.xml
index 6f94f9e..16a8bc5 100644
--- a/packages/SystemUI/res/values/config.xml
+++ b/packages/SystemUI/res/values/config.xml
@@ -70,6 +70,12 @@
<!-- The number of rows in the QuickSettings -->
<integer name="quick_settings_max_rows">4</integer>
+ <!-- The number of rows in the paginated grid QuickSettings -->
+ <integer name="quick_settings_paginated_grid_num_rows">4</integer>
+
+ <!-- The number of rows in the paginated grid QuickQuickSettings -->
+ <integer name="quick_qs_paginated_grid_num_rows">2</integer>
+
<!-- The number of columns in the infinite grid QuickSettings -->
<integer name="quick_settings_infinite_grid_num_columns">4</integer>
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/qs/panels/data/repository/PaginatedGridRepository.kt b/packages/SystemUI/src/com/android/systemui/qs/panels/data/repository/PaginatedGridRepository.kt
index 26b2e2b..424be90 100644
--- a/packages/SystemUI/src/com/android/systemui/qs/panels/data/repository/PaginatedGridRepository.kt
+++ b/packages/SystemUI/src/com/android/systemui/qs/panels/data/repository/PaginatedGridRepository.kt
@@ -38,6 +38,6 @@
) {
val rows =
configurationRepository.onConfigurationChange.emitOnStart().map {
- resources.getInteger(R.integer.quick_settings_max_rows)
+ resources.getInteger(R.integer.quick_settings_paginated_grid_num_rows)
}
}
diff --git a/packages/SystemUI/src/com/android/systemui/qs/panels/data/repository/QuickQuickSettingsRowRepository.kt b/packages/SystemUI/src/com/android/systemui/qs/panels/data/repository/QuickQuickSettingsRowRepository.kt
index f7c71ce..ee0cfb3 100644
--- a/packages/SystemUI/src/com/android/systemui/qs/panels/data/repository/QuickQuickSettingsRowRepository.kt
+++ b/packages/SystemUI/src/com/android/systemui/qs/panels/data/repository/QuickQuickSettingsRowRepository.kt
@@ -34,6 +34,6 @@
) {
val rows =
configurationRepository.onConfigurationChange.emitOnStart().map {
- resources.getInteger(R.integer.quick_qs_panel_max_rows)
+ resources.getInteger(R.integer.quick_qs_paginated_grid_num_rows)
}
}
diff --git a/packages/SystemUI/src/com/android/systemui/shade/NotificationPanelViewController.java b/packages/SystemUI/src/com/android/systemui/shade/NotificationPanelViewController.java
index 757e37e..d652d5b 100644
--- a/packages/SystemUI/src/com/android/systemui/shade/NotificationPanelViewController.java
+++ b/packages/SystemUI/src/com/android/systemui/shade/NotificationPanelViewController.java
@@ -123,7 +123,6 @@
import com.android.systemui.dagger.qualifiers.DisplayId;
import com.android.systemui.dagger.qualifiers.Main;
import com.android.systemui.deviceentry.domain.interactor.DeviceEntryFaceAuthInteractor;
-import com.android.systemui.deviceentry.shared.DeviceEntryUdfpsRefactor;
import com.android.systemui.doze.DozeLog;
import com.android.systemui.dump.DumpManager;
import com.android.systemui.dump.DumpsysTableLogger;
@@ -1859,16 +1858,11 @@
/** Returns space between top of lock icon and bottom of NotificationStackScrollLayout. */
private float getLockIconPadding() {
float lockIconPadding = 0f;
- if (DeviceEntryUdfpsRefactor.isEnabled()) {
- View deviceEntryIconView = mKeyguardViewConfigurator.getKeyguardRootView()
- .findViewById(R.id.device_entry_icon_view);
- if (deviceEntryIconView != null) {
- lockIconPadding = mNotificationStackScrollLayoutController.getBottom()
- - deviceEntryIconView.getTop();
- }
- } else if (mLockIconViewController.getTop() != 0f) {
+ View deviceEntryIconView = mKeyguardViewConfigurator.getKeyguardRootView()
+ .findViewById(R.id.device_entry_icon_view);
+ if (deviceEntryIconView != null) {
lockIconPadding = mNotificationStackScrollLayoutController.getBottom()
- - mLockIconViewController.getTop();
+ - deviceEntryIconView.getTop();
}
return lockIconPadding;
}
@@ -5059,8 +5053,7 @@
return false;
}
- if (DeviceEntryUdfpsRefactor.isEnabled()
- && mAlternateBouncerInteractor.isVisibleState()) {
+ if (mAlternateBouncerInteractor.isVisibleState()) {
// never send touches to shade if the alternate bouncer is showing
return false;
}
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/notification/row/NotifRemoteViewsFactoryContainer.kt b/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/NotifRemoteViewsFactoryContainer.kt
index b90aa10..71f9c07 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/NotifRemoteViewsFactoryContainer.kt
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/NotifRemoteViewsFactoryContainer.kt
@@ -19,6 +19,7 @@
import android.widget.flags.Flags.notifLinearlayoutOptimized
import com.android.systemui.flags.FeatureFlags
import com.android.systemui.flags.Flags
+import com.android.systemui.statusbar.notification.row.icon.NotificationRowIconViewInflaterFactory
import com.android.systemui.statusbar.notification.shared.NotificationViewFlipperPausing
import javax.inject.Inject
import javax.inject.Provider
@@ -35,6 +36,7 @@
bigPictureLayoutInflaterFactory: BigPictureLayoutInflaterFactory,
optimizedLinearLayoutFactory: NotificationOptimizedLinearLayoutFactory,
notificationViewFlipperFactory: Provider<NotificationViewFlipperFactory>,
+ notificationRowIconViewInflaterFactory: NotificationRowIconViewInflaterFactory,
) : NotifRemoteViewsFactoryContainer {
override val factories: Set<NotifRemoteViewsFactory> = buildSet {
add(precomputedTextViewFactory)
@@ -47,5 +49,8 @@
if (NotificationViewFlipperPausing.isEnabled) {
add(notificationViewFlipperFactory.get())
}
+ if (android.app.Flags.notificationsRedesignAppIcons()) {
+ add(notificationRowIconViewInflaterFactory)
+ }
}
}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/NotificationContentInflater.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/NotificationContentInflater.java
index e10fd8f..41abac1 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/NotificationContentInflater.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/NotificationContentInflater.java
@@ -342,7 +342,7 @@
* Cancel any pending content view frees from {@link #freeNotificationView} for the provided
* content views.
*
- * @param row top level notification row containing the content views
+ * @param row top level notification row containing the content views
* @param contentViews content views to cancel pending frees on
*/
private void cancelContentViewFrees(
@@ -478,6 +478,13 @@
notifLayoutInflaterFactoryProvider.provide(row, FLAG_CONTENT_VIEW_HEADS_UP));
setRemoteViewsInflaterFactory(result.newPublicView,
notifLayoutInflaterFactoryProvider.provide(row, FLAG_CONTENT_VIEW_PUBLIC));
+ if (android.app.Flags.notificationsRedesignAppIcons()) {
+ setRemoteViewsInflaterFactory(result.mNewGroupHeaderView,
+ notifLayoutInflaterFactoryProvider.provide(row, FLAG_GROUP_SUMMARY_HEADER));
+ setRemoteViewsInflaterFactory(result.mNewMinimizedGroupHeaderView,
+ notifLayoutInflaterFactoryProvider.provide(row,
+ FLAG_LOW_PRIORITY_GROUP_SUMMARY_HEADER));
+ }
}
private static void setRemoteViewsInflaterFactory(RemoteViews remoteViews,
@@ -516,6 +523,7 @@
logger.logAsyncTaskProgress(entry, "contracted view applied");
result.inflatedContentView = v;
}
+
@Override
public RemoteViews getRemoteView() {
return result.newContentView;
@@ -1406,6 +1414,7 @@
@VisibleForTesting
abstract static class ApplyCallback {
public abstract void setResultView(View v);
+
public abstract RemoteViews getRemoteView();
}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/NotificationRowModule.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/NotificationRowModule.java
index 84f2f66..43ade5c 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/NotificationRowModule.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/NotificationRowModule.java
@@ -17,6 +17,7 @@
package com.android.systemui.statusbar.notification.row;
import com.android.systemui.dagger.SysUISingleton;
+import com.android.systemui.statusbar.notification.row.icon.AppIconProviderModule;
import com.android.systemui.statusbar.notification.row.shared.NotificationRowContentBinderRefactor;
import dagger.Binds;
@@ -28,7 +29,7 @@
/**
* Dagger Module containing notification row and view inflation implementations.
*/
-@Module
+@Module(includes = {AppIconProviderModule.class})
public abstract class NotificationRowModule {
/**
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/icon/AppIconProvider.kt b/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/icon/AppIconProvider.kt
new file mode 100644
index 0000000..24b5cf1a
--- /dev/null
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/icon/AppIconProvider.kt
@@ -0,0 +1,86 @@
+/*
+ * Copyright (C) 2024 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.systemui.statusbar.notification.row.icon
+
+import android.app.ActivityManager
+import android.app.Flags
+import android.content.Context
+import android.content.pm.PackageManager.NameNotFoundException
+import android.graphics.Color
+import android.graphics.drawable.BitmapDrawable
+import android.graphics.drawable.ColorDrawable
+import android.graphics.drawable.Drawable
+import android.util.Log
+import com.android.internal.R
+import com.android.launcher3.icons.BaseIconFactory
+import com.android.systemui.dagger.SysUISingleton
+import dagger.Module
+import dagger.Provides
+import javax.inject.Inject
+import javax.inject.Provider
+
+/** A provider used to cache and fetch app icons used by notifications. */
+interface AppIconProvider {
+ @Throws(NameNotFoundException::class)
+ fun getOrFetchAppIcon(packageName: String, context: Context): Drawable
+}
+
+@SysUISingleton
+class AppIconProviderImpl @Inject constructor(private val sysuiContext: Context) : AppIconProvider {
+ private val iconFactory: BaseIconFactory
+ get() {
+ val isLowRam = ActivityManager.isLowRamDeviceStatic()
+ val res = sysuiContext.resources
+ val iconSize: Int =
+ res.getDimensionPixelSize(
+ if (isLowRam) R.dimen.notification_small_icon_size_low_ram
+ else R.dimen.notification_small_icon_size
+ )
+ return BaseIconFactory(sysuiContext, res.configuration.densityDpi, iconSize)
+ }
+
+ override fun getOrFetchAppIcon(packageName: String, context: Context): Drawable {
+ val icon = context.packageManager.getApplicationIcon(packageName)
+ return BitmapDrawable(
+ context.resources,
+ iconFactory.createScaledBitmap(icon, BaseIconFactory.MODE_HARDWARE),
+ )
+ }
+}
+
+class NoOpIconProvider : AppIconProvider {
+ companion object {
+ const val TAG = "NoOpIconProvider"
+ }
+
+ override fun getOrFetchAppIcon(packageName: String, context: Context): Drawable {
+ Log.wtf(TAG, "NoOpIconProvider should not be used anywhere.")
+ return ColorDrawable(Color.WHITE)
+ }
+}
+
+@Module
+class AppIconProviderModule {
+ @Provides
+ @SysUISingleton
+ fun provideImpl(realImpl: Provider<AppIconProviderImpl>): AppIconProvider =
+ if (Flags.notificationsRedesignAppIcons()) {
+ realImpl.get()
+ } else {
+ NoOpIconProvider()
+ }
+}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/icon/NotificationRowIconViewInflaterFactory.kt b/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/icon/NotificationRowIconViewInflaterFactory.kt
new file mode 100644
index 0000000..2522e58
--- /dev/null
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/icon/NotificationRowIconViewInflaterFactory.kt
@@ -0,0 +1,64 @@
+/*
+ * Copyright (C) 2024 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.systemui.statusbar.notification.row.icon
+
+import android.content.Context
+import android.graphics.drawable.Drawable
+import android.util.AttributeSet
+import android.view.View
+import com.android.internal.widget.NotificationRowIconView
+import com.android.systemui.statusbar.notification.row.ExpandableNotificationRow
+import com.android.systemui.statusbar.notification.row.NotifRemoteViewsFactory
+import com.android.systemui.statusbar.notification.row.NotificationRowContentBinder
+import javax.inject.Inject
+
+/**
+ * A factory which owns the construction of any NotificationRowIconView inside of Notifications in
+ * SystemUI. This allows overriding the small icon with the app icon in notifications.
+ */
+class NotificationRowIconViewInflaterFactory
+@Inject
+constructor(private val appIconProvider: AppIconProvider) : NotifRemoteViewsFactory {
+ override fun instantiate(
+ row: ExpandableNotificationRow,
+ @NotificationRowContentBinder.InflationFlag layoutType: Int,
+ parent: View?,
+ name: String,
+ context: Context,
+ attrs: AttributeSet,
+ ): View? {
+ return when (name) {
+ NotificationRowIconView::class.java.name ->
+ NotificationRowIconView(context, attrs).also { view ->
+ val sbn = row.entry.sbn
+ view.setIconProvider(
+ object : NotificationRowIconView.NotificationIconProvider {
+ override fun shouldShowAppIcon(): Boolean {
+ // TODO(b/371174789): implement me
+ return true
+ }
+
+ override fun getAppIcon(): Drawable {
+ return appIconProvider.getOrFetchAppIcon(sbn.packageName, context)
+ }
+ }
+ )
+ }
+ else -> null
+ }
+ }
+}
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..3d7cd9c 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/CentralSurfacesImpl.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/CentralSurfacesImpl.java
@@ -128,7 +128,6 @@
import com.android.systemui.dagger.qualifiers.UiBackground;
import com.android.systemui.demomode.DemoMode;
import com.android.systemui.demomode.DemoModeController;
-import com.android.systemui.deviceentry.shared.DeviceEntryUdfpsRefactor;
import com.android.systemui.emergency.EmergencyGesture;
import com.android.systemui.emergency.EmergencyGestureModule.EmergencyGestureIntentFactory;
import com.android.systemui.flags.FeatureFlags;
@@ -226,7 +225,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 +371,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 +609,7 @@
LightBarController lightBarController,
AutoHideController autoHideController,
StatusBarInitializer statusBarInitializer,
- StatusBarWindowController statusBarWindowController,
+ StatusBarWindowControllerStore statusBarWindowControllerStore,
StatusBarWindowStateController statusBarWindowStateController,
StatusBarModeRepositoryStore statusBarModeRepository,
KeyguardUpdateMonitor keyguardUpdateMonitor,
@@ -716,7 +715,7 @@
mLightBarController = lightBarController;
mAutoHideController = autoHideController;
mStatusBarInitializer = statusBarInitializer;
- mStatusBarWindowController = statusBarWindowController;
+ mStatusBarWindowControllerStore = statusBarWindowControllerStore;
mStatusBarModeRepository = statusBarModeRepository;
mKeyguardUpdateMonitor = keyguardUpdateMonitor;
mPulseExpansionHandler = pulseExpansionHandler;
@@ -1894,7 +1893,7 @@
// When the StatusBarSimpleFragment flag is enabled, this logic will be done in
// StatusBarOrchestrator
if (!StatusBarSimpleFragment.isEnabled()) {
- mStatusBarWindowController.attach();
+ mStatusBarWindowControllerStore.getDefaultDisplay().attach();
}
}
@@ -2825,23 +2824,13 @@
mScrimController.setExpansionAffectsAlpha(!unlocking);
if (mAlternateBouncerInteractor.isVisibleState()) {
- if (DeviceEntryUdfpsRefactor.isEnabled()) {
- if ((!mKeyguardStateController.isOccluded() || mShadeSurface.isPanelExpanded())
- && (mState == StatusBarState.SHADE || mState == StatusBarState.SHADE_LOCKED
- || mTransitionToFullShadeProgress > 0f)) {
- // Assume scrim state for shade is already correct and do nothing
- } else {
- // Safeguard which prevents the scrim from being stuck in the wrong state
- mScrimController.legacyTransitionTo(ScrimState.KEYGUARD);
- }
+ if ((!mKeyguardStateController.isOccluded() || mShadeSurface.isPanelExpanded())
+ && (mState == StatusBarState.SHADE || mState == StatusBarState.SHADE_LOCKED
+ || mTransitionToFullShadeProgress > 0f)) {
+ // Assume scrim state for shade is already correct and do nothing
} else {
- if ((!mKeyguardStateController.isOccluded() || mShadeSurface.isPanelExpanded())
- && (mState == StatusBarState.SHADE || mState == StatusBarState.SHADE_LOCKED
- || mTransitionToFullShadeProgress > 0f)) {
- mScrimController.legacyTransitionTo(ScrimState.AUTH_SCRIMMED_SHADE);
- } else {
- mScrimController.legacyTransitionTo(ScrimState.AUTH_SCRIMMED);
- }
+ // Safeguard which prevents the scrim from being stuck in the wrong state
+ mScrimController.legacyTransitionTo(ScrimState.KEYGUARD);
}
// This will cancel the keyguardFadingAway animation if it is running. We need to do
// this as otherwise it can remain pending and leave keyguard in a weird state.
@@ -3168,12 +3157,8 @@
public void onDozeAmountChanged(float linear, float eased) {
if (!lightRevealMigration()
&& !(mLightRevealScrim.getRevealEffect() instanceof CircleReveal)) {
- if (DeviceEntryUdfpsRefactor.isEnabled()) {
- // If wakeAndUnlocking, this is handled in AuthRippleInteractor
- if (!mBiometricUnlockController.isWakeAndUnlock()) {
- mLightRevealScrim.setRevealAmount(1f - linear);
- }
- } else {
+ // If wakeAndUnlocking, this is handled in AuthRippleInteractor
+ if (!mBiometricUnlockController.isWakeAndUnlock()) {
mLightRevealScrim.setRevealAmount(1f - linear);
}
}
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..44d81a7 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
@@ -21,7 +21,6 @@
import static android.provider.Settings.Global.HEADS_UP_NOTIFICATIONS_ENABLED;
import static android.provider.Settings.Global.HEADS_UP_ON;
-import static com.android.systemui.Flags.FLAG_DEVICE_ENTRY_UDFPS_REFACTOR;
import static com.android.systemui.Flags.FLAG_KEYBOARD_SHORTCUT_HELPER_REWRITE;
import static com.android.systemui.Flags.FLAG_LIGHT_REVEAL_MIGRATION;
import static com.android.systemui.flags.Flags.SHORTCUT_LIST_SEARCH_LAYOUT;
@@ -170,6 +169,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 +194,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 +293,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 +385,9 @@
when(mBubbles.canShowBubbleNotification()).thenReturn(true);
+ when(mStatusBarWindowControllerStore.getDefaultDisplay())
+ .thenReturn(mStatusBarWindowController);
+
mVisualInterruptionDecisionProvider =
VisualInterruptionDecisionProviderTestUtil.INSTANCE.createProviderByFlag(
mAmbientDisplayConfiguration,
@@ -465,7 +470,7 @@
mKeyguardStateController,
mStatusBarStateController,
mStatusBarKeyguardViewManager,
- mStatusBarWindowController,
+ mStatusBarWindowControllerStore,
mDeviceProvisionedController,
mNotificationShadeWindowController,
0,
@@ -507,10 +512,11 @@
mLightBarController,
mAutoHideController,
new StatusBarInitializerImpl(
- mStatusBarWindowController,
+ mContext.getDisplayId(),
+ mStatusBarWindowControllerStore,
mCollapsedStatusBarFragmentProvider,
emptySet()),
- mStatusBarWindowController,
+ mStatusBarWindowControllerStore,
mStatusBarWindowStateController,
new FakeStatusBarModeRepository(),
mKeyguardUpdateMonitor,
@@ -852,34 +858,6 @@
}
@Test
- @DisableFlags(FLAG_DEVICE_ENTRY_UDFPS_REFACTOR)
- public void testSetDozingNotUnlocking_transitionToAuthScrimmed_cancelKeyguardFadingAway() {
- when(mAlternateBouncerInteractor.isVisibleState()).thenReturn(true);
- when(mKeyguardStateController.isKeyguardFadingAway()).thenReturn(true);
-
- mCentralSurfaces.updateScrimController();
-
- verify(mScrimController).legacyTransitionTo(eq(ScrimState.AUTH_SCRIMMED_SHADE));
- verify(mStatusBarKeyguardViewManager).onKeyguardFadedAway();
- }
-
- @Test
- @DisableFlags(FLAG_DEVICE_ENTRY_UDFPS_REFACTOR)
- public void testOccludingQSNotExpanded_flagOff_transitionToAuthScrimmed() {
- when(mAlternateBouncerInteractor.isVisibleState()).thenReturn(true);
-
- // GIVEN device occluded and panel is NOT expanded
- mCentralSurfaces.setBarStateForTest(SHADE); // occluding on LS has StatusBarState = SHADE
- when(mKeyguardStateController.isOccluded()).thenReturn(true);
- when(mNotificationPanelViewController.isPanelExpanded()).thenReturn(false);
-
- mCentralSurfaces.updateScrimController();
-
- verify(mScrimController).legacyTransitionTo(eq(ScrimState.AUTH_SCRIMMED));
- }
-
- @Test
- @EnableFlags(FLAG_DEVICE_ENTRY_UDFPS_REFACTOR)
public void testNotOccluding_QSNotExpanded_flagOn_doesNotTransitionScrimState() {
when(mAlternateBouncerInteractor.isVisibleState()).thenReturn(true);
@@ -895,7 +873,6 @@
}
@Test
- @EnableFlags(FLAG_DEVICE_ENTRY_UDFPS_REFACTOR)
public void testNotOccluding_QSExpanded_flagOn_doesTransitionScrimStateToKeyguard() {
when(mAlternateBouncerInteractor.isVisibleState()).thenReturn(true);
@@ -911,21 +888,6 @@
}
@Test
- @DisableFlags(FLAG_DEVICE_ENTRY_UDFPS_REFACTOR)
- public void testOccludingQSExpanded_transitionToAuthScrimmedShade() {
- when(mAlternateBouncerInteractor.isVisibleState()).thenReturn(true);
-
- // GIVEN device occluded and qs IS expanded
- mCentralSurfaces.setBarStateForTest(SHADE); // occluding on LS has StatusBarState = SHADE
- when(mKeyguardStateController.isOccluded()).thenReturn(true);
- when(mNotificationPanelViewController.isPanelExpanded()).thenReturn(true);
-
- mCentralSurfaces.updateScrimController();
-
- verify(mScrimController).legacyTransitionTo(eq(ScrimState.AUTH_SCRIMMED_SHADE));
- }
-
- @Test
public void testEnteringGlanceableHub_updatesScrim() {
// Transition to the glanceable hub.
mKosmos.getCommunalRepository()
@@ -1149,6 +1111,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/notification/row/ExpandableNotificationRowBuilder.kt b/packages/SystemUI/tests/utils/src/com/android/systemui/statusbar/notification/row/ExpandableNotificationRowBuilder.kt
index fc4f05d..a7a6195 100644
--- a/packages/SystemUI/tests/utils/src/com/android/systemui/statusbar/notification/row/ExpandableNotificationRowBuilder.kt
+++ b/packages/SystemUI/tests/utils/src/com/android/systemui/statusbar/notification/row/ExpandableNotificationRowBuilder.kt
@@ -69,6 +69,8 @@
import com.android.systemui.statusbar.notification.row.NotificationRowContentBinder.FLAG_CONTENT_VIEW_EXPANDED
import com.android.systemui.statusbar.notification.row.NotificationRowContentBinder.FLAG_CONTENT_VIEW_HEADS_UP
import com.android.systemui.statusbar.notification.row.NotificationRowContentBinder.InflationFlag
+import com.android.systemui.statusbar.notification.row.icon.AppIconProviderImpl
+import com.android.systemui.statusbar.notification.row.icon.NotificationRowIconViewInflaterFactory
import com.android.systemui.statusbar.notification.row.shared.NotificationRowContentBinderRefactor
import com.android.systemui.statusbar.notification.stack.NotificationChildrenContainerLogger
import com.android.systemui.statusbar.phone.KeyguardBypassController
@@ -99,7 +101,7 @@
class ExpandableNotificationRowBuilder(
private val context: Context,
dependency: TestableDependency,
- private val featureFlags: FakeFeatureFlagsClassic = FakeFeatureFlagsClassic()
+ private val featureFlags: FakeFeatureFlagsClassic = FakeFeatureFlagsClassic(),
) {
private val mMockLogger: ExpandableNotificationRowLogger
@@ -161,21 +163,21 @@
DeviceConfig.NAMESPACE_SYSTEMUI,
SystemUiDeviceConfigFlags.SSIN_SHOW_IN_HEADS_UP,
"true",
- true
+ true,
)
setProperty(
DeviceConfig.NAMESPACE_SYSTEMUI,
SystemUiDeviceConfigFlags.SSIN_ENABLED,
"true",
- true
+ true,
)
setProperty(
DeviceConfig.NAMESPACE_SYSTEMUI,
SystemUiDeviceConfigFlags.SSIN_REQUIRES_TARGETING_P,
"false",
- true
+ true,
)
- }
+ },
)
val remoteViewsFactories = getNotifRemoteViewsFactoryContainer(featureFlags)
val remoteInputManager = Mockito.mock(NotificationRemoteInputManager::class.java, STUB_ONLY)
@@ -192,21 +194,21 @@
Mockito.mock(KeyguardDismissUtil::class.java, STUB_ONLY),
remoteInputManager = remoteInputManager,
smartReplyController = mSmartReplyController,
- context = context
+ context = context,
),
smartActionsInflater =
SmartActionInflaterImpl(
constants = mSmartReplyConstants,
activityStarter = Mockito.mock(ActivityStarter::class.java, STUB_ONLY),
smartReplyController = mSmartReplyController,
- headsUpManager = mHeadsUpManager
- )
+ headsUpManager = mHeadsUpManager,
+ ),
)
val notifLayoutInflaterFactoryProvider =
object : NotifLayoutInflaterFactory.Provider {
override fun provide(
row: ExpandableNotificationRow,
- layoutType: Int
+ layoutType: Int,
): NotifLayoutInflaterFactory =
NotifLayoutInflaterFactory(row, layoutType, remoteViewsFactories)
}
@@ -270,14 +272,14 @@
whenever(
mOnUserInteractionCallback.registerFutureDismissal(
ArgumentMatchers.any(),
- ArgumentMatchers.anyInt()
+ ArgumentMatchers.anyInt(),
)
)
.thenReturn(mFutureDismissalRunnable)
}
private fun getNotifRemoteViewsFactoryContainer(
- featureFlags: FeatureFlags,
+ featureFlags: FeatureFlags
): NotifRemoteViewsFactoryContainer {
return NotifRemoteViewsFactoryContainerImpl(
featureFlags,
@@ -285,6 +287,7 @@
BigPictureLayoutInflaterFactory(),
NotificationOptimizedLinearLayoutFactory(),
{ Mockito.mock(NotificationViewFlipperFactory::class.java) },
+ NotificationRowIconViewInflaterFactory(AppIconProviderImpl(context)),
)
}
@@ -293,7 +296,7 @@
NotificationChannel(
notification.channelId,
notification.channelId,
- NotificationManager.IMPORTANCE_DEFAULT
+ NotificationManager.IMPORTANCE_DEFAULT,
)
channel.isBlockable = true
val entry =
@@ -321,7 +324,7 @@
private fun generateRow(
entry: NotificationEntry,
- @InflationFlag extraInflationFlags: Int
+ @InflationFlag extraInflationFlags: Int,
): ExpandableNotificationRow {
// NOTE: This flag is read when the ExpandableNotificationRow is inflated, so it needs to be
// set, but we do not want to override an existing value that is needed by a specific test.
@@ -329,7 +332,7 @@
val rowInflaterTask =
RowInflaterTask(
mFakeSystemClock,
- Mockito.mock(RowInflaterTaskLogger::class.java, STUB_ONLY)
+ Mockito.mock(RowInflaterTaskLogger::class.java, STUB_ONLY),
)
val row = rowInflaterTask.inflateSynchronously(context, null, entry)
@@ -364,7 +367,7 @@
mSmartReplyController,
featureFlags,
Mockito.mock(IStatusBarService::class.java, STUB_ONLY),
- Mockito.mock(UiEventLogger::class.java, STUB_ONLY)
+ Mockito.mock(UiEventLogger::class.java, STUB_ONLY),
)
row.setAboveShelfChangedListener { aboveShelf: Boolean -> }
mBindStage.getStageParams(entry).requireContentViews(extraInflationFlags)
diff --git a/packages/SystemUI/tests/utils/src/com/android/systemui/statusbar/notification/row/icon/AppIconProviderKosmos.kt b/packages/SystemUI/tests/utils/src/com/android/systemui/statusbar/notification/row/icon/AppIconProviderKosmos.kt
new file mode 100644
index 0000000..08c6bba
--- /dev/null
+++ b/packages/SystemUI/tests/utils/src/com/android/systemui/statusbar/notification/row/icon/AppIconProviderKosmos.kt
@@ -0,0 +1,22 @@
+/*
+ * Copyright (C) 2024 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.systemui.statusbar.notification.row.icon
+
+import android.content.applicationContext
+import com.android.systemui.kosmos.Kosmos
+
+val Kosmos.appIconProvider by Kosmos.Fixture { AppIconProviderImpl(applicationContext) }
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/contentsuggestions/java/com/android/server/contentsuggestions/ContentSuggestionsManagerService.java b/services/contentsuggestions/java/com/android/server/contentsuggestions/ContentSuggestionsManagerService.java
index 57c643b..a7aab49 100644
--- a/services/contentsuggestions/java/com/android/server/contentsuggestions/ContentSuggestionsManagerService.java
+++ b/services/contentsuggestions/java/com/android/server/contentsuggestions/ContentSuggestionsManagerService.java
@@ -160,11 +160,13 @@
HardwareBuffer snapshotBuffer = null;
int colorSpaceId = 0;
+ TaskSnapshot snapshot = null;
// Skip taking TaskSnapshot when bitmap is provided.
if (!imageContextRequestExtras.containsKey(ContentSuggestionsManager.EXTRA_BITMAP)) {
// Can block, so call before acquiring the lock.
- TaskSnapshot snapshot =
- mActivityTaskManagerInternal.getTaskSnapshotBlocking(taskId, false);
+ snapshot = mActivityTaskManagerInternal.getTaskSnapshotBlocking(
+ taskId, false /* isLowResolution */,
+ TaskSnapshot.REFERENCE_CONTENT_SUGGESTION);
if (snapshot != null) {
snapshotBuffer = snapshot.getHardwareBuffer();
ColorSpace colorSpace = snapshot.getColorSpace();
@@ -185,6 +187,9 @@
}
}
}
+ if (snapshot != null) {
+ snapshot.removeReference(TaskSnapshot.REFERENCE_CONTENT_SUGGESTION);
+ }
}
@Override
diff --git a/services/core/java/com/android/server/BinaryTransparencyService.java b/services/core/java/com/android/server/BinaryTransparencyService.java
index 05d07ae..485bf31 100644
--- a/services/core/java/com/android/server/BinaryTransparencyService.java
+++ b/services/core/java/com/android/server/BinaryTransparencyService.java
@@ -1523,7 +1523,7 @@
@Override
public void onApexStaged(ApexStagedEvent event) throws RemoteException {
Slog.d(TAG, "A new APEX has been staged for update. There are currently "
- + event.stagedApexModuleNames.length + " APEX(s) staged for update. "
+ + event.stagedApexInfos.length + " APEX(s) staged for update. "
+ "Scheduling measurement...");
UpdateMeasurementsJobService.scheduleBinaryMeasurements(mContext,
BinaryTransparencyService.this);
diff --git a/services/core/java/com/android/server/UiModeManagerService.java b/services/core/java/com/android/server/UiModeManagerService.java
index f8857d3..d13dd2f 100644
--- a/services/core/java/com/android/server/UiModeManagerService.java
+++ b/services/core/java/com/android/server/UiModeManagerService.java
@@ -443,6 +443,11 @@
mDreamsDisabledByAmbientModeSuppression = disabledByAmbientModeSuppression;
}
+ @VisibleForTesting
+ void setCurrentUser(int currentUserId) {
+ mCurrentUser = currentUserId;
+ }
+
@Override
public void onUserSwitching(@Nullable TargetUser from, @NonNull TargetUser to) {
mCurrentUser = to.getUserIdentifier();
@@ -864,9 +869,9 @@
throw new IllegalArgumentException("Unknown mode: " + mode);
}
- final int user = UserHandle.getCallingUserId();
- enforceCurrentUserIfVisibleBackgroundEnabled(user);
+ enforceCurrentUserIfVisibleBackgroundEnabled(mCurrentUser);
+ final int user = UserHandle.getCallingUserId();
final long ident = Binder.clearCallingIdentity();
try {
synchronized (mLock) {
@@ -929,7 +934,7 @@
@AttentionModeThemeOverlayType int attentionModeThemeOverlayType) {
setAttentionModeThemeOverlay_enforcePermission();
- enforceCurrentUserIfVisibleBackgroundEnabled(UserHandle.getCallingUserId());
+ enforceCurrentUserIfVisibleBackgroundEnabled(mCurrentUser);
synchronized (mLock) {
if (mAttentionModeThemeOverlay != attentionModeThemeOverlayType) {
@@ -1020,16 +1025,16 @@
return false;
}
final int user = Binder.getCallingUserHandle().getIdentifier();
- enforceCurrentUserIfVisibleBackgroundEnabled(user);
-
if (user != mCurrentUser && getContext().checkCallingOrSelfPermission(
android.Manifest.permission.INTERACT_ACROSS_USERS)
!= PackageManager.PERMISSION_GRANTED) {
Slog.e(TAG, "Target user is not current user,"
+ " INTERACT_ACROSS_USERS permission is required");
return false;
-
}
+
+ enforceCurrentUserIfVisibleBackgroundEnabled(mCurrentUser);
+
// Store the last requested bedtime night mode state so that we don't need to notify
// anyone if the user decides to switch to the night mode to bedtime.
if (modeCustomType == MODE_NIGHT_CUSTOM_TYPE_BEDTIME) {
@@ -1078,9 +1083,10 @@
Slog.e(TAG, "Set custom time start, requires MODIFY_DAY_NIGHT_MODE permission");
return;
}
- final int user = UserHandle.getCallingUserId();
- enforceCurrentUserIfVisibleBackgroundEnabled(user);
+ enforceCurrentUserIfVisibleBackgroundEnabled(mCurrentUser);
+
+ final int user = UserHandle.getCallingUserId();
final long ident = Binder.clearCallingIdentity();
try {
LocalTime newTime = LocalTime.ofNanoOfDay(time * 1000);
@@ -1108,9 +1114,10 @@
Slog.e(TAG, "Set custom time end, requires MODIFY_DAY_NIGHT_MODE permission");
return;
}
- final int user = UserHandle.getCallingUserId();
- enforceCurrentUserIfVisibleBackgroundEnabled(user);
+ enforceCurrentUserIfVisibleBackgroundEnabled(mCurrentUser);
+
+ final int user = UserHandle.getCallingUserId();
final long ident = Binder.clearCallingIdentity();
try {
LocalTime newTime = LocalTime.ofNanoOfDay(time * 1000);
@@ -1131,7 +1138,7 @@
assertLegit(callingPackage);
assertSingleProjectionType(projectionType);
enforceProjectionTypePermissions(projectionType);
- enforceCurrentUserIfVisibleBackgroundEnabled(getCallingUserId());
+ enforceCurrentUserIfVisibleBackgroundEnabled(mCurrentUser);
synchronized (mLock) {
if (mProjectionHolders == null) {
@@ -1177,7 +1184,7 @@
assertLegit(callingPackage);
assertSingleProjectionType(projectionType);
enforceProjectionTypePermissions(projectionType);
- enforceCurrentUserIfVisibleBackgroundEnabled(getCallingUserId());
+ enforceCurrentUserIfVisibleBackgroundEnabled(mCurrentUser);
return releaseProjectionUnchecked(projectionType, callingPackage);
}
@@ -1219,7 +1226,7 @@
return;
}
- enforceCurrentUserIfVisibleBackgroundEnabled(getCallingUserId());
+ enforceCurrentUserIfVisibleBackgroundEnabled(mCurrentUser);
synchronized (mLock) {
if (mProjectionListeners == null) {
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/am/ActivityManagerConstants.java b/services/core/java/com/android/server/am/ActivityManagerConstants.java
index f5a297b..65a2c18 100644
--- a/services/core/java/com/android/server/am/ActivityManagerConstants.java
+++ b/services/core/java/com/android/server/am/ActivityManagerConstants.java
@@ -246,7 +246,7 @@
static final int DEFAULT_MAX_SERVICE_CONNECTIONS_PER_PROCESS = 3000;
- private static final boolean DEFAULT_USE_TIERED_CACHED_ADJ = false;
+ private static final boolean DEFAULT_USE_TIERED_CACHED_ADJ = Flags.oomadjusterCachedAppTiers();
private static final long DEFAULT_TIERED_CACHED_ADJ_DECAY_TIME = 60 * 1000;
/**
diff --git a/services/core/java/com/android/server/am/flags.aconfig b/services/core/java/com/android/server/am/flags.aconfig
index adf0e64..d67fea0 100644
--- a/services/core/java/com/android/server/am/flags.aconfig
+++ b/services/core/java/com/android/server/am/flags.aconfig
@@ -225,3 +225,11 @@
description: "Migrate OomAdjuster pulled device state to a push model"
bug: "302575389"
}
+
+flag {
+ name: "oomadjuster_cached_app_tiers"
+ namespace: "system_performance"
+ is_fixed_read_only: true
+ description: "Assign cached oom_score_adj in tiers."
+ bug: "369893532"
+}
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/display/brightness/BrightnessReason.java b/services/core/java/com/android/server/display/brightness/BrightnessReason.java
index 9a0ee03..a4804e1 100644
--- a/services/core/java/com/android/server/display/brightness/BrightnessReason.java
+++ b/services/core/java/com/android/server/display/brightness/BrightnessReason.java
@@ -50,8 +50,10 @@
public static final int MODIFIER_THROTTLED = 0x8;
public static final int MODIFIER_MIN_LUX = 0x10;
public static final int MODIFIER_MIN_USER_SET_LOWER_BOUND = 0x20;
+ public static final int MODIFIER_STYLUS_UNDER_USE = 0x40;
public static final int MODIFIER_MASK = MODIFIER_DIMMED | MODIFIER_LOW_POWER | MODIFIER_HDR
- | MODIFIER_THROTTLED | MODIFIER_MIN_LUX | MODIFIER_MIN_USER_SET_LOWER_BOUND;
+ | MODIFIER_THROTTLED | MODIFIER_MIN_LUX | MODIFIER_MIN_USER_SET_LOWER_BOUND
+ | MODIFIER_STYLUS_UNDER_USE;
// ADJUSTMENT_*
// These things can happen at any point, even if the main brightness reason doesn't
@@ -158,6 +160,9 @@
if ((mModifier & MODIFIER_MIN_USER_SET_LOWER_BOUND) != 0) {
sb.append(" user_min_pref");
}
+ if ((mModifier & MODIFIER_STYLUS_UNDER_USE) != 0) {
+ sb.append(" stylus_under_use");
+ }
int strlen = sb.length();
if (sb.charAt(strlen - 1) == '[') {
sb.setLength(strlen - 2);
diff --git a/services/core/java/com/android/server/display/brightness/DisplayBrightnessController.java b/services/core/java/com/android/server/display/brightness/DisplayBrightnessController.java
index 71fdaf3..4bd9808 100644
--- a/services/core/java/com/android/server/display/brightness/DisplayBrightnessController.java
+++ b/services/core/java/com/android/server/display/brightness/DisplayBrightnessController.java
@@ -110,6 +110,9 @@
@VisibleForTesting
AutomaticBrightnessController mAutomaticBrightnessController;
+ // True if the stylus is being used
+ private boolean mIsStylusBeingUsed;
+
/**
* The constructor of DisplayBrightnessController.
*/
@@ -460,6 +463,8 @@
writer.println(" mScreenBrightnessDefault=" + mScreenBrightnessDefault);
writer.println(" mPersistBrightnessNitsForDefaultDisplay="
+ mPersistBrightnessNitsForDefaultDisplay);
+ writer.println(" mIsStylusBeingUsed="
+ + mIsStylusBeingUsed);
synchronized (mLock) {
writer.println(" mPendingScreenBrightness=" + mPendingScreenBrightness);
writer.println(" mCurrentScreenBrightness=" + mCurrentScreenBrightness);
@@ -505,7 +510,12 @@
* Notifies if the stylus is currently being used or not.
*/
public void setStylusBeingUsed(boolean isEnabled) {
- // Todo(b/369977976) - Disable the auto-brightness strategy
+ mIsStylusBeingUsed = isEnabled;
+ }
+
+ @VisibleForTesting
+ boolean isStylusBeingUsed() {
+ return mIsStylusBeingUsed;
}
@VisibleForTesting
@@ -626,13 +636,14 @@
lastUserSetScreenBrightness = mLastUserSetScreenBrightness;
}
return new StrategySelectionRequest(displayPowerRequest, targetDisplayState,
- lastUserSetScreenBrightness, userSetBrightnessChanged, displayOffloadSession);
+ lastUserSetScreenBrightness, userSetBrightnessChanged, displayOffloadSession,
+ mIsStylusBeingUsed);
}
private StrategyExecutionRequest constructStrategyExecutionRequest(
DisplayManagerInternal.DisplayPowerRequest displayPowerRequest) {
float currentScreenBrightness = getCurrentBrightness();
return new StrategyExecutionRequest(displayPowerRequest, currentScreenBrightness,
- mUserSetScreenBrightnessUpdated);
+ mUserSetScreenBrightnessUpdated, mIsStylusBeingUsed);
}
}
diff --git a/services/core/java/com/android/server/display/brightness/DisplayBrightnessStrategySelector.java b/services/core/java/com/android/server/display/brightness/DisplayBrightnessStrategySelector.java
index 06890e7..ded7447 100644
--- a/services/core/java/com/android/server/display/brightness/DisplayBrightnessStrategySelector.java
+++ b/services/core/java/com/android/server/display/brightness/DisplayBrightnessStrategySelector.java
@@ -306,7 +306,8 @@
strategySelectionRequest.getDisplayPowerRequest().useNormalBrightnessForDoze,
strategySelectionRequest.getLastUserSetScreenBrightness(),
strategySelectionRequest.isUserSetBrightnessChanged());
- return mAutomaticBrightnessStrategy1.isAutoBrightnessValid();
+ return !strategySelectionRequest.isStylusBeingUsed()
+ && mAutomaticBrightnessStrategy1.isAutoBrightnessValid();
}
private StrategySelectionNotifyRequest constructStrategySelectionNotifyRequest(
diff --git a/services/core/java/com/android/server/display/brightness/StrategyExecutionRequest.java b/services/core/java/com/android/server/display/brightness/StrategyExecutionRequest.java
index 304640b..7a07c4f 100644
--- a/services/core/java/com/android/server/display/brightness/StrategyExecutionRequest.java
+++ b/services/core/java/com/android/server/display/brightness/StrategyExecutionRequest.java
@@ -32,11 +32,15 @@
// Represents if the user set screen brightness was changed or not.
private boolean mUserSetBrightnessChanged;
+ private boolean mIsStylusBeingUsed;
+
public StrategyExecutionRequest(DisplayManagerInternal.DisplayPowerRequest displayPowerRequest,
- float currentScreenBrightness, boolean userSetBrightnessChanged) {
+ float currentScreenBrightness, boolean userSetBrightnessChanged,
+ boolean isStylusBeingUsed) {
mDisplayPowerRequest = displayPowerRequest;
mCurrentScreenBrightness = currentScreenBrightness;
mUserSetBrightnessChanged = userSetBrightnessChanged;
+ mIsStylusBeingUsed = isStylusBeingUsed;
}
public DisplayManagerInternal.DisplayPowerRequest getDisplayPowerRequest() {
@@ -51,6 +55,10 @@
return mUserSetBrightnessChanged;
}
+ public boolean isStylusBeingUsed() {
+ return mIsStylusBeingUsed;
+ }
+
@Override
public boolean equals(Object obj) {
if (!(obj instanceof StrategyExecutionRequest)) {
@@ -59,12 +67,13 @@
StrategyExecutionRequest other = (StrategyExecutionRequest) obj;
return Objects.equals(mDisplayPowerRequest, other.getDisplayPowerRequest())
&& mCurrentScreenBrightness == other.getCurrentScreenBrightness()
- && mUserSetBrightnessChanged == other.isUserSetBrightnessChanged();
+ && mUserSetBrightnessChanged == other.isUserSetBrightnessChanged()
+ && mIsStylusBeingUsed == other.isStylusBeingUsed();
}
@Override
public int hashCode() {
return Objects.hash(mDisplayPowerRequest, mCurrentScreenBrightness,
- mUserSetBrightnessChanged);
+ mUserSetBrightnessChanged, mIsStylusBeingUsed);
}
}
diff --git a/services/core/java/com/android/server/display/brightness/StrategySelectionRequest.java b/services/core/java/com/android/server/display/brightness/StrategySelectionRequest.java
index aa2f23e..5c1f03d 100644
--- a/services/core/java/com/android/server/display/brightness/StrategySelectionRequest.java
+++ b/services/core/java/com/android/server/display/brightness/StrategySelectionRequest.java
@@ -40,15 +40,19 @@
private DisplayManagerInternal.DisplayOffloadSession mDisplayOffloadSession;
+ private boolean mIsStylusBeingUsed;
+
public StrategySelectionRequest(DisplayManagerInternal.DisplayPowerRequest displayPowerRequest,
int targetDisplayState, float lastUserSetScreenBrightness,
boolean userSetBrightnessChanged,
- DisplayManagerInternal.DisplayOffloadSession displayOffloadSession) {
+ DisplayManagerInternal.DisplayOffloadSession displayOffloadSession,
+ boolean isStylusBeingUsed) {
mDisplayPowerRequest = displayPowerRequest;
mTargetDisplayState = targetDisplayState;
mLastUserSetScreenBrightness = lastUserSetScreenBrightness;
mUserSetBrightnessChanged = userSetBrightnessChanged;
mDisplayOffloadSession = displayOffloadSession;
+ mIsStylusBeingUsed = isStylusBeingUsed;
}
public DisplayManagerInternal.DisplayPowerRequest getDisplayPowerRequest() {
@@ -72,6 +76,10 @@
return mDisplayOffloadSession;
}
+ public boolean isStylusBeingUsed() {
+ return mIsStylusBeingUsed;
+ }
+
@Override
public boolean equals(Object obj) {
if (!(obj instanceof StrategySelectionRequest)) {
@@ -82,12 +90,14 @@
&& mTargetDisplayState == other.getTargetDisplayState()
&& mLastUserSetScreenBrightness == other.getLastUserSetScreenBrightness()
&& mUserSetBrightnessChanged == other.isUserSetBrightnessChanged()
- && mDisplayOffloadSession.equals(other.getDisplayOffloadSession());
+ && mDisplayOffloadSession.equals(other.getDisplayOffloadSession())
+ && mIsStylusBeingUsed == other.isStylusBeingUsed();
}
@Override
public int hashCode() {
return Objects.hash(mDisplayPowerRequest, mTargetDisplayState,
- mLastUserSetScreenBrightness, mUserSetBrightnessChanged, mDisplayOffloadSession);
+ mLastUserSetScreenBrightness, mUserSetBrightnessChanged, mDisplayOffloadSession,
+ mIsStylusBeingUsed);
}
}
diff --git a/services/core/java/com/android/server/display/brightness/strategy/FallbackBrightnessStrategy.java b/services/core/java/com/android/server/display/brightness/strategy/FallbackBrightnessStrategy.java
index 7c0c931..b9de34a 100644
--- a/services/core/java/com/android/server/display/brightness/strategy/FallbackBrightnessStrategy.java
+++ b/services/core/java/com/android/server/display/brightness/strategy/FallbackBrightnessStrategy.java
@@ -37,6 +37,9 @@
StrategyExecutionRequest strategyExecutionRequest) {
BrightnessReason brightnessReason = new BrightnessReason();
brightnessReason.setReason(BrightnessReason.REASON_MANUAL);
+ if (strategyExecutionRequest.isStylusBeingUsed()) {
+ brightnessReason.setModifier(BrightnessReason.MODIFIER_STYLUS_UNDER_USE);
+ }
return new DisplayBrightnessState.Builder()
.setBrightness(strategyExecutionRequest.getCurrentScreenBrightness())
.setBrightnessReason(brightnessReason)
diff --git a/services/core/java/com/android/server/media/AudioManagerRouteController.java b/services/core/java/com/android/server/media/AudioManagerRouteController.java
index c79f41d..25e1c94 100644
--- a/services/core/java/com/android/server/media/AudioManagerRouteController.java
+++ b/services/core/java/com/android/server/media/AudioManagerRouteController.java
@@ -420,7 +420,7 @@
// to derive a name ourselves from the type instead.
String deviceName = audioDeviceInfo.getPort().name();
- if (!TextUtils.isEmpty(address)) {
+ if (mBluetoothRouteController.containsBondedDeviceWithAddress(address)) {
routeId = mBluetoothRouteController.getRouteIdForBluetoothAddress(address);
deviceName = mBluetoothRouteController.getNameForBluetoothAddress(address);
}
diff --git a/services/core/java/com/android/server/media/BluetoothDeviceRoutesManager.java b/services/core/java/com/android/server/media/BluetoothDeviceRoutesManager.java
index 8b65ea3..c79d6e5 100644
--- a/services/core/java/com/android/server/media/BluetoothDeviceRoutesManager.java
+++ b/services/core/java/com/android/server/media/BluetoothDeviceRoutesManager.java
@@ -141,6 +141,11 @@
mContext.unregisterReceiver(mDeviceStateChangedReceiver);
}
+ /** Returns true if the given address corresponds to a currently-bonded Bluetooth device. */
+ public synchronized boolean containsBondedDeviceWithAddress(@Nullable String address) {
+ return mAddressToBondedDevice.containsKey(address);
+ }
+
@Nullable
public synchronized String getRouteIdForBluetoothAddress(@Nullable String address) {
BluetoothDevice bluetoothDevice = mAddressToBondedDevice.get(address);
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/BackgroundUserSoundNotifier.java b/services/core/java/com/android/server/pm/BackgroundUserSoundNotifier.java
index 49a6ffd..a221152 100644
--- a/services/core/java/com/android/server/pm/BackgroundUserSoundNotifier.java
+++ b/services/core/java/com/android/server/pm/BackgroundUserSoundNotifier.java
@@ -55,6 +55,8 @@
private static final String ACTION_SWITCH_USER = "com.android.server.ACTION_SWITCH_TO_USER";
private static final String ACTION_DISMISS_NOTIFICATION =
"com.android.server.ACTION_DISMISS_NOTIFICATION";
+ private static final String EXTRA_NOTIFICATION_CLIENT_UID =
+ "com.android.server.EXTRA_CLIENT_UID";
/**
* The clientUid from the AudioFocusInfo of the background user,
* for which an active notification is currently displayed.
@@ -101,7 +103,7 @@
ActivityManager am = mSystemUserContext.getSystemService(ActivityManager.class);
registerReceiver(am);
- mBgUserListener = new BackgroundUserListener(mSystemUserContext);
+ mBgUserListener = new BackgroundUserListener();
AudioPolicy.Builder focusControlPolicyBuilder = new AudioPolicy.Builder(mSystemUserContext);
focusControlPolicyBuilder.setLooper(Looper.getMainLooper());
@@ -119,26 +121,16 @@
final class BackgroundUserListener extends AudioPolicy.AudioPolicyFocusListener {
- Context mSystemContext;
-
- BackgroundUserListener(Context systemContext) {
- mSystemContext = systemContext;
- }
-
- @SuppressLint("MissingPermission")
public void onAudioFocusGrant(AudioFocusInfo afi, int requestResult) {
try {
- BackgroundUserSoundNotifier.this.notifyForegroundUserAboutSoundIfNecessary(afi,
- mSystemContext.createContextAsUser(
- UserHandle.of(ActivityManager.getCurrentUser()), 0));
+ BackgroundUserSoundNotifier.this.notifyForegroundUserAboutSoundIfNecessary(afi);
} catch (RemoteException e) {
throw new RuntimeException(e);
}
}
- @SuppressLint("MissingPermission")
public void onAudioFocusLoss(AudioFocusInfo afi, boolean wasNotified) {
- BackgroundUserSoundNotifier.this.dismissNotificationIfNecessary();
+ BackgroundUserSoundNotifier.this.dismissNotificationIfNecessary(afi.getClientUid());
}
}
@@ -160,7 +152,7 @@
if (mNotificationClientUid == -1) {
return;
}
- dismissNotification();
+ dismissNotification(mNotificationClientUid);
if (DEBUG) {
final int actionIndex = intent.getAction().lastIndexOf(".") + 1;
@@ -171,7 +163,7 @@
}
if (ACTION_MUTE_SOUND.equals(intent.getAction())) {
- muteAlarmSounds(mSystemUserContext);
+ muteAlarmSounds(mNotificationClientUid);
} else if (ACTION_SWITCH_USER.equals(intent.getAction())) {
activityManager.switchUser(UserHandle.getUserId(mNotificationClientUid));
}
@@ -193,17 +185,17 @@
*/
@SuppressLint("MissingPermission")
@VisibleForTesting
- void muteAlarmSounds(Context context) {
- AudioManager audioManager = context.getSystemService(AudioManager.class);
+ void muteAlarmSounds(int notificationClientUid) {
+ AudioManager audioManager = mSystemUserContext.getSystemService(AudioManager.class);
if (audioManager != null) {
for (AudioPlaybackConfiguration apc : audioManager.getActivePlaybackConfigurations()) {
- if (apc.getClientUid() == mNotificationClientUid && apc.getPlayerProxy() != null) {
+ if (apc.getClientUid() == notificationClientUid && apc.getPlayerProxy() != null) {
apc.getPlayerProxy().stop();
}
}
}
- AudioFocusInfo currentAfi = getAudioFocusInfoForNotification();
+ AudioFocusInfo currentAfi = getAudioFocusInfoForNotification(notificationClientUid);
if (currentAfi != null) {
mFocusControlAudioPolicy.sendFocusLossAndUpdate(currentAfi);
}
@@ -212,9 +204,14 @@
/**
* Check if sound is coming from background user and show notification is required.
*/
+ @SuppressLint("MissingPermission")
@VisibleForTesting
- void notifyForegroundUserAboutSoundIfNecessary(AudioFocusInfo afi, Context foregroundContext)
- throws RemoteException {
+ void notifyForegroundUserAboutSoundIfNecessary(AudioFocusInfo afi) throws RemoteException {
+ if (afi == null) {
+ return;
+ }
+ Context foregroundContext = mSystemUserContext.createContextAsUser(
+ UserHandle.of(ActivityManager.getCurrentUser()), 0);
final int userId = UserHandle.getUserId(afi.getClientUid());
final int usage = afi.getAttributes().getUsage();
UserInfo userInfo = mUserManager.getUserInfo(userId);
@@ -232,8 +229,8 @@
mNotificationClientUid = afi.getClientUid();
- mNotificationManager.notifyAsUser(LOG_TAG, mNotificationClientUid,
- createNotification(userInfo.name, foregroundContext),
+ mNotificationManager.notifyAsUser(LOG_TAG, afi.getClientUid(),
+ createNotification(userInfo.name, foregroundContext, afi.getClientUid()),
foregroundContext.getUser());
}
}
@@ -245,14 +242,15 @@
* focus ownership.
*/
@VisibleForTesting
- void dismissNotificationIfNecessary() {
- if (getAudioFocusInfoForNotification() == null && mNotificationClientUid >= 0) {
+ void dismissNotificationIfNecessary(int notificationClientUid) {
+ if (getAudioFocusInfoForNotification(notificationClientUid) == null
+ && mNotificationClientUid >= 0) {
if (DEBUG) {
Log.d(LOG_TAG, "Alarm ringing on background user "
- + UserHandle.getUserHandleForUid(mNotificationClientUid).getIdentifier()
+ + UserHandle.getUserHandleForUid(notificationClientUid).getIdentifier()
+ " left focus stack, dismissing notification");
}
- dismissNotification();
+ dismissNotification(notificationClientUid);
mNotificationClientUid = -1;
}
}
@@ -262,8 +260,8 @@
* shown.
*/
@SuppressLint("MissingPermission")
- private void dismissNotification() {
- mNotificationManager.cancelAsUser(LOG_TAG, mNotificationClientUid, UserHandle.ALL);
+ private void dismissNotification(int notificationClientUid) {
+ mNotificationManager.cancelAsUser(LOG_TAG, notificationClientUid, UserHandle.ALL);
}
/**
@@ -272,11 +270,11 @@
@SuppressLint("MissingPermission")
@VisibleForTesting
@Nullable
- AudioFocusInfo getAudioFocusInfoForNotification() {
- if (mNotificationClientUid >= 0) {
+ AudioFocusInfo getAudioFocusInfoForNotification(int notificationClientUid) {
+ if (notificationClientUid >= 0) {
List<AudioFocusInfo> stack = mFocusControlAudioPolicy.getFocusStack();
for (int i = stack.size() - 1; i >= 0; i--) {
- if (stack.get(i).getClientUid() == mNotificationClientUid) {
+ if (stack.get(i).getClientUid() == notificationClientUid) {
return stack.get(i);
}
}
@@ -284,22 +282,24 @@
return null;
}
- private PendingIntent createPendingIntent(String intentAction) {
+ private PendingIntent createPendingIntent(String intentAction, int notificationClientUid) {
final Intent intent = new Intent(intentAction);
- PendingIntent resultPI = PendingIntent.getBroadcast(mSystemUserContext, 0, intent,
- PendingIntent.FLAG_UPDATE_CURRENT | PendingIntent.FLAG_IMMUTABLE);
- return resultPI;
+ intent.putExtra(EXTRA_NOTIFICATION_CLIENT_UID, notificationClientUid);
+ return PendingIntent.getBroadcast(mSystemUserContext, notificationClientUid, intent,
+ PendingIntent.FLAG_IMMUTABLE);
}
+ @SuppressLint("MissingPermission")
@VisibleForTesting
- Notification createNotification(String userName, Context fgContext) {
+ Notification createNotification(String userName, Context fgContext, int notificationClientUid) {
final String title = fgContext.getString(R.string.bg_user_sound_notification_title_alarm,
userName);
final int icon = R.drawable.ic_audio_alarm;
- PendingIntent mutePI = createPendingIntent(ACTION_MUTE_SOUND);
- PendingIntent switchPI = createPendingIntent(ACTION_SWITCH_USER);
- PendingIntent dismissNotificationPI = createPendingIntent(ACTION_DISMISS_NOTIFICATION);
+ PendingIntent mutePI = createPendingIntent(ACTION_MUTE_SOUND, notificationClientUid);
+ PendingIntent switchPI = createPendingIntent(ACTION_SWITCH_USER, notificationClientUid);
+ PendingIntent dismissNotificationPI = createPendingIntent(ACTION_DISMISS_NOTIFICATION,
+ notificationClientUid);
final Notification.Action mute = new Notification.Action.Builder(null,
fgContext.getString(R.string.bg_user_sound_notification_button_mute),
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/core/java/com/android/server/wm/ActivityRecord.java b/services/core/java/com/android/server/wm/ActivityRecord.java
index a44eb48..460de01 100644
--- a/services/core/java/com/android/server/wm/ActivityRecord.java
+++ b/services/core/java/com/android/server/wm/ActivityRecord.java
@@ -285,9 +285,6 @@
import android.app.servertransaction.TopResumedActivityChangeItem;
import android.app.servertransaction.TransferSplashScreenViewStateItem;
import android.app.usage.UsageEvents.Event;
-import android.compat.annotation.ChangeId;
-import android.compat.annotation.EnabledAfter;
-import android.compat.annotation.Overridable;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
@@ -467,11 +464,6 @@
// finished destroying itself.
private static final int DESTROY_TIMEOUT = 10 * 1000;
- @ChangeId
- @Overridable
- @EnabledAfter(targetSdkVersion = Build.VERSION_CODES.VANILLA_ICE_CREAM)
- static final long UNIVERSAL_RESIZABLE_BY_DEFAULT = 357141415;
-
final ActivityTaskManagerService mAtmService;
final ActivityCallerState mCallerState;
@NonNull
@@ -3192,7 +3184,7 @@
&& mDisplayContent != null && mDisplayContent.getConfiguration()
.smallestScreenWidthDp >= WindowManager.LARGE_SCREEN_SMALLEST_SCREEN_WIDTH_DP
&& mDisplayContent.getIgnoreOrientationRequest()
- && info.isChangeEnabled(UNIVERSAL_RESIZABLE_BY_DEFAULT);
+ && info.isChangeEnabled(ActivityInfo.UNIVERSAL_RESIZABLE_BY_DEFAULT);
if (!compatEnabled && !mWmService.mConstants.mIgnoreActivityOrientationRequest) {
return false;
}
diff --git a/services/core/java/com/android/server/wm/ActivityStarter.java b/services/core/java/com/android/server/wm/ActivityStarter.java
index 87fa62a..5b5bb88 100644
--- a/services/core/java/com/android/server/wm/ActivityStarter.java
+++ b/services/core/java/com/android/server/wm/ActivityStarter.java
@@ -86,6 +86,7 @@
import static com.android.server.wm.TaskFragment.EMBEDDING_DISALLOWED_NEW_TASK;
import static com.android.server.wm.TaskFragment.EMBEDDING_DISALLOWED_UNTRUSTED_HOST;
import static com.android.server.wm.WindowContainer.POSITION_TOP;
+import static com.android.server.wm.WindowManagerDebugConfig.TAG_WM;
import static com.android.window.flags.Flags.balDontBringExistingBackgroundTaskStackToFg;
import android.annotation.IntDef;
@@ -2786,10 +2787,22 @@
}
}
- if ((mLaunchFlags & FLAG_ACTIVITY_LAUNCH_ADJACENT) != 0
- && ((mLaunchFlags & FLAG_ACTIVITY_NEW_TASK) == 0 || mSourceRecord == null)) {
- // ignore the flag if there is no the sourceRecord or without new_task flag
- mLaunchFlags &= ~FLAG_ACTIVITY_LAUNCH_ADJACENT;
+ if ((mLaunchFlags & FLAG_ACTIVITY_LAUNCH_ADJACENT) != 0) {
+ final boolean hasNewTaskFlag = (mLaunchFlags & FLAG_ACTIVITY_NEW_TASK) != 0;
+ if (!hasNewTaskFlag || mSourceRecord == null) {
+ // ignore the flag if there is no the sourceRecord or without new_task flag
+ Slog.w(TAG_WM, !hasNewTaskFlag
+ ? "Launch adjacent ignored due to missing NEW_TASK"
+ : "Launch adjacent ignored due to missing source activity");
+ mLaunchFlags &= ~FLAG_ACTIVITY_LAUNCH_ADJACENT;
+ }
+ // Ensure that the source task or its parents has not disabled launch-adjacent
+ if (mSourceRecord != null && mSourceRecord.getTask() != null &&
+ mSourceRecord.getTask().isLaunchAdjacentDisabled()) {
+ Slog.w(TAG_WM, "Launch adjacent blocked by source task or ancestor");
+ mLaunchFlags &= ~FLAG_ACTIVITY_LAUNCH_ADJACENT;
+ }
+
}
}
diff --git a/services/core/java/com/android/server/wm/ActivityTaskManagerInternal.java b/services/core/java/com/android/server/wm/ActivityTaskManagerInternal.java
index 3d6b64b..3560565 100644
--- a/services/core/java/com/android/server/wm/ActivityTaskManagerInternal.java
+++ b/services/core/java/com/android/server/wm/ActivityTaskManagerInternal.java
@@ -589,7 +589,7 @@
* sensitive environment.
*/
public abstract TaskSnapshot getTaskSnapshotBlocking(int taskId,
- boolean isLowResolution);
+ boolean isLowResolution, @TaskSnapshot.ReferenceFlags int usage);
/** Returns true if uid is considered foreground for activity start purposes. */
public abstract boolean isUidForeground(int uid);
diff --git a/services/core/java/com/android/server/wm/ActivityTaskManagerService.java b/services/core/java/com/android/server/wm/ActivityTaskManagerService.java
index 3dfc8f4..4db478a 100644
--- a/services/core/java/com/android/server/wm/ActivityTaskManagerService.java
+++ b/services/core/java/com/android/server/wm/ActivityTaskManagerService.java
@@ -3946,6 +3946,28 @@
}
}
+ private TaskSnapshot getTaskSnapshotInner(int taskId, boolean isLowResolution,
+ @TaskSnapshot.ReferenceFlags int usage) {
+ final Task task;
+ synchronized (mGlobalLock) {
+ task = mRootWindowContainer.anyTaskForId(taskId, MATCH_ATTACHED_TASK_OR_RECENT_TASKS);
+ if (task == null) {
+ Slog.w(TAG, "getTaskSnapshot: taskId=" + taskId + " not found");
+ return null;
+ }
+ // Try to load snapshot from cache first, and add reference if the snapshot is in cache.
+ final TaskSnapshot snapshot = mWindowManager.mTaskSnapshotController.getSnapshot(taskId,
+ task.mUserId, false /* restoreFromDisk */, isLowResolution);
+ if (snapshot != null) {
+ snapshot.addReference(usage);
+ return snapshot;
+ }
+ }
+ // Don't call this while holding the lock as this operation might hit the disk.
+ return mWindowManager.mTaskSnapshotController.getSnapshot(taskId,
+ task.mUserId, true /* restoreFromDisk */, isLowResolution);
+ }
+
@Override
public TaskSnapshot getTaskSnapshot(int taskId, boolean isLowResolution) {
mAmInternal.enforceCallingPermission(READ_FRAME_BUFFER, "getTaskSnapshot()");
@@ -7274,8 +7296,9 @@
@Override
public TaskSnapshot getTaskSnapshotBlocking(
- int taskId, boolean isLowResolution) {
- return ActivityTaskManagerService.this.getTaskSnapshot(taskId, isLowResolution);
+ int taskId, boolean isLowResolution, @TaskSnapshot.ReferenceFlags int usage) {
+ return ActivityTaskManagerService.this.getTaskSnapshotInner(
+ taskId, isLowResolution, usage);
}
@Override
diff --git a/services/core/java/com/android/server/wm/Task.java b/services/core/java/com/android/server/wm/Task.java
index 00704b3..a4e4deb 100644
--- a/services/core/java/com/android/server/wm/Task.java
+++ b/services/core/java/com/android/server/wm/Task.java
@@ -503,6 +503,11 @@
boolean mIsTrimmableFromRecents;
/**
+ * Sets whether the launch-adjacent flag is respected or not for this task or its child tasks.
+ */
+ private boolean mLaunchAdjacentDisabled;
+
+ /**
* Bounds offset should be applied when calculating compatible configuration for apps targeting
* SDK level 34 or before.
*/
@@ -3802,6 +3807,9 @@
pw.print(prefix); pw.print("lastActiveTime="); pw.print(lastActiveTime);
pw.println(" (inactive for " + (getInactiveDuration() / 1000) + "s)");
pw.print(prefix); pw.println(" isTrimmable=" + mIsTrimmableFromRecents);
+ if (mLaunchAdjacentDisabled) {
+ pw.println(prefix + "mLaunchAdjacentDisabled=true");
+ }
}
@Override
@@ -6274,6 +6282,28 @@
}
/**
+ * Sets this task and its children to disable respecting launch-adjacent.
+ */
+ void setLaunchAdjacentDisabled(boolean disabled) {
+ mLaunchAdjacentDisabled = disabled;
+ }
+
+ /**
+ * Returns whether this task or any of its ancestors have disabled respecting the
+ * launch-adjacent flag.
+ */
+ boolean isLaunchAdjacentDisabled() {
+ Task t = this;
+ while (t != null) {
+ if (t.mLaunchAdjacentDisabled) {
+ return true;
+ }
+ t = t.getParent().asTask();
+ }
+ return false;
+ }
+
+ /**
* Return true if the activityInfo has the same requiredDisplayCategory as this task.
*/
boolean isSameRequiredDisplayCategory(@NonNull ActivityInfo info) {
diff --git a/services/core/java/com/android/server/wm/TaskDisplayArea.java b/services/core/java/com/android/server/wm/TaskDisplayArea.java
index 5dd3bbc..2c71c1a 100644
--- a/services/core/java/com/android/server/wm/TaskDisplayArea.java
+++ b/services/core/java/com/android/server/wm/TaskDisplayArea.java
@@ -1074,6 +1074,8 @@
final Task launchRootTask = Task.fromWindowContainerToken(options.getLaunchRootTask());
// We only allow this for created by organizer tasks.
if (launchRootTask != null && launchRootTask.mCreatedByOrganizer) {
+ Slog.i(TAG_WM, "Using launch root task from activity options: taskId="
+ + launchRootTask.mTaskId);
return launchRootTask;
}
}
@@ -1081,19 +1083,25 @@
// Use launch-adjacent-flag-root if launching with launch-adjacent flag.
if ((launchFlags & FLAG_ACTIVITY_LAUNCH_ADJACENT) != 0
&& mLaunchAdjacentFlagRootTask != null) {
+ final Task launchAdjacentRootAdjacentTask =
+ mLaunchAdjacentFlagRootTask.getAdjacentTask();
if (sourceTask != null && (sourceTask == candidateTask
|| sourceTask.topRunningActivity() == null)) {
// Do nothing when task that is getting opened is same as the source or when
// the source is no-longer valid.
Slog.w(TAG_WM, "Ignoring LAUNCH_ADJACENT because adjacent source is gone.");
} else if (sourceTask != null
- && mLaunchAdjacentFlagRootTask.getAdjacentTask() != null
+ && launchAdjacentRootAdjacentTask != null
&& (sourceTask == mLaunchAdjacentFlagRootTask
|| sourceTask.isDescendantOf(mLaunchAdjacentFlagRootTask))) {
- // If the adjacent launch is coming from the same root, launch to
- // adjacent root instead.
- return mLaunchAdjacentFlagRootTask.getAdjacentTask();
+ // If the adjacent launch is coming from the same root that was specified as the
+ // launch-adjacent task, so instead we launch to its adjacent root instead.
+ Slog.i(TAG_WM, "Using adjacent-to specified launch-adjacent task: taskId="
+ + launchAdjacentRootAdjacentTask.mTaskId);
+ return launchAdjacentRootAdjacentTask;
} else {
+ Slog.i(TAG_WM, "Using specified launch-adjacent task: taskId="
+ + mLaunchAdjacentFlagRootTask.mTaskId);
return mLaunchAdjacentFlagRootTask;
}
}
diff --git a/services/core/java/com/android/server/wm/WindowOrganizerController.java b/services/core/java/com/android/server/wm/WindowOrganizerController.java
index 82c7a93..166d74b 100644
--- a/services/core/java/com/android/server/wm/WindowOrganizerController.java
+++ b/services/core/java/com/android/server/wm/WindowOrganizerController.java
@@ -69,6 +69,7 @@
import static android.window.WindowContainerTransaction.HierarchyOp.HIERARCHY_OP_TYPE_SET_ADJACENT_ROOTS;
import static android.window.WindowContainerTransaction.HierarchyOp.HIERARCHY_OP_TYPE_SET_ALWAYS_ON_TOP;
import static android.window.WindowContainerTransaction.HierarchyOp.HIERARCHY_OP_TYPE_SET_EXCLUDE_INSETS_TYPES;
+import static android.window.WindowContainerTransaction.HierarchyOp.HIERARCHY_OP_TYPE_SET_DISABLE_LAUNCH_ADJACENT;
import static android.window.WindowContainerTransaction.HierarchyOp.HIERARCHY_OP_TYPE_SET_IS_TRIMMABLE;
import static android.window.WindowContainerTransaction.HierarchyOp.HIERARCHY_OP_TYPE_SET_LAUNCH_ADJACENT_FLAG_ROOT;
import static android.window.WindowContainerTransaction.HierarchyOp.HIERARCHY_OP_TYPE_SET_LAUNCH_ROOT;
@@ -1450,6 +1451,17 @@
task.setTrimmableFromRecents(hop.isTrimmableFromRecents());
break;
}
+ case HIERARCHY_OP_TYPE_SET_DISABLE_LAUNCH_ADJACENT: {
+ final WindowContainer container = WindowContainer.fromBinder(hop.getContainer());
+ final Task task = container != null ? container.asTask() : null;
+ if (task == null || !task.isAttached()) {
+ Slog.e(TAG, "Attempt to operate on unknown or detached container: "
+ + container);
+ break;
+ }
+ task.setLaunchAdjacentDisabled(hop.isLaunchAdjacentDisabled());
+ break;
+ }
case HIERARCHY_OP_TYPE_RESTORE_BACK_NAVIGATION: {
if (mService.mBackNavigationController.restoreBackNavigation()) {
effects |= TRANSACT_EFFECTS_LIFECYCLE;
diff --git a/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java b/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java
index 7e450dd..aca6f72 100644
--- a/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java
+++ b/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java
@@ -16815,6 +16815,9 @@
}
}
EnforcingAdmin enforcingAdmin;
+
+ // TODO(b/370472975): enable when we stop policy enforecer callback from blocking the main
+ // thread
if (Flags.setPermissionGrantStateCoexistence()) {
enforcingAdmin = enforcePermissionAndGetEnforcingAdmin(
admin,
@@ -16840,54 +16843,7 @@
callback.sendResult(null);
return;
}
- } else {
- Preconditions.checkCallAuthorization((caller.hasAdminComponent()
- && (isProfileOwner(caller) || isDefaultDeviceOwner(caller)
- || isFinancedDeviceOwner(caller)))
- || (caller.hasPackage() && isCallerDelegate(caller,
- DELEGATION_PERMISSION_GRANT)));
- if (SENSOR_PERMISSIONS.contains(permission)
- && grantState == PERMISSION_GRANT_STATE_GRANTED
- && !canAdminGrantSensorsPermissions()) {
- if (mInjector.isChangeEnabled(THROW_SECURITY_EXCEPTION_FOR_SENSOR_PERMISSIONS,
- caller.getPackageName(), caller.getUserId())) {
- throw new SecurityException(
- "Caller not permitted to grant sensor permissions.");
- } else {
- Slogf.e(LOG_TAG, "Caller attempted to grant sensor permissions but denied");
- // This is to match the legacy behaviour.
- callback.sendResult(Bundle.EMPTY);
- return;
- }
- }
- synchronized (getLockObject()) {
- long ident = mInjector.binderClearCallingIdentity();
- try {
- boolean isPostQAdmin = getTargetSdk(caller.getPackageName(), caller.getUserId())
- >= android.os.Build.VERSION_CODES.Q;
- if (!isPostQAdmin) {
- // Legacy admins assume that they cannot control pre-M apps
- if (getTargetSdk(packageName, caller.getUserId())
- < android.os.Build.VERSION_CODES.M) {
- callback.sendResult(null);
- return;
- }
- }
- if (!isRuntimePermission(permission)) {
- callback.sendResult(null);
- return;
- }
- } catch (SecurityException e) {
- Slogf.e(LOG_TAG, "Could not set permission grant state", e);
- callback.sendResult(null);
- } finally {
- mInjector.binderRestoreCallingIdentity(ident);
- }
- }
- }
- // TODO(b/278710449): enable when we stop policy enforecer callback from blocking the main
- // thread
- if (false) {
+
// TODO(b/266924257): decide how to handle the internal state if the package doesn't
// exist, or the permission isn't requested by the app, because we could end up with
// inconsistent state between the policy engine and package manager. Also a package
@@ -16913,11 +16869,43 @@
callback.sendResult(null);
}
} else {
+ Preconditions.checkCallAuthorization((caller.hasAdminComponent()
+ && (isProfileOwner(caller) || isDefaultDeviceOwner(caller)
+ || isFinancedDeviceOwner(caller)))
+ || (caller.hasPackage() && isCallerDelegate(caller,
+ DELEGATION_PERMISSION_GRANT)));
+ if (SENSOR_PERMISSIONS.contains(permission)
+ && grantState == PERMISSION_GRANT_STATE_GRANTED
+ && !canAdminGrantSensorsPermissions()) {
+ if (mInjector.isChangeEnabled(THROW_SECURITY_EXCEPTION_FOR_SENSOR_PERMISSIONS,
+ caller.getPackageName(), caller.getUserId())) {
+ throw new SecurityException(
+ "Caller not permitted to grant sensor permissions.");
+ } else {
+ Slogf.e(LOG_TAG, "Caller attempted to grant sensor permissions but denied");
+ // This is to match the legacy behaviour.
+ callback.sendResult(Bundle.EMPTY);
+ return;
+ }
+ }
synchronized (getLockObject()) {
long ident = mInjector.binderClearCallingIdentity();
+ boolean isPostQAdmin = getTargetSdk(caller.getPackageName(), caller.getUserId())
+ >= android.os.Build.VERSION_CODES.Q;
+
try {
- boolean isPostQAdmin = getTargetSdk(caller.getPackageName(), caller.getUserId())
- >= android.os.Build.VERSION_CODES.Q;
+ if (!isPostQAdmin) {
+ // Legacy admins assume that they cannot control pre-M apps
+ if (getTargetSdk(packageName, caller.getUserId())
+ < android.os.Build.VERSION_CODES.M) {
+ callback.sendResult(null);
+ return;
+ }
+ }
+ if (!isRuntimePermission(permission)) {
+ callback.sendResult(null);
+ return;
+ }
if (grantState == PERMISSION_GRANT_STATE_GRANTED
|| grantState == DevicePolicyManager.PERMISSION_GRANT_STATE_DENIED
|| grantState == DevicePolicyManager.PERMISSION_GRANT_STATE_DEFAULT) {
@@ -16939,7 +16927,6 @@
}
} catch (SecurityException e) {
Slogf.e(LOG_TAG, "Could not set permission grant state", e);
-
callback.sendResult(null);
} finally {
mInjector.binderRestoreCallingIdentity(ident);
diff --git a/services/tests/displayservicetests/src/com/android/server/display/DisplayPowerControllerTest.java b/services/tests/displayservicetests/src/com/android/server/display/DisplayPowerControllerTest.java
index 01b2d3e..fdf6b80 100644
--- a/services/tests/displayservicetests/src/com/android/server/display/DisplayPowerControllerTest.java
+++ b/services/tests/displayservicetests/src/com/android/server/display/DisplayPowerControllerTest.java
@@ -2343,6 +2343,41 @@
}
}
+ @Test
+ public void stylusUsageStarted_disablesAutomaticBrightnessStrategy() {
+ when(mDisplayManagerFlagsMock.isBlockAutobrightnessChangesOnStylusUsage())
+ .thenReturn(true);
+ when(mDisplayManagerFlagsMock.isRefactorDisplayPowerControllerEnabled())
+ .thenReturn(true);
+ mHolder = createDisplayPowerController(DISPLAY_ID, UNIQUE_ID);
+ mHolder.dpc.setDisplayOffloadSession(mDisplayOffloadSession);
+ Settings.System.putInt(mContext.getContentResolver(),
+ Settings.System.SCREEN_BRIGHTNESS_MODE,
+ Settings.System.SCREEN_BRIGHTNESS_MODE_AUTOMATIC);
+
+ DisplayPowerRequest dpr = new DisplayPowerRequest();
+ dpr.policy = DisplayPowerRequest.POLICY_BRIGHT;
+ when(mHolder.displayPowerState.getScreenState()).thenReturn(Display.STATE_ON);
+ advanceTime(2);
+ clearInvocations(mHolder.automaticBrightnessController);
+ mHolder.dpc.stylusGestureStarted(2000000);
+
+ mHolder.dpc.requestPowerState(dpr, /* waitForNegativeProximity= */ false);
+ advanceTime(1); // Run updatePowerState
+ verify(mHolder.automaticBrightnessController, times(0))
+ .getAutomaticScreenBrightness(any());
+
+ // Stylus usage timed out, hence autobrightness is now enabled back again
+ advanceTime(6);
+ verify(mHolder.automaticBrightnessController).getAutomaticScreenBrightness(null);
+
+ // Ideally we should be able to assert against new BrightnessEvent(Display.DEFAULT_DISPLAY),
+ // but because brightnessEvent has the mTime field which refers to the current time,
+ // asserting against that is non-trivial
+ verify(mHolder.automaticBrightnessController).getAutomaticScreenBrightness(
+ any(BrightnessEvent.class));
+ }
+
/**
* Creates a mock and registers it to {@link LocalServices}.
*/
@@ -2406,6 +2441,7 @@
.thenReturn(new int[0]);
when(displayDeviceConfigMock.getDefaultDozeBrightness())
.thenReturn(DEFAULT_DOZE_BRIGHTNESS);
+ when(displayDeviceConfigMock.getIdleStylusTimeoutMillis()).thenReturn(5);
when(displayDeviceConfigMock.getBrightnessRampFastDecrease())
.thenReturn(BRIGHTNESS_RAMP_RATE_FAST_DECREASE);
diff --git a/services/tests/displayservicetests/src/com/android/server/display/brightness/BrightnessReasonTest.java b/services/tests/displayservicetests/src/com/android/server/display/brightness/BrightnessReasonTest.java
index 04b79b4..d93ee84 100644
--- a/services/tests/displayservicetests/src/com/android/server/display/brightness/BrightnessReasonTest.java
+++ b/services/tests/displayservicetests/src/com/android/server/display/brightness/BrightnessReasonTest.java
@@ -74,7 +74,7 @@
@Test
public void setModifierDoesntSetIfModifierIsBeyondExtremes() {
- int extremeModifier = 0x40; // equal to BrightnessReason.MODIFIER_MASK * 2
+ int extremeModifier = 0x80;
// reset modifier
mBrightnessReason.setModifier(0);
diff --git a/services/tests/displayservicetests/src/com/android/server/display/brightness/DisplayBrightnessControllerTest.java b/services/tests/displayservicetests/src/com/android/server/display/brightness/DisplayBrightnessControllerTest.java
index c069875..b3baa5d 100644
--- a/services/tests/displayservicetests/src/com/android/server/display/brightness/DisplayBrightnessControllerTest.java
+++ b/services/tests/displayservicetests/src/com/android/server/display/brightness/DisplayBrightnessControllerTest.java
@@ -125,7 +125,7 @@
DisplayManagerInternal.DisplayOffloadSession.class));
verify(displayBrightnessStrategy).updateBrightness(
eq(new StrategyExecutionRequest(displayPowerRequest, DEFAULT_BRIGHTNESS,
- /* userSetBrightnessChanged= */ false)));
+ /* userSetBrightnessChanged= */ false, /* isStylusBeingUsed */ false)));
assertEquals(mDisplayBrightnessController.getCurrentDisplayBrightnessStrategy(),
displayBrightnessStrategy);
}
@@ -559,4 +559,11 @@
displayDeviceConfig, handler, brightnessMappingStrategy, isDisplayEnabled,
leadDisplayId);
}
+
+ @Test
+ public void setStylusBeingUsed_setsStylusInUseState() {
+ assertFalse(mDisplayBrightnessController.isStylusBeingUsed());
+ mDisplayBrightnessController.setStylusBeingUsed(true);
+ assertTrue(mDisplayBrightnessController.isStylusBeingUsed());
+ }
}
diff --git a/services/tests/displayservicetests/src/com/android/server/display/brightness/DisplayBrightnessStrategySelectorTest.java b/services/tests/displayservicetests/src/com/android/server/display/brightness/DisplayBrightnessStrategySelectorTest.java
index a44c517..fe15051 100644
--- a/services/tests/displayservicetests/src/com/android/server/display/brightness/DisplayBrightnessStrategySelectorTest.java
+++ b/services/tests/displayservicetests/src/com/android/server/display/brightness/DisplayBrightnessStrategySelectorTest.java
@@ -68,6 +68,8 @@
@RunWith(AndroidJUnit4.class)
public final class DisplayBrightnessStrategySelectorTest {
private static final boolean DISALLOW_AUTO_BRIGHTNESS_WHILE_DOZING = false;
+ private static final boolean STYLUS_IS_NOT_BEING_USED = false;
+ private static final boolean STYLUS_IS_BEING_USED = true;
private static final int DISPLAY_ID = 1;
@Mock
@@ -196,7 +198,8 @@
DISALLOW_AUTO_BRIGHTNESS_WHILE_DOZING);
assertEquals(mDisplayBrightnessStrategySelector.selectStrategy(
new StrategySelectionRequest(displayPowerRequest, Display.STATE_DOZE,
- 0.1f, false, mDisplayOffloadSession)),
+ 0.1f, false, mDisplayOffloadSession,
+ STYLUS_IS_NOT_BEING_USED)),
mDozeBrightnessModeStrategy);
}
@@ -212,7 +215,8 @@
DISALLOW_AUTO_BRIGHTNESS_WHILE_DOZING);
assertNotEquals(mDisplayBrightnessStrategySelector.selectStrategy(
new StrategySelectionRequest(displayPowerRequest, Display.STATE_DOZE,
- 0.1f, false, mDisplayOffloadSession)),
+ 0.1f, false, mDisplayOffloadSession,
+ STYLUS_IS_NOT_BEING_USED)),
mDozeBrightnessModeStrategy);
}
@@ -226,7 +230,8 @@
DISALLOW_AUTO_BRIGHTNESS_WHILE_DOZING);
assertNotEquals(mDisplayBrightnessStrategySelector.selectStrategy(
new StrategySelectionRequest(displayPowerRequest, Display.STATE_DOZE,
- 0.1f, false, mDisplayOffloadSession)),
+ 0.1f, false, mDisplayOffloadSession,
+ STYLUS_IS_NOT_BEING_USED)),
mDozeBrightnessModeStrategy);
}
@@ -249,7 +254,8 @@
assertNotEquals(mDisplayBrightnessStrategySelector.selectStrategy(
new StrategySelectionRequest(displayPowerRequest, Display.STATE_DOZE,
- 0.1f, false, mDisplayOffloadSession)),
+ 0.1f, false, mDisplayOffloadSession,
+ STYLUS_IS_NOT_BEING_USED)),
mDozeBrightnessModeStrategy);
}
@@ -259,7 +265,8 @@
DisplayManagerInternal.DisplayPowerRequest.class);
assertEquals(mDisplayBrightnessStrategySelector.selectStrategy(
new StrategySelectionRequest(displayPowerRequest, Display.STATE_OFF,
- 0.1f, false, mDisplayOffloadSession)),
+ 0.1f, false, mDisplayOffloadSession,
+ STYLUS_IS_NOT_BEING_USED)),
mScreenOffBrightnessModeStrategy);
}
@@ -271,7 +278,8 @@
when(mFollowerBrightnessStrategy.getBrightnessToFollow()).thenReturn(Float.NaN);
assertEquals(mDisplayBrightnessStrategySelector.selectStrategy(
new StrategySelectionRequest(displayPowerRequest, Display.STATE_ON,
- 0.1f, false, mDisplayOffloadSession)),
+ 0.1f, false, mDisplayOffloadSession,
+ STYLUS_IS_NOT_BEING_USED)),
mOverrideBrightnessStrategy);
}
@@ -284,7 +292,8 @@
when(mTemporaryBrightnessStrategy.getTemporaryScreenBrightness()).thenReturn(0.3f);
assertEquals(mDisplayBrightnessStrategySelector.selectStrategy(
new StrategySelectionRequest(displayPowerRequest, Display.STATE_ON,
- 0.1f, false, mDisplayOffloadSession)),
+ 0.1f, false, mDisplayOffloadSession,
+ STYLUS_IS_NOT_BEING_USED)),
mTemporaryBrightnessStrategy);
}
@@ -298,7 +307,8 @@
when(mTemporaryBrightnessStrategy.getTemporaryScreenBrightness()).thenReturn(Float.NaN);
assertEquals(mDisplayBrightnessStrategySelector.selectStrategy(
new StrategySelectionRequest(displayPowerRequest, Display.STATE_ON,
- 0.1f, false, mDisplayOffloadSession)),
+ 0.1f, false, mDisplayOffloadSession,
+ STYLUS_IS_NOT_BEING_USED)),
mBoostBrightnessStrategy);
}
@@ -312,7 +322,8 @@
when(mOffloadBrightnessStrategy.getOffloadScreenBrightness()).thenReturn(Float.NaN);
assertEquals(mDisplayBrightnessStrategySelector.selectStrategy(
new StrategySelectionRequest(displayPowerRequest, Display.STATE_ON,
- 0.1f, false, mDisplayOffloadSession)),
+ 0.1f, false, mDisplayOffloadSession,
+ STYLUS_IS_NOT_BEING_USED)),
mInvalidBrightnessStrategy);
}
@@ -323,7 +334,8 @@
when(mFollowerBrightnessStrategy.getBrightnessToFollow()).thenReturn(0.3f);
assertEquals(mDisplayBrightnessStrategySelector.selectStrategy(
new StrategySelectionRequest(displayPowerRequest, Display.STATE_ON,
- 0.1f, false, mDisplayOffloadSession)),
+ 0.1f, false, mDisplayOffloadSession,
+ STYLUS_IS_NOT_BEING_USED)),
mFollowerBrightnessStrategy);
}
@@ -341,7 +353,8 @@
when(mOffloadBrightnessStrategy.getOffloadScreenBrightness()).thenReturn(0.3f);
assertEquals(mDisplayBrightnessStrategySelector.selectStrategy(
new StrategySelectionRequest(displayPowerRequest, Display.STATE_ON,
- 0.1f, false, mDisplayOffloadSession)),
+ 0.1f, false, mDisplayOffloadSession,
+ STYLUS_IS_NOT_BEING_USED)),
mOffloadBrightnessStrategy);
}
@@ -365,7 +378,8 @@
when(mAutomaticBrightnessStrategy.isAutoBrightnessValid()).thenReturn(true);
assertEquals(mDisplayBrightnessStrategySelector.selectStrategy(
new StrategySelectionRequest(displayPowerRequest, Display.STATE_ON,
- 0.1f, false, mDisplayOffloadSession)),
+ 0.1f, false, mDisplayOffloadSession,
+ STYLUS_IS_NOT_BEING_USED)),
mAutomaticBrightnessStrategy);
verify(mAutomaticBrightnessStrategy).setAutoBrightnessState(Display.STATE_ON,
true, BrightnessReason.REASON_UNKNOWN,
@@ -373,6 +387,32 @@
/* useNormalBrightnessForDoze= */ false, 0.1f, false);
}
+
+ @Test
+ public void selectStrategy_doesNotSelectAutomaticStrategyWhenStylusInUse() {
+ when(mDisplayManagerFlags.isRefactorDisplayPowerControllerEnabled()).thenReturn(true);
+ when(mDisplayManagerFlags.offloadControlsDozeAutoBrightness()).thenReturn(true);
+ when(mDisplayManagerFlags.isDisplayOffloadEnabled()).thenReturn(true);
+ when(mDisplayOffloadSession.allowAutoBrightnessInDoze()).thenReturn(true);
+ when(mResources.getBoolean(R.bool.config_allowAutoBrightnessWhileDozing)).thenReturn(
+ true);
+ mDisplayBrightnessStrategySelector = new DisplayBrightnessStrategySelector(mContext,
+ mInjector, DISPLAY_ID, mDisplayManagerFlags);
+ DisplayManagerInternal.DisplayPowerRequest displayPowerRequest = mock(
+ DisplayManagerInternal.DisplayPowerRequest.class);
+ displayPowerRequest.policy = DisplayManagerInternal.DisplayPowerRequest.POLICY_BRIGHT;
+ displayPowerRequest.screenBrightnessOverride = Float.NaN;
+ when(mFollowerBrightnessStrategy.getBrightnessToFollow()).thenReturn(Float.NaN);
+ when(mTemporaryBrightnessStrategy.getTemporaryScreenBrightness()).thenReturn(Float.NaN);
+ when(mAutomaticBrightnessStrategy.shouldUseAutoBrightness()).thenReturn(true);
+ when(mAutomaticBrightnessStrategy.isAutoBrightnessValid()).thenReturn(true);
+ assertNotEquals(mDisplayBrightnessStrategySelector.selectStrategy(
+ new StrategySelectionRequest(displayPowerRequest, Display.STATE_ON,
+ 0.1f, false, mDisplayOffloadSession,
+ STYLUS_IS_BEING_USED)),
+ mAutomaticBrightnessStrategy);
+ }
+
@Test
public void selectStrategy_selectsAutomaticFallbackStrategyWhenValid() {
when(mDisplayManagerFlags.isRefactorDisplayPowerControllerEnabled()).thenReturn(true);
@@ -389,7 +429,8 @@
when(mAutoBrightnessFallbackStrategy.isValid()).thenReturn(true);
assertEquals(mDisplayBrightnessStrategySelector.selectStrategy(
new StrategySelectionRequest(displayPowerRequest, Display.STATE_ON,
- 0.1f, false, mDisplayOffloadSession)),
+ 0.1f, false, mDisplayOffloadSession,
+ STYLUS_IS_NOT_BEING_USED)),
mAutoBrightnessFallbackStrategy);
}
@@ -407,7 +448,8 @@
assertNotEquals(mOffloadBrightnessStrategy,
mDisplayBrightnessStrategySelector.selectStrategy(
new StrategySelectionRequest(displayPowerRequest, Display.STATE_ON,
- 0.1f, false, mDisplayOffloadSession)));
+ 0.1f, false, mDisplayOffloadSession,
+ STYLUS_IS_NOT_BEING_USED)));
}
@Test
@@ -425,7 +467,8 @@
when(mAutomaticBrightnessStrategy.isAutoBrightnessValid()).thenReturn(false);
assertEquals(mDisplayBrightnessStrategySelector.selectStrategy(
new StrategySelectionRequest(displayPowerRequest, Display.STATE_ON,
- 0.1f, false, mDisplayOffloadSession)),
+ 0.1f, false, mDisplayOffloadSession,
+ STYLUS_IS_NOT_BEING_USED)),
mFallbackBrightnessStrategy);
}
@@ -440,7 +483,8 @@
mDisplayBrightnessStrategySelector.selectStrategy(
new StrategySelectionRequest(displayPowerRequest, Display.STATE_ON,
- 0.1f, false, mDisplayOffloadSession));
+ 0.1f, false, mDisplayOffloadSession,
+ STYLUS_IS_NOT_BEING_USED));
StrategySelectionNotifyRequest strategySelectionNotifyRequest =
new StrategySelectionNotifyRequest(displayPowerRequest, Display.STATE_ON,
diff --git a/services/tests/displayservicetests/src/com/android/server/display/brightness/strategy/AutoBrightnessFallbackStrategyTest.java b/services/tests/displayservicetests/src/com/android/server/display/brightness/strategy/AutoBrightnessFallbackStrategyTest.java
index 99dfa73..2a71af0 100644
--- a/services/tests/displayservicetests/src/com/android/server/display/brightness/strategy/AutoBrightnessFallbackStrategyTest.java
+++ b/services/tests/displayservicetests/src/com/android/server/display/brightness/strategy/AutoBrightnessFallbackStrategyTest.java
@@ -129,7 +129,8 @@
DisplayBrightnessState updatedDisplayBrightnessState =
mAutoBrightnessFallbackStrategy.updateBrightness(
new StrategyExecutionRequest(displayPowerRequest, 0.2f,
- /* userSetBrightnessChanged= */ false));
+ /* userSetBrightnessChanged= */ false,
+ /* isStylusBeingUsed */ false));
assertEquals(updatedDisplayBrightnessState, expectedDisplayBrightnessState);
}
diff --git a/services/tests/displayservicetests/src/com/android/server/display/brightness/strategy/AutomaticBrightnessStrategyTest.java b/services/tests/displayservicetests/src/com/android/server/display/brightness/strategy/AutomaticBrightnessStrategyTest.java
index efa8b3e..8a1f860 100644
--- a/services/tests/displayservicetests/src/com/android/server/display/brightness/strategy/AutomaticBrightnessStrategyTest.java
+++ b/services/tests/displayservicetests/src/com/android/server/display/brightness/strategy/AutomaticBrightnessStrategyTest.java
@@ -637,7 +637,7 @@
.build();
DisplayBrightnessState actualDisplayBrightnessState = mAutomaticBrightnessStrategy
.updateBrightness(new StrategyExecutionRequest(displayPowerRequest, 0.6f,
- /* userSetBrightnessChanged= */ true));
+ /* userSetBrightnessChanged= */ true, /* isStylusBeingUsed */ false));
assertEquals(expectedDisplayBrightnessState, actualDisplayBrightnessState);
}
@@ -686,7 +686,7 @@
.build();
DisplayBrightnessState actualDisplayBrightnessState = mAutomaticBrightnessStrategy
.updateBrightness(new StrategyExecutionRequest(displayPowerRequest, 0.6f,
- /* userSetBrightnessChanged= */ true));
+ /* userSetBrightnessChanged= */ true, /* isStylusBeingUsed */ false));
assertEquals(expectedDisplayBrightnessState, actualDisplayBrightnessState);
}
@@ -725,7 +725,7 @@
.build();
DisplayBrightnessState actualDisplayBrightnessState = mAutomaticBrightnessStrategy
.updateBrightness(new StrategyExecutionRequest(displayPowerRequest, 0.6f,
- /* userSetBrightnessChanged= */ true));
+ /* userSetBrightnessChanged= */ true, /* isStylusBeingUsed */ false));
assertEquals(expectedDisplayBrightnessState, actualDisplayBrightnessState);
}
@@ -764,7 +764,7 @@
.build();
DisplayBrightnessState actualDisplayBrightnessState = mAutomaticBrightnessStrategy
.updateBrightness(new StrategyExecutionRequest(displayPowerRequest, 0.6f,
- /* userSetBrightnessChanged= */ true));
+ /* userSetBrightnessChanged= */ true, /* isStylusBeingUsed */ false));
assertEquals(expectedDisplayBrightnessState, actualDisplayBrightnessState);
}
diff --git a/services/tests/displayservicetests/src/com/android/server/display/brightness/strategy/BoostBrightnessStrategyTest.java b/services/tests/displayservicetests/src/com/android/server/display/brightness/strategy/BoostBrightnessStrategyTest.java
index 275bb3ef..c03309e 100644
--- a/services/tests/displayservicetests/src/com/android/server/display/brightness/strategy/BoostBrightnessStrategyTest.java
+++ b/services/tests/displayservicetests/src/com/android/server/display/brightness/strategy/BoostBrightnessStrategyTest.java
@@ -60,7 +60,8 @@
DisplayBrightnessState updatedDisplayBrightnessState =
mBoostBrightnessStrategy.updateBrightness(
new StrategyExecutionRequest(displayPowerRequest, 0.2f,
- /* userSetBrightnessChanged= */ false));
+ /* userSetBrightnessChanged= */ false,
+ /* isStylusBeingUsed */ false));
assertEquals(updatedDisplayBrightnessState, expectedDisplayBrightnessState);
}
diff --git a/services/tests/displayservicetests/src/com/android/server/display/brightness/strategy/DozeBrightnessStrategyTest.java b/services/tests/displayservicetests/src/com/android/server/display/brightness/strategy/DozeBrightnessStrategyTest.java
index 23e447c..e7f80b0 100644
--- a/services/tests/displayservicetests/src/com/android/server/display/brightness/strategy/DozeBrightnessStrategyTest.java
+++ b/services/tests/displayservicetests/src/com/android/server/display/brightness/strategy/DozeBrightnessStrategyTest.java
@@ -57,7 +57,8 @@
DisplayBrightnessState updatedDisplayBrightnessState =
mDozeBrightnessModeStrategy.updateBrightness(
new StrategyExecutionRequest(displayPowerRequest, 0.2f,
- /* userSetBrightnessChanged= */ false));
+ /* userSetBrightnessChanged= */ false,
+ /* isStylusBeingUsed */ false));
assertEquals(updatedDisplayBrightnessState, expectedDisplayBrightnessState);
}
}
diff --git a/services/tests/displayservicetests/src/com/android/server/display/brightness/strategy/FallbackBrightnessStrategyTest.java b/services/tests/displayservicetests/src/com/android/server/display/brightness/strategy/FallbackBrightnessStrategyTest.java
index c4a5790..dcfa174 100644
--- a/services/tests/displayservicetests/src/com/android/server/display/brightness/strategy/FallbackBrightnessStrategyTest.java
+++ b/services/tests/displayservicetests/src/com/android/server/display/brightness/strategy/FallbackBrightnessStrategyTest.java
@@ -61,7 +61,8 @@
DisplayBrightnessState updatedDisplayBrightnessState =
mFallbackBrightnessStrategy.updateBrightness(
new StrategyExecutionRequest(displayPowerRequest, currentBrightness,
- /* userSetBrightnessChanged= */ true));
+ /* userSetBrightnessChanged= */ true,
+ /* isStylusBeingUsed */ false));
assertEquals(updatedDisplayBrightnessState, expectedDisplayBrightnessState);
}
}
diff --git a/services/tests/displayservicetests/src/com/android/server/display/brightness/strategy/FollowerBrightnessStrategyTest.java b/services/tests/displayservicetests/src/com/android/server/display/brightness/strategy/FollowerBrightnessStrategyTest.java
index c01f96e..239cdb6 100644
--- a/services/tests/displayservicetests/src/com/android/server/display/brightness/strategy/FollowerBrightnessStrategyTest.java
+++ b/services/tests/displayservicetests/src/com/android/server/display/brightness/strategy/FollowerBrightnessStrategyTest.java
@@ -61,7 +61,8 @@
DisplayBrightnessState updatedDisplayBrightnessState =
mFollowerBrightnessStrategy.updateBrightness(
new StrategyExecutionRequest(displayPowerRequest, 0.2f,
- /* userSetBrightnessChanged= */ false));
+ /* userSetBrightnessChanged= */ false,
+ /* isStylusBeingUsed */ false));
assertEquals(expectedDisplayBrightnessState, updatedDisplayBrightnessState);
}
diff --git a/services/tests/displayservicetests/src/com/android/server/display/brightness/strategy/OffloadBrightnessStrategyTest.java b/services/tests/displayservicetests/src/com/android/server/display/brightness/strategy/OffloadBrightnessStrategyTest.java
index 9fb2afa..77302f8 100644
--- a/services/tests/displayservicetests/src/com/android/server/display/brightness/strategy/OffloadBrightnessStrategyTest.java
+++ b/services/tests/displayservicetests/src/com/android/server/display/brightness/strategy/OffloadBrightnessStrategyTest.java
@@ -72,7 +72,8 @@
DisplayBrightnessState updatedDisplayBrightnessState =
mOffloadBrightnessStrategy.updateBrightness(
new StrategyExecutionRequest(displayPowerRequest, 0.2f,
- /* userSetBrightnessChanged= */ false));
+ /* userSetBrightnessChanged= */ false,
+ /* isStylusBeingUsed */ false));
assertEquals(updatedDisplayBrightnessState, expectedDisplayBrightnessState);
assertEquals(PowerManager.BRIGHTNESS_INVALID_FLOAT, mOffloadBrightnessStrategy
.getOffloadScreenBrightness(), 0.0f);
diff --git a/services/tests/displayservicetests/src/com/android/server/display/brightness/strategy/OverrideBrightnessStrategyTest.java b/services/tests/displayservicetests/src/com/android/server/display/brightness/strategy/OverrideBrightnessStrategyTest.java
index e8b4c06..cc21af1 100644
--- a/services/tests/displayservicetests/src/com/android/server/display/brightness/strategy/OverrideBrightnessStrategyTest.java
+++ b/services/tests/displayservicetests/src/com/android/server/display/brightness/strategy/OverrideBrightnessStrategyTest.java
@@ -60,7 +60,8 @@
DisplayBrightnessState updatedDisplayBrightnessState =
mOverrideBrightnessStrategy.updateBrightness(
new StrategyExecutionRequest(displayPowerRequest, 0.2f,
- /* userSetBrightnessChanged= */ false));
+ /* userSetBrightnessChanged= */ false,
+ /* isStylusBeingUsed */ false));
assertEquals(updatedDisplayBrightnessState, expectedDisplayBrightnessState);
}
diff --git a/services/tests/displayservicetests/src/com/android/server/display/brightness/strategy/ScreenOffBrightnessStrategyTest.java b/services/tests/displayservicetests/src/com/android/server/display/brightness/strategy/ScreenOffBrightnessStrategyTest.java
index 38709ec..652663e 100644
--- a/services/tests/displayservicetests/src/com/android/server/display/brightness/strategy/ScreenOffBrightnessStrategyTest.java
+++ b/services/tests/displayservicetests/src/com/android/server/display/brightness/strategy/ScreenOffBrightnessStrategyTest.java
@@ -58,7 +58,8 @@
DisplayBrightnessState updatedDisplayBrightnessState =
mScreenOffBrightnessModeStrategy.updateBrightness(
new StrategyExecutionRequest(displayPowerRequest, 0.2f,
- /* userSetBrightnessChanged= */ false));
+ /* userSetBrightnessChanged= */ false,
+ /* isStylusBeingUsed */ false));
assertEquals(updatedDisplayBrightnessState, expectedDisplayBrightnessState);
}
}
diff --git a/services/tests/displayservicetests/src/com/android/server/display/brightness/strategy/TemporaryBrightnessStrategyTest.java b/services/tests/displayservicetests/src/com/android/server/display/brightness/strategy/TemporaryBrightnessStrategyTest.java
index f523b6a..0022cab 100644
--- a/services/tests/displayservicetests/src/com/android/server/display/brightness/strategy/TemporaryBrightnessStrategyTest.java
+++ b/services/tests/displayservicetests/src/com/android/server/display/brightness/strategy/TemporaryBrightnessStrategyTest.java
@@ -60,7 +60,8 @@
DisplayBrightnessState updatedDisplayBrightnessState =
mTemporaryBrightnessStrategy.updateBrightness(
new StrategyExecutionRequest(displayPowerRequest, 0.2f,
- /* userSetBrightnessChanged= */ false));
+ /* userSetBrightnessChanged= */ false,
+ /* isStylusBeingUsed */ false));
assertEquals(updatedDisplayBrightnessState, expectedDisplayBrightnessState);
}
diff --git a/services/tests/media/mediarouterservicetest/src/com/android/server/media/AudioManagerRouteControllerTest.java b/services/tests/media/mediarouterservicetest/src/com/android/server/media/AudioManagerRouteControllerTest.java
index 1211456..439243e 100644
--- a/services/tests/media/mediarouterservicetest/src/com/android/server/media/AudioManagerRouteControllerTest.java
+++ b/services/tests/media/mediarouterservicetest/src/com/android/server/media/AudioManagerRouteControllerTest.java
@@ -82,6 +82,11 @@
private static final AudioDeviceInfo FAKE_AUDIO_DEVICE_INFO_WIRED_HEADSET =
createAudioDeviceInfo(
AudioSystem.DEVICE_OUT_WIRED_HEADSET, "name_wired_hs", /* address= */ null);
+ private static final AudioDeviceInfo FAKE_AUDIO_DEVICE_INFO_WIRED_HEADSET_WITH_ADDRESS =
+ createAudioDeviceInfo(
+ AudioSystem.DEVICE_OUT_WIRED_HEADSET,
+ "name_wired_hs_with_address",
+ /* address= */ "card=1;device=0");
private static final AudioDeviceInfo FAKE_AUDIO_DEVICE_INFO_BLUETOOTH_A2DP =
createAudioDeviceInfo(
AudioSystem.DEVICE_OUT_BLUETOOTH_A2DP, "name_a2dp", /* address= */ "12:34:45");
@@ -304,6 +309,55 @@
assertThat(selectedRoute.getName().toString()).isEqualTo(FAKE_ROUTE_NAME);
}
+ @Test
+ public void getAvailableRoutes_whenAddressIsPopulatedForNonBluetoothDevice_usesCorrectName() {
+ addAvailableAudioDeviceInfo(
+ /* newSelectedDevice= */ FAKE_AUDIO_DEVICE_INFO_WIRED_HEADSET_WITH_ADDRESS,
+ /* newAvailableDevices...= */ FAKE_AUDIO_DEVICE_INFO_WIRED_HEADSET_WITH_ADDRESS,
+ FAKE_AUDIO_DEVICE_INFO_BLUETOOTH_A2DP);
+
+ List<MediaRoute2Info> availableRoutes = mControllerUnderTest.getAvailableRoutes();
+ assertThat(availableRoutes.size()).isEqualTo(3);
+
+ assertThat(
+ getAvailableRouteWithType(MediaRoute2Info.TYPE_WIRED_HEADSET)
+ .getName()
+ .toString())
+ .isEqualTo(
+ FAKE_AUDIO_DEVICE_INFO_WIRED_HEADSET_WITH_ADDRESS
+ .getProductName()
+ .toString());
+
+ assertThat(
+ getAvailableRouteWithType(MediaRoute2Info.TYPE_BLUETOOTH_A2DP)
+ .getName()
+ .toString())
+ .isEqualTo(FAKE_AUDIO_DEVICE_INFO_BLUETOOTH_A2DP.getProductName().toString());
+ }
+
+ @Test
+ public void
+ getAvailableRoutes_whenAddressIsNotPopulatedForNonBluetoothDevice_usesCorrectName() {
+ addAvailableAudioDeviceInfo(
+ /* newSelectedDevice= */ FAKE_AUDIO_DEVICE_INFO_WIRED_HEADSET,
+ /* newAvailableDevices...= */ FAKE_AUDIO_DEVICE_INFO_WIRED_HEADSET);
+
+ List<MediaRoute2Info> availableRoutes = mControllerUnderTest.getAvailableRoutes();
+ assertThat(availableRoutes.size()).isEqualTo(2);
+
+ assertThat(
+ getAvailableRouteWithType(MediaRoute2Info.TYPE_BUILTIN_SPEAKER)
+ .getName()
+ .toString())
+ .isEqualTo(FAKE_AUDIO_DEVICE_INFO_BUILTIN_SPEAKER.getProductName().toString());
+
+ assertThat(
+ getAvailableRouteWithType(MediaRoute2Info.TYPE_WIRED_HEADSET)
+ .getName()
+ .toString())
+ .isEqualTo(FAKE_AUDIO_DEVICE_INFO_WIRED_HEADSET.getProductName().toString());
+ }
+
// Internal methods.
@NonNull
diff --git a/services/tests/mockingservicestests/src/com/android/server/pm/BackgroundUserSoundNotifierTest.java b/services/tests/mockingservicestests/src/com/android/server/pm/BackgroundUserSoundNotifierTest.java
index 9ba2724..625dbe6 100644
--- a/services/tests/mockingservicestests/src/com/android/server/pm/BackgroundUserSoundNotifierTest.java
+++ b/services/tests/mockingservicestests/src/com/android/server/pm/BackgroundUserSoundNotifierTest.java
@@ -18,6 +18,7 @@
import static android.media.AudioAttributes.USAGE_ALARM;
+import static org.junit.Assume.assumeTrue;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.clearInvocations;
@@ -91,6 +92,7 @@
}
@Test
public void testAlarmOnBackgroundUser_foregroundUserNotified() throws RemoteException {
+ assumeTrue(UserManager.supportsMultipleUsers());
AudioAttributes aa = new AudioAttributes.Builder().setUsage(USAGE_ALARM).build();
UserInfo user = createUser("User", UserManager.USER_TYPE_FULL_SECONDARY, 0);
final int fgUserId = mSpiedContext.getUserId();
@@ -100,7 +102,7 @@
/* packageName= */ "com.android.car.audio", AudioManager.AUDIOFOCUS_GAIN,
AudioManager.AUDIOFOCUS_NONE, /* flags= */ 0, Build.VERSION.SDK_INT);
clearInvocations(mNotificationManager);
- mBackgroundUserSoundNotifier.notifyForegroundUserAboutSoundIfNecessary(afi, mSpiedContext);
+ mBackgroundUserSoundNotifier.notifyForegroundUserAboutSoundIfNecessary(afi);
verify(mNotificationManager)
.notifyAsUser(eq(BackgroundUserSoundNotifier.class.getSimpleName()),
eq(afi.getClientUid()), any(Notification.class),
@@ -116,7 +118,7 @@
/* packageName= */ "com.android.car.audio", AudioManager.AUDIOFOCUS_GAIN,
AudioManager.AUDIOFOCUS_NONE, /* flags= */ 0, Build.VERSION.SDK_INT);
clearInvocations(mNotificationManager);
- mBackgroundUserSoundNotifier.notifyForegroundUserAboutSoundIfNecessary(afi, mSpiedContext);
+ mBackgroundUserSoundNotifier.notifyForegroundUserAboutSoundIfNecessary(afi);
verifyZeroInteractions(mNotificationManager);
}
@@ -131,7 +133,7 @@
AudioManager.AUDIOFOCUS_GAIN, AudioManager.AUDIOFOCUS_NONE, /* flags= */ 0,
Build.VERSION.SDK_INT);
clearInvocations(mNotificationManager);
- mBackgroundUserSoundNotifier.notifyForegroundUserAboutSoundIfNecessary(afi, mSpiedContext);
+ mBackgroundUserSoundNotifier.notifyForegroundUserAboutSoundIfNecessary(afi);
verifyZeroInteractions(mNotificationManager);
}
@@ -169,7 +171,7 @@
doReturn(focusStack).when(mockAudioPolicy).getFocusStack();
mBackgroundUserSoundNotifier.mFocusControlAudioPolicy = mockAudioPolicy;
- mBackgroundUserSoundNotifier.muteAlarmSounds(mSpiedContext);
+ mBackgroundUserSoundNotifier.muteAlarmSounds(bgUserUid);
verify(apc1.getPlayerProxy()).stop();
verify(mockAudioPolicy).sendFocusLossAndUpdate(afi);
@@ -178,6 +180,7 @@
@Test
public void testOnAudioFocusGrant_alarmOnBackgroundUser_notifiesForegroundUser() {
+ assumeTrue(UserManager.supportsMultipleUsers());
final int fgUserId = mSpiedContext.getUserId();
UserInfo bgUser = createUser("Background User", UserManager.USER_TYPE_FULL_SECONDARY, 0);
int bgUserUid = bgUser.id * 100000;
@@ -205,7 +208,7 @@
.when(mUserManager).getUserSwitchability(any());
Notification notification = mBackgroundUserSoundNotifier.createNotification(userName,
- mSpiedContext);
+ mSpiedContext, 101000);
assertEquals("Alarm for BgUser", notification.extras.getString(
Notification.EXTRA_TITLE));
@@ -232,7 +235,7 @@
.when(mUserManager).getUserSwitchability(any());
Notification notification = mBackgroundUserSoundNotifier.createNotification(userName,
- mSpiedContext);
+ mSpiedContext, 101000);
assertEquals(1, notification.actions.length);
assertEquals(mSpiedContext.getString(
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/UiModeManagerServiceTest.java b/services/tests/uiservicestests/src/com/android/server/UiModeManagerServiceTest.java
index c247c08..3b0cb4a 100644
--- a/services/tests/uiservicestests/src/com/android/server/UiModeManagerServiceTest.java
+++ b/services/tests/uiservicestests/src/com/android/server/UiModeManagerServiceTest.java
@@ -68,6 +68,7 @@
import android.Manifest;
import android.app.Activity;
+import android.app.ActivityManager;
import android.app.AlarmManager;
import android.app.Flags;
import android.app.IOnProjectionStateChangedListener;
@@ -247,6 +248,8 @@
mInjector = spy(new TestInjector());
mUiManagerService = new UiModeManagerService(mContext, /* setupWizardComplete= */ true,
mTwilightManager, mInjector);
+ // Initialize the current user.
+ mUiManagerService.setCurrentUser(ActivityManager.getCurrentUser());
try {
mUiManagerService.onBootPhase(SystemService.PHASE_SYSTEM_SERVICES_READY);
} catch (SecurityException e) {/* ignore for permission denial */}
diff --git a/services/tests/uiservicestests/src/com/android/server/notification/NotificationRecordTest.java b/services/tests/uiservicestests/src/com/android/server/notification/NotificationRecordTest.java
index 50a5f65..4391152 100644
--- a/services/tests/uiservicestests/src/com/android/server/notification/NotificationRecordTest.java
+++ b/services/tests/uiservicestests/src/com/android/server/notification/NotificationRecordTest.java
@@ -546,7 +546,8 @@
}
@Test
- @EnableFlags(com.android.server.notification.Flags.FLAG_NOTIFICATION_VIBRATION_IN_SOUND_URI)
+ @EnableFlags(com.android.server.notification.Flags
+ .FLAG_NOTIFICATION_VIBRATION_IN_SOUND_URI_FOR_CHANNEL)
public void testVibration_customVibrationForSound_withVibrationUri() throws IOException {
defaultChannel.enableVibration(true);
VibrationInfo vibration = getTestingVibration(mVibrator);
diff --git a/services/tests/wmtests/src/com/android/server/wm/ActivityStarterTests.java b/services/tests/wmtests/src/com/android/server/wm/ActivityStarterTests.java
index d0080d2..d5f86b6 100644
--- a/services/tests/wmtests/src/com/android/server/wm/ActivityStarterTests.java
+++ b/services/tests/wmtests/src/com/android/server/wm/ActivityStarterTests.java
@@ -1261,6 +1261,33 @@
}
@Test
+ public void testLaunchAdjacentDisabled() {
+ final ActivityStarter starter =
+ prepareStarter(FLAG_ACTIVITY_LAUNCH_ADJACENT, false /* mockGetRootTask */);
+ final ActivityRecord top = new ActivityBuilder(mAtm).setCreateTask(true).build();
+ final ActivityOptions options = ActivityOptions.makeBasic();
+ final ActivityRecord[] outActivity = new ActivityRecord[1];
+
+ // Activity must not land on split-screen task if currently not in split-screen mode.
+ starter.setActivityOptions(options.toBundle())
+ .setReason("testLaunchAdjacentDisabled")
+ .setOutActivity(outActivity).execute();
+ assertThat(outActivity[0].inMultiWindowMode()).isFalse();
+
+ // Move activity to split-screen-primary task and make sure it has the focus.
+ TestSplitOrganizer splitOrg = new TestSplitOrganizer(mAtm, top.getDisplayContent());
+ top.getRootTask().reparent(splitOrg.mPrimary, POSITION_BOTTOM);
+ top.getRootTask().moveToFront("testLaunchAdjacentDisabled");
+ top.getRootTask().setLaunchAdjacentDisabled(true);
+
+ // Ensure activity does not launch into split-screen-secondary when launch adjacent is
+ // disabled
+ startActivityInner(starter, outActivity[0], top, options, null /* inTask */,
+ null /* taskFragment*/);
+ assertThat(outActivity[0].isDescendantOf(splitOrg.mSecondary)).isFalse();
+ }
+
+ @Test
public void testTransientLaunchWithKeyguard() {
final ActivityStarter starter = prepareStarter(0 /* flags */);
final ActivityRecord target = new ActivityBuilder(mAtm).setCreateTask(true).build();
diff --git a/services/tests/wmtests/src/com/android/server/wm/SizeCompatTests.java b/services/tests/wmtests/src/com/android/server/wm/SizeCompatTests.java
index 72f4fa91..c1edae9 100644
--- a/services/tests/wmtests/src/com/android/server/wm/SizeCompatTests.java
+++ b/services/tests/wmtests/src/com/android/server/wm/SizeCompatTests.java
@@ -4883,7 +4883,7 @@
@Test
- @EnableCompatChanges({ActivityRecord.UNIVERSAL_RESIZABLE_BY_DEFAULT})
+ @EnableCompatChanges({ActivityInfo.UNIVERSAL_RESIZABLE_BY_DEFAULT})
public void testUniversalResizeableByDefault() {
mSetFlagsRule.enableFlags(Flags.FLAG_UNIVERSAL_RESIZABLE_BY_DEFAULT);
mDisplayContent.setIgnoreOrientationRequest(false);
diff --git a/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 47f6764..02999c8 100644
--- a/telephony/java/android/telephony/CarrierConfigManager.java
+++ b/telephony/java/android/telephony/CarrierConfigManager.java
@@ -253,7 +253,6 @@
*
* The default value is true.
*/
- @FlaggedApi(Flags.FLAG_SHOW_CALL_ID_AND_CALL_WAITING_IN_ADDITIONAL_SETTINGS_MENU)
public static final String KEY_ADDITIONAL_SETTINGS_CALLER_ID_VISIBILITY_BOOL =
"additional_settings_caller_id_visibility_bool";
@@ -263,7 +262,6 @@
*
* The default value is true.
*/
- @FlaggedApi(Flags.FLAG_SHOW_CALL_ID_AND_CALL_WAITING_IN_ADDITIONAL_SETTINGS_MENU)
public static final String KEY_ADDITIONAL_SETTINGS_CALL_WAITING_VISIBILITY_BOOL =
"additional_settings_call_waiting_visibility_bool";
@@ -10558,7 +10556,6 @@
* @see SubscriptionInfo#getServiceCapabilities()
* @see SubscriptionManager.OnSubscriptionsChangedListener
*/
- @FlaggedApi(Flags.FLAG_DATA_ONLY_CELLULAR_SERVICE)
public static final String KEY_CELLULAR_SERVICE_CAPABILITIES_INT_ARRAY =
"cellular_service_capabilities_int_array";
/**
@@ -11110,7 +11107,7 @@
sDefaults.putString(KEY_5G_ICON_DISPLAY_SECONDARY_GRACE_PERIOD_STRING, "");
sDefaults.putInt(KEY_NR_ADVANCED_BANDS_SECONDARY_TIMER_SECONDS_INT, 0);
sDefaults.putBoolean(KEY_NR_TIMERS_RESET_IF_NON_ENDC_AND_RRC_IDLE_BOOL, false);
- sDefaults.putBoolean(KEY_NR_TIMERS_RESET_ON_VOICE_QOS_BOOL, true);
+ sDefaults.putBoolean(KEY_NR_TIMERS_RESET_ON_VOICE_QOS_BOOL, false);
sDefaults.putBoolean(KEY_NR_TIMERS_RESET_ON_PLMN_CHANGE_BOOL, false);
/* Default value is 1 hour. */
sDefaults.putLong(KEY_5G_WATCHDOG_TIME_MS_LONG, 3600000);
diff --git a/telephony/java/android/telephony/SubscriptionInfo.java b/telephony/java/android/telephony/SubscriptionInfo.java
index 1089602..d164c88 100644
--- a/telephony/java/android/telephony/SubscriptionInfo.java
+++ b/telephony/java/android/telephony/SubscriptionInfo.java
@@ -951,7 +951,6 @@
* @see SubscriptionManager#SERVICE_CAPABILITY_DATA
*/
@NonNull
- @FlaggedApi(Flags.FLAG_DATA_ONLY_CELLULAR_SERVICE)
public @SubscriptionManager.ServiceCapability Set<Integer> getServiceCapabilities() {
return SubscriptionManager.getServiceCapabilitiesSet(mServiceCapabilities);
}
@@ -1829,7 +1828,6 @@
* @throws IllegalArgumentException when any capability is not supported.
*/
@NonNull
- @FlaggedApi(Flags.FLAG_DATA_ONLY_CELLULAR_SERVICE)
public Builder setServiceCapabilities(
@NonNull @SubscriptionManager.ServiceCapability Set<Integer> capabilities) {
int combinedCapabilities = 0;
diff --git a/telephony/java/android/telephony/SubscriptionManager.java b/telephony/java/android/telephony/SubscriptionManager.java
index 6faef7e..377e5f2 100644
--- a/telephony/java/android/telephony/SubscriptionManager.java
+++ b/telephony/java/android/telephony/SubscriptionManager.java
@@ -1422,7 +1422,6 @@
*
* @see TelephonyManager#isDeviceVoiceCapable()
*/
- @FlaggedApi(Flags.FLAG_DATA_ONLY_CELLULAR_SERVICE)
public static final int SERVICE_CAPABILITY_VOICE = 1;
/**
@@ -1440,13 +1439,11 @@
*
* @see TelephonyManager#isDeviceSmsCapable()
*/
- @FlaggedApi(Flags.FLAG_DATA_ONLY_CELLULAR_SERVICE)
public static final int SERVICE_CAPABILITY_SMS = 2;
/**
* Represents a value indicating the data calling capabilities of a subscription.
*/
- @FlaggedApi(Flags.FLAG_DATA_ONLY_CELLULAR_SERVICE)
public static final int SERVICE_CAPABILITY_DATA = 3;
/**
@@ -3474,14 +3471,62 @@
@SystemApi
public boolean canManageSubscription(@NonNull SubscriptionInfo info,
@NonNull String packageName) {
+ if (Flags.hsumPackageManager()) {
+ return canManageSubscriptionAsUser(info, packageName, mContext.getUser());
+ } else {
+ if (info == null || info.getAccessRules() == null || packageName == null) {
+ return false;
+ }
+ PackageManager packageManager = mContext.getPackageManager();
+ PackageInfo packageInfo;
+ try {
+ packageInfo = packageManager.getPackageInfo(packageName,
+ PackageManager.GET_SIGNING_CERTIFICATES);
+ } catch (PackageManager.NameNotFoundException e) {
+ logd("Unknown package: " + packageName);
+ return false;
+ }
+ for (UiccAccessRule rule : info.getAccessRules()) {
+ if (rule.getCarrierPrivilegeStatus(packageInfo)
+ == TelephonyManager.CARRIER_PRIVILEGE_STATUS_HAS_ACCESS) {
+ return true;
+ }
+ }
+ return false;
+ }
+ }
+
+ /**
+ * Checks whether the given app is authorized to manage the given subscription for given user.
+ *
+ * <p>An app can only be authorized if it is available to the given user and included in the
+ * {@link android.telephony.UiccAccessRule} of the {@link android.telephony.SubscriptionInfo}
+ * with the access status.
+ *
+ * <p>Only supported for embedded subscriptions (if {@link SubscriptionInfo#isEmbedded} returns
+ * true). To check for permissions for non-embedded subscription as well,
+ * see {@link android.telephony.TelephonyManager#hasCarrierPrivileges}.
+ *
+ * @param info The subscription to check.
+ * @param packageName Package name of the app to check.
+ * @param user UserHandle to check
+ * @return whether the app is authorized to manage this subscription per its access rules.
+ *
+ * @see android.telephony.TelephonyManager#hasCarrierPrivileges
+ * @hide
+ */
+ public boolean canManageSubscriptionAsUser(@NonNull SubscriptionInfo info,
+ @NonNull String packageName, @NonNull UserHandle user) {
if (info == null || info.getAccessRules() == null || packageName == null) {
return false;
}
- PackageManager packageManager = mContext.getPackageManager();
+ PackageManager pm = mContext.getUser().equals(user)
+ ? mContext.getPackageManager()
+ : mContext.createContextAsUser(user, 0).getPackageManager();
PackageInfo packageInfo;
try {
- packageInfo = packageManager.getPackageInfo(packageName,
- PackageManager.GET_SIGNING_CERTIFICATES);
+ packageInfo = pm.getPackageInfo(packageName,
+ PackageManager.GET_SIGNING_CERTIFICATES);
} catch (PackageManager.NameNotFoundException e) {
logd("Unknown package: " + packageName);
return false;
diff --git a/telephony/java/android/telephony/TelephonyManager.java b/telephony/java/android/telephony/TelephonyManager.java
index fee4587..a7fe0cb 100644
--- a/telephony/java/android/telephony/TelephonyManager.java
+++ b/telephony/java/android/telephony/TelephonyManager.java
@@ -2127,7 +2127,6 @@
* <p>On some devices, this settings activity may not exist. Callers should ensure that this
* case is appropriately handled.
*/
- @FlaggedApi(Flags.FLAG_RESET_MOBILE_NETWORK_SETTINGS)
@SdkConstant(SdkConstant.SdkConstantType.ACTIVITY_INTENT_ACTION)
public static final String ACTION_RESET_MOBILE_NETWORK_SETTINGS =
"android.telephony.action.RESET_MOBILE_NETWORK_SETTINGS";
@@ -6934,7 +6933,6 @@
*
* @see SubscriptionInfo#getServiceCapabilities()
*/
- @FlaggedApi(Flags.FLAG_DATA_ONLY_CELLULAR_SERVICE)
public boolean isDeviceVoiceCapable() {
return isVoiceCapable();
}
@@ -6974,7 +6972,6 @@
*
* @see SubscriptionInfo#getServiceCapabilities()
*/
- @FlaggedApi(Flags.FLAG_DATA_ONLY_CELLULAR_SERVICE)
public boolean isDeviceSmsCapable() {
return isSmsCapable();
}
@@ -8781,13 +8778,14 @@
* Authentication error, no memory space available in EFMUK
*
* @throws UnsupportedOperationException If the device does not have
- * {@link PackageManager#FEATURE_TELEPHONY_SUBSCRIPTION}.
+ * {@link PackageManager#FEATURE_TELEPHONY_SUBSCRIPTION} or doesn't support given
+ * authType.
*/
// TODO(b/73660190): This should probably require MODIFY_PHONE_STATE, not
// READ_PRIVILEGED_PHONE_STATE. It certainly shouldn't reference the permission in Javadoc since
// it's not public API.
@RequiresFeature(PackageManager.FEATURE_TELEPHONY_SUBSCRIPTION)
- public String getIccAuthentication(int appType,@AuthType int authType, String data) {
+ public String getIccAuthentication(int appType, @AuthType int authType, String data) {
return getIccAuthentication(getSubId(), appType, authType, data);
}
@@ -8812,10 +8810,14 @@
* Key freshness failure
* Authentication error, no memory space available
* Authentication error, no memory space available in EFMUK
+ * @throws UnsupportedOperationException If the device does not have
+ * {@link PackageManager#FEATURE_TELEPHONY_SUBSCRIPTION} or doesn't support given
+ * authType.
* @hide
*/
@UnsupportedAppUsage
- public String getIccAuthentication(int subId, int appType,@AuthType int authType, String data) {
+ public String getIccAuthentication(int subId, int appType, @AuthType int authType,
+ String data) {
try {
IPhoneSubInfo info = getSubscriberInfoService();
if (info == null)
diff --git a/tests/FlickerTests/test-apps/flickerapp/AndroidManifest.xml b/tests/FlickerTests/test-apps/flickerapp/AndroidManifest.xml
index f2e3425..9ce8e80 100644
--- a/tests/FlickerTests/test-apps/flickerapp/AndroidManifest.xml
+++ b/tests/FlickerTests/test-apps/flickerapp/AndroidManifest.xml
@@ -352,7 +352,8 @@
android:taskAffinity="com.android.server.wm.flicker.testapp.SplitScreenActivity"
android:theme="@style/CutoutShortEdges"
android:label="SplitScreenPrimaryActivity"
- android:exported="true">
+ android:exported="true"
+ android:configChanges="screenSize|smallestScreenSize|screenLayout|orientation">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
@@ -363,7 +364,8 @@
android:taskAffinity="com.android.server.wm.flicker.testapp.SplitScreenSecondaryActivity"
android:theme="@style/CutoutShortEdges"
android:label="SplitScreenSecondaryActivity"
- android:exported="true">
+ android:exported="true"
+ android:configChanges="screenSize|smallestScreenSize|screenLayout|orientation">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
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.