Merge "Fix shortcuts flash in wallpaper picker preview" into main
diff --git a/AconfigFlags.bp b/AconfigFlags.bp
index 0916227..845a28c 100644
--- a/AconfigFlags.bp
+++ b/AconfigFlags.bp
@@ -75,8 +75,78 @@
":android.speech.flags-aconfig-java{.generated_srcjars}",
":power_flags_lib{.generated_srcjars}",
":android.content.flags-aconfig-java{.generated_srcjars}",
+ ":aconfig_mediacodec_flags_java_lib{.generated_srcjars}",
]
+stubs_defaults {
+ name: "framework-minus-apex-aconfig-declarations",
+ aconfig_declarations: [
+ "android.app.flags-aconfig",
+ "android.app.smartspace.flags-aconfig",
+ "android.app.usage.flags-aconfig",
+ "android.appwidget.flags-aconfig",
+ "android.companion.flags-aconfig",
+ "android.companion.virtual.flags-aconfig",
+ "android.content.pm.flags-aconfig",
+ "android.content.res.flags-aconfig",
+ "android.credentials.flags-aconfig",
+ "android.database.sqlite-aconfig",
+ "android.hardware.biometrics.flags-aconfig",
+ "android.hardware.flags-aconfig",
+ "android.hardware.radio.flags-aconfig",
+ "android.hardware.usb.flags-aconfig",
+ "android.location.flags-aconfig",
+ "android.media.audio-aconfig",
+ "android.media.audiopolicy-aconfig",
+ "android.media.midi-aconfig",
+ "android.media.tv.flags-aconfig",
+ "android.multiuser.flags-aconfig",
+ "android.net.vcn.flags-aconfig",
+ "android.nfc.flags-aconfig",
+ "android.os.flags-aconfig",
+ "android.os.vibrator.flags-aconfig",
+ "android.permission.flags-aconfig",
+ "android.provider.flags-aconfig",
+ "android.security.flags-aconfig",
+ "android.server.app.flags-aconfig",
+ "android.service.autofill.flags-aconfig",
+ "android.service.chooser.flags-aconfig",
+ "android.service.controls.flags-aconfig",
+ "android.service.dreams.flags-aconfig",
+ "android.service.notification.flags-aconfig",
+ "android.service.voice.flags-aconfig",
+ "android.speech.flags-aconfig",
+ "android.tracing.flags-aconfig",
+ "android.view.accessibility.flags-aconfig",
+ "android.view.contentcapture.flags-aconfig",
+ "android.view.contentprotection.flags-aconfig",
+ "android.view.flags-aconfig",
+ "android.view.inputmethod.flags-aconfig",
+ "android.webkit.flags-aconfig",
+ "android.widget.flags-aconfig",
+ "camera_platform_flags",
+ "chre_flags",
+ "com.android.hardware.input.input-aconfig",
+ "com.android.input.flags-aconfig",
+ "com.android.media.flags.bettertogether-aconfig",
+ "com.android.net.flags-aconfig",
+ "com.android.server.flags.services-aconfig",
+ "com.android.text.flags-aconfig",
+ "com.android.window.flags.window-aconfig",
+ "device_policy_aconfig_flags",
+ "display_flags",
+ "fold_lock_setting_flags",
+ "framework-jobscheduler-job.flags-aconfig",
+ "framework_graphics_flags",
+ "hwui_flags",
+ "power_flags",
+ "sdk_sandbox_flags",
+ "surfaceflinger_flags",
+ "telecom_flags",
+ "telephony_flags",
+ ],
+}
+
filegroup {
name: "framework-minus-apex-aconfig-srcjars",
srcs: aconfig_srcjars,
@@ -456,6 +526,13 @@
defaults: ["framework-minus-apex-aconfig-java-defaults"],
}
+java_aconfig_library {
+ name: "com.android.media.flags.bettertogether-aconfig-java-host",
+ aconfig_declarations: "com.android.media.flags.bettertogether-aconfig",
+ host_supported: true,
+ defaults: ["framework-minus-apex-aconfig-java-defaults"],
+}
+
// Media TV
aconfig_declarations {
name: "android.media.tv.flags-aconfig",
diff --git a/TEST_MAPPING b/TEST_MAPPING
index d59775f..c904eb4 100644
--- a/TEST_MAPPING
+++ b/TEST_MAPPING
@@ -138,15 +138,13 @@
}
],
"postsubmit-ravenwood": [
- // TODO(ravenwood) promote it to presubmit
- // TODO: Enable it once the infra knows how to run it.
-// {
-// "name": "CtsUtilTestCasesRavenwood",
-// "file_patterns": [
-// "*Ravenwood*",
-// "*ravenwood*"
-// ]
-// }
+ {
+ "name": "CtsUtilTestCasesRavenwood",
+ "host": true,
+ "file_patterns": [
+ "[Rr]avenwood"
+ ]
+ }
],
"postsubmit-managedprofile-stress": [
{
diff --git a/api/Android.bp b/api/Android.bp
index 1686943..126176d 100644
--- a/api/Android.bp
+++ b/api/Android.bp
@@ -269,6 +269,7 @@
// classpath (or sources) somehow.
stubs_defaults {
name: "android-non-updatable-stubs-defaults",
+ defaults: ["framework-minus-apex-aconfig-declarations"],
srcs: [":android-non-updatable-stub-sources"],
sdk_version: "none",
system_modules: "none",
diff --git a/core/api/current.txt b/core/api/current.txt
index 7d5079a..617cd3f 100644
--- a/core/api/current.txt
+++ b/core/api/current.txt
@@ -5317,7 +5317,6 @@
ctor @Deprecated public AutomaticZenRule(String, android.content.ComponentName, android.net.Uri, int, boolean);
ctor public AutomaticZenRule(@NonNull String, @Nullable android.content.ComponentName, @Nullable android.content.ComponentName, @NonNull android.net.Uri, @Nullable android.service.notification.ZenPolicy, int, boolean);
ctor public AutomaticZenRule(android.os.Parcel);
- method @FlaggedApi("android.app.modes_api") public boolean canUpdate();
method public int describeContents();
method public android.net.Uri getConditionId();
method @Nullable public android.content.ComponentName getConfigurationActivity();
@@ -18753,21 +18752,21 @@
method @Nullable public java.security.Signature getSignature();
}
- @FlaggedApi("android.hardware.biometrics.custom_biometric_prompt") public interface PromptContentListItem {
+ @FlaggedApi("android.hardware.biometrics.custom_biometric_prompt") public interface PromptContentItem {
}
- @FlaggedApi("android.hardware.biometrics.custom_biometric_prompt") public final class PromptContentListItemBulletedText implements android.os.Parcelable android.hardware.biometrics.PromptContentListItem {
- ctor public PromptContentListItemBulletedText(@NonNull CharSequence);
+ @FlaggedApi("android.hardware.biometrics.custom_biometric_prompt") public final class PromptContentItemBulletedText implements android.os.Parcelable android.hardware.biometrics.PromptContentItem {
+ ctor public PromptContentItemBulletedText(@NonNull CharSequence);
method public int describeContents();
method public void writeToParcel(@NonNull android.os.Parcel, int);
- field @NonNull public static final android.os.Parcelable.Creator<android.hardware.biometrics.PromptContentListItemBulletedText> CREATOR;
+ field @NonNull public static final android.os.Parcelable.Creator<android.hardware.biometrics.PromptContentItemBulletedText> CREATOR;
}
- @FlaggedApi("android.hardware.biometrics.custom_biometric_prompt") public final class PromptContentListItemPlainText implements android.os.Parcelable android.hardware.biometrics.PromptContentListItem {
- ctor public PromptContentListItemPlainText(@NonNull CharSequence);
+ @FlaggedApi("android.hardware.biometrics.custom_biometric_prompt") public final class PromptContentItemPlainText implements android.os.Parcelable android.hardware.biometrics.PromptContentItem {
+ ctor public PromptContentItemPlainText(@NonNull CharSequence);
method public int describeContents();
method public void writeToParcel(@NonNull android.os.Parcel, int);
- field @NonNull public static final android.os.Parcelable.Creator<android.hardware.biometrics.PromptContentListItemPlainText> CREATOR;
+ field @NonNull public static final android.os.Parcelable.Creator<android.hardware.biometrics.PromptContentItemPlainText> CREATOR;
}
@FlaggedApi("android.hardware.biometrics.custom_biometric_prompt") public interface PromptContentView {
@@ -18776,7 +18775,7 @@
@FlaggedApi("android.hardware.biometrics.custom_biometric_prompt") public final class PromptVerticalListContentView implements android.os.Parcelable android.hardware.biometrics.PromptContentView {
method public int describeContents();
method @Nullable public CharSequence getDescription();
- method @NonNull public java.util.List<android.hardware.biometrics.PromptContentListItem> getListItems();
+ method @NonNull public java.util.List<android.hardware.biometrics.PromptContentItem> getListItems();
method public static int getMaxEachItemCharacterNumber();
method public static int getMaxItemCount();
method public void writeToParcel(@NonNull android.os.Parcel, int);
@@ -18785,7 +18784,8 @@
public static final class PromptVerticalListContentView.Builder {
ctor public PromptVerticalListContentView.Builder();
- method @NonNull public android.hardware.biometrics.PromptVerticalListContentView.Builder addListItem(@NonNull android.hardware.biometrics.PromptContentListItem);
+ method @NonNull public android.hardware.biometrics.PromptVerticalListContentView.Builder addListItem(@NonNull android.hardware.biometrics.PromptContentItem);
+ method @NonNull public android.hardware.biometrics.PromptVerticalListContentView.Builder addListItem(@NonNull android.hardware.biometrics.PromptContentItem, int);
method @NonNull public android.hardware.biometrics.PromptVerticalListContentView build();
method @NonNull public android.hardware.biometrics.PromptVerticalListContentView.Builder setDescription(@NonNull CharSequence);
}
@@ -23341,6 +23341,7 @@
field public static final String KEY_HDR10_PLUS_INFO = "hdr10-plus-info";
field public static final String KEY_HDR_STATIC_INFO = "hdr-static-info";
field public static final String KEY_HEIGHT = "height";
+ field @FlaggedApi("com.android.media.codec.flags.codec_importance") public static final String KEY_IMPORTANCE = "importance";
field public static final String KEY_INTRA_REFRESH_PERIOD = "intra-refresh-period";
field public static final String KEY_IS_ADTS = "is-adts";
field public static final String KEY_IS_AUTOSELECT = "is-autoselect";
@@ -26669,12 +26670,16 @@
public static final class TvContract.Channels implements android.media.tv.TvContract.BaseTvColumns {
method @Nullable public static String getVideoResolution(String);
+ field @FlaggedApi("android.media.tv.flags.broadcast_visibility_types") public static final int BROADCAST_VISIBILITY_TYPE_INVISIBLE = 2; // 0x2
+ field @FlaggedApi("android.media.tv.flags.broadcast_visibility_types") public static final int BROADCAST_VISIBILITY_TYPE_NUMERIC_SELECTABLE_ONLY = 1; // 0x1
+ field @FlaggedApi("android.media.tv.flags.broadcast_visibility_types") public static final int BROADCAST_VISIBILITY_TYPE_VISIBLE = 0; // 0x0
field public static final String COLUMN_APP_LINK_COLOR = "app_link_color";
field public static final String COLUMN_APP_LINK_ICON_URI = "app_link_icon_uri";
field public static final String COLUMN_APP_LINK_INTENT_URI = "app_link_intent_uri";
field public static final String COLUMN_APP_LINK_POSTER_ART_URI = "app_link_poster_art_uri";
field public static final String COLUMN_APP_LINK_TEXT = "app_link_text";
field public static final String COLUMN_BROADCAST_GENRE = "broadcast_genre";
+ field @FlaggedApi("android.media.tv.flags.broadcast_visibility_types") public static final String COLUMN_BROADCAST_VISIBILITY_TYPE = "broadcast_visibility_type";
field public static final String COLUMN_BROWSABLE = "browsable";
field public static final String COLUMN_CHANNEL_LIST_ID = "channel_list_id";
field public static final String COLUMN_DESCRIPTION = "description";
@@ -40512,7 +40517,6 @@
public final class ZenPolicy implements android.os.Parcelable {
method public int describeContents();
- method @FlaggedApi("android.app.modes_api") public int getAllowedChannels();
method public int getPriorityCallSenders();
method public int getPriorityCategoryAlarms();
method public int getPriorityCategoryCalls();
@@ -40523,6 +40527,7 @@
method public int getPriorityCategoryReminders();
method public int getPriorityCategoryRepeatCallers();
method public int getPriorityCategorySystem();
+ method @FlaggedApi("android.app.modes_api") public int getPriorityChannels();
method public int getPriorityConversationSenders();
method public int getPriorityMessageSenders();
method public int getVisualEffectAmbient();
@@ -40533,9 +40538,6 @@
method public int getVisualEffectPeek();
method public int getVisualEffectStatusBar();
method public void writeToParcel(android.os.Parcel, int);
- field @FlaggedApi("android.app.modes_api") public static final int CHANNEL_TYPE_NONE = 2; // 0x2
- field @FlaggedApi("android.app.modes_api") public static final int CHANNEL_TYPE_PRIORITY = 1; // 0x1
- field @FlaggedApi("android.app.modes_api") public static final int CHANNEL_TYPE_UNSET = 0; // 0x0
field public static final int CONVERSATION_SENDERS_ANYONE = 1; // 0x1
field public static final int CONVERSATION_SENDERS_IMPORTANT = 2; // 0x2
field public static final int CONVERSATION_SENDERS_NONE = 3; // 0x3
@@ -40556,11 +40558,11 @@
method @NonNull public android.service.notification.ZenPolicy.Builder allowAlarms(boolean);
method @NonNull public android.service.notification.ZenPolicy.Builder allowAllSounds();
method @NonNull public android.service.notification.ZenPolicy.Builder allowCalls(int);
- method @FlaggedApi("android.app.modes_api") @NonNull public android.service.notification.ZenPolicy.Builder allowChannels(int);
method @NonNull public android.service.notification.ZenPolicy.Builder allowConversations(int);
method @NonNull public android.service.notification.ZenPolicy.Builder allowEvents(boolean);
method @NonNull public android.service.notification.ZenPolicy.Builder allowMedia(boolean);
method @NonNull public android.service.notification.ZenPolicy.Builder allowMessages(int);
+ method @FlaggedApi("android.app.modes_api") @NonNull public android.service.notification.ZenPolicy.Builder allowPriorityChannels(boolean);
method @NonNull public android.service.notification.ZenPolicy.Builder allowReminders(boolean);
method @NonNull public android.service.notification.ZenPolicy.Builder allowRepeatCallers(boolean);
method @NonNull public android.service.notification.ZenPolicy.Builder allowSystem(boolean);
@@ -41656,6 +41658,7 @@
method public void sendEvent(@NonNull String, @NonNull android.os.Bundle);
method public void setActive(@NonNull java.util.concurrent.Executor, @NonNull android.os.OutcomeReceiver<java.lang.Void,android.telecom.CallException>);
method public void setInactive(@NonNull java.util.concurrent.Executor, @NonNull android.os.OutcomeReceiver<java.lang.Void,android.telecom.CallException>);
+ method @FlaggedApi("com.android.server.telecom.flags.set_mute_state") public void setMuteState(boolean, @NonNull java.util.concurrent.Executor, @NonNull android.os.OutcomeReceiver<java.lang.Void,android.telecom.CallException>);
method public void startCallStreaming(@NonNull java.util.concurrent.Executor, @NonNull android.os.OutcomeReceiver<java.lang.Void,android.telecom.CallException>);
}
@@ -43074,6 +43077,8 @@
field public static final String KEY_RTT_UPGRADE_SUPPORTED_FOR_DOWNGRADED_VT_CALL_BOOL = "rtt_upgrade_supported_for_downgraded_vt_call";
field @FlaggedApi("com.android.internal.telephony.flags.carrier_enabled_satellite_flag") public static final String KEY_SATELLITE_ATTACH_SUPPORTED_BOOL = "satellite_attach_supported_bool";
field @FlaggedApi("com.android.internal.telephony.flags.carrier_enabled_satellite_flag") public static final String KEY_SATELLITE_CONNECTION_HYSTERESIS_SEC_INT = "satellite_connection_hysteresis_sec_int";
+ field @FlaggedApi("com.android.internal.telephony.flags.carrier_enabled_satellite_flag") public static final String KEY_SATELLITE_ENTITLEMENT_STATUS_REFRESH_DAYS_INT = "satellite_entitlement_status_refresh_days_int";
+ field @FlaggedApi("com.android.internal.telephony.flags.carrier_enabled_satellite_flag") public static final String KEY_SATELLITE_ENTITLEMENT_SUPPORTED_BOOL = "satellite_entitlement_supported_bool";
field public static final String KEY_SHOW_4G_FOR_3G_DATA_ICON_BOOL = "show_4g_for_3g_data_icon_bool";
field public static final String KEY_SHOW_4G_FOR_LTE_DATA_ICON_BOOL = "show_4g_for_lte_data_icon_bool";
field public static final String KEY_SHOW_APN_SETTING_CDMA_BOOL = "show_apn_setting_cdma_bool";
diff --git a/core/api/system-current.txt b/core/api/system-current.txt
index d26662d..2596f9c 100644
--- a/core/api/system-current.txt
+++ b/core/api/system-current.txt
@@ -133,6 +133,7 @@
field public static final String FORCE_STOP_PACKAGES = "android.permission.FORCE_STOP_PACKAGES";
field public static final String GET_APP_METADATA = "android.permission.GET_APP_METADATA";
field public static final String GET_APP_OPS_STATS = "android.permission.GET_APP_OPS_STATS";
+ field @FlaggedApi("android.app.bic_client") public static final String GET_BACKGROUND_INSTALLED_PACKAGES = "android.permission.GET_BACKGROUND_INSTALLED_PACKAGES";
field @FlaggedApi("android.app.get_binding_uid_importance") public static final String GET_BINDING_UID_IMPORTANCE = "android.permission.GET_BINDING_UID_IMPORTANCE";
field public static final String GET_HISTORICAL_APP_OPS_STATS = "android.permission.GET_HISTORICAL_APP_OPS_STATS";
field public static final String GET_PROCESS_STATE_AND_OOM_SCORE = "android.permission.GET_PROCESS_STATE_AND_OOM_SCORE";
@@ -622,6 +623,7 @@
field public static final String OPSTR_ACCEPT_HANDOVER = "android:accept_handover";
field public static final String OPSTR_ACCESS_ACCESSIBILITY = "android:access_accessibility";
field public static final String OPSTR_ACCESS_NOTIFICATIONS = "android:access_notifications";
+ field @FlaggedApi("android.permission.flags.enhanced_confirmation_mode_apis_enabled") public static final String OPSTR_ACCESS_RESTRICTED_SETTINGS = "android:access_restricted_settings";
field public static final String OPSTR_ACTIVATE_PLATFORM_VPN = "android:activate_platform_vpn";
field public static final String OPSTR_ACTIVATE_VPN = "android:activate_vpn";
field public static final String OPSTR_ASSIST_SCREENSHOT = "android:assist_screenshot";
@@ -3541,6 +3543,7 @@
field public static final String CLOUDSEARCH_SERVICE = "cloudsearch";
field public static final String CONTENT_SUGGESTIONS_SERVICE = "content_suggestions";
field public static final String CONTEXTHUB_SERVICE = "contexthub";
+ field @FlaggedApi("android.permission.flags.enhanced_confirmation_mode_apis_enabled") public static final String ECM_ENHANCED_CONFIRMATION_SERVICE = "ecm_enhanced_confirmation";
field public static final String ETHERNET_SERVICE = "ethernet";
field public static final String EUICC_CARD_SERVICE = "euicc_card";
field public static final String FONT_SERVICE = "font";
@@ -4219,11 +4222,14 @@
field @NonNull public static final android.os.Parcelable.Creator<android.content.pm.UserProperties> CREATOR;
field public static final int CROSS_PROFILE_CONTENT_SHARING_DELEGATE_FROM_PARENT = 1; // 0x1
field public static final int CROSS_PROFILE_CONTENT_SHARING_NO_DELEGATION = 0; // 0x0
+ field public static final int CROSS_PROFILE_CONTENT_SHARING_UNKNOWN = -1; // 0xffffffff
field public static final int SHOW_IN_QUIET_MODE_DEFAULT = 2; // 0x2
field public static final int SHOW_IN_QUIET_MODE_HIDDEN = 1; // 0x1
field public static final int SHOW_IN_QUIET_MODE_PAUSED = 0; // 0x0
+ field public static final int SHOW_IN_QUIET_MODE_UNKNOWN = -1; // 0xffffffff
field public static final int SHOW_IN_SHARING_SURFACES_NO = 2; // 0x2
field public static final int SHOW_IN_SHARING_SURFACES_SEPARATE = 1; // 0x1
+ field public static final int SHOW_IN_SHARING_SURFACES_UNKNOWN = -1; // 0xffffffff
field public static final int SHOW_IN_SHARING_SURFACES_WITH_PARENT = 0; // 0x0
}
@@ -14554,6 +14560,7 @@
field public static final int EVENT_SERVICE_STATE_CHANGED = 1; // 0x1
field public static final int EVENT_SIGNAL_STRENGTHS_CHANGED = 9; // 0x9
field public static final int EVENT_SIGNAL_STRENGTH_CHANGED = 2; // 0x2
+ field @FlaggedApi("com.android.internal.telephony.flags.simultaneous_calling_indications") @RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE) public static final int EVENT_SIMULTANEOUS_CELLULAR_CALLING_SUBSCRIPTIONS_CHANGED = 41; // 0x29
field @RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE) public static final int EVENT_SRVCC_STATE_CHANGED = 16; // 0x10
field public static final int EVENT_USER_MOBILE_DATA_STATE_CHANGED = 20; // 0x14
field @RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE) public static final int EVENT_VOICE_ACTIVATION_STATE_CHANGED = 18; // 0x12
@@ -14600,6 +14607,10 @@
method @RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE) public void onRadioPowerStateChanged(int);
}
+ @FlaggedApi("com.android.internal.telephony.flags.simultaneous_calling_indications") public static interface TelephonyCallback.SimultaneousCellularCallingSupportListener {
+ method @RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE) public void onSimultaneousCellularCallingSubscriptionsChanged(@NonNull java.util.Set<java.lang.Integer>);
+ }
+
public static interface TelephonyCallback.SrvccStateListener {
method @RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE) public void onSrvccStateChanged(int);
}
@@ -17154,6 +17165,7 @@
field @FlaggedApi("com.android.internal.telephony.flags.oem_enabled_satellite_flag") public static final int NT_RADIO_TECHNOLOGY_NR_NTN = 2; // 0x2
field @FlaggedApi("com.android.internal.telephony.flags.oem_enabled_satellite_flag") public static final int NT_RADIO_TECHNOLOGY_PROPRIETARY = 4; // 0x4
field @FlaggedApi("com.android.internal.telephony.flags.oem_enabled_satellite_flag") public static final int NT_RADIO_TECHNOLOGY_UNKNOWN = 0; // 0x0
+ field @FlaggedApi("com.android.internal.telephony.flags.carrier_enabled_satellite_flag") public static final int SATELLITE_COMMUNICATION_RESTRICTION_REASON_ENTITLEMENT = 2; // 0x2
field @FlaggedApi("com.android.internal.telephony.flags.carrier_enabled_satellite_flag") public static final int SATELLITE_COMMUNICATION_RESTRICTION_REASON_GEOLOCATION = 1; // 0x1
field @FlaggedApi("com.android.internal.telephony.flags.oem_enabled_satellite_flag") public static final int SATELLITE_DATAGRAM_TRANSFER_STATE_IDLE = 0; // 0x0
field @FlaggedApi("com.android.internal.telephony.flags.oem_enabled_satellite_flag") public static final int SATELLITE_DATAGRAM_TRANSFER_STATE_RECEIVE_FAILED = 7; // 0x7
diff --git a/core/api/test-current.txt b/core/api/test-current.txt
index bbe03a3..0d1d8d7 100644
--- a/core/api/test-current.txt
+++ b/core/api/test-current.txt
@@ -284,16 +284,6 @@
method public default void onOpActiveChanged(@NonNull String, int, @NonNull String, @Nullable String, boolean, int, int);
}
- public final class AutomaticZenRule implements android.os.Parcelable {
- method @FlaggedApi("android.app.modes_api") public int getUserModifiedFields();
- field @FlaggedApi("android.app.modes_api") public static final int FIELD_INTERRUPTION_FILTER = 2; // 0x2
- field @FlaggedApi("android.app.modes_api") public static final int FIELD_NAME = 1; // 0x1
- }
-
- @FlaggedApi("android.app.modes_api") public static final class AutomaticZenRule.Builder {
- method @FlaggedApi("android.app.modes_api") @NonNull public android.app.AutomaticZenRule.Builder setUserModifiedFields(int);
- }
-
public class BroadcastOptions extends android.app.ComponentOptions {
ctor public BroadcastOptions();
ctor public BroadcastOptions(@NonNull android.os.Bundle);
@@ -1177,6 +1167,7 @@
method public int getShowInLauncher();
field public static final int SHOW_IN_LAUNCHER_NO = 2; // 0x2
field public static final int SHOW_IN_LAUNCHER_SEPARATE = 1; // 0x1
+ field public static final int SHOW_IN_LAUNCHER_UNKNOWN = -1; // 0xffffffff
field public static final int SHOW_IN_LAUNCHER_WITH_PARENT = 0; // 0x0
}
@@ -3021,47 +3012,8 @@
method @Deprecated public boolean isBound();
}
- @FlaggedApi("android.app.modes_api") public final class ZenDeviceEffects implements android.os.Parcelable {
- method public int getUserModifiedFields();
- field public static final int FIELD_DIM_WALLPAPER = 4; // 0x4
- field public static final int FIELD_DISABLE_AUTO_BRIGHTNESS = 16; // 0x10
- field public static final int FIELD_DISABLE_TAP_TO_WAKE = 32; // 0x20
- field public static final int FIELD_DISABLE_TILT_TO_WAKE = 64; // 0x40
- field public static final int FIELD_DISABLE_TOUCH = 128; // 0x80
- field public static final int FIELD_GRAYSCALE = 1; // 0x1
- field public static final int FIELD_MAXIMIZE_DOZE = 512; // 0x200
- field public static final int FIELD_MINIMIZE_RADIO_USAGE = 256; // 0x100
- field public static final int FIELD_NIGHT_MODE = 8; // 0x8
- field public static final int FIELD_SUPPRESS_AMBIENT_DISPLAY = 2; // 0x2
- }
-
- @FlaggedApi("android.app.modes_api") public static final class ZenDeviceEffects.Builder {
- method @NonNull public android.service.notification.ZenDeviceEffects.Builder setUserModifiedFields(int);
- }
-
- public final class ZenPolicy implements android.os.Parcelable {
- method @FlaggedApi("android.app.modes_api") public int getUserModifiedFields();
- field @FlaggedApi("android.app.modes_api") public static final int FIELD_ALLOW_CHANNELS = 8; // 0x8
- field @FlaggedApi("android.app.modes_api") public static final int FIELD_CALLS = 2; // 0x2
- field @FlaggedApi("android.app.modes_api") public static final int FIELD_CONVERSATIONS = 4; // 0x4
- field @FlaggedApi("android.app.modes_api") public static final int FIELD_MESSAGES = 1; // 0x1
- field @FlaggedApi("android.app.modes_api") public static final int FIELD_PRIORITY_CATEGORY_ALARMS = 128; // 0x80
- field @FlaggedApi("android.app.modes_api") public static final int FIELD_PRIORITY_CATEGORY_EVENTS = 32; // 0x20
- field @FlaggedApi("android.app.modes_api") public static final int FIELD_PRIORITY_CATEGORY_MEDIA = 256; // 0x100
- field @FlaggedApi("android.app.modes_api") public static final int FIELD_PRIORITY_CATEGORY_REPEAT_CALLERS = 64; // 0x40
- field @FlaggedApi("android.app.modes_api") public static final int FIELD_PRIORITY_CATEGORY_SYSTEM = 512; // 0x200
- field @FlaggedApi("android.app.modes_api") public static final int FIELD_VISUAL_EFFECT_AMBIENT = 32768; // 0x8000
- field @FlaggedApi("android.app.modes_api") public static final int FIELD_VISUAL_EFFECT_BADGE = 16384; // 0x4000
- field @FlaggedApi("android.app.modes_api") public static final int FIELD_VISUAL_EFFECT_FULL_SCREEN_INTENT = 1024; // 0x400
- field @FlaggedApi("android.app.modes_api") public static final int FIELD_VISUAL_EFFECT_LIGHTS = 2048; // 0x800
- field @FlaggedApi("android.app.modes_api") public static final int FIELD_VISUAL_EFFECT_NOTIFICATION_LIST = 65536; // 0x10000
- field @FlaggedApi("android.app.modes_api") public static final int FIELD_VISUAL_EFFECT_PEEK = 4096; // 0x1000
- field @FlaggedApi("android.app.modes_api") public static final int FIELD_VISUAL_EFFECT_STATUS_BAR = 8192; // 0x2000
- }
-
public static final class ZenPolicy.Builder {
ctor public ZenPolicy.Builder(@Nullable android.service.notification.ZenPolicy);
- method @FlaggedApi("android.app.modes_api") @NonNull public android.service.notification.ZenPolicy.Builder setUserModifiedFields(int);
}
}
diff --git a/core/java/android/app/ActivityManager.java b/core/java/android/app/ActivityManager.java
index ebb5ba0..1fd49ef 100644
--- a/core/java/android/app/ActivityManager.java
+++ b/core/java/android/app/ActivityManager.java
@@ -3574,7 +3574,7 @@
* foreground. This may be running a window that is behind the current
* foreground (so paused and with its state saved, not interacting with
* the user, but visible to them to some degree); it may also be running
- * other services under the system's control that it inconsiders important.
+ * other services under the system's control that it considers important.
*/
public static final int IMPORTANCE_VISIBLE = 200;
@@ -3646,9 +3646,9 @@
public static final int IMPORTANCE_CANT_SAVE_STATE = 350;
/**
- * Constant for {@link #importance}: This process process contains
- * cached code that is expendable, not actively running any app components
- * we care about.
+ * Constant for {@link #importance}: This process contains cached code
+ * that is expendable, not actively running any app components we care
+ * about.
*/
public static final int IMPORTANCE_CACHED = 400;
diff --git a/core/java/android/app/AppOpsManager.java b/core/java/android/app/AppOpsManager.java
index 1db1caf..669baf9 100644
--- a/core/java/android/app/AppOpsManager.java
+++ b/core/java/android/app/AppOpsManager.java
@@ -2180,6 +2180,8 @@
*
* @hide
*/
+ @FlaggedApi(android.permission.flags.Flags.FLAG_ENHANCED_CONFIRMATION_MODE_APIS_ENABLED)
+ @SystemApi
public static final String OPSTR_ACCESS_RESTRICTED_SETTINGS =
"android:access_restricted_settings";
diff --git a/core/java/android/app/AutomaticZenRule.java b/core/java/android/app/AutomaticZenRule.java
index 5b354fc..d57a4e5 100644
--- a/core/java/android/app/AutomaticZenRule.java
+++ b/core/java/android/app/AutomaticZenRule.java
@@ -23,7 +23,6 @@
import android.annotation.IntDef;
import android.annotation.NonNull;
import android.annotation.Nullable;
-import android.annotation.TestApi;
import android.app.NotificationManager.InterruptionFilter;
import android.content.ComponentName;
import android.net.Uri;
@@ -113,8 +112,8 @@
@Retention(RetentionPolicy.SOURCE)
public @interface Type {}
- /** Used to track which rule variables have been modified by the user.
- * Should be checked against the bitmask {@link #getUserModifiedFields()}.
+ /**
+ * Enum for the user-modifiable fields in this object.
* @hide
*/
@IntDef(flag = true, prefix = { "FIELD_" }, value = {
@@ -128,13 +127,11 @@
* @hide
*/
@FlaggedApi(Flags.FLAG_MODES_API)
- @TestApi
public static final int FIELD_NAME = 1 << 0;
/**
* @hide
*/
@FlaggedApi(Flags.FLAG_MODES_API)
- @TestApi
public static final int FIELD_INTERRUPTION_FILTER = 1 << 1;
private boolean enabled;
@@ -153,7 +150,6 @@
private int mIconResId;
private String mTriggerDescription;
private boolean mAllowManualInvocation;
- private @ModifiableField int mUserModifiedFields; // Bitwise representation
/**
* The maximum string length for any string contained in this automatic zen rule. This pertains
@@ -256,7 +252,6 @@
mIconResId = source.readInt();
mTriggerDescription = getTrimmedString(source.readString(), MAX_DESC_LENGTH);
mType = source.readInt();
- mUserModifiedFields = source.readInt();
}
}
@@ -307,8 +302,7 @@
* Returns whether this rule's name has been modified by the user.
* @hide
*/
- // TODO: b/310620812 - Replace with mUserModifiedFields & FIELD_NAME once
- // FLAG_MODES_API is inlined.
+ // TODO: b/310620812 - Consider removing completely. Seems not be used anywhere except tests.
public boolean isModified() {
return mModified;
}
@@ -506,32 +500,6 @@
return type;
}
- /**
- * Gets the bitmask representing which fields are user modified. Bits are set using
- * {@link ModifiableField}.
- * @hide
- */
- @FlaggedApi(Flags.FLAG_MODES_API)
- @TestApi
- public @ModifiableField int getUserModifiedFields() {
- return mUserModifiedFields;
- }
-
- /**
- * Returns {@code true} if the {@link AutomaticZenRule} can be updated.
- * When this returns {@code false}, calls to
- * {@link NotificationManager#updateAutomaticZenRule(String, AutomaticZenRule)}) with this rule
- * will ignore changes to user-configurable fields.
- */
- @FlaggedApi(Flags.FLAG_MODES_API)
- public boolean canUpdate() {
- // The rule is considered updateable if its bitmask has no user modifications, and
- // the bitmasks of the policy and device effects have no modification.
- return mUserModifiedFields == 0
- && (mZenPolicy == null || mZenPolicy.getUserModifiedFields() == 0)
- && (mDeviceEffects == null || mDeviceEffects.getUserModifiedFields() == 0);
- }
-
@Override
public int describeContents() {
return 0;
@@ -560,7 +528,6 @@
dest.writeInt(mIconResId);
dest.writeString(mTriggerDescription);
dest.writeInt(mType);
- dest.writeInt(mUserModifiedFields);
}
}
@@ -582,16 +549,14 @@
.append(",allowManualInvocation=").append(mAllowManualInvocation)
.append(",iconResId=").append(mIconResId)
.append(",triggerDescription=").append(mTriggerDescription)
- .append(",type=").append(mType)
- .append(",userModifiedFields=")
- .append(modifiedFieldsToString(mUserModifiedFields));
+ .append(",type=").append(mType);
}
return sb.append(']').toString();
}
- @FlaggedApi(Flags.FLAG_MODES_API)
- private String modifiedFieldsToString(int bitmask) {
+ /** @hide */
+ public static String fieldsToString(@ModifiableField int bitmask) {
ArrayList<String> modified = new ArrayList<>();
if ((bitmask & FIELD_NAME) != 0) {
modified.add("FIELD_NAME");
@@ -623,8 +588,7 @@
&& other.mAllowManualInvocation == mAllowManualInvocation
&& other.mIconResId == mIconResId
&& Objects.equals(other.mTriggerDescription, mTriggerDescription)
- && other.mType == mType
- && other.mUserModifiedFields == mUserModifiedFields;
+ && other.mType == mType;
}
return finalEquals;
}
@@ -634,8 +598,7 @@
if (Flags.modesApi()) {
return Objects.hash(enabled, name, interruptionFilter, conditionId, owner,
configurationActivity, mZenPolicy, mDeviceEffects, mModified, creationTime,
- mPkg, mAllowManualInvocation, mIconResId, mTriggerDescription, mType,
- mUserModifiedFields);
+ mPkg, mAllowManualInvocation, mIconResId, mTriggerDescription, mType);
}
return Objects.hash(enabled, name, interruptionFilter, conditionId, owner,
configurationActivity, mZenPolicy, mModified, creationTime, mPkg);
@@ -704,7 +667,6 @@
private boolean mAllowManualInvocation;
private long mCreationTime;
private String mPkg;
- private @ModifiableField int mUserModifiedFields;
public Builder(@NonNull AutomaticZenRule rule) {
mName = rule.getName();
@@ -721,7 +683,6 @@
mAllowManualInvocation = rule.isManualInvocationAllowed();
mCreationTime = rule.getCreationTime();
mPkg = rule.getPackageName();
- mUserModifiedFields = rule.mUserModifiedFields;
}
public Builder(@NonNull String name, @NonNull Uri conditionId) {
@@ -848,19 +809,6 @@
return this;
}
- /**
- * Sets the bitmask representing which fields have been user-modified.
- * This method should not be used outside of tests. The value of userModifiedFields
- * should be set based on what values are changed when a rule is populated or updated..
- * @hide
- */
- @FlaggedApi(Flags.FLAG_MODES_API)
- @TestApi
- public @NonNull Builder setUserModifiedFields(@ModifiableField int userModifiedFields) {
- mUserModifiedFields = userModifiedFields;
- return this;
- }
-
public @NonNull AutomaticZenRule build() {
AutomaticZenRule rule = new AutomaticZenRule(mName, mOwner, mConfigurationActivity,
mConditionId, mPolicy, mInterruptionFilter, mEnabled);
@@ -871,7 +819,6 @@
rule.mIconResId = mIconResId;
rule.mAllowManualInvocation = mAllowManualInvocation;
rule.setPackageName(mPkg);
- rule.mUserModifiedFields = mUserModifiedFields;
return rule;
}
diff --git a/core/java/android/app/Notification.java b/core/java/android/app/Notification.java
index 476232c..ed0cfbe 100644
--- a/core/java/android/app/Notification.java
+++ b/core/java/android/app/Notification.java
@@ -5652,7 +5652,7 @@
pillColor = Colors.flattenAlpha(
getColors(p).getTertiaryFixedDimAccentColor(), bgColor);
textColor = Colors.flattenAlpha(
- getColors(p).getOnTertiaryAccentTextColor(), pillColor);
+ getColors(p).getOnTertiaryFixedAccentTextColor(), pillColor);
}
contentView.setInt(R.id.expand_button, "setHighlightTextColor", textColor);
contentView.setInt(R.id.expand_button, "setHighlightPillColor", pillColor);
diff --git a/core/java/android/app/SystemServiceRegistry.java b/core/java/android/app/SystemServiceRegistry.java
index 9cf732a..d755413 100644
--- a/core/java/android/app/SystemServiceRegistry.java
+++ b/core/java/android/app/SystemServiceRegistry.java
@@ -31,6 +31,7 @@
import android.app.blob.BlobStoreManagerFrameworkInitializer;
import android.app.contentsuggestions.ContentSuggestionsManager;
import android.app.contentsuggestions.IContentSuggestionsManager;
+import android.app.ecm.EnhancedConfirmationFrameworkInitializer;
import android.app.job.JobSchedulerFrameworkInitializer;
import android.app.people.PeopleManager;
import android.app.prediction.AppPredictionManager;
@@ -1631,6 +1632,9 @@
OnDevicePersonalizationFrameworkInitializer.registerServiceWrappers();
DeviceLockFrameworkInitializer.registerServiceWrappers();
VirtualizationFrameworkInitializer.registerServiceWrappers();
+ if (android.permission.flags.Flags.enhancedConfirmationModeApisEnabled()) {
+ EnhancedConfirmationFrameworkInitializer.registerServiceWrappers();
+ }
} finally {
// If any of the above code throws, we're in a pretty bad shape and the process
// will likely crash, but we'll reset it just in case there's an exception handler...
diff --git a/core/java/android/app/activity_manager.aconfig b/core/java/android/app/activity_manager.aconfig
index b303ea6..4fc25fd 100644
--- a/core/java/android/app/activity_manager.aconfig
+++ b/core/java/android/app/activity_manager.aconfig
@@ -13,3 +13,10 @@
description: "API to get importance of UID that's binding to the caller"
bug: "292533010"
}
+
+flag {
+ namespace: "backstage_power"
+ name: "app_restrictions_api"
+ description: "API to track and query restrictions applied to apps"
+ bug: "320150834"
+}
\ No newline at end of file
diff --git a/core/java/android/content/AttributionSource.java b/core/java/android/content/AttributionSource.java
index a1357c9..bde562d 100644
--- a/core/java/android/content/AttributionSource.java
+++ b/core/java/android/content/AttributionSource.java
@@ -231,7 +231,7 @@
}
/** @hide */
- public AttributionSource withToken(@NonNull Binder token) {
+ public AttributionSource withToken(@NonNull IBinder token) {
return new AttributionSource(getUid(), getPid(), getPackageName(), getAttributionTag(),
token, mAttributionSourceState.renouncedPermissions, getDeviceId(), getNext());
}
diff --git a/core/java/android/content/Context.java b/core/java/android/content/Context.java
index 4bc1237..249c0e43 100644
--- a/core/java/android/content/Context.java
+++ b/core/java/android/content/Context.java
@@ -4242,6 +4242,7 @@
VIRTUALIZATION_SERVICE,
GRAMMATICAL_INFLECTION_SERVICE,
SECURITY_STATE_SERVICE,
+ //@hide: ECM_ENHANCED_CONFIRMATION_SERVICE,
})
@Retention(RetentionPolicy.SOURCE)
@@ -6527,6 +6528,18 @@
public static final String SECURITY_STATE_SERVICE = "security_state";
/**
+ * Use with {@link #getSystemService(String)} to retrieve an
+ * {@link android.app.ecm.EnhancedConfirmationManager}.
+ *
+ * @see #getSystemService(String)
+ * @see android.app.ecm.EnhancedConfirmationManager
+ * @hide
+ */
+ @FlaggedApi(android.permission.flags.Flags.FLAG_ENHANCED_CONFIRMATION_MODE_APIS_ENABLED)
+ @SystemApi
+ public static final String ECM_ENHANCED_CONFIRMATION_SERVICE = "ecm_enhanced_confirmation";
+
+ /**
* Determine whether the given permission is allowed for a particular
* process and user ID running in the system.
*
diff --git a/core/java/android/content/pm/UserProperties.java b/core/java/android/content/pm/UserProperties.java
index 57749d4..269c6c2 100644
--- a/core/java/android/content/pm/UserProperties.java
+++ b/core/java/android/content/pm/UserProperties.java
@@ -123,6 +123,7 @@
* @hide
*/
@IntDef(prefix = "SHOW_IN_LAUNCHER_", value = {
+ SHOW_IN_LAUNCHER_UNKNOWN,
SHOW_IN_LAUNCHER_WITH_PARENT,
SHOW_IN_LAUNCHER_SEPARATE,
SHOW_IN_LAUNCHER_NO,
@@ -131,6 +132,13 @@
public @interface ShowInLauncher {
}
/**
+ * Indicates that the show in launcher value for this profile is unknown or unsupported.
+ * @hide
+ */
+ @TestApi
+ @SuppressLint("UnflaggedApi") // b/306636213
+ public static final int SHOW_IN_LAUNCHER_UNKNOWN = -1;
+ /**
* Suggests that the launcher should show this user's apps in the main tab.
* That is, either this user is a full user, so its apps should be presented accordingly, or, if
* this user is a profile, then its apps should be shown alongside its parent's apps.
@@ -157,6 +165,7 @@
* @hide
*/
@IntDef(prefix = "SHOW_IN_SETTINGS_", value = {
+ SHOW_IN_SETTINGS_UNKNOWN,
SHOW_IN_SETTINGS_WITH_PARENT,
SHOW_IN_SETTINGS_SEPARATE,
SHOW_IN_SETTINGS_NO,
@@ -165,6 +174,12 @@
public @interface ShowInSettings {
}
/**
+ * Indicates that the show in settings value for this profile is unknown or unsupported.
+ * @hide
+ */
+ @SuppressLint("UnflaggedApi") // b/306636213
+ public static final int SHOW_IN_SETTINGS_UNKNOWN = -1;
+ /**
* Suggests that the Settings app should show this user's apps in the main tab.
* That is, either this user is a full user, so its apps should be presented accordingly, or, if
* this user is a profile, then its apps should be shown alongside its parent's apps.
@@ -309,6 +324,7 @@
@Retention(RetentionPolicy.SOURCE)
@IntDef(prefix = "SHOW_IN_QUIET_MODE_",
value = {
+ SHOW_IN_QUIET_MODE_UNKNOWN,
SHOW_IN_QUIET_MODE_PAUSED,
SHOW_IN_QUIET_MODE_HIDDEN,
SHOW_IN_QUIET_MODE_DEFAULT,
@@ -318,6 +334,12 @@
}
/**
+ * Indicates that the show in quiet mode value for this profile is unknown.
+ */
+ @SuppressLint("UnflaggedApi") // b/306636213
+ public static final int SHOW_IN_QUIET_MODE_UNKNOWN = -1;
+
+ /**
* Indicates that the profile should still be visible in quiet mode but should be shown as
* paused (e.g. by greying out its icons).
*/
@@ -347,6 +369,7 @@
@Retention(RetentionPolicy.SOURCE)
@IntDef(prefix = "SHOW_IN_SHARING_SURFACES_",
value = {
+ SHOW_IN_SHARING_SURFACES_UNKNOWN,
SHOW_IN_SHARING_SURFACES_SEPARATE,
SHOW_IN_SHARING_SURFACES_WITH_PARENT,
SHOW_IN_SHARING_SURFACES_NO,
@@ -356,6 +379,12 @@
}
/**
+ * Indicates that the show in launcher value for this profile is unknown or unsupported.
+ */
+ @SuppressLint("UnflaggedApi") // b/306636213
+ public static final int SHOW_IN_SHARING_SURFACES_UNKNOWN = SHOW_IN_LAUNCHER_UNKNOWN;
+
+ /**
* Indicates that the profile data and apps should be shown in sharing surfaces intermixed with
* parent user's data and apps.
*/
@@ -379,7 +408,8 @@
*
* @hide
*/
- @IntDef(prefix = {"CROSS_PROFILE_CONTENT_SHARING_STRATEGY_"}, value = {
+ @IntDef(prefix = {"CROSS_PROFILE_CONTENT_SHARING_"}, value = {
+ CROSS_PROFILE_CONTENT_SHARING_UNKNOWN,
CROSS_PROFILE_CONTENT_SHARING_NO_DELEGATION,
CROSS_PROFILE_CONTENT_SHARING_DELEGATE_FROM_PARENT
})
@@ -388,6 +418,13 @@
}
/**
+ * Signifies that cross-profile content sharing strategy, both to and from this profile, is
+ * unknown/unsupported.
+ */
+ @SuppressLint("UnflaggedApi") // b/306636213
+ public static final int CROSS_PROFILE_CONTENT_SHARING_UNKNOWN = -1;
+
+ /**
* Signifies that cross-profile content sharing strategy, both to and from this profile, should
* not be delegated to any other user/profile.
* For ex:
diff --git a/core/java/android/credentials/flags.aconfig b/core/java/android/credentials/flags.aconfig
index f876eeb..1165f9a 100644
--- a/core/java/android/credentials/flags.aconfig
+++ b/core/java/android/credentials/flags.aconfig
@@ -33,4 +33,11 @@
name: "new_settings_ui"
description: "Enables new settings UI for VIC"
bug: "315209085"
+}
+
+flag {
+ namespace: "credential_manager"
+ name: "selector_ui_improvements_enabled"
+ description: "Enables Credential Selector UI improvements for VIC"
+ bug: "319448437"
}
\ No newline at end of file
diff --git a/core/java/android/hardware/biometrics/PromptContentListItem.java b/core/java/android/hardware/biometrics/PromptContentItem.java
similarity index 88%
rename from core/java/android/hardware/biometrics/PromptContentListItem.java
rename to core/java/android/hardware/biometrics/PromptContentItem.java
index fa3783d..c47b37a 100644
--- a/core/java/android/hardware/biometrics/PromptContentListItem.java
+++ b/core/java/android/hardware/biometrics/PromptContentItem.java
@@ -21,9 +21,9 @@
import android.annotation.FlaggedApi;
/**
- * A list item shown on {@link PromptVerticalListContentView}.
+ * An item shown on {@link PromptContentView}.
*/
@FlaggedApi(FLAG_CUSTOM_BIOMETRIC_PROMPT)
-public interface PromptContentListItem {
+public interface PromptContentItem {
}
diff --git a/core/java/android/hardware/biometrics/PromptContentListItemBulletedText.java b/core/java/android/hardware/biometrics/PromptContentItemBulletedText.java
similarity index 75%
rename from core/java/android/hardware/biometrics/PromptContentListItemBulletedText.java
rename to core/java/android/hardware/biometrics/PromptContentItemBulletedText.java
index c31f8a6..c5e5a80 100644
--- a/core/java/android/hardware/biometrics/PromptContentListItemBulletedText.java
+++ b/core/java/android/hardware/biometrics/PromptContentItemBulletedText.java
@@ -27,7 +27,7 @@
* A list item with bulleted text shown on {@link PromptVerticalListContentView}.
*/
@FlaggedApi(FLAG_CUSTOM_BIOMETRIC_PROMPT)
-public final class PromptContentListItemBulletedText implements PromptContentListItemParcelable {
+public final class PromptContentItemBulletedText implements PromptContentItemParcelable {
private final CharSequence mText;
/**
@@ -35,7 +35,7 @@
*
* @param text The text of this list item.
*/
- public PromptContentListItemBulletedText(@NonNull CharSequence text) {
+ public PromptContentItemBulletedText(@NonNull CharSequence text) {
mText = text;
}
@@ -67,15 +67,15 @@
* @see Parcelable.Creator
*/
@NonNull
- public static final Creator<PromptContentListItemBulletedText> CREATOR = new Creator<>() {
+ public static final Creator<PromptContentItemBulletedText> CREATOR = new Creator<>() {
@Override
- public PromptContentListItemBulletedText createFromParcel(Parcel in) {
- return new PromptContentListItemBulletedText(in.readCharSequence());
+ public PromptContentItemBulletedText createFromParcel(Parcel in) {
+ return new PromptContentItemBulletedText(in.readCharSequence());
}
@Override
- public PromptContentListItemBulletedText[] newArray(int size) {
- return new PromptContentListItemBulletedText[size];
+ public PromptContentItemBulletedText[] newArray(int size) {
+ return new PromptContentItemBulletedText[size];
}
};
}
diff --git a/core/java/android/hardware/biometrics/PromptContentListItemParcelable.java b/core/java/android/hardware/biometrics/PromptContentItemParcelable.java
similarity index 79%
rename from core/java/android/hardware/biometrics/PromptContentListItemParcelable.java
rename to core/java/android/hardware/biometrics/PromptContentItemParcelable.java
index 15271f0..668912cf 100644
--- a/core/java/android/hardware/biometrics/PromptContentListItemParcelable.java
+++ b/core/java/android/hardware/biometrics/PromptContentItemParcelable.java
@@ -22,9 +22,9 @@
import android.os.Parcelable;
/**
- * A parcelable {@link PromptContentListItem}.
+ * A parcelable {@link PromptContentItem}.
*/
@FlaggedApi(FLAG_CUSTOM_BIOMETRIC_PROMPT)
-sealed interface PromptContentListItemParcelable extends PromptContentListItem, Parcelable
- permits PromptContentListItemPlainText, PromptContentListItemBulletedText {
+sealed interface PromptContentItemParcelable extends PromptContentItem, Parcelable
+ permits PromptContentItemPlainText, PromptContentItemBulletedText {
}
diff --git a/core/java/android/hardware/biometrics/PromptContentListItemPlainText.java b/core/java/android/hardware/biometrics/PromptContentItemPlainText.java
similarity index 76%
rename from core/java/android/hardware/biometrics/PromptContentListItemPlainText.java
rename to core/java/android/hardware/biometrics/PromptContentItemPlainText.java
index d72a758..6434c59 100644
--- a/core/java/android/hardware/biometrics/PromptContentListItemPlainText.java
+++ b/core/java/android/hardware/biometrics/PromptContentItemPlainText.java
@@ -27,7 +27,7 @@
* A list item with plain text shown on {@link PromptVerticalListContentView}.
*/
@FlaggedApi(FLAG_CUSTOM_BIOMETRIC_PROMPT)
-public final class PromptContentListItemPlainText implements PromptContentListItemParcelable {
+public final class PromptContentItemPlainText implements PromptContentItemParcelable {
private final CharSequence mText;
/**
@@ -35,7 +35,7 @@
*
* @param text The text of this list item.
*/
- public PromptContentListItemPlainText(@NonNull CharSequence text) {
+ public PromptContentItemPlainText(@NonNull CharSequence text) {
mText = text;
}
@@ -67,15 +67,15 @@
* @see Parcelable.Creator
*/
@NonNull
- public static final Creator<PromptContentListItemPlainText> CREATOR = new Creator<>() {
+ public static final Creator<PromptContentItemPlainText> CREATOR = new Creator<>() {
@Override
- public PromptContentListItemPlainText createFromParcel(Parcel in) {
- return new PromptContentListItemPlainText(in.readCharSequence());
+ public PromptContentItemPlainText createFromParcel(Parcel in) {
+ return new PromptContentItemPlainText(in.readCharSequence());
}
@Override
- public PromptContentListItemPlainText[] newArray(int size) {
- return new PromptContentListItemPlainText[size];
+ public PromptContentItemPlainText[] newArray(int size) {
+ return new PromptContentItemPlainText[size];
}
};
}
diff --git a/core/java/android/hardware/biometrics/PromptVerticalListContentView.java b/core/java/android/hardware/biometrics/PromptVerticalListContentView.java
index f3cb189..f3e6290 100644
--- a/core/java/android/hardware/biometrics/PromptVerticalListContentView.java
+++ b/core/java/android/hardware/biometrics/PromptVerticalListContentView.java
@@ -40,9 +40,9 @@
* .setSubTitle(...)
* .setContentView(new PromptVerticalListContentView.Builder()
* .setDescription("test description")
- * .addListItem(new PromptContentListItemPlainText("test item 1"))
- * .addListItem(new PromptContentListItemPlainText("test item 2"))
- * .addListItem(new PromptContentListItemBulletedText("test item 3"))
+ * .addListItem(new PromptContentItemPlainText("test item 1"))
+ * .addListItem(new PromptContentItemPlainText("test item 2"))
+ * .addListItem(new PromptContentItemBulletedText("test item 3"))
* .build())
* .build();
* </pre>
@@ -51,11 +51,11 @@
public final class PromptVerticalListContentView implements PromptContentViewParcelable {
private static final int MAX_ITEM_NUMBER = 20;
private static final int MAX_EACH_ITEM_CHARACTER_NUMBER = 640;
- private final List<PromptContentListItemParcelable> mContentList;
+ private final List<PromptContentItemParcelable> mContentList;
private final CharSequence mDescription;
private PromptVerticalListContentView(
- @NonNull List<PromptContentListItemParcelable> contentList,
+ @NonNull List<PromptContentItemParcelable> contentList,
@NonNull CharSequence description) {
mContentList = contentList;
mDescription = description;
@@ -63,8 +63,8 @@
private PromptVerticalListContentView(Parcel in) {
mContentList = in.readArrayList(
- PromptContentListItemParcelable.class.getClassLoader(),
- PromptContentListItemParcelable.class);
+ PromptContentItemParcelable.class.getClassLoader(),
+ PromptContentItemParcelable.class);
mDescription = in.readCharSequence();
}
@@ -94,13 +94,13 @@
}
/**
- * Gets the list of ListItem on the content view, as set by
- * {@link PromptVerticalListContentView.Builder#addListItem(PromptContentListItem)}.
+ * Gets the list of items on the content view, as set by
+ * {@link PromptVerticalListContentView.Builder#addListItem(PromptContentItem)}.
*
* @return The item list on the content view.
*/
@NonNull
- public List<PromptContentListItem> getListItems() {
+ public List<PromptContentItem> getListItems() {
return new ArrayList<>(mContentList);
}
@@ -142,7 +142,7 @@
* A builder that collects arguments to be shown on the vertical list view.
*/
public static final class Builder {
- private final List<PromptContentListItemParcelable> mContentList = new ArrayList<>();
+ private final List<PromptContentItemParcelable> mContentList = new ArrayList<>();
private CharSequence mDescription;
/**
@@ -159,28 +159,50 @@
/**
* Optional: Adds a list item in the current row. Maximum {@value MAX_ITEM_NUMBER} items in
- * total.
+ * total. The maximum length for each item is {@value MAX_EACH_ITEM_CHARACTER_NUMBER}
+ * characters.
*
* @param listItem The list item view to display
* @return This builder.
*/
@NonNull
- public Builder addListItem(@NonNull PromptContentListItem listItem) {
+ public Builder addListItem(@NonNull PromptContentItem listItem) {
if (doesListItemExceedsCharLimit(listItem)) {
throw new IllegalStateException(
"The character number of list item exceeds "
+ MAX_EACH_ITEM_CHARACTER_NUMBER);
}
- mContentList.add((PromptContentListItemParcelable) listItem);
+ mContentList.add((PromptContentItemParcelable) listItem);
return this;
}
- private boolean doesListItemExceedsCharLimit(PromptContentListItem listItem) {
- if (listItem instanceof PromptContentListItemPlainText) {
- return ((PromptContentListItemPlainText) listItem).getText().length()
+
+ /**
+ * Optional: Adds a list item in the current row. Maximum {@value MAX_ITEM_NUMBER} items in
+ * total. The maximum length for each item is {@value MAX_EACH_ITEM_CHARACTER_NUMBER}
+ * characters.
+ *
+ * @param listItem The list item view to display
+ * @param index The position at which to add the item
+ * @return This builder.
+ */
+ @NonNull
+ public Builder addListItem(@NonNull PromptContentItem listItem, int index) {
+ if (doesListItemExceedsCharLimit(listItem)) {
+ throw new IllegalStateException(
+ "The character number of list item exceeds "
+ + MAX_EACH_ITEM_CHARACTER_NUMBER);
+ }
+ mContentList.add(index, (PromptContentItemParcelable) listItem);
+ return this;
+ }
+
+ private boolean doesListItemExceedsCharLimit(PromptContentItem listItem) {
+ if (listItem instanceof PromptContentItemPlainText) {
+ return ((PromptContentItemPlainText) listItem).getText().length()
> MAX_EACH_ITEM_CHARACTER_NUMBER;
- } else if (listItem instanceof PromptContentListItemBulletedText) {
- return ((PromptContentListItemBulletedText) listItem).getText().length()
+ } else if (listItem instanceof PromptContentItemBulletedText) {
+ return ((PromptContentItemBulletedText) listItem).getText().length()
> MAX_EACH_ITEM_CHARACTER_NUMBER;
} else {
return false;
diff --git a/core/java/android/hardware/radio/TEST_MAPPING b/core/java/android/hardware/radio/TEST_MAPPING
new file mode 100644
index 0000000..ee4eeb6
--- /dev/null
+++ b/core/java/android/hardware/radio/TEST_MAPPING
@@ -0,0 +1,7 @@
+{
+ "imports": [
+ {
+ "path": "frameworks/base/core/tests/BroadcastRadioTests"
+ }
+ ]
+}
diff --git a/core/java/android/os/PerformanceHintManager.java b/core/java/android/os/PerformanceHintManager.java
index 746278f..e6bfcd7 100644
--- a/core/java/android/os/PerformanceHintManager.java
+++ b/core/java/android/os/PerformanceHintManager.java
@@ -183,13 +183,14 @@
/** @hide */
@Retention(RetentionPolicy.SOURCE)
- @IntDef(prefix = {"CPU_LOAD_"}, value = {
+ @IntDef(prefix = {"CPU_LOAD_", "GPU_LOAD_"}, value = {
CPU_LOAD_UP,
CPU_LOAD_DOWN,
CPU_LOAD_RESET,
CPU_LOAD_RESUME,
GPU_LOAD_UP,
- GPU_LOAD_DOWN
+ GPU_LOAD_DOWN,
+ GPU_LOAD_RESET
})
public @interface Hint {}
diff --git a/core/java/android/os/storage/StorageManagerInternal.java b/core/java/android/os/storage/StorageManagerInternal.java
index 8961846..6995ea8 100644
--- a/core/java/android/os/storage/StorageManagerInternal.java
+++ b/core/java/android/os/storage/StorageManagerInternal.java
@@ -193,7 +193,7 @@
* @see com.android.server.pm.Installer#createFsveritySetupAuthToken()
*/
public abstract IInstalld.IFsveritySetupAuthToken createFsveritySetupAuthToken(
- ParcelFileDescriptor authFd, int appUid, @UserIdInt int userId) throws IOException;
+ ParcelFileDescriptor authFd, int uid) throws IOException;
/**
* A proxy call to the corresponding method in Installer.
diff --git a/core/java/android/permission/IPermissionManager.aidl b/core/java/android/permission/IPermissionManager.aidl
index 7cecfdc..471f95b 100644
--- a/core/java/android/permission/IPermissionManager.aidl
+++ b/core/java/android/permission/IPermissionManager.aidl
@@ -92,7 +92,7 @@
boolean isAutoRevokeExempted(String packageName, int userId);
- void registerAttributionSource(in AttributionSourceState source);
+ IBinder registerAttributionSource(in AttributionSourceState source);
boolean isRegisteredAttributionSource(in AttributionSourceState source);
diff --git a/core/java/android/permission/PermissionManager.java b/core/java/android/permission/PermissionManager.java
index 91adc37..4af6e3a 100644
--- a/core/java/android/permission/PermissionManager.java
+++ b/core/java/android/permission/PermissionManager.java
@@ -23,6 +23,7 @@
import static android.content.pm.PackageManager.FLAG_PERMISSION_USER_FIXED;
import static android.content.pm.PackageManager.FLAG_PERMISSION_USER_SET;
import static android.os.Build.VERSION_CODES.S;
+import static android.permission.flags.Flags.serverSideAttributionRegistration;
import android.Manifest;
import android.annotation.CheckResult;
@@ -59,6 +60,7 @@
import android.os.Binder;
import android.os.Build;
import android.os.Handler;
+import android.os.IBinder;
import android.os.Looper;
import android.os.Message;
import android.os.Process;
@@ -1464,13 +1466,19 @@
// We use a shared static token for sources that are not registered since the token's
// only used for process death detection. If we are about to use the source for security
// enforcement we need to replace the binder with a unique one.
- final AttributionSource registeredSource = source.withToken(new Binder());
try {
- mPermissionManager.registerAttributionSource(registeredSource.asState());
+ if (serverSideAttributionRegistration()) {
+ IBinder newToken = mPermissionManager.registerAttributionSource(source.asState());
+ return source.withToken(newToken);
+ } else {
+ AttributionSource registeredSource = source.withToken(new Binder());
+ mPermissionManager.registerAttributionSource(registeredSource.asState());
+ return registeredSource;
+ }
} catch (RemoteException e) {
e.rethrowFromSystemServer();
}
- return registeredSource;
+ return source;
}
/**
diff --git a/core/java/android/permission/flags.aconfig b/core/java/android/permission/flags.aconfig
index 60143cc..39b6aeb 100644
--- a/core/java/android/permission/flags.aconfig
+++ b/core/java/android/permission/flags.aconfig
@@ -45,7 +45,8 @@
}
flag {
- name: "enhanced_confirmation_mode_apis"
+ name: "enhanced_confirmation_mode_apis_enabled"
+ is_fixed_read_only: true
namespace: "permissions"
description: "enable enhanced confirmation mode apis"
bug: "310220212"
@@ -73,6 +74,13 @@
}
flag {
+ name: "server_side_attribution_registration"
+ namespace: "permissions"
+ description: "controls whether the binder representing an AttributionSource is created in the system server, or client process"
+ bug: "310953959"
+}
+
+flag {
name: "wallet_role_enabled"
namespace: "wallet_integration"
description: "This flag is used to enabled the Wallet Role for all users on the device"
diff --git a/core/java/android/service/notification/ZenDeviceEffects.java b/core/java/android/service/notification/ZenDeviceEffects.java
index 03ebae5..90049e6 100644
--- a/core/java/android/service/notification/ZenDeviceEffects.java
+++ b/core/java/android/service/notification/ZenDeviceEffects.java
@@ -20,7 +20,6 @@
import android.annotation.IntDef;
import android.annotation.NonNull;
import android.annotation.Nullable;
-import android.annotation.TestApi;
import android.app.Flags;
import android.os.Parcel;
import android.os.Parcelable;
@@ -37,8 +36,8 @@
@FlaggedApi(Flags.FLAG_MODES_API)
public final class ZenDeviceEffects implements Parcelable {
- /** Used to track which rule variables have been modified by the user.
- * Should be checked against the bitmask {@link #getUserModifiedFields()}.
+ /**
+ * Enum for the user-modifiable fields in this object.
* @hide
*/
@IntDef(flag = true, prefix = { "FIELD_" }, value = {
@@ -59,52 +58,42 @@
/**
* @hide
*/
- @TestApi
public static final int FIELD_GRAYSCALE = 1 << 0;
/**
* @hide
*/
- @TestApi
public static final int FIELD_SUPPRESS_AMBIENT_DISPLAY = 1 << 1;
/**
* @hide
*/
- @TestApi
public static final int FIELD_DIM_WALLPAPER = 1 << 2;
/**
* @hide
*/
- @TestApi
public static final int FIELD_NIGHT_MODE = 1 << 3;
/**
* @hide
*/
- @TestApi
public static final int FIELD_DISABLE_AUTO_BRIGHTNESS = 1 << 4;
/**
* @hide
*/
- @TestApi
public static final int FIELD_DISABLE_TAP_TO_WAKE = 1 << 5;
/**
* @hide
*/
- @TestApi
public static final int FIELD_DISABLE_TILT_TO_WAKE = 1 << 6;
/**
* @hide
*/
- @TestApi
public static final int FIELD_DISABLE_TOUCH = 1 << 7;
/**
* @hide
*/
- @TestApi
public static final int FIELD_MINIMIZE_RADIO_USAGE = 1 << 8;
/**
* @hide
*/
- @TestApi
public static final int FIELD_MAXIMIZE_DOZE = 1 << 9;
private final boolean mGrayscale;
@@ -119,13 +108,10 @@
private final boolean mMinimizeRadioUsage;
private final boolean mMaximizeDoze;
- private final @ModifiableField int mUserModifiedFields; // Bitwise representation
-
private ZenDeviceEffects(boolean grayscale, boolean suppressAmbientDisplay,
boolean dimWallpaper, boolean nightMode, boolean disableAutoBrightness,
boolean disableTapToWake, boolean disableTiltToWake, boolean disableTouch,
- boolean minimizeRadioUsage, boolean maximizeDoze,
- @ModifiableField int userModifiedFields) {
+ boolean minimizeRadioUsage, boolean maximizeDoze) {
mGrayscale = grayscale;
mSuppressAmbientDisplay = suppressAmbientDisplay;
mDimWallpaper = dimWallpaper;
@@ -136,7 +122,6 @@
mDisableTouch = disableTouch;
mMinimizeRadioUsage = minimizeRadioUsage;
mMaximizeDoze = maximizeDoze;
- mUserModifiedFields = userModifiedFields;
}
@Override
@@ -153,15 +138,14 @@
&& this.mDisableTiltToWake == that.mDisableTiltToWake
&& this.mDisableTouch == that.mDisableTouch
&& this.mMinimizeRadioUsage == that.mMinimizeRadioUsage
- && this.mMaximizeDoze == that.mMaximizeDoze
- && this.mUserModifiedFields == that.mUserModifiedFields;
+ && this.mMaximizeDoze == that.mMaximizeDoze;
}
@Override
public int hashCode() {
return Objects.hash(mGrayscale, mSuppressAmbientDisplay, mDimWallpaper, mNightMode,
mDisableAutoBrightness, mDisableTapToWake, mDisableTiltToWake, mDisableTouch,
- mMinimizeRadioUsage, mMaximizeDoze, mUserModifiedFields);
+ mMinimizeRadioUsage, mMaximizeDoze);
}
@Override
@@ -177,11 +161,11 @@
if (mDisableTouch) effects.add("disableTouch");
if (mMinimizeRadioUsage) effects.add("minimizeRadioUsage");
if (mMaximizeDoze) effects.add("maximizeDoze");
- return "[" + String.join(", ", effects) + "]"
- + " userModifiedFields: " + modifiedFieldsToString(mUserModifiedFields);
+ return "[" + String.join(", ", effects) + "]";
}
- private String modifiedFieldsToString(int bitmask) {
+ /** @hide */
+ public static String fieldsToString(@ModifiableField int bitmask) {
ArrayList<String> modified = new ArrayList<>();
if ((bitmask & FIELD_GRAYSCALE) != 0) {
modified.add("FIELD_GRAYSCALE");
@@ -312,7 +296,7 @@
return new ZenDeviceEffects(in.readBoolean(),
in.readBoolean(), in.readBoolean(), in.readBoolean(), in.readBoolean(),
in.readBoolean(), in.readBoolean(), in.readBoolean(), in.readBoolean(),
- in.readBoolean(), in.readInt());
+ in.readBoolean());
}
@Override
@@ -321,16 +305,6 @@
}
};
- /**
- * Gets the bitmask representing which fields are user modified. Bits are set using
- * {@link ModifiableField}.
- * @hide
- */
- @TestApi
- public @ModifiableField int getUserModifiedFields() {
- return mUserModifiedFields;
- }
-
@Override
public int describeContents() {
return 0;
@@ -348,7 +322,6 @@
dest.writeBoolean(mDisableTouch);
dest.writeBoolean(mMinimizeRadioUsage);
dest.writeBoolean(mMaximizeDoze);
- dest.writeInt(mUserModifiedFields);
}
/** Builder class for {@link ZenDeviceEffects} objects. */
@@ -365,7 +338,6 @@
private boolean mDisableTouch;
private boolean mMinimizeRadioUsage;
private boolean mMaximizeDoze;
- private @ModifiableField int mUserModifiedFields;
/**
* Instantiates a new {@link ZenPolicy.Builder} with all effects set to default (disabled).
@@ -388,7 +360,6 @@
mDisableTouch = zenDeviceEffects.shouldDisableTouch();
mMinimizeRadioUsage = zenDeviceEffects.shouldMinimizeRadioUsage();
mMaximizeDoze = zenDeviceEffects.shouldMaximizeDoze();
- mUserModifiedFields = zenDeviceEffects.mUserModifiedFields;
}
/**
@@ -510,24 +481,13 @@
return this;
}
- /**
- * Sets the bitmask representing which fields are user modified. See the FIELD_ constants.
- * @hide
- */
- @TestApi
- @NonNull
- public Builder setUserModifiedFields(@ModifiableField int userModifiedFields) {
- mUserModifiedFields = userModifiedFields;
- return this;
- }
-
/** Builds a {@link ZenDeviceEffects} object based on the builder's state. */
@NonNull
public ZenDeviceEffects build() {
return new ZenDeviceEffects(mGrayscale,
mSuppressAmbientDisplay, mDimWallpaper, mNightMode, mDisableAutoBrightness,
mDisableTapToWake, mDisableTiltToWake, mDisableTouch, mMinimizeRadioUsage,
- mMaximizeDoze, mUserModifiedFields);
+ mMaximizeDoze);
}
}
}
diff --git a/core/java/android/service/notification/ZenModeConfig.java b/core/java/android/service/notification/ZenModeConfig.java
index 54248be..c479877 100644
--- a/core/java/android/service/notification/ZenModeConfig.java
+++ b/core/java/android/service/notification/ZenModeConfig.java
@@ -205,8 +205,8 @@
private static final String ALLOW_ATT_SCREEN_ON = "visualScreenOn";
private static final String ALLOW_ATT_CONV = "convos";
private static final String ALLOW_ATT_CONV_FROM = "convosFrom";
- private static final String ALLOW_ATT_CHANNELS = "channels";
- private static final String USER_MODIFIED_FIELDS = "policyUserModifiedFields";
+ private static final String ALLOW_ATT_CHANNELS = "priorityChannels";
+ private static final String POLICY_USER_MODIFIED_FIELDS = "policyUserModifiedFields";
private static final String DISALLOW_TAG = "disallow";
private static final String DISALLOW_ATT_VISUAL_EFFECTS = "visualEffects";
private static final String STATE_TAG = "state";
@@ -806,6 +806,9 @@
rt.triggerDescription = parser.getAttributeValue(null, RULE_ATT_TRIGGER_DESC);
rt.type = safeInt(parser, RULE_ATT_TYPE, AutomaticZenRule.TYPE_UNKNOWN);
rt.userModifiedFields = safeInt(parser, RULE_ATT_USER_MODIFIED_FIELDS, 0);
+ rt.zenPolicyUserModifiedFields = safeInt(parser, POLICY_USER_MODIFIED_FIELDS, 0);
+ rt.zenDeviceEffectsUserModifiedFields = safeInt(parser,
+ DEVICE_EFFECT_USER_MODIFIED_FIELDS, 0);
Long deletionInstant = tryParseLong(
parser.getAttributeValue(null, RULE_ATT_DELETION_INSTANT), null);
if (deletionInstant != null) {
@@ -858,6 +861,9 @@
}
out.attributeInt(null, RULE_ATT_TYPE, rule.type);
out.attributeInt(null, RULE_ATT_USER_MODIFIED_FIELDS, rule.userModifiedFields);
+ out.attributeInt(null, POLICY_USER_MODIFIED_FIELDS, rule.zenPolicyUserModifiedFields);
+ out.attributeInt(null, DEVICE_EFFECT_USER_MODIFIED_FIELDS,
+ rule.zenDeviceEffectsUserModifiedFields);
if (rule.deletionInstant != null) {
out.attributeLong(null, RULE_ATT_DELETION_INSTANT,
rule.deletionInstant.toEpochMilli());
@@ -919,12 +925,11 @@
final int events = safeInt(parser, ALLOW_ATT_EVENTS, ZenPolicy.STATE_UNSET);
final int reminders = safeInt(parser, ALLOW_ATT_REMINDERS, ZenPolicy.STATE_UNSET);
if (Flags.modesApi()) {
- final int channels = safeInt(parser, ALLOW_ATT_CHANNELS, ZenPolicy.CHANNEL_TYPE_UNSET);
- if (channels != ZenPolicy.CHANNEL_TYPE_UNSET) {
- builder.allowChannels(channels);
+ final int channels = safeInt(parser, ALLOW_ATT_CHANNELS, ZenPolicy.STATE_UNSET);
+ if (channels != ZenPolicy.STATE_UNSET) {
+ builder.allowPriorityChannels(channels == ZenPolicy.STATE_ALLOW);
policySet = true;
}
- builder.setUserModifiedFields(safeInt(parser, USER_MODIFIED_FIELDS, 0));
}
if (calls != ZenPolicy.PEOPLE_TYPE_UNSET) {
@@ -1036,8 +1041,7 @@
out);
if (Flags.modesApi()) {
- writeZenPolicyState(ALLOW_ATT_CHANNELS, policy.getAllowedChannels(), out);
- out.attributeInt(null, USER_MODIFIED_FIELDS, policy.getUserModifiedFields());
+ writeZenPolicyState(ALLOW_ATT_CHANNELS, policy.getPriorityChannels(), out);
}
}
@@ -1053,7 +1057,7 @@
out.attributeInt(null, attr, val);
}
} else if (Flags.modesApi() && Objects.equals(attr, ALLOW_ATT_CHANNELS)) {
- if (val != ZenPolicy.CHANNEL_TYPE_UNSET) {
+ if (val != ZenPolicy.STATE_UNSET) {
out.attributeInt(null, attr, val);
}
} else {
@@ -1083,7 +1087,6 @@
.setShouldMinimizeRadioUsage(
safeBoolean(parser, DEVICE_EFFECT_MINIMIZE_RADIO_USAGE, false))
.setShouldMaximizeDoze(safeBoolean(parser, DEVICE_EFFECT_MAXIMIZE_DOZE, false))
- .setUserModifiedFields(safeInt(parser, DEVICE_EFFECT_USER_MODIFIED_FIELDS, 0))
.build();
return deviceEffects.hasEffects() ? deviceEffects : null;
@@ -1108,8 +1111,6 @@
writeBooleanIfTrue(out, DEVICE_EFFECT_MINIMIZE_RADIO_USAGE,
deviceEffects.shouldMinimizeRadioUsage());
writeBooleanIfTrue(out, DEVICE_EFFECT_MAXIMIZE_DOZE, deviceEffects.shouldMaximizeDoze());
- out.attributeInt(null, DEVICE_EFFECT_USER_MODIFIED_FIELDS,
- deviceEffects.getUserModifiedFields());
}
private static void writeBooleanIfTrue(TypedXmlSerializer out, String att, boolean value)
@@ -1238,8 +1239,7 @@
}
if (Flags.modesApi()) {
- builder.allowChannels(allowPriorityChannels ? ZenPolicy.CHANNEL_TYPE_PRIORITY
- : ZenPolicy.CHANNEL_TYPE_NONE);
+ builder.allowPriorityChannels(allowPriorityChannels);
}
return builder.build();
}
@@ -1369,7 +1369,7 @@
int state = defaultPolicy.state;
if (Flags.modesApi()) {
state = Policy.policyState(defaultPolicy.hasPriorityChannels(),
- getAllowPriorityChannelsWithDefault(zenPolicy.getAllowedChannels(),
+ ZenPolicy.stateToBoolean(zenPolicy.getPriorityChannels(),
DEFAULT_ALLOW_PRIORITY_CHANNELS));
}
@@ -1412,24 +1412,6 @@
}
/**
- * Gets whether priority channels are permitted by this channel type, with the specified
- * default if the value is unset. This effectively converts the channel enum to a boolean,
- * where "true" indicates priority channels are allowed to break through and "false" means
- * they are not.
- */
- public static boolean getAllowPriorityChannelsWithDefault(
- @ZenPolicy.ChannelType int channelType, boolean defaultAllowChannels) {
- switch (channelType) {
- case ZenPolicy.CHANNEL_TYPE_PRIORITY:
- return true;
- case ZenPolicy.CHANNEL_TYPE_NONE:
- return false;
- default:
- return defaultAllowChannels;
- }
- }
-
- /**
* Maps NotificationManager.Policy senders type to ZenPolicy.PeopleType
*/
public static @ZenPolicy.PeopleType int getZenPolicySenders(int senders) {
@@ -2060,7 +2042,9 @@
public String triggerDescription;
public String iconResName;
public boolean allowManualInvocation;
- public int userModifiedFields;
+ @AutomaticZenRule.ModifiableField public int userModifiedFields;
+ @ZenPolicy.ModifiableField public int zenPolicyUserModifiedFields;
+ @ZenDeviceEffects.ModifiableField public int zenDeviceEffectsUserModifiedFields;
@Nullable public Instant deletionInstant; // Only set on deleted rules.
public ZenRule() { }
@@ -2095,6 +2079,8 @@
triggerDescription = source.readString();
type = source.readInt();
userModifiedFields = source.readInt();
+ zenPolicyUserModifiedFields = source.readInt();
+ zenDeviceEffectsUserModifiedFields = source.readInt();
if (source.readInt() == 1) {
deletionInstant = Instant.ofEpochMilli(source.readLong());
}
@@ -2102,15 +2088,21 @@
}
/**
- * @see AutomaticZenRule#canUpdate()
+ * Whether this ZenRule can be updated by an app. In general, rules that have been
+ * customized by the user cannot be further updated by an app, with some exceptions:
+ * <ul>
+ * <li>Non user-configurable fields, like type, icon, configurationActivity, etc.
+ * <li>Name, if the name was not specifically modified by the user (to support language
+ * switches).
+ * </ul>
*/
@FlaggedApi(Flags.FLAG_MODES_API)
public boolean canBeUpdatedByApp() {
// The rule is considered updateable if its bitmask has no user modifications, and
// the bitmasks of the policy and device effects have no modification.
return userModifiedFields == 0
- && (zenPolicy == null || zenPolicy.getUserModifiedFields() == 0)
- && (zenDeviceEffects == null || zenDeviceEffects.getUserModifiedFields() == 0);
+ && zenPolicyUserModifiedFields == 0
+ && zenDeviceEffectsUserModifiedFields == 0;
}
@Override
@@ -2158,6 +2150,8 @@
dest.writeString(triggerDescription);
dest.writeInt(type);
dest.writeInt(userModifiedFields);
+ dest.writeInt(zenPolicyUserModifiedFields);
+ dest.writeInt(zenDeviceEffectsUserModifiedFields);
if (deletionInstant != null) {
dest.writeInt(1);
dest.writeLong(deletionInstant.toEpochMilli());
@@ -2192,8 +2186,20 @@
.append(",allowManualInvocation=").append(allowManualInvocation)
.append(",iconResName=").append(iconResName)
.append(",triggerDescription=").append(triggerDescription)
- .append(",type=").append(type)
- .append(",userModifiedFields=").append(userModifiedFields);
+ .append(",type=").append(type);
+ if (userModifiedFields != 0) {
+ sb.append(",userModifiedFields=")
+ .append(AutomaticZenRule.fieldsToString(userModifiedFields));
+ }
+ if (zenPolicyUserModifiedFields != 0) {
+ sb.append(",zenPolicyUserModifiedFields=")
+ .append(ZenPolicy.fieldsToString(zenPolicyUserModifiedFields));
+ }
+ if (zenDeviceEffectsUserModifiedFields != 0) {
+ sb.append(",zenDeviceEffectsUserModifiedFields=")
+ .append(ZenDeviceEffects.fieldsToString(
+ zenDeviceEffectsUserModifiedFields));
+ }
if (deletionInstant != null) {
sb.append(",deletionInstant=").append(deletionInstant);
}
@@ -2257,6 +2263,9 @@
&& Objects.equals(other.triggerDescription, triggerDescription)
&& other.type == type
&& other.userModifiedFields == userModifiedFields
+ && other.zenPolicyUserModifiedFields == zenPolicyUserModifiedFields
+ && other.zenDeviceEffectsUserModifiedFields
+ == zenDeviceEffectsUserModifiedFields
&& Objects.equals(other.deletionInstant, deletionInstant);
}
@@ -2269,7 +2278,8 @@
return Objects.hash(enabled, snoozing, name, zenMode, conditionId, condition,
component, configurationActivity, pkg, id, enabler, zenPolicy,
zenDeviceEffects, modified, allowManualInvocation, iconResName,
- triggerDescription, type, userModifiedFields, deletionInstant);
+ triggerDescription, type, userModifiedFields, zenPolicyUserModifiedFields,
+ zenDeviceEffectsUserModifiedFields, deletionInstant);
}
return Objects.hash(enabled, snoozing, name, zenMode, conditionId, condition,
component, configurationActivity, pkg, id, enabler, zenPolicy, modified);
diff --git a/core/java/android/service/notification/ZenPolicy.java b/core/java/android/service/notification/ZenPolicy.java
index 8477eb7..fb491d0 100644
--- a/core/java/android/service/notification/ZenPolicy.java
+++ b/core/java/android/service/notification/ZenPolicy.java
@@ -45,8 +45,8 @@
*/
public final class ZenPolicy implements Parcelable {
- /** Used to track which rule variables have been modified by the user.
- * Should be checked against the bitmask {@link #getUserModifiedFields()}.
+ /**
+ * Enum for the user-modifiable fields in this object.
* @hide
*/
@IntDef(flag = true, prefix = { "FIELD_" }, value = {
@@ -76,7 +76,6 @@
* the same time.
* @hide
*/
- @TestApi
@FlaggedApi(Flags.FLAG_MODES_API)
public static final int FIELD_MESSAGES = 1 << 0;
/**
@@ -84,7 +83,6 @@
* the same time.
* @hide
*/
- @TestApi
@FlaggedApi(Flags.FLAG_MODES_API)
public static final int FIELD_CALLS = 1 << 1;
/**
@@ -92,13 +90,11 @@
* set at the same time.
* @hide
*/
- @TestApi
@FlaggedApi(Flags.FLAG_MODES_API)
public static final int FIELD_CONVERSATIONS = 1 << 2;
/**
* @hide
*/
- @TestApi
@FlaggedApi(Flags.FLAG_MODES_API)
public static final int FIELD_ALLOW_CHANNELS = 1 << 3;
/**
@@ -109,73 +105,61 @@
/**
* @hide
*/
- @TestApi
@FlaggedApi(Flags.FLAG_MODES_API)
public static final int FIELD_PRIORITY_CATEGORY_EVENTS = 1 << 5;
/**
* @hide
*/
- @TestApi
@FlaggedApi(Flags.FLAG_MODES_API)
public static final int FIELD_PRIORITY_CATEGORY_REPEAT_CALLERS = 1 << 6;
/**
* @hide
*/
- @TestApi
@FlaggedApi(Flags.FLAG_MODES_API)
public static final int FIELD_PRIORITY_CATEGORY_ALARMS = 1 << 7;
/**
* @hide
*/
- @TestApi
@FlaggedApi(Flags.FLAG_MODES_API)
public static final int FIELD_PRIORITY_CATEGORY_MEDIA = 1 << 8;
/**
* @hide
*/
- @TestApi
@FlaggedApi(Flags.FLAG_MODES_API)
public static final int FIELD_PRIORITY_CATEGORY_SYSTEM = 1 << 9;
/**
* @hide
*/
- @TestApi
@FlaggedApi(Flags.FLAG_MODES_API)
public static final int FIELD_VISUAL_EFFECT_FULL_SCREEN_INTENT = 1 << 10;
/**
* @hide
*/
- @TestApi
@FlaggedApi(Flags.FLAG_MODES_API)
public static final int FIELD_VISUAL_EFFECT_LIGHTS = 1 << 11;
/**
* @hide
*/
- @TestApi
@FlaggedApi(Flags.FLAG_MODES_API)
public static final int FIELD_VISUAL_EFFECT_PEEK = 1 << 12;
/**
* @hide
*/
- @TestApi
@FlaggedApi(Flags.FLAG_MODES_API)
public static final int FIELD_VISUAL_EFFECT_STATUS_BAR = 1 << 13;
/**
* @hide
*/
- @TestApi
@FlaggedApi(Flags.FLAG_MODES_API)
public static final int FIELD_VISUAL_EFFECT_BADGE = 1 << 14;
/**
* @hide
*/
- @TestApi
@FlaggedApi(Flags.FLAG_MODES_API)
public static final int FIELD_VISUAL_EFFECT_AMBIENT = 1 << 15;
/**
* @hide
*/
- @TestApi
@FlaggedApi(Flags.FLAG_MODES_API)
public static final int FIELD_VISUAL_EFFECT_NOTIFICATION_LIST = 1 << 16;
@@ -184,8 +168,8 @@
private @PeopleType int mPriorityMessages = PEOPLE_TYPE_UNSET;
private @PeopleType int mPriorityCalls = PEOPLE_TYPE_UNSET;
private @ConversationSenders int mConversationSenders = CONVERSATION_SENDERS_UNSET;
- private @ChannelType int mAllowChannels = CHANNEL_TYPE_UNSET;
- private final @ModifiableField int mUserModifiedFields; // Bitwise representation
+ @FlaggedApi(Flags.FLAG_MODES_API)
+ private @ChannelType int mAllowChannels = CHANNEL_POLICY_UNSET;
/** @hide */
@IntDef(prefix = { "PRIORITY_CATEGORY_" }, value = {
@@ -354,56 +338,52 @@
*/
public static final int STATE_DISALLOW = 2;
- /** @hide */
- @IntDef(prefix = { "CHANNEL_TYPE_" }, value = {
- CHANNEL_TYPE_UNSET,
- CHANNEL_TYPE_PRIORITY,
- CHANNEL_TYPE_NONE,
+ @IntDef(prefix = { "CHANNEL_POLICY_" }, value = {
+ CHANNEL_POLICY_UNSET,
+ CHANNEL_POLICY_PRIORITY,
+ CHANNEL_POLICY_NONE,
})
@Retention(RetentionPolicy.SOURCE)
- public @interface ChannelType {}
+ private @interface ChannelType {}
/**
* Indicates no explicit setting for which channels may bypass DND when this policy is active.
- * Defaults to {@link #CHANNEL_TYPE_PRIORITY}.
+ * Defaults to {@link #CHANNEL_POLICY_PRIORITY}.
*/
@FlaggedApi(Flags.FLAG_MODES_API)
- public static final int CHANNEL_TYPE_UNSET = 0;
+ private static final int CHANNEL_POLICY_UNSET = 0;
/**
* Indicates that channels marked as {@link NotificationChannel#canBypassDnd()} can bypass DND
* when this policy is active.
*/
@FlaggedApi(Flags.FLAG_MODES_API)
- public static final int CHANNEL_TYPE_PRIORITY = 1;
+ private static final int CHANNEL_POLICY_PRIORITY = 1;
/**
* Indicates that no channels can bypass DND when this policy is active, even those marked as
* {@link NotificationChannel#canBypassDnd()}.
*/
@FlaggedApi(Flags.FLAG_MODES_API)
- public static final int CHANNEL_TYPE_NONE = 2;
+ private static final int CHANNEL_POLICY_NONE = 2;
/** @hide */
public ZenPolicy() {
mPriorityCategories = new ArrayList<>(Collections.nCopies(NUM_PRIORITY_CATEGORIES, 0));
mVisualEffects = new ArrayList<>(Collections.nCopies(NUM_VISUAL_EFFECTS, 0));
- mUserModifiedFields = 0;
}
/** @hide */
@FlaggedApi(Flags.FLAG_MODES_API)
public ZenPolicy(List<Integer> priorityCategories, List<Integer> visualEffects,
@PeopleType int priorityMessages, @PeopleType int priorityCalls,
- @ConversationSenders int conversationSenders, @ChannelType int allowChannels,
- @ModifiableField int userModifiedFields) {
+ @ConversationSenders int conversationSenders, @ChannelType int allowChannels) {
mPriorityCategories = priorityCategories;
mVisualEffects = visualEffects;
mPriorityMessages = priorityMessages;
mPriorityCalls = priorityCalls;
mConversationSenders = conversationSenders;
mAllowChannels = allowChannels;
- mUserModifiedFields = userModifiedFields;
}
/**
@@ -584,16 +564,21 @@
}
/**
- * Which types of {@link NotificationChannel channels} this policy allows to bypass DND. When
- * this value is {@link #CHANNEL_TYPE_PRIORITY priority} channels, any channel with
- * canBypassDnd() may bypass DND; when it is {@link #CHANNEL_TYPE_NONE none}, even channels
- * with canBypassDnd() will be intercepted.
- * @return {@link #CHANNEL_TYPE_UNSET}, {@link #CHANNEL_TYPE_PRIORITY}, or
- * {@link #CHANNEL_TYPE_NONE}
+ * Whether this policy allows {@link NotificationChannel channels} marked as
+ * {@link NotificationChannel#canBypassDnd()} to bypass DND. If {@link #STATE_ALLOW}, these
+ * channels may bypass; if {@link #STATE_DISALLOW}, then even notifications from channels
+ * with {@link NotificationChannel#canBypassDnd()} will be intercepted.
*/
@FlaggedApi(Flags.FLAG_MODES_API)
- public @ChannelType int getAllowedChannels() {
- return mAllowChannels;
+ public @State int getPriorityChannels() {
+ switch (mAllowChannels) {
+ case CHANNEL_POLICY_PRIORITY:
+ return STATE_ALLOW;
+ case CHANNEL_POLICY_NONE:
+ return STATE_DISALLOW;
+ default:
+ return STATE_UNSET;
+ }
}
/**
@@ -628,8 +613,6 @@
* is not set, it is (@link STATE_UNSET} and will not change the current set policy.
*/
public static final class Builder {
- private @ModifiableField int mUserModifiedFields;
-
private ZenPolicy mZenPolicy;
public Builder() {
@@ -644,9 +627,6 @@
public Builder(@Nullable ZenPolicy policy) {
if (policy != null) {
mZenPolicy = policy.copy();
- if (Flags.modesApi()) {
- mUserModifiedFields = policy.mUserModifiedFields;
- }
} else {
mZenPolicy = new ZenPolicy();
}
@@ -657,11 +637,10 @@
*/
public @NonNull ZenPolicy build() {
if (Flags.modesApi()) {
- return new ZenPolicy(new ArrayList<Integer>(mZenPolicy.mPriorityCategories),
- new ArrayList<Integer>(mZenPolicy.mVisualEffects),
+ return new ZenPolicy(new ArrayList<>(mZenPolicy.mPriorityCategories),
+ new ArrayList<>(mZenPolicy.mVisualEffects),
mZenPolicy.mPriorityMessages, mZenPolicy.mPriorityCalls,
- mZenPolicy.mConversationSenders, mZenPolicy.mAllowChannels,
- mUserModifiedFields);
+ mZenPolicy.mConversationSenders, mZenPolicy.mAllowChannels);
} else {
return mZenPolicy.copy();
}
@@ -1016,32 +995,10 @@
* Set whether priority channels are permitted to break through DND.
*/
@FlaggedApi(Flags.FLAG_MODES_API)
- public @NonNull Builder allowChannels(@ChannelType int channelType) {
- mZenPolicy.mAllowChannels = channelType;
+ public @NonNull Builder allowPriorityChannels(boolean allow) {
+ mZenPolicy.mAllowChannels = allow ? CHANNEL_POLICY_PRIORITY : CHANNEL_POLICY_NONE;
return this;
}
-
- /**
- * Sets the user modified fields bitmask.
- * @hide
- */
- @TestApi
- @FlaggedApi(Flags.FLAG_MODES_API)
- public @NonNull Builder setUserModifiedFields(@ModifiableField int userModifiedFields) {
- mUserModifiedFields = userModifiedFields;
- return this;
- }
- }
-
- /**
- Gets the bitmask representing which fields are user modified. Bits are set using
- * {@link ModifiableField}.
- * @hide
- */
- @TestApi
- @FlaggedApi(Flags.FLAG_MODES_API)
- public @ModifiableField int getUserModifiedFields() {
- return mUserModifiedFields;
}
@Override
@@ -1058,7 +1015,6 @@
dest.writeInt(mConversationSenders);
if (Flags.modesApi()) {
dest.writeInt(mAllowChannels);
- dest.writeInt(mUserModifiedFields);
}
}
@@ -1074,7 +1030,7 @@
trimList(source.readArrayList(Integer.class.getClassLoader(),
Integer.class), NUM_VISUAL_EFFECTS),
source.readInt(), source.readInt(), source.readInt(),
- source.readInt(), source.readInt()
+ source.readInt()
);
} else {
policy = new ZenPolicy();
@@ -1109,14 +1065,12 @@
conversationTypeToString(mConversationSenders));
if (Flags.modesApi()) {
sb.append(", allowChannels=").append(channelTypeToString(mAllowChannels));
- sb.append(", userModifiedFields=")
- .append(modifiedFieldsToString(mUserModifiedFields));
}
return sb.append('}').toString();
}
- @FlaggedApi(Flags.FLAG_MODES_API)
- private String modifiedFieldsToString(@ModifiableField int bitmask) {
+ /** @hide */
+ public static String fieldsToString(@ModifiableField int bitmask) {
ArrayList<String> modified = new ArrayList<>();
if ((bitmask & FIELD_MESSAGES) != 0) {
modified.add("FIELD_MESSAGES");
@@ -1305,11 +1259,11 @@
@FlaggedApi(Flags.FLAG_MODES_API)
public static String channelTypeToString(@ChannelType int channelType) {
switch (channelType) {
- case CHANNEL_TYPE_UNSET:
+ case CHANNEL_POLICY_UNSET:
return "unset";
- case CHANNEL_TYPE_PRIORITY:
+ case CHANNEL_POLICY_PRIORITY:
return "priority";
- case CHANNEL_TYPE_NONE:
+ case CHANNEL_POLICY_NONE:
return "none";
}
return "invalidChannelType{" + channelType + "}";
@@ -1327,8 +1281,7 @@
&& other.mPriorityMessages == mPriorityMessages
&& other.mConversationSenders == mConversationSenders;
if (Flags.modesApi()) {
- return eq && other.mAllowChannels == mAllowChannels
- && other.mUserModifiedFields == mUserModifiedFields;
+ return eq && other.mAllowChannels == mAllowChannels;
}
return eq;
}
@@ -1337,7 +1290,7 @@
public int hashCode() {
if (Flags.modesApi()) {
return Objects.hash(mPriorityCategories, mVisualEffects, mPriorityCalls,
- mPriorityMessages, mConversationSenders, mAllowChannels, mUserModifiedFields);
+ mPriorityMessages, mConversationSenders, mAllowChannels);
}
return Objects.hash(mPriorityCategories, mVisualEffects, mPriorityCalls, mPriorityMessages,
mConversationSenders);
@@ -1389,11 +1342,11 @@
}
/** @hide */
- public boolean isCategoryAllowed(@PriorityCategory int category, boolean defaultVal) {
- switch (getZenPolicyPriorityCategoryState(category)) {
- case ZenPolicy.STATE_ALLOW:
+ public static boolean stateToBoolean(@State int state, boolean defaultVal) {
+ switch (state) {
+ case STATE_ALLOW:
return true;
- case ZenPolicy.STATE_DISALLOW:
+ case STATE_DISALLOW:
return false;
default:
return defaultVal;
@@ -1401,15 +1354,13 @@
}
/** @hide */
+ public boolean isCategoryAllowed(@PriorityCategory int category, boolean defaultVal) {
+ return stateToBoolean(getZenPolicyPriorityCategoryState(category), defaultVal);
+ }
+
+ /** @hide */
public boolean isVisualEffectAllowed(@VisualEffect int effect, boolean defaultVal) {
- switch (getZenPolicyVisualEffectState(effect)) {
- case ZenPolicy.STATE_ALLOW:
- return true;
- case ZenPolicy.STATE_DISALLOW:
- return false;
- default:
- return defaultVal;
- }
+ return stateToBoolean(getZenPolicyVisualEffectState(effect), defaultVal);
}
/**
@@ -1463,8 +1414,8 @@
// apply allowed channels
if (Flags.modesApi()) {
// if no channels are allowed, can't newly allow them
- if (mAllowChannels != CHANNEL_TYPE_NONE
- && policyToApply.mAllowChannels != CHANNEL_TYPE_UNSET) {
+ if (mAllowChannels != CHANNEL_POLICY_NONE
+ && policyToApply.mAllowChannels != CHANNEL_POLICY_UNSET) {
mAllowChannels = policyToApply.mAllowChannels;
}
}
@@ -1530,7 +1481,7 @@
proto.write(DNDPolicyProto.ALLOW_CONVERSATIONS_FROM, getPriorityConversationSenders());
if (Flags.modesApi()) {
- proto.write(DNDPolicyProto.ALLOW_CHANNELS, getAllowedChannels());
+ proto.write(DNDPolicyProto.ALLOW_CHANNELS, getPriorityChannels());
}
proto.flush();
diff --git a/core/java/android/service/voice/VisualQueryDetector.java b/core/java/android/service/voice/VisualQueryDetector.java
index adc54f5..f2bdbf6 100644
--- a/core/java/android/service/voice/VisualQueryDetector.java
+++ b/core/java/android/service/voice/VisualQueryDetector.java
@@ -325,7 +325,7 @@
Slog.v(TAG, "BinderCallback#onQueryDetected");
Binder.withCleanCallingIdentity(() -> {
synchronized (mLock) {
- mCallback.onQueryDetected(partialQuery);
+ mExecutor.execute(()->mCallback.onQueryDetected(partialQuery));
}
});
}
@@ -335,7 +335,7 @@
Slog.v(TAG, "BinderCallback#onQueryFinished");
Binder.withCleanCallingIdentity(() -> {
synchronized (mLock) {
- mCallback.onQueryFinished();
+ mExecutor.execute(()->mCallback.onQueryFinished());
}
});
}
@@ -345,7 +345,7 @@
Slog.v(TAG, "BinderCallback#onQueryRejected");
Binder.withCleanCallingIdentity(() -> {
synchronized (mLock) {
- mCallback.onQueryRejected();
+ mExecutor.execute(()->mCallback.onQueryRejected());
}
});
}
diff --git a/core/java/android/telephony/PhoneStateListener.java b/core/java/android/telephony/PhoneStateListener.java
index cf1156d..fb57921 100644
--- a/core/java/android/telephony/PhoneStateListener.java
+++ b/core/java/android/telephony/PhoneStateListener.java
@@ -1681,6 +1681,10 @@
@EmergencyCallbackModeStopReason int reason) {
// not support. Can't override. Use TelephonyCallback.
}
+
+ public final void onSimultaneousCallingStateChanged(int[] subIds) {
+ // not supported on the deprecated interface - Use TelephonyCallback instead
+ }
}
private void log(String s) {
diff --git a/core/java/android/telephony/TelephonyCallback.java b/core/java/android/telephony/TelephonyCallback.java
index 19bcf28..dc6a035 100644
--- a/core/java/android/telephony/TelephonyCallback.java
+++ b/core/java/android/telephony/TelephonyCallback.java
@@ -18,6 +18,7 @@
import android.Manifest;
import android.annotation.CallbackExecutor;
+import android.annotation.FlaggedApi;
import android.annotation.IntDef;
import android.annotation.NonNull;
import android.annotation.RequiresPermission;
@@ -33,15 +34,19 @@
import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.telephony.IPhoneStateListener;
+import com.android.internal.telephony.flags.Flags;
import dalvik.system.VMRuntime;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.ref.WeakReference;
+import java.util.Arrays;
import java.util.List;
import java.util.Map;
+import java.util.Set;
import java.util.concurrent.Executor;
+import java.util.stream.Collectors;
/**
* A callback class for monitoring changes in specific telephony states
@@ -627,6 +632,18 @@
public static final int EVENT_EMERGENCY_CALLBACK_MODE_CHANGED = 40;
/**
+ * Event for listening to changes in simultaneous cellular calling subscriptions.
+ *
+ * @see SimultaneousCellularCallingSupportListener
+ *
+ * @hide
+ */
+ @FlaggedApi(Flags.FLAG_SIMULTANEOUS_CALLING_INDICATIONS)
+ @RequiresPermission(Manifest.permission.READ_PRIVILEGED_PHONE_STATE)
+ @SystemApi
+ public static final int EVENT_SIMULTANEOUS_CELLULAR_CALLING_SUBSCRIPTIONS_CHANGED = 41;
+
+ /**
* @hide
*/
@IntDef(prefix = {"EVENT_"}, value = {
@@ -669,7 +686,8 @@
EVENT_LINK_CAPACITY_ESTIMATE_CHANGED,
EVENT_TRIGGER_NOTIFY_ANBR,
EVENT_MEDIA_QUALITY_STATUS_CHANGED,
- EVENT_EMERGENCY_CALLBACK_MODE_CHANGED
+ EVENT_EMERGENCY_CALLBACK_MODE_CHANGED,
+ EVENT_SIMULTANEOUS_CELLULAR_CALLING_SUBSCRIPTIONS_CHANGED
})
@Retention(RetentionPolicy.SOURCE)
public @interface TelephonyEvent {
@@ -1373,6 +1391,44 @@
}
/**
+ * Interface for listening to changes in the simultaneous cellular calling state for active
+ * cellular subscriptions.
+ *
+ * @hide
+ */
+ @FlaggedApi(Flags.FLAG_SIMULTANEOUS_CALLING_INDICATIONS)
+ @SystemApi
+ public interface SimultaneousCellularCallingSupportListener {
+ /**
+ * Notify the Listener that the subscriptions available for simultaneous <b>cellular</b>
+ * calling have changed.
+ * <p>
+ * If we have an ongoing <b>cellular</b> call on one subscription in this Set, a
+ * simultaneous incoming or outgoing <b>cellular</b> call is possible on any of the
+ * subscriptions in this Set. On a traditional Dual Sim Dual Standby device, simultaneous
+ * calling is not possible between subscriptions, where on a Dual Sim Dual Active device,
+ * simultaneous calling may be possible between subscriptions in certain network conditions.
+ * <p>
+ * Note: This listener only tracks the capability of the modem to perform simultaneous
+ * cellular calls and does not track the simultaneous calling state of scenarios based on
+ * multiple IMS registration over multiple transports (WiFi/Internet calling).
+ * <p>
+ * Note: This listener fires for all changes to cellular calling subscriptions independent
+ * of which subscription it is registered on.
+ *
+ * @param simultaneousCallingSubscriptionIds The Set of subscription IDs that support
+ * simultaneous calling. If there is an ongoing call on a subscription in this Set, then a
+ * simultaneous incoming or outgoing call is only possible for other subscriptions in this
+ * Set. If there is an ongoing call on a subscription that is not in this Set, then
+ * simultaneous calling is not possible at the current time.
+ *
+ */
+ @RequiresPermission(Manifest.permission.READ_PRIVILEGED_PHONE_STATE)
+ void onSimultaneousCellularCallingSubscriptionsChanged(
+ @NonNull Set<Integer> simultaneousCallingSubscriptionIds);
+ }
+
+ /**
* Interface for call attributes listener.
*
* @hide
@@ -1976,6 +2032,17 @@
allowedNetworkType)));
}
+ public void onSimultaneousCallingStateChanged(int[] subIds) {
+ SimultaneousCellularCallingSupportListener listener =
+ (SimultaneousCellularCallingSupportListener) mTelephonyCallbackWeakRef.get();
+ if (listener == null) return;
+
+ Binder.withCleanCallingIdentity(
+ () -> mExecutor.execute(
+ () -> listener.onSimultaneousCellularCallingSubscriptionsChanged(
+ Arrays.stream(subIds).boxed().collect(Collectors.toSet()))));
+ }
+
public void onLinkCapacityEstimateChanged(
List<LinkCapacityEstimate> linkCapacityEstimateList) {
LinkCapacityEstimateChangedListener listener =
diff --git a/core/java/android/telephony/TelephonyRegistryManager.java b/core/java/android/telephony/TelephonyRegistryManager.java
index 886727e..0de4505 100644
--- a/core/java/android/telephony/TelephonyRegistryManager.java
+++ b/core/java/android/telephony/TelephonyRegistryManager.java
@@ -994,6 +994,21 @@
}
}
+ /**
+ * Notify external listeners that the subscriptions supporting simultaneous cellular calling
+ * have changed.
+ * @param subIds The new set of subIds supporting simultaneous cellular calling.
+ */
+ public void notifySimultaneousCellularCallingSubscriptionsChanged(Set<Integer> subIds) {
+ try {
+ sRegistry.notifySimultaneousCellularCallingSubscriptionsChanged(
+ subIds.stream().mapToInt(i -> i).toArray());
+ } catch (RemoteException ex) {
+ // system server crash
+ throw ex.rethrowFromSystemServer();
+ }
+ }
+
public @NonNull Set<Integer> getEventsFromCallback(
@NonNull TelephonyCallback telephonyCallback) {
Set<Integer> eventList = new ArraySet<>();
@@ -1135,7 +1150,11 @@
eventList.add(TelephonyCallback.EVENT_EMERGENCY_CALLBACK_MODE_CHANGED);
}
-
+ if (telephonyCallback
+ instanceof TelephonyCallback.SimultaneousCellularCallingSupportListener) {
+ eventList.add(
+ TelephonyCallback.EVENT_SIMULTANEOUS_CELLULAR_CALLING_SUBSCRIPTIONS_CHANGED);
+ }
return eventList;
}
diff --git a/core/java/android/view/IWindowManager.aidl b/core/java/android/view/IWindowManager.aidl
index 36b74e3..7903050 100644
--- a/core/java/android/view/IWindowManager.aidl
+++ b/core/java/android/view/IWindowManager.aidl
@@ -69,12 +69,13 @@
import android.view.displayhash.DisplayHash;
import android.view.displayhash.VerifiedDisplayHash;
import android.window.AddToSurfaceSyncGroupResult;
+import android.window.IScreenRecordingCallback;
import android.window.ISurfaceSyncGroupCompletedListener;
import android.window.ITaskFpsCallback;
-import android.window.ScreenCapture;
-import android.window.WindowContextInfo;
import android.window.ITrustedPresentationListener;
+import android.window.ScreenCapture;
import android.window.TrustedPresentationThresholds;
+import android.window.WindowContextInfo;
/**
* System private interface to the window manager.
@@ -1083,4 +1084,8 @@
void unregisterTrustedPresentationListener(in ITrustedPresentationListener listener, int id);
+
+ boolean registerScreenRecordingCallback(IScreenRecordingCallback callback);
+
+ void unregisterScreenRecordingCallback(IScreenRecordingCallback callback);
}
diff --git a/core/java/android/view/View.java b/core/java/android/view/View.java
index 257ecc5..c98d1d7 100644
--- a/core/java/android/view/View.java
+++ b/core/java/android/view/View.java
@@ -15015,6 +15015,7 @@
}
/** @hide */
+ @Nullable
View getSelfOrParentImportantForA11y() {
if (isImportantForAccessibility()) return this;
ViewParent parent = getParentForAccessibility();
diff --git a/core/java/android/view/ViewRootImpl.java b/core/java/android/view/ViewRootImpl.java
index c66f3c8..34b46700 100644
--- a/core/java/android/view/ViewRootImpl.java
+++ b/core/java/android/view/ViewRootImpl.java
@@ -87,6 +87,7 @@
import static android.view.WindowManagerGlobal.RELAYOUT_RES_CANCEL_AND_REDRAW;
import static android.view.WindowManagerGlobal.RELAYOUT_RES_CONSUME_ALWAYS_SYSTEM_BARS;
import static android.view.WindowManagerGlobal.RELAYOUT_RES_SURFACE_CHANGED;
+import static android.view.accessibility.Flags.fixMergedContentChangeEvent;
import static android.view.accessibility.Flags.forceInvertColor;
import static android.view.accessibility.Flags.reduceWindowContentChangedEventThrottle;
import static android.view.inputmethod.InputMethodEditorTraceProto.InputMethodClientsTraceProto.ClientSideProto.IME_FOCUS_CONTROLLER;
@@ -11509,6 +11510,15 @@
event.setContentChangeTypes(mChangeTypes);
if (mAction.isPresent()) event.setAction(mAction.getAsInt());
if (AccessibilityEvent.DEBUG_ORIGIN) event.originStackTrace = mOrigin;
+
+ if (fixMergedContentChangeEvent()) {
+ if ((mChangeTypes & AccessibilityEvent.CONTENT_CHANGE_TYPE_SUBTREE) != 0) {
+ final View importantParent = source.getSelfOrParentImportantForA11y();
+ if (importantParent != null) {
+ source = importantParent;
+ }
+ }
+ }
source.sendAccessibilityEventUnchecked(event);
} else {
mLastEventTimeMillis = 0;
@@ -11543,14 +11553,29 @@
}
if (mSource != null) {
- // If there is no common predecessor, then mSource points to
- // a removed view, hence in this case always prefer the source.
- View predecessor = getCommonPredecessor(mSource, source);
- if (predecessor != null) {
- predecessor = predecessor.getSelfOrParentImportantForA11y();
+ if (fixMergedContentChangeEvent()) {
+ View newSource = getCommonPredecessor(mSource, source);
+ if (newSource == null) {
+ // If there is no common predecessor, then mSource points to
+ // a removed view, hence in this case always prefer the source.
+ newSource = source;
+ }
+
+ mChangeTypes |= changeType;
+ if (mSource != newSource) {
+ mChangeTypes |= AccessibilityEvent.CONTENT_CHANGE_TYPE_SUBTREE;
+ mSource = newSource;
+ }
+ } else {
+ // If there is no common predecessor, then mSource points to
+ // a removed view, hence in this case always prefer the source.
+ View predecessor = getCommonPredecessor(mSource, source);
+ if (predecessor != null) {
+ predecessor = predecessor.getSelfOrParentImportantForA11y();
+ }
+ mSource = (predecessor != null) ? predecessor : source;
+ mChangeTypes |= changeType;
}
- mSource = (predecessor != null) ? predecessor : source;
- mChangeTypes |= changeType;
final int performingAction = mAccessibilityManager.getPerformingAction();
if (performingAction != 0) {
diff --git a/core/java/android/view/accessibility/flags/accessibility_flags.aconfig b/core/java/android/view/accessibility/flags/accessibility_flags.aconfig
index c7355c1..efae57c 100644
--- a/core/java/android/view/accessibility/flags/accessibility_flags.aconfig
+++ b/core/java/android/view/accessibility/flags/accessibility_flags.aconfig
@@ -53,6 +53,13 @@
flag {
namespace: "accessibility"
+ name: "fix_merged_content_change_event"
+ description: "Fixes event type and source of content change event merged in ViewRootImpl"
+ bug: "277305460"
+}
+
+flag {
+ namespace: "accessibility"
name: "flash_notification_system_api"
description: "Makes flash notification APIs as system APIs for calling from mainline module"
bug: "303131332"
diff --git a/core/java/android/hardware/biometrics/PromptContentListItem.java b/core/java/android/window/IScreenRecordingCallback.aidl
similarity index 61%
copy from core/java/android/hardware/biometrics/PromptContentListItem.java
copy to core/java/android/window/IScreenRecordingCallback.aidl
index fa3783d..560ee75 100644
--- a/core/java/android/hardware/biometrics/PromptContentListItem.java
+++ b/core/java/android/window/IScreenRecordingCallback.aidl
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2023 The Android Open Source Project
+ * Copyright 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.
@@ -14,16 +14,11 @@
* limitations under the License.
*/
-package android.hardware.biometrics;
-
-import static android.hardware.biometrics.Flags.FLAG_CUSTOM_BIOMETRIC_PROMPT;
-
-import android.annotation.FlaggedApi;
+package android.window;
/**
- * A list item shown on {@link PromptVerticalListContentView}.
+ * @hide
*/
-@FlaggedApi(FLAG_CUSTOM_BIOMETRIC_PROMPT)
-public interface PromptContentListItem {
+oneway interface IScreenRecordingCallback {
+ void onScreenRecordingStateChanged(boolean visibleInScreenRecording);
}
-
diff --git a/core/java/android/window/TaskFragmentOperation.java b/core/java/android/window/TaskFragmentOperation.java
index acc6a74..7b8cdff 100644
--- a/core/java/android/window/TaskFragmentOperation.java
+++ b/core/java/android/window/TaskFragmentOperation.java
@@ -125,6 +125,16 @@
*/
public static final int OP_TYPE_SET_DIM_ON_TASK = 16;
+ /**
+ * Sets this TaskFragment to move to bottom of the Task if any of the activities below it is
+ * launched in a mode requiring clear top.
+ *
+ * This is only allowed for system organizers. See
+ * {@link com.android.server.wm.TaskFragmentOrganizerController#registerOrganizer(
+ * ITaskFragmentOrganizer, boolean)}
+ */
+ public static final int OP_TYPE_SET_MOVE_TO_BOTTOM_IF_CLEAR_WHEN_LAUNCH = 17;
+
@IntDef(prefix = { "OP_TYPE_" }, value = {
OP_TYPE_UNKNOWN,
OP_TYPE_CREATE_TASK_FRAGMENT,
@@ -144,6 +154,7 @@
OP_TYPE_CREATE_TASK_FRAGMENT_DECOR_SURFACE,
OP_TYPE_REMOVE_TASK_FRAGMENT_DECOR_SURFACE,
OP_TYPE_SET_DIM_ON_TASK,
+ OP_TYPE_SET_MOVE_TO_BOTTOM_IF_CLEAR_WHEN_LAUNCH,
})
@Retention(RetentionPolicy.SOURCE)
public @interface OperationType {}
@@ -173,12 +184,14 @@
private final boolean mDimOnTask;
+ private final boolean mMoveToBottomIfClearWhenLaunch;
+
private TaskFragmentOperation(@OperationType int opType,
@Nullable TaskFragmentCreationParams taskFragmentCreationParams,
@Nullable IBinder activityToken, @Nullable Intent activityIntent,
@Nullable Bundle bundle, @Nullable IBinder secondaryFragmentToken,
@Nullable TaskFragmentAnimationParams animationParams,
- boolean isolatedNav, boolean dimOnTask) {
+ boolean isolatedNav, boolean dimOnTask, boolean moveToBottomIfClearWhenLaunch) {
mOpType = opType;
mTaskFragmentCreationParams = taskFragmentCreationParams;
mActivityToken = activityToken;
@@ -188,6 +201,7 @@
mAnimationParams = animationParams;
mIsolatedNav = isolatedNav;
mDimOnTask = dimOnTask;
+ mMoveToBottomIfClearWhenLaunch = moveToBottomIfClearWhenLaunch;
}
private TaskFragmentOperation(Parcel in) {
@@ -200,6 +214,7 @@
mAnimationParams = in.readTypedObject(TaskFragmentAnimationParams.CREATOR);
mIsolatedNav = in.readBoolean();
mDimOnTask = in.readBoolean();
+ mMoveToBottomIfClearWhenLaunch = in.readBoolean();
}
@Override
@@ -213,6 +228,7 @@
dest.writeTypedObject(mAnimationParams, flags);
dest.writeBoolean(mIsolatedNav);
dest.writeBoolean(mDimOnTask);
+ dest.writeBoolean(mMoveToBottomIfClearWhenLaunch);
}
@NonNull
@@ -300,6 +316,14 @@
return mDimOnTask;
}
+ /**
+ * Returns whether the TaskFragment should move to bottom of task when any activity below it
+ * is launched in clear top mode.
+ */
+ public boolean isMoveToBottomIfClearWhenLaunch() {
+ return mMoveToBottomIfClearWhenLaunch;
+ }
+
@Override
public String toString() {
final StringBuilder sb = new StringBuilder();
@@ -324,6 +348,7 @@
}
sb.append(", isolatedNav=").append(mIsolatedNav);
sb.append(", dimOnTask=").append(mDimOnTask);
+ sb.append(", moveToBottomIfClearWhenLaunch=").append(mMoveToBottomIfClearWhenLaunch);
sb.append('}');
return sb.toString();
@@ -332,7 +357,8 @@
@Override
public int hashCode() {
return Objects.hash(mOpType, mTaskFragmentCreationParams, mActivityToken, mActivityIntent,
- mBundle, mSecondaryFragmentToken, mAnimationParams, mIsolatedNav, mDimOnTask);
+ mBundle, mSecondaryFragmentToken, mAnimationParams, mIsolatedNav, mDimOnTask,
+ mMoveToBottomIfClearWhenLaunch);
}
@Override
@@ -349,7 +375,8 @@
&& Objects.equals(mSecondaryFragmentToken, other.mSecondaryFragmentToken)
&& Objects.equals(mAnimationParams, other.mAnimationParams)
&& mIsolatedNav == other.mIsolatedNav
- && mDimOnTask == other.mDimOnTask;
+ && mDimOnTask == other.mDimOnTask
+ && mMoveToBottomIfClearWhenLaunch == other.mMoveToBottomIfClearWhenLaunch;
}
@Override
@@ -385,6 +412,8 @@
private boolean mDimOnTask;
+ private boolean mMoveToBottomIfClearWhenLaunch;
+
/**
* @param opType the {@link OperationType} of this {@link TaskFragmentOperation}.
*/
@@ -466,13 +495,23 @@
}
/**
+ * Sets whether the TaskFragment should move to bottom of task when any activity below it
+ * is launched in clear top mode.
+ */
+ @NonNull
+ public Builder setMoveToBottomIfClearWhenLaunch(boolean moveToBottomIfClearWhenLaunch) {
+ mMoveToBottomIfClearWhenLaunch = moveToBottomIfClearWhenLaunch;
+ return this;
+ }
+
+ /**
* Constructs the {@link TaskFragmentOperation}.
*/
@NonNull
public TaskFragmentOperation build() {
return new TaskFragmentOperation(mOpType, mTaskFragmentCreationParams, mActivityToken,
mActivityIntent, mBundle, mSecondaryFragmentToken, mAnimationParams,
- mIsolatedNav, mDimOnTask);
+ mIsolatedNav, mDimOnTask, mMoveToBottomIfClearWhenLaunch);
}
}
}
diff --git a/core/java/android/window/TransitionInfo.java b/core/java/android/window/TransitionInfo.java
index bceb872..feae173 100644
--- a/core/java/android/window/TransitionInfo.java
+++ b/core/java/android/window/TransitionInfo.java
@@ -421,8 +421,11 @@
final String perChangeLineStart = shouldPrettyPrint ? "\n" + innerPrefix : "";
StringBuilder sb = new StringBuilder();
sb.append("{id=").append(mDebugId).append(" t=").append(transitTypeToString(mType))
- .append(" f=0x").append(Integer.toHexString(mFlags)).append(" trk=").append(mTrack)
- .append(" r=[");
+ .append(" f=0x").append(Integer.toHexString(mFlags)).append(" trk=").append(mTrack);
+ if (mOptions != null) {
+ sb.append(" opt=").append(mOptions);
+ }
+ sb.append(" r=[");
for (int i = 0; i < mRoots.size(); ++i) {
if (i > 0) {
sb.append(',');
@@ -1211,21 +1214,31 @@
@NonNull
private static String typeToString(int mode) {
- switch(mode) {
- case ANIM_CUSTOM: return "ANIM_CUSTOM";
- case ANIM_CLIP_REVEAL: return "ANIM_CLIP_REVEAL";
- case ANIM_SCALE_UP: return "ANIM_SCALE_UP";
- case ANIM_THUMBNAIL_SCALE_UP: return "ANIM_THUMBNAIL_SCALE_UP";
- case ANIM_THUMBNAIL_SCALE_DOWN: return "ANIM_THUMBNAIL_SCALE_DOWN";
- case ANIM_OPEN_CROSS_PROFILE_APPS: return "ANIM_OPEN_CROSS_PROFILE_APPS";
- default: return "<unknown:" + mode + ">";
- }
+ return switch (mode) {
+ case ANIM_CUSTOM -> "CUSTOM";
+ case ANIM_SCALE_UP -> "SCALE_UP";
+ case ANIM_THUMBNAIL_SCALE_UP -> "THUMBNAIL_SCALE_UP";
+ case ANIM_THUMBNAIL_SCALE_DOWN -> "THUMBNAIL_SCALE_DOWN";
+ case ANIM_SCENE_TRANSITION -> "SCENE_TRANSITION";
+ case ANIM_CLIP_REVEAL -> "CLIP_REVEAL";
+ case ANIM_OPEN_CROSS_PROFILE_APPS -> "OPEN_CROSS_PROFILE_APPS";
+ case ANIM_FROM_STYLE -> "FROM_STYLE";
+ default -> "<" + mode + ">";
+ };
}
@Override
public String toString() {
- return "{ AnimationOptions type= " + typeToString(mType) + " package=" + mPackageName
- + " override=" + mOverrideTaskTransition + " b=" + mTransitionBounds + "}";
+ final StringBuilder sb = new StringBuilder(32);
+ sb.append("{t=").append(typeToString(mType));
+ if (mOverrideTaskTransition) {
+ sb.append(" overrideTask=true");
+ }
+ if (!mTransitionBounds.isEmpty()) {
+ sb.append(" bounds=").append(mTransitionBounds);
+ }
+ sb.append('}');
+ return sb.toString();
}
/** Customized activity transition. */
diff --git a/core/java/android/window/flags/large_screen_experiences_app_compat.aconfig b/core/java/android/window/flags/large_screen_experiences_app_compat.aconfig
index 4b5595f..cbf6367 100644
--- a/core/java/android/window/flags/large_screen_experiences_app_compat.aconfig
+++ b/core/java/android/window/flags/large_screen_experiences_app_compat.aconfig
@@ -43,3 +43,10 @@
description: "Whether the API PackageManager.USER_MIN_ASPECT_RATIO_APP_DEFAULT is available"
bug: "310816437"
}
+
+flag {
+ name: "allow_hide_scm_button"
+ namespace: "large_screen_experiences_app_compat"
+ description: "Whether we should allow hiding the size compat restart button"
+ bug: "318840081"
+}
diff --git a/core/java/android/window/flags/window_surfaces.aconfig b/core/java/android/window/flags/window_surfaces.aconfig
index 3c3c846..751c1a8 100644
--- a/core/java/android/window/flags/window_surfaces.aconfig
+++ b/core/java/android/window/flags/window_surfaces.aconfig
@@ -80,3 +80,11 @@
is_fixed_read_only: true
bug: "278757236"
}
+
+flag {
+ namespace: "window_surfaces"
+ name: "screen_recording_callbacks"
+ description: "Enable screen recording callbacks public API"
+ is_fixed_read_only: true
+ bug: "304574518"
+}
diff --git a/core/java/android/window/flags/windowing_frontend.aconfig b/core/java/android/window/flags/windowing_frontend.aconfig
index bb16ad2..2b96ee6 100644
--- a/core/java/android/window/flags/windowing_frontend.aconfig
+++ b/core/java/android/window/flags/windowing_frontend.aconfig
@@ -69,11 +69,10 @@
}
flag {
- name: "predictive_back_system_animations"
+ name: "predictive_back_system_anims"
namespace: "systemui"
description: "Predictive back for system animations"
- bug: "319421778"
- is_fixed_read_only: true
+ bug: "320510464"
}
flag {
diff --git a/core/java/com/android/internal/telephony/IPhoneStateListener.aidl b/core/java/com/android/internal/telephony/IPhoneStateListener.aidl
index 03cfd4f..969f95d 100644
--- a/core/java/com/android/internal/telephony/IPhoneStateListener.aidl
+++ b/core/java/com/android/internal/telephony/IPhoneStateListener.aidl
@@ -80,4 +80,5 @@
void onMediaQualityStatusChanged(in MediaQualityStatus mediaQualityStatus);
void onCallBackModeStarted(int type);
void onCallBackModeStopped(int type, int reason);
+ void onSimultaneousCallingStateChanged(in int[] subIds);
}
diff --git a/core/java/com/android/internal/telephony/ITelephonyRegistry.aidl b/core/java/com/android/internal/telephony/ITelephonyRegistry.aidl
index aab2242..0203ea4 100644
--- a/core/java/com/android/internal/telephony/ITelephonyRegistry.aidl
+++ b/core/java/com/android/internal/telephony/ITelephonyRegistry.aidl
@@ -104,6 +104,7 @@
void notifyAllowedNetworkTypesChanged(in int phoneId, in int subId, in int reason, in long allowedNetworkType);
void notifyLinkCapacityEstimateChanged(in int phoneId, in int subId,
in List<LinkCapacityEstimate> linkCapacityEstimateList);
+ void notifySimultaneousCellularCallingSubscriptionsChanged(in int[] subIds);
void addCarrierPrivilegesCallback(
int phoneId, ICarrierPrivilegesCallback callback, String pkg, String featureId);
diff --git a/core/java/com/android/internal/util/RingBuffer.java b/core/java/com/android/internal/util/RingBuffer.java
index 0488659..342ba1b6 100644
--- a/core/java/com/android/internal/util/RingBuffer.java
+++ b/core/java/com/android/internal/util/RingBuffer.java
@@ -19,7 +19,10 @@
import static com.android.internal.util.Preconditions.checkArgumentPositive;
import java.lang.reflect.Array;
+import java.lang.reflect.InvocationTargetException;
import java.util.Arrays;
+import java.util.function.IntFunction;
+import java.util.function.Supplier;
/**
* A simple ring buffer structure with bounded capacity backed by an array.
@@ -30,16 +33,35 @@
@android.ravenwood.annotation.RavenwoodKeepWholeClass
public class RingBuffer<T> {
+ private final Supplier<T> mNewItem;
// Array for storing events.
private final T[] mBuffer;
// Cursor keeping track of the logical end of the array. This cursor never
// wraps and instead keeps track of the total number of append() operations.
private long mCursor = 0;
+ /**
+ * @deprecated This uses reflection to create new instances.
+ * Use {@link #RingBuffer(Supplier, IntFunction, int)}} instead.
+ */
+ @Deprecated
public RingBuffer(Class<T> c, int capacity) {
+ this(() -> (T) createNewItem(c), cap -> (T[]) Array.newInstance(c, cap), capacity);
+ }
+
+ private static Object createNewItem(Class c) {
+ try {
+ return c.getDeclaredConstructor().newInstance();
+ } catch (IllegalAccessException | InstantiationException | NoSuchMethodException
+ | InvocationTargetException e) {
+ return null;
+ }
+ }
+
+ public RingBuffer(Supplier<T> newItem, IntFunction<T[]> newBacking, int capacity) {
checkArgumentPositive(capacity, "A RingBuffer cannot have 0 capacity");
- // Java cannot create generic arrays without a runtime hint.
- mBuffer = (T[]) Array.newInstance(c, capacity);
+ mBuffer = newBacking.apply(capacity);
+ mNewItem = newItem;
}
public int size() {
@@ -69,22 +91,11 @@
public T getNextSlot() {
final int nextSlotIdx = indexOf(mCursor++);
if (mBuffer[nextSlotIdx] == null) {
- mBuffer[nextSlotIdx] = createNewItem();
+ mBuffer[nextSlotIdx] = mNewItem.get();
}
return mBuffer[nextSlotIdx];
}
- /**
- * @return a new object of type <T> or null if a new object could not be created.
- */
- protected T createNewItem() {
- try {
- return (T) mBuffer.getClass().getComponentType().newInstance();
- } catch (IllegalAccessException | InstantiationException e) {
- return null;
- }
- }
-
public T[] toArray() {
// Only generic way to create a T[] from another T[]
T[] out = Arrays.copyOf(mBuffer, size(), (Class<T[]>) mBuffer.getClass());
diff --git a/core/jni/android_hardware_OverlayProperties.cpp b/core/jni/android_hardware_OverlayProperties.cpp
index 5b95ee7..f6fe3dd 100644
--- a/core/jni/android_hardware_OverlayProperties.cpp
+++ b/core/jni/android_hardware_OverlayProperties.cpp
@@ -61,13 +61,12 @@
static_cast<int32_t>(HAL_PIXEL_FORMAT_RGBA_FP16)) !=
i.pixelFormats.end() &&
std::find(i.standards.begin(), i.standards.end(),
- static_cast<int32_t>(HAL_DATASPACE_STANDARD_BT2020)) !=
+ static_cast<int32_t>(HAL_DATASPACE_STANDARD_BT709)) !=
i.standards.end() &&
std::find(i.transfers.begin(), i.transfers.end(),
- static_cast<int32_t>(HAL_DATASPACE_TRANSFER_ST2084)) !=
- i.transfers.end() &&
+ static_cast<int32_t>(HAL_DATASPACE_TRANSFER_SRGB)) != i.transfers.end() &&
std::find(i.ranges.begin(), i.ranges.end(),
- static_cast<int32_t>(HAL_DATASPACE_RANGE_FULL)) != i.ranges.end()) {
+ static_cast<int32_t>(HAL_DATASPACE_RANGE_EXTENDED)) != i.ranges.end()) {
return true;
}
}
diff --git a/core/proto/android/service/notification.proto b/core/proto/android/service/notification.proto
index a2978be..ad36b1c 100644
--- a/core/proto/android/service/notification.proto
+++ b/core/proto/android/service/notification.proto
@@ -360,7 +360,7 @@
optional ConversationType allow_conversations_from = 19;
- optional ChannelType allow_channels = 20;
+ optional ChannelPolicy allow_channels = 20;
}
// Enum identifying the type of rule that changed; values set to match ones used in the
@@ -373,8 +373,8 @@
// Enum used in DNDPolicyProto to indicate the type of channels permitted to
// break through DND. Mirrors values in ZenPolicy.
-enum ChannelType {
- CHANNEL_TYPE_UNSET = 0;
- CHANNEL_TYPE_PRIORITY = 1;
- CHANNEL_TYPE_NONE = 2;
+enum ChannelPolicy {
+ CHANNEL_POLICY_UNSET = 0;
+ CHANNEL_POLICY_PRIORITY = 1;
+ CHANNEL_POLICY_NONE = 2;
}
diff --git a/core/res/AndroidManifest.xml b/core/res/AndroidManifest.xml
index 5f3f641..4a82675 100644
--- a/core/res/AndroidManifest.xml
+++ b/core/res/AndroidManifest.xml
@@ -7896,6 +7896,18 @@
<permission android:name="android.permission.RECEIVE_SENSITIVE_NOTIFICATIONS"
android:protectionLevel="signature|role" />
+ <!-- @SystemApi
+ @FlaggedApi("android.app.bic_client")
+ Allows app to call BackgroundInstallControlManager API to retrieve silently installed apps
+ for all users on device.
+ <p>Apps with a BackgroundInstallControlManager client will not be able to call any API without
+ this permission.
+ <p>Protection level: signature|role
+ @hide
+ -->
+ <permission android:name="android.permission.GET_BACKGROUND_INSTALLED_PACKAGES"
+ android:protectionLevel="signature|role" />
+
<!-- Attribution for Geofencing service. -->
<attribution android:tag="GeofencingService" android:label="@string/geofencing_service"/>
<!-- Attribution for Country Detector. -->
diff --git a/core/res/res/values/config.xml b/core/res/res/values/config.xml
index 28adccd..5be29a6 100644
--- a/core/res/res/values/config.xml
+++ b/core/res/res/values/config.xml
@@ -57,7 +57,6 @@
<item><xliff:g id="id">@string/status_bar_screen_record</xliff:g></item>
<item><xliff:g id="id">@string/status_bar_cast</xliff:g></item>
<item><xliff:g id="id">@string/status_bar_ethernet</xliff:g></item>
- <item><xliff:g id="id">@string/status_bar_oem_satellite</xliff:g></item>
<item><xliff:g id="id">@string/status_bar_wifi</xliff:g></item>
<item><xliff:g id="id">@string/status_bar_hotspot</xliff:g></item>
<item><xliff:g id="id">@string/status_bar_mobile</xliff:g></item>
@@ -103,7 +102,6 @@
<string translatable="false" name="status_bar_call_strength">call_strength</string>
<string translatable="false" name="status_bar_sensors_off">sensors_off</string>
<string translatable="false" name="status_bar_screen_record">screen_record</string>
- <string translatable="false" name="status_bar_oem_satellite">satellite</string>
<!-- Flag indicating whether the surface flinger has limited
alpha compositing functionality in hardware. If set, the window
diff --git a/core/res/res/values/symbols.xml b/core/res/res/values/symbols.xml
index ef12d8f..d12ef2b 100644
--- a/core/res/res/values/symbols.xml
+++ b/core/res/res/values/symbols.xml
@@ -3198,7 +3198,6 @@
<java-symbol type="string" name="status_bar_camera" />
<java-symbol type="string" name="status_bar_sensors_off" />
<java-symbol type="string" name="status_bar_screen_record" />
- <java-symbol type="string" name="status_bar_oem_satellite" />
<!-- Locale picker -->
<java-symbol type="id" name="locale_search_menu" />
diff --git a/core/tests/BroadcastRadioTests/TEST_MAPPING b/core/tests/BroadcastRadioTests/TEST_MAPPING
new file mode 100644
index 0000000..b085a27
--- /dev/null
+++ b/core/tests/BroadcastRadioTests/TEST_MAPPING
@@ -0,0 +1,7 @@
+{
+ "postsubmit": [
+ {
+ "name": "BroadcastRadioTests"
+ }
+ ]
+}
diff --git a/core/tests/coretests/Android.bp b/core/tests/coretests/Android.bp
index 531756e..e18de2e 100644
--- a/core/tests/coretests/Android.bp
+++ b/core/tests/coretests/Android.bp
@@ -30,6 +30,8 @@
android_test {
name: "FrameworksCoreTests",
+ // FrameworksCoreTestsRavenwood references the .aapt.srcjar
+ use_resource_processor: false,
srcs: [
"src/**/*.java",
diff --git a/core/tests/coretests/src/android/app/AutomaticZenRuleTest.java b/core/tests/coretests/src/android/app/AutomaticZenRuleTest.java
index 9d85b65..1925588 100644
--- a/core/tests/coretests/src/android/app/AutomaticZenRuleTest.java
+++ b/core/tests/coretests/src/android/app/AutomaticZenRuleTest.java
@@ -16,8 +16,6 @@
package android.app;
-import static com.google.common.truth.Truth.assertThat;
-
import static junit.framework.Assert.assertEquals;
import static junit.framework.Assert.fail;
@@ -28,8 +26,6 @@
import android.os.Parcel;
import android.platform.test.annotations.EnableFlags;
import android.platform.test.flag.junit.SetFlagsRule;
-import android.service.notification.ZenDeviceEffects;
-import android.service.notification.ZenPolicy;
import androidx.test.ext.junit.runners.AndroidJUnit4;
import androidx.test.filters.SmallTest;
@@ -230,66 +226,4 @@
assertThrows(IllegalArgumentException.class, () -> builder.setType(100));
}
-
- @Test
- @EnableFlags(Flags.FLAG_MODES_API)
- public void testCanUpdate_nullPolicyAndDeviceEffects() {
- AutomaticZenRule.Builder builder = new AutomaticZenRule.Builder("name",
- Uri.parse("uri://short"));
-
- AutomaticZenRule rule = builder.setUserModifiedFields(0)
- .setZenPolicy(null)
- .setDeviceEffects(null)
- .build();
-
- assertThat(rule.canUpdate()).isTrue();
-
- rule = builder.setUserModifiedFields(1).build();
- assertThat(rule.canUpdate()).isFalse();
- }
-
- @Test
- @EnableFlags(Flags.FLAG_MODES_API)
- public void testCanUpdate_policyModified() {
- ZenPolicy.Builder policyBuilder = new ZenPolicy.Builder().setUserModifiedFields(0);
- ZenPolicy policy = policyBuilder.build();
-
- AutomaticZenRule.Builder builder = new AutomaticZenRule.Builder("name",
- Uri.parse("uri://short"));
- AutomaticZenRule rule = builder.setUserModifiedFields(0)
- .setZenPolicy(policy)
- .setDeviceEffects(null).build();
-
- // Newly created ZenPolicy is not user modified.
- assertThat(policy.getUserModifiedFields()).isEqualTo(0);
- assertThat(rule.canUpdate()).isTrue();
-
- policy = policyBuilder.setUserModifiedFields(1).build();
- assertThat(policy.getUserModifiedFields()).isEqualTo(1);
- rule = builder.setZenPolicy(policy).build();
- assertThat(rule.canUpdate()).isFalse();
- }
-
- @Test
- @EnableFlags(Flags.FLAG_MODES_API)
- public void testCanUpdate_deviceEffectsModified() {
- ZenDeviceEffects.Builder deviceEffectsBuilder =
- new ZenDeviceEffects.Builder().setUserModifiedFields(0);
- ZenDeviceEffects deviceEffects = deviceEffectsBuilder.build();
-
- AutomaticZenRule.Builder builder = new AutomaticZenRule.Builder("name",
- Uri.parse("uri://short"));
- AutomaticZenRule rule = builder.setUserModifiedFields(0)
- .setZenPolicy(null)
- .setDeviceEffects(deviceEffects).build();
-
- // Newly created ZenDeviceEffects is not user modified.
- assertThat(deviceEffects.getUserModifiedFields()).isEqualTo(0);
- assertThat(rule.canUpdate()).isTrue();
-
- deviceEffects = deviceEffectsBuilder.setUserModifiedFields(1).build();
- assertThat(deviceEffects.getUserModifiedFields()).isEqualTo(1);
- rule = builder.setDeviceEffects(deviceEffects).build();
- assertThat(rule.canUpdate()).isFalse();
- }
}
diff --git a/data/etc/privapp-permissions-platform.xml b/data/etc/privapp-permissions-platform.xml
index a1ea2b8..42068aa 100644
--- a/data/etc/privapp-permissions-platform.xml
+++ b/data/etc/privapp-permissions-platform.xml
@@ -541,6 +541,8 @@
<permission name="android.permission.GET_BINDING_UID_IMPORTANCE"/>
<!-- Permission required for CTS test NotificationManagerZenTest -->
<permission name="android.permission.CONTROL_DISPLAY_COLOR_TRANSFORMS" />
+ <!-- Permission required for BinaryTransparencyService shell API and host test -->
+ <permission name="android.permission.GET_BACKGROUND_INSTALLED_PACKAGES" />
</privapp-permissions>
<privapp-permissions package="com.android.statementservice">
diff --git a/data/etc/services.core.protolog.json b/data/etc/services.core.protolog.json
index 917a300..3a778c3 100644
--- a/data/etc/services.core.protolog.json
+++ b/data/etc/services.core.protolog.json
@@ -535,6 +535,12 @@
"group": "WM_DEBUG_TASKS",
"at": "com\/android\/server\/wm\/ActivityStarter.java"
},
+ "-1583619037": {
+ "message": "Failed to register MediaProjectionWatcherCallback",
+ "level": "ERROR",
+ "group": "WM_ERROR",
+ "at": "com\/android\/server\/wm\/ScreenRecordingCallbackController.java"
+ },
"-1582845629": {
"message": "Starting animation on %s",
"level": "VERBOSE",
@@ -2983,12 +2989,6 @@
"group": "WM_DEBUG_SCREEN_ON",
"at": "com\/android\/server\/wm\/WindowManagerService.java"
},
- "466506262": {
- "message": "Clear freezing of %s: visible=%b freezing=%b",
- "level": "VERBOSE",
- "group": "WM_DEBUG_ORIENTATION",
- "at": "com\/android\/server\/wm\/ActivityRecord.java"
- },
"485170982": {
"message": "Not finishing noHistory %s on stop because we're just sleeping",
"level": "DEBUG",
diff --git a/graphics/java/android/graphics/Paint.java b/graphics/java/android/graphics/Paint.java
index c5a2f98..f6ba103 100644
--- a/graphics/java/android/graphics/Paint.java
+++ b/graphics/java/android/graphics/Paint.java
@@ -65,8 +65,6 @@
private long mNativeShader;
private long mNativeColorFilter;
- private static boolean sIsRobolectric = Build.FINGERPRINT.equals("robolectric");
-
// Use a Holder to allow static initialization of Paint in the boot image.
private static class NoImagePreloadHolder {
public static final NativeAllocationRegistry sRegistry =
@@ -3393,13 +3391,8 @@
return 0.0f;
}
- if (sIsRobolectric) {
- return nGetRunCharacterAdvance(mNativePaint, text, start, end,
- contextStart, contextEnd, isRtl, offset, advances, advancesIndex, drawBounds);
- } else {
- return nGetRunCharacterAdvance(mNativePaint, text, start, end, contextStart, contextEnd,
- isRtl, offset, advances, advancesIndex, drawBounds, runInfo);
- }
+ return nGetRunCharacterAdvance(mNativePaint, text, start, end, contextStart, contextEnd,
+ isRtl, offset, advances, advancesIndex, drawBounds, runInfo);
}
/**
diff --git a/graphics/java/android/graphics/text/LineBreakConfig.java b/graphics/java/android/graphics/text/LineBreakConfig.java
index ddae673..b21bf11 100644
--- a/graphics/java/android/graphics/text/LineBreakConfig.java
+++ b/graphics/java/android/graphics/text/LineBreakConfig.java
@@ -23,9 +23,7 @@
import android.annotation.IntDef;
import android.annotation.NonNull;
import android.annotation.Nullable;
-import android.app.compat.CompatChanges;
-import android.compat.annotation.ChangeId;
-import android.compat.annotation.EnabledSince;
+import android.app.ActivityThread;
import android.os.Build;
import android.os.LocaleList;
import android.os.Parcel;
@@ -43,15 +41,6 @@
* line-break property</a> for more information.
*/
public final class LineBreakConfig implements Parcelable {
-
- /**
- * A feature ID for automatic line break word style.
- * @hide
- */
- @ChangeId
- @EnabledSince(targetSdkVersion = Build.VERSION_CODES.VANILLA_ICE_CREAM)
- public static final long WORD_STYLE_AUTO = 280005585L;
-
/**
* No hyphenation preference is specified.
*
@@ -487,8 +476,15 @@
* @hide
*/
public static @LineBreakStyle int getResolvedLineBreakStyle(@Nullable LineBreakConfig config) {
- final int defaultStyle = CompatChanges.isChangeEnabled(WORD_STYLE_AUTO)
- ? LINE_BREAK_STYLE_AUTO : LINE_BREAK_STYLE_NONE;
+ final int targetSdkVersion = ActivityThread.currentApplication().getApplicationInfo()
+ .targetSdkVersion;
+ final int defaultStyle;
+ final int vicVersion = Build.VERSION_CODES.VANILLA_ICE_CREAM;
+ if (targetSdkVersion >= vicVersion) {
+ defaultStyle = LINE_BREAK_STYLE_AUTO;
+ } else {
+ defaultStyle = LINE_BREAK_STYLE_NONE;
+ }
if (config == null) {
return defaultStyle;
}
@@ -515,8 +511,15 @@
*/
public static @LineBreakWordStyle int getResolvedLineBreakWordStyle(
@Nullable LineBreakConfig config) {
- final int defaultWordStyle = CompatChanges.isChangeEnabled(WORD_STYLE_AUTO)
- ? LINE_BREAK_WORD_STYLE_AUTO : LINE_BREAK_WORD_STYLE_NONE;
+ final int targetSdkVersion = ActivityThread.currentApplication().getApplicationInfo()
+ .targetSdkVersion;
+ final int defaultWordStyle;
+ final int vicVersion = Build.VERSION_CODES.VANILLA_ICE_CREAM;
+ if (targetSdkVersion >= vicVersion) {
+ defaultWordStyle = LINE_BREAK_WORD_STYLE_AUTO;
+ } else {
+ defaultWordStyle = LINE_BREAK_WORD_STYLE_NONE;
+ }
if (config == null) {
return defaultWordStyle;
}
diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/back/BackAnimationController.java b/libs/WindowManager/Shell/src/com/android/wm/shell/back/BackAnimationController.java
index bb433db..e7f6f0d 100644
--- a/libs/WindowManager/Shell/src/com/android/wm/shell/back/BackAnimationController.java
+++ b/libs/WindowManager/Shell/src/com/android/wm/shell/back/BackAnimationController.java
@@ -17,7 +17,7 @@
package com.android.wm.shell.back;
import static com.android.internal.jank.InteractionJankMonitor.CUJ_PREDICTIVE_BACK_HOME;
-import static com.android.window.flags.Flags.predictiveBackSystemAnimations;
+import static com.android.window.flags.Flags.predictiveBackSystemAnims;
import static com.android.wm.shell.common.ExecutorUtils.executeRemoteCallWithTaskPermission;
import static com.android.wm.shell.protolog.ShellProtoLogGroup.WM_SHELL_BACK_PREVIEW;
import static com.android.wm.shell.sysui.ShellSharedConstants.KEY_EXTRA_SHELL_BACK_ANIMATION;
@@ -244,7 +244,7 @@
private void setupAnimationDeveloperSettingsObserver(
@NonNull ContentResolver contentResolver,
@NonNull @ShellBackgroundThread final Handler backgroundHandler) {
- if (predictiveBackSystemAnimations()) {
+ if (predictiveBackSystemAnims()) {
ProtoLog.d(WM_SHELL_BACK_PREVIEW, "Back animation aconfig flag is enabled, therefore "
+ "developer settings flag is ignored and no content observer registered");
return;
@@ -267,7 +267,7 @@
*/
@ShellBackgroundThread
private void updateEnableAnimationFromFlags() {
- boolean isEnabled = predictiveBackSystemAnimations() || isDeveloperSettingEnabled();
+ boolean isEnabled = predictiveBackSystemAnims() || isDeveloperSettingEnabled();
mEnableAnimations.set(isEnabled);
ProtoLog.d(WM_SHELL_BACK_PREVIEW, "Back animation enabled=%s", isEnabled);
}
diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/animation/StackAnimationController.java b/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/animation/StackAnimationController.java
index e487328..bb0dd95 100644
--- a/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/animation/StackAnimationController.java
+++ b/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/animation/StackAnimationController.java
@@ -769,8 +769,10 @@
boolean swapped = false;
for (int newIndex = 0; newIndex < bubbleViews.size(); newIndex++) {
View view = bubbleViews.get(newIndex);
- final int oldIndex = mLayout.indexOfChild(view);
- swapped |= animateSwap(view, oldIndex, newIndex, updateAllIcons, after);
+ if (view != null) {
+ final int oldIndex = mLayout.indexOfChild(view);
+ swapped |= animateSwap(view, oldIndex, newIndex, updateAllIcons, after);
+ }
}
if (!swapped) {
// All bubbles were at the right position. Make sure badges and z order is correct.
diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/bar/BubbleBarLayerView.java b/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/bar/BubbleBarLayerView.java
index 1211451..bd8ce80 100644
--- a/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/bar/BubbleBarLayerView.java
+++ b/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/bar/BubbleBarLayerView.java
@@ -26,6 +26,7 @@
import android.graphics.Rect;
import android.graphics.Region;
import android.graphics.drawable.ColorDrawable;
+import android.view.Gravity;
import android.view.TouchDelegate;
import android.view.View;
import android.view.ViewTreeObserver;
@@ -74,10 +75,6 @@
private DismissView mDismissView;
private @Nullable Consumer<String> mUnBubbleConversationCallback;
- // TODO(b/273310265) - currently the view is always on the right, need to update for RTL.
- /** Whether the expanded view is displaying on the left of the screen or not. */
- private boolean mOnLeft = false;
-
/** Whether a bubble is expanded. */
private boolean mIsExpanded = false;
@@ -154,10 +151,10 @@
return mIsExpanded;
}
- // (TODO: b/273310265): BubblePositioner should be source of truth when this work is done.
+ // TODO(b/313661121) - when dragging is implemented, check user setting first
/** Whether the expanded view is positioned on the left or right side of the screen. */
public boolean isOnLeft() {
- return mOnLeft;
+ return getLayoutDirection() == LAYOUT_DIRECTION_RTL;
}
/** Shows the expanded view of the provided bubble. */
@@ -216,7 +213,7 @@
return Unit.INSTANCE;
});
- addView(mExpandedView, new FrameLayout.LayoutParams(width, height));
+ addView(mExpandedView, new LayoutParams(width, height, Gravity.LEFT));
}
if (mEducationViewController.isEducationVisible()) {
@@ -311,7 +308,7 @@
lp.width = width;
lp.height = height;
mExpandedView.setLayoutParams(lp);
- if (mOnLeft) {
+ if (isOnLeft()) {
mExpandedView.setX(mPositioner.getInsets().left + padding);
} else {
mExpandedView.setX(mPositioner.getAvailableRect().width() - width - padding);
diff --git a/libs/hwui/Android.bp b/libs/hwui/Android.bp
index eebf8aa..b40b73c 100644
--- a/libs/hwui/Android.bp
+++ b/libs/hwui/Android.bp
@@ -716,7 +716,6 @@
],
shared_libs: [
"libmemunreachable",
- "server_configurable_flags",
],
srcs: [
"tests/unit/main.cpp",
diff --git a/libs/hwui/DeviceInfo.h b/libs/hwui/DeviceInfo.h
index d4af087..a5a841e 100644
--- a/libs/hwui/DeviceInfo.h
+++ b/libs/hwui/DeviceInfo.h
@@ -23,6 +23,7 @@
#include <mutex>
+#include "Properties.h"
#include "utils/Macros.h"
namespace android {
@@ -60,7 +61,13 @@
static void setWideColorDataspace(ADataSpace dataspace);
static void setSupportFp16ForHdr(bool supportFp16ForHdr);
- static bool isSupportFp16ForHdr() { return get()->mSupportFp16ForHdr; };
+ static bool isSupportFp16ForHdr() {
+ if (!Properties::hdr10bitPlus) {
+ return false;
+ }
+
+ return get()->mSupportFp16ForHdr;
+ };
static void setSupportMixedColorSpaces(bool supportMixedColorSpaces);
static bool isSupportMixedColorSpaces() { return get()->mSupportMixedColorSpaces; };
diff --git a/libs/hwui/HardwareBitmapUploader.cpp b/libs/hwui/HardwareBitmapUploader.cpp
index 16de21d..71f7926 100644
--- a/libs/hwui/HardwareBitmapUploader.cpp
+++ b/libs/hwui/HardwareBitmapUploader.cpp
@@ -379,7 +379,7 @@
case kAlpha_8_SkColorType:
formatInfo.isSupported = HardwareBitmapUploader::hasAlpha8Support();
formatInfo.bufferFormat = AHARDWAREBUFFER_FORMAT_R8_UNORM;
- formatInfo.format = GL_R8;
+ formatInfo.format = GL_RED;
formatInfo.type = GL_UNSIGNED_BYTE;
formatInfo.vkFormat = VK_FORMAT_R8_UNORM;
break;
diff --git a/libs/hwui/Properties.cpp b/libs/hwui/Properties.cpp
index d58c872..755332ff 100644
--- a/libs/hwui/Properties.cpp
+++ b/libs/hwui/Properties.cpp
@@ -38,6 +38,9 @@
constexpr bool clip_surfaceviews() {
return false;
}
+constexpr bool hdr_10bit_plus() {
+ return false;
+}
} // namespace hwui_flags
#endif
@@ -105,6 +108,7 @@
float Properties::maxHdrHeadroomOn8bit = 5.f; // TODO: Refine this number
bool Properties::clipSurfaceViews = false;
+bool Properties::hdr10bitPlus = false;
StretchEffectBehavior Properties::stretchEffectBehavior = StretchEffectBehavior::ShaderHWUI;
@@ -177,6 +181,7 @@
clipSurfaceViews =
base::GetBoolProperty("debug.hwui.clip_surfaceviews", hwui_flags::clip_surfaceviews());
+ hdr10bitPlus = hwui_flags::hdr_10bit_plus();
return (prevDebugLayersUpdates != debugLayersUpdates) || (prevDebugOverdraw != debugOverdraw);
}
diff --git a/libs/hwui/Properties.h b/libs/hwui/Properties.h
index b956fac..ec53070 100644
--- a/libs/hwui/Properties.h
+++ b/libs/hwui/Properties.h
@@ -336,6 +336,7 @@
static float maxHdrHeadroomOn8bit;
static bool clipSurfaceViews;
+ static bool hdr10bitPlus;
static StretchEffectBehavior getStretchEffectBehavior() {
return stretchEffectBehavior;
diff --git a/libs/hwui/jni/Paint.cpp b/libs/hwui/jni/Paint.cpp
index 58d9d8b..286f06a 100644
--- a/libs/hwui/jni/Paint.cpp
+++ b/libs/hwui/jni/Paint.cpp
@@ -578,16 +578,6 @@
return result;
}
- // This method is kept for old Robolectric JNI signature used by SystemUIGoogleRoboRNGTests.
- static jfloat getRunCharacterAdvance___CIIIIZI_FI_F_ForRobolectric(
- JNIEnv* env, jclass cls, jlong paintHandle, jcharArray text, jint start, jint end,
- jint contextStart, jint contextEnd, jboolean isRtl, jint offset, jfloatArray advances,
- jint advancesIndex, jobject drawBounds) {
- return getRunCharacterAdvance___CIIIIZI_FI_F(env, cls, paintHandle, text, start, end,
- contextStart, contextEnd, isRtl, offset,
- advances, advancesIndex, drawBounds, nullptr);
- }
-
static jint doOffsetForAdvance(const Paint* paint, const Typeface* typeface, const jchar buf[],
jint start, jint count, jint bufSize, jboolean isRtl, jfloat advance) {
minikin::Bidi bidiFlags = isRtl ? minikin::Bidi::FORCE_RTL : minikin::Bidi::FORCE_LTR;
@@ -1163,8 +1153,6 @@
{"nGetRunCharacterAdvance",
"(J[CIIIIZI[FILandroid/graphics/RectF;Landroid/graphics/Paint$RunInfo;)F",
(void*)PaintGlue::getRunCharacterAdvance___CIIIIZI_FI_F},
- {"nGetRunCharacterAdvance", "(J[CIIIIZI[FILandroid/graphics/RectF;)F",
- (void*)PaintGlue::getRunCharacterAdvance___CIIIIZI_FI_F_ForRobolectric},
{"nGetOffsetForAdvance", "(J[CIIIIZF)I", (void*)PaintGlue::getOffsetForAdvance___CIIIIZF_I},
{"nGetFontMetricsIntForText", "(J[CIIIIZLandroid/graphics/Paint$FontMetricsInt;)V",
(void*)PaintGlue::getFontMetricsIntForText___C},
diff --git a/libs/hwui/pipeline/skia/SkiaPipeline.cpp b/libs/hwui/pipeline/skia/SkiaPipeline.cpp
index e0f1f6e..326b6ed 100644
--- a/libs/hwui/pipeline/skia/SkiaPipeline.cpp
+++ b/libs/hwui/pipeline/skia/SkiaPipeline.cpp
@@ -650,9 +650,14 @@
mSurfaceColorSpace = DeviceInfo::get()->getWideColorSpace();
break;
case ColorMode::Hdr:
- mSurfaceColorType = SkColorType::kN32_SkColorType;
- mSurfaceColorSpace = SkColorSpace::MakeRGB(
- GetExtendedTransferFunction(mTargetSdrHdrRatio), SkNamedGamut::kDisplayP3);
+ if (DeviceInfo::get()->isSupportFp16ForHdr()) {
+ mSurfaceColorType = SkColorType::kRGBA_F16_SkColorType;
+ mSurfaceColorSpace = SkColorSpace::MakeSRGB();
+ } else {
+ mSurfaceColorType = SkColorType::kN32_SkColorType;
+ mSurfaceColorSpace = SkColorSpace::MakeRGB(
+ GetExtendedTransferFunction(mTargetSdrHdrRatio), SkNamedGamut::kDisplayP3);
+ }
break;
case ColorMode::Hdr10:
mSurfaceColorType = SkColorType::kRGBA_1010102_SkColorType;
@@ -669,8 +674,13 @@
void SkiaPipeline::setTargetSdrHdrRatio(float ratio) {
if (mColorMode == ColorMode::Hdr || mColorMode == ColorMode::Hdr10) {
mTargetSdrHdrRatio = ratio;
- mSurfaceColorSpace = SkColorSpace::MakeRGB(GetExtendedTransferFunction(mTargetSdrHdrRatio),
- SkNamedGamut::kDisplayP3);
+
+ if (mColorMode == ColorMode::Hdr && DeviceInfo::get()->isSupportFp16ForHdr()) {
+ mSurfaceColorSpace = SkColorSpace::MakeSRGB();
+ } else {
+ mSurfaceColorSpace = SkColorSpace::MakeRGB(
+ GetExtendedTransferFunction(mTargetSdrHdrRatio), SkNamedGamut::kDisplayP3);
+ }
} else {
mTargetSdrHdrRatio = 1.f;
}
diff --git a/libs/hwui/renderthread/CacheManager.cpp b/libs/hwui/renderthread/CacheManager.cpp
index eb4d494..ac2a936 100644
--- a/libs/hwui/renderthread/CacheManager.cpp
+++ b/libs/hwui/renderthread/CacheManager.cpp
@@ -124,24 +124,19 @@
// flush and submit all work to the gpu and wait for it to finish
mGrContext->flushAndSubmit(GrSyncCpu::kYes);
- switch (mode) {
- case TrimLevel::BACKGROUND:
- mGrContext->freeGpuResources();
- SkGraphics::PurgeAllCaches();
- mRenderThread.destroyRenderingContext();
- break;
- case TrimLevel::UI_HIDDEN:
- // Here we purge all the unlocked scratch resources and then toggle the resources cache
- // limits between the background and max amounts. This causes the unlocked resources
- // that have persistent data to be purged in LRU order.
- mGrContext->setResourceCacheLimit(mBackgroundResourceBytes);
- SkGraphics::SetFontCacheLimit(mBackgroundCpuFontCacheBytes);
- mGrContext->purgeUnlockedResources(toSkiaEnum(mMemoryPolicy.purgeScratchOnly));
- mGrContext->setResourceCacheLimit(mMaxResourceBytes);
- SkGraphics::SetFontCacheLimit(mMaxCpuFontCacheBytes);
- break;
- default:
- break;
+ if (mode >= TrimLevel::BACKGROUND) {
+ mGrContext->freeGpuResources();
+ SkGraphics::PurgeAllCaches();
+ mRenderThread.destroyRenderingContext();
+ } else if (mode == TrimLevel::UI_HIDDEN) {
+ // Here we purge all the unlocked scratch resources and then toggle the resources cache
+ // limits between the background and max amounts. This causes the unlocked resources
+ // that have persistent data to be purged in LRU order.
+ mGrContext->setResourceCacheLimit(mBackgroundResourceBytes);
+ SkGraphics::SetFontCacheLimit(mBackgroundCpuFontCacheBytes);
+ mGrContext->purgeUnlockedResources(toSkiaEnum(mMemoryPolicy.purgeScratchOnly));
+ mGrContext->setResourceCacheLimit(mMaxResourceBytes);
+ SkGraphics::SetFontCacheLimit(mMaxCpuFontCacheBytes);
}
}
diff --git a/libs/hwui/renderthread/EglManager.cpp b/libs/hwui/renderthread/EglManager.cpp
index facf30b..2904dfe 100644
--- a/libs/hwui/renderthread/EglManager.cpp
+++ b/libs/hwui/renderthread/EglManager.cpp
@@ -441,22 +441,32 @@
colorMode = ColorMode::Default;
}
- if (DeviceInfo::get()->getWideColorType() == kRGBA_F16_SkColorType) {
+ // TODO: maybe we want to get rid of the WCG check if overlay properties just works?
+ const bool canUseFp16 = DeviceInfo::get()->isSupportFp16ForHdr() ||
+ DeviceInfo::get()->getWideColorType() == kRGBA_F16_SkColorType;
+
+ if (canUseFp16) {
if (mEglConfigF16 == EGL_NO_CONFIG_KHR) {
colorMode = ColorMode::Default;
} else {
config = mEglConfigF16;
}
}
+
if (EglExtensions.glColorSpace) {
attribs[0] = EGL_GL_COLORSPACE_KHR;
switch (colorMode) {
case ColorMode::Default:
attribs[1] = EGL_GL_COLORSPACE_LINEAR_KHR;
break;
+ case ColorMode::Hdr:
+ if (canUseFp16) {
+ attribs[1] = EGL_GL_COLORSPACE_SCRGB_EXT;
+ break;
+ // No fp16 support so fallthrough to HDR10
+ }
// We don't have an EGL colorspace for extended range P3 that's used for HDR
// So override it after configuring the EGL context
- case ColorMode::Hdr:
case ColorMode::Hdr10:
overrideWindowDataSpaceForHdr = true;
attribs[1] = EGL_GL_COLORSPACE_DISPLAY_P3_PASSTHROUGH_EXT;
diff --git a/media/java/android/media/AudioFormat.java b/media/java/android/media/AudioFormat.java
index b002bbf..ea136ed 100644
--- a/media/java/android/media/AudioFormat.java
+++ b/media/java/android/media/AudioFormat.java
@@ -1079,7 +1079,7 @@
* @return one of the values that can be set in {@link Builder#setEncoding(int)} or
* {@link AudioFormat#ENCODING_INVALID} if not set.
*/
- public int getEncoding() {
+ public @Encoding int getEncoding() {
return mEncoding;
}
diff --git a/media/java/android/media/MediaFormat.java b/media/java/android/media/MediaFormat.java
index 46db777..587e35b 100644
--- a/media/java/android/media/MediaFormat.java
+++ b/media/java/android/media/MediaFormat.java
@@ -16,6 +16,9 @@
package android.media;
+import static com.android.media.codec.flags.Flags.FLAG_CODEC_IMPORTANCE;
+
+import android.annotation.FlaggedApi;
import android.annotation.IntDef;
import android.annotation.NonNull;
import android.annotation.Nullable;
@@ -1635,6 +1638,34 @@
*/
public static final String KEY_ALLOW_FRAME_DROP = "allow-frame-drop";
+ /**
+ * A key describing the desired codec importance for the application.
+ * <p>
+ * The associated value is a positive integer including zero.
+ * Higher value means lesser importance.
+ * <p>
+ * The resource manager may use the codec importance, along with other factors
+ * when reclaiming codecs from an application.
+ * The specifics of reclaim policy is device dependent, but specifying the codec importance,
+ * will allow the resource manager to prioritize reclaiming less important codecs
+ * (assigned higher values) from the (reclaim) requesting application first.
+ * So, the codec importance is only relevant within the context of that application.
+ * <p>
+ * The codec importance can be set:
+ * <ul>
+ * <li>through {@link MediaCodec#configure}. </li>
+ * <li>through {@link MediaCodec#setParameters} if the codec has been configured already,
+ * which allows the users to change the codec importance multiple times.
+ * </ul>
+ * Any change/update in codec importance is guaranteed upon the completion of the function call
+ * that sets the codec importance. So, in case of concurrent codec operations,
+ * make sure to wait for the change in codec importance, before using another codec.
+ * Note that unless specified, by default the codecs will have highest importance (of value 0).
+ *
+ */
+ @FlaggedApi(FLAG_CODEC_IMPORTANCE)
+ public static final String KEY_IMPORTANCE = "importance";
+
/* package private */ MediaFormat(@NonNull Map<String, Object> map) {
mMap = map;
}
diff --git a/media/java/android/media/projection/IMediaProjectionManager.aidl b/media/java/android/media/projection/IMediaProjectionManager.aidl
index 8ce1b6d..3d927d3 100644
--- a/media/java/android/media/projection/IMediaProjectionManager.aidl
+++ b/media/java/android/media/projection/IMediaProjectionManager.aidl
@@ -121,7 +121,7 @@
@EnforcePermission("MANAGE_MEDIA_PROJECTION")
@JavaPassthrough(annotation = "@android.annotation.RequiresPermission(android.Manifest"
+ ".permission.MANAGE_MEDIA_PROJECTION)")
- void addCallback(IMediaProjectionWatcherCallback callback);
+ MediaProjectionInfo addCallback(IMediaProjectionWatcherCallback callback);
@JavaPassthrough(annotation = "@android.annotation.RequiresPermission(android.Manifest"
+ ".permission.MANAGE_MEDIA_PROJECTION)")
diff --git a/media/java/android/media/projection/MediaProjectionInfo.java b/media/java/android/media/projection/MediaProjectionInfo.java
index ff60856..c820392 100644
--- a/media/java/android/media/projection/MediaProjectionInfo.java
+++ b/media/java/android/media/projection/MediaProjectionInfo.java
@@ -16,6 +16,7 @@
package android.media.projection;
+import android.os.IBinder;
import android.os.Parcel;
import android.os.Parcelable;
import android.os.UserHandle;
@@ -26,15 +27,18 @@
public final class MediaProjectionInfo implements Parcelable {
private final String mPackageName;
private final UserHandle mUserHandle;
+ private final IBinder mLaunchCookie;
- public MediaProjectionInfo(String packageName, UserHandle handle) {
+ public MediaProjectionInfo(String packageName, UserHandle handle, IBinder launchCookie) {
mPackageName = packageName;
mUserHandle = handle;
+ mLaunchCookie = launchCookie;
}
public MediaProjectionInfo(Parcel in) {
mPackageName = in.readString();
mUserHandle = UserHandle.readFromParcel(in);
+ mLaunchCookie = in.readStrongBinder();
}
public String getPackageName() {
@@ -45,12 +49,16 @@
return mUserHandle;
}
+ public IBinder getLaunchCookie() {
+ return mLaunchCookie;
+ }
+
@Override
public boolean equals(Object o) {
- if (o instanceof MediaProjectionInfo) {
- final MediaProjectionInfo other = (MediaProjectionInfo) o;
+ if (o instanceof MediaProjectionInfo other) {
return Objects.equals(other.mPackageName, mPackageName)
- && Objects.equals(other.mUserHandle, mUserHandle);
+ && Objects.equals(other.mUserHandle, mUserHandle)
+ && Objects.equals(other.mLaunchCookie, mLaunchCookie);
}
return false;
}
@@ -64,7 +72,8 @@
public String toString() {
return "MediaProjectionInfo{mPackageName="
+ mPackageName + ", mUserHandle="
- + mUserHandle + "}";
+ + mUserHandle + ", mLaunchCookie"
+ + mLaunchCookie + "}";
}
@Override
@@ -76,6 +85,7 @@
public void writeToParcel(Parcel out, int flags) {
out.writeString(mPackageName);
UserHandle.writeToParcel(mUserHandle, out);
+ out.writeStrongBinder(mLaunchCookie);
}
public static final @android.annotation.NonNull Parcelable.Creator<MediaProjectionInfo> CREATOR =
diff --git a/media/java/android/media/tv/TvContract.java b/media/java/android/media/tv/TvContract.java
index db01950..7f8f1a3 100644
--- a/media/java/android/media/tv/TvContract.java
+++ b/media/java/android/media/tv/TvContract.java
@@ -16,6 +16,7 @@
package android.media.tv;
+import android.annotation.FlaggedApi;
import android.annotation.IntDef;
import android.annotation.NonNull;
import android.annotation.Nullable;
@@ -29,6 +30,7 @@
import android.content.ContentUris;
import android.content.Context;
import android.content.Intent;
+import android.media.tv.flags.Flags;
import android.net.Uri;
import android.os.Bundle;
import android.os.IBinder;
@@ -2540,9 +2542,9 @@
* <p>This is used to indicate the broadcast visibility type defined in the underlying
* broadcast standard or country/operator profile, if applicable. For example,
* {@code visible_service_flag} and {@code numeric_selection_flag} of
- * {@code service_attribute_descriptor} in D-Book, {@code visible_service_flag} and
- * {@code selectable_service_flag} of {@code ciplus_service_descriptor} in CI Plus 1.3
- * specification.
+ * {@code service_attribute_descriptor} in D-Book, the specification for UK-based TV
+ * products, {@code visible_service_flag} and {@code selectable_service_flag} of
+ * {@code ciplus_service_descriptor} in the CI Plus 1.3 specification.
*
* <p>The value should match one of the following:
* {@link #BROADCAST_VISIBILITY_TYPE_VISIBLE},
@@ -2553,8 +2555,8 @@
* by default.
*
* <p>Type: INTEGER
- * @hide
*/
+ @FlaggedApi(Flags.FLAG_BROADCAST_VISIBILITY_TYPES)
public static final String COLUMN_BROADCAST_VISIBILITY_TYPE = "broadcast_visibility_type";
/** @hide */
@@ -2571,8 +2573,8 @@
* visible from users and selectable by users via normal service navigation mechanisms.
*
* @see #COLUMN_BROADCAST_VISIBILITY_TYPE
- * @hide
*/
+ @FlaggedApi(Flags.FLAG_BROADCAST_VISIBILITY_TYPES)
public static final int BROADCAST_VISIBILITY_TYPE_VISIBLE = 0;
/**
@@ -2581,18 +2583,18 @@
* the logical channel number.
*
* @see #COLUMN_BROADCAST_VISIBILITY_TYPE
- * @hide
*/
+ @FlaggedApi(Flags.FLAG_BROADCAST_VISIBILITY_TYPES)
public static final int BROADCAST_VISIBILITY_TYPE_NUMERIC_SELECTABLE_ONLY = 1;
/**
* The broadcast visibility type for invisible services. Use this type when the service
- * is invisible from users and unselectable by users via any of normal service navigation
- * mechanisms.
+ * is invisible from users and not able to be selected by users via any of the normal
+ * service navigation mechanisms.
*
* @see #COLUMN_BROADCAST_VISIBILITY_TYPE
- * @hide
*/
+ @FlaggedApi(Flags.FLAG_BROADCAST_VISIBILITY_TYPES)
public static final int BROADCAST_VISIBILITY_TYPE_INVISIBLE = 2;
private Channels() {}
diff --git a/media/java/android/media/tv/TvTrackInfo.java b/media/java/android/media/tv/TvTrackInfo.java
index 78d7d76..2ebb19a 100644
--- a/media/java/android/media/tv/TvTrackInfo.java
+++ b/media/java/android/media/tv/TvTrackInfo.java
@@ -55,6 +55,27 @@
*/
public static final int TYPE_SUBTITLE = 2;
+ /**
+ * The component tag identifies a component carried by a MPEG-2 TS.
+ *
+ * This corresponds to the component_tag in the component descriptor in the
+ * Elementary Stream loop of the stream in the Program Map Table
+ * (PMT) [EN 300 468], or undefined if the component is not carried in an
+ * MPEG-2 TS.
+ *
+ * @hide
+ */
+ public static final String EXTRA_BUNDLE_KEY_COMPONENT_TAG = "component_tag";
+
+ /**
+ * The MPEG Program ID (PID) of the component in the MPEG2-TS in
+ * which it is carried, or undefined if the component is not carried in an
+ * MPEG-2 TS.
+ *
+ * @hide
+ */
+ public static final String EXTRA_BUNDLE_KEY_PID = "pid";
+
private final int mType;
private final String mId;
private final String mLanguage;
diff --git a/media/java/android/media/tv/ad/ITvAdClient.aidl b/media/java/android/media/tv/ad/ITvAdClient.aidl
new file mode 100644
index 0000000..34d96b3
--- /dev/null
+++ b/media/java/android/media/tv/ad/ITvAdClient.aidl
@@ -0,0 +1,30 @@
+/*
+ * Copyright (C) 2023 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.media.tv.ad;
+
+import android.view.InputChannel;
+
+/**
+ * Interface a client of the ITvAdManager implements, to identify itself and receive
+ * information about changes to the state of each TV AD service.
+ * @hide
+ */
+oneway interface ITvAdClient {
+ void onSessionCreated(in String serviceId, IBinder token, in InputChannel channel, int seq);
+ void onSessionReleased(int seq);
+ void onLayoutSurface(int left, int top, int right, int bottom, int seq);
+}
\ No newline at end of file
diff --git a/media/java/android/media/tv/ad/ITvAdManager.aidl b/media/java/android/media/tv/ad/ITvAdManager.aidl
index 92cc923..a747e49 100644
--- a/media/java/android/media/tv/ad/ITvAdManager.aidl
+++ b/media/java/android/media/tv/ad/ITvAdManager.aidl
@@ -16,10 +16,25 @@
package android.media.tv.ad;
+import android.media.tv.ad.ITvAdClient;
+import android.media.tv.ad.ITvAdManagerCallback;
+import android.media.tv.ad.TvAdServiceInfo;
+import android.view.Surface;
+
/**
* Interface to the TV AD service.
* @hide
*/
interface ITvAdManager {
+ List<TvAdServiceInfo> getTvAdServiceList(int userId);
+ void createSession(
+ in ITvAdClient client, in String serviceId, in String type, int seq, int userId);
+ void releaseSession(in IBinder sessionToken, int userId);
void startAdService(in IBinder sessionToken, int userId);
+ void setSurface(in IBinder sessionToken, in Surface surface, int userId);
+ void dispatchSurfaceChanged(in IBinder sessionToken, int format, int width, int height,
+ int userId);
+
+ void registerCallback(in ITvAdManagerCallback callback, int userId);
+ void unregisterCallback(in ITvAdManagerCallback callback, int userId);
}
diff --git a/core/java/android/hardware/biometrics/PromptContentListItem.java b/media/java/android/media/tv/ad/ITvAdManagerCallback.aidl
similarity index 66%
copy from core/java/android/hardware/biometrics/PromptContentListItem.java
copy to media/java/android/media/tv/ad/ITvAdManagerCallback.aidl
index fa3783d..f55f67e 100644
--- a/core/java/android/hardware/biometrics/PromptContentListItem.java
+++ b/media/java/android/media/tv/ad/ITvAdManagerCallback.aidl
@@ -14,16 +14,14 @@
* limitations under the License.
*/
-package android.hardware.biometrics;
-
-import static android.hardware.biometrics.Flags.FLAG_CUSTOM_BIOMETRIC_PROMPT;
-
-import android.annotation.FlaggedApi;
+package android.media.tv.ad;
/**
- * A list item shown on {@link PromptVerticalListContentView}.
+ * Interface to receive callbacks from ITvAdManager regardless of sessions.
+ * @hide
*/
-@FlaggedApi(FLAG_CUSTOM_BIOMETRIC_PROMPT)
-public interface PromptContentListItem {
-}
-
+oneway interface ITvAdManagerCallback {
+ void onAdServiceAdded(in String serviceId);
+ void onAdServiceRemoved(in String serviceId);
+ void onAdServiceUpdated(in String serviceId);
+}
\ No newline at end of file
diff --git a/media/java/android/media/tv/ad/ITvAdService.aidl b/media/java/android/media/tv/ad/ITvAdService.aidl
new file mode 100644
index 0000000..3bb0409
--- /dev/null
+++ b/media/java/android/media/tv/ad/ITvAdService.aidl
@@ -0,0 +1,35 @@
+/*
+ * Copyright (C) 2023 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.media.tv.ad;
+
+import android.media.tv.ad.ITvAdServiceCallback;
+import android.media.tv.ad.ITvAdSessionCallback;
+import android.os.Bundle;
+import android.view.InputChannel;
+
+/**
+ * Top-level interface to a TV AD component (implemented in a Service). It's used for
+ * TvAdManagerService to communicate with TvAdService.
+ * @hide
+ */
+oneway interface ITvAdService {
+ void registerCallback(in ITvAdServiceCallback callback);
+ void unregisterCallback(in ITvAdServiceCallback callback);
+ void createSession(in InputChannel channel, in ITvAdSessionCallback callback,
+ in String serviceId, in String type);
+ void sendAppLinkCommand(in Bundle command);
+}
\ No newline at end of file
diff --git a/core/java/android/hardware/biometrics/PromptContentListItem.java b/media/java/android/media/tv/ad/ITvAdServiceCallback.aidl
similarity index 66%
copy from core/java/android/hardware/biometrics/PromptContentListItem.java
copy to media/java/android/media/tv/ad/ITvAdServiceCallback.aidl
index fa3783d..a087181 100644
--- a/core/java/android/hardware/biometrics/PromptContentListItem.java
+++ b/media/java/android/media/tv/ad/ITvAdServiceCallback.aidl
@@ -14,16 +14,11 @@
* limitations under the License.
*/
-package android.hardware.biometrics;
-
-import static android.hardware.biometrics.Flags.FLAG_CUSTOM_BIOMETRIC_PROMPT;
-
-import android.annotation.FlaggedApi;
+package android.media.tv.ad;
/**
- * A list item shown on {@link PromptVerticalListContentView}.
+ * Helper interface for ITvAdService to allow the TvAdService to notify the TvAdManagerService.
+ * @hide
*/
-@FlaggedApi(FLAG_CUSTOM_BIOMETRIC_PROMPT)
-public interface PromptContentListItem {
-}
-
+oneway interface ITvAdServiceCallback {
+}
\ No newline at end of file
diff --git a/media/java/android/media/tv/ad/ITvAdSession.aidl b/media/java/android/media/tv/ad/ITvAdSession.aidl
index b834f1b9..751257c 100644
--- a/media/java/android/media/tv/ad/ITvAdSession.aidl
+++ b/media/java/android/media/tv/ad/ITvAdSession.aidl
@@ -16,10 +16,15 @@
package android.media.tv.ad;
+import android.view.Surface;
+
/**
- * Sub-interface of ITvAdService which is created per session and has its own context.
+ * Sub-interface of ITvAdService.aidl which is created per session and has its own context.
* @hide
*/
oneway interface ITvAdSession {
+ void release();
void startAdService();
+ void setSurface(in Surface surface);
+ void dispatchSurfaceChanged(int format, int width, int height);
}
diff --git a/core/java/android/hardware/biometrics/PromptContentListItem.java b/media/java/android/media/tv/ad/ITvAdSessionCallback.aidl
similarity index 63%
copy from core/java/android/hardware/biometrics/PromptContentListItem.java
copy to media/java/android/media/tv/ad/ITvAdSessionCallback.aidl
index fa3783d..f21ef19 100644
--- a/core/java/android/hardware/biometrics/PromptContentListItem.java
+++ b/media/java/android/media/tv/ad/ITvAdSessionCallback.aidl
@@ -14,16 +14,16 @@
* limitations under the License.
*/
-package android.hardware.biometrics;
+package android.media.tv.ad;
-import static android.hardware.biometrics.Flags.FLAG_CUSTOM_BIOMETRIC_PROMPT;
-
-import android.annotation.FlaggedApi;
+import android.media.tv.ad.ITvAdSession;
/**
- * A list item shown on {@link PromptVerticalListContentView}.
+ * Helper interface for ITvAdSession to allow TvAdService to notify the system service when there is
+ * a related event.
+ * @hide
*/
-@FlaggedApi(FLAG_CUSTOM_BIOMETRIC_PROMPT)
-public interface PromptContentListItem {
-}
-
+oneway interface ITvAdSessionCallback {
+ void onSessionCreated(in ITvAdSession session);
+ void onLayoutSurface(int left, int top, int right, int bottom);
+}
\ No newline at end of file
diff --git a/media/java/android/media/tv/ad/ITvAdSessionWrapper.java b/media/java/android/media/tv/ad/ITvAdSessionWrapper.java
new file mode 100644
index 0000000..4df2783
--- /dev/null
+++ b/media/java/android/media/tv/ad/ITvAdSessionWrapper.java
@@ -0,0 +1,152 @@
+/*
+ * Copyright (C) 2023 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.media.tv.ad;
+
+import android.content.Context;
+import android.os.Looper;
+import android.os.Message;
+import android.os.RemoteException;
+import android.util.Log;
+import android.view.InputChannel;
+import android.view.InputEvent;
+import android.view.InputEventReceiver;
+import android.view.Surface;
+
+import com.android.internal.os.HandlerCaller;
+import com.android.internal.os.SomeArgs;
+
+/**
+ * Implements the internal ITvAdSession interface.
+ * @hide
+ */
+public class ITvAdSessionWrapper
+ extends ITvAdSession.Stub implements HandlerCaller.Callback {
+
+ private static final String TAG = "ITvAdSessionWrapper";
+
+ private static final int EXECUTE_MESSAGE_TIMEOUT_SHORT_MILLIS = 1000;
+ private static final int EXECUTE_MESSAGE_TIMEOUT_LONG_MILLIS = 5 * 1000;
+ private static final int DO_RELEASE = 1;
+ private static final int DO_SET_SURFACE = 2;
+ private static final int DO_DISPATCH_SURFACE_CHANGED = 3;
+
+ private final HandlerCaller mCaller;
+ private TvAdService.Session mSessionImpl;
+ private InputChannel mChannel;
+ private TvAdEventReceiver mReceiver;
+
+ public ITvAdSessionWrapper(
+ Context context, TvAdService.Session mSessionImpl, InputChannel channel) {
+ this.mSessionImpl = mSessionImpl;
+ mCaller = new HandlerCaller(context, null, this, true /* asyncHandler */);
+ mChannel = channel;
+ if (channel != null) {
+ mReceiver = new TvAdEventReceiver(channel, context.getMainLooper());
+ }
+ }
+
+ @Override
+ public void release() {
+ mCaller.executeOrSendMessage(mCaller.obtainMessage(DO_RELEASE));
+ }
+
+
+ @Override
+ public void executeMessage(Message msg) {
+ if (mSessionImpl == null) {
+ return;
+ }
+
+ long startTime = System.nanoTime();
+ switch (msg.what) {
+ case DO_RELEASE: {
+ mSessionImpl.release();
+ mSessionImpl = null;
+ if (mReceiver != null) {
+ mReceiver.dispose();
+ mReceiver = null;
+ }
+ if (mChannel != null) {
+ mChannel.dispose();
+ mChannel = null;
+ }
+ break;
+ }
+ case DO_SET_SURFACE: {
+ mSessionImpl.setSurface((Surface) msg.obj);
+ break;
+ }
+ case DO_DISPATCH_SURFACE_CHANGED: {
+ SomeArgs args = (SomeArgs) msg.obj;
+ mSessionImpl.dispatchSurfaceChanged(
+ (Integer) args.argi1, (Integer) args.argi2, (Integer) args.argi3);
+ args.recycle();
+ break;
+ }
+ default: {
+ Log.w(TAG, "Unhandled message code: " + msg.what);
+ break;
+ }
+ }
+ long durationMs = (System.nanoTime() - startTime) / (1000 * 1000);
+ if (durationMs > EXECUTE_MESSAGE_TIMEOUT_SHORT_MILLIS) {
+ Log.w(TAG, "Handling message (" + msg.what + ") took too long time (duration="
+ + durationMs + "ms)");
+ if (durationMs > EXECUTE_MESSAGE_TIMEOUT_LONG_MILLIS) {
+ // TODO: handle timeout
+ }
+ }
+
+ }
+
+ @Override
+ public void startAdService() throws RemoteException {
+
+ }
+
+ @Override
+ public void setSurface(Surface surface) {
+ mCaller.executeOrSendMessage(mCaller.obtainMessageO(DO_SET_SURFACE, surface));
+ }
+
+ @Override
+ public void dispatchSurfaceChanged(int format, int width, int height) {
+ mCaller.executeOrSendMessage(
+ mCaller.obtainMessageIIII(DO_DISPATCH_SURFACE_CHANGED, format, width, height, 0));
+ }
+
+ private final class TvAdEventReceiver extends InputEventReceiver {
+ TvAdEventReceiver(InputChannel inputChannel, Looper looper) {
+ super(inputChannel, looper);
+ }
+
+ @Override
+ public void onInputEvent(InputEvent event) {
+ if (mSessionImpl == null) {
+ // The session has been finished.
+ finishInputEvent(event, false);
+ return;
+ }
+
+ int handled = mSessionImpl.dispatchInputEvent(event, this);
+ if (handled != TvAdManager.Session.DISPATCH_IN_PROGRESS) {
+ finishInputEvent(
+ event, handled == TvAdManager.Session.DISPATCH_HANDLED);
+ }
+ }
+ }
+}
diff --git a/media/java/android/media/tv/ad/TvAdManager.java b/media/java/android/media/tv/ad/TvAdManager.java
index 2b52c4b..9c75051 100644
--- a/media/java/android/media/tv/ad/TvAdManager.java
+++ b/media/java/android/media/tv/ad/TvAdManager.java
@@ -17,12 +17,30 @@
package android.media.tv.ad;
import android.annotation.FlaggedApi;
+import android.annotation.NonNull;
+import android.annotation.Nullable;
import android.annotation.SystemService;
import android.content.Context;
+import android.media.tv.TvInputManager;
import android.media.tv.flags.Flags;
+import android.os.Handler;
import android.os.IBinder;
+import android.os.Looper;
+import android.os.Message;
import android.os.RemoteException;
import android.util.Log;
+import android.util.Pools;
+import android.util.SparseArray;
+import android.view.InputChannel;
+import android.view.InputEvent;
+import android.view.InputEventSender;
+import android.view.Surface;
+
+import com.android.internal.util.Preconditions;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.concurrent.Executor;
/**
* Central system API to the overall client-side TV AD architecture, which arbitrates interaction
@@ -37,10 +55,163 @@
private final ITvAdManager mService;
private final int mUserId;
+ // A mapping from the sequence number of a session to its SessionCallbackRecord.
+ private final SparseArray<SessionCallbackRecord> mSessionCallbackRecordMap =
+ new SparseArray<>();
+
+ // @GuardedBy("mLock")
+ private final List<TvAdServiceCallbackRecord> mCallbackRecords = new ArrayList<>();
+
+ // A sequence number for the next session to be created. Should be protected by a lock
+ // {@code mSessionCallbackRecordMap}.
+ private int mNextSeq;
+
+ private final Object mLock = new Object();
+ private final ITvAdClient mClient;
+
/** @hide */
public TvAdManager(ITvAdManager service, int userId) {
mService = service;
mUserId = userId;
+ mClient = new ITvAdClient.Stub() {
+ @Override
+ public void onSessionCreated(String serviceId, IBinder token, InputChannel channel,
+ int seq) {
+ synchronized (mSessionCallbackRecordMap) {
+ SessionCallbackRecord record = mSessionCallbackRecordMap.get(seq);
+ if (record == null) {
+ Log.e(TAG, "Callback not found for " + token);
+ return;
+ }
+ Session session = null;
+ if (token != null) {
+ session = new Session(token, channel, mService, mUserId, seq,
+ mSessionCallbackRecordMap);
+ } else {
+ mSessionCallbackRecordMap.delete(seq);
+ }
+ record.postSessionCreated(session);
+ }
+ }
+
+ @Override
+ public void onSessionReleased(int seq) {
+ synchronized (mSessionCallbackRecordMap) {
+ SessionCallbackRecord record = mSessionCallbackRecordMap.get(seq);
+ mSessionCallbackRecordMap.delete(seq);
+ if (record == null) {
+ Log.e(TAG, "Callback not found for seq:" + seq);
+ return;
+ }
+ record.mSession.releaseInternal();
+ record.postSessionReleased();
+ }
+ }
+
+ @Override
+ public void onLayoutSurface(int left, int top, int right, int bottom, int seq) {
+ synchronized (mSessionCallbackRecordMap) {
+ SessionCallbackRecord record = mSessionCallbackRecordMap.get(seq);
+ if (record == null) {
+ Log.e(TAG, "Callback not found for seq " + seq);
+ return;
+ }
+ record.postLayoutSurface(left, top, right, bottom);
+ }
+ }
+
+ };
+
+ ITvAdManagerCallback managerCallback =
+ new ITvAdManagerCallback.Stub() {
+ @Override
+ public void onAdServiceAdded(String serviceId) {
+ synchronized (mLock) {
+ for (TvAdServiceCallbackRecord record : mCallbackRecords) {
+ record.postAdServiceAdded(serviceId);
+ }
+ }
+ }
+
+ @Override
+ public void onAdServiceRemoved(String serviceId) {
+ synchronized (mLock) {
+ for (TvAdServiceCallbackRecord record : mCallbackRecords) {
+ record.postAdServiceRemoved(serviceId);
+ }
+ }
+ }
+
+ @Override
+ public void onAdServiceUpdated(String serviceId) {
+ synchronized (mLock) {
+ for (TvAdServiceCallbackRecord record : mCallbackRecords) {
+ record.postAdServiceUpdated(serviceId);
+ }
+ }
+ }
+ };
+ try {
+ if (mService != null) {
+ mService.registerCallback(managerCallback, mUserId);
+ }
+ } catch (RemoteException e) {
+ throw e.rethrowFromSystemServer();
+ }
+ }
+
+ /**
+ * Returns the complete list of TV AD service on the system.
+ *
+ * @return List of {@link TvAdServiceInfo} for each TV AD service that describes its meta
+ * information.
+ * @hide
+ */
+ @NonNull
+ public List<TvAdServiceInfo> getTvAdServiceList() {
+ try {
+ return mService.getTvAdServiceList(mUserId);
+ } catch (RemoteException e) {
+ throw e.rethrowFromSystemServer();
+ }
+ }
+
+ /**
+ * Creates a {@link Session} for a given TV AD service.
+ *
+ * <p>The number of sessions that can be created at the same time is limited by the capability
+ * of the given AD service.
+ *
+ * @param serviceId The ID of the AD service.
+ * @param callback A callback used to receive the created session.
+ * @param handler A {@link Handler} that the session creation will be delivered to.
+ * @hide
+ */
+ public void createSession(
+ @NonNull String serviceId,
+ @NonNull String type,
+ @NonNull final TvAdManager.SessionCallback callback,
+ @NonNull Handler handler) {
+ createSessionInternal(serviceId, type, callback, handler);
+ }
+
+ private void createSessionInternal(String serviceId, String type,
+ TvAdManager.SessionCallback callback, Handler handler) {
+ Preconditions.checkNotNull(serviceId);
+ Preconditions.checkNotNull(type);
+ Preconditions.checkNotNull(callback);
+ Preconditions.checkNotNull(handler);
+ TvAdManager.SessionCallbackRecord
+ record = new TvAdManager.SessionCallbackRecord(callback, handler);
+ synchronized (mSessionCallbackRecordMap) {
+ int seq = mNextSeq++;
+ mSessionCallbackRecordMap.put(seq, record);
+ try {
+ mService.createSession(mClient, serviceId, type, seq, mUserId);
+ } catch (RemoteException e) {
+ throw e.rethrowFromSystemServer();
+ }
+ }
}
/**
@@ -48,14 +219,121 @@
* @hide
*/
public static final class Session {
- private final IBinder mToken;
+ static final int DISPATCH_IN_PROGRESS = -1;
+ static final int DISPATCH_NOT_HANDLED = 0;
+ static final int DISPATCH_HANDLED = 1;
+
+ private static final long INPUT_SESSION_NOT_RESPONDING_TIMEOUT = 2500;
private final ITvAdManager mService;
private final int mUserId;
+ private final int mSeq;
+ private final SparseArray<SessionCallbackRecord> mSessionCallbackRecordMap;
- private Session(IBinder token, ITvAdManager service, int userId) {
+ // For scheduling input event handling on the main thread. This also serves as a lock to
+ // protect pending input events and the input channel.
+ private final InputEventHandler mHandler = new InputEventHandler(Looper.getMainLooper());
+
+ private TvInputManager.Session mInputSession;
+ private final Pools.Pool<PendingEvent> mPendingEventPool = new Pools.SimplePool<>(20);
+ private final SparseArray<PendingEvent> mPendingEvents = new SparseArray<>(20);
+ private TvInputEventSender mSender;
+ private InputChannel mInputChannel;
+ private IBinder mToken;
+
+ private Session(IBinder token, InputChannel channel, ITvAdManager service, int userId,
+ int seq, SparseArray<SessionCallbackRecord> sessionCallbackRecordMap) {
mToken = token;
+ mInputChannel = channel;
mService = service;
mUserId = userId;
+ mSeq = seq;
+ mSessionCallbackRecordMap = sessionCallbackRecordMap;
+ }
+
+ /**
+ * Releases this session.
+ */
+ public void release() {
+ if (mToken == null) {
+ Log.w(TAG, "The session has been already released");
+ return;
+ }
+ try {
+ mService.releaseSession(mToken, mUserId);
+ } catch (RemoteException e) {
+ throw e.rethrowFromSystemServer();
+ }
+
+ releaseInternal();
+ }
+
+ /**
+ * Sets the {@link android.view.Surface} for this session.
+ *
+ * @param surface A {@link android.view.Surface} used to render AD.
+ */
+ public void setSurface(Surface surface) {
+ if (mToken == null) {
+ Log.w(TAG, "The session has been already released");
+ return;
+ }
+ // surface can be null.
+ try {
+ mService.setSurface(mToken, surface, mUserId);
+ } catch (RemoteException e) {
+ throw e.rethrowFromSystemServer();
+ }
+ }
+
+ /**
+ * Notifies of any structural changes (format or size) of the surface passed in
+ * {@link #setSurface}.
+ *
+ * @param format The new PixelFormat of the surface.
+ * @param width The new width of the surface.
+ * @param height The new height of the surface.
+ */
+ public void dispatchSurfaceChanged(int format, int width, int height) {
+ if (mToken == null) {
+ Log.w(TAG, "The session has been already released");
+ return;
+ }
+ try {
+ mService.dispatchSurfaceChanged(mToken, format, width, height, mUserId);
+ } catch (RemoteException e) {
+ throw e.rethrowFromSystemServer();
+ }
+ }
+
+ private void flushPendingEventsLocked() {
+ mHandler.removeMessages(InputEventHandler.MSG_FLUSH_INPUT_EVENT);
+
+ final int count = mPendingEvents.size();
+ for (int i = 0; i < count; i++) {
+ int seq = mPendingEvents.keyAt(i);
+ Message msg = mHandler.obtainMessage(
+ InputEventHandler.MSG_FLUSH_INPUT_EVENT, seq, 0);
+ msg.setAsynchronous(true);
+ msg.sendToTarget();
+ }
+ }
+
+ private void releaseInternal() {
+ mToken = null;
+ synchronized (mHandler) {
+ if (mInputChannel != null) {
+ if (mSender != null) {
+ flushPendingEventsLocked();
+ mSender.dispose();
+ mSender = null;
+ }
+ mInputChannel.dispose();
+ mInputChannel = null;
+ }
+ }
+ synchronized (mSessionCallbackRecordMap) {
+ mSessionCallbackRecordMap.delete(mSeq);
+ }
}
void startAdService() {
@@ -69,5 +347,324 @@
throw e.rethrowFromSystemServer();
}
}
+
+ private final class InputEventHandler extends Handler {
+ public static final int MSG_SEND_INPUT_EVENT = 1;
+ public static final int MSG_TIMEOUT_INPUT_EVENT = 2;
+ public static final int MSG_FLUSH_INPUT_EVENT = 3;
+
+ InputEventHandler(Looper looper) {
+ super(looper, null, true);
+ }
+
+ @Override
+ public void handleMessage(Message msg) {
+ switch (msg.what) {
+ case MSG_SEND_INPUT_EVENT: {
+ sendInputEventAndReportResultOnMainLooper((PendingEvent) msg.obj);
+ return;
+ }
+ case MSG_TIMEOUT_INPUT_EVENT: {
+ finishedInputEvent(msg.arg1, false, true);
+ return;
+ }
+ case MSG_FLUSH_INPUT_EVENT: {
+ finishedInputEvent(msg.arg1, false, false);
+ return;
+ }
+ }
+ }
+ }
+
+ // Assumes the event has already been removed from the queue.
+ void invokeFinishedInputEventCallback(PendingEvent p, boolean handled) {
+ p.mHandled = handled;
+ if (p.mEventHandler.getLooper().isCurrentThread()) {
+ // Already running on the callback handler thread so we can send the callback
+ // immediately.
+ p.run();
+ } else {
+ // Post the event to the callback handler thread.
+ // In this case, the callback will be responsible for recycling the event.
+ Message msg = Message.obtain(p.mEventHandler, p);
+ msg.setAsynchronous(true);
+ msg.sendToTarget();
+ }
+ }
+
+ // Must be called on the main looper
+ private void sendInputEventAndReportResultOnMainLooper(PendingEvent p) {
+ synchronized (mHandler) {
+ int result = sendInputEventOnMainLooperLocked(p);
+ if (result == DISPATCH_IN_PROGRESS) {
+ return;
+ }
+ }
+
+ invokeFinishedInputEventCallback(p, false);
+ }
+
+ private int sendInputEventOnMainLooperLocked(PendingEvent p) {
+ if (mInputChannel != null) {
+ if (mSender == null) {
+ mSender = new TvInputEventSender(mInputChannel, mHandler.getLooper());
+ }
+
+ final InputEvent event = p.mEvent;
+ final int seq = event.getSequenceNumber();
+ if (mSender.sendInputEvent(seq, event)) {
+ mPendingEvents.put(seq, p);
+ Message msg = mHandler.obtainMessage(
+ InputEventHandler.MSG_TIMEOUT_INPUT_EVENT, p);
+ msg.setAsynchronous(true);
+ mHandler.sendMessageDelayed(msg, INPUT_SESSION_NOT_RESPONDING_TIMEOUT);
+ return DISPATCH_IN_PROGRESS;
+ }
+
+ Log.w(TAG, "Unable to send input event to session: " + mToken + " dropping:"
+ + event);
+ }
+ return DISPATCH_NOT_HANDLED;
+ }
+
+ void finishedInputEvent(int seq, boolean handled, boolean timeout) {
+ final PendingEvent p;
+ synchronized (mHandler) {
+ int index = mPendingEvents.indexOfKey(seq);
+ if (index < 0) {
+ return; // spurious, event already finished or timed out
+ }
+
+ p = mPendingEvents.valueAt(index);
+ mPendingEvents.removeAt(index);
+
+ if (timeout) {
+ Log.w(TAG, "Timeout waiting for session to handle input event after "
+ + INPUT_SESSION_NOT_RESPONDING_TIMEOUT + " ms: " + mToken);
+ } else {
+ mHandler.removeMessages(InputEventHandler.MSG_TIMEOUT_INPUT_EVENT, p);
+ }
+ }
+
+ invokeFinishedInputEventCallback(p, handled);
+ }
+
+ private void recyclePendingEventLocked(PendingEvent p) {
+ p.recycle();
+ mPendingEventPool.release(p);
+ }
+
+ /**
+ * Callback that is invoked when an input event that was dispatched to this session has been
+ * finished.
+ *
+ * @hide
+ */
+ public interface FinishedInputEventCallback {
+ /**
+ * Called when the dispatched input event is finished.
+ *
+ * @param token A token passed to {@link #dispatchInputEvent}.
+ * @param handled {@code true} if the dispatched input event was handled properly.
+ * {@code false} otherwise.
+ */
+ void onFinishedInputEvent(Object token, boolean handled);
+ }
+
+ private final class TvInputEventSender extends InputEventSender {
+ TvInputEventSender(InputChannel inputChannel, Looper looper) {
+ super(inputChannel, looper);
+ }
+
+ @Override
+ public void onInputEventFinished(int seq, boolean handled) {
+ finishedInputEvent(seq, handled, false);
+ }
+ }
+
+ private final class PendingEvent implements Runnable {
+ public InputEvent mEvent;
+ public Object mEventToken;
+ public Session.FinishedInputEventCallback mCallback;
+ public Handler mEventHandler;
+ public boolean mHandled;
+
+ public void recycle() {
+ mEvent = null;
+ mEventToken = null;
+ mCallback = null;
+ mEventHandler = null;
+ mHandled = false;
+ }
+
+ @Override
+ public void run() {
+ mCallback.onFinishedInputEvent(mEventToken, mHandled);
+
+ synchronized (mEventHandler) {
+ recyclePendingEventLocked(this);
+ }
+ }
+ }
+ }
+
+
+ /**
+ * Interface used to receive the created session.
+ * @hide
+ */
+ public abstract static class SessionCallback {
+ /**
+ * This is called after {@link TvAdManager#createSession} has been processed.
+ *
+ * @param session A {@link TvAdManager.Session} instance created. This can be
+ * {@code null} if the creation request failed.
+ */
+ public void onSessionCreated(@Nullable Session session) {
+ }
+
+ /**
+ * This is called when {@link TvAdManager.Session} is released.
+ * This typically happens when the process hosting the session has crashed or been killed.
+ *
+ * @param session the {@link TvAdManager.Session} instance released.
+ */
+ public void onSessionReleased(@NonNull Session session) {
+ }
+
+ /**
+ * This is called when {@link TvAdService.Session#layoutSurface} is called to
+ * change the layout of surface.
+ *
+ * @param session A {@link TvAdManager.Session} associated with this callback.
+ * @param left Left position.
+ * @param top Top position.
+ * @param right Right position.
+ * @param bottom Bottom position.
+ */
+ public void onLayoutSurface(Session session, int left, int top, int right, int bottom) {
+ }
+
+ }
+
+ /**
+ * Callback used to monitor status of the TV AD service.
+ * @hide
+ */
+ public abstract static class TvAdServiceCallback {
+ /**
+ * This is called when a TV AD service is added to the system.
+ *
+ * <p>Normally it happens when the user installs a new TV AD service package that implements
+ * {@link TvAdService} interface.
+ *
+ * @param serviceId The ID of the TV AD service.
+ */
+ public void onAdServiceAdded(@NonNull String serviceId) {
+ }
+
+ /**
+ * This is called when a TV AD service is removed from the system.
+ *
+ * <p>Normally it happens when the user uninstalls the previously installed TV AD service
+ * package.
+ *
+ * @param serviceId The ID of the TV AD service.
+ */
+ public void onAdServiceRemoved(@NonNull String serviceId) {
+ }
+
+ /**
+ * This is called when a TV AD service is updated on the system.
+ *
+ * <p>Normally it happens when a previously installed TV AD service package is re-installed
+ * or a newer version of the package exists becomes available/unavailable.
+ *
+ * @param serviceId The ID of the TV AD service.
+ */
+ public void onAdServiceUpdated(@NonNull String serviceId) {
+ }
+
+ }
+
+ private static final class SessionCallbackRecord {
+ private final SessionCallback mSessionCallback;
+ private final Handler mHandler;
+ private Session mSession;
+
+ SessionCallbackRecord(SessionCallback sessionCallback, Handler handler) {
+ mSessionCallback = sessionCallback;
+ mHandler = handler;
+ }
+
+ void postSessionCreated(final Session session) {
+ mSession = session;
+ mHandler.post(new Runnable() {
+ @Override
+ public void run() {
+ mSessionCallback.onSessionCreated(session);
+ }
+ });
+ }
+
+ void postSessionReleased() {
+ mHandler.post(new Runnable() {
+ @Override
+ public void run() {
+ mSessionCallback.onSessionReleased(mSession);
+ }
+ });
+ }
+
+ void postLayoutSurface(final int left, final int top, final int right,
+ final int bottom) {
+ mHandler.post(new Runnable() {
+ @Override
+ public void run() {
+ mSessionCallback.onLayoutSurface(mSession, left, top, right, bottom);
+ }
+ });
+ }
+ }
+
+ private static final class TvAdServiceCallbackRecord {
+ private final TvAdServiceCallback mCallback;
+ private final Executor mExecutor;
+
+ TvAdServiceCallbackRecord(TvAdServiceCallback callback, Executor executor) {
+ mCallback = callback;
+ mExecutor = executor;
+ }
+
+ public TvAdServiceCallback getCallback() {
+ return mCallback;
+ }
+
+ public void postAdServiceAdded(final String serviceId) {
+ mExecutor.execute(new Runnable() {
+ @Override
+ public void run() {
+ mCallback.onAdServiceAdded(serviceId);
+ }
+ });
+ }
+
+ public void postAdServiceRemoved(final String serviceId) {
+ mExecutor.execute(new Runnable() {
+ @Override
+ public void run() {
+ mCallback.onAdServiceRemoved(serviceId);
+ }
+ });
+ }
+
+ public void postAdServiceUpdated(final String serviceId) {
+ mExecutor.execute(new Runnable() {
+ @Override
+ public void run() {
+ mCallback.onAdServiceUpdated(serviceId);
+ }
+ });
+ }
}
}
diff --git a/media/java/android/media/tv/ad/TvAdService.java b/media/java/android/media/tv/ad/TvAdService.java
index 6897a78..6995703 100644
--- a/media/java/android/media/tv/ad/TvAdService.java
+++ b/media/java/android/media/tv/ad/TvAdService.java
@@ -16,8 +16,37 @@
package android.media.tv.ad;
+import android.annotation.CallSuper;
+import android.annotation.MainThread;
+import android.annotation.NonNull;
+import android.annotation.Nullable;
+import android.annotation.SdkConstant;
+import android.annotation.SuppressLint;
import android.app.Service;
+import android.content.Context;
+import android.content.Intent;
+import android.graphics.PixelFormat;
+import android.os.Bundle;
+import android.os.Handler;
+import android.os.IBinder;
+import android.os.Message;
+import android.os.RemoteCallbackList;
+import android.os.RemoteException;
+import android.util.Log;
+import android.view.InputChannel;
+import android.view.InputDevice;
+import android.view.InputEvent;
+import android.view.InputEventReceiver;
import android.view.KeyEvent;
+import android.view.MotionEvent;
+import android.view.Surface;
+import android.view.View;
+import android.view.WindowManager;
+
+import com.android.internal.os.SomeArgs;
+
+import java.util.ArrayList;
+import java.util.List;
/**
* The TvAdService class represents a TV client-side advertisement service.
@@ -36,9 +65,123 @@
public static final String SERVICE_META_DATA = "android.media.tv.ad.service";
/**
+ * This is the interface name that a service implementing a TV AD service should
+ * say that it supports -- that is, this is the action it uses for its intent filter. To be
+ * supported, the service must also require the
+ * android.Manifest.permission#BIND_TV_AD_SERVICE permission so that other
+ * applications cannot abuse it.
+ */
+ @SdkConstant(SdkConstant.SdkConstantType.SERVICE_ACTION)
+ public static final String SERVICE_INTERFACE = "android.media.tv.ad.TvAdService";
+
+ private final Handler mServiceHandler = new ServiceHandler();
+ private final RemoteCallbackList<ITvAdServiceCallback> mCallbacks = new RemoteCallbackList<>();
+
+ @Override
+ @Nullable
+ public final IBinder onBind(@NonNull Intent intent) {
+ ITvAdService.Stub tvAdServiceBinder = new ITvAdService.Stub() {
+ @Override
+ public void registerCallback(ITvAdServiceCallback cb) {
+ if (cb != null) {
+ mCallbacks.register(cb);
+ }
+ }
+
+ @Override
+ public void unregisterCallback(ITvAdServiceCallback cb) {
+ if (cb != null) {
+ mCallbacks.unregister(cb);
+ }
+ }
+
+ @Override
+ public void createSession(InputChannel channel, ITvAdSessionCallback cb,
+ String serviceId, String type) {
+ if (cb == null) {
+ return;
+ }
+ SomeArgs args = SomeArgs.obtain();
+ args.arg1 = channel;
+ args.arg2 = cb;
+ args.arg3 = serviceId;
+ args.arg4 = type;
+ mServiceHandler.obtainMessage(ServiceHandler.DO_CREATE_SESSION, args)
+ .sendToTarget();
+ }
+
+ @Override
+ public void sendAppLinkCommand(Bundle command) {
+ onAppLinkCommand(command);
+ }
+ };
+ return tvAdServiceBinder;
+ }
+
+ /**
+ * Called when app link command is received.
+ */
+ public void onAppLinkCommand(@NonNull Bundle command) {
+ }
+
+
+ /**
+ * Returns a concrete implementation of {@link Session}.
+ *
+ * <p>May return {@code null} if this TV AD service fails to create a session for some
+ * reason.
+ *
+ * @param serviceId The ID of the TV AD associated with the session.
+ * @param type The type of the TV AD associated with the session.
+ */
+ @Nullable
+ public abstract Session onCreateSession(@NonNull String serviceId, @NonNull String type);
+
+ /**
* Base class for derived classes to implement to provide a TV AD session.
*/
public abstract static class Session implements KeyEvent.Callback {
+ private final KeyEvent.DispatcherState mDispatcherState = new KeyEvent.DispatcherState();
+
+ private final Object mLock = new Object();
+ // @GuardedBy("mLock")
+ private ITvAdSessionCallback mSessionCallback;
+ // @GuardedBy("mLock")
+ private final List<Runnable> mPendingActions = new ArrayList<>();
+ private final Context mContext;
+ final Handler mHandler;
+ private final WindowManager mWindowManager;
+ private Surface mSurface;
+
+
+ /**
+ * Creates a new Session.
+ *
+ * @param context The context of the application
+ */
+ public Session(@NonNull Context context) {
+ mContext = context;
+ mWindowManager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
+ mHandler = new Handler(context.getMainLooper());
+ }
+
+ /**
+ * Releases TvAdService session.
+ */
+ public abstract void onRelease();
+
+ void release() {
+ onRelease();
+ if (mSurface != null) {
+ mSurface.release();
+ mSurface = null;
+ }
+ synchronized (mLock) {
+ mSessionCallback = null;
+ mPendingActions.clear();
+ }
+ }
+
/**
* Starts TvAdService session.
*/
@@ -48,21 +191,264 @@
void startAdService() {
onStartAdService();
}
- }
- /**
- * Implements the internal ITvAdService interface.
- */
- public static class ITvAdSessionWrapper extends ITvAdSession.Stub {
- private final Session mSessionImpl;
-
- public ITvAdSessionWrapper(Session mSessionImpl) {
- this.mSessionImpl = mSessionImpl;
+ @Override
+ public boolean onKeyDown(int keyCode, @NonNull KeyEvent event) {
+ return false;
}
@Override
- public void startAdService() {
- mSessionImpl.startAdService();
+ public boolean onKeyLongPress(int keyCode, @NonNull KeyEvent event) {
+ return false;
}
+
+ @Override
+ public boolean onKeyMultiple(int keyCode, int count, @NonNull KeyEvent event) {
+ return false;
+ }
+
+ @Override
+ public boolean onKeyUp(int keyCode, @NonNull KeyEvent event) {
+ return false;
+ }
+
+ /**
+ * Implement this method to handle touch screen motion events on the current session.
+ *
+ * @param event The motion event being received.
+ * @return If you handled the event, return {@code true}. If you want to allow the event to
+ * be handled by the next receiver, return {@code false}.
+ * @see View#onTouchEvent
+ */
+ public boolean onTouchEvent(@NonNull MotionEvent event) {
+ return false;
+ }
+
+ /**
+ * Implement this method to handle trackball events on the current session.
+ *
+ * @param event The motion event being received.
+ * @return If you handled the event, return {@code true}. If you want to allow the event to
+ * be handled by the next receiver, return {@code false}.
+ * @see View#onTrackballEvent
+ */
+ public boolean onTrackballEvent(@NonNull MotionEvent event) {
+ return false;
+ }
+
+ /**
+ * Implement this method to handle generic motion events on the current session.
+ *
+ * @param event The motion event being received.
+ * @return If you handled the event, return {@code true}. If you want to allow the event to
+ * be handled by the next receiver, return {@code false}.
+ * @see View#onGenericMotionEvent
+ */
+ public boolean onGenericMotionEvent(@NonNull MotionEvent event) {
+ return false;
+ }
+
+ /**
+ * Assigns a size and position to the surface passed in {@link #onSetSurface}. The position
+ * is relative to the overlay view that sits on top of this surface.
+ *
+ * @param left Left position in pixels, relative to the overlay view.
+ * @param top Top position in pixels, relative to the overlay view.
+ * @param right Right position in pixels, relative to the overlay view.
+ * @param bottom Bottom position in pixels, relative to the overlay view.
+ */
+ @CallSuper
+ public void layoutSurface(final int left, final int top, final int right,
+ final int bottom) {
+ if (left > right || top > bottom) {
+ throw new IllegalArgumentException("Invalid parameter");
+ }
+ executeOrPostRunnableOnMainThread(new Runnable() {
+ @MainThread
+ @Override
+ public void run() {
+ try {
+ if (DEBUG) {
+ Log.d(TAG, "layoutSurface (l=" + left + ", t=" + top
+ + ", r=" + right + ", b=" + bottom + ",)");
+ }
+ if (mSessionCallback != null) {
+ mSessionCallback.onLayoutSurface(left, top, right, bottom);
+ }
+ } catch (RemoteException e) {
+ Log.w(TAG, "error in layoutSurface", e);
+ }
+ }
+ });
+ }
+
+ /**
+ * Called when the application sets the surface.
+ *
+ * <p>The TV AD service should render AD UI onto the given surface. When called with
+ * {@code null}, the AD service should immediately free any references to the currently set
+ * surface and stop using it.
+ *
+ * @param surface The surface to be used for AD UI rendering. Can be {@code null}.
+ * @return {@code true} if the surface was set successfully, {@code false} otherwise.
+ */
+ public abstract boolean onSetSurface(@Nullable Surface surface);
+
+ /**
+ * Called after any structural changes (format or size) have been made to the surface passed
+ * in {@link #onSetSurface}. This method is always called at least once, after
+ * {@link #onSetSurface} is called with non-null surface.
+ *
+ * @param format The new {@link PixelFormat} of the surface.
+ * @param width The new width of the surface.
+ * @param height The new height of the surface.
+ */
+ public void onSurfaceChanged(@PixelFormat.Format int format, int width, int height) {
+ }
+
+ /**
+ * Takes care of dispatching incoming input events and tells whether the event was handled.
+ */
+ int dispatchInputEvent(InputEvent event, InputEventReceiver receiver) {
+ if (DEBUG) Log.d(TAG, "dispatchInputEvent(" + event + ")");
+ if (event instanceof KeyEvent) {
+ KeyEvent keyEvent = (KeyEvent) event;
+ if (keyEvent.dispatch(this, mDispatcherState, this)) {
+ return TvAdManager.Session.DISPATCH_HANDLED;
+ }
+
+ // TODO: special handlings of navigation keys and media keys
+ } else if (event instanceof MotionEvent) {
+ MotionEvent motionEvent = (MotionEvent) event;
+ final int source = motionEvent.getSource();
+ if (motionEvent.isTouchEvent()) {
+ if (onTouchEvent(motionEvent)) {
+ return TvAdManager.Session.DISPATCH_HANDLED;
+ }
+ } else if ((source & InputDevice.SOURCE_CLASS_TRACKBALL) != 0) {
+ if (onTrackballEvent(motionEvent)) {
+ return TvAdManager.Session.DISPATCH_HANDLED;
+ }
+ } else {
+ if (onGenericMotionEvent(motionEvent)) {
+ return TvAdManager.Session.DISPATCH_HANDLED;
+ }
+ }
+ }
+ // TODO: handle overlay view
+ return TvAdManager.Session.DISPATCH_NOT_HANDLED;
+ }
+
+
+ private void initialize(ITvAdSessionCallback callback) {
+ synchronized (mLock) {
+ mSessionCallback = callback;
+ for (Runnable runnable : mPendingActions) {
+ runnable.run();
+ }
+ mPendingActions.clear();
+ }
+ }
+
+ /**
+ * Calls {@link #onSetSurface}.
+ */
+ void setSurface(Surface surface) {
+ onSetSurface(surface);
+ if (mSurface != null) {
+ mSurface.release();
+ }
+ mSurface = surface;
+ // TODO: Handle failure.
+ }
+
+ /**
+ * Calls {@link #onSurfaceChanged}.
+ */
+ void dispatchSurfaceChanged(int format, int width, int height) {
+ if (DEBUG) {
+ Log.d(TAG, "dispatchSurfaceChanged(format=" + format + ", width=" + width
+ + ", height=" + height + ")");
+ }
+ onSurfaceChanged(format, width, height);
+ }
+
+ private void executeOrPostRunnableOnMainThread(Runnable action) {
+ synchronized (mLock) {
+ if (mSessionCallback == null) {
+ // The session is not initialized yet.
+ mPendingActions.add(action);
+ } else {
+ if (mHandler.getLooper().isCurrentThread()) {
+ action.run();
+ } else {
+ // Posts the runnable if this is not called from the main thread
+ mHandler.post(action);
+ }
+ }
+ }
+ }
+ }
+
+
+ @SuppressLint("HandlerLeak")
+ private final class ServiceHandler extends Handler {
+ private static final int DO_CREATE_SESSION = 1;
+ private static final int DO_NOTIFY_SESSION_CREATED = 2;
+
+ @Override
+ public void handleMessage(Message msg) {
+ switch (msg.what) {
+ case DO_CREATE_SESSION: {
+ SomeArgs args = (SomeArgs) msg.obj;
+ InputChannel channel = (InputChannel) args.arg1;
+ ITvAdSessionCallback cb = (ITvAdSessionCallback) args.arg2;
+ String serviceId = (String) args.arg3;
+ String type = (String) args.arg4;
+ args.recycle();
+ TvAdService.Session sessionImpl = onCreateSession(serviceId, type);
+ if (sessionImpl == null) {
+ try {
+ // Failed to create a session.
+ cb.onSessionCreated(null);
+ } catch (RemoteException e) {
+ Log.e(TAG, "error in onSessionCreated", e);
+ }
+ return;
+ }
+ ITvAdSession stub =
+ new ITvAdSessionWrapper(TvAdService.this, sessionImpl, channel);
+
+ SomeArgs someArgs = SomeArgs.obtain();
+ someArgs.arg1 = sessionImpl;
+ someArgs.arg2 = stub;
+ someArgs.arg3 = cb;
+ mServiceHandler.obtainMessage(
+ DO_NOTIFY_SESSION_CREATED, someArgs).sendToTarget();
+ return;
+ }
+ case DO_NOTIFY_SESSION_CREATED: {
+ SomeArgs args = (SomeArgs) msg.obj;
+ Session sessionImpl = (Session) args.arg1;
+ ITvAdSession stub = (ITvAdSession) args.arg2;
+ ITvAdSessionCallback cb = (ITvAdSessionCallback) args.arg3;
+ try {
+ cb.onSessionCreated(stub);
+ } catch (RemoteException e) {
+ Log.e(TAG, "error in onSessionCreated", e);
+ }
+ if (sessionImpl != null) {
+ sessionImpl.initialize(cb);
+ }
+ args.recycle();
+ return;
+ }
+ default: {
+ Log.w(TAG, "Unhandled message code: " + msg.what);
+ return;
+ }
+ }
+ }
+
}
}
diff --git a/media/java/android/media/tv/ad/TvAdServiceInfo.java b/media/java/android/media/tv/ad/TvAdServiceInfo.java
index ed04f1f..45dc89d 100644
--- a/media/java/android/media/tv/ad/TvAdServiceInfo.java
+++ b/media/java/android/media/tv/ad/TvAdServiceInfo.java
@@ -24,6 +24,7 @@
import android.content.pm.ResolveInfo;
import android.content.pm.ServiceInfo;
import android.content.res.Resources;
+import android.content.res.TypedArray;
import android.content.res.XmlResourceParser;
import android.os.Parcel;
import android.os.Parcelable;
@@ -63,8 +64,7 @@
if (context == null) {
throw new IllegalArgumentException("context cannot be null.");
}
- // TODO: use a constant
- Intent intent = new Intent("android.media.tv.ad.TvAdService").setComponent(component);
+ Intent intent = new Intent(TvAdService.SERVICE_INTERFACE).setComponent(component);
ResolveInfo resolveInfo = context.getPackageManager().resolveService(
intent, PackageManager.GET_SERVICES | PackageManager.GET_META_DATA);
if (resolveInfo == null) {
@@ -80,6 +80,7 @@
mService = resolveInfo;
mId = id;
+ mTypes.addAll(types);
}
private TvAdServiceInfo(ResolveInfo service, String id, List<String> types) {
@@ -147,9 +148,8 @@
ResolveInfo resolveInfo, Context context, List<String> types) {
ServiceInfo serviceInfo = resolveInfo.serviceInfo;
PackageManager pm = context.getPackageManager();
- // TODO: use constant for the metadata
try (XmlResourceParser parser =
- serviceInfo.loadXmlMetaData(pm, "android.media.tv.ad.service")) {
+ serviceInfo.loadXmlMetaData(pm, TvAdService.SERVICE_META_DATA)) {
if (parser == null) {
throw new IllegalStateException(
"No " + "android.media.tv.ad.service"
@@ -171,7 +171,15 @@
+ XML_START_TAG_NAME + " tag for " + serviceInfo.name);
}
- // TODO: parse attributes
+ TypedArray sa = resources.obtainAttributes(attrs,
+ com.android.internal.R.styleable.TvAdService);
+ CharSequence[] textArr = sa.getTextArray(
+ com.android.internal.R.styleable.TvAdService_adServiceTypes);
+ for (CharSequence cs : textArr) {
+ types.add(cs.toString().toLowerCase());
+ }
+
+ sa.recycle();
} catch (IOException | XmlPullParserException e) {
throw new IllegalStateException(
"Failed reading meta-data for " + serviceInfo.packageName, e);
diff --git a/media/java/android/media/tv/ad/TvAdView.java b/media/java/android/media/tv/ad/TvAdView.java
index 1a3771a..5e67fe9 100644
--- a/media/java/android/media/tv/ad/TvAdView.java
+++ b/media/java/android/media/tv/ad/TvAdView.java
@@ -16,8 +16,20 @@
package android.media.tv.ad;
+import android.annotation.NonNull;
+import android.annotation.Nullable;
import android.content.Context;
+import android.content.res.Resources;
+import android.content.res.XmlResourceParser;
+import android.graphics.PixelFormat;
+import android.os.Handler;
+import android.util.AttributeSet;
import android.util.Log;
+import android.util.Xml;
+import android.view.Surface;
+import android.view.SurfaceHolder;
+import android.view.SurfaceView;
+import android.view.View;
import android.view.ViewGroup;
/**
@@ -28,18 +40,166 @@
private static final String TAG = "TvAdView";
private static final boolean DEBUG = false;
- // TODO: create session
- private TvAdManager.Session mSession;
+ private final TvAdManager mTvAdManager;
- public TvAdView(Context context) {
- super(context, /* attrs = */null, /* defStyleAttr = */0);
+ private final Handler mHandler = new Handler();
+ private TvAdManager.Session mSession;
+ private MySessionCallback mSessionCallback;
+
+ private final AttributeSet mAttrs;
+ private final int mDefStyleAttr;
+ private final XmlResourceParser mParser;
+
+ private SurfaceView mSurfaceView;
+ private Surface mSurface;
+
+ private boolean mSurfaceChanged;
+ private int mSurfaceFormat;
+ private int mSurfaceWidth;
+ private int mSurfaceHeight;
+
+ private boolean mUseRequestedSurfaceLayout;
+ private int mSurfaceViewLeft;
+ private int mSurfaceViewRight;
+ private int mSurfaceViewTop;
+ private int mSurfaceViewBottom;
+
+
+
+ private final SurfaceHolder.Callback mSurfaceHolderCallback = new SurfaceHolder.Callback() {
+ @Override
+ public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) {
+ if (DEBUG) {
+ Log.d(TAG, "surfaceChanged(holder=" + holder + ", format=" + format
+ + ", width=" + width + ", height=" + height + ")");
+ }
+ mSurfaceFormat = format;
+ mSurfaceWidth = width;
+ mSurfaceHeight = height;
+ mSurfaceChanged = true;
+ dispatchSurfaceChanged(mSurfaceFormat, mSurfaceWidth, mSurfaceHeight);
+ }
+
+ @Override
+ public void surfaceCreated(SurfaceHolder holder) {
+ mSurface = holder.getSurface();
+ setSessionSurface(mSurface);
+ }
+
+ @Override
+ public void surfaceDestroyed(SurfaceHolder holder) {
+ mSurface = null;
+ mSurfaceChanged = false;
+ setSessionSurface(null);
+ }
+ };
+
+
+ public TvAdView(@NonNull Context context) {
+ this(context, null, 0);
+ }
+
+ public TvAdView(@NonNull Context context, @Nullable AttributeSet attrs) {
+ this(context, attrs, 0);
+ }
+
+ public TvAdView(@NonNull Context context, @Nullable AttributeSet attrs,
+ int defStyleAttr) {
+ super(context, attrs, defStyleAttr);
+ int sourceResId = Resources.getAttributeSetSourceResId(attrs);
+ if (sourceResId != Resources.ID_NULL) {
+ Log.d(TAG, "Build local AttributeSet");
+ mParser = context.getResources().getXml(sourceResId);
+ mAttrs = Xml.asAttributeSet(mParser);
+ } else {
+ Log.d(TAG, "Use passed in AttributeSet");
+ mParser = null;
+ mAttrs = attrs;
+ }
+ mDefStyleAttr = defStyleAttr;
+ resetSurfaceView();
+ mTvAdManager = (TvAdManager) getContext().getSystemService(Context.TV_AD_SERVICE);
}
@Override
- protected void onLayout(boolean changed, int l, int t, int r, int b) {
+ public void onLayout(boolean changed, int left, int top, int right, int bottom) {
if (DEBUG) {
- Log.d(TAG,
- "onLayout (left=" + l + ", top=" + t + ", right=" + r + ", bottom=" + b + ",)");
+ Log.d(TAG, "onLayout (left=" + left + ", top=" + top + ", right=" + right
+ + ", bottom=" + bottom + ",)");
+ }
+ if (mUseRequestedSurfaceLayout) {
+ mSurfaceView.layout(mSurfaceViewLeft, mSurfaceViewTop, mSurfaceViewRight,
+ mSurfaceViewBottom);
+ } else {
+ mSurfaceView.layout(0, 0, right - left, bottom - top);
+ }
+ }
+
+ @Override
+ public void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
+ mSurfaceView.measure(widthMeasureSpec, heightMeasureSpec);
+ int width = mSurfaceView.getMeasuredWidth();
+ int height = mSurfaceView.getMeasuredHeight();
+ int childState = mSurfaceView.getMeasuredState();
+ setMeasuredDimension(resolveSizeAndState(width, widthMeasureSpec, childState),
+ resolveSizeAndState(height, heightMeasureSpec,
+ childState << MEASURED_HEIGHT_STATE_SHIFT));
+ }
+
+ @Override
+ public void onVisibilityChanged(@NonNull View changedView, int visibility) {
+ super.onVisibilityChanged(changedView, visibility);
+ mSurfaceView.setVisibility(visibility);
+ }
+
+ private void resetSurfaceView() {
+ if (mSurfaceView != null) {
+ mSurfaceView.getHolder().removeCallback(mSurfaceHolderCallback);
+ removeView(mSurfaceView);
+ }
+ mSurface = null;
+ mSurfaceView = new SurfaceView(getContext(), mAttrs, mDefStyleAttr) {
+ @Override
+ protected void updateSurface() {
+ super.updateSurface();
+ }};
+ // The surface view's content should be treated as secure all the time.
+ mSurfaceView.setSecure(true);
+ mSurfaceView.getHolder().addCallback(mSurfaceHolderCallback);
+ mSurfaceView.getHolder().setFormat(PixelFormat.TRANSLUCENT);
+
+ mSurfaceView.setZOrderOnTop(false);
+ mSurfaceView.setZOrderMediaOverlay(true);
+
+ addView(mSurfaceView);
+ }
+
+ private void setSessionSurface(Surface surface) {
+ if (mSession == null) {
+ return;
+ }
+ mSession.setSurface(surface);
+ }
+
+ private void dispatchSurfaceChanged(int format, int width, int height) {
+ if (mSession == null) {
+ return;
+ }
+ //mSession.dispatchSurfaceChanged(format, width, height);
+ }
+
+ /**
+ * Prepares the AD service of corresponding {@link TvAdService}.
+ *
+ * @param serviceId the AD service ID, which can be found in TvAdServiceInfo#getId().
+ */
+ public void prepareAdService(@NonNull String serviceId, @NonNull String type) {
+ if (DEBUG) {
+ Log.d(TAG, "prepareAdService");
+ }
+ mSessionCallback = new TvAdView.MySessionCallback(serviceId);
+ if (mTvAdManager != null) {
+ mTvAdManager.createSession(serviceId, type, mSessionCallback, mHandler);
}
}
@@ -54,4 +214,75 @@
mSession.startAdService();
}
}
+
+ private class MySessionCallback extends TvAdManager.SessionCallback {
+ final String mServiceId;
+
+ MySessionCallback(String serviceId) {
+ mServiceId = serviceId;
+ }
+
+ @Override
+ public void onSessionCreated(TvAdManager.Session session) {
+ if (DEBUG) {
+ Log.d(TAG, "onSessionCreated()");
+ }
+ if (this != mSessionCallback) {
+ Log.w(TAG, "onSessionCreated - session already created");
+ // This callback is obsolete.
+ if (session != null) {
+ session.release();
+ }
+ return;
+ }
+ mSession = session;
+ if (session != null) {
+ // mSurface may not be ready yet as soon as starting an application.
+ // In the case, we don't send Session.setSurface(null) unnecessarily.
+ // setSessionSurface will be called in surfaceCreated.
+ if (mSurface != null) {
+ setSessionSurface(mSurface);
+ if (mSurfaceChanged) {
+ dispatchSurfaceChanged(mSurfaceFormat, mSurfaceWidth, mSurfaceHeight);
+ }
+ }
+ } else {
+ // Failed to create
+ // Todo: forward error to Tv App
+ mSessionCallback = null;
+ }
+ }
+
+ @Override
+ public void onSessionReleased(TvAdManager.Session session) {
+ if (DEBUG) {
+ Log.d(TAG, "onSessionReleased()");
+ }
+ if (this != mSessionCallback) {
+ Log.w(TAG, "onSessionReleased - session not created");
+ return;
+ }
+ mSessionCallback = null;
+ mSession = null;
+ }
+
+ @Override
+ public void onLayoutSurface(
+ TvAdManager.Session session, int left, int top, int right, int bottom) {
+ if (DEBUG) {
+ Log.d(TAG, "onLayoutSurface (left=" + left + ", top=" + top + ", right="
+ + right + ", bottom=" + bottom + ",)");
+ }
+ if (this != mSessionCallback) {
+ Log.w(TAG, "onLayoutSurface - session not created");
+ return;
+ }
+ mSurfaceViewLeft = left;
+ mSurfaceViewTop = top;
+ mSurfaceViewRight = right;
+ mSurfaceViewBottom = bottom;
+ mUseRequestedSurfaceLayout = true;
+ requestLayout();
+ }
+ }
}
diff --git a/media/java/android/media/tv/interactive/ITvInteractiveAppClient.aidl b/media/java/android/media/tv/interactive/ITvInteractiveAppClient.aidl
index 7739184..e3dba03 100644
--- a/media/java/android/media/tv/interactive/ITvInteractiveAppClient.aidl
+++ b/media/java/android/media/tv/interactive/ITvInteractiveAppClient.aidl
@@ -48,6 +48,7 @@
void onRequestCurrentChannelLcn(int seq);
void onRequestStreamVolume(int seq);
void onRequestTrackInfoList(int seq);
+ void onRequestSelectedTrackInfo(int seq);
void onRequestCurrentTvInputId(int seq);
void onRequestTimeShiftMode(int seq);
void onRequestAvailableSpeeds(int seq);
diff --git a/media/java/android/media/tv/interactive/ITvInteractiveAppManager.aidl b/media/java/android/media/tv/interactive/ITvInteractiveAppManager.aidl
index 41cbe4a..4316d05 100644
--- a/media/java/android/media/tv/interactive/ITvInteractiveAppManager.aidl
+++ b/media/java/android/media/tv/interactive/ITvInteractiveAppManager.aidl
@@ -102,6 +102,8 @@
int UserId);
void notifyAdResponse(in IBinder sessionToken, in AdResponse response, int UserId);
void notifyAdBufferConsumed(in IBinder sessionToken, in AdBuffer buffer, int userId);
+ void sendSelectedTrackInfo(in IBinder sessionToken, in List<TvTrackInfo> tracks,
+ int userId);
void createMediaView(in IBinder sessionToken, in IBinder windowToken, in Rect frame,
int userId);
diff --git a/media/java/android/media/tv/interactive/ITvInteractiveAppSession.aidl b/media/java/android/media/tv/interactive/ITvInteractiveAppSession.aidl
index 052bc3d..ba7cf13 100644
--- a/media/java/android/media/tv/interactive/ITvInteractiveAppSession.aidl
+++ b/media/java/android/media/tv/interactive/ITvInteractiveAppSession.aidl
@@ -78,6 +78,7 @@
void notifyBroadcastInfoResponse(in BroadcastInfoResponse response);
void notifyAdResponse(in AdResponse response);
void notifyAdBufferConsumed(in AdBuffer buffer);
+ void sendSelectedTrackInfo(in List<TvTrackInfo> tracks);
void createMediaView(in IBinder windowToken, in Rect frame);
void relayoutMediaView(in Rect frame);
diff --git a/media/java/android/media/tv/interactive/ITvInteractiveAppSessionCallback.aidl b/media/java/android/media/tv/interactive/ITvInteractiveAppSessionCallback.aidl
index 9e43e79..416b8f1 100644
--- a/media/java/android/media/tv/interactive/ITvInteractiveAppSessionCallback.aidl
+++ b/media/java/android/media/tv/interactive/ITvInteractiveAppSessionCallback.aidl
@@ -50,6 +50,7 @@
void onRequestCurrentTvInputId();
void onRequestTimeShiftMode();
void onRequestAvailableSpeeds();
+ void onRequestSelectedTrackInfo();
void onRequestStartRecording(in String requestId, in Uri programUri);
void onRequestStopRecording(in String recordingId);
void onRequestScheduleRecording(in String requestId, in String inputId, in Uri channelUri,
diff --git a/media/java/android/media/tv/interactive/ITvInteractiveAppSessionWrapper.java b/media/java/android/media/tv/interactive/ITvInteractiveAppSessionWrapper.java
index 253ade8..518b08a 100644
--- a/media/java/android/media/tv/interactive/ITvInteractiveAppSessionWrapper.java
+++ b/media/java/android/media/tv/interactive/ITvInteractiveAppSessionWrapper.java
@@ -102,6 +102,7 @@
private static final int DO_NOTIFY_RECORDING_SCHEDULED = 45;
private static final int DO_SEND_TIME_SHIFT_MODE = 46;
private static final int DO_SEND_AVAILABLE_SPEEDS = 47;
+ private static final int DO_SEND_SELECTED_TRACK_INFO = 48;
private final HandlerCaller mCaller;
private Session mSessionImpl;
@@ -247,6 +248,10 @@
args.recycle();
break;
}
+ case DO_SEND_SELECTED_TRACK_INFO: {
+ mSessionImpl.sendSelectedTrackInfo((List<TvTrackInfo>) msg.obj);
+ break;
+ }
case DO_NOTIFY_VIDEO_AVAILABLE: {
mSessionImpl.notifyVideoAvailable();
break;
@@ -526,6 +531,12 @@
}
@Override
+ public void sendSelectedTrackInfo(List<TvTrackInfo> tracks) {
+ mCaller.executeOrSendMessage(
+ mCaller.obtainMessageO(DO_SEND_SELECTED_TRACK_INFO, tracks));
+ }
+
+ @Override
public void notifyTracksChanged(List<TvTrackInfo> tracks) {
mCaller.executeOrSendMessage(mCaller.obtainMessageO(DO_NOTIFY_TRACKS_CHANGED, tracks));
}
diff --git a/media/java/android/media/tv/interactive/TvInteractiveAppManager.java b/media/java/android/media/tv/interactive/TvInteractiveAppManager.java
index 7cce84a..bf4379f 100755
--- a/media/java/android/media/tv/interactive/TvInteractiveAppManager.java
+++ b/media/java/android/media/tv/interactive/TvInteractiveAppManager.java
@@ -33,7 +33,6 @@
import android.media.tv.TvInputManager;
import android.media.tv.TvRecordingInfo;
import android.media.tv.TvTrackInfo;
-import android.media.tv.interactive.TvInteractiveAppService.Session;
import android.net.Uri;
import android.os.Bundle;
import android.os.Handler;
@@ -506,6 +505,18 @@
}
@Override
+ public void onRequestSelectedTrackInfo(int seq) {
+ synchronized (mSessionCallbackRecordMap) {
+ SessionCallbackRecord record = mSessionCallbackRecordMap.get(seq);
+ if (record == null) {
+ Log.e(TAG, "Callback not found for seq " + seq);
+ return;
+ }
+ record.postRequestSelectedTrackInfo();
+ }
+ }
+
+ @Override
public void onRequestCurrentTvInputId(int seq) {
synchronized (mSessionCallbackRecordMap) {
SessionCallbackRecord record = mSessionCallbackRecordMap.get(seq);
@@ -1209,6 +1220,18 @@
}
}
+ void sendSelectedTrackInfo(@NonNull List<TvTrackInfo> tracks) {
+ if (mToken == null) {
+ Log.w(TAG, "The session has been already released");
+ return;
+ }
+ try {
+ mService.sendSelectedTrackInfo(mToken, tracks, mUserId);
+ } catch (RemoteException e) {
+ throw e.rethrowFromSystemServer();
+ }
+ }
+
void sendCurrentTvInputId(@Nullable String inputId) {
if (mToken == null) {
Log.w(TAG, "The session has been already released");
@@ -2108,6 +2131,15 @@
});
}
+ void postRequestSelectedTrackInfo() {
+ mHandler.post(new Runnable() {
+ @Override
+ public void run() {
+ mSessionCallback.onRequestSelectedTrackInfo(mSession);
+ }
+ });
+ }
+
void postRequestCurrentTvInputId() {
mHandler.post(new Runnable() {
@Override
@@ -2378,6 +2410,15 @@
}
/**
+ * This is called when {@link TvInteractiveAppService.Session#requestSelectedTrackInfo()} is
+ * called.
+ *
+ * @param session A {@link TvInteractiveAppManager.Session} associated with this callback.
+ */
+ public void onRequestSelectedTrackInfo(Session session) {
+ }
+
+ /**
* This is called when {@link TvInteractiveAppService.Session#requestCurrentTvInputId} is
* called.
*
diff --git a/media/java/android/media/tv/interactive/TvInteractiveAppService.java b/media/java/android/media/tv/interactive/TvInteractiveAppService.java
index 2419404..5cc86ba 100755
--- a/media/java/android/media/tv/interactive/TvInteractiveAppService.java
+++ b/media/java/android/media/tv/interactive/TvInteractiveAppService.java
@@ -932,6 +932,16 @@
@NonNull Bundle data) {
}
+ /**
+ * Called when the TV App sends the selected track info as a response to
+ * requestSelectedTrackInfo.
+ *
+ * @param tracks
+ * @hide
+ */
+ public void onSelectedTrackInfo(List<TvTrackInfo> tracks) {
+ }
+
@Override
public boolean onKeyDown(int keyCode, @NonNull KeyEvent event) {
return false;
@@ -1338,6 +1348,30 @@
}
/**
+ * Requests the currently selected {@link TvTrackInfo} from the TV App.
+ *
+ * <p> Normally, track info cannot be synchronized until the channel has
+ * been changed. This is used when the session of the TIAS is newly
+ * created and the normal synchronization has not happened yet.
+ * @hide
+ */
+ @CallSuper
+ public void requestSelectedTrackInfo() {
+ executeOrPostRunnableOnMainThread(() -> {
+ try {
+ if (DEBUG) {
+ Log.d(TAG, "requestSelectedTrackInfo");
+ }
+ if (mSessionCallback != null) {
+ mSessionCallback.onRequestSelectedTrackInfo();
+ }
+ } catch (RemoteException e) {
+ Log.w(TAG, "error in requestSelectedTrackInfo", e);
+ }
+ });
+ }
+
+ /**
* Requests starting of recording
*
* <p> This is used to request the active {@link android.media.tv.TvRecordingClient} to
@@ -1781,6 +1815,13 @@
onTvMessage(type, data);
}
+ void sendSelectedTrackInfo(List<TvTrackInfo> tracks) {
+ if (DEBUG) {
+ Log.d(TAG, "notifySelectedTrackInfo (tracks= " + tracks + ")");
+ }
+ onSelectedTrackInfo(tracks);
+ }
+
/**
* Calls {@link #onAdBufferConsumed}.
*/
diff --git a/media/java/android/media/tv/interactive/TvInteractiveAppView.java b/media/java/android/media/tv/interactive/TvInteractiveAppView.java
index cbaf5e4..40a12e4 100755
--- a/media/java/android/media/tv/interactive/TvInteractiveAppView.java
+++ b/media/java/android/media/tv/interactive/TvInteractiveAppView.java
@@ -582,6 +582,20 @@
}
/**
+ * Sends the currently selected track info to the TV Interactive App.
+ *
+ * @hide
+ */
+ public void sendSelectedTrackInfo(@Nullable List<TvTrackInfo> tracks) {
+ if (DEBUG) {
+ Log.d(TAG, "sendSelectedTrackInfo");
+ }
+ if (mSession != null) {
+ mSession.sendSelectedTrackInfo(tracks);
+ }
+ }
+
+ /**
* Sends current TV input ID to related TV interactive app.
*
* @param inputId The current TV input ID whose channel is tuned. {@code null} if no channel is
@@ -1197,6 +1211,16 @@
}
/**
+ * This is called when {@link TvInteractiveAppService.Session#requestSelectedTrackInfo()} is
+ * called.
+ *
+ * @param iAppServiceId The ID of the TV interactive app service bound to this view.
+ * @hide
+ */
+ public void onRequestSelectedTrackInfo(@NonNull String iAppServiceId) {
+ }
+
+ /**
* This is called when {@link TvInteractiveAppService.Session#requestCurrentTvInputId()} is
* called.
*
@@ -1714,6 +1738,28 @@
}
@Override
+ public void onRequestSelectedTrackInfo(Session session) {
+ if (DEBUG) {
+ Log.d(TAG, "onRequestSelectedTrackInfo");
+ }
+ if (this != mSessionCallback) {
+ Log.w(TAG, "onRequestSelectedTrackInfo - session not created");
+ return;
+ }
+ synchronized (mCallbackLock) {
+ if (mCallbackExecutor != null) {
+ mCallbackExecutor.execute(() -> {
+ synchronized (mCallbackLock) {
+ if (mCallback != null) {
+ mCallback.onRequestSelectedTrackInfo(mIAppServiceId);
+ }
+ }
+ });
+ }
+ }
+ }
+
+ @Override
public void onRequestCurrentTvInputId(Session session) {
if (DEBUG) {
Log.d(TAG, "onRequestCurrentTvInputId");
diff --git a/media/jni/android_media_tv_Tuner.cpp b/media/jni/android_media_tv_Tuner.cpp
index 3fcb871..00b0e57 100644
--- a/media/jni/android_media_tv_Tuner.cpp
+++ b/media/jni/android_media_tv_Tuner.cpp
@@ -967,7 +967,7 @@
ScopedLocalRef<jobject> filter(env);
{
android::Mutex::Autolock autoLock(mLock);
- if (env->IsSameObject(filter.get(), nullptr)) {
+ if (env->IsSameObject(mFilterObj, nullptr)) {
ALOGE("FilterClientCallbackImpl::onFilterStatus:"
"Filter object has been freed. Ignoring callback.");
return;
diff --git a/nfc/Android.bp b/nfc/Android.bp
index 87da299..74bec3e 100644
--- a/nfc/Android.bp
+++ b/nfc/Android.bp
@@ -69,6 +69,7 @@
jarjar_rules: ":nfc-jarjar-rules",
lint: {
strict_updatability_linting: true,
+ baseline_filename: "lint-baseline.xml",
},
apex_available: [
"//apex_available:platform",
diff --git a/nfc/lint-baseline.xml b/nfc/lint-baseline.xml
new file mode 100644
index 0000000..1dfdd29
--- /dev/null
+++ b/nfc/lint-baseline.xml
@@ -0,0 +1,213 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<issues format="6" by="lint 8.4.0-alpha01" type="baseline" client="" dependencies="true" name="" variant="all" version="8.4.0-alpha01">
+
+ <issue
+ id="NewApi"
+ message="Call requires API level 35 (current min is 34): `new android.nfc.cardemulation.AidGroup`"
+ errorLine1=" AidGroup aidGroup = new AidGroup(aids, category);"
+ errorLine2=" ~~~~~~~~~~~~">
+ <location
+ file="frameworks/base/nfc/java/android/nfc/cardemulation/CardEmulation.java"
+ line="377"
+ column="29"/>
+ </issue>
+
+ <issue
+ id="NewApi"
+ message="Call requires API level 35 (current min is 34): `android.nfc.cardemulation.AidGroup#getAids`"
+ errorLine1=" return (group != null ? group.getAids() : null);"
+ errorLine2=" ~~~~~~~">
+ <location
+ file="frameworks/base/nfc/java/android/nfc/cardemulation/CardEmulation.java"
+ line="537"
+ column="43"/>
+ </issue>
+
+ <issue
+ id="NewApi"
+ message="Call requires API level 35 (current min is 34): `android.nfc.cardemulation.AidGroup#getAids`"
+ errorLine1=" return (group != null ? group.getAids() : null);"
+ errorLine2=" ~~~~~~~">
+ <location
+ file="frameworks/base/nfc/java/android/nfc/cardemulation/CardEmulation.java"
+ line="547"
+ column="47"/>
+ </issue>
+
+ <issue
+ id="NewApi"
+ message="Call requires API level 35 (current min is 34): `android.nfc.cardemulation.ApduServiceInfo#getAids`"
+ errorLine1=" return (serviceInfo != null ? serviceInfo.getAids() : null);"
+ errorLine2=" ~~~~~~~">
+ <location
+ file="frameworks/base/nfc/java/android/nfc/cardemulation/CardEmulation.java"
+ line="714"
+ column="55"/>
+ </issue>
+
+ <issue
+ id="NewApi"
+ message="Call requires API level 35 (current min is 34): `android.nfc.cardemulation.ApduServiceInfo#getAids`"
+ errorLine1=" return (serviceInfo != null ? serviceInfo.getAids() : null);"
+ errorLine2=" ~~~~~~~">
+ <location
+ file="frameworks/base/nfc/java/android/nfc/cardemulation/CardEmulation.java"
+ line="724"
+ column="59"/>
+ </issue>
+
+ <issue
+ id="NewApi"
+ message="Call requires API level 35 (current min is 34): `android.nfc.cardemulation.ApduServiceInfo#isOnHost`"
+ errorLine1=" if (!serviceInfo.isOnHost()) {"
+ errorLine2=" ~~~~~~~~">
+ <location
+ file="frameworks/base/nfc/java/android/nfc/cardemulation/CardEmulation.java"
+ line="755"
+ column="34"/>
+ </issue>
+
+ <issue
+ id="NewApi"
+ message="Call requires API level 35 (current min is 34): `android.nfc.cardemulation.ApduServiceInfo#getOffHostSecureElement`"
+ errorLine1=" return serviceInfo.getOffHostSecureElement() == null ?"
+ errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~">
+ <location
+ file="frameworks/base/nfc/java/android/nfc/cardemulation/CardEmulation.java"
+ line="756"
+ column="40"/>
+ </issue>
+
+ <issue
+ id="NewApi"
+ message="Call requires API level 35 (current min is 34): `android.nfc.cardemulation.ApduServiceInfo#getOffHostSecureElement`"
+ errorLine1=' "OffHost" : serviceInfo.getOffHostSecureElement();'
+ errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~">
+ <location
+ file="frameworks/base/nfc/java/android/nfc/cardemulation/CardEmulation.java"
+ line="757"
+ column="53"/>
+ </issue>
+
+ <issue
+ id="NewApi"
+ message="Call requires API level 35 (current min is 34): `android.nfc.cardemulation.ApduServiceInfo#isOnHost`"
+ errorLine1=" if (!serviceInfo.isOnHost()) {"
+ errorLine2=" ~~~~~~~~">
+ <location
+ file="frameworks/base/nfc/java/android/nfc/cardemulation/CardEmulation.java"
+ line="772"
+ column="38"/>
+ </issue>
+
+ <issue
+ id="NewApi"
+ message="Call requires API level 35 (current min is 34): `android.nfc.cardemulation.ApduServiceInfo#getOffHostSecureElement`"
+ errorLine1=" return serviceInfo.getOffHostSecureElement() == null ?"
+ errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~">
+ <location
+ file="frameworks/base/nfc/java/android/nfc/cardemulation/CardEmulation.java"
+ line="773"
+ column="44"/>
+ </issue>
+
+ <issue
+ id="NewApi"
+ message="Call requires API level 35 (current min is 34): `android.nfc.cardemulation.ApduServiceInfo#getOffHostSecureElement`"
+ errorLine1=' "Offhost" : serviceInfo.getOffHostSecureElement();'
+ errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~">
+ <location
+ file="frameworks/base/nfc/java/android/nfc/cardemulation/CardEmulation.java"
+ line="774"
+ column="57"/>
+ </issue>
+
+ <issue
+ id="NewApi"
+ message="Call requires API level 35 (current min is 34): `android.nfc.cardemulation.ApduServiceInfo#getDescription`"
+ errorLine1=" return (serviceInfo != null ? serviceInfo.getDescription() : null);"
+ errorLine2=" ~~~~~~~~~~~~~~">
+ <location
+ file="frameworks/base/nfc/java/android/nfc/cardemulation/CardEmulation.java"
+ line="798"
+ column="55"/>
+ </issue>
+
+ <issue
+ id="NewApi"
+ message="Call requires API level 35 (current min is 34): `android.nfc.cardemulation.ApduServiceInfo#getDescription`"
+ errorLine1=" return (serviceInfo != null ? serviceInfo.getDescription() : null);"
+ errorLine2=" ~~~~~~~~~~~~~~">
+ <location
+ file="frameworks/base/nfc/java/android/nfc/cardemulation/CardEmulation.java"
+ line="808"
+ column="59"/>
+ </issue>
+
+ <issue
+ id="NewApi"
+ message="Call requires API level 35 (current min is 34): `android.app.Activity#isResumed`"
+ errorLine1=" if (!activity.isResumed()) {"
+ errorLine2=" ~~~~~~~~~">
+ <location
+ file="frameworks/base/nfc/java/android/nfc/cardemulation/CardEmulation.java"
+ line="1032"
+ column="23"/>
+ </issue>
+
+ <issue
+ id="NewApi"
+ message="Call requires API level 35 (current min is 34): `android.app.Activity#isResumed`"
+ errorLine1=" if (!activity.isResumed()) {"
+ errorLine2=" ~~~~~~~~~">
+ <location
+ file="frameworks/base/nfc/java/android/nfc/cardemulation/CardEmulation.java"
+ line="1066"
+ column="23"/>
+ </issue>
+
+ <issue
+ id="NewApi"
+ message="Call requires API level 35 (current min is 34): `android.app.Activity#isResumed`"
+ errorLine1=" resumed = activity.isResumed();"
+ errorLine2=" ~~~~~~~~~">
+ <location
+ file="frameworks/base/nfc/java/android/nfc/NfcActivityManager.java"
+ line="124"
+ column="32"/>
+ </issue>
+
+ <issue
+ id="NewApi"
+ message="Call requires API level 35 (current min is 34): `android.app.Activity#isResumed`"
+ errorLine1=" if (!activity.isResumed()) {"
+ errorLine2=" ~~~~~~~~~">
+ <location
+ file="frameworks/base/nfc/java/android/nfc/NfcAdapter.java"
+ line="2457"
+ column="23"/>
+ </issue>
+
+ <issue
+ id="NewApi"
+ message="Call requires API level 35 (current min is 34): `android.app.Activity#isResumed`"
+ errorLine1=" if (!activity.isResumed()) {"
+ errorLine2=" ~~~~~~~~~">
+ <location
+ file="frameworks/base/nfc/java/android/nfc/cardemulation/NfcFCardEmulation.java"
+ line="315"
+ column="23"/>
+ </issue>
+
+ <issue
+ id="NewApi"
+ message="Call requires API level 35 (current min is 34): `android.app.Activity#isResumed`"
+ errorLine1=" if (!activity.isResumed()) {"
+ errorLine2=" ~~~~~~~~~">
+ <location
+ file="frameworks/base/nfc/java/android/nfc/cardemulation/NfcFCardEmulation.java"
+ line="351"
+ column="23"/>
+ </issue>
+
+</issues>
\ No newline at end of file
diff --git a/packages/SettingsLib/Android.bp b/packages/SettingsLib/Android.bp
index 5da4b95..c2cb757 100644
--- a/packages/SettingsLib/Android.bp
+++ b/packages/SettingsLib/Android.bp
@@ -9,6 +9,9 @@
android_library {
name: "SettingsLib",
+ defaults: [
+ "SettingsLintDefaults",
+ ],
static_libs: [
"androidx.localbroadcastmanager_localbroadcastmanager",
@@ -60,8 +63,15 @@
"src/**/*.java",
"src/**/*.kt",
],
+}
+
+// defaults for lint option
+java_defaults {
+ name: "SettingsLintDefaults",
lint: {
- extra_check_modules: ["SettingsLibLintChecker"],
+ extra_check_modules: [
+ "SettingsLibLintChecker",
+ ],
},
}
diff --git a/packages/SettingsLib/SpaPrivileged/src/com/android/settingslib/spaprivileged/template/app/TogglePermissionAppInfoPage.kt b/packages/SettingsLib/SpaPrivileged/src/com/android/settingslib/spaprivileged/template/app/TogglePermissionAppInfoPage.kt
index 1c830c1..74b556e 100644
--- a/packages/SettingsLib/SpaPrivileged/src/com/android/settingslib/spaprivileged/template/app/TogglePermissionAppInfoPage.kt
+++ b/packages/SettingsLib/SpaPrivileged/src/com/android/settingslib/spaprivileged/template/app/TogglePermissionAppInfoPage.kt
@@ -162,6 +162,7 @@
uid = checkNotNull(applicationInfo).uid,
packageName = packageName) })
RestrictedSwitchPreference(switchModel, restrictions, restrictionsProviderFactory)
+ InfoPageAdditionalContent(record, isAllowed)
}
}
diff --git a/packages/SettingsLib/SpaPrivileged/src/com/android/settingslib/spaprivileged/template/app/TogglePermissionAppList.kt b/packages/SettingsLib/SpaPrivileged/src/com/android/settingslib/spaprivileged/template/app/TogglePermissionAppList.kt
index 916d83a..3f7a852 100644
--- a/packages/SettingsLib/SpaPrivileged/src/com/android/settingslib/spaprivileged/template/app/TogglePermissionAppList.kt
+++ b/packages/SettingsLib/SpaPrivileged/src/com/android/settingslib/spaprivileged/template/app/TogglePermissionAppList.kt
@@ -77,6 +77,9 @@
* Sets whether the permission is allowed for the given app.
*/
fun setAllowed(record: T, newAllowed: Boolean)
+
+ @Composable
+ fun InfoPageAdditionalContent(record: T, isAllowed: () -> Boolean?){}
}
interface TogglePermissionAppListProvider {
diff --git a/packages/SettingsLib/src/com/android/settingslib/bluetooth/BluetoothUtils.java b/packages/SettingsLib/src/com/android/settingslib/bluetooth/BluetoothUtils.java
index 071afaf..f7f0673 100644
--- a/packages/SettingsLib/src/com/android/settingslib/bluetooth/BluetoothUtils.java
+++ b/packages/SettingsLib/src/com/android/settingslib/bluetooth/BluetoothUtils.java
@@ -117,6 +117,12 @@
}
}
+ if (cachedDevice.isHearingAidDevice()) {
+ return new Pair<>(getBluetoothDrawable(context,
+ com.android.internal.R.drawable.ic_bt_hearing_aid),
+ context.getString(R.string.bluetooth_talkback_hearing_aids));
+ }
+
List<LocalBluetoothProfile> profiles = cachedDevice.getProfiles();
int resId = 0;
for (LocalBluetoothProfile profile : profiles) {
diff --git a/packages/SettingsLib/src/com/android/settingslib/bluetooth/CachedBluetoothDevice.java b/packages/SettingsLib/src/com/android/settingslib/bluetooth/CachedBluetoothDevice.java
index 032a838..560bc46 100644
--- a/packages/SettingsLib/src/com/android/settingslib/bluetooth/CachedBluetoothDevice.java
+++ b/packages/SettingsLib/src/com/android/settingslib/bluetooth/CachedBluetoothDevice.java
@@ -412,6 +412,7 @@
public void setHearingAidInfo(HearingAidInfo hearingAidInfo) {
mHearingAidInfo = hearingAidInfo;
+ dispatchAttributesChanged();
}
public HearingAidInfo getHearingAidInfo() {
diff --git a/packages/SettingsLib/tests/robotests/src/com/android/settingslib/bluetooth/BluetoothUtilsTest.java b/packages/SettingsLib/tests/robotests/src/com/android/settingslib/bluetooth/BluetoothUtilsTest.java
index 7409eea..f7ec80b 100644
--- a/packages/SettingsLib/tests/robotests/src/com/android/settingslib/bluetooth/BluetoothUtilsTest.java
+++ b/packages/SettingsLib/tests/robotests/src/com/android/settingslib/bluetooth/BluetoothUtilsTest.java
@@ -16,6 +16,7 @@
package com.android.settingslib.bluetooth;
import static com.google.common.truth.Truth.assertThat;
+
import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
@@ -87,6 +88,14 @@
}
@Test
+ public void getBtClassDrawableWithDescription_typeHearingAid_returnHearingAidDrawable() {
+ when(mCachedBluetoothDevice.isHearingAidDevice()).thenReturn(true);
+ BluetoothUtils.getBtClassDrawableWithDescription(mContext, mCachedBluetoothDevice);
+
+ verify(mContext).getDrawable(com.android.internal.R.drawable.ic_bt_hearing_aid);
+ }
+
+ @Test
public void getBtRainbowDrawableWithDescription_normalHeadset_returnAdaptiveIcon() {
when(mBluetoothDevice.getMetadata(
BluetoothDevice.METADATA_IS_UNTETHERED_HEADSET)).thenReturn("false".getBytes());
diff --git a/packages/SettingsProvider/src/com/android/providers/settings/SettingsProvider.java b/packages/SettingsProvider/src/com/android/providers/settings/SettingsProvider.java
index b0abf92..2d442f4 100644
--- a/packages/SettingsProvider/src/com/android/providers/settings/SettingsProvider.java
+++ b/packages/SettingsProvider/src/com/android/providers/settings/SettingsProvider.java
@@ -1349,6 +1349,26 @@
final int nameCount = names.size();
HashMap<String, String> flagsToValues = new HashMap<>(names.size());
+ if (Flags.loadAconfigDefaults()) {
+ Map<String, Map<String, String>> allDefaults =
+ settingsState.getAconfigDefaultValues();
+
+ if (allDefaults != null) {
+ if (prefix != null) {
+ String namespace = prefix.substring(0, prefix.length() - 1);
+
+ Map<String, String> namespaceDefaults = allDefaults.get(namespace);
+ if (namespaceDefaults != null) {
+ flagsToValues.putAll(namespaceDefaults);
+ }
+ } else {
+ for (Map<String, String> namespaceDefaults : allDefaults.values()) {
+ flagsToValues.putAll(namespaceDefaults);
+ }
+ }
+ }
+ }
+
for (int i = 0; i < nameCount; i++) {
String name = names.get(i);
Setting setting = settingsState.getSettingLocked(name);
diff --git a/packages/SettingsProvider/src/com/android/providers/settings/SettingsState.java b/packages/SettingsProvider/src/com/android/providers/settings/SettingsState.java
index 73c2e22..6f3c88f 100644
--- a/packages/SettingsProvider/src/com/android/providers/settings/SettingsState.java
+++ b/packages/SettingsProvider/src/com/android/providers/settings/SettingsState.java
@@ -69,6 +69,7 @@
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.ArrayList;
+import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
@@ -236,6 +237,10 @@
@GuardedBy("mLock")
private int mNextHistoricalOpIdx;
+ @GuardedBy("mLock")
+ @Nullable
+ private Map<String, Map<String, String>> mNamespaceDefaults;
+
public static final int SETTINGS_TYPE_GLOBAL = 0;
public static final int SETTINGS_TYPE_SYSTEM = 1;
public static final int SETTINGS_TYPE_SECURE = 2;
@@ -331,25 +336,21 @@
readStateSyncLocked();
if (Flags.loadAconfigDefaults()) {
- // Only load aconfig defaults if this is the first boot, the XML
- // file doesn't exist yet, or this device is on its first boot after
- // an OTA.
- boolean shouldLoadAconfigValues = isConfigSettingsKey(mKey)
- && (!file.exists()
- || mContext.getPackageManager().isDeviceUpgrading());
- if (shouldLoadAconfigValues) {
+ if (isConfigSettingsKey(mKey)) {
loadAconfigDefaultValuesLocked();
}
}
+
}
}
@GuardedBy("mLock")
private void loadAconfigDefaultValuesLocked() {
+ mNamespaceDefaults = new HashMap<>();
+
for (String fileName : sAconfigTextProtoFilesOnDevice) {
try (FileInputStream inputStream = new FileInputStream(fileName)) {
- byte[] contents = inputStream.readAllBytes();
- loadAconfigDefaultValues(contents);
+ loadAconfigDefaultValues(inputStream.readAllBytes(), mNamespaceDefaults);
} catch (IOException e) {
Slog.e(LOG_TAG, "failed to read protobuf", e);
}
@@ -358,27 +359,21 @@
@VisibleForTesting
@GuardedBy("mLock")
- public void loadAconfigDefaultValues(byte[] fileContents) {
+ public static void loadAconfigDefaultValues(byte[] fileContents,
+ @NonNull Map<String, Map<String, String>> defaultMap) {
try {
- parsed_flags parsedFlags = parsed_flags.parseFrom(fileContents);
-
- if (parsedFlags == null) {
- Slog.e(LOG_TAG, "failed to parse aconfig protobuf");
- return;
- }
-
+ parsed_flags parsedFlags =
+ parsed_flags.parseFrom(fileContents);
for (parsed_flag flag : parsedFlags.getParsedFlagList()) {
- String flagName = flag.getNamespace() + "/"
- + flag.getPackage() + "." + flag.getName();
- String value = flag.getState() == flag_state.ENABLED ? "true" : "false";
-
- Setting existingSetting = getSettingLocked(flagName);
- boolean isDefaultLoaded = existingSetting.getTag() != null
- && existingSetting.getTag().equals(BOOT_LOADED_DEFAULT_TAG);
- if (existingSetting.getValue() == null || isDefaultLoaded) {
- insertSettingLocked(flagName, value, BOOT_LOADED_DEFAULT_TAG,
- false, flag.getPackage());
+ if (!defaultMap.containsKey(flag.getNamespace())) {
+ Map<String, String> defaults = new HashMap<>();
+ defaultMap.put(flag.getNamespace(), defaults);
}
+ String flagName = flag.getNamespace()
+ + "/" + flag.getPackage() + "." + flag.getName();
+ String flagValue = flag.getState() == flag_state.ENABLED
+ ? "true" : "false";
+ defaultMap.get(flag.getNamespace()).put(flagName, flagValue);
}
} catch (IOException e) {
Slog.e(LOG_TAG, "failed to parse protobuf", e);
@@ -443,6 +438,13 @@
return names;
}
+ @Nullable
+ public Map<String, Map<String, String>> getAconfigDefaultValues() {
+ synchronized (mLock) {
+ return mNamespaceDefaults;
+ }
+ }
+
// The settings provider must hold its lock when calling here.
public Setting getSettingLocked(String name) {
if (TextUtils.isEmpty(name)) {
diff --git a/packages/SettingsProvider/src/com/android/providers/settings/device_config_service.aconfig b/packages/SettingsProvider/src/com/android/providers/settings/device_config_service.aconfig
index ecac5ee..edbc0b3 100644
--- a/packages/SettingsProvider/src/com/android/providers/settings/device_config_service.aconfig
+++ b/packages/SettingsProvider/src/com/android/providers/settings/device_config_service.aconfig
@@ -14,3 +14,11 @@
bug: "311155098"
is_fixed_read_only: true
}
+
+flag {
+ name: "configurable_font_scale_default"
+ namespace: "large_screen_experiences_app_compat"
+ description: "Whether the font_scale is read from a device dependent configuration file"
+ bug: "319808237"
+ is_fixed_read_only: true
+}
\ No newline at end of file
diff --git a/packages/SettingsProvider/test/src/com/android/providers/settings/SettingsStateTest.java b/packages/SettingsProvider/test/src/com/android/providers/settings/SettingsStateTest.java
index 24625ea..e55bbec 100644
--- a/packages/SettingsProvider/test/src/com/android/providers/settings/SettingsStateTest.java
+++ b/packages/SettingsProvider/test/src/com/android/providers/settings/SettingsStateTest.java
@@ -30,6 +30,8 @@
import java.io.File;
import java.io.FileOutputStream;
import java.io.PrintStream;
+import java.util.HashMap;
+import java.util.Map;
public class SettingsStateTest extends AndroidTestCase {
public static final String CRAZY_STRING =
@@ -93,7 +95,6 @@
SettingsState settingsState = new SettingsState(
getContext(), lock, mSettingsFile, configKey,
SettingsState.MAX_BYTES_PER_APP_PACKAGE_UNLIMITED, Looper.getMainLooper());
-
parsed_flags flags = parsed_flags
.newBuilder()
.addParsedFlag(parsed_flag
@@ -117,18 +118,13 @@
.build();
synchronized (lock) {
- settingsState.loadAconfigDefaultValues(flags.toByteArray());
- settingsState.persistSettingsLocked();
- }
- settingsState.waitForHandler();
+ Map<String, Map<String, String>> defaults = new HashMap<>();
+ settingsState.loadAconfigDefaultValues(flags.toByteArray(), defaults);
+ Map<String, String> namespaceDefaults = defaults.get("test_namespace");
+ assertEquals(2, namespaceDefaults.keySet().size());
- synchronized (lock) {
- assertEquals("false",
- settingsState.getSettingLocked(
- "test_namespace/com.android.flags.flag1").getValue());
- assertEquals("true",
- settingsState.getSettingLocked(
- "test_namespace/com.android.flags.flag2").getValue());
+ assertEquals("false", namespaceDefaults.get("test_namespace/com.android.flags.flag1"));
+ assertEquals("true", namespaceDefaults.get("test_namespace/com.android.flags.flag2"));
}
}
@@ -150,21 +146,18 @@
.build();
synchronized (lock) {
- settingsState.loadAconfigDefaultValues(flags.toByteArray());
- settingsState.persistSettingsLocked();
- }
- settingsState.waitForHandler();
+ Map<String, Map<String, String>> defaults = new HashMap<>();
+ settingsState.loadAconfigDefaultValues(flags.toByteArray(), defaults);
- synchronized (lock) {
- assertEquals(null,
- settingsState.getSettingLocked(
- "test_namespace/com.android.flags.flag1").getValue());
+ Map<String, String> namespaceDefaults = defaults.get("test_namespace");
+ assertEquals(null, namespaceDefaults);
}
}
public void testInvalidAconfigProtoDoesNotCrash() {
+ Map<String, Map<String, String>> defaults = new HashMap<>();
SettingsState settingsState = getSettingStateObject();
- settingsState.loadAconfigDefaultValues("invalid protobuf".getBytes());
+ settingsState.loadAconfigDefaultValues("invalid protobuf".getBytes(), defaults);
}
public void testIsBinary() {
diff --git a/packages/Shell/AndroidManifest.xml b/packages/Shell/AndroidManifest.xml
index 507d9c4..f204e48 100644
--- a/packages/Shell/AndroidManifest.xml
+++ b/packages/Shell/AndroidManifest.xml
@@ -891,6 +891,9 @@
<!-- Permission required for Cts test - CtsNotificationTestCases -->
<uses-permission android:name="android.permission.RECEIVE_SENSITIVE_NOTIFICATIONS" />
+ <!-- Permission required for BinaryTransparencyService shell API and host test -->
+ <uses-permission android:name="android.permission.GET_BACKGROUND_INSTALLED_PACKAGES" />
+
<application
android:label="@string/app_label"
android:theme="@android:style/Theme.DeviceDefault.DayNight"
diff --git a/packages/SystemUI/AndroidManifest.xml b/packages/SystemUI/AndroidManifest.xml
index 7443e4c..168e6e0 100644
--- a/packages/SystemUI/AndroidManifest.xml
+++ b/packages/SystemUI/AndroidManifest.xml
@@ -355,6 +355,8 @@
<uses-permission android:name="android.permission.MONITOR_KEYBOARD_BACKLIGHT" />
+ <uses-permission android:name="android.permission.MONITOR_STICKY_MODIFIER_STATE" />
+
<!-- Listen to (dis-)connection of external displays and enable / disable them. -->
<uses-permission android:name="android.permission.MANAGE_DISPLAYS" />
diff --git a/packages/SystemUI/aconfig/accessibility.aconfig b/packages/SystemUI/aconfig/accessibility.aconfig
index f7b1a26..7ba889b 100644
--- a/packages/SystemUI/aconfig/accessibility.aconfig
+++ b/packages/SystemUI/aconfig/accessibility.aconfig
@@ -36,3 +36,10 @@
description: "Animates the floating menu's transition between curved and jagged edges."
bug: "281140482"
}
+
+flag {
+ name: "create_windowless_window_magnifier"
+ namespace: "accessibility"
+ description: "Uses SurfaceControlViewHost to create the magnifier for window magnification."
+ bug: "280992417"
+}
diff --git a/packages/SystemUI/aconfig/systemui.aconfig b/packages/SystemUI/aconfig/systemui.aconfig
index c23a49c..b464498 100644
--- a/packages/SystemUI/aconfig/systemui.aconfig
+++ b/packages/SystemUI/aconfig/systemui.aconfig
@@ -343,3 +343,10 @@
description: "Relocate Smartspace to bottom of the Lock Screen"
bug: "316212788"
}
+
+flag {
+ name: "pin_input_field_styled_focus_state"
+ namespace: "systemui"
+ description: "Enables styled focus states on pin input field if keyboard is connected"
+ bug: "316106516"
+}
diff --git a/packages/SystemUI/compose/features/src/com/android/systemui/communal/ui/compose/CommunalHub.kt b/packages/SystemUI/compose/features/src/com/android/systemui/communal/ui/compose/CommunalHub.kt
index 91a4d2e..c8e18d7 100644
--- a/packages/SystemUI/compose/features/src/com/android/systemui/communal/ui/compose/CommunalHub.kt
+++ b/packages/SystemUI/compose/features/src/com/android/systemui/communal/ui/compose/CommunalHub.kt
@@ -20,6 +20,7 @@
import android.os.Bundle
import android.util.SizeF
import android.widget.FrameLayout
+import androidx.compose.animation.core.animateFloatAsState
import androidx.compose.foundation.BorderStroke
import androidx.compose.foundation.ExperimentalFoundationApi
import androidx.compose.foundation.background
@@ -38,6 +39,7 @@
import androidx.compose.foundation.layout.width
import androidx.compose.foundation.lazy.grid.GridCells
import androidx.compose.foundation.lazy.grid.GridItemSpan
+import androidx.compose.foundation.lazy.grid.LazyGridState
import androidx.compose.foundation.lazy.grid.LazyHorizontalGrid
import androidx.compose.foundation.lazy.grid.rememberLazyGridState
import androidx.compose.foundation.shape.RoundedCornerShape
@@ -58,17 +60,22 @@
import androidx.compose.material3.OutlinedButton
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
+import androidx.compose.runtime.State
import androidx.compose.runtime.collectAsState
+import androidx.compose.runtime.derivedStateOf
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
+import androidx.compose.ui.draw.alpha
import androidx.compose.ui.geometry.Offset
import androidx.compose.ui.graphics.Color
+import androidx.compose.ui.graphics.graphicsLayer
import androidx.compose.ui.input.pointer.pointerInput
import androidx.compose.ui.layout.LayoutCoordinates
+import androidx.compose.ui.layout.boundsInWindow
import androidx.compose.ui.layout.onGloballyPositioned
import androidx.compose.ui.layout.onSizeChanged
import androidx.compose.ui.layout.positionInWindow
@@ -86,6 +93,9 @@
import com.android.compose.theme.LocalAndroidColorScheme
import com.android.systemui.communal.domain.model.CommunalContentModel
import com.android.systemui.communal.shared.model.CommunalContentSize
+import com.android.systemui.communal.ui.compose.extensions.allowGestures
+import com.android.systemui.communal.ui.compose.extensions.firstItemAtOffset
+import com.android.systemui.communal.ui.compose.extensions.observeTapsWithoutConsuming
import com.android.systemui.communal.ui.viewmodel.BaseCommunalViewModel
import com.android.systemui.communal.ui.viewmodel.CommunalEditModeViewModel
import com.android.systemui.res.R
@@ -104,22 +114,59 @@
var toolbarSize: IntSize? by remember { mutableStateOf(null) }
var gridCoordinates: LayoutCoordinates? by remember { mutableStateOf(null) }
var isDraggingToRemove by remember { mutableStateOf(false) }
+ val gridState = rememberLazyGridState()
+ val contentListState = rememberContentListState(communalContent, viewModel)
+ val reorderingWidgets by viewModel.reorderingWidgets.collectAsState()
+ val selectedIndex = viewModel.selectedIndex.collectAsState()
+ val removeButtonEnabled by remember {
+ derivedStateOf { selectedIndex.value != null || reorderingWidgets }
+ }
+
+ val contentPadding = gridContentPadding(viewModel.isEditMode, toolbarSize)
+ val contentOffset = beforeContentPadding(contentPadding).toOffset()
Box(
modifier =
- modifier.fillMaxSize().background(LocalAndroidColorScheme.current.outlineVariant),
+ modifier
+ .fillMaxSize()
+ .background(LocalAndroidColorScheme.current.outlineVariant)
+ .pointerInput(gridState, contentOffset, contentListState) {
+ // If not in edit mode, don't allow selecting items.
+ if (!viewModel.isEditMode) return@pointerInput
+ observeTapsWithoutConsuming { offset ->
+ val adjustedOffset = offset - contentOffset
+ val index =
+ gridState.layoutInfo.visibleItemsInfo
+ .firstItemAtOffset(adjustedOffset)
+ ?.index
+ val newIndex =
+ if (index?.let(contentListState::isItemEditable) == true) {
+ index
+ } else {
+ null
+ }
+ viewModel.setSelectedIndex(newIndex)
+ }
+ },
) {
CommunalHubLazyGrid(
communalContent = communalContent,
viewModel = viewModel,
- contentPadding = gridContentPadding(viewModel.isEditMode, toolbarSize),
+ contentPadding = contentPadding,
+ contentOffset = contentOffset,
setGridCoordinates = { gridCoordinates = it },
- updateDragPositionForRemove = {
+ updateDragPositionForRemove = { offset ->
isDraggingToRemove =
- checkForDraggingToRemove(it, removeButtonCoordinates, gridCoordinates)
+ isPointerWithinCoordinates(
+ offset = gridCoordinates?.let { it.positionInWindow() + offset },
+ containerToCheck = removeButtonCoordinates
+ )
isDraggingToRemove
},
onOpenWidgetPicker = onOpenWidgetPicker,
+ gridState = gridState,
+ contentListState = contentListState,
+ selectedIndex = selectedIndex
)
if (viewModel.isEditMode && onOpenWidgetPicker != null && onEditDone != null) {
@@ -129,6 +176,14 @@
setRemoveButtonCoordinates = { removeButtonCoordinates = it },
onEditDone = onEditDone,
onOpenWidgetPicker = onOpenWidgetPicker,
+ onRemoveClicked = {
+ selectedIndex.value?.let { index ->
+ contentListState.onRemove(index)
+ contentListState.onSaveList()
+ viewModel.setSelectedIndex(null)
+ }
+ },
+ removeEnabled = removeButtonEnabled
)
} else {
IconButton(onClick = viewModel::onOpenWidgetEditor) {
@@ -158,16 +213,18 @@
communalContent: List<CommunalContentModel>,
viewModel: BaseCommunalViewModel,
contentPadding: PaddingValues,
+ selectedIndex: State<Int?>,
+ contentOffset: Offset,
+ gridState: LazyGridState,
+ contentListState: ContentListState,
setGridCoordinates: (coordinates: LayoutCoordinates) -> Unit,
updateDragPositionForRemove: (offset: Offset) -> Boolean,
onOpenWidgetPicker: (() -> Unit)? = null,
) {
var gridModifier = Modifier.align(Alignment.CenterStart)
- val gridState = rememberLazyGridState()
var list = communalContent
var dragDropState: GridDragDropState? = null
if (viewModel.isEditMode && viewModel is CommunalEditModeViewModel) {
- val contentListState = rememberContentListState(list, viewModel)
list = contentListState.list
// for drag & drop operations within the communal hub grid
dragDropState =
@@ -179,7 +236,7 @@
gridModifier =
gridModifier
.fillMaxSize()
- .dragContainer(dragDropState, beforeContentPadding(contentPadding), viewModel)
+ .dragContainer(dragDropState, contentOffset, viewModel)
.onGloballyPositioned { setGridCoordinates(it) }
// for widgets dropped from other activities
val dragAndDropTargetState =
@@ -218,8 +275,10 @@
list[index].size.dp().value,
)
if (viewModel.isEditMode && dragDropState != null) {
+ val selected by remember(index) { derivedStateOf { index == selectedIndex.value } }
DraggableItem(
dragDropState = dragDropState,
+ selected = selected,
enabled = list[index] is CommunalContentModel.Widget,
index = index,
size = size
@@ -253,11 +312,19 @@
@Composable
private fun Toolbar(
isDraggingToRemove: Boolean,
+ removeEnabled: Boolean,
+ onRemoveClicked: () -> Unit,
setToolbarSize: (toolbarSize: IntSize) -> Unit,
setRemoveButtonCoordinates: (coordinates: LayoutCoordinates) -> Unit,
onOpenWidgetPicker: () -> Unit,
- onEditDone: () -> Unit,
+ onEditDone: () -> Unit
) {
+ val removeButtonAlpha: Float by
+ animateFloatAsState(
+ targetValue = if (removeEnabled) 1f else 0.5f,
+ label = "RemoveButtonAlphaAnimation"
+ )
+
Row(
modifier =
Modifier.fillMaxWidth()
@@ -301,13 +368,18 @@
}
} else {
OutlinedButton(
- // Button is disabled to make it non-clickable
- enabled = false,
- onClick = {},
- colors = ButtonDefaults.outlinedButtonColors(disabledContentColor = colors.primary),
+ enabled = removeEnabled,
+ onClick = onRemoveClicked,
+ colors =
+ ButtonDefaults.outlinedButtonColors(
+ contentColor = colors.primary,
+ disabledContentColor = colors.primary
+ ),
border = BorderStroke(width = 1.0.dp, color = colors.primary),
contentPadding = Dimensions.ButtonPadding,
- modifier = Modifier.onGloballyPositioned { setRemoveButtonCoordinates(it) }
+ modifier =
+ Modifier.graphicsLayer { alpha = removeButtonAlpha }
+ .onGloballyPositioned { setRemoveButtonCoordinates(it) }
) {
RemoveButtonContent(spacerModifier)
}
@@ -385,7 +457,7 @@
) {
when (model) {
is CommunalContentModel.Widget -> WidgetContent(viewModel, model, size, modifier)
- is CommunalContentModel.WidgetPlaceholder -> WidgetPlaceholderContent(size)
+ is CommunalContentModel.WidgetPlaceholder -> HighlightedItem(size)
is CommunalContentModel.CtaTileInViewMode ->
CtaTileInViewModeContent(viewModel, size, modifier)
is CommunalContentModel.CtaTileInEditMode ->
@@ -396,11 +468,11 @@
}
}
-/** Presents a placeholder card for the new widget being dragged and dropping into the grid. */
+/** Creates an empty card used to highlight a particular spot on the grid. */
@Composable
-fun WidgetPlaceholderContent(size: SizeF) {
+fun HighlightedItem(size: SizeF, modifier: Modifier = Modifier) {
Card(
- modifier = Modifier.size(Dp(size.width), Dp(size.height)),
+ modifier = modifier.size(Dp(size.width), Dp(size.height)),
colors = CardDefaults.cardColors(containerColor = Color.Transparent),
border = BorderStroke(3.dp, LocalAndroidColorScheme.current.tertiaryFixed),
shape = RoundedCornerShape(16.dp)
@@ -528,7 +600,7 @@
contentAlignment = Alignment.Center,
) {
AndroidView(
- modifier = modifier,
+ modifier = modifier.allowGestures(allowed = !viewModel.isEditMode),
factory = { context ->
// The AppWidgetHostView will inherit the interaction handler from the
// AppWidgetHost. So set the interaction handler here before creating the view, and
@@ -616,8 +688,8 @@
private fun beforeContentPadding(paddingValues: PaddingValues): ContentPaddingInPx {
return with(LocalDensity.current) {
ContentPaddingInPx(
- startPadding = paddingValues.calculateLeftPadding(LayoutDirection.Ltr).toPx(),
- topPadding = paddingValues.calculateTopPadding().toPx()
+ start = paddingValues.calculateLeftPadding(LayoutDirection.Ltr).toPx(),
+ top = paddingValues.calculateTopPadding().toPx()
)
}
}
@@ -626,18 +698,15 @@
* Check whether the pointer position that the item is being dragged at is within the coordinates of
* the remove button in the toolbar. Returns true if the item is removable.
*/
-private fun checkForDraggingToRemove(
- offset: Offset,
- removeButtonCoordinates: LayoutCoordinates?,
- gridCoordinates: LayoutCoordinates?,
+private fun isPointerWithinCoordinates(
+ offset: Offset?,
+ containerToCheck: LayoutCoordinates?
): Boolean {
- if (removeButtonCoordinates == null || gridCoordinates == null) {
+ if (offset == null || containerToCheck == null) {
return false
}
- val pointer = gridCoordinates.positionInWindow() + offset
- val removeButton = removeButtonCoordinates.positionInWindow()
- return pointer.x in removeButton.x..removeButton.x + removeButtonCoordinates.size.width &&
- pointer.y in removeButton.y..removeButton.y + removeButtonCoordinates.size.height
+ val container = containerToCheck.boundsInWindow()
+ return container.contains(offset)
}
private fun CommunalContentSize.dp(): Dp {
@@ -648,7 +717,9 @@
}
}
-data class ContentPaddingInPx(val startPadding: Float, val topPadding: Float)
+data class ContentPaddingInPx(val start: Float, val top: Float) {
+ fun toOffset(): Offset = Offset(start, top)
+}
object Dimensions {
val CardWidth = 464.dp
diff --git a/packages/SystemUI/compose/features/src/com/android/systemui/communal/ui/compose/ContentListState.kt b/packages/SystemUI/compose/features/src/com/android/systemui/communal/ui/compose/ContentListState.kt
index 979991d..45f98b8 100644
--- a/packages/SystemUI/compose/features/src/com/android/systemui/communal/ui/compose/ContentListState.kt
+++ b/packages/SystemUI/compose/features/src/com/android/systemui/communal/ui/compose/ContentListState.kt
@@ -21,12 +21,12 @@
import androidx.compose.runtime.remember
import androidx.compose.runtime.toMutableStateList
import com.android.systemui.communal.domain.model.CommunalContentModel
-import com.android.systemui.communal.ui.viewmodel.CommunalEditModeViewModel
+import com.android.systemui.communal.ui.viewmodel.BaseCommunalViewModel
@Composable
fun rememberContentListState(
communalContent: List<CommunalContentModel>,
- viewModel: CommunalEditModeViewModel,
+ viewModel: BaseCommunalViewModel,
): ContentListState {
return remember(communalContent) {
ContentListState(
diff --git a/packages/SystemUI/compose/features/src/com/android/systemui/communal/ui/compose/GridDragDropState.kt b/packages/SystemUI/compose/features/src/com/android/systemui/communal/ui/compose/GridDragDropState.kt
index 1138221..a195953 100644
--- a/packages/SystemUI/compose/features/src/com/android/systemui/communal/ui/compose/GridDragDropState.kt
+++ b/packages/SystemUI/compose/features/src/com/android/systemui/communal/ui/compose/GridDragDropState.kt
@@ -17,6 +17,10 @@
package com.android.systemui.communal.ui.compose
import android.util.SizeF
+import androidx.compose.animation.AnimatedVisibility
+import androidx.compose.animation.core.animateFloatAsState
+import androidx.compose.animation.fadeIn
+import androidx.compose.animation.fadeOut
import androidx.compose.foundation.ExperimentalFoundationApi
import androidx.compose.foundation.gestures.detectDragGesturesAfterLongPress
import androidx.compose.foundation.gestures.scrollBy
@@ -32,6 +36,7 @@
import androidx.compose.runtime.rememberCoroutineScope
import androidx.compose.runtime.setValue
import androidx.compose.ui.Modifier
+import androidx.compose.ui.draw.alpha
import androidx.compose.ui.geometry.Offset
import androidx.compose.ui.graphics.graphicsLayer
import androidx.compose.ui.input.pointer.pointerInput
@@ -39,6 +44,7 @@
import androidx.compose.ui.unit.toOffset
import androidx.compose.ui.unit.toSize
import androidx.compose.ui.zIndex
+import com.android.systemui.communal.ui.compose.extensions.firstItemAtOffset
import com.android.systemui.communal.ui.compose.extensions.plus
import com.android.systemui.communal.ui.viewmodel.BaseCommunalViewModel
import kotlinx.coroutines.CoroutineScope
@@ -109,13 +115,10 @@
internal fun onDragStart(offset: Offset, contentOffset: Offset) {
state.layoutInfo.visibleItemsInfo
- .firstOrNull { item ->
- // grid item offset is based off grid content container so we need to deduct
- // before content padding from the initial pointer position
- contentListState.isItemEditable(item.index) &&
- (offset.x - contentOffset.x).toInt() in item.offset.x..item.offsetEnd.x &&
- (offset.y - contentOffset.y).toInt() in item.offset.y..item.offsetEnd.y
- }
+ .filter { item -> contentListState.isItemEditable(item.index) }
+ // grid item offset is based off grid content container so we need to deduct
+ // before content padding from the initial pointer position
+ .firstItemAtOffset(offset - contentOffset)
?.apply {
dragStartPointerOffset = offset - this.offset.toOffset()
draggingItemIndex = index
@@ -148,12 +151,11 @@
val middleOffset = startOffset + (endOffset - startOffset) / 2f
val targetItem =
- state.layoutInfo.visibleItemsInfo.find { item ->
- contentListState.isItemEditable(item.index) &&
- middleOffset.x.toInt() in item.offset.x..item.offsetEnd.x &&
- middleOffset.y.toInt() in item.offset.y..item.offsetEnd.y &&
- draggingItem.index != item.index
- }
+ state.layoutInfo.visibleItemsInfo
+ .asSequence()
+ .filter { item -> contentListState.isItemEditable(item.index) }
+ .filter { item -> draggingItem.index != item.index }
+ .firstItemAtOffset(middleOffset)
if (targetItem != null) {
val scrollToIndex =
@@ -208,32 +210,31 @@
fun Modifier.dragContainer(
dragDropState: GridDragDropState,
- beforeContentPadding: ContentPaddingInPx,
+ contentOffset: Offset,
viewModel: BaseCommunalViewModel,
): Modifier {
- return pointerInput(dragDropState, beforeContentPadding) {
- detectDragGesturesAfterLongPress(
- onDrag = { change, offset ->
- change.consume()
- dragDropState.onDrag(offset = offset)
- },
- onDragStart = { offset ->
- dragDropState.onDragStart(
- offset,
- Offset(beforeContentPadding.startPadding, beforeContentPadding.topPadding)
- )
- viewModel.onReorderWidgetStart()
- },
- onDragEnd = {
- dragDropState.onDragInterrupted()
- viewModel.onReorderWidgetEnd()
- },
- onDragCancel = {
- dragDropState.onDragInterrupted()
- viewModel.onReorderWidgetCancel()
- }
- )
- }
+ return this.then(
+ pointerInput(dragDropState, contentOffset) {
+ detectDragGesturesAfterLongPress(
+ onDrag = { change, offset ->
+ change.consume()
+ dragDropState.onDrag(offset = offset)
+ },
+ onDragStart = { offset ->
+ dragDropState.onDragStart(offset, contentOffset)
+ viewModel.onReorderWidgetStart()
+ },
+ onDragEnd = {
+ dragDropState.onDragInterrupted()
+ viewModel.onReorderWidgetEnd()
+ },
+ onDragCancel = {
+ dragDropState.onDragInterrupted()
+ viewModel.onReorderWidgetCancel()
+ }
+ )
+ }
+ )
}
/** Wrap LazyGrid item with additional modifier needed for drag and drop. */
@@ -243,6 +244,7 @@
dragDropState: GridDragDropState,
index: Int,
enabled: Boolean,
+ selected: Boolean,
size: SizeF,
modifier: Modifier = Modifier,
content: @Composable (isDragging: Boolean) -> Unit
@@ -250,21 +252,31 @@
if (!enabled) {
return Box(modifier = modifier) { content(false) }
}
+
val dragging = index == dragDropState.draggingItemIndex
+ val itemAlpha: Float by
+ animateFloatAsState(
+ targetValue = if (dragDropState.isDraggingToRemove) 0.5f else 1f,
+ label = "DraggableItemAlpha"
+ )
val draggingModifier =
if (dragging) {
Modifier.zIndex(1f).graphicsLayer {
translationX = dragDropState.draggingItemOffset.x
translationY = dragDropState.draggingItemOffset.y
- alpha = if (dragDropState.isDraggingToRemove) 0.5f else 1f
+ alpha = itemAlpha
}
} else {
Modifier.animateItemPlacement()
}
Box(modifier) {
- if (dragging) {
- WidgetPlaceholderContent(size)
+ AnimatedVisibility(
+ visible = (dragging || selected) && !dragDropState.isDraggingToRemove,
+ enter = fadeIn(),
+ exit = fadeOut()
+ ) {
+ HighlightedItem(size)
}
Box(modifier = draggingModifier, propagateMinConstraints = true) { content(dragging) }
}
diff --git a/packages/SystemUI/compose/features/src/com/android/systemui/communal/ui/compose/extensions/LazyGridStateExt.kt b/packages/SystemUI/compose/features/src/com/android/systemui/communal/ui/compose/extensions/LazyGridStateExt.kt
new file mode 100644
index 0000000..132093f
--- /dev/null
+++ b/packages/SystemUI/compose/features/src/com/android/systemui/communal/ui/compose/extensions/LazyGridStateExt.kt
@@ -0,0 +1,47 @@
+/*
+ * 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.communal.ui.compose.extensions
+
+import androidx.compose.foundation.lazy.grid.LazyGridItemInfo
+import androidx.compose.ui.geometry.Offset
+import androidx.compose.ui.unit.IntRect
+import androidx.compose.ui.unit.toRect
+
+/**
+ * Determine the item at the specified offset, or null if none exist.
+ *
+ * @param offset The offset in pixels, relative to the top start of the grid.
+ */
+fun Iterable<LazyGridItemInfo>.firstItemAtOffset(offset: Offset): LazyGridItemInfo? =
+ firstOrNull { item ->
+ isItemAtOffset(item, offset)
+ }
+
+/**
+ * Determine the item at the specified offset, or null if none exist.
+ *
+ * @param offset The offset in pixels, relative to the top start of the grid.
+ */
+fun Sequence<LazyGridItemInfo>.firstItemAtOffset(offset: Offset): LazyGridItemInfo? =
+ firstOrNull { item ->
+ isItemAtOffset(item, offset)
+ }
+
+private fun isItemAtOffset(item: LazyGridItemInfo, offset: Offset): Boolean {
+ val boundingBox = IntRect(item.offset, item.size)
+ return boundingBox.toRect().contains(offset)
+}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/pipeline/dagger/OemSatelliteInputLog.kt b/packages/SystemUI/compose/features/src/com/android/systemui/communal/ui/compose/extensions/ModifierExt.kt
similarity index 60%
copy from packages/SystemUI/src/com/android/systemui/statusbar/pipeline/dagger/OemSatelliteInputLog.kt
copy to packages/SystemUI/compose/features/src/com/android/systemui/communal/ui/compose/extensions/ModifierExt.kt
index 252945f..b31008e 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/pipeline/dagger/OemSatelliteInputLog.kt
+++ b/packages/SystemUI/compose/features/src/com/android/systemui/communal/ui/compose/extensions/ModifierExt.kt
@@ -14,13 +14,15 @@
* limitations under the License.
*/
-package com.android.systemui.statusbar.pipeline.dagger
+package com.android.systemui.communal.ui.compose.extensions
-import com.android.systemui.statusbar.pipeline.satellite.data.DeviceBasedSatelliteRepository
-import javax.inject.Qualifier
+import androidx.compose.ui.Modifier
+import androidx.compose.ui.input.pointer.pointerInput
-/** Detailed [DeviceBasedSatelliteRepository] logs */
-@Qualifier
-@MustBeDocumented
-@kotlin.annotation.Retention(AnnotationRetention.RUNTIME)
-annotation class OemSatelliteInputLog
+/** Sets whether gestures are allowed on children of this element. */
+fun Modifier.allowGestures(allowed: Boolean): Modifier =
+ if (allowed) {
+ this
+ } else {
+ this.then(pointerInput(Unit) { consumeAllGestures() })
+ }
diff --git a/packages/SystemUI/compose/features/src/com/android/systemui/communal/ui/compose/extensions/PointerInputScopeExt.kt b/packages/SystemUI/compose/features/src/com/android/systemui/communal/ui/compose/extensions/PointerInputScopeExt.kt
new file mode 100644
index 0000000..1407494
--- /dev/null
+++ b/packages/SystemUI/compose/features/src/com/android/systemui/communal/ui/compose/extensions/PointerInputScopeExt.kt
@@ -0,0 +1,54 @@
+/*
+ * 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.communal.ui.compose.extensions
+
+import androidx.compose.foundation.gestures.awaitEachGesture
+import androidx.compose.foundation.gestures.awaitFirstDown
+import androidx.compose.foundation.gestures.waitForUpOrCancellation
+import androidx.compose.ui.geometry.Offset
+import androidx.compose.ui.input.pointer.PointerEventPass
+import androidx.compose.ui.input.pointer.PointerInputChange
+import androidx.compose.ui.input.pointer.PointerInputScope
+import kotlinx.coroutines.coroutineScope
+
+/**
+ * Observe taps without actually consuming them, so child elements can still respond to them. Long
+ * presses are excluded.
+ */
+suspend fun PointerInputScope.observeTapsWithoutConsuming(
+ pass: PointerEventPass = PointerEventPass.Initial,
+ onTap: ((Offset) -> Unit)? = null,
+) = coroutineScope {
+ if (onTap == null) return@coroutineScope
+ awaitEachGesture {
+ awaitFirstDown(pass = pass)
+ val tapTimeout = viewConfiguration.longPressTimeoutMillis
+ val up = withTimeoutOrNull(tapTimeout) { waitForUpOrCancellation(pass = pass) }
+ if (up != null) {
+ onTap(up.position)
+ }
+ }
+}
+
+/** Consume all gestures on the initial pass so that child elements do not receive them. */
+suspend fun PointerInputScope.consumeAllGestures() = coroutineScope {
+ awaitEachGesture {
+ awaitPointerEvent(pass = PointerEventPass.Initial)
+ .changes
+ .forEach(PointerInputChange::consume)
+ }
+}
diff --git a/packages/SystemUI/compose/features/src/com/android/systemui/keyguard/ui/composable/section/NotificationSection.kt b/packages/SystemUI/compose/features/src/com/android/systemui/keyguard/ui/composable/section/NotificationSection.kt
index 900616f..42fcd13 100644
--- a/packages/SystemUI/compose/features/src/com/android/systemui/keyguard/ui/composable/section/NotificationSection.kt
+++ b/packages/SystemUI/compose/features/src/com/android/systemui/keyguard/ui/composable/section/NotificationSection.kt
@@ -16,23 +16,55 @@
package com.android.systemui.keyguard.ui.composable.section
+import android.content.Context
+import android.view.ViewGroup
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import com.android.compose.animation.scene.SceneScope
+import com.android.systemui.dagger.qualifiers.Application
import com.android.systemui.notifications.ui.composable.NotificationStack
+import com.android.systemui.scene.shared.flag.SceneContainerFlags
+import com.android.systemui.statusbar.notification.stack.AmbientState
+import com.android.systemui.statusbar.notification.stack.NotificationStackScrollLayout
+import com.android.systemui.statusbar.notification.stack.NotificationStackScrollLayoutController
+import com.android.systemui.statusbar.notification.stack.shared.flexiNotifsEnabled
+import com.android.systemui.statusbar.notification.stack.ui.view.SharedNotificationContainer
+import com.android.systemui.statusbar.notification.stack.ui.viewbinder.NotificationStackAppearanceViewBinder
+import com.android.systemui.statusbar.notification.stack.ui.viewmodel.NotificationStackAppearanceViewModel
import com.android.systemui.statusbar.notification.stack.ui.viewmodel.NotificationsPlaceholderViewModel
import javax.inject.Inject
class NotificationSection
@Inject
constructor(
+ @Application context: Context,
private val viewModel: NotificationsPlaceholderViewModel,
+ controller: NotificationStackScrollLayoutController,
+ sceneContainerFlags: SceneContainerFlags,
+ sharedNotificationContainer: SharedNotificationContainer,
+ stackScrollLayout: NotificationStackScrollLayout,
+ notificationStackAppearanceViewModel: NotificationStackAppearanceViewModel,
+ ambientState: AmbientState,
) {
+ init {
+ if (sceneContainerFlags.flexiNotifsEnabled()) {
+ (stackScrollLayout.parent as? ViewGroup)?.removeView(stackScrollLayout)
+ sharedNotificationContainer.addNotificationStackScrollLayout(stackScrollLayout)
+
+ NotificationStackAppearanceViewBinder.bind(
+ context,
+ sharedNotificationContainer,
+ notificationStackAppearanceViewModel,
+ ambientState,
+ controller,
+ )
+ }
+ }
+
@Composable
fun SceneScope.Notifications(modifier: Modifier = Modifier) {
NotificationStack(
viewModel = viewModel,
- isScrimVisible = false,
modifier = modifier,
)
}
diff --git a/packages/SystemUI/compose/features/src/com/android/systemui/notifications/ui/composable/Notifications.kt b/packages/SystemUI/compose/features/src/com/android/systemui/notifications/ui/composable/Notifications.kt
index 0b26ae9..e835d3e 100644
--- a/packages/SystemUI/compose/features/src/com/android/systemui/notifications/ui/composable/Notifications.kt
+++ b/packages/SystemUI/compose/features/src/com/android/systemui/notifications/ui/composable/Notifications.kt
@@ -22,6 +22,7 @@
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
+import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material3.MaterialTheme
@@ -43,8 +44,10 @@
import androidx.compose.ui.unit.dp
import com.android.compose.animation.scene.ElementKey
import com.android.compose.animation.scene.SceneScope
+import com.android.compose.modifiers.height
import com.android.systemui.notifications.ui.composable.Notifications.Form
import com.android.systemui.statusbar.notification.stack.ui.viewmodel.NotificationsPlaceholderViewModel
+import kotlin.math.roundToInt
object Notifications {
object Elements {
@@ -77,32 +80,52 @@
)
}
-/** Adds the space where notification stack will appear in the scene. */
+/** Adds the space where notification stack should appear in the scene. */
@Composable
fun SceneScope.NotificationStack(
viewModel: NotificationsPlaceholderViewModel,
- isScrimVisible: Boolean,
+ modifier: Modifier = Modifier,
+) {
+ NotificationPlaceholder(
+ viewModel = viewModel,
+ form = Form.Stack,
+ modifier = modifier,
+ )
+}
+
+/**
+ * Adds the space where notification stack should appear in the scene, with a scrim and nested
+ * scrolling.
+ */
+@Composable
+fun SceneScope.NotificationScrollingStack(
+ viewModel: NotificationsPlaceholderViewModel,
modifier: Modifier = Modifier,
) {
val cornerRadius by viewModel.cornerRadiusDp.collectAsState()
- Box(modifier = modifier) {
- if (isScrimVisible) {
- Box(
- modifier =
- Modifier.element(Notifications.Elements.NotificationScrim)
- .fillMaxSize()
- .graphicsLayer {
- shape = RoundedCornerShape(cornerRadius.dp)
- clip = true
- }
- .background(MaterialTheme.colorScheme.surface)
- )
- }
+ val contentHeight by viewModel.intrinsicContentHeight.collectAsState()
+
+ val expansionFraction by viewModel.expandFraction.collectAsState(0f)
+
+ Box(
+ modifier =
+ modifier
+ .verticalNestedScrollToScene()
+ .fillMaxWidth()
+ .element(Notifications.Elements.NotificationScrim)
+ .graphicsLayer {
+ shape = RoundedCornerShape(cornerRadius.dp)
+ clip = true
+ alpha = expansionFraction
+ }
+ .background(MaterialTheme.colorScheme.surface)
+ .debugBackground(viewModel, Color(0.5f, 0.5f, 0f, 0.2f))
+ ) {
NotificationPlaceholder(
viewModel = viewModel,
form = Form.Stack,
- modifier = Modifier.fillMaxSize(),
+ modifier = Modifier.fillMaxWidth().height { contentHeight.roundToInt() }
)
}
}
@@ -159,6 +182,7 @@
debugLog(viewModel) { "STACK onSizeChanged: size=$size" }
}
.onPlaced { coordinates: LayoutCoordinates ->
+ viewModel.onContentTopChanged(coordinates.positionInWindow().y)
debugLog(viewModel) {
"STACK onPlaced:" +
" size=${coordinates.size}" +
diff --git a/packages/SystemUI/compose/features/src/com/android/systemui/scene/ui/composable/GoneScene.kt b/packages/SystemUI/compose/features/src/com/android/systemui/scene/ui/composable/GoneScene.kt
index bded98d..747faab 100644
--- a/packages/SystemUI/compose/features/src/com/android/systemui/scene/ui/composable/GoneScene.kt
+++ b/packages/SystemUI/compose/features/src/com/android/systemui/scene/ui/composable/GoneScene.kt
@@ -25,6 +25,7 @@
import com.android.compose.animation.scene.SceneScope
import com.android.systemui.dagger.SysUISingleton
import com.android.systemui.notifications.ui.composable.HeadsUpNotificationSpace
+import com.android.systemui.notifications.ui.composable.Notifications
import com.android.systemui.scene.shared.model.Direction
import com.android.systemui.scene.shared.model.Edge
import com.android.systemui.scene.shared.model.SceneKey
@@ -66,6 +67,7 @@
modifier: Modifier,
) {
Box(modifier = modifier) {
+ Box(modifier = Modifier.fillMaxSize().element(Notifications.Elements.NotificationScrim))
HeadsUpNotificationSpace(
viewModel = notificationsViewModel,
modifier = Modifier.padding(16.dp).fillMaxSize(),
diff --git a/packages/SystemUI/compose/features/src/com/android/systemui/scene/ui/composable/transitions/FromGoneToShadeTransition.kt b/packages/SystemUI/compose/features/src/com/android/systemui/scene/ui/composable/transitions/FromGoneToShadeTransition.kt
index 6bb525a..0c2c519 100644
--- a/packages/SystemUI/compose/features/src/com/android/systemui/scene/ui/composable/transitions/FromGoneToShadeTransition.kt
+++ b/packages/SystemUI/compose/features/src/com/android/systemui/scene/ui/composable/transitions/FromGoneToShadeTransition.kt
@@ -3,12 +3,12 @@
import androidx.compose.animation.core.tween
import com.android.compose.animation.scene.Edge
import com.android.compose.animation.scene.TransitionBuilder
-import com.android.systemui.notifications.ui.composable.Notifications
-import com.android.systemui.scene.ui.composable.Shade
+import com.android.systemui.qs.ui.composable.QuickSettings
+import com.android.systemui.shade.ui.composable.ShadeHeader
fun TransitionBuilder.goneToShadeTransition() {
spec = tween(durationMillis = 500)
- translate(Shade.rootElementKey, Edge.Top, true)
- fade(Notifications.Elements.NotificationScrim)
+ fractionRange(start = .58f) { fade(ShadeHeader.Elements.CollapsedContent) }
+ translate(QuickSettings.Elements.Content, Edge.Top, true)
}
diff --git a/packages/SystemUI/compose/features/src/com/android/systemui/shade/ui/composable/ShadeScene.kt b/packages/SystemUI/compose/features/src/com/android/systemui/shade/ui/composable/ShadeScene.kt
index 9c0f1fe..085dcf4 100644
--- a/packages/SystemUI/compose/features/src/com/android/systemui/shade/ui/composable/ShadeScene.kt
+++ b/packages/SystemUI/compose/features/src/com/android/systemui/shade/ui/composable/ShadeScene.kt
@@ -22,11 +22,9 @@
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Spacer
-import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
-import androidx.compose.foundation.layout.wrapContentHeight
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material3.MaterialTheme
import androidx.compose.runtime.Composable
@@ -47,7 +45,7 @@
import com.android.systemui.media.controls.ui.MediaHost
import com.android.systemui.media.controls.ui.composable.MediaCarousel
import com.android.systemui.media.dagger.MediaModule.QUICK_QS_PANEL
-import com.android.systemui.notifications.ui.composable.NotificationStack
+import com.android.systemui.notifications.ui.composable.NotificationScrollingStack
import com.android.systemui.qs.ui.composable.QuickSettings
import com.android.systemui.res.R
import com.android.systemui.scene.shared.model.Direction
@@ -148,35 +146,27 @@
mediaHost: MediaHost,
modifier: Modifier = Modifier,
) {
+ val localDensity = LocalDensity.current
val layoutWidth = remember { mutableStateOf(0) }
- Box(modifier.element(Shade.Elements.Scrim)) {
- Spacer(
- modifier =
- Modifier.element(Shade.Elements.ScrimBackground)
- .fillMaxSize()
- .background(MaterialTheme.colorScheme.scrim, shape = Shade.Shapes.Scrim)
- )
+ Box(
+ modifier =
+ modifier.element(Shade.Elements.Scrim).background(MaterialTheme.colorScheme.scrim),
+ )
+ Box {
Column(
horizontalAlignment = Alignment.CenterHorizontally,
- modifier =
- Modifier.fillMaxSize()
- .clickable(onClick = { viewModel.onContentClicked() })
- .padding(
- start = Shade.Dimensions.HorizontalPadding,
- end = Shade.Dimensions.HorizontalPadding,
- bottom = 48.dp
- )
+ modifier = Modifier.fillMaxWidth().clickable(onClick = { viewModel.onContentClicked() })
) {
CollapsedShadeHeader(
viewModel = viewModel.shadeHeaderViewModel,
createTintedIconManager = createTintedIconManager,
createBatteryMeterViewController = createBatteryMeterViewController,
statusBarIconController = statusBarIconController,
+ modifier = Modifier.padding(horizontal = Shade.Dimensions.HorizontalPadding)
)
- Spacer(modifier = Modifier.height(16.dp))
QuickSettings(
- modifier = Modifier.wrapContentHeight(),
+ modifier = Modifier.height(130.dp),
viewModel.qsSceneAdapter,
)
@@ -202,16 +192,15 @@
},
mediaHost = mediaHost,
layoutWidth = layoutWidth.value,
- layoutHeight = with(LocalDensity.current) { mediaHeight.toPx() }.toInt(),
+ layoutHeight = with(localDensity) { mediaHeight.toPx() }.toInt(),
carouselController = mediaCarouselController,
)
}
Spacer(modifier = Modifier.height(16.dp))
- NotificationStack(
+ NotificationScrollingStack(
viewModel = viewModel.notifications,
- isScrimVisible = true,
- modifier = Modifier.weight(1f),
+ modifier = Modifier.fillMaxWidth().weight(1f),
)
}
}
diff --git a/packages/SystemUI/compose/features/tests/AndroidManifest.xml b/packages/SystemUI/compose/features/tests/AndroidManifest.xml
index 8fe9656..fc337fb 100644
--- a/packages/SystemUI/compose/features/tests/AndroidManifest.xml
+++ b/packages/SystemUI/compose/features/tests/AndroidManifest.xml
@@ -30,11 +30,6 @@
android:enabled="false"
tools:replace="android:authorities"
tools:node="remove" />
- <provider android:name="com.google.android.systemui.keyguard.KeyguardSliceProviderGoogle"
- android:authorities="com.android.systemui.test.keyguard.disabled"
- android:enabled="false"
- tools:replace="android:authorities"
- tools:node="remove" />
<provider android:name="com.android.systemui.keyguard.CustomizationProvider"
android:authorities="com.android.systemui.test.keyguard.quickaffordance.disabled"
android:enabled="false"
diff --git a/packages/SystemUI/multivalentTests/src/com/android/keyguard/KeyguardPinBasedInputViewControllerTest.java b/packages/SystemUI/multivalentTests/src/com/android/keyguard/KeyguardPinBasedInputViewControllerTest.java
index e893169..c4bcb53 100644
--- a/packages/SystemUI/multivalentTests/src/com/android/keyguard/KeyguardPinBasedInputViewControllerTest.java
+++ b/packages/SystemUI/multivalentTests/src/com/android/keyguard/KeyguardPinBasedInputViewControllerTest.java
@@ -35,6 +35,7 @@
import com.android.systemui.classifier.FalsingCollector;
import com.android.systemui.classifier.FalsingCollectorFake;
import com.android.systemui.flags.FakeFeatureFlags;
+import com.android.systemui.keyboard.data.repository.FakeKeyboardRepository;
import com.android.systemui.res.R;
import com.android.systemui.user.domain.interactor.SelectedUserInteractor;
@@ -107,7 +108,7 @@
mKeyguardUpdateMonitor, mSecurityMode, mLockPatternUtils, mKeyguardSecurityCallback,
mKeyguardMessageAreaControllerFactory, mLatencyTracker, mLiftToactivateListener,
mEmergencyButtonController, mFalsingCollector, featureFlags,
- mSelectedUserInteractor) {
+ mSelectedUserInteractor, new FakeKeyboardRepository()) {
@Override
public void onResume(int reason) {
super.onResume(reason);
diff --git a/packages/SystemUI/multivalentTests/src/com/android/keyguard/KeyguardPinViewControllerTest.kt b/packages/SystemUI/multivalentTests/src/com/android/keyguard/KeyguardPinViewControllerTest.kt
index 78b854e..c2efc05 100644
--- a/packages/SystemUI/multivalentTests/src/com/android/keyguard/KeyguardPinViewControllerTest.kt
+++ b/packages/SystemUI/multivalentTests/src/com/android/keyguard/KeyguardPinViewControllerTest.kt
@@ -33,6 +33,7 @@
import com.android.systemui.classifier.FalsingCollectorFake
import com.android.systemui.flags.FeatureFlags
import com.android.systemui.flags.Flags
+import com.android.systemui.keyboard.data.repository.FakeKeyboardRepository
import com.android.systemui.res.R
import com.android.systemui.statusbar.policy.DevicePostureController
import com.android.systemui.statusbar.policy.DevicePostureController.DEVICE_POSTURE_HALF_OPENED
@@ -141,7 +142,8 @@
postureController,
featureFlags,
mSelectedUserInteractor,
- uiEventLogger
+ uiEventLogger,
+ FakeKeyboardRepository()
)
}
diff --git a/packages/SystemUI/multivalentTests/src/com/android/keyguard/KeyguardSimPinViewControllerTest.kt b/packages/SystemUI/multivalentTests/src/com/android/keyguard/KeyguardSimPinViewControllerTest.kt
index f775175..0959f1b 100644
--- a/packages/SystemUI/multivalentTests/src/com/android/keyguard/KeyguardSimPinViewControllerTest.kt
+++ b/packages/SystemUI/multivalentTests/src/com/android/keyguard/KeyguardSimPinViewControllerTest.kt
@@ -16,7 +16,6 @@
package com.android.keyguard
-import android.telephony.PinResult
import android.telephony.TelephonyManager
import android.testing.TestableLooper
import android.view.LayoutInflater
@@ -28,9 +27,11 @@
import com.android.systemui.SysuiTestCase
import com.android.systemui.classifier.FalsingCollector
import com.android.systemui.flags.FakeFeatureFlags
+import com.android.systemui.keyboard.data.repository.FakeKeyboardRepository
import com.android.systemui.res.R
import com.android.systemui.user.domain.interactor.SelectedUserInteractor
import com.android.systemui.util.mockito.any
+import com.android.systemui.util.mockito.mock
import org.junit.Before
import org.junit.Test
import org.junit.runner.RunWith
@@ -39,7 +40,6 @@
import org.mockito.Mock
import org.mockito.Mockito
import org.mockito.Mockito.anyInt
-import org.mockito.Mockito.mock
import org.mockito.Mockito.never
import org.mockito.Mockito.reset
import org.mockito.Mockito.verify
@@ -75,8 +75,7 @@
`when`(messageAreaControllerFactory.create(Mockito.any(KeyguardMessageArea::class.java)))
.thenReturn(keyguardMessageAreaController)
`when`(telephonyManager.createForSubscriptionId(anyInt())).thenReturn(telephonyManager)
- `when`(telephonyManager.supplyIccLockPin(anyString()))
- .thenReturn(mock(PinResult::class.java))
+ `when`(telephonyManager.supplyIccLockPin(anyString())).thenReturn(mock())
simPinView =
LayoutInflater.from(context).inflate(R.layout.keyguard_sim_pin_view, null)
as KeyguardSimPinView
@@ -97,7 +96,8 @@
falsingCollector,
emergencyButtonController,
fakeFeatureFlags,
- mSelectedUserInteractor
+ mSelectedUserInteractor,
+ FakeKeyboardRepository()
)
underTest.init()
underTest.onViewAttached()
diff --git a/packages/SystemUI/multivalentTests/src/com/android/keyguard/KeyguardSimPukViewControllerTest.kt b/packages/SystemUI/multivalentTests/src/com/android/keyguard/KeyguardSimPukViewControllerTest.kt
index 45a60199..1281e44 100644
--- a/packages/SystemUI/multivalentTests/src/com/android/keyguard/KeyguardSimPukViewControllerTest.kt
+++ b/packages/SystemUI/multivalentTests/src/com/android/keyguard/KeyguardSimPukViewControllerTest.kt
@@ -28,6 +28,7 @@
import com.android.systemui.SysuiTestCase
import com.android.systemui.classifier.FalsingCollector
import com.android.systemui.flags.FakeFeatureFlags
+import com.android.systemui.keyboard.data.repository.FakeKeyboardRepository
import com.android.systemui.res.R
import com.android.systemui.user.domain.interactor.SelectedUserInteractor
import com.android.systemui.util.mockito.any
@@ -91,6 +92,7 @@
emergencyButtonController,
fakeFeatureFlags,
mSelectedUserInteractor,
+ FakeKeyboardRepository()
)
underTest.init()
}
diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/accessibility/data/repository/ColorCorrectionRepositoryImplTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/accessibility/data/repository/ColorCorrectionRepositoryImplTest.kt
index 27d1eb7..c86c747 100644
--- a/packages/SystemUI/multivalentTests/src/com/android/systemui/accessibility/data/repository/ColorCorrectionRepositoryImplTest.kt
+++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/accessibility/data/repository/ColorCorrectionRepositoryImplTest.kt
@@ -17,14 +17,15 @@
package com.android.systemui.accessibility.data.repository
import android.os.UserHandle
+import android.provider.Settings.Secure.ACCESSIBILITY_DISPLAY_DALTONIZER_ENABLED
import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.filters.SmallTest
import com.android.systemui.SysuiTestCase
+import com.android.systemui.coroutines.collectLastValue
+import com.android.systemui.coroutines.collectValues
import com.android.systemui.util.settings.FakeSettings
import com.google.common.truth.Truth
import kotlinx.coroutines.ExperimentalCoroutinesApi
-import kotlinx.coroutines.flow.first
-import kotlinx.coroutines.flow.launchIn
import kotlinx.coroutines.test.StandardTestDispatcher
import kotlinx.coroutines.test.TestScope
import kotlinx.coroutines.test.runCurrent
@@ -51,6 +52,7 @@
underTest =
ColorCorrectionRepositoryImpl(
testDispatcher,
+ scope.backgroundScope,
settings,
)
}
@@ -58,83 +60,78 @@
@Test
fun isEnabled_initiallyGetsSettingsValue() =
scope.runTest {
+ val actualValue by collectLastValue(underTest.isEnabled(testUser1))
+
settings.putIntForUser(
- ColorCorrectionRepositoryImpl.SETTING_NAME,
- 1,
+ SETTING_NAME,
+ ENABLED,
testUser1.identifier
)
-
- underTest =
- ColorCorrectionRepositoryImpl(
- testDispatcher,
- settings,
- )
-
- underTest.isEnabled(testUser1).launchIn(backgroundScope)
runCurrent()
- val actualValue: Boolean = underTest.isEnabled(testUser1).first()
Truth.assertThat(actualValue).isTrue()
}
@Test
fun isEnabled_settingUpdated_valueUpdated() =
scope.runTest {
- underTest.isEnabled(testUser1).launchIn(backgroundScope)
+ val flowValues: List<Boolean> by collectValues(underTest.isEnabled(testUser1))
settings.putIntForUser(
- ColorCorrectionRepositoryImpl.SETTING_NAME,
- ColorCorrectionRepositoryImpl.DISABLED,
+ SETTING_NAME,
+ DISABLED,
testUser1.identifier
)
runCurrent()
- Truth.assertThat(underTest.isEnabled(testUser1).first()).isFalse()
settings.putIntForUser(
- ColorCorrectionRepositoryImpl.SETTING_NAME,
- ColorCorrectionRepositoryImpl.ENABLED,
+ SETTING_NAME,
+ ENABLED,
testUser1.identifier
)
runCurrent()
- Truth.assertThat(underTest.isEnabled(testUser1).first()).isTrue()
settings.putIntForUser(
- ColorCorrectionRepositoryImpl.SETTING_NAME,
- ColorCorrectionRepositoryImpl.DISABLED,
+ SETTING_NAME,
+ DISABLED,
testUser1.identifier
)
runCurrent()
- Truth.assertThat(underTest.isEnabled(testUser1).first()).isFalse()
+
+ Truth.assertThat(flowValues.size).isEqualTo(3)
+ Truth.assertThat(flowValues).containsExactly(false, true, false).inOrder()
}
@Test
fun isEnabled_settingForUserOneOnly_valueUpdatedForUserOneOnly() =
scope.runTest {
- underTest.isEnabled(testUser1).launchIn(backgroundScope)
+ val lastValueUser1 by collectLastValue(underTest.isEnabled(testUser1))
+ val lastValueUser2 by collectLastValue(underTest.isEnabled(testUser2))
+
settings.putIntForUser(
- ColorCorrectionRepositoryImpl.SETTING_NAME,
- ColorCorrectionRepositoryImpl.DISABLED,
+ SETTING_NAME,
+ DISABLED,
testUser1.identifier
)
- underTest.isEnabled(testUser2).launchIn(backgroundScope)
settings.putIntForUser(
- ColorCorrectionRepositoryImpl.SETTING_NAME,
- ColorCorrectionRepositoryImpl.DISABLED,
+ SETTING_NAME,
+ DISABLED,
testUser2.identifier
)
-
runCurrent()
- Truth.assertThat(underTest.isEnabled(testUser1).first()).isFalse()
- Truth.assertThat(underTest.isEnabled(testUser2).first()).isFalse()
+
+ Truth.assertThat(lastValueUser1).isFalse()
+ Truth.assertThat(lastValueUser2).isFalse()
settings.putIntForUser(
- ColorCorrectionRepositoryImpl.SETTING_NAME,
- ColorCorrectionRepositoryImpl.ENABLED,
+ SETTING_NAME,
+ ENABLED,
testUser1.identifier
)
runCurrent()
- Truth.assertThat(underTest.isEnabled(testUser1).first()).isTrue()
- Truth.assertThat(underTest.isEnabled(testUser2).first()).isFalse()
+
+ Truth.assertThat(lastValueUser1).isTrue()
+ Truth.assertThat(lastValueUser2).isFalse()
}
@Test
@@ -146,10 +143,10 @@
val actualValue =
settings.getIntForUser(
- ColorCorrectionRepositoryImpl.SETTING_NAME,
+ SETTING_NAME,
testUser1.identifier
)
- Truth.assertThat(actualValue).isEqualTo(ColorCorrectionRepositoryImpl.ENABLED)
+ Truth.assertThat(actualValue).isEqualTo(ENABLED)
}
@Test
@@ -161,9 +158,15 @@
val actualValue =
settings.getIntForUser(
- ColorCorrectionRepositoryImpl.SETTING_NAME,
+ SETTING_NAME,
testUser1.identifier
)
- Truth.assertThat(actualValue).isEqualTo(ColorCorrectionRepositoryImpl.DISABLED)
+ Truth.assertThat(actualValue).isEqualTo(DISABLED)
}
+
+ companion object {
+ private const val SETTING_NAME = ACCESSIBILITY_DISPLAY_DALTONIZER_ENABLED
+ private const val DISABLED = 0
+ private const val ENABLED = 1
+ }
}
diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/accessibility/data/repository/ColorInversionRepositoryImplTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/accessibility/data/repository/ColorInversionRepositoryImplTest.kt
index 423e124..4853529 100644
--- a/packages/SystemUI/multivalentTests/src/com/android/systemui/accessibility/data/repository/ColorInversionRepositoryImplTest.kt
+++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/accessibility/data/repository/ColorInversionRepositoryImplTest.kt
@@ -21,11 +21,11 @@
import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.filters.SmallTest
import com.android.systemui.SysuiTestCase
+import com.android.systemui.coroutines.collectLastValue
+import com.android.systemui.coroutines.collectValues
import com.android.systemui.util.settings.FakeSettings
import com.google.common.truth.Truth.assertThat
import kotlinx.coroutines.ExperimentalCoroutinesApi
-import kotlinx.coroutines.flow.first
-import kotlinx.coroutines.flow.launchIn
import kotlinx.coroutines.test.StandardTestDispatcher
import kotlinx.coroutines.test.TestScope
import kotlinx.coroutines.test.runCurrent
@@ -52,6 +52,7 @@
underTest =
ColorInversionRepositoryImpl(
testDispatcher,
+ scope.backgroundScope,
settings,
)
}
@@ -59,55 +60,47 @@
@Test
fun isEnabled_initiallyGetsSettingsValue() =
scope.runTest {
- settings.putIntForUser(SETTING_NAME, 1, testUser1.identifier)
+ val actualValue by collectLastValue(underTest.isEnabled(testUser1))
- underTest =
- ColorInversionRepositoryImpl(
- testDispatcher,
- settings,
- )
-
- underTest.isEnabled(testUser1).launchIn(backgroundScope)
+ settings.putIntForUser(SETTING_NAME, ENABLED, testUser1.identifier)
runCurrent()
- val actualValue: Boolean = underTest.isEnabled(testUser1).first()
assertThat(actualValue).isTrue()
}
@Test
fun isEnabled_settingUpdated_valueUpdated() =
scope.runTest {
- underTest.isEnabled(testUser1).launchIn(backgroundScope)
+ val flowValues: List<Boolean> by
+ collectValues(underTest.isEnabled(testUser1))
settings.putIntForUser(SETTING_NAME, DISABLED, testUser1.identifier)
runCurrent()
- assertThat(underTest.isEnabled(testUser1).first()).isFalse()
-
settings.putIntForUser(SETTING_NAME, ENABLED, testUser1.identifier)
runCurrent()
- assertThat(underTest.isEnabled(testUser1).first()).isTrue()
-
settings.putIntForUser(SETTING_NAME, DISABLED, testUser1.identifier)
runCurrent()
- assertThat(underTest.isEnabled(testUser1).first()).isFalse()
+
+ assertThat(flowValues.size).isEqualTo(3)
+ assertThat(flowValues).containsExactly(false, true, false).inOrder()
}
@Test
fun isEnabled_settingForUserOneOnly_valueUpdatedForUserOneOnly() =
scope.runTest {
- underTest.isEnabled(testUser1).launchIn(backgroundScope)
- settings.putIntForUser(SETTING_NAME, DISABLED, testUser1.identifier)
- underTest.isEnabled(testUser2).launchIn(backgroundScope)
- settings.putIntForUser(SETTING_NAME, DISABLED, testUser2.identifier)
+ val lastValueUser1 by collectLastValue(underTest.isEnabled(testUser1))
+ val lastValueUser2 by collectLastValue(underTest.isEnabled(testUser2))
+ settings.putIntForUser(SETTING_NAME, DISABLED, testUser1.identifier)
+ settings.putIntForUser(SETTING_NAME, DISABLED, testUser2.identifier)
runCurrent()
- assertThat(underTest.isEnabled(testUser1).first()).isFalse()
- assertThat(underTest.isEnabled(testUser2).first()).isFalse()
+ assertThat(lastValueUser1).isFalse()
+ assertThat(lastValueUser2).isFalse()
settings.putIntForUser(SETTING_NAME, ENABLED, testUser1.identifier)
runCurrent()
- assertThat(underTest.isEnabled(testUser1).first()).isTrue()
- assertThat(underTest.isEnabled(testUser2).first()).isFalse()
+ assertThat(lastValueUser1).isTrue()
+ assertThat(lastValueUser2).isFalse()
}
@Test
diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/communal/data/repository/CommunalPrefsRepositoryImplTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/communal/data/repository/CommunalPrefsRepositoryImplTest.kt
new file mode 100644
index 0000000..820bfbf
--- /dev/null
+++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/communal/data/repository/CommunalPrefsRepositoryImplTest.kt
@@ -0,0 +1,135 @@
+/*
+ * 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.communal.data.repository
+
+import android.content.SharedPreferences
+import android.content.pm.UserInfo
+import androidx.test.ext.junit.runners.AndroidJUnit4
+import androidx.test.filters.SmallTest
+import com.android.systemui.SysuiTestCase
+import com.android.systemui.communal.data.repository.CommunalPrefsRepositoryImpl.Companion.FILE_NAME
+import com.android.systemui.coroutines.collectLastValue
+import com.android.systemui.kosmos.testDispatcher
+import com.android.systemui.kosmos.testScope
+import com.android.systemui.settings.UserFileManager
+import com.android.systemui.testKosmos
+import com.android.systemui.user.data.repository.FakeUserRepository
+import com.android.systemui.user.data.repository.fakeUserRepository
+import com.android.systemui.util.FakeSharedPreferences
+import com.google.common.truth.Truth.assertThat
+import java.io.File
+import kotlinx.coroutines.test.runTest
+import org.junit.Before
+import org.junit.Test
+import org.junit.runner.RunWith
+
+@SmallTest
+@RunWith(AndroidJUnit4::class)
+class CommunalPrefsRepositoryImplTest : SysuiTestCase() {
+ private lateinit var underTest: CommunalPrefsRepositoryImpl
+
+ private val kosmos = testKosmos()
+ private val testScope = kosmos.testScope
+
+ private lateinit var userRepository: FakeUserRepository
+ private lateinit var userFileManager: UserFileManager
+
+ @Before
+ fun setUp() {
+ userRepository = kosmos.fakeUserRepository
+ userRepository.setUserInfos(USER_INFOS)
+
+ userFileManager =
+ FakeUserFileManager(
+ mapOf(
+ USER_INFOS[0].id to FakeSharedPreferences(),
+ USER_INFOS[1].id to FakeSharedPreferences()
+ )
+ )
+ underTest =
+ CommunalPrefsRepositoryImpl(
+ testScope.backgroundScope,
+ kosmos.testDispatcher,
+ userRepository,
+ userFileManager,
+ )
+ }
+
+ @Test
+ fun isCtaDismissedValue_byDefault_isFalse() =
+ testScope.runTest {
+ val isCtaDismissed by collectLastValue(underTest.isCtaDismissed)
+ assertThat(isCtaDismissed).isFalse()
+ }
+
+ @Test
+ fun isCtaDismissedValue_onSet_isTrue() =
+ testScope.runTest {
+ val isCtaDismissed by collectLastValue(underTest.isCtaDismissed)
+
+ underTest.setCtaDismissedForCurrentUser()
+ assertThat(isCtaDismissed).isTrue()
+ }
+
+ @Test
+ fun isCtaDismissedValue_whenSwitchUser() =
+ testScope.runTest {
+ val isCtaDismissed by collectLastValue(underTest.isCtaDismissed)
+ underTest.setCtaDismissedForCurrentUser()
+
+ // dismissed true for primary user
+ assertThat(isCtaDismissed).isTrue()
+
+ // switch to secondary user
+ userRepository.setSelectedUserInfo(USER_INFOS[1])
+
+ // dismissed is false for secondary user
+ assertThat(isCtaDismissed).isFalse()
+
+ // switch back to primary user
+ userRepository.setSelectedUserInfo(USER_INFOS[0])
+
+ // dismissed is true for primary user
+ assertThat(isCtaDismissed).isTrue()
+ }
+
+ private class FakeUserFileManager(private val sharedPrefs: Map<Int, SharedPreferences>) :
+ UserFileManager {
+ override fun getFile(fileName: String, userId: Int): File {
+ throw UnsupportedOperationException()
+ }
+
+ override fun getSharedPreferences(
+ fileName: String,
+ mode: Int,
+ userId: Int
+ ): SharedPreferences {
+ if (fileName != FILE_NAME) {
+ throw IllegalArgumentException("Preference files must be $FILE_NAME")
+ }
+ return sharedPrefs.getValue(userId)
+ }
+ }
+
+ companion object {
+ val USER_INFOS =
+ listOf(
+ UserInfo(/* id= */ 0, "zero", /* flags= */ 0),
+ UserInfo(/* id= */ 1, "secondary", /* flags= */ 0),
+ )
+ }
+}
diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/communal/domain/interactor/CommunalInteractorTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/communal/domain/interactor/CommunalInteractorTest.kt
index cd83c07..178eb6a 100644
--- a/packages/SystemUI/multivalentTests/src/com/android/systemui/communal/domain/interactor/CommunalInteractorTest.kt
+++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/communal/domain/interactor/CommunalInteractorTest.kt
@@ -24,6 +24,7 @@
import androidx.test.filters.SmallTest
import com.android.systemui.SysuiTestCase
import com.android.systemui.communal.data.repository.FakeCommunalMediaRepository
+import com.android.systemui.communal.data.repository.FakeCommunalPrefsRepository
import com.android.systemui.communal.data.repository.FakeCommunalRepository
import com.android.systemui.communal.data.repository.FakeCommunalTutorialRepository
import com.android.systemui.communal.data.repository.FakeCommunalWidgetRepository
@@ -65,6 +66,7 @@
private lateinit var widgetRepository: FakeCommunalWidgetRepository
private lateinit var smartspaceRepository: FakeSmartspaceRepository
private lateinit var keyguardRepository: FakeKeyguardRepository
+ private lateinit var communalPrefsRepository: FakeCommunalPrefsRepository
private lateinit var editWidgetsActivityStarter: EditWidgetsActivityStarter
private lateinit var underTest: CommunalInteractor
@@ -84,6 +86,7 @@
smartspaceRepository = withDeps.smartspaceRepository
keyguardRepository = withDeps.keyguardRepository
editWidgetsActivityStarter = withDeps.editWidgetsActivityStarter
+ communalPrefsRepository = withDeps.communalPrefsRepository
underTest = withDeps.communalInteractor
}
@@ -331,10 +334,9 @@
}
@Test
- fun cta_visibilityTrue_shows() =
+ fun ctaTile_showsByDefault() =
testScope.runTest {
tutorialRepository.setTutorialSettingState(HUB_MODE_TUTORIAL_COMPLETED)
- communalRepository.setCtaTileInViewModeVisibility(true)
val ctaTileContent by collectLastValue(underTest.ctaTileContent)
@@ -346,10 +348,10 @@
}
@Test
- fun ctaTile_visibilityFalse_doesNotShow() =
+ fun ctaTile_afterDismiss_doesNotShow() =
testScope.runTest {
tutorialRepository.setTutorialSettingState(HUB_MODE_TUTORIAL_COMPLETED)
- communalRepository.setCtaTileInViewModeVisibility(false)
+ communalPrefsRepository.setCtaDismissedForCurrentUser()
val ctaTileContent by collectLastValue(underTest.ctaTileContent)
diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/communal/view/viewmodel/CommunalViewModelTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/communal/view/viewmodel/CommunalViewModelTest.kt
index 804c052..f9cfc37 100644
--- a/packages/SystemUI/multivalentTests/src/com/android/systemui/communal/view/viewmodel/CommunalViewModelTest.kt
+++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/communal/view/viewmodel/CommunalViewModelTest.kt
@@ -23,6 +23,7 @@
import androidx.test.filters.SmallTest
import com.android.systemui.SysuiTestCase
import com.android.systemui.communal.data.repository.FakeCommunalMediaRepository
+import com.android.systemui.communal.data.repository.FakeCommunalPrefsRepository
import com.android.systemui.communal.data.repository.FakeCommunalRepository
import com.android.systemui.communal.data.repository.FakeCommunalTutorialRepository
import com.android.systemui.communal.data.repository.FakeCommunalWidgetRepository
@@ -66,6 +67,7 @@
private lateinit var widgetRepository: FakeCommunalWidgetRepository
private lateinit var smartspaceRepository: FakeSmartspaceRepository
private lateinit var mediaRepository: FakeCommunalMediaRepository
+ private lateinit var communalPrefsRepository: FakeCommunalPrefsRepository
private lateinit var underTest: CommunalViewModel
@@ -82,6 +84,7 @@
widgetRepository = withDeps.widgetRepository
smartspaceRepository = withDeps.smartspaceRepository
mediaRepository = withDeps.mediaRepository
+ communalPrefsRepository = withDeps.communalPrefsRepository
underTest =
CommunalViewModel(
@@ -149,9 +152,6 @@
// Media playing.
mediaRepository.mediaActive()
- // CTA Tile not dismissed.
- communalRepository.setCtaTileInViewModeVisibility(true)
-
val communalContent by collectLastValue(underTest.communalContent)
// Order is smart space, then UMO, widget content and cta tile.
@@ -171,7 +171,6 @@
fun dismissCta_hidesCtaTileAndShowsPopup_thenHidesPopupAfterTimeout() =
testScope.runTest {
tutorialRepository.setTutorialSettingState(Settings.Secure.HUB_MODE_TUTORIAL_COMPLETED)
- communalRepository.setCtaTileInViewModeVisibility(true)
val communalContent by collectLastValue(underTest.communalContent)
val isPopupOnDismissCtaShowing by collectLastValue(underTest.isPopupOnDismissCtaShowing)
@@ -195,7 +194,6 @@
fun popup_onDismiss_hidesImmediately() =
testScope.runTest {
tutorialRepository.setTutorialSettingState(Settings.Secure.HUB_MODE_TUTORIAL_COMPLETED)
- communalRepository.setCtaTileInViewModeVisibility(true)
val isPopupOnDismissCtaShowing by collectLastValue(underTest.isPopupOnDismissCtaShowing)
diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/keyguard/domain/interactor/KeyguardTransitionInteractorTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/keyguard/domain/interactor/KeyguardTransitionInteractorTest.kt
index 4f7d944..6828041 100644
--- a/packages/SystemUI/multivalentTests/src/com/android/systemui/keyguard/domain/interactor/KeyguardTransitionInteractorTest.kt
+++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/keyguard/domain/interactor/KeyguardTransitionInteractorTest.kt
@@ -21,23 +21,24 @@
import androidx.test.filters.SmallTest
import com.android.systemui.SysuiTestCase
import com.android.systemui.coroutines.collectValues
-import com.android.systemui.keyguard.data.repository.FakeKeyguardTransitionRepository
+import com.android.systemui.keyguard.data.repository.fakeKeyguardTransitionRepository
import com.android.systemui.keyguard.shared.model.KeyguardState.AOD
import com.android.systemui.keyguard.shared.model.KeyguardState.DOZING
import com.android.systemui.keyguard.shared.model.KeyguardState.GONE
import com.android.systemui.keyguard.shared.model.KeyguardState.LOCKSCREEN
+import com.android.systemui.keyguard.shared.model.KeyguardState.OFF
import com.android.systemui.keyguard.shared.model.KeyguardState.PRIMARY_BOUNCER
import com.android.systemui.keyguard.shared.model.TransitionState.CANCELED
import com.android.systemui.keyguard.shared.model.TransitionState.FINISHED
import com.android.systemui.keyguard.shared.model.TransitionState.RUNNING
import com.android.systemui.keyguard.shared.model.TransitionState.STARTED
import com.android.systemui.keyguard.shared.model.TransitionStep
+import com.android.systemui.kosmos.testScope
+import com.android.systemui.testKosmos
import com.google.common.truth.Truth.assertThat
import junit.framework.Assert.assertEquals
-import kotlinx.coroutines.test.TestScope
import kotlinx.coroutines.test.runCurrent
import kotlinx.coroutines.test.runTest
-import org.junit.Before
import org.junit.Test
import org.junit.runner.RunWith
@@ -46,18 +47,11 @@
@kotlinx.coroutines.ExperimentalCoroutinesApi
class KeyguardTransitionInteractorTest : SysuiTestCase() {
- private lateinit var underTest: KeyguardTransitionInteractor
- private lateinit var repository: FakeKeyguardTransitionRepository
- private val testScope = TestScope()
+ val kosmos = testKosmos()
- @Before
- fun setUp() {
- repository = FakeKeyguardTransitionRepository()
- underTest = KeyguardTransitionInteractorFactory.create(
- scope = testScope.backgroundScope,
- repository = repository,
- ).keyguardTransitionInteractor
- }
+ val underTest = kosmos.keyguardTransitionInteractor
+ val repository = kosmos.fakeKeyguardTransitionRepository
+ val testScope = kosmos.testScope
@Test
fun transitionCollectorsReceivesOnlyAppropriateEvents() = runTest {
@@ -114,48 +108,50 @@
}
@Test
- fun finishedKeyguardStateTests() = testScope.runTest {
- val finishedSteps by collectValues(underTest.finishedKeyguardState)
- runCurrent()
- val steps = mutableListOf<TransitionStep>()
-
- steps.add(TransitionStep(AOD, PRIMARY_BOUNCER, 0f, STARTED))
- steps.add(TransitionStep(AOD, PRIMARY_BOUNCER, 0.5f, RUNNING))
- steps.add(TransitionStep(AOD, PRIMARY_BOUNCER, 1f, FINISHED))
- steps.add(TransitionStep(PRIMARY_BOUNCER, AOD, 0f, STARTED))
- steps.add(TransitionStep(PRIMARY_BOUNCER, AOD, 0.9f, RUNNING))
- steps.add(TransitionStep(PRIMARY_BOUNCER, AOD, 1f, FINISHED))
- steps.add(TransitionStep(AOD, GONE, 1f, STARTED))
-
- steps.forEach {
- repository.sendTransitionStep(it)
+ fun finishedKeyguardStateTests() =
+ testScope.runTest {
+ val finishedSteps by collectValues(underTest.finishedKeyguardState)
runCurrent()
- }
+ val steps = mutableListOf<TransitionStep>()
- assertThat(finishedSteps).isEqualTo(listOf(LOCKSCREEN, PRIMARY_BOUNCER, AOD))
- }
+ steps.add(TransitionStep(AOD, PRIMARY_BOUNCER, 0f, STARTED))
+ steps.add(TransitionStep(AOD, PRIMARY_BOUNCER, 0.5f, RUNNING))
+ steps.add(TransitionStep(AOD, PRIMARY_BOUNCER, 1f, FINISHED))
+ steps.add(TransitionStep(PRIMARY_BOUNCER, AOD, 0f, STARTED))
+ steps.add(TransitionStep(PRIMARY_BOUNCER, AOD, 0.9f, RUNNING))
+ steps.add(TransitionStep(PRIMARY_BOUNCER, AOD, 1f, FINISHED))
+ steps.add(TransitionStep(AOD, GONE, 1f, STARTED))
+
+ steps.forEach {
+ repository.sendTransitionStep(it)
+ runCurrent()
+ }
+
+ assertThat(finishedSteps).isEqualTo(listOf(LOCKSCREEN, PRIMARY_BOUNCER, AOD))
+ }
@Test
- fun startedKeyguardStateTests() = testScope.runTest {
- val startedStates by collectValues(underTest.startedKeyguardState)
- runCurrent()
- val steps = mutableListOf<TransitionStep>()
-
- steps.add(TransitionStep(AOD, PRIMARY_BOUNCER, 0f, STARTED))
- steps.add(TransitionStep(AOD, PRIMARY_BOUNCER, 0.5f, RUNNING))
- steps.add(TransitionStep(AOD, PRIMARY_BOUNCER, 1f, FINISHED))
- steps.add(TransitionStep(PRIMARY_BOUNCER, AOD, 0f, STARTED))
- steps.add(TransitionStep(PRIMARY_BOUNCER, AOD, 0.9f, RUNNING))
- steps.add(TransitionStep(PRIMARY_BOUNCER, AOD, 1f, FINISHED))
- steps.add(TransitionStep(AOD, GONE, 1f, STARTED))
-
- steps.forEach {
- repository.sendTransitionStep(it)
+ fun startedKeyguardStateTests() =
+ testScope.runTest {
+ val startedStates by collectValues(underTest.startedKeyguardState)
runCurrent()
- }
+ val steps = mutableListOf<TransitionStep>()
- assertThat(startedStates).isEqualTo(listOf(LOCKSCREEN, PRIMARY_BOUNCER, AOD, GONE))
- }
+ steps.add(TransitionStep(AOD, PRIMARY_BOUNCER, 0f, STARTED))
+ steps.add(TransitionStep(AOD, PRIMARY_BOUNCER, 0.5f, RUNNING))
+ steps.add(TransitionStep(AOD, PRIMARY_BOUNCER, 1f, FINISHED))
+ steps.add(TransitionStep(PRIMARY_BOUNCER, AOD, 0f, STARTED))
+ steps.add(TransitionStep(PRIMARY_BOUNCER, AOD, 0.9f, RUNNING))
+ steps.add(TransitionStep(PRIMARY_BOUNCER, AOD, 1f, FINISHED))
+ steps.add(TransitionStep(AOD, GONE, 1f, STARTED))
+
+ steps.forEach {
+ repository.sendTransitionStep(it)
+ runCurrent()
+ }
+
+ assertThat(startedStates).isEqualTo(listOf(LOCKSCREEN, PRIMARY_BOUNCER, AOD, GONE))
+ }
@Test
fun finishedKeyguardTransitionStepTests() = runTest {
@@ -178,7 +174,7 @@
// Ignore the default state.
assertThat(finishedSteps.subList(1, finishedSteps.size))
- .isEqualTo(listOf(steps[2], steps[5]))
+ .isEqualTo(listOf(steps[2], steps[5]))
}
@Test
@@ -233,500 +229,1067 @@
}
@Test
- fun isInTransitionToState() = testScope.runTest {
- val results by collectValues(underTest.isInTransitionToState(GONE))
+ fun isInTransitionToAnyState() =
+ testScope.runTest {
+ val inTransition by collectValues(underTest.isInTransitionToAnyState)
- sendSteps(
+ assertEquals(
+ listOf(
+ true, // The repo is seeded with a transition from OFF to LOCKSCREEN.
+ false,
+ ),
+ inTransition
+ )
+
+ sendSteps(
+ TransitionStep(LOCKSCREEN, GONE, 0f, STARTED),
+ )
+
+ assertEquals(
+ listOf(
+ true,
+ false,
+ true,
+ ),
+ inTransition
+ )
+
+ sendSteps(
+ TransitionStep(LOCKSCREEN, GONE, 0.5f, RUNNING),
+ )
+
+ assertEquals(
+ listOf(
+ true,
+ false,
+ true,
+ ),
+ inTransition
+ )
+
+ sendSteps(
+ TransitionStep(LOCKSCREEN, GONE, 1f, FINISHED),
+ )
+
+ assertEquals(
+ listOf(
+ true,
+ false,
+ true,
+ false,
+ ),
+ inTransition
+ )
+ }
+
+ @Test
+ fun isInTransitionToAnyState_finishedStateIsStartedStateAfterCancels() =
+ testScope.runTest {
+ val inTransition by collectValues(underTest.isInTransitionToAnyState)
+
+ assertEquals(
+ listOf(
+ true,
+ false,
+ ),
+ inTransition
+ )
+
+ // Start FINISHED in GONE.
+ sendSteps(
+ TransitionStep(LOCKSCREEN, GONE, 0f, STARTED),
+ TransitionStep(LOCKSCREEN, GONE, 0.5f, RUNNING),
+ TransitionStep(LOCKSCREEN, GONE, 1f, FINISHED),
+ )
+
+ assertEquals(
+ listOf(
+ true,
+ false,
+ true,
+ false,
+ ),
+ inTransition
+ )
+
+ sendSteps(
+ TransitionStep(GONE, DOZING, 0f, STARTED),
+ )
+
+ assertEquals(
+ listOf(
+ true,
+ false,
+ true,
+ false,
+ true,
+ ),
+ inTransition
+ )
+
+ sendSteps(
+ TransitionStep(GONE, DOZING, 0.5f, RUNNING),
+ TransitionStep(GONE, DOZING, 0.6f, CANCELED),
+ TransitionStep(DOZING, LOCKSCREEN, 0f, STARTED),
+ TransitionStep(DOZING, LOCKSCREEN, 0.5f, RUNNING),
+ TransitionStep(DOZING, LOCKSCREEN, 0.6f, CANCELED),
+ TransitionStep(LOCKSCREEN, GONE, 0f, STARTED),
+ )
+
+ assertEquals(
+ listOf(
+ true,
+ false,
+ true,
+ false,
+ // We should have been in transition throughout the entire transition, including
+ // both cancellations, and we should still be in transition despite now
+ // transitioning to GONE, the state we're also FINISHED in.
+ true,
+ ),
+ inTransition
+ )
+
+ sendSteps(
+ TransitionStep(LOCKSCREEN, GONE, 0.5f, RUNNING),
+ TransitionStep(LOCKSCREEN, GONE, 1f, FINISHED),
+ )
+
+ assertEquals(
+ listOf(
+ true,
+ false,
+ true,
+ false,
+ true,
+ false,
+ ),
+ inTransition
+ )
+ }
+
+ @Test
+ fun isInTransitionToState() =
+ testScope.runTest {
+ val results by collectValues(underTest.isInTransitionToState(GONE))
+
+ sendSteps(
TransitionStep(AOD, DOZING, 0f, STARTED),
TransitionStep(AOD, DOZING, 0.5f, RUNNING),
TransitionStep(AOD, DOZING, 1f, FINISHED),
- )
+ )
+ assertThat(results)
+ .isEqualTo(
+ listOf(
+ false,
+ )
+ )
- assertThat(results).isEqualTo(listOf(
- false,
- ))
-
- sendSteps(
+ sendSteps(
TransitionStep(DOZING, GONE, 0f, STARTED),
- )
+ )
- assertThat(results).isEqualTo(listOf(
- false,
- true,
- ))
+ assertThat(results)
+ .isEqualTo(
+ listOf(
+ false,
+ true,
+ )
+ )
- sendSteps(
+ sendSteps(
TransitionStep(DOZING, GONE, 0f, RUNNING),
- )
+ )
- assertThat(results).isEqualTo(listOf(
- false,
- true,
- ))
+ assertThat(results)
+ .isEqualTo(
+ listOf(
+ false,
+ true,
+ )
+ )
- sendSteps(
+ sendSteps(
TransitionStep(DOZING, GONE, 0f, FINISHED),
- )
+ )
- assertThat(results).isEqualTo(listOf(
- false,
- true,
- false,
- ))
+ assertThat(results)
+ .isEqualTo(
+ listOf(
+ false,
+ true,
+ false,
+ )
+ )
- sendSteps(
+ sendSteps(
TransitionStep(GONE, DOZING, 0f, STARTED),
TransitionStep(GONE, DOZING, 0f, RUNNING),
TransitionStep(GONE, DOZING, 1f, FINISHED),
- )
+ )
- assertThat(results).isEqualTo(listOf(
- false,
- true,
- false,
- ))
+ assertThat(results)
+ .isEqualTo(
+ listOf(
+ false,
+ true,
+ false,
+ )
+ )
- sendSteps(
+ sendSteps(
TransitionStep(DOZING, GONE, 0f, STARTED),
TransitionStep(DOZING, GONE, 0f, RUNNING),
- )
+ )
- assertThat(results).isEqualTo(listOf(
- false,
- true,
- false,
- true,
- ))
- }
+ assertThat(results)
+ .isEqualTo(
+ listOf(
+ false,
+ true,
+ false,
+ true,
+ )
+ )
+ }
@Test
- fun isInTransitionFromState() = testScope.runTest {
- val results by collectValues(underTest.isInTransitionFromState(DOZING))
+ fun isInTransitionFromState() =
+ testScope.runTest {
+ val results by collectValues(underTest.isInTransitionFromState(DOZING))
- sendSteps(
+ sendSteps(
TransitionStep(AOD, DOZING, 0f, STARTED),
TransitionStep(AOD, DOZING, 0.5f, RUNNING),
TransitionStep(AOD, DOZING, 1f, FINISHED),
- )
+ )
+ assertThat(results)
+ .isEqualTo(
+ listOf(
+ false,
+ )
+ )
- assertThat(results).isEqualTo(listOf(
- false,
- ))
-
- sendSteps(
+ sendSteps(
TransitionStep(DOZING, GONE, 0f, STARTED),
- )
+ )
- assertThat(results).isEqualTo(listOf(
- false,
- true,
- ))
+ assertThat(results)
+ .isEqualTo(
+ listOf(
+ false,
+ true,
+ )
+ )
- sendSteps(
+ sendSteps(
TransitionStep(DOZING, GONE, 0f, RUNNING),
- )
+ )
- assertThat(results).isEqualTo(listOf(
- false,
- true,
- ))
+ assertThat(results)
+ .isEqualTo(
+ listOf(
+ false,
+ true,
+ )
+ )
- sendSteps(
+ sendSteps(
TransitionStep(DOZING, GONE, 0f, FINISHED),
- )
+ )
- assertThat(results).isEqualTo(listOf(
- false,
- true,
- false,
- ))
+ assertThat(results)
+ .isEqualTo(
+ listOf(
+ false,
+ true,
+ false,
+ )
+ )
- sendSteps(
+ sendSteps(
TransitionStep(GONE, DOZING, 0f, STARTED),
TransitionStep(GONE, DOZING, 0f, RUNNING),
TransitionStep(GONE, DOZING, 1f, FINISHED),
- )
+ )
- assertThat(results).isEqualTo(listOf(
- false,
- true,
- false,
- ))
+ assertThat(results)
+ .isEqualTo(
+ listOf(
+ false,
+ true,
+ false,
+ )
+ )
- sendSteps(
+ sendSteps(
TransitionStep(DOZING, GONE, 0f, STARTED),
TransitionStep(DOZING, GONE, 0f, RUNNING),
- )
+ )
- assertThat(results).isEqualTo(listOf(
- false,
- true,
- false,
- true,
- ))
- }
+ assertThat(results)
+ .isEqualTo(
+ listOf(
+ false,
+ true,
+ false,
+ true,
+ )
+ )
+ }
@Test
- fun isInTransitionFromStateWhere() = testScope.runTest {
- val results by collectValues(underTest.isInTransitionFromStateWhere {
- it == DOZING
- })
+ fun isInTransitionFromStateWhere() =
+ testScope.runTest {
+ val results by collectValues(underTest.isInTransitionFromStateWhere { it == DOZING })
- sendSteps(
+ sendSteps(
TransitionStep(AOD, DOZING, 0f, STARTED),
TransitionStep(AOD, DOZING, 0.5f, RUNNING),
TransitionStep(AOD, DOZING, 1f, FINISHED),
- )
+ )
+ assertThat(results)
+ .isEqualTo(
+ listOf(
+ false,
+ )
+ )
- assertThat(results).isEqualTo(listOf(
- false,
- ))
-
- sendSteps(
+ sendSteps(
TransitionStep(DOZING, GONE, 0f, STARTED),
- )
+ )
- assertThat(results).isEqualTo(listOf(
- false,
- true,
- ))
+ assertThat(results)
+ .isEqualTo(
+ listOf(
+ false,
+ true,
+ )
+ )
- sendSteps(
+ sendSteps(
TransitionStep(DOZING, GONE, 0f, RUNNING),
- )
+ )
- assertThat(results).isEqualTo(listOf(
- false,
- true,
- ))
+ assertThat(results)
+ .isEqualTo(
+ listOf(
+ false,
+ true,
+ )
+ )
- sendSteps(
+ sendSteps(
TransitionStep(DOZING, GONE, 0f, FINISHED),
- )
+ )
- assertThat(results).isEqualTo(listOf(
- false,
- true,
- false,
- ))
+ assertThat(results)
+ .isEqualTo(
+ listOf(
+ false,
+ true,
+ false,
+ )
+ )
- sendSteps(
+ sendSteps(
TransitionStep(GONE, DOZING, 0f, STARTED),
TransitionStep(GONE, DOZING, 0f, RUNNING),
TransitionStep(GONE, DOZING, 1f, FINISHED),
- )
+ )
- assertThat(results).isEqualTo(listOf(
- false,
- true,
- false,
- ))
+ assertThat(results)
+ .isEqualTo(
+ listOf(
+ false,
+ true,
+ false,
+ )
+ )
- sendSteps(
+ sendSteps(
TransitionStep(DOZING, GONE, 0f, STARTED),
TransitionStep(DOZING, GONE, 0f, RUNNING),
- )
+ )
- assertThat(results).isEqualTo(listOf(
- false,
- true,
- false,
- true,
- ))
- }
+ assertThat(results)
+ .isEqualTo(
+ listOf(
+ false,
+ true,
+ false,
+ true,
+ )
+ )
+ }
@Test
- fun isInTransitionWhere() = testScope.runTest {
- val results by collectValues(underTest.isInTransitionWhere(
- fromStatePredicate = { it == DOZING },
- toStatePredicate = { it == GONE },
- ))
+ fun isInTransitionWhere() =
+ testScope.runTest {
+ val results by
+ collectValues(
+ underTest.isInTransitionWhere(
+ fromStatePredicate = { it == DOZING },
+ toStatePredicate = { it == GONE },
+ )
+ )
- sendSteps(
+ sendSteps(
TransitionStep(AOD, DOZING, 0f, STARTED),
TransitionStep(AOD, DOZING, 0.5f, RUNNING),
TransitionStep(AOD, DOZING, 1f, FINISHED),
- )
+ )
+ assertThat(results)
+ .isEqualTo(
+ listOf(
+ false,
+ )
+ )
- assertThat(results).isEqualTo(listOf(
- false,
- ))
-
- sendSteps(
+ sendSteps(
TransitionStep(DOZING, GONE, 0f, STARTED),
- )
+ )
- assertThat(results).isEqualTo(listOf(
- false,
- true,
- ))
+ assertThat(results)
+ .isEqualTo(
+ listOf(
+ false,
+ true,
+ )
+ )
- sendSteps(
+ sendSteps(
TransitionStep(DOZING, GONE, 0f, RUNNING),
- )
+ )
- assertThat(results).isEqualTo(listOf(
- false,
- true,
- ))
+ assertThat(results)
+ .isEqualTo(
+ listOf(
+ false,
+ true,
+ )
+ )
- sendSteps(
+ sendSteps(
TransitionStep(DOZING, GONE, 0f, FINISHED),
- )
+ )
- assertThat(results).isEqualTo(listOf(
- false,
- true,
- false,
- ))
+ assertThat(results)
+ .isEqualTo(
+ listOf(
+ false,
+ true,
+ false,
+ )
+ )
- sendSteps(
+ sendSteps(
TransitionStep(GONE, DOZING, 0f, STARTED),
TransitionStep(GONE, DOZING, 0f, RUNNING),
TransitionStep(GONE, DOZING, 1f, FINISHED),
- )
+ )
- assertThat(results).isEqualTo(listOf(
- false,
- true,
- false,
- ))
+ assertThat(results)
+ .isEqualTo(
+ listOf(
+ false,
+ true,
+ false,
+ )
+ )
- sendSteps(
+ sendSteps(
TransitionStep(DOZING, GONE, 0f, STARTED),
TransitionStep(DOZING, GONE, 0f, RUNNING),
- )
+ )
- assertThat(results).isEqualTo(listOf(
- false,
- true,
- false,
- true,
- ))
- }
+ assertThat(results)
+ .isEqualTo(
+ listOf(
+ false,
+ true,
+ false,
+ true,
+ )
+ )
+ }
@Test
- fun isFinishedInStateWhere() = testScope.runTest {
- val results by collectValues(underTest.isFinishedInStateWhere { it == GONE } )
+ fun isInTransitionWhere_withCanceledStep() =
+ testScope.runTest {
+ val results by
+ collectValues(
+ underTest.isInTransitionWhere(
+ fromStatePredicate = { it == DOZING },
+ toStatePredicate = { it == GONE },
+ )
+ )
- sendSteps(
+ sendSteps(
TransitionStep(AOD, DOZING, 0f, STARTED),
TransitionStep(AOD, DOZING, 0.5f, RUNNING),
TransitionStep(AOD, DOZING, 1f, FINISHED),
- )
+ )
- assertThat(results).isEqualTo(listOf(
- false, // Finished in DOZING, not GONE.
- ))
+ assertThat(results)
+ .isEqualTo(
+ listOf(
+ false,
+ )
+ )
- sendSteps(TransitionStep(DOZING, GONE, 0f, STARTED))
+ sendSteps(
+ TransitionStep(DOZING, GONE, 0f, STARTED),
+ )
- assertThat(results).isEqualTo(listOf(
- false,
- ))
+ assertThat(results)
+ .isEqualTo(
+ listOf(
+ false,
+ true,
+ )
+ )
- sendSteps(TransitionStep(DOZING, GONE, 0f, RUNNING))
+ sendSteps(
+ TransitionStep(DOZING, GONE, 0f, RUNNING),
+ )
- assertThat(results).isEqualTo(listOf(
- false,
- ))
+ assertThat(results)
+ .isEqualTo(
+ listOf(
+ false,
+ true,
+ )
+ )
- sendSteps(TransitionStep(DOZING, GONE, 1f, FINISHED))
+ sendSteps(
+ TransitionStep(DOZING, GONE, 0f, CANCELED),
+ )
- assertThat(results).isEqualTo(listOf(
- false,
- true,
- ))
+ assertThat(results)
+ .isEqualTo(
+ listOf(
+ false,
+ true,
+ )
+ )
- sendSteps(
+ sendSteps(
TransitionStep(GONE, DOZING, 0f, STARTED),
TransitionStep(GONE, DOZING, 0f, RUNNING),
- )
+ TransitionStep(GONE, DOZING, 1f, FINISHED),
+ )
- assertThat(results).isEqualTo(listOf(
- false,
- true,
- ))
+ assertThat(results)
+ .isEqualTo(
+ listOf(
+ false,
+ true,
+ false,
+ )
+ )
- sendSteps(TransitionStep(GONE, DOZING, 1f, FINISHED))
-
- assertThat(results).isEqualTo(listOf(
- false,
- true,
- false,
- ))
-
- sendSteps(
+ sendSteps(
TransitionStep(DOZING, GONE, 0f, STARTED),
TransitionStep(DOZING, GONE, 0f, RUNNING),
- )
+ )
- assertThat(results).isEqualTo(listOf(
- false,
- true,
- false,
- ))
-
- sendSteps(TransitionStep(DOZING, GONE, 1f, FINISHED))
-
- assertThat(results).isEqualTo(listOf(
- false,
- true,
- false,
- true,
- ))
- }
+ assertThat(results)
+ .isEqualTo(
+ listOf(
+ false,
+ true,
+ false,
+ true,
+ )
+ )
+ }
@Test
- fun isFinishedInState() = testScope.runTest {
- val results by collectValues(underTest.isFinishedInState(GONE))
+ fun isFinishedInStateWhere() =
+ testScope.runTest {
+ val results by collectValues(underTest.isFinishedInStateWhere { it == GONE })
- sendSteps(
+ sendSteps(
TransitionStep(AOD, DOZING, 0f, STARTED),
TransitionStep(AOD, DOZING, 0.5f, RUNNING),
TransitionStep(AOD, DOZING, 1f, FINISHED),
- )
+ )
- assertThat(results).isEqualTo(listOf(
- false, // Finished in DOZING, not GONE.
- ))
+ assertThat(results)
+ .isEqualTo(
+ listOf(
+ false, // Finished in DOZING, not GONE.
+ )
+ )
- sendSteps(TransitionStep(DOZING, GONE, 0f, STARTED))
+ sendSteps(TransitionStep(DOZING, GONE, 0f, STARTED))
- assertThat(results).isEqualTo(listOf(
- false,
- ))
+ assertThat(results)
+ .isEqualTo(
+ listOf(
+ false,
+ )
+ )
- sendSteps(TransitionStep(DOZING, GONE, 0f, RUNNING))
+ sendSteps(TransitionStep(DOZING, GONE, 0f, RUNNING))
- assertThat(results).isEqualTo(listOf(
- false,
- ))
+ assertThat(results)
+ .isEqualTo(
+ listOf(
+ false,
+ )
+ )
- sendSteps(TransitionStep(DOZING, GONE, 1f, FINISHED))
+ sendSteps(TransitionStep(DOZING, GONE, 1f, FINISHED))
- assertThat(results).isEqualTo(listOf(
- false,
- true,
- ))
+ assertThat(results)
+ .isEqualTo(
+ listOf(
+ false,
+ true,
+ )
+ )
- sendSteps(
+ sendSteps(
TransitionStep(GONE, DOZING, 0f, STARTED),
TransitionStep(GONE, DOZING, 0f, RUNNING),
- )
+ )
- assertThat(results).isEqualTo(listOf(
- false,
- true,
- ))
+ assertThat(results)
+ .isEqualTo(
+ listOf(
+ false,
+ true,
+ )
+ )
- sendSteps(TransitionStep(GONE, DOZING, 1f, FINISHED))
+ sendSteps(TransitionStep(GONE, DOZING, 1f, FINISHED))
- assertThat(results).isEqualTo(listOf(
- false,
- true,
- false,
- ))
+ assertThat(results)
+ .isEqualTo(
+ listOf(
+ false,
+ true,
+ false,
+ )
+ )
- sendSteps(
+ sendSteps(
TransitionStep(DOZING, GONE, 0f, STARTED),
TransitionStep(DOZING, GONE, 0f, RUNNING),
- )
+ )
- assertThat(results).isEqualTo(listOf(
- false,
- true,
- false,
- ))
+ assertThat(results)
+ .isEqualTo(
+ listOf(
+ false,
+ true,
+ false,
+ )
+ )
- sendSteps(TransitionStep(DOZING, GONE, 1f, FINISHED))
+ sendSteps(TransitionStep(DOZING, GONE, 1f, FINISHED))
- assertThat(results).isEqualTo(listOf(
- false,
- true,
- false,
- true,
- ))
- }
+ assertThat(results)
+ .isEqualTo(
+ listOf(
+ false,
+ true,
+ false,
+ true,
+ )
+ )
+ }
@Test
- fun finishedKeyguardState_emitsAgainIfCancelledAndReversed() = testScope.runTest {
- val finishedStates by collectValues(underTest.finishedKeyguardState)
+ fun isFinishedInState() =
+ testScope.runTest {
+ val results by collectValues(underTest.isFinishedInState(GONE))
- // We default FINISHED in LOCKSCREEN.
- assertEquals(listOf(
- LOCKSCREEN
- ), finishedStates)
+ sendSteps(
+ TransitionStep(AOD, DOZING, 0f, STARTED),
+ TransitionStep(AOD, DOZING, 0.5f, RUNNING),
+ TransitionStep(AOD, DOZING, 1f, FINISHED),
+ )
- sendSteps(
+ assertThat(results)
+ .isEqualTo(
+ listOf(
+ false, // Finished in DOZING, not GONE.
+ )
+ )
+
+ sendSteps(TransitionStep(DOZING, GONE, 0f, STARTED))
+
+ assertThat(results)
+ .isEqualTo(
+ listOf(
+ false,
+ )
+ )
+
+ sendSteps(TransitionStep(DOZING, GONE, 0f, RUNNING))
+
+ assertThat(results)
+ .isEqualTo(
+ listOf(
+ false,
+ )
+ )
+
+ sendSteps(TransitionStep(DOZING, GONE, 1f, FINISHED))
+
+ assertThat(results)
+ .isEqualTo(
+ listOf(
+ false,
+ true,
+ )
+ )
+
+ sendSteps(
+ TransitionStep(GONE, DOZING, 0f, STARTED),
+ TransitionStep(GONE, DOZING, 0f, RUNNING),
+ )
+
+ assertThat(results)
+ .isEqualTo(
+ listOf(
+ false,
+ true,
+ )
+ )
+
+ sendSteps(TransitionStep(GONE, DOZING, 1f, FINISHED))
+
+ assertThat(results)
+ .isEqualTo(
+ listOf(
+ false,
+ true,
+ false,
+ )
+ )
+
+ sendSteps(
+ TransitionStep(DOZING, GONE, 0f, STARTED),
+ TransitionStep(DOZING, GONE, 0f, RUNNING),
+ )
+
+ assertThat(results)
+ .isEqualTo(
+ listOf(
+ false,
+ true,
+ false,
+ )
+ )
+
+ sendSteps(TransitionStep(DOZING, GONE, 1f, FINISHED))
+
+ assertThat(results)
+ .isEqualTo(
+ listOf(
+ false,
+ true,
+ false,
+ true,
+ )
+ )
+ }
+
+ @Test
+ fun finishedKeyguardState_emitsAgainIfCancelledAndReversed() =
+ testScope.runTest {
+ val finishedStates by collectValues(underTest.finishedKeyguardState)
+
+ // We default FINISHED in LOCKSCREEN.
+ assertEquals(listOf(LOCKSCREEN), finishedStates)
+
+ sendSteps(
TransitionStep(LOCKSCREEN, AOD, 0f, STARTED),
TransitionStep(LOCKSCREEN, AOD, 0.5f, RUNNING),
TransitionStep(LOCKSCREEN, AOD, 1f, FINISHED),
- )
+ )
- // We're FINISHED in AOD.
- assertEquals(listOf(
- LOCKSCREEN,
- AOD,
- ), finishedStates)
+ // We're FINISHED in AOD.
+ assertEquals(
+ listOf(
+ LOCKSCREEN,
+ AOD,
+ ),
+ finishedStates
+ )
- // Transition back to LOCKSCREEN.
- sendSteps(
+ // Transition back to LOCKSCREEN.
+ sendSteps(
TransitionStep(AOD, LOCKSCREEN, 0f, STARTED),
TransitionStep(AOD, LOCKSCREEN, 0.5f, RUNNING),
TransitionStep(AOD, LOCKSCREEN, 1f, FINISHED),
- )
+ )
- // We're FINISHED in LOCKSCREEN.
- assertEquals(listOf(
- LOCKSCREEN,
- AOD,
- LOCKSCREEN,
- ), finishedStates)
+ // We're FINISHED in LOCKSCREEN.
+ assertEquals(
+ listOf(
+ LOCKSCREEN,
+ AOD,
+ LOCKSCREEN,
+ ),
+ finishedStates
+ )
- sendSteps(
+ sendSteps(
TransitionStep(LOCKSCREEN, GONE, 0f, STARTED),
TransitionStep(LOCKSCREEN, GONE, 0.5f, RUNNING),
- )
+ )
- // We've STARTED a transition to GONE but not yet finished it so we're still FINISHED in
- // LOCKSCREEN.
- assertEquals(listOf(
- LOCKSCREEN,
- AOD,
- LOCKSCREEN,
- ), finishedStates)
+ // We've STARTED a transition to GONE but not yet finished it so we're still FINISHED in
+ // LOCKSCREEN.
+ assertEquals(
+ listOf(
+ LOCKSCREEN,
+ AOD,
+ LOCKSCREEN,
+ ),
+ finishedStates
+ )
- sendSteps(
+ sendSteps(
TransitionStep(LOCKSCREEN, GONE, 0.6f, CANCELED),
- )
+ )
- // We've CANCELED a transition to GONE, we're still FINISHED in LOCKSCREEN.
- assertEquals(listOf(
- LOCKSCREEN,
- AOD,
- LOCKSCREEN,
- ), finishedStates)
+ // We've CANCELED a transition to GONE, we're still FINISHED in LOCKSCREEN.
+ assertEquals(
+ listOf(
+ LOCKSCREEN,
+ AOD,
+ LOCKSCREEN,
+ ),
+ finishedStates
+ )
- sendSteps(
+ sendSteps(
TransitionStep(GONE, LOCKSCREEN, 0.6f, STARTED),
TransitionStep(GONE, LOCKSCREEN, 0.9f, RUNNING),
TransitionStep(GONE, LOCKSCREEN, 1f, FINISHED),
- )
+ )
- // Expect another emission of LOCKSCREEN, as we have FINISHED a second transition to
- // LOCKSCREEN after the cancellation.
- assertEquals(listOf(
- LOCKSCREEN,
- AOD,
- LOCKSCREEN,
- LOCKSCREEN,
- ), finishedStates)
- }
+ // Expect another emission of LOCKSCREEN, as we have FINISHED a second transition to
+ // LOCKSCREEN after the cancellation.
+ assertEquals(
+ listOf(
+ LOCKSCREEN,
+ AOD,
+ LOCKSCREEN,
+ LOCKSCREEN,
+ ),
+ finishedStates
+ )
+ }
+
+ @Test
+ fun testCurrentState() =
+ testScope.runTest {
+ val currentStates by collectValues(underTest.currentKeyguardState)
+
+ // We init the repo with a transition from OFF -> LOCKSCREEN.
+ assertEquals(
+ listOf(
+ OFF,
+ LOCKSCREEN,
+ ),
+ currentStates
+ )
+
+ sendSteps(
+ TransitionStep(LOCKSCREEN, AOD, 0f, STARTED),
+ )
+
+ // The current state should continue to be LOCKSCREEN as we transition to AOD.
+ assertEquals(
+ listOf(
+ OFF,
+ LOCKSCREEN,
+ ),
+ currentStates
+ )
+
+ sendSteps(
+ TransitionStep(LOCKSCREEN, AOD, 0.5f, RUNNING),
+ )
+
+ // The current state should continue to be LOCKSCREEN as we transition to AOD.
+ assertEquals(
+ listOf(
+ OFF,
+ LOCKSCREEN,
+ ),
+ currentStates
+ )
+
+ sendSteps(
+ TransitionStep(LOCKSCREEN, AOD, 0.6f, CANCELED),
+ )
+
+ // Once CANCELED, we're still currently in LOCKSCREEN...
+ assertEquals(
+ listOf(
+ OFF,
+ LOCKSCREEN,
+ ),
+ currentStates
+ )
+
+ sendSteps(
+ TransitionStep(AOD, LOCKSCREEN, 0.6f, STARTED),
+ )
+
+ // ...until STARTING back to LOCKSCREEN, at which point the "current" state should be
+ // the
+ // one we're transitioning from, despite never FINISHING in that state.
+ assertEquals(
+ listOf(
+ OFF,
+ LOCKSCREEN,
+ AOD,
+ ),
+ currentStates
+ )
+
+ sendSteps(
+ TransitionStep(AOD, LOCKSCREEN, 0.8f, RUNNING),
+ TransitionStep(AOD, LOCKSCREEN, 0.8f, FINISHED),
+ )
+
+ // FINSHING in LOCKSCREEN should update the current state to LOCKSCREEN.
+ assertEquals(
+ listOf(
+ OFF,
+ LOCKSCREEN,
+ AOD,
+ LOCKSCREEN,
+ ),
+ currentStates
+ )
+ }
+
+ @Test
+ fun testCurrentState_multipleCancellations_backToLastFinishedState() =
+ testScope.runTest {
+ val currentStates by collectValues(underTest.currentKeyguardState)
+
+ // We init the repo with a transition from OFF -> LOCKSCREEN.
+ assertEquals(
+ listOf(
+ OFF,
+ LOCKSCREEN,
+ ),
+ currentStates
+ )
+
+ sendSteps(
+ TransitionStep(LOCKSCREEN, GONE, 0f, STARTED),
+ TransitionStep(LOCKSCREEN, GONE, 0.5f, RUNNING),
+ TransitionStep(LOCKSCREEN, GONE, 1f, FINISHED),
+ )
+
+ assertEquals(
+ listOf(
+ // Default transition from OFF -> LOCKSCREEN
+ OFF,
+ LOCKSCREEN,
+ // Transitioned to GONE
+ GONE,
+ ),
+ currentStates
+ )
+
+ sendSteps(
+ TransitionStep(GONE, DOZING, 0f, STARTED),
+ TransitionStep(GONE, DOZING, 0.5f, RUNNING),
+ TransitionStep(GONE, DOZING, 0.6f, CANCELED),
+ )
+
+ assertEquals(
+ listOf(
+ OFF,
+ LOCKSCREEN,
+ GONE,
+ // Current state should not be DOZING until the post-cancelation transition is
+ // STARTED
+ ),
+ currentStates
+ )
+
+ sendSteps(
+ TransitionStep(DOZING, LOCKSCREEN, 0f, STARTED),
+ )
+
+ assertEquals(
+ listOf(
+ OFF,
+ LOCKSCREEN,
+ GONE,
+ // DOZING -> LS STARTED, DOZING is now the current state.
+ DOZING,
+ ),
+ currentStates
+ )
+
+ sendSteps(
+ TransitionStep(DOZING, LOCKSCREEN, 0.5f, RUNNING),
+ TransitionStep(DOZING, LOCKSCREEN, 0.6f, CANCELED),
+ )
+
+ assertEquals(
+ listOf(
+ OFF,
+ LOCKSCREEN,
+ GONE,
+ DOZING,
+ ),
+ currentStates
+ )
+
+ sendSteps(
+ TransitionStep(LOCKSCREEN, GONE, 0f, STARTED),
+ )
+
+ assertEquals(
+ listOf(
+ OFF,
+ LOCKSCREEN,
+ GONE,
+ DOZING,
+ // LS -> GONE STARTED, LS is now the current state.
+ LOCKSCREEN,
+ ),
+ currentStates
+ )
+
+ sendSteps(
+ TransitionStep(LOCKSCREEN, GONE, 0.5f, RUNNING),
+ TransitionStep(LOCKSCREEN, GONE, 1f, FINISHED),
+ )
+
+ assertEquals(
+ listOf(
+ OFF,
+ LOCKSCREEN,
+ GONE,
+ DOZING,
+ LOCKSCREEN,
+ // FINISHED in GONE, GONE is now the current state.
+ GONE,
+ ),
+ currentStates
+ )
+ }
private suspend fun sendSteps(vararg steps: TransitionStep) {
steps.forEach {
diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/scene/domain/interactor/WindowRootViewVisibilityInteractorTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/scene/domain/interactor/WindowRootViewVisibilityInteractorTest.kt
index 8be4eeb..f23716c 100644
--- a/packages/SystemUI/multivalentTests/src/com/android/systemui/scene/domain/interactor/WindowRootViewVisibilityInteractorTest.kt
+++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/scene/domain/interactor/WindowRootViewVisibilityInteractorTest.kt
@@ -16,6 +16,8 @@
package com.android.systemui.scene.domain.interactor
+import android.platform.test.annotations.DisableFlags
+import android.platform.test.annotations.EnableFlags
import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.filters.SmallTest
import com.android.internal.statusbar.IStatusBarService
@@ -28,7 +30,11 @@
import com.android.systemui.power.domain.interactor.PowerInteractorFactory
import com.android.systemui.scene.data.repository.WindowRootViewVisibilityRepository
import com.android.systemui.statusbar.NotificationPresenter
+import com.android.systemui.statusbar.notification.data.repository.ActiveNotificationListRepository
+import com.android.systemui.statusbar.notification.data.repository.setActiveNotifs
+import com.android.systemui.statusbar.notification.domain.interactor.ActiveNotificationsInteractor
import com.android.systemui.statusbar.notification.init.NotificationsController
+import com.android.systemui.statusbar.notification.shared.NotificationsLiveDataStoreRefactor
import com.android.systemui.statusbar.policy.HeadsUpManager
import com.android.systemui.util.concurrency.FakeExecutor
import com.android.systemui.util.mockito.any
@@ -37,6 +43,7 @@
import com.android.systemui.util.mockito.whenever
import com.android.systemui.util.time.FakeSystemClock
import com.google.common.truth.Truth.assertThat
+import kotlinx.coroutines.test.StandardTestDispatcher
import kotlinx.coroutines.test.TestScope
import kotlinx.coroutines.test.runCurrent
import kotlinx.coroutines.test.runTest
@@ -50,6 +57,7 @@
class WindowRootViewVisibilityInteractorTest : SysuiTestCase() {
private val testScope = TestScope()
+ private val testDispatcher = StandardTestDispatcher()
private val iStatusBarService = mock<IStatusBarService>()
private val executor = FakeExecutor(FakeSystemClock())
private val windowRootViewVisibilityRepository =
@@ -59,6 +67,9 @@
private val notificationPresenter = mock<NotificationPresenter>()
private val notificationsController = mock<NotificationsController>()
private val powerInteractor = PowerInteractorFactory.create().powerInteractor
+ private val activeNotificationsRepository = ActiveNotificationListRepository()
+ private val activeNotificationsInteractor =
+ ActiveNotificationsInteractor(activeNotificationsRepository, testDispatcher)
private val underTest =
WindowRootViewVisibilityInteractor(
@@ -67,6 +78,7 @@
keyguardRepository,
headsUpManager,
powerInteractor,
+ activeNotificationsInteractor,
)
.apply { setUp(notificationPresenter, notificationsController) }
@@ -257,7 +269,8 @@
}
@Test
- fun lockscreenShadeInteractive_hasHeadsUpAndNotifPresenterCollapsed_notifCountOne() =
+ @DisableFlags(NotificationsLiveDataStoreRefactor.FLAG_NAME)
+ fun lockscreenShadeInteractive_hasHeadsUpAndNotifPresenterCollapsed_flagOff_notifCountOne() =
testScope.runTest {
underTest.start()
@@ -273,6 +286,23 @@
}
@Test
+ @EnableFlags(NotificationsLiveDataStoreRefactor.FLAG_NAME)
+ fun lockscreenShadeInteractive_hasHeadsUpAndNotifPresenterCollapsed_flagOn_notifCountOne() =
+ testScope.runTest {
+ underTest.start()
+
+ whenever(headsUpManager.hasPinnedHeadsUp()).thenReturn(true)
+ whenever(notificationPresenter.isPresenterFullyCollapsed).thenReturn(true)
+ activeNotificationsRepository.setActiveNotifs(4)
+
+ makeLockscreenShadeVisible()
+
+ val notifCount = argumentCaptor<Int>()
+ verify(iStatusBarService).onPanelRevealed(any(), notifCount.capture())
+ assertThat(notifCount.value).isEqualTo(1)
+ }
+
+ @Test
fun lockscreenShadeInteractive_hasHeadsUpAndNullPresenter_notifCountOne() =
testScope.runTest {
underTest.start()
@@ -288,7 +318,8 @@
}
@Test
- fun lockscreenShadeInteractive_noHeadsUp_notifCountMatchesNotifController() =
+ @DisableFlags(NotificationsLiveDataStoreRefactor.FLAG_NAME)
+ fun lockscreenShadeInteractive_noHeadsUp_flagOff_notifCountMatchesNotifController() =
testScope.runTest {
underTest.start()
whenever(notificationPresenter.isPresenterFullyCollapsed).thenReturn(true)
@@ -304,7 +335,25 @@
}
@Test
- fun lockscreenShadeInteractive_notifPresenterNotCollapsed_notifCountMatchesNotifController() =
+ @EnableFlags(NotificationsLiveDataStoreRefactor.FLAG_NAME)
+ fun lockscreenShadeInteractive_noHeadsUp_flagOn_notifCountMatchesNotifController() =
+ testScope.runTest {
+ underTest.start()
+ whenever(notificationPresenter.isPresenterFullyCollapsed).thenReturn(true)
+
+ whenever(headsUpManager.hasPinnedHeadsUp()).thenReturn(false)
+ activeNotificationsRepository.setActiveNotifs(9)
+
+ makeLockscreenShadeVisible()
+
+ val notifCount = argumentCaptor<Int>()
+ verify(iStatusBarService).onPanelRevealed(any(), notifCount.capture())
+ assertThat(notifCount.value).isEqualTo(9)
+ }
+
+ @Test
+ @DisableFlags(NotificationsLiveDataStoreRefactor.FLAG_NAME)
+ fun lockscreenShadeInteractive_notifPresenterNotCollapsed_flagOff_notifCountMatchesNotifController() =
testScope.runTest {
underTest.start()
whenever(headsUpManager.hasPinnedHeadsUp()).thenReturn(true)
@@ -320,6 +369,23 @@
}
@Test
+ @EnableFlags(NotificationsLiveDataStoreRefactor.FLAG_NAME)
+ fun lockscreenShadeInteractive_notifPresenterNotCollapsed_flagOn_notifCountMatchesNotifController() =
+ testScope.runTest {
+ underTest.start()
+ whenever(headsUpManager.hasPinnedHeadsUp()).thenReturn(true)
+
+ whenever(notificationPresenter.isPresenterFullyCollapsed).thenReturn(false)
+ activeNotificationsRepository.setActiveNotifs(8)
+
+ makeLockscreenShadeVisible()
+
+ val notifCount = argumentCaptor<Int>()
+ verify(iStatusBarService).onPanelRevealed(any(), notifCount.capture())
+ assertThat(notifCount.value).isEqualTo(8)
+ }
+
+ @Test
fun lockscreenShadeInteractive_noHeadsUp_noNotifController_notifCountZero() =
testScope.runTest {
underTest.start()
diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/collection/render/GroupExpansionManagerTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/notification/collection/render/GroupExpansionManagerTest.kt
similarity index 69%
rename from packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/collection/render/GroupExpansionManagerTest.kt
rename to packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/notification/collection/render/GroupExpansionManagerTest.kt
index 0a10b2c..0c7ce97 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/collection/render/GroupExpansionManagerTest.kt
+++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/notification/collection/render/GroupExpansionManagerTest.kt
@@ -16,11 +16,10 @@
package com.android.systemui.statusbar.notification.collection.render
+import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.filters.SmallTest
import com.android.systemui.SysuiTestCase
import com.android.systemui.dump.DumpManager
-import com.android.systemui.flags.FakeFeatureFlagsClassic
-import com.android.systemui.flags.Flags
import com.android.systemui.statusbar.notification.collection.GroupEntryBuilder
import com.android.systemui.statusbar.notification.collection.ListEntry
import com.android.systemui.statusbar.notification.collection.NotifPipeline
@@ -34,18 +33,19 @@
import org.junit.Assert.assertThrows
import org.junit.Before
import org.junit.Test
+import org.junit.runner.RunWith
import org.mockito.Mockito.never
import org.mockito.Mockito.verify
import org.mockito.Mockito.verifyNoMoreInteractions
import org.mockito.Mockito.`when` as whenever
@SmallTest
+@RunWith(AndroidJUnit4::class)
class GroupExpansionManagerTest : SysuiTestCase() {
- private lateinit var gem: GroupExpansionManagerImpl
+ private lateinit var underTest: GroupExpansionManagerImpl
private val dumpManager: DumpManager = mock()
private val groupMembershipManager: GroupMembershipManager = mock()
- private val featureFlags = FakeFeatureFlagsClassic()
private val pipeline: NotifPipeline = mock()
private lateinit var beforeRenderListListener: OnBeforeRenderListListener
@@ -85,79 +85,57 @@
whenever(groupMembershipManager.getGroupSummary(summary1)).thenReturn(summary1)
whenever(groupMembershipManager.getGroupSummary(summary2)).thenReturn(summary2)
- gem = GroupExpansionManagerImpl(dumpManager, groupMembershipManager, featureFlags)
+ underTest = GroupExpansionManagerImpl(dumpManager, groupMembershipManager)
}
@Test
- fun testNotifyOnlyOnChange_enabled() {
- featureFlags.set(Flags.NOTIFICATION_GROUP_EXPANSION_CHANGE, true)
-
+ fun notifyOnlyOnChange() {
var listenerCalledCount = 0
- gem.registerGroupExpansionChangeListener { _, _ -> listenerCalledCount++ }
+ underTest.registerGroupExpansionChangeListener { _, _ -> listenerCalledCount++ }
- gem.setGroupExpanded(summary1, false)
+ underTest.setGroupExpanded(summary1, false)
assertThat(listenerCalledCount).isEqualTo(0)
- gem.setGroupExpanded(summary1, true)
+ underTest.setGroupExpanded(summary1, true)
assertThat(listenerCalledCount).isEqualTo(1)
- gem.setGroupExpanded(summary2, true)
+ underTest.setGroupExpanded(summary2, true)
assertThat(listenerCalledCount).isEqualTo(2)
- gem.setGroupExpanded(summary1, true)
+ underTest.setGroupExpanded(summary1, true)
assertThat(listenerCalledCount).isEqualTo(2)
- gem.setGroupExpanded(summary2, false)
+ underTest.setGroupExpanded(summary2, false)
assertThat(listenerCalledCount).isEqualTo(3)
}
@Test
- fun testNotifyOnlyOnChange_disabled() {
- featureFlags.set(Flags.NOTIFICATION_GROUP_EXPANSION_CHANGE, false)
-
- var listenerCalledCount = 0
- gem.registerGroupExpansionChangeListener { _, _ -> listenerCalledCount++ }
-
- gem.setGroupExpanded(summary1, false)
- assertThat(listenerCalledCount).isEqualTo(1)
- gem.setGroupExpanded(summary1, true)
- assertThat(listenerCalledCount).isEqualTo(2)
- gem.setGroupExpanded(summary2, true)
- assertThat(listenerCalledCount).isEqualTo(3)
- gem.setGroupExpanded(summary1, true)
- assertThat(listenerCalledCount).isEqualTo(4)
- gem.setGroupExpanded(summary2, false)
- assertThat(listenerCalledCount).isEqualTo(5)
- }
-
- @Test
- fun testExpandUnattachedEntry() {
- featureFlags.set(Flags.NOTIFICATION_GROUP_EXPANSION_CHANGE, true)
-
+ fun expandUnattachedEntry() {
// First, expand the entry when it is attached.
- gem.setGroupExpanded(summary1, true)
- assertThat(gem.isGroupExpanded(summary1)).isTrue()
+ underTest.setGroupExpanded(summary1, true)
+ assertThat(underTest.isGroupExpanded(summary1)).isTrue()
// Un-attach it, and un-expand it.
NotificationEntryBuilder.setNewParent(summary1, null)
- gem.setGroupExpanded(summary1, false)
+ underTest.setGroupExpanded(summary1, false)
// Expanding again should throw.
- assertThrows(IllegalArgumentException::class.java) { gem.setGroupExpanded(summary1, true) }
+ assertThrows(IllegalArgumentException::class.java) {
+ underTest.setGroupExpanded(summary1, true)
+ }
}
@Test
- fun testSyncWithPipeline() {
- featureFlags.set(Flags.NOTIFICATION_GROUP_EXPANSION_CHANGE, true)
- gem.attach(pipeline)
+ fun syncWithPipeline() {
+ underTest.attach(pipeline)
beforeRenderListListener = withArgCaptor {
verify(pipeline).addOnBeforeRenderListListener(capture())
}
val listener: OnGroupExpansionChangeListener = mock()
- gem.registerGroupExpansionChangeListener(listener)
+ underTest.registerGroupExpansionChangeListener(listener)
beforeRenderListListener.onBeforeRenderList(entries)
verify(listener, never()).onGroupExpansionChange(any(), any())
// Expand one of the groups.
- gem.setGroupExpanded(summary1, true)
+ underTest.setGroupExpanded(summary1, true)
verify(listener).onGroupExpansionChange(summary1.row, true)
// Empty the pipeline list and verify that the group is no longer expanded.
diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/notification/collection/render/GroupMembershipManagerTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/notification/collection/render/GroupMembershipManagerTest.kt
new file mode 100644
index 0000000..2cbcc5a
--- /dev/null
+++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/notification/collection/render/GroupMembershipManagerTest.kt
@@ -0,0 +1,124 @@
+/*
+ * Copyright (C) 2023 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.systemui.statusbar.notification.collection.render
+
+import androidx.test.ext.junit.runners.AndroidJUnit4
+import androidx.test.filters.SmallTest
+import com.android.systemui.SysuiTestCase
+import com.android.systemui.statusbar.notification.collection.GroupEntry
+import com.android.systemui.statusbar.notification.collection.GroupEntryBuilder
+import com.android.systemui.statusbar.notification.collection.NotificationEntryBuilder
+import com.google.common.truth.Truth.assertThat
+import org.junit.Test
+import org.junit.runner.RunWith
+
+@SmallTest
+@RunWith(AndroidJUnit4::class)
+class GroupMembershipManagerTest : SysuiTestCase() {
+ private var underTest = GroupMembershipManagerImpl()
+
+ @Test
+ fun isChildInGroup_topLevel() {
+ val topLevelEntry = NotificationEntryBuilder().setParent(GroupEntry.ROOT_ENTRY).build()
+ assertThat(underTest.isChildInGroup(topLevelEntry)).isFalse()
+ }
+
+ @Test
+ fun isChildInGroup_noParent() {
+ val noParentEntry = NotificationEntryBuilder().setParent(null).build()
+ assertThat(underTest.isChildInGroup(noParentEntry)).isFalse()
+ }
+
+ @Test
+ fun isChildInGroup_summary() {
+ val groupKey = "group"
+ val summary =
+ NotificationEntryBuilder()
+ .setGroup(mContext, groupKey)
+ .setGroupSummary(mContext, true)
+ .build()
+ GroupEntryBuilder().setKey(groupKey).setSummary(summary).build()
+
+ assertThat(underTest.isChildInGroup(summary)).isFalse()
+ }
+
+ @Test
+ fun isGroupSummary_topLevelEntry() {
+ val entry = NotificationEntryBuilder().setParent(GroupEntry.ROOT_ENTRY).build()
+ assertThat(underTest.isGroupSummary(entry)).isFalse()
+ }
+
+ @Test
+ fun isGroupSummary_summary() {
+ val groupKey = "group"
+ val summary =
+ NotificationEntryBuilder()
+ .setGroup(mContext, groupKey)
+ .setGroupSummary(mContext, true)
+ .build()
+ GroupEntryBuilder().setKey(groupKey).setSummary(summary).build()
+
+ assertThat(underTest.isGroupSummary(summary)).isTrue()
+ }
+
+ @Test
+ fun isGroupSummary_child() {
+ val groupKey = "group"
+ val summary =
+ NotificationEntryBuilder()
+ .setGroup(mContext, groupKey)
+ .setGroupSummary(mContext, true)
+ .build()
+ val entry = NotificationEntryBuilder().setGroup(mContext, groupKey).build()
+ GroupEntryBuilder().setKey(groupKey).setSummary(summary).addChild(entry).build()
+
+ assertThat(underTest.isGroupSummary(entry)).isFalse()
+ }
+
+ @Test
+ fun getGroupSummary_topLevelEntry() {
+ val entry = NotificationEntryBuilder().setParent(GroupEntry.ROOT_ENTRY).build()
+ assertThat(underTest.getGroupSummary(entry)).isNull()
+ }
+
+ @Test
+ fun getGroupSummary_summary() {
+ val groupKey = "group"
+ val summary =
+ NotificationEntryBuilder()
+ .setGroup(mContext, groupKey)
+ .setGroupSummary(mContext, true)
+ .build()
+ GroupEntryBuilder().setKey(groupKey).setSummary(summary).build()
+
+ assertThat(underTest.getGroupSummary(summary)).isEqualTo(summary)
+ }
+
+ @Test
+ fun getGroupSummary_child() {
+ val groupKey = "group"
+ val summary =
+ NotificationEntryBuilder()
+ .setGroup(mContext, groupKey)
+ .setGroupSummary(mContext, true)
+ .build()
+ val entry = NotificationEntryBuilder().setGroup(mContext, groupKey).build()
+ GroupEntryBuilder().setKey(groupKey).setSummary(summary).addChild(entry).build()
+
+ assertThat(underTest.getGroupSummary(entry)).isEqualTo(summary)
+ }
+}
diff --git a/packages/SystemUI/res-keyguard/drawable/bouncer_password_text_view_focused_background.xml b/packages/SystemUI/res-keyguard/drawable/bouncer_password_text_view_focused_background.xml
new file mode 100644
index 0000000..84b89ca
--- /dev/null
+++ b/packages/SystemUI/res-keyguard/drawable/bouncer_password_text_view_focused_background.xml
@@ -0,0 +1,27 @@
+<?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.
+-->
+<selector xmlns:android="http://schemas.android.com/apk/res/android">
+ <item android:state_focused="true">
+ <shape android:shape="rectangle">
+ <corners android:radius="16dp" />
+ <!--By default this outline will not show hence 0 width.
+ width is set programmatically when needed and is gated by the flag:
+ com.android.systemui.Flags.pinInputFieldStyledFocusState-->
+ <stroke android:width="0dp"
+ android:color="@color/bouncer_password_focus_color" />
+ </shape>
+ </item>
+</selector>
\ No newline at end of file
diff --git a/packages/SystemUI/res-keyguard/layout/keyguard_bouncer_message_area.xml b/packages/SystemUI/res-keyguard/layout/keyguard_bouncer_message_area.xml
index 66c54f2..0b35559 100644
--- a/packages/SystemUI/res-keyguard/layout/keyguard_bouncer_message_area.xml
+++ b/packages/SystemUI/res-keyguard/layout/keyguard_bouncer_message_area.xml
@@ -23,7 +23,7 @@
android:layout_marginTop="@dimen/keyguard_lock_padding"
android:importantForAccessibility="no"
android:ellipsize="marquee"
- android:focusable="true"
+ android:focusable="false"
android:gravity="center"
android:singleLine="true" />
</merge>
diff --git a/packages/SystemUI/res-keyguard/values/dimens.xml b/packages/SystemUI/res-keyguard/values/dimens.xml
index 0628c3e..ddad1e3 100644
--- a/packages/SystemUI/res-keyguard/values/dimens.xml
+++ b/packages/SystemUI/res-keyguard/values/dimens.xml
@@ -25,6 +25,12 @@
<!-- Maximum width of the sliding KeyguardSecurityContainer -->
<dimen name="keyguard_security_width">420dp</dimen>
+ <!-- Width for the keyguard pin input field -->
+ <dimen name="keyguard_pin_field_width">292dp</dimen>
+
+ <!-- Width for the keyguard pin input field -->
+ <dimen name="keyguard_pin_field_height">48dp</dimen>
+
<!-- Height of the sliding KeyguardSecurityContainer
(includes 2x keyguard_security_view_top_margin) -->
<dimen name="keyguard_security_height">420dp</dimen>
diff --git a/packages/SystemUI/res-keyguard/values/strings.xml b/packages/SystemUI/res-keyguard/values/strings.xml
index 565ed10..f51e109 100644
--- a/packages/SystemUI/res-keyguard/values/strings.xml
+++ b/packages/SystemUI/res-keyguard/values/strings.xml
@@ -62,10 +62,10 @@
<string name="keyguard_plugged_in_charging_slowly"><xliff:g id="percentage">%s</xliff:g> • Charging slowly</string>
<!-- When the lock screen is showing and the phone plugged in, and the defend mode is triggered, say that charging is temporarily limited. -->
- <string name="keyguard_plugged_in_charging_limited"><xliff:g id="percentage">%s</xliff:g> • Charging optimized to protect battery</string>
+ <string name="keyguard_plugged_in_charging_limited"><xliff:g id="percentage">%s</xliff:g> • Charging on hold to protect battery</string>
<!-- When the lock screen is showing and the phone plugged in with incompatible charger. -->
- <string name="keyguard_plugged_in_incompatible_charger"><xliff:g id="percentage">%s</xliff:g> • Issue with charging accessory</string>
+ <string name="keyguard_plugged_in_incompatible_charger"><xliff:g id="percentage">%s</xliff:g> • Check charging accessory</string>
<!-- SIM messages --><skip />
<!-- When the user inserts a sim card from an unsupported network, it becomes network locked -->
diff --git a/packages/SystemUI/res-keyguard/values/styles.xml b/packages/SystemUI/res-keyguard/values/styles.xml
index 2cca951..4789a22 100644
--- a/packages/SystemUI/res-keyguard/values/styles.xml
+++ b/packages/SystemUI/res-keyguard/values/styles.xml
@@ -76,6 +76,7 @@
</style>
<style name="Widget.TextView.Password" parent="@android:style/Widget.TextView">
<item name="android:fontFamily">@*android:string/config_headlineFontFamily</item>
+ <item name="android:background">@drawable/bouncer_password_text_view_focused_background</item>
<item name="android:gravity">center</item>
<item name="android:textColor">?android:attr/textColorPrimary</item>
</style>
diff --git a/packages/SystemUI/res/drawable/ic_satellite_connected_0.xml b/packages/SystemUI/res/drawable/ic_satellite_connected_0.xml
deleted file mode 100644
index 045c19e..0000000
--- a/packages/SystemUI/res/drawable/ic_satellite_connected_0.xml
+++ /dev/null
@@ -1,49 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
- ~ Copyright (C) 2023 The Android Open Source Project
- ~
- ~ Licensed under the Apache License, Version 2.0 (the "License");
- ~ you may not use this file except in compliance with the License.
- ~ You may obtain a copy of the License at
- ~
- ~ http://www.apache.org/licenses/LICENSE-2.0
- ~
- ~ Unless required by applicable law or agreed to in writing, software
- ~ distributed under the License is distributed on an "AS IS" BASIS,
- ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- ~ See the License for the specific language governing permissions and
- ~ limitations under the License.
- -->
-
-<vector xmlns:android="http://schemas.android.com/apk/res/android"
- android:width="24dp"
- android:height="24dp"
- android:viewportWidth="24.0"
- android:viewportHeight="24.0">
- <path
- android:pathData="M14.73,3.36L17.63,6.2C17.83,6.39 17.83,6.71 17.63,6.91L16.89,7.65C16.69,7.85 16.37,7.85 16.18,7.65L13.34,4.78C13.15,4.59 13.15,4.28 13.34,4.08L14.01,3.37C14.2,3.17 14.52,3.16 14.72,3.36H14.73ZM14.37,1C13.85,1 13.32,1.2 12.93,1.61L11.56,3.06C10.8,3.84 10.81,5.09 11.58,5.86L15.13,9.41C15.52,9.8 16.03,10 16.55,10C17.07,10 17.58,9.8 17.97,9.41L19.42,7.96C20.21,7.17 20.2,5.89 19.4,5.12L15.77,1.57C15.38,1.19 14.88,1 14.37,1Z"
- android:fillColor="#fff"/>
- <path
- android:pathData="M4.73,13.36L7.63,16.2C7.83,16.39 7.83,16.71 7.63,16.91L6.89,17.65C6.69,17.85 6.37,17.85 6.18,17.65L3.34,14.78C3.15,14.59 3.15,14.28 3.34,14.08L4.01,13.37C4.2,13.17 4.52,13.16 4.72,13.36H4.73ZM4.37,11C3.85,11 3.32,11.2 2.93,11.61L1.56,13.06C0.8,13.84 0.81,15.09 1.58,15.86L5.13,19.41C5.52,19.8 6.03,20 6.55,20C7.07,20 7.58,19.8 7.97,19.41L9.42,17.96C10.21,17.17 10.2,15.89 9.4,15.12L5.77,11.57C5.38,11.19 4.88,11 4.37,11Z"
- android:fillColor="#fff"/>
- <path
- android:pathData="M8.622,5.368L5.372,8.618L10.112,13.358C11.009,14.255 12.464,14.255 13.362,13.358C14.259,12.46 14.259,11.005 13.362,10.108L8.622,5.368Z"
- android:fillColor="#fff"/>
- <path
- android:pathData="M16.766,3.169L13.471,6.464L14.532,7.525L17.827,4.23L16.766,3.169Z"
- android:fillColor="#fff"/>
- <path
- android:pathData="M14.728,5.226L3.478,16.476L4.538,17.536L15.788,6.286L14.728,5.226Z"
- android:fillColor="#fff"/>
- <path
- android:pathData="M12.63,9.38L9.38,12.63L4.67,7.92C3.77,7.02 3.77,5.57 4.67,4.67C5.57,3.77 7.02,3.77 7.92,4.67L12.63,9.38Z"
- android:fillColor="#fff"/>
- <path
- android:pathData="M11,22.48V21.48C11,21.21 11.22,21 11.49,20.99C16.63,20.8 20.75,16.62 20.99,11.48C21,11.21 21.21,11 21.48,11H22.48C22.76,11 23,11.24 22.99,11.52C22.72,17.73 17.73,22.73 11.52,22.99C11.24,23 11,22.77 11,22.48Z"
- android:fillAlpha="0.3"
- android:fillColor="#fff"/>
- <path
- android:pathData="M11,18.98V17.98C11,17.71 11.21,17.51 11.48,17.49C14.69,17.26 17.33,14.7 17.49,11.49C17.5,11.22 17.71,11.01 17.98,11.01H18.79C19.26,11.01 19.5,11.25 19.48,11.53C19.22,15.8 15.79,19.23 11.52,19.49C11.24,19.51 11,19.27 11,18.99V18.98Z"
- android:fillAlpha="0.3"
- android:fillColor="#fff"/>
-</vector>
diff --git a/packages/SystemUI/res/drawable/ic_satellite_connected_1.xml b/packages/SystemUI/res/drawable/ic_satellite_connected_1.xml
deleted file mode 100644
index 5e012ab..0000000
--- a/packages/SystemUI/res/drawable/ic_satellite_connected_1.xml
+++ /dev/null
@@ -1,49 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
- ~ Copyright (C) 2023 The Android Open Source Project
- ~
- ~ Licensed under the Apache License, Version 2.0 (the "License");
- ~ you may not use this file except in compliance with the License.
- ~ You may obtain a copy of the License at
- ~
- ~ http://www.apache.org/licenses/LICENSE-2.0
- ~
- ~ Unless required by applicable law or agreed to in writing, software
- ~ distributed under the License is distributed on an "AS IS" BASIS,
- ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- ~ See the License for the specific language governing permissions and
- ~ limitations under the License.
- -->
-
-<vector xmlns:android="http://schemas.android.com/apk/res/android"
- android:width="24dp"
- android:height="24dp"
- android:viewportWidth="24.0"
- android:viewportHeight="24.0">
- <path
- android:pathData="M14.73,3.36L17.63,6.2C17.83,6.39 17.83,6.71 17.63,6.91L16.89,7.65C16.69,7.85 16.37,7.85 16.18,7.65L13.34,4.78C13.15,4.59 13.15,4.28 13.34,4.08L14.01,3.37C14.2,3.17 14.52,3.16 14.72,3.36H14.73ZM14.37,1C13.85,1 13.32,1.2 12.93,1.61L11.56,3.06C10.8,3.84 10.81,5.09 11.58,5.86L15.13,9.41C15.52,9.8 16.03,10 16.55,10C17.07,10 17.58,9.8 17.97,9.41L19.42,7.96C20.21,7.17 20.2,5.89 19.4,5.12L15.77,1.57C15.38,1.19 14.88,1 14.37,1Z"
- android:fillColor="#fff"/>
- <path
- android:pathData="M4.73,13.36L7.63,16.2C7.83,16.39 7.83,16.71 7.63,16.91L6.89,17.65C6.69,17.85 6.37,17.85 6.18,17.65L3.34,14.78C3.15,14.59 3.15,14.28 3.34,14.08L4.01,13.37C4.2,13.17 4.52,13.16 4.72,13.36H4.73ZM4.37,11C3.85,11 3.32,11.2 2.93,11.61L1.56,13.06C0.8,13.84 0.81,15.09 1.58,15.86L5.13,19.41C5.52,19.8 6.03,20 6.55,20C7.07,20 7.58,19.8 7.97,19.41L9.42,17.96C10.21,17.17 10.2,15.89 9.4,15.12L5.77,11.57C5.38,11.19 4.88,11 4.37,11Z"
- android:fillColor="#fff"/>
- <path
- android:pathData="M8.622,5.368L5.372,8.618L10.112,13.358C11.009,14.255 12.464,14.255 13.362,13.358C14.259,12.46 14.259,11.005 13.362,10.108L8.622,5.368Z"
- android:fillColor="#fff"/>
- <path
- android:pathData="M16.766,3.169L13.471,6.464L14.532,7.525L17.827,4.23L16.766,3.169Z"
- android:fillColor="#fff"/>
- <path
- android:pathData="M14.728,5.226L3.478,16.476L4.538,17.536L15.788,6.286L14.728,5.226Z"
- android:fillColor="#fff"/>
- <path
- android:pathData="M12.63,9.38L9.38,12.63L4.67,7.92C3.77,7.02 3.77,5.57 4.67,4.67C5.57,3.77 7.02,3.77 7.92,4.67L12.63,9.38Z"
- android:fillColor="#fff"/>
- <path
- android:pathData="M11,22.48V21.48C11,21.21 11.22,21 11.49,20.99C16.63,20.8 20.75,16.62 20.99,11.48C21,11.21 21.21,11 21.48,11H22.48C22.76,11 23,11.24 22.99,11.52C22.72,17.73 17.73,22.73 11.52,22.99C11.24,23 11,22.77 11,22.48Z"
- android:fillAlpha="0.3"
- android:fillColor="#fff"/>
- <path
- android:pathData="M11,18.98V17.98C11,17.71 11.21,17.51 11.48,17.49C14.69,17.26 17.33,14.7 17.49,11.49C17.5,11.22 17.71,11.01 17.98,11.01H18.79C19.26,11.01 19.5,11.25 19.48,11.53C19.22,15.8 15.79,19.23 11.52,19.49C11.24,19.51 11,19.27 11,18.99V18.98Z"
- android:fillColor="#fff"/>
-</vector>
-
diff --git a/packages/SystemUI/res/drawable/ic_satellite_connected_2.xml b/packages/SystemUI/res/drawable/ic_satellite_connected_2.xml
deleted file mode 100644
index d8a9a70..0000000
--- a/packages/SystemUI/res/drawable/ic_satellite_connected_2.xml
+++ /dev/null
@@ -1,47 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
- ~ Copyright (C) 2023 The Android Open Source Project
- ~
- ~ Licensed under the Apache License, Version 2.0 (the "License");
- ~ you may not use this file except in compliance with the License.
- ~ You may obtain a copy of the License at
- ~
- ~ http://www.apache.org/licenses/LICENSE-2.0
- ~
- ~ Unless required by applicable law or agreed to in writing, software
- ~ distributed under the License is distributed on an "AS IS" BASIS,
- ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- ~ See the License for the specific language governing permissions and
- ~ limitations under the License.
- -->
-
-<vector xmlns:android="http://schemas.android.com/apk/res/android"
- android:width="24dp"
- android:height="24dp"
- android:viewportWidth="24.0"
- android:viewportHeight="24.0">
- <path
- android:pathData="M14.73,3.36L17.63,6.2C17.83,6.39 17.83,6.71 17.63,6.91L16.89,7.65C16.69,7.85 16.37,7.85 16.18,7.65L13.34,4.78C13.15,4.59 13.15,4.28 13.34,4.08L14.01,3.37C14.2,3.17 14.52,3.16 14.72,3.36H14.73ZM14.37,1C13.85,1 13.32,1.2 12.93,1.61L11.56,3.06C10.8,3.84 10.81,5.09 11.58,5.86L15.13,9.41C15.52,9.8 16.03,10 16.55,10C17.07,10 17.58,9.8 17.97,9.41L19.42,7.96C20.21,7.17 20.2,5.89 19.4,5.12L15.77,1.57C15.38,1.19 14.88,1 14.37,1Z"
- android:fillColor="#fff"/>
- <path
- android:pathData="M4.73,13.36L7.63,16.2C7.83,16.39 7.83,16.71 7.63,16.91L6.89,17.65C6.69,17.85 6.37,17.85 6.18,17.65L3.34,14.78C3.15,14.59 3.15,14.28 3.34,14.08L4.01,13.37C4.2,13.17 4.52,13.16 4.72,13.36H4.73ZM4.37,11C3.85,11 3.32,11.2 2.93,11.61L1.56,13.06C0.8,13.84 0.81,15.09 1.58,15.86L5.13,19.41C5.52,19.8 6.03,20 6.55,20C7.07,20 7.58,19.8 7.97,19.41L9.42,17.96C10.21,17.17 10.2,15.89 9.4,15.12L5.77,11.57C5.38,11.19 4.88,11 4.37,11Z"
- android:fillColor="#fff"/>
- <path
- android:pathData="M8.622,5.368L5.372,8.618L10.112,13.358C11.009,14.255 12.464,14.255 13.362,13.358C14.259,12.46 14.259,11.005 13.362,10.108L8.622,5.368Z"
- android:fillColor="#fff"/>
- <path
- android:pathData="M16.766,3.169L13.471,6.464L14.532,7.525L17.827,4.23L16.766,3.169Z"
- android:fillColor="#fff"/>
- <path
- android:pathData="M14.728,5.226L3.478,16.476L4.538,17.536L15.788,6.286L14.728,5.226Z"
- android:fillColor="#fff"/>
- <path
- android:pathData="M12.63,9.38L9.38,12.63L4.67,7.92C3.77,7.02 3.77,5.57 4.67,4.67C5.57,3.77 7.02,3.77 7.92,4.67L12.63,9.38Z"
- android:fillColor="#fff"/>
- <path
- android:pathData="M11,22.48V21.48C11,21.21 11.22,21 11.49,20.99C16.63,20.8 20.75,16.62 20.99,11.48C21,11.21 21.21,11 21.48,11H22.48C22.76,11 23,11.24 22.99,11.52C22.72,17.73 17.73,22.73 11.52,22.99C11.24,23 11,22.77 11,22.48Z"
- android:fillColor="#fff"/>
- <path
- android:pathData="M11,18.98V17.98C11,17.71 11.21,17.51 11.48,17.49C14.69,17.26 17.33,14.7 17.49,11.49C17.5,11.22 17.71,11.01 17.98,11.01H18.79C19.26,11.01 19.5,11.25 19.48,11.53C19.22,15.8 15.79,19.23 11.52,19.49C11.24,19.51 11,19.27 11,18.99V18.98Z"
- android:fillColor="#fff"/>
-</vector>
diff --git a/packages/SystemUI/res/drawable/ic_satellite_not_connected.xml b/packages/SystemUI/res/drawable/ic_satellite_not_connected.xml
deleted file mode 100644
index dec9930..0000000
--- a/packages/SystemUI/res/drawable/ic_satellite_not_connected.xml
+++ /dev/null
@@ -1,42 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
- ~ Copyright (C) 2023 The Android Open Source Project
- ~
- ~ Licensed under the Apache License, Version 2.0 (the "License");
- ~ you may not use this file except in compliance with the License.
- ~ You may obtain a copy of the License at
- ~
- ~ http://www.apache.org/licenses/LICENSE-2.0
- ~
- ~ Unless required by applicable law or agreed to in writing, software
- ~ distributed under the License is distributed on an "AS IS" BASIS,
- ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- ~ See the License for the specific language governing permissions and
- ~ limitations under the License.
- -->
-
-<vector xmlns:android="http://schemas.android.com/apk/res/android"
- android:width="24dp"
- android:height="24dp"
- android:viewportWidth="24.0"
- android:viewportHeight="24.0"
- >
- <path
- android:pathData="M14.73,3.36L17.63,6.2C17.83,6.39 17.83,6.71 17.63,6.91L16.89,7.65C16.69,7.85 16.37,7.85 16.18,7.65L13.34,4.78C13.15,4.59 13.15,4.28 13.34,4.08L14.01,3.37C14.2,3.17 14.52,3.16 14.72,3.36H14.73ZM14.37,1C13.85,1 13.32,1.2 12.93,1.61L11.56,3.06C10.8,3.84 10.81,5.09 11.58,5.86L15.13,9.41C15.52,9.8 16.03,10 16.55,10C17.07,10 17.58,9.8 17.97,9.41L19.42,7.96C20.21,7.17 20.2,5.89 19.4,5.12L15.77,1.57C15.38,1.19 14.88,1 14.37,1Z"
- android:fillColor="#fff"/>
- <path
- android:pathData="M4.73,13.36L7.63,16.2C7.83,16.39 7.83,16.71 7.63,16.91L6.89,17.65C6.69,17.85 6.37,17.85 6.18,17.65L3.34,14.78C3.15,14.59 3.15,14.28 3.34,14.08L4.01,13.37C4.2,13.17 4.52,13.16 4.72,13.36H4.73ZM4.37,11C3.85,11 3.32,11.2 2.93,11.61L1.56,13.06C0.8,13.84 0.81,15.09 1.58,15.86L5.13,19.41C5.52,19.8 6.03,20 6.55,20C7.07,20 7.58,19.8 7.97,19.41L9.42,17.96C10.21,17.17 10.2,15.89 9.4,15.12L5.77,11.57C5.38,11.19 4.88,11 4.37,11Z"
- android:fillColor="#fff"/>
- <path
- android:pathData="M8.622,5.368L5.372,8.618L10.112,13.358C11.009,14.255 12.464,14.255 13.362,13.358C14.259,12.46 14.259,11.005 13.362,10.108L8.622,5.368Z"
- android:fillColor="#fff"/>
- <path
- android:pathData="M16.766,3.169L13.471,6.464L14.532,7.525L17.827,4.23L16.766,3.169Z"
- android:fillColor="#fff"/>
- <path
- android:pathData="M14.728,5.226L3.478,16.476L4.538,17.536L15.788,6.286L14.728,5.226Z"
- android:fillColor="#fff"/>
- <path
- android:pathData="M12.63,9.38L9.38,12.63L4.67,7.92C3.77,7.02 3.77,5.57 4.67,4.67C5.57,3.77 7.02,3.77 7.92,4.67L12.63,9.38Z"
- android:fillColor="#fff"/>
-</vector>
diff --git a/packages/SystemUI/res/layout/bindable_status_bar_icon.xml b/packages/SystemUI/res/layout/bindable_status_bar_icon.xml
deleted file mode 100644
index ee4d05c..0000000
--- a/packages/SystemUI/res/layout/bindable_status_bar_icon.xml
+++ /dev/null
@@ -1,34 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?><!--
- ~ Copyright (C) 2023 The Android Open Source Project
- ~
- ~ Licensed under the Apache License, Version 2.0 (the "License");
- ~ you may not use this file except in compliance with the License.
- ~ You may obtain a copy of the License at
- ~
- ~ http://www.apache.org/licenses/LICENSE-2.0
- ~
- ~ Unless required by applicable law or agreed to in writing, software
- ~ distributed under the License is distributed on an "AS IS" BASIS,
- ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- ~ See the License for the specific language governing permissions and
- ~ limitations under the License.
- -->
-
-<!-- Base layout that provides a single bindable icon_view id image view -->
-<com.android.systemui.statusbar.pipeline.shared.ui.view.SingleBindableStatusBarIconView
- xmlns:android="http://schemas.android.com/apk/res/android"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:gravity="center_vertical"
- >
-
- <ImageView
- android:id="@+id/icon_view"
- android:layout_height="@dimen/status_bar_bindable_icon_size"
- android:layout_width="wrap_content"
- android:layout_gravity="center_vertical"
- android:padding="@dimen/status_bar_bindable_icon_padding"
- android:scaleType="fitCenter"
- />
-
-</com.android.systemui.statusbar.pipeline.shared.ui.view.SingleBindableStatusBarIconView>
diff --git a/packages/SystemUI/res/values-night/colors.xml b/packages/SystemUI/res/values-night/colors.xml
index bcc3c83..61a323d4 100644
--- a/packages/SystemUI/res/values-night/colors.xml
+++ b/packages/SystemUI/res/values-night/colors.xml
@@ -93,6 +93,8 @@
<color name="qs_user_switcher_selected_avatar_icon_color">#202124</color>
<!-- Color of background circle of user avatars in quick settings user switcher -->
<color name="qs_user_switcher_avatar_background">#3C4043</color>
+ <!-- Color of border for keyguard password input when focused -->
+ <color name="bouncer_password_focus_color">@*android:color/system_secondary_dark</color>
<!-- Accessibility floating menu -->
<color name="accessibility_floating_menu_background">#B3000000</color> <!-- 70% -->
diff --git a/packages/SystemUI/res/values/colors.xml b/packages/SystemUI/res/values/colors.xml
index 8be1cc7..3839dd9 100644
--- a/packages/SystemUI/res/values/colors.xml
+++ b/packages/SystemUI/res/values/colors.xml
@@ -56,6 +56,8 @@
<color name="kg_user_switcher_restricted_avatar_icon_color">@color/GM2_grey_600</color>
<!-- Color of background circle of user avatars in keyguard user switcher -->
<color name="user_avatar_color_bg">?android:attr/colorBackgroundFloating</color>
+ <!-- Color of border for keyguard password input when focused -->
+ <color name="bouncer_password_focus_color">@*android:color/system_secondary_light</color>
<!-- Icon color for user avatars in user switcher quick settings -->
<color name="qs_user_switcher_avatar_icon_color">#3C4043</color>
diff --git a/packages/SystemUI/res/values/dimens.xml b/packages/SystemUI/res/values/dimens.xml
index 9a4520c..798fc06b 100644
--- a/packages/SystemUI/res/values/dimens.xml
+++ b/packages/SystemUI/res/values/dimens.xml
@@ -151,8 +151,6 @@
<dimen name="status_bar_icon_size_sp">@*android:dimen/status_bar_icon_size_sp</dimen>
<!-- Original dp height of notification icons in the status bar -->
<dimen name="status_bar_icon_size">@*android:dimen/status_bar_icon_size</dimen>
- <dimen name="status_bar_bindable_icon_size">20sp</dimen>
- <dimen name="status_bar_bindable_icon_padding">2sp</dimen>
<!-- Default horizontal drawable padding for status bar icons. -->
<dimen name="status_bar_horizontal_padding">2.5sp</dimen>
diff --git a/packages/SystemUI/res/values/ids.xml b/packages/SystemUI/res/values/ids.xml
index 6e035e8..ec4c7d5 100644
--- a/packages/SystemUI/res/values/ids.xml
+++ b/packages/SystemUI/res/values/ids.xml
@@ -249,6 +249,9 @@
-->
<item type="id" name="tag_smartspace_view" />
+ <!-- ID of the Scene Container root Composable view -->
+ <item type='id' name="scene_container_root_composable" />
+
<!-- Tag set on the Compose implementation of the QS footer actions. -->
<item type="id" name="tag_compose_qs_footer_actions" />
diff --git a/packages/SystemUI/src/com/android/keyguard/KeyguardClockSwitch.java b/packages/SystemUI/src/com/android/keyguard/KeyguardClockSwitch.java
index a5a545a..033f93b 100644
--- a/packages/SystemUI/src/com/android/keyguard/KeyguardClockSwitch.java
+++ b/packages/SystemUI/src/com/android/keyguard/KeyguardClockSwitch.java
@@ -3,6 +3,7 @@
import static com.android.keyguard.KeyguardStatusAreaView.TRANSLATE_X_CLOCK_DESIGN;
import static com.android.keyguard.KeyguardStatusAreaView.TRANSLATE_Y_CLOCK_DESIGN;
import static com.android.keyguard.KeyguardStatusAreaView.TRANSLATE_Y_CLOCK_SIZE;
+import static com.android.systemui.Flags.migrateClocksToBlueprint;
import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
@@ -191,11 +192,11 @@
@Override
protected void onFinishInflate() {
super.onFinishInflate();
-
- mSmallClockFrame = findViewById(R.id.lockscreen_clock_view);
- mLargeClockFrame = findViewById(R.id.lockscreen_clock_view_large);
- mStatusArea = findViewById(R.id.keyguard_status_area);
-
+ if (!migrateClocksToBlueprint()) {
+ mSmallClockFrame = findViewById(R.id.lockscreen_clock_view);
+ mLargeClockFrame = findViewById(R.id.lockscreen_clock_view_large);
+ mStatusArea = findViewById(R.id.keyguard_status_area);
+ }
onConfigChanged();
}
diff --git a/packages/SystemUI/src/com/android/keyguard/KeyguardInputViewController.java b/packages/SystemUI/src/com/android/keyguard/KeyguardInputViewController.java
index 66f965a..efd8f7f 100644
--- a/packages/SystemUI/src/com/android/keyguard/KeyguardInputViewController.java
+++ b/packages/SystemUI/src/com/android/keyguard/KeyguardInputViewController.java
@@ -37,6 +37,7 @@
import com.android.systemui.classifier.FalsingCollector;
import com.android.systemui.dagger.qualifiers.Main;
import com.android.systemui.flags.FeatureFlags;
+import com.android.systemui.keyboard.data.repository.KeyboardRepository;
import com.android.systemui.log.BouncerLogger;
import com.android.systemui.res.R;
import com.android.systemui.statusbar.policy.DevicePostureController;
@@ -210,6 +211,7 @@
private final FeatureFlags mFeatureFlags;
private final SelectedUserInteractor mSelectedUserInteractor;
private final UiEventLogger mUiEventLogger;
+ private final KeyboardRepository mKeyboardRepository;
@Inject
public Factory(KeyguardUpdateMonitor keyguardUpdateMonitor,
@@ -223,7 +225,8 @@
DevicePostureController devicePostureController,
KeyguardViewController keyguardViewController,
FeatureFlags featureFlags, SelectedUserInteractor selectedUserInteractor,
- UiEventLogger uiEventLogger) {
+ UiEventLogger uiEventLogger,
+ KeyboardRepository keyboardRepository) {
mKeyguardUpdateMonitor = keyguardUpdateMonitor;
mLockPatternUtils = lockPatternUtils;
mLatencyTracker = latencyTracker;
@@ -240,6 +243,7 @@
mFeatureFlags = featureFlags;
mSelectedUserInteractor = selectedUserInteractor;
mUiEventLogger = uiEventLogger;
+ mKeyboardRepository = keyboardRepository;
}
/** Create a new {@link KeyguardInputViewController}. */
@@ -268,19 +272,22 @@
keyguardSecurityCallback, mMessageAreaControllerFactory, mLatencyTracker,
mLiftToActivateListener, emergencyButtonController, mFalsingCollector,
mDevicePostureController, mFeatureFlags, mSelectedUserInteractor,
- mUiEventLogger);
+ mUiEventLogger, mKeyboardRepository
+ );
} else if (keyguardInputView instanceof KeyguardSimPinView) {
return new KeyguardSimPinViewController((KeyguardSimPinView) keyguardInputView,
mKeyguardUpdateMonitor, securityMode, mLockPatternUtils,
keyguardSecurityCallback, mMessageAreaControllerFactory, mLatencyTracker,
mLiftToActivateListener, mTelephonyManager, mFalsingCollector,
- emergencyButtonController, mFeatureFlags, mSelectedUserInteractor);
+ emergencyButtonController, mFeatureFlags, mSelectedUserInteractor,
+ mKeyboardRepository);
} else if (keyguardInputView instanceof KeyguardSimPukView) {
return new KeyguardSimPukViewController((KeyguardSimPukView) keyguardInputView,
mKeyguardUpdateMonitor, securityMode, mLockPatternUtils,
keyguardSecurityCallback, mMessageAreaControllerFactory, mLatencyTracker,
mLiftToActivateListener, mTelephonyManager, mFalsingCollector,
- emergencyButtonController, mFeatureFlags, mSelectedUserInteractor);
+ emergencyButtonController, mFeatureFlags, mSelectedUserInteractor,
+ mKeyboardRepository);
}
throw new RuntimeException("Unable to find controller for " + keyguardInputView);
diff --git a/packages/SystemUI/src/com/android/keyguard/KeyguardPinBasedInputView.java b/packages/SystemUI/src/com/android/keyguard/KeyguardPinBasedInputView.java
index 36fe75f..fcff0db 100644
--- a/packages/SystemUI/src/com/android/keyguard/KeyguardPinBasedInputView.java
+++ b/packages/SystemUI/src/com/android/keyguard/KeyguardPinBasedInputView.java
@@ -25,6 +25,7 @@
import static com.android.keyguard.KeyguardSecurityView.PROMPT_REASON_TIMEOUT;
import static com.android.keyguard.KeyguardSecurityView.PROMPT_REASON_TRUSTAGENT_EXPIRED;
import static com.android.keyguard.KeyguardSecurityView.PROMPT_REASON_USER_REQUEST;
+import static com.android.systemui.Flags.pinInputFieldStyledFocusState;
import android.animation.Animator;
import android.animation.AnimatorSet;
@@ -168,7 +169,9 @@
// Set selected property on so the view can send accessibility events.
mPasswordEntry.setSelected(true);
- mPasswordEntry.setDefaultFocusHighlightEnabled(false);
+ if (!pinInputFieldStyledFocusState()) {
+ mPasswordEntry.setDefaultFocusHighlightEnabled(false);
+ }
mOkButton = findViewById(R.id.key_enter);
diff --git a/packages/SystemUI/src/com/android/keyguard/KeyguardPinBasedInputViewController.java b/packages/SystemUI/src/com/android/keyguard/KeyguardPinBasedInputViewController.java
index 376933d..60dd568 100644
--- a/packages/SystemUI/src/com/android/keyguard/KeyguardPinBasedInputViewController.java
+++ b/packages/SystemUI/src/com/android/keyguard/KeyguardPinBasedInputViewController.java
@@ -16,17 +16,25 @@
package com.android.keyguard;
+import static com.android.systemui.util.kotlin.JavaAdapterKt.collectFlow;
+import static com.android.systemui.Flags.pinInputFieldStyledFocusState;
+
+import android.graphics.drawable.GradientDrawable;
+import android.graphics.drawable.StateListDrawable;
+import android.util.TypedValue;
import android.view.KeyEvent;
import android.view.MotionEvent;
import android.view.View;
import android.view.View.OnKeyListener;
import android.view.View.OnTouchListener;
+import android.view.ViewGroup;
import com.android.internal.util.LatencyTracker;
import com.android.internal.widget.LockPatternUtils;
import com.android.keyguard.KeyguardSecurityModel.SecurityMode;
import com.android.systemui.classifier.FalsingCollector;
import com.android.systemui.flags.FeatureFlags;
+import com.android.systemui.keyboard.data.repository.KeyboardRepository;
import com.android.systemui.res.R;
import com.android.systemui.user.domain.interactor.SelectedUserInteractor;
@@ -35,6 +43,7 @@
private final LiftToActivateListener mLiftToActivateListener;
private final FalsingCollector mFalsingCollector;
+ private final KeyboardRepository mKeyboardRepository;
protected PasswordTextView mPasswordEntry;
private final OnKeyListener mOnKeyListener = (v, keyCode, event) -> {
@@ -65,12 +74,14 @@
EmergencyButtonController emergencyButtonController,
FalsingCollector falsingCollector,
FeatureFlags featureFlags,
- SelectedUserInteractor selectedUserInteractor) {
+ SelectedUserInteractor selectedUserInteractor,
+ KeyboardRepository keyboardRepository) {
super(view, keyguardUpdateMonitor, securityMode, lockPatternUtils, keyguardSecurityCallback,
messageAreaControllerFactory, latencyTracker, falsingCollector,
emergencyButtonController, featureFlags, selectedUserInteractor);
mLiftToActivateListener = liftToActivateListener;
mFalsingCollector = falsingCollector;
+ mKeyboardRepository = keyboardRepository;
mPasswordEntry = mView.findViewById(mView.getPasswordTextViewId());
}
@@ -120,6 +131,35 @@
});
okButton.setOnHoverListener(mLiftToActivateListener);
}
+ if (pinInputFieldStyledFocusState()) {
+ collectFlow(mPasswordEntry, mKeyboardRepository.isAnyKeyboardConnected(),
+ this::setKeyboardBasedFocusOutline);
+
+ /**
+ * new UI Specs for PIN Input field have new dimensions go/pin-focus-states.
+ * However we want these changes behind a flag, and resource files cannot be flagged
+ * hence the dimension change in code. When the flags are removed these dimensions
+ * should be set in resources permanently and the code below removed.
+ */
+ ViewGroup.LayoutParams layoutParams = mPasswordEntry.getLayoutParams();
+ layoutParams.width = (int) getResources().getDimension(
+ R.dimen.keyguard_pin_field_width);
+ layoutParams.height = (int) getResources().getDimension(
+ R.dimen.keyguard_pin_field_height);
+ }
+ }
+
+ private void setKeyboardBasedFocusOutline(boolean isAnyKeyboardConnected) {
+ StateListDrawable background = (StateListDrawable) mPasswordEntry.getBackground();
+ GradientDrawable stateDrawable = (GradientDrawable) background.getStateDrawable(0);
+ int color = getResources().getColor(R.color.bouncer_password_focus_color);
+ if (!isAnyKeyboardConnected) {
+ stateDrawable.setStroke(0, color);
+ } else {
+ int strokeWidthInDP = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 3,
+ getResources().getDisplayMetrics());
+ stateDrawable.setStroke(strokeWidthInDP, color);
+ }
}
@Override
diff --git a/packages/SystemUI/src/com/android/keyguard/KeyguardPinViewController.java b/packages/SystemUI/src/com/android/keyguard/KeyguardPinViewController.java
index 2aab1f1..b958f55 100644
--- a/packages/SystemUI/src/com/android/keyguard/KeyguardPinViewController.java
+++ b/packages/SystemUI/src/com/android/keyguard/KeyguardPinViewController.java
@@ -28,6 +28,7 @@
import com.android.systemui.classifier.FalsingCollector;
import com.android.systemui.flags.FeatureFlags;
import com.android.systemui.flags.Flags;
+import com.android.systemui.keyboard.data.repository.KeyboardRepository;
import com.android.systemui.res.R;
import com.android.systemui.statusbar.policy.DevicePostureController;
import com.android.systemui.user.domain.interactor.SelectedUserInteractor;
@@ -58,12 +59,13 @@
LatencyTracker latencyTracker, LiftToActivateListener liftToActivateListener,
EmergencyButtonController emergencyButtonController,
FalsingCollector falsingCollector,
- DevicePostureController postureController,
- FeatureFlags featureFlags, SelectedUserInteractor selectedUserInteractor,
- UiEventLogger uiEventLogger) {
+ DevicePostureController postureController, FeatureFlags featureFlags,
+ SelectedUserInteractor selectedUserInteractor, UiEventLogger uiEventLogger,
+ KeyboardRepository keyboardRepository) {
super(view, keyguardUpdateMonitor, securityMode, lockPatternUtils, keyguardSecurityCallback,
messageAreaControllerFactory, latencyTracker, liftToActivateListener,
- emergencyButtonController, falsingCollector, featureFlags, selectedUserInteractor);
+ emergencyButtonController, falsingCollector, featureFlags, selectedUserInteractor,
+ keyboardRepository);
mKeyguardUpdateMonitor = keyguardUpdateMonitor;
mPostureController = postureController;
mLockPatternUtils = lockPatternUtils;
diff --git a/packages/SystemUI/src/com/android/keyguard/KeyguardSimPinViewController.java b/packages/SystemUI/src/com/android/keyguard/KeyguardSimPinViewController.java
index 5729119..1cdcbd0 100644
--- a/packages/SystemUI/src/com/android/keyguard/KeyguardSimPinViewController.java
+++ b/packages/SystemUI/src/com/android/keyguard/KeyguardSimPinViewController.java
@@ -44,6 +44,7 @@
import com.android.keyguard.KeyguardSecurityModel.SecurityMode;
import com.android.systemui.classifier.FalsingCollector;
import com.android.systemui.flags.FeatureFlags;
+import com.android.systemui.keyboard.data.repository.KeyboardRepository;
import com.android.systemui.res.R;
import com.android.systemui.user.domain.interactor.SelectedUserInteractor;
@@ -93,10 +94,11 @@
LatencyTracker latencyTracker, LiftToActivateListener liftToActivateListener,
TelephonyManager telephonyManager, FalsingCollector falsingCollector,
EmergencyButtonController emergencyButtonController, FeatureFlags featureFlags,
- SelectedUserInteractor selectedUserInteractor) {
+ SelectedUserInteractor selectedUserInteractor, KeyboardRepository keyboardRepository) {
super(view, keyguardUpdateMonitor, securityMode, lockPatternUtils, keyguardSecurityCallback,
messageAreaControllerFactory, latencyTracker, liftToActivateListener,
- emergencyButtonController, falsingCollector, featureFlags, selectedUserInteractor);
+ emergencyButtonController, falsingCollector, featureFlags, selectedUserInteractor,
+ keyboardRepository);
mKeyguardUpdateMonitor = keyguardUpdateMonitor;
mTelephonyManager = telephonyManager;
mSimImageView = mView.findViewById(R.id.keyguard_sim);
diff --git a/packages/SystemUI/src/com/android/keyguard/KeyguardSimPukViewController.java b/packages/SystemUI/src/com/android/keyguard/KeyguardSimPukViewController.java
index 05fb5fa..f019d61 100644
--- a/packages/SystemUI/src/com/android/keyguard/KeyguardSimPukViewController.java
+++ b/packages/SystemUI/src/com/android/keyguard/KeyguardSimPukViewController.java
@@ -39,6 +39,7 @@
import com.android.keyguard.KeyguardSecurityModel.SecurityMode;
import com.android.systemui.classifier.FalsingCollector;
import com.android.systemui.flags.FeatureFlags;
+import com.android.systemui.keyboard.data.repository.KeyboardRepository;
import com.android.systemui.res.R;
import com.android.systemui.user.domain.interactor.SelectedUserInteractor;
@@ -90,10 +91,11 @@
LatencyTracker latencyTracker, LiftToActivateListener liftToActivateListener,
TelephonyManager telephonyManager, FalsingCollector falsingCollector,
EmergencyButtonController emergencyButtonController, FeatureFlags featureFlags,
- SelectedUserInteractor selectedUserInteractor) {
+ SelectedUserInteractor selectedUserInteractor, KeyboardRepository keyboardRepository) {
super(view, keyguardUpdateMonitor, securityMode, lockPatternUtils, keyguardSecurityCallback,
messageAreaControllerFactory, latencyTracker, liftToActivateListener,
- emergencyButtonController, falsingCollector, featureFlags, selectedUserInteractor);
+ emergencyButtonController, falsingCollector, featureFlags, selectedUserInteractor,
+ keyboardRepository);
mKeyguardUpdateMonitor = keyguardUpdateMonitor;
mTelephonyManager = telephonyManager;
mSimImageView = mView.findViewById(R.id.keyguard_sim);
diff --git a/packages/SystemUI/src/com/android/keyguard/KeyguardStatusViewController.java b/packages/SystemUI/src/com/android/keyguard/KeyguardStatusViewController.java
index d372f5a..1758831 100644
--- a/packages/SystemUI/src/com/android/keyguard/KeyguardStatusViewController.java
+++ b/packages/SystemUI/src/com/android/keyguard/KeyguardStatusViewController.java
@@ -494,7 +494,7 @@
boolean shouldBeCentered,
boolean animate) {
if (migrateClocksToBlueprint()) {
- mKeyguardInteractor.setClockShouldBeCentered(mSplitShadeEnabled && shouldBeCentered);
+ mKeyguardInteractor.setClockShouldBeCentered(shouldBeCentered);
} else {
mKeyguardClockSwitchController.setSplitShadeCentered(
splitShadeEnabled && shouldBeCentered);
diff --git a/packages/SystemUI/src/com/android/systemui/SystemUIAppComponentFactoryBase.kt b/packages/SystemUI/src/com/android/systemui/SystemUIAppComponentFactoryBase.kt
index b15aaaf..e88aaf01 100644
--- a/packages/SystemUI/src/com/android/systemui/SystemUIAppComponentFactoryBase.kt
+++ b/packages/SystemUI/src/com/android/systemui/SystemUIAppComponentFactoryBase.kt
@@ -91,7 +91,7 @@
return app
}
- @UsesReflection(KeepTarget(extendsClassConstant = SysUIComponent::class, methodName = "inject"))
+ @UsesReflection(KeepTarget(instanceOfClassConstant = SysUIComponent::class, methodName = "inject"))
override fun instantiateProviderCompat(cl: ClassLoader, className: String): ContentProvider {
val contentProvider = super.instantiateProviderCompat(cl, className)
if (contentProvider is ContextInitializer) {
diff --git a/packages/SystemUI/src/com/android/systemui/accessibility/data/repository/ColorCorrectionRepository.kt b/packages/SystemUI/src/com/android/systemui/accessibility/data/repository/ColorCorrectionRepository.kt
index 6483ae4..c7e5b64 100644
--- a/packages/SystemUI/src/com/android/systemui/accessibility/data/repository/ColorCorrectionRepository.kt
+++ b/packages/SystemUI/src/com/android/systemui/accessibility/data/repository/ColorCorrectionRepository.kt
@@ -19,16 +19,20 @@
import android.os.UserHandle
import android.provider.Settings.Secure
import com.android.systemui.dagger.SysUISingleton
+import com.android.systemui.dagger.qualifiers.Application
import com.android.systemui.dagger.qualifiers.Background
import com.android.systemui.util.settings.SecureSettings
import com.android.systemui.util.settings.SettingsProxyExt.observerFlow
import javax.inject.Inject
import kotlin.coroutines.CoroutineContext
+import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.flow.Flow
+import kotlinx.coroutines.flow.SharingStarted
import kotlinx.coroutines.flow.distinctUntilChanged
import kotlinx.coroutines.flow.flowOn
import kotlinx.coroutines.flow.map
import kotlinx.coroutines.flow.onStart
+import kotlinx.coroutines.flow.shareIn
import kotlinx.coroutines.withContext
/** Provides data related to color correction. */
@@ -45,22 +49,24 @@
@Inject
constructor(
@Background private val bgCoroutineContext: CoroutineContext,
+ @Application private val scope: CoroutineScope,
private val secureSettings: SecureSettings,
) : ColorCorrectionRepository {
- companion object {
- const val SETTING_NAME = Secure.ACCESSIBILITY_DISPLAY_DALTONIZER_ENABLED
- const val DISABLED = 0
- const val ENABLED = 1
- }
+ private val userMap = mutableMapOf<Int, Flow<Boolean>>()
override fun isEnabled(userHandle: UserHandle): Flow<Boolean> =
- secureSettings
- .observerFlow(userHandle.identifier, SETTING_NAME)
- .onStart { emit(Unit) }
- .map { secureSettings.getIntForUser(SETTING_NAME, userHandle.identifier) == ENABLED }
- .distinctUntilChanged()
- .flowOn(bgCoroutineContext)
+ userMap.getOrPut(userHandle.identifier) {
+ secureSettings
+ .observerFlow(userHandle.identifier, SETTING_NAME)
+ .onStart { emit(Unit) }
+ .map {
+ secureSettings.getIntForUser(SETTING_NAME, userHandle.identifier) == ENABLED
+ }
+ .distinctUntilChanged()
+ .flowOn(bgCoroutineContext)
+ .shareIn(scope, SharingStarted.WhileSubscribed(), replay = 1)
+ }
override suspend fun setIsEnabled(isEnabled: Boolean, userHandle: UserHandle): Boolean =
withContext(bgCoroutineContext) {
@@ -70,4 +76,10 @@
userHandle.identifier
)
}
+
+ companion object {
+ private const val SETTING_NAME = Secure.ACCESSIBILITY_DISPLAY_DALTONIZER_ENABLED
+ private const val DISABLED = 0
+ private const val ENABLED = 1
+ }
}
diff --git a/packages/SystemUI/src/com/android/systemui/accessibility/data/repository/ColorInversionRepository.kt b/packages/SystemUI/src/com/android/systemui/accessibility/data/repository/ColorInversionRepository.kt
index bbf10c5..419eada 100644
--- a/packages/SystemUI/src/com/android/systemui/accessibility/data/repository/ColorInversionRepository.kt
+++ b/packages/SystemUI/src/com/android/systemui/accessibility/data/repository/ColorInversionRepository.kt
@@ -19,16 +19,20 @@
import android.os.UserHandle
import android.provider.Settings.Secure
import com.android.systemui.dagger.SysUISingleton
+import com.android.systemui.dagger.qualifiers.Application
import com.android.systemui.dagger.qualifiers.Background
import com.android.systemui.util.settings.SecureSettings
import com.android.systemui.util.settings.SettingsProxyExt.observerFlow
import javax.inject.Inject
import kotlin.coroutines.CoroutineContext
+import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.flow.Flow
+import kotlinx.coroutines.flow.SharingStarted
import kotlinx.coroutines.flow.distinctUntilChanged
import kotlinx.coroutines.flow.flowOn
import kotlinx.coroutines.flow.map
import kotlinx.coroutines.flow.onStart
+import kotlinx.coroutines.flow.shareIn
import kotlinx.coroutines.withContext
/** Provides data related to color inversion. */
@@ -45,16 +49,24 @@
@Inject
constructor(
@Background private val bgCoroutineContext: CoroutineContext,
+ @Application private val scope: CoroutineScope,
private val secureSettings: SecureSettings,
) : ColorInversionRepository {
+ private val userMap = mutableMapOf<Int, Flow<Boolean>>()
+
override fun isEnabled(userHandle: UserHandle): Flow<Boolean> =
- secureSettings
- .observerFlow(userHandle.identifier, SETTING_NAME)
- .onStart { emit(Unit) }
- .map { secureSettings.getIntForUser(SETTING_NAME, userHandle.identifier) == ENABLED }
- .distinctUntilChanged()
- .flowOn(bgCoroutineContext)
+ userMap.getOrPut(userHandle.identifier) {
+ secureSettings
+ .observerFlow(userHandle.identifier, SETTING_NAME)
+ .onStart { emit(Unit) }
+ .map {
+ secureSettings.getIntForUser(SETTING_NAME, userHandle.identifier) == ENABLED
+ }
+ .distinctUntilChanged()
+ .flowOn(bgCoroutineContext)
+ .shareIn(scope, SharingStarted.WhileSubscribed(), replay = 1)
+ }
override suspend fun setIsEnabled(isEnabled: Boolean, userHandle: UserHandle): Boolean =
withContext(bgCoroutineContext) {
diff --git a/packages/SystemUI/src/com/android/systemui/biometrics/ui/binder/BiometricCustomizedViewBinder.kt b/packages/SystemUI/src/com/android/systemui/biometrics/ui/binder/BiometricCustomizedViewBinder.kt
index 22b02da..16e7f05 100644
--- a/packages/SystemUI/src/com/android/systemui/biometrics/ui/binder/BiometricCustomizedViewBinder.kt
+++ b/packages/SystemUI/src/com/android/systemui/biometrics/ui/binder/BiometricCustomizedViewBinder.kt
@@ -20,9 +20,9 @@
import android.content.res.Resources
import android.content.res.Resources.Theme
import android.graphics.Paint
-import android.hardware.biometrics.PromptContentListItem
-import android.hardware.biometrics.PromptContentListItemBulletedText
-import android.hardware.biometrics.PromptContentListItemPlainText
+import android.hardware.biometrics.PromptContentItem
+import android.hardware.biometrics.PromptContentItemBulletedText
+import android.hardware.biometrics.PromptContentItemPlainText
import android.hardware.biometrics.PromptContentView
import android.hardware.biometrics.PromptVerticalListContentView
import android.text.SpannableString
@@ -111,21 +111,21 @@
return inflater.inflate(R.layout.biometric_prompt_content_row_layout, null) as LinearLayout
}
-private fun PromptContentListItem.doesExceedMaxLinesIfTwoColumn(
+private fun PromptContentItem.doesExceedMaxLinesIfTwoColumn(
resources: Resources,
): Boolean {
val passedInText: CharSequence =
when (this) {
- is PromptContentListItemPlainText -> text
- is PromptContentListItemBulletedText -> text
+ is PromptContentItemPlainText -> text
+ is PromptContentItemBulletedText -> text
else -> {
- throw IllegalStateException("No such ListItem: $this")
+ throw IllegalStateException("No such PromptContentItem: $this")
}
}
when (this) {
- is PromptContentListItemPlainText,
- is PromptContentListItemBulletedText -> {
+ is PromptContentItemPlainText,
+ is PromptContentItemBulletedText -> {
val dialogMargin =
resources.getDimensionPixelSize(R.dimen.biometric_dialog_border_padding)
val halfDialogWidth =
@@ -155,12 +155,12 @@
return numLines > maxLines
}
else -> {
- throw IllegalStateException("No such ListItem: $this")
+ throw IllegalStateException("No such PromptContentItem: $this")
}
}
}
-private fun PromptContentListItem.toView(
+private fun PromptContentItem.toView(
resources: Resources,
inflater: LayoutInflater,
theme: Theme,
@@ -171,10 +171,10 @@
textView.layoutParams = lp
when (this) {
- is PromptContentListItemPlainText -> {
+ is PromptContentItemPlainText -> {
textView.text = text
}
- is PromptContentListItemBulletedText -> {
+ is PromptContentItemBulletedText -> {
val bulletedText = SpannableString(text)
val span =
BulletSpan(
@@ -186,25 +186,25 @@
textView.text = bulletedText
}
else -> {
- throw IllegalStateException("No such ListItem: $this")
+ throw IllegalStateException("No such PromptContentItem: $this")
}
}
return textView
}
-private fun PromptContentListItem.getListItemPadding(resources: Resources): Int {
+private fun PromptContentItem.getListItemPadding(resources: Resources): Int {
var listItemPadding =
resources.getDimensionPixelSize(
R.dimen.biometric_prompt_content_list_item_padding_horizontal
) * 2
when (this) {
- is PromptContentListItemPlainText -> {}
- is PromptContentListItemBulletedText -> {
+ is PromptContentItemPlainText -> {}
+ is PromptContentItemBulletedText -> {
listItemPadding +=
getListItemBulletRadius(resources) * 2 + getListItemBulletGapWidth(resources)
}
else -> {
- throw IllegalStateException("No such ListItem: $this")
+ throw IllegalStateException("No such PromptContentItem: $this")
}
}
return listItemPadding
diff --git a/packages/SystemUI/src/com/android/systemui/communal/dagger/CommunalModule.kt b/packages/SystemUI/src/com/android/systemui/communal/dagger/CommunalModule.kt
index 10768ea..dc07c1b 100644
--- a/packages/SystemUI/src/com/android/systemui/communal/dagger/CommunalModule.kt
+++ b/packages/SystemUI/src/com/android/systemui/communal/dagger/CommunalModule.kt
@@ -18,6 +18,7 @@
import com.android.systemui.communal.data.db.CommunalDatabaseModule
import com.android.systemui.communal.data.repository.CommunalMediaRepositoryModule
+import com.android.systemui.communal.data.repository.CommunalPrefsRepositoryModule
import com.android.systemui.communal.data.repository.CommunalRepositoryModule
import com.android.systemui.communal.data.repository.CommunalTutorialRepositoryModule
import com.android.systemui.communal.data.repository.CommunalWidgetRepositoryModule
@@ -34,6 +35,7 @@
CommunalTutorialRepositoryModule::class,
CommunalWidgetRepositoryModule::class,
CommunalDatabaseModule::class,
+ CommunalPrefsRepositoryModule::class,
]
)
interface CommunalModule {
diff --git a/packages/SystemUI/src/com/android/systemui/communal/data/repository/CommunalPrefsRepository.kt b/packages/SystemUI/src/com/android/systemui/communal/data/repository/CommunalPrefsRepository.kt
new file mode 100644
index 0000000..c2ea2e9
--- /dev/null
+++ b/packages/SystemUI/src/com/android/systemui/communal/data/repository/CommunalPrefsRepository.kt
@@ -0,0 +1,108 @@
+/*
+ * 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.communal.data.repository
+
+import android.content.Context
+import android.content.SharedPreferences
+import android.content.pm.UserInfo
+import com.android.systemui.dagger.SysUISingleton
+import com.android.systemui.dagger.qualifiers.Background
+import com.android.systemui.settings.UserFileManager
+import com.android.systemui.settings.UserFileManagerExt.observeSharedPreferences
+import com.android.systemui.user.data.repository.UserRepository
+import javax.inject.Inject
+import kotlinx.coroutines.CoroutineDispatcher
+import kotlinx.coroutines.CoroutineScope
+import kotlinx.coroutines.ExperimentalCoroutinesApi
+import kotlinx.coroutines.flow.Flow
+import kotlinx.coroutines.flow.SharingStarted
+import kotlinx.coroutines.flow.flatMapLatest
+import kotlinx.coroutines.flow.flowOn
+import kotlinx.coroutines.flow.map
+import kotlinx.coroutines.flow.onStart
+import kotlinx.coroutines.flow.stateIn
+import kotlinx.coroutines.withContext
+
+/**
+ * Stores simple preferences for the current user in communal hub. For use cases like "has the CTA
+ * tile been dismissed?"
+ */
+interface CommunalPrefsRepository {
+
+ /** Whether the CTA tile has been dismissed. */
+ val isCtaDismissed: Flow<Boolean>
+
+ /** Save the CTA tile dismissed state for the current user. */
+ suspend fun setCtaDismissedForCurrentUser()
+}
+
+@OptIn(ExperimentalCoroutinesApi::class)
+@SysUISingleton
+class CommunalPrefsRepositoryImpl
+@Inject
+constructor(
+ @Background private val backgroundScope: CoroutineScope,
+ @Background private val bgDispatcher: CoroutineDispatcher,
+ private val userRepository: UserRepository,
+ private val userFileManager: UserFileManager,
+) : CommunalPrefsRepository {
+
+ override val isCtaDismissed: Flow<Boolean> =
+ userRepository.selectedUserInfo
+ .flatMapLatest(::observeCtaDismissState)
+ .stateIn(
+ scope = backgroundScope,
+ started = SharingStarted.WhileSubscribed(),
+ initialValue = false,
+ )
+
+ override suspend fun setCtaDismissedForCurrentUser() =
+ withContext(bgDispatcher) {
+ getSharedPrefsForUser(userRepository.getSelectedUserInfo())
+ .edit()
+ .putBoolean(CTA_DISMISSED_STATE, true)
+ .apply()
+ }
+
+ private fun observeCtaDismissState(user: UserInfo): Flow<Boolean> =
+ userFileManager
+ .observeSharedPreferences(FILE_NAME, Context.MODE_PRIVATE, user.id)
+ // Emit at the start of collection to ensure we get an initial value
+ .onStart { emit(Unit) }
+ .map { getCtaDismissedState() }
+ .flowOn(bgDispatcher)
+
+ private suspend fun getCtaDismissedState(): Boolean =
+ withContext(bgDispatcher) {
+ getSharedPrefsForUser(userRepository.getSelectedUserInfo())
+ .getBoolean(CTA_DISMISSED_STATE, false)
+ }
+
+ private fun getSharedPrefsForUser(user: UserInfo): SharedPreferences {
+ return userFileManager.getSharedPreferences(
+ FILE_NAME,
+ Context.MODE_PRIVATE,
+ user.id,
+ )
+ }
+
+ companion object {
+ const val TAG = "CommunalRepository"
+ const val FILE_NAME = "communal_hub_prefs"
+ const val CTA_DISMISSED_STATE = "cta_dismissed"
+ }
+}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/pipeline/dagger/OemSatelliteInputLog.kt b/packages/SystemUI/src/com/android/systemui/communal/data/repository/CommunalPrefsRepositoryModule.kt
similarity index 63%
copy from packages/SystemUI/src/com/android/systemui/statusbar/pipeline/dagger/OemSatelliteInputLog.kt
copy to packages/SystemUI/src/com/android/systemui/communal/data/repository/CommunalPrefsRepositoryModule.kt
index 252945f..a4ff6d3 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/pipeline/dagger/OemSatelliteInputLog.kt
+++ b/packages/SystemUI/src/com/android/systemui/communal/data/repository/CommunalPrefsRepositoryModule.kt
@@ -12,15 +12,15 @@
* 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.pipeline.dagger
+package com.android.systemui.communal.data.repository
-import com.android.systemui.statusbar.pipeline.satellite.data.DeviceBasedSatelliteRepository
-import javax.inject.Qualifier
+import dagger.Binds
+import dagger.Module
-/** Detailed [DeviceBasedSatelliteRepository] logs */
-@Qualifier
-@MustBeDocumented
-@kotlin.annotation.Retention(AnnotationRetention.RUNTIME)
-annotation class OemSatelliteInputLog
+@Module
+interface CommunalPrefsRepositoryModule {
+ @Binds fun communalPrefsRepository(impl: CommunalPrefsRepositoryImpl): CommunalPrefsRepository
+}
diff --git a/packages/SystemUI/src/com/android/systemui/communal/data/repository/CommunalRepository.kt b/packages/SystemUI/src/com/android/systemui/communal/data/repository/CommunalRepository.kt
index 553b3eb..1f4be40 100644
--- a/packages/SystemUI/src/com/android/systemui/communal/data/repository/CommunalRepository.kt
+++ b/packages/SystemUI/src/com/android/systemui/communal/data/repository/CommunalRepository.kt
@@ -56,9 +56,6 @@
/** Exposes the transition state of the communal [SceneTransitionLayout]. */
val transitionState: StateFlow<ObservableCommunalTransitionState>
- /** Whether the CTA tile is visible in the hub under view mode. */
- val isCtaTileInViewModeVisible: Flow<Boolean>
-
/** Updates the requested scene. */
fun setDesiredScene(desiredScene: CommunalSceneKey)
@@ -68,9 +65,6 @@
* Note that you must call is with `null` when the UI is done or risk a memory leak.
*/
fun setTransitionState(transitionState: Flow<ObservableCommunalTransitionState>?)
-
- /** Updates whether to display the CTA tile in the hub under view mode. */
- fun setCtaTileInViewModeVisibility(isVisible: Boolean)
}
@OptIn(ExperimentalCoroutinesApi::class)
@@ -102,16 +96,6 @@
initialValue = defaultTransitionState,
)
- // TODO(b/313462210) - persist the value in local storage, so the tile won't show up again
- // once dismissed.
- private val _isCtaTileInViewModeVisible: MutableStateFlow<Boolean> = MutableStateFlow(true)
- override val isCtaTileInViewModeVisible: Flow<Boolean> =
- _isCtaTileInViewModeVisible.asStateFlow()
-
- override fun setCtaTileInViewModeVisibility(isVisible: Boolean) {
- _isCtaTileInViewModeVisible.value = isVisible
- }
-
override fun setDesiredScene(desiredScene: CommunalSceneKey) {
_desiredScene.value = desiredScene
}
diff --git a/packages/SystemUI/src/com/android/systemui/communal/domain/interactor/CommunalInteractor.kt b/packages/SystemUI/src/com/android/systemui/communal/domain/interactor/CommunalInteractor.kt
index 9fa4cd6..aa9a426 100644
--- a/packages/SystemUI/src/com/android/systemui/communal/domain/interactor/CommunalInteractor.kt
+++ b/packages/SystemUI/src/com/android/systemui/communal/domain/interactor/CommunalInteractor.kt
@@ -20,6 +20,7 @@
import android.appwidget.AppWidgetHost
import android.content.ComponentName
import com.android.systemui.communal.data.repository.CommunalMediaRepository
+import com.android.systemui.communal.data.repository.CommunalPrefsRepository
import com.android.systemui.communal.data.repository.CommunalRepository
import com.android.systemui.communal.data.repository.CommunalWidgetRepository
import com.android.systemui.communal.domain.model.CommunalContentModel
@@ -49,6 +50,7 @@
constructor(
private val communalRepository: CommunalRepository,
private val widgetRepository: CommunalWidgetRepository,
+ private val communalPrefsRepository: CommunalPrefsRepository,
mediaRepository: CommunalMediaRepository,
smartspaceRepository: SmartspaceRepository,
keyguardInteractor: KeyguardInteractor,
@@ -122,7 +124,7 @@
}
/** Dismiss the CTA tile from the hub in view mode. */
- fun dismissCtaTile() = communalRepository.setCtaTileInViewModeVisibility(isVisible = false)
+ suspend fun dismissCtaTile() = communalPrefsRepository.setCtaDismissedForCurrentUser()
/**
* Add a widget at the specified position.
@@ -174,8 +176,8 @@
/** CTA tile to be displayed in the glanceable hub (view mode). */
val ctaTileContent: Flow<List<CommunalContentModel.CtaTileInViewMode>> =
- communalRepository.isCtaTileInViewModeVisible.map { visible ->
- if (visible) listOf(CommunalContentModel.CtaTileInViewMode()) else emptyList()
+ communalPrefsRepository.isCtaDismissed.map { isDismissed ->
+ if (isDismissed) emptyList() else listOf(CommunalContentModel.CtaTileInViewMode())
}
/** A list of tutorial content to be displayed in the communal hub in tutorial mode. */
diff --git a/packages/SystemUI/src/com/android/systemui/communal/ui/viewmodel/BaseCommunalViewModel.kt b/packages/SystemUI/src/com/android/systemui/communal/ui/viewmodel/BaseCommunalViewModel.kt
index 84708a4..4da348e 100644
--- a/packages/SystemUI/src/com/android/systemui/communal/ui/viewmodel/BaseCommunalViewModel.kt
+++ b/packages/SystemUI/src/com/android/systemui/communal/ui/viewmodel/BaseCommunalViewModel.kt
@@ -24,6 +24,7 @@
import com.android.systemui.communal.shared.model.ObservableCommunalTransitionState
import com.android.systemui.media.controls.ui.MediaHost
import kotlinx.coroutines.flow.Flow
+import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.flow.StateFlow
import kotlinx.coroutines.flow.flowOf
@@ -36,6 +37,15 @@
val currentScene: StateFlow<CommunalSceneKey> = communalInteractor.desiredScene
+ /** Whether widgets are currently being re-ordered. */
+ open val reorderingWidgets: StateFlow<Boolean> = MutableStateFlow(false)
+
+ private val _selectedIndex: MutableStateFlow<Int?> = MutableStateFlow(null)
+
+ /** The index of the currently selected item, or null if no item selected. */
+ val selectedIndex: StateFlow<Int?>
+ get() = _selectedIndex
+
fun onSceneChanged(scene: CommunalSceneKey) {
communalInteractor.onSceneChanged(scene)
}
@@ -105,4 +115,9 @@
/** Called as the user cancels dragging a widget to reorder. */
open fun onReorderWidgetCancel() {}
+
+ /** Set the index of the currently selected item */
+ fun setSelectedIndex(index: Int?) {
+ _selectedIndex.value = index
+ }
}
diff --git a/packages/SystemUI/src/com/android/systemui/communal/ui/viewmodel/CommunalEditModeViewModel.kt b/packages/SystemUI/src/com/android/systemui/communal/ui/viewmodel/CommunalEditModeViewModel.kt
index 7faf653..fcad45f 100644
--- a/packages/SystemUI/src/com/android/systemui/communal/ui/viewmodel/CommunalEditModeViewModel.kt
+++ b/packages/SystemUI/src/com/android/systemui/communal/ui/viewmodel/CommunalEditModeViewModel.kt
@@ -37,7 +37,10 @@
import kotlinx.coroutines.CompletableDeferred
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.MutableSharedFlow
+import kotlinx.coroutines.flow.MutableStateFlow
+import kotlinx.coroutines.flow.StateFlow
import kotlinx.coroutines.flow.map
+import kotlinx.coroutines.flow.onEach
/** The view model for communal hub in edit mode. */
@SysUISingleton
@@ -69,9 +72,15 @@
// Only widgets are editable. The CTA tile comes last in the list and remains visible.
override val communalContent: Flow<List<CommunalContentModel>> =
- communalInteractor.widgetContent.map { widgets ->
- widgets + listOf(CommunalContentModel.CtaTileInEditMode())
- }
+ communalInteractor.widgetContent
+ // Clear the selected index when the list is updated.
+ .onEach { setSelectedIndex(null) }
+ .map { widgets -> widgets + listOf(CommunalContentModel.CtaTileInEditMode()) }
+
+ private val _reorderingWidgets = MutableStateFlow(false)
+
+ override val reorderingWidgets: StateFlow<Boolean>
+ get() = _reorderingWidgets
override fun onDeleteWidget(id: Int) = communalInteractor.deleteWidget(id)
@@ -135,14 +144,19 @@
}
override fun onReorderWidgetStart() {
+ // Clear selection status
+ setSelectedIndex(null)
+ _reorderingWidgets.value = true
uiEventLogger.log(CommunalUiEvent.COMMUNAL_HUB_REORDER_WIDGET_START)
}
override fun onReorderWidgetEnd() {
+ _reorderingWidgets.value = false
uiEventLogger.log(CommunalUiEvent.COMMUNAL_HUB_REORDER_WIDGET_FINISH)
}
override fun onReorderWidgetCancel() {
+ _reorderingWidgets.value = false
uiEventLogger.log(CommunalUiEvent.COMMUNAL_HUB_REORDER_WIDGET_CANCEL)
}
}
diff --git a/packages/SystemUI/src/com/android/systemui/communal/ui/viewmodel/CommunalViewModel.kt b/packages/SystemUI/src/com/android/systemui/communal/ui/viewmodel/CommunalViewModel.kt
index 09c18ed..d619362 100644
--- a/packages/SystemUI/src/com/android/systemui/communal/ui/viewmodel/CommunalViewModel.kt
+++ b/packages/SystemUI/src/com/android/systemui/communal/ui/viewmodel/CommunalViewModel.kt
@@ -86,9 +86,11 @@
override fun onOpenWidgetEditor() = communalInteractor.showWidgetEditor()
override fun onDismissCtaTile() {
- communalInteractor.dismissCtaTile()
- setPopupOnDismissCtaVisibility(true)
- schedulePopupHiding()
+ scope.launch {
+ communalInteractor.dismissCtaTile()
+ setPopupOnDismissCtaVisibility(true)
+ schedulePopupHiding()
+ }
}
override fun getInteractionHandler(): RemoteViews.InteractionHandler = interactionHandler
diff --git a/packages/SystemUI/src/com/android/systemui/dagger/FrameworkServicesModule.java b/packages/SystemUI/src/com/android/systemui/dagger/FrameworkServicesModule.java
index b2d7052..6d9994f 100644
--- a/packages/SystemUI/src/com/android/systemui/dagger/FrameworkServicesModule.java
+++ b/packages/SystemUI/src/com/android/systemui/dagger/FrameworkServicesModule.java
@@ -556,7 +556,7 @@
@Provides
@Singleton
static SubscriptionManager provideSubscriptionManager(Context context) {
- return context.getSystemService(SubscriptionManager.class);
+ return context.getSystemService(SubscriptionManager.class).createForAllUserProfiles();
}
@Provides
diff --git a/packages/SystemUI/src/com/android/systemui/flags/Flags.kt b/packages/SystemUI/src/com/android/systemui/flags/Flags.kt
index 846736c..ea8ba10 100644
--- a/packages/SystemUI/src/com/android/systemui/flags/Flags.kt
+++ b/packages/SystemUI/src/com/android/systemui/flags/Flags.kt
@@ -102,12 +102,6 @@
default = true
)
- /** Only notify group expansion listeners when a change happens. */
- // TODO(b/292213543): Tracking Bug
- @JvmField
- val NOTIFICATION_GROUP_EXPANSION_CHANGE =
- releasedFlag("notification_group_expansion_change")
-
// TODO(b/301955929)
@JvmField
val NOTIF_LS_BACKGROUND_THREAD =
diff --git a/packages/SystemUI/src/com/android/systemui/keyboard/KeyboardModule.kt b/packages/SystemUI/src/com/android/systemui/keyboard/KeyboardModule.kt
index 496c64e..c6fb4f9 100644
--- a/packages/SystemUI/src/com/android/systemui/keyboard/KeyboardModule.kt
+++ b/packages/SystemUI/src/com/android/systemui/keyboard/KeyboardModule.kt
@@ -19,6 +19,8 @@
import com.android.systemui.keyboard.data.repository.KeyboardRepository
import com.android.systemui.keyboard.data.repository.KeyboardRepositoryImpl
+import com.android.systemui.keyboard.stickykeys.data.repository.StickyKeysRepository
+import com.android.systemui.keyboard.stickykeys.data.repository.StickyKeysRepositoryImpl
import dagger.Binds
import dagger.Module
@@ -27,4 +29,9 @@
@Binds
abstract fun bindKeyboardRepository(repository: KeyboardRepositoryImpl): KeyboardRepository
+
+ @Binds
+ abstract fun bindStickyKeysRepository(
+ repository: StickyKeysRepositoryImpl
+ ): StickyKeysRepository
}
diff --git a/packages/SystemUI/src/com/android/systemui/keyboard/stickykeys/StickyKeysLogger.kt b/packages/SystemUI/src/com/android/systemui/keyboard/stickykeys/StickyKeysLogger.kt
new file mode 100644
index 0000000..37034f6
--- /dev/null
+++ b/packages/SystemUI/src/com/android/systemui/keyboard/stickykeys/StickyKeysLogger.kt
@@ -0,0 +1,37 @@
+/*
+ * 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.keyboard.stickykeys
+
+import com.android.systemui.keyboard.stickykeys.shared.model.Locked
+import com.android.systemui.keyboard.stickykeys.shared.model.ModifierKey
+import com.android.systemui.log.LogBuffer
+import com.android.systemui.log.core.LogLevel
+import com.android.systemui.log.dagger.KeyboardLog
+import javax.inject.Inject
+
+private const val TAG = "stickyKeys"
+
+class StickyKeysLogger @Inject constructor(@KeyboardLog private val buffer: LogBuffer) {
+ fun logNewStickyKeysReceived(linkedHashMap: Map<ModifierKey, Locked>) {
+ buffer.log(
+ TAG,
+ LogLevel.VERBOSE,
+ { str1 = linkedHashMap.toString() },
+ { "new sticky keys state received: $str1" }
+ )
+ }
+}
\ No newline at end of file
diff --git a/packages/SystemUI/src/com/android/systemui/keyboard/stickykeys/data/repository/StickyKeysRepository.kt b/packages/SystemUI/src/com/android/systemui/keyboard/stickykeys/data/repository/StickyKeysRepository.kt
new file mode 100644
index 0000000..34d2888
--- /dev/null
+++ b/packages/SystemUI/src/com/android/systemui/keyboard/stickykeys/data/repository/StickyKeysRepository.kt
@@ -0,0 +1,92 @@
+/*
+ * 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.keyboard.stickykeys.data.repository
+
+import android.hardware.input.InputManager
+import android.hardware.input.InputManager.StickyModifierStateListener
+import android.hardware.input.StickyModifierState
+import com.android.systemui.common.coroutine.ChannelExt.trySendWithFailureLogging
+import com.android.systemui.common.coroutine.ConflatedCallbackFlow.conflatedCallbackFlow
+import com.android.systemui.dagger.qualifiers.Background
+import com.android.systemui.keyboard.stickykeys.StickyKeysLogger
+import com.android.systemui.keyboard.stickykeys.shared.model.Locked
+import com.android.systemui.keyboard.stickykeys.shared.model.ModifierKey
+import com.android.systemui.keyboard.stickykeys.shared.model.ModifierKey.ALT
+import com.android.systemui.keyboard.stickykeys.shared.model.ModifierKey.ALT_GR
+import com.android.systemui.keyboard.stickykeys.shared.model.ModifierKey.CTRL
+import com.android.systemui.keyboard.stickykeys.shared.model.ModifierKey.META
+import com.android.systemui.keyboard.stickykeys.shared.model.ModifierKey.SHIFT
+import kotlinx.coroutines.CoroutineDispatcher
+import kotlinx.coroutines.channels.awaitClose
+import kotlinx.coroutines.flow.Flow
+import kotlinx.coroutines.flow.MutableStateFlow
+import kotlinx.coroutines.flow.StateFlow
+import kotlinx.coroutines.flow.flowOn
+import kotlinx.coroutines.flow.map
+import kotlinx.coroutines.flow.onEach
+import javax.inject.Inject
+
+interface StickyKeysRepository {
+ val stickyKeys: Flow<LinkedHashMap<ModifierKey, Locked>>
+ val settingEnabled: Flow<Boolean>
+}
+
+class StickyKeysRepositoryImpl
+@Inject
+constructor(
+ private val inputManager: InputManager,
+ @Background private val backgroundDispatcher: CoroutineDispatcher,
+ private val stickyKeysLogger: StickyKeysLogger,
+) : StickyKeysRepository {
+
+ override val stickyKeys: Flow<LinkedHashMap<ModifierKey, Locked>> =
+ conflatedCallbackFlow {
+ val listener = StickyModifierStateListener { stickyModifierState ->
+ trySendWithFailureLogging(stickyModifierState, TAG)
+ }
+ // after registering, InputManager calls listener with the current value
+ inputManager.registerStickyModifierStateListener(Runnable::run, listener)
+ awaitClose { inputManager.unregisterStickyModifierStateListener(listener) }
+ }
+ .map { toStickyKeysMap(it) }
+ .onEach { stickyKeysLogger.logNewStickyKeysReceived(it) }
+ .flowOn(backgroundDispatcher)
+
+ // TODO(b/319837892): Implement reading actual setting
+ override val settingEnabled: StateFlow<Boolean> = MutableStateFlow(true)
+
+ private fun toStickyKeysMap(state: StickyModifierState): LinkedHashMap<ModifierKey, Locked> {
+ val keys = linkedMapOf<ModifierKey, Locked>()
+ state.apply {
+ if (isAltGrModifierOn) keys[ALT_GR] = Locked(false)
+ if (isAltGrModifierLocked) keys[ALT_GR] = Locked(true)
+ if (isAltModifierOn) keys[ALT] = Locked(false)
+ if (isAltModifierLocked) keys[ALT] = Locked(true)
+ if (isCtrlModifierOn) keys[CTRL] = Locked(false)
+ if (isCtrlModifierLocked) keys[CTRL] = Locked(true)
+ if (isMetaModifierOn) keys[META] = Locked(false)
+ if (isMetaModifierLocked) keys[META] = Locked(true)
+ if (isShiftModifierOn) keys[SHIFT] = Locked(false)
+ if (isShiftModifierLocked) keys[SHIFT] = Locked(true)
+ }
+ return keys
+ }
+
+ companion object {
+ const val TAG = "StickyKeysRepositoryImpl"
+ }
+}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/pipeline/dagger/OemSatelliteInputLog.kt b/packages/SystemUI/src/com/android/systemui/keyboard/stickykeys/shared/model/StickyKey.kt
similarity index 63%
copy from packages/SystemUI/src/com/android/systemui/statusbar/pipeline/dagger/OemSatelliteInputLog.kt
copy to packages/SystemUI/src/com/android/systemui/keyboard/stickykeys/shared/model/StickyKey.kt
index 252945f..d5f082a 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/pipeline/dagger/OemSatelliteInputLog.kt
+++ b/packages/SystemUI/src/com/android/systemui/keyboard/stickykeys/shared/model/StickyKey.kt
@@ -14,13 +14,15 @@
* limitations under the License.
*/
-package com.android.systemui.statusbar.pipeline.dagger
+package com.android.systemui.keyboard.stickykeys.shared.model
-import com.android.systemui.statusbar.pipeline.satellite.data.DeviceBasedSatelliteRepository
-import javax.inject.Qualifier
+@JvmInline
+value class Locked(val locked: Boolean)
-/** Detailed [DeviceBasedSatelliteRepository] logs */
-@Qualifier
-@MustBeDocumented
-@kotlin.annotation.Retention(AnnotationRetention.RUNTIME)
-annotation class OemSatelliteInputLog
+enum class ModifierKey(val text: String) {
+ ALT("ALT LEFT"),
+ ALT_GR("ALT RIGHT"),
+ CTRL("CTRL"),
+ META("META"),
+ SHIFT("SHIFT"),
+}
diff --git a/packages/SystemUI/src/com/android/systemui/keyboard/stickykeys/ui/viewmodel/StickyKeysIndicatorViewModel.kt b/packages/SystemUI/src/com/android/systemui/keyboard/stickykeys/ui/viewmodel/StickyKeysIndicatorViewModel.kt
new file mode 100644
index 0000000..26eb706
--- /dev/null
+++ b/packages/SystemUI/src/com/android/systemui/keyboard/stickykeys/ui/viewmodel/StickyKeysIndicatorViewModel.kt
@@ -0,0 +1,51 @@
+/*
+ * 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.keyboard.stickykeys.ui.viewmodel
+
+import com.android.systemui.dagger.qualifiers.Application
+import com.android.systemui.keyboard.data.repository.KeyboardRepository
+import com.android.systemui.keyboard.stickykeys.data.repository.StickyKeysRepository
+import com.android.systemui.keyboard.stickykeys.shared.model.Locked
+import com.android.systemui.keyboard.stickykeys.shared.model.ModifierKey
+import kotlinx.coroutines.CoroutineScope
+import kotlinx.coroutines.ExperimentalCoroutinesApi
+import kotlinx.coroutines.flow.Flow
+import kotlinx.coroutines.flow.SharingStarted
+import kotlinx.coroutines.flow.flatMapLatest
+import kotlinx.coroutines.flow.flowOf
+import kotlinx.coroutines.flow.stateIn
+import javax.inject.Inject
+
+class StickyKeysIndicatorViewModel
+@Inject
+constructor(
+ stickyKeysRepository: StickyKeysRepository,
+ keyboardRepository: KeyboardRepository,
+ @Application applicationScope: CoroutineScope,
+) {
+
+ @OptIn(ExperimentalCoroutinesApi::class)
+ val indicatorContent: Flow<Map<ModifierKey, Locked>> =
+ keyboardRepository.isAnyKeyboardConnected
+ .flatMapLatest { keyboardPresent ->
+ if (keyboardPresent) stickyKeysRepository.settingEnabled else flowOf(false)
+ }
+ .flatMapLatest { enabled ->
+ if (enabled) stickyKeysRepository.stickyKeys else flowOf(emptyMap())
+ }
+ .stateIn(applicationScope, SharingStarted.Lazily, emptyMap())
+}
diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/data/repository/KeyguardSmartspaceRepository.kt b/packages/SystemUI/src/com/android/systemui/keyguard/data/repository/KeyguardSmartspaceRepository.kt
new file mode 100644
index 0000000..afe9151
--- /dev/null
+++ b/packages/SystemUI/src/com/android/systemui/keyguard/data/repository/KeyguardSmartspaceRepository.kt
@@ -0,0 +1,34 @@
+/*
+ * Copyright (C) 2023 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.systemui.keyguard.data.repository
+
+import android.view.View
+import com.android.systemui.dagger.SysUISingleton
+import javax.inject.Inject
+import kotlinx.coroutines.flow.MutableStateFlow
+import kotlinx.coroutines.flow.StateFlow
+import kotlinx.coroutines.flow.asStateFlow
+
+@SysUISingleton
+class KeyguardSmartspaceRepository @Inject constructor() {
+ private val _bcSmartspaceVisibility: MutableStateFlow<Int> = MutableStateFlow(View.GONE)
+ val bcSmartspaceVisibility: StateFlow<Int> = _bcSmartspaceVisibility.asStateFlow()
+
+ fun setBcSmartspaceVisibility(visibility: Int) {
+ _bcSmartspaceVisibility.value = visibility
+ }
+}
diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/domain/interactor/FromAodTransitionInteractor.kt b/packages/SystemUI/src/com/android/systemui/keyguard/domain/interactor/FromAodTransitionInteractor.kt
index fedd63b..8fa33ee7 100644
--- a/packages/SystemUI/src/com/android/systemui/keyguard/domain/interactor/FromAodTransitionInteractor.kt
+++ b/packages/SystemUI/src/com/android/systemui/keyguard/domain/interactor/FromAodTransitionInteractor.kt
@@ -54,12 +54,33 @@
) {
override fun start() {
- listenForAodToLockscreenOrOccluded()
+ listenForAodToLockscreen()
+ listenForAodToPrimaryBouncer()
listenForAodToGone()
+ listenForAodToOccluded()
listenForTransitionToCamera(scope, keyguardInteractor)
}
- private fun listenForAodToLockscreenOrOccluded() {
+ /**
+ * There are cases where the transition to AOD begins but never completes, such as tapping power
+ * during an incoming phone call when unlocked. In this case, GONE->AOD should be interrupted to
+ * run AOD->OCCLUDED.
+ */
+ private fun listenForAodToOccluded() {
+ scope.launch {
+ keyguardInteractor.isKeyguardOccluded.sample(startedKeyguardState, ::Pair).collect {
+ (isOccluded, startedKeyguardState) ->
+ if (isOccluded && startedKeyguardState == KeyguardState.AOD) {
+ startTransitionTo(
+ toState = KeyguardState.OCCLUDED,
+ modeOnCanceled = TransitionModeOnCanceled.RESET
+ )
+ }
+ }
+ }
+ }
+
+ private fun listenForAodToLockscreen() {
scope.launch {
keyguardInteractor
.dozeTransitionTo(DozeStateModel.FINISH)
@@ -72,20 +93,15 @@
::toTriple
)
.collect { (_, lastStartedStep, occluded) ->
- if (lastStartedStep.to == KeyguardState.AOD) {
- val toState =
- if (occluded) KeyguardState.OCCLUDED else KeyguardState.LOCKSCREEN
+ if (lastStartedStep.to == KeyguardState.AOD && !occluded) {
val modeOnCanceled =
- if (
- toState == KeyguardState.LOCKSCREEN &&
- lastStartedStep.from == KeyguardState.LOCKSCREEN
- ) {
+ if (lastStartedStep.from == KeyguardState.LOCKSCREEN) {
TransitionModeOnCanceled.REVERSE
} else {
TransitionModeOnCanceled.LAST_VALUE
}
startTransitionTo(
- toState = toState,
+ toState = KeyguardState.LOCKSCREEN,
modeOnCanceled = modeOnCanceled,
)
}
@@ -93,11 +109,26 @@
}
}
+ /**
+ * If there is a biometric lockout and FPS is tapped while on AOD, it should go directly to the
+ * PRIMARY_BOUNCER.
+ */
+ private fun listenForAodToPrimaryBouncer() {
+ scope.launch {
+ keyguardInteractor.primaryBouncerShowing
+ .sample(startedKeyguardTransitionStep, ::Pair)
+ .collect { (isBouncerShowing, lastStartedTransitionStep) ->
+ if (isBouncerShowing && lastStartedTransitionStep.to == KeyguardState.AOD) {
+ startTransitionTo(KeyguardState.PRIMARY_BOUNCER)
+ }
+ }
+ }
+ }
+
private fun listenForAodToGone() {
scope.launch {
keyguardInteractor.biometricUnlockState.sample(finishedKeyguardState, ::Pair).collect {
- pair ->
- val (biometricUnlockState, keyguardState) = pair
+ (biometricUnlockState, keyguardState) ->
if (keyguardState == KeyguardState.AOD && isWakeAndUnlock(biometricUnlockState)) {
startTransitionTo(KeyguardState.GONE)
}
diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/domain/interactor/KeyguardSmartspaceInteractor.kt b/packages/SystemUI/src/com/android/systemui/keyguard/domain/interactor/KeyguardSmartspaceInteractor.kt
new file mode 100644
index 0000000..67b5745
--- /dev/null
+++ b/packages/SystemUI/src/com/android/systemui/keyguard/domain/interactor/KeyguardSmartspaceInteractor.kt
@@ -0,0 +1,33 @@
+/*
+ * Copyright (C) 2023 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.systemui.keyguard.domain.interactor
+
+import com.android.systemui.dagger.SysUISingleton
+import com.android.systemui.keyguard.data.repository.KeyguardSmartspaceRepository
+import javax.inject.Inject
+import kotlinx.coroutines.flow.StateFlow
+
+@SysUISingleton
+class KeyguardSmartspaceInteractor
+@Inject
+constructor(private val keyguardSmartspaceRepository: KeyguardSmartspaceRepository) {
+ var bcSmartspaceVisibility: StateFlow<Int> = keyguardSmartspaceRepository.bcSmartspaceVisibility
+
+ fun setBcSmartspaceVisibility(visibility: Int) {
+ keyguardSmartspaceRepository.setBcSmartspaceVisibility(visibility)
+ }
+}
diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/domain/interactor/KeyguardTransitionInteractor.kt b/packages/SystemUI/src/com/android/systemui/keyguard/domain/interactor/KeyguardTransitionInteractor.kt
index a8223ea..b43ab5e 100644
--- a/packages/SystemUI/src/com/android/systemui/keyguard/domain/interactor/KeyguardTransitionInteractor.kt
+++ b/packages/SystemUI/src/com/android/systemui/keyguard/domain/interactor/KeyguardTransitionInteractor.kt
@@ -37,17 +37,19 @@
import com.android.systemui.keyguard.shared.model.TransitionStep
import javax.inject.Inject
import kotlinx.coroutines.CoroutineScope
+import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.SharedFlow
import kotlinx.coroutines.flow.SharingStarted
-import kotlinx.coroutines.flow.combine
import kotlinx.coroutines.flow.distinctUntilChanged
import kotlinx.coroutines.flow.filter
import kotlinx.coroutines.flow.map
+import kotlinx.coroutines.flow.mapLatest
import kotlinx.coroutines.flow.merge
import kotlinx.coroutines.flow.shareIn
/** Encapsulates business-logic related to the keyguard transitions. */
+@OptIn(ExperimentalCoroutinesApi::class)
@SysUISingleton
class KeyguardTransitionInteractor
@Inject
@@ -192,29 +194,121 @@
val finishedKeyguardTransitionStep: Flow<TransitionStep> =
repository.transitions.filter { step -> step.transitionState == TransitionState.FINISHED }
- /** The destination state of the last started transition. */
+ /** The destination state of the last [TransitionState.STARTED] transition. */
val startedKeyguardState: SharedFlow<KeyguardState> =
startedKeyguardTransitionStep
.map { step -> step.to }
.shareIn(scope, SharingStarted.Eagerly, replay = 1)
- /** The last completed [KeyguardState] transition */
+ /**
+ * The last [KeyguardState] to which we [TransitionState.FINISHED] a transition.
+ *
+ * WARNING: This will NOT emit a value if a transition is CANCELED, and will also not emit a
+ * value when a subsequent transition is STARTED. It will *only* emit once we have finally
+ * FINISHED in a state. This can have unintuitive implications.
+ *
+ * For example, if we're transitioning from GONE -> DOZING, and that transition is CANCELED in
+ * favor of a DOZING -> LOCKSCREEN transition, the FINISHED state is still GONE, and will remain
+ * GONE throughout the DOZING -> LOCKSCREEN transition until the DOZING -> LOCKSCREEN transition
+ * finishes (at which point we'll be FINISHED in LOCKSCREEN).
+ *
+ * Since there's no real limit to how many consecutive transitions can be canceled, it's even
+ * possible for the FINISHED state to be the same as the STARTED state while still
+ * transitioning.
+ *
+ * For example:
+ * 1. We're finished in GONE.
+ * 2. The user presses the power button, starting a GONE -> DOZING transition. We're still
+ * FINISHED in GONE.
+ * 3. The user changes their mind, pressing the power button to wake up; this starts a DOZING ->
+ * LOCKSCREEN transition. We're still FINISHED in GONE.
+ * 4. The user quickly swipes away the lockscreen prior to DOZING -> LOCKSCREEN finishing; this
+ * starts a LOCKSCREEN -> GONE transition. We're still FINISHED in GONE, but we've also
+ * STARTED a transition *to* GONE.
+ * 5. We'll emit KeyguardState.GONE again once the transition finishes.
+ *
+ * If you just need to know when we eventually settle into a state, this flow is likely
+ * sufficient. However, if you're having issues with state *during* transitions started after
+ * one or more canceled transitions, you probably need to use [currentKeyguardState].
+ */
val finishedKeyguardState: SharedFlow<KeyguardState> =
finishedKeyguardTransitionStep
.map { step -> step.to }
.shareIn(scope, SharingStarted.Eagerly, replay = 1)
/**
- * Whether we're currently in a transition to a new [KeyguardState] and haven't yet completed
- * it.
+ * The [KeyguardState] we're currently in.
+ *
+ * If we're not in transition, this is simply the [finishedKeyguardState]. If we're in
+ * transition, this is the state we're transitioning *from*.
+ *
+ * Absent CANCELED transitions, [currentKeyguardState] and [finishedKeyguardState] are always
+ * identical - if a transition FINISHES in a given state, the subsequent state we START a
+ * transition *from* would always be that same previously FINISHED state.
+ *
+ * However, if a transition is CANCELED, the next transition will START from a state we never
+ * FINISHED in. For example, if we transition from GONE -> DOZING, but CANCEL that transition in
+ * favor of DOZING -> LOCKSCREEN, we've STARTED a transition *from* DOZING despite never
+ * FINISHING in DOZING. Thus, the current state will be DOZING but the FINISHED state will still
+ * be GONE.
+ *
+ * In this example, if there was DOZING-related state that needs to be set up in order to
+ * properly render a DOZING -> LOCKSCREEN transition, it would never be set up if we were
+ * listening for [finishedKeyguardState] to emit DOZING. However, [currentKeyguardState] would
+ * emit DOZING immediately upon STARTING DOZING -> LOCKSCREEN, allowing us to set up the state.
+ *
+ * Whether you want to use [currentKeyguardState] or [finishedKeyguardState] depends on your
+ * specific use case and how you want to handle cancellations. In general, if you're dealing
+ * with state/UI present across multiple [KeyguardState]s, you probably want
+ * [currentKeyguardState]. If you're dealing with state/UI encapsulated within a single state,
+ * you likely want [finishedKeyguardState].
+ *
+ * As an example, let's say you want to animate in a message on the lockscreen UI after waking
+ * up, and that TextView is not involved in animations between states. You'd want to collect
+ * [finishedKeyguardState], so you'll only animate it in once we're settled on the lockscreen.
+ * If you use [currentKeyguardState] in this case, a DOZING -> LOCKSCREEN transition that is
+ * interrupted by a LOCKSCREEN -> GONE transition would cause the message to become visible
+ * immediately upon LOCKSCREEN -> GONE STARTING, as the current state would become LOCKSCREEN in
+ * that case. That's likely not what you want.
+ *
+ * On the other hand, let's say you're animating the smartspace from alpha 0f to 1f during
+ * DOZING -> LOCKSCREEN, but the transition is interrupted by LOCKSCREEN -> GONE. LS -> GONE
+ * needs the smartspace to be alpha=1f so that it can play the shared-element unlock animation.
+ * In this case, we'd want to collect [currentKeyguardState] and ensure the smartspace is
+ * visible when the current state is LOCKSCREEN. If you use [finishedKeyguardState] in this
+ * case, the smartspace will never be set to alpha = 1f and you'll have a half-faded smartspace
+ * during the LS -> GONE transition.
+ *
+ * If you need special-case handling for cancellations (such as conditional handling depending
+ * on which [KeyguardState] was canceled) you can collect [canceledKeyguardTransitionStep]
+ * directly.
+ *
+ * As a helpful footnote, here's the values of [finishedKeyguardState] and
+ * [currentKeyguardState] during a sequence with two cancellations:
+ * 1. We're FINISHED in GONE. currentKeyguardState=GONE; finishedKeyguardState=GONE.
+ * 2. We START a transition from GONE -> DOZING. currentKeyguardState=GONE;
+ * finishedKeyguardState=GONE.
+ * 3. We CANCEL this transition and START a transition from DOZING -> LOCKSCREEN.
+ * currentKeyguardState=DOZING; finishedKeyguardState=GONE.
+ * 4. We subsequently also CANCEL DOZING -> LOCKSCREEN and START LOCKSCREEN -> GONE.
+ * currentKeyguardState=LOCKSCREEN finishedKeyguardState=GONE.
+ * 5. LOCKSCREEN -> GONE is allowed to FINISH. currentKeyguardState=GONE;
+ * finishedKeyguardState=GONE.
*/
- val isInTransitionToAnyState =
- combine(
- startedKeyguardTransitionStep,
- finishedKeyguardState,
- ) { startedStep, finishedState ->
- startedStep.to != finishedState
- }
+ val currentKeyguardState: SharedFlow<KeyguardState> =
+ repository.transitions
+ .mapLatest {
+ if (it.transitionState == TransitionState.FINISHED) {
+ it.to
+ } else {
+ it.from
+ }
+ }
+ .distinctUntilChanged()
+ .shareIn(scope, SharingStarted.Eagerly, replay = 1)
+
+ /** Whether we've currently STARTED a transition and haven't yet FINISHED it. */
+ val isInTransitionToAnyState = isInTransitionWhere({ true }, { true })
/**
* The amount of transition into or out of the given [KeyguardState].
@@ -304,13 +398,12 @@
fromStatePredicate: (KeyguardState) -> Boolean,
toStatePredicate: (KeyguardState) -> Boolean,
): Flow<Boolean> {
- return combine(
- startedKeyguardTransitionStep,
- finishedKeyguardState,
- ) { startedStep, finishedState ->
- fromStatePredicate(startedStep.from) &&
- toStatePredicate(startedStep.to) &&
- finishedState != startedStep.to
+ return repository.transitions
+ .filter { it.transitionState != TransitionState.CANCELED }
+ .mapLatest {
+ it.transitionState != TransitionState.FINISHED &&
+ fromStatePredicate(it.from) &&
+ toStatePredicate(it.to)
}
.distinctUntilChanged()
}
diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/ui/binder/KeyguardClockViewBinder.kt b/packages/SystemUI/src/com/android/systemui/keyguard/ui/binder/KeyguardClockViewBinder.kt
index bf763b4..400b8bf 100644
--- a/packages/SystemUI/src/com/android/systemui/keyguard/ui/binder/KeyguardClockViewBinder.kt
+++ b/packages/SystemUI/src/com/android/systemui/keyguard/ui/binder/KeyguardClockViewBinder.kt
@@ -30,7 +30,10 @@
import androidx.lifecycle.Lifecycle
import androidx.lifecycle.repeatOnLifecycle
import com.android.app.animation.Interpolators
+import com.android.keyguard.KeyguardClockSwitch.LARGE
+import com.android.keyguard.KeyguardClockSwitch.SMALL
import com.android.systemui.Flags.migrateClocksToBlueprint
+import com.android.systemui.keyguard.domain.interactor.KeyguardBlueprintInteractor
import com.android.systemui.keyguard.domain.interactor.KeyguardClockInteractor
import com.android.systemui.keyguard.ui.view.layout.sections.ClockSection
import com.android.systemui.keyguard.ui.viewmodel.KeyguardClockViewModel
@@ -48,6 +51,7 @@
keyguardRootView: ConstraintLayout,
viewModel: KeyguardClockViewModel,
keyguardClockInteractor: KeyguardClockInteractor,
+ blueprintInteractor: KeyguardBlueprintInteractor,
) {
keyguardRootView.repeatWhenAttached {
repeatOnLifecycle(Lifecycle.State.CREATED) {
@@ -61,18 +65,16 @@
viewModel.currentClock.collect { currentClock ->
cleanupClockViews(viewModel.clock, keyguardRootView, viewModel.burnInLayer)
viewModel.clock = currentClock
- addClockViews(currentClock, keyguardRootView, viewModel.burnInLayer)
- viewModel.burnInLayer?.updatePostLayout(keyguardRootView)
- applyConstraints(clockSection, keyguardRootView, true)
+ addClockViews(currentClock, keyguardRootView)
+ updateBurnInLayer(keyguardRootView, viewModel)
+ blueprintInteractor.refreshBlueprint()
}
}
- // TODO: Weather clock dozing animation
- // will trigger both shouldBeCentered and clockSize change
- // we should avoid this
launch {
if (!migrateClocksToBlueprint()) return@launch
viewModel.clockSize.collect {
- applyConstraints(clockSection, keyguardRootView, true)
+ updateBurnInLayer(keyguardRootView, viewModel)
+ blueprintInteractor.refreshBlueprint()
}
}
launch {
@@ -82,7 +84,7 @@
if (it.largeClock.config.hasCustomPositionUpdatedAnimation) {
playClockCenteringAnimation(clockSection, keyguardRootView, it)
} else {
- applyConstraints(clockSection, keyguardRootView, true)
+ blueprintInteractor.refreshBlueprint()
}
}
}
@@ -90,6 +92,29 @@
}
}
}
+ @VisibleForTesting
+ fun updateBurnInLayer(
+ keyguardRootView: ConstraintLayout,
+ viewModel: KeyguardClockViewModel,
+ ) {
+ val burnInLayer = viewModel.burnInLayer
+ val clockController = viewModel.currentClock.value
+ clockController?.let { clock ->
+ when (viewModel.clockSize.value) {
+ LARGE -> {
+ clock.smallClock.layout.views.forEach { burnInLayer?.removeView(it) }
+ if (clock.config.useAlternateSmartspaceAODTransition) {
+ clock.largeClock.layout.views.forEach { burnInLayer?.addView(it) }
+ }
+ }
+ SMALL -> {
+ clock.smallClock.layout.views.forEach { burnInLayer?.addView(it) }
+ clock.largeClock.layout.views.forEach { burnInLayer?.removeView(it) }
+ }
+ }
+ }
+ viewModel.burnInLayer?.updatePostLayout(keyguardRootView)
+ }
private fun cleanupClockViews(
clockController: ClockController?,
@@ -116,7 +141,6 @@
fun addClockViews(
clockController: ClockController?,
rootView: ConstraintLayout,
- burnInLayer: Layer?
) {
clockController?.let { clock ->
clock.smallClock.layout.views[0].id = R.id.lockscreen_clock_view
@@ -125,17 +149,10 @@
}
// small clock should either be a single view or container with id
// `lockscreen_clock_view`
- clock.smallClock.layout.views.forEach {
- rootView.addView(it)
- burnInLayer?.addView(it)
- }
+ clock.smallClock.layout.views.forEach { rootView.addView(it) }
clock.largeClock.layout.views.forEach { rootView.addView(it) }
- if (clock.config.useAlternateSmartspaceAODTransition) {
- clock.largeClock.layout.views.forEach { burnInLayer?.addView(it) }
- }
}
}
-
fun applyConstraints(
clockSection: ClockSection,
rootView: ConstraintLayout,
diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/ui/binder/KeyguardSmartspaceViewBinder.kt b/packages/SystemUI/src/com/android/systemui/keyguard/ui/binder/KeyguardSmartspaceViewBinder.kt
index 81ce8f0..10392e3 100644
--- a/packages/SystemUI/src/com/android/systemui/keyguard/ui/binder/KeyguardSmartspaceViewBinder.kt
+++ b/packages/SystemUI/src/com/android/systemui/keyguard/ui/binder/KeyguardSmartspaceViewBinder.kt
@@ -16,15 +16,13 @@
package com.android.systemui.keyguard.ui.binder
-import android.transition.TransitionManager
import android.view.View
import androidx.constraintlayout.helper.widget.Layer
import androidx.constraintlayout.widget.ConstraintLayout
-import androidx.constraintlayout.widget.ConstraintSet
import androidx.lifecycle.Lifecycle
import androidx.lifecycle.repeatOnLifecycle
import com.android.systemui.Flags.migrateClocksToBlueprint
-import com.android.systemui.keyguard.ui.view.layout.sections.SmartspaceSection
+import com.android.systemui.keyguard.domain.interactor.KeyguardBlueprintInteractor
import com.android.systemui.keyguard.ui.viewmodel.KeyguardClockViewModel
import com.android.systemui.keyguard.ui.viewmodel.KeyguardSmartspaceViewModel
import com.android.systemui.lifecycle.repeatWhenAttached
@@ -35,10 +33,10 @@
object KeyguardSmartspaceViewBinder {
@JvmStatic
fun bind(
- smartspaceSection: SmartspaceSection,
keyguardRootView: ConstraintLayout,
clockViewModel: KeyguardClockViewModel,
smartspaceViewModel: KeyguardSmartspaceViewModel,
+ blueprintInteractor: KeyguardBlueprintInteractor,
) {
keyguardRootView.repeatWhenAttached {
repeatOnLifecycle(Lifecycle.State.STARTED) {
@@ -46,22 +44,56 @@
if (!migrateClocksToBlueprint()) return@launch
clockViewModel.hasCustomWeatherDataDisplay.collect { hasCustomWeatherDataDisplay
->
- if (hasCustomWeatherDataDisplay) {
- removeDateWeatherToBurnInLayer(keyguardRootView, smartspaceViewModel)
- } else {
- addDateWeatherToBurnInLayer(keyguardRootView, smartspaceViewModel)
- }
- clockViewModel.burnInLayer?.updatePostLayout(keyguardRootView)
- val constraintSet = ConstraintSet().apply { clone(keyguardRootView) }
- smartspaceSection.applyConstraints(constraintSet)
- TransitionManager.beginDelayedTransition(keyguardRootView)
- constraintSet.applyTo(keyguardRootView)
+ updateDateWeatherToBurnInLayer(
+ keyguardRootView,
+ clockViewModel,
+ smartspaceViewModel
+ )
+ blueprintInteractor.refreshBlueprint()
+ }
+ }
+
+ launch {
+ smartspaceViewModel.bcSmartspaceVisibility.collect {
+ updateBCSmartspaceInBurnInLayer(keyguardRootView, clockViewModel)
+ blueprintInteractor.refreshBlueprint()
}
}
}
}
}
+ private fun updateBCSmartspaceInBurnInLayer(
+ keyguardRootView: ConstraintLayout,
+ clockViewModel: KeyguardClockViewModel,
+ ) {
+ // Visibility is controlled by updateTargetVisibility in CardPagerAdapter
+ val burnInLayer = keyguardRootView.requireViewById<Layer>(R.id.burn_in_layer)
+ burnInLayer.apply {
+ val smartspaceView =
+ keyguardRootView.requireViewById<View>(sharedR.id.bc_smartspace_view)
+ if (smartspaceView.visibility == View.VISIBLE) {
+ addView(smartspaceView)
+ } else {
+ removeView(smartspaceView)
+ }
+ }
+ clockViewModel.burnInLayer?.updatePostLayout(keyguardRootView)
+ }
+
+ private fun updateDateWeatherToBurnInLayer(
+ keyguardRootView: ConstraintLayout,
+ clockViewModel: KeyguardClockViewModel,
+ smartspaceViewModel: KeyguardSmartspaceViewModel
+ ) {
+ if (clockViewModel.hasCustomWeatherDataDisplay.value) {
+ removeDateWeatherFromBurnInLayer(keyguardRootView, smartspaceViewModel)
+ } else {
+ addDateWeatherToBurnInLayer(keyguardRootView, smartspaceViewModel)
+ }
+ clockViewModel.burnInLayer?.updatePostLayout(keyguardRootView)
+ }
+
private fun addDateWeatherToBurnInLayer(
constraintLayout: ConstraintLayout,
smartspaceViewModel: KeyguardSmartspaceViewModel
@@ -76,13 +108,13 @@
constraintLayout.requireViewById<View>(sharedR.id.date_smartspace_view)
val weatherView =
constraintLayout.requireViewById<View>(sharedR.id.weather_smartspace_view)
- addView(weatherView)
addView(dateView)
+ addView(weatherView)
}
}
}
- private fun removeDateWeatherToBurnInLayer(
+ private fun removeDateWeatherFromBurnInLayer(
constraintLayout: ConstraintLayout,
smartspaceViewModel: KeyguardSmartspaceViewModel
) {
diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/ui/view/layout/blueprints/SplitShadeKeyguardBlueprint.kt b/packages/SystemUI/src/com/android/systemui/keyguard/ui/view/layout/blueprints/SplitShadeKeyguardBlueprint.kt
index 24d0602..8472a9f 100644
--- a/packages/SystemUI/src/com/android/systemui/keyguard/ui/view/layout/blueprints/SplitShadeKeyguardBlueprint.kt
+++ b/packages/SystemUI/src/com/android/systemui/keyguard/ui/view/layout/blueprints/SplitShadeKeyguardBlueprint.kt
@@ -23,6 +23,7 @@
import com.android.systemui.keyguard.shared.model.KeyguardSection
import com.android.systemui.keyguard.ui.view.layout.sections.AodBurnInSection
import com.android.systemui.keyguard.ui.view.layout.sections.AodNotificationIconsSection
+import com.android.systemui.keyguard.ui.view.layout.sections.ClockSection
import com.android.systemui.keyguard.ui.view.layout.sections.DefaultDeviceEntrySection
import com.android.systemui.keyguard.ui.view.layout.sections.DefaultIndicationAreaSection
import com.android.systemui.keyguard.ui.view.layout.sections.DefaultSettingsPopupMenuSection
@@ -30,11 +31,10 @@
import com.android.systemui.keyguard.ui.view.layout.sections.DefaultStatusBarSection
import com.android.systemui.keyguard.ui.view.layout.sections.DefaultStatusViewSection
import com.android.systemui.keyguard.ui.view.layout.sections.KeyguardSectionsModule
-import com.android.systemui.keyguard.ui.view.layout.sections.SplitShadeClockSection
+import com.android.systemui.keyguard.ui.view.layout.sections.SmartspaceSection
import com.android.systemui.keyguard.ui.view.layout.sections.SplitShadeGuidelines
import com.android.systemui.keyguard.ui.view.layout.sections.SplitShadeMediaSection
import com.android.systemui.keyguard.ui.view.layout.sections.SplitShadeNotificationStackScrollLayoutSection
-import com.android.systemui.keyguard.ui.view.layout.sections.SplitShadeSmartspaceSection
import com.android.systemui.util.kotlin.getOrNull
import java.util.Optional
import javax.inject.Inject
@@ -62,8 +62,8 @@
aodNotificationIconsSection: AodNotificationIconsSection,
aodBurnInSection: AodBurnInSection,
communalTutorialIndicatorSection: CommunalTutorialIndicatorSection,
- smartspaceSection: SplitShadeSmartspaceSection,
- clockSection: SplitShadeClockSection,
+ clockSection: ClockSection,
+ smartspaceSection: SmartspaceSection,
mediaSection: SplitShadeMediaSection,
) : KeyguardBlueprint {
override val id: String = ID
diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/ui/view/layout/blueprints/transitions/BaseBlueprintTransition.kt b/packages/SystemUI/src/com/android/systemui/keyguard/ui/view/layout/blueprints/transitions/BaseBlueprintTransition.kt
index d0626d5..fd530b7 100644
--- a/packages/SystemUI/src/com/android/systemui/keyguard/ui/view/layout/blueprints/transitions/BaseBlueprintTransition.kt
+++ b/packages/SystemUI/src/com/android/systemui/keyguard/ui/view/layout/blueprints/transitions/BaseBlueprintTransition.kt
@@ -25,6 +25,8 @@
import android.view.View
import android.view.ViewGroup
import androidx.constraintlayout.helper.widget.Layer
+import com.android.systemui.plugins.BcSmartspaceDataPlugin.SmartspaceView
+import com.android.systemui.res.R
class BaseBlueprintTransition : TransitionSet() {
init {
@@ -33,7 +35,16 @@
.addTransition(ChangeBounds())
.addTransition(AlphaInVisibility())
excludeTarget(Layer::class.java, /* exclude= */ true)
+ excludeClockAndSmartspaceViews()
}
+
+ private fun excludeClockAndSmartspaceViews() {
+ excludeTarget(R.id.lockscreen_clock_view, true)
+ excludeTarget(R.id.lockscreen_clock_view_large, true)
+ excludeTarget(SmartspaceView::class.java, true)
+ // TODO(b/319468190): need to exclude views from large weather clock
+ }
+
class AlphaOutVisibility : Visibility() {
override fun onDisappear(
sceneRoot: ViewGroup?,
diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/ui/view/layout/sections/AodBurnInLayer.kt b/packages/SystemUI/src/com/android/systemui/keyguard/ui/view/layout/sections/AodBurnInLayer.kt
new file mode 100644
index 0000000..67a20e5
--- /dev/null
+++ b/packages/SystemUI/src/com/android/systemui/keyguard/ui/view/layout/sections/AodBurnInLayer.kt
@@ -0,0 +1,73 @@
+/*
+ * Copyright (C) 2023 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.systemui.keyguard.ui.view.layout.sections
+
+import android.content.Context
+import android.view.View
+import androidx.constraintlayout.helper.widget.Layer
+
+class AodBurnInLayer(context: Context) : Layer(context) {
+ // For setScale in Layer class, it stores it in mScaleX/Y and directly apply scale to
+ // referenceViews instead of keeping the value in fields of View class
+ // when we try to clone ConstraintSet, it will call getScaleX from View class and return 1.0
+ // and when we clone and apply, it will reset everything in the layer
+ // which cause the flicker from AOD to LS
+ private var _scaleX = 1F
+ private var _scaleY = 1F
+ // As described for _scaleX and _scaleY, we have similar issue with translation
+ private var _translationX = 1F
+ private var _translationY = 1F
+ // avoid adding views with same ids
+ override fun addView(view: View?) {
+ view?.let { if (it.id !in referencedIds) super.addView(view) }
+ }
+ override fun setScaleX(scaleX: Float) {
+ _scaleX = scaleX
+ super.setScaleX(scaleX)
+ }
+
+ override fun getScaleX(): Float {
+ return _scaleX
+ }
+
+ override fun setScaleY(scaleY: Float) {
+ _scaleY = scaleY
+ super.setScaleY(scaleY)
+ }
+
+ override fun getScaleY(): Float {
+ return _scaleY
+ }
+
+ override fun setTranslationX(dx: Float) {
+ _translationX = dx
+ super.setTranslationX(dx)
+ }
+
+ override fun getTranslationX(): Float {
+ return _translationX
+ }
+
+ override fun setTranslationY(dy: Float) {
+ _translationY = dy
+ super.setTranslationY(dy)
+ }
+
+ override fun getTranslationY(): Float {
+ return _translationY
+ }
+}
diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/ui/view/layout/sections/AodBurnInSection.kt b/packages/SystemUI/src/com/android/systemui/keyguard/ui/view/layout/sections/AodBurnInSection.kt
index 1ccc6cc..3d36eb0 100644
--- a/packages/SystemUI/src/com/android/systemui/keyguard/ui/view/layout/sections/AodBurnInSection.kt
+++ b/packages/SystemUI/src/com/android/systemui/keyguard/ui/view/layout/sections/AodBurnInSection.kt
@@ -19,16 +19,13 @@
import android.content.Context
import android.view.View
-import androidx.constraintlayout.helper.widget.Layer
import androidx.constraintlayout.widget.ConstraintLayout
import androidx.constraintlayout.widget.ConstraintSet
import com.android.systemui.Flags.migrateClocksToBlueprint
import com.android.systemui.keyguard.shared.KeyguardShadeMigrationNssl
import com.android.systemui.keyguard.shared.model.KeyguardSection
import com.android.systemui.keyguard.ui.viewmodel.KeyguardClockViewModel
-import com.android.systemui.keyguard.ui.viewmodel.KeyguardSmartspaceViewModel
import com.android.systemui.res.R
-import com.android.systemui.shared.R as sharedR
import javax.inject.Inject
/** Adds a layer to group elements for translation for burn-in preventation */
@@ -37,10 +34,8 @@
constructor(
private val context: Context,
private val clockViewModel: KeyguardClockViewModel,
- private val smartspaceViewModel: KeyguardSmartspaceViewModel,
) : KeyguardSection() {
- lateinit var burnInLayer: Layer
-
+ private lateinit var burnInLayer: AodBurnInLayer
override fun addViews(constraintLayout: ConstraintLayout) {
if (!KeyguardShadeMigrationNssl.isEnabled) {
return
@@ -48,7 +43,7 @@
val nic = constraintLayout.requireViewById<View>(R.id.aod_notification_icon_container)
burnInLayer =
- Layer(context).apply {
+ AodBurnInLayer(context).apply {
id = R.id.burn_in_layer
addView(nic)
if (!migrateClocksToBlueprint()) {
@@ -57,11 +52,6 @@
addView(statusView)
}
}
- if (migrateClocksToBlueprint()) {
- // weather and date parts won't be added here, cause their visibility doesn't align
- // with others in burnInLayer
- addSmartspaceViews(constraintLayout)
- }
constraintLayout.addView(burnInLayer)
}
@@ -83,14 +73,4 @@
override fun removeViews(constraintLayout: ConstraintLayout) {
constraintLayout.removeView(R.id.burn_in_layer)
}
-
- private fun addSmartspaceViews(constraintLayout: ConstraintLayout) {
- burnInLayer.apply {
- if (smartspaceViewModel.isSmartspaceEnabled) {
- val smartspaceView =
- constraintLayout.requireViewById<View>(sharedR.id.bc_smartspace_view)
- addView(smartspaceView)
- }
- }
- }
}
diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/ui/view/layout/sections/AodNotificationIconsSection.kt b/packages/SystemUI/src/com/android/systemui/keyguard/ui/view/layout/sections/AodNotificationIconsSection.kt
index f560b5f..ed7abff 100644
--- a/packages/SystemUI/src/com/android/systemui/keyguard/ui/view/layout/sections/AodNotificationIconsSection.kt
+++ b/packages/SystemUI/src/com/android/systemui/keyguard/ui/view/layout/sections/AodNotificationIconsSection.kt
@@ -30,9 +30,7 @@
import com.android.systemui.common.ui.ConfigurationState
import com.android.systemui.keyguard.shared.KeyguardShadeMigrationNssl
import com.android.systemui.keyguard.shared.model.KeyguardSection
-import com.android.systemui.keyguard.ui.viewmodel.KeyguardSmartspaceViewModel
import com.android.systemui.res.R
-import com.android.systemui.shared.R as sharedR
import com.android.systemui.statusbar.notification.icon.ui.viewbinder.AlwaysOnDisplayNotificationIconViewStore
import com.android.systemui.statusbar.notification.icon.ui.viewbinder.NotificationIconContainerViewBinder
import com.android.systemui.statusbar.notification.icon.ui.viewbinder.StatusBarIconViewBindingFailureTracker
@@ -53,13 +51,13 @@
private val nicAodViewModel: NotificationIconContainerAlwaysOnDisplayViewModel,
private val nicAodIconViewStore: AlwaysOnDisplayNotificationIconViewStore,
private val notificationIconAreaController: NotificationIconAreaController,
- private val smartspaceViewModel: KeyguardSmartspaceViewModel,
private val systemBarUtilsState: SystemBarUtilsState,
) : KeyguardSection() {
private var nicBindingDisposable: DisposableHandle? = null
private val nicId = R.id.aod_notification_icon_container
private lateinit var nic: NotificationIconContainer
+ private val smartSpaceBarrier = View.generateViewId()
override fun addViews(constraintLayout: ConstraintLayout) {
if (!KeyguardShadeMigrationNssl.isEnabled) {
@@ -118,7 +116,7 @@
}
constraintSet.apply {
if (migrateClocksToBlueprint()) {
- connect(nicId, TOP, sharedR.id.bc_smartspace_view, BOTTOM, bottomMargin)
+ connect(nicId, TOP, R.id.smart_space_barrier_bottom, BOTTOM, bottomMargin)
setGoneMargin(nicId, BOTTOM, bottomMargin)
} else {
connect(nicId, TOP, R.id.keyguard_status_view, topAlignment, bottomMargin)
diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/ui/view/layout/sections/ClockSection.kt b/packages/SystemUI/src/com/android/systemui/keyguard/ui/view/layout/sections/ClockSection.kt
index b5f32c8..b344d3b 100644
--- a/packages/SystemUI/src/com/android/systemui/keyguard/ui/view/layout/sections/ClockSection.kt
+++ b/packages/SystemUI/src/com/android/systemui/keyguard/ui/view/layout/sections/ClockSection.kt
@@ -23,11 +23,14 @@
import androidx.constraintlayout.widget.ConstraintSet
import androidx.constraintlayout.widget.ConstraintSet.BOTTOM
import androidx.constraintlayout.widget.ConstraintSet.END
+import androidx.constraintlayout.widget.ConstraintSet.INVISIBLE
import androidx.constraintlayout.widget.ConstraintSet.PARENT_ID
import androidx.constraintlayout.widget.ConstraintSet.START
import androidx.constraintlayout.widget.ConstraintSet.TOP
+import androidx.constraintlayout.widget.ConstraintSet.VISIBLE
import androidx.constraintlayout.widget.ConstraintSet.WRAP_CONTENT
import com.android.systemui.Flags
+import com.android.systemui.keyguard.domain.interactor.KeyguardBlueprintInteractor
import com.android.systemui.keyguard.domain.interactor.KeyguardClockInteractor
import com.android.systemui.keyguard.shared.model.KeyguardSection
import com.android.systemui.keyguard.ui.binder.KeyguardClockViewBinder
@@ -35,8 +38,10 @@
import com.android.systemui.plugins.clocks.ClockController
import com.android.systemui.plugins.clocks.ClockFaceLayout
import com.android.systemui.res.R
+import com.android.systemui.shared.R as sharedR
import com.android.systemui.statusbar.policy.SplitShadeStateController
import com.android.systemui.util.Utils
+import dagger.Lazy
import javax.inject.Inject
internal fun ConstraintSet.setVisibility(
@@ -56,6 +61,7 @@
protected val keyguardClockViewModel: KeyguardClockViewModel,
private val context: Context,
private val splitShadeStateController: SplitShadeStateController,
+ val blueprintInteractor: Lazy<KeyguardBlueprintInteractor>,
) : KeyguardSection() {
override fun addViews(constraintLayout: ConstraintLayout) {}
@@ -68,6 +74,7 @@
constraintLayout,
keyguardClockViewModel,
clockInteractor,
+ blueprintInteractor.get()
)
}
@@ -88,12 +95,16 @@
): ConstraintSet {
// Add constraint between rootView and clockContainer
applyDefaultConstraints(constraintSet)
+ getNonTargetClockFace(clock).applyConstraints(constraintSet)
getTargetClockFace(clock).applyConstraints(constraintSet)
// Add constraint between elements in clock and clock container
return constraintSet.apply {
- setAlpha(getTargetClockFace(clock).views, 1F)
- setAlpha(getNonTargetClockFace(clock).views, 0F)
+ setVisibility(getTargetClockFace(clock).views, VISIBLE)
+ setVisibility(getNonTargetClockFace(clock).views, INVISIBLE)
+ if (!keyguardClockViewModel.useLargeClock) {
+ connect(sharedR.id.bc_smartspace_view, TOP, sharedR.id.date_smartspace_view, BOTTOM)
+ }
}
}
@@ -107,9 +118,12 @@
private fun getLargeClockFace(clock: ClockController): ClockFaceLayout = clock.largeClock.layout
private fun getSmallClockFace(clock: ClockController): ClockFaceLayout = clock.smallClock.layout
open fun applyDefaultConstraints(constraints: ConstraintSet) {
+ val guideline =
+ if (keyguardClockViewModel.clockShouldBeCentered.value) PARENT_ID
+ else R.id.split_shade_guideline
constraints.apply {
connect(R.id.lockscreen_clock_view_large, START, PARENT_ID, START)
- connect(R.id.lockscreen_clock_view_large, END, PARENT_ID, END)
+ connect(R.id.lockscreen_clock_view_large, END, guideline, END)
connect(R.id.lockscreen_clock_view_large, BOTTOM, R.id.lock_icon_view, TOP)
var largeClockTopMargin =
context.resources.getDimensionPixelSize(R.dimen.status_bar_height) +
diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/ui/view/layout/sections/DefaultNotificationStackScrollLayoutSection.kt b/packages/SystemUI/src/com/android/systemui/keyguard/ui/view/layout/sections/DefaultNotificationStackScrollLayoutSection.kt
index b0eee0a..8c5e9b4 100644
--- a/packages/SystemUI/src/com/android/systemui/keyguard/ui/view/layout/sections/DefaultNotificationStackScrollLayoutSection.kt
+++ b/packages/SystemUI/src/com/android/systemui/keyguard/ui/view/layout/sections/DefaultNotificationStackScrollLayoutSection.kt
@@ -18,6 +18,7 @@
package com.android.systemui.keyguard.ui.view.layout.sections
import android.content.Context
+import android.view.View
import androidx.constraintlayout.widget.ConstraintSet
import androidx.constraintlayout.widget.ConstraintSet.BOTTOM
import androidx.constraintlayout.widget.ConstraintSet.END
@@ -27,11 +28,9 @@
import com.android.systemui.Flags.migrateClocksToBlueprint
import com.android.systemui.dagger.qualifiers.Main
import com.android.systemui.keyguard.shared.KeyguardShadeMigrationNssl
-import com.android.systemui.keyguard.ui.viewmodel.KeyguardSmartspaceViewModel
import com.android.systemui.res.R
import com.android.systemui.scene.shared.flag.SceneContainerFlags
import com.android.systemui.shade.NotificationPanelView
-import com.android.systemui.shared.R as sharedR
import com.android.systemui.statusbar.notification.stack.AmbientState
import com.android.systemui.statusbar.notification.stack.NotificationStackScrollLayoutController
import com.android.systemui.statusbar.notification.stack.NotificationStackSizeCalculator
@@ -54,7 +53,6 @@
ambientState: AmbientState,
controller: NotificationStackScrollLayoutController,
notificationStackSizeCalculator: NotificationStackSizeCalculator,
- private val smartspaceViewModel: KeyguardSmartspaceViewModel,
@Main mainDispatcher: CoroutineDispatcher,
) :
NotificationStackScrollLayoutSection(
@@ -69,6 +67,7 @@
notificationStackSizeCalculator,
mainDispatcher,
) {
+ private val smartSpaceBarrier = View.generateViewId()
override fun applyConstraints(constraintSet: ConstraintSet) {
if (!KeyguardShadeMigrationNssl.isEnabled) {
return
@@ -76,16 +75,14 @@
constraintSet.apply {
val bottomMargin =
context.resources.getDimensionPixelSize(R.dimen.keyguard_status_view_bottom_margin)
-
if (migrateClocksToBlueprint()) {
connect(
R.id.nssl_placeholder,
TOP,
- sharedR.id.bc_smartspace_view,
+ R.id.smart_space_barrier_bottom,
BOTTOM,
bottomMargin
)
- setGoneMargin(R.id.nssl_placeholder, TOP, bottomMargin)
} else {
connect(R.id.nssl_placeholder, TOP, R.id.keyguard_status_view, BOTTOM, bottomMargin)
}
diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/ui/view/layout/sections/SmartspaceSection.kt b/packages/SystemUI/src/com/android/systemui/keyguard/ui/view/layout/sections/SmartspaceSection.kt
index eacd466..37842a8 100644
--- a/packages/SystemUI/src/com/android/systemui/keyguard/ui/view/layout/sections/SmartspaceSection.kt
+++ b/packages/SystemUI/src/com/android/systemui/keyguard/ui/view/layout/sections/SmartspaceSection.kt
@@ -18,37 +18,41 @@
import android.content.Context
import android.view.View
+import android.view.View.GONE
+import android.view.ViewTreeObserver.OnGlobalLayoutListener
+import androidx.constraintlayout.widget.Barrier
import androidx.constraintlayout.widget.ConstraintLayout
import androidx.constraintlayout.widget.ConstraintSet
-import androidx.constraintlayout.widget.ConstraintSet.BOTTOM
-import androidx.constraintlayout.widget.ConstraintSet.END
-import androidx.constraintlayout.widget.ConstraintSet.PARENT_ID
-import androidx.constraintlayout.widget.ConstraintSet.START
-import androidx.constraintlayout.widget.ConstraintSet.TOP
-import androidx.constraintlayout.widget.ConstraintSet.WRAP_CONTENT
import com.android.systemui.Flags.migrateClocksToBlueprint
import com.android.systemui.keyguard.KeyguardUnlockAnimationController
+import com.android.systemui.keyguard.domain.interactor.KeyguardBlueprintInteractor
+import com.android.systemui.keyguard.domain.interactor.KeyguardSmartspaceInteractor
import com.android.systemui.keyguard.shared.model.KeyguardSection
import com.android.systemui.keyguard.ui.binder.KeyguardSmartspaceViewBinder
import com.android.systemui.keyguard.ui.viewmodel.KeyguardClockViewModel
import com.android.systemui.keyguard.ui.viewmodel.KeyguardSmartspaceViewModel
-import com.android.systemui.res.R
+import com.android.systemui.shared.R
import com.android.systemui.statusbar.lockscreen.LockscreenSmartspaceController
+import dagger.Lazy
import javax.inject.Inject
open class SmartspaceSection
@Inject
constructor(
+ val context: Context,
val keyguardClockViewModel: KeyguardClockViewModel,
val keyguardSmartspaceViewModel: KeyguardSmartspaceViewModel,
- private val context: Context,
+ val keyguardSmartspaceInteractor: KeyguardSmartspaceInteractor,
val smartspaceController: LockscreenSmartspaceController,
val keyguardUnlockAnimationController: KeyguardUnlockAnimationController,
+ val blueprintInteractor: Lazy<KeyguardBlueprintInteractor>,
) : KeyguardSection() {
private var smartspaceView: View? = null
private var weatherView: View? = null
private var dateView: View? = null
+ private var smartspaceVisibilityListener: OnGlobalLayoutListener? = null
+
override fun addViews(constraintLayout: ConstraintLayout) {
if (!migrateClocksToBlueprint()) {
return
@@ -64,6 +68,20 @@
}
}
keyguardUnlockAnimationController.lockscreenSmartspace = smartspaceView
+ smartspaceVisibilityListener =
+ object : OnGlobalLayoutListener {
+ var pastVisibility = GONE
+ override fun onGlobalLayout() {
+ smartspaceView?.let {
+ val newVisibility = it.visibility
+ if (pastVisibility != newVisibility) {
+ keyguardSmartspaceInteractor.setBcSmartspaceVisibility(newVisibility)
+ pastVisibility = newVisibility
+ }
+ }
+ }
+ }
+ smartspaceView?.viewTreeObserver?.addOnGlobalLayoutListener(smartspaceVisibilityListener)
}
override fun bindData(constraintLayout: ConstraintLayout) {
@@ -71,10 +89,10 @@
return
}
KeyguardSmartspaceViewBinder.bind(
- this,
constraintLayout,
keyguardClockViewModel,
keyguardSmartspaceViewModel,
+ blueprintInteractor.get(),
)
}
@@ -82,65 +100,96 @@
if (!migrateClocksToBlueprint()) {
return
}
- // Generally, weather should be next to dateView
- // smartspace should be below date & weather views
constraintSet.apply {
// migrate addDateWeatherView, addWeatherView from KeyguardClockSwitchController
- dateView?.let { dateView ->
- constrainHeight(dateView.id, WRAP_CONTENT)
- constrainWidth(dateView.id, WRAP_CONTENT)
- connect(
- dateView.id,
- START,
- PARENT_ID,
- START,
- context.resources.getDimensionPixelSize(R.dimen.below_clock_padding_start)
+ constrainHeight(R.id.date_smartspace_view, ConstraintSet.WRAP_CONTENT)
+ constrainWidth(R.id.date_smartspace_view, ConstraintSet.WRAP_CONTENT)
+ connect(
+ R.id.date_smartspace_view,
+ ConstraintSet.START,
+ ConstraintSet.PARENT_ID,
+ ConstraintSet.START,
+ context.resources.getDimensionPixelSize(
+ com.android.systemui.res.R.dimen.below_clock_padding_start
)
- }
- weatherView?.let {
- constrainWidth(it.id, WRAP_CONTENT)
- dateView?.let { dateView ->
- connect(it.id, TOP, dateView.id, TOP)
- connect(it.id, BOTTOM, dateView.id, BOTTOM)
- connect(it.id, START, dateView.id, END, 4)
- }
- }
+ )
+ constrainWidth(R.id.weather_smartspace_view, ConstraintSet.WRAP_CONTENT)
+ connect(
+ R.id.weather_smartspace_view,
+ ConstraintSet.TOP,
+ R.id.date_smartspace_view,
+ ConstraintSet.TOP
+ )
+ connect(
+ R.id.weather_smartspace_view,
+ ConstraintSet.BOTTOM,
+ R.id.date_smartspace_view,
+ ConstraintSet.BOTTOM
+ )
+ connect(
+ R.id.weather_smartspace_view,
+ ConstraintSet.START,
+ R.id.date_smartspace_view,
+ ConstraintSet.END,
+ 4
+ )
+
// migrate addSmartspaceView from KeyguardClockSwitchController
- smartspaceView?.let {
- constrainHeight(it.id, WRAP_CONTENT)
+ constrainHeight(R.id.bc_smartspace_view, ConstraintSet.WRAP_CONTENT)
+ connect(
+ R.id.bc_smartspace_view,
+ ConstraintSet.START,
+ ConstraintSet.PARENT_ID,
+ ConstraintSet.START,
+ context.resources.getDimensionPixelSize(
+ com.android.systemui.res.R.dimen.below_clock_padding_start
+ )
+ )
+ connect(
+ R.id.bc_smartspace_view,
+ ConstraintSet.END,
+ if (keyguardClockViewModel.clockShouldBeCentered.value) ConstraintSet.PARENT_ID
+ else com.android.systemui.res.R.id.split_shade_guideline,
+ ConstraintSet.END,
+ context.resources.getDimensionPixelSize(
+ com.android.systemui.res.R.dimen.below_clock_padding_end
+ )
+ )
+
+ if (keyguardClockViewModel.hasCustomWeatherDataDisplay.value) {
+ clear(R.id.date_smartspace_view, ConstraintSet.TOP)
connect(
- it.id,
- START,
- PARENT_ID,
- START,
- context.resources.getDimensionPixelSize(R.dimen.below_clock_padding_start)
+ R.id.date_smartspace_view,
+ ConstraintSet.BOTTOM,
+ R.id.bc_smartspace_view,
+ ConstraintSet.TOP
+ )
+ } else {
+ clear(R.id.date_smartspace_view, ConstraintSet.BOTTOM)
+ connect(
+ R.id.date_smartspace_view,
+ ConstraintSet.TOP,
+ com.android.systemui.res.R.id.lockscreen_clock_view,
+ ConstraintSet.BOTTOM
)
connect(
- it.id,
- END,
- PARENT_ID,
- END,
- context.resources.getDimensionPixelSize(R.dimen.below_clock_padding_end)
+ R.id.bc_smartspace_view,
+ ConstraintSet.TOP,
+ R.id.date_smartspace_view,
+ ConstraintSet.BOTTOM
)
}
- if (keyguardClockViewModel.hasCustomWeatherDataDisplay.value) {
- dateView?.let { dateView ->
- smartspaceView?.let { smartspaceView ->
- connect(dateView.id, BOTTOM, smartspaceView.id, TOP)
- }
- }
- } else {
- dateView?.let { dateView ->
- clear(dateView.id, BOTTOM)
- connect(dateView.id, TOP, R.id.lockscreen_clock_view, BOTTOM)
- constrainHeight(dateView.id, WRAP_CONTENT)
- smartspaceView?.let { smartspaceView ->
- clear(smartspaceView.id, TOP)
- connect(smartspaceView.id, TOP, dateView.id, BOTTOM)
- }
- }
- }
+ createBarrier(
+ com.android.systemui.res.R.id.smart_space_barrier_bottom,
+ Barrier.BOTTOM,
+ 0,
+ *intArrayOf(
+ R.id.bc_smartspace_view,
+ R.id.date_smartspace_view,
+ R.id.weather_smartspace_view,
+ )
+ )
}
updateVisibility(constraintSet)
}
@@ -156,30 +205,28 @@
}
}
}
+ smartspaceView?.viewTreeObserver?.removeOnGlobalLayoutListener(smartspaceVisibilityListener)
+ smartspaceVisibilityListener = null
}
private fun updateVisibility(constraintSet: ConstraintSet) {
constraintSet.apply {
- weatherView?.let {
- setVisibility(
- it.id,
- when (keyguardClockViewModel.hasCustomWeatherDataDisplay.value) {
- true -> ConstraintSet.GONE
- false ->
- when (keyguardSmartspaceViewModel.isWeatherEnabled) {
- true -> ConstraintSet.VISIBLE
- false -> ConstraintSet.GONE
- }
- }
- )
- }
- dateView?.let {
- setVisibility(
- it.id,
- if (keyguardClockViewModel.hasCustomWeatherDataDisplay.value) ConstraintSet.GONE
- else ConstraintSet.VISIBLE
- )
- }
+ setVisibility(
+ R.id.weather_smartspace_view,
+ when (keyguardClockViewModel.hasCustomWeatherDataDisplay.value) {
+ true -> ConstraintSet.GONE
+ false ->
+ when (keyguardSmartspaceViewModel.isWeatherEnabled) {
+ true -> ConstraintSet.VISIBLE
+ false -> ConstraintSet.GONE
+ }
+ }
+ )
+ setVisibility(
+ R.id.date_smartspace_view,
+ if (keyguardClockViewModel.hasCustomWeatherDataDisplay.value) ConstraintSet.GONE
+ else ConstraintSet.VISIBLE
+ )
}
}
}
diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/ui/view/layout/sections/SplitShadeClockSection.kt b/packages/SystemUI/src/com/android/systemui/keyguard/ui/view/layout/sections/SplitShadeClockSection.kt
deleted file mode 100644
index 19ba1aa..0000000
--- a/packages/SystemUI/src/com/android/systemui/keyguard/ui/view/layout/sections/SplitShadeClockSection.kt
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * Copyright (C) 2023 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.systemui.keyguard.ui.view.layout.sections
-
-import android.content.Context
-import androidx.constraintlayout.widget.ConstraintSet
-import com.android.systemui.keyguard.domain.interactor.KeyguardClockInteractor
-import com.android.systemui.keyguard.ui.viewmodel.KeyguardClockViewModel
-import com.android.systemui.res.R
-import com.android.systemui.statusbar.policy.SplitShadeStateController
-import javax.inject.Inject
-
-class SplitShadeClockSection
-@Inject
-constructor(
- clockInteractor: KeyguardClockInteractor,
- keyguardClockViewModel: KeyguardClockViewModel,
- context: Context,
- splitShadeStateController: SplitShadeStateController,
-) : ClockSection(clockInteractor, keyguardClockViewModel, context, splitShadeStateController) {
- override fun applyDefaultConstraints(constraints: ConstraintSet) {
- super.applyDefaultConstraints(constraints)
- val largeClockEndGuideline =
- if (keyguardClockViewModel.clockShouldBeCentered.value) ConstraintSet.PARENT_ID
- else R.id.split_shade_guideline
- constraints.apply {
- connect(
- R.id.lockscreen_clock_view_large,
- ConstraintSet.END,
- largeClockEndGuideline,
- ConstraintSet.END
- )
- }
- }
-}
diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/ui/view/layout/sections/SplitShadeMediaSection.kt b/packages/SystemUI/src/com/android/systemui/keyguard/ui/view/layout/sections/SplitShadeMediaSection.kt
index f20ab06..b12a8a8 100644
--- a/packages/SystemUI/src/com/android/systemui/keyguard/ui/view/layout/sections/SplitShadeMediaSection.kt
+++ b/packages/SystemUI/src/com/android/systemui/keyguard/ui/view/layout/sections/SplitShadeMediaSection.kt
@@ -20,7 +20,6 @@
import android.view.View
import android.view.ViewGroup.LayoutParams.WRAP_CONTENT
import android.widget.FrameLayout
-import androidx.constraintlayout.widget.Barrier
import androidx.constraintlayout.widget.ConstraintLayout
import androidx.constraintlayout.widget.ConstraintSet
import androidx.constraintlayout.widget.ConstraintSet.BOTTOM
@@ -31,11 +30,9 @@
import androidx.constraintlayout.widget.ConstraintSet.TOP
import com.android.systemui.Flags.migrateClocksToBlueprint
import com.android.systemui.keyguard.shared.model.KeyguardSection
-import com.android.systemui.keyguard.ui.viewmodel.KeyguardSmartspaceViewModel
import com.android.systemui.media.controls.ui.KeyguardMediaController
import com.android.systemui.res.R
import com.android.systemui.shade.NotificationPanelView
-import com.android.systemui.shared.R as sharedR
import javax.inject.Inject
/** Aligns media on left side for split shade, below smartspace, date, and weather. */
@@ -44,11 +41,9 @@
constructor(
private val context: Context,
private val notificationPanelView: NotificationPanelView,
- private val keyguardSmartspaceViewModel: KeyguardSmartspaceViewModel,
private val keyguardMediaController: KeyguardMediaController
) : KeyguardSection() {
private val mediaContainerId = R.id.status_view_media_container
- private val smartSpaceBarrier = R.id.smart_space_barrier_bottom
override fun addViews(constraintLayout: ConstraintLayout) {
if (!migrateClocksToBlueprint()) {
@@ -85,18 +80,7 @@
constraintSet.apply {
constrainWidth(mediaContainerId, MATCH_CONSTRAINT)
constrainHeight(mediaContainerId, WRAP_CONTENT)
-
- createBarrier(
- smartSpaceBarrier,
- Barrier.BOTTOM,
- 0,
- *intArrayOf(
- sharedR.id.bc_smartspace_view,
- sharedR.id.date_smartspace_view,
- sharedR.id.weather_smartspace_view,
- )
- )
- connect(mediaContainerId, TOP, smartSpaceBarrier, BOTTOM)
+ connect(mediaContainerId, TOP, R.id.smart_space_barrier_bottom, BOTTOM)
connect(mediaContainerId, START, PARENT_ID, START)
connect(mediaContainerId, END, R.id.split_shade_guideline, END)
}
diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/ui/view/layout/sections/SplitShadeSmartspaceSection.kt b/packages/SystemUI/src/com/android/systemui/keyguard/ui/view/layout/sections/SplitShadeSmartspaceSection.kt
deleted file mode 100644
index 8728ada..0000000
--- a/packages/SystemUI/src/com/android/systemui/keyguard/ui/view/layout/sections/SplitShadeSmartspaceSection.kt
+++ /dev/null
@@ -1,45 +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.
- */
-
-package com.android.systemui.keyguard.ui.view.layout.sections
-
-import android.content.Context
-import com.android.systemui.keyguard.KeyguardUnlockAnimationController
-import com.android.systemui.keyguard.ui.viewmodel.KeyguardClockViewModel
-import com.android.systemui.keyguard.ui.viewmodel.KeyguardSmartspaceViewModel
-import com.android.systemui.statusbar.lockscreen.LockscreenSmartspaceController
-import javax.inject.Inject
-
-/*
- * We need this class for the splitShadeBlueprint so `addViews` and `removeViews` will be called
- * when switching to and from splitShade.
- */
-class SplitShadeSmartspaceSection
-@Inject
-constructor(
- keyguardClockViewModel: KeyguardClockViewModel,
- keyguardSmartspaceViewModel: KeyguardSmartspaceViewModel,
- context: Context,
- smartspaceController: LockscreenSmartspaceController,
- keyguardUnlockAnimationController: KeyguardUnlockAnimationController,
-) :
- SmartspaceSection(
- keyguardClockViewModel,
- keyguardSmartspaceViewModel,
- context,
- smartspaceController,
- keyguardUnlockAnimationController,
- )
diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/ui/viewmodel/KeyguardSmartspaceViewModel.kt b/packages/SystemUI/src/com/android/systemui/keyguard/ui/viewmodel/KeyguardSmartspaceViewModel.kt
index a1dd720..e8c1ab5 100644
--- a/packages/SystemUI/src/com/android/systemui/keyguard/ui/viewmodel/KeyguardSmartspaceViewModel.kt
+++ b/packages/SystemUI/src/com/android/systemui/keyguard/ui/viewmodel/KeyguardSmartspaceViewModel.kt
@@ -18,6 +18,7 @@
import com.android.systemui.dagger.SysUISingleton
import com.android.systemui.dagger.qualifiers.Application
+import com.android.systemui.keyguard.domain.interactor.KeyguardSmartspaceInteractor
import com.android.systemui.statusbar.lockscreen.LockscreenSmartspaceController
import javax.inject.Inject
import kotlinx.coroutines.CoroutineScope
@@ -33,6 +34,7 @@
@Application applicationScope: CoroutineScope,
smartspaceController: LockscreenSmartspaceController,
keyguardClockViewModel: KeyguardClockViewModel,
+ smartspaceInteractor: KeyguardSmartspaceInteractor,
) {
/** Whether the smartspace section is available in the build. */
val isSmartspaceEnabled: Boolean = smartspaceController.isEnabled()
@@ -78,4 +80,7 @@
): Boolean {
return !clockIncludesCustomWeatherDisplay && isWeatherEnabled
}
+
+ /* trigger clock and smartspace constraints change when smartspace appears */
+ var bcSmartspaceVisibility: StateFlow<Int> = smartspaceInteractor.bcSmartspaceVisibility
}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/pipeline/dagger/OemSatelliteInputLog.kt b/packages/SystemUI/src/com/android/systemui/log/dagger/KeyboardLog.kt
similarity index 69%
rename from packages/SystemUI/src/com/android/systemui/statusbar/pipeline/dagger/OemSatelliteInputLog.kt
rename to packages/SystemUI/src/com/android/systemui/log/dagger/KeyboardLog.kt
index 252945f..5910701 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/pipeline/dagger/OemSatelliteInputLog.kt
+++ b/packages/SystemUI/src/com/android/systemui/log/dagger/KeyboardLog.kt
@@ -14,13 +14,12 @@
* limitations under the License.
*/
-package com.android.systemui.statusbar.pipeline.dagger
+package com.android.systemui.log.dagger
-import com.android.systemui.statusbar.pipeline.satellite.data.DeviceBasedSatelliteRepository
import javax.inject.Qualifier
-/** Detailed [DeviceBasedSatelliteRepository] logs */
+/** A [com.android.systemui.log.LogBuffer] for keyboard-related functionality. */
@Qualifier
@MustBeDocumented
-@kotlin.annotation.Retention(AnnotationRetention.RUNTIME)
-annotation class OemSatelliteInputLog
+@Retention(AnnotationRetention.RUNTIME)
+annotation class KeyboardLog
diff --git a/packages/SystemUI/src/com/android/systemui/log/dagger/LogModule.java b/packages/SystemUI/src/com/android/systemui/log/dagger/LogModule.java
index 24cb8ff..3e00940 100644
--- a/packages/SystemUI/src/com/android/systemui/log/dagger/LogModule.java
+++ b/packages/SystemUI/src/com/android/systemui/log/dagger/LogModule.java
@@ -603,6 +603,14 @@
return factory.create("BluetoothTileDialogLog", 50);
}
+ /** Provides a {@link LogBuffer} for the keyboard functionalities. */
+ @Provides
+ @SysUISingleton
+ @KeyboardLog
+ public static LogBuffer provideKeyboardLogBuffer(LogBufferFactory factory) {
+ return factory.create("KeyboardLog", 50);
+ }
+
/** Provides a {@link LogBuffer} for {@link PackageChangeRepository} */
@Provides
@SysUISingleton
diff --git a/packages/SystemUI/src/com/android/systemui/qs/LeftRightArrowPressedListener.kt b/packages/SystemUI/src/com/android/systemui/qs/LeftRightArrowPressedListener.kt
new file mode 100644
index 0000000..ca790e8
--- /dev/null
+++ b/packages/SystemUI/src/com/android/systemui/qs/LeftRightArrowPressedListener.kt
@@ -0,0 +1,75 @@
+/*
+ * Copyright (C) 2023 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.systemui.qs
+
+import android.view.KeyEvent
+import android.view.View
+import androidx.core.util.Consumer
+
+/**
+ * Listens for left and right arrow keys pressed while focus is on the view.
+ *
+ * Key press is treated as correct when its full lifecycle happened on the view: first
+ * [KeyEvent.ACTION_DOWN] was performed, view didn't lose focus in the meantime and then
+ * [KeyEvent.ACTION_UP] was performed with the same [KeyEvent.getKeyCode]
+ */
+class LeftRightArrowPressedListener private constructor() :
+ View.OnKeyListener, View.OnFocusChangeListener {
+
+ private var lastKeyCode: Int? = 0
+ private var listener: Consumer<Int>? = null
+
+ fun setArrowKeyPressedListener(arrowPressedListener: Consumer<Int>) {
+ listener = arrowPressedListener
+ }
+
+ override fun onKey(view: View, keyCode: Int, keyEvent: KeyEvent): Boolean {
+ if (keyCode == KeyEvent.KEYCODE_DPAD_LEFT || keyCode == KeyEvent.KEYCODE_DPAD_RIGHT) {
+ // only scroll on ACTION_UP as we don't handle longpressing for now. Still we need
+ // to intercept even ACTION_DOWN otherwise keyboard focus will be moved before we
+ // have a chance to intercept ACTION_UP.
+ if (keyEvent.action == KeyEvent.ACTION_UP && keyCode == lastKeyCode) {
+ listener?.accept(keyCode)
+ lastKeyCode = null
+ } else if (keyEvent.repeatCount == 0) {
+ // we only read key events that are NOT coming from long pressing because that also
+ // causes reading ACTION_DOWN event (with repeated count > 0) when moving focus with
+ // arrow from another sibling view
+ lastKeyCode = keyCode
+ }
+ return true
+ }
+ return false
+ }
+
+ override fun onFocusChange(view: View, hasFocus: Boolean) {
+ // resetting lastKeyCode so we get fresh cleared state on focus
+ if (hasFocus) {
+ lastKeyCode = null
+ }
+ }
+
+ companion object {
+ @JvmStatic
+ fun createAndRegisterListenerForView(view: View): LeftRightArrowPressedListener {
+ val listener = LeftRightArrowPressedListener()
+ view.setOnKeyListener(listener)
+ view.onFocusChangeListener = listener
+ return listener
+ }
+ }
+}
diff --git a/packages/SystemUI/src/com/android/systemui/qs/PageIndicator.java b/packages/SystemUI/src/com/android/systemui/qs/PageIndicator.java
index 4770d52..1c9f5fd 100644
--- a/packages/SystemUI/src/com/android/systemui/qs/PageIndicator.java
+++ b/packages/SystemUI/src/com/android/systemui/qs/PageIndicator.java
@@ -1,5 +1,8 @@
package com.android.systemui.qs;
+import static com.android.systemui.qs.PageIndicator.PageScrollActionListener.LEFT;
+import static com.android.systemui.qs.PageIndicator.PageScrollActionListener.RIGHT;
+
import android.content.Context;
import android.content.res.ColorStateList;
import android.content.res.Resources;
@@ -9,10 +12,12 @@
import android.graphics.drawable.Drawable;
import android.util.AttributeSet;
import android.util.Log;
+import android.view.KeyEvent;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
+import androidx.annotation.IntDef;
import androidx.annotation.NonNull;
import com.android.settingslib.Utils;
@@ -43,6 +48,7 @@
private int mPosition = -1;
private boolean mAnimating;
+ private PageScrollActionListener mPageScrollActionListener;
private final Animatable2.AnimationCallback mAnimationCallback =
new Animatable2.AnimationCallback() {
@@ -77,6 +83,14 @@
mPageIndicatorWidth = res.getDimensionPixelSize(R.dimen.qs_page_indicator_width);
mPageIndicatorHeight = res.getDimensionPixelSize(R.dimen.qs_page_indicator_height);
mPageDotWidth = res.getDimensionPixelSize(R.dimen.qs_page_indicator_dot_width);
+ LeftRightArrowPressedListener arrowListener =
+ LeftRightArrowPressedListener.createAndRegisterListenerForView(this);
+ arrowListener.setArrowKeyPressedListener(keyCode -> {
+ if (mPageScrollActionListener != null) {
+ int swipeDirection = keyCode == KeyEvent.KEYCODE_DPAD_LEFT ? LEFT : RIGHT;
+ mPageScrollActionListener.onScrollActionTriggered(swipeDirection);
+ }
+ });
}
public void setNumPages(int numPages) {
@@ -280,4 +294,19 @@
getChildAt(i).layout(left, 0, mPageIndicatorWidth + left, mPageIndicatorHeight);
}
}
+
+ void setPageScrollActionListener(PageScrollActionListener listener) {
+ mPageScrollActionListener = listener;
+ }
+
+ interface PageScrollActionListener {
+
+ @IntDef({LEFT, RIGHT})
+ @interface Direction { }
+
+ int LEFT = 0;
+ int RIGHT = 1;
+
+ void onScrollActionTriggered(@Direction int swipeDirection);
+ }
}
diff --git a/packages/SystemUI/src/com/android/systemui/qs/PagedTileLayout.java b/packages/SystemUI/src/com/android/systemui/qs/PagedTileLayout.java
index 052c0da..43f3a22 100644
--- a/packages/SystemUI/src/com/android/systemui/qs/PagedTileLayout.java
+++ b/packages/SystemUI/src/com/android/systemui/qs/PagedTileLayout.java
@@ -1,6 +1,8 @@
package com.android.systemui.qs;
import static com.android.internal.jank.InteractionJankMonitor.CUJ_NOTIFICATION_SHADE_QS_SCROLL_SWIPE;
+import static com.android.systemui.qs.PageIndicator.PageScrollActionListener.LEFT;
+import static com.android.systemui.qs.PageIndicator.PageScrollActionListener.RIGHT;
import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
@@ -12,7 +14,6 @@
import android.content.res.Configuration;
import android.os.Bundle;
import android.util.AttributeSet;
-import android.view.KeyEvent;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
@@ -30,6 +31,7 @@
import com.android.internal.jank.InteractionJankMonitor;
import com.android.internal.logging.UiEventLogger;
import com.android.systemui.plugins.qs.QSTile;
+import com.android.systemui.qs.PageIndicator.PageScrollActionListener.Direction;
import com.android.systemui.qs.QSPanel.QSTileLayout;
import com.android.systemui.qs.QSPanelControllerBase.TileRecord;
import com.android.systemui.qs.logging.QSLogger;
@@ -310,26 +312,18 @@
mPageIndicator = indicator;
mPageIndicator.setNumPages(mPages.size());
mPageIndicator.setLocation(mPageIndicatorPosition);
- mPageIndicator.setOnKeyListener((view, keyCode, keyEvent) -> {
- if (keyCode == KeyEvent.KEYCODE_DPAD_LEFT || keyCode == KeyEvent.KEYCODE_DPAD_RIGHT) {
- // only scroll on ACTION_UP as we don't handle longpressing for now. Still we need
- // to intercept even ACTION_DOWN otherwise keyboard focus will be moved before we
- // have a chance to intercept ACTION_UP.
- if (keyEvent.getAction() == KeyEvent.ACTION_UP && mScroller.isFinished()) {
- scrollByX(getDeltaXForKeyboardScrolling(keyCode),
- SINGLE_PAGE_SCROLL_DURATION_MILLIS);
- }
- return true;
+ mPageIndicator.setPageScrollActionListener(swipeDirection -> {
+ if (mScroller.isFinished()) {
+ scrollByX(getDeltaXForPageScrolling(swipeDirection),
+ SINGLE_PAGE_SCROLL_DURATION_MILLIS);
}
- return false;
});
}
- private int getDeltaXForKeyboardScrolling(int keyCode) {
- if (keyCode == KeyEvent.KEYCODE_DPAD_LEFT && getCurrentItem() != 0) {
+ private int getDeltaXForPageScrolling(@Direction int swipeDirection) {
+ if (swipeDirection == LEFT && getCurrentItem() != 0) {
return -getWidth();
- } else if (keyCode == KeyEvent.KEYCODE_DPAD_RIGHT
- && getCurrentItem() != mPages.size() - 1) {
+ } else if (swipeDirection == RIGHT && getCurrentItem() != mPages.size() - 1) {
return getWidth();
}
return 0;
diff --git a/packages/SystemUI/src/com/android/systemui/scene/domain/interactor/WindowRootViewVisibilityInteractor.kt b/packages/SystemUI/src/com/android/systemui/scene/domain/interactor/WindowRootViewVisibilityInteractor.kt
index a6cccf1..e2959fe 100644
--- a/packages/SystemUI/src/com/android/systemui/scene/domain/interactor/WindowRootViewVisibilityInteractor.kt
+++ b/packages/SystemUI/src/com/android/systemui/scene/domain/interactor/WindowRootViewVisibilityInteractor.kt
@@ -24,7 +24,9 @@
import com.android.systemui.power.domain.interactor.PowerInteractor
import com.android.systemui.scene.data.repository.WindowRootViewVisibilityRepository
import com.android.systemui.statusbar.NotificationPresenter
+import com.android.systemui.statusbar.notification.domain.interactor.ActiveNotificationsInteractor
import com.android.systemui.statusbar.notification.init.NotificationsController
+import com.android.systemui.statusbar.notification.shared.NotificationsLiveDataStoreRefactor
import com.android.systemui.statusbar.policy.HeadsUpManager
import javax.inject.Inject
import kotlinx.coroutines.CoroutineScope
@@ -44,6 +46,7 @@
private val keyguardRepository: KeyguardRepository,
private val headsUpManager: HeadsUpManager,
private val powerInteractor: PowerInteractor,
+ private val activeNotificationsInteractor: ActiveNotificationsInteractor,
) : CoreStartable {
private var notificationPresenter: NotificationPresenter? = null
@@ -117,6 +120,14 @@
return if (headsUpManager.hasPinnedHeadsUp() && isNotifPresenterFullyCollapsed) {
1
} else {
+ getActiveNotificationsCount()
+ }
+ }
+
+ private fun getActiveNotificationsCount(): Int {
+ return if (NotificationsLiveDataStoreRefactor.isEnabled) {
+ activeNotificationsInteractor.allNotificationsCountValue
+ } else {
notificationsController?.getActiveNotificationsCount() ?: 0
}
}
diff --git a/packages/SystemUI/src/com/android/systemui/scene/shared/flag/SceneContainerFlags.kt b/packages/SystemUI/src/com/android/systemui/scene/shared/flag/SceneContainerFlags.kt
index ab08f66..a755805 100644
--- a/packages/SystemUI/src/com/android/systemui/scene/shared/flag/SceneContainerFlags.kt
+++ b/packages/SystemUI/src/com/android/systemui/scene/shared/flag/SceneContainerFlags.kt
@@ -37,6 +37,7 @@
/** The flag description -- not an aconfig flag name */
const val DESCRIPTION = "SceneContainerFlag"
+ @JvmStatic
inline val isEnabled
get() =
SCENE_CONTAINER_ENABLED && // mainStaticFlag
diff --git a/packages/SystemUI/src/com/android/systemui/scene/ui/view/SceneWindowRootViewBinder.kt b/packages/SystemUI/src/com/android/systemui/scene/ui/view/SceneWindowRootViewBinder.kt
index 4a839b8..93cfc5d 100644
--- a/packages/SystemUI/src/com/android/systemui/scene/ui/view/SceneWindowRootViewBinder.kt
+++ b/packages/SystemUI/src/com/android/systemui/scene/ui/view/SceneWindowRootViewBinder.kt
@@ -85,12 +85,13 @@
view.addView(
ComposeFacade.createSceneContainerView(
- scope = this,
- context = view.context,
- viewModel = viewModel,
- windowInsets = windowInsets,
- sceneByKey = sortedSceneByKey,
- )
+ scope = this,
+ context = view.context,
+ viewModel = viewModel,
+ windowInsets = windowInsets,
+ sceneByKey = sortedSceneByKey,
+ )
+ .also { it.id = R.id.scene_container_root_composable }
)
val legacyView = view.requireViewById<View>(R.id.legacy_window_root)
diff --git a/packages/SystemUI/src/com/android/systemui/settings/UserFileManagerExt.kt b/packages/SystemUI/src/com/android/systemui/settings/UserFileManagerExt.kt
new file mode 100644
index 0000000..b09bfe2
--- /dev/null
+++ b/packages/SystemUI/src/com/android/systemui/settings/UserFileManagerExt.kt
@@ -0,0 +1,43 @@
+/*
+ * 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.settings
+
+import android.annotation.UserIdInt
+import android.content.Context
+import android.content.SharedPreferences
+import com.android.systemui.common.coroutine.ConflatedCallbackFlow.conflatedCallbackFlow
+import kotlinx.coroutines.channels.awaitClose
+import kotlinx.coroutines.flow.Flow
+
+/** Extension functions for [UserFileManager]. */
+object UserFileManagerExt {
+
+ /** Returns a flow of [Unit] that is invoked each time the shared preference is updated. */
+ fun UserFileManager.observeSharedPreferences(
+ fileName: String,
+ @Context.PreferencesMode mode: Int,
+ @UserIdInt userId: Int
+ ): Flow<Unit> = conflatedCallbackFlow {
+ val sharedPrefs = getSharedPreferences(fileName, mode, userId)
+
+ val listener = SharedPreferences.OnSharedPreferenceChangeListener { _, _ -> trySend(Unit) }
+
+ sharedPrefs.registerOnSharedPreferenceChangeListener(listener)
+ awaitClose { sharedPrefs.unregisterOnSharedPreferenceChangeListener(listener) }
+ }
+}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/render/GroupExpansionManagerImpl.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/render/GroupExpansionManagerImpl.java
index 2d5afd5..3cdb2cd 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/render/GroupExpansionManagerImpl.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/render/GroupExpansionManagerImpl.java
@@ -21,8 +21,6 @@
import com.android.systemui.Dumpable;
import com.android.systemui.dagger.SysUISingleton;
import com.android.systemui.dump.DumpManager;
-import com.android.systemui.flags.FeatureFlags;
-import com.android.systemui.flags.Flags;
import com.android.systemui.statusbar.notification.collection.GroupEntry;
import com.android.systemui.statusbar.notification.collection.ListEntry;
import com.android.systemui.statusbar.notification.collection.NotifPipeline;
@@ -53,14 +51,11 @@
*/
private final Set<NotificationEntry> mExpandedGroups = new HashSet<>();
- private final FeatureFlags mFeatureFlags;
-
@Inject
public GroupExpansionManagerImpl(DumpManager dumpManager,
- GroupMembershipManager groupMembershipManager, FeatureFlags featureFlags) {
+ GroupMembershipManager groupMembershipManager) {
mDumpManager = dumpManager;
mGroupMembershipManager = groupMembershipManager;
- mFeatureFlags = featureFlags;
}
/**
@@ -86,10 +81,8 @@
};
public void attach(NotifPipeline pipeline) {
- if (mFeatureFlags.isEnabled(Flags.NOTIFICATION_GROUP_EXPANSION_CHANGE)) {
- mDumpManager.registerDumpable(this);
- pipeline.addOnBeforeRenderListListener(mNotifTracker);
- }
+ mDumpManager.registerDumpable(this);
+ pipeline.addOnBeforeRenderListListener(mNotifTracker);
}
@Override
@@ -105,8 +98,7 @@
@Override
public void setGroupExpanded(NotificationEntry entry, boolean expanded) {
NotificationEntry groupSummary = mGroupMembershipManager.getGroupSummary(entry);
- if (mFeatureFlags.isEnabled(Flags.NOTIFICATION_GROUP_EXPANSION_CHANGE)
- && entry.getParent() == null) {
+ if (entry.getParent() == null) {
if (expanded) {
throw new IllegalArgumentException("Cannot expand group that is not attached");
} else {
@@ -124,7 +116,7 @@
}
// Only notify listeners if something changed.
- if (!mFeatureFlags.isEnabled(Flags.NOTIFICATION_GROUP_EXPANSION_CHANGE) || changed) {
+ if (changed) {
sendOnGroupExpandedChange(entry, expanded);
}
}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/render/GroupMembershipManagerImpl.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/render/GroupMembershipManagerImpl.java
index cb79353..da12479 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/render/GroupMembershipManagerImpl.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/render/GroupMembershipManagerImpl.java
@@ -22,8 +22,6 @@
import androidx.annotation.Nullable;
import com.android.systemui.dagger.SysUISingleton;
-import com.android.systemui.flags.FeatureFlagsClassic;
-import com.android.systemui.flags.Flags;
import com.android.systemui.statusbar.notification.collection.GroupEntry;
import com.android.systemui.statusbar.notification.collection.ListEntry;
import com.android.systemui.statusbar.notification.collection.NotificationEntry;
@@ -38,25 +36,17 @@
*/
@SysUISingleton
public class GroupMembershipManagerImpl implements GroupMembershipManager {
- FeatureFlagsClassic mFeatureFlags;
-
@Inject
- public GroupMembershipManagerImpl(FeatureFlagsClassic featureFlags) {
- mFeatureFlags = featureFlags;
- }
+ public GroupMembershipManagerImpl() {}
@Override
public boolean isGroupSummary(@NonNull NotificationEntry entry) {
- if (mFeatureFlags.isEnabled(Flags.NOTIFICATION_GROUP_EXPANSION_CHANGE)) {
- if (entry.getParent() == null) {
- // The entry is not attached, so it doesn't count.
- return false;
- }
- // If entry is a summary, its parent is a GroupEntry with summary = entry.
- return entry.getParent().getSummary() == entry;
- } else {
- return getGroupSummary(entry) == entry;
+ if (entry.getParent() == null) {
+ // The entry is not attached, so it doesn't count.
+ return false;
}
+ // If entry is a summary, its parent is a GroupEntry with summary = entry.
+ return entry.getParent().getSummary() == entry;
}
@Nullable
@@ -70,12 +60,8 @@
@Override
public boolean isChildInGroup(@NonNull NotificationEntry entry) {
- if (mFeatureFlags.isEnabled(Flags.NOTIFICATION_GROUP_EXPANSION_CHANGE)) {
- // An entry is a child if it's not a summary or top level entry, but it is attached.
- return !isGroupSummary(entry) && !isTopLevelEntry(entry) && entry.getParent() != null;
- } else {
- return !isTopLevelEntry(entry);
- }
+ // An entry is a child if it's not a summary or top level entry, but it is attached.
+ return !isGroupSummary(entry) && !isTopLevelEntry(entry) && entry.getParent() != null;
}
@Override
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/domain/interactor/ActiveNotificationsInteractor.kt b/packages/SystemUI/src/com/android/systemui/statusbar/notification/domain/interactor/ActiveNotificationsInteractor.kt
index 5180bab..b22e9fd 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/domain/interactor/ActiveNotificationsInteractor.kt
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/domain/interactor/ActiveNotificationsInteractor.kt
@@ -68,7 +68,8 @@
/**
* The same as [allNotificationsCount], but without flows, for easy access in synchronous code.
*/
- val allNotificationsCountValue: Int = repository.activeNotifications.value.individuals.size
+ val allNotificationsCountValue: Int
+ get() = repository.activeNotifications.value.individuals.size
/** Are any notifications being actively presented in the notification stack? */
val areAnyNotificationsPresent: Flow<Boolean> =
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/init/NotificationsControllerImpl.kt b/packages/SystemUI/src/com/android/systemui/statusbar/notification/init/NotificationsControllerImpl.kt
index ac49960..1677418 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/init/NotificationsControllerImpl.kt
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/init/NotificationsControllerImpl.kt
@@ -18,7 +18,6 @@
import android.service.notification.StatusBarNotification
import com.android.systemui.dagger.SysUISingleton
-import com.android.systemui.flags.FeatureFlags
import com.android.systemui.people.widget.PeopleSpaceWidgetManager
import com.android.systemui.plugins.statusbar.NotificationSwipeActionHelper.SnoozeOption
import com.android.systemui.statusbar.NotificationListener
@@ -72,7 +71,6 @@
private val animatedImageNotificationManager: AnimatedImageNotificationManager,
private val peopleSpaceWidgetManager: PeopleSpaceWidgetManager,
private val bubblesOptional: Optional<Bubbles>,
- private val featureFlags: FeatureFlags
) : NotificationsController {
override fun initialize(
@@ -136,5 +134,8 @@
}
}
- override fun getActiveNotificationsCount(): Int = notifLiveDataStore.activeNotifCount.value
+ override fun getActiveNotificationsCount(): Int {
+ NotificationsLiveDataStoreRefactor.assertInLegacyMode()
+ return notifLiveDataStore.activeNotifCount.value
+ }
}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/AmbientState.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/AmbientState.java
index d9c5108..c527bb5 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/AmbientState.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/AmbientState.java
@@ -26,9 +26,9 @@
import androidx.annotation.VisibleForTesting;
import com.android.systemui.Dumpable;
-import com.android.systemui.res.R;
import com.android.systemui.dagger.SysUISingleton;
import com.android.systemui.dump.DumpManager;
+import com.android.systemui.res.R;
import com.android.systemui.shade.transition.LargeScreenShadeInterpolator;
import com.android.systemui.statusbar.NotificationShelf;
import com.android.systemui.statusbar.StatusBarState;
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayout.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayout.java
index e791a64..04db653 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayout.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayout.java
@@ -94,6 +94,7 @@
import com.android.systemui.plugins.ActivityStarter;
import com.android.systemui.plugins.statusbar.NotificationSwipeActionHelper;
import com.android.systemui.res.R;
+import com.android.systemui.scene.shared.flag.SceneContainerFlag;
import com.android.systemui.shade.TouchLogger;
import com.android.systemui.statusbar.EmptyShadeView;
import com.android.systemui.statusbar.NotificationShelf;
@@ -187,6 +188,7 @@
private int mOverflingDistance;
private float mMaxOverScroll;
private boolean mIsBeingDragged;
+ private boolean mSendingTouchesToSceneFramework;
private int mLastMotionY;
private int mDownX;
private int mActivePointerId = INVALID_POINTER;
@@ -1509,7 +1511,12 @@
*/
public void setExpandedHeight(float height) {
final boolean skipHeightUpdate = shouldSkipHeightUpdate();
- updateStackPosition();
+
+ // when scene framework is enabled, updateStackPosition is already called by
+ // updateTopPadding every time the stack moves, so skip it here to avoid flickering.
+ if (!SceneContainerFlag.isEnabled()) {
+ updateStackPosition();
+ }
if (!skipHeightUpdate) {
mExpandedHeight = height;
@@ -2450,6 +2457,7 @@
/* notificationStackScrollLayout= */ this, mMaxDisplayedNotifications,
shelfIntrinsicHeight);
mIntrinsicContentHeight = height;
+ mController.setIntrinsicContentHeight(mIntrinsicContentHeight);
// The topPadding can be bigger than the regular padding when qs is expanded, in that
// state the maxPanelHeight and the contentHeight should be bigger
@@ -3558,8 +3566,11 @@
@Override
public boolean onTouchEvent(MotionEvent ev) {
- if (mTouchHandler != null && mTouchHandler.onTouchEvent(ev)) {
- return true;
+ if (mTouchHandler != null) {
+ boolean touchHandled = mTouchHandler.onTouchEvent(ev);
+ if (SceneContainerFlag.isEnabled() || touchHandled) {
+ return touchHandled;
+ }
}
return super.onTouchEvent(ev);
@@ -3567,6 +3578,27 @@
@Override
public boolean dispatchTouchEvent(MotionEvent ev) {
+ if (SceneContainerFlag.isEnabled() && mIsBeingDragged) {
+ if (!mSendingTouchesToSceneFramework) {
+ // if this is the first touch being sent to the scene framework,
+ // convert it into a synthetic DOWN event.
+ mSendingTouchesToSceneFramework = true;
+ MotionEvent downEvent = MotionEvent.obtain(ev);
+ downEvent.setAction(MotionEvent.ACTION_DOWN);
+ mController.sendTouchToSceneFramework(downEvent);
+ downEvent.recycle();
+ } else {
+ mController.sendTouchToSceneFramework(ev);
+ }
+
+ if (
+ ev.getActionMasked() == MotionEvent.ACTION_UP
+ || ev.getActionMasked() == MotionEvent.ACTION_CANCEL
+ ) {
+ setIsBeingDragged(false);
+ }
+ return false;
+ }
return TouchLogger.logDispatchTouch(TAG, ev, super.dispatchTouchEvent(ev));
}
@@ -3633,6 +3665,18 @@
return true;
}
+ // If the scene framework is enabled, ignore all non-move gestures if we are currently
+ // dragging - they should be dispatched to the scene framework. Move gestures should be let
+ // through to determine if we are still dragging or not.
+ if (
+ SceneContainerFlag.isEnabled()
+ && mIsBeingDragged
+ && action != MotionEvent.ACTION_MOVE
+ ) {
+ setIsBeingDragged(false);
+ return false;
+ }
+
switch (action) {
case MotionEvent.ACTION_DOWN: {
if (getChildCount() == 0 || !isInContentBounds(ev)) {
@@ -3676,6 +3720,11 @@
}
}
if (mIsBeingDragged) {
+ // Defer actual scrolling to the scene framework if enabled
+ if (SceneContainerFlag.isEnabled()) {
+ setIsBeingDragged(false);
+ return false;
+ }
// Scroll to follow the motion event
mLastMotionY = y;
float scrollAmount;
@@ -3770,9 +3819,8 @@
}
protected boolean isInsideQsHeader(MotionEvent ev) {
- if (mQsHeader == null) {
- Log.wtf(TAG, "qsHeader is null while NSSL is handling a touch");
- return false;
+ if (SceneContainerFlag.isEnabled()) {
+ return ev.getY() < mController.getPlaceholderTop();
}
mQsHeader.getBoundsOnScreen(mQsHeaderBound);
@@ -4026,9 +4074,16 @@
requestDisallowInterceptTouchEvent(true);
cancelLongPress();
resetExposedMenuView(true /* animate */, true /* force */);
+ } else {
+ mSendingTouchesToSceneFramework = false;
}
}
+ @VisibleForTesting
+ boolean getIsBeingDragged() {
+ return mIsBeingDragged;
+ }
+
public void requestDisallowLongPress() {
cancelLongPress();
}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayoutController.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayoutController.java
index c0e0b73..6a66bb7 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayoutController.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayoutController.java
@@ -80,6 +80,9 @@
import com.android.systemui.plugins.statusbar.NotificationSwipeActionHelper;
import com.android.systemui.plugins.statusbar.StatusBarStateController;
import com.android.systemui.power.domain.interactor.PowerInteractor;
+import com.android.systemui.res.R;
+import com.android.systemui.scene.shared.flag.SceneContainerFlags;
+import com.android.systemui.scene.ui.view.WindowRootView;
import com.android.systemui.shade.ShadeController;
import com.android.systemui.shade.ShadeViewController;
import com.android.systemui.statusbar.CommandQueue;
@@ -120,6 +123,7 @@
import com.android.systemui.statusbar.notification.row.NotificationGuts;
import com.android.systemui.statusbar.notification.row.NotificationGutsManager;
import com.android.systemui.statusbar.notification.row.NotificationSnooze;
+import com.android.systemui.statusbar.notification.stack.domain.interactor.NotificationStackAppearanceInteractor;
import com.android.systemui.statusbar.notification.stack.ui.viewbinder.NotificationListViewBinder;
import com.android.systemui.statusbar.phone.HeadsUpAppearanceController;
import com.android.systemui.statusbar.phone.HeadsUpTouchHelper;
@@ -145,6 +149,7 @@
import javax.inject.Inject;
import javax.inject.Named;
+import javax.inject.Provider;
/**
* Controller for {@link NotificationStackScrollLayout}.
@@ -181,6 +186,8 @@
private final NotificationRemoteInputManager mRemoteInputManager;
private final VisibilityLocationProviderDelegator mVisibilityLocationProviderDelegator;
private final ShadeController mShadeController;
+ private final Provider<WindowRootView> mWindowRootView;
+ private final NotificationStackAppearanceInteractor mStackAppearanceInteractor;
private final KeyguardMediaController mKeyguardMediaController;
private final SysuiStatusBarStateController mStatusBarStateController;
private final KeyguardBypassController mKeyguardBypassController;
@@ -689,6 +696,9 @@
SeenNotificationsInteractor seenNotificationsInteractor,
NotificationListViewBinder viewBinder,
ShadeController shadeController,
+ SceneContainerFlags sceneContainerFlags,
+ Provider<WindowRootView> windowRootView,
+ NotificationStackAppearanceInteractor stackAppearanceInteractor,
InteractionJankMonitor jankMonitor,
StackStateLogger stackLogger,
NotificationStackScrollLogger logger,
@@ -739,6 +749,8 @@
mVisibilityLocationProviderDelegator = visibilityLocationProviderDelegator;
mSeenNotificationsInteractor = seenNotificationsInteractor;
mShadeController = shadeController;
+ mWindowRootView = windowRootView;
+ mStackAppearanceInteractor = stackAppearanceInteractor;
mFeatureFlags = featureFlags;
mNotificationTargetsHelper = notificationTargetsHelper;
mSecureSettings = secureSettings;
@@ -1076,6 +1088,28 @@
return mView.getIntrinsicContentHeight();
}
+ /**
+ * Dispatch a touch to the scene container framework.
+ * TODO(b/316965302): Replace findViewById to avoid DFS
+ */
+ public void sendTouchToSceneFramework(MotionEvent ev) {
+ View sceneContainer = mWindowRootView.get()
+ .findViewById(R.id.scene_container_root_composable);
+ if (sceneContainer != null) {
+ sceneContainer.dispatchTouchEvent(ev);
+ }
+ }
+
+ /** Get the y-coordinate of the top bound of the stack. */
+ public float getPlaceholderTop() {
+ return mStackAppearanceInteractor.getStackBounds().getValue().getTop();
+ }
+
+ /** Set the intrinsic height of the stack content without additional padding. */
+ public void setIntrinsicContentHeight(float intrinsicContentHeight) {
+ mStackAppearanceInteractor.setIntrinsicContentHeight(intrinsicContentHeight);
+ }
+
public void setIntrinsicPadding(int intrinsicPadding) {
mView.setIntrinsicPadding(intrinsicPadding);
}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/data/repository/NotificationStackAppearanceRepository.kt b/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/data/repository/NotificationStackAppearanceRepository.kt
index e78a694..aac3c28 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/data/repository/NotificationStackAppearanceRepository.kt
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/data/repository/NotificationStackAppearanceRepository.kt
@@ -30,4 +30,18 @@
/** The corner radius of the notification stack, in dp. */
val cornerRadiusDp = MutableStateFlow(32f)
+
+ /**
+ * The height in px of the contents of notification stack. Depending on the number of
+ * notifications, this can exceed the space available on screen to show notifications, at which
+ * point the notification stack should become scrollable.
+ */
+ val intrinsicContentHeight = MutableStateFlow(0f)
+
+ /**
+ * The y-coordinate in px of top of the contents of the notification stack. This value can be
+ * negative, if the stack is scrolled such that its top extends beyond the top edge of the
+ * screen.
+ */
+ val contentTop = MutableStateFlow(0f)
}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/domain/interactor/NotificationStackAppearanceInteractor.kt b/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/domain/interactor/NotificationStackAppearanceInteractor.kt
index 61a4dfc..1dfde09 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/domain/interactor/NotificationStackAppearanceInteractor.kt
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/domain/interactor/NotificationStackAppearanceInteractor.kt
@@ -34,12 +34,32 @@
/** The bounds of the notification stack in the current scene. */
val stackBounds: StateFlow<NotificationContainerBounds> = repository.stackBounds.asStateFlow()
+ /** The corner radius of the notification stack, in dp. */
+ val cornerRadiusDp: StateFlow<Float> = repository.cornerRadiusDp.asStateFlow()
+
+ /**
+ * The height in px of the contents of notification stack. Depending on the number of
+ * notifications, this can exceed the space available on screen to show notifications, at which
+ * point the notification stack should become scrollable.
+ */
+ val intrinsicContentHeight = repository.intrinsicContentHeight.asStateFlow()
+
+ /** The y-coordinate in px of top of the contents of the notification stack. */
+ val contentTop = repository.contentTop.asStateFlow()
+
/** Sets the position of the notification stack in the current scene. */
fun setStackBounds(bounds: NotificationContainerBounds) {
check(bounds.top <= bounds.bottom) { "Invalid bounds: $bounds" }
repository.stackBounds.value = bounds
}
- /** The corner radius of the notification stack, in dp. */
- val cornerRadiusDp: StateFlow<Float> = repository.cornerRadiusDp.asStateFlow()
+ /** Sets the height of the contents of the notification stack. */
+ fun setIntrinsicContentHeight(height: Float) {
+ repository.intrinsicContentHeight.value = height
+ }
+
+ /** Sets the y-coord in px of the top of the contents of the notification stack. */
+ fun setContentTop(startY: Float) {
+ repository.contentTop.value = startY
+ }
}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/ui/viewbinder/NotificationStackAppearanceViewBinder.kt b/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/ui/viewbinder/NotificationStackAppearanceViewBinder.kt
index a9b542d..ed15f55 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/ui/viewbinder/NotificationStackAppearanceViewBinder.kt
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/ui/viewbinder/NotificationStackAppearanceViewBinder.kt
@@ -25,6 +25,7 @@
import com.android.systemui.statusbar.notification.stack.NotificationStackScrollLayoutController
import com.android.systemui.statusbar.notification.stack.ui.view.SharedNotificationContainer
import com.android.systemui.statusbar.notification.stack.ui.viewmodel.NotificationStackAppearanceViewModel
+import kotlin.math.pow
import kotlin.math.roundToInt
import kotlinx.coroutines.launch
@@ -43,24 +44,28 @@
repeatOnLifecycle(Lifecycle.State.CREATED) {
launch {
viewModel.stackBounds.collect { bounds ->
- controller.updateTopPadding(
- bounds.top,
- controller.isAddOrRemoveAnimationPending
- )
controller.setRoundedClippingBounds(
- it.left,
- it.top,
- it.right,
- it.bottom,
+ bounds.left.roundToInt(),
+ bounds.top.roundToInt(),
+ bounds.right.roundToInt(),
+ bounds.bottom.roundToInt(),
viewModel.cornerRadiusDp.value.dpToPx(context),
viewModel.cornerRadiusDp.value.dpToPx(context),
)
}
}
+
+ launch {
+ viewModel.contentTop.collect {
+ controller.updateTopPadding(it, controller.isAddOrRemoveAnimationPending)
+ }
+ }
+
launch {
viewModel.expandFraction.collect { expandFraction ->
ambientState.expansionFraction = expandFraction
controller.expandedHeight = expandFraction * controller.view.height
+ controller.setMaxAlphaForExpansion(expandFraction.pow(0.75f))
}
}
}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/ui/viewmodel/NotificationStackAppearanceViewModel.kt b/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/ui/viewmodel/NotificationStackAppearanceViewModel.kt
index 834d3ff..74db583 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/ui/viewmodel/NotificationStackAppearanceViewModel.kt
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/ui/viewmodel/NotificationStackAppearanceViewModel.kt
@@ -41,4 +41,7 @@
/** The corner radius of the notification stack, in dp. */
val cornerRadiusDp: StateFlow<Float> = stackAppearanceInteractor.cornerRadiusDp
+
+ /** The y-coordinate in px of top of the contents of the notification stack. */
+ val contentTop: StateFlow<Float> = stackAppearanceInteractor.contentTop
}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/ui/viewmodel/NotificationsPlaceholderViewModel.kt b/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/ui/viewmodel/NotificationsPlaceholderViewModel.kt
index 9f22118..385f061 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/ui/viewmodel/NotificationsPlaceholderViewModel.kt
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/ui/viewmodel/NotificationsPlaceholderViewModel.kt
@@ -21,9 +21,11 @@
import com.android.systemui.flags.FeatureFlagsClassic
import com.android.systemui.flags.Flags
import com.android.systemui.scene.shared.flag.SceneContainerFlags
+import com.android.systemui.shade.domain.interactor.ShadeInteractor
import com.android.systemui.statusbar.notification.stack.domain.interactor.NotificationStackAppearanceInteractor
import com.android.systemui.statusbar.notification.stack.shared.flexiNotifsEnabled
import javax.inject.Inject
+import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.StateFlow
/**
@@ -35,6 +37,7 @@
@Inject
constructor(
private val interactor: NotificationStackAppearanceInteractor,
+ shadeInteractor: ShadeInteractor,
flags: SceneContainerFlags,
featureFlags: FeatureFlagsClassic,
) {
@@ -66,4 +69,22 @@
/** The corner radius of the placeholder, in dp. */
val cornerRadiusDp: StateFlow<Float> = interactor.cornerRadiusDp
+
+ /**
+ * The height in px of the contents of notification stack. Depending on the number of
+ * notifications, this can exceed the space available on screen to show notifications, at which
+ * point the notification stack should become scrollable.
+ */
+ val intrinsicContentHeight = interactor.intrinsicContentHeight
+
+ /**
+ * The amount [0-1] that the shade has been opened. At 0, the shade is closed; at 1, the shade
+ * is open.
+ */
+ val expandFraction: Flow<Float> = shadeInteractor.shadeExpansion
+
+ /** Sets the y-coord in px of the top of the contents of the notification stack. */
+ fun onContentTopChanged(padding: Float) {
+ interactor.setContentTop(padding)
+ }
}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/ui/viewmodel/SharedNotificationContainerViewModel.kt b/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/ui/viewmodel/SharedNotificationContainerViewModel.kt
index 5ee38be..a48fb45 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/ui/viewmodel/SharedNotificationContainerViewModel.kt
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/ui/viewmodel/SharedNotificationContainerViewModel.kt
@@ -240,13 +240,13 @@
*/
val translationY: Flow<Float> =
combine(
- isOnLockscreen,
+ isOnLockscreenWithoutShade,
merge(
keyguardInteractor.keyguardTranslationY,
occludedToLockscreenTransitionViewModel.lockscreenTranslationY,
)
- ) { isOnLockscreen, translationY ->
- if (isOnLockscreen) {
+ ) { isOnLockscreenWithoutShade, translationY ->
+ if (isOnLockscreenWithoutShade) {
translationY
} else {
0f
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/pipeline/dagger/StatusBarPipelineModule.kt b/packages/SystemUI/src/com/android/systemui/statusbar/pipeline/dagger/StatusBarPipelineModule.kt
index 2b90e64..e309c32 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/pipeline/dagger/StatusBarPipelineModule.kt
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/pipeline/dagger/StatusBarPipelineModule.kt
@@ -265,13 +265,6 @@
return factory.create("VerboseMobileViewLog", 100)
}
- @Provides
- @SysUISingleton
- @OemSatelliteInputLog
- fun provideOemSatelliteInputLog(factory: LogBufferFactory): LogBuffer {
- return factory.create("DeviceBasedSatelliteInputLog", 32)
- }
-
const val FIRST_MOBILE_SUB_SHOWING_NETWORK_TYPE_ICON =
"FirstMobileSubShowingNetworkTypeIcon"
}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/pipeline/icons/shared/BindableIconsRegistry.kt b/packages/SystemUI/src/com/android/systemui/statusbar/pipeline/icons/shared/BindableIconsRegistry.kt
index 8400fb0..e3c3139 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/pipeline/icons/shared/BindableIconsRegistry.kt
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/pipeline/icons/shared/BindableIconsRegistry.kt
@@ -18,7 +18,6 @@
import com.android.systemui.dagger.SysUISingleton
import com.android.systemui.statusbar.pipeline.icons.shared.model.BindableIcon
-import com.android.systemui.statusbar.pipeline.satellite.ui.DeviceBasedSatelliteBindableIcon
import javax.inject.Inject
/**
@@ -39,12 +38,11 @@
class BindableIconsRegistryImpl
@Inject
constructor(
- /** Bindables go here */
- oemSatellite: DeviceBasedSatelliteBindableIcon
+/** Bindables go here */
) : BindableIconsRegistry {
/**
* Adding the injected bindables to this list will get them registered with
* StatusBarIconController
*/
- override val bindableIcons: List<BindableIcon> = listOf(oemSatellite)
+ override val bindableIcons: List<BindableIcon> = listOf()
}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/pipeline/satellite/data/prod/DeviceBasedSatelliteRepositoryImpl.kt b/packages/SystemUI/src/com/android/systemui/statusbar/pipeline/satellite/data/prod/DeviceBasedSatelliteRepositoryImpl.kt
index 5e6e36d..de46a5e 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/pipeline/satellite/data/prod/DeviceBasedSatelliteRepositoryImpl.kt
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/pipeline/satellite/data/prod/DeviceBasedSatelliteRepositoryImpl.kt
@@ -19,17 +19,11 @@
import android.os.OutcomeReceiver
import android.telephony.satellite.NtnSignalStrengthCallback
import android.telephony.satellite.SatelliteManager
-import android.telephony.satellite.SatelliteManager.SATELLITE_RESULT_SUCCESS
import android.telephony.satellite.SatelliteModemStateCallback
import com.android.systemui.common.coroutine.ConflatedCallbackFlow.conflatedCallbackFlow
import com.android.systemui.dagger.SysUISingleton
import com.android.systemui.dagger.qualifiers.Application
import com.android.systemui.dagger.qualifiers.Background
-import com.android.systemui.log.LogBuffer
-import com.android.systemui.log.core.LogLevel
-import com.android.systemui.log.core.MessageInitializer
-import com.android.systemui.log.core.MessagePrinter
-import com.android.systemui.statusbar.pipeline.dagger.OemSatelliteInputLog
import com.android.systemui.statusbar.pipeline.satellite.data.DeviceBasedSatelliteRepository
import com.android.systemui.statusbar.pipeline.satellite.data.prod.SatelliteSupport.Companion.whenSupported
import com.android.systemui.statusbar.pipeline.satellite.data.prod.SatelliteSupport.NotSupported
@@ -129,7 +123,6 @@
satelliteManagerOpt: Optional<SatelliteManager>,
@Background private val bgDispatcher: CoroutineDispatcher,
@Application private val scope: CoroutineScope,
- @OemSatelliteInputLog private val logBuffer: LogBuffer,
private val systemClock: SystemClock,
) : DeviceBasedSatelliteRepository {
@@ -152,11 +145,6 @@
ensureMinUptime(systemClock, MIN_UPTIME)
satelliteSupport.value = satelliteManager.checkSatelliteSupported()
- logBuffer.i(
- { str1 = satelliteSupport.value.toString() },
- { "Checked for system support. support=$str1" },
- )
-
// We only need to check location availability if this mode is supported
if (satelliteSupport.value is Supported) {
isSatelliteAllowedForCurrentLocation.subscriptionCount
@@ -171,9 +159,6 @@
* connection might cause more frequent checks.
*/
while (true) {
- logBuffer.i {
- "requestIsSatelliteCommunicationAllowedForCurrentLocation"
- }
checkIsSatelliteAllowed()
delay(POLLING_INTERVAL_MS)
}
@@ -182,8 +167,6 @@
}
}
} else {
- logBuffer.i { "Satellite manager is null" }
-
satelliteSupport.value = NotSupported
}
}
@@ -198,21 +181,12 @@
private fun connectionStateFlow(sm: SupportedSatelliteManager): Flow<SatelliteConnectionState> =
conflatedCallbackFlow {
val cb = SatelliteModemStateCallback { state ->
- logBuffer.i({ int1 = state }) { "onSatelliteModemStateChanged: state=$int1" }
trySend(SatelliteConnectionState.fromModemState(state))
}
- var registered = false
+ sm.registerForSatelliteModemStateChanged(bgDispatcher.asExecutor(), cb)
- try {
- val res =
- sm.registerForSatelliteModemStateChanged(bgDispatcher.asExecutor(), cb)
- registered = res == SATELLITE_RESULT_SUCCESS
- } catch (e: Exception) {
- logBuffer.e("error registering for modem state", e)
- }
-
- awaitClose { if (registered) sm.unregisterForSatelliteModemStateChanged(cb) }
+ awaitClose { sm.unregisterForSatelliteModemStateChanged(cb) }
}
.flowOn(bgDispatcher)
@@ -223,21 +197,12 @@
private fun signalStrengthFlow(sm: SupportedSatelliteManager) =
conflatedCallbackFlow {
val cb = NtnSignalStrengthCallback { signalStrength ->
- logBuffer.i({ int1 = signalStrength.level }) {
- "onNtnSignalStrengthChanged: level=$int1"
- }
trySend(signalStrength.level)
}
- var registered = false
- try {
- sm.registerForNtnSignalStrengthChanged(bgDispatcher.asExecutor(), cb)
- registered = true
- } catch (e: Exception) {
- logBuffer.e("error registering for signal strength", e)
- }
+ sm.registerForNtnSignalStrengthChanged(bgDispatcher.asExecutor(), cb)
- awaitClose { if (registered) sm.unregisterForNtnSignalStrengthChanged(cb) }
+ awaitClose { sm.unregisterForNtnSignalStrengthChanged(cb) }
}
.flowOn(bgDispatcher)
@@ -248,15 +213,11 @@
bgDispatcher.asExecutor(),
object : OutcomeReceiver<Boolean, SatelliteManager.SatelliteException> {
override fun onError(e: SatelliteManager.SatelliteException) {
- logBuffer.e(
- "Found exception when checking availability",
- e,
- )
+ android.util.Log.e(TAG, "Found exception when checking for satellite: ", e)
isSatelliteAllowedForCurrentLocation.value = false
}
override fun onResult(allowed: Boolean) {
- logBuffer.i { allowed.toString() }
isSatelliteAllowedForCurrentLocation.value = allowed
}
}
@@ -278,12 +239,6 @@
}
override fun onError(error: SatelliteManager.SatelliteException) {
- logBuffer.e(
- "Exception when checking for satellite support. " +
- "Assuming it is not supported for this device.",
- error,
- )
-
// Assume that an error means it's not supported
continuation.resume(NotSupported)
}
@@ -309,19 +264,5 @@
delay(timeTilMinUptime)
}
}
-
- /** A couple of convenience logging methods rather than a whole class */
- private fun LogBuffer.i(
- initializer: MessageInitializer = {},
- printer: MessagePrinter,
- ) = this.log(TAG, LogLevel.INFO, initializer, printer)
-
- private fun LogBuffer.e(message: String, exception: Throwable? = null) =
- this.log(
- tag = TAG,
- level = LogLevel.ERROR,
- message = message,
- exception = exception,
- )
}
}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/pipeline/satellite/ui/DeviceBasedSatelliteBindableIcon.kt b/packages/SystemUI/src/com/android/systemui/statusbar/pipeline/satellite/ui/DeviceBasedSatelliteBindableIcon.kt
deleted file mode 100644
index f5d0f6b..0000000
--- a/packages/SystemUI/src/com/android/systemui/statusbar/pipeline/satellite/ui/DeviceBasedSatelliteBindableIcon.kt
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * Copyright (C) 2023 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.systemui.statusbar.pipeline.satellite.ui
-
-import android.content.Context
-import com.android.internal.telephony.flags.Flags.oemEnabledSatelliteFlag
-import com.android.systemui.dagger.SysUISingleton
-import com.android.systemui.statusbar.pipeline.icons.shared.model.BindableIcon
-import com.android.systemui.statusbar.pipeline.icons.shared.model.ModernStatusBarViewCreator
-import com.android.systemui.statusbar.pipeline.satellite.ui.binder.DeviceBasedSatelliteIconBinder
-import com.android.systemui.statusbar.pipeline.satellite.ui.viewmodel.DeviceBasedSatelliteViewModel
-import com.android.systemui.statusbar.pipeline.shared.ui.view.SingleBindableStatusBarIconView
-import javax.inject.Inject
-
-@SysUISingleton
-class DeviceBasedSatelliteBindableIcon
-@Inject
-constructor(
- context: Context,
- viewModel: DeviceBasedSatelliteViewModel,
-) : BindableIcon {
- override val slot: String =
- context.getString(com.android.internal.R.string.status_bar_oem_satellite)
-
- override val initializer = ModernStatusBarViewCreator { context ->
- SingleBindableStatusBarIconView.createView(context).also { view ->
- view.initView(slot) { DeviceBasedSatelliteIconBinder.bind(view, viewModel) }
- }
- }
-
- override val shouldBindIcon: Boolean = oemEnabledSatelliteFlag()
-}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/pipeline/satellite/ui/binder/DeviceBasedSatelliteIconBinder.kt b/packages/SystemUI/src/com/android/systemui/statusbar/pipeline/satellite/ui/binder/DeviceBasedSatelliteIconBinder.kt
deleted file mode 100644
index 59ac5f2..0000000
--- a/packages/SystemUI/src/com/android/systemui/statusbar/pipeline/satellite/ui/binder/DeviceBasedSatelliteIconBinder.kt
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * Copyright (C) 2023 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.systemui.statusbar.pipeline.satellite.ui.binder
-
-import androidx.lifecycle.Lifecycle
-import androidx.lifecycle.lifecycleScope
-import androidx.lifecycle.repeatOnLifecycle
-import com.android.systemui.common.ui.binder.IconViewBinder
-import com.android.systemui.statusbar.pipeline.satellite.ui.viewmodel.DeviceBasedSatelliteViewModel
-import com.android.systemui.statusbar.pipeline.shared.ui.binder.ModernStatusBarViewBinding
-import com.android.systemui.statusbar.pipeline.shared.ui.view.SingleBindableStatusBarIconView
-import kotlinx.coroutines.launch
-
-object DeviceBasedSatelliteIconBinder {
- fun bind(
- view: SingleBindableStatusBarIconView,
- viewModel: DeviceBasedSatelliteViewModel,
- ): ModernStatusBarViewBinding {
- return SingleBindableStatusBarIconView.withDefaultBinding(
- view = view,
- shouldBeVisible = { viewModel.icon.value != null }
- ) {
- lifecycleScope.launch {
- repeatOnLifecycle(Lifecycle.State.STARTED) {
- viewModel.icon.collect { newIcon ->
- if (newIcon == null) {
- view.iconView.setImageDrawable(null)
- } else {
- IconViewBinder.bind(newIcon, view.iconView)
- }
- }
- }
- }
- }
- }
-}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/pipeline/satellite/ui/model/SatelliteIconModel.kt b/packages/SystemUI/src/com/android/systemui/statusbar/pipeline/satellite/ui/model/SatelliteIconModel.kt
deleted file mode 100644
index 6938d66..0000000
--- a/packages/SystemUI/src/com/android/systemui/statusbar/pipeline/satellite/ui/model/SatelliteIconModel.kt
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- * Copyright (C) 2023 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.systemui.statusbar.pipeline.satellite.ui.model
-
-import com.android.systemui.common.shared.model.Icon
-import com.android.systemui.res.R
-import com.android.systemui.statusbar.pipeline.satellite.shared.model.SatelliteConnectionState
-
-/**
- * Define the [Icon] that relates to a given satellite connection state + level. Note that for now
- * We don't need any data class box, so we can just use a simple mapping function.
- */
-object SatelliteIconModel {
- fun fromConnectionState(
- connectionState: SatelliteConnectionState,
- signalStrength: Int,
- ): Icon? =
- when (connectionState) {
- // TODO(b/316635648): check if this should be null
- SatelliteConnectionState.Unknown,
- SatelliteConnectionState.Off,
- SatelliteConnectionState.On ->
- Icon.Resource(
- res = R.drawable.ic_satellite_not_connected,
- contentDescription = null,
- )
- SatelliteConnectionState.Connected -> fromSignalStrength(signalStrength)
- }
-
- private fun fromSignalStrength(
- signalStrength: Int,
- ): Icon? =
- // TODO(b/316634365): these need content descriptions
- when (signalStrength) {
- // No signal
- 0 -> Icon.Resource(res = R.drawable.ic_satellite_connected_0, contentDescription = null)
-
- // Poor -> Moderate
- 1,
- 2 -> Icon.Resource(res = R.drawable.ic_satellite_connected_1, contentDescription = null)
-
- // Good -> Great
- 3,
- 4 -> Icon.Resource(res = R.drawable.ic_satellite_connected_2, contentDescription = null)
- else -> null
- }
-}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/pipeline/satellite/ui/viewmodel/DeviceBasedSatelliteViewModel.kt b/packages/SystemUI/src/com/android/systemui/statusbar/pipeline/satellite/ui/viewmodel/DeviceBasedSatelliteViewModel.kt
deleted file mode 100644
index 0051161..0000000
--- a/packages/SystemUI/src/com/android/systemui/statusbar/pipeline/satellite/ui/viewmodel/DeviceBasedSatelliteViewModel.kt
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
- * Copyright (C) 2023 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.systemui.statusbar.pipeline.satellite.ui.viewmodel
-
-import com.android.systemui.common.shared.model.Icon
-import com.android.systemui.dagger.qualifiers.Application
-import com.android.systemui.statusbar.pipeline.satellite.domain.interactor.DeviceBasedSatelliteInteractor
-import com.android.systemui.statusbar.pipeline.satellite.ui.model.SatelliteIconModel
-import javax.inject.Inject
-import kotlinx.coroutines.CoroutineScope
-import kotlinx.coroutines.ExperimentalCoroutinesApi
-import kotlinx.coroutines.flow.SharingStarted
-import kotlinx.coroutines.flow.StateFlow
-import kotlinx.coroutines.flow.combine
-import kotlinx.coroutines.flow.flatMapLatest
-import kotlinx.coroutines.flow.flowOf
-import kotlinx.coroutines.flow.stateIn
-
-/**
- * View-Model for the device-based satellite icon. This icon will only show in the status bar if
- * satellite is available AND all other service states are considered OOS.
- */
-@OptIn(ExperimentalCoroutinesApi::class)
-class DeviceBasedSatelliteViewModel
-@Inject
-constructor(
- interactor: DeviceBasedSatelliteInteractor,
- @Application scope: CoroutineScope,
-) {
- private val shouldShowIcon: StateFlow<Boolean> =
- interactor.areAllConnectionsOutOfService
- .flatMapLatest { allOos ->
- if (!allOos) {
- flowOf(false)
- } else {
- interactor.isSatelliteAllowed
- }
- }
- .stateIn(scope, SharingStarted.WhileSubscribed(), false)
-
- val icon: StateFlow<Icon?> =
- combine(
- shouldShowIcon,
- interactor.connectionState,
- interactor.signalStrength,
- ) { shouldShow, state, signalStrength ->
- if (shouldShow) {
- SatelliteIconModel.fromConnectionState(state, signalStrength)
- } else {
- null
- }
- }
- .stateIn(scope, SharingStarted.WhileSubscribed(), null)
-}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/pipeline/shared/ui/view/ModernStatusBarView.kt b/packages/SystemUI/src/com/android/systemui/statusbar/pipeline/shared/ui/view/ModernStatusBarView.kt
index 25a2c9d..3b87bed 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/pipeline/shared/ui/view/ModernStatusBarView.kt
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/pipeline/shared/ui/view/ModernStatusBarView.kt
@@ -103,7 +103,7 @@
*
* Creates a dot view, and uses [bindingCreator] to get and set the binding.
*/
- open fun initView(slot: String, bindingCreator: () -> ModernStatusBarViewBinding) {
+ fun initView(slot: String, bindingCreator: () -> ModernStatusBarViewBinding) {
// The dot view requires [slot] to be set, and the [binding] may require an instantiated dot
// view. So, this is the required order.
this.slot = slot
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/pipeline/shared/ui/view/SingleBindableStatusBarIconView.kt b/packages/SystemUI/src/com/android/systemui/statusbar/pipeline/shared/ui/view/SingleBindableStatusBarIconView.kt
deleted file mode 100644
index c663c37..0000000
--- a/packages/SystemUI/src/com/android/systemui/statusbar/pipeline/shared/ui/view/SingleBindableStatusBarIconView.kt
+++ /dev/null
@@ -1,184 +0,0 @@
-/*
- * Copyright (C) 2023 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.systemui.statusbar.pipeline.shared.ui.view
-
-import android.content.Context
-import android.content.res.ColorStateList
-import android.graphics.Color
-import android.util.AttributeSet
-import android.view.LayoutInflater
-import android.view.View
-import android.widget.ImageView
-import androidx.lifecycle.Lifecycle
-import androidx.lifecycle.LifecycleOwner
-import androidx.lifecycle.lifecycleScope
-import androidx.lifecycle.repeatOnLifecycle
-import com.android.internal.annotations.VisibleForTesting
-import com.android.systemui.lifecycle.repeatWhenAttached
-import com.android.systemui.res.R
-import com.android.systemui.statusbar.StatusBarIconView
-import com.android.systemui.statusbar.StatusBarIconView.STATE_HIDDEN
-import com.android.systemui.statusbar.pipeline.shared.ui.binder.ModernStatusBarViewBinding
-import com.android.systemui.statusbar.pipeline.shared.ui.binder.ModernStatusBarViewVisibilityHelper
-import kotlinx.coroutines.awaitCancellation
-import kotlinx.coroutines.flow.MutableStateFlow
-import kotlinx.coroutines.launch
-
-/** Simple single-icon view that is bound to bindable_status_bar_icon.xml */
-class SingleBindableStatusBarIconView(
- context: Context,
- attrs: AttributeSet?,
-) : ModernStatusBarView(context, attrs) {
-
- internal lateinit var iconView: ImageView
- internal lateinit var dotView: StatusBarIconView
-
- override fun toString(): String {
- return "SingleBindableStatusBarIcon(" +
- "slot='$slot', " +
- "isCollecting=${binding.isCollecting()}, " +
- "visibleState=${StatusBarIconView.getVisibleStateString(visibleState)}); " +
- "viewString=${super.toString()}"
- }
-
- override fun initView(slot: String, bindingCreator: () -> ModernStatusBarViewBinding) {
- super.initView(slot, bindingCreator)
-
- iconView = requireViewById(R.id.icon_view)
- dotView = requireViewById(R.id.status_bar_dot)
- }
-
- companion object {
- fun createView(
- context: Context,
- ): SingleBindableStatusBarIconView {
- return LayoutInflater.from(context).inflate(R.layout.bindable_status_bar_icon, null)
- as SingleBindableStatusBarIconView
- }
-
- /**
- * Using a given binding [block], create the necessary scaffolding to handle the general
- * case of a single status bar icon. This includes eliding into a dot view when there is not
- * enough space, and handling tint.
- *
- * [block] should be a simple [launch] call that handles updating the single icon view with
- * its new view. Currently there is no simple way to e.g., extend to handle multiple tints
- * for dual-layered icons, and any more complex logic should probably find a way to return
- * its own version of [ModernStatusBarViewBinding].
- */
- fun withDefaultBinding(
- view: SingleBindableStatusBarIconView,
- shouldBeVisible: () -> Boolean,
- block: suspend LifecycleOwner.(View) -> Unit
- ): SingleBindableStatusBarIconViewBinding {
- @StatusBarIconView.VisibleState
- val visibilityState: MutableStateFlow<Int> = MutableStateFlow(STATE_HIDDEN)
-
- val iconTint: MutableStateFlow<Int> = MutableStateFlow(Color.WHITE)
- val decorTint: MutableStateFlow<Int> = MutableStateFlow(Color.WHITE)
-
- var isCollecting: Boolean = false
-
- view.repeatWhenAttached {
- // Child binding
- block(view)
-
- lifecycleScope.launch {
- repeatOnLifecycle(Lifecycle.State.STARTED) {
- // isVisible controls the visibility state of the outer group, and thus it
- // needs
- // to run in the CREATED lifecycle so it can continue to watch while
- // invisible
- // See (b/291031862) for details
- launch {
- visibilityState.collect { visibilityState ->
- // for b/296864006, we can not hide all the child views if
- // visibilityState is STATE_HIDDEN. Because hiding all child views
- // would cause the
- // getWidth() of this view return 0, and that would cause the
- // translation
- // calculation fails in StatusIconContainer. Therefore, like class
- // MobileIconBinder, instead of set the child views visibility to
- // View.GONE,
- // we set their visibility to View.INVISIBLE to make them invisible
- // but
- // keep the width.
- ModernStatusBarViewVisibilityHelper.setVisibilityState(
- visibilityState,
- view.iconView,
- view.dotView,
- )
- }
- }
-
- launch {
- iconTint.collect { tint ->
- val tintList = ColorStateList.valueOf(tint)
- view.iconView.imageTintList = tintList
- view.dotView.setDecorColor(tint)
- }
- }
-
- launch {
- decorTint.collect { decorTint -> view.dotView.setDecorColor(decorTint) }
- }
-
- try {
- awaitCancellation()
- } finally {
- isCollecting = false
- }
- }
- }
- }
-
- return object : SingleBindableStatusBarIconViewBinding {
- override val decorTint: Int
- get() = decorTint.value
-
- override val iconTint: Int
- get() = iconTint.value
-
- override fun getShouldIconBeVisible(): Boolean {
- return shouldBeVisible()
- }
-
- override fun onVisibilityStateChanged(state: Int) {
- visibilityState.value = state
- }
-
- override fun onIconTintChanged(newTint: Int, contrastTint: Int) {
- iconTint.value = newTint
- }
-
- override fun onDecorTintChanged(newTint: Int) {
- decorTint.value = newTint
- }
-
- override fun isCollecting(): Boolean {
- return isCollecting
- }
- }
- }
- }
-}
-
-@VisibleForTesting
-interface SingleBindableStatusBarIconViewBinding : ModernStatusBarViewBinding {
- val iconTint: Int
- val decorTint: Int
-}
diff --git a/packages/SystemUI/tests/src/com/android/systemui/accessibility/WindowMagnificationAnimationControllerTest.java b/packages/SystemUI/tests/src/com/android/systemui/accessibility/WindowMagnificationAnimationControllerTest.java
index 2afb3a1..d86d123 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/accessibility/WindowMagnificationAnimationControllerTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/accessibility/WindowMagnificationAnimationControllerTest.java
@@ -640,11 +640,10 @@
@Test
public void deleteWindowMagnification_enabling_expectedValuesAndInvokeCallback()
throws RemoteException {
-
enableWindowMagnificationAndWaitAnimating(mWaitPartialAnimationDuration,
mAnimationCallback);
- Mockito.reset(mSpyController);
+ resetMockObjects();
getInstrumentation().runOnMainSync(() -> {
mWindowMagnificationAnimationController.deleteWindowMagnification(
mAnimationCallback2);
@@ -658,6 +657,11 @@
mValueAnimator.end();
});
+ // wait for animation returns
+ waitForIdleSync();
+
+ // {@link ValueAnimator.AnimatorUpdateListener#onAnimationUpdate(ValueAnimator)} will only
+ // be triggered once in {@link ValueAnimator#end()}
verify(mSpyController).enableWindowMagnificationInternal(
mScaleCaptor.capture(),
mCenterXCaptor.capture(), mCenterYCaptor.capture(),
@@ -717,7 +721,11 @@
deleteWindowMagnificationAndWaitAnimating(mWaitPartialAnimationDuration,
mAnimationCallback);
- deleteWindowMagnificationAndWaitAnimating(0, null);
+ // Verifying that WindowMagnificationController#deleteWindowMagnification is never called
+ // in previous steps
+ verify(mSpyController, never()).deleteWindowMagnification();
+
+ deleteWindowMagnificationWithoutAnimation();
verify(mSpyController).deleteWindowMagnification();
verifyFinalSpec(Float.NaN, Float.NaN, Float.NaN);
@@ -810,6 +818,8 @@
mWindowMagnificationAnimationController.enableWindowMagnification(
targetScale, targetCenterX, targetCenterY, null);
});
+ // wait for animation returns
+ waitForIdleSync();
}
private void enableWindowMagnificationAndWaitAnimating(long duration,
@@ -829,12 +839,16 @@
targetScale, targetCenterX, targetCenterY, callback);
advanceTimeBy(duration);
});
+ // wait for animation returns
+ waitForIdleSync();
}
private void deleteWindowMagnificationWithoutAnimation() {
getInstrumentation().runOnMainSync(() -> {
mWindowMagnificationAnimationController.deleteWindowMagnification(null);
});
+ // wait for animation returns
+ waitForIdleSync();
}
private void deleteWindowMagnificationAndWaitAnimating(long duration,
@@ -843,6 +857,8 @@
mWindowMagnificationAnimationController.deleteWindowMagnification(callback);
advanceTimeBy(duration);
});
+ // wait for animation returns
+ waitForIdleSync();
}
private void verifyStartValue(ArgumentCaptor<Float> captor, float startValue) {
diff --git a/packages/SystemUI/tests/src/com/android/systemui/back/domain/interactor/BackActionInteractorTest.kt b/packages/SystemUI/tests/src/com/android/systemui/back/domain/interactor/BackActionInteractorTest.kt
index 7c626a1..e0c6bba 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/back/domain/interactor/BackActionInteractorTest.kt
+++ b/packages/SystemUI/tests/src/com/android/systemui/back/domain/interactor/BackActionInteractorTest.kt
@@ -44,6 +44,8 @@
import com.android.systemui.shade.ShadeViewController
import com.android.systemui.statusbar.NotificationShadeWindowController
import com.android.systemui.statusbar.StatusBarState
+import com.android.systemui.statusbar.notification.data.repository.ActiveNotificationListRepository
+import com.android.systemui.statusbar.notification.domain.interactor.ActiveNotificationsInteractor
import com.android.systemui.statusbar.phone.StatusBarKeyguardViewManager
import com.android.systemui.statusbar.policy.HeadsUpManager
import com.android.systemui.util.concurrency.FakeExecutor
@@ -56,6 +58,7 @@
import junit.framework.Assert.assertFalse
import junit.framework.Assert.assertTrue
import kotlinx.coroutines.ExperimentalCoroutinesApi
+import kotlinx.coroutines.test.StandardTestDispatcher
import kotlinx.coroutines.test.TestScope
import kotlinx.coroutines.test.runCurrent
import org.junit.Before
@@ -89,6 +92,9 @@
@Mock private lateinit var onBackInvokedDispatcher: WindowOnBackInvokedDispatcher
@Mock private lateinit var iStatusBarService: IStatusBarService
@Mock private lateinit var headsUpManager: HeadsUpManager
+ private val activeNotificationsRepository = ActiveNotificationListRepository()
+ private val activeNotificationsInteractor =
+ ActiveNotificationsInteractor(activeNotificationsRepository, StandardTestDispatcher())
private val keyguardRepository = FakeKeyguardRepository()
private val windowRootViewVisibilityInteractor: WindowRootViewVisibilityInteractor by lazy {
@@ -98,6 +104,7 @@
keyguardRepository,
headsUpManager,
powerInteractor,
+ activeNotificationsInteractor,
)
}
diff --git a/packages/SystemUI/tests/src/com/android/systemui/biometrics/domain/model/BiometricPromptRequestTest.kt b/packages/SystemUI/tests/src/com/android/systemui/biometrics/domain/model/BiometricPromptRequestTest.kt
index bd4973d..a57b890 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/biometrics/domain/model/BiometricPromptRequestTest.kt
+++ b/packages/SystemUI/tests/src/com/android/systemui/biometrics/domain/model/BiometricPromptRequestTest.kt
@@ -1,6 +1,6 @@
package com.android.systemui.biometrics.domain.model
-import android.hardware.biometrics.PromptContentListItemBulletedText
+import android.hardware.biometrics.PromptContentItemBulletedText
import android.hardware.biometrics.PromptVerticalListContentView
import androidx.test.filters.SmallTest
import com.android.systemui.SysuiTestCase
@@ -28,7 +28,8 @@
val contentView =
PromptVerticalListContentView.Builder()
.setDescription("content description")
- .addListItem(PromptContentListItemBulletedText("content text"))
+ .addListItem(PromptContentItemBulletedText("content item 1"))
+ .addListItem(PromptContentItemBulletedText("content item 2"), 1)
.build()
val fpPros = fingerprintSensorPropertiesInternal().first()
diff --git a/packages/SystemUI/tests/src/com/android/systemui/biometrics/ui/viewmodel/PromptViewModelTest.kt b/packages/SystemUI/tests/src/com/android/systemui/biometrics/ui/viewmodel/PromptViewModelTest.kt
index bf61c2e..3944054 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/biometrics/ui/viewmodel/PromptViewModelTest.kt
+++ b/packages/SystemUI/tests/src/com/android/systemui/biometrics/ui/viewmodel/PromptViewModelTest.kt
@@ -18,7 +18,7 @@
import android.content.res.Configuration
import android.graphics.Point
-import android.hardware.biometrics.PromptContentListItemBulletedText
+import android.hardware.biometrics.PromptContentItemBulletedText
import android.hardware.biometrics.PromptContentView
import android.hardware.biometrics.PromptInfo
import android.hardware.biometrics.PromptVerticalListContentView
@@ -140,7 +140,8 @@
selector.resetPrompt()
promptContentView =
PromptVerticalListContentView.Builder()
- .addListItem(PromptContentListItemBulletedText("test"))
+ .addListItem(PromptContentItemBulletedText("content item 1"))
+ .addListItem(PromptContentItemBulletedText("content item 2"), 1)
.build()
viewModel =
diff --git a/packages/SystemUI/tests/src/com/android/systemui/keyboard/stickykeys/ui/viewmodel/StickyKeysIndicatorViewModelTest.kt b/packages/SystemUI/tests/src/com/android/systemui/keyboard/stickykeys/ui/viewmodel/StickyKeysIndicatorViewModelTest.kt
new file mode 100644
index 0000000..d397fc2
--- /dev/null
+++ b/packages/SystemUI/tests/src/com/android/systemui/keyboard/stickykeys/ui/viewmodel/StickyKeysIndicatorViewModelTest.kt
@@ -0,0 +1,211 @@
+/*
+ * 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.keyboard.stickykeys.ui.viewmodel
+
+import android.hardware.input.InputManager
+import android.hardware.input.StickyModifierState
+import androidx.test.filters.SmallTest
+import com.android.systemui.SysuiTestCase
+import com.android.systemui.coroutines.collectLastValue
+import com.android.systemui.keyboard.data.repository.FakeKeyboardRepository
+import com.android.systemui.keyboard.stickykeys.StickyKeysLogger
+import com.android.systemui.keyboard.stickykeys.data.repository.StickyKeysRepositoryImpl
+import com.android.systemui.keyboard.stickykeys.shared.model.Locked
+import com.android.systemui.keyboard.stickykeys.shared.model.ModifierKey
+import com.android.systemui.keyboard.stickykeys.shared.model.ModifierKey.ALT
+import com.android.systemui.keyboard.stickykeys.shared.model.ModifierKey.ALT_GR
+import com.android.systemui.keyboard.stickykeys.shared.model.ModifierKey.CTRL
+import com.android.systemui.keyboard.stickykeys.shared.model.ModifierKey.META
+import com.android.systemui.keyboard.stickykeys.shared.model.ModifierKey.SHIFT
+import com.android.systemui.util.mockito.any
+import com.android.systemui.util.mockito.mock
+import com.google.common.truth.Truth.assertThat
+import kotlinx.coroutines.test.StandardTestDispatcher
+import kotlinx.coroutines.test.TestScope
+import kotlinx.coroutines.test.runCurrent
+import kotlinx.coroutines.test.runTest
+import org.junit.Before
+import org.junit.Test
+import org.junit.runner.RunWith
+import org.junit.runners.JUnit4
+import org.mockito.ArgumentCaptor
+import org.mockito.Mockito.verify
+import org.mockito.Mockito.verifyZeroInteractions
+
+@SmallTest
+@RunWith(JUnit4::class)
+class StickyKeysIndicatorViewModelTest : SysuiTestCase() {
+
+ private val dispatcher = StandardTestDispatcher()
+ private val testScope = TestScope(dispatcher)
+ private lateinit var viewModel: StickyKeysIndicatorViewModel
+ private val inputManager = mock<InputManager>()
+ private val keyboardRepository = FakeKeyboardRepository()
+ private val captor =
+ ArgumentCaptor.forClass(InputManager.StickyModifierStateListener::class.java)
+
+ @Before
+ fun setup() {
+ val stickyKeysRepository = StickyKeysRepositoryImpl(
+ inputManager,
+ dispatcher,
+ mock<StickyKeysLogger>()
+ )
+ viewModel =
+ StickyKeysIndicatorViewModel(
+ stickyKeysRepository = stickyKeysRepository,
+ keyboardRepository = keyboardRepository,
+ applicationScope = testScope.backgroundScope,
+ )
+ }
+
+ @Test
+ fun startsListeningToStickyKeysOnlyWhenKeyboardIsConnected() {
+ testScope.runTest {
+ collectLastValue(viewModel.indicatorContent)
+ runCurrent()
+ verifyZeroInteractions(inputManager)
+
+ keyboardRepository.setIsAnyKeyboardConnected(true)
+ runCurrent()
+
+ verify(inputManager)
+ .registerStickyModifierStateListener(
+ any(),
+ any(InputManager.StickyModifierStateListener::class.java)
+ )
+ }
+ }
+
+ @Test
+ fun stopsListeningToStickyKeysWhenKeyboardDisconnects() {
+ testScope.runTest {
+ collectLastValue(viewModel.indicatorContent)
+ keyboardRepository.setIsAnyKeyboardConnected(true)
+ runCurrent()
+
+ keyboardRepository.setIsAnyKeyboardConnected(false)
+ runCurrent()
+
+ verify(inputManager).unregisterStickyModifierStateListener(any())
+ }
+ }
+
+ @Test
+ fun emitsStickyKeysListWhenStickyKeyIsPressed() {
+ testScope.runTest {
+ val stickyKeys by collectLastValue(viewModel.indicatorContent)
+ keyboardRepository.setIsAnyKeyboardConnected(true)
+
+ setStickyKeys(mapOf(ALT to false))
+
+ assertThat(stickyKeys).isEqualTo(mapOf(ALT to Locked(false)))
+ }
+ }
+
+ @Test
+ fun emitsEmptyListWhenNoStickyKeysAreActive() {
+ testScope.runTest {
+ val stickyKeys by collectLastValue(viewModel.indicatorContent)
+ keyboardRepository.setIsAnyKeyboardConnected(true)
+
+ setStickyKeys(emptyMap())
+
+ assertThat(stickyKeys).isEqualTo(emptyMap<ModifierKey, Locked>())
+ }
+ }
+
+ @Test
+ fun passesAllStickyKeysToDialog() {
+ testScope.runTest {
+ val stickyKeys by collectLastValue(viewModel.indicatorContent)
+ keyboardRepository.setIsAnyKeyboardConnected(true)
+
+ setStickyKeys(mapOf(
+ ALT to false,
+ META to false,
+ SHIFT to false))
+
+ assertThat(stickyKeys).isEqualTo(mapOf(
+ ALT to Locked(false),
+ META to Locked(false),
+ SHIFT to Locked(false),
+ ))
+ }
+ }
+
+ @Test
+ fun showsOnlyLockedStateIfKeyIsStickyAndLocked() {
+ testScope.runTest {
+ val stickyKeys by collectLastValue(viewModel.indicatorContent)
+ keyboardRepository.setIsAnyKeyboardConnected(true)
+
+ setStickyKeys(mapOf(
+ ALT to false,
+ ALT to true))
+
+ assertThat(stickyKeys).isEqualTo(mapOf(ALT to Locked(true)))
+ }
+ }
+
+ @Test
+ fun doesNotChangeOrderOfKeysIfTheyBecomeLocked() {
+ testScope.runTest {
+ val stickyKeys by collectLastValue(viewModel.indicatorContent)
+ keyboardRepository.setIsAnyKeyboardConnected(true)
+
+ setStickyKeys(mapOf(
+ META to false,
+ SHIFT to false, // shift is sticky but not locked
+ CTRL to false))
+ val previousShiftIndex = stickyKeys?.toList()?.indexOf(SHIFT to Locked(false))
+
+ setStickyKeys(mapOf(
+ SHIFT to false,
+ SHIFT to true, // shift is now locked
+ META to false,
+ CTRL to false))
+ assertThat(stickyKeys?.toList()?.indexOf(SHIFT to Locked(true)))
+ .isEqualTo(previousShiftIndex)
+ }
+ }
+
+ private fun TestScope.setStickyKeys(keys: Map<ModifierKey, Boolean>) {
+ runCurrent()
+ verify(inputManager).registerStickyModifierStateListener(any(), captor.capture())
+ captor.value.onStickyModifierStateChanged(TestStickyModifierState(keys))
+ runCurrent()
+ }
+
+ private class TestStickyModifierState(private val keys: Map<ModifierKey, Boolean>) :
+ StickyModifierState() {
+
+ private fun isOn(key: ModifierKey) = keys.any { it.key == key && !it.value }
+ private fun isLocked(key: ModifierKey) = keys.any { it.key == key && it.value }
+
+ override fun isAltGrModifierLocked() = isLocked(ALT_GR)
+ override fun isAltGrModifierOn() = isOn(ALT_GR)
+ override fun isAltModifierLocked() = isLocked(ALT)
+ override fun isAltModifierOn() = isOn(ALT)
+ override fun isCtrlModifierLocked() = isLocked(CTRL)
+ override fun isCtrlModifierOn() = isOn(CTRL)
+ override fun isMetaModifierLocked() = isLocked(META)
+ override fun isMetaModifierOn() = isOn(META)
+ override fun isShiftModifierLocked() = isLocked(SHIFT)
+ override fun isShiftModifierOn() = isOn(SHIFT)
+ }
+}
diff --git a/packages/SystemUI/tests/src/com/android/systemui/keyguard/domain/interactor/KeyguardTransitionScenariosTest.kt b/packages/SystemUI/tests/src/com/android/systemui/keyguard/domain/interactor/KeyguardTransitionScenariosTest.kt
index 0ea4e9f..8b6611f 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/keyguard/domain/interactor/KeyguardTransitionScenariosTest.kt
+++ b/packages/SystemUI/tests/src/com/android/systemui/keyguard/domain/interactor/KeyguardTransitionScenariosTest.kt
@@ -1342,14 +1342,8 @@
runTransitionAndSetWakefulness(KeyguardState.LOCKSCREEN, KeyguardState.AOD)
runCurrent()
- // WHEN the keyguard is occluded and aod ends
+ // WHEN the keyguard is occluded
keyguardRepository.setKeyguardOccluded(true)
- keyguardRepository.setDozeTransitionModel(
- DozeTransitionModel(
- from = DozeStateModel.DOZE_AOD,
- to = DozeStateModel.FINISH,
- )
- )
runCurrent()
val info =
@@ -1366,6 +1360,30 @@
}
@Test
+ fun aodToPrimaryBouncer() =
+ testScope.runTest {
+ // GIVEN a prior transition has run to AOD
+ runTransitionAndSetWakefulness(KeyguardState.LOCKSCREEN, KeyguardState.AOD)
+ runCurrent()
+
+ // WHEN the primary bouncer is set to show
+ bouncerRepository.setPrimaryShow(true)
+ runCurrent()
+
+ val info =
+ withArgCaptor<TransitionInfo> {
+ verify(transitionRepository).startTransition(capture())
+ }
+ // THEN a transition to OCCLUDED should occur
+ assertThat(info.ownerName).isEqualTo("FromAodTransitionInteractor")
+ assertThat(info.from).isEqualTo(KeyguardState.AOD)
+ assertThat(info.to).isEqualTo(KeyguardState.PRIMARY_BOUNCER)
+ assertThat(info.animator).isNotNull()
+
+ coroutineContext.cancelChildren()
+ }
+
+ @Test
fun lockscreenToOccluded_fromCameraGesture() =
testScope.runTest {
// GIVEN a prior transition has run to LOCKSCREEN
diff --git a/packages/SystemUI/tests/src/com/android/systemui/keyguard/ui/binder/KeyguardClockViewBinderTest.kt b/packages/SystemUI/tests/src/com/android/systemui/keyguard/ui/binder/KeyguardClockViewBinderTest.kt
index a4d217f..5dd37ae 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/keyguard/ui/binder/KeyguardClockViewBinderTest.kt
+++ b/packages/SystemUI/tests/src/com/android/systemui/keyguard/ui/binder/KeyguardClockViewBinderTest.kt
@@ -21,13 +21,17 @@
import androidx.constraintlayout.widget.ConstraintLayout
import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.filters.SmallTest
+import com.android.keyguard.KeyguardClockSwitch.LARGE
+import com.android.keyguard.KeyguardClockSwitch.SMALL
import com.android.systemui.SysuiTestCase
+import com.android.systemui.keyguard.ui.viewmodel.KeyguardClockViewModel
import com.android.systemui.plugins.clocks.ClockConfig
import com.android.systemui.plugins.clocks.ClockController
import com.android.systemui.plugins.clocks.ClockFaceController
import com.android.systemui.plugins.clocks.ClockFaceLayout
import com.android.systemui.util.mockito.whenever
import kotlin.test.Test
+import kotlinx.coroutines.flow.MutableStateFlow
import org.junit.Before
import org.junit.runner.RunWith
import org.mockito.Mock
@@ -48,32 +52,60 @@
@Mock private lateinit var smallClockView: View
@Mock private lateinit var smallClockFaceLayout: ClockFaceLayout
@Mock private lateinit var largeClockFaceLayout: ClockFaceLayout
+ @Mock private lateinit var clockViewModel: KeyguardClockViewModel
+ private val clockSize = MutableStateFlow(LARGE)
+ private val currentClock: MutableStateFlow<ClockController?> = MutableStateFlow(null)
@Before
fun setup() {
MockitoAnnotations.initMocks(this)
- }
-
- @Test
- fun addClockViews_nonWeatherClock() {
- setupNonWeatherClock()
- KeyguardClockViewBinder.addClockViews(clock, rootView, burnInLayer)
- verify(rootView).addView(smallClockView)
- verify(rootView).addView(largeClockView)
- verify(burnInLayer).addView(smallClockView)
- verify(burnInLayer, never()).addView(largeClockView)
+ whenever(clockViewModel.clockSize).thenReturn(clockSize)
+ whenever(clockViewModel.currentClock).thenReturn(currentClock)
+ whenever(clockViewModel.burnInLayer).thenReturn(burnInLayer)
}
@Test
fun addClockViews_WeatherClock() {
setupWeatherClock()
- KeyguardClockViewBinder.addClockViews(clock, rootView, burnInLayer)
+ KeyguardClockViewBinder.addClockViews(clock, rootView)
verify(rootView).addView(smallClockView)
verify(rootView).addView(largeClockView)
- verify(burnInLayer).addView(smallClockView)
+ }
+
+ @Test
+ fun addClockViews_nonWeatherClock() {
+ setupNonWeatherClock()
+ KeyguardClockViewBinder.addClockViews(clock, rootView)
+ verify(rootView).addView(smallClockView)
+ verify(rootView).addView(largeClockView)
+ }
+ @Test
+ fun addClockViewsToBurnInLayer_LargeWeatherClock() {
+ setupWeatherClock()
+ clockSize.value = LARGE
+ KeyguardClockViewBinder.updateBurnInLayer(rootView, clockViewModel)
+ verify(burnInLayer).removeView(smallClockView)
verify(burnInLayer).addView(largeClockView)
}
+ @Test
+ fun addClockViewsToBurnInLayer_LargeNonWeatherClock() {
+ setupNonWeatherClock()
+ clockSize.value = LARGE
+ KeyguardClockViewBinder.updateBurnInLayer(rootView, clockViewModel)
+ verify(burnInLayer).removeView(smallClockView)
+ verify(burnInLayer, never()).addView(largeClockView)
+ }
+
+ @Test
+ fun addClockViewsToBurnInLayer_SmallClock() {
+ setupNonWeatherClock()
+ clockSize.value = SMALL
+ KeyguardClockViewBinder.updateBurnInLayer(rootView, clockViewModel)
+ verify(burnInLayer).addView(smallClockView)
+ verify(burnInLayer).removeView(largeClockView)
+ }
+
private fun setupWeatherClock() {
setupClock()
val clockConfig =
@@ -99,5 +131,7 @@
whenever(clock.smallClock).thenReturn(smallClock)
whenever(largeClock.layout).thenReturn(largeClockFaceLayout)
whenever(smallClock.layout).thenReturn(smallClockFaceLayout)
+ whenever(clockViewModel.clock).thenReturn(clock)
+ currentClock.value = clock
}
}
diff --git a/packages/SystemUI/tests/src/com/android/systemui/keyguard/ui/view/layout/sections/ClockSectionTest.kt b/packages/SystemUI/tests/src/com/android/systemui/keyguard/ui/view/layout/sections/ClockSectionTest.kt
index 070a0cc..57b5559 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/keyguard/ui/view/layout/sections/ClockSectionTest.kt
+++ b/packages/SystemUI/tests/src/com/android/systemui/keyguard/ui/view/layout/sections/ClockSectionTest.kt
@@ -22,6 +22,7 @@
import androidx.constraintlayout.widget.ConstraintSet
import androidx.test.filters.SmallTest
import com.android.systemui.SysuiTestCase
+import com.android.systemui.keyguard.domain.interactor.KeyguardBlueprintInteractor
import com.android.systemui.keyguard.domain.interactor.KeyguardClockInteractor
import com.android.systemui.keyguard.ui.viewmodel.KeyguardClockViewModel
import com.android.systemui.res.R
@@ -31,6 +32,8 @@
import com.android.systemui.util.mockito.mock
import com.android.systemui.util.mockito.whenever
import com.google.common.truth.Truth.assertThat
+import dagger.Lazy
+import kotlinx.coroutines.flow.MutableStateFlow
import org.junit.Before
import org.junit.Test
import org.junit.runner.RunWith
@@ -46,6 +49,8 @@
@Mock private lateinit var keyguardClockInteractor: KeyguardClockInteractor
@Mock private lateinit var keyguardClockViewModel: KeyguardClockViewModel
@Mock private lateinit var splitShadeStateController: SplitShadeStateController
+ @Mock private lateinit var blueprintInteractor: Lazy<KeyguardBlueprintInteractor>
+ private val clockShouldBeCentered: MutableStateFlow<Boolean> = MutableStateFlow(true)
private lateinit var underTest: ClockSection
@@ -104,12 +109,15 @@
whenever(packageManager.getResourcesForApplication(anyString())).thenReturn(remoteResources)
mContext.setMockPackageManager(packageManager)
+ whenever(keyguardClockViewModel.clockShouldBeCentered).thenReturn(clockShouldBeCentered)
+
underTest =
ClockSection(
keyguardClockInteractor,
keyguardClockViewModel,
mContext,
splitShadeStateController,
+ blueprintInteractor
)
}
diff --git a/packages/SystemUI/tests/src/com/android/systemui/keyguard/ui/view/layout/sections/SmartspaceSectionTest.kt b/packages/SystemUI/tests/src/com/android/systemui/keyguard/ui/view/layout/sections/SmartspaceSectionTest.kt
index 28da957..deb3a83 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/keyguard/ui/view/layout/sections/SmartspaceSectionTest.kt
+++ b/packages/SystemUI/tests/src/com/android/systemui/keyguard/ui/view/layout/sections/SmartspaceSectionTest.kt
@@ -26,6 +26,8 @@
import com.android.systemui.Flags
import com.android.systemui.SysuiTestCase
import com.android.systemui.keyguard.KeyguardUnlockAnimationController
+import com.android.systemui.keyguard.domain.interactor.KeyguardBlueprintInteractor
+import com.android.systemui.keyguard.domain.interactor.KeyguardSmartspaceInteractor
import com.android.systemui.keyguard.ui.viewmodel.KeyguardClockViewModel
import com.android.systemui.keyguard.ui.viewmodel.KeyguardSmartspaceViewModel
import com.android.systemui.res.R
@@ -34,7 +36,8 @@
import com.android.systemui.util.mockito.any
import com.android.systemui.util.mockito.whenever
import com.google.common.truth.Truth.assertThat
-import kotlinx.coroutines.flow.StateFlow
+import dagger.Lazy
+import kotlinx.coroutines.flow.MutableStateFlow
import org.junit.Before
import org.junit.Test
import org.junit.runner.RunWith
@@ -50,7 +53,8 @@
@Mock private lateinit var keyguardSmartspaceViewModel: KeyguardSmartspaceViewModel
@Mock private lateinit var lockscreenSmartspaceController: LockscreenSmartspaceController
@Mock private lateinit var keyguardUnlockAnimationController: KeyguardUnlockAnimationController
- @Mock private lateinit var hasCustomWeatherDataDisplay: StateFlow<Boolean>
+ @Mock private lateinit var keyguardSmartspaceInteractor: KeyguardSmartspaceInteractor
+ @Mock private lateinit var blueprintInteractor: Lazy<KeyguardBlueprintInteractor>
private val smartspaceView = View(mContext).also { it.id = sharedR.id.bc_smartspace_view }
private val weatherView = View(mContext).also { it.id = sharedR.id.weather_smartspace_view }
@@ -58,17 +62,22 @@
private lateinit var constraintLayout: ConstraintLayout
private lateinit var constraintSet: ConstraintSet
+ private val clockShouldBeCentered = MutableStateFlow(false)
+ private val hasCustomWeatherDataDisplay = MutableStateFlow(false)
+
@Before
fun setup() {
MockitoAnnotations.initMocks(this)
mSetFlagsRule.enableFlags(Flags.FLAG_MIGRATE_CLOCKS_TO_BLUEPRINT)
underTest =
SmartspaceSection(
+ mContext,
keyguardClockViewModel,
keyguardSmartspaceViewModel,
- mContext,
+ keyguardSmartspaceInteractor,
lockscreenSmartspaceController,
keyguardUnlockAnimationController,
+ blueprintInteractor
)
constraintLayout = ConstraintLayout(mContext)
whenever(lockscreenSmartspaceController.buildAndConnectView(any()))
@@ -78,6 +87,7 @@
whenever(lockscreenSmartspaceController.buildAndConnectDateView(any())).thenReturn(dateView)
whenever(keyguardClockViewModel.hasCustomWeatherDataDisplay)
.thenReturn(hasCustomWeatherDataDisplay)
+ whenever(keyguardClockViewModel.clockShouldBeCentered).thenReturn(clockShouldBeCentered)
constraintSet = ConstraintSet()
}
@@ -115,7 +125,7 @@
fun testConstraintsWhenNotHasCustomWeatherDataDisplay() {
whenever(keyguardSmartspaceViewModel.isSmartspaceEnabled).thenReturn(true)
whenever(keyguardSmartspaceViewModel.isDateWeatherDecoupled).thenReturn(true)
- whenever(keyguardClockViewModel.hasCustomWeatherDataDisplay.value).thenReturn(false)
+ hasCustomWeatherDataDisplay.value = false
underTest.addViews(constraintLayout)
underTest.applyConstraints(constraintSet)
assertWeatherSmartspaceConstrains(constraintSet)
@@ -129,7 +139,7 @@
@Test
fun testConstraintsWhenHasCustomWeatherDataDisplay() {
- whenever(keyguardClockViewModel.hasCustomWeatherDataDisplay.value).thenReturn(true)
+ hasCustomWeatherDataDisplay.value = true
underTest.addViews(constraintLayout)
underTest.applyConstraints(constraintSet)
assertWeatherSmartspaceConstrains(constraintSet)
@@ -140,7 +150,7 @@
@Test
fun testNormalDateWeatherVisibility() {
- whenever(keyguardClockViewModel.hasCustomWeatherDataDisplay.value).thenReturn(false)
+ hasCustomWeatherDataDisplay.value = false
whenever(keyguardSmartspaceViewModel.isWeatherEnabled).thenReturn(true)
underTest.addViews(constraintLayout)
underTest.applyConstraints(constraintSet)
@@ -153,7 +163,7 @@
}
@Test
fun testCustomDateWeatherVisibility() {
- whenever(keyguardClockViewModel.hasCustomWeatherDataDisplay.value).thenReturn(true)
+ hasCustomWeatherDataDisplay.value = true
underTest.addViews(constraintLayout)
underTest.applyConstraints(constraintSet)
diff --git a/packages/SystemUI/tests/src/com/android/systemui/mediaprojection/taskswitcher/data/repository/FakeMediaProjectionManager.kt b/packages/SystemUI/tests/src/com/android/systemui/mediaprojection/taskswitcher/data/repository/FakeMediaProjectionManager.kt
index 45f0a8c..44c411f 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/mediaprojection/taskswitcher/data/repository/FakeMediaProjectionManager.kt
+++ b/packages/SystemUI/tests/src/com/android/systemui/mediaprojection/taskswitcher/data/repository/FakeMediaProjectionManager.kt
@@ -66,6 +66,11 @@
private const val DEFAULT_PACKAGE_NAME = "com.media.projection.test"
private val DEFAULT_USER_HANDLE = UserHandle.getUserHandleForUid(UserHandle.myUserId())
- private val DEFAULT_INFO = MediaProjectionInfo(DEFAULT_PACKAGE_NAME, DEFAULT_USER_HANDLE)
+ private val DEFAULT_INFO =
+ MediaProjectionInfo(
+ DEFAULT_PACKAGE_NAME,
+ DEFAULT_USER_HANDLE,
+ /* launchCookie = */ null
+ )
}
}
diff --git a/packages/SystemUI/tests/src/com/android/systemui/qs/LeftRightArrowPressedListenerTest.kt b/packages/SystemUI/tests/src/com/android/systemui/qs/LeftRightArrowPressedListenerTest.kt
new file mode 100644
index 0000000..60eb3ae
--- /dev/null
+++ b/packages/SystemUI/tests/src/com/android/systemui/qs/LeftRightArrowPressedListenerTest.kt
@@ -0,0 +1,107 @@
+/*
+ * Copyright (C) 2023 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.systemui.qs
+
+import android.testing.AndroidTestingRunner
+import android.view.KeyEvent
+import android.view.KeyEvent.KEYCODE_DPAD_LEFT
+import android.view.View
+import androidx.core.util.Consumer
+import androidx.test.filters.SmallTest
+import com.android.systemui.SysuiTestCase
+import com.google.common.truth.Truth.assertThat
+import org.junit.Before
+import org.junit.Test
+import org.junit.runner.RunWith
+
+@RunWith(AndroidTestingRunner::class)
+@SmallTest
+class LeftRightArrowPressedListenerTest : SysuiTestCase() {
+
+ private lateinit var underTest: LeftRightArrowPressedListener
+ private val callback =
+ object : Consumer<Int> {
+ var lastValue: Int? = null
+
+ override fun accept(keyCode: Int?) {
+ lastValue = keyCode
+ }
+ }
+
+ private val view = View(context)
+
+ @Before
+ fun setUp() {
+ underTest = LeftRightArrowPressedListener.createAndRegisterListenerForView(view)
+ underTest.setArrowKeyPressedListener(callback)
+ }
+
+ @Test
+ fun shouldTriggerCallback_whenArrowUpReceived_afterArrowDownReceived() {
+ underTest.sendKey(KeyEvent.ACTION_DOWN, KEYCODE_DPAD_LEFT)
+
+ underTest.sendKey(KeyEvent.ACTION_UP, KEYCODE_DPAD_LEFT)
+
+ assertThat(callback.lastValue).isEqualTo(KEYCODE_DPAD_LEFT)
+ }
+
+ @Test
+ fun shouldNotTriggerCallback_whenKeyUpReceived_ifKeyDownNotReceived() {
+ underTest.sendKey(KeyEvent.ACTION_UP, KEYCODE_DPAD_LEFT)
+
+ assertThat(callback.lastValue).isNull()
+ }
+
+ @Test
+ fun shouldNotTriggerCallback_whenKeyUpReceived_ifKeyDownWasRepeated() {
+ underTest.sendKeyWithRepeat(KeyEvent.ACTION_UP, KEYCODE_DPAD_LEFT, repeat = 2)
+ underTest.sendKey(KeyEvent.ACTION_UP, KEYCODE_DPAD_LEFT)
+
+ assertThat(callback.lastValue).isNull()
+ }
+
+ @Test
+ fun shouldNotTriggerCallback_whenKeyUpReceived_ifKeyDownReceivedBeforeLosingFocus() {
+ underTest.sendKey(KeyEvent.ACTION_DOWN, KEYCODE_DPAD_LEFT)
+ underTest.onFocusChange(view, hasFocus = false)
+ underTest.onFocusChange(view, hasFocus = true)
+
+ underTest.sendKey(KeyEvent.ACTION_UP, KEYCODE_DPAD_LEFT)
+
+ assertThat(callback.lastValue).isNull()
+ }
+
+ private fun LeftRightArrowPressedListener.sendKey(action: Int, keyCode: Int) {
+ onKey(view, keyCode, KeyEvent(action, keyCode))
+ }
+
+ private fun LeftRightArrowPressedListener.sendKeyWithRepeat(
+ action: Int,
+ keyCode: Int,
+ repeat: Int
+ ) {
+ val keyEvent =
+ KeyEvent(
+ /* downTime= */ 0L,
+ /* eventTime= */ 0L,
+ /* action= */ action,
+ /* code= */ KEYCODE_DPAD_LEFT,
+ /* repeat= */ repeat
+ )
+ onKey(view, keyCode, keyEvent)
+ }
+}
diff --git a/packages/SystemUI/tests/src/com/android/systemui/qs/PagedTileLayoutTest.kt b/packages/SystemUI/tests/src/com/android/systemui/qs/PagedTileLayoutTest.kt
index db9e548..8ef3f57 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/qs/PagedTileLayoutTest.kt
+++ b/packages/SystemUI/tests/src/com/android/systemui/qs/PagedTileLayoutTest.kt
@@ -2,11 +2,13 @@
import android.content.Context
import android.testing.AndroidTestingRunner
-import android.view.KeyEvent
import android.view.View
import android.widget.Scroller
import androidx.test.filters.SmallTest
import com.android.systemui.SysuiTestCase
+import com.android.systemui.qs.PageIndicator.PageScrollActionListener
+import com.android.systemui.qs.PageIndicator.PageScrollActionListener.LEFT
+import com.android.systemui.qs.PageIndicator.PageScrollActionListener.RIGHT
import com.google.common.truth.Truth.assertThat
import org.junit.Before
import org.junit.Test
@@ -22,7 +24,7 @@
class PagedTileLayoutTest : SysuiTestCase() {
@Mock private lateinit var pageIndicator: PageIndicator
- @Captor private lateinit var captor: ArgumentCaptor<View.OnKeyListener>
+ @Captor private lateinit var captor: ArgumentCaptor<PageScrollActionListener>
private lateinit var pageTileLayout: TestPagedTileLayout
private lateinit var scroller: Scroller
@@ -32,7 +34,7 @@
MockitoAnnotations.initMocks(this)
pageTileLayout = TestPagedTileLayout(mContext)
pageTileLayout.setPageIndicator(pageIndicator)
- verify(pageIndicator).setOnKeyListener(captor.capture())
+ verify(pageIndicator).setPageScrollActionListener(captor.capture())
setViewWidth(pageTileLayout, width = PAGE_WIDTH)
scroller = pageTileLayout.mScroller
}
@@ -43,28 +45,27 @@
}
@Test
- fun scrollsRight_afterRightArrowPressed_whenFocusOnPagerIndicator() {
+ fun scrollsRight_afterRightScrollActionTriggered() {
pageTileLayout.currentPageIndex = 0
- sendUpEvent(KeyEvent.KEYCODE_DPAD_RIGHT)
+ sendScrollActionEvent(RIGHT)
assertThat(scroller.isFinished).isFalse() // aka we're scrolling
assertThat(scroller.finalX).isEqualTo(scroller.currX + PAGE_WIDTH)
}
@Test
- fun scrollsLeft_afterLeftArrowPressed_whenFocusOnPagerIndicator() {
+ fun scrollsLeft_afterLeftScrollActionTriggered() {
pageTileLayout.currentPageIndex = 1 // we won't scroll left if we're on the first page
- sendUpEvent(KeyEvent.KEYCODE_DPAD_LEFT)
+ sendScrollActionEvent(LEFT)
assertThat(scroller.isFinished).isFalse() // aka we're scrolling
assertThat(scroller.finalX).isEqualTo(scroller.currX - PAGE_WIDTH)
}
- private fun sendUpEvent(keyCode: Int) {
- val event = KeyEvent(KeyEvent.ACTION_UP, keyCode)
- captor.value.onKey(pageIndicator, keyCode, event)
+ private fun sendScrollActionEvent(@PageScrollActionListener.Direction direction: Int) {
+ captor.value.onScrollActionTriggered(direction)
}
/**
diff --git a/packages/SystemUI/tests/src/com/android/systemui/shade/ShadeControllerImplTest.kt b/packages/SystemUI/tests/src/com/android/systemui/shade/ShadeControllerImplTest.kt
index 215f8b1..c4911a4 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/shade/ShadeControllerImplTest.kt
+++ b/packages/SystemUI/tests/src/com/android/systemui/shade/ShadeControllerImplTest.kt
@@ -33,6 +33,8 @@
import com.android.systemui.scene.domain.interactor.WindowRootViewVisibilityInteractor
import com.android.systemui.statusbar.CommandQueue
import com.android.systemui.statusbar.NotificationShadeWindowController
+import com.android.systemui.statusbar.notification.data.repository.ActiveNotificationListRepository
+import com.android.systemui.statusbar.notification.domain.interactor.ActiveNotificationsInteractor
import com.android.systemui.statusbar.notification.row.NotificationGutsManager
import com.android.systemui.statusbar.phone.StatusBarKeyguardViewManager
import com.android.systemui.statusbar.policy.DeviceProvisionedController
@@ -45,6 +47,7 @@
import com.android.systemui.util.time.FakeSystemClock
import com.google.common.truth.Truth.assertThat
import dagger.Lazy
+import kotlinx.coroutines.test.StandardTestDispatcher
import org.junit.Before
import org.junit.Test
import org.junit.runner.RunWith
@@ -59,6 +62,8 @@
@SmallTest
class ShadeControllerImplTest : SysuiTestCase() {
private val executor = FakeExecutor(FakeSystemClock())
+ private val testDispatcher = StandardTestDispatcher()
+ private val activeNotificationsRepository = ActiveNotificationListRepository()
@Mock private lateinit var commandQueue: CommandQueue
@Mock private lateinit var keyguardStateController: KeyguardStateController
@@ -84,6 +89,7 @@
FakeKeyguardRepository(),
headsUpManager,
PowerInteractorFactory.create().powerInteractor,
+ ActiveNotificationsInteractor(activeNotificationsRepository, testDispatcher)
)
}
diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/collection/coordinator/ConversationCoordinatorTest.kt b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/collection/coordinator/ConversationCoordinatorTest.kt
index 65697b73..36f643a 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/collection/coordinator/ConversationCoordinatorTest.kt
+++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/collection/coordinator/ConversationCoordinatorTest.kt
@@ -24,7 +24,6 @@
import android.testing.TestableLooper
import androidx.test.filters.SmallTest
import com.android.systemui.SysuiTestCase
-import com.android.systemui.flags.FakeFeatureFlagsClassic
import com.android.systemui.statusbar.notification.collection.GroupEntry
import com.android.systemui.statusbar.notification.collection.GroupEntryBuilder
import com.android.systemui.statusbar.notification.collection.NotifPipeline
@@ -53,8 +52,8 @@
import org.junit.runner.RunWith
import org.mockito.Mock
import org.mockito.Mockito.verify
-import org.mockito.MockitoAnnotations
import org.mockito.Mockito.`when` as whenever
+import org.mockito.MockitoAnnotations
@SmallTest
@RunWith(AndroidTestingRunner::class)
@@ -78,28 +77,22 @@
private lateinit var coordinator: ConversationCoordinator
- private val featureFlags = FakeFeatureFlagsClassic()
-
@Before
fun setUp() {
MockitoAnnotations.initMocks(this)
- coordinator = ConversationCoordinator(
- peopleNotificationIdentifier,
- conversationIconManager,
- HighPriorityProvider(
+ coordinator =
+ ConversationCoordinator(
peopleNotificationIdentifier,
- GroupMembershipManagerImpl(featureFlags)
- ),
- headerController
- )
+ conversationIconManager,
+ HighPriorityProvider(peopleNotificationIdentifier, GroupMembershipManagerImpl()),
+ headerController
+ )
whenever(channel.isImportantConversation).thenReturn(true)
coordinator.attach(pipeline)
// capture arguments:
- promoter = withArgCaptor {
- verify(pipeline).addPromoter(capture())
- }
+ promoter = withArgCaptor { verify(pipeline).addPromoter(capture()) }
beforeRenderListListener = withArgCaptor {
verify(pipeline).addOnBeforeRenderListListener(capture())
}
@@ -111,10 +104,10 @@
entry = NotificationEntryBuilder().setChannel(channel).build()
val section = NotifSection(peopleAlertingSectioner, 0)
- entryA = NotificationEntryBuilder().setChannel(channel)
- .setSection(section).setTag("A").build()
- entryB = NotificationEntryBuilder().setChannel(channel)
- .setSection(section).setTag("B").build()
+ entryA =
+ NotificationEntryBuilder().setChannel(channel).setSection(section).setTag("A").build()
+ entryB =
+ NotificationEntryBuilder().setChannel(channel).setSection(section).setTag("B").build()
}
@Test
@@ -129,11 +122,12 @@
val altChildA = NotificationEntryBuilder().setTag("A").build()
val altChildB = NotificationEntryBuilder().setTag("B").build()
val summary = NotificationEntryBuilder().setId(2).setChannel(channel).build()
- val groupEntry = GroupEntryBuilder()
- .setParent(GroupEntry.ROOT_ENTRY)
- .setSummary(summary)
- .setChildren(listOf(entry, altChildA, altChildB))
- .build()
+ val groupEntry =
+ GroupEntryBuilder()
+ .setParent(GroupEntry.ROOT_ENTRY)
+ .setSummary(summary)
+ .setChildren(listOf(entry, altChildA, altChildB))
+ .build()
assertTrue(promoter.shouldPromoteToTopLevel(entry))
assertFalse(promoter.shouldPromoteToTopLevel(altChildA))
assertFalse(promoter.shouldPromoteToTopLevel(altChildB))
@@ -146,41 +140,42 @@
@Test
fun testInAlertingPeopleSectionWhenTheImportanceIsAtLeastDefault() {
// GIVEN
- val alertingEntry = NotificationEntryBuilder().setChannel(channel)
- .setImportance(IMPORTANCE_DEFAULT).build()
+ val alertingEntry =
+ NotificationEntryBuilder().setChannel(channel).setImportance(IMPORTANCE_DEFAULT).build()
whenever(peopleNotificationIdentifier.getPeopleNotificationType(alertingEntry))
- .thenReturn(TYPE_PERSON)
+ .thenReturn(TYPE_PERSON)
// put alerting people notifications in this section
assertThat(peopleAlertingSectioner.isInSection(alertingEntry)).isTrue()
- }
+ }
@Test
fun testInSilentPeopleSectionWhenTheImportanceIsLowerThanDefault() {
// GIVEN
- val silentEntry = NotificationEntryBuilder().setChannel(channel)
- .setImportance(IMPORTANCE_LOW).build()
+ val silentEntry =
+ NotificationEntryBuilder().setChannel(channel).setImportance(IMPORTANCE_LOW).build()
whenever(peopleNotificationIdentifier.getPeopleNotificationType(silentEntry))
- .thenReturn(TYPE_PERSON)
+ .thenReturn(TYPE_PERSON)
// THEN put silent people notifications in this section
assertThat(peopleSilentSectioner.isInSection(silentEntry)).isTrue()
// People Alerting sectioning happens before the silent one.
- // It claims high important conversations and rest of conversations will be considered as silent.
+ // It claims high important conversations and rest of conversations will be considered as
+ // silent.
assertThat(peopleAlertingSectioner.isInSection(silentEntry)).isFalse()
}
@Test
fun testNotInPeopleSection() {
// GIVEN
- val entry = NotificationEntryBuilder().setChannel(channel)
- .setImportance(IMPORTANCE_LOW).build()
- val importantEntry = NotificationEntryBuilder().setChannel(channel)
- .setImportance(IMPORTANCE_HIGH).build()
+ val entry =
+ NotificationEntryBuilder().setChannel(channel).setImportance(IMPORTANCE_LOW).build()
+ val importantEntry =
+ NotificationEntryBuilder().setChannel(channel).setImportance(IMPORTANCE_HIGH).build()
whenever(peopleNotificationIdentifier.getPeopleNotificationType(entry))
- .thenReturn(TYPE_NON_PERSON)
+ .thenReturn(TYPE_NON_PERSON)
whenever(peopleNotificationIdentifier.getPeopleNotificationType(importantEntry))
- .thenReturn(TYPE_NON_PERSON)
+ .thenReturn(TYPE_NON_PERSON)
// THEN - only put people notification either silent or alerting
assertThat(peopleSilentSectioner.isInSection(entry)).isFalse()
@@ -190,19 +185,23 @@
@Test
fun testInAlertingPeopleSectionWhenThereIsAnImportantChild() {
// GIVEN
- val altChildA = NotificationEntryBuilder().setTag("A")
- .setImportance(IMPORTANCE_DEFAULT).build()
- val altChildB = NotificationEntryBuilder().setTag("B")
- .setImportance(IMPORTANCE_LOW).build()
- val summary = NotificationEntryBuilder().setId(2)
- .setImportance(IMPORTANCE_LOW).setChannel(channel).build()
- val groupEntry = GroupEntryBuilder()
+ val altChildA =
+ NotificationEntryBuilder().setTag("A").setImportance(IMPORTANCE_DEFAULT).build()
+ val altChildB = NotificationEntryBuilder().setTag("B").setImportance(IMPORTANCE_LOW).build()
+ val summary =
+ NotificationEntryBuilder()
+ .setId(2)
+ .setImportance(IMPORTANCE_LOW)
+ .setChannel(channel)
+ .build()
+ val groupEntry =
+ GroupEntryBuilder()
.setParent(GroupEntry.ROOT_ENTRY)
.setSummary(summary)
.setChildren(listOf(altChildA, altChildB))
.build()
whenever(peopleNotificationIdentifier.getPeopleNotificationType(summary))
- .thenReturn(TYPE_PERSON)
+ .thenReturn(TYPE_PERSON)
// THEN
assertThat(peopleAlertingSectioner.isInSection(groupEntry)).isTrue()
}
diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/collection/render/GroupMembershipManagerTest.kt b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/collection/render/GroupMembershipManagerTest.kt
deleted file mode 100644
index c1ffa64..0000000
--- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/collection/render/GroupMembershipManagerTest.kt
+++ /dev/null
@@ -1,173 +0,0 @@
-/*
- * Copyright (C) 2023 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.systemui.statusbar.notification.collection.render
-
-import androidx.test.filters.SmallTest
-import com.android.systemui.SysuiTestCase
-import com.android.systemui.flags.FakeFeatureFlagsClassic
-import com.android.systemui.flags.Flags
-import com.android.systemui.statusbar.notification.collection.GroupEntry
-import com.android.systemui.statusbar.notification.collection.GroupEntryBuilder
-import com.android.systemui.statusbar.notification.collection.NotificationEntryBuilder
-import com.google.common.truth.Truth.assertThat
-import org.junit.Before
-import org.junit.Test
-
-@SmallTest
-class GroupMembershipManagerTest : SysuiTestCase() {
- private lateinit var gmm: GroupMembershipManagerImpl
-
- private val featureFlags = FakeFeatureFlagsClassic()
-
- @Before
- fun setUp() {
- gmm = GroupMembershipManagerImpl(featureFlags)
- }
-
- @Test
- fun testIsChildInGroup_topLevel() {
- featureFlags.set(Flags.NOTIFICATION_GROUP_EXPANSION_CHANGE, false)
- val topLevelEntry = NotificationEntryBuilder().setParent(GroupEntry.ROOT_ENTRY).build()
- assertThat(gmm.isChildInGroup(topLevelEntry)).isFalse()
- }
-
- @Test
- fun testIsChildInGroup_noParent_old() {
- featureFlags.set(Flags.NOTIFICATION_GROUP_EXPANSION_CHANGE, false)
- val noParentEntry = NotificationEntryBuilder().setParent(null).build()
- assertThat(gmm.isChildInGroup(noParentEntry)).isTrue()
- }
-
- @Test
- fun testIsChildInGroup_noParent_new() {
- featureFlags.set(Flags.NOTIFICATION_GROUP_EXPANSION_CHANGE, true)
- val noParentEntry = NotificationEntryBuilder().setParent(null).build()
- assertThat(gmm.isChildInGroup(noParentEntry)).isFalse()
- }
- @Test
- fun testIsChildInGroup_summary_old() {
- featureFlags.set(Flags.NOTIFICATION_GROUP_EXPANSION_CHANGE, false)
-
- val groupKey = "group"
- val summary =
- NotificationEntryBuilder()
- .setGroup(mContext, groupKey)
- .setGroupSummary(mContext, true)
- .build()
- GroupEntryBuilder().setKey(groupKey).setSummary(summary).build()
-
- assertThat(gmm.isChildInGroup(summary)).isTrue()
- }
-
- @Test
- fun testIsChildInGroup_summary_new() {
- featureFlags.set(Flags.NOTIFICATION_GROUP_EXPANSION_CHANGE, true)
-
- val groupKey = "group"
- val summary =
- NotificationEntryBuilder()
- .setGroup(mContext, groupKey)
- .setGroupSummary(mContext, true)
- .build()
- GroupEntryBuilder().setKey(groupKey).setSummary(summary).build()
-
- assertThat(gmm.isChildInGroup(summary)).isFalse()
- }
-
- @Test
- fun testIsChildInGroup_child() {
- featureFlags.set(Flags.NOTIFICATION_GROUP_EXPANSION_CHANGE, false)
- val childEntry = NotificationEntryBuilder().build()
- assertThat(gmm.isChildInGroup(childEntry)).isTrue()
- }
-
- @Test
- fun testIsGroupSummary_topLevelEntry() {
- featureFlags.set(Flags.NOTIFICATION_GROUP_EXPANSION_CHANGE, true)
- val entry = NotificationEntryBuilder().setParent(GroupEntry.ROOT_ENTRY).build()
- assertThat(gmm.isGroupSummary(entry)).isFalse()
- }
-
- @Test
- fun testIsGroupSummary_summary() {
- featureFlags.set(Flags.NOTIFICATION_GROUP_EXPANSION_CHANGE, true)
-
- val groupKey = "group"
- val summary =
- NotificationEntryBuilder()
- .setGroup(mContext, groupKey)
- .setGroupSummary(mContext, true)
- .build()
- GroupEntryBuilder().setKey(groupKey).setSummary(summary).build()
-
- assertThat(gmm.isGroupSummary(summary)).isTrue()
- }
-
- @Test
- fun testIsGroupSummary_child() {
- featureFlags.set(Flags.NOTIFICATION_GROUP_EXPANSION_CHANGE, true)
-
- val groupKey = "group"
- val summary =
- NotificationEntryBuilder()
- .setGroup(mContext, groupKey)
- .setGroupSummary(mContext, true)
- .build()
- val entry = NotificationEntryBuilder().setGroup(mContext, groupKey).build()
- GroupEntryBuilder().setKey(groupKey).setSummary(summary).addChild(entry).build()
-
- assertThat(gmm.isGroupSummary(entry)).isFalse()
- }
-
- @Test
- fun testGetGroupSummary_topLevelEntry() {
- featureFlags.set(Flags.NOTIFICATION_GROUP_EXPANSION_CHANGE, true)
- val entry = NotificationEntryBuilder().setParent(GroupEntry.ROOT_ENTRY).build()
- assertThat(gmm.getGroupSummary(entry)).isNull()
- }
-
- @Test
- fun testGetGroupSummary_summary() {
- featureFlags.set(Flags.NOTIFICATION_GROUP_EXPANSION_CHANGE, true)
-
- val groupKey = "group"
- val summary =
- NotificationEntryBuilder()
- .setGroup(mContext, groupKey)
- .setGroupSummary(mContext, true)
- .build()
- GroupEntryBuilder().setKey(groupKey).setSummary(summary).build()
-
- assertThat(gmm.getGroupSummary(summary)).isEqualTo(summary)
- }
-
- @Test
- fun testGetGroupSummary_child() {
- featureFlags.set(Flags.NOTIFICATION_GROUP_EXPANSION_CHANGE, true)
-
- val groupKey = "group"
- val summary =
- NotificationEntryBuilder()
- .setGroup(mContext, groupKey)
- .setGroupSummary(mContext, true)
- .build()
- val entry = NotificationEntryBuilder().setGroup(mContext, groupKey).build()
- GroupEntryBuilder().setKey(groupKey).setSummary(summary).addChild(entry).build()
-
- assertThat(gmm.getGroupSummary(entry)).isEqualTo(summary)
- }
-}
diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/logging/NotificationLoggerTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/logging/NotificationLoggerTest.java
index 168e782..ff02ef3 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/logging/NotificationLoggerTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/logging/NotificationLoggerTest.java
@@ -28,6 +28,8 @@
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
+import static kotlinx.coroutines.test.TestCoroutineDispatchersKt.StandardTestDispatcher;
+
import android.app.Notification;
import android.os.Handler;
import android.os.Looper;
@@ -56,6 +58,8 @@
import com.android.systemui.statusbar.notification.collection.NotificationEntry;
import com.android.systemui.statusbar.notification.collection.NotificationEntryBuilder;
import com.android.systemui.statusbar.notification.collection.render.NotificationVisibilityProvider;
+import com.android.systemui.statusbar.notification.data.repository.ActiveNotificationListRepository;
+import com.android.systemui.statusbar.notification.domain.interactor.ActiveNotificationsInteractor;
import com.android.systemui.statusbar.notification.logging.nano.Notifications;
import com.android.systemui.statusbar.notification.row.ExpandableNotificationRow;
import com.android.systemui.statusbar.notification.stack.NotificationListContainer;
@@ -110,6 +114,11 @@
private final FakeKeyguardRepository mKeyguardRepository = new FakeKeyguardRepository();
private final PowerInteractor mPowerInteractor =
PowerInteractorFactory.create().getPowerInteractor();
+ private final ActiveNotificationListRepository mActiveNotificationListRepository =
+ new ActiveNotificationListRepository();
+ private final ActiveNotificationsInteractor mActiveNotificationsInteractor =
+ new ActiveNotificationsInteractor(mActiveNotificationListRepository,
+ StandardTestDispatcher(null, null));
private WindowRootViewVisibilityInteractor mWindowRootViewVisibilityInteractor;
private final JavaAdapter mJavaAdapter = new JavaAdapter(mTestScope.getBackgroundScope());
@@ -123,7 +132,8 @@
new WindowRootViewVisibilityRepository(mBarService, mUiBgExecutor),
mKeyguardRepository,
mHeadsUpManager,
- mPowerInteractor);
+ mPowerInteractor,
+ mActiveNotificationsInteractor);
mWindowRootViewVisibilityInteractor.setIsLockscreenOrShadeVisible(true);
mEntry = new NotificationEntryBuilder()
diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/row/NotificationGutsManagerTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/row/NotificationGutsManagerTest.java
index 8a730cf..71613ed 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/row/NotificationGutsManagerTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/row/NotificationGutsManagerTest.java
@@ -42,6 +42,8 @@
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
+import static kotlinx.coroutines.test.TestCoroutineDispatchersKt.StandardTestDispatcher;
+
import android.app.INotificationManager;
import android.app.Notification;
import android.app.NotificationChannel;
@@ -85,6 +87,8 @@
import com.android.systemui.statusbar.notification.NotificationActivityStarter;
import com.android.systemui.statusbar.notification.collection.NotificationEntry;
import com.android.systemui.statusbar.notification.collection.provider.HighPriorityProvider;
+import com.android.systemui.statusbar.notification.data.repository.ActiveNotificationListRepository;
+import com.android.systemui.statusbar.notification.domain.interactor.ActiveNotificationsInteractor;
import com.android.systemui.statusbar.notification.people.PeopleNotificationIdentifier;
import com.android.systemui.statusbar.notification.row.NotificationGutsManager.OnSettingsClickListener;
import com.android.systemui.statusbar.notification.stack.NotificationListContainer;
@@ -156,6 +160,12 @@
@Mock private UserManager mUserManager;
+ private final ActiveNotificationListRepository mActiveNotificationListRepository =
+ new ActiveNotificationListRepository();
+ private final ActiveNotificationsInteractor mActiveNotificationsInteractor =
+ new ActiveNotificationsInteractor(mActiveNotificationListRepository,
+ StandardTestDispatcher(null, null));
+
private WindowRootViewVisibilityInteractor mWindowRootViewVisibilityInteractor;
@Before
@@ -171,7 +181,8 @@
new WindowRootViewVisibilityRepository(mBarService, mExecutor),
new FakeKeyguardRepository(),
mHeadsUpManager,
- PowerInteractorFactory.create().getPowerInteractor());
+ PowerInteractorFactory.create().getPowerInteractor(),
+ mActiveNotificationsInteractor);
mGutsManager = new NotificationGutsManager(
mContext,
diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayoutControllerTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayoutControllerTest.java
index 88662b6..89f826b 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayoutControllerTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayoutControllerTest.java
@@ -66,6 +66,8 @@
import com.android.systemui.plugins.statusbar.NotificationMenuRowPlugin.OnMenuEventListener;
import com.android.systemui.plugins.statusbar.StatusBarStateController;
import com.android.systemui.power.domain.interactor.PowerInteractor;
+import com.android.systemui.scene.shared.flag.SceneContainerFlags;
+import com.android.systemui.scene.ui.view.WindowRootView;
import com.android.systemui.shade.ShadeController;
import com.android.systemui.statusbar.LockscreenShadeTransitionController;
import com.android.systemui.statusbar.NotificationLockscreenUserManager;
@@ -91,6 +93,7 @@
import com.android.systemui.statusbar.notification.row.NotificationGutsManager;
import com.android.systemui.statusbar.notification.stack.NotificationStackScrollLayoutController.NotificationPanelEvent;
import com.android.systemui.statusbar.notification.stack.NotificationSwipeHelper.NotificationCallback;
+import com.android.systemui.statusbar.notification.stack.domain.interactor.NotificationStackAppearanceInteractor;
import com.android.systemui.statusbar.notification.stack.ui.viewbinder.NotificationListViewBinder;
import com.android.systemui.statusbar.phone.KeyguardBypassController;
import com.android.systemui.statusbar.phone.ScrimController;
@@ -112,6 +115,8 @@
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
+import javax.inject.Provider;
+
/**
* Tests for {@link NotificationStackScrollLayoutController}.
*/
@@ -153,6 +158,9 @@
@Mock private NotificationRemoteInputManager mRemoteInputManager;
@Mock private VisibilityLocationProviderDelegator mVisibilityLocationProviderDelegator;
@Mock private ShadeController mShadeController;
+ @Mock private SceneContainerFlags mSceneContainerFlags;
+ @Mock private Provider<WindowRootView> mWindowRootView;
+ @Mock private NotificationStackAppearanceInteractor mNotificationStackAppearanceInteractor;
@Mock private InteractionJankMonitor mJankMonitor;
private final StackStateLogger mStackLogger = new StackStateLogger(logcatLogBuffer(),
logcatLogBuffer());
@@ -724,6 +732,9 @@
mSeenNotificationsInteractor,
mViewBinder,
mShadeController,
+ mSceneContainerFlags,
+ mWindowRootView,
+ mNotificationStackAppearanceInteractor,
mJankMonitor,
mStackLogger,
mLogger,
diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayoutTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayoutTest.java
index a172120..4afcc8c 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayoutTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayoutTest.java
@@ -20,6 +20,7 @@
import static android.view.WindowInsets.Type.ime;
import static com.android.systemui.Flags.FLAG_NEW_AOD_TRANSITION;
+import static com.android.systemui.Flags.FLAG_SCENE_CONTAINER;
import static com.android.systemui.statusbar.notification.stack.NotificationStackScrollLayout.ROWS_ALL;
import static com.android.systemui.statusbar.notification.stack.NotificationStackScrollLayout.ROWS_GENTLE;
import static com.android.systemui.statusbar.notification.stack.NotificationStackScrollLayout.RUBBER_BAND_FACTOR_NORMAL;
@@ -37,6 +38,7 @@
import static org.mockito.ArgumentMatchers.anyBoolean;
import static org.mockito.ArgumentMatchers.anyFloat;
import static org.mockito.ArgumentMatchers.anyInt;
+import static org.mockito.ArgumentMatchers.argThat;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.atLeastOnce;
import static org.mockito.Mockito.clearInvocations;
@@ -51,6 +53,7 @@
import android.graphics.Insets;
import android.graphics.Rect;
+import android.os.SystemClock;
import android.platform.test.annotations.DisableFlags;
import android.platform.test.annotations.EnableFlags;
import android.testing.AndroidTestingRunner;
@@ -74,6 +77,7 @@
import com.android.systemui.flags.FeatureFlags;
import com.android.systemui.flags.Flags;
import com.android.systemui.res.R;
+import com.android.systemui.scene.shared.flag.SceneContainerFlag;
import com.android.systemui.shade.ShadeController;
import com.android.systemui.shade.transition.LargeScreenShadeInterpolator;
import com.android.systemui.statusbar.EmptyShadeView;
@@ -93,11 +97,13 @@
import com.android.systemui.statusbar.policy.ResourcesSplitShadeStateController;
import org.junit.Assert;
+import org.junit.Assume;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.ArgumentCaptor;
+import org.mockito.ArgumentMatcher;
import org.mockito.Mock;
import org.mockito.junit.MockitoJUnit;
import org.mockito.junit.MockitoRule;
@@ -947,6 +953,78 @@
verify(runnable).run();
}
+ @Test
+ public void testDispatchTouchEvent_sceneContainerDisabled() {
+ Assume.assumeFalse(SceneContainerFlag.isEnabled());
+
+ MotionEvent event = MotionEvent.obtain(
+ SystemClock.uptimeMillis(),
+ SystemClock.uptimeMillis(),
+ MotionEvent.ACTION_MOVE,
+ 0,
+ 0,
+ 0
+ );
+
+ mStackScroller.dispatchTouchEvent(event);
+
+ verify(mStackScrollLayoutController, never()).sendTouchToSceneFramework(any());
+ }
+
+ @Test
+ public void testDispatchTouchEvent_sceneContainerEnabled() {
+ Assume.assumeTrue(SceneContainerFlag.isEnabled());
+ mStackScroller.setIsBeingDragged(true);
+
+ MotionEvent moveEvent = MotionEvent.obtain(
+ SystemClock.uptimeMillis(),
+ SystemClock.uptimeMillis(),
+ MotionEvent.ACTION_MOVE,
+ 0,
+ 0,
+ 0
+ );
+ MotionEvent syntheticDownEvent = moveEvent.copy();
+ syntheticDownEvent.setAction(MotionEvent.ACTION_DOWN);
+ mStackScroller.dispatchTouchEvent(moveEvent);
+
+ verify(mStackScrollLayoutController).sendTouchToSceneFramework(argThat(
+ new MotionEventMatcher(syntheticDownEvent)));
+
+ mStackScroller.dispatchTouchEvent(moveEvent);
+
+ verify(mStackScrollLayoutController).sendTouchToSceneFramework(moveEvent);
+ }
+
+ @Test
+ @EnableFlags(FLAG_SCENE_CONTAINER)
+ public void testDispatchTouchEvent_sceneContainerEnabled_actionUp() {
+ Assume.assumeTrue(SceneContainerFlag.isEnabled());
+ mStackScroller.setIsBeingDragged(true);
+
+ MotionEvent upEvent = MotionEvent.obtain(
+ SystemClock.uptimeMillis(),
+ SystemClock.uptimeMillis(),
+ MotionEvent.ACTION_UP,
+ 0,
+ 0,
+ 0
+ );
+ MotionEvent syntheticDownEvent = upEvent.copy();
+ syntheticDownEvent.setAction(MotionEvent.ACTION_DOWN);
+
+ mStackScroller.dispatchTouchEvent(upEvent);
+
+ verify(mStackScrollLayoutController, atLeastOnce()).sendTouchToSceneFramework(argThat(
+ new MotionEventMatcher(syntheticDownEvent)));
+
+ mStackScroller.dispatchTouchEvent(upEvent);
+
+ verify(mStackScrollLayoutController, atLeastOnce()).sendTouchToSceneFramework(argThat(
+ new MotionEventMatcher(upEvent)));
+ assertFalse(mStackScroller.getIsBeingDragged());
+ }
+
private void setBarStateForTest(int state) {
// Can't inject this through the listener or we end up on the actual implementation
// rather than the mock because the spy just coppied the anonymous inner /shruggie.
@@ -993,4 +1071,21 @@
/* metaState= */0
);
}
+
+ private static class MotionEventMatcher implements ArgumentMatcher<MotionEvent> {
+ private final MotionEvent mLeftEvent;
+
+ MotionEventMatcher(MotionEvent leftEvent) {
+ mLeftEvent = leftEvent;
+ }
+
+ @Override
+ public boolean matches(MotionEvent right) {
+ return mLeftEvent.getActionMasked() == right.getActionMasked()
+ && mLeftEvent.getDownTime() == right.getDownTime()
+ && mLeftEvent.getEventTime() == right.getEventTime()
+ && mLeftEvent.getX() == right.getX()
+ && mLeftEvent.getY() == right.getY();
+ }
+ }
}
diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/stack/ui/viewmodel/SharedNotificationContainerViewModelTest.kt b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/stack/ui/viewmodel/SharedNotificationContainerViewModelTest.kt
index 9f15b05..a824bc4 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/stack/ui/viewmodel/SharedNotificationContainerViewModelTest.kt
+++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/stack/ui/viewmodel/SharedNotificationContainerViewModelTest.kt
@@ -484,6 +484,46 @@
}
@Test
+ fun translationYUpdatesOnKeyguard() =
+ testScope.runTest {
+ val translationY by collectLastValue(underTest.translationY)
+
+ configurationRepository.setDimensionPixelSize(
+ R.dimen.keyguard_translate_distance_on_swipe_up,
+ -100
+ )
+ configurationRepository.onAnyConfigurationChange()
+
+ // legacy expansion means the user is swiping up, usually for the bouncer
+ shadeRepository.setLegacyShadeExpansion(0.5f)
+
+ showLockscreen()
+
+ // The translation values are negative
+ assertThat(translationY).isLessThan(0f)
+ }
+
+ @Test
+ fun translationYDoesNotUpdateWhenShadeIsExpanded() =
+ testScope.runTest {
+ val translationY by collectLastValue(underTest.translationY)
+
+ configurationRepository.setDimensionPixelSize(
+ R.dimen.keyguard_translate_distance_on_swipe_up,
+ -100
+ )
+ configurationRepository.onAnyConfigurationChange()
+
+ // legacy expansion means the user is swiping up, usually for the bouncer but also for
+ // shade collapsing
+ shadeRepository.setLegacyShadeExpansion(0.5f)
+
+ showLockscreenWithShadeExpanded()
+
+ assertThat(translationY).isEqualTo(0f)
+ }
+
+ @Test
fun updateBounds_fromKeyguardRoot() =
testScope.runTest {
val bounds by collectLastValue(underTest.bounds)
diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/pipeline/satellite/data/prod/DeviceBasedSatelliteRepositoryImplTest.kt b/packages/SystemUI/tests/src/com/android/systemui/statusbar/pipeline/satellite/data/prod/DeviceBasedSatelliteRepositoryImplTest.kt
index 7d91e8b..02e6fd5 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/pipeline/satellite/data/prod/DeviceBasedSatelliteRepositoryImplTest.kt
+++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/pipeline/satellite/data/prod/DeviceBasedSatelliteRepositoryImplTest.kt
@@ -35,7 +35,6 @@
import androidx.test.filters.SmallTest
import com.android.systemui.SysuiTestCase
import com.android.systemui.coroutines.collectLastValue
-import com.android.systemui.log.core.FakeLogBuffer
import com.android.systemui.statusbar.pipeline.satellite.data.prod.DeviceBasedSatelliteRepositoryImpl.Companion.MIN_UPTIME
import com.android.systemui.statusbar.pipeline.satellite.data.prod.DeviceBasedSatelliteRepositoryImpl.Companion.POLLING_INTERVAL_MS
import com.android.systemui.statusbar.pipeline.satellite.shared.model.SatelliteConnectionState
@@ -88,7 +87,6 @@
Optional.empty(),
dispatcher,
testScope.backgroundScope,
- FakeLogBuffer.Factory.create(),
systemClock,
)
@@ -102,22 +100,6 @@
}
@Test
- fun satelliteManagerThrows_doesNotCrash() =
- testScope.runTest {
- setupDefaultRepo()
-
- whenever(satelliteManager.registerForNtnSignalStrengthChanged(any(), any()))
- .thenThrow(SatelliteException(13))
-
- val conn by collectLastValue(underTest.connectionState)
- val strength by collectLastValue(underTest.signalStrength)
-
- // Flows have not emitted, we haven't crashed
- assertThat(conn).isNull()
- assertThat(strength).isNull()
- }
-
- @Test
fun connectionState_mapsFromSatelliteModemState() =
testScope.runTest {
setupDefaultRepo()
@@ -398,7 +380,6 @@
if (satMan != null) Optional.of(satMan) else Optional.empty(),
dispatcher,
testScope.backgroundScope,
- FakeLogBuffer.Factory.create(),
systemClock,
)
}
diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/pipeline/satellite/ui/viewmodel/DeviceBasedSatelliteViewModelTest.kt b/packages/SystemUI/tests/src/com/android/systemui/statusbar/pipeline/satellite/ui/viewmodel/DeviceBasedSatelliteViewModelTest.kt
deleted file mode 100644
index 21c038a..0000000
--- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/pipeline/satellite/ui/viewmodel/DeviceBasedSatelliteViewModelTest.kt
+++ /dev/null
@@ -1,110 +0,0 @@
-/*
- * Copyright (C) 2023 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.systemui.statusbar.pipeline.satellite.ui.viewmodel
-
-import androidx.test.filters.SmallTest
-import com.android.systemui.SysuiTestCase
-import com.android.systemui.common.shared.model.Icon
-import com.android.systemui.coroutines.collectLastValue
-import com.android.systemui.statusbar.pipeline.mobile.domain.interactor.FakeMobileIconsInteractor
-import com.android.systemui.statusbar.pipeline.mobile.util.FakeMobileMappingsProxy
-import com.android.systemui.statusbar.pipeline.satellite.data.prod.FakeDeviceBasedSatelliteRepository
-import com.android.systemui.statusbar.pipeline.satellite.domain.interactor.DeviceBasedSatelliteInteractor
-import com.android.systemui.util.mockito.mock
-import com.google.common.truth.Truth.assertThat
-import kotlin.test.Test
-import kotlinx.coroutines.test.TestScope
-import kotlinx.coroutines.test.runTest
-import org.junit.Before
-import org.mockito.MockitoAnnotations
-
-@SmallTest
-class DeviceBasedSatelliteViewModelTest : SysuiTestCase() {
- private lateinit var underTest: DeviceBasedSatelliteViewModel
- private lateinit var interactor: DeviceBasedSatelliteInteractor
-
- private val repo = FakeDeviceBasedSatelliteRepository()
- private val mobileIconsInteractor = FakeMobileIconsInteractor(FakeMobileMappingsProxy(), mock())
-
- private val testScope = TestScope()
-
- @Before
- fun setUp() {
- MockitoAnnotations.initMocks(this)
-
- interactor =
- DeviceBasedSatelliteInteractor(
- repo,
- mobileIconsInteractor,
- testScope.backgroundScope,
- )
-
- underTest =
- DeviceBasedSatelliteViewModel(
- interactor,
- testScope.backgroundScope,
- )
- }
-
- @Test
- fun icon_nullWhenShouldNotShow_satelliteNotAllowed() =
- testScope.runTest {
- val latest by collectLastValue(underTest.icon)
-
- // GIVEN satellite is not allowed
- repo.isSatelliteAllowedForCurrentLocation.value = false
-
- // GIVEN all icons are OOS
- val i1 = mobileIconsInteractor.getMobileConnectionInteractorForSubId(1)
- i1.isInService.value = false
-
- // THEN icon is null because we should not be showing it
- assertThat(latest).isNull()
- }
-
- @Test
- fun icon_nullWhenShouldNotShow_notAllOos() =
- testScope.runTest {
- val latest by collectLastValue(underTest.icon)
-
- // GIVEN satellite is allowed
- repo.isSatelliteAllowedForCurrentLocation.value = true
-
- // GIVEN all icons are not OOS
- val i1 = mobileIconsInteractor.getMobileConnectionInteractorForSubId(1)
- i1.isInService.value = true
-
- // THEN icon is null because we have service
- assertThat(latest).isNull()
- }
-
- @Test
- fun icon_satelliteIsOff() =
- testScope.runTest {
- val latest by collectLastValue(underTest.icon)
-
- // GIVEN satellite is allowed
- repo.isSatelliteAllowedForCurrentLocation.value = true
-
- // GIVEN all icons are OOS
- val i1 = mobileIconsInteractor.getMobileConnectionInteractorForSubId(1)
- i1.isInService.value = false
-
- // THEN icon is null because we have service
- assertThat(latest).isInstanceOf(Icon::class.java)
- }
-}
diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/pipeline/shared/ui/view/SingleBindableStatusBarIconViewTest.kt b/packages/SystemUI/tests/src/com/android/systemui/statusbar/pipeline/shared/ui/view/SingleBindableStatusBarIconViewTest.kt
deleted file mode 100644
index ca9df57..0000000
--- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/pipeline/shared/ui/view/SingleBindableStatusBarIconViewTest.kt
+++ /dev/null
@@ -1,150 +0,0 @@
-/*
- * Copyright (C) 2023 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.systemui.statusbar.pipeline.shared.ui.view
-
-import android.graphics.Rect
-import android.testing.AndroidTestingRunner
-import android.testing.TestableLooper
-import androidx.test.filters.SmallTest
-import com.android.systemui.SysuiTestCase
-import com.android.systemui.statusbar.StatusBarIconView
-import com.google.common.truth.Truth.assertThat
-import org.junit.Test
-import org.junit.runner.RunWith
-
-/**
- * Being a simple subclass of [ModernStatusBarView], use the same basic test cases to verify the
- * root behavior, and add testing for the new [SingleBindableStatusBarIconView.withDefaultBinding]
- * method.
- */
-@SmallTest
-@RunWith(AndroidTestingRunner::class)
-@TestableLooper.RunWithLooper(setAsMainLooper = true)
-class SingleBindableStatusBarIconViewTest : SysuiTestCase() {
- private lateinit var binding: SingleBindableStatusBarIconViewBinding
-
- // Visibility is outsourced to view-models. This simulates it
- private var isVisible = true
- private var visibilityFn: () -> Boolean = { isVisible }
-
- @Test
- fun initView_hasCorrectSlot() {
- val view = createAndInitView()
-
- assertThat(view.slot).isEqualTo(SLOT_NAME)
- }
-
- @Test
- fun getVisibleState_icon_returnsIcon() {
- val view = createAndInitView()
-
- view.setVisibleState(StatusBarIconView.STATE_ICON, /* animate= */ false)
-
- assertThat(view.visibleState).isEqualTo(StatusBarIconView.STATE_ICON)
- }
-
- @Test
- fun getVisibleState_dot_returnsDot() {
- val view = createAndInitView()
-
- view.setVisibleState(StatusBarIconView.STATE_DOT, /* animate= */ false)
-
- assertThat(view.visibleState).isEqualTo(StatusBarIconView.STATE_DOT)
- }
-
- @Test
- fun getVisibleState_hidden_returnsHidden() {
- val view = createAndInitView()
-
- view.setVisibleState(StatusBarIconView.STATE_HIDDEN, /* animate= */ false)
-
- assertThat(view.visibleState).isEqualTo(StatusBarIconView.STATE_HIDDEN)
- }
-
- @Test
- fun onDarkChanged_bindingReceivesIconAndDecorTint() {
- val view = createAndInitView()
-
- view.onDarkChangedWithContrast(arrayListOf(), 0x12345678, 0x12344321)
-
- assertThat(binding.iconTint).isEqualTo(0x12345678)
- assertThat(binding.decorTint).isEqualTo(0x12345678)
- }
-
- @Test
- fun setStaticDrawableColor_bindingReceivesIconTint() {
- val view = createAndInitView()
-
- view.setStaticDrawableColor(0x12345678, 0x12344321)
-
- assertThat(binding.iconTint).isEqualTo(0x12345678)
- }
-
- @Test
- fun setDecorColor_bindingReceivesDecorColor() {
- val view = createAndInitView()
-
- view.setDecorColor(0x23456789)
-
- assertThat(binding.decorTint).isEqualTo(0x23456789)
- }
-
- @Test
- fun isIconVisible_usesBinding_true() {
- val view = createAndInitView()
-
- isVisible = true
-
- assertThat(view.isIconVisible).isEqualTo(true)
- }
-
- @Test
- fun isIconVisible_usesBinding_false() {
- val view = createAndInitView()
-
- isVisible = false
-
- assertThat(view.isIconVisible).isEqualTo(false)
- }
-
- @Test
- fun getDrawingRect_takesTranslationIntoAccount() {
- val view = createAndInitView()
-
- view.translationX = 50f
- view.translationY = 60f
-
- val drawingRect = Rect()
- view.getDrawingRect(drawingRect)
-
- assertThat(drawingRect.left).isEqualTo(view.left + 50)
- assertThat(drawingRect.right).isEqualTo(view.right + 50)
- assertThat(drawingRect.top).isEqualTo(view.top + 60)
- assertThat(drawingRect.bottom).isEqualTo(view.bottom + 60)
- }
-
- private fun createAndInitView(): SingleBindableStatusBarIconView {
- val view = SingleBindableStatusBarIconView.createView(context)
- binding = SingleBindableStatusBarIconView.withDefaultBinding(view, visibilityFn) {}
- view.initView(SLOT_NAME) { binding }
- return view
- }
-
- companion object {
- private const val SLOT_NAME = "test_slot"
- }
-}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/pipeline/dagger/OemSatelliteInputLog.kt b/packages/SystemUI/tests/utils/src/com/android/systemui/communal/data/repository/CommunalPrefsRepositoryKosmos.kt
similarity index 63%
copy from packages/SystemUI/src/com/android/systemui/statusbar/pipeline/dagger/OemSatelliteInputLog.kt
copy to packages/SystemUI/tests/utils/src/com/android/systemui/communal/data/repository/CommunalPrefsRepositoryKosmos.kt
index 252945f..79107cc 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/pipeline/dagger/OemSatelliteInputLog.kt
+++ b/packages/SystemUI/tests/utils/src/com/android/systemui/communal/data/repository/CommunalPrefsRepositoryKosmos.kt
@@ -12,15 +12,13 @@
* 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.pipeline.dagger
+package com.android.systemui.communal.data.repository
-import com.android.systemui.statusbar.pipeline.satellite.data.DeviceBasedSatelliteRepository
-import javax.inject.Qualifier
+import com.android.systemui.kosmos.Kosmos
-/** Detailed [DeviceBasedSatelliteRepository] logs */
-@Qualifier
-@MustBeDocumented
-@kotlin.annotation.Retention(AnnotationRetention.RUNTIME)
-annotation class OemSatelliteInputLog
+var Kosmos.communalPrefsRepository: CommunalPrefsRepository by
+ Kosmos.Fixture { fakeCommunalPrefsRepository }
+val Kosmos.fakeCommunalPrefsRepository by Kosmos.Fixture { FakeCommunalPrefsRepository() }
diff --git a/packages/SystemUI/tests/utils/src/com/android/systemui/communal/data/repository/FakeCommunalPrefsRepository.kt b/packages/SystemUI/tests/utils/src/com/android/systemui/communal/data/repository/FakeCommunalPrefsRepository.kt
new file mode 100644
index 0000000..d3ed58b
--- /dev/null
+++ b/packages/SystemUI/tests/utils/src/com/android/systemui/communal/data/repository/FakeCommunalPrefsRepository.kt
@@ -0,0 +1,32 @@
+/*
+ * 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.communal.data.repository
+
+import kotlinx.coroutines.flow.Flow
+import kotlinx.coroutines.flow.MutableStateFlow
+import kotlinx.coroutines.flow.asStateFlow
+
+/** Fake implementation of [CommunalPrefsRepository] */
+class FakeCommunalPrefsRepository : CommunalPrefsRepository {
+ private val _isCtaDismissed = MutableStateFlow(false)
+ override val isCtaDismissed: Flow<Boolean> = _isCtaDismissed.asStateFlow()
+
+ override suspend fun setCtaDismissedForCurrentUser() {
+ _isCtaDismissed.value = true
+ }
+}
diff --git a/packages/SystemUI/tests/utils/src/com/android/systemui/communal/data/repository/FakeCommunalRepository.kt b/packages/SystemUI/tests/utils/src/com/android/systemui/communal/data/repository/FakeCommunalRepository.kt
index e82cae4..c85c27e 100644
--- a/packages/SystemUI/tests/utils/src/com/android/systemui/communal/data/repository/FakeCommunalRepository.kt
+++ b/packages/SystemUI/tests/utils/src/com/android/systemui/communal/data/repository/FakeCommunalRepository.kt
@@ -9,7 +9,6 @@
import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.flow.SharingStarted
import kotlinx.coroutines.flow.StateFlow
-import kotlinx.coroutines.flow.asStateFlow
import kotlinx.coroutines.flow.flatMapLatest
import kotlinx.coroutines.flow.flowOf
import kotlinx.coroutines.flow.stateIn
@@ -53,12 +52,4 @@
fun setIsCommunalHubShowing(isCommunalHubShowing: Boolean) {
_isCommunalHubShowing.value = isCommunalHubShowing
}
-
- private val _isCtaTileInViewModeVisible: MutableStateFlow<Boolean> = MutableStateFlow(true)
- override val isCtaTileInViewModeVisible: Flow<Boolean> =
- _isCtaTileInViewModeVisible.asStateFlow()
-
- override fun setCtaTileInViewModeVisibility(isVisible: Boolean) {
- _isCtaTileInViewModeVisible.value = isVisible
- }
}
diff --git a/packages/SystemUI/tests/utils/src/com/android/systemui/communal/domain/interactor/CommunalInteractorFactory.kt b/packages/SystemUI/tests/utils/src/com/android/systemui/communal/domain/interactor/CommunalInteractorFactory.kt
index 95ff889..8430cf6 100644
--- a/packages/SystemUI/tests/utils/src/com/android/systemui/communal/domain/interactor/CommunalInteractorFactory.kt
+++ b/packages/SystemUI/tests/utils/src/com/android/systemui/communal/domain/interactor/CommunalInteractorFactory.kt
@@ -19,6 +19,7 @@
import android.appwidget.AppWidgetHost
import com.android.systemui.communal.data.repository.FakeCommunalMediaRepository
+import com.android.systemui.communal.data.repository.FakeCommunalPrefsRepository
import com.android.systemui.communal.data.repository.FakeCommunalRepository
import com.android.systemui.communal.data.repository.FakeCommunalTutorialRepository
import com.android.systemui.communal.data.repository.FakeCommunalWidgetRepository
@@ -42,6 +43,7 @@
mediaRepository: FakeCommunalMediaRepository = FakeCommunalMediaRepository(),
smartspaceRepository: FakeSmartspaceRepository = FakeSmartspaceRepository(),
tutorialRepository: FakeCommunalTutorialRepository = FakeCommunalTutorialRepository(),
+ communalPrefsRepository: FakeCommunalPrefsRepository = FakeCommunalPrefsRepository(),
appWidgetHost: AppWidgetHost = mock(),
editWidgetsActivityStarter: EditWidgetsActivityStarter = mock(),
): WithDependencies {
@@ -55,6 +57,7 @@
testScope,
communalRepository,
widgetRepository,
+ communalPrefsRepository,
mediaRepository,
smartspaceRepository,
tutorialRepository,
@@ -66,6 +69,7 @@
CommunalInteractor(
communalRepository,
widgetRepository,
+ communalPrefsRepository,
mediaRepository,
smartspaceRepository,
withDeps.keyguardInteractor,
@@ -79,6 +83,7 @@
val testScope: TestScope,
val communalRepository: FakeCommunalRepository,
val widgetRepository: FakeCommunalWidgetRepository,
+ val communalPrefsRepository: FakeCommunalPrefsRepository,
val mediaRepository: FakeCommunalMediaRepository,
val smartspaceRepository: FakeSmartspaceRepository,
val tutorialRepository: FakeCommunalTutorialRepository,
diff --git a/packages/SystemUI/tests/utils/src/com/android/systemui/communal/domain/interactor/CommunalInteractorKosmos.kt b/packages/SystemUI/tests/utils/src/com/android/systemui/communal/domain/interactor/CommunalInteractorKosmos.kt
index 649b373..7cbbaab 100644
--- a/packages/SystemUI/tests/utils/src/com/android/systemui/communal/domain/interactor/CommunalInteractorKosmos.kt
+++ b/packages/SystemUI/tests/utils/src/com/android/systemui/communal/domain/interactor/CommunalInteractorKosmos.kt
@@ -17,6 +17,7 @@
package com.android.systemui.communal.domain.interactor
import com.android.systemui.communal.data.repository.communalMediaRepository
+import com.android.systemui.communal.data.repository.communalPrefsRepository
import com.android.systemui.communal.data.repository.communalRepository
import com.android.systemui.communal.data.repository.communalWidgetRepository
import com.android.systemui.keyguard.domain.interactor.keyguardInteractor
@@ -30,6 +31,7 @@
communalRepository = communalRepository,
widgetRepository = communalWidgetRepository,
mediaRepository = communalMediaRepository,
+ communalPrefsRepository = communalPrefsRepository,
smartspaceRepository = smartspaceRepository,
appWidgetHost = mock(),
keyguardInteractor = keyguardInteractor,
diff --git a/packages/SystemUI/tests/utils/src/com/android/systemui/keyguard/domain/interactor/CommunalInteractorKosmos.kt b/packages/SystemUI/tests/utils/src/com/android/systemui/keyguard/domain/interactor/CommunalInteractorKosmos.kt
index 59f0ec3..37b1b08 100644
--- a/packages/SystemUI/tests/utils/src/com/android/systemui/keyguard/domain/interactor/CommunalInteractorKosmos.kt
+++ b/packages/SystemUI/tests/utils/src/com/android/systemui/keyguard/domain/interactor/CommunalInteractorKosmos.kt
@@ -18,6 +18,7 @@
import android.appwidget.AppWidgetHost
import com.android.systemui.communal.data.repository.communalMediaRepository
+import com.android.systemui.communal.data.repository.communalPrefsRepository
import com.android.systemui.communal.data.repository.communalRepository
import com.android.systemui.communal.data.repository.communalWidgetRepository
import com.android.systemui.communal.domain.interactor.CommunalInteractor
@@ -32,6 +33,7 @@
communalRepository = communalRepository,
widgetRepository = communalWidgetRepository,
mediaRepository = communalMediaRepository,
+ communalPrefsRepository = communalPrefsRepository,
smartspaceRepository = smartspaceRepository,
keyguardInteractor = keyguardInteractor,
appWidgetHost = mock(AppWidgetHost::class.java),
diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/collection/EntryUtil.kt b/packages/SystemUI/tests/utils/src/com/android/systemui/statusbar/notification/collection/EntryUtil.kt
similarity index 100%
rename from packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/collection/EntryUtil.kt
rename to packages/SystemUI/tests/utils/src/com/android/systemui/statusbar/notification/collection/EntryUtil.kt
diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/collection/GroupEntryBuilder.java b/packages/SystemUI/tests/utils/src/com/android/systemui/statusbar/notification/collection/GroupEntryBuilder.java
similarity index 90%
rename from packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/collection/GroupEntryBuilder.java
rename to packages/SystemUI/tests/utils/src/com/android/systemui/statusbar/notification/collection/GroupEntryBuilder.java
index dda7fad..4efcada 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/collection/GroupEntryBuilder.java
+++ b/packages/SystemUI/tests/utils/src/com/android/systemui/statusbar/notification/collection/GroupEntryBuilder.java
@@ -52,32 +52,38 @@
return ge;
}
+ /** Sets the group key. */
public GroupEntryBuilder setKey(String key) {
mKey = key;
return this;
}
+ /** Sets the creation time. */
public GroupEntryBuilder setCreationTime(long creationTime) {
mCreationTime = creationTime;
return this;
}
+ /** Sets the parent entry of the group. */
public GroupEntryBuilder setParent(@Nullable GroupEntry entry) {
mParent = entry;
return this;
}
+ /** Sets the section the group belongs to. */
public GroupEntryBuilder setSection(@Nullable NotifSection section) {
mNotifSection = section;
return this;
}
+ /** Sets the group summary. */
public GroupEntryBuilder setSummary(
NotificationEntry summary) {
mSummary = summary;
return this;
}
+ /** Sets the group children. */
public GroupEntryBuilder setChildren(List<NotificationEntry> children) {
mChildren.clear();
mChildren.addAll(children);
@@ -90,6 +96,7 @@
return this;
}
+ /** Get the group's internal children list. */
public static List<NotificationEntry> getRawChildren(GroupEntry groupEntry) {
return groupEntry.getRawChildren();
}
diff --git a/packages/SystemUI/tests/utils/src/com/android/systemui/statusbar/notification/stack/ui/viewmodel/NotificationsPlaceholderViewModelKosmos.kt b/packages/SystemUI/tests/utils/src/com/android/systemui/statusbar/notification/stack/ui/viewmodel/NotificationsPlaceholderViewModelKosmos.kt
index 0dbade7..d7e948e 100644
--- a/packages/SystemUI/tests/utils/src/com/android/systemui/statusbar/notification/stack/ui/viewmodel/NotificationsPlaceholderViewModelKosmos.kt
+++ b/packages/SystemUI/tests/utils/src/com/android/systemui/statusbar/notification/stack/ui/viewmodel/NotificationsPlaceholderViewModelKosmos.kt
@@ -20,11 +20,13 @@
import com.android.systemui.kosmos.Kosmos
import com.android.systemui.kosmos.Kosmos.Fixture
import com.android.systemui.scene.shared.flag.sceneContainerFlags
+import com.android.systemui.shade.domain.interactor.shadeInteractor
import com.android.systemui.statusbar.notification.stack.domain.interactor.notificationStackAppearanceInteractor
val Kosmos.notificationsPlaceholderViewModel by Fixture {
NotificationsPlaceholderViewModel(
interactor = notificationStackAppearanceInteractor,
+ shadeInteractor = shadeInteractor,
flags = sceneContainerFlags,
featureFlags = featureFlagsClassic,
)
diff --git a/packages/SystemUI/tests/utils/src/com/android/systemui/statusbar/notification/stack/ui/viewmodel/WindowRootViewVisibilityInteractorKosmos.kt b/packages/SystemUI/tests/utils/src/com/android/systemui/statusbar/notification/stack/ui/viewmodel/WindowRootViewVisibilityInteractorKosmos.kt
index d9beabb..d80ee75 100644
--- a/packages/SystemUI/tests/utils/src/com/android/systemui/statusbar/notification/stack/ui/viewmodel/WindowRootViewVisibilityInteractorKosmos.kt
+++ b/packages/SystemUI/tests/utils/src/com/android/systemui/statusbar/notification/stack/ui/viewmodel/WindowRootViewVisibilityInteractorKosmos.kt
@@ -23,6 +23,7 @@
import com.android.systemui.power.domain.interactor.powerInteractor
import com.android.systemui.scene.data.repository.windowRootViewVisibilityRepository
import com.android.systemui.scene.domain.interactor.WindowRootViewVisibilityInteractor
+import com.android.systemui.statusbar.notification.domain.interactor.activeNotificationsInteractor
import com.android.systemui.statusbar.policy.headsUpManager
val Kosmos.windowRootViewVisibilityInteractor by Fixture {
@@ -32,5 +33,6 @@
keyguardRepository = keyguardRepository,
headsUpManager = headsUpManager,
powerInteractor = powerInteractor,
+ activeNotificationsInteractor = activeNotificationsInteractor,
)
}
diff --git a/services/autofill/java/com/android/server/autofill/Session.java b/services/autofill/java/com/android/server/autofill/Session.java
index a856f42..f3b74ea 100644
--- a/services/autofill/java/com/android/server/autofill/Session.java
+++ b/services/autofill/java/com/android/server/autofill/Session.java
@@ -1735,6 +1735,7 @@
processResponseLockedForPcc(response, response.getClientState(), requestFlags);
mFillResponseEventLogger.maybeSetLatencyResponseProcessingMillis();
+ mFillResponseEventLogger.logAndEndEvent();
}
@@ -1847,6 +1848,33 @@
return;
}
synchronized (mLock) {
+ // TODO(b/319913595): refactor logging for fill response for primary and secondary
+ // providers
+ // Start a new FillResponse logger for the success case.
+ mFillResponseEventLogger.startLogForNewResponse();
+ mFillResponseEventLogger.maybeSetRequestId(fillResponse.getRequestId());
+ mFillResponseEventLogger.maybeSetAppPackageUid(uid);
+ mFillResponseEventLogger.maybeSetResponseStatus(RESPONSE_STATUS_SUCCESS);
+ mFillResponseEventLogger.startResponseProcessingTime();
+ // Time passed since session was created
+ final long fillRequestReceivedRelativeTimestamp =
+ SystemClock.elapsedRealtime() - mLatencyBaseTime;
+ mPresentationStatsEventLogger.maybeSetFillResponseReceivedTimestampMs(
+ (int) (fillRequestReceivedRelativeTimestamp));
+ mFillResponseEventLogger.maybeSetLatencyFillResponseReceivedMillis(
+ (int) (fillRequestReceivedRelativeTimestamp));
+ if (mDestroyed) {
+ Slog.w(TAG, "Call to Session#onSecondaryFillResponse() rejected - session: "
+ + id + " destroyed");
+ mFillResponseEventLogger.maybeSetResponseStatus(RESPONSE_STATUS_SESSION_DESTROYED);
+ mFillResponseEventLogger.logAndEndEvent();
+ return;
+ }
+
+ List<Dataset> datasetList = fillResponse.getDatasets();
+ int datasetCount = (datasetList == null) ? 0 : datasetList.size();
+ mFillResponseEventLogger.maybeSetTotalDatasetsProvided(datasetCount);
+ mFillResponseEventLogger.maybeSetAvailableCount(datasetCount);
if (mSecondaryResponses == null) {
mSecondaryResponses = new SparseArray<>(2);
}
@@ -1859,6 +1887,8 @@
if (currentView != null) {
currentView.maybeCallOnFillReady(flags);
}
+ mFillResponseEventLogger.maybeSetLatencyResponseProcessingMillis();
+ mFillResponseEventLogger.logAndEndEvent();
}
}
diff --git a/services/companion/java/com/android/server/companion/CompanionDeviceManagerService.java b/services/companion/java/com/android/server/companion/CompanionDeviceManagerService.java
index 056ec89..50e1862 100644
--- a/services/companion/java/com/android/server/companion/CompanionDeviceManagerService.java
+++ b/services/companion/java/com/android/server/companion/CompanionDeviceManagerService.java
@@ -21,6 +21,7 @@
import static android.Manifest.permission.DELIVER_COMPANION_MESSAGES;
import static android.Manifest.permission.MANAGE_COMPANION_DEVICES;
import static android.Manifest.permission.REQUEST_OBSERVE_COMPANION_DEVICE_PRESENCE;
+import static android.Manifest.permission.REQUEST_COMPANION_PROFILE_AUTOMOTIVE_PROJECTION;
import static android.Manifest.permission.USE_COMPANION_TRANSPORTS;
import static android.app.ActivityManager.RunningAppProcessInfo.IMPORTANCE_VISIBLE;
import static android.companion.AssociationRequest.DEVICE_PROFILE_AUTOMOTIVE_PROJECTION;
@@ -82,6 +83,7 @@
import android.content.pm.PackageManager;
import android.content.pm.PackageManagerInternal;
import android.content.pm.UserInfo;
+import android.hardware.power.Mode;
import android.net.MacAddress;
import android.net.NetworkPolicyManager;
import android.os.Binder;
@@ -90,6 +92,7 @@
import android.os.Message;
import android.os.Parcel;
import android.os.ParcelFileDescriptor;
+import android.os.PowerManagerInternal;
import android.os.PowerWhitelistManager;
import android.os.RemoteCallbackList;
import android.os.RemoteException;
@@ -175,6 +178,7 @@
private final PowerWhitelistManager mPowerWhitelistManager;
private final UserManager mUserManager;
final PackageManagerInternal mPackageManagerInternal;
+ private final PowerManagerInternal mPowerManagerInternal;
/**
* A structure that consists of two nested maps, and effectively maps (userId + packageName) to
@@ -235,6 +239,7 @@
mOnPackageVisibilityChangeListener =
new OnPackageVisibilityChangeListener(mActivityManager);
+ mPowerManagerInternal = LocalServices.getService(PowerManagerInternal.class);
}
@Override
@@ -949,6 +954,10 @@
mAssociationStore.updateAssociation(association);
mDevicePresenceMonitor.onSelfManagedDeviceConnected(associationId);
+
+ if (association.getDeviceProfile() == REQUEST_COMPANION_PROFILE_AUTOMOTIVE_PROJECTION) {
+ mPowerManagerInternal.setPowerMode(Mode.AUTOMOTIVE_PROJECTION, true);
+ }
}
@Override
@@ -963,6 +972,10 @@
}
mDevicePresenceMonitor.onSelfManagedDeviceDisconnected(associationId);
+
+ if (association.getDeviceProfile() == REQUEST_COMPANION_PROFILE_AUTOMOTIVE_PROJECTION) {
+ mPowerManagerInternal.setPowerMode(Mode.AUTOMOTIVE_PROJECTION, false);
+ }
}
@Override
diff --git a/services/companion/java/com/android/server/companion/transport/SecureTransport.java b/services/companion/java/com/android/server/companion/transport/SecureTransport.java
index a0301a9..6e906eb 100644
--- a/services/companion/java/com/android/server/companion/transport/SecureTransport.java
+++ b/services/companion/java/com/android/server/companion/transport/SecureTransport.java
@@ -34,7 +34,7 @@
private volatile boolean mShouldProcessRequests = false;
- private final BlockingQueue<byte[]> mRequestQueue = new ArrayBlockingQueue<>(100);
+ private final BlockingQueue<byte[]> mRequestQueue = new ArrayBlockingQueue<>(500);
SecureTransport(int associationId, ParcelFileDescriptor fd, Context context) {
super(associationId, fd, context);
diff --git a/services/core/java/com/android/server/StorageManagerService.java b/services/core/java/com/android/server/StorageManagerService.java
index 7a4ac6a..2b35231 100644
--- a/services/core/java/com/android/server/StorageManagerService.java
+++ b/services/core/java/com/android/server/StorageManagerService.java
@@ -5040,9 +5040,9 @@
@Override
public IFsveritySetupAuthToken createFsveritySetupAuthToken(ParcelFileDescriptor authFd,
- int appUid, @UserIdInt int userId) throws IOException {
+ int uid) throws IOException {
try {
- return mInstaller.createFsveritySetupAuthToken(authFd, appUid, userId);
+ return mInstaller.createFsveritySetupAuthToken(authFd, uid);
} catch (Installer.InstallerException e) {
throw new IOException(e);
}
diff --git a/services/core/java/com/android/server/TelephonyRegistry.java b/services/core/java/com/android/server/TelephonyRegistry.java
index eb6fdd7..f921b0b 100644
--- a/services/core/java/com/android/server/TelephonyRegistry.java
+++ b/services/core/java/com/android/server/TelephonyRegistry.java
@@ -418,6 +418,8 @@
LinkCapacityEstimate.INVALID, LinkCapacityEstimate.INVALID)));
private List<List<LinkCapacityEstimate>> mLinkCapacityEstimateLists;
+ private int[] mSimultaneousCellularCallingSubIds = {};
+
private int[] mECBMReason;
private boolean[] mECBMStarted;
private int[] mSCBMReason;
@@ -564,7 +566,9 @@
|| events.contains(TelephonyCallback.EVENT_VOICE_ACTIVATION_STATE_CHANGED)
|| events.contains(TelephonyCallback.EVENT_RADIO_POWER_STATE_CHANGED)
|| events.contains(TelephonyCallback.EVENT_ALLOWED_NETWORK_TYPE_LIST_CHANGED)
- || events.contains(TelephonyCallback.EVENT_EMERGENCY_CALLBACK_MODE_CHANGED);
+ || events.contains(TelephonyCallback.EVENT_EMERGENCY_CALLBACK_MODE_CHANGED)
+ || events.contains(TelephonyCallback
+ .EVENT_SIMULTANEOUS_CELLULAR_CALLING_SUBSCRIPTIONS_CHANGED);
}
private static final int MSG_USER_SWITCHED = 1;
@@ -1427,6 +1431,15 @@
remove(r.binder);
}
}
+ if (events.contains(TelephonyCallback
+ .EVENT_SIMULTANEOUS_CELLULAR_CALLING_SUBSCRIPTIONS_CHANGED)) {
+ try {
+ r.callback.onSimultaneousCallingStateChanged(
+ mSimultaneousCellularCallingSubIds);
+ } catch (RemoteException ex) {
+ remove(r.binder);
+ }
+ }
if (events.contains(
TelephonyCallback.EVENT_LINK_CAPACITY_ESTIMATE_CHANGED)) {
try {
@@ -3092,6 +3105,43 @@
}
}
+ /**
+ * Notify the listeners that simultaneous cellular calling subscriptions have changed
+ * @param subIds The set of subIds that support simultaneous cellular calling
+ */
+ public void notifySimultaneousCellularCallingSubscriptionsChanged(int[] subIds) {
+ if (!checkNotifyPermission("notifySimultaneousCellularCallingSubscriptionsChanged()")) {
+ return;
+ }
+
+ if (VDBG) {
+ StringBuilder b = new StringBuilder();
+ b.append("notifySimultaneousCellularCallingSubscriptionsChanged: ");
+ b.append("subIds = {");
+ for (int i : subIds) {
+ b.append(" ");
+ b.append(i);
+ }
+ b.append("}");
+ log(b.toString());
+ }
+
+ synchronized (mRecords) {
+ mSimultaneousCellularCallingSubIds = subIds;
+ for (Record r : mRecords) {
+ if (r.matchTelephonyCallbackEvent(TelephonyCallback
+ .EVENT_SIMULTANEOUS_CELLULAR_CALLING_SUBSCRIPTIONS_CHANGED)) {
+ try {
+ r.callback.onSimultaneousCallingStateChanged(subIds);
+ } catch (RemoteException ex) {
+ mRemoveList.add(r.binder);
+ }
+ }
+ }
+ handleRemoveListLocked();
+ }
+ }
+
@Override
public void addCarrierPrivilegesCallback(
int phoneId,
diff --git a/services/core/java/com/android/server/Watchdog.java b/services/core/java/com/android/server/Watchdog.java
index fd17261..c18bacb 100644
--- a/services/core/java/com/android/server/Watchdog.java
+++ b/services/core/java/com/android/server/Watchdog.java
@@ -172,6 +172,7 @@
public static final String[] AIDL_INTERFACE_PREFIXES_OF_INTEREST = new String[] {
"android.hardware.audio.core.IModule/",
"android.hardware.audio.core.IConfig/",
+ "android.hardware.audio.effect.IFactory/",
"android.hardware.biometrics.face.IFace/",
"android.hardware.biometrics.fingerprint.IFingerprint/",
"android.hardware.bluetooth.IBluetoothHci/",
diff --git a/services/core/java/com/android/server/am/ProcessList.java b/services/core/java/com/android/server/am/ProcessList.java
index b03183c..fa5dbd2 100644
--- a/services/core/java/com/android/server/am/ProcessList.java
+++ b/services/core/java/com/android/server/am/ProcessList.java
@@ -2935,7 +2935,11 @@
return true;
}
- private static void freezeBinderAndPackageCgroup(ArrayList<Pair<ProcessRecord, Boolean>> procs,
+ private static boolean unfreezePackageCgroup(int packageUID) {
+ return freezePackageCgroup(packageUID, false);
+ }
+
+ private static void freezeBinderAndPackageCgroup(List<Pair<ProcessRecord, Boolean>> procs,
int packageUID) {
// Freeze all binder processes under the target UID (whose cgroup is about to be frozen).
// Since we're going to kill these, we don't need to unfreze them later.
@@ -2943,12 +2947,9 @@
// processes (forks) should not be Binder users.
int N = procs.size();
for (int i = 0; i < N; i++) {
- final int uid = procs.get(i).first.uid;
final int pid = procs.get(i).first.getPid();
int nRetries = 0;
- // We only freeze the cgroup of the target package, so we do not need to freeze the
- // Binder interfaces of dependant processes in other UIDs.
- if (pid > 0 && uid == packageUID) {
+ if (pid > 0) {
try {
int rc;
do {
@@ -2962,12 +2963,19 @@
}
// We freeze the entire UID (parent) cgroup so that newly-specialized processes also freeze
- // despite being added to a new child cgroup. The cgroups of package dependant processes are
- // not frozen, since it's possible this would freeze processes with no dependency on the
- // package being killed here.
+ // despite being added to a child cgroup created after this call that would otherwise be
+ // unfrozen.
freezePackageCgroup(packageUID, true);
}
+ private static List<Pair<ProcessRecord, Boolean>> getUIDSublist(
+ List<Pair<ProcessRecord, Boolean>> procs, int startIdx) {
+ final int uid = procs.get(startIdx).first.uid;
+ int endIdx = startIdx + 1;
+ while (endIdx < procs.size() && procs.get(endIdx).first.uid == uid) ++endIdx;
+ return procs.subList(startIdx, endIdx);
+ }
+
@GuardedBy({"mService", "mProcLock"})
boolean killPackageProcessesLSP(String packageName, int appId,
int userId, int minOomAdj, boolean callerWillRestart, boolean allowRestart,
@@ -3063,25 +3071,36 @@
}
}
- final int packageUID = UserHandle.getUid(userId, appId);
- final boolean doFreeze = appId >= Process.FIRST_APPLICATION_UID
- && appId <= Process.LAST_APPLICATION_UID;
- if (doFreeze) {
- freezeBinderAndPackageCgroup(procs, packageUID);
+ final boolean killingUserApp = appId >= Process.FIRST_APPLICATION_UID
+ && appId <= Process.LAST_APPLICATION_UID;
+
+ if (killingUserApp) {
+ procs.sort((o1, o2) -> Integer.compare(o1.first.uid, o2.first.uid));
}
- int N = procs.size();
- for (int i=0; i<N; i++) {
- final Pair<ProcessRecord, Boolean> proc = procs.get(i);
- removeProcessLocked(proc.first, callerWillRestart, allowRestart || proc.second,
- reasonCode, subReason, reason, !doFreeze /* async */);
+ int idx = 0;
+ while (idx < procs.size()) {
+ final List<Pair<ProcessRecord, Boolean>> uidProcs = getUIDSublist(procs, idx);
+ final int packageUID = uidProcs.get(0).first.uid;
+
+ // Do not freeze for system apps or for dependencies of the targeted package, but
+ // make sure to freeze the targeted package for all users if called with USER_ALL.
+ final boolean doFreeze = killingUserApp && UserHandle.getAppId(packageUID) == appId;
+
+ if (doFreeze) freezeBinderAndPackageCgroup(uidProcs, packageUID);
+
+ for (Pair<ProcessRecord, Boolean> proc : uidProcs) {
+ removeProcessLocked(proc.first, callerWillRestart, allowRestart || proc.second,
+ reasonCode, subReason, reason, !doFreeze /* async */);
+ }
+ killAppZygotesLocked(packageName, appId, userId, false /* force */);
+
+ if (doFreeze) unfreezePackageCgroup(packageUID);
+
+ idx += uidProcs.size();
}
- killAppZygotesLocked(packageName, appId, userId, false /* force */);
mService.updateOomAdjLocked(OOM_ADJ_REASON_PROCESS_END);
- if (doFreeze) {
- freezePackageCgroup(packageUID, false);
- }
- return N > 0;
+ return procs.size() > 0;
}
@GuardedBy("mService")
diff --git a/services/core/java/com/android/server/app/GameManagerSettings.java b/services/core/java/com/android/server/app/GameManagerSettings.java
index 5189017..b084cf3 100644
--- a/services/core/java/com/android/server/app/GameManagerSettings.java
+++ b/services/core/java/com/android/server/app/GameManagerSettings.java
@@ -251,6 +251,7 @@
+ type);
}
}
+ str.close();
} catch (XmlPullParserException | java.io.IOException e) {
Slog.wtf(TAG, "Error reading game manager settings", e);
return false;
diff --git a/services/core/java/com/android/server/appop/AppOpsService.java b/services/core/java/com/android/server/appop/AppOpsService.java
index df8d9e1..8fa0089 100644
--- a/services/core/java/com/android/server/appop/AppOpsService.java
+++ b/services/core/java/com/android/server/appop/AppOpsService.java
@@ -65,6 +65,9 @@
import static android.app.AppOpsManager.opToName;
import static android.app.AppOpsManager.opToPublicName;
import static android.companion.virtual.VirtualDeviceManager.PERSISTENT_DEVICE_ID_DEFAULT;
+import static android.content.Intent.ACTION_PACKAGE_ADDED;
+import static android.content.Intent.ACTION_PACKAGE_REMOVED;
+import static android.content.Intent.EXTRA_REPLACING;
import static android.content.pm.PermissionInfo.PROTECTION_DANGEROUS;
import static android.content.pm.PermissionInfo.PROTECTION_FLAG_APPOP;
@@ -973,7 +976,29 @@
String pkgName = intent.getData().getEncodedSchemeSpecificPart();
int uid = intent.getIntExtra(Intent.EXTRA_UID, Process.INVALID_UID);
- if (action.equals(Intent.ACTION_PACKAGE_REPLACED)) {
+ if (action.equals(ACTION_PACKAGE_ADDED)
+ && !intent.getBooleanExtra(EXTRA_REPLACING, false)) {
+ PackageInfo pi = getPackageManagerInternal().getPackageInfo(pkgName,
+ PackageManager.GET_PERMISSIONS, Process.myUid(),
+ UserHandle.getUserId(uid));
+ boolean isSamplingTarget = isSamplingTarget(pi);
+ synchronized (AppOpsService.this) {
+ if (isSamplingTarget) {
+ mRarelyUsedPackages.add(pkgName);
+ }
+ UidState uidState = getUidStateLocked(uid, true);
+ if (!uidState.pkgOps.containsKey(pkgName)) {
+ uidState.pkgOps.put(pkgName,
+ new Ops(pkgName, uidState));
+ }
+
+ createSandboxUidStateIfNotExistsForAppLocked(uid);
+ }
+ } else if (action.equals(ACTION_PACKAGE_REMOVED) && !intent.hasExtra(EXTRA_REPLACING)) {
+ synchronized (AppOpsService.this) {
+ packageRemovedLocked(uid, pkgName);
+ }
+ } else if (action.equals(Intent.ACTION_PACKAGE_REPLACED)) {
AndroidPackage pkg = getPackageManagerInternal().getPackage(pkgName);
if (pkg == null) {
return;
@@ -1052,7 +1077,9 @@
mHistoricalRegistry.systemReady(mContext.getContentResolver());
IntentFilter packageUpdateFilter = new IntentFilter();
+ packageUpdateFilter.addAction(ACTION_PACKAGE_ADDED);
packageUpdateFilter.addAction(Intent.ACTION_PACKAGE_REPLACED);
+ packageUpdateFilter.addAction(ACTION_PACKAGE_REMOVED);
packageUpdateFilter.addDataScheme("package");
mContext.registerReceiverAsUser(mOnPackageUpdatedReceiver, UserHandle.ALL,
@@ -1079,7 +1106,7 @@
String action;
if (!ArrayUtils.contains(pkgsInUid, pkg)) {
- action = Intent.ACTION_PACKAGE_REMOVED;
+ action = ACTION_PACKAGE_REMOVED;
} else {
action = Intent.ACTION_PACKAGE_REPLACED;
}
@@ -1160,44 +1187,6 @@
// onUserRemoved handled by #removeUser
});
-
- getPackageManagerInternal().getPackageList(
- new PackageManagerInternal.PackageListObserver() {
- @Override
- public void onPackageAdded(String packageName, int appId) {
- PackageInfo pi = getPackageManagerInternal().getPackageInfo(packageName,
- PackageManager.GET_PERMISSIONS, Process.myUid(),
- mContext.getUserId());
- boolean isSamplingTarget = isSamplingTarget(pi);
- int[] userIds = getUserManagerInternal().getUserIds();
- synchronized (AppOpsService.this) {
- if (isSamplingTarget) {
- mRarelyUsedPackages.add(packageName);
- }
- for (int i = 0; i < userIds.length; i++) {
- int uid = UserHandle.getUid(userIds[i], appId);
- UidState uidState = getUidStateLocked(uid, true);
- if (!uidState.pkgOps.containsKey(packageName)) {
- uidState.pkgOps.put(packageName,
- new Ops(packageName, uidState));
- }
-
- createSandboxUidStateIfNotExistsForAppLocked(uid);
- }
- }
- }
-
- @Override
- public void onPackageRemoved(String packageName, int appId) {
- int[] userIds = getUserManagerInternal().getUserIds();
- synchronized (AppOpsService.this) {
- for (int i = 0; i < userIds.length; i++) {
- int uid = UserHandle.getUid(userIds[i], appId);
- packageRemovedLocked(uid, packageName);
- }
- }
- }
- });
}
/**
diff --git a/services/core/java/com/android/server/audio/AudioDeviceBroker.java b/services/core/java/com/android/server/audio/AudioDeviceBroker.java
index f80228a..99b45ec 100644
--- a/services/core/java/com/android/server/audio/AudioDeviceBroker.java
+++ b/services/core/java/com/android/server/audio/AudioDeviceBroker.java
@@ -1812,22 +1812,21 @@
"msg: MSG_L_SET_BT_ACTIVE_DEVICE "
+ "received with null profile proxy: "
+ btInfo)).printLog(TAG));
- sendMsg(MSG_CHECK_MUTE_MUSIC, SENDMSG_REPLACE, 0 /*delay*/);
- return;
- }
- @AudioSystem.AudioFormatNativeEnumForBtCodec final int codec =
- mBtHelper.getCodecWithFallback(btInfo.mDevice,
- btInfo.mProfile, btInfo.mIsLeOutput,
- "MSG_L_SET_BT_ACTIVE_DEVICE");
- mDeviceInventory.onSetBtActiveDevice(btInfo, codec,
- (btInfo.mProfile
- != BluetoothProfile.LE_AUDIO || btInfo.mIsLeOutput)
- ? mAudioService.getBluetoothContextualVolumeStream()
- : AudioSystem.STREAM_DEFAULT);
- if (btInfo.mProfile == BluetoothProfile.LE_AUDIO
- || btInfo.mProfile == BluetoothProfile.HEARING_AID) {
- onUpdateCommunicationRouteClient(isBluetoothScoRequested(),
- "setBluetoothActiveDevice");
+ } else {
+ @AudioSystem.AudioFormatNativeEnumForBtCodec final int codec =
+ mBtHelper.getCodecWithFallback(btInfo.mDevice,
+ btInfo.mProfile, btInfo.mIsLeOutput,
+ "MSG_L_SET_BT_ACTIVE_DEVICE");
+ mDeviceInventory.onSetBtActiveDevice(btInfo, codec,
+ (btInfo.mProfile
+ != BluetoothProfile.LE_AUDIO || btInfo.mIsLeOutput)
+ ? mAudioService.getBluetoothContextualVolumeStream()
+ : AudioSystem.STREAM_DEFAULT);
+ if (btInfo.mProfile == BluetoothProfile.LE_AUDIO
+ || btInfo.mProfile == BluetoothProfile.HEARING_AID) {
+ onUpdateCommunicationRouteClient(isBluetoothScoRequested(),
+ "setBluetoothActiveDevice");
+ }
}
}
}
diff --git a/services/core/java/com/android/server/audio/AudioDeviceInventory.java b/services/core/java/com/android/server/audio/AudioDeviceInventory.java
index bf20ae3..57b19cd 100644
--- a/services/core/java/com/android/server/audio/AudioDeviceInventory.java
+++ b/services/core/java/com/android/server/audio/AudioDeviceInventory.java
@@ -764,7 +764,7 @@
/** only public for mocking/spying, do not call outside of AudioService */
// @GuardedBy("mDeviceBroker.mSetModeLock")
@VisibleForTesting
- @GuardedBy("mDeviceBroker.mDeviceStateLock")
+ //@GuardedBy("AudioDeviceBroker.this.mDeviceStateLock")
public void onSetBtActiveDevice(@NonNull AudioDeviceBroker.BtDeviceInfo btInfo,
@AudioSystem.AudioFormatNativeEnumForBtCodec int codec,
int streamType) {
diff --git a/services/core/java/com/android/server/broadcastradio/TEST_MAPPING b/services/core/java/com/android/server/broadcastradio/TEST_MAPPING
new file mode 100644
index 0000000..ee4eeb6
--- /dev/null
+++ b/services/core/java/com/android/server/broadcastradio/TEST_MAPPING
@@ -0,0 +1,7 @@
+{
+ "imports": [
+ {
+ "path": "frameworks/base/core/tests/BroadcastRadioTests"
+ }
+ ]
+}
diff --git a/services/core/java/com/android/server/hdmi/HdmiCecLocalDeviceTv.java b/services/core/java/com/android/server/hdmi/HdmiCecLocalDeviceTv.java
index 1cd267d..d34661d 100644
--- a/services/core/java/com/android/server/hdmi/HdmiCecLocalDeviceTv.java
+++ b/services/core/java/com/android/server/hdmi/HdmiCecLocalDeviceTv.java
@@ -1290,15 +1290,19 @@
mService.getHdmiCecNetwork().removeCecSwitches(portId);
}
- // Turning System Audio Mode off when the AVR is unlugged or standby.
- // When the device is not unplugged but reawaken from standby, we check if the System
- // Audio Control Feature is enabled or not then decide if turning SAM on/off accordingly.
- if (getAvrDeviceInfo() != null && portId == getAvrDeviceInfo().getPortId()) {
- HdmiLogger.debug("Port ID:%d, 5v=%b", portId, connected);
- if (!connected) {
- setSystemAudioMode(false);
- } else {
- onNewAvrAdded(getAvrDeviceInfo());
+ if (!mService.isEarcEnabled() || !mService.isEarcSupported()) {
+ HdmiDeviceInfo avr = getAvrDeviceInfo();
+ if (avr != null
+ && portId == avr.getPortId()
+ && isConnectedToArcPort(avr.getPhysicalAddress())) {
+ HdmiLogger.debug("Port ID:%d, 5v=%b", portId, connected);
+ if (connected) {
+ if (mArcEstablished) {
+ enableAudioReturnChannel(true);
+ }
+ } else {
+ enableAudioReturnChannel(false);
+ }
}
}
diff --git a/services/core/java/com/android/server/hdmi/HdmiControlService.java b/services/core/java/com/android/server/hdmi/HdmiControlService.java
index eaf754d..e0e825d 100644
--- a/services/core/java/com/android/server/hdmi/HdmiControlService.java
+++ b/services/core/java/com/android/server/hdmi/HdmiControlService.java
@@ -3617,7 +3617,7 @@
}
}
- @VisibleForTesting
+ @VisibleForTesting(visibility = VisibleForTesting.Visibility.PACKAGE)
protected boolean isEarcSupported() {
synchronized (mLock) {
return mEarcSupported;
diff --git a/services/core/java/com/android/server/hdmi/NewDeviceAction.java b/services/core/java/com/android/server/hdmi/NewDeviceAction.java
index f3532e5..b6c0e5d 100644
--- a/services/core/java/com/android/server/hdmi/NewDeviceAction.java
+++ b/services/core/java/com/android/server/hdmi/NewDeviceAction.java
@@ -53,6 +53,7 @@
private int mVendorId;
private String mDisplayName;
private int mTimeoutRetry;
+ private HdmiDeviceInfo mOldDeviceInfo;
/**
* Constructor.
@@ -73,6 +74,38 @@
@Override
public boolean start() {
+ mOldDeviceInfo =
+ localDevice().mService.getHdmiCecNetwork().getCecDeviceInfo(mDeviceLogicalAddress);
+ // If there's deviceInfo with same (logical address, physical address) set
+ // Then addCecDevice should be delayed until system information process is finished
+ if (mOldDeviceInfo != null
+ && mOldDeviceInfo.getPhysicalAddress() == mDevicePhysicalAddress) {
+ Slog.d(TAG, "Start NewDeviceAction with old deviceInfo:["
+ + mOldDeviceInfo.toString() + "]");
+ } else {
+ // Add the device ahead with default information to handle <Active Source>
+ // promptly, rather than waiting till the new device action is finished.
+ Slog.d(TAG, "Start NewDeviceAction with default deviceInfo");
+ HdmiDeviceInfo deviceInfo = HdmiDeviceInfo.cecDeviceBuilder()
+ .setLogicalAddress(mDeviceLogicalAddress)
+ .setPhysicalAddress(mDevicePhysicalAddress)
+ .setPortId(tv().getPortId(mDevicePhysicalAddress))
+ .setDeviceType(mDeviceType)
+ .setVendorId(Constants.VENDOR_ID_UNKNOWN)
+ .build();
+ // If a deviceInfo with same logical address but different physical address exists
+ // We should remove the old deviceInfo first
+ // This will happen if the interval between unplugging and plugging device is too short
+ // and HotplugDetection Action fails to remove the old deviceInfo, or when the newly
+ // plugged device violates HDMI Spec and uses an occupied logical address
+ if (mOldDeviceInfo != null) {
+ Slog.d(TAG, "Remove device by NewDeviceAction, logical address conflicts: "
+ + mDevicePhysicalAddress);
+ localDevice().mService.getHdmiCecNetwork().removeCecDevice(
+ localDevice(), mDeviceLogicalAddress);
+ }
+ localDevice().mService.getHdmiCecNetwork().addCecDevice(deviceInfo);
+ }
requestOsdName(true);
return true;
}
@@ -182,14 +215,30 @@
.setVendorId(mVendorId)
.setDisplayName(mDisplayName)
.build();
- localDevice().mService.getHdmiCecNetwork().updateCecDevice(deviceInfo);
- // Consume CEC messages we already got for this newly found device.
- tv().processDelayedMessages(mDeviceLogicalAddress);
+ // Check if oldDevice is same as newDevice
+ // If so, don't add newDevice info, preventing ARC or HDMI source re-connection
+ if (mOldDeviceInfo != null
+ && mOldDeviceInfo.getLogicalAddress() == mDeviceLogicalAddress
+ && mOldDeviceInfo.getPhysicalAddress() == mDevicePhysicalAddress
+ && mOldDeviceInfo.getDeviceType() == mDeviceType
+ && mOldDeviceInfo.getVendorId() == mVendorId
+ && mOldDeviceInfo.getDisplayName().equals(mDisplayName)) {
+ // Consume CEC messages we already got for this newly found device.
+ tv().processDelayedMessages(mDeviceLogicalAddress);
+ Slog.d(TAG, "Ignore NewDevice, deviceInfo is same as current device");
+ Slog.d(TAG, "Old:[" + mOldDeviceInfo.toString()
+ + "]; New:[" + deviceInfo.toString() + "]");
+ } else {
+ Slog.d(TAG, "Add NewDevice:[" + deviceInfo.toString() + "]");
+ localDevice().mService.getHdmiCecNetwork().addCecDevice(deviceInfo);
- if (HdmiUtils.isEligibleAddressForDevice(HdmiDeviceInfo.DEVICE_AUDIO_SYSTEM,
- mDeviceLogicalAddress)) {
- tv().onNewAvrAdded(deviceInfo);
+ // Consume CEC messages we already got for this newly found device.
+ tv().processDelayedMessages(mDeviceLogicalAddress);
+ if (HdmiUtils.isEligibleAddressForDevice(HdmiDeviceInfo.DEVICE_AUDIO_SYSTEM,
+ mDeviceLogicalAddress)) {
+ tv().onNewAvrAdded(deviceInfo);
+ }
}
}
diff --git a/services/core/java/com/android/server/input/KeyboardLayoutManager.java b/services/core/java/com/android/server/input/KeyboardLayoutManager.java
index 6236e2b..46668de 100644
--- a/services/core/java/com/android/server/input/KeyboardLayoutManager.java
+++ b/services/core/java/com/android/server/input/KeyboardLayoutManager.java
@@ -1370,7 +1370,7 @@
public boolean isVirtualDevice(int deviceId) {
VirtualDeviceManagerInternal vdm = LocalServices.getService(
VirtualDeviceManagerInternal.class);
- return vdm == null || vdm.isInputDeviceOwnedByVirtualDevice(deviceId);
+ return vdm != null && vdm.isInputDeviceOwnedByVirtualDevice(deviceId);
}
private static int[] getScriptCodes(@Nullable Locale locale) {
diff --git a/services/core/java/com/android/server/inputmethod/ClientController.java b/services/core/java/com/android/server/inputmethod/ClientController.java
index 2934640..21b952b 100644
--- a/services/core/java/com/android/server/inputmethod/ClientController.java
+++ b/services/core/java/com/android/server/inputmethod/ClientController.java
@@ -25,9 +25,13 @@
import android.view.inputmethod.InputBinding;
import com.android.internal.annotations.GuardedBy;
+import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.inputmethod.IInputMethodClient;
import com.android.internal.inputmethod.IRemoteInputConnection;
+import java.util.ArrayList;
+import java.util.List;
+
/**
* Store and manage {@link InputMethodManagerService} clients. This class was designed to be a
* singleton in {@link InputMethodManagerService} since it stores information about all clients,
@@ -37,9 +41,7 @@
* As part of the re-architecture plan (described in go/imms-rearchitecture-plan), the following
* fields and methods will be moved out from IMMS and placed here:
* <ul>
- * <li>mCurClient (ClientState)</li>
* <li>mClients (ArrayMap of ClientState indexed by IBinder)</li>
- * <li>mLastSwitchUserId</li>
* </ul>
* <p>
* Nested Classes (to move from IMMS):
@@ -54,7 +56,6 @@
* <li>removeClient</li>
* <li>verifyClientAndPackageMatch</li>
* <li>setImeTraceEnabledForAllClients (make it reactive)</li>
- * <li>unbindCurrentClient</li>
* </ul>
*/
// TODO(b/314150112): Update the Javadoc above, by removing the re-architecture steps, once this
@@ -65,18 +66,32 @@
@GuardedBy("ImfLock.class")
final ArrayMap<IBinder, ClientState> mClients = new ArrayMap<>();
+ @GuardedBy("ImfLock.class")
+ private final List<ClientControllerCallback> mCallbacks = new ArrayList<>();
+
private final PackageManagerInternal mPackageManagerInternal;
+ interface ClientControllerCallback {
+
+ void onClientRemoved(ClientState client);
+ }
+
ClientController(PackageManagerInternal packageManagerInternal) {
mPackageManagerInternal = packageManagerInternal;
}
@GuardedBy("ImfLock.class")
- void addClient(IInputMethodClientInvoker clientInvoker,
- IRemoteInputConnection inputConnection,
- int selfReportedDisplayId, IBinder.DeathRecipient deathRecipient, int callerUid,
+ ClientState addClient(IInputMethodClientInvoker clientInvoker,
+ IRemoteInputConnection inputConnection, int selfReportedDisplayId, int callerUid,
int callerPid) {
- // TODO: Optimize this linear search.
+ final IBinder.DeathRecipient deathRecipient = () -> {
+ // Exceptionally holding ImfLock here since this is a internal lambda expression.
+ synchronized (ImfLock.class) {
+ removeClientAsBinder(clientInvoker.asBinder());
+ }
+ };
+
+ // TODO(b/319457906): Optimize this linear search.
final int numClients = mClients.size();
for (int i = 0; i < numClients; ++i) {
final ClientState state = mClients.valueAt(i);
@@ -101,14 +116,40 @@
// have the client crash. Thus we do not verify the display ID at all here. Instead we
// later check the display ID every time the client needs to interact with the specified
// display.
- mClients.put(clientInvoker.asBinder(), new ClientState(clientInvoker, inputConnection,
- callerUid, callerPid, selfReportedDisplayId, deathRecipient));
+ final ClientState cs = new ClientState(clientInvoker, inputConnection,
+ callerUid, callerPid, selfReportedDisplayId, deathRecipient);
+ mClients.put(clientInvoker.asBinder(), cs);
+ return cs;
+ }
+
+ @VisibleForTesting
+ @GuardedBy("ImfLock.class")
+ boolean removeClient(IInputMethodClient client) {
+ return removeClientAsBinder(client.asBinder());
+ }
+
+ @GuardedBy("ImfLock.class")
+ private boolean removeClientAsBinder(IBinder binder) {
+ final ClientState cs = mClients.remove(binder);
+ if (cs == null) {
+ return false;
+ }
+ binder.unlinkToDeath(cs.mClientDeathRecipient, 0 /* flags */);
+ for (int i = 0; i < mCallbacks.size(); i++) {
+ mCallbacks.get(i).onClientRemoved(cs);
+ }
+ return true;
+ }
+
+ @GuardedBy("ImfLock.class")
+ void addClientControllerCallback(ClientControllerCallback callback) {
+ mCallbacks.add(callback);
}
@GuardedBy("ImfLock.class")
boolean verifyClientAndPackageMatch(
@NonNull IInputMethodClient client, @NonNull String packageName) {
- ClientState cs = mClients.get(client.asBinder());
+ final ClientState cs = mClients.get(client.asBinder());
if (cs == null) {
throw new IllegalArgumentException("unknown client " + client.asBinder());
}
diff --git a/services/core/java/com/android/server/inputmethod/InputMethodManagerService.java b/services/core/java/com/android/server/inputmethod/InputMethodManagerService.java
index 622a2de..8448fc2 100644
--- a/services/core/java/com/android/server/inputmethod/InputMethodManagerService.java
+++ b/services/core/java/com/android/server/inputmethod/InputMethodManagerService.java
@@ -478,7 +478,6 @@
/**
* The client that is currently bound to an input method.
*/
- // TODO(b/314150112): Move this to ClientController.
@Nullable
private ClientState mCurClient;
@@ -1676,7 +1675,11 @@
mVisibilityStateComputer = new ImeVisibilityStateComputer(this);
mVisibilityApplier = new DefaultImeVisibilityApplier(this);
+
mClientController = new ClientController(mPackageManagerInternal);
+ synchronized (ImfLock.class) {
+ mClientController.addClientControllerCallback(c -> onClientRemoved(c));
+ }
mPreventImeStartupUnlessTextEditor = mRes.getBoolean(
com.android.internal.R.bool.config_preventImeStartupUnlessTextEditor);
@@ -2168,47 +2171,41 @@
// actually running.
final int callerUid = Binder.getCallingUid();
final int callerPid = Binder.getCallingPid();
-
- // TODO(b/314150112): Move the death recipient logic to ClientController when moving
- // removeClient method.
- final IBinder.DeathRecipient deathRecipient = () -> removeClient(client);
final IInputMethodClientInvoker clientInvoker =
IInputMethodClientInvoker.create(client, mHandler);
synchronized (ImfLock.class) {
mClientController.addClient(clientInvoker, inputConnection, selfReportedDisplayId,
- deathRecipient, callerUid, callerPid);
+ callerUid, callerPid);
}
}
- // TODO(b/314150112): Move this to ClientController.
- void removeClient(IInputMethodClient client) {
+ // TODO(b/314150112): Move this method to InputMethodBindingController
+ /**
+ * Hide the IME if the removed user is the current user.
+ */
+ private void onClientRemoved(ClientController.ClientState client) {
synchronized (ImfLock.class) {
- ClientState cs = mClientController.mClients.remove(client.asBinder());
- if (cs != null) {
- client.asBinder().unlinkToDeath(cs.mClientDeathRecipient, 0 /* flags */);
- clearClientSessionLocked(cs);
- clearClientSessionForAccessibilityLocked(cs);
-
- if (mCurClient == cs) {
- hideCurrentInputLocked(mCurFocusedWindow, null /* statsToken */, 0 /* flags */,
- null /* resultReceiver */, SoftInputShowHideReason.HIDE_REMOVE_CLIENT);
- if (mBoundToMethod) {
- mBoundToMethod = false;
- IInputMethodInvoker curMethod = getCurMethodLocked();
- if (curMethod != null) {
- // When we unbind input, we are unbinding the client, so we always
- // unbind ime and a11y together.
- curMethod.unbindInput();
- AccessibilityManagerInternal.get().unbindInput();
- }
+ clearClientSessionLocked(client);
+ clearClientSessionForAccessibilityLocked(client);
+ if (mCurClient == client) {
+ hideCurrentInputLocked(mCurFocusedWindow, null /* statsToken */, 0 /* flags */,
+ null /* resultReceiver */, SoftInputShowHideReason.HIDE_REMOVE_CLIENT);
+ if (mBoundToMethod) {
+ mBoundToMethod = false;
+ IInputMethodInvoker curMethod = getCurMethodLocked();
+ if (curMethod != null) {
+ // When we unbind input, we are unbinding the client, so we always
+ // unbind ime and a11y together.
+ curMethod.unbindInput();
+ AccessibilityManagerInternal.get().unbindInput();
}
- mBoundToAccessibility = false;
- mCurClient = null;
}
- if (mCurFocusedWindowClient == cs) {
- mCurFocusedWindowClient = null;
- mCurFocusedWindowEditorInfo = null;
- }
+ mBoundToAccessibility = false;
+ mCurClient = null;
+ }
+ if (mCurFocusedWindowClient == client) {
+ mCurFocusedWindowClient = null;
+ mCurFocusedWindowEditorInfo = null;
}
}
}
@@ -2218,8 +2215,7 @@
void unbindCurrentClientLocked(@UnbindReason int unbindClientReason) {
if (mCurClient != null) {
if (DEBUG) {
- Slog.v(TAG, "unbindCurrentInputLocked: client="
- + mCurClient.mClient.asBinder());
+ Slog.v(TAG, "unbindCurrentInputLocked: client=" + mCurClient.mClient.asBinder());
}
if (mBoundToMethod) {
mBoundToMethod = false;
@@ -2312,7 +2308,8 @@
final StartInputInfo info = new StartInputInfo(mSettings.getCurrentUserId(),
getCurTokenLocked(),
mCurTokenDisplayId, getCurIdLocked(), startInputReason, restarting,
- UserHandle.getUserId(mCurClient.mUid), mCurClient.mSelfReportedDisplayId,
+ UserHandle.getUserId(mCurClient.mUid),
+ mCurClient.mSelfReportedDisplayId,
mCurFocusedWindow, mCurEditorInfo, mCurFocusedWindowSoftInputMode,
getSequenceNumberLocked());
mImeTargetWindowMap.put(startInputToken, mCurFocusedWindow);
@@ -2323,14 +2320,14 @@
// same-user scenarios.
// That said ignoring cross-user scenario will never affect IMEs that do not have
// INTERACT_ACROSS_USERS(_FULL) permissions, which is actually almost always the case.
- if (mSettings.getCurrentUserId() == UserHandle.getUserId(mCurClient.mUid)) {
+ if (mSettings.getCurrentUserId() == UserHandle.getUserId(
+ mCurClient.mUid)) {
mPackageManagerInternal.grantImplicitAccess(mSettings.getCurrentUserId(),
null /* intent */, UserHandle.getAppId(getCurMethodUidLocked()),
mCurClient.mUid, true /* direct */);
}
- @InputMethodNavButtonFlags
- final int navButtonFlags = getInputMethodNavButtonFlagsLocked();
+ @InputMethodNavButtonFlags final int navButtonFlags = getInputMethodNavButtonFlagsLocked();
final SessionState session = mCurClient.mCurSession;
setEnabledSessionLocked(session);
session.mMethod.startInput(startInputToken, mCurInputConnection, mCurEditorInfo, restarting,
@@ -2750,8 +2747,8 @@
&& curMethod.asBinder() == method.asBinder()) {
if (mCurClient != null) {
clearClientSessionLocked(mCurClient);
- mCurClient.mCurSession = new SessionState(mCurClient,
- method, session, channel);
+ mCurClient.mCurSession = new SessionState(
+ mCurClient, method, session, channel);
InputBindResult res = attachNewInputLocked(
StartInputReason.SESSION_CREATED_BY_IME, true);
attachNewAccessibilityLocked(StartInputReason.SESSION_CREATED_BY_IME, true);
@@ -5776,8 +5773,10 @@
// TODO(b/305829876): Implement user ID verification
if (mCurClient != null) {
clearClientSessionForAccessibilityLocked(mCurClient, accessibilityConnectionId);
- mCurClient.mAccessibilitySessions.put(accessibilityConnectionId,
- new AccessibilitySessionState(mCurClient, accessibilityConnectionId,
+ mCurClient.mAccessibilitySessions.put(
+ accessibilityConnectionId,
+ new AccessibilitySessionState(mCurClient,
+ accessibilityConnectionId,
session));
attachNewAccessibilityLocked(StartInputReason.SESSION_CREATED_BY_ACCESSIBILITY,
@@ -5811,7 +5810,8 @@
}
// A11yManagerService unbinds the disabled accessibility service. We don't need
// to do it here.
- mCurClient.mClient.onUnbindAccessibilityService(getSequenceNumberLocked(),
+ mCurClient.mClient.onUnbindAccessibilityService(
+ getSequenceNumberLocked(),
accessibilityConnectionId);
}
// We only have sessions when we bound to an input method. Remove this session
diff --git a/services/core/java/com/android/server/media/projection/MediaProjectionManagerService.java b/services/core/java/com/android/server/media/projection/MediaProjectionManagerService.java
index f6571d9..550aed5 100644
--- a/services/core/java/com/android/server/media/projection/MediaProjectionManagerService.java
+++ b/services/core/java/com/android/server/media/projection/MediaProjectionManagerService.java
@@ -304,7 +304,7 @@
}
@VisibleForTesting
- void addCallback(final IMediaProjectionWatcherCallback callback) {
+ MediaProjectionInfo addCallback(final IMediaProjectionWatcherCallback callback) {
IBinder.DeathRecipient deathRecipient = new IBinder.DeathRecipient() {
@Override
public void binderDied() {
@@ -314,6 +314,7 @@
synchronized (mLock) {
mCallbackDelegate.add(callback);
linkDeathRecipientLocked(callback, deathRecipient);
+ return mProjectionGrant != null ? mProjectionGrant.getProjectionInfo() : null;
}
}
@@ -786,11 +787,11 @@
@Override //Binder call
@EnforcePermission(MANAGE_MEDIA_PROJECTION)
- public void addCallback(final IMediaProjectionWatcherCallback callback) {
+ public MediaProjectionInfo addCallback(final IMediaProjectionWatcherCallback callback) {
addCallback_enforcePermission();
final long token = Binder.clearCallingIdentity();
try {
- MediaProjectionManagerService.this.addCallback(callback);
+ return MediaProjectionManagerService.this.addCallback(callback);
} finally {
Binder.restoreCallingIdentity(token);
}
@@ -1244,7 +1245,7 @@
}
public MediaProjectionInfo getProjectionInfo() {
- return new MediaProjectionInfo(packageName, userHandle);
+ return new MediaProjectionInfo(packageName, userHandle, mLaunchCookie);
}
boolean requiresForegroundService() {
diff --git a/services/core/java/com/android/server/net/NetworkPolicyLogger.java b/services/core/java/com/android/server/net/NetworkPolicyLogger.java
index 4d19ead..d7188c7 100644
--- a/services/core/java/com/android/server/net/NetworkPolicyLogger.java
+++ b/services/core/java/com/android/server/net/NetworkPolicyLogger.java
@@ -42,7 +42,6 @@
import android.util.Log;
import android.util.Slog;
-import com.android.internal.annotations.Keep;
import com.android.internal.util.IndentingPrintWriter;
import com.android.internal.util.RingBuffer;
import com.android.server.am.ProcessList;
@@ -414,7 +413,7 @@
private static final Date sDate = new Date();
public LogBuffer(int capacity) {
- super(Data.class, capacity);
+ super(Data::new, Data[]::new, capacity);
}
public void uidStateChanged(int uid, int procState, long procStateSeq,
@@ -690,12 +689,8 @@
/**
* Container class for all networkpolicy events data.
- *
- * Note: This class needs to be public for RingBuffer class to be able to create
- * new instances of this.
*/
- @Keep
- public static final class Data {
+ private static final class Data {
public int type;
public long timeStamp;
diff --git a/services/core/java/com/android/server/notification/NotificationManagerService.java b/services/core/java/com/android/server/notification/NotificationManagerService.java
index 9ddc362..2ae040a6 100755
--- a/services/core/java/com/android/server/notification/NotificationManagerService.java
+++ b/services/core/java/com/android/server/notification/NotificationManagerService.java
@@ -5931,8 +5931,7 @@
newVisualEffects, policy.priorityConversationSenders);
if (shouldApplyAsImplicitRule) {
- mZenModeHelper.applyGlobalPolicyAsImplicitZenRule(pkg, callingUid, policy,
- origin);
+ mZenModeHelper.applyGlobalPolicyAsImplicitZenRule(pkg, callingUid, policy);
} else {
ZenLog.traceSetNotificationPolicy(pkg, applicationInfo.targetSdkVersion,
policy);
@@ -12103,6 +12102,7 @@
return true;
}
+ long token = Binder.clearCallingIdentity();
try {
if (mPackageManager.checkUidPermission(RECEIVE_SENSITIVE_NOTIFICATIONS, uid)
== PERMISSION_GRANTED || mPackageManagerInternal.isPlatformSigned(pkg)) {
@@ -12129,6 +12129,8 @@
}
} catch (RemoteException e) {
Slog.e(TAG, "Failed to check trusted status of listener", e);
+ } finally {
+ Binder.restoreCallingIdentity(token);
}
return false;
}
diff --git a/services/core/java/com/android/server/notification/ZenAdapters.java b/services/core/java/com/android/server/notification/ZenAdapters.java
index 91df04c..37b263c 100644
--- a/services/core/java/com/android/server/notification/ZenAdapters.java
+++ b/services/core/java/com/android/server/notification/ZenAdapters.java
@@ -59,9 +59,7 @@
}
if (Flags.modesApi()) {
- zenPolicyBuilder.allowChannels(
- policy.allowPriorityChannels()
- ? ZenPolicy.CHANNEL_TYPE_PRIORITY : ZenPolicy.CHANNEL_TYPE_NONE);
+ zenPolicyBuilder.allowPriorityChannels(policy.allowPriorityChannels());
}
return zenPolicyBuilder.build();
diff --git a/services/core/java/com/android/server/notification/ZenModeEventLogger.java b/services/core/java/com/android/server/notification/ZenModeEventLogger.java
index 0145577..a90efe6 100644
--- a/services/core/java/com/android/server/notification/ZenModeEventLogger.java
+++ b/services/core/java/com/android/server/notification/ZenModeEventLogger.java
@@ -18,6 +18,8 @@
import static android.app.NotificationManager.Policy.STATE_CHANNELS_BYPASSING_DND;
import static android.provider.Settings.Global.ZEN_MODE_OFF;
+import static android.service.notification.NotificationServiceProto.CHANNEL_POLICY_PRIORITY;
+import static android.service.notification.NotificationServiceProto.CHANNEL_POLICY_NONE;
import static android.service.notification.NotificationServiceProto.RULE_TYPE_AUTOMATIC;
import static android.service.notification.NotificationServiceProto.RULE_TYPE_MANUAL;
import static android.service.notification.NotificationServiceProto.RULE_TYPE_UNKNOWN;
@@ -551,8 +553,8 @@
if (Flags.modesApi()) {
proto.write(DNDPolicyProto.ALLOW_CHANNELS,
mNewPolicy.allowPriorityChannels()
- ? ZenPolicy.CHANNEL_TYPE_PRIORITY
- : ZenPolicy.CHANNEL_TYPE_NONE);
+ ? CHANNEL_POLICY_PRIORITY
+ : CHANNEL_POLICY_NONE);
}
} else {
Log.wtf(TAG, "attempted to write zen mode log event with null policy");
diff --git a/services/core/java/com/android/server/notification/ZenModeHelper.java b/services/core/java/com/android/server/notification/ZenModeHelper.java
index afbf08d..93ffd97 100644
--- a/services/core/java/com/android/server/notification/ZenModeHelper.java
+++ b/services/core/java/com/android/server/notification/ZenModeHelper.java
@@ -32,6 +32,7 @@
import static android.service.notification.ZenModeConfig.UPDATE_ORIGIN_USER;
import static com.android.internal.util.FrameworkStatsLog.DND_MODE_RULE;
+import static com.android.internal.util.Preconditions.checkArgument;
import android.annotation.DrawableRes;
import android.annotation.NonNull;
@@ -427,6 +428,7 @@
public String addAutomaticZenRule(String pkg, AutomaticZenRule automaticZenRule,
@ConfigChangeOrigin int origin, String reason, int callingUid) {
+ requirePublicOrigin("addAutomaticZenRule", origin);
if (!ZenModeConfig.SYSTEM_AUTHORITY.equals(pkg)) {
PackageItemInfo component = getServiceInfo(automaticZenRule.getOwner());
if (component == null) {
@@ -525,6 +527,7 @@
public boolean updateAutomaticZenRule(String ruleId, AutomaticZenRule automaticZenRule,
@ConfigChangeOrigin int origin, String reason, int callingUid) {
+ requirePublicOrigin("updateAutomaticZenRule", origin);
ZenModeConfig newConfig;
synchronized (mConfigLock) {
if (mConfig == null) return false;
@@ -602,7 +605,11 @@
rule = newImplicitZenRule(callingPkg);
newConfig.automaticRules.put(rule.id, rule);
}
- rule.zenMode = zenMode;
+ // If the user has changed the rule's *zenMode*, then don't let app overwrite it.
+ // We allow the update if the user has only changed other aspects of the rule.
+ if ((rule.userModifiedFields & AutomaticZenRule.FIELD_INTERRUPTION_FILTER) == 0) {
+ rule.zenMode = zenMode;
+ }
rule.snoozing = false;
rule.condition = new Condition(rule.conditionId,
mContext.getString(R.string.zen_mode_implicit_activated),
@@ -625,7 +632,7 @@
* {@link Global#ZEN_MODE_IMPORTANT_INTERRUPTIONS}.
*/
void applyGlobalPolicyAsImplicitZenRule(String callingPkg, int callingUid,
- NotificationManager.Policy policy, @ConfigChangeOrigin int origin) {
+ NotificationManager.Policy policy) {
if (!android.app.Flags.modesApi()) {
Log.wtf(TAG, "applyGlobalPolicyAsImplicitZenRule called with flag off!");
return;
@@ -641,10 +648,17 @@
rule.zenMode = Global.ZEN_MODE_IMPORTANT_INTERRUPTIONS;
newConfig.automaticRules.put(rule.id, rule);
}
- // TODO: b/308673679 - Keep user customization of this rule!
- rule.zenPolicy = ZenAdapters.notificationPolicyToZenPolicy(policy);
- setConfigLocked(newConfig, /* triggeringComponent= */ null, origin,
- "applyGlobalPolicyAsImplicitZenRule", callingUid);
+ // If the user has changed the rule's *ZenPolicy*, then don't let app overwrite it.
+ // We allow the update if the user has only changed other aspects of the rule.
+ if (rule.zenPolicyUserModifiedFields == 0) {
+ updatePolicy(
+ rule,
+ ZenAdapters.notificationPolicyToZenPolicy(policy),
+ /* updateBitmask= */ false);
+
+ setConfigLocked(newConfig, /* triggeringComponent= */ null, UPDATE_ORIGIN_APP,
+ "applyGlobalPolicyAsImplicitZenRule", callingUid);
+ }
}
}
@@ -726,6 +740,7 @@
boolean removeAutomaticZenRule(String id, @ConfigChangeOrigin int origin, String reason,
int callingUid) {
+ requirePublicOrigin("removeAutomaticZenRule", origin);
ZenModeConfig newConfig;
synchronized (mConfigLock) {
if (mConfig == null) return false;
@@ -758,6 +773,7 @@
boolean removeAutomaticZenRules(String packageName, @ConfigChangeOrigin int origin,
String reason, int callingUid) {
+ requirePublicOrigin("removeAutomaticZenRules", origin);
ZenModeConfig newConfig;
synchronized (mConfigLock) {
if (mConfig == null) return false;
@@ -806,6 +822,7 @@
void setAutomaticZenRuleState(String id, Condition condition, @ConfigChangeOrigin int origin,
int callingUid) {
+ requirePublicOrigin("setAutomaticZenRuleState", origin);
ZenModeConfig newConfig;
synchronized (mConfigLock) {
if (mConfig == null) return;
@@ -819,6 +836,7 @@
void setAutomaticZenRuleState(Uri ruleDefinition, Condition condition,
@ConfigChangeOrigin int origin, int callingUid) {
+ requirePublicOrigin("setAutomaticZenRuleState", origin);
ZenModeConfig newConfig;
synchronized (mConfigLock) {
if (mConfig == null) return;
@@ -988,7 +1006,7 @@
return null;
}
- void populateZenRule(String pkg, AutomaticZenRule automaticZenRule, ZenRule rule,
+ private void populateZenRule(String pkg, AutomaticZenRule automaticZenRule, ZenRule rule,
@ConfigChangeOrigin int origin, boolean isNew) {
if (Flags.modesApi()) {
// These values can always be edited by the app, so we apply changes immediately.
@@ -1053,11 +1071,9 @@
rule.zenMode = newZenMode;
// Updates the bitmask and values for all policy fields, based on the origin.
- rule.zenPolicy = updatePolicy(rule.zenPolicy, automaticZenRule.getZenPolicy(),
- updateBitmask);
+ updatePolicy(rule, automaticZenRule.getZenPolicy(), updateBitmask);
// Updates the bitmask and values for all device effect fields, based on the origin.
- rule.zenDeviceEffects = updateZenDeviceEffects(
- rule.zenDeviceEffects, automaticZenRule.getDeviceEffects(),
+ updateZenDeviceEffects(rule, automaticZenRule.getDeviceEffects(),
origin == UPDATE_ORIGIN_APP, updateBitmask);
} else {
if (rule.enabled != automaticZenRule.isEnabled()) {
@@ -1069,13 +1085,6 @@
rule.enabled = automaticZenRule.isEnabled();
rule.modified = automaticZenRule.isModified();
rule.zenPolicy = automaticZenRule.getZenPolicy();
- if (Flags.modesApi()) {
- rule.zenDeviceEffects = updateZenDeviceEffects(
- rule.zenDeviceEffects,
- automaticZenRule.getDeviceEffects(),
- origin == UPDATE_ORIGIN_APP,
- origin == UPDATE_ORIGIN_USER);
- }
rule.zenMode = NotificationManager.zenModeFromInterruptionFilter(
automaticZenRule.getInterruptionFilter(), Global.ZEN_MODE_OFF);
rule.configurationActivity = automaticZenRule.getConfigurationActivity();
@@ -1099,28 +1108,28 @@
}
/**
- * Modifies {@link ZenPolicy} that is being stored as part of a new or updated ZenRule.
- * Returns a policy based on {@code oldPolicy}, but with fields updated to match
- * {@code newPolicy} where they differ, and updating the internal user-modified bitmask to
- * track these changes, if applicable based on {@code origin}.
+ * Modifies the {@link ZenPolicy} associated to a new or updated ZenRule.
+ *
+ * <p>The new policy is {@code newPolicy}, while the user-modified bitmask is updated to reflect
+ * the changes being applied (if applicable, i.e. if the update is from the user).
*/
- @Nullable
- private ZenPolicy updatePolicy(@Nullable ZenPolicy oldPolicy, @Nullable ZenPolicy newPolicy,
- boolean updateBitmask) {
- // If the update is to make the policy null, we don't need to update the bitmask,
- // because it won't be stored anywhere anyway.
+ private void updatePolicy(ZenRule zenRule, @Nullable ZenPolicy newPolicy,
+ boolean updateBitmask) {
if (newPolicy == null) {
- return null;
+ // TODO: b/319242206 - Treat as newPolicy == default policy and continue below.
+ zenRule.zenPolicy = null;
+ return;
}
// If oldPolicy is null, we compare against the default policy when determining which
// fields in the bitmask should be marked as updated.
- if (oldPolicy == null) {
- oldPolicy = mDefaultConfig.toZenPolicy();
- }
+ ZenPolicy oldPolicy =
+ zenRule.zenPolicy != null ? zenRule.zenPolicy : mDefaultConfig.toZenPolicy();
- int userModifiedFields = oldPolicy.getUserModifiedFields();
+ zenRule.zenPolicy = newPolicy;
+
if (updateBitmask) {
+ int userModifiedFields = zenRule.zenPolicyUserModifiedFields;
if (oldPolicy.getPriorityMessageSenders() != newPolicy.getPriorityMessageSenders()) {
userModifiedFields |= ZenPolicy.FIELD_MESSAGES;
}
@@ -1131,7 +1140,7 @@
!= newPolicy.getPriorityConversationSenders()) {
userModifiedFields |= ZenPolicy.FIELD_CONVERSATIONS;
}
- if (oldPolicy.getAllowedChannels() != newPolicy.getAllowedChannels()) {
+ if (oldPolicy.getPriorityChannels() != newPolicy.getPriorityChannels()) {
userModifiedFields |= ZenPolicy.FIELD_ALLOW_CHANNELS;
}
if (oldPolicy.getPriorityCategoryReminders()
@@ -1178,66 +1187,47 @@
!= newPolicy.getVisualEffectNotificationList()) {
userModifiedFields |= ZenPolicy.FIELD_VISUAL_EFFECT_NOTIFICATION_LIST;
}
+ zenRule.zenPolicyUserModifiedFields = userModifiedFields;
}
-
- // After all bitmask changes have been made, sets the bitmask.
- return new ZenPolicy.Builder(newPolicy).setUserModifiedFields(userModifiedFields).build();
}
/**
- * Modifies {@link ZenDeviceEffects} that are being stored as part of a new or updated ZenRule.
- * Returns a {@link ZenDeviceEffects} based on {@code oldEffects}, but with fields updated to
- * match {@code newEffects} where they differ, and updating the internal user-modified bitmask
- * to track these changes, if applicable based on {@code origin}.
- * <ul>
- * <li> Apps cannot turn on hidden effects (those tagged as {@code @hide}) since they are
- * intended for platform-specific rules (e.g. wearables). If it's a new rule, we blank them
- * out; if it's an update, we preserve the previous values.
- * </ul>
+ * Modifies the {@link ZenDeviceEffects} associated to a new or updated ZenRule.
+ *
+ * <p>The new value is {@code newEffects}, while the user-modified bitmask is updated to reflect
+ * the changes being applied (if applicable, i.e. if the update is from the user).
+ *
+ * <p>Apps cannot turn on hidden effects (those tagged as {@code @hide}), so those fields are
+ * treated especially: for a new rule, they are blanked out; for an updated rule, previous
+ * values are preserved.
*/
- @Nullable
- private static ZenDeviceEffects updateZenDeviceEffects(@Nullable ZenDeviceEffects oldEffects,
- @Nullable ZenDeviceEffects newEffects,
- boolean isFromApp,
- boolean updateBitmask) {
+ private static void updateZenDeviceEffects(ZenRule zenRule,
+ @Nullable ZenDeviceEffects newEffects, boolean isFromApp, boolean updateBitmask) {
if (newEffects == null) {
- return null;
+ zenRule.zenDeviceEffects = null;
+ return;
}
- // Since newEffects is not null, we want to adopt all the new provided device effects.
- ZenDeviceEffects.Builder builder = new ZenDeviceEffects.Builder(newEffects);
+ ZenDeviceEffects oldEffects = zenRule.zenDeviceEffects != null
+ ? zenRule.zenDeviceEffects
+ : new ZenDeviceEffects.Builder().build();
if (isFromApp) {
- if (oldEffects != null) {
- // We can do this because we know we don't need to update the bitmask FROM_APP.
- return builder
- .setShouldDisableAutoBrightness(oldEffects.shouldDisableAutoBrightness())
- .setShouldDisableTapToWake(oldEffects.shouldDisableTapToWake())
- .setShouldDisableTiltToWake(oldEffects.shouldDisableTiltToWake())
- .setShouldDisableTouch(oldEffects.shouldDisableTouch())
- .setShouldMinimizeRadioUsage(oldEffects.shouldMinimizeRadioUsage())
- .setShouldMaximizeDoze(oldEffects.shouldMaximizeDoze())
- .build();
- } else {
- return builder
- .setShouldDisableAutoBrightness(false)
- .setShouldDisableTapToWake(false)
- .setShouldDisableTiltToWake(false)
- .setShouldDisableTouch(false)
- .setShouldMinimizeRadioUsage(false)
- .setShouldMaximizeDoze(false)
- .build();
- }
+ // Don't allow apps to toggle hidden effects.
+ newEffects = new ZenDeviceEffects.Builder(newEffects)
+ .setShouldDisableAutoBrightness(oldEffects.shouldDisableAutoBrightness())
+ .setShouldDisableTapToWake(oldEffects.shouldDisableTapToWake())
+ .setShouldDisableTiltToWake(oldEffects.shouldDisableTiltToWake())
+ .setShouldDisableTouch(oldEffects.shouldDisableTouch())
+ .setShouldMinimizeRadioUsage(oldEffects.shouldMinimizeRadioUsage())
+ .setShouldMaximizeDoze(oldEffects.shouldMaximizeDoze())
+ .build();
}
- // If oldEffects is null, we compare against the default device effects object when
- // determining which fields in the bitmask should be marked as updated.
- if (oldEffects == null) {
- oldEffects = new ZenDeviceEffects.Builder().build();
- }
+ zenRule.zenDeviceEffects = newEffects;
- int userModifiedFields = oldEffects.getUserModifiedFields();
if (updateBitmask) {
+ int userModifiedFields = zenRule.zenDeviceEffectsUserModifiedFields;
if (oldEffects.shouldDisplayGrayscale() != newEffects.shouldDisplayGrayscale()) {
userModifiedFields |= ZenDeviceEffects.FIELD_GRAYSCALE;
}
@@ -1270,11 +1260,8 @@
if (oldEffects.shouldMaximizeDoze() != newEffects.shouldMaximizeDoze()) {
userModifiedFields |= ZenDeviceEffects.FIELD_MAXIMIZE_DOZE;
}
+ zenRule.zenDeviceEffectsUserModifiedFields = userModifiedFields;
}
-
- // Since newEffects is not null, we want to adopt all the new provided device effects.
- // Set the usermodifiedFields value separately, to reflect the updated bitmask.
- return builder.setUserModifiedFields(userModifiedFields).build();
}
private AutomaticZenRule zenRuleToAutomaticZenRule(ZenRule rule) {
@@ -1293,7 +1280,6 @@
.setOwner(rule.component)
.setConfigurationActivity(rule.configurationActivity)
.setTriggerDescription(rule.triggerDescription)
- .setUserModifiedFields(rule.userModifiedFields)
.build();
} else {
azr = new AutomaticZenRule(rule.name, rule.component,
@@ -2369,6 +2355,19 @@
return null;
}
}
+
+ /** Checks that the {@code origin} supplied to a ZenModeHelper "API" method makes sense. */
+ private static void requirePublicOrigin(String method, @ConfigChangeOrigin int origin) {
+ if (!Flags.modesApi()) {
+ return;
+ }
+ checkArgument(origin == UPDATE_ORIGIN_APP || origin == UPDATE_ORIGIN_SYSTEM_OR_SYSTEMUI
+ || origin == UPDATE_ORIGIN_USER,
+ "Expected one of UPDATE_ORIGIN_APP, UPDATE_ORIGIN_SYSTEM_OR_SYSTEMUI, or "
+ + "UPDATE_ORIGIN_USER for %s, but received '%s'.",
+ method, origin);
+ }
+
private final class Metrics extends Callback {
private static final String COUNTER_MODE_PREFIX = "dnd_mode_";
private static final String COUNTER_TYPE_PREFIX = "dnd_type_";
diff --git a/services/core/java/com/android/server/pm/BackgroundInstallControlService.java b/services/core/java/com/android/server/pm/BackgroundInstallControlService.java
index 7f0aadc..c110fb6 100644
--- a/services/core/java/com/android/server/pm/BackgroundInstallControlService.java
+++ b/services/core/java/com/android/server/pm/BackgroundInstallControlService.java
@@ -75,11 +75,9 @@
private static final int MSG_PACKAGE_ADDED = 1;
private static final int MSG_PACKAGE_REMOVED = 2;
- private final Context mContext;
private final BinderService mBinderService;
private final PackageManager mPackageManager;
private final PackageManagerInternal mPackageManagerInternal;
- private final UsageStatsManagerInternal mUsageStatsManagerInternal;
private final PermissionManagerServiceInternal mPermissionManager;
private final Handler mHandler;
private final File mDiskFile;
@@ -99,14 +97,14 @@
@VisibleForTesting
BackgroundInstallControlService(@NonNull Injector injector) {
super(injector.getContext());
- mContext = injector.getContext();
mPackageManager = injector.getPackageManager();
mPackageManagerInternal = injector.getPackageManagerInternal();
mPermissionManager = injector.getPermissionManager();
mHandler = new EventHandler(injector.getLooper(), this);
mDiskFile = injector.getDiskFile();
- mUsageStatsManagerInternal = injector.getUsageStatsManagerInternal();
- mUsageStatsManagerInternal.registerListener(
+ UsageStatsManagerInternal usageStatsManagerInternal =
+ injector.getUsageStatsManagerInternal();
+ usageStatsManagerInternal.registerListener(
(userId, event) ->
mHandler.obtainMessage(MSG_USAGE_EVENT_RECEIVED,
userId,
diff --git a/services/core/java/com/android/server/pm/DataLoaderManagerService.java b/services/core/java/com/android/server/pm/DataLoaderManagerService.java
index 888e1c2..c25cea6 100644
--- a/services/core/java/com/android/server/pm/DataLoaderManagerService.java
+++ b/services/core/java/com/android/server/pm/DataLoaderManagerService.java
@@ -47,7 +47,6 @@
public class DataLoaderManagerService extends SystemService {
private static final String TAG = "DataLoaderManager";
private final Context mContext;
- private final HandlerThread mThread;
private final Handler mHandler;
private final DataLoaderManagerBinderService mBinderService;
private final SparseArray<DataLoaderServiceConnection> mServiceConnections =
@@ -57,10 +56,10 @@
super(context);
mContext = context;
- mThread = new HandlerThread(TAG);
- mThread.start();
+ HandlerThread thread = new HandlerThread(TAG);
+ thread.start();
- mHandler = new Handler(mThread.getLooper());
+ mHandler = new Handler(thread.getLooper());
mBinderService = new DataLoaderManagerBinderService();
}
diff --git a/services/core/java/com/android/server/pm/IPackageManagerBase.java b/services/core/java/com/android/server/pm/IPackageManagerBase.java
index e3bbd2d..f987d4a 100644
--- a/services/core/java/com/android/server/pm/IPackageManagerBase.java
+++ b/services/core/java/com/android/server/pm/IPackageManagerBase.java
@@ -107,9 +107,6 @@
@Nullable
private final ComponentName mInstantAppResolverSettingsComponent;
- @NonNull
- private final String mRequiredSupplementalProcessPackage;
-
@Nullable
private final String mServicesExtensionPackageName;
@@ -125,7 +122,6 @@
@NonNull PackageInstallerService installerService,
@NonNull PackageProperty packageProperty, @NonNull ComponentName resolveComponentName,
@Nullable ComponentName instantAppResolverSettingsComponent,
- @NonNull String requiredSupplementalProcessPackage,
@Nullable String servicesExtensionPackageName,
@Nullable String sharedSystemSharedLibraryPackageName) {
mService = service;
@@ -140,7 +136,6 @@
mPackageProperty = packageProperty;
mResolveComponentName = resolveComponentName;
mInstantAppResolverSettingsComponent = instantAppResolverSettingsComponent;
- mRequiredSupplementalProcessPackage = requiredSupplementalProcessPackage;
mServicesExtensionPackageName = servicesExtensionPackageName;
mSharedSystemSharedLibraryPackageName = sharedSystemSharedLibraryPackageName;
}
diff --git a/services/core/java/com/android/server/pm/Installer.java b/services/core/java/com/android/server/pm/Installer.java
index d5471cb0..34903d1 100644
--- a/services/core/java/com/android/server/pm/Installer.java
+++ b/services/core/java/com/android/server/pm/Installer.java
@@ -1183,8 +1183,7 @@
* Returns an auth token for the provided writable FD.
*
* @param authFd a file descriptor to proof that the caller can write to the file.
- * @param appUid uid of the calling app.
- * @param userId id of the user whose app file to enable fs-verity.
+ * @param uid uid of the calling app.
*
* @return authToken, or null if a remote call shouldn't be continued. See {@link
* #checkBeforeRemote}.
@@ -1192,13 +1191,12 @@
* @throws InstallerException if the remote call failed.
*/
public IInstalld.IFsveritySetupAuthToken createFsveritySetupAuthToken(
- ParcelFileDescriptor authFd, int appUid, @UserIdInt int userId)
- throws InstallerException {
+ ParcelFileDescriptor authFd, int uid) throws InstallerException {
if (!checkBeforeRemote()) {
return null;
}
try {
- return mInstalld.createFsveritySetupAuthToken(authFd, appUid, userId);
+ return mInstalld.createFsveritySetupAuthToken(authFd, uid);
} catch (Exception e) {
throw InstallerException.from(e);
}
diff --git a/services/core/java/com/android/server/pm/PackageArchiver.java b/services/core/java/com/android/server/pm/PackageArchiver.java
index 3e5759a..b18f2bf 100644
--- a/services/core/java/com/android/server/pm/PackageArchiver.java
+++ b/services/core/java/com/android/server/pm/PackageArchiver.java
@@ -51,6 +51,7 @@
import android.content.IntentSender;
import android.content.pm.ApplicationInfo;
import android.content.pm.ArchivedActivityParcel;
+import android.content.pm.ArchivedPackageInfo;
import android.content.pm.ArchivedPackageParcel;
import android.content.pm.LauncherActivityInfo;
import android.content.pm.LauncherApps;
@@ -402,23 +403,30 @@
installerPackage, /* flags= */ 0, userId);
if (installerInfo == null) {
// Should never happen because we just fetched the installerInfo.
- Slog.e(TAG, "Couldnt find installer " + installerPackage);
+ Slog.e(TAG, "Couldn't find installer " + installerPackage);
return null;
}
+ final int iconSize = mContext.getSystemService(
+ ActivityManager.class).getLauncherLargeIconSize();
+
+ var info = new ArchivedPackageInfo(archivedPackage);
try {
- var packageName = archivedPackage.packageName;
- var mainActivities = archivedPackage.archivedActivities;
- List<ArchiveActivityInfo> archiveActivityInfos = new ArrayList<>(mainActivities.length);
- for (int i = 0, size = mainActivities.length; i < size; ++i) {
- var mainActivity = mainActivities[i];
- Path iconPath = storeIconForParcel(packageName, mainActivity, userId, i);
+ var packageName = info.getPackageName();
+ var mainActivities = info.getLauncherActivities();
+ List<ArchiveActivityInfo> archiveActivityInfos = new ArrayList<>(mainActivities.size());
+ for (int i = 0, size = mainActivities.size(); i < size; ++i) {
+ var mainActivity = mainActivities.get(i);
+ Path iconPath = storeDrawable(
+ packageName, mainActivity.getIcon(), userId, i, iconSize);
+ Path monochromePath = storeDrawable(
+ packageName, mainActivity.getMonochromeIcon(), userId, i, iconSize);
ArchiveActivityInfo activityInfo =
new ArchiveActivityInfo(
- mainActivity.title,
- mainActivity.originalComponentName,
+ mainActivity.getLabel().toString(),
+ mainActivity.getComponentName(),
iconPath,
- null);
+ monochromePath);
archiveActivityInfos.add(activityInfo);
}
@@ -452,21 +460,6 @@
return new ArchiveState(archiveActivityInfos, installerTitle);
}
- // TODO(b/298452477) Handle monochrome icons.
- private static Path storeIconForParcel(String packageName, ArchivedActivityParcel mainActivity,
- @UserIdInt int userId, int index) throws IOException {
- if (mainActivity.iconBitmap == null) {
- return null;
- }
- File iconsDir = createIconsDir(packageName, userId);
- File iconFile = new File(iconsDir, index + ".png");
- try (FileOutputStream out = new FileOutputStream(iconFile)) {
- out.write(mainActivity.iconBitmap);
- out.flush();
- }
- return iconFile.toPath();
- }
-
@VisibleForTesting
Path storeIcon(String packageName, LauncherActivityInfo mainActivity,
@UserIdInt int userId, int index, int iconSize) throws IOException {
@@ -475,9 +468,18 @@
// The app doesn't define an icon. No need to store anything.
return null;
}
+ return storeDrawable(packageName, mainActivity.getIcon(/* density= */ 0), userId, index,
+ iconSize);
+ }
+
+ private static Path storeDrawable(String packageName, @Nullable Drawable iconDrawable,
+ @UserIdInt int userId, int index, int iconSize) throws IOException {
+ if (iconDrawable == null) {
+ return null;
+ }
File iconsDir = createIconsDir(packageName, userId);
File iconFile = new File(iconsDir, index + ".png");
- Bitmap icon = drawableToBitmap(mainActivity.getIcon(/* density= */ 0), iconSize);
+ Bitmap icon = drawableToBitmap(iconDrawable, iconSize);
try (FileOutputStream out = new FileOutputStream(iconFile)) {
// Note: Quality is ignored for PNGs.
if (!icon.compress(Bitmap.CompressFormat.PNG, /* quality= */ 100, out)) {
diff --git a/services/core/java/com/android/server/pm/PackageManagerService.java b/services/core/java/com/android/server/pm/PackageManagerService.java
index 5225529..c5b5a76 100644
--- a/services/core/java/com/android/server/pm/PackageManagerService.java
+++ b/services/core/java/com/android/server/pm/PackageManagerService.java
@@ -4659,8 +4659,7 @@
mPreferredActivityHelper, mResolveIntentHelper, mDomainVerificationManager,
mDomainVerificationConnection, mInstallerService, mPackageProperty,
mResolveComponentName, mInstantAppResolverSettingsComponent,
- mRequiredSdkSandboxPackage, mServicesExtensionPackageName,
- mSharedSystemSharedLibraryPackageName);
+ mServicesExtensionPackageName, mSharedSystemSharedLibraryPackageName);
}
@Override
diff --git a/services/core/java/com/android/server/pm/ProtectedPackages.java b/services/core/java/com/android/server/pm/ProtectedPackages.java
index 98533725..524252c 100644
--- a/services/core/java/com/android/server/pm/ProtectedPackages.java
+++ b/services/core/java/com/android/server/pm/ProtectedPackages.java
@@ -57,11 +57,8 @@
@GuardedBy("this")
private final SparseArray<Set<String>> mOwnerProtectedPackages = new SparseArray<>();
- private final Context mContext;
-
public ProtectedPackages(Context context) {
- mContext = context;
- mDeviceProvisioningPackage = mContext.getResources().getString(
+ mDeviceProvisioningPackage = context.getResources().getString(
R.string.config_deviceProvisioningPackage);
}
diff --git a/services/core/java/com/android/server/pm/RemovePackageHelper.java b/services/core/java/com/android/server/pm/RemovePackageHelper.java
index 7bd6a43..3e3b72c 100644
--- a/services/core/java/com/android/server/pm/RemovePackageHelper.java
+++ b/services/core/java/com/android/server/pm/RemovePackageHelper.java
@@ -67,7 +67,6 @@
private final PackageManagerService mPm;
private final IncrementalManager mIncrementalManager;
private final Installer mInstaller;
- private final UserManagerInternal mUserManagerInternal;
private final PermissionManagerServiceInternal mPermissionManager;
private final SharedLibrariesImpl mSharedLibraries;
private final AppDataHelper mAppDataHelper;
@@ -79,7 +78,6 @@
mPm = pm;
mIncrementalManager = mPm.mInjector.getIncrementalManager();
mInstaller = mPm.mInjector.getInstaller();
- mUserManagerInternal = mPm.mInjector.getUserManagerInternal();
mPermissionManager = mPm.mInjector.getPermissionManagerServiceInternal();
mSharedLibraries = mPm.mInjector.getSharedLibrariesImpl();
mAppDataHelper = appDataHelper;
diff --git a/services/core/java/com/android/server/pm/ShortcutNonPersistentUser.java b/services/core/java/com/android/server/pm/ShortcutNonPersistentUser.java
index 7f6f684..aa52522 100644
--- a/services/core/java/com/android/server/pm/ShortcutNonPersistentUser.java
+++ b/services/core/java/com/android/server/pm/ShortcutNonPersistentUser.java
@@ -31,7 +31,6 @@
* The access to it must be guarded with the shortcut manager lock.
*/
public class ShortcutNonPersistentUser {
- private final ShortcutService mService;
private final int mUserId;
@@ -49,8 +48,7 @@
*/
private final ArraySet<String> mHostPackageSet = new ArraySet<>();
- public ShortcutNonPersistentUser(ShortcutService service, int userId) {
- mService = service;
+ public ShortcutNonPersistentUser(int userId) {
mUserId = userId;
}
diff --git a/services/core/java/com/android/server/pm/ShortcutPackage.java b/services/core/java/com/android/server/pm/ShortcutPackage.java
index e993d9e..d644235 100644
--- a/services/core/java/com/android/server/pm/ShortcutPackage.java
+++ b/services/core/java/com/android/server/pm/ShortcutPackage.java
@@ -33,6 +33,7 @@
import android.app.appsearch.SearchResults;
import android.app.appsearch.SearchSpec;
import android.app.appsearch.SetSchemaRequest;
+import android.app.usage.UsageStatsManagerInternal;
import android.content.ComponentName;
import android.content.Intent;
import android.content.IntentFilter;
@@ -47,6 +48,7 @@
import android.os.Binder;
import android.os.PersistableBundle;
import android.os.StrictMode;
+import android.os.SystemClock;
import android.text.format.Formatter;
import android.util.ArrayMap;
import android.util.ArraySet;
@@ -192,6 +194,9 @@
private long mLastKnownForegroundElapsedTime;
@GuardedBy("mLock")
+ private long mLastReportedTime;
+
+ @GuardedBy("mLock")
private boolean mIsAppSearchSchemaUpToDate;
private ShortcutPackage(ShortcutUser shortcutUser,
@@ -1673,6 +1678,26 @@
return condition[0];
}
+ void reportShortcutUsed(@NonNull final UsageStatsManagerInternal usageStatsManagerInternal,
+ @NonNull final String shortcutId) {
+ synchronized (mLock) {
+ final long currentTS = SystemClock.elapsedRealtime();
+ final ShortcutService s = mShortcutUser.mService;
+ if (currentTS - mLastReportedTime > s.mSaveDelayMillis) {
+ mLastReportedTime = currentTS;
+ } else {
+ return;
+ }
+ final long token = s.injectClearCallingIdentity();
+ try {
+ usageStatsManagerInternal.reportShortcutUsage(getPackageName(), shortcutId,
+ getPackageUserId());
+ } finally {
+ s.injectRestoreCallingIdentity(token);
+ }
+ }
+ }
+
public void dump(@NonNull PrintWriter pw, @NonNull String prefix, DumpFilter filter) {
pw.println();
diff --git a/services/core/java/com/android/server/pm/ShortcutService.java b/services/core/java/com/android/server/pm/ShortcutService.java
index 446c629..c23d2ab 100644
--- a/services/core/java/com/android/server/pm/ShortcutService.java
+++ b/services/core/java/com/android/server/pm/ShortcutService.java
@@ -371,7 +371,7 @@
private CompressFormat mIconPersistFormat;
private int mIconPersistQuality;
- private int mSaveDelayMillis;
+ int mSaveDelayMillis;
private final IPackageManager mIPackageManager;
private final PackageManagerInternal mPackageManagerInternal;
@@ -1378,7 +1378,7 @@
ShortcutNonPersistentUser getNonPersistentUserLocked(@UserIdInt int userId) {
ShortcutNonPersistentUser ret = mShortcutNonPersistentUsers.get(userId);
if (ret == null) {
- ret = new ShortcutNonPersistentUser(this, userId);
+ ret = new ShortcutNonPersistentUser(userId);
mShortcutNonPersistentUsers.put(userId, ret);
}
return ret;
@@ -2291,7 +2291,7 @@
packageShortcutsChanged(ps, changedShortcuts, removedShortcuts);
- reportShortcutUsedInternal(packageName, shortcut.getId(), userId);
+ ps.reportShortcutUsed(mUsageStatsManagerInternal, shortcut.getId());
verifyStates();
}
@@ -2695,25 +2695,17 @@
Slog.d(TAG, String.format("reportShortcutUsed: Shortcut %s package %s used on user %d",
shortcutId, packageName, userId));
}
+ final ShortcutPackage ps;
synchronized (mLock) {
throwIfUserLockedL(userId);
- final ShortcutPackage ps = getPackageShortcutsForPublisherLocked(packageName, userId);
+ ps = getPackageShortcutsForPublisherLocked(packageName, userId);
if (ps.findShortcutById(shortcutId) == null) {
Log.w(TAG, String.format("reportShortcutUsed: package %s doesn't have shortcut %s",
packageName, shortcutId));
return;
}
}
- reportShortcutUsedInternal(packageName, shortcutId, userId);
- }
-
- private void reportShortcutUsedInternal(String packageName, String shortcutId, int userId) {
- final long token = injectClearCallingIdentity();
- try {
- mUsageStatsManagerInternal.reportShortcutUsage(packageName, shortcutId, userId);
- } finally {
- injectRestoreCallingIdentity(token);
- }
+ ps.reportShortcutUsed(mUsageStatsManagerInternal, shortcutId);
}
@Override
@@ -5202,13 +5194,11 @@
}
// Injection point.
- @VisibleForTesting
long injectClearCallingIdentity() {
return Binder.clearCallingIdentity();
}
// Injection point.
- @VisibleForTesting
void injectRestoreCallingIdentity(long token) {
Binder.restoreCallingIdentity(token);
}
diff --git a/services/core/java/com/android/server/pm/UserDataPreparer.java b/services/core/java/com/android/server/pm/UserDataPreparer.java
index 4c42c2d..1d41401 100644
--- a/services/core/java/com/android/server/pm/UserDataPreparer.java
+++ b/services/core/java/com/android/server/pm/UserDataPreparer.java
@@ -141,7 +141,7 @@
// If internal storage of the system user fails to prepare on first boot, then
// things are *really* broken, so we might as well reboot to recovery right away.
try {
- Log.wtf(TAG, "prepareUserData failed for user " + userId, e);
+ Log.e(TAG, "prepareUserData failed for user " + userId, e);
if (isNewUser && userId == UserHandle.USER_SYSTEM && volumeUuid == null) {
RecoverySystem.rebootPromptAndWipeUserData(mContext,
"failed to prepare internal storage for system user");
diff --git a/services/core/java/com/android/server/pm/UserManagerService.java b/services/core/java/com/android/server/pm/UserManagerService.java
index c1b7489..7b0a69b 100644
--- a/services/core/java/com/android/server/pm/UserManagerService.java
+++ b/services/core/java/com/android/server/pm/UserManagerService.java
@@ -46,6 +46,7 @@
import android.app.ActivityManager;
import android.app.ActivityManagerInternal;
import android.app.ActivityManagerNative;
+import android.app.ActivityOptions;
import android.app.BroadcastOptions;
import android.app.IActivityManager;
import android.app.IStopUserCallback;
@@ -587,7 +588,10 @@
public void onFinished(int id, Bundle extras) {
mHandler.post(() -> {
try {
- mContext.startIntentSender(mTarget, null, 0, 0, 0);
+ ActivityOptions activityOptions =
+ ActivityOptions.makeBasic().setPendingIntentBackgroundActivityStartMode(
+ ActivityOptions.MODE_BACKGROUND_ACTIVITY_START_ALLOWED);
+ mContext.startIntentSender(mTarget, null, 0, 0, 0, activityOptions.toBundle());
} catch (IntentSender.SendIntentException e) {
Slog.e(LOG_TAG, "Failed to start the target in the callback", e);
}
diff --git a/services/core/java/com/android/server/pm/VerifyingSession.java b/services/core/java/com/android/server/pm/VerifyingSession.java
index c6435ae..f0ff85d 100644
--- a/services/core/java/com/android/server/pm/VerifyingSession.java
+++ b/services/core/java/com/android/server/pm/VerifyingSession.java
@@ -356,6 +356,11 @@
if (verifierUser == UserHandle.ALL) {
verifierUser = UserHandle.of(mPm.mUserManager.getCurrentUserId());
}
+ // TODO(b/300965895): Remove when inconsistencies loading classpaths from apex for
+ // user > 1 are fixed.
+ if (pkgLite.isSdkLibrary) {
+ verifierUser = UserHandle.SYSTEM;
+ }
final int verifierUserId = verifierUser.getIdentifier();
List<String> requiredVerifierPackages = new ArrayList<>(
diff --git a/services/core/java/com/android/server/pm/permission/PermissionManagerService.java b/services/core/java/com/android/server/pm/permission/PermissionManagerService.java
index 5d710d2..40f2264 100644
--- a/services/core/java/com/android/server/pm/permission/PermissionManagerService.java
+++ b/services/core/java/com/android/server/pm/permission/PermissionManagerService.java
@@ -29,6 +29,7 @@
import static android.app.AppOpsManager.OP_BLUETOOTH_CONNECT;
import static android.content.pm.ApplicationInfo.AUTO_REVOKE_DISALLOWED;
import static android.content.pm.ApplicationInfo.AUTO_REVOKE_DISCOURAGED;
+import static android.permission.flags.Flags.serverSideAttributionRegistration;
import static com.android.server.pm.PackageManagerService.PLATFORM_PACKAGE_NAME;
@@ -76,7 +77,6 @@
import com.android.internal.util.function.QuadFunction;
import com.android.internal.util.function.TriFunction;
import com.android.server.LocalServices;
-import com.android.server.pm.UserManagerInternal;
import com.android.server.pm.UserManagerService;
import com.android.server.pm.permission.PermissionManagerServiceInternal.HotwordDetectionServiceProvider;
import com.android.server.pm.pkg.AndroidPackage;
@@ -113,9 +113,6 @@
/** Internal connection to the package manager */
private final PackageManagerInternal mPackageManagerInt;
- /** Internal connection to the user manager */
- private final UserManagerInternal mUserManagerInt;
-
/** Map of OneTimePermissionUserManagers keyed by userId */
@GuardedBy("mLock")
@NonNull
@@ -147,7 +144,6 @@
mContext = context;
mPackageManagerInt = LocalServices.getService(PackageManagerInternal.class);
- mUserManagerInt = LocalServices.getService(UserManagerInternal.class);
mAppOpsManager = context.getSystemService(AppOpsManager.class);
mAttributionSourceRegistry = new AttributionSourceRegistry(context);
@@ -439,10 +435,27 @@
}
}
+ /**
+ * Reference propagation over binder is affected by the ownership of the object. So if
+ * the token is owned by client, references to the token on client side won't be
+ * propagated to the server and the token may still be garbage collected on server side.
+ * But if the token is owned by server, references to the token on client side will now
+ * be propagated to the server since it's a foreign object to the client, and that will
+ * keep the token referenced on the server side as long as the client is alive and
+ * holding it.
+ */
@Override
- public void registerAttributionSource(@NonNull AttributionSourceState source) {
- mAttributionSourceRegistry
- .registerAttributionSource(new AttributionSource(source));
+ public IBinder registerAttributionSource(@NonNull AttributionSourceState source) {
+ if (serverSideAttributionRegistration()) {
+ Binder token = new Binder();
+ mAttributionSourceRegistry
+ .registerAttributionSource(new AttributionSource(source).withToken(token));
+ return token;
+ } else {
+ mAttributionSourceRegistry
+ .registerAttributionSource(new AttributionSource(source));
+ return source.token;
+ }
}
@Override
@@ -1080,12 +1093,10 @@
private static final AtomicInteger sAttributionChainIds = new AtomicInteger(0);
private final @NonNull Context mContext;
- private final @NonNull AppOpsManager mAppOpsManager;
private final @NonNull PermissionManagerServiceInternal mPermissionManagerServiceInternal;
PermissionCheckerService(@NonNull Context context) {
mContext = context;
- mAppOpsManager = mContext.getSystemService(AppOpsManager.class);
mPermissionManagerServiceInternal =
LocalServices.getService(PermissionManagerServiceInternal.class);
}
@@ -1218,7 +1229,6 @@
@Nullable String message, boolean forDataDelivery, boolean startDataDelivery,
boolean fromDatasource, int attributedOp) {
PermissionInfo permissionInfo = sPlatformPermissions.get(permission);
-
if (permissionInfo == null) {
try {
permissionInfo = context.getPackageManager().getPermissionInfo(permission, 0);
@@ -1346,8 +1356,8 @@
// If the call is from a datasource we need to vet only the chain before it. This
// way we can avoid the datasource creating an attribution context for every call.
- if (!(fromDatasource && current.equals(attributionSource))
- && next != null && !current.isTrusted(context)) {
+ boolean isDatasource = fromDatasource && current.equals(attributionSource);
+ if (!isDatasource && next != null && !current.isTrusted(context)) {
return PermissionChecker.PERMISSION_HARD_DENIED;
}
diff --git a/services/core/java/com/android/server/pm/permission/PermissionManagerServiceImpl.java b/services/core/java/com/android/server/pm/permission/PermissionManagerServiceImpl.java
index 3afba39..6a57362 100644
--- a/services/core/java/com/android/server/pm/permission/PermissionManagerServiceImpl.java
+++ b/services/core/java/com/android/server/pm/permission/PermissionManagerServiceImpl.java
@@ -279,7 +279,6 @@
@NonNull
private final int[] mGlobalGids;
- private final HandlerThread mHandlerThread;
private final Handler mHandler;
private final Context mContext;
private final MetricsLogger mMetricsLogger = new MetricsLogger();
@@ -432,10 +431,10 @@
}
}
- mHandlerThread = new ServiceThread(TAG,
+ HandlerThread handlerThread = new ServiceThread(TAG,
Process.THREAD_PRIORITY_BACKGROUND, true /*allowIo*/);
- mHandlerThread.start();
- mHandler = new Handler(mHandlerThread.getLooper());
+ handlerThread.start();
+ mHandler = new Handler(handlerThread.getLooper());
Watchdog.getInstance().addThread(mHandler);
SystemConfig systemConfig = SystemConfig.getInstance();
diff --git a/services/core/java/com/android/server/power/PowerManagerService.java b/services/core/java/com/android/server/power/PowerManagerService.java
index e226953..a172de0 100644
--- a/services/core/java/com/android/server/power/PowerManagerService.java
+++ b/services/core/java/com/android/server/power/PowerManagerService.java
@@ -4413,8 +4413,8 @@
private boolean setPowerModeInternal(int mode, boolean enabled) {
// Maybe filter the event.
- if (mBatterySaverStateMachine == null || (mode == Mode.LAUNCH && enabled
- && mBatterySaverStateMachine.getBatterySaverController().isLaunchBoostDisabled())) {
+ if (mode == Mode.LAUNCH && enabled && mBatterySaverStateMachine != null
+ && mBatterySaverStateMachine.getBatterySaverController().isLaunchBoostDisabled()) {
return false;
}
return mNativeWrapper.nativeSetPowerMode(mode, enabled);
diff --git a/services/core/java/com/android/server/security/FileIntegrityService.java b/services/core/java/com/android/server/security/FileIntegrityService.java
index a49df50..bb4876b 100644
--- a/services/core/java/com/android/server/security/FileIntegrityService.java
+++ b/services/core/java/com/android/server/security/FileIntegrityService.java
@@ -157,7 +157,7 @@
Objects.requireNonNull(authFd);
try {
var authToken = getStorageManagerInternal().createFsveritySetupAuthToken(authFd,
- Binder.getCallingUid(), Binder.getCallingUserHandle().getIdentifier());
+ Binder.getCallingUid());
// fs-verity setup requires no writable fd to the file. Release the dup now that
// it's passed.
authFd.close();
diff --git a/services/core/java/com/android/server/tv/interactive/TvInteractiveAppManagerService.java b/services/core/java/com/android/server/tv/interactive/TvInteractiveAppManagerService.java
index 0467d0c..7ab075e 100644
--- a/services/core/java/com/android/server/tv/interactive/TvInteractiveAppManagerService.java
+++ b/services/core/java/com/android/server/tv/interactive/TvInteractiveAppManagerService.java
@@ -38,7 +38,16 @@
import android.media.tv.BroadcastInfoResponse;
import android.media.tv.TvRecordingInfo;
import android.media.tv.TvTrackInfo;
+import android.media.tv.ad.ITvAdClient;
import android.media.tv.ad.ITvAdManager;
+import android.media.tv.ad.ITvAdManagerCallback;
+import android.media.tv.ad.ITvAdService;
+import android.media.tv.ad.ITvAdServiceCallback;
+import android.media.tv.ad.ITvAdSession;
+import android.media.tv.ad.ITvAdSessionCallback;
+import android.media.tv.ad.TvAdService;
+import android.media.tv.ad.TvAdServiceInfo;
+import android.media.tv.flags.Flags;
import android.media.tv.interactive.AppLinkInfo;
import android.media.tv.interactive.ITvInteractiveAppClient;
import android.media.tv.interactive.ITvInteractiveAppManager;
@@ -110,6 +119,8 @@
@GuardedBy("mLock")
private boolean mGetServiceListCalled = false;
@GuardedBy("mLock")
+ private boolean mGetAdServiceListCalled = false;
+ @GuardedBy("mLock")
private boolean mGetAppLinkInfoListCalled = false;
private final UserManager mUserManager;
@@ -256,6 +267,141 @@
}
@GuardedBy("mLock")
+ private void buildTvAdServiceListLocked(int userId, String[] updatedPackages) {
+ if (!Flags.enableAdServiceFw()) {
+ return;
+ }
+ UserState userState = getOrCreateUserStateLocked(userId);
+ userState.mPackageSet.clear();
+
+ if (DEBUG) {
+ Slogf.d(TAG, "buildTvAdServiceListLocked");
+ }
+ PackageManager pm = mContext.getPackageManager();
+ List<ResolveInfo> services = pm.queryIntentServicesAsUser(
+ new Intent(TvAdService.SERVICE_INTERFACE),
+ PackageManager.GET_SERVICES | PackageManager.GET_META_DATA,
+ userId);
+ List<TvAdServiceInfo> serviceList = new ArrayList<>();
+
+ for (ResolveInfo ri : services) {
+ ServiceInfo si = ri.serviceInfo;
+ if (!android.Manifest.permission.BIND_TV_AD_SERVICE.equals(si.permission)) {
+ Slog.w(TAG, "Skipping TV AD service " + si.name
+ + ": it does not require the permission "
+ + android.Manifest.permission.BIND_TV_AD_SERVICE);
+ continue;
+ }
+
+ ComponentName component = new ComponentName(si.packageName, si.name);
+ try {
+ TvAdServiceInfo info = new TvAdServiceInfo(mContext, component);
+ serviceList.add(info);
+ } catch (Exception e) {
+ Slogf.e(TAG, "failed to load TV AD service " + si.name, e);
+ continue;
+ }
+ userState.mPackageSet.add(si.packageName);
+ }
+
+ // sort the service list by service id
+ Collections.sort(serviceList, Comparator.comparing(TvAdServiceInfo::getId));
+ Map<String, TvAdServiceState> adServiceMap = new HashMap<>();
+ for (TvAdServiceInfo info : serviceList) {
+ String serviceId = info.getId();
+ if (DEBUG) {
+ Slogf.d(TAG, "add " + serviceId);
+ }
+ TvAdServiceState adServiceState = userState.mAdServiceMap.get(serviceId);
+ if (adServiceState == null) {
+ adServiceState = new TvAdServiceState();
+ }
+ adServiceState.mInfo = info;
+ adServiceState.mUid = getAdServiceUid(info);
+ adServiceState.mComponentName = info.getComponent();
+ adServiceMap.put(serviceId, adServiceState);
+ }
+
+ for (String serviceId : adServiceMap.keySet()) {
+ if (!userState.mAdServiceMap.containsKey(serviceId)) {
+ notifyAdServiceAddedLocked(userState, serviceId);
+ } else if (updatedPackages != null) {
+ // Notify the package updates
+ ComponentName component = adServiceMap.get(serviceId).mInfo.getComponent();
+ for (String updatedPackage : updatedPackages) {
+ if (component.getPackageName().equals(updatedPackage)) {
+ updateAdServiceConnectionLocked(component, userId);
+ notifyAdServiceUpdatedLocked(userState, serviceId);
+ break;
+ }
+ }
+ }
+ }
+
+ for (String serviceId : userState.mAdServiceMap.keySet()) {
+ if (!adServiceMap.containsKey(serviceId)) {
+ TvAdServiceInfo info = userState.mAdServiceMap.get(serviceId).mInfo;
+ AdServiceState serviceState = userState.mAdServiceStateMap.get(info.getComponent());
+ if (serviceState != null) {
+ abortPendingCreateAdSessionRequestsLocked(serviceState, serviceId, userId);
+ }
+ notifyAdServiceRemovedLocked(userState, serviceId);
+ }
+ }
+
+ userState.mIAppMap.clear();
+ userState.mAdServiceMap = adServiceMap;
+ }
+
+ @GuardedBy("mLock")
+ private void notifyAdServiceAddedLocked(UserState userState, String serviceId) {
+ if (DEBUG) {
+ Slog.d(TAG, "notifyAdServiceAddedLocked(serviceId=" + serviceId + ")");
+ }
+ int n = userState.mAdCallbacks.beginBroadcast();
+ for (int i = 0; i < n; ++i) {
+ try {
+ userState.mAdCallbacks.getBroadcastItem(i).onAdServiceAdded(serviceId);
+ } catch (RemoteException e) {
+ Slog.e(TAG, "failed to report added AD service to callback", e);
+ }
+ }
+ userState.mAdCallbacks.finishBroadcast();
+ }
+
+ @GuardedBy("mLock")
+ private void notifyAdServiceRemovedLocked(UserState userState, String serviceId) {
+ if (DEBUG) {
+ Slog.d(TAG, "notifyAdServiceRemovedLocked(serviceId=" + serviceId + ")");
+ }
+ int n = userState.mAdCallbacks.beginBroadcast();
+ for (int i = 0; i < n; ++i) {
+ try {
+ userState.mAdCallbacks.getBroadcastItem(i).onAdServiceRemoved(serviceId);
+ } catch (RemoteException e) {
+ Slog.e(TAG, "failed to report removed AD service to callback", e);
+ }
+ }
+ userState.mAdCallbacks.finishBroadcast();
+ }
+
+ @GuardedBy("mLock")
+ private void notifyAdServiceUpdatedLocked(UserState userState, String serviceId) {
+ if (DEBUG) {
+ Slog.d(TAG, "notifyAdServiceUpdatedLocked(serviceId=" + serviceId + ")");
+ }
+ int n = userState.mAdCallbacks.beginBroadcast();
+ for (int i = 0; i < n; ++i) {
+ try {
+ userState.mAdCallbacks.getBroadcastItem(i).onAdServiceUpdated(serviceId);
+ } catch (RemoteException e) {
+ Slog.e(TAG, "failed to report updated AD service to callback", e);
+ }
+ }
+ userState.mAdCallbacks.finishBroadcast();
+ }
+
+ @GuardedBy("mLock")
private void notifyInteractiveAppServiceAddedLocked(UserState userState, String iAppServiceId) {
if (DEBUG) {
Slog.d(TAG, "notifyInteractiveAppServiceAddedLocked(iAppServiceId="
@@ -340,6 +486,16 @@
}
}
+ private int getAdServiceUid(TvAdServiceInfo info) {
+ try {
+ return getContext().getPackageManager().getApplicationInfo(
+ info.getServiceInfo().packageName, 0).uid;
+ } catch (PackageManager.NameNotFoundException e) {
+ Slogf.w(TAG, "Unable to get UID for " + info, e);
+ return Process.INVALID_UID;
+ }
+ }
+
@Override
public void onStart() {
if (DEBUG) {
@@ -357,6 +513,7 @@
synchronized (mLock) {
buildTvInteractiveAppServiceListLocked(mCurrentUserId, null);
buildAppLinkInfoLocked(mCurrentUserId);
+ buildTvAdServiceListLocked(mCurrentUserId, null);
}
}
}
@@ -372,6 +529,14 @@
}
}
}
+ private void buildTvAdServiceList(String[] packages) {
+ int userId = getChangingUserId();
+ synchronized (mLock) {
+ if (mCurrentUserId == userId || mRunningProfiles.contains(userId)) {
+ buildTvAdServiceListLocked(userId, packages);
+ }
+ }
+ }
@Override
public void onPackageUpdateFinished(String packageName, int uid) {
@@ -379,6 +544,7 @@
// This callback is invoked when the TV interactive App service is reinstalled.
// In this case, isReplacing() always returns true.
buildTvInteractiveAppServiceList(new String[] { packageName });
+ buildTvAdServiceList(new String[] { packageName });
}
@Override
@@ -390,6 +556,7 @@
// available.
if (isReplacing()) {
buildTvInteractiveAppServiceList(packages);
+ buildTvAdServiceList(packages);
}
}
@@ -403,6 +570,7 @@
}
if (isReplacing()) {
buildTvInteractiveAppServiceList(packages);
+ buildTvAdServiceList(packages);
}
}
@@ -418,6 +586,7 @@
return;
}
buildTvInteractiveAppServiceList(null);
+ buildTvAdServiceList(null);
}
@Override
@@ -476,6 +645,7 @@
mCurrentUserId = userId;
buildTvInteractiveAppServiceListLocked(userId, null);
buildAppLinkInfoLocked(userId);
+ buildTvAdServiceListLocked(userId, null);
}
}
@@ -562,6 +732,7 @@
mRunningProfiles.add(userId);
buildTvInteractiveAppServiceListLocked(userId, null);
buildAppLinkInfoLocked(userId);
+ buildTvAdServiceListLocked(userId, null);
}
@GuardedBy("mLock")
@@ -619,7 +790,19 @@
Slog.e(TAG, "error in onSessionReleased", e);
}
}
- removeSessionStateLocked(state.mSessionToken, state.mUserId);
+ removeAdSessionStateLocked(state.mSessionToken, state.mUserId);
+ }
+
+ @GuardedBy("mLock")
+ private void clearAdSessionAndNotifyClientLocked(AdSessionState state) {
+ if (state.mClient != null) {
+ try {
+ state.mClient.onSessionReleased(state.mSeq);
+ } catch (RemoteException e) {
+ Slog.e(TAG, "error in onSessionReleased", e);
+ }
+ }
+ removeAdSessionStateLocked(state.mSessionToken, state.mUserId);
}
private int resolveCallingUserId(int callingPid, int callingUid, int requestedUserId,
@@ -655,6 +838,44 @@
}
@GuardedBy("mLock")
+ private AdSessionState getAdSessionStateLocked(
+ IBinder sessionToken, int callingUid, int userId) {
+ UserState userState = getOrCreateUserStateLocked(userId);
+ return getAdSessionStateLocked(sessionToken, callingUid, userState);
+ }
+
+ @GuardedBy("mLock")
+ private AdSessionState getAdSessionStateLocked(IBinder sessionToken, int callingUid,
+ UserState userState) {
+ AdSessionState sessionState = userState.mAdSessionStateMap.get(sessionToken);
+ if (sessionState == null) {
+ throw new SessionNotFoundException("Session state not found for token " + sessionToken);
+ }
+ // Only the application that requested this session or the system can access it.
+ if (callingUid != Process.SYSTEM_UID && callingUid != sessionState.mCallingUid) {
+ throw new SecurityException("Illegal access to the session with token " + sessionToken
+ + " from uid " + callingUid);
+ }
+ return sessionState;
+ }
+
+ @GuardedBy("mLock")
+ private ITvAdSession getAdSessionLocked(
+ IBinder sessionToken, int callingUid, int userId) {
+ return getAdSessionLocked(getAdSessionStateLocked(sessionToken, callingUid, userId));
+ }
+
+ @GuardedBy("mLock")
+ private ITvAdSession getAdSessionLocked(AdSessionState sessionState) {
+ ITvAdSession session = sessionState.mSession;
+ if (session == null) {
+ throw new IllegalStateException("Session not yet created for token "
+ + sessionState.mSessionToken);
+ }
+ return session;
+ }
+
+ @GuardedBy("mLock")
private SessionState getSessionStateLocked(IBinder sessionToken, int callingUid, int userId) {
UserState userState = getOrCreateUserStateLocked(userId);
return getSessionStateLocked(sessionToken, callingUid, userState);
@@ -691,10 +912,200 @@
return session;
}
private final class TvAdBinderService extends ITvAdManager.Stub {
+
+ @Override
+ public List<TvAdServiceInfo> getTvAdServiceList(int userId) {
+ final int resolvedUserId = resolveCallingUserId(Binder.getCallingPid(),
+ Binder.getCallingUid(), userId, "getTvAdServiceList");
+ final long identity = Binder.clearCallingIdentity();
+ try {
+ synchronized (mLock) {
+ if (!mGetAdServiceListCalled) {
+ buildTvAdServiceListLocked(userId, null);
+ mGetAdServiceListCalled = true;
+ }
+ UserState userState = getOrCreateUserStateLocked(resolvedUserId);
+ List<TvAdServiceInfo> adServiceList = new ArrayList<>();
+ for (TvAdServiceState state : userState.mAdServiceMap.values()) {
+ adServiceList.add(state.mInfo);
+ }
+ return adServiceList;
+ }
+ } finally {
+ Binder.restoreCallingIdentity(identity);
+ }
+ }
+
+ @Override
+ public void createSession(final ITvAdClient client, final String serviceId, String type,
+ int seq, int userId) {
+ final int callingUid = Binder.getCallingUid();
+ final int callingPid = Binder.getCallingPid();
+ final int resolvedUserId = resolveCallingUserId(callingPid, callingUid,
+ userId, "createSession");
+ final long identity = Binder.clearCallingIdentity();
+
+ try {
+ synchronized (mLock) {
+ if (userId != mCurrentUserId && !mRunningProfiles.contains(userId)) {
+ // Only current user and its running profiles can create sessions.
+ // Let the client get onConnectionFailed callback for this case.
+ sendAdSessionTokenToClientLocked(client, serviceId, null, null, seq);
+ return;
+ }
+ UserState userState = getOrCreateUserStateLocked(resolvedUserId);
+ TvAdServiceState adState = userState.mAdMap.get(serviceId);
+ if (adState == null) {
+ Slogf.w(TAG, "Failed to find state for serviceId=" + serviceId);
+ sendAdSessionTokenToClientLocked(client, serviceId, null, null, seq);
+ return;
+ }
+ AdServiceState serviceState =
+ userState.mAdServiceStateMap.get(adState.mComponentName);
+ if (serviceState == null) {
+ int tasUid = PackageManager.getApplicationInfoAsUserCached(
+ adState.mComponentName.getPackageName(), 0, resolvedUserId).uid;
+ serviceState = new AdServiceState(
+ adState.mComponentName, serviceId, resolvedUserId);
+ userState.mAdServiceStateMap.put(adState.mComponentName, serviceState);
+ }
+ // Send a null token immediately while reconnecting.
+ if (serviceState.mReconnecting) {
+ sendAdSessionTokenToClientLocked(client, serviceId, null, null, seq);
+ return;
+ }
+
+ // Create a new session token and a session state.
+ IBinder sessionToken = new Binder();
+ AdSessionState sessionState = new AdSessionState(sessionToken, serviceId, type,
+ adState.mComponentName, client, seq, callingUid,
+ callingPid, resolvedUserId);
+
+ // Add them to the global session state map of the current user.
+ userState.mAdSessionStateMap.put(sessionToken, sessionState);
+
+ // Also, add them to the session state map of the current service.
+ serviceState.mSessionTokens.add(sessionToken);
+
+ if (serviceState.mService != null) {
+ if (!createAdSessionInternalLocked(serviceState.mService, sessionToken,
+ resolvedUserId)) {
+ removeAdSessionStateLocked(sessionToken, resolvedUserId);
+ }
+ } else {
+ updateAdServiceConnectionLocked(adState.mComponentName, resolvedUserId);
+ }
+ }
+ } finally {
+ Binder.restoreCallingIdentity(identity);
+ }
+ }
+
+ @Override
+ public void releaseSession(IBinder sessionToken, int userId) {
+ if (DEBUG) {
+ Slogf.d(TAG, "releaseSession(sessionToken=" + sessionToken + ")");
+ }
+ final int callingUid = Binder.getCallingUid();
+ final int resolvedUserId = resolveCallingUserId(Binder.getCallingPid(), callingUid,
+ userId, "releaseSession");
+ final long identity = Binder.clearCallingIdentity();
+ try {
+ synchronized (mLock) {
+ releaseSessionLocked(sessionToken, callingUid, resolvedUserId);
+ }
+ } finally {
+ Binder.restoreCallingIdentity(identity);
+ }
+ }
+
+ @Override
+ public void setSurface(IBinder sessionToken, Surface surface, int userId) {
+ final int callingUid = Binder.getCallingUid();
+ final int resolvedUserId = resolveCallingUserId(Binder.getCallingPid(), callingUid,
+ userId, "setSurface");
+ AdSessionState sessionState = null;
+ final long identity = Binder.clearCallingIdentity();
+ try {
+ synchronized (mLock) {
+ try {
+ sessionState = getAdSessionStateLocked(sessionToken, callingUid,
+ resolvedUserId);
+ getAdSessionLocked(sessionState).setSurface(surface);
+ } catch (RemoteException | SessionNotFoundException e) {
+ Slogf.e(TAG, "error in setSurface", e);
+ }
+ }
+ } finally {
+ if (surface != null) {
+ // surface is not used in TvInteractiveAppManagerService.
+ surface.release();
+ }
+ Binder.restoreCallingIdentity(identity);
+ }
+ }
+
+ @Override
+ public void dispatchSurfaceChanged(IBinder sessionToken, int format, int width,
+ int height, int userId) {
+ final int callingUid = Binder.getCallingUid();
+ final int resolvedUserId = resolveCallingUserId(Binder.getCallingPid(), callingUid,
+ userId, "dispatchSurfaceChanged");
+ final long identity = Binder.clearCallingIdentity();
+ try {
+ synchronized (mLock) {
+ try {
+ AdSessionState sessionState = getAdSessionStateLocked(
+ sessionToken, callingUid, resolvedUserId);
+ getAdSessionLocked(sessionState).dispatchSurfaceChanged(format, width,
+ height);
+ } catch (RemoteException | SessionNotFoundException e) {
+ Slogf.e(TAG, "error in dispatchSurfaceChanged", e);
+ }
+ }
+ } finally {
+ Binder.restoreCallingIdentity(identity);
+ }
+ }
+
@Override
public void startAdService(IBinder sessionToken, int userId) {
}
+ @Override
+ public void registerCallback(final ITvAdManagerCallback callback, int userId) {
+ int callingPid = Binder.getCallingPid();
+ int callingUid = Binder.getCallingUid();
+ final int resolvedUserId = resolveCallingUserId(callingPid, callingUid, userId,
+ "registerCallback");
+ final long identity = Binder.clearCallingIdentity();
+ try {
+ synchronized (mLock) {
+ final UserState userState = getOrCreateUserStateLocked(resolvedUserId);
+ if (!userState.mAdCallbacks.register(callback)) {
+ Slog.e(TAG, "client process has already died");
+ }
+ }
+ } finally {
+ Binder.restoreCallingIdentity(identity);
+ }
+ }
+
+ @Override
+ public void unregisterCallback(ITvAdManagerCallback callback, int userId) {
+ final int resolvedUserId = resolveCallingUserId(Binder.getCallingPid(),
+ Binder.getCallingUid(), userId, "unregisterCallback");
+ final long identity = Binder.clearCallingIdentity();
+ try {
+ synchronized (mLock) {
+ UserState userState = getOrCreateUserStateLocked(resolvedUserId);
+ userState.mAdCallbacks.unregister(callback);
+ }
+ } finally {
+ Binder.restoreCallingIdentity(identity);
+ }
+ }
+
}
private final class BinderService extends ITvInteractiveAppManager.Stub {
@@ -927,7 +1338,7 @@
final long identity = Binder.clearCallingIdentity();
try {
synchronized (mLock) {
- releaseSessionLocked(sessionToken, callingUid, resolvedUserId);
+ releaseAdSessionLocked(sessionToken, callingUid, resolvedUserId);
}
} finally {
Binder.restoreCallingIdentity(identity);
@@ -1471,6 +1882,32 @@
}
@Override
+ public void sendSelectedTrackInfo(IBinder sessionToken, List<TvTrackInfo> tracks,
+ int userId) {
+ if (DEBUG) {
+ Slogf.d(TAG, "sendSelectedTrackInfo(tracks=%s)", tracks.toString());
+ }
+ final int callingUid = Binder.getCallingUid();
+ final int resolvedUserId = resolveCallingUserId(Binder.getCallingPid(), callingUid,
+ userId, "sendSelectedTrackInfo");
+ SessionState sessionState = null;
+ final long identity = Binder.clearCallingIdentity();
+ try {
+ synchronized (mLock) {
+ try {
+ sessionState = getSessionStateLocked(sessionToken, callingUid,
+ resolvedUserId);
+ getSessionLocked(sessionState).sendSelectedTrackInfo(tracks);
+ } catch (RemoteException | SessionNotFoundException e) {
+ Slogf.e(TAG, "error in sendSelectedTrackInfo", e);
+ }
+ }
+ } finally {
+ Binder.restoreCallingIdentity(identity);
+ }
+ }
+
+ @Override
public void sendCurrentTvInputId(IBinder sessionToken, String inputId, int userId) {
if (DEBUG) {
Slogf.d(TAG, "sendCurrentTvInputId(inputId=%s)", inputId);
@@ -2134,6 +2571,17 @@
}
@GuardedBy("mLock")
+ private void sendAdSessionTokenToClientLocked(
+ ITvAdClient client, String serviceId, IBinder sessionToken,
+ InputChannel channel, int seq) {
+ try {
+ client.onSessionCreated(serviceId, sessionToken, channel, seq);
+ } catch (RemoteException e) {
+ Slogf.e(TAG, "error in onSessionCreated", e);
+ }
+ }
+
+ @GuardedBy("mLock")
private boolean createSessionInternalLocked(
ITvInteractiveAppService service, IBinder sessionToken, int userId) {
UserState userState = getOrCreateUserStateLocked(userId);
@@ -2163,6 +2611,58 @@
}
@GuardedBy("mLock")
+ private boolean createAdSessionInternalLocked(
+ ITvAdService service, IBinder sessionToken, int userId) {
+ UserState userState = getOrCreateUserStateLocked(userId);
+ AdSessionState sessionState = userState.mAdSessionStateMap.get(sessionToken);
+ if (DEBUG) {
+ Slogf.d(TAG, "createAdSessionInternalLocked(iAppServiceId="
+ + sessionState.mAdServiceId + ")");
+ }
+ InputChannel[] channels = InputChannel.openInputChannelPair(sessionToken.toString());
+
+ // Set up a callback to send the session token.
+ ITvAdSessionCallback callback = new AdSessionCallback(sessionState, channels);
+
+ boolean created = true;
+ // Create a session. When failed, send a null token immediately.
+ try {
+ service.createSession(
+ channels[1], callback, sessionState.mAdServiceId, sessionState.mType);
+ } catch (RemoteException e) {
+ Slogf.e(TAG, "error in createSession", e);
+ sendAdSessionTokenToClientLocked(sessionState.mClient, sessionState.mAdServiceId, null,
+ null, sessionState.mSeq);
+ created = false;
+ }
+ channels[1].dispose();
+ return created;
+ }
+
+ @GuardedBy("mLock")
+ @Nullable
+ private AdSessionState releaseAdSessionLocked(
+ IBinder sessionToken, int callingUid, int userId) {
+ AdSessionState sessionState = null;
+ try {
+ sessionState = getAdSessionStateLocked(sessionToken, callingUid, userId);
+ UserState userState = getOrCreateUserStateLocked(userId);
+ if (sessionState.mSession != null) {
+ sessionState.mSession.asBinder().unlinkToDeath(sessionState, 0);
+ sessionState.mSession.release();
+ }
+ } catch (RemoteException | SessionNotFoundException e) {
+ Slogf.e(TAG, "error in releaseSession", e);
+ } finally {
+ if (sessionState != null) {
+ sessionState.mSession = null;
+ }
+ }
+ removeAdSessionStateLocked(sessionToken, userId);
+ return sessionState;
+ }
+
+ @GuardedBy("mLock")
@Nullable
private SessionState releaseSessionLocked(IBinder sessionToken, int callingUid, int userId) {
SessionState sessionState = null;
@@ -2215,6 +2715,36 @@
}
@GuardedBy("mLock")
+ private void removeAdSessionStateLocked(IBinder sessionToken, int userId) {
+ UserState userState = getOrCreateUserStateLocked(userId);
+
+ // Remove the session state from the global session state map of the current user.
+ AdSessionState sessionState = userState.mAdSessionStateMap.remove(sessionToken);
+
+ if (sessionState == null) {
+ Slogf.e(TAG, "sessionState null, no more remove session action!");
+ return;
+ }
+
+ // Also remove the session token from the session token list of the current client and
+ // service.
+ ClientState clientState = userState.mClientStateMap.get(sessionState.mClient.asBinder());
+ if (clientState != null) {
+ clientState.mSessionTokens.remove(sessionToken);
+ if (clientState.isEmpty()) {
+ userState.mClientStateMap.remove(sessionState.mClient.asBinder());
+ sessionState.mClient.asBinder().unlinkToDeath(clientState, 0);
+ }
+ }
+
+ AdServiceState serviceState = userState.mAdServiceStateMap.get(sessionState.mComponent);
+ if (serviceState != null) {
+ serviceState.mSessionTokens.remove(sessionToken);
+ }
+ updateAdServiceConnectionLocked(sessionState.mComponent, userId);
+ }
+
+ @GuardedBy("mLock")
private void abortPendingCreateSessionRequestsLocked(ServiceState serviceState,
String iAppServiceId, int userId) {
// Let clients know the create session requests are failed.
@@ -2237,6 +2767,28 @@
}
@GuardedBy("mLock")
+ private void abortPendingCreateAdSessionRequestsLocked(AdServiceState serviceState,
+ String serviceId, int userId) {
+ // Let clients know the create session requests are failed.
+ UserState userState = getOrCreateUserStateLocked(userId);
+ List<AdSessionState> sessionsToAbort = new ArrayList<>();
+ for (IBinder sessionToken : serviceState.mSessionTokens) {
+ AdSessionState sessionState = userState.mAdSessionStateMap.get(sessionToken);
+ if (sessionState.mSession == null
+ && (serviceState == null
+ || sessionState.mAdServiceId.equals(serviceId))) {
+ sessionsToAbort.add(sessionState);
+ }
+ }
+ for (AdSessionState sessionState : sessionsToAbort) {
+ removeAdSessionStateLocked(sessionState.mSessionToken, sessionState.mUserId);
+ sendAdSessionTokenToClientLocked(sessionState.mClient,
+ sessionState.mAdServiceId, null, null, sessionState.mSeq);
+ }
+ updateAdServiceConnectionLocked(serviceState.mComponent, userId);
+ }
+
+ @GuardedBy("mLock")
private void updateServiceConnectionLocked(ComponentName component, int userId) {
UserState userState = getOrCreateUserStateLocked(userId);
ServiceState serviceState = userState.mServiceStateMap.get(component);
@@ -2284,10 +2836,64 @@
}
}
+ @GuardedBy("mLock")
+ private void updateAdServiceConnectionLocked(ComponentName component, int userId) {
+ UserState userState = getOrCreateUserStateLocked(userId);
+ AdServiceState serviceState = userState.mAdServiceStateMap.get(component);
+ if (serviceState == null) {
+ return;
+ }
+ if (serviceState.mReconnecting) {
+ if (!serviceState.mSessionTokens.isEmpty()) {
+ // wait until all the sessions are removed.
+ return;
+ }
+ serviceState.mReconnecting = false;
+ }
+
+ boolean shouldBind = (!serviceState.mSessionTokens.isEmpty())
+ || (!serviceState.mPendingAppLinkCommand.isEmpty());
+
+ if (serviceState.mService == null && shouldBind) {
+ // This means that the service is not yet connected but its state indicates that we
+ // have pending requests. Then, connect the service.
+ if (serviceState.mBound) {
+ // We have already bound to the service so we don't try to bind again until after we
+ // unbind later on.
+ return;
+ }
+ if (DEBUG) {
+ Slogf.d(TAG, "bindServiceAsUser(service=" + component + ", userId=" + userId + ")");
+ }
+
+ Intent i = new Intent(TvAdService.SERVICE_INTERFACE).setComponent(component);
+ serviceState.mBound = mContext.bindServiceAsUser(
+ i, serviceState.mConnection,
+ Context.BIND_AUTO_CREATE | Context.BIND_FOREGROUND_SERVICE_WHILE_AWAKE,
+ new UserHandle(userId));
+ } else if (serviceState.mService != null && !shouldBind) {
+ // This means that the service is already connected but its state indicates that we have
+ // nothing to do with it. Then, disconnect the service.
+ if (DEBUG) {
+ Slogf.d(TAG, "unbindService(service=" + component + ")");
+ }
+ mContext.unbindService(serviceState.mConnection);
+ userState.mAdServiceStateMap.remove(component);
+ }
+ }
+
private static final class UserState {
private final int mUserId;
+ // A mapping from the TV AD service ID to its TvAdServiceState.
+ private Map<String, TvAdServiceState> mAdMap = new HashMap<>();
+ // A mapping from the name of a TV Interactive App service to its state.
+ private final Map<ComponentName, AdServiceState> mAdServiceStateMap = new HashMap<>();
+ // A mapping from the token of a TV Interactive App session to its state.
+ private final Map<IBinder, AdSessionState> mAdSessionStateMap = new HashMap<>();
// A mapping from the TV Interactive App ID to its TvInteractiveAppState.
private Map<String, TvInteractiveAppState> mIAppMap = new HashMap<>();
+ // A mapping from the TV AD service ID to its TvAdServiceState.
+ private Map<String, TvAdServiceState> mAdServiceMap = new HashMap<>();
// A mapping from the token of a client to its state.
private final Map<IBinder, ClientState> mClientStateMap = new HashMap<>();
// A mapping from the name of a TV Interactive App service to its state.
@@ -2299,6 +2905,8 @@
private final Set<String> mPackageSet = new HashSet<>();
// A list of all app link infos.
private final List<AppLinkInfo> mAppLinkInfoList = new ArrayList<>();
+ private final RemoteCallbackList<ITvAdManagerCallback> mAdCallbacks =
+ new RemoteCallbackList<>();
// A list of callbacks.
private final RemoteCallbackList<ITvInteractiveAppManagerCallback> mCallbacks =
@@ -2317,7 +2925,16 @@
private int mIAppNumber;
}
+ private static final class TvAdServiceState {
+ private String mAdServiceId;
+ private ComponentName mComponentName;
+ private TvAdServiceInfo mInfo;
+ private int mUid;
+ private int mAdNumber;
+ }
+
private final class SessionState implements IBinder.DeathRecipient {
+ // TODO: rename SessionState and reorganize classes / methods of this file
private final IBinder mSessionToken;
private ITvInteractiveAppSession mSession;
private final String mIAppServiceId;
@@ -2359,6 +2976,49 @@
}
}
+ private final class AdSessionState implements IBinder.DeathRecipient {
+ private final IBinder mSessionToken;
+ private ITvAdSession mSession;
+ private final String mAdServiceId;
+
+ private final String mType;
+ private final ITvAdClient mClient;
+ private final int mSeq;
+ private final ComponentName mComponent;
+
+ // The UID of the application that created the session.
+ // The application is usually the TV app.
+ private final int mCallingUid;
+
+ // The PID of the application that created the session.
+ // The application is usually the TV app.
+ private final int mCallingPid;
+
+ private final int mUserId;
+
+ private AdSessionState(IBinder sessionToken, String serviceId, String type,
+ ComponentName componentName, ITvAdClient client, int seq,
+ int callingUid, int callingPid, int userId) {
+ mSessionToken = sessionToken;
+ mAdServiceId = serviceId;
+ mType = type;
+ mComponent = componentName;
+ mClient = client;
+ mSeq = seq;
+ mCallingUid = callingUid;
+ mCallingPid = callingPid;
+ mUserId = userId;
+ }
+
+ @Override
+ public void binderDied() {
+ synchronized (mLock) {
+ mSession = null;
+ clearAdSessionAndNotifyClientLocked(this);
+ }
+ }
+ }
+
private final class ClientState implements IBinder.DeathRecipient {
private final List<IBinder> mSessionTokens = new ArrayList<>();
@@ -2429,6 +3089,29 @@
}
}
+ private final class AdServiceState {
+ private final List<IBinder> mSessionTokens = new ArrayList<>();
+ private final ServiceConnection mConnection;
+ private final ComponentName mComponent;
+ private final String mAdServiceId;
+ private final List<Bundle> mPendingAppLinkCommand = new ArrayList<>();
+
+ private ITvAdService mService;
+ private AdServiceCallback mCallback;
+ private boolean mBound;
+ private boolean mReconnecting;
+
+ private AdServiceState(ComponentName component, String tasId, int userId) {
+ mComponent = component;
+ mConnection = new AdServiceConnection(component, userId);
+ mAdServiceId = tasId;
+ }
+
+ private void addPendingAppLinkCommand(Bundle command) {
+ mPendingAppLinkCommand.add(command);
+ }
+ }
+
private final class InteractiveAppServiceConnection implements ServiceConnection {
private final ComponentName mComponent;
private final int mUserId;
@@ -2542,6 +3225,98 @@
}
}
+ private final class AdServiceConnection implements ServiceConnection {
+ private final ComponentName mComponent;
+ private final int mUserId;
+
+ private AdServiceConnection(ComponentName component, int userId) {
+ mComponent = component;
+ mUserId = userId;
+ }
+
+ @Override
+ public void onServiceConnected(ComponentName component, IBinder service) {
+ if (DEBUG) {
+ Slogf.d(TAG, "onServiceConnected(component=" + component + ")");
+ }
+ synchronized (mLock) {
+ UserState userState = getUserStateLocked(mUserId);
+ if (userState == null) {
+ // The user was removed while connecting.
+ mContext.unbindService(this);
+ return;
+ }
+ AdServiceState serviceState = userState.mAdServiceStateMap.get(mComponent);
+ serviceState.mService = ITvAdService.Stub.asInterface(service);
+
+ // Register a callback, if we need to.
+ if (serviceState.mCallback == null) {
+ serviceState.mCallback = new AdServiceCallback(mComponent, mUserId);
+ try {
+ serviceState.mService.registerCallback(serviceState.mCallback);
+ } catch (RemoteException e) {
+ Slog.e(TAG, "error in registerCallback", e);
+ }
+ }
+
+ if (!serviceState.mPendingAppLinkCommand.isEmpty()) {
+ for (Iterator<Bundle> it = serviceState.mPendingAppLinkCommand.iterator();
+ it.hasNext(); ) {
+ Bundle command = it.next();
+ final long identity = Binder.clearCallingIdentity();
+ try {
+ serviceState.mService.sendAppLinkCommand(command);
+ it.remove();
+ } catch (RemoteException e) {
+ Slogf.e(TAG, "error in sendAppLinkCommand(" + command
+ + ") when onServiceConnected", e);
+ } finally {
+ Binder.restoreCallingIdentity(identity);
+ }
+ }
+ }
+
+ List<IBinder> tokensToBeRemoved = new ArrayList<>();
+
+ // And create sessions, if any.
+ for (IBinder sessionToken : serviceState.mSessionTokens) {
+ if (!createAdSessionInternalLocked(
+ serviceState.mService, sessionToken, mUserId)) {
+ tokensToBeRemoved.add(sessionToken);
+ }
+ }
+
+ for (IBinder sessionToken : tokensToBeRemoved) {
+ removeAdSessionStateLocked(sessionToken, mUserId);
+ }
+ }
+ }
+
+ @Override
+ public void onServiceDisconnected(ComponentName component) {
+ if (DEBUG) {
+ Slogf.d(TAG, "onServiceDisconnected(component=" + component + ")");
+ }
+ if (!mComponent.equals(component)) {
+ throw new IllegalArgumentException("Mismatched ComponentName: "
+ + mComponent + " (expected), " + component + " (actual).");
+ }
+ synchronized (mLock) {
+ UserState userState = getOrCreateUserStateLocked(mUserId);
+ AdServiceState serviceState = userState.mAdServiceStateMap.get(mComponent);
+ if (serviceState != null) {
+ serviceState.mReconnecting = true;
+ serviceState.mBound = false;
+ serviceState.mService = null;
+ serviceState.mCallback = null;
+
+ abortPendingCreateAdSessionRequestsLocked(serviceState, null, mUserId);
+ }
+ }
+ }
+ }
+
+
private final class ServiceCallback extends ITvInteractiveAppServiceCallback.Stub {
private final ComponentName mComponent;
private final int mUserId;
@@ -2567,6 +3342,17 @@
}
}
+
+ private final class AdServiceCallback extends ITvAdServiceCallback.Stub {
+ private final ComponentName mComponent;
+ private final int mUserId;
+
+ AdServiceCallback(ComponentName component, int userId) {
+ mComponent = component;
+ mUserId = userId;
+ }
+ }
+
private final class SessionCallback extends ITvInteractiveAppSessionCallback.Stub {
private final SessionState mSessionState;
private final InputChannel[] mInputChannels;
@@ -2798,6 +3584,23 @@
}
@Override
+ public void onRequestSelectedTrackInfo() {
+ synchronized (mLock) {
+ if (DEBUG) {
+ Slogf.d(TAG, "onRequestSelectedTrackInfo");
+ }
+ if (mSessionState.mSession == null || mSessionState.mClient == null) {
+ return;
+ }
+ try {
+ mSessionState.mClient.onRequestSelectedTrackInfo(mSessionState.mSeq);
+ } catch (RemoteException e) {
+ Slogf.e(TAG, "error in onRequestSelectedTrackInfo", e);
+ }
+ }
+ }
+
+ @Override
public void onRequestCurrentTvInputId() {
synchronized (mLock) {
if (DEBUG) {
@@ -3110,6 +3913,85 @@
}
}
+ private final class AdSessionCallback extends ITvAdSessionCallback.Stub {
+ private final AdSessionState mSessionState;
+ private final InputChannel[] mInputChannels;
+
+ AdSessionCallback(AdSessionState sessionState, InputChannel[] channels) {
+ mSessionState = sessionState;
+ mInputChannels = channels;
+ }
+
+ @Override
+ public void onSessionCreated(ITvAdSession session) {
+ if (DEBUG) {
+ Slogf.d(TAG, "onSessionCreated(adServiceId="
+ + mSessionState.mAdServiceId + ")");
+ }
+ synchronized (mLock) {
+ mSessionState.mSession = session;
+ if (session != null && addAdSessionTokenToClientStateLocked(session)) {
+ sendAdSessionTokenToClientLocked(
+ mSessionState.mClient,
+ mSessionState.mAdServiceId,
+ mSessionState.mSessionToken,
+ mInputChannels[0],
+ mSessionState.mSeq);
+ } else {
+ removeAdSessionStateLocked(mSessionState.mSessionToken, mSessionState.mUserId);
+ sendAdSessionTokenToClientLocked(mSessionState.mClient,
+ mSessionState.mAdServiceId, null, null, mSessionState.mSeq);
+ }
+ mInputChannels[0].dispose();
+ }
+ }
+
+ @Override
+ public void onLayoutSurface(int left, int top, int right, int bottom) {
+ synchronized (mLock) {
+ if (DEBUG) {
+ Slogf.d(TAG, "onLayoutSurface (left=" + left + ", top=" + top
+ + ", right=" + right + ", bottom=" + bottom + ",)");
+ }
+ if (mSessionState.mSession == null || mSessionState.mClient == null) {
+ return;
+ }
+ try {
+ mSessionState.mClient.onLayoutSurface(left, top, right, bottom,
+ mSessionState.mSeq);
+ } catch (RemoteException e) {
+ Slogf.e(TAG, "error in onLayoutSurface", e);
+ }
+ }
+ }
+
+ @GuardedBy("mLock")
+ private boolean addAdSessionTokenToClientStateLocked(ITvAdSession session) {
+ try {
+ session.asBinder().linkToDeath(mSessionState, 0);
+ } catch (RemoteException e) {
+ Slogf.e(TAG, "session process has already died", e);
+ return false;
+ }
+
+ IBinder clientToken = mSessionState.mClient.asBinder();
+ UserState userState = getOrCreateUserStateLocked(mSessionState.mUserId);
+ ClientState clientState = userState.mClientStateMap.get(clientToken);
+ if (clientState == null) {
+ clientState = new ClientState(clientToken, mSessionState.mUserId);
+ try {
+ clientToken.linkToDeath(clientState, 0);
+ } catch (RemoteException e) {
+ Slogf.e(TAG, "client process has already died", e);
+ return false;
+ }
+ userState.mClientStateMap.put(clientToken, clientState);
+ }
+ clientState.mSessionTokens.add(mSessionState.mSessionToken);
+ return true;
+ }
+ }
+
private static class SessionNotFoundException extends IllegalArgumentException {
SessionNotFoundException(String name) {
super(name);
diff --git a/services/core/java/com/android/server/webkit/WebViewUpdateServiceImpl.java b/services/core/java/com/android/server/webkit/WebViewUpdateServiceImpl.java
index 60dc4ff..d95b431 100644
--- a/services/core/java/com/android/server/webkit/WebViewUpdateServiceImpl.java
+++ b/services/core/java/com/android/server/webkit/WebViewUpdateServiceImpl.java
@@ -348,6 +348,10 @@
private void pinWebviewIfRequired(ApplicationInfo appInfo) {
PinnerService pinnerService = LocalServices.getService(PinnerService.class);
+ if (pinnerService == null) {
+ // This happens in unit tests which do not have services.
+ return;
+ }
int webviewPinQuota = pinnerService.getWebviewPinQuota();
if (webviewPinQuota <= 0) {
return;
diff --git a/services/core/java/com/android/server/wm/ActivityClientController.java b/services/core/java/com/android/server/wm/ActivityClientController.java
index 676203b..2e0546e 100644
--- a/services/core/java/com/android/server/wm/ActivityClientController.java
+++ b/services/core/java/com/android/server/wm/ActivityClientController.java
@@ -778,17 +778,22 @@
try {
synchronized (mGlobalLock) {
final ActivityRecord r = ActivityRecord.isInRootTaskLocked(token);
+ if (r == null) {
+ return false;
+ }
// Create a transition if the activity is playing in case the below activity didn't
// commit invisible. That's because if any activity below this one has changed its
// visibility while playing transition, there won't able to commit visibility until
// the running transition finish.
- final Transition transition = r != null
- && r.mTransitionController.inPlayingTransition(r)
+ final Transition transition = r.mTransitionController.isShellTransitionsEnabled()
&& !r.mTransitionController.isCollecting()
? r.mTransitionController.createTransition(TRANSIT_TO_BACK) : null;
- final boolean changed = r != null && r.setOccludesParent(true);
+ final boolean changed = r.setOccludesParent(true);
if (transition != null) {
if (changed) {
+ // Always set as scene transition because it expects to be a jump-cut.
+ transition.setOverrideAnimation(TransitionInfo.AnimationOptions
+ .makeSceneTransitionAnimOptions(), null, null);
r.mTransitionController.requestStartTransition(transition,
null /*startTask */, null /* remoteTransition */,
null /* displayChange */);
diff --git a/services/core/java/com/android/server/wm/ActivityRecord.java b/services/core/java/com/android/server/wm/ActivityRecord.java
index 69fbe6b..9b1f9c8 100644
--- a/services/core/java/com/android/server/wm/ActivityRecord.java
+++ b/services/core/java/com/android/server/wm/ActivityRecord.java
@@ -3093,7 +3093,6 @@
final boolean changed = occludesParent != mOccludesParent;
mOccludesParent = occludesParent;
setMainWindowOpaque(occludesParent);
- mWmService.mWindowPlacerLocked.requestTraversal();
if (changed && task != null && !occludesParent) {
getRootTask().convertActivityToTranslucent(this);
diff --git a/services/core/java/com/android/server/wm/ActivityStartInterceptor.java b/services/core/java/com/android/server/wm/ActivityStartInterceptor.java
index e7621ff..182e1c1 100644
--- a/services/core/java/com/android/server/wm/ActivityStartInterceptor.java
+++ b/services/core/java/com/android/server/wm/ActivityStartInterceptor.java
@@ -18,6 +18,7 @@
import static android.app.ActivityManager.INTENT_SENDER_ACTIVITY;
import static android.app.ActivityOptions.ANIM_OPEN_CROSS_PROFILE_APPS;
+import static android.app.ActivityOptions.MODE_BACKGROUND_ACTIVITY_START_ALLOWED;
import static android.app.PendingIntent.FLAG_CANCEL_CURRENT;
import static android.app.PendingIntent.FLAG_IMMUTABLE;
import static android.app.PendingIntent.FLAG_ONE_SHOT;
@@ -144,22 +145,20 @@
}
private IntentSender createIntentSenderForOriginalIntent(int callingUid, int flags) {
- Bundle bOptions = deferCrossProfileAppsAnimationIfNecessary();
+ ActivityOptions activityOptions = deferCrossProfileAppsAnimationIfNecessary();
+ activityOptions.setPendingIntentCreatorBackgroundActivityStartMode(
+ MODE_BACKGROUND_ACTIVITY_START_ALLOWED);
final TaskFragment taskFragment = getLaunchTaskFragment();
// If the original intent is going to be embedded, try to forward the embedding TaskFragment
// and its task id to embed back the original intent.
if (taskFragment != null) {
- ActivityOptions activityOptions = bOptions != null
- ? ActivityOptions.fromBundle(bOptions)
- : ActivityOptions.makeBasic();
activityOptions.setLaunchTaskFragmentToken(taskFragment.getFragmentToken());
- bOptions = activityOptions.toBundle();
}
final IIntentSender target = mService.getIntentSenderLocked(
INTENT_SENDER_ACTIVITY, mCallingPackage, mCallingFeatureId, callingUid, mUserId,
null /*token*/, null /*resultCode*/, 0 /*requestCode*/,
new Intent[] { mIntent }, new String[] { mResolvedType },
- flags, bOptions);
+ flags, activityOptions.toBundle());
return new IntentSender(target);
}
@@ -272,12 +271,12 @@
*
* @return the activity option used to start the original intent.
*/
- private Bundle deferCrossProfileAppsAnimationIfNecessary() {
+ private ActivityOptions deferCrossProfileAppsAnimationIfNecessary() {
if (hasCrossProfileAnimation()) {
mActivityOptions = null;
- return ActivityOptions.makeOpenCrossProfileAppsAnimation().toBundle();
+ return ActivityOptions.makeOpenCrossProfileAppsAnimation();
}
- return null;
+ return ActivityOptions.makeBasic();
}
private boolean interceptQuietProfileIfNeeded() {
diff --git a/services/core/java/com/android/server/wm/ScreenRecordingCallbackController.java b/services/core/java/com/android/server/wm/ScreenRecordingCallbackController.java
new file mode 100644
index 0000000..5f488b7
--- /dev/null
+++ b/services/core/java/com/android/server/wm/ScreenRecordingCallbackController.java
@@ -0,0 +1,284 @@
+/*
+ * Copyright 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.server.wm;
+
+import static android.content.Context.MEDIA_PROJECTION_SERVICE;
+
+import static com.android.internal.protolog.ProtoLogGroup.WM_ERROR;
+
+import android.media.projection.IMediaProjectionManager;
+import android.media.projection.IMediaProjectionWatcherCallback;
+import android.media.projection.MediaProjectionInfo;
+import android.os.Binder;
+import android.os.IBinder;
+import android.os.RemoteException;
+import android.os.ServiceManager;
+import android.util.ArrayMap;
+import android.util.ArraySet;
+import android.view.ContentRecordingSession;
+import android.window.IScreenRecordingCallback;
+
+import com.android.internal.annotations.GuardedBy;
+import com.android.internal.protolog.common.ProtoLog;
+
+import java.io.PrintWriter;
+import java.util.Map;
+import java.util.Set;
+
+public class ScreenRecordingCallbackController {
+
+ private final class Callback implements IBinder.DeathRecipient {
+
+ IScreenRecordingCallback mCallback;
+ int mUid;
+
+ Callback(IScreenRecordingCallback callback, int uid) {
+ this.mCallback = callback;
+ this.mUid = uid;
+ }
+
+ public void binderDied() {
+ unregister(mCallback);
+ }
+ }
+
+ @GuardedBy("WindowManagerService.mGlobalLock")
+ private final Map<IBinder, Callback> mCallbacks = new ArrayMap<>();
+
+ @GuardedBy("WindowManagerService.mGlobalLock")
+ private final Map<Integer /*UID*/, Boolean> mLastInvokedStateByUid = new ArrayMap<>();
+
+ private final WindowManagerService mWms;
+
+ @GuardedBy("WindowManagerService.mGlobalLock")
+ private WindowContainer<WindowContainer> mRecordedWC;
+
+ private boolean mWatcherCallbackRegistered = false;
+
+ private final class MediaProjectionWatcherCallback extends
+ IMediaProjectionWatcherCallback.Stub {
+ @Override
+ public void onStart(MediaProjectionInfo mediaProjectionInfo) {
+ onScreenRecordingStart(mediaProjectionInfo);
+ }
+
+ @Override
+ public void onStop(MediaProjectionInfo mediaProjectionInfo) {
+ onScreenRecordingStop();
+ }
+
+ @Override
+ public void onRecordingSessionSet(MediaProjectionInfo mediaProjectionInfo,
+ ContentRecordingSession contentRecordingSession) {
+ }
+ }
+
+ ScreenRecordingCallbackController(WindowManagerService wms) {
+ mWms = wms;
+ }
+
+ @GuardedBy("WindowManagerService.mGlobalLock")
+ private void setRecordedWindowContainer(MediaProjectionInfo mediaProjectionInfo) {
+ if (mediaProjectionInfo.getLaunchCookie() == null) {
+ mRecordedWC = (WindowContainer) mWms.mRoot.getDefaultDisplay();
+ } else {
+ mRecordedWC = mWms.mRoot.getActivity(activity -> activity.mLaunchCookie
+ == mediaProjectionInfo.getLaunchCookie()).getTask();
+ }
+ }
+
+ @GuardedBy("WindowManagerService.mGlobalLock")
+ private void ensureMediaProjectionWatcherCallbackRegistered() {
+ if (mWatcherCallbackRegistered) {
+ return;
+ }
+
+ IBinder binder = ServiceManager.getService(MEDIA_PROJECTION_SERVICE);
+ IMediaProjectionManager mediaProjectionManager =
+ IMediaProjectionManager.Stub.asInterface(binder);
+
+ long identityToken = Binder.clearCallingIdentity();
+ MediaProjectionInfo mediaProjectionInfo = null;
+ try {
+ mediaProjectionInfo = mediaProjectionManager.addCallback(
+ new MediaProjectionWatcherCallback());
+ mWatcherCallbackRegistered = true;
+ } catch (RemoteException e) {
+ ProtoLog.e(WM_ERROR, "Failed to register MediaProjectionWatcherCallback");
+ } finally {
+ Binder.restoreCallingIdentity(identityToken);
+ }
+
+ if (mediaProjectionInfo != null) {
+ setRecordedWindowContainer(mediaProjectionInfo);
+ }
+ }
+
+ boolean register(IScreenRecordingCallback callback) {
+ synchronized (mWms.mGlobalLock) {
+ ensureMediaProjectionWatcherCallbackRegistered();
+
+ IBinder binder = callback.asBinder();
+ int uid = Binder.getCallingUid();
+
+ if (mCallbacks.containsKey(binder)) {
+ return mLastInvokedStateByUid.get(uid);
+ }
+
+ Callback callbackInfo = new Callback(callback, uid);
+ try {
+ binder.linkToDeath(callbackInfo, 0);
+ } catch (RemoteException e) {
+ return false;
+ }
+
+ boolean uidInRecording = uidHasRecordedActivity(callbackInfo.mUid);
+ mLastInvokedStateByUid.put(callbackInfo.mUid, uidInRecording);
+ mCallbacks.put(binder, callbackInfo);
+ return uidInRecording;
+ }
+ }
+
+ void unregister(IScreenRecordingCallback callback) {
+ synchronized (mWms.mGlobalLock) {
+ IBinder binder = callback.asBinder();
+ Callback callbackInfo = mCallbacks.remove(binder);
+ binder.unlinkToDeath(callbackInfo, 0);
+
+ boolean uidHasCallback = false;
+ for (Callback cb : mCallbacks.values()) {
+ if (cb.mUid == callbackInfo.mUid) {
+ uidHasCallback = true;
+ break;
+ }
+ }
+ if (!uidHasCallback) {
+ mLastInvokedStateByUid.remove(callbackInfo.mUid);
+ }
+ }
+ }
+
+ private void onScreenRecordingStart(MediaProjectionInfo mediaProjectionInfo) {
+ synchronized (mWms.mGlobalLock) {
+ setRecordedWindowContainer(mediaProjectionInfo);
+ dispatchCallbacks(getRecordedUids(), true /* visibleInScreenRecording*/);
+ }
+ }
+
+ private void onScreenRecordingStop() {
+ synchronized (mWms.mGlobalLock) {
+ dispatchCallbacks(getRecordedUids(), false /*visibleInScreenRecording*/);
+ mRecordedWC = null;
+ }
+ }
+
+ @GuardedBy("WindowManagerService.mGlobalLock")
+ void onProcessActivityVisibilityChanged(int uid, boolean processVisible) {
+ // If recording isn't active or there's no registered callback for the uid, there's nothing
+ // to do on this visibility change.
+ if (mRecordedWC == null || !mLastInvokedStateByUid.containsKey(uid)) {
+ return;
+ }
+
+ // If the callbacks are already in the correct state, avoid making duplicate callbacks for
+ // the same state. This can happen when:
+ // * a process becomes visible but its UID already has a recorded activity from another
+ // process.
+ // * a process becomes invisible but its UID already doesn't have any recorded activities.
+ if (processVisible == mLastInvokedStateByUid.get(uid)) {
+ return;
+ }
+
+ // If the process visibility change doesn't change the visibility of the UID, avoid making
+ // duplicate callbacks for the same state. This can happen when:
+ // * a process becomes visible but the newly visible activity isn't in the recorded window
+ // container.
+ // * a process becomes invisible but there are still activities being recorded for the UID.
+ boolean uidInRecording = uidHasRecordedActivity(uid);
+ if ((processVisible && !uidInRecording) || (!processVisible && uidInRecording)) {
+ return;
+ }
+
+ dispatchCallbacks(Set.of(uid), processVisible);
+ }
+
+ @GuardedBy("WindowManagerService.mGlobalLock")
+ private boolean uidHasRecordedActivity(int uid) {
+ if (mRecordedWC == null) {
+ return false;
+ }
+ boolean[] hasRecordedActivity = {false};
+ mRecordedWC.forAllActivities(activityRecord -> {
+ if (activityRecord.getUid() == uid && activityRecord.isVisibleRequested()) {
+ hasRecordedActivity[0] = true;
+ return true;
+ }
+ return false;
+ }, true /*traverseTopToBottom*/);
+ return hasRecordedActivity[0];
+ }
+
+ @GuardedBy("WindowManagerService.mGlobalLock")
+ private Set<Integer> getRecordedUids() {
+ Set<Integer> result = new ArraySet<>();
+ if (mRecordedWC == null) {
+ return result;
+ }
+ mRecordedWC.forAllActivities(activityRecord -> {
+ if (activityRecord.isVisibleRequested() && mLastInvokedStateByUid.containsKey(
+ activityRecord.getUid())) {
+ result.add(activityRecord.getUid());
+ }
+ }, true /*traverseTopToBottom*/);
+ return result;
+ }
+
+ @GuardedBy("WindowManagerService.mGlobalLock")
+ private void dispatchCallbacks(Set<Integer> uids, boolean visibleInScreenRecording) {
+ if (uids.isEmpty()) {
+ return;
+ }
+
+ for (Integer uid : uids) {
+ mLastInvokedStateByUid.put(uid, visibleInScreenRecording);
+ }
+
+ for (Callback callback : mCallbacks.values()) {
+ if (!uids.contains(callback.mUid)) {
+ continue;
+ }
+ try {
+ callback.mCallback.onScreenRecordingStateChanged(visibleInScreenRecording);
+ } catch (RemoteException e) {
+ // Client has died. Cleanup is handled via DeathRecipient.
+ }
+ }
+ }
+
+ void dump(PrintWriter pw) {
+ pw.format("ScreenRecordingCallbackController:\n");
+ pw.format(" Registered callbacks:\n");
+ for (Map.Entry<IBinder, Callback> entry : mCallbacks.entrySet()) {
+ pw.format(" callback=%s uid=%s\n", entry.getKey(), entry.getValue().mUid);
+ }
+ pw.format(" Last invoked states:\n");
+ for (Map.Entry<Integer, Boolean> entry : mLastInvokedStateByUid.entrySet()) {
+ pw.format(" uid=%s isVisibleInScreenRecording=%s\n", entry.getKey(),
+ entry.getValue());
+ }
+ }
+}
diff --git a/services/core/java/com/android/server/wm/Task.java b/services/core/java/com/android/server/wm/Task.java
index a7a6bf2..314d720 100644
--- a/services/core/java/com/android/server/wm/Task.java
+++ b/services/core/java/com/android/server/wm/Task.java
@@ -208,6 +208,7 @@
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.util.ArrayList;
+import java.util.List;
import java.util.Objects;
import java.util.function.Consumer;
import java.util.function.Predicate;
@@ -1702,6 +1703,8 @@
final ActivityRecord r = findActivityInHistory(newR.mActivityComponent, newR.mUserId);
if (r == null) return null;
+ moveTaskFragmentsToBottomIfNeeded(r, finishCount);
+
final PooledPredicate f = PooledLambda.obtainPredicate(
(ActivityRecord ar, ActivityRecord boundaryActivity) ->
finishActivityAbove(ar, boundaryActivity, finishCount),
@@ -1722,6 +1725,50 @@
return r;
}
+ /**
+ * Moves {@link TaskFragment}s to the bottom if the flag
+ * {@link TaskFragment#isMoveToBottomIfClearWhenLaunch} is {@code true}.
+ */
+ @VisibleForTesting
+ void moveTaskFragmentsToBottomIfNeeded(@NonNull ActivityRecord r, @NonNull int[] finishCount) {
+ final int activityIndex = mChildren.indexOf(r);
+ if (activityIndex < 0) {
+ return;
+ }
+
+ List<TaskFragment> taskFragmentsToMove = null;
+
+ // Find the TaskFragments that need to be moved
+ for (int i = mChildren.size() - 1; i > activityIndex; i--) {
+ final TaskFragment taskFragment = mChildren.get(i).asTaskFragment();
+ if (taskFragment != null && taskFragment.isMoveToBottomIfClearWhenLaunch()) {
+ if (taskFragmentsToMove == null) {
+ taskFragmentsToMove = new ArrayList<>();
+ }
+ taskFragmentsToMove.add(taskFragment);
+ }
+ }
+ if (taskFragmentsToMove == null) {
+ return;
+ }
+
+ // Move the TaskFragments to the bottom of the Task. Their relative orders are preserved.
+ final int size = taskFragmentsToMove.size();
+ for (int i = 0; i < size; i++) {
+ final TaskFragment taskFragment = taskFragmentsToMove.get(i);
+
+ // The visibility of the TaskFragment may change. Collect it in the transition so that
+ // transition animation can be properly played.
+ mTransitionController.collect(taskFragment);
+
+ positionChildAt(POSITION_BOTTOM, taskFragment, false /* includeParents */);
+ }
+
+ // Treat it as if the TaskFragments are finished so that a transition animation can be
+ // played to send the TaskFragments back and bring the activity to front.
+ finishCount[0] += size;
+ }
+
private static boolean finishActivityAbove(ActivityRecord r, ActivityRecord boundaryActivity,
@NonNull int[] finishCount) {
// Stop operation once we reach the boundary activity.
diff --git a/services/core/java/com/android/server/wm/TaskFragment.java b/services/core/java/com/android/server/wm/TaskFragment.java
index f56759f..7d418ea 100644
--- a/services/core/java/com/android/server/wm/TaskFragment.java
+++ b/services/core/java/com/android/server/wm/TaskFragment.java
@@ -363,6 +363,12 @@
*/
private boolean mIsolatedNav;
+ /**
+ * Whether the TaskFragment should move to bottom of task when any activity below it is
+ * launched in clear top mode.
+ */
+ private boolean mMoveToBottomIfClearWhenLaunch;
+
/** When set, will force the task to report as invisible. */
static final int FLAG_FORCE_HIDDEN_FOR_PINNED_TASK = 1;
static final int FLAG_FORCE_HIDDEN_FOR_TASK_ORG = 1 << 1;
@@ -3045,6 +3051,14 @@
mEmbeddedDimArea = embeddedDimArea;
}
+ void setMoveToBottomIfClearWhenLaunch(boolean moveToBottomIfClearWhenLaunch) {
+ mMoveToBottomIfClearWhenLaunch = moveToBottomIfClearWhenLaunch;
+ }
+
+ boolean isMoveToBottomIfClearWhenLaunch() {
+ return mMoveToBottomIfClearWhenLaunch;
+ }
+
@VisibleForTesting
boolean isDimmingOnParentTask() {
return mEmbeddedDimArea == EMBEDDED_DIM_AREA_PARENT_TASK;
diff --git a/services/core/java/com/android/server/wm/Transition.java b/services/core/java/com/android/server/wm/Transition.java
index f620a97..2accf9a 100644
--- a/services/core/java/com/android/server/wm/Transition.java
+++ b/services/core/java/com/android/server/wm/Transition.java
@@ -2841,6 +2841,19 @@
}
}
+ /** Returns {@code true} if the display should use high performance hint for this transition. */
+ boolean shouldUsePerfHint(@NonNull DisplayContent dc) {
+ if (mOverrideOptions != null
+ && mOverrideOptions.getType() == ActivityOptions.ANIM_SCENE_TRANSITION
+ && mType == TRANSIT_TO_BACK && mParticipants.size() == 1) {
+ // This should be from convertFromTranslucent that makes the occluded activity invisible
+ // without animation. So do not use perf hint (especially early-wakeup) that may disturb
+ // SurfaceFlinger scheduling around the last frame.
+ return false;
+ }
+ return mTargetDisplays.contains(dc);
+ }
+
/**
* Returns {@code true} if the transition and the corresponding transaction should be applied
* on display thread. Currently, this only checks for display rotation change because the order
diff --git a/services/core/java/com/android/server/wm/TransitionController.java b/services/core/java/com/android/server/wm/TransitionController.java
index 708d63e..59e3350 100644
--- a/services/core/java/com/android/server/wm/TransitionController.java
+++ b/services/core/java/com/android/server/wm/TransitionController.java
@@ -1237,8 +1237,15 @@
// enableHighPerfTransition(true) is also called in Transition#recordDisplay.
for (int i = mAtm.mRootWindowContainer.getChildCount() - 1; i >= 0; i--) {
final DisplayContent dc = mAtm.mRootWindowContainer.getChildAt(i);
- if (isTransitionOnDisplay(dc)) {
+ if (mCollectingTransition != null && mCollectingTransition.shouldUsePerfHint(dc)) {
dc.enableHighPerfTransition(true);
+ continue;
+ }
+ for (int j = mPlayingTransitions.size() - 1; j >= 0; j--) {
+ if (mPlayingTransitions.get(j).shouldUsePerfHint(dc)) {
+ dc.enableHighPerfTransition(true);
+ break;
+ }
}
}
// Usually transitions put quite a load onto the system already (with all the things
diff --git a/services/core/java/com/android/server/wm/WindowManagerService.java b/services/core/java/com/android/server/wm/WindowManagerService.java
index b38dc00..9179acf 100644
--- a/services/core/java/com/android/server/wm/WindowManagerService.java
+++ b/services/core/java/com/android/server/wm/WindowManagerService.java
@@ -303,6 +303,7 @@
import android.view.inputmethod.ImeTracker;
import android.window.AddToSurfaceSyncGroupResult;
import android.window.ClientWindowFrames;
+import android.window.IScreenRecordingCallback;
import android.window.ISurfaceSyncGroupCompletedListener;
import android.window.ITaskFpsCallback;
import android.window.ITrustedPresentationListener;
@@ -1104,6 +1105,8 @@
void onAppFreezeTimeout();
}
+ private final ScreenRecordingCallbackController mScreenRecordingCallbackController;
+
public static WindowManagerService main(final Context context, final InputManagerService im,
final boolean showBootMsgs, WindowManagerPolicy policy,
ActivityTaskManagerService atm) {
@@ -1345,6 +1348,7 @@
mBlurController = new BlurController(mContext, mPowerManager);
mTaskFpsCallbackController = new TaskFpsCallbackController(mContext);
mAccessibilityController = new AccessibilityController(this);
+ mScreenRecordingCallbackController = new ScreenRecordingCallbackController(this);
mSystemPerformanceHinter = new SystemPerformanceHinter(mContext, displayId -> {
synchronized (mGlobalLock) {
DisplayContent dc = mRoot.getDisplayContent(displayId);
@@ -7188,6 +7192,7 @@
mSystemPerformanceHinter.dump(pw, "");
mTrustedPresentationListenerController.dump(pw);
mSensitiveContentPackages.dump(pw);
+ mScreenRecordingCallbackController.dump(pw);
}
}
@@ -9889,4 +9894,18 @@
int id) {
mTrustedPresentationListenerController.unregisterListener(listener, id);
}
+
+ @Override
+ public boolean registerScreenRecordingCallback(IScreenRecordingCallback callback) {
+ return mScreenRecordingCallbackController.register(callback);
+ }
+
+ @Override
+ public void unregisterScreenRecordingCallback(IScreenRecordingCallback callback) {
+ mScreenRecordingCallbackController.unregister(callback);
+ }
+
+ void onProcessActivityVisibilityChanged(int uid, boolean visible) {
+ mScreenRecordingCallbackController.onProcessActivityVisibilityChanged(uid, visible);
+ }
}
diff --git a/services/core/java/com/android/server/wm/WindowOrganizerController.java b/services/core/java/com/android/server/wm/WindowOrganizerController.java
index 0da0bb4..205ed97 100644
--- a/services/core/java/com/android/server/wm/WindowOrganizerController.java
+++ b/services/core/java/com/android/server/wm/WindowOrganizerController.java
@@ -36,6 +36,7 @@
import static android.window.TaskFragmentOperation.OP_TYPE_SET_COMPANION_TASK_FRAGMENT;
import static android.window.TaskFragmentOperation.OP_TYPE_SET_DIM_ON_TASK;
import static android.window.TaskFragmentOperation.OP_TYPE_SET_ISOLATED_NAVIGATION;
+import static android.window.TaskFragmentOperation.OP_TYPE_SET_MOVE_TO_BOTTOM_IF_CLEAR_WHEN_LAUNCH;
import static android.window.TaskFragmentOperation.OP_TYPE_SET_RELATIVE_BOUNDS;
import static android.window.TaskFragmentOperation.OP_TYPE_START_ACTIVITY_IN_TASK_FRAGMENT;
import static android.window.TaskFragmentOperation.OP_TYPE_UNKNOWN;
@@ -1514,6 +1515,11 @@
: EMBEDDED_DIM_AREA_TASK_FRAGMENT);
break;
}
+ case OP_TYPE_SET_MOVE_TO_BOTTOM_IF_CLEAR_WHEN_LAUNCH: {
+ taskFragment.setMoveToBottomIfClearWhenLaunch(
+ operation.isMoveToBottomIfClearWhenLaunch());
+ break;
+ }
}
return effects;
}
@@ -1566,6 +1572,17 @@
return false;
}
+ if ((opType == OP_TYPE_SET_MOVE_TO_BOTTOM_IF_CLEAR_WHEN_LAUNCH)
+ && !mTaskFragmentOrganizerController.isSystemOrganizer(organizer.asBinder())) {
+ final Throwable exception = new SecurityException(
+ "Only a system organizer can perform "
+ + "OP_TYPE_SET_MOVE_TO_BOTTOM_IF_CLEAR_WHEN_LAUNCH."
+ );
+ sendTaskFragmentOperationFailure(organizer, errorCallbackToken, taskFragment,
+ opType, exception);
+ return false;
+ }
+
final IBinder secondaryFragmentToken = operation.getSecondaryFragmentToken();
return secondaryFragmentToken == null
|| validateTaskFragment(mLaunchTaskFragments.get(secondaryFragmentToken), opType,
diff --git a/services/core/java/com/android/server/wm/WindowProcessController.java b/services/core/java/com/android/server/wm/WindowProcessController.java
index b8fa5e5..6d2e8cc 100644
--- a/services/core/java/com/android/server/wm/WindowProcessController.java
+++ b/services/core/java/com/android/server/wm/WindowProcessController.java
@@ -1271,8 +1271,10 @@
& (ACTIVITY_STATE_FLAG_IS_VISIBLE | ACTIVITY_STATE_FLAG_IS_WINDOW_VISIBLE)) != 0;
if (!wasAnyVisible && anyVisible) {
mAtm.mVisibleActivityProcessTracker.onAnyActivityVisible(this);
+ mAtm.mWindowManager.onProcessActivityVisibilityChanged(mUid, true /*visible*/);
} else if (wasAnyVisible && !anyVisible) {
mAtm.mVisibleActivityProcessTracker.onAllActivitiesInvisible(this);
+ mAtm.mWindowManager.onProcessActivityVisibilityChanged(mUid, false /*visible*/);
} else if (wasAnyVisible && !wasResumed && hasResumedActivity()) {
mAtm.mVisibleActivityProcessTracker.onActivityResumedWhileVisible(this);
}
diff --git a/services/permission/java/com/android/server/permission/access/permission/AppIdPermissionPolicy.kt b/services/permission/java/com/android/server/permission/access/permission/AppIdPermissionPolicy.kt
index 022268d..62d2d7e 100644
--- a/services/permission/java/com/android/server/permission/access/permission/AppIdPermissionPolicy.kt
+++ b/services/permission/java/com/android/server/permission/access/permission/AppIdPermissionPolicy.kt
@@ -134,7 +134,9 @@
) {
val changedPermissionNames = MutableIndexedSet<String>()
packageNames.forEachIndexed { _, packageName ->
- val packageState = newState.externalState.packageStates[packageName]!!
+ // The package may still be removed even if it was once notified as installed.
+ val packageState = newState.externalState.packageStates[packageName]
+ ?: return@forEachIndexed
adoptPermissions(packageState, changedPermissionNames)
addPermissionGroups(packageState)
addPermissions(packageState, changedPermissionNames)
@@ -147,12 +149,14 @@
}
packageNames.forEachIndexed { _, packageName ->
- val packageState = newState.externalState.packageStates[packageName]!!
+ val packageState = newState.externalState.packageStates[packageName]
+ ?: return@forEachIndexed
val installedPackageState = if (isSystemUpdated) packageState else null
evaluateAllPermissionStatesForPackage(packageState, installedPackageState)
}
packageNames.forEachIndexed { _, packageName ->
- val packageState = newState.externalState.packageStates[packageName]!!
+ val packageState = newState.externalState.packageStates[packageName]
+ ?: return@forEachIndexed
newState.externalState.userIds.forEachIndexed { _, userId ->
inheritImplicitPermissionStates(packageState.appId, userId)
}
@@ -1607,6 +1611,13 @@
flagMask: Int,
flagValues: Int
): Boolean {
+ if (userId !in newState.userStates) {
+ // Despite that we check UserManagerInternal.exists() in PermissionService, we may still
+ // sometimes get race conditions between that check and the actual mutateState() call.
+ // This should rarely happen but at least we should not crash.
+ Slog.e(LOG_TAG, "Unable to update permission flags for missing user $userId")
+ return false
+ }
val oldFlags =
newState.userStates[userId]!!
.appIdPermissionFlags[appId]
diff --git a/services/tests/InputMethodSystemServerTests/src/com/android/server/inputmethod/ClientControllerTest.java b/services/tests/InputMethodSystemServerTests/src/com/android/server/inputmethod/ClientControllerTest.java
index 3c8f5c9..30afa72 100644
--- a/services/tests/InputMethodSystemServerTests/src/com/android/server/inputmethod/ClientControllerTest.java
+++ b/services/tests/InputMethodSystemServerTests/src/com/android/server/inputmethod/ClientControllerTest.java
@@ -15,9 +15,16 @@
*/
package com.android.server.inputmethod;
+import static com.android.server.inputmethod.ClientController.ClientControllerCallback;
+import static com.android.server.inputmethod.ClientController.ClientState;
+
import static com.google.common.truth.Truth.assertThat;
+import static com.google.common.truth.Truth.assertWithMessage;
import static org.junit.Assert.assertThrows;
+import static org.mockito.Mockito.any;
+import static org.mockito.Mockito.eq;
+import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import android.content.pm.PackageManagerInternal;
@@ -38,6 +45,8 @@
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.TimeUnit;
// This test is designed to run on both device and host (Ravenwood) side.
public final class ClientControllerTest {
@@ -58,9 +67,6 @@
@Mock
private IRemoteInputConnection mConnection;
- @Mock
- private IBinder.DeathRecipient mDeathRecipient;
-
private Handler mHandler;
private ClientController mController;
@@ -68,9 +74,10 @@
@Before
public void setUp() {
MockitoAnnotations.initMocks(this);
+ when(mClient.asBinder()).thenReturn((IBinder) mClient);
+
mHandler = new Handler(Looper.getMainLooper());
mController = new ClientController(mMockPackageManagerInternal);
- when(mClient.asBinder()).thenReturn((IBinder) mClient);
}
@Test
@@ -80,18 +87,77 @@
var invoker = IInputMethodClientInvoker.create(mClient, mHandler);
synchronized (ImfLock.class) {
- mController.addClient(invoker, mConnection, ANY_DISPLAY_ID, mDeathRecipient,
- ANY_CALLER_UID, ANY_CALLER_PID);
+ mController.addClient(invoker, mConnection, ANY_DISPLAY_ID, ANY_CALLER_UID,
+ ANY_CALLER_PID);
SecurityException thrown = assertThrows(SecurityException.class,
() -> {
synchronized (ImfLock.class) {
mController.addClient(invoker, mConnection, ANY_DISPLAY_ID,
- mDeathRecipient, ANY_CALLER_UID, ANY_CALLER_PID);
+ ANY_CALLER_UID, ANY_CALLER_PID);
}
});
assertThat(thrown.getMessage()).isEqualTo(
"uid=1/pid=1/displayId=0 is already registered");
}
}
+
+ @Test
+ // TODO(b/314150112): Enable host side mode for this test once b/315544364 is fixed.
+ @IgnoreUnderRavenwood(blockedBy = {InputBinding.class, IInputMethodClientInvoker.class})
+ public void testAddClient() throws Exception {
+ synchronized (ImfLock.class) {
+ var invoker = IInputMethodClientInvoker.create(mClient, mHandler);
+ var added = mController.addClient(invoker, mConnection, ANY_DISPLAY_ID, ANY_CALLER_UID,
+ ANY_CALLER_PID);
+
+ verify(invoker.asBinder()).linkToDeath(any(IBinder.DeathRecipient.class), eq(0));
+ assertThat(mController.mClients).containsEntry(invoker.asBinder(), added);
+ }
+ }
+
+ @Test
+ // TODO(b/314150112): Enable host side mode for this test once b/315544364 is fixed.
+ @IgnoreUnderRavenwood(blockedBy = {InputBinding.class, IInputMethodClientInvoker.class})
+ public void testRemoveClient() {
+ var callback = new TestClientControllerCallback();
+ ClientState added;
+ synchronized (ImfLock.class) {
+ mController.addClientControllerCallback(callback);
+
+ var invoker = IInputMethodClientInvoker.create(mClient, mHandler);
+ added = mController.addClient(invoker, mConnection, ANY_DISPLAY_ID, ANY_CALLER_UID,
+ ANY_CALLER_PID);
+ assertThat(mController.mClients).containsEntry(invoker.asBinder(), added);
+ assertThat(mController.removeClient(mClient)).isTrue();
+ }
+
+ // Test callback
+ var removed = callback.waitForRemovedClient(5, TimeUnit.SECONDS);
+ assertThat(removed).isSameInstanceAs(added);
+ }
+
+ private static class TestClientControllerCallback implements ClientControllerCallback {
+
+ private final CountDownLatch mLatch = new CountDownLatch(1);
+
+ private ClientState mRemoved;
+
+ @Override
+ public void onClientRemoved(ClientState removed) {
+ mRemoved = removed;
+ mLatch.countDown();
+ }
+
+ ClientState waitForRemovedClient(long timeout, TimeUnit unit) {
+ try {
+ assertWithMessage("ClientController callback wasn't called on user removed").that(
+ mLatch.await(timeout, unit)).isTrue();
+ } catch (InterruptedException e) {
+ Thread.currentThread().interrupt();
+ throw new IllegalStateException("Unexpected thread interruption", e);
+ }
+ return mRemoved;
+ }
+ }
}
diff --git a/services/tests/displayservicetests/src/com/android/server/display/mode/DisplayObserverTest.java b/services/tests/displayservicetests/src/com/android/server/display/mode/DisplayObserverTest.java
index ff91d34..92016df 100644
--- a/services/tests/displayservicetests/src/com/android/server/display/mode/DisplayObserverTest.java
+++ b/services/tests/displayservicetests/src/com/android/server/display/mode/DisplayObserverTest.java
@@ -20,11 +20,10 @@
import static android.view.Display.DEFAULT_DISPLAY;
import static android.view.Display.Mode.INVALID_MODE_ID;
-
import static com.android.server.display.mode.DisplayModeDirector.SYNCHRONIZED_REFRESH_RATE_TOLERANCE;
import static com.android.server.display.mode.Vote.PRIORITY_LIMIT_MODE;
-import static com.android.server.display.mode.Vote.PRIORITY_USER_SETTING_DISPLAY_PREFERRED_SIZE;
import static com.android.server.display.mode.Vote.PRIORITY_SYNCHRONIZED_REFRESH_RATE;
+import static com.android.server.display.mode.Vote.PRIORITY_USER_SETTING_DISPLAY_PREFERRED_SIZE;
import static com.android.server.display.mode.VotesStorage.GLOBAL_ID;
import static com.google.common.truth.Truth.assertThat;
@@ -43,6 +42,7 @@
import android.os.Handler;
import android.os.Looper;
import android.provider.DeviceConfigInterface;
+import android.test.mock.MockContentResolver;
import android.view.Display;
import android.view.DisplayInfo;
@@ -51,21 +51,26 @@
import androidx.test.filters.SmallTest;
import com.android.internal.R;
+import com.android.internal.util.test.FakeSettingsProvider;
+import com.android.internal.util.test.FakeSettingsProviderRule;
import com.android.server.display.feature.DisplayManagerFlags;
import com.android.server.sensors.SensorManagerInternal;
+import junitparams.JUnitParamsRunner;
+
import org.junit.Before;
+import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
-import junitparams.JUnitParamsRunner;
-
-
@SmallTest
@RunWith(JUnitParamsRunner.class)
public class DisplayObserverTest {
+ @Rule
+ public FakeSettingsProviderRule mSettingsProviderRule = FakeSettingsProvider.rule();
+
private static final int EXTERNAL_DISPLAY = 1;
private static final int MAX_WIDTH = 1920;
private static final int MAX_HEIGHT = 1080;
@@ -120,6 +125,8 @@
mContext = spy(new ContextWrapper(ApplicationProvider.getApplicationContext()));
mResources = mock(Resources.class);
when(mContext.getResources()).thenReturn(mResources);
+ MockContentResolver resolver = mSettingsProviderRule.mockContentResolver(mContext);
+ when(mContext.getContentResolver()).thenReturn(resolver);
when(mResources.getInteger(R.integer.config_externalDisplayPeakRefreshRate))
.thenReturn(0);
when(mResources.getInteger(R.integer.config_externalDisplayPeakWidth))
diff --git a/services/tests/servicestests/Android.bp b/services/tests/servicestests/Android.bp
index 0045026..0831086 100644
--- a/services/tests/servicestests/Android.bp
+++ b/services/tests/servicestests/Android.bp
@@ -29,8 +29,6 @@
"src/**/*.java",
"src/**/*.kt",
- "test-apps/JobTestApp/src/**/*.java",
-
"test-apps/SuspendTestApp/src/**/*.java",
],
static_libs: [
@@ -124,7 +122,6 @@
},
data: [
- ":JobTestApp",
":SimpleServiceTestApp1",
":SimpleServiceTestApp2",
":SimpleServiceTestApp3",
diff --git a/services/tests/servicestests/AndroidTest.xml b/services/tests/servicestests/AndroidTest.xml
index b1d5039..27c522d 100644
--- a/services/tests/servicestests/AndroidTest.xml
+++ b/services/tests/servicestests/AndroidTest.xml
@@ -29,7 +29,6 @@
<option name="cleanup-apks" value="true" />
<option name="install-arg" value="-t" />
<option name="test-file-name" value="FrameworksServicesTests.apk" />
- <option name="test-file-name" value="JobTestApp.apk" />
<option name="test-file-name" value="SuspendTestApp.apk" />
<option name="test-file-name" value="SimpleServiceTestApp1.apk" />
<option name="test-file-name" value="SimpleServiceTestApp2.apk" />
diff --git a/services/tests/servicestests/src/com/android/server/job/BackgroundRestrictionsTest.java b/services/tests/servicestests/src/com/android/server/job/BackgroundRestrictionsTest.java
deleted file mode 100644
index e871fc5..0000000
--- a/services/tests/servicestests/src/com/android/server/job/BackgroundRestrictionsTest.java
+++ /dev/null
@@ -1,233 +0,0 @@
-/*
- * Copyright (C) 2017 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License
- */
-
-package com.android.server.job;
-
-import static com.android.servicestests.apps.jobtestapp.TestJobService.ACTION_JOB_STARTED;
-import static com.android.servicestests.apps.jobtestapp.TestJobService.ACTION_JOB_STOPPED;
-import static com.android.servicestests.apps.jobtestapp.TestJobService.JOB_PARAMS_EXTRA_KEY;
-
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-
-import android.app.ActivityManager;
-import android.app.AppOpsManager;
-import android.app.IActivityManager;
-import android.app.job.JobParameters;
-import android.content.BroadcastReceiver;
-import android.content.ComponentName;
-import android.content.Context;
-import android.content.Intent;
-import android.content.IntentFilter;
-import android.os.IDeviceIdleController;
-import android.os.RemoteException;
-import android.os.ServiceManager;
-import android.os.SystemClock;
-import android.os.UserHandle;
-import android.util.Log;
-
-import androidx.test.InstrumentationRegistry;
-import androidx.test.filters.FlakyTest;
-import androidx.test.filters.LargeTest;
-import androidx.test.runner.AndroidJUnit4;
-
-import com.android.servicestests.apps.jobtestapp.TestJobActivity;
-
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-
-/**
- * Tests that background restrictions on jobs work as expected.
- * This test requires test-apps/JobTestApp to be installed on the device.
- * To run this test from root of checkout:
- * <pre>
- * mmm -j32 frameworks/base/services/tests/servicestests/
- * adb install -r $OUT/data/app/JobTestApp/JobTestApp.apk
- * adb install -r $OUT/data/app/FrameworksServicesTests/FrameworksServicesTests.apk
- * adb shell am instrument -e class 'com.android.server.job.BackgroundRestrictionsTest' -w \
- * com.android.frameworks.servicestests
- * </pre>
- */
-@RunWith(AndroidJUnit4.class)
-@LargeTest
-public class BackgroundRestrictionsTest {
- private static final String TAG = BackgroundRestrictionsTest.class.getSimpleName();
- private static final String TEST_APP_PACKAGE = "com.android.servicestests.apps.jobtestapp";
- private static final String TEST_APP_ACTIVITY = TEST_APP_PACKAGE + ".TestJobActivity";
- private static final long POLL_INTERVAL = 500;
- private static final long DEFAULT_WAIT_TIMEOUT = 10_000;
-
- private Context mContext;
- private AppOpsManager mAppOpsManager;
- private IDeviceIdleController mDeviceIdleController;
- private IActivityManager mIActivityManager;
- private volatile int mTestJobId = -1;
- private int mTestPackageUid;
- /* accesses must be synchronized on itself */
- private final TestJobStatus mTestJobStatus = new TestJobStatus();
- private final BroadcastReceiver mJobStateChangeReceiver = new BroadcastReceiver() {
- @Override
- public void onReceive(Context context, Intent intent) {
- final JobParameters params = intent.getParcelableExtra(JOB_PARAMS_EXTRA_KEY);
- Log.d(TAG, "Received action " + intent.getAction());
- synchronized (mTestJobStatus) {
- switch (intent.getAction()) {
- case ACTION_JOB_STARTED:
- mTestJobStatus.running = true;
- mTestJobStatus.jobId = params.getJobId();
- mTestJobStatus.stopReason = JobParameters.STOP_REASON_UNDEFINED;
- break;
- case ACTION_JOB_STOPPED:
- mTestJobStatus.running = false;
- mTestJobStatus.jobId = params.getJobId();
- mTestJobStatus.stopReason = params.getStopReason();
- break;
- }
- }
- }
- };
-
- @Before
- public void setUp() throws Exception {
- mContext = InstrumentationRegistry.getTargetContext();
- mAppOpsManager = (AppOpsManager) mContext.getSystemService(Context.APP_OPS_SERVICE);
- mDeviceIdleController = IDeviceIdleController.Stub.asInterface(
- ServiceManager.getService(Context.DEVICE_IDLE_CONTROLLER));
- mIActivityManager = ActivityManager.getService();
- mTestPackageUid = mContext.getPackageManager().getPackageUid(TEST_APP_PACKAGE, 0);
- mTestJobStatus.reset();
- final IntentFilter intentFilter = new IntentFilter();
- intentFilter.addAction(ACTION_JOB_STARTED);
- intentFilter.addAction(ACTION_JOB_STOPPED);
- mContext.registerReceiver(mJobStateChangeReceiver, intentFilter,
- Context.RECEIVER_EXPORTED_UNAUDITED);
- setAppOpsModeAllowed(true);
- setPowerExemption(false);
- }
-
- private void scheduleTestJob() {
- mTestJobId = (int) (SystemClock.uptimeMillis() / 1000);
- final Intent scheduleJobIntent = new Intent(TestJobActivity.ACTION_START_JOB);
- scheduleJobIntent.putExtra(TestJobActivity.EXTRA_JOB_ID_KEY, mTestJobId);
- scheduleJobIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
- scheduleJobIntent.setComponent(new ComponentName(TEST_APP_PACKAGE, TEST_APP_ACTIVITY));
- mContext.startActivity(scheduleJobIntent);
- }
-
- private void scheduleAndAssertJobStarted() throws Exception {
- scheduleTestJob();
- Thread.sleep(TestJobActivity.JOB_MINIMUM_LATENCY);
- assertTrue("Job did not start after scheduling", awaitJobStart(DEFAULT_WAIT_TIMEOUT));
- }
-
- @FlakyTest
- @Test
- public void testPowerExemption() throws Exception {
- scheduleAndAssertJobStarted();
- setAppOpsModeAllowed(false);
- mIActivityManager.makePackageIdle(TEST_APP_PACKAGE, UserHandle.USER_CURRENT);
- assertTrue("Job did not stop after putting app under bg-restriction",
- awaitJobStop(DEFAULT_WAIT_TIMEOUT,
- JobParameters.STOP_REASON_BACKGROUND_RESTRICTION));
-
- setPowerExemption(true);
- scheduleTestJob();
- Thread.sleep(TestJobActivity.JOB_MINIMUM_LATENCY);
- assertTrue("Job did not start when the app was in the power exemption list",
- awaitJobStart(DEFAULT_WAIT_TIMEOUT));
-
- setPowerExemption(false);
- assertTrue("Job did not stop after removing from the power exemption list",
- awaitJobStop(DEFAULT_WAIT_TIMEOUT,
- JobParameters.STOP_REASON_BACKGROUND_RESTRICTION));
-
- scheduleTestJob();
- Thread.sleep(TestJobActivity.JOB_MINIMUM_LATENCY);
- assertFalse("Job started under bg-restrictions", awaitJobStart(DEFAULT_WAIT_TIMEOUT));
- setPowerExemption(true);
- assertTrue("Job did not start when the app was in the power exemption list",
- awaitJobStart(DEFAULT_WAIT_TIMEOUT));
- }
-
- @After
- public void tearDown() throws Exception {
- final Intent cancelJobsIntent = new Intent(TestJobActivity.ACTION_CANCEL_JOBS);
- cancelJobsIntent.setComponent(new ComponentName(TEST_APP_PACKAGE, TEST_APP_ACTIVITY));
- cancelJobsIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
- mContext.startActivity(cancelJobsIntent);
- mContext.unregisterReceiver(mJobStateChangeReceiver);
- Thread.sleep(500); // To avoid race with register in the next setUp
- setAppOpsModeAllowed(true);
- setPowerExemption(false);
- }
-
- private void setPowerExemption(boolean exempt) throws RemoteException {
- if (exempt) {
- mDeviceIdleController.addPowerSaveWhitelistApp(TEST_APP_PACKAGE);
- } else {
- mDeviceIdleController.removePowerSaveWhitelistApp(TEST_APP_PACKAGE);
- }
- }
-
- private void setAppOpsModeAllowed(boolean allow) {
- mAppOpsManager.setMode(AppOpsManager.OP_RUN_ANY_IN_BACKGROUND, mTestPackageUid,
- TEST_APP_PACKAGE, allow ? AppOpsManager.MODE_ALLOWED : AppOpsManager.MODE_IGNORED);
- }
-
- private boolean awaitJobStart(long timeout) throws InterruptedException {
- return waitUntilTrue(timeout, () -> {
- synchronized (mTestJobStatus) {
- return (mTestJobStatus.jobId == mTestJobId) && mTestJobStatus.running;
- }
- });
- }
-
- private boolean awaitJobStop(long timeout, @JobParameters.StopReason int expectedStopReason)
- throws InterruptedException {
- return waitUntilTrue(timeout, () -> {
- synchronized (mTestJobStatus) {
- return (mTestJobStatus.jobId == mTestJobId) && !mTestJobStatus.running
- && (expectedStopReason == JobParameters.STOP_REASON_UNDEFINED
- || mTestJobStatus.stopReason == expectedStopReason);
- }
- });
- }
-
- private boolean waitUntilTrue(long timeout, Condition condition) throws InterruptedException {
- final long deadLine = SystemClock.uptimeMillis() + timeout;
- do {
- Thread.sleep(POLL_INTERVAL);
- } while (!condition.isTrue() && SystemClock.uptimeMillis() < deadLine);
- return condition.isTrue();
- }
-
- private static final class TestJobStatus {
- int jobId;
- int stopReason;
- boolean running;
-
- private void reset() {
- running = false;
- stopReason = jobId = 0;
- }
- }
-
- private interface Condition {
- boolean isTrue();
- }
-}
diff --git a/services/tests/servicestests/src/com/android/server/pm/ShortcutManagerTest1.java b/services/tests/servicestests/src/com/android/server/pm/ShortcutManagerTest1.java
index 0f5fb91..d50affb 100644
--- a/services/tests/servicestests/src/com/android/server/pm/ShortcutManagerTest1.java
+++ b/services/tests/servicestests/src/com/android/server/pm/ShortcutManagerTest1.java
@@ -406,8 +406,8 @@
public void testPushDynamicShortcut() {
// Change the max number of shortcuts.
- mService.updateConfigurationLocked(ConfigConstants.KEY_MAX_SHORTCUTS + "=5");
-
+ mService.updateConfigurationLocked(ConfigConstants.KEY_MAX_SHORTCUTS + "=5,"
+ + ShortcutService.ConfigConstants.KEY_SAVE_DELAY_MILLIS + "=1");
setCaller(CALLING_PACKAGE_1, USER_0);
final ShortcutInfo s1 = makeShortcut("s1");
@@ -545,6 +545,57 @@
eq(CALLING_PACKAGE_1), eq("s9"), eq(USER_0));
}
+ public void testPushDynamicShortcut_CallsToUsageStatsManagerAreThrottled()
+ throws InterruptedException {
+ mService.updateConfigurationLocked(
+ ShortcutService.ConfigConstants.KEY_SAVE_DELAY_MILLIS + "=500");
+
+ // Verify calls to UsageStatsManagerInternal#reportShortcutUsage are throttled.
+ setCaller(CALLING_PACKAGE_1, USER_0);
+ {
+ final ShortcutInfo si = makeShortcut("s0");
+ mManager.pushDynamicShortcut(si);
+ }
+ verify(mMockUsageStatsManagerInternal, times(1)).reportShortcutUsage(
+ eq(CALLING_PACKAGE_1), eq("s0"), eq(USER_0));
+ Mockito.reset(mMockUsageStatsManagerInternal);
+ for (int i = 2; i <= 10; i++) {
+ final ShortcutInfo si = makeShortcut("s" + i);
+ mManager.pushDynamicShortcut(si);
+ }
+ verify(mMockUsageStatsManagerInternal, times(0)).reportShortcutUsage(
+ any(), any(), anyInt());
+
+ // Verify pkg2 isn't blocked by pkg1, but consecutive calls from pkg2 are throttled as well.
+ setCaller(CALLING_PACKAGE_2, USER_0);
+ {
+ final ShortcutInfo si = makeShortcut("s1");
+ mManager.pushDynamicShortcut(si);
+ }
+ verify(mMockUsageStatsManagerInternal, times(1)).reportShortcutUsage(
+ eq(CALLING_PACKAGE_2), eq("s1"), eq(USER_0));
+ Mockito.reset(mMockUsageStatsManagerInternal);
+ for (int i = 2; i <= 10; i++) {
+ final ShortcutInfo si = makeShortcut("s" + i);
+ mManager.pushDynamicShortcut(si);
+ }
+ verify(mMockUsageStatsManagerInternal, times(0)).reportShortcutUsage(
+ any(), any(), anyInt());
+
+ Mockito.reset(mMockUsageStatsManagerInternal);
+ // Let time passes which resets the throttle
+ Thread.sleep(505);
+ // Verify UsageStatsManagerInternal#reportShortcutUsed can be called again
+ setCaller(CALLING_PACKAGE_1, USER_0);
+ mManager.pushDynamicShortcut(makeShortcut("s10"));
+ setCaller(CALLING_PACKAGE_2, USER_0);
+ mManager.pushDynamicShortcut(makeShortcut("s10"));
+ verify(mMockUsageStatsManagerInternal, times(1)).reportShortcutUsage(
+ eq(CALLING_PACKAGE_1), any(), eq(USER_0));
+ verify(mMockUsageStatsManagerInternal, times(1)).reportShortcutUsage(
+ eq(CALLING_PACKAGE_2), any(), eq(USER_0));
+ }
+
public void testUnlimitedCalls() {
setCaller(CALLING_PACKAGE_1, USER_0);
diff --git a/services/tests/servicestests/test-apps/JobTestApp/Android.bp b/services/tests/servicestests/test-apps/JobTestApp/Android.bp
deleted file mode 100644
index 6458bcd..0000000
--- a/services/tests/servicestests/test-apps/JobTestApp/Android.bp
+++ /dev/null
@@ -1,37 +0,0 @@
-// Copyright (C) 2017 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 {
- // See: http://go/android-license-faq
- // A large-scale-change added 'default_applicable_licenses' to import
- // all of the 'license_kinds' from "frameworks_base_license"
- // to get the below license kinds:
- // SPDX-license-identifier-Apache-2.0
- default_applicable_licenses: ["frameworks_base_license"],
-}
-
-android_test_helper_app {
- name: "JobTestApp",
-
- sdk_version: "current",
-
- srcs: ["**/*.java"],
-
- dex_preopt: {
- enabled: false,
- },
- optimize: {
- enabled: false,
- },
-}
diff --git a/services/tests/servicestests/test-apps/JobTestApp/AndroidManifest.xml b/services/tests/servicestests/test-apps/JobTestApp/AndroidManifest.xml
deleted file mode 100644
index ac35805..0000000
--- a/services/tests/servicestests/test-apps/JobTestApp/AndroidManifest.xml
+++ /dev/null
@@ -1,27 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2017 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.
--->
-
-<manifest xmlns:android="http://schemas.android.com/apk/res/android"
- package="com.android.servicestests.apps.jobtestapp">
-
- <application>
- <service android:name=".TestJobService"
- android:permission="android.permission.BIND_JOB_SERVICE" />
- <activity android:name=".TestJobActivity"
- android:exported="true" />
- </application>
-
-</manifest>
\ No newline at end of file
diff --git a/services/tests/servicestests/test-apps/JobTestApp/OWNERS b/services/tests/servicestests/test-apps/JobTestApp/OWNERS
deleted file mode 100644
index 6f207fb1..0000000
--- a/services/tests/servicestests/test-apps/JobTestApp/OWNERS
+++ /dev/null
@@ -1 +0,0 @@
-include /apex/jobscheduler/OWNERS
diff --git a/services/tests/servicestests/test-apps/JobTestApp/src/com/android/servicestests/apps/jobtestapp/TestJobActivity.java b/services/tests/servicestests/test-apps/JobTestApp/src/com/android/servicestests/apps/jobtestapp/TestJobActivity.java
deleted file mode 100644
index 99eb196..0000000
--- a/services/tests/servicestests/test-apps/JobTestApp/src/com/android/servicestests/apps/jobtestapp/TestJobActivity.java
+++ /dev/null
@@ -1,67 +0,0 @@
-/*
- * Copyright (C) 2017 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.servicestests.apps.jobtestapp;
-
-import android.app.Activity;
-import android.app.job.JobInfo;
-import android.app.job.JobScheduler;
-import android.content.ComponentName;
-import android.content.Context;
-import android.content.Intent;
-import android.os.Bundle;
-import android.util.Log;
-
-public class TestJobActivity extends Activity {
- private static final String TAG = TestJobActivity.class.getSimpleName();
- private static final String PACKAGE_NAME = "com.android.servicestests.apps.jobtestapp";
-
- public static final String EXTRA_JOB_ID_KEY = PACKAGE_NAME + ".extra.JOB_ID";
- public static final String ACTION_START_JOB = PACKAGE_NAME + ".action.START_JOB";
- public static final String ACTION_CANCEL_JOBS = PACKAGE_NAME + ".action.CANCEL_JOBS";
- public static final int JOB_INITIAL_BACKOFF = 10_000;
- public static final int JOB_MINIMUM_LATENCY = 5_000;
-
- @Override
- public void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- ComponentName jobServiceComponent = new ComponentName(this, TestJobService.class);
- JobScheduler jobScheduler = (JobScheduler) getSystemService(Context.JOB_SCHEDULER_SERVICE);
- final Intent intent = getIntent();
- switch (intent.getAction()) {
- case ACTION_CANCEL_JOBS:
- jobScheduler.cancelAll();
- Log.d(TAG, "Cancelled all jobs for " + getPackageName());
- break;
- case ACTION_START_JOB:
- final int jobId = intent.getIntExtra(EXTRA_JOB_ID_KEY, hashCode());
- JobInfo.Builder jobBuilder = new JobInfo.Builder(jobId, jobServiceComponent)
- .setBackoffCriteria(JOB_INITIAL_BACKOFF, JobInfo.BACKOFF_POLICY_LINEAR)
- .setMinimumLatency(JOB_MINIMUM_LATENCY)
- .setOverrideDeadline(JOB_MINIMUM_LATENCY);
- final int result = jobScheduler.schedule(jobBuilder.build());
- if (result != JobScheduler.RESULT_SUCCESS) {
- Log.e(TAG, "Could not schedule job " + jobId);
- } else {
- Log.d(TAG, "Successfully scheduled job with id " + jobId);
- }
- break;
- default:
- Log.e(TAG, "Unknown action " + intent.getAction());
- }
- finish();
- }
-}
\ No newline at end of file
diff --git a/services/tests/servicestests/test-apps/JobTestApp/src/com/android/servicestests/apps/jobtestapp/TestJobService.java b/services/tests/servicestests/test-apps/JobTestApp/src/com/android/servicestests/apps/jobtestapp/TestJobService.java
deleted file mode 100644
index b8585f2..0000000
--- a/services/tests/servicestests/test-apps/JobTestApp/src/com/android/servicestests/apps/jobtestapp/TestJobService.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * Copyright (C) 2017 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.servicestests.apps.jobtestapp;
-
-import android.annotation.TargetApi;
-import android.app.job.JobParameters;
-import android.app.job.JobService;
-import android.content.Intent;
-import android.util.Log;
-
-@TargetApi(24)
-public class TestJobService extends JobService {
- private static final String TAG = TestJobService.class.getSimpleName();
- private static final String PACKAGE_NAME = "com.android.servicestests.apps.jobtestapp";
- public static final String ACTION_JOB_STARTED = PACKAGE_NAME + ".action.JOB_STARTED";
- public static final String ACTION_JOB_STOPPED = PACKAGE_NAME + ".action.JOB_STOPPED";
- public static final String JOB_PARAMS_EXTRA_KEY = PACKAGE_NAME + ".extra.JOB_PARAMETERS";
-
- @Override
- public boolean onStartJob(JobParameters params) {
- Log.i(TAG, "Test job executing: " + params.getJobId());
- Intent reportJobStartIntent = new Intent(ACTION_JOB_STARTED);
- reportJobStartIntent.putExtra(JOB_PARAMS_EXTRA_KEY, params)
- .addFlags(Intent.FLAG_RECEIVER_FOREGROUND);
- sendBroadcast(reportJobStartIntent);
- return true;
- }
-
- @Override
- public boolean onStopJob(JobParameters params) {
- Log.i(TAG, "Test job stopped executing: " + params.getJobId());
- Intent reportJobStopIntent = new Intent(ACTION_JOB_STOPPED);
- reportJobStopIntent.putExtra(JOB_PARAMS_EXTRA_KEY, params)
- .addFlags(Intent.FLAG_RECEIVER_FOREGROUND);
- sendBroadcast(reportJobStopIntent);
- // Deadline constraint is dropped on reschedule, so it's more reliable to use a new job.
- return false;
- }
-}
diff --git a/services/tests/uiservicestests/src/com/android/server/notification/NotificationManagerServiceTest.java b/services/tests/uiservicestests/src/com/android/server/notification/NotificationManagerServiceTest.java
index c1f35cc..723ac15 100755
--- a/services/tests/uiservicestests/src/com/android/server/notification/NotificationManagerServiceTest.java
+++ b/services/tests/uiservicestests/src/com/android/server/notification/NotificationManagerServiceTest.java
@@ -13792,8 +13792,7 @@
NotificationManager.Policy policy = new NotificationManager.Policy(0, 0, 0);
mBinderService.setNotificationPolicy("package", policy, false);
- verify(zenHelper).applyGlobalPolicyAsImplicitZenRule(eq("package"), anyInt(), eq(policy),
- eq(ZenModeConfig.UPDATE_ORIGIN_APP));
+ verify(zenHelper).applyGlobalPolicyAsImplicitZenRule(eq("package"), anyInt(), eq(policy));
}
@Test
@@ -13859,7 +13858,7 @@
verify(zenModeHelper).setNotificationPolicy(eq(policy), anyInt(), anyInt());
} else {
verify(zenModeHelper).applyGlobalPolicyAsImplicitZenRule(anyString(), anyInt(),
- eq(policy), anyInt());
+ eq(policy));
}
}
diff --git a/services/tests/uiservicestests/src/com/android/server/notification/ZenAdaptersTest.java b/services/tests/uiservicestests/src/com/android/server/notification/ZenAdaptersTest.java
index 08af09c..0e20daf 100644
--- a/services/tests/uiservicestests/src/com/android/server/notification/ZenAdaptersTest.java
+++ b/services/tests/uiservicestests/src/com/android/server/notification/ZenAdaptersTest.java
@@ -143,12 +143,12 @@
Policy.policyState(false, true), 0);
ZenPolicy zenPolicy = notificationPolicyToZenPolicy(policy);
- assertThat(zenPolicy.getAllowedChannels()).isEqualTo(ZenPolicy.CHANNEL_TYPE_PRIORITY);
+ assertThat(zenPolicy.getPriorityChannels()).isEqualTo(ZenPolicy.STATE_ALLOW);
Policy notAllowed = new Policy(0, 0, 0, 0,
Policy.policyState(false, false), 0);
ZenPolicy zenPolicyNotAllowed = notificationPolicyToZenPolicy(notAllowed);
- assertThat(zenPolicyNotAllowed.getAllowedChannels()).isEqualTo(ZenPolicy.CHANNEL_TYPE_NONE);
+ assertThat(zenPolicyNotAllowed.getPriorityChannels()).isEqualTo(ZenPolicy.STATE_DISALLOW);
}
@Test
@@ -158,12 +158,11 @@
Policy.policyState(false, true), 0);
ZenPolicy zenPolicy = notificationPolicyToZenPolicy(policy);
- assertThat(zenPolicy.getAllowedChannels()).isEqualTo(ZenPolicy.CHANNEL_TYPE_UNSET);
+ assertThat(zenPolicy.getPriorityChannels()).isEqualTo(ZenPolicy.STATE_UNSET);
Policy notAllowed = new Policy(0, 0, 0, 0,
Policy.policyState(false, false), 0);
ZenPolicy zenPolicyNotAllowed = notificationPolicyToZenPolicy(notAllowed);
- assertThat(zenPolicyNotAllowed.getAllowedChannels())
- .isEqualTo(ZenPolicy.CHANNEL_TYPE_UNSET);
+ assertThat(zenPolicyNotAllowed.getPriorityChannels()).isEqualTo(ZenPolicy.STATE_UNSET);
}
}
diff --git a/services/tests/uiservicestests/src/com/android/server/notification/ZenDeviceEffectsTest.java b/services/tests/uiservicestests/src/com/android/server/notification/ZenDeviceEffectsTest.java
index 3d8ec2e..f604f1e 100644
--- a/services/tests/uiservicestests/src/com/android/server/notification/ZenDeviceEffectsTest.java
+++ b/services/tests/uiservicestests/src/com/android/server/notification/ZenDeviceEffectsTest.java
@@ -52,7 +52,6 @@
.setShouldMaximizeDoze(true)
.setShouldUseNightMode(false)
.setShouldSuppressAmbientDisplay(false).setShouldSuppressAmbientDisplay(true)
- .setUserModifiedFields(8)
.build();
assertThat(deviceEffects.shouldDimWallpaper()).isTrue();
@@ -65,7 +64,6 @@
assertThat(deviceEffects.shouldMinimizeRadioUsage()).isFalse();
assertThat(deviceEffects.shouldUseNightMode()).isFalse();
assertThat(deviceEffects.shouldSuppressAmbientDisplay()).isTrue();
- assertThat(deviceEffects.getUserModifiedFields()).isEqualTo(8);
}
@Test
@@ -97,7 +95,6 @@
.setShouldMinimizeRadioUsage(true)
.setShouldUseNightMode(true)
.setShouldSuppressAmbientDisplay(true)
- .setUserModifiedFields(6)
.build();
Parcel parcel = Parcel.obtain();
@@ -116,7 +113,6 @@
assertThat(copy.shouldUseNightMode()).isTrue();
assertThat(copy.shouldSuppressAmbientDisplay()).isTrue();
assertThat(copy.shouldDisplayGrayscale()).isFalse();
- assertThat(copy.getUserModifiedFields()).isEqualTo(6);
}
@Test
diff --git a/services/tests/uiservicestests/src/com/android/server/notification/ZenModeConfigTest.java b/services/tests/uiservicestests/src/com/android/server/notification/ZenModeConfigTest.java
index dd252f3..e523e79f 100644
--- a/services/tests/uiservicestests/src/com/android/server/notification/ZenModeConfigTest.java
+++ b/services/tests/uiservicestests/src/com/android/server/notification/ZenModeConfigTest.java
@@ -164,7 +164,7 @@
.allowConversations(CONVERSATION_SENDERS_IMPORTANT)
.showLights(false)
.showInAmbientDisplay(false)
- .allowChannels(ZenPolicy.CHANNEL_TYPE_NONE)
+ .allowPriorityChannels(false)
.build();
Policy originalPolicy = config.toNotificationPolicy();
@@ -255,7 +255,7 @@
.allowCalls(ZenPolicy.PEOPLE_TYPE_CONTACTS)
.allowMessages(ZenPolicy.PEOPLE_TYPE_STARRED)
.allowConversations(ZenPolicy.CONVERSATION_SENDERS_NONE)
- .allowChannels(ZenPolicy.CHANNEL_TYPE_NONE)
+ .allowPriorityChannels(false)
.build();
ZenModeConfig config = getMutedAllConfig();
@@ -284,8 +284,7 @@
actual.getPriorityConversationSenders());
assertEquals(expected.getPriorityCallSenders(), actual.getPriorityCallSenders());
assertEquals(expected.getPriorityMessageSenders(), actual.getPriorityMessageSenders());
- assertEquals(expected.getAllowedChannels(), actual.getAllowedChannels());
- assertEquals(expected.getUserModifiedFields(), actual.getUserModifiedFields());
+ assertEquals(expected.getPriorityChannels(), actual.getPriorityChannels());
}
@Test
@@ -342,45 +341,32 @@
ZenModeConfig.ZenRule rule = new ZenModeConfig.ZenRule();
rule.zenPolicy = null;
rule.zenDeviceEffects = null;
-
assertThat(rule.canBeUpdatedByApp()).isTrue();
rule.userModifiedFields = 1;
+
assertThat(rule.canBeUpdatedByApp()).isFalse();
}
@Test
public void testCanBeUpdatedByApp_policyModified() throws Exception {
- ZenPolicy.Builder policyBuilder = new ZenPolicy.Builder().setUserModifiedFields(0);
- ZenPolicy policy = policyBuilder.build();
-
ZenModeConfig.ZenRule rule = new ZenModeConfig.ZenRule();
- rule.zenPolicy = policy;
-
- assertThat(rule.userModifiedFields).isEqualTo(0);
+ rule.zenPolicy = new ZenPolicy();
assertThat(rule.canBeUpdatedByApp()).isTrue();
- policy = policyBuilder.setUserModifiedFields(1).build();
- assertThat(policy.getUserModifiedFields()).isEqualTo(1);
- rule.zenPolicy = policy;
+ rule.zenPolicyUserModifiedFields = 1;
+
assertThat(rule.canBeUpdatedByApp()).isFalse();
}
@Test
public void testCanBeUpdatedByApp_deviceEffectsModified() throws Exception {
- ZenDeviceEffects.Builder deviceEffectsBuilder =
- new ZenDeviceEffects.Builder().setUserModifiedFields(0);
- ZenDeviceEffects deviceEffects = deviceEffectsBuilder.build();
-
ZenModeConfig.ZenRule rule = new ZenModeConfig.ZenRule();
- rule.zenDeviceEffects = deviceEffects;
-
- assertThat(rule.userModifiedFields).isEqualTo(0);
+ rule.zenDeviceEffects = new ZenDeviceEffects.Builder().build();
assertThat(rule.canBeUpdatedByApp()).isTrue();
- deviceEffects = deviceEffectsBuilder.setUserModifiedFields(1).build();
- assertThat(deviceEffects.getUserModifiedFields()).isEqualTo(1);
- rule.zenDeviceEffects = deviceEffects;
+ rule.zenDeviceEffectsUserModifiedFields = 1;
+
assertThat(rule.canBeUpdatedByApp()).isFalse();
}
@@ -406,6 +392,8 @@
rule.allowManualInvocation = ALLOW_MANUAL;
rule.type = TYPE;
rule.userModifiedFields = 16;
+ rule.zenPolicyUserModifiedFields = 5;
+ rule.zenDeviceEffectsUserModifiedFields = 2;
rule.iconResName = ICON_RES_NAME;
rule.triggerDescription = TRIGGER_DESC;
rule.deletionInstant = Instant.ofEpochMilli(1701790147000L);
@@ -432,6 +420,9 @@
assertEquals(rule.iconResName, parceled.iconResName);
assertEquals(rule.type, parceled.type);
assertEquals(rule.userModifiedFields, parceled.userModifiedFields);
+ assertEquals(rule.zenPolicyUserModifiedFields, parceled.zenPolicyUserModifiedFields);
+ assertEquals(rule.zenDeviceEffectsUserModifiedFields,
+ parceled.zenDeviceEffectsUserModifiedFields);
assertEquals(rule.triggerDescription, parceled.triggerDescription);
assertEquals(rule.zenPolicy, parceled.zenPolicy);
assertEquals(rule.deletionInstant, parceled.deletionInstant);
@@ -511,6 +502,8 @@
rule.allowManualInvocation = ALLOW_MANUAL;
rule.type = TYPE;
rule.userModifiedFields = 4;
+ rule.zenPolicyUserModifiedFields = 5;
+ rule.zenDeviceEffectsUserModifiedFields = 2;
rule.iconResName = ICON_RES_NAME;
rule.triggerDescription = TRIGGER_DESC;
rule.deletionInstant = Instant.ofEpochMilli(1701790147000L);
@@ -541,6 +534,9 @@
assertEquals(rule.allowManualInvocation, fromXml.allowManualInvocation);
assertEquals(rule.type, fromXml.type);
assertEquals(rule.userModifiedFields, fromXml.userModifiedFields);
+ assertEquals(rule.zenPolicyUserModifiedFields, fromXml.zenPolicyUserModifiedFields);
+ assertEquals(rule.zenDeviceEffectsUserModifiedFields,
+ fromXml.zenDeviceEffectsUserModifiedFields);
assertEquals(rule.triggerDescription, fromXml.triggerDescription);
assertEquals(rule.iconResName, fromXml.iconResName);
assertEquals(rule.deletionInstant, fromXml.deletionInstant);
@@ -694,10 +690,9 @@
.allowSystem(true)
.allowReminders(false)
.allowEvents(true)
- .allowChannels(ZenPolicy.CHANNEL_TYPE_NONE)
+ .allowPriorityChannels(false)
.hideAllVisualEffects()
.showVisualEffect(ZenPolicy.VISUAL_EFFECT_AMBIENT, true)
- .setUserModifiedFields(4)
.build();
ByteArrayOutputStream baos = new ByteArrayOutputStream();
@@ -721,7 +716,7 @@
assertEquals(policy.getPriorityCategorySystem(), fromXml.getPriorityCategorySystem());
assertEquals(policy.getPriorityCategoryReminders(), fromXml.getPriorityCategoryReminders());
assertEquals(policy.getPriorityCategoryEvents(), fromXml.getPriorityCategoryEvents());
- assertEquals(policy.getAllowedChannels(), fromXml.getAllowedChannels());
+ assertEquals(policy.getPriorityChannels(), fromXml.getPriorityChannels());
assertEquals(policy.getVisualEffectFullScreenIntent(),
fromXml.getVisualEffectFullScreenIntent());
@@ -732,7 +727,6 @@
assertEquals(policy.getVisualEffectAmbient(), fromXml.getVisualEffectAmbient());
assertEquals(policy.getVisualEffectNotificationList(),
fromXml.getVisualEffectNotificationList());
- assertEquals(policy.getUserModifiedFields(), fromXml.getUserModifiedFields());
}
private ZenModeConfig getMutedRingerConfig() {
diff --git a/services/tests/uiservicestests/src/com/android/server/notification/ZenModeDiffTest.java b/services/tests/uiservicestests/src/com/android/server/notification/ZenModeDiffTest.java
index 9d7cf53..2e64645 100644
--- a/services/tests/uiservicestests/src/com/android/server/notification/ZenModeDiffTest.java
+++ b/services/tests/uiservicestests/src/com/android/server/notification/ZenModeDiffTest.java
@@ -73,13 +73,15 @@
: Set.of("version", "manualRule", "automaticRules");
// Differences for flagged fields are only generated if the flag is enabled.
- // "Metadata" fields (userModifiedFields, deletionInstant) are not compared.
+ // "Metadata" fields (userModifiedFields & co, deletionInstant) are not compared.
private static final Set<String> ZEN_RULE_EXEMPT_FIELDS =
android.app.Flags.modesApi()
- ? Set.of("userModifiedFields", "deletionInstant")
+ ? Set.of("userModifiedFields", "zenPolicyUserModifiedFields",
+ "zenDeviceEffectsUserModifiedFields", "deletionInstant")
: Set.of(RuleDiff.FIELD_TYPE, RuleDiff.FIELD_TRIGGER_DESCRIPTION,
RuleDiff.FIELD_ICON_RES, RuleDiff.FIELD_ALLOW_MANUAL,
RuleDiff.FIELD_ZEN_DEVICE_EFFECTS, "userModifiedFields",
+ "zenPolicyUserModifiedFields", "zenDeviceEffectsUserModifiedFields",
"deletionInstant");
// allowPriorityChannels is flagged by android.app.modes_api
diff --git a/services/tests/uiservicestests/src/com/android/server/notification/ZenModeFilteringTest.java b/services/tests/uiservicestests/src/com/android/server/notification/ZenModeFilteringTest.java
index 29208f4..7d6e12c 100644
--- a/services/tests/uiservicestests/src/com/android/server/notification/ZenModeFilteringTest.java
+++ b/services/tests/uiservicestests/src/com/android/server/notification/ZenModeFilteringTest.java
@@ -546,13 +546,13 @@
// Create a policy to allow channels through, which means shouldIntercept is false
ZenModeConfig config = new ZenModeConfig();
Policy policy = config.toNotificationPolicy(new ZenPolicy.Builder()
- .allowChannels(ZenPolicy.CHANNEL_TYPE_PRIORITY)
+ .allowPriorityChannels(true)
.build());
assertFalse(mZenModeFiltering.shouldIntercept(ZEN_MODE_IMPORTANT_INTERRUPTIONS, policy, r));
// Now create a policy which does not allow priority channels:
policy = config.toNotificationPolicy(new ZenPolicy.Builder()
- .allowChannels(ZenPolicy.CHANNEL_TYPE_NONE)
+ .allowPriorityChannels(false)
.build());
assertTrue(mZenModeFiltering.shouldIntercept(ZEN_MODE_IMPORTANT_INTERRUPTIONS, policy, r));
}
diff --git a/services/tests/uiservicestests/src/com/android/server/notification/ZenModeHelperTest.java b/services/tests/uiservicestests/src/com/android/server/notification/ZenModeHelperTest.java
index 9e3e336..edc876a 100644
--- a/services/tests/uiservicestests/src/com/android/server/notification/ZenModeHelperTest.java
+++ b/services/tests/uiservicestests/src/com/android/server/notification/ZenModeHelperTest.java
@@ -46,6 +46,7 @@
import static android.content.pm.PackageManager.PERMISSION_GRANTED;
import static android.provider.Settings.Global.ZEN_MODE_ALARMS;
import static android.provider.Settings.Global.ZEN_MODE_IMPORTANT_INTERRUPTIONS;
+import static android.provider.Settings.Global.ZEN_MODE_NO_INTERRUPTIONS;
import static android.provider.Settings.Global.ZEN_MODE_OFF;
import static android.service.notification.Condition.SOURCE_SCHEDULE;
import static android.service.notification.Condition.SOURCE_USER_ACTION;
@@ -67,6 +68,7 @@
import static com.android.os.dnd.DNDProtoEnums.STATE_DISALLOW;
import static com.android.server.notification.ZenModeHelper.RULE_LIMIT_PER_PACKAGE;
+import static com.google.common.collect.Iterables.getOnlyElement;
import static com.google.common.truth.Truth.assertThat;
import static junit.framework.Assert.assertEquals;
@@ -295,6 +297,8 @@
when(appInfoSpy.loadLabel(any())).thenReturn(CUSTOM_APP_LABEL);
when(mPackageManager.getApplicationInfo(eq(CUSTOM_PKG_NAME), anyInt()))
.thenReturn(appInfoSpy);
+ when(mPackageManager.getApplicationInfo(eq(mContext.getPackageName()), anyInt()))
+ .thenReturn(appInfoSpy);
mZenModeHelper.mPm = mPackageManager;
mZenModeEventLogger.reset();
@@ -1151,7 +1155,7 @@
.allowAlarms(true)
.allowRepeatCallers(false)
.allowCalls(PEOPLE_TYPE_STARRED)
- .allowChannels(ZenPolicy.CHANNEL_TYPE_NONE)
+ .allowPriorityChannels(false)
.build();
mZenModeHelper.mConfig.automaticRules.put(rule.id, rule);
List<StatsEvent> events = new LinkedList<>();
@@ -1174,7 +1178,7 @@
assertThat(policy.getAllowCallsFrom().getNumber())
.isEqualTo(DNDProtoEnums.PEOPLE_STARRED);
assertThat(policy.getAllowChannels().getNumber())
- .isEqualTo(DNDProtoEnums.CHANNEL_TYPE_NONE);
+ .isEqualTo(DNDProtoEnums.CHANNEL_POLICY_NONE);
}
}
assertTrue("couldn't find custom rule", foundCustomEvent);
@@ -2236,12 +2240,7 @@
AutomaticZenRule savedRule = mZenModeHelper.getAutomaticZenRule(ruleId);
- // savedRule.getDeviceEffects() is equal to zde, except for the userModifiedFields.
- // So we clear before comparing.
- ZenDeviceEffects savedEffects = new ZenDeviceEffects.Builder(savedRule.getDeviceEffects())
- .setUserModifiedFields(0).build();
-
- assertThat(savedEffects).isEqualTo(zde);
+ assertThat(savedRule.getDeviceEffects()).isEqualTo(zde);
}
@Test
@@ -2331,12 +2330,7 @@
AutomaticZenRule savedRule = mZenModeHelper.getAutomaticZenRule(ruleId);
- // savedRule.getDeviceEffects() is equal to updateFromUser, except for the
- // userModifiedFields, so we clear before comparing.
- ZenDeviceEffects savedEffects = new ZenDeviceEffects.Builder(savedRule.getDeviceEffects())
- .setUserModifiedFields(0).build();
-
- assertThat(savedEffects).isEqualTo(updateFromUser);
+ assertThat(savedRule.getDeviceEffects()).isEqualTo(updateFromUser);
}
@Test
@@ -3098,7 +3092,7 @@
DNDPolicyProto origDndProto = mZenModeEventLogger.getPolicyProto(0);
checkDndProtoMatchesSetupZenConfig(origDndProto);
assertThat(origDndProto.getAllowChannels().getNumber())
- .isEqualTo(DNDProtoEnums.CHANNEL_TYPE_PRIORITY);
+ .isEqualTo(DNDProtoEnums.CHANNEL_POLICY_PRIORITY);
// Second message where we change the policy:
// - DND_POLICY_CHANGED (indicates only the policy changed and nothing else)
@@ -3110,7 +3104,7 @@
.isEqualTo(DNDProtoEnums.UNKNOWN_RULE);
DNDPolicyProto dndProto = mZenModeEventLogger.getPolicyProto(1);
assertThat(dndProto.getAllowChannels().getNumber())
- .isEqualTo(DNDProtoEnums.CHANNEL_TYPE_NONE);
+ .isEqualTo(DNDProtoEnums.CHANNEL_POLICY_NONE);
}
@Test
@@ -3299,7 +3293,7 @@
// one rule, custom policy, allows channels
ZenPolicy customPolicy = new ZenPolicy.Builder()
- .allowChannels(ZenPolicy.CHANNEL_TYPE_PRIORITY)
+ .allowPriorityChannels(true)
.build();
AutomaticZenRule zenRule = new AutomaticZenRule("name",
@@ -3321,7 +3315,7 @@
// add new rule with policy that disallows channels
ZenPolicy strictPolicy = new ZenPolicy.Builder()
- .allowChannels(ZenPolicy.CHANNEL_TYPE_NONE)
+ .allowPriorityChannels(false)
.build();
AutomaticZenRule zenRule2 = new AutomaticZenRule("name2",
@@ -3411,7 +3405,6 @@
rule.allowManualInvocation = ALLOW_MANUAL;
rule.type = TYPE;
- rule.userModifiedFields = AutomaticZenRule.FIELD_NAME;
rule.iconResName = ICON_RES_NAME;
rule.triggerDescription = TRIGGER_DESC;
@@ -3426,7 +3419,6 @@
assertEquals(POLICY, actual.getZenPolicy());
assertEquals(CONFIG_ACTIVITY, actual.getConfigurationActivity());
assertEquals(TYPE, actual.getType());
- assertEquals(AutomaticZenRule.FIELD_NAME, actual.getUserModifiedFields());
assertEquals(ALLOW_MANUAL, actual.isManualInvocationAllowed());
assertEquals(CREATION_TIME, actual.getCreationTime());
assertEquals(OWNER.getPackageName(), actual.getPackageName());
@@ -3453,29 +3445,31 @@
.setManualInvocationAllowed(ALLOW_MANUAL)
.build();
- ZenModeConfig.ZenRule rule = new ZenModeConfig.ZenRule();
+ String ruleId = mZenModeHelper.addAutomaticZenRule(OWNER.getPackageName(), azr,
+ UPDATE_ORIGIN_APP, "add", CUSTOM_PKG_UID);
- mZenModeHelper.populateZenRule(OWNER.getPackageName(), azr, rule, UPDATE_ORIGIN_APP, true);
+ ZenModeConfig.ZenRule storedRule = mZenModeHelper.mConfig.automaticRules.get(ruleId);
- assertEquals(NAME, rule.name);
- assertEquals(OWNER, rule.component);
- assertEquals(CONDITION_ID, rule.conditionId);
- assertEquals(INTERRUPTION_FILTER_ZR, rule.zenMode);
- assertEquals(ENABLED, rule.enabled);
- assertEquals(POLICY, rule.zenPolicy);
- assertEquals(CONFIG_ACTIVITY, rule.configurationActivity);
- assertEquals(TYPE, rule.type);
- assertEquals(ALLOW_MANUAL, rule.allowManualInvocation);
- assertEquals(OWNER.getPackageName(), rule.getPkg());
- assertEquals(ICON_RES_NAME, rule.iconResName);
+ assertThat(storedRule).isNotNull();
+ assertEquals(NAME, storedRule.name);
+ assertEquals(OWNER, storedRule.component);
+ assertEquals(CONDITION_ID, storedRule.conditionId);
+ assertEquals(INTERRUPTION_FILTER_ZR, storedRule.zenMode);
+ assertEquals(ENABLED, storedRule.enabled);
+ assertEquals(POLICY, storedRule.zenPolicy);
+ assertEquals(CONFIG_ACTIVITY, storedRule.configurationActivity);
+ assertEquals(TYPE, storedRule.type);
+ assertEquals(ALLOW_MANUAL, storedRule.allowManualInvocation);
+ assertEquals(OWNER.getPackageName(), storedRule.getPkg());
+ assertEquals(ICON_RES_NAME, storedRule.iconResName);
// Because the origin of the update is the app, we don't expect the bitmask to change.
- assertEquals(0, rule.userModifiedFields);
- assertEquals(TRIGGER_DESC, rule.triggerDescription);
+ assertEquals(0, storedRule.userModifiedFields);
+ assertEquals(TRIGGER_DESC, storedRule.triggerDescription);
}
@Test
@EnableFlags(Flags.FLAG_MODES_API)
- public void automaticZenRuleToZenRule_updatesNameUnlessUserModified() {
+ public void updateAutomaticZenRule_fromApp_updatesNameUnlessUserModified() {
// Add a starting rule with the name OriginalName.
AutomaticZenRule azrBase = new AutomaticZenRule.Builder("OriginalName", CONDITION_ID)
.setInterruptionFilter(INTERRUPTION_FILTER_PRIORITY)
@@ -3492,7 +3486,6 @@
Process.SYSTEM_UID);
rule = mZenModeHelper.getAutomaticZenRule(ruleId);
assertThat(rule.getName()).isEqualTo("NewName");
- assertThat(rule.canUpdate()).isTrue();
// The user modifies some other field in the rule, which makes the rule as a whole not
// app modifiable.
@@ -3501,10 +3494,6 @@
.build();
mZenModeHelper.updateAutomaticZenRule(ruleId, azrUpdate, UPDATE_ORIGIN_USER, "reason",
Process.SYSTEM_UID);
- rule = mZenModeHelper.getAutomaticZenRule(ruleId);
- assertThat(rule.getUserModifiedFields())
- .isEqualTo(AutomaticZenRule.FIELD_INTERRUPTION_FILTER);
- assertThat(rule.canUpdate()).isFalse();
// ...but the app can still modify the name, because the name itself hasn't been modified
// by the user.
@@ -3524,8 +3513,6 @@
Process.SYSTEM_UID);
rule = mZenModeHelper.getAutomaticZenRule(ruleId);
assertThat(rule.getName()).isEqualTo("UserProvidedName");
- assertThat(rule.getUserModifiedFields()).isEqualTo(AutomaticZenRule.FIELD_NAME
- | AutomaticZenRule.FIELD_INTERRUPTION_FILTER);
// The app is no longer able to modify the name.
azrUpdate = new AutomaticZenRule.Builder(rule)
@@ -3539,7 +3526,7 @@
@Test
@EnableFlags(Flags.FLAG_MODES_API)
- public void automaticZenRuleToZenRule_updatesBitmaskAndValueForUserOrigin() {
+ public void updateAutomaticZenRule_fromUser_updatesBitmaskAndValue() {
// Adds a starting rule with empty zen policies and device effects
AutomaticZenRule azrBase = new AutomaticZenRule.Builder(NAME, CONDITION_ID)
.setZenPolicy(new ZenPolicy.Builder().build())
@@ -3552,7 +3539,7 @@
// Modifies the zen policy and device effects
ZenPolicy policy = new ZenPolicy.Builder(rule.getZenPolicy())
- .allowChannels(ZenPolicy.CHANNEL_TYPE_PRIORITY)
+ .allowPriorityChannels(true)
.build();
ZenDeviceEffects deviceEffects =
new ZenDeviceEffects.Builder(rule.getDeviceEffects())
@@ -3571,85 +3558,21 @@
// UPDATE_ORIGIN_USER should change the bitmask and change the values.
assertThat(rule.getInterruptionFilter()).isEqualTo(INTERRUPTION_FILTER_PRIORITY);
- assertThat(rule.getUserModifiedFields())
- .isEqualTo(AutomaticZenRule.FIELD_INTERRUPTION_FILTER);
- assertThat(rule.getZenPolicy().getUserModifiedFields())
- .isEqualTo(ZenPolicy.FIELD_ALLOW_CHANNELS);
- assertThat(rule.getZenPolicy().getAllowedChannels())
- .isEqualTo(ZenPolicy.CHANNEL_TYPE_PRIORITY);
- assertThat(rule.getDeviceEffects().getUserModifiedFields())
- .isEqualTo(ZenDeviceEffects.FIELD_GRAYSCALE);
+ assertThat(rule.getZenPolicy().getPriorityChannels()).isEqualTo(ZenPolicy.STATE_ALLOW);
assertThat(rule.getDeviceEffects().shouldDisplayGrayscale()).isTrue();
+
+ ZenRule storedRule = mZenModeHelper.mConfig.automaticRules.get(ruleId);
+ assertThat(storedRule.userModifiedFields)
+ .isEqualTo(AutomaticZenRule.FIELD_INTERRUPTION_FILTER);
+ assertThat(storedRule.zenPolicyUserModifiedFields)
+ .isEqualTo(ZenPolicy.FIELD_ALLOW_CHANNELS);
+ assertThat(storedRule.zenDeviceEffectsUserModifiedFields)
+ .isEqualTo(ZenDeviceEffects.FIELD_GRAYSCALE);
}
@Test
@EnableFlags(Flags.FLAG_MODES_API)
- public void automaticZenRuleToZenRule_doesNotUpdateValuesForInitUserOrigin() {
- // Adds a starting rule with empty zen policies and device effects
- AutomaticZenRule azrBase = new AutomaticZenRule.Builder(NAME, CONDITION_ID)
- .setInterruptionFilter(INTERRUPTION_FILTER_ALL) // Already the default, no change
- .setZenPolicy(new ZenPolicy.Builder()
- .allowReminders(false)
- .build())
- .setDeviceEffects(new ZenDeviceEffects.Builder()
- .setShouldDisplayGrayscale(false)
- .build())
- .build();
- // Adds the rule using the user, to set user-modified bits.
- String ruleId = mZenModeHelper.addAutomaticZenRule(mContext.getPackageName(),
- azrBase, UPDATE_ORIGIN_USER, "reason", Process.SYSTEM_UID);
- AutomaticZenRule rule = mZenModeHelper.getAutomaticZenRule(ruleId);
- assertThat(rule.canUpdate()).isFalse();
- assertThat(rule.getUserModifiedFields()).isEqualTo(AutomaticZenRule.FIELD_NAME);
-
- ZenPolicy policy = new ZenPolicy.Builder(rule.getZenPolicy())
- .allowReminders(true)
- .build();
- ZenDeviceEffects deviceEffects = new ZenDeviceEffects.Builder(rule.getDeviceEffects())
- .setShouldDisplayGrayscale(true)
- .build();
- AutomaticZenRule azrUpdate = new AutomaticZenRule.Builder(rule)
- .setInterruptionFilter(INTERRUPTION_FILTER_PRIORITY)
- .setZenPolicy(policy)
- .setDeviceEffects(deviceEffects)
- .build();
-
- // Attempts to update the rule with the AZR from origin init user.
- mZenModeHelper.updateAutomaticZenRule(ruleId, azrUpdate, UPDATE_ORIGIN_INIT_USER, "reason",
- Process.SYSTEM_UID);
- AutomaticZenRule unchangedRule = mZenModeHelper.getAutomaticZenRule(ruleId);
-
- // UPDATE_ORIGIN_INIT_USER does not change the bitmask or values if rule is user modified.
- // TODO: b/318506692 - Remove once we check that INIT origins can't call add/updateAZR.
- assertThat(unchangedRule.getUserModifiedFields()).isEqualTo(rule.getUserModifiedFields());
- assertThat(unchangedRule.getInterruptionFilter()).isEqualTo(INTERRUPTION_FILTER_ALL);
- assertThat(unchangedRule.getZenPolicy().getUserModifiedFields()).isEqualTo(
- rule.getZenPolicy().getUserModifiedFields());
- assertThat(unchangedRule.getZenPolicy().getPriorityCategoryReminders()).isEqualTo(
- ZenPolicy.STATE_DISALLOW);
- assertThat(unchangedRule.getDeviceEffects().getUserModifiedFields()).isEqualTo(
- rule.getDeviceEffects().getUserModifiedFields());
- assertThat(unchangedRule.getDeviceEffects().shouldDisplayGrayscale()).isFalse();
-
- // Creates a new rule with the AZR from origin init user.
- String newRuleId = mZenModeHelper.addAutomaticZenRule(mContext.getPackageName(),
- azrUpdate, UPDATE_ORIGIN_INIT_USER, "reason", Process.SYSTEM_UID);
- AutomaticZenRule newRule = mZenModeHelper.getAutomaticZenRule(newRuleId);
-
- // UPDATE_ORIGIN_INIT_USER does change the values if the rule is new,
- // but does not update the bitmask.
- assertThat(newRule.getUserModifiedFields()).isEqualTo(0);
- assertThat(newRule.getInterruptionFilter()).isEqualTo(INTERRUPTION_FILTER_PRIORITY);
- assertThat(newRule.getZenPolicy().getUserModifiedFields()).isEqualTo(0);
- assertThat(newRule.getZenPolicy().getPriorityCategoryReminders())
- .isEqualTo(ZenPolicy.STATE_ALLOW);
- assertThat(newRule.getDeviceEffects().getUserModifiedFields()).isEqualTo(0);
- assertThat(newRule.getDeviceEffects().shouldDisplayGrayscale()).isTrue();
- }
-
- @Test
- @EnableFlags(Flags.FLAG_MODES_API)
- public void automaticZenRuleToZenRule_updatesValuesForSystemUiOrigin() {
+ public void updateAutomaticZenRule_fromSystemUi_updatesValues() {
// Adds a starting rule with empty zen policies and device effects
AutomaticZenRule azrBase = new AutomaticZenRule.Builder(NAME, CONDITION_ID)
.setInterruptionFilter(INTERRUPTION_FILTER_ALL)
@@ -3685,17 +3608,19 @@
rule = mZenModeHelper.getAutomaticZenRule(ruleId);
// UPDATE_ORIGIN_SYSTEM_OR_SYSTEMUI should change the value but NOT update the bitmask.
- assertThat(rule.getUserModifiedFields()).isEqualTo(0);
- assertThat(rule.getZenPolicy().getUserModifiedFields()).isEqualTo(0);
assertThat(rule.getZenPolicy().getPriorityCategoryReminders())
.isEqualTo(ZenPolicy.STATE_ALLOW);
- assertThat(rule.getDeviceEffects().getUserModifiedFields()).isEqualTo(0);
assertThat(rule.getDeviceEffects().shouldDisplayGrayscale()).isTrue();
+
+ ZenRule storedRule = mZenModeHelper.mConfig.automaticRules.get(ruleId);
+ assertThat(storedRule.userModifiedFields).isEqualTo(0);
+ assertThat(storedRule.zenPolicyUserModifiedFields).isEqualTo(0);
+ assertThat(storedRule.zenDeviceEffectsUserModifiedFields).isEqualTo(0);
}
@Test
@EnableFlags(Flags.FLAG_MODES_API)
- public void automaticZenRuleToZenRule_updatesValuesIfRuleNotUserModified() {
+ public void updateAutomaticZenRule_fromApp_updatesValuesIfRuleNotUserModified() {
// Adds a starting rule with empty zen policies and device effects
AutomaticZenRule azrBase = new AutomaticZenRule.Builder(NAME, CONDITION_ID)
.setInterruptionFilter(INTERRUPTION_FILTER_ALL)
@@ -3710,7 +3635,6 @@
String ruleId = mZenModeHelper.addAutomaticZenRule(mContext.getPackageName(),
azrBase, UPDATE_ORIGIN_APP, "reason", Process.SYSTEM_UID);
AutomaticZenRule rule = mZenModeHelper.getAutomaticZenRule(ruleId);
- assertThat(rule.canUpdate()).isTrue();
ZenPolicy policy = new ZenPolicy.Builder()
.allowReminders(true)
@@ -3718,57 +3642,59 @@
ZenDeviceEffects deviceEffects = new ZenDeviceEffects.Builder()
.setShouldDisplayGrayscale(true)
.build();
- AutomaticZenRule azrUpdate = new AutomaticZenRule.Builder(rule)
+ AutomaticZenRule azrUpdate = new AutomaticZenRule.Builder(rule)
.setInterruptionFilter(INTERRUPTION_FILTER_ALARMS)
.setZenPolicy(policy)
.setDeviceEffects(deviceEffects)
.build();
- // Since the rule is not already user modified, UPDATE_ORIGIN_UNKNOWN can modify the rule.
+ // Since the rule is not already user modified, UPDATE_ORIGIN_APP can modify the rule.
// The bitmask is not modified.
- mZenModeHelper.updateAutomaticZenRule(ruleId, azrUpdate, UPDATE_ORIGIN_UNKNOWN, "reason",
+ mZenModeHelper.updateAutomaticZenRule(ruleId, azrUpdate, UPDATE_ORIGIN_APP, "reason",
Process.SYSTEM_UID);
- AutomaticZenRule unchangedRule = mZenModeHelper.getAutomaticZenRule(ruleId);
- assertThat(unchangedRule.getUserModifiedFields()).isEqualTo(rule.getUserModifiedFields());
- assertThat(unchangedRule.getInterruptionFilter()).isEqualTo(INTERRUPTION_FILTER_ALARMS);
- assertThat(unchangedRule.getZenPolicy().getUserModifiedFields()).isEqualTo(
- rule.getZenPolicy().getUserModifiedFields());
- assertThat(unchangedRule.getZenPolicy().getPriorityCategoryReminders())
+ ZenRule storedRule = mZenModeHelper.mConfig.automaticRules.get(ruleId);
+ assertThat(storedRule.userModifiedFields).isEqualTo(0);
+
+ assertThat(storedRule.zenMode).isEqualTo(ZEN_MODE_ALARMS);
+ assertThat(storedRule.zenPolicy.getPriorityCategoryReminders())
.isEqualTo(ZenPolicy.STATE_ALLOW);
- assertThat(unchangedRule.getDeviceEffects().getUserModifiedFields()).isEqualTo(
- rule.getDeviceEffects().getUserModifiedFields());
- assertThat(unchangedRule.getDeviceEffects().shouldDisplayGrayscale()).isTrue();
+ assertThat(storedRule.zenDeviceEffects.shouldDisplayGrayscale()).isTrue();
+ assertThat(storedRule.userModifiedFields).isEqualTo(0);
+ assertThat(storedRule.zenPolicyUserModifiedFields).isEqualTo(0);
+ assertThat(storedRule.zenDeviceEffectsUserModifiedFields).isEqualTo(0);
// Creates another rule, this time from user. This will have user modified bits set.
String ruleIdUser = mZenModeHelper.addAutomaticZenRule(mContext.getPackageName(),
azrBase, UPDATE_ORIGIN_USER, "reason", Process.SYSTEM_UID);
- AutomaticZenRule ruleUser = mZenModeHelper.getAutomaticZenRule(ruleIdUser);
- assertThat(ruleUser.canUpdate()).isFalse();
+ storedRule = mZenModeHelper.mConfig.automaticRules.get(ruleIdUser);
+ int ruleModifiedFields = storedRule.userModifiedFields;
+ int rulePolicyModifiedFields = storedRule.zenPolicyUserModifiedFields;
+ int ruleDeviceEffectsModifiedFields = storedRule.zenDeviceEffectsUserModifiedFields;
- // Zen rule update coming from unknown origin. This cannot fully update the rule, because
+ // Zen rule update coming from the app again. This cannot fully update the rule, because
// the rule is already considered user modified.
- mZenModeHelper.updateAutomaticZenRule(ruleIdUser, azrUpdate, UPDATE_ORIGIN_UNKNOWN,
+ mZenModeHelper.updateAutomaticZenRule(ruleIdUser, azrUpdate, UPDATE_ORIGIN_APP,
"reason", Process.SYSTEM_UID);
- ruleUser = mZenModeHelper.getAutomaticZenRule(ruleIdUser);
+ AutomaticZenRule ruleUser = mZenModeHelper.getAutomaticZenRule(ruleIdUser);
- // UPDATE_ORIGIN_UNKNOWN can only change the value if the rule is not already user modified,
+ // The app can only change the value if the rule is not already user modified,
// so the rule is not changed, and neither is the bitmask.
assertThat(ruleUser.getInterruptionFilter()).isEqualTo(INTERRUPTION_FILTER_ALL);
- // Interruption Filter All is the default value, so it's not included as a modified field.
- assertThat(ruleUser.getUserModifiedFields() | AutomaticZenRule.FIELD_NAME).isGreaterThan(0);
- assertThat(ruleUser.getZenPolicy().getUserModifiedFields()
- | ZenPolicy.FIELD_PRIORITY_CATEGORY_REMINDERS).isGreaterThan(0);
assertThat(ruleUser.getZenPolicy().getPriorityCategoryReminders())
.isEqualTo(ZenPolicy.STATE_DISALLOW);
- assertThat(ruleUser.getDeviceEffects().getUserModifiedFields()
- | ZenDeviceEffects.FIELD_GRAYSCALE).isGreaterThan(0);
assertThat(ruleUser.getDeviceEffects().shouldDisplayGrayscale()).isFalse();
+
+ storedRule = mZenModeHelper.mConfig.automaticRules.get(ruleIdUser);
+ assertThat(storedRule.userModifiedFields).isEqualTo(ruleModifiedFields);
+ assertThat(storedRule.zenPolicyUserModifiedFields).isEqualTo(rulePolicyModifiedFields);
+ assertThat(storedRule.zenDeviceEffectsUserModifiedFields).isEqualTo(
+ ruleDeviceEffectsModifiedFields);
}
@Test
@EnableFlags(Flags.FLAG_MODES_API)
- public void automaticZenRuleToZenRule_updatesValuesIfRuleNew() {
+ public void addAutomaticZenRule_updatesValues() {
// Adds a starting rule with empty zen policies and device effects
AutomaticZenRule azrBase = new AutomaticZenRule.Builder(NAME, CONDITION_ID)
.setInterruptionFilter(INTERRUPTION_FILTER_ALARMS)
@@ -3779,21 +3705,22 @@
.setShouldDisplayGrayscale(true)
.build())
.build();
- // Adds the rule using origin unknown, to show that a new rule is always allowed.
String ruleId = mZenModeHelper.addAutomaticZenRule(mContext.getPackageName(),
- azrBase, UPDATE_ORIGIN_UNKNOWN, "reason", Process.SYSTEM_UID);
+ azrBase, UPDATE_ORIGIN_APP, "reason", Process.SYSTEM_UID);
AutomaticZenRule rule = mZenModeHelper.getAutomaticZenRule(ruleId);
// The values are modified but the bitmask is not.
- assertThat(rule.canUpdate()).isTrue();
assertThat(rule.getZenPolicy().getPriorityCategoryReminders())
.isEqualTo(ZenPolicy.STATE_ALLOW);
assertThat(rule.getDeviceEffects().shouldDisplayGrayscale()).isTrue();
+
+ ZenRule storedRule = mZenModeHelper.mConfig.automaticRules.get(ruleId);
+ assertThat(storedRule.canBeUpdatedByApp()).isTrue();
}
@Test
@EnableFlags(Flags.FLAG_MODES_API)
- public void automaticZenRuleToZenRule_nullDeviceEffectsUpdate() {
+ public void updateAutomaticZenRule_nullDeviceEffectsUpdate() {
// Adds a starting rule with empty zen policies and device effects
AutomaticZenRule azrBase = new AutomaticZenRule.Builder(NAME, CONDITION_ID)
.setDeviceEffects(new ZenDeviceEffects.Builder().build())
@@ -3808,9 +3735,9 @@
.setDeviceEffects(null)
.build();
- // Zen rule update coming from unknown origin, but since the rule isn't already
+ // Zen rule update coming from app, but since the rule isn't already
// user modified, it can be updated.
- mZenModeHelper.updateAutomaticZenRule(ruleId, azr, UPDATE_ORIGIN_UNKNOWN, "reason",
+ mZenModeHelper.updateAutomaticZenRule(ruleId, azr, UPDATE_ORIGIN_APP, "reason",
Process.SYSTEM_UID);
rule = mZenModeHelper.getAutomaticZenRule(ruleId);
@@ -3820,7 +3747,7 @@
@Test
@EnableFlags(Flags.FLAG_MODES_API)
- public void automaticZenRuleToZenRule_nullPolicyUpdate() {
+ public void updateAutomaticZenRule_nullPolicyUpdate() {
// Adds a starting rule with empty zen policies and device effects
AutomaticZenRule azrBase = new AutomaticZenRule.Builder(NAME, CONDITION_ID)
.setZenPolicy(new ZenPolicy.Builder().build())
@@ -3829,16 +3756,15 @@
String ruleId = mZenModeHelper.addAutomaticZenRule(mContext.getPackageName(),
azrBase, UPDATE_ORIGIN_APP, "reason", Process.SYSTEM_UID);
AutomaticZenRule rule = mZenModeHelper.getAutomaticZenRule(ruleId);
- assertThat(rule.canUpdate()).isTrue();
AutomaticZenRule azr = new AutomaticZenRule.Builder(azrBase)
// Set zen policy to null
.setZenPolicy(null)
.build();
- // Zen rule update coming from unknown origin, but since the rule isn't already
+ // Zen rule update coming from app, but since the rule isn't already
// user modified, it can be updated.
- mZenModeHelper.updateAutomaticZenRule(ruleId, azr, UPDATE_ORIGIN_UNKNOWN, "reason",
+ mZenModeHelper.updateAutomaticZenRule(ruleId, azr, UPDATE_ORIGIN_APP, "reason",
Process.SYSTEM_UID);
rule = mZenModeHelper.getAutomaticZenRule(ruleId);
@@ -3860,11 +3786,10 @@
String ruleId = mZenModeHelper.addAutomaticZenRule(mContext.getPackageName(),
azrBase, UPDATE_ORIGIN_APP, "reason", Process.SYSTEM_UID);
AutomaticZenRule rule = mZenModeHelper.getAutomaticZenRule(ruleId);
- assertThat(rule.canUpdate()).isTrue();
// Create a fully populated ZenPolicy.
ZenPolicy policy = new ZenPolicy.Builder()
- .allowChannels(ZenPolicy.CHANNEL_TYPE_NONE) // Differs from the default
+ .allowPriorityChannels(false) // Differs from the default
.allowReminders(true) // Differs from the default
.allowEvents(true) // Differs from the default
.allowConversations(ZenPolicy.CONVERSATION_SENDERS_IMPORTANT)
@@ -3894,9 +3819,11 @@
// New ZenPolicy differs from the default config
assertThat(rule.getZenPolicy()).isNotNull();
- assertThat(rule.getZenPolicy().getAllowedChannels()).isEqualTo(ZenPolicy.CHANNEL_TYPE_NONE);
- assertThat(rule.canUpdate()).isFalse();
- assertThat(rule.getZenPolicy().getUserModifiedFields()).isEqualTo(
+ assertThat(rule.getZenPolicy().getPriorityChannels()).isEqualTo(ZenPolicy.STATE_DISALLOW);
+
+ ZenRule storedRule = mZenModeHelper.mConfig.automaticRules.get(ruleId);
+ assertThat(storedRule.canBeUpdatedByApp()).isFalse();
+ assertThat(storedRule.zenPolicyUserModifiedFields).isEqualTo(
ZenPolicy.FIELD_ALLOW_CHANNELS
| ZenPolicy.FIELD_PRIORITY_CATEGORY_REMINDERS
| ZenPolicy.FIELD_PRIORITY_CATEGORY_EVENTS
@@ -3919,7 +3846,6 @@
String ruleId = mZenModeHelper.addAutomaticZenRule(mContext.getPackageName(),
azrBase, UPDATE_ORIGIN_APP, "reason", Process.SYSTEM_UID);
AutomaticZenRule rule = mZenModeHelper.getAutomaticZenRule(ruleId);
- assertThat(rule.canUpdate()).isTrue();
ZenDeviceEffects deviceEffects = new ZenDeviceEffects.Builder()
.setShouldDisplayGrayscale(true)
@@ -3936,8 +3862,10 @@
// New ZenDeviceEffects is used; all fields considered set, since previously were null.
assertThat(rule.getDeviceEffects()).isNotNull();
assertThat(rule.getDeviceEffects().shouldDisplayGrayscale()).isTrue();
- assertThat(rule.canUpdate()).isFalse();
- assertThat(rule.getDeviceEffects().getUserModifiedFields()).isEqualTo(
+
+ ZenRule storedRule = mZenModeHelper.mConfig.automaticRules.get(ruleId);
+ assertThat(storedRule.canBeUpdatedByApp()).isFalse();
+ assertThat(storedRule.zenDeviceEffectsUserModifiedFields).isEqualTo(
ZenDeviceEffects.FIELD_GRAYSCALE);
}
@@ -4340,7 +4268,6 @@
String ruleId = mZenModeHelper.addAutomaticZenRule(mContext.getPackageName(), rule,
UPDATE_ORIGIN_APP, "add it", CUSTOM_PKG_UID);
assertThat(mZenModeHelper.getAutomaticZenRule(ruleId).getCreationTime()).isEqualTo(1000);
- assertThat(mZenModeHelper.getAutomaticZenRule(ruleId).canUpdate()).isTrue();
// User customizes it.
AutomaticZenRule userUpdate = new AutomaticZenRule.Builder(rule)
@@ -4372,9 +4299,11 @@
assertThat(finalRule.getInterruptionFilter()).isEqualTo(INTERRUPTION_FILTER_ALARMS);
assertThat(finalRule.getZenPolicy().getPriorityCategoryRepeatCallers()).isEqualTo(
ZenPolicy.STATE_ALLOW);
- assertThat(finalRule.getUserModifiedFields()).isEqualTo(
+
+ ZenRule storedRule = mZenModeHelper.mConfig.automaticRules.get(ruleId);
+ assertThat(storedRule.userModifiedFields).isEqualTo(
AutomaticZenRule.FIELD_INTERRUPTION_FILTER);
- assertThat(finalRule.getZenPolicy().getUserModifiedFields()).isEqualTo(
+ assertThat(storedRule.zenPolicyUserModifiedFields).isEqualTo(
ZenPolicy.FIELD_PRIORITY_CATEGORY_REPEAT_CALLERS);
// Also, we discarded the "deleted rule" since we already used it for restoration.
@@ -4653,7 +4582,7 @@
ZEN_MODE_IMPORTANT_INTERRUPTIONS);
assertThat(mZenModeHelper.mConfig.automaticRules.values())
- .comparingElementsUsing(IGNORE_TIMESTAMPS)
+ .comparingElementsUsing(IGNORE_METADATA)
.containsExactly(
expectedImplicitRule(CUSTOM_PKG_NAME, ZEN_MODE_IMPORTANT_INTERRUPTIONS,
null, true));
@@ -4673,12 +4602,75 @@
ZEN_MODE_ALARMS);
assertThat(mZenModeHelper.mConfig.automaticRules.values())
- .comparingElementsUsing(IGNORE_TIMESTAMPS)
+ .comparingElementsUsing(IGNORE_METADATA)
.containsExactly(
expectedImplicitRule(CUSTOM_PKG_NAME, ZEN_MODE_ALARMS, null, true));
}
@Test
+ @EnableFlags(android.app.Flags.FLAG_MODES_API)
+ public void applyGlobalZenModeAsImplicitZenRule_ruleCustomized_doesNotUpdateRule() {
+ mZenModeHelper.mConfig.automaticRules.clear();
+ String pkg = mContext.getPackageName();
+
+ // From app, call "setInterruptionFilter" and create and implicit rule.
+ mZenModeHelper.applyGlobalZenModeAsImplicitZenRule(pkg, CUSTOM_PKG_UID,
+ ZEN_MODE_IMPORTANT_INTERRUPTIONS);
+ String ruleId = getOnlyElement(mZenModeHelper.mConfig.automaticRules.keySet());
+ assertThat(getOnlyElement(mZenModeHelper.mConfig.automaticRules.values()).zenMode)
+ .isEqualTo(ZEN_MODE_IMPORTANT_INTERRUPTIONS);
+
+ // From user, update that rule's interruption filter.
+ AutomaticZenRule rule = mZenModeHelper.getAutomaticZenRule(ruleId);
+ AutomaticZenRule userUpdateRule = new AutomaticZenRule.Builder(rule)
+ .setInterruptionFilter(INTERRUPTION_FILTER_ALARMS)
+ .build();
+ mZenModeHelper.updateAutomaticZenRule(ruleId, userUpdateRule, UPDATE_ORIGIN_USER, "reason",
+ Process.SYSTEM_UID);
+
+ // From app, call "setInterruptionFilter" again.
+ mZenModeHelper.applyGlobalZenModeAsImplicitZenRule(pkg, CUSTOM_PKG_UID,
+ ZEN_MODE_NO_INTERRUPTIONS);
+
+ // The app's update was ignored, and the user's update is still current, and the current
+ // mode is the one they chose.
+ assertThat(getOnlyElement(mZenModeHelper.mConfig.automaticRules.values()).zenMode)
+ .isEqualTo(ZEN_MODE_ALARMS);
+ assertThat(mZenModeHelper.getZenMode()).isEqualTo(ZEN_MODE_ALARMS);
+ }
+
+ @Test
+ @EnableFlags(android.app.Flags.FLAG_MODES_API)
+ public void applyGlobalZenModeAsImplicitZenRule_ruleCustomizedButNotFilter_updatesRule() {
+ mZenModeHelper.mConfig.automaticRules.clear();
+ String pkg = mContext.getPackageName();
+
+ // From app, call "setInterruptionFilter" and create and implicit rule.
+ mZenModeHelper.applyGlobalZenModeAsImplicitZenRule(pkg, CUSTOM_PKG_UID,
+ ZEN_MODE_IMPORTANT_INTERRUPTIONS);
+ String ruleId = getOnlyElement(mZenModeHelper.mConfig.automaticRules.keySet());
+ assertThat(getOnlyElement(mZenModeHelper.mConfig.automaticRules.values()).zenMode)
+ .isEqualTo(ZEN_MODE_IMPORTANT_INTERRUPTIONS);
+
+ // From user, update something in that rule, but not the interruption filter.
+ AutomaticZenRule rule = mZenModeHelper.getAutomaticZenRule(ruleId);
+ AutomaticZenRule userUpdateRule = new AutomaticZenRule.Builder(rule)
+ .setName("Renamed")
+ .build();
+ mZenModeHelper.updateAutomaticZenRule(ruleId, userUpdateRule, UPDATE_ORIGIN_USER, "reason",
+ Process.SYSTEM_UID);
+
+ // From app, call "setInterruptionFilter" again.
+ mZenModeHelper.applyGlobalZenModeAsImplicitZenRule(pkg, CUSTOM_PKG_UID,
+ ZEN_MODE_NO_INTERRUPTIONS);
+
+ // The app's update was accepted, and the current mode is the one that they wanted.
+ assertThat(getOnlyElement(mZenModeHelper.mConfig.automaticRules.values()).zenMode)
+ .isEqualTo(ZEN_MODE_NO_INTERRUPTIONS);
+ assertThat(mZenModeHelper.getZenMode()).isEqualTo(ZEN_MODE_NO_INTERRUPTIONS);
+ }
+
+ @Test
public void applyGlobalZenModeAsImplicitZenRule_modeOff_deactivatesImplicitRule() {
mSetFlagsRule.enableFlags(android.app.Flags.FLAG_MODES_API);
mZenModeHelper.mConfig.automaticRules.clear();
@@ -4748,18 +4740,17 @@
Policy policy = new Policy(PRIORITY_CATEGORY_CALLS | PRIORITY_CATEGORY_CONVERSATIONS,
PRIORITY_SENDERS_CONTACTS, PRIORITY_SENDERS_STARRED,
Policy.getAllSuppressedVisualEffects(), CONVERSATION_SENDERS_IMPORTANT);
- mZenModeHelper.applyGlobalPolicyAsImplicitZenRule(CUSTOM_PKG_NAME, CUSTOM_PKG_UID, policy,
- UPDATE_ORIGIN_APP);
+ mZenModeHelper.applyGlobalPolicyAsImplicitZenRule(CUSTOM_PKG_NAME, CUSTOM_PKG_UID, policy);
ZenPolicy expectedZenPolicy = new ZenPolicy.Builder()
.disallowAllSounds()
.allowCalls(PEOPLE_TYPE_CONTACTS)
.allowConversations(CONVERSATION_SENDERS_IMPORTANT)
.hideAllVisualEffects()
- .allowChannels(ZenPolicy.CHANNEL_TYPE_PRIORITY)
+ .allowPriorityChannels(true)
.build();
assertThat(mZenModeHelper.mConfig.automaticRules.values())
- .comparingElementsUsing(IGNORE_TIMESTAMPS)
+ .comparingElementsUsing(IGNORE_METADATA)
.containsExactly(
expectedImplicitRule(CUSTOM_PKG_NAME, ZEN_MODE_IMPORTANT_INTERRUPTIONS,
expectedZenPolicy, /* conditionActive= */ null));
@@ -4774,37 +4765,103 @@
PRIORITY_SENDERS_CONTACTS, PRIORITY_SENDERS_STARRED,
Policy.getAllSuppressedVisualEffects(), CONVERSATION_SENDERS_IMPORTANT);
mZenModeHelper.applyGlobalPolicyAsImplicitZenRule(CUSTOM_PKG_NAME, CUSTOM_PKG_UID,
- original, UPDATE_ORIGIN_APP);
+ original);
// Change priorityCallSenders: contacts -> starred.
Policy updated = new Policy(PRIORITY_CATEGORY_CALLS | PRIORITY_CATEGORY_CONVERSATIONS,
PRIORITY_SENDERS_STARRED, PRIORITY_SENDERS_STARRED,
Policy.getAllSuppressedVisualEffects(), CONVERSATION_SENDERS_IMPORTANT);
- mZenModeHelper.applyGlobalPolicyAsImplicitZenRule(CUSTOM_PKG_NAME, CUSTOM_PKG_UID, updated,
- UPDATE_ORIGIN_APP);
+ mZenModeHelper.applyGlobalPolicyAsImplicitZenRule(CUSTOM_PKG_NAME, CUSTOM_PKG_UID, updated);
ZenPolicy expectedZenPolicy = new ZenPolicy.Builder()
.disallowAllSounds()
.allowCalls(PEOPLE_TYPE_STARRED)
.allowConversations(CONVERSATION_SENDERS_IMPORTANT)
.hideAllVisualEffects()
- .allowChannels(ZenPolicy.CHANNEL_TYPE_PRIORITY)
+ .allowPriorityChannels(true)
.build();
assertThat(mZenModeHelper.mConfig.automaticRules.values())
- .comparingElementsUsing(IGNORE_TIMESTAMPS)
+ .comparingElementsUsing(IGNORE_METADATA)
.containsExactly(
expectedImplicitRule(CUSTOM_PKG_NAME, ZEN_MODE_IMPORTANT_INTERRUPTIONS,
expectedZenPolicy, /* conditionActive= */ null));
}
@Test
+ @EnableFlags(android.app.Flags.FLAG_MODES_API)
+ public void applyGlobalPolicyAsImplicitZenRule_ruleCustomized_doesNotUpdateRule() {
+ mZenModeHelper.mConfig.automaticRules.clear();
+ String pkg = mContext.getPackageName();
+
+ // From app, call "setNotificationPolicy" and create and implicit rule.
+ Policy originalPolicy = new Policy(PRIORITY_CATEGORY_MEDIA, 0, 0);
+ mZenModeHelper.applyGlobalPolicyAsImplicitZenRule(pkg, CUSTOM_PKG_UID, originalPolicy);
+ String ruleId = getOnlyElement(mZenModeHelper.mConfig.automaticRules.keySet());
+
+ // From user, update that rule's policy.
+ AutomaticZenRule rule = mZenModeHelper.getAutomaticZenRule(ruleId);
+ ZenPolicy userUpdateZenPolicy = new ZenPolicy.Builder().disallowAllSounds()
+ .allowAlarms(true).build();
+ AutomaticZenRule userUpdateRule = new AutomaticZenRule.Builder(rule)
+ .setZenPolicy(userUpdateZenPolicy)
+ .build();
+ mZenModeHelper.updateAutomaticZenRule(ruleId, userUpdateRule, UPDATE_ORIGIN_USER, "reason",
+ Process.SYSTEM_UID);
+
+ // From app, call "setNotificationPolicy" again.
+ Policy appUpdatePolicy = new Policy(PRIORITY_CATEGORY_SYSTEM, 0, 0);
+ mZenModeHelper.applyGlobalPolicyAsImplicitZenRule(pkg, CUSTOM_PKG_UID, appUpdatePolicy);
+
+ // The app's update was ignored, and the user's update is still current.
+ assertThat(mZenModeHelper.mConfig.automaticRules.values())
+ .comparingElementsUsing(IGNORE_METADATA)
+ .containsExactly(
+ expectedImplicitRule(pkg, ZEN_MODE_IMPORTANT_INTERRUPTIONS,
+ userUpdateZenPolicy,
+ /* conditionActive= */ null));
+ }
+
+ @Test
+ @EnableFlags(android.app.Flags.FLAG_MODES_API)
+ public void applyGlobalPolicyAsImplicitZenRule_ruleCustomizedButNotZenPolicy_updatesRule() {
+ mZenModeHelper.mConfig.automaticRules.clear();
+ String pkg = mContext.getPackageName();
+
+ // From app, call "setNotificationPolicy" and create and implicit rule.
+ Policy originalPolicy = new Policy(PRIORITY_CATEGORY_MEDIA, 0, 0);
+ mZenModeHelper.applyGlobalPolicyAsImplicitZenRule(pkg, CUSTOM_PKG_UID, originalPolicy);
+ String ruleId = getOnlyElement(mZenModeHelper.mConfig.automaticRules.keySet());
+
+ // From user, update something in that rule, but not the ZenPolicy.
+ AutomaticZenRule rule = mZenModeHelper.getAutomaticZenRule(ruleId);
+ AutomaticZenRule userUpdateRule = new AutomaticZenRule.Builder(rule)
+ .setName("Rule renamed, not touching policy")
+ .build();
+ mZenModeHelper.updateAutomaticZenRule(ruleId, userUpdateRule, UPDATE_ORIGIN_USER, "reason",
+ Process.SYSTEM_UID);
+
+ // From app, call "setNotificationPolicy" again.
+ Policy appUpdatePolicy = new Policy(PRIORITY_CATEGORY_SYSTEM, 0, 0);
+ mZenModeHelper.applyGlobalPolicyAsImplicitZenRule(pkg, CUSTOM_PKG_UID, appUpdatePolicy);
+
+ // The app's update was applied.
+ ZenPolicy appsSecondZenPolicy = new ZenPolicy.Builder()
+ .disallowAllSounds()
+ .allowSystem(true)
+ .allowPriorityChannels(true)
+ .build();
+ assertThat(getOnlyElement(mZenModeHelper.mConfig.automaticRules.values()).zenPolicy)
+ .isEqualTo(appsSecondZenPolicy);
+ }
+
+ @Test
public void applyGlobalPolicyAsImplicitZenRule_flagOff_ignored() {
mSetFlagsRule.disableFlags(android.app.Flags.FLAG_MODES_API);
mZenModeHelper.mConfig.automaticRules.clear();
withoutWtfCrash(
() -> mZenModeHelper.applyGlobalPolicyAsImplicitZenRule(CUSTOM_PKG_NAME,
- CUSTOM_PKG_UID, new Policy(0, 0, 0), UPDATE_ORIGIN_APP));
+ CUSTOM_PKG_UID, new Policy(0, 0, 0)));
assertThat(mZenModeHelper.mConfig.automaticRules).isEmpty();
}
@@ -4817,7 +4874,7 @@
Policy.getAllSuppressedVisualEffects(), STATE_FALSE,
CONVERSATION_SENDERS_IMPORTANT);
mZenModeHelper.applyGlobalPolicyAsImplicitZenRule(CUSTOM_PKG_NAME, CUSTOM_PKG_UID,
- writtenPolicy, UPDATE_ORIGIN_APP);
+ writtenPolicy);
Policy readPolicy = mZenModeHelper.getNotificationPolicyFromImplicitZenRule(
CUSTOM_PKG_NAME);
@@ -4857,7 +4914,7 @@
assertThat(readPolicy.allowConversations()).isFalse();
}
- private static final Correspondence<ZenRule, ZenRule> IGNORE_TIMESTAMPS =
+ private static final Correspondence<ZenRule, ZenRule> IGNORE_METADATA =
Correspondence.transforming(zr -> {
Parcel p = Parcel.obtain();
try {
@@ -4865,12 +4922,15 @@
p.setDataPosition(0);
ZenRule copy = new ZenRule(p);
copy.creationTime = 0;
+ copy.userModifiedFields = 0;
+ copy.zenPolicyUserModifiedFields = 0;
+ copy.zenDeviceEffectsUserModifiedFields = 0;
return copy;
} finally {
p.recycle();
}
},
- "Ignoring timestamps");
+ "Ignoring timestamp and userModifiedFields");
private ZenRule expectedImplicitRule(String ownerPkg, int zenMode, ZenPolicy policy,
@Nullable Boolean conditionActive) {
diff --git a/services/tests/uiservicestests/src/com/android/server/notification/ZenPolicyTest.java b/services/tests/uiservicestests/src/com/android/server/notification/ZenPolicyTest.java
index 21c96d6..4ed55df 100644
--- a/services/tests/uiservicestests/src/com/android/server/notification/ZenPolicyTest.java
+++ b/services/tests/uiservicestests/src/com/android/server/notification/ZenPolicyTest.java
@@ -213,13 +213,12 @@
ZenPolicy unset = builder.build();
// priority channels allowed
- builder.allowChannels(ZenPolicy.CHANNEL_TYPE_PRIORITY);
+ builder.allowPriorityChannels(true);
ZenPolicy channelsPriority = builder.build();
// unset applied, channels setting keeps its state
channelsPriority.apply(unset);
- assertThat(channelsPriority.getAllowedChannels())
- .isEqualTo(ZenPolicy.CHANNEL_TYPE_PRIORITY);
+ assertThat(channelsPriority.getPriorityChannels()).isEqualTo(ZenPolicy.STATE_ALLOW);
}
@Test
@@ -227,15 +226,15 @@
mSetFlagsRule.enableFlags(Flags.FLAG_MODES_API);
ZenPolicy.Builder builder = new ZenPolicy.Builder();
- builder.allowChannels(ZenPolicy.CHANNEL_TYPE_NONE);
+ builder.allowPriorityChannels(false);
ZenPolicy none = builder.build();
- builder.allowChannels(ZenPolicy.CHANNEL_TYPE_PRIORITY);
+ builder.allowPriorityChannels(true);
ZenPolicy priority = builder.build();
// priority channels (less strict state) cannot override a setting that sets it to none
none.apply(priority);
- assertThat(none.getAllowedChannels()).isEqualTo(ZenPolicy.CHANNEL_TYPE_NONE);
+ assertThat(none.getPriorityChannels()).isEqualTo(ZenPolicy.STATE_DISALLOW);
}
@Test
@@ -243,15 +242,15 @@
mSetFlagsRule.enableFlags(Flags.FLAG_MODES_API);
ZenPolicy.Builder builder = new ZenPolicy.Builder();
- builder.allowChannels(ZenPolicy.CHANNEL_TYPE_NONE);
+ builder.allowPriorityChannels(false);
ZenPolicy none = builder.build();
- builder.allowChannels(ZenPolicy.CHANNEL_TYPE_PRIORITY);
+ builder.allowPriorityChannels(true);
ZenPolicy priority = builder.build();
// applying a policy with channelType=none overrides priority setting
priority.apply(none);
- assertThat(priority.getAllowedChannels()).isEqualTo(ZenPolicy.CHANNEL_TYPE_NONE);
+ assertThat(priority.getPriorityChannels()).isEqualTo(ZenPolicy.STATE_DISALLOW);
}
@Test
@@ -261,12 +260,12 @@
ZenPolicy.Builder builder = new ZenPolicy.Builder();
ZenPolicy unset = builder.build();
- builder.allowChannels(ZenPolicy.CHANNEL_TYPE_PRIORITY);
+ builder.allowPriorityChannels(true);
ZenPolicy priority = builder.build();
// applying a policy with a set channel type actually goes through
unset.apply(priority);
- assertThat(unset.getAllowedChannels()).isEqualTo(ZenPolicy.CHANNEL_TYPE_PRIORITY);
+ assertThat(unset.getPriorityChannels()).isEqualTo(ZenPolicy.STATE_ALLOW);
}
@Test
@@ -308,7 +307,7 @@
ZenPolicy.Builder builder = new ZenPolicy.Builder();
ZenPolicy policy = builder.build();
- assertThat(policy.getAllowedChannels()).isEqualTo(ZenPolicy.CHANNEL_TYPE_UNSET);
+ assertThat(policy.getPriorityChannels()).isEqualTo(ZenPolicy.STATE_UNSET);
}
@Test
@@ -622,10 +621,10 @@
// allowChannels should be unset, not be modifiable, and not show up in any output
ZenPolicy.Builder builder = new ZenPolicy.Builder();
- builder.allowChannels(ZenPolicy.CHANNEL_TYPE_PRIORITY);
+ builder.allowPriorityChannels(true);
ZenPolicy policy = builder.build();
- assertThat(policy.getAllowedChannels()).isEqualTo(ZenPolicy.CHANNEL_TYPE_UNSET);
+ assertThat(policy.getPriorityChannels()).isEqualTo(ZenPolicy.STATE_UNSET);
assertThat(policy.toString().contains("allowChannels")).isFalse();
}
@@ -635,40 +634,14 @@
// allow priority channels
ZenPolicy.Builder builder = new ZenPolicy.Builder();
- builder.allowChannels(ZenPolicy.CHANNEL_TYPE_PRIORITY);
+ builder.allowPriorityChannels(true);
ZenPolicy policy = builder.build();
- assertThat(policy.getAllowedChannels()).isEqualTo(ZenPolicy.CHANNEL_TYPE_PRIORITY);
+ assertThat(policy.getPriorityChannels()).isEqualTo(ZenPolicy.STATE_ALLOW);
// disallow priority channels
- builder.allowChannels(ZenPolicy.CHANNEL_TYPE_NONE);
+ builder.allowPriorityChannels(false);
policy = builder.build();
- assertThat(policy.getAllowedChannels()).isEqualTo(ZenPolicy.CHANNEL_TYPE_NONE);
- }
-
- @Test
- public void testFromParcel() {
- ZenPolicy.Builder builder = new ZenPolicy.Builder();
- builder.setUserModifiedFields(10);
-
- ZenPolicy policy = builder.build();
- assertThat(policy.getUserModifiedFields()).isEqualTo(10);
-
- Parcel parcel = Parcel.obtain();
- policy.writeToParcel(parcel, 0);
- parcel.setDataPosition(0);
-
- ZenPolicy fromParcel = ZenPolicy.CREATOR.createFromParcel(parcel);
- assertThat(fromParcel.getUserModifiedFields()).isEqualTo(10);
- }
-
- @Test
- public void testPolicy_userModifiedFields() {
- ZenPolicy.Builder builder = new ZenPolicy.Builder();
- builder.setUserModifiedFields(10);
- assertThat(builder.build().getUserModifiedFields()).isEqualTo(10);
-
- builder.setUserModifiedFields(0);
- assertThat(builder.build().getUserModifiedFields()).isEqualTo(0);
+ assertThat(policy.getPriorityChannels()).isEqualTo(ZenPolicy.STATE_DISALLOW);
}
@Test
@@ -676,8 +649,8 @@
ZenPolicy.Builder builder = new ZenPolicy.Builder();
ZenPolicy policy = builder.allowRepeatCallers(true).allowAlarms(false)
.showLights(true).showBadges(false)
- .allowChannels(ZenPolicy.CHANNEL_TYPE_PRIORITY)
- .setUserModifiedFields(20).build();
+ .allowPriorityChannels(true)
+ .build();
ZenPolicy newPolicy = new ZenPolicy.Builder(policy).build();
@@ -689,8 +662,7 @@
assertThat(newPolicy.getVisualEffectBadge()).isEqualTo(ZenPolicy.STATE_DISALLOW);
assertThat(newPolicy.getVisualEffectPeek()).isEqualTo(ZenPolicy.STATE_UNSET);
- assertThat(newPolicy.getAllowedChannels()).isEqualTo(ZenPolicy.CHANNEL_TYPE_PRIORITY);
- assertThat(newPolicy.getUserModifiedFields()).isEqualTo(20);
+ assertThat(newPolicy.getPriorityChannels()).isEqualTo(ZenPolicy.STATE_ALLOW);
}
@Test
diff --git a/services/tests/wmtests/src/com/android/server/wm/TaskTests.java b/services/tests/wmtests/src/com/android/server/wm/TaskTests.java
index b360800..961fdfb 100644
--- a/services/tests/wmtests/src/com/android/server/wm/TaskTests.java
+++ b/services/tests/wmtests/src/com/android/server/wm/TaskTests.java
@@ -1822,6 +1822,35 @@
verify(fragment2).assignLayer(t, 2);
}
+ @Test
+ public void testMoveTaskFragmentsToBottomIfNeeded() {
+ final TaskFragmentOrganizer organizer = new TaskFragmentOrganizer(Runnable::run);
+ final Task task = new TaskBuilder(mSupervisor).setCreateActivity(true).build();
+ final ActivityRecord unembeddedActivity = task.getTopMostActivity();
+
+ final TaskFragment fragment1 = createTaskFragmentWithEmbeddedActivity(task, organizer);
+ final TaskFragment fragment2 = createTaskFragmentWithEmbeddedActivity(task, organizer);
+ final TaskFragment fragment3 = createTaskFragmentWithEmbeddedActivity(task, organizer);
+ doReturn(true).when(fragment1).isMoveToBottomIfClearWhenLaunch();
+ doReturn(false).when(fragment2).isMoveToBottomIfClearWhenLaunch();
+ doReturn(true).when(fragment3).isMoveToBottomIfClearWhenLaunch();
+
+ assertEquals(unembeddedActivity, task.mChildren.get(0));
+ assertEquals(fragment1, task.mChildren.get(1));
+ assertEquals(fragment2, task.mChildren.get(2));
+ assertEquals(fragment3, task.mChildren.get(3));
+
+ final int[] finishCount = {0};
+ task.moveTaskFragmentsToBottomIfNeeded(unembeddedActivity, finishCount);
+
+ // fragment1 and fragment3 should be moved to the bottom of the task
+ assertEquals(fragment1, task.mChildren.get(0));
+ assertEquals(fragment3, task.mChildren.get(1));
+ assertEquals(unembeddedActivity, task.mChildren.get(2));
+ assertEquals(fragment2, task.mChildren.get(3));
+ assertEquals(2, finishCount[0]);
+ }
+
private Task getTestTask() {
return new TaskBuilder(mSupervisor).setCreateActivity(true).build();
}
diff --git a/services/usage/java/com/android/server/usage/BroadcastResponseStatsLogger.java b/services/usage/java/com/android/server/usage/BroadcastResponseStatsLogger.java
index 336bfdd..a8fd6f2 100644
--- a/services/usage/java/com/android/server/usage/BroadcastResponseStatsLogger.java
+++ b/services/usage/java/com/android/server/usage/BroadcastResponseStatsLogger.java
@@ -35,11 +35,13 @@
import android.util.TimeUtils;
import com.android.internal.annotations.GuardedBy;
-import com.android.internal.annotations.Keep;
import com.android.internal.util.IndentingPrintWriter;
import com.android.internal.util.RingBuffer;
import com.android.server.usage.BroadcastResponseStatsTracker.NotificationEventType;
+import java.util.function.IntFunction;
+import java.util.function.Supplier;
+
public class BroadcastResponseStatsLogger {
private static final int MAX_LOG_SIZE =
@@ -49,10 +51,10 @@
@GuardedBy("mLock")
private final LogBuffer mBroadcastEventsBuffer = new LogBuffer(
- BroadcastEvent.class, MAX_LOG_SIZE);
+ BroadcastEvent::new, BroadcastEvent[]::new, MAX_LOG_SIZE);
@GuardedBy("mLock")
private final LogBuffer mNotificationEventsBuffer = new LogBuffer(
- NotificationEvent.class, MAX_LOG_SIZE);
+ NotificationEvent::new, NotificationEvent[]::new, MAX_LOG_SIZE);
void logBroadcastDispatchEvent(int sourceUid, @NonNull String targetPackage,
UserHandle targetUser, long idForResponseEvent,
@@ -96,8 +98,8 @@
private static final class LogBuffer<T extends Data> extends RingBuffer<T> {
- LogBuffer(Class<T> classType, int capacity) {
- super(classType, capacity);
+ LogBuffer(Supplier<T> newItem, IntFunction<T[]> newBacking, int capacity) {
+ super(newItem, newBacking, capacity);
}
void logBroadcastDispatchEvent(int sourceUid, @NonNull String targetPackage,
@@ -179,8 +181,7 @@
}
}
- @Keep
- public static final class BroadcastEvent implements Data {
+ private static final class BroadcastEvent implements Data {
public int sourceUid;
public int targetUserId;
public int targetUidProcessState;
@@ -200,8 +201,7 @@
}
}
- @Keep
- public static final class NotificationEvent implements Data {
+ private static final class NotificationEvent implements Data {
public int type;
public String packageName;
public int userId;
@@ -218,7 +218,7 @@
}
}
- public interface Data {
+ private interface Data {
void reset();
}
}
diff --git a/services/voiceinteraction/java/com/android/server/soundtrigger/PhoneCallStateHandler.java b/services/voiceinteraction/java/com/android/server/soundtrigger/PhoneCallStateHandler.java
index 1df7012..49ad461 100644
--- a/services/voiceinteraction/java/com/android/server/soundtrigger/PhoneCallStateHandler.java
+++ b/services/voiceinteraction/java/com/android/server/soundtrigger/PhoneCallStateHandler.java
@@ -62,7 +62,8 @@
SubscriptionManager subscriptionManager,
TelephonyManager telephonyManager,
Callback callback) {
- mSubscriptionManager = Objects.requireNonNull(subscriptionManager);
+ mSubscriptionManager = Objects.requireNonNull(subscriptionManager)
+ .createForAllUserProfiles();
mTelephonyManager = Objects.requireNonNull(telephonyManager);
mCallback = Objects.requireNonNull(callback);
mSubscriptionManager.addOnSubscriptionsChangedListener(
diff --git a/telecomm/java/android/telecom/CallControl.java b/telecomm/java/android/telecom/CallControl.java
index 24d3918..fe699af 100644
--- a/telecomm/java/android/telecom/CallControl.java
+++ b/telecomm/java/android/telecom/CallControl.java
@@ -19,6 +19,7 @@
import static android.telecom.CallException.TRANSACTION_EXCEPTION_KEY;
import android.annotation.CallbackExecutor;
+import android.annotation.FlaggedApi;
import android.annotation.NonNull;
import android.annotation.Nullable;
import android.annotation.SuppressLint;
@@ -32,6 +33,7 @@
import com.android.internal.telecom.ClientTransactionalServiceRepository;
import com.android.internal.telecom.ICallControl;
+import com.android.server.telecom.flags.Flags;
import java.util.List;
import java.util.Objects;
@@ -292,6 +294,43 @@
}
/**
+ * Request a new mute state. Note: {@link CallEventCallback#onMuteStateChanged(boolean)}
+ * will be called every time the mute state is changed and can be used to track the current
+ * mute state.
+ *
+ * @param isMuted The new mute state. Passing in a {@link Boolean#TRUE} for the isMuted
+ * parameter will mute the call. {@link Boolean#FALSE} will unmute the call.
+ * @param executor The {@link Executor} on which the {@link OutcomeReceiver} callback
+ * will be called on.
+ * @param callback The {@link OutcomeReceiver} that will be completed on the Telecom side
+ * that details success or failure of the requested operation.
+ *
+ * {@link OutcomeReceiver#onResult} will be called if Telecom has
+ * successfully changed the mute state.
+ *
+ * {@link OutcomeReceiver#onError} will be called if Telecom has failed to
+ * switch to the mute state. A {@link CallException} will be
+ * passed that details why the operation failed.
+ */
+ @FlaggedApi(Flags.FLAG_SET_MUTE_STATE)
+ public void setMuteState(boolean isMuted, @CallbackExecutor @NonNull Executor executor,
+ @NonNull OutcomeReceiver<Void, CallException> callback) {
+ Objects.requireNonNull(executor);
+ Objects.requireNonNull(callback);
+ if (mServerInterface != null) {
+ try {
+ mServerInterface.setMuteState(isMuted,
+ new CallControlResultReceiver("setMuteState", executor, callback));
+
+ } catch (RemoteException e) {
+ throw e.rethrowAsRuntimeException();
+ }
+ } else {
+ throw new IllegalStateException(INTERFACE_ERROR_MSG);
+ }
+ }
+
+ /**
* Raises an event to the {@link android.telecom.InCallService} implementations tracking this
* call via {@link android.telecom.Call.Callback#onConnectionEvent(Call, String, Bundle)}.
* These events and the associated extra keys for the {@code Bundle} parameter are mutually
diff --git a/telecomm/java/android/telecom/TelecomManager.java b/telecomm/java/android/telecom/TelecomManager.java
index 57b13e9..e81f482 100644
--- a/telecomm/java/android/telecom/TelecomManager.java
+++ b/telecomm/java/android/telecom/TelecomManager.java
@@ -1049,8 +1049,17 @@
public static final int PRESENTATION_UNAVAILABLE = 5;
+ /**
+ * Controls audio route for video calls.
+ * 0 - Use the default audio routing strategy.
+ * 1 - Disable the speaker. Route the audio to Headset or Bluetooth
+ * or Earpiece, based on the default audio routing strategy.
+ * @hide
+ */
+ public static final String PROPERTY_VIDEOCALL_AUDIO_OUTPUT = "persist.radio.call.audio.output";
+
/*
- * Values for the adb property "persist.radio.videocall.audio.output"
+ * Values for the adb property "persist.radio.call.audio.output"
*/
/** @hide */
public static final int AUDIO_OUTPUT_ENABLE_SPEAKER = 0;
diff --git a/telecomm/java/com/android/internal/telecom/ICallControl.aidl b/telecomm/java/com/android/internal/telecom/ICallControl.aidl
index 5e2c923..372e4a12 100644
--- a/telecomm/java/com/android/internal/telecom/ICallControl.aidl
+++ b/telecomm/java/com/android/internal/telecom/ICallControl.aidl
@@ -32,5 +32,6 @@
void disconnect(String callId, in DisconnectCause disconnectCause, in ResultReceiver callback);
void startCallStreaming(String callId, in ResultReceiver callback);
void requestCallEndpointChange(in CallEndpoint callEndpoint, in ResultReceiver callback);
+ void setMuteState(boolean isMuted, in ResultReceiver callback);
void sendEvent(String callId, String event, in Bundle extras);
}
\ No newline at end of file
diff --git a/telephony/java/android/telephony/CarrierConfigManager.java b/telephony/java/android/telephony/CarrierConfigManager.java
index 73c26a3..1badf67 100644
--- a/telephony/java/android/telephony/CarrierConfigManager.java
+++ b/telephony/java/android/telephony/CarrierConfigManager.java
@@ -9694,6 +9694,27 @@
"remove_satellite_plmn_in_manual_network_scan_bool";
/**
+ * An integer key holds the time interval for refreshing or re-querying the satellite
+ * entitlement status from the entitlement server to ensure it is the latest.
+ *
+ * The default value is 30 days (1 month).
+ */
+ @FlaggedApi(Flags.FLAG_CARRIER_ENABLED_SATELLITE_FLAG)
+ public static final String KEY_SATELLITE_ENTITLEMENT_STATUS_REFRESH_DAYS_INT =
+ "satellite_entitlement_status_refresh_days_int";
+
+ /**
+ * This configuration enables device to query the entitlement server to get the satellite
+ * configuration.
+ * This will need agreement the carrier before enabling this flag.
+ *
+ * The default value is false.
+ */
+ @FlaggedApi(Flags.FLAG_CARRIER_ENABLED_SATELLITE_FLAG)
+ public static final String KEY_SATELLITE_ENTITLEMENT_SUPPORTED_BOOL =
+ "satellite_entitlement_supported_bool";
+
+ /**
* Indicating whether DUN APN should be disabled when the device is roaming. In that case,
* the default APN (i.e. internet) will be used for tethering.
*
@@ -10799,6 +10820,8 @@
sDefaults.putInt(KEY_PARAMETERS_USED_FOR_NTN_LTE_SIGNAL_BAR_INT,
CellSignalStrengthLte.USE_RSRP);
sDefaults.putBoolean(KEY_REMOVE_SATELLITE_PLMN_IN_MANUAL_NETWORK_SCAN_BOOL, true);
+ sDefaults.putInt(KEY_SATELLITE_ENTITLEMENT_STATUS_REFRESH_DAYS_INT, 30);
+ sDefaults.putBoolean(KEY_SATELLITE_ENTITLEMENT_SUPPORTED_BOOL, false);
sDefaults.putBoolean(KEY_DISABLE_DUN_APN_WHILE_ROAMING_WITH_PRESET_APN_BOOL, false);
sDefaults.putString(KEY_DEFAULT_PREFERRED_APN_NAME_STRING, "");
sDefaults.putBoolean(KEY_SUPPORTS_CALL_COMPOSER_BOOL, false);
diff --git a/telephony/java/android/telephony/ims/ImsService.java b/telephony/java/android/telephony/ims/ImsService.java
index 4c37f7d..b84ff29 100644
--- a/telephony/java/android/telephony/ims/ImsService.java
+++ b/telephony/java/android/telephony/ims/ImsService.java
@@ -16,6 +16,7 @@
package android.telephony.ims;
+import android.annotation.FlaggedApi;
import android.annotation.LongDef;
import android.annotation.NonNull;
import android.annotation.Nullable;
@@ -46,6 +47,7 @@
import com.android.ims.internal.IImsFeatureStatusCallback;
import com.android.internal.annotations.VisibleForTesting;
+import com.android.internal.telephony.flags.Flags;
import com.android.internal.telephony.util.TelephonyUtils;
import java.lang.annotation.Retention;
@@ -152,12 +154,36 @@
public static final long CAPABILITY_TERMINAL_BASED_CALL_WAITING = 1 << 2;
/**
+ * This ImsService supports the capability to manage calls on multiple subscriptions at the same
+ * time.
+ * <p>
+ * When set, this ImsService supports managing calls on multiple subscriptions at the same time
+ * for all WLAN network configurations. Telephony will allow new outgoing/incoming IMS calls to
+ * be set up on other subscriptions while there is an ongoing call. The ImsService must also
+ * support managing calls on WWAN + WWAN configurations whenever the modem also reports
+ * simultaneous calling availability, which can be listened to using the
+ * {@link android.telephony.TelephonyCallback.SimultaneousCellularCallingSupportListener} API.
+ * Telephony will only allow additional ongoing/incoming IMS calls on another subscription to be
+ * set up on WWAN + WWAN configurations when the modem reports that simultaneous cellular
+ * calling is allowed at the current time on both subscriptions where there are ongoing calls.
+ * <p>
+ * When unset (default), this ImsService can not support calls on multiple subscriptions at the
+ * same time for any WLAN or WWAN configurations, so pending outgoing call placed on another
+ * cellular subscription while there is an ongoing call will be cancelled by Telephony.
+ * Similarly, any incoming call notification on another cellular subscription while there is an
+ * ongoing call will be rejected.
+ * @hide TODO: move this to system API when we have a backing implementation + CTS testing
+ */
+ @FlaggedApi(Flags.FLAG_SIMULTANEOUS_CALLING_INDICATIONS)
+ public static final long CAPABILITY_SUPPORTS_SIMULTANEOUS_CALLING = 1 << 3;
+
+ /**
* Used for internal correctness checks of capabilities set by the ImsService implementation and
* tracks the index of the largest defined flag in the capabilities long.
* @hide
*/
public static final long CAPABILITY_MAX_INDEX =
- Long.numberOfTrailingZeros(CAPABILITY_TERMINAL_BASED_CALL_WAITING);
+ Long.numberOfTrailingZeros(CAPABILITY_SUPPORTS_SIMULTANEOUS_CALLING);
/**
* @hide
diff --git a/telephony/java/android/telephony/satellite/SatelliteManager.java b/telephony/java/android/telephony/satellite/SatelliteManager.java
index 3b0397b..70047a6 100644
--- a/telephony/java/android/telephony/satellite/SatelliteManager.java
+++ b/telephony/java/android/telephony/satellite/SatelliteManager.java
@@ -928,10 +928,19 @@
@FlaggedApi(Flags.FLAG_CARRIER_ENABLED_SATELLITE_FLAG)
public static final int SATELLITE_COMMUNICATION_RESTRICTION_REASON_GEOLOCATION = 1;
+ /**
+ * Satellite communication restricted by entitlement server. This can be triggered based on
+ * the EntitlementStatus value received from the entitlement server to enable or disable
+ * satellite.
+ */
+ @FlaggedApi(Flags.FLAG_CARRIER_ENABLED_SATELLITE_FLAG)
+ public static final int SATELLITE_COMMUNICATION_RESTRICTION_REASON_ENTITLEMENT = 2;
+
/** @hide */
@IntDef(prefix = "SATELLITE_COMMUNICATION_RESTRICTION_REASON_", value = {
SATELLITE_COMMUNICATION_RESTRICTION_REASON_USER,
- SATELLITE_COMMUNICATION_RESTRICTION_REASON_GEOLOCATION
+ SATELLITE_COMMUNICATION_RESTRICTION_REASON_GEOLOCATION,
+ SATELLITE_COMMUNICATION_RESTRICTION_REASON_ENTITLEMENT
})
@Retention(RetentionPolicy.SOURCE)
public @interface SatelliteCommunicationRestrictionReason {}
diff --git a/tests/FlickerTests/test-apps/flickerapp/src/com/android/server/wm/flicker/testapp/ActivityEmbeddingSecondaryActivity.java b/tests/FlickerTests/test-apps/flickerapp/src/com/android/server/wm/flicker/testapp/ActivityEmbeddingSecondaryActivity.java
index e3988cd..c44d943 100644
--- a/tests/FlickerTests/test-apps/flickerapp/src/com/android/server/wm/flicker/testapp/ActivityEmbeddingSecondaryActivity.java
+++ b/tests/FlickerTests/test-apps/flickerapp/src/com/android/server/wm/flicker/testapp/ActivityEmbeddingSecondaryActivity.java
@@ -68,7 +68,7 @@
// This triggers a recalcuation of splitatributes.
ActivityEmbeddingController
.getInstance(ActivityEmbeddingSecondaryActivity.this)
- .invalidateTopVisibleActivityStacks();
+ .invalidateVisibleActivityStacks();
}
});
findViewById(R.id.secondary_enter_pip_button).setOnClickListener(
diff --git a/tests/FsVerityTest/AndroidTest.xml b/tests/FsVerityTest/AndroidTest.xml
index d2537f6..f2d7990 100644
--- a/tests/FsVerityTest/AndroidTest.xml
+++ b/tests/FsVerityTest/AndroidTest.xml
@@ -15,6 +15,7 @@
-->
<configuration description="fs-verity end-to-end test">
<option name="test-suite-tag" value="apct" />
+ <option name="config-descriptor:metadata" key="parameter" value="secondary_user"/>
<object type="module_controller" class="com.android.tradefed.testtype.suite.module.ShippingApiLevelModuleController">
<!-- fs-verity is required since R/30 -->