diff options
134 files changed, 5541 insertions, 957 deletions
diff --git a/apex/jobscheduler/service/java/com/android/server/DeviceIdleController.java b/apex/jobscheduler/service/java/com/android/server/DeviceIdleController.java index 4bddbd65c0c3..4caaa09f6a31 100644 --- a/apex/jobscheduler/service/java/com/android/server/DeviceIdleController.java +++ b/apex/jobscheduler/service/java/com/android/server/DeviceIdleController.java @@ -4589,6 +4589,22 @@ public class DeviceIdleController extends SystemService Binder.restoreCallingIdentity(token); } } + } else if ("force-active".equals(cmd)) { + getContext().enforceCallingOrSelfPermission(android.Manifest.permission.DEVICE_POWER, + null); + synchronized (this) { + final long token = Binder.clearCallingIdentity(); + try { + mForceIdle = true; + becomeActiveLocked("force-active", Process.myUid()); + pw.print("Light state: "); + pw.print(lightStateToString(mLightState)); + pw.print(", deep state: "); + pw.println(stateToString(mState)); + } finally { + Binder.restoreCallingIdentity(token); + } + } } else if ("force-idle".equals(cmd)) { getContext().enforceCallingOrSelfPermission(android.Manifest.permission.DEVICE_POWER, null); diff --git a/apex/jobscheduler/service/java/com/android/server/job/JobSchedulerService.java b/apex/jobscheduler/service/java/com/android/server/job/JobSchedulerService.java index 70bf3530eab3..4088a4832f96 100644 --- a/apex/jobscheduler/service/java/com/android/server/job/JobSchedulerService.java +++ b/apex/jobscheduler/service/java/com/android/server/job/JobSchedulerService.java @@ -478,7 +478,6 @@ public class JobSchedulerService extends com.android.server.SystemService case Constants.KEY_RUNTIME_FREE_QUOTA_MAX_LIMIT_MS: case Constants.KEY_RUNTIME_MIN_GUARANTEE_MS: case Constants.KEY_RUNTIME_MIN_EJ_GUARANTEE_MS: - case Constants.KEY_RUNTIME_MIN_HIGH_PRIORITY_GUARANTEE_MS: case Constants.KEY_RUNTIME_MIN_DATA_TRANSFER_GUARANTEE_MS: case Constants.KEY_RUNTIME_DATA_TRANSFER_LIMIT_MS: case Constants.KEY_RUNTIME_MIN_USER_INITIATED_GUARANTEE_MS: @@ -575,8 +574,6 @@ public class JobSchedulerService extends com.android.server.SystemService "runtime_free_quota_max_limit_ms"; private static final String KEY_RUNTIME_MIN_GUARANTEE_MS = "runtime_min_guarantee_ms"; private static final String KEY_RUNTIME_MIN_EJ_GUARANTEE_MS = "runtime_min_ej_guarantee_ms"; - private static final String KEY_RUNTIME_MIN_HIGH_PRIORITY_GUARANTEE_MS = - "runtime_min_high_priority_guarantee_ms"; private static final String KEY_RUNTIME_MIN_DATA_TRANSFER_GUARANTEE_MS = "runtime_min_data_transfer_guarantee_ms"; private static final String KEY_RUNTIME_DATA_TRANSFER_LIMIT_MS = @@ -619,8 +616,6 @@ public class JobSchedulerService extends com.android.server.SystemService public static final long DEFAULT_RUNTIME_MIN_GUARANTEE_MS = 10 * MINUTE_IN_MILLIS; @VisibleForTesting public static final long DEFAULT_RUNTIME_MIN_EJ_GUARANTEE_MS = 3 * MINUTE_IN_MILLIS; - @VisibleForTesting - static final long DEFAULT_RUNTIME_MIN_HIGH_PRIORITY_GUARANTEE_MS = 5 * MINUTE_IN_MILLIS; public static final long DEFAULT_RUNTIME_MIN_DATA_TRANSFER_GUARANTEE_MS = DEFAULT_RUNTIME_MIN_GUARANTEE_MS; public static final long DEFAULT_RUNTIME_DATA_TRANSFER_LIMIT_MS = @@ -744,12 +739,6 @@ public class JobSchedulerService extends com.android.server.SystemService public long RUNTIME_MIN_EJ_GUARANTEE_MS = DEFAULT_RUNTIME_MIN_EJ_GUARANTEE_MS; /** - * The minimum amount of time we try to guarantee high priority jobs will run for. - */ - public long RUNTIME_MIN_HIGH_PRIORITY_GUARANTEE_MS = - DEFAULT_RUNTIME_MIN_HIGH_PRIORITY_GUARANTEE_MS; - - /** * The minimum amount of time we try to guarantee normal data transfer jobs will run for. */ public long RUNTIME_MIN_DATA_TRANSFER_GUARANTEE_MS = @@ -895,7 +884,6 @@ public class JobSchedulerService extends com.android.server.SystemService DeviceConfig.NAMESPACE_JOB_SCHEDULER, KEY_RUNTIME_FREE_QUOTA_MAX_LIMIT_MS, KEY_RUNTIME_MIN_GUARANTEE_MS, KEY_RUNTIME_MIN_EJ_GUARANTEE_MS, - KEY_RUNTIME_MIN_HIGH_PRIORITY_GUARANTEE_MS, KEY_RUNTIME_MIN_USER_INITIATED_DATA_TRANSFER_GUARANTEE_BUFFER_FACTOR, KEY_RUNTIME_MIN_DATA_TRANSFER_GUARANTEE_MS, KEY_RUNTIME_DATA_TRANSFER_LIMIT_MS, @@ -908,11 +896,6 @@ public class JobSchedulerService extends com.android.server.SystemService RUNTIME_MIN_GUARANTEE_MS = Math.max(10 * MINUTE_IN_MILLIS, properties.getLong( KEY_RUNTIME_MIN_GUARANTEE_MS, DEFAULT_RUNTIME_MIN_GUARANTEE_MS)); - // Make sure min runtime for high priority jobs is at least 4 minutes. - RUNTIME_MIN_HIGH_PRIORITY_GUARANTEE_MS = Math.max(4 * MINUTE_IN_MILLIS, - properties.getLong( - KEY_RUNTIME_MIN_HIGH_PRIORITY_GUARANTEE_MS, - DEFAULT_RUNTIME_MIN_HIGH_PRIORITY_GUARANTEE_MS)); // Make sure min runtime for expedited jobs is at least one minute. RUNTIME_MIN_EJ_GUARANTEE_MS = Math.max(MINUTE_IN_MILLIS, properties.getLong( @@ -1008,8 +991,6 @@ public class JobSchedulerService extends com.android.server.SystemService pw.print(KEY_RUNTIME_MIN_GUARANTEE_MS, RUNTIME_MIN_GUARANTEE_MS).println(); pw.print(KEY_RUNTIME_MIN_EJ_GUARANTEE_MS, RUNTIME_MIN_EJ_GUARANTEE_MS).println(); - pw.print(KEY_RUNTIME_MIN_HIGH_PRIORITY_GUARANTEE_MS, - RUNTIME_MIN_HIGH_PRIORITY_GUARANTEE_MS).println(); pw.print(KEY_RUNTIME_FREE_QUOTA_MAX_LIMIT_MS, RUNTIME_FREE_QUOTA_MAX_LIMIT_MS) .println(); pw.print(KEY_RUNTIME_MIN_DATA_TRANSFER_GUARANTEE_MS, @@ -3333,8 +3314,6 @@ public class JobSchedulerService extends com.android.server.SystemService return job.getEffectiveStandbyBucket() != RESTRICTED_INDEX ? mConstants.RUNTIME_MIN_EJ_GUARANTEE_MS : Math.min(mConstants.RUNTIME_MIN_EJ_GUARANTEE_MS, 5 * MINUTE_IN_MILLIS); - } else if (job.getEffectivePriority() >= JobInfo.PRIORITY_HIGH) { - return mConstants.RUNTIME_MIN_HIGH_PRIORITY_GUARANTEE_MS; } else { return mConstants.RUNTIME_MIN_GUARANTEE_MS; } diff --git a/core/api/current.txt b/core/api/current.txt index 2968b59e16c9..a7f69374ff00 100644 --- a/core/api/current.txt +++ b/core/api/current.txt @@ -9848,6 +9848,7 @@ package android.content { method @Nullable public final String getReadPermission(); method @Nullable public String[] getStreamTypes(@NonNull android.net.Uri, @NonNull String); method @Nullable public abstract String getType(@NonNull android.net.Uri); + method @Nullable public String getTypeAnonymous(@NonNull android.net.Uri); method @Nullable public final String getWritePermission(); method @Nullable public abstract android.net.Uri insert(@NonNull android.net.Uri, @Nullable android.content.ContentValues); method @Nullable public android.net.Uri insert(@NonNull android.net.Uri, @Nullable android.content.ContentValues, @Nullable android.os.Bundle); @@ -15782,9 +15783,9 @@ package android.graphics { method @NonNull public static android.graphics.MeshSpecification make(@NonNull @Size(max=8) android.graphics.MeshSpecification.Attribute[], @IntRange(from=1, to=1024) int, @NonNull @Size(max=6) android.graphics.MeshSpecification.Varying[], @NonNull String, @NonNull String, @NonNull android.graphics.ColorSpace); method @NonNull public static android.graphics.MeshSpecification make(@NonNull @Size(max=8) android.graphics.MeshSpecification.Attribute[], @IntRange(from=1, to=1024) int, @NonNull @Size(max=6) android.graphics.MeshSpecification.Varying[], @NonNull String, @NonNull String, @NonNull android.graphics.ColorSpace, int); field public static final int ALPHA_TYPE_OPAQUE = 1; // 0x1 - field public static final int ALPHA_TYPE_PREMUL = 2; // 0x2 - field public static final int ALPHA_TYPE_PREMULT = 3; // 0x3 + field public static final int ALPHA_TYPE_PREMULTIPLIED = 2; // 0x2 field public static final int ALPHA_TYPE_UNKNOWN = 0; // 0x0 + field public static final int ALPHA_TYPE_UNPREMULTIPLIED = 3; // 0x3 field public static final int TYPE_FLOAT = 0; // 0x0 field public static final int TYPE_FLOAT2 = 1; // 0x1 field public static final int TYPE_FLOAT3 = 2; // 0x2 @@ -33460,6 +33461,7 @@ package android.os { field public static final String ACTION_LOW_POWER_STANDBY_ENABLED_CHANGED = "android.os.action.LOW_POWER_STANDBY_ENABLED_CHANGED"; field public static final String ACTION_LOW_POWER_STANDBY_POLICY_CHANGED = "android.os.action.LOW_POWER_STANDBY_POLICY_CHANGED"; field public static final String ACTION_POWER_SAVE_MODE_CHANGED = "android.os.action.POWER_SAVE_MODE_CHANGED"; + field public static final String FEATURE_WAKE_ON_LAN_IN_LOW_POWER_STANDBY = "com.android.lowpowerstandby.WAKE_ON_LAN"; field @Deprecated public static final int FULL_WAKE_LOCK = 26; // 0x1a field public static final int LOCATION_MODE_ALL_DISABLED_WHEN_SCREEN_OFF = 2; // 0x2 field public static final int LOCATION_MODE_FOREGROUND_ONLY = 3; // 0x3 @@ -33469,7 +33471,6 @@ package android.os { field public static final int LOW_POWER_STANDBY_ALLOWED_REASON_ONGOING_CALL = 4; // 0x4 field public static final int LOW_POWER_STANDBY_ALLOWED_REASON_TEMP_POWER_SAVE_ALLOWLIST = 2; // 0x2 field public static final int LOW_POWER_STANDBY_ALLOWED_REASON_VOICE_INTERACTION = 1; // 0x1 - field public static final String LOW_POWER_STANDBY_FEATURE_WAKE_ON_LAN = "com.android.lowpowerstandby.WAKE_ON_LAN"; field public static final int ON_AFTER_RELEASE = 536870912; // 0x20000000 field public static final int PARTIAL_WAKE_LOCK = 1; // 0x1 field public static final int PROXIMITY_SCREEN_OFF_WAKE_LOCK = 32; // 0x20 @@ -41246,6 +41247,7 @@ package android.service.voice { method public void setUiEnabled(boolean); method public void show(android.os.Bundle, int); method public void startAssistantActivity(android.content.Intent); + method public void startAssistantActivity(@NonNull android.content.Intent, @NonNull android.os.Bundle); method public void startVoiceActivity(android.content.Intent); method public final void unregisterVisibleActivityCallback(@NonNull android.service.voice.VoiceInteractionSession.VisibleActivityCallback); field public static final String KEY_SHOW_SESSION_ID = "android.service.voice.SHOW_SESSION_ID"; diff --git a/core/api/system-current.txt b/core/api/system-current.txt index 0c5640192069..e6d636155dcd 100644 --- a/core/api/system-current.txt +++ b/core/api/system-current.txt @@ -10152,7 +10152,6 @@ package android.net.wifi.sharedconnectivity.service { public abstract class SharedConnectivityService extends android.app.Service { ctor public SharedConnectivityService(); - ctor public SharedConnectivityService(@NonNull android.os.Handler); method @Nullable public final android.os.IBinder onBind(@NonNull android.content.Intent); method public abstract void onConnectKnownNetwork(@NonNull android.net.wifi.sharedconnectivity.app.KnownNetwork); method public abstract void onConnectTetherNetwork(@NonNull android.net.wifi.sharedconnectivity.app.TetherNetwork); @@ -13041,6 +13040,19 @@ package android.service.voice { method public int getStart(); } + public abstract class DetectorFailure implements android.os.Parcelable { + method public int describeContents(); + method @NonNull public String getErrorMessage(); + method public abstract int getSuggestedAction(); + method public void writeToParcel(@NonNull android.os.Parcel, int); + field @NonNull public static final android.os.Parcelable.Creator<android.service.voice.DetectorFailure> CREATOR; + field public static final int SUGGESTED_ACTION_DISABLE_DETECTION = 2; // 0x2 + field public static final int SUGGESTED_ACTION_NONE = 1; // 0x1 + field public static final int SUGGESTED_ACTION_RECREATE_DETECTOR = 3; // 0x3 + field public static final int SUGGESTED_ACTION_RESTART_RECOGNITION = 4; // 0x4 + field public static final int SUGGESTED_ACTION_UNKNOWN = 0; // 0x0 + } + public final class HotwordAudioStream implements android.os.Parcelable { method public int describeContents(); method @NonNull public android.media.AudioFormat getAudioFormat(); @@ -13131,6 +13143,20 @@ package android.service.voice { method public void onRejected(@NonNull android.service.voice.HotwordRejectedResult); } + public final class HotwordDetectionServiceFailure extends android.service.voice.DetectorFailure { + method public int getErrorCode(); + method public int getSuggestedAction(); + field @NonNull public static final android.os.Parcelable.Creator<android.service.voice.HotwordDetectionServiceFailure> CREATOR; + field public static final int ERROR_CODE_BINDING_DIED = 2; // 0x2 + field public static final int ERROR_CODE_BIND_FAILURE = 1; // 0x1 + field public static final int ERROR_CODE_COPY_AUDIO_DATA_FAILURE = 3; // 0x3 + field public static final int ERROR_CODE_DETECT_TIMEOUT = 4; // 0x4 + field public static final int ERROR_CODE_ON_DETECTED_SECURITY_EXCEPTION = 5; // 0x5 + field public static final int ERROR_CODE_ON_DETECTED_STREAM_COPY_FAILURE = 6; // 0x6 + field public static final int ERROR_CODE_REMOTE_EXCEPTION = 7; // 0x7 + field public static final int ERROR_CODE_UNKNOWN = 0; // 0x0 + } + public interface HotwordDetector { method public default void destroy(); method @RequiresPermission(allOf={android.Manifest.permission.RECORD_AUDIO, android.Manifest.permission.CAPTURE_AUDIO_HOTWORD}) public boolean startRecognition() throws android.service.voice.HotwordDetector.IllegalDetectorStateException; @@ -13141,7 +13167,8 @@ package android.service.voice { public static interface HotwordDetector.Callback { method public void onDetected(@NonNull android.service.voice.AlwaysOnHotwordDetector.EventPayload); - method public void onError(); + method @Deprecated public void onError(); + method public default void onFailure(@NonNull android.service.voice.DetectorFailure); method public void onHotwordDetectionServiceInitialized(int); method public void onHotwordDetectionServiceRestarted(); method public void onRecognitionPaused(); @@ -13176,6 +13203,21 @@ package android.service.voice { field public static final int INITIALIZATION_STATUS_UNKNOWN = 100; // 0x64 } + public final class SoundTriggerFailure extends android.service.voice.DetectorFailure { + method public int getErrorCode(); + method public int getSuggestedAction(); + field @NonNull public static final android.os.Parcelable.Creator<android.service.voice.SoundTriggerFailure> CREATOR; + field public static final int ERROR_CODE_MODULE_DIED = 1; // 0x1 + field public static final int ERROR_CODE_RECOGNITION_RESUME_FAILED = 2; // 0x2 + field public static final int ERROR_CODE_UNEXPECTED_PREEMPTION = 3; // 0x3 + field public static final int ERROR_CODE_UNKNOWN = 0; // 0x0 + } + + public final class UnknownFailure extends android.service.voice.DetectorFailure { + method public int getSuggestedAction(); + field @NonNull public static final android.os.Parcelable.Creator<android.service.voice.UnknownFailure> CREATOR; + } + public abstract class VisualQueryDetectionService extends android.app.Service implements android.service.voice.SandboxedDetectionServiceBase { ctor public VisualQueryDetectionService(); method @Nullable public android.os.IBinder onBind(@NonNull android.content.Intent); @@ -13194,6 +13236,18 @@ package android.service.voice { method public void onQueryRejected() throws java.lang.IllegalStateException; } + public final class VisualQueryDetectionServiceFailure extends android.service.voice.DetectorFailure { + method public int getErrorCode(); + method public int getSuggestedAction(); + field @NonNull public static final android.os.Parcelable.Creator<android.service.voice.VisualQueryDetectionServiceFailure> CREATOR; + field public static final int ERROR_CODE_BINDING_DIED = 2; // 0x2 + field public static final int ERROR_CODE_BIND_FAILURE = 1; // 0x1 + field public static final int ERROR_CODE_ILLEGAL_ATTENTION_STATE = 3; // 0x3 + field public static final int ERROR_CODE_ILLEGAL_STREAMING_STATE = 4; // 0x4 + field public static final int ERROR_CODE_REMOTE_EXCEPTION = 5; // 0x5 + field public static final int ERROR_CODE_UNKNOWN = 0; // 0x0 + } + public class VisualQueryDetector { method public void destroy(); method @RequiresPermission(allOf={android.Manifest.permission.CAMERA, android.Manifest.permission.RECORD_AUDIO}) public boolean startRecognition() throws android.service.voice.HotwordDetector.IllegalDetectorStateException; @@ -13202,7 +13256,7 @@ package android.service.voice { } public static interface VisualQueryDetector.Callback { - method public void onError(); + method public void onFailure(@NonNull android.service.voice.DetectorFailure); method public void onQueryDetected(@NonNull String); method public void onQueryFinished(); method public void onQueryRejected(); diff --git a/core/api/test-current.txt b/core/api/test-current.txt index c0cd6386aec2..3baf5a24e683 100644 --- a/core/api/test-current.txt +++ b/core/api/test-current.txt @@ -985,7 +985,7 @@ package android.content.pm { method public boolean isInitialized(); method public boolean isMain(); method public boolean isManagedProfile(); - method public boolean isPrimary(); + method @Deprecated public boolean isPrimary(); method public boolean isProfile(); method public boolean isQuietModeEnabled(); method public boolean isRestricted(); @@ -1002,7 +1002,7 @@ package android.content.pm { field public static final int FLAG_INITIALIZED = 16; // 0x10 field public static final int FLAG_MAIN = 16384; // 0x4000 field @Deprecated public static final int FLAG_MANAGED_PROFILE = 32; // 0x20 - field public static final int FLAG_PRIMARY = 1; // 0x1 + field @Deprecated public static final int FLAG_PRIMARY = 1; // 0x1 field public static final int FLAG_PROFILE = 4096; // 0x1000 field public static final int FLAG_QUIET_MODE = 128; // 0x80 field @Deprecated public static final int FLAG_RESTRICTED = 8; // 0x8 @@ -2796,10 +2796,26 @@ package android.service.voice { field public static final boolean ENABLE_PROXIMITY_RESULT = true; } + public final class HotwordDetectionServiceFailure extends android.service.voice.DetectorFailure { + ctor public HotwordDetectionServiceFailure(int, @NonNull String); + } + + public final class SoundTriggerFailure extends android.service.voice.DetectorFailure { + ctor public SoundTriggerFailure(int, @NonNull String); + } + + public final class UnknownFailure extends android.service.voice.DetectorFailure { + ctor public UnknownFailure(@NonNull String); + } + public final class VisibleActivityInfo implements android.os.Parcelable { ctor public VisibleActivityInfo(int, @NonNull android.os.IBinder); } + public final class VisualQueryDetectionServiceFailure extends android.service.voice.DetectorFailure { + ctor public VisualQueryDetectionServiceFailure(int, @NonNull String); + } + public class VoiceInteractionService extends android.app.Service { method @NonNull @RequiresPermission(android.Manifest.permission.MANAGE_HOTWORD_DETECTION) public final android.service.voice.AlwaysOnHotwordDetector createAlwaysOnHotwordDetectorForTest(@NonNull String, @NonNull java.util.Locale, @NonNull android.hardware.soundtrigger.SoundTrigger.ModuleProperties, @NonNull java.util.concurrent.Executor, @NonNull android.service.voice.AlwaysOnHotwordDetector.Callback); method @NonNull @RequiresPermission(android.Manifest.permission.MANAGE_HOTWORD_DETECTION) public final android.service.voice.AlwaysOnHotwordDetector createAlwaysOnHotwordDetectorForTest(@NonNull String, @NonNull java.util.Locale, @Nullable android.os.PersistableBundle, @Nullable android.os.SharedMemory, @NonNull android.hardware.soundtrigger.SoundTrigger.ModuleProperties, @NonNull java.util.concurrent.Executor, @NonNull android.service.voice.AlwaysOnHotwordDetector.Callback); diff --git a/core/java/android/app/IActivityManager.aidl b/core/java/android/app/IActivityManager.aidl index aa5b86679849..f653e132f7e3 100644 --- a/core/java/android/app/IActivityManager.aidl +++ b/core/java/android/app/IActivityManager.aidl @@ -347,7 +347,7 @@ interface IActivityManager { String getProviderMimeType(in Uri uri, int userId); oneway void getProviderMimeTypeAsync(in Uri uri, int userId, in RemoteCallback resultCallback); - + oneway void getMimeTypeFilterAsync(in Uri uri, int userId, in RemoteCallback resultCallback); // Cause the specified process to dump the specified heap. boolean dumpHeap(in String process, int userId, boolean managed, boolean mallocInfo, boolean runGc, in String path, in ParcelFileDescriptor fd, diff --git a/core/java/android/app/Notification.java b/core/java/android/app/Notification.java index 3a3ad8cef1e9..87c77c2e8602 100644 --- a/core/java/android/app/Notification.java +++ b/core/java/android/app/Notification.java @@ -4634,8 +4634,8 @@ public class Notification implements Parcelable * Set whether this is an "ongoing" notification. * * Ongoing notifications cannot be dismissed by the user on locked devices, or by - * notification listeners, and some notifications cannnot be dismissed on unlocked - * devices (system, device management, media), so your application or service must take + * notification listeners, and some notifications (device management, media) cannot be + * dismissed on unlocked devices, so your application or service must take * care of canceling them. * * They are typically used to indicate a background task that the user is actively engaged @@ -6992,8 +6992,10 @@ public class Notification implements Parcelable /** * Returns whether an app can colorize due to the android.permission.USE_COLORIZED_NOTIFICATIONS * permission. The permission is checked when a notification is enqueued. + * + * @hide */ - private boolean hasColorizedPermission() { + public boolean hasColorizedPermission() { return (flags & Notification.FLAG_CAN_COLORIZE) != 0; } diff --git a/core/java/android/app/NotificationManager.java b/core/java/android/app/NotificationManager.java index 82adaaf70bcb..4330831642db 100644 --- a/core/java/android/app/NotificationManager.java +++ b/core/java/android/app/NotificationManager.java @@ -1365,7 +1365,7 @@ public class NotificationManager { } /** - * Returns whether notifications from the calling package are blocked. + * Returns whether notifications from the calling package are enabled. */ public boolean areNotificationsEnabled() { INotificationManager service = getService(); diff --git a/core/java/android/app/admin/DevicePolicyManager.java b/core/java/android/app/admin/DevicePolicyManager.java index a331b404047b..024141777604 100644 --- a/core/java/android/app/admin/DevicePolicyManager.java +++ b/core/java/android/app/admin/DevicePolicyManager.java @@ -5462,7 +5462,8 @@ public class DevicePolicyManager { public boolean isActivePasswordSufficient() { if (mService != null) { try { - return mService.isActivePasswordSufficient(myUserId(), mParentInstance); + return mService.isActivePasswordSufficient( + mContext.getPackageName(), myUserId(), mParentInstance); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } @@ -5619,7 +5620,8 @@ public class DevicePolicyManager { } try { - return mService.getRequiredPasswordComplexity(mParentInstance); + return mService.getRequiredPasswordComplexity( + mContext.getPackageName(), mParentInstance); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } @@ -5743,7 +5745,8 @@ public class DevicePolicyManager { public int getCurrentFailedPasswordAttempts(int userHandle) { if (mService != null) { try { - return mService.getCurrentFailedPasswordAttempts(userHandle, mParentInstance); + return mService.getCurrentFailedPasswordAttempts( + mContext.getPackageName(), userHandle, mParentInstance); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } @@ -16643,7 +16646,7 @@ public class DevicePolicyManager { return null; } try { - return mService.getWifiSsidPolicy(); + return mService.getWifiSsidPolicy(mContext.getPackageName()); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } diff --git a/core/java/android/app/admin/IDevicePolicyManager.aidl b/core/java/android/app/admin/IDevicePolicyManager.aidl index 3a75da340745..51aff9ef71ba 100644 --- a/core/java/android/app/admin/IDevicePolicyManager.aidl +++ b/core/java/android/app/admin/IDevicePolicyManager.aidl @@ -96,15 +96,15 @@ interface IDevicePolicyManager { long getPasswordExpiration(in ComponentName who, int userHandle, boolean parent); - boolean isActivePasswordSufficient(int userHandle, boolean parent); + boolean isActivePasswordSufficient(String callerPackageName, int userHandle, boolean parent); boolean isActivePasswordSufficientForDeviceRequirement(); boolean isPasswordSufficientAfterProfileUnification(int userHandle, int profileUser); int getPasswordComplexity(boolean parent); void setRequiredPasswordComplexity(String callerPackageName, int passwordComplexity, boolean parent); - int getRequiredPasswordComplexity(boolean parent); + int getRequiredPasswordComplexity(String callerPackageName, boolean parent); int getAggregatedPasswordComplexityForUser(int userId, boolean deviceWideOnly); boolean isUsingUnifiedPassword(in ComponentName admin); - int getCurrentFailedPasswordAttempts(int userHandle, boolean parent); + int getCurrentFailedPasswordAttempts(String callerPackageName, int userHandle, boolean parent); int getProfileWithMinimumFailedPasswordsForWipe(int userHandle, boolean parent); void setMaximumFailedPasswordsForWipe( @@ -572,7 +572,7 @@ interface IDevicePolicyManager { int getMinimumRequiredWifiSecurityLevel(); void setWifiSsidPolicy(String callerPackageName, in WifiSsidPolicy policy); - WifiSsidPolicy getWifiSsidPolicy(); + WifiSsidPolicy getWifiSsidPolicy(String callerPackageName); List<UserHandle> listForegroundAffiliatedUsers(); void setDrawables(in List<DevicePolicyDrawableResource> drawables); diff --git a/core/java/android/content/ContentProvider.java b/core/java/android/content/ContentProvider.java index e8f0a89930ad..c8db0d8c958d 100644 --- a/core/java/android/content/ContentProvider.java +++ b/core/java/android/content/ContentProvider.java @@ -18,14 +18,15 @@ package android.content; import static android.Manifest.permission.INTERACT_ACROSS_USERS; import static android.Manifest.permission.INTERACT_ACROSS_USERS_FULL; +import static android.os.Process.SYSTEM_UID; import static android.os.Process.myUserHandle; import static android.os.Trace.TRACE_TAG_DATABASE; import static com.android.internal.util.FrameworkStatsLog.GET_TYPE_ACCESSED_WITHOUT_PERMISSION; import static com.android.internal.util.FrameworkStatsLog.GET_TYPE_ACCESSED_WITHOUT_PERMISSION__LOCATION__PROVIDER_CHECK_URI_PERMISSION; -import static com.android.internal.util.FrameworkStatsLog.GET_TYPE_ACCESSED_WITHOUT_PERMISSION__LOCATION__PROVIDER_ERROR; import static com.android.internal.util.FrameworkStatsLog.GET_TYPE_ACCESSED_WITHOUT_PERMISSION__LOCATION__PROVIDER_FRAMEWORK_PERMISSION; +import android.Manifest; import android.annotation.NonNull; import android.annotation.Nullable; import android.annotation.SystemApi; @@ -300,17 +301,32 @@ public abstract class ContentProvider implements ContentInterface, ComponentCall } @Override - public String getType(Uri uri) { + public String getType(AttributionSource attributionSource, Uri uri) { // getCallingPackage() isn't available in getType(), as the javadoc states. uri = validateIncomingUri(uri); uri = maybeGetUriWithoutUserId(uri); traceBegin(TRACE_TAG_DATABASE, "getType: ", uri.getAuthority()); try { - final String type = mInterface.getType(uri); - if (type != null) { - logGetTypeData(Binder.getCallingUid(), uri, type); + if (checkGetTypePermission(attributionSource, uri) + == PermissionChecker.PERMISSION_GRANTED) { + final String type = mInterface.getType(uri); + if (type != null) { + logGetTypeData(Binder.getCallingUid(), uri, type, true); + } + return type; + } else { + final int callingUid = Binder.getCallingUid(); + final long origId = Binder.clearCallingIdentity(); + try { + final String type = getTypeAnonymous(uri); + if (type != null) { + logGetTypeData(callingUid, uri, type, false); + } + return type; + } finally { + Binder.restoreCallingIdentity(origId); + } } - return type; } catch (RemoteException e) { throw e.rethrowAsRuntimeException(); } finally { @@ -319,59 +335,62 @@ public abstract class ContentProvider implements ContentInterface, ComponentCall } // Utility function to log the getTypeData calls - private void logGetTypeData(int callingUid, Uri uri, String type) { + private void logGetTypeData(int callingUid, Uri uri, String type, + boolean permissionCheckPassed) { final int enumFrameworkPermission = GET_TYPE_ACCESSED_WITHOUT_PERMISSION__LOCATION__PROVIDER_FRAMEWORK_PERMISSION; final int enumCheckUriPermission = GET_TYPE_ACCESSED_WITHOUT_PERMISSION__LOCATION__PROVIDER_CHECK_URI_PERMISSION; - final int enumError = GET_TYPE_ACCESSED_WITHOUT_PERMISSION__LOCATION__PROVIDER_ERROR; - - try { - final AttributionSource attributionSource = new AttributionSource.Builder( - callingUid).build(); + if (permissionCheckPassed) { + // Just for logging for mediaProvider cases + final ProviderInfo cpi = mContext.getPackageManager() + .resolveContentProvider(uri.getAuthority(), + PackageManager.ComponentInfoFlags.of(PackageManager.GET_META_DATA)); + final int callingUserId = UserHandle.getUserId(callingUid); + final Uri userUri = (mSingleUser + && !UserHandle.isSameUser(mMyUid, callingUid)) + ? maybeAddUserId(uri, callingUserId) : uri; try { - if (enforceReadPermission(attributionSource, uri) - != PermissionChecker.PERMISSION_GRANTED) { + if (cpi.forceUriPermissions + && mInterface.checkUriPermission(uri, + callingUid, Intent.FLAG_GRANT_READ_URI_PERMISSION) + != PermissionChecker.PERMISSION_GRANTED + && getContext().checkUriPermission(userUri, Binder.getCallingPid(), + callingUid, Intent.FLAG_GRANT_READ_URI_PERMISSION) + != PackageManager.PERMISSION_GRANTED) { FrameworkStatsLog.write(GET_TYPE_ACCESSED_WITHOUT_PERMISSION, - enumFrameworkPermission, + enumCheckUriPermission, callingUid, uri.getAuthority(), type); - } else { - final ProviderInfo cpi = mContext.getPackageManager() - .resolveContentProvider(uri.getAuthority(), - PackageManager.ComponentInfoFlags.of(PackageManager.GET_META_DATA)); - final int callingUserId = UserHandle.getUserId(callingUid); - final Uri userUri = (mSingleUser - && !UserHandle.isSameUser(mMyUid, callingUid)) - ? maybeAddUserId(uri, callingUserId) : uri; - if (cpi.forceUriPermissions - && mInterface.checkUriPermission(uri, - callingUid, Intent.FLAG_GRANT_READ_URI_PERMISSION) - != PermissionChecker.PERMISSION_GRANTED - && getContext().checkUriPermission(userUri, Binder.getCallingPid(), - callingUid, Intent.FLAG_GRANT_READ_URI_PERMISSION) - != PackageManager.PERMISSION_GRANTED) { - FrameworkStatsLog.write(GET_TYPE_ACCESSED_WITHOUT_PERMISSION, - enumCheckUriPermission, - callingUid, uri.getAuthority(), type); - } } - } catch (SecurityException e) { - FrameworkStatsLog.write(GET_TYPE_ACCESSED_WITHOUT_PERMISSION, - enumFrameworkPermission, - callingUid, uri.getAuthority(), type); + } catch (RemoteException e) { + //does nothing } - } catch (Exception e) { + } else { FrameworkStatsLog.write(GET_TYPE_ACCESSED_WITHOUT_PERMISSION, - enumError, + enumFrameworkPermission, callingUid, uri.getAuthority(), type); } } @Override - public void getTypeAsync(Uri uri, RemoteCallback callback) { + public void getTypeAsync(AttributionSource attributionSource, + Uri uri, RemoteCallback callback) { final Bundle result = new Bundle(); try { - result.putString(ContentResolver.REMOTE_CALLBACK_RESULT, getType(uri)); + result.putString(ContentResolver.REMOTE_CALLBACK_RESULT, + getType(attributionSource, uri)); + } catch (Exception e) { + result.putParcelable(ContentResolver.REMOTE_CALLBACK_ERROR, + new ParcelableException(e)); + } + callback.sendResult(result); + } + + @Override + public void getTypeAnonymousAsync(Uri uri, RemoteCallback callback) { + final Bundle result = new Bundle(); + try { + result.putString(ContentResolver.REMOTE_CALLBACK_RESULT, getTypeAnonymous(uri)); } catch (Exception e) { result.putParcelable(ContentResolver.REMOTE_CALLBACK_ERROR, new ParcelableException(e)); @@ -795,6 +814,23 @@ public abstract class ContentProvider implements ContentInterface, ComponentCall } return PermissionChecker.PERMISSION_GRANTED; } + + @PermissionCheckerManager.PermissionResult + private int checkGetTypePermission(@NonNull AttributionSource attributionSource, + Uri uri) { + final int callingUid = Binder.getCallingUid(); + if (UserHandle.getAppId(callingUid) == SYSTEM_UID + || checkPermission(Manifest.permission.GET_ANY_PROVIDER_TYPE, attributionSource) + == PermissionChecker.PERMISSION_GRANTED) { + // Allowing System Uid and apps with permission to get any type, to access all types + return PermissionChecker.PERMISSION_GRANTED; + } + try { + return enforceReadPermission(attributionSource, uri); + } catch (SecurityException e) { + return PermissionChecker.PERMISSION_HARD_DENIED; + } + } } boolean checkUser(int pid, int uid, Context context) { @@ -1625,11 +1661,15 @@ public abstract class ContentProvider implements ContentInterface, ComponentCall * <a href="{@docRoot}guide/topics/fundamentals/processes-and-threads.html#Threads">Processes * and Threads</a>. * - * <p>Note that there are no permissions needed for an application to + * <p>Note that by default there are no permissions needed for an application to * access this information; if your content provider requires read and/or * write permissions, or is not exported, all applications can still call - * this method regardless of their access permissions. This allows them - * to retrieve the MIME type for a URI when dispatching intents. + * this method regardless of their access permissions. </p> + * + * <p>If your mime type reveals details that should be protected, + * then you should protect this method by implementing {@link #getTypeAnonymous}. + * Implementing {@link #getTypeAnonymous} ensures your {@link #getType} can be + * only accessed by caller's having associated readPermission for the URI. </p> * * @param uri the URI to query. * @return a MIME type string, or {@code null} if there is no type. @@ -1638,6 +1678,24 @@ public abstract class ContentProvider implements ContentInterface, ComponentCall public abstract @Nullable String getType(@NonNull Uri uri); /** + * Implement this to handle requests for MIME type of URIs, that does not need to + * reveal any internal information which should be protected by any permission. + * + * <p>If your mime type reveals details that should be protected, then you should protect those + * by implementing those in {@link #getType}, and in this function, only return types of + * URIs which can be obtained by anyone without any access. + * + * Implementing ths function will make sure {@link #getType} is protected by readPermission. + * This function by default works as the {@link #getType}</p> + * + * @param uri the URI to query. + * @return a MIME type string, or {@code null} if type needs to be protected. + */ + public @Nullable String getTypeAnonymous(@NonNull Uri uri) { + return getType(uri); + } + + /** * Implement this to support canonicalization of URIs that refer to your * content provider. A canonical URI is one that can be transported across * devices, backup/restore, and other contexts, and still be able to refer diff --git a/core/java/android/content/ContentProviderNative.java b/core/java/android/content/ContentProviderNative.java index 47c966990861..4ba3ff4fe3d3 100644 --- a/core/java/android/content/ContentProviderNative.java +++ b/core/java/android/content/ContentProviderNative.java @@ -140,8 +140,10 @@ abstract public class ContentProviderNative extends Binder implements IContentPr case GET_TYPE_TRANSACTION: { data.enforceInterface(IContentProvider.descriptor); + AttributionSource attributionSource = AttributionSource.CREATOR + .createFromParcel(data); Uri url = Uri.CREATOR.createFromParcel(data); - String type = getType(url); + String type = getType(attributionSource, url); reply.writeNoException(); reply.writeString(type); @@ -150,9 +152,19 @@ abstract public class ContentProviderNative extends Binder implements IContentPr case GET_TYPE_ASYNC_TRANSACTION: { data.enforceInterface(IContentProvider.descriptor); + AttributionSource attributionSource = AttributionSource.CREATOR + .createFromParcel(data); Uri url = Uri.CREATOR.createFromParcel(data); RemoteCallback callback = RemoteCallback.CREATOR.createFromParcel(data); - getTypeAsync(url, callback); + getTypeAsync(attributionSource, url, callback); + return true; + } + + case GET_TYPE_ANONYMOUS_ASYNC_TRANSACTION: { + data.enforceInterface(IContentProvider.descriptor); + Uri url = Uri.CREATOR.createFromParcel(data); + RemoteCallback callback = RemoteCallback.CREATOR.createFromParcel(data); + getTypeAnonymousAsync(url, callback); return true; } @@ -502,13 +514,13 @@ final class ContentProviderProxy implements IContentProvider } @Override - public String getType(Uri url) throws RemoteException + public String getType(AttributionSource attributionSource, Uri url) throws RemoteException { Parcel data = Parcel.obtain(); Parcel reply = Parcel.obtain(); try { data.writeInterfaceToken(IContentProvider.descriptor); - + attributionSource.writeToParcel(data, 0); url.writeToParcel(data, 0); mRemote.transact(IContentProvider.GET_TYPE_TRANSACTION, data, reply, 0); @@ -523,11 +535,12 @@ final class ContentProviderProxy implements IContentProvider } @Override - /* oneway */ public void getTypeAsync(Uri uri, RemoteCallback callback) throws RemoteException { + /* oneway */ public void getTypeAsync(AttributionSource attributionSource, + Uri uri, RemoteCallback callback) throws RemoteException { Parcel data = Parcel.obtain(); try { data.writeInterfaceToken(IContentProvider.descriptor); - + attributionSource.writeToParcel(data, 0); uri.writeToParcel(data, 0); callback.writeToParcel(data, 0); @@ -539,6 +552,23 @@ final class ContentProviderProxy implements IContentProvider } @Override + /* oneway */ public void getTypeAnonymousAsync(Uri uri, RemoteCallback callback) + throws RemoteException { + Parcel data = Parcel.obtain(); + try { + data.writeInterfaceToken(IContentProvider.descriptor); + + uri.writeToParcel(data, 0); + callback.writeToParcel(data, 0); + + mRemote.transact(IContentProvider.GET_TYPE_ANONYMOUS_ASYNC_TRANSACTION, data, null, + IBinder.FLAG_ONEWAY); + } finally { + data.recycle(); + } + } + + @Override public Uri insert(@NonNull AttributionSource attributionSource, Uri url, ContentValues values, Bundle extras) throws RemoteException { diff --git a/core/java/android/content/ContentResolver.java b/core/java/android/content/ContentResolver.java index 37794531dfa3..b84eb118b8d4 100644 --- a/core/java/android/content/ContentResolver.java +++ b/core/java/android/content/ContentResolver.java @@ -920,8 +920,13 @@ public abstract class ContentResolver implements ContentInterface { return null; } - // XXX would like to have an acquireExistingUnstableProvider for this. - IContentProvider provider = acquireExistingProvider(url); + IContentProvider provider = null; + try { + provider = acquireProvider(url); + } catch (Exception e) { + // if unable to acquire the provider, then it should try to get the type + // using getTypeAnonymous via ActivityManagerService + } if (provider != null) { try { final StringResultListener resultListener = new StringResultListener(); @@ -949,7 +954,7 @@ public abstract class ContentResolver implements ContentInterface { try { final StringResultListener resultListener = new StringResultListener(); - ActivityManager.getService().getProviderMimeTypeAsync( + ActivityManager.getService().getMimeTypeFilterAsync( ContentProvider.getUriWithoutUserId(url), resolveUserId(url), new RemoteCallback(resultListener)); diff --git a/core/java/android/content/IContentProvider.java b/core/java/android/content/IContentProvider.java index e0315a3e171b..eb80148250b9 100644 --- a/core/java/android/content/IContentProvider.java +++ b/core/java/android/content/IContentProvider.java @@ -18,6 +18,7 @@ package android.content; import android.annotation.NonNull; import android.annotation.Nullable; +import android.app.AppGlobals; import android.compat.annotation.UnsupportedAppUsage; import android.content.res.AssetFileDescriptor; import android.database.Cursor; @@ -44,14 +45,42 @@ public interface IContentProvider extends IInterface { @Nullable String[] projection, @Nullable Bundle queryArgs, @Nullable ICancellationSignal cancellationSignal) throws RemoteException; - String getType(Uri url) throws RemoteException; + /** + * getType function with AttributionSource + */ + String getType(@NonNull AttributionSource attributionSource, + Uri url) throws RemoteException; + /** + * one way getType function with AttributionSource + */ + void getTypeAsync(@NonNull AttributionSource attributionSource, + Uri url, RemoteCallback callback) throws RemoteException; + /** + * @deprecated -- use getType with AttributionSource + */ + @Deprecated + default String getType(Uri url) throws RemoteException { + return getType(new AttributionSource(Binder.getCallingUid(), + AppGlobals.getPackageManager().getPackagesForUid(Binder.getCallingUid())[0], + null), url); + } /** * A oneway version of getType. The functionality is exactly the same, except that the * call returns immediately, and the resulting type is returned when available via * a binder callback. + * + * @deprecated -- use getTypeAsync with AttributionSource */ - void getTypeAsync(Uri uri, RemoteCallback callback) throws RemoteException; + @Deprecated + default void getTypeAsync(Uri uri, RemoteCallback callback) throws RemoteException { + getTypeAsync(new AttributionSource(Binder.getCallingUid(), + AppGlobals.getPackageManager().getPackagesForUid(Binder.getCallingUid())[0], + null), uri, callback); + } + + /** oneway version of getTypeAnonymous*/ + void getTypeAnonymousAsync(Uri uri, RemoteCallback callback) throws RemoteException; @Deprecated @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.Q, publicAlternatives = "Use {@link " @@ -185,4 +214,7 @@ public interface IContentProvider extends IInterface { int GET_TYPE_ASYNC_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION + 28; int CANONICALIZE_ASYNC_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION + 29; int UNCANONICALIZE_ASYNC_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION + 30; + int GET_TYPE_ANONYMOUS_ASYNC_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION + 31; + + } diff --git a/core/java/android/content/pm/PackageInstaller.java b/core/java/android/content/pm/PackageInstaller.java index 2b4ea70aabf4..7766896c7367 100644 --- a/core/java/android/content/pm/PackageInstaller.java +++ b/core/java/android/content/pm/PackageInstaller.java @@ -581,7 +581,7 @@ public class PackageInstaller { /** * Indicate the user intervention is required because the update ownership enforcement is - * enabled, and remind the update owner will retain. + * enabled, and remind the update owner is a different package. * * @see PackageInstaller.SessionParams#setRequestUpdateOwnership * @see InstallSourceInfo#getUpdateOwnerPackageName @@ -2978,8 +2978,7 @@ public class PackageInstaller { * permission. Default to {@code false}. * * The update ownership enforcement can only be enabled on initial installation. Set - * this to {@code true} on package update indicates the installer package wants to be - * the update owner if the update ownership enforcement has enabled. + * this to {@code true} on package update is a no-op. * * Note: To enable the update ownership enforcement, the installer must have the * {@link android.Manifest.permission#ENFORCE_UPDATE_OWNERSHIP ENFORCE_UPDATE_OWNERSHIP} diff --git a/core/java/android/content/pm/PackageManager.java b/core/java/android/content/pm/PackageManager.java index 23cce6a1c135..db05b959a7b1 100644 --- a/core/java/android/content/pm/PackageManager.java +++ b/core/java/android/content/pm/PackageManager.java @@ -1607,6 +1607,13 @@ public abstract class PackageManager { */ public static final int INSTALL_REQUEST_UPDATE_OWNERSHIP = 1 << 25; + /** + * Flag parameter for {@link PackageInstaller.SessionParams} to indicate that this + * session is from a managed user or profile. + * @hide + */ + public static final int INSTALL_FROM_MANAGED_USER_OR_PROFILE = 1 << 26; + /** @hide */ @IntDef(flag = true, value = { DONT_KILL_APP, diff --git a/core/java/android/content/pm/UserInfo.java b/core/java/android/content/pm/UserInfo.java index 6386f75ae2f3..81fc0293b685 100644 --- a/core/java/android/content/pm/UserInfo.java +++ b/core/java/android/content/pm/UserInfo.java @@ -60,10 +60,17 @@ public class UserInfo implements Parcelable { */ /** - * Primary user. Only one user can have this flag set. It identifies the first human user - * on a device. This flag is not supported in headless system user mode. + * Primary user. In practice, this is just synonymous with {@link #FLAG_SYSTEM}. + * + * <p>On many devices, this will also be the first human user. + * However, in {@link UserManager#isHeadlessSystemUserMode() headless system user mode}, this + * should be regarded as unsupported since the system user may not be a human. + * + * @deprecated For checking for user 0, use {@link #FLAG_SYSTEM}. + * For checking for the designated "main human user", use {@link #FLAG_MAIN}. */ @UnsupportedAppUsage + @Deprecated public static final int FLAG_PRIMARY = 0x00000001; /** @@ -335,7 +342,12 @@ public class UserInfo implements Parcelable { } } + /** + * @deprecated For checking for user 0, compare {@link #id} to {@link UserHandle#USER_SYSTEM}. + * For checking for the designated "main human user", use {@link #isMain()}. + */ @UnsupportedAppUsage + @Deprecated public boolean isPrimary() { return (flags & FLAG_PRIMARY) == FLAG_PRIMARY; } diff --git a/core/java/android/hardware/display/DisplayManager.java b/core/java/android/hardware/display/DisplayManager.java index f693a2f6d0cf..eeff6ccafd5d 100644 --- a/core/java/android/hardware/display/DisplayManager.java +++ b/core/java/android/hardware/display/DisplayManager.java @@ -66,7 +66,7 @@ import java.util.concurrent.Executor; public final class DisplayManager { private static final String TAG = "DisplayManager"; private static final boolean DEBUG = false; - private static final boolean ENABLE_VIRTUAL_DISPLAY_REFRESH_RATE = false; + private static final boolean ENABLE_VIRTUAL_DISPLAY_REFRESH_RATE = true; private final Context mContext; private final DisplayManagerGlobal mGlobal; diff --git a/core/java/android/hardware/input/InputManager.java b/core/java/android/hardware/input/InputManager.java index 2ea9ea06f720..a33cd9760091 100644 --- a/core/java/android/hardware/input/InputManager.java +++ b/core/java/android/hardware/input/InputManager.java @@ -74,6 +74,7 @@ import com.android.internal.os.SomeArgs; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; +import java.lang.ref.WeakReference; import java.util.ArrayList; import java.util.List; import java.util.Map; @@ -99,13 +100,12 @@ public final class InputManager { private final IInputManager mIm; /** - * InputManager has historically used its own static getter {@link #getInstance()} that doesn't - * provide a context. We provide a Context to the InputManager instance through the - * {@link android.app.SystemServiceRegistry}. Methods that need a Context must use - * {@link #getContext()} to obtain it. + * We hold a weak reference to the context to avoid leaking it indefinitely, + * since we currently store the input manager instance as a static variable that + * will outlive any context. */ @Nullable - private Context mLateInitContext; + private WeakReference<Context> mWeakContext; /** * Whether a PointerIcon is shown for stylus pointers. @@ -372,8 +372,8 @@ public final class InputManager { throw new IllegalStateException(e); } } - if (sInstance.mLateInitContext == null) { - sInstance.mLateInitContext = context; + if (sInstance.mWeakContext == null || sInstance.mWeakContext.get() == null) { + sInstance.mWeakContext = new WeakReference(context); } return sInstance; } @@ -381,9 +381,14 @@ public final class InputManager { @NonNull private Context getContext() { - return Objects.requireNonNull(mLateInitContext, + WeakReference<Context> weakContext = Objects.requireNonNull(mWeakContext, "A context is required for InputManager. Get the InputManager instance using " + "Context#getSystemService before calling this method."); + // If we get at this point, an app calling this function could potentially expect a + // Context that has disappeared due to garbage collection. Holding a weak reference + // is a temporary solution that should be resolved before the release of a + // production version. This is being tracked in b/267758905 + return Objects.requireNonNull(weakContext.get(), "missing Context"); } /** diff --git a/core/java/android/os/PowerManager.java b/core/java/android/os/PowerManager.java index 122494198b63..38e331c4ac0d 100644 --- a/core/java/android/os/PowerManager.java +++ b/core/java/android/os/PowerManager.java @@ -3049,7 +3049,7 @@ public final class PowerManager { * * @see #isAllowedInLowPowerStandby(String) */ - public static final String LOW_POWER_STANDBY_FEATURE_WAKE_ON_LAN = + public static final String FEATURE_WAKE_ON_LAN_IN_LOW_POWER_STANDBY = "com.android.lowpowerstandby.WAKE_ON_LAN"; /** @@ -3131,10 +3131,25 @@ public final class PowerManager { @LowPowerStandbyAllowedReason private final int mAllowedReasons; - /** Features that are allowed to be used in Low Power Standby. */ + /** + * Features that are allowed to be used in Low Power Standby. + * + * @see #FEATURE_WAKE_ON_LAN_IN_LOW_POWER_STANDBY + */ @NonNull private final Set<String> mAllowedFeatures; + /** + * Create a policy that defines the restrictions enforced by Low Power Standby. + * + * @param identifier Name of the policy, used for debugging & metrics. + * @param exemptPackages Packages that are exempt from Low Power Standby restrictions. + * @param allowedReasons Reasons that this policy allows apps to be automatically exempted + * from Low Power Standby restrictions for. + * @param allowedFeatures Features that are allowed to be used in Low Power Standby. + * Features are declared as strings, see + * {@link #FEATURE_WAKE_ON_LAN_IN_LOW_POWER_STANDBY} as an example. + */ public LowPowerStandbyPolicy(@NonNull String identifier, @NonNull Set<String> exemptPackages, @LowPowerStandbyAllowedReason int allowedReasons, diff --git a/core/java/android/os/UserManager.java b/core/java/android/os/UserManager.java index 9c55ad692f42..bbf7f810b3c0 100644 --- a/core/java/android/os/UserManager.java +++ b/core/java/android/os/UserManager.java @@ -4381,11 +4381,16 @@ public class UserManager { } /** - * Returns information for Primary user. + * Returns information for Primary user (which in practice is the same as the System user). * * @return the Primary user, null if not found. + * @deprecated For the system user, call {@link #getUserInfo} on {@link UserHandle#USER_SYSTEM}, + * or just use {@link UserHandle#SYSTEM} or {@link UserHandle#USER_SYSTEM}. + * For the designated MainUser, use {@link #getMainUser()}. + * * @hide */ + @Deprecated @RequiresPermission(android.Manifest.permission.MANAGE_USERS) public @Nullable UserInfo getPrimaryUser() { try { diff --git a/core/java/android/service/voice/AbstractDetector.java b/core/java/android/service/voice/AbstractDetector.java index 39c2b98fd9bc..466bc0520ee5 100644 --- a/core/java/android/service/voice/AbstractDetector.java +++ b/core/java/android/service/voice/AbstractDetector.java @@ -231,9 +231,12 @@ abstract class AbstractDetector implements HotwordDetector { /** Called when the detection fails due to an error. */ @Override - public void onError() { - Slog.v(TAG, "BinderCallback#onError"); - Binder.withCleanCallingIdentity(() -> mExecutor.execute(() -> mCallback.onError())); + public void onError(DetectorFailure detectorFailure) { + Slog.v(TAG, "BinderCallback#onError detectorFailure: " + detectorFailure); + Binder.withCleanCallingIdentity(() -> mExecutor.execute(() -> { + mCallback.onFailure(detectorFailure != null ? detectorFailure + : new UnknownFailure("Error data is null")); + })); } @Override diff --git a/core/java/android/service/voice/AlwaysOnHotwordDetector.java b/core/java/android/service/voice/AlwaysOnHotwordDetector.java index 48b7a5915658..bb3f03d70308 100644 --- a/core/java/android/service/voice/AlwaysOnHotwordDetector.java +++ b/core/java/android/service/voice/AlwaysOnHotwordDetector.java @@ -732,7 +732,13 @@ public class AlwaysOnHotwordDetector extends AbstractDetector { */ public abstract void onDetected(@NonNull EventPayload eventPayload); - /** {@inheritDoc} */ + /** + * {@inheritDoc} + * + * @deprecated Use {@link HotwordDetector.Callback#onError(DetectorFailure)} instead. + */ + @Deprecated + @Override public abstract void onError(); /** {@inheritDoc} */ @@ -1658,10 +1664,19 @@ public class AlwaysOnHotwordDetector extends AbstractDetector { @Override public void onError(int status) { Slog.i(TAG, "onError: " + status); - mHandler.sendEmptyMessage(MSG_DETECTION_ERROR); + // This is a workaround before the sound trigger uses the onDetectionFailure method. + Message.obtain(mHandler, MSG_DETECTION_ERROR, + new SoundTriggerFailure(status, "Sound trigger error")).sendToTarget(); } @Override + public void onDetectionFailure(DetectorFailure detectorFailure) { + Slog.v(TAG, "onDetectionFailure detectorFailure: " + detectorFailure); + Message.obtain(mHandler, MSG_DETECTION_ERROR, + detectorFailure != null ? detectorFailure + : new UnknownFailure("Error data is null")).sendToTarget(); + } + @Override public void onRecognitionPaused() { Slog.i(TAG, "onRecognitionPaused"); mHandler.sendEmptyMessage(MSG_DETECTION_PAUSE); @@ -1716,7 +1731,7 @@ public class AlwaysOnHotwordDetector extends AbstractDetector { mExternalCallback.onDetected((EventPayload) message.obj); break; case MSG_DETECTION_ERROR: - mExternalCallback.onError(); + mExternalCallback.onFailure((DetectorFailure) msg.obj); break; case MSG_DETECTION_PAUSE: mExternalCallback.onRecognitionPaused(); diff --git a/core/java/android/service/voice/DetectorFailure.aidl b/core/java/android/service/voice/DetectorFailure.aidl new file mode 100644 index 000000000000..3591329ac111 --- /dev/null +++ b/core/java/android/service/voice/DetectorFailure.aidl @@ -0,0 +1,19 @@ +/* + * 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.service.voice; + +parcelable DetectorFailure; diff --git a/core/java/android/service/voice/DetectorFailure.java b/core/java/android/service/voice/DetectorFailure.java new file mode 100644 index 000000000000..c6efdc3063e3 --- /dev/null +++ b/core/java/android/service/voice/DetectorFailure.java @@ -0,0 +1,218 @@ +/* + * 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.service.voice; + +import android.annotation.IntDef; +import android.annotation.NonNull; +import android.annotation.SuppressLint; +import android.annotation.SystemApi; +import android.os.Parcel; +import android.os.Parcelable; +import android.text.TextUtils; + +import com.android.internal.util.Preconditions; + +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; + +/** + * This is used by the assistant application to know what went wrong during using the detector + * and which action the application should take. The detector can be a HotwordDector or a visual + * query detector. + * + * <p>Any class that derives this class must only add an integer value of error source type, an + * integer value of error code and a string of error message passed into the constructor. Any other + * field will not be parceled through. If the derived class has custom parceling implementation, + * this class will not be able to unpack the parcel without having access to that implementation. + * + * @hide + */ +@SuppressLint("ParcelNotFinal") // Safe because the constructor is package-private +@SystemApi +public abstract class DetectorFailure implements Parcelable { + + /** + * A suggested action due to an unknown error occurs. + */ + public static final int SUGGESTED_ACTION_UNKNOWN = 0; + + /** + * Indicates that an error occurs, but no action is needed for the client. The error will be + * recovered from within the framework. + */ + public static final int SUGGESTED_ACTION_NONE = 1; + + /** + * Indicates that an error occurs, but no action is needed for the client due to the error can + * not be recovered. It means that the detection will not work even though the assistant + * application creates the detector again. + * + * Example: The detection service always crashes after assistant application creates the + * detector. The assistant application can stop re-creating the detector and show a suitable + * error dialog to notify the user. + */ + public static final int SUGGESTED_ACTION_DISABLE_DETECTION = 2; + + /** + * Indicates that the detection service is invalid, the client needs to destroy its detector + * first and recreate its detector later. + */ + public static final int SUGGESTED_ACTION_RECREATE_DETECTOR = 3; + + /** + * Indicates that the detection has stopped. The client needs to start recognition again. + * + * Example: The system server receives a Dsp trigger event. + */ + public static final int SUGGESTED_ACTION_RESTART_RECOGNITION = 4; + + /** + * @hide + */ + @IntDef(prefix = {"SUGGESTED_ACTION_"}, value = { + SUGGESTED_ACTION_UNKNOWN, + SUGGESTED_ACTION_NONE, + SUGGESTED_ACTION_DISABLE_DETECTION, + SUGGESTED_ACTION_RECREATE_DETECTOR, + SUGGESTED_ACTION_RESTART_RECOGNITION + }) + @Retention(RetentionPolicy.SOURCE) + public @interface SuggestedAction {} + + /** + * Indicates that an error occurs from the unknown error source. + * + * @hide + */ + public static final int ERROR_SOURCE_TYPE_UNKNOWN = -1; + + /** + * Indicates that an error occurs from the hotword detection. + * + * @see HotwordDetectionServiceFailure#ERROR_CODE_BIND_FAILURE + * @see HotwordDetectionServiceFailure#ERROR_CODE_BINDING_DIED + * @see HotwordDetectionServiceFailure#ERROR_CODE_COPY_AUDIO_DATA_FAILURE + * @see HotwordDetectionServiceFailure#ERROR_CODE_DETECT_TIMEOUT + * @see HotwordDetectionServiceFailure#ERROR_CODE_ON_DETECTED_SECURITY_EXCEPTION + * @see HotwordDetectionServiceFailure#ERROR_CODE_ON_DETECTED_STREAM_COPY_FAILURE + * @see HotwordDetectionServiceFailure#ERROR_CODE_REMOTE_EXCEPTION + * + * @hide + */ + public static final int ERROR_SOURCE_TYPE_HOTWORD_DETECTION = 0; + + /** + * Indicates that an error occurs from the sound trigger system service + * {@link com.android.server.soundtrigger.SoundTriggerService} and + * {@link com.android.server.soundtrigger_middleware.SoundTriggerMiddlewareService}. + * + * @see SoundTriggerFailure#ERROR_CODE_MODULE_DIED + * @see SoundTriggerFailure#ERROR_CODE_RECOGNITION_RESUME_FAILED + * @see SoundTriggerFailure#ERROR_CODE_UNEXPECTED_PREEMPTION + * + * @hide + */ + public static final int ERROR_SOURCE_TYPE_SOUND_TRIGGER = 1; + + /** + * Indicates that an error occurs from {@link VisualQueryDetectionService}. + * + * @see VisualQueryDetectionServiceFailure#ERROR_CODE_BIND_FAILURE + * @see VisualQueryDetectionServiceFailure#ERROR_CODE_BINDING_DIED + * @see VisualQueryDetectionServiceFailure#ERROR_CODE_ILLEGAL_ATTENTION_STATE + * @see VisualQueryDetectionServiceFailure#ERROR_CODE_ILLEGAL_STREAMING_STATE + * @see VisualQueryDetectionServiceFailure#ERROR_CODE_REMOTE_EXCEPTION + * + * @hide + */ + public static final int ERROR_SOURCE_TYPE_VISUAL_QUERY_DETECTION = 2; + + private int mErrorSourceType = ERROR_SOURCE_TYPE_UNKNOWN; + private int mErrorCode = UnknownFailure.ERROR_CODE_UNKNOWN; + private String mErrorMessage = "Unknown"; + + DetectorFailure(int errorSourceType, int errorCode, @NonNull String errorMessage) { + Preconditions.checkArgumentInRange(errorSourceType, ERROR_SOURCE_TYPE_UNKNOWN, + ERROR_SOURCE_TYPE_VISUAL_QUERY_DETECTION, "errorSourceType"); + if (TextUtils.isEmpty(errorMessage)) { + throw new IllegalArgumentException("errorMessage is empty or null."); + } + mErrorSourceType = errorSourceType; + mErrorCode = errorCode; + mErrorMessage = errorMessage; + } + + /** + * Returns the suggested action. + */ + @SuggestedAction + public abstract int getSuggestedAction(); + + /** + * Returns the error code. + * + * @hide + */ + public int getErrorCode() { + return mErrorCode; + } + + /** + * Returns the error message. + */ + @NonNull + public String getErrorMessage() { + return mErrorMessage; + } + + @Override + public int describeContents() { + return 0; + } + + @Override + public void writeToParcel(@NonNull Parcel dest, int flags) { + dest.writeInt(mErrorSourceType); + dest.writeInt(mErrorCode); + dest.writeString8(mErrorMessage); + } + + public static final @NonNull Parcelable.Creator<DetectorFailure> CREATOR = + new Parcelable.Creator<DetectorFailure>() { + @Override + public DetectorFailure[] newArray(int size) { + return new DetectorFailure[size]; + } + + @Override + public DetectorFailure createFromParcel(@NonNull Parcel in) { + final int errorSourceType = in.readInt(); + final int errorCode = in.readInt(); + final String errorMessage = in.readString8(); + switch (errorSourceType) { + case ERROR_SOURCE_TYPE_HOTWORD_DETECTION: + return new HotwordDetectionServiceFailure(errorCode, errorMessage); + case ERROR_SOURCE_TYPE_SOUND_TRIGGER: + return new SoundTriggerFailure(errorCode, errorMessage); + case ERROR_SOURCE_TYPE_VISUAL_QUERY_DETECTION: + return new VisualQueryDetectionServiceFailure(errorCode, errorMessage); + default: + return new UnknownFailure(errorMessage); + } + } + }; +} diff --git a/core/java/android/service/voice/HotwordDetectionServiceFailure.aidl b/core/java/android/service/voice/HotwordDetectionServiceFailure.aidl new file mode 100644 index 000000000000..8d3cfc2de850 --- /dev/null +++ b/core/java/android/service/voice/HotwordDetectionServiceFailure.aidl @@ -0,0 +1,19 @@ +/* + * 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.service.voice; + +parcelable HotwordDetectionServiceFailure; diff --git a/core/java/android/service/voice/HotwordDetectionServiceFailure.java b/core/java/android/service/voice/HotwordDetectionServiceFailure.java new file mode 100644 index 000000000000..3d9f66b173d4 --- /dev/null +++ b/core/java/android/service/voice/HotwordDetectionServiceFailure.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.service.voice; + +import android.annotation.IntDef; +import android.annotation.NonNull; +import android.annotation.SystemApi; +import android.annotation.TestApi; +import android.os.Parcel; +import android.os.Parcelable; + +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; + +/** + * This class is used by the assistant application to know what went wrong during using the + * {@link HotwordDetector} and which action that the application should take. When an error occurs + * from Dsp hotword detection, software hotword detection and {@link HotwordDetectionService}, the + * system will send {@link HotwordDetectionServiceFailure} which contains the error code, error + * message and the suggested action to help the assistant application to take the next action. + * + * @hide + */ +@SystemApi +public final class HotwordDetectionServiceFailure extends DetectorFailure { + + /** + * An error code which means an unknown error occurs. + */ + public static final int ERROR_CODE_UNKNOWN = 0; + + /** + * Indicates that the system server binds hotword detection service failure. + */ + public static final int ERROR_CODE_BIND_FAILURE = 1; + + /** + * Indicates that the hotword detection service is dead. + */ + public static final int ERROR_CODE_BINDING_DIED = 2; + + /** + * Indicates to copy audio data failure for external source detection. + */ + public static final int ERROR_CODE_COPY_AUDIO_DATA_FAILURE = 3; + + /** + * Indicates that the detection service doesn’t respond to the detection result before timeout. + */ + public static final int ERROR_CODE_DETECT_TIMEOUT = 4; + + /** + * Indicates that the security exception occurs in #onDetected method. + */ + public static final int ERROR_CODE_ON_DETECTED_SECURITY_EXCEPTION = 5; + + /** + * Indicates to copy the audio stream failure in #onDetected method. + */ + public static final int ERROR_CODE_ON_DETECTED_STREAM_COPY_FAILURE = 6; + + /** + * Indicates that the remote exception occurs when calling callback method. + */ + public static final int ERROR_CODE_REMOTE_EXCEPTION = 7; + + /** + * @hide + */ + @IntDef(prefix = {"ERROR_CODE_"}, value = { + ERROR_CODE_UNKNOWN, + ERROR_CODE_BIND_FAILURE, + ERROR_CODE_BINDING_DIED, + ERROR_CODE_COPY_AUDIO_DATA_FAILURE, + ERROR_CODE_DETECT_TIMEOUT, + ERROR_CODE_ON_DETECTED_SECURITY_EXCEPTION, + ERROR_CODE_ON_DETECTED_STREAM_COPY_FAILURE, + ERROR_CODE_REMOTE_EXCEPTION + }) + @Retention(RetentionPolicy.SOURCE) + public @interface HotwordDetectionServiceErrorCode {} + + /** + * @hide + */ + @TestApi + public HotwordDetectionServiceFailure(int errorCode, @NonNull String errorMessage) { + super(ERROR_SOURCE_TYPE_HOTWORD_DETECTION, errorCode, errorMessage); + } + + /** + * Returns the error code. + */ + @HotwordDetectionServiceErrorCode + public int getErrorCode() { + return super.getErrorCode(); + } + + @Override + public int getSuggestedAction() { + switch (getErrorCode()) { + case ERROR_CODE_BIND_FAILURE: + case ERROR_CODE_BINDING_DIED: + case ERROR_CODE_REMOTE_EXCEPTION: + return SUGGESTED_ACTION_RECREATE_DETECTOR; + case ERROR_CODE_DETECT_TIMEOUT: + case ERROR_CODE_ON_DETECTED_SECURITY_EXCEPTION: + case ERROR_CODE_ON_DETECTED_STREAM_COPY_FAILURE: + return SUGGESTED_ACTION_RESTART_RECOGNITION; + default: + return SUGGESTED_ACTION_NONE; + } + } + + @Override + public int describeContents() { + return 0; + } + + @Override + public void writeToParcel(@NonNull Parcel dest, int flags) { + super.writeToParcel(dest, flags); + } + + public static final @NonNull Parcelable.Creator<HotwordDetectionServiceFailure> CREATOR = + new Parcelable.Creator<HotwordDetectionServiceFailure>() { + @Override + public HotwordDetectionServiceFailure[] newArray(int size) { + return new HotwordDetectionServiceFailure[size]; + } + + @Override + public HotwordDetectionServiceFailure createFromParcel(@NonNull Parcel in) { + DetectorFailure detectorFailure = DetectorFailure.CREATOR.createFromParcel(in); + return (HotwordDetectionServiceFailure) detectorFailure; + } + }; +} diff --git a/core/java/android/service/voice/HotwordDetector.java b/core/java/android/service/voice/HotwordDetector.java index 562277e9d097..22d97b7bbcaa 100644 --- a/core/java/android/service/voice/HotwordDetector.java +++ b/core/java/android/service/voice/HotwordDetector.java @@ -231,10 +231,29 @@ public interface HotwordDetector { /** * Called when the detection fails due to an error. + * + * @deprecated On Android 14 and above, implement {@link #onFailure(DetectorFailure)} + * instead. */ + @Deprecated void onError(); /** + * Called when the detection fails due to an error, the subclasses of + * {@link DetectorFailure} will be reported to the detector. + * + * @see android.service.voice.HotwordDetectionServiceFailure + * @see android.service.voice.SoundTriggerFailure + * @see android.service.voice.UnknownFailure + * @see android.service.voice.VisualQueryDetectionServiceFailure + * + * @param detectorFailure It provides the error code, error message and suggested action. + */ + default void onFailure(@NonNull DetectorFailure detectorFailure) { + onError(); + } + + /** * Called when the recognition is paused temporarily for some reason. * This is an informational callback, and the clients shouldn't be doing anything here * except showing an indication on their UI if they have to. diff --git a/core/java/android/service/voice/IMicrophoneHotwordDetectionVoiceInteractionCallback.aidl b/core/java/android/service/voice/IMicrophoneHotwordDetectionVoiceInteractionCallback.aidl index 61ac68be9775..f800c1ee22d6 100644 --- a/core/java/android/service/voice/IMicrophoneHotwordDetectionVoiceInteractionCallback.aidl +++ b/core/java/android/service/voice/IMicrophoneHotwordDetectionVoiceInteractionCallback.aidl @@ -17,6 +17,7 @@ package android.service.voice; import android.media.AudioFormat; +import android.service.voice.DetectorFailure; import android.service.voice.HotwordDetectedResult; import android.service.voice.HotwordRejectedResult; @@ -38,7 +39,7 @@ oneway interface IMicrophoneHotwordDetectionVoiceInteractionCallback { /** * Called when the detection fails due to an error. */ - void onError(); + void onError(in DetectorFailure detectorFailure); /** * Called when the detected result was not detected. diff --git a/core/java/android/service/voice/IVisualQueryDetectionVoiceInteractionCallback.aidl b/core/java/android/service/voice/IVisualQueryDetectionVoiceInteractionCallback.aidl index 2eb24706da30..1a935c0acbf6 100644 --- a/core/java/android/service/voice/IVisualQueryDetectionVoiceInteractionCallback.aidl +++ b/core/java/android/service/voice/IVisualQueryDetectionVoiceInteractionCallback.aidl @@ -16,7 +16,7 @@ package android.service.voice; -import android.media.AudioFormat; +import android.service.voice.DetectorFailure; /** * Callback for returning the detected result from the VisualQueryDetectionService. @@ -43,6 +43,5 @@ oneway interface IVisualQueryDetectionVoiceInteractionCallback { /** * Called when the detection fails due to an error. */ - void onError(); - + void onDetectionFailure(in DetectorFailure detectorFailure); } diff --git a/core/java/android/service/voice/SoftwareHotwordDetector.java b/core/java/android/service/voice/SoftwareHotwordDetector.java index 6e17bd0e656d..d4b6f3bf5c4c 100644 --- a/core/java/android/service/voice/SoftwareHotwordDetector.java +++ b/core/java/android/service/voice/SoftwareHotwordDetector.java @@ -169,9 +169,12 @@ class SoftwareHotwordDetector extends AbstractDetector { /** Called when the detection fails due to an error. */ @Override - public void onError() { - Slog.v(TAG, "BinderCallback#onError"); - Binder.withCleanCallingIdentity(() -> mExecutor.execute(() -> mCallback.onError())); + public void onError(DetectorFailure detectorFailure) { + Slog.v(TAG, "BinderCallback#onError detectorFailure: " + detectorFailure); + Binder.withCleanCallingIdentity(() -> mExecutor.execute(() -> { + mCallback.onFailure(detectorFailure != null ? detectorFailure + : new UnknownFailure("Error data is null")); + })); } @Override @@ -222,6 +225,16 @@ class SoftwareHotwordDetector extends AbstractDetector { if (DEBUG) { Slog.i(TAG, "Ignored #onError (" + status + ") event"); } + // TODO: Check if we still need to implement this method with DetectorFailure mechanism. + } + + @Override + public void onDetectionFailure(DetectorFailure detectorFailure) throws RemoteException { + Slog.v(TAG, "onDetectionFailure detectorFailure: " + detectorFailure); + Binder.withCleanCallingIdentity(() -> mExecutor.execute(() -> { + mCallback.onFailure(detectorFailure != null ? detectorFailure + : new UnknownFailure("Error data is null")); + })); } @Override diff --git a/core/java/android/service/voice/SoundTriggerFailure.aidl b/core/java/android/service/voice/SoundTriggerFailure.aidl new file mode 100644 index 000000000000..7ba1c7bf338e --- /dev/null +++ b/core/java/android/service/voice/SoundTriggerFailure.aidl @@ -0,0 +1,19 @@ +/* + * 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.service.voice; + +parcelable SoundTriggerFailure; diff --git a/core/java/android/service/voice/SoundTriggerFailure.java b/core/java/android/service/voice/SoundTriggerFailure.java new file mode 100644 index 000000000000..a431fbc0fe1d --- /dev/null +++ b/core/java/android/service/voice/SoundTriggerFailure.java @@ -0,0 +1,126 @@ +/* + * 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.service.voice; + +import android.annotation.IntDef; +import android.annotation.NonNull; +import android.annotation.SystemApi; +import android.annotation.TestApi; +import android.os.Parcel; +import android.os.Parcelable; + +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; + +/** + * This class is used by the assistant application to know what went wrong during using the + * sound trigger system service {@link com.android.server.soundtrigger.SoundTriggerService} and + * {@link com.android.server.soundtrigger_middleware.SoundTriggerMiddlewareService}, and which + * action that the application should take. + * + * @hide + */ +@SystemApi +public final class SoundTriggerFailure extends DetectorFailure { + + /** + * An error code which means an unknown error occurs. + */ + public static final int ERROR_CODE_UNKNOWN = 0; + + /** + * Indicates that the underlying sound trigger module has died and will be restarted. All + * session state has been invalidated. + */ + public static final int ERROR_CODE_MODULE_DIED = 1; + + /** + * Indicates that sound trigger service recognition resume has failed. The model is in the + * stopped state and will not be restarted by the framework. + */ + public static final int ERROR_CODE_RECOGNITION_RESUME_FAILED = 2; + + /** + * Indicates that the sound trigger service has been unexpectedly preempted by another user. + * The model is in the stopped state and will not be restarted by the framework. + */ + public static final int ERROR_CODE_UNEXPECTED_PREEMPTION = 3; + + /** + * @hide + */ + @IntDef(prefix = {"ERROR_CODE_"}, value = { + ERROR_CODE_UNKNOWN, + ERROR_CODE_MODULE_DIED, + ERROR_CODE_RECOGNITION_RESUME_FAILED, + ERROR_CODE_UNEXPECTED_PREEMPTION + }) + @Retention(RetentionPolicy.SOURCE) + public @interface SoundTriggerErrorCode {} + + /** + * @hide + */ + @TestApi + public SoundTriggerFailure(int errorCode, @NonNull String errorMessage) { + super(ERROR_SOURCE_TYPE_SOUND_TRIGGER, errorCode, errorMessage); + } + + /** + * Returns the error code. + */ + @SoundTriggerErrorCode + public int getErrorCode() { + return super.getErrorCode(); + } + + @Override + public int getSuggestedAction() { + switch (getErrorCode()) { + case ERROR_CODE_MODULE_DIED: + case ERROR_CODE_UNEXPECTED_PREEMPTION: + return SUGGESTED_ACTION_RECREATE_DETECTOR; + case ERROR_CODE_RECOGNITION_RESUME_FAILED: + return SUGGESTED_ACTION_RESTART_RECOGNITION; + default: + return SUGGESTED_ACTION_NONE; + } + } + + @Override + public int describeContents() { + return 0; + } + + @Override + public void writeToParcel(@NonNull Parcel dest, int flags) { + super.writeToParcel(dest, flags); + } + + public static final @NonNull Parcelable.Creator<SoundTriggerFailure> CREATOR = + new Parcelable.Creator<SoundTriggerFailure>() { + @Override + public SoundTriggerFailure[] newArray(int size) { + return new SoundTriggerFailure[size]; + } + + @Override + public SoundTriggerFailure createFromParcel(@NonNull Parcel in) { + return (SoundTriggerFailure) DetectorFailure.CREATOR.createFromParcel(in); + } + }; +} diff --git a/core/java/android/service/voice/UnknownFailure.aidl b/core/java/android/service/voice/UnknownFailure.aidl new file mode 100644 index 000000000000..cf43cc2fad46 --- /dev/null +++ b/core/java/android/service/voice/UnknownFailure.aidl @@ -0,0 +1,19 @@ +/* + * 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.service.voice; + +parcelable UnknownFailure; diff --git a/core/java/android/service/voice/UnknownFailure.java b/core/java/android/service/voice/UnknownFailure.java new file mode 100644 index 000000000000..2ef2d5f880fd --- /dev/null +++ b/core/java/android/service/voice/UnknownFailure.java @@ -0,0 +1,77 @@ +/* + * 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.service.voice; + +import android.annotation.NonNull; +import android.annotation.SystemApi; +import android.annotation.TestApi; +import android.os.Parcel; +import android.os.Parcelable; + +/** + * A class which indicates an unknown error occurs during the detector doing detection. The class + * is mainly used by the assistant application, the application still can get the suggested action + * for the unknown error. + * + * @hide + */ +@SystemApi +public final class UnknownFailure extends DetectorFailure { + + /** + * An error code which means an unknown error occurs. + * + * @hide + */ + public static final int ERROR_CODE_UNKNOWN = 0; + + /** + * @hide + */ + @TestApi + public UnknownFailure(@NonNull String errorMessage) { + super(ERROR_SOURCE_TYPE_UNKNOWN, ERROR_CODE_UNKNOWN, errorMessage); + } + + @Override + public int getSuggestedAction() { + return SUGGESTED_ACTION_UNKNOWN; + } + + @Override + public int describeContents() { + return 0; + } + + @Override + public void writeToParcel(@NonNull Parcel dest, int flags) { + super.writeToParcel(dest, flags); + } + + public static final @NonNull Parcelable.Creator<UnknownFailure> CREATOR = + new Parcelable.Creator<UnknownFailure>() { + @Override + public UnknownFailure[] newArray(int size) { + return new UnknownFailure[size]; + } + + @Override + public UnknownFailure createFromParcel(@NonNull Parcel in) { + return (UnknownFailure) DetectorFailure.CREATOR.createFromParcel(in); + } + }; +} diff --git a/core/java/android/service/voice/VisualQueryDetectionServiceFailure.aidl b/core/java/android/service/voice/VisualQueryDetectionServiceFailure.aidl new file mode 100644 index 000000000000..877df2895357 --- /dev/null +++ b/core/java/android/service/voice/VisualQueryDetectionServiceFailure.aidl @@ -0,0 +1,19 @@ +/* + * 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.service.voice; + +parcelable VisualQueryDetectionServiceFailure; diff --git a/core/java/android/service/voice/VisualQueryDetectionServiceFailure.java b/core/java/android/service/voice/VisualQueryDetectionServiceFailure.java new file mode 100644 index 000000000000..aa02299b2b28 --- /dev/null +++ b/core/java/android/service/voice/VisualQueryDetectionServiceFailure.java @@ -0,0 +1,136 @@ +/* + * 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.service.voice; + +import android.annotation.IntDef; +import android.annotation.NonNull; +import android.annotation.SystemApi; +import android.annotation.TestApi; +import android.os.Parcel; +import android.os.Parcelable; + +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; + +/** + * This class is used by the assistant application to know what went wrong during using + * {@link VisualQueryDetectionService} and which action that the application should take. + * + * @hide + */ +@SystemApi +public final class VisualQueryDetectionServiceFailure extends DetectorFailure { + + /** + * An error code which means an unknown error occurs. + */ + public static final int ERROR_CODE_UNKNOWN = 0; + + /** + * Indicates that the system server binds visual query detection service failure. + */ + public static final int ERROR_CODE_BIND_FAILURE = 1; + + /** + * Indicates that the visual query detection service is dead. + */ + public static final int ERROR_CODE_BINDING_DIED = 2; + + /** + * Indicates that the detection service has no attention listener registered. + */ + public static final int ERROR_CODE_ILLEGAL_ATTENTION_STATE = 3; + + /** + * Indicates that the detection service is not egressing and should not be streaming queries. + */ + public static final int ERROR_CODE_ILLEGAL_STREAMING_STATE = 4; + + /** + * Indicates that the remote exception occurs when calling callback method. + */ + public static final int ERROR_CODE_REMOTE_EXCEPTION = 5; + + /** + * @hide + */ + @IntDef(prefix = {"ERROR_CODE_"}, value = { + ERROR_CODE_UNKNOWN, + ERROR_CODE_BIND_FAILURE, + ERROR_CODE_BINDING_DIED, + ERROR_CODE_ILLEGAL_ATTENTION_STATE, + ERROR_CODE_ILLEGAL_STREAMING_STATE, + ERROR_CODE_REMOTE_EXCEPTION + }) + @Retention(RetentionPolicy.SOURCE) + public @interface VisualQueryDetectionServiceErrorCode {} + + /** + * @hide + */ + @TestApi + public VisualQueryDetectionServiceFailure(int errorCode, @NonNull String errorMessage) { + super(ERROR_SOURCE_TYPE_VISUAL_QUERY_DETECTION, errorCode, errorMessage); + } + + /** + * Returns the error code. + */ + @VisualQueryDetectionServiceErrorCode + public int getErrorCode() { + return super.getErrorCode(); + } + + @Override + public int getSuggestedAction() { + switch (getErrorCode()) { + case ERROR_CODE_BIND_FAILURE: + case ERROR_CODE_BINDING_DIED: + case ERROR_CODE_ILLEGAL_ATTENTION_STATE: + case ERROR_CODE_REMOTE_EXCEPTION: + return SUGGESTED_ACTION_RECREATE_DETECTOR; + case ERROR_CODE_ILLEGAL_STREAMING_STATE: + return SUGGESTED_ACTION_RESTART_RECOGNITION; + default: + return SUGGESTED_ACTION_NONE; + } + } + + @Override + public int describeContents() { + return 0; + } + + @Override + public void writeToParcel(@NonNull Parcel dest, int flags) { + super.writeToParcel(dest, flags); + } + + public static final @NonNull Parcelable.Creator<VisualQueryDetectionServiceFailure> CREATOR = + new Parcelable.Creator<VisualQueryDetectionServiceFailure>() { + @Override + public VisualQueryDetectionServiceFailure[] newArray(int size) { + return new VisualQueryDetectionServiceFailure[size]; + } + + @Override + public VisualQueryDetectionServiceFailure createFromParcel(@NonNull Parcel in) { + DetectorFailure detectorFailure = DetectorFailure.CREATOR.createFromParcel(in); + return (VisualQueryDetectionServiceFailure) detectorFailure; + } + }; +} diff --git a/core/java/android/service/voice/VisualQueryDetector.java b/core/java/android/service/voice/VisualQueryDetector.java index e4c47ef7cee3..0be3253fc570 100644 --- a/core/java/android/service/voice/VisualQueryDetector.java +++ b/core/java/android/service/voice/VisualQueryDetector.java @@ -216,8 +216,7 @@ public class VisualQueryDetector { /** * Called when the detection fails due to an error. */ - //TODO(b/265390855): Replace this callback with the new onError(DetectorError) design. - void onError(); + void onFailure(@NonNull DetectorFailure detectorFailure); } private class VisualQueryDetectorInitializationDelegate extends AbstractDetector { @@ -294,12 +293,11 @@ public class VisualQueryDetector { /** Called when the detection fails due to an error. */ @Override - public void onError() { - Slog.v(TAG, "BinderCallback#onError"); + public void onDetectionFailure(DetectorFailure detectorFailure) { + Slog.v(TAG, "BinderCallback#onDetectionFailure"); Binder.withCleanCallingIdentity(() -> mExecutor.execute( - () -> mCallback.onError())); + () -> mCallback.onFailure(detectorFailure))); } - } @@ -373,5 +371,9 @@ public class VisualQueryDetector { Slog.v(TAG, "Initialization Error: (" + status + ")"); // Do nothing } + + @Override + public void onDetectionFailure(DetectorFailure detectorFailure) throws RemoteException { + } } } diff --git a/core/java/android/service/voice/VoiceInteractionSession.java b/core/java/android/service/voice/VoiceInteractionSession.java index 5778518921ca..cabcae30851f 100644 --- a/core/java/android/service/voice/VoiceInteractionSession.java +++ b/core/java/android/service/voice/VoiceInteractionSession.java @@ -26,6 +26,7 @@ import android.annotation.NonNull; import android.annotation.Nullable; import android.annotation.TestApi; import android.app.Activity; +import android.app.ActivityOptions; import android.app.Dialog; import android.app.DirectAction; import android.app.Instrumentation; @@ -1527,8 +1528,34 @@ public class VoiceInteractionSession implements KeyEvent.Callback, ComponentCall * <p>By default, the system will create a window for the UI for this session. If you are using * an assistant activity instead, then you can disable the window creation by calling * {@link #setUiEnabled} in {@link #onPrepareShow(Bundle, int)}.</p> + * + * NOTE: if the app would like to override some options to start the Activity, + * use {@link #startAssistantActivity(Intent, Bundle)} instead. */ public void startAssistantActivity(Intent intent) { + startAssistantActivity(intent, ActivityOptions.makeBasic().toBundle()); + } + + /** + * <p>Ask that a new assistant activity be started. This will create a new task in the + * in activity manager: this means that + * {@link Intent#FLAG_ACTIVITY_NEW_TASK Intent.FLAG_ACTIVITY_NEW_TASK} + * will be set for you to make it a new task.</p> + * + * <p>The newly started activity will be displayed on top of other activities in the system + * in a new layer that is not affected by multi-window mode. Tasks started from this activity + * will go into the normal activity layer and not this new layer.</p> + * + * <p>By default, the system will create a window for the UI for this session. If you are using + * an assistant activity instead, then you can disable the window creation by calling + * {@link #setUiEnabled} in {@link #onPrepareShow(Bundle, int)}.</p> + * + * @param intent the intent used to start an assistant activity + * @param bundle Additional options for how the Activity should be started. See + * {@link ActivityOptions} for how to build the Bundle supplied here. + */ + public void startAssistantActivity(@NonNull Intent intent, @NonNull Bundle bundle) { + Objects.requireNonNull(bundle); if (mToken == null) { throw new IllegalStateException("Can't call before onCreate()"); } @@ -1537,7 +1564,7 @@ public class VoiceInteractionSession implements KeyEvent.Callback, ComponentCall intent.prepareToLeaveProcess(mContext); int res = mSystemService.startAssistantActivity(mToken, intent, intent.resolveType(mContext.getContentResolver()), - mContext.getAttributionTag()); + mContext.getAttributionTag(), bundle); Instrumentation.checkStartActivityResult(res, intent); } catch (RemoteException e) { } diff --git a/core/java/android/view/SurfaceControl.java b/core/java/android/view/SurfaceControl.java index a99766f36ee4..4895aed60a3a 100644 --- a/core/java/android/view/SurfaceControl.java +++ b/core/java/android/view/SurfaceControl.java @@ -226,6 +226,9 @@ public final class SurfaceControl implements Parcelable { @DataSpace.NamedDataSpace int dataSpace); private static native void nativeSetExtendedRangeBrightness(long transactionObj, long nativeObject, float currentBufferRatio, float desiredRatio); + + private static native void nativeSetCachingHint(long transactionObj, + long nativeObject, int cachingHint); private static native void nativeSetDamageRegion(long transactionObj, long nativeObject, Region region); private static native void nativeSetDimmingEnabled(long transactionObj, long nativeObject, @@ -742,6 +745,29 @@ public final class SurfaceControl implements Parcelable { */ public static final int POWER_MODE_ON_SUSPEND = 4; + /** + * Hint that this SurfaceControl should not participate in layer caching within SurfaceFlinger. + * + * A system layer may request that a layer does not participate in caching when there are known + * quality limitations when caching via the compositor's GPU path. + * Use only with {@link SurfaceControl.Transaction#setCachingHint}. + * @hide + */ + public static final int CACHING_DISABLED = 0; + + /** + * Hint that this SurfaceControl should participate in layer caching within SurfaceFlinger. + * + * Use only with {@link SurfaceControl.Transaction#setCachingHint}. + * @hide + */ + public static final int CACHING_ENABLED = 1; + + /** @hide */ + @IntDef(flag = true, value = {CACHING_DISABLED, CACHING_ENABLED}) + @Retention(RetentionPolicy.SOURCE) + public @interface CachingHint {} + private void assignNativeObject(long nativeObject, String callsite) { if (mNativeObject != 0) { release(); @@ -3881,6 +3907,23 @@ public final class SurfaceControl implements Parcelable { } /** + * Sets the caching hint for the layer. By default, the caching hint is + * {@link CACHING_ENABLED}. + * + * @param sc The SurfaceControl to update + * @param cachingHint The caching hint to apply to the SurfaceControl. The CachingHint is + * not applied to any children of this SurfaceControl. + * @return this + * @hide + */ + public @NonNull Transaction setCachingHint( + @NonNull SurfaceControl sc, @CachingHint int cachingHint) { + checkPreconditions(sc); + nativeSetCachingHint(mNativeObject, sc.mNativeObject, cachingHint); + return this; + } + + /** * Sets the trusted overlay state on this SurfaceControl and it is inherited to all the * children. The caller must hold the ACCESS_SURFACE_FLINGER permission. * @hide diff --git a/core/java/android/view/ViewRootImpl.java b/core/java/android/view/ViewRootImpl.java index 472daf988924..e9b3e2808a6d 100644 --- a/core/java/android/view/ViewRootImpl.java +++ b/core/java/android/view/ViewRootImpl.java @@ -1135,6 +1135,10 @@ public final class ViewRootImpl implements ViewParent, updateLastConfigurationFromResources(getConfiguration()); // Make sure to report the completion of draw for relaunch with preserved window. reportNextDraw("rebuilt"); + // Make sure to resume this root view when relaunching its host activity which was stopped. + if (mStopped && getHostVisibility() != View.GONE) { + setWindowStopped(false); + } } private Configuration getConfiguration() { diff --git a/core/java/android/view/contentcapture/ContentCaptureSession.java b/core/java/android/view/contentcapture/ContentCaptureSession.java index ee86fc141490..0da7e3b95863 100644 --- a/core/java/android/view/contentcapture/ContentCaptureSession.java +++ b/core/java/android/view/contentcapture/ContentCaptureSession.java @@ -175,6 +175,8 @@ public abstract class ContentCaptureSession implements AutoCloseable { public static final int FLUSH_REASON_TEXT_CHANGE_TIMEOUT = 6; /** @hide */ public static final int FLUSH_REASON_SESSION_CONNECTED = 7; + /** @hide */ + public static final int FLUSH_REASON_FORCE_FLUSH = 8; @ChangeId @EnabledSince(targetSdkVersion = UPSIDE_DOWN_CAKE) @@ -188,7 +190,8 @@ public abstract class ContentCaptureSession implements AutoCloseable { FLUSH_REASON_SESSION_FINISHED, FLUSH_REASON_IDLE_TIMEOUT, FLUSH_REASON_TEXT_CHANGE_TIMEOUT, - FLUSH_REASON_SESSION_CONNECTED + FLUSH_REASON_SESSION_CONNECTED, + FLUSH_REASON_FORCE_FLUSH }) @Retention(RetentionPolicy.SOURCE) public @interface FlushReason{} @@ -666,6 +669,8 @@ public abstract class ContentCaptureSession implements AutoCloseable { return "TEXT_CHANGE"; case FLUSH_REASON_SESSION_CONNECTED: return "CONNECTED"; + case FLUSH_REASON_FORCE_FLUSH: + return "FORCE_FLUSH"; default: return "UNKOWN-" + reason; } diff --git a/core/java/android/view/contentcapture/MainContentCaptureSession.java b/core/java/android/view/contentcapture/MainContentCaptureSession.java index a98955862d7b..8c040e482cdf 100644 --- a/core/java/android/view/contentcapture/MainContentCaptureSession.java +++ b/core/java/android/view/contentcapture/MainContentCaptureSession.java @@ -459,7 +459,7 @@ public final class MainContentCaptureSession extends ContentCaptureSession { flushReason = FLUSH_REASON_SESSION_FINISHED; break; default: - flushReason = FLUSH_REASON_FULL; + flushReason = forceFlush ? FLUSH_REASON_FORCE_FLUSH : FLUSH_REASON_FULL; } flush(flushReason); @@ -555,8 +555,13 @@ public final class MainContentCaptureSession extends ContentCaptureSession { final int numberEvents = mEvents.size(); final String reasonString = getFlushReasonAsString(reason); + if (sDebug) { - Log.d(TAG, "Flushing " + numberEvents + " event(s) for " + getDebugState(reason)); + ContentCaptureEvent event = mEvents.get(numberEvents - 1); + String forceString = (reason == FLUSH_REASON_FORCE_FLUSH) ? ". The force flush event " + + ContentCaptureEvent.getTypeAsString(event.getType()) : ""; + Log.d(TAG, "Flushing " + numberEvents + " event(s) for " + getDebugState(reason) + + forceString); } if (mFlushHistory != null) { // Logs reason, size, max size, idle timeout diff --git a/core/java/com/android/internal/app/IHotwordRecognitionStatusCallback.aidl b/core/java/com/android/internal/app/IHotwordRecognitionStatusCallback.aidl index d0214e6e0082..813febf33964 100644 --- a/core/java/com/android/internal/app/IHotwordRecognitionStatusCallback.aidl +++ b/core/java/com/android/internal/app/IHotwordRecognitionStatusCallback.aidl @@ -17,6 +17,7 @@ package com.android.internal.app; import android.hardware.soundtrigger.SoundTrigger; +import android.service.voice.DetectorFailure; import android.service.voice.HotwordDetectedResult; import android.service.voice.HotwordRejectedResult; @@ -62,6 +63,13 @@ oneway interface IHotwordRecognitionStatusCallback { void onError(int status); /** + * Called when the detection fails due to an error. + * + * @param detectorFailure It provides the error code, error message and suggested action. + */ + void onDetectionFailure(in DetectorFailure detectorFailure); + + /** * Called when the recognition is paused temporarily for some reason. */ void onRecognitionPaused(); diff --git a/core/java/com/android/internal/app/IVoiceInteractionManagerService.aidl b/core/java/com/android/internal/app/IVoiceInteractionManagerService.aidl index 5eb97862c79f..6b40d9873fbb 100644 --- a/core/java/com/android/internal/app/IVoiceInteractionManagerService.aidl +++ b/core/java/com/android/internal/app/IVoiceInteractionManagerService.aidl @@ -51,7 +51,7 @@ interface IVoiceInteractionManagerService { int startVoiceActivity(IBinder token, in Intent intent, String resolvedType, String attributionTag); int startAssistantActivity(IBinder token, in Intent intent, String resolvedType, - String attributionTag); + String attributionTag, in Bundle bundle); void setKeepAwake(IBinder token, boolean keepAwake); void closeSystemDialogs(IBinder token); void finish(IBinder token); diff --git a/core/java/com/android/internal/app/ResolverActivity.java b/core/java/com/android/internal/app/ResolverActivity.java index d6a515ae2da2..73c5207e6238 100644 --- a/core/java/com/android/internal/app/ResolverActivity.java +++ b/core/java/com/android/internal/app/ResolverActivity.java @@ -739,6 +739,11 @@ public class ResolverActivity extends Activity implements } protected UserHandle fetchPersonalProfileUserHandle() { + // ActivityManager.getCurrentUser() refers to the current Foreground user. When clone/work + // profile is active, we always make the personal tab from the foreground user. + // Outside profiles, current foreground user is potentially the same as the sharesheet + // process's user (UserHandle.myUserId()), so we continue to create personal tab with the + // current foreground user. mPersonalProfileUserHandle = UserHandle.of(ActivityManager.getCurrentUser()); return mPersonalProfileUserHandle; } @@ -768,10 +773,11 @@ public class ResolverActivity extends Activity implements } private UserHandle fetchTabOwnerUserHandleForLaunch() { - if (isLaunchedAsCloneProfile()) { - return getPersonalProfileUserHandle(); - } - return mLaunchedFromUserHandle; + // If we are in work profile's process, return WorkProfile user as owner, otherwise we + // always return PersonalProfile user as owner + return UserHandle.of(UserHandle.myUserId()).equals(getWorkProfileUserHandle()) + ? getWorkProfileUserHandle() + : getPersonalProfileUserHandle(); } private boolean hasWorkProfile() { diff --git a/core/jni/android_view_SurfaceControl.cpp b/core/jni/android_view_SurfaceControl.cpp index d2d87d6916d2..03d6eece61e6 100644 --- a/core/jni/android_view_SurfaceControl.cpp +++ b/core/jni/android_view_SurfaceControl.cpp @@ -639,6 +639,13 @@ static void nativeSetExtendedRangeBrightness(JNIEnv* env, jclass clazz, jlong tr transaction->setExtendedRangeBrightness(ctrl, currentBufferRatio, desiredRatio); } +static void nativeSetCachingHint(JNIEnv* env, jclass clazz, jlong transactionObj, + jlong nativeObject, jint cachingHint) { + auto transaction = reinterpret_cast<SurfaceComposerClient::Transaction*>(transactionObj); + SurfaceControl* const ctrl = reinterpret_cast<SurfaceControl*>(nativeObject); + transaction->setCachingHint(ctrl, static_cast<gui::CachingHint>(cachingHint)); +} + static void nativeSetBlurRegions(JNIEnv* env, jclass clazz, jlong transactionObj, jlong nativeObject, jobjectArray regions, jint regionsLength) { auto transaction = reinterpret_cast<SurfaceComposerClient::Transaction*>(transactionObj); @@ -2204,6 +2211,8 @@ static const JNINativeMethod sSurfaceControlMethods[] = { (void*)nativeSetDataSpace }, {"nativeSetExtendedRangeBrightness", "(JJFF)V", (void*)nativeSetExtendedRangeBrightness }, + {"nativeSetCachingHint", "(JJI)V", + (void*)nativeSetCachingHint }, {"nativeAddWindowInfosReportedListener", "(JLjava/lang/Runnable;)V", (void*)nativeAddWindowInfosReportedListener }, {"nativeGetDisplayBrightnessSupport", "(Landroid/os/IBinder;)Z", diff --git a/core/res/AndroidManifest.xml b/core/res/AndroidManifest.xml index e9771a9dcb7f..e2431221d995 100644 --- a/core/res/AndroidManifest.xml +++ b/core/res/AndroidManifest.xml @@ -7604,6 +7604,13 @@ <permission android:name="android.permission.LOG_PROCESS_ACTIVITIES" android:protectionLevel="signature|privileged" /> + <!-- @hide Allows an application to get type of any provider uri. + <p>Not for use by third-party applications. + <p>Protection level: signature + --> + <permission android:name="android.permission.GET_ANY_PROVIDER_TYPE" + android:protectionLevel="signature" /> + <!-- Attribution for Geofencing service. --> <attribution android:tag="GeofencingService" android:label="@string/geofencing_service"/> <!-- Attribution for Country Detector. --> diff --git a/core/res/res/values/attrs.xml b/core/res/res/values/attrs.xml index d1bef475be1d..9252b149797b 100644 --- a/core/res/res/values/attrs.xml +++ b/core/res/res/values/attrs.xml @@ -1210,6 +1210,122 @@ a value of 'true' will not override any 'false' value in its parent chain nor will it prevent any 'false' in any of its children. --> <attr name="forceDarkAllowed" format="boolean" /> + + <!-- A lower-emphasized variant of the color on the fixed secondary branding color. @hide + --> + <attr name="materialColorOnSecondaryFixedVariant" format="color"/> + <!-- A lower-emphasized variant of the color on the fixed tertiary branding color. @hide + --> + <attr name="materialColorOnTertiaryFixedVariant" format="color"/> + <!-- The container color of surface the most lowered. @hide --> + <attr name="materialColorSurfaceContainerLowest" format="color"/> + <!-- A lower-emphasized variant of the color on the fixed primary branding color. @hide --> + <attr name="materialColorOnPrimaryFixedVariant" format="color"/> + <!-- A color that passes accessibility guidelines for text/iconography when drawn on top of + the secondary container color. @hide --> + <attr name="materialColorOnSecondaryContainer" format="color"/> + <!-- A color that passes accessibility guidelines for text/iconography when drawn on top of + the tertiary container color. @hide --> + <attr name="materialColorOnTertiaryContainer" format="color"/> + <!-- The container color of surface slightly lowered, which replaces the previous surface + at elevation level 1. @hide --> + <attr name="materialColorSurfaceContainerLow" format="color"/> + <!-- A color that passes accessibility guidelines for text/iconography when drawn on top of + the primary container color. @hide --> + <attr name="materialColorOnPrimaryContainer" format="color"/> + <!-- A stronger, more emphasized variant of the fixed secondary branding color. @hide --> + <attr name="materialColorSecondaryFixedDim" format="color"/> + <!-- A tonal variation of the on error color that passes accessibility guidelines for + text/iconography when drawn on top of error container. @hide --> + <attr name="materialColorOnErrorContainer" format="color"/> + <!-- The color text/iconography when drawn on top of the fixed secondary branding color. + @hide --> + <attr name="materialColorOnSecondaryFixed" format="color"/> + <!-- The "on surface" inverse color, useful for inverted backgrounds. @hide --> + <attr name="materialColorOnSurfaceInverse" format="color"/> + <!-- A stronger, more emphasized variant of the fixed tertiary branding color. @hide --> + <attr name="materialColorTertiaryFixedDim" format="color"/> + <!-- The color text/iconography when drawn on top of the fixed tertiary branding color. + @hide --> + <attr name="materialColorOnTertiaryFixed" format="color"/> + <!-- A stronger, more emphasized variant of the fixed primary branding color. @hide --> + <attr name="materialColorPrimaryFixedDim" format="color"/> + <!-- A tonal variation of the secondary color suitable for background color of container + views. @hide --> + <attr name="materialColorSecondaryContainer" format="color"/> + <!-- A tonal variation of the error color suitable for background color of container views. + @hide --> + <attr name="materialColorErrorContainer" format="color"/> + <!-- The color text/iconography when drawn on top of the fixed primary branding color. + @hide --> + <attr name="materialColorOnPrimaryFixed" format="color"/> + <!-- The inverse color of colorPrimary. @hide --> + <attr name="materialColorPrimaryInverse" format="color"/> + <!-- A secondary branding color for the app, which stays the same between light and dark + themes. @hide --> + <attr name="materialColorSecondaryFixed" format="color"/> + <!-- The surface inverse color, useful for inverted backgrounds. @hide --> + <attr name="materialColorSurfaceInverse" format="color"/> + <!-- A tonal variation of the surface color. @hide --> + <attr name="materialColorSurfaceVariant" format="color"/> + <!-- A tonal variation of the tertiary color suitable for background color of container + views. @hide --> + <attr name="materialColorTertiaryContainer" format="color"/> + <!-- A tertiary branding color for the app, which stays the same between light and dark + themes. @hide --> + <attr name="materialColorTertiaryFixed" format="color"/> + <!-- A tonal variation of the primary color suitable for background color of container + views. @hide --> + <attr name="materialColorPrimaryContainer" format="color"/> + <!-- A color that passes accessibility guidelines for text/iconography when drawn on top of + background. @hide --> + <attr name="materialColorOnBackground" format="color"/> + <!-- A primary branding color for the app, which stays the same between light and dark + themes. @hide --> + <attr name="materialColorPrimaryFixed" format="color"/> + <!-- A color that passes accessibility guidelines for text/iconography when drawn on top of + secondary. @hide --> + <attr name="materialColorOnSecondary" format="color"/> + <!-- A color that passes accessibility guidelines for text/iconography when drawn on top of + tertiary. @hide --> + <attr name="materialColorOnTertiary" format="color"/> + <!-- The surface color which always stay the dimmest in either dark or light theme. @hide + --> + <attr name="materialColorSurfaceDim" format="color"/> + <!-- The surface color which always stay the brightest in either dark or light theme. @hide + --> + <attr name="materialColorSurfaceBright" format="color"/> + <!-- The secondary branding color for the app, usually a bright complement to the primary + branding color. @hide --> + <attr name="materialColorSecondary" format="color"/> + <!-- A color that passes accessibility guidelines for text/iconography when drawn on top of + error. @hide --> + <attr name="materialColorOnError" format="color"/> + <!-- The color of surfaces such as cards, sheets, menus. @hide --> + <attr name="materialColorSurface" format="color"/> + <!-- The container color of surface slightly elevated, which replaces the previous surface + at elevation level 3. @hide --> + <attr name="materialColorSurfaceContainerHigh" format="color"/> + <!-- The tertiary branding color for the app, usually a bright complement to the primary + branding color. @hide --> + <attr name="materialColorTertiary" format="color"/> + <!-- The container color of surface the most elevated, which replaces the previous surface + variant. @hide --> + <attr name="materialColorSurfaceContainerHighest" format="color"/> + <!-- undefined @hide --> + <attr name="materialColorOnSurfaceVariant" format="color"/> + <!-- undefined @hide --> + <attr name="materialColorOutline" format="color"/> + <!-- undefined @hide --> + <attr name="materialColorOnPrimary" format="color"/> + <!-- undefined @hide --> + <attr name="materialColorOnSurface" format="color"/> + <!-- undefined @hide --> + <attr name="materialColorSurfaceContainer" format="color"/> + <!-- The container color of surface, which replaces the previous surface at elevation level + 2. @hide --> + <attr name="materialColorSurfaceContainer" format="color"/> + </declare-styleable> <!-- **************************************************************** --> diff --git a/core/res/res/values/themes_device_defaults.xml b/core/res/res/values/themes_device_defaults.xml index c603c83e033d..511e734a0994 100644 --- a/core/res/res/values/themes_device_defaults.xml +++ b/core/res/res/values/themes_device_defaults.xml @@ -238,6 +238,51 @@ easier. <item name="textColorOnAccent">@color/text_color_on_accent_device_default</item> <item name="colorForeground">@color/foreground_device_default_dark</item> <item name="colorForegroundInverse">@color/foreground_device_default_light</item> + + <item name="materialColorOnSecondaryFixedVariant">@color/system_on_secondary_fixed_variant_dark</item> + <item name="materialColorOnTertiaryFixedVariant">@color/system_on_tertiary_fixed_variant_dark</item> + <item name="materialColorSurfaceContainerLowest">@color/system_surface_container_lowest_dark</item> + <item name="materialColorOnPrimaryFixedVariant">@color/system_on_primary_fixed_variant_dark</item> + <item name="materialColorOnSecondaryContainer">@color/system_on_secondary_container_dark</item> + <item name="materialColorOnTertiaryContainer">@color/system_on_tertiary_container_dark</item> + <item name="materialColorSurfaceContainerLow">@color/system_surface_container_low_dark</item> + <item name="materialColorOnPrimaryContainer">@color/system_on_primary_container_dark</item> + <item name="materialColorSecondaryFixedDim">@color/system_secondary_fixed_dim_dark</item> + <item name="materialColorOnErrorContainer">@color/system_on_error_container_dark</item> + <item name="materialColorOnSecondaryFixed">@color/system_on_secondary_fixed_dark</item> + <item name="materialColorOnSurfaceInverse">@color/system_on_surface_dark</item> + <item name="materialColorTertiaryFixedDim">@color/system_tertiary_fixed_dim_dark</item> + <item name="materialColorOnTertiaryFixed">@color/system_on_tertiary_fixed_dark</item> + <item name="materialColorPrimaryFixedDim">@color/system_primary_fixed_dim_dark</item> + <item name="materialColorSecondaryContainer">@color/system_secondary_container_dark</item> + <item name="materialColorErrorContainer">@color/system_error_container_dark</item> + <item name="materialColorOnPrimaryFixed">@color/system_on_primary_fixed_dark</item> + <item name="materialColorPrimaryInverse">@color/system_primary_dark</item> + <item name="materialColorSecondaryFixed">@color/system_secondary_fixed_dark</item> + <item name="materialColorSurfaceInverse">@color/system_surface_dark</item> + <item name="materialColorSurfaceVariant">@color/system_surface_variant_dark</item> + <item name="materialColorTertiaryContainer">@color/system_tertiary_container_dark</item> + <item name="materialColorTertiaryFixed">@color/system_tertiary_fixed_dark</item> + <item name="materialColorPrimaryContainer">@color/system_primary_container_dark</item> + <item name="materialColorOnBackground">@color/system_on_background_dark</item> + <item name="materialColorPrimaryFixed">@color/system_primary_fixed_dark</item> + <item name="materialColorOnSecondary">@color/system_on_secondary_dark</item> + <item name="materialColorOnTertiary">@color/system_on_tertiary_dark</item> + <item name="materialColorSurfaceDim">@color/system_surface_dim_dark</item> + <item name="materialColorSurfaceBright">@color/system_surface_bright_dark</item> + <item name="materialColorSecondary">@color/system_secondary_dark</item> + <item name="materialColorOnError">@color/system_on_error_dark</item> + <item name="materialColorSurface">@color/system_surface_dark</item> + <item name="materialColorSurfaceContainerHigh">@color/system_surface_container_high_dark</item> + <item name="materialColorTertiary">@color/system_tertiary_dark</item> + <item name="materialColorSurfaceContainerHighest">@color/system_surface_container_highest_dark</item> + <item name="materialColorOnSurfaceVariant">@color/system_on_surface_variant_dark</item> + <item name="materialColorOutline">@color/system_outline_dark</item> + <item name="materialColorOnPrimary">@color/system_on_primary_dark</item> + <item name="materialColorOnSurface">@color/system_on_surface_dark</item> + <item name="materialColorSurfaceContainer">@color/system_surface_container_dark</item> + <item name="materialColorSurfaceContainer">@color/system_surface_container_dark</item> + </style> <style name="Theme.DeviceDefault" parent="Theme.DeviceDefaultBase" /> @@ -288,6 +333,51 @@ easier. <!-- Toolbar attributes --> <item name="toolbarStyle">@style/Widget.DeviceDefault.Toolbar</item> + + <item name="materialColorOnSecondaryFixedVariant">@color/system_on_secondary_fixed_variant_dark</item> + <item name="materialColorOnTertiaryFixedVariant">@color/system_on_tertiary_fixed_variant_dark</item> + <item name="materialColorSurfaceContainerLowest">@color/system_surface_container_lowest_dark</item> + <item name="materialColorOnPrimaryFixedVariant">@color/system_on_primary_fixed_variant_dark</item> + <item name="materialColorOnSecondaryContainer">@color/system_on_secondary_container_dark</item> + <item name="materialColorOnTertiaryContainer">@color/system_on_tertiary_container_dark</item> + <item name="materialColorSurfaceContainerLow">@color/system_surface_container_low_dark</item> + <item name="materialColorOnPrimaryContainer">@color/system_on_primary_container_dark</item> + <item name="materialColorSecondaryFixedDim">@color/system_secondary_fixed_dim_dark</item> + <item name="materialColorOnErrorContainer">@color/system_on_error_container_dark</item> + <item name="materialColorOnSecondaryFixed">@color/system_on_secondary_fixed_dark</item> + <item name="materialColorOnSurfaceInverse">@color/system_on_surface_dark</item> + <item name="materialColorTertiaryFixedDim">@color/system_tertiary_fixed_dim_dark</item> + <item name="materialColorOnTertiaryFixed">@color/system_on_tertiary_fixed_dark</item> + <item name="materialColorPrimaryFixedDim">@color/system_primary_fixed_dim_dark</item> + <item name="materialColorSecondaryContainer">@color/system_secondary_container_dark</item> + <item name="materialColorErrorContainer">@color/system_error_container_dark</item> + <item name="materialColorOnPrimaryFixed">@color/system_on_primary_fixed_dark</item> + <item name="materialColorPrimaryInverse">@color/system_primary_dark</item> + <item name="materialColorSecondaryFixed">@color/system_secondary_fixed_dark</item> + <item name="materialColorSurfaceInverse">@color/system_surface_dark</item> + <item name="materialColorSurfaceVariant">@color/system_surface_variant_dark</item> + <item name="materialColorTertiaryContainer">@color/system_tertiary_container_dark</item> + <item name="materialColorTertiaryFixed">@color/system_tertiary_fixed_dark</item> + <item name="materialColorPrimaryContainer">@color/system_primary_container_dark</item> + <item name="materialColorOnBackground">@color/system_on_background_dark</item> + <item name="materialColorPrimaryFixed">@color/system_primary_fixed_dark</item> + <item name="materialColorOnSecondary">@color/system_on_secondary_dark</item> + <item name="materialColorOnTertiary">@color/system_on_tertiary_dark</item> + <item name="materialColorSurfaceDim">@color/system_surface_dim_dark</item> + <item name="materialColorSurfaceBright">@color/system_surface_bright_dark</item> + <item name="materialColorSecondary">@color/system_secondary_dark</item> + <item name="materialColorOnError">@color/system_on_error_dark</item> + <item name="materialColorSurface">@color/system_surface_dark</item> + <item name="materialColorSurfaceContainerHigh">@color/system_surface_container_high_dark</item> + <item name="materialColorTertiary">@color/system_tertiary_dark</item> + <item name="materialColorSurfaceContainerHighest">@color/system_surface_container_highest_dark</item> + <item name="materialColorOnSurfaceVariant">@color/system_on_surface_variant_dark</item> + <item name="materialColorOutline">@color/system_outline_dark</item> + <item name="materialColorOnPrimary">@color/system_on_primary_dark</item> + <item name="materialColorOnSurface">@color/system_on_surface_dark</item> + <item name="materialColorSurfaceContainer">@color/system_surface_container_dark</item> + <item name="materialColorSurfaceContainer">@color/system_surface_container_dark</item> + </style> <!-- Variant of {@link #Theme_DeviceDefault} with no action bar and no status bar. This theme @@ -337,6 +427,51 @@ easier. <!-- Toolbar attributes --> <item name="toolbarStyle">@style/Widget.DeviceDefault.Toolbar</item> + + <item name="materialColorOnSecondaryFixedVariant">@color/system_on_secondary_fixed_variant_dark</item> + <item name="materialColorOnTertiaryFixedVariant">@color/system_on_tertiary_fixed_variant_dark</item> + <item name="materialColorSurfaceContainerLowest">@color/system_surface_container_lowest_dark</item> + <item name="materialColorOnPrimaryFixedVariant">@color/system_on_primary_fixed_variant_dark</item> + <item name="materialColorOnSecondaryContainer">@color/system_on_secondary_container_dark</item> + <item name="materialColorOnTertiaryContainer">@color/system_on_tertiary_container_dark</item> + <item name="materialColorSurfaceContainerLow">@color/system_surface_container_low_dark</item> + <item name="materialColorOnPrimaryContainer">@color/system_on_primary_container_dark</item> + <item name="materialColorSecondaryFixedDim">@color/system_secondary_fixed_dim_dark</item> + <item name="materialColorOnErrorContainer">@color/system_on_error_container_dark</item> + <item name="materialColorOnSecondaryFixed">@color/system_on_secondary_fixed_dark</item> + <item name="materialColorOnSurfaceInverse">@color/system_on_surface_dark</item> + <item name="materialColorTertiaryFixedDim">@color/system_tertiary_fixed_dim_dark</item> + <item name="materialColorOnTertiaryFixed">@color/system_on_tertiary_fixed_dark</item> + <item name="materialColorPrimaryFixedDim">@color/system_primary_fixed_dim_dark</item> + <item name="materialColorSecondaryContainer">@color/system_secondary_container_dark</item> + <item name="materialColorErrorContainer">@color/system_error_container_dark</item> + <item name="materialColorOnPrimaryFixed">@color/system_on_primary_fixed_dark</item> + <item name="materialColorPrimaryInverse">@color/system_primary_dark</item> + <item name="materialColorSecondaryFixed">@color/system_secondary_fixed_dark</item> + <item name="materialColorSurfaceInverse">@color/system_surface_dark</item> + <item name="materialColorSurfaceVariant">@color/system_surface_variant_dark</item> + <item name="materialColorTertiaryContainer">@color/system_tertiary_container_dark</item> + <item name="materialColorTertiaryFixed">@color/system_tertiary_fixed_dark</item> + <item name="materialColorPrimaryContainer">@color/system_primary_container_dark</item> + <item name="materialColorOnBackground">@color/system_on_background_dark</item> + <item name="materialColorPrimaryFixed">@color/system_primary_fixed_dark</item> + <item name="materialColorOnSecondary">@color/system_on_secondary_dark</item> + <item name="materialColorOnTertiary">@color/system_on_tertiary_dark</item> + <item name="materialColorSurfaceDim">@color/system_surface_dim_dark</item> + <item name="materialColorSurfaceBright">@color/system_surface_bright_dark</item> + <item name="materialColorSecondary">@color/system_secondary_dark</item> + <item name="materialColorOnError">@color/system_on_error_dark</item> + <item name="materialColorSurface">@color/system_surface_dark</item> + <item name="materialColorSurfaceContainerHigh">@color/system_surface_container_high_dark</item> + <item name="materialColorTertiary">@color/system_tertiary_dark</item> + <item name="materialColorSurfaceContainerHighest">@color/system_surface_container_highest_dark</item> + <item name="materialColorOnSurfaceVariant">@color/system_on_surface_variant_dark</item> + <item name="materialColorOutline">@color/system_outline_dark</item> + <item name="materialColorOnPrimary">@color/system_on_primary_dark</item> + <item name="materialColorOnSurface">@color/system_on_surface_dark</item> + <item name="materialColorSurfaceContainer">@color/system_surface_container_dark</item> + <item name="materialColorSurfaceContainer">@color/system_surface_container_dark</item> + </style> <!-- Variant of {@link #Theme_DeviceDefault} with no action bar and no status bar and @@ -388,6 +523,51 @@ easier. <!-- Toolbar attributes --> <item name="toolbarStyle">@style/Widget.DeviceDefault.Toolbar</item> + + <item name="materialColorOnSecondaryFixedVariant">@color/system_on_secondary_fixed_variant_dark</item> + <item name="materialColorOnTertiaryFixedVariant">@color/system_on_tertiary_fixed_variant_dark</item> + <item name="materialColorSurfaceContainerLowest">@color/system_surface_container_lowest_dark</item> + <item name="materialColorOnPrimaryFixedVariant">@color/system_on_primary_fixed_variant_dark</item> + <item name="materialColorOnSecondaryContainer">@color/system_on_secondary_container_dark</item> + <item name="materialColorOnTertiaryContainer">@color/system_on_tertiary_container_dark</item> + <item name="materialColorSurfaceContainerLow">@color/system_surface_container_low_dark</item> + <item name="materialColorOnPrimaryContainer">@color/system_on_primary_container_dark</item> + <item name="materialColorSecondaryFixedDim">@color/system_secondary_fixed_dim_dark</item> + <item name="materialColorOnErrorContainer">@color/system_on_error_container_dark</item> + <item name="materialColorOnSecondaryFixed">@color/system_on_secondary_fixed_dark</item> + <item name="materialColorOnSurfaceInverse">@color/system_on_surface_dark</item> + <item name="materialColorTertiaryFixedDim">@color/system_tertiary_fixed_dim_dark</item> + <item name="materialColorOnTertiaryFixed">@color/system_on_tertiary_fixed_dark</item> + <item name="materialColorPrimaryFixedDim">@color/system_primary_fixed_dim_dark</item> + <item name="materialColorSecondaryContainer">@color/system_secondary_container_dark</item> + <item name="materialColorErrorContainer">@color/system_error_container_dark</item> + <item name="materialColorOnPrimaryFixed">@color/system_on_primary_fixed_dark</item> + <item name="materialColorPrimaryInverse">@color/system_primary_dark</item> + <item name="materialColorSecondaryFixed">@color/system_secondary_fixed_dark</item> + <item name="materialColorSurfaceInverse">@color/system_surface_dark</item> + <item name="materialColorSurfaceVariant">@color/system_surface_variant_dark</item> + <item name="materialColorTertiaryContainer">@color/system_tertiary_container_dark</item> + <item name="materialColorTertiaryFixed">@color/system_tertiary_fixed_dark</item> + <item name="materialColorPrimaryContainer">@color/system_primary_container_dark</item> + <item name="materialColorOnBackground">@color/system_on_background_dark</item> + <item name="materialColorPrimaryFixed">@color/system_primary_fixed_dark</item> + <item name="materialColorOnSecondary">@color/system_on_secondary_dark</item> + <item name="materialColorOnTertiary">@color/system_on_tertiary_dark</item> + <item name="materialColorSurfaceDim">@color/system_surface_dim_dark</item> + <item name="materialColorSurfaceBright">@color/system_surface_bright_dark</item> + <item name="materialColorSecondary">@color/system_secondary_dark</item> + <item name="materialColorOnError">@color/system_on_error_dark</item> + <item name="materialColorSurface">@color/system_surface_dark</item> + <item name="materialColorSurfaceContainerHigh">@color/system_surface_container_high_dark</item> + <item name="materialColorTertiary">@color/system_tertiary_dark</item> + <item name="materialColorSurfaceContainerHighest">@color/system_surface_container_highest_dark</item> + <item name="materialColorOnSurfaceVariant">@color/system_on_surface_variant_dark</item> + <item name="materialColorOutline">@color/system_outline_dark</item> + <item name="materialColorOnPrimary">@color/system_on_primary_dark</item> + <item name="materialColorOnSurface">@color/system_on_surface_dark</item> + <item name="materialColorSurfaceContainer">@color/system_surface_container_dark</item> + <item name="materialColorSurfaceContainer">@color/system_surface_container_dark</item> + </style> <!-- Variant of {@link #Theme_DeviceDefault} that has no title bar and translucent @@ -438,6 +618,51 @@ easier. <!-- Toolbar attributes --> <item name="toolbarStyle">@style/Widget.DeviceDefault.Toolbar</item> + + <item name="materialColorOnSecondaryFixedVariant">@color/system_on_secondary_fixed_variant_dark</item> + <item name="materialColorOnTertiaryFixedVariant">@color/system_on_tertiary_fixed_variant_dark</item> + <item name="materialColorSurfaceContainerLowest">@color/system_surface_container_lowest_dark</item> + <item name="materialColorOnPrimaryFixedVariant">@color/system_on_primary_fixed_variant_dark</item> + <item name="materialColorOnSecondaryContainer">@color/system_on_secondary_container_dark</item> + <item name="materialColorOnTertiaryContainer">@color/system_on_tertiary_container_dark</item> + <item name="materialColorSurfaceContainerLow">@color/system_surface_container_low_dark</item> + <item name="materialColorOnPrimaryContainer">@color/system_on_primary_container_dark</item> + <item name="materialColorSecondaryFixedDim">@color/system_secondary_fixed_dim_dark</item> + <item name="materialColorOnErrorContainer">@color/system_on_error_container_dark</item> + <item name="materialColorOnSecondaryFixed">@color/system_on_secondary_fixed_dark</item> + <item name="materialColorOnSurfaceInverse">@color/system_on_surface_dark</item> + <item name="materialColorTertiaryFixedDim">@color/system_tertiary_fixed_dim_dark</item> + <item name="materialColorOnTertiaryFixed">@color/system_on_tertiary_fixed_dark</item> + <item name="materialColorPrimaryFixedDim">@color/system_primary_fixed_dim_dark</item> + <item name="materialColorSecondaryContainer">@color/system_secondary_container_dark</item> + <item name="materialColorErrorContainer">@color/system_error_container_dark</item> + <item name="materialColorOnPrimaryFixed">@color/system_on_primary_fixed_dark</item> + <item name="materialColorPrimaryInverse">@color/system_primary_dark</item> + <item name="materialColorSecondaryFixed">@color/system_secondary_fixed_dark</item> + <item name="materialColorSurfaceInverse">@color/system_surface_dark</item> + <item name="materialColorSurfaceVariant">@color/system_surface_variant_dark</item> + <item name="materialColorTertiaryContainer">@color/system_tertiary_container_dark</item> + <item name="materialColorTertiaryFixed">@color/system_tertiary_fixed_dark</item> + <item name="materialColorPrimaryContainer">@color/system_primary_container_dark</item> + <item name="materialColorOnBackground">@color/system_on_background_dark</item> + <item name="materialColorPrimaryFixed">@color/system_primary_fixed_dark</item> + <item name="materialColorOnSecondary">@color/system_on_secondary_dark</item> + <item name="materialColorOnTertiary">@color/system_on_tertiary_dark</item> + <item name="materialColorSurfaceDim">@color/system_surface_dim_dark</item> + <item name="materialColorSurfaceBright">@color/system_surface_bright_dark</item> + <item name="materialColorSecondary">@color/system_secondary_dark</item> + <item name="materialColorOnError">@color/system_on_error_dark</item> + <item name="materialColorSurface">@color/system_surface_dark</item> + <item name="materialColorSurfaceContainerHigh">@color/system_surface_container_high_dark</item> + <item name="materialColorTertiary">@color/system_tertiary_dark</item> + <item name="materialColorSurfaceContainerHighest">@color/system_surface_container_highest_dark</item> + <item name="materialColorOnSurfaceVariant">@color/system_on_surface_variant_dark</item> + <item name="materialColorOutline">@color/system_outline_dark</item> + <item name="materialColorOnPrimary">@color/system_on_primary_dark</item> + <item name="materialColorOnSurface">@color/system_on_surface_dark</item> + <item name="materialColorSurfaceContainer">@color/system_surface_container_dark</item> + <item name="materialColorSurfaceContainer">@color/system_surface_container_dark</item> + </style> <!-- DeviceDefault theme for dialog windows and activities. This changes the window to be @@ -496,6 +721,51 @@ easier. <!-- Toolbar attributes --> <item name="toolbarStyle">@style/Widget.DeviceDefault.Toolbar</item> + + <item name="materialColorOnSecondaryFixedVariant">@color/system_on_secondary_fixed_variant_dark</item> + <item name="materialColorOnTertiaryFixedVariant">@color/system_on_tertiary_fixed_variant_dark</item> + <item name="materialColorSurfaceContainerLowest">@color/system_surface_container_lowest_dark</item> + <item name="materialColorOnPrimaryFixedVariant">@color/system_on_primary_fixed_variant_dark</item> + <item name="materialColorOnSecondaryContainer">@color/system_on_secondary_container_dark</item> + <item name="materialColorOnTertiaryContainer">@color/system_on_tertiary_container_dark</item> + <item name="materialColorSurfaceContainerLow">@color/system_surface_container_low_dark</item> + <item name="materialColorOnPrimaryContainer">@color/system_on_primary_container_dark</item> + <item name="materialColorSecondaryFixedDim">@color/system_secondary_fixed_dim_dark</item> + <item name="materialColorOnErrorContainer">@color/system_on_error_container_dark</item> + <item name="materialColorOnSecondaryFixed">@color/system_on_secondary_fixed_dark</item> + <item name="materialColorOnSurfaceInverse">@color/system_on_surface_dark</item> + <item name="materialColorTertiaryFixedDim">@color/system_tertiary_fixed_dim_dark</item> + <item name="materialColorOnTertiaryFixed">@color/system_on_tertiary_fixed_dark</item> + <item name="materialColorPrimaryFixedDim">@color/system_primary_fixed_dim_dark</item> + <item name="materialColorSecondaryContainer">@color/system_secondary_container_dark</item> + <item name="materialColorErrorContainer">@color/system_error_container_dark</item> + <item name="materialColorOnPrimaryFixed">@color/system_on_primary_fixed_dark</item> + <item name="materialColorPrimaryInverse">@color/system_primary_dark</item> + <item name="materialColorSecondaryFixed">@color/system_secondary_fixed_dark</item> + <item name="materialColorSurfaceInverse">@color/system_surface_dark</item> + <item name="materialColorSurfaceVariant">@color/system_surface_variant_dark</item> + <item name="materialColorTertiaryContainer">@color/system_tertiary_container_dark</item> + <item name="materialColorTertiaryFixed">@color/system_tertiary_fixed_dark</item> + <item name="materialColorPrimaryContainer">@color/system_primary_container_dark</item> + <item name="materialColorOnBackground">@color/system_on_background_dark</item> + <item name="materialColorPrimaryFixed">@color/system_primary_fixed_dark</item> + <item name="materialColorOnSecondary">@color/system_on_secondary_dark</item> + <item name="materialColorOnTertiary">@color/system_on_tertiary_dark</item> + <item name="materialColorSurfaceDim">@color/system_surface_dim_dark</item> + <item name="materialColorSurfaceBright">@color/system_surface_bright_dark</item> + <item name="materialColorSecondary">@color/system_secondary_dark</item> + <item name="materialColorOnError">@color/system_on_error_dark</item> + <item name="materialColorSurface">@color/system_surface_dark</item> + <item name="materialColorSurfaceContainerHigh">@color/system_surface_container_high_dark</item> + <item name="materialColorTertiary">@color/system_tertiary_dark</item> + <item name="materialColorSurfaceContainerHighest">@color/system_surface_container_highest_dark</item> + <item name="materialColorOnSurfaceVariant">@color/system_on_surface_variant_dark</item> + <item name="materialColorOutline">@color/system_outline_dark</item> + <item name="materialColorOnPrimary">@color/system_on_primary_dark</item> + <item name="materialColorOnSurface">@color/system_on_surface_dark</item> + <item name="materialColorSurfaceContainer">@color/system_surface_container_dark</item> + <item name="materialColorSurfaceContainer">@color/system_surface_container_dark</item> + </style> <!-- Variant of {@link #Theme_DeviceDefault_Dialog} that has a nice minimum width for a @@ -545,6 +815,51 @@ easier. <!-- Toolbar attributes --> <item name="toolbarStyle">@style/Widget.DeviceDefault.Toolbar</item> + + <item name="materialColorOnSecondaryFixedVariant">@color/system_on_secondary_fixed_variant_dark</item> + <item name="materialColorOnTertiaryFixedVariant">@color/system_on_tertiary_fixed_variant_dark</item> + <item name="materialColorSurfaceContainerLowest">@color/system_surface_container_lowest_dark</item> + <item name="materialColorOnPrimaryFixedVariant">@color/system_on_primary_fixed_variant_dark</item> + <item name="materialColorOnSecondaryContainer">@color/system_on_secondary_container_dark</item> + <item name="materialColorOnTertiaryContainer">@color/system_on_tertiary_container_dark</item> + <item name="materialColorSurfaceContainerLow">@color/system_surface_container_low_dark</item> + <item name="materialColorOnPrimaryContainer">@color/system_on_primary_container_dark</item> + <item name="materialColorSecondaryFixedDim">@color/system_secondary_fixed_dim_dark</item> + <item name="materialColorOnErrorContainer">@color/system_on_error_container_dark</item> + <item name="materialColorOnSecondaryFixed">@color/system_on_secondary_fixed_dark</item> + <item name="materialColorOnSurfaceInverse">@color/system_on_surface_dark</item> + <item name="materialColorTertiaryFixedDim">@color/system_tertiary_fixed_dim_dark</item> + <item name="materialColorOnTertiaryFixed">@color/system_on_tertiary_fixed_dark</item> + <item name="materialColorPrimaryFixedDim">@color/system_primary_fixed_dim_dark</item> + <item name="materialColorSecondaryContainer">@color/system_secondary_container_dark</item> + <item name="materialColorErrorContainer">@color/system_error_container_dark</item> + <item name="materialColorOnPrimaryFixed">@color/system_on_primary_fixed_dark</item> + <item name="materialColorPrimaryInverse">@color/system_primary_dark</item> + <item name="materialColorSecondaryFixed">@color/system_secondary_fixed_dark</item> + <item name="materialColorSurfaceInverse">@color/system_surface_dark</item> + <item name="materialColorSurfaceVariant">@color/system_surface_variant_dark</item> + <item name="materialColorTertiaryContainer">@color/system_tertiary_container_dark</item> + <item name="materialColorTertiaryFixed">@color/system_tertiary_fixed_dark</item> + <item name="materialColorPrimaryContainer">@color/system_primary_container_dark</item> + <item name="materialColorOnBackground">@color/system_on_background_dark</item> + <item name="materialColorPrimaryFixed">@color/system_primary_fixed_dark</item> + <item name="materialColorOnSecondary">@color/system_on_secondary_dark</item> + <item name="materialColorOnTertiary">@color/system_on_tertiary_dark</item> + <item name="materialColorSurfaceDim">@color/system_surface_dim_dark</item> + <item name="materialColorSurfaceBright">@color/system_surface_bright_dark</item> + <item name="materialColorSecondary">@color/system_secondary_dark</item> + <item name="materialColorOnError">@color/system_on_error_dark</item> + <item name="materialColorSurface">@color/system_surface_dark</item> + <item name="materialColorSurfaceContainerHigh">@color/system_surface_container_high_dark</item> + <item name="materialColorTertiary">@color/system_tertiary_dark</item> + <item name="materialColorSurfaceContainerHighest">@color/system_surface_container_highest_dark</item> + <item name="materialColorOnSurfaceVariant">@color/system_on_surface_variant_dark</item> + <item name="materialColorOutline">@color/system_outline_dark</item> + <item name="materialColorOnPrimary">@color/system_on_primary_dark</item> + <item name="materialColorOnSurface">@color/system_on_surface_dark</item> + <item name="materialColorSurfaceContainer">@color/system_surface_container_dark</item> + <item name="materialColorSurfaceContainer">@color/system_surface_container_dark</item> + </style> <!-- Variant of {@link #Theme_DeviceDefault_Dialog} without an action bar --> @@ -593,6 +908,51 @@ easier. <!-- Toolbar attributes --> <item name="toolbarStyle">@style/Widget.DeviceDefault.Toolbar</item> + + <item name="materialColorOnSecondaryFixedVariant">@color/system_on_secondary_fixed_variant_dark</item> + <item name="materialColorOnTertiaryFixedVariant">@color/system_on_tertiary_fixed_variant_dark</item> + <item name="materialColorSurfaceContainerLowest">@color/system_surface_container_lowest_dark</item> + <item name="materialColorOnPrimaryFixedVariant">@color/system_on_primary_fixed_variant_dark</item> + <item name="materialColorOnSecondaryContainer">@color/system_on_secondary_container_dark</item> + <item name="materialColorOnTertiaryContainer">@color/system_on_tertiary_container_dark</item> + <item name="materialColorSurfaceContainerLow">@color/system_surface_container_low_dark</item> + <item name="materialColorOnPrimaryContainer">@color/system_on_primary_container_dark</item> + <item name="materialColorSecondaryFixedDim">@color/system_secondary_fixed_dim_dark</item> + <item name="materialColorOnErrorContainer">@color/system_on_error_container_dark</item> + <item name="materialColorOnSecondaryFixed">@color/system_on_secondary_fixed_dark</item> + <item name="materialColorOnSurfaceInverse">@color/system_on_surface_dark</item> + <item name="materialColorTertiaryFixedDim">@color/system_tertiary_fixed_dim_dark</item> + <item name="materialColorOnTertiaryFixed">@color/system_on_tertiary_fixed_dark</item> + <item name="materialColorPrimaryFixedDim">@color/system_primary_fixed_dim_dark</item> + <item name="materialColorSecondaryContainer">@color/system_secondary_container_dark</item> + <item name="materialColorErrorContainer">@color/system_error_container_dark</item> + <item name="materialColorOnPrimaryFixed">@color/system_on_primary_fixed_dark</item> + <item name="materialColorPrimaryInverse">@color/system_primary_dark</item> + <item name="materialColorSecondaryFixed">@color/system_secondary_fixed_dark</item> + <item name="materialColorSurfaceInverse">@color/system_surface_dark</item> + <item name="materialColorSurfaceVariant">@color/system_surface_variant_dark</item> + <item name="materialColorTertiaryContainer">@color/system_tertiary_container_dark</item> + <item name="materialColorTertiaryFixed">@color/system_tertiary_fixed_dark</item> + <item name="materialColorPrimaryContainer">@color/system_primary_container_dark</item> + <item name="materialColorOnBackground">@color/system_on_background_dark</item> + <item name="materialColorPrimaryFixed">@color/system_primary_fixed_dark</item> + <item name="materialColorOnSecondary">@color/system_on_secondary_dark</item> + <item name="materialColorOnTertiary">@color/system_on_tertiary_dark</item> + <item name="materialColorSurfaceDim">@color/system_surface_dim_dark</item> + <item name="materialColorSurfaceBright">@color/system_surface_bright_dark</item> + <item name="materialColorSecondary">@color/system_secondary_dark</item> + <item name="materialColorOnError">@color/system_on_error_dark</item> + <item name="materialColorSurface">@color/system_surface_dark</item> + <item name="materialColorSurfaceContainerHigh">@color/system_surface_container_high_dark</item> + <item name="materialColorTertiary">@color/system_tertiary_dark</item> + <item name="materialColorSurfaceContainerHighest">@color/system_surface_container_highest_dark</item> + <item name="materialColorOnSurfaceVariant">@color/system_on_surface_variant_dark</item> + <item name="materialColorOutline">@color/system_outline_dark</item> + <item name="materialColorOnPrimary">@color/system_on_primary_dark</item> + <item name="materialColorOnSurface">@color/system_on_surface_dark</item> + <item name="materialColorSurfaceContainer">@color/system_surface_container_dark</item> + <item name="materialColorSurfaceContainer">@color/system_surface_container_dark</item> + </style> <!-- Variant of {@link #Theme_DeviceDefault_Dialog_NoActionBar} that has a nice minimum width @@ -642,6 +1002,51 @@ easier. <!-- Toolbar attributes --> <item name="toolbarStyle">@style/Widget.DeviceDefault.Toolbar</item> + + <item name="materialColorOnSecondaryFixedVariant">@color/system_on_secondary_fixed_variant_dark</item> + <item name="materialColorOnTertiaryFixedVariant">@color/system_on_tertiary_fixed_variant_dark</item> + <item name="materialColorSurfaceContainerLowest">@color/system_surface_container_lowest_dark</item> + <item name="materialColorOnPrimaryFixedVariant">@color/system_on_primary_fixed_variant_dark</item> + <item name="materialColorOnSecondaryContainer">@color/system_on_secondary_container_dark</item> + <item name="materialColorOnTertiaryContainer">@color/system_on_tertiary_container_dark</item> + <item name="materialColorSurfaceContainerLow">@color/system_surface_container_low_dark</item> + <item name="materialColorOnPrimaryContainer">@color/system_on_primary_container_dark</item> + <item name="materialColorSecondaryFixedDim">@color/system_secondary_fixed_dim_dark</item> + <item name="materialColorOnErrorContainer">@color/system_on_error_container_dark</item> + <item name="materialColorOnSecondaryFixed">@color/system_on_secondary_fixed_dark</item> + <item name="materialColorOnSurfaceInverse">@color/system_on_surface_dark</item> + <item name="materialColorTertiaryFixedDim">@color/system_tertiary_fixed_dim_dark</item> + <item name="materialColorOnTertiaryFixed">@color/system_on_tertiary_fixed_dark</item> + <item name="materialColorPrimaryFixedDim">@color/system_primary_fixed_dim_dark</item> + <item name="materialColorSecondaryContainer">@color/system_secondary_container_dark</item> + <item name="materialColorErrorContainer">@color/system_error_container_dark</item> + <item name="materialColorOnPrimaryFixed">@color/system_on_primary_fixed_dark</item> + <item name="materialColorPrimaryInverse">@color/system_primary_dark</item> + <item name="materialColorSecondaryFixed">@color/system_secondary_fixed_dark</item> + <item name="materialColorSurfaceInverse">@color/system_surface_dark</item> + <item name="materialColorSurfaceVariant">@color/system_surface_variant_dark</item> + <item name="materialColorTertiaryContainer">@color/system_tertiary_container_dark</item> + <item name="materialColorTertiaryFixed">@color/system_tertiary_fixed_dark</item> + <item name="materialColorPrimaryContainer">@color/system_primary_container_dark</item> + <item name="materialColorOnBackground">@color/system_on_background_dark</item> + <item name="materialColorPrimaryFixed">@color/system_primary_fixed_dark</item> + <item name="materialColorOnSecondary">@color/system_on_secondary_dark</item> + <item name="materialColorOnTertiary">@color/system_on_tertiary_dark</item> + <item name="materialColorSurfaceDim">@color/system_surface_dim_dark</item> + <item name="materialColorSurfaceBright">@color/system_surface_bright_dark</item> + <item name="materialColorSecondary">@color/system_secondary_dark</item> + <item name="materialColorOnError">@color/system_on_error_dark</item> + <item name="materialColorSurface">@color/system_surface_dark</item> + <item name="materialColorSurfaceContainerHigh">@color/system_surface_container_high_dark</item> + <item name="materialColorTertiary">@color/system_tertiary_dark</item> + <item name="materialColorSurfaceContainerHighest">@color/system_surface_container_highest_dark</item> + <item name="materialColorOnSurfaceVariant">@color/system_on_surface_variant_dark</item> + <item name="materialColorOutline">@color/system_outline_dark</item> + <item name="materialColorOnPrimary">@color/system_on_primary_dark</item> + <item name="materialColorOnSurface">@color/system_on_surface_dark</item> + <item name="materialColorSurfaceContainer">@color/system_surface_container_dark</item> + <item name="materialColorSurfaceContainer">@color/system_surface_container_dark</item> + </style> <!-- Variant of Theme.DeviceDefault.Dialog that has a fixed size. --> @@ -707,6 +1112,51 @@ easier. <!-- Toolbar attributes --> <item name="toolbarStyle">@style/Widget.DeviceDefault.Toolbar</item> + + <item name="materialColorOnSecondaryFixedVariant">@color/system_on_secondary_fixed_variant_dark</item> + <item name="materialColorOnTertiaryFixedVariant">@color/system_on_tertiary_fixed_variant_dark</item> + <item name="materialColorSurfaceContainerLowest">@color/system_surface_container_lowest_dark</item> + <item name="materialColorOnPrimaryFixedVariant">@color/system_on_primary_fixed_variant_dark</item> + <item name="materialColorOnSecondaryContainer">@color/system_on_secondary_container_dark</item> + <item name="materialColorOnTertiaryContainer">@color/system_on_tertiary_container_dark</item> + <item name="materialColorSurfaceContainerLow">@color/system_surface_container_low_dark</item> + <item name="materialColorOnPrimaryContainer">@color/system_on_primary_container_dark</item> + <item name="materialColorSecondaryFixedDim">@color/system_secondary_fixed_dim_dark</item> + <item name="materialColorOnErrorContainer">@color/system_on_error_container_dark</item> + <item name="materialColorOnSecondaryFixed">@color/system_on_secondary_fixed_dark</item> + <item name="materialColorOnSurfaceInverse">@color/system_on_surface_dark</item> + <item name="materialColorTertiaryFixedDim">@color/system_tertiary_fixed_dim_dark</item> + <item name="materialColorOnTertiaryFixed">@color/system_on_tertiary_fixed_dark</item> + <item name="materialColorPrimaryFixedDim">@color/system_primary_fixed_dim_dark</item> + <item name="materialColorSecondaryContainer">@color/system_secondary_container_dark</item> + <item name="materialColorErrorContainer">@color/system_error_container_dark</item> + <item name="materialColorOnPrimaryFixed">@color/system_on_primary_fixed_dark</item> + <item name="materialColorPrimaryInverse">@color/system_primary_dark</item> + <item name="materialColorSecondaryFixed">@color/system_secondary_fixed_dark</item> + <item name="materialColorSurfaceInverse">@color/system_surface_dark</item> + <item name="materialColorSurfaceVariant">@color/system_surface_variant_dark</item> + <item name="materialColorTertiaryContainer">@color/system_tertiary_container_dark</item> + <item name="materialColorTertiaryFixed">@color/system_tertiary_fixed_dark</item> + <item name="materialColorPrimaryContainer">@color/system_primary_container_dark</item> + <item name="materialColorOnBackground">@color/system_on_background_dark</item> + <item name="materialColorPrimaryFixed">@color/system_primary_fixed_dark</item> + <item name="materialColorOnSecondary">@color/system_on_secondary_dark</item> + <item name="materialColorOnTertiary">@color/system_on_tertiary_dark</item> + <item name="materialColorSurfaceDim">@color/system_surface_dim_dark</item> + <item name="materialColorSurfaceBright">@color/system_surface_bright_dark</item> + <item name="materialColorSecondary">@color/system_secondary_dark</item> + <item name="materialColorOnError">@color/system_on_error_dark</item> + <item name="materialColorSurface">@color/system_surface_dark</item> + <item name="materialColorSurfaceContainerHigh">@color/system_surface_container_high_dark</item> + <item name="materialColorTertiary">@color/system_tertiary_dark</item> + <item name="materialColorSurfaceContainerHighest">@color/system_surface_container_highest_dark</item> + <item name="materialColorOnSurfaceVariant">@color/system_on_surface_variant_dark</item> + <item name="materialColorOutline">@color/system_outline_dark</item> + <item name="materialColorOnPrimary">@color/system_on_primary_dark</item> + <item name="materialColorOnSurface">@color/system_on_surface_dark</item> + <item name="materialColorSurfaceContainer">@color/system_surface_container_dark</item> + <item name="materialColorSurfaceContainer">@color/system_surface_container_dark</item> + </style> <!-- DeviceDefault theme for a window without an action bar that will be displayed either @@ -757,6 +1207,51 @@ easier. <!-- Toolbar attributes --> <item name="toolbarStyle">@style/Widget.DeviceDefault.Toolbar</item> + + <item name="materialColorOnSecondaryFixedVariant">@color/system_on_secondary_fixed_variant_dark</item> + <item name="materialColorOnTertiaryFixedVariant">@color/system_on_tertiary_fixed_variant_dark</item> + <item name="materialColorSurfaceContainerLowest">@color/system_surface_container_lowest_dark</item> + <item name="materialColorOnPrimaryFixedVariant">@color/system_on_primary_fixed_variant_dark</item> + <item name="materialColorOnSecondaryContainer">@color/system_on_secondary_container_dark</item> + <item name="materialColorOnTertiaryContainer">@color/system_on_tertiary_container_dark</item> + <item name="materialColorSurfaceContainerLow">@color/system_surface_container_low_dark</item> + <item name="materialColorOnPrimaryContainer">@color/system_on_primary_container_dark</item> + <item name="materialColorSecondaryFixedDim">@color/system_secondary_fixed_dim_dark</item> + <item name="materialColorOnErrorContainer">@color/system_on_error_container_dark</item> + <item name="materialColorOnSecondaryFixed">@color/system_on_secondary_fixed_dark</item> + <item name="materialColorOnSurfaceInverse">@color/system_on_surface_dark</item> + <item name="materialColorTertiaryFixedDim">@color/system_tertiary_fixed_dim_dark</item> + <item name="materialColorOnTertiaryFixed">@color/system_on_tertiary_fixed_dark</item> + <item name="materialColorPrimaryFixedDim">@color/system_primary_fixed_dim_dark</item> + <item name="materialColorSecondaryContainer">@color/system_secondary_container_dark</item> + <item name="materialColorErrorContainer">@color/system_error_container_dark</item> + <item name="materialColorOnPrimaryFixed">@color/system_on_primary_fixed_dark</item> + <item name="materialColorPrimaryInverse">@color/system_primary_dark</item> + <item name="materialColorSecondaryFixed">@color/system_secondary_fixed_dark</item> + <item name="materialColorSurfaceInverse">@color/system_surface_dark</item> + <item name="materialColorSurfaceVariant">@color/system_surface_variant_dark</item> + <item name="materialColorTertiaryContainer">@color/system_tertiary_container_dark</item> + <item name="materialColorTertiaryFixed">@color/system_tertiary_fixed_dark</item> + <item name="materialColorPrimaryContainer">@color/system_primary_container_dark</item> + <item name="materialColorOnBackground">@color/system_on_background_dark</item> + <item name="materialColorPrimaryFixed">@color/system_primary_fixed_dark</item> + <item name="materialColorOnSecondary">@color/system_on_secondary_dark</item> + <item name="materialColorOnTertiary">@color/system_on_tertiary_dark</item> + <item name="materialColorSurfaceDim">@color/system_surface_dim_dark</item> + <item name="materialColorSurfaceBright">@color/system_surface_bright_dark</item> + <item name="materialColorSecondary">@color/system_secondary_dark</item> + <item name="materialColorOnError">@color/system_on_error_dark</item> + <item name="materialColorSurface">@color/system_surface_dark</item> + <item name="materialColorSurfaceContainerHigh">@color/system_surface_container_high_dark</item> + <item name="materialColorTertiary">@color/system_tertiary_dark</item> + <item name="materialColorSurfaceContainerHighest">@color/system_surface_container_highest_dark</item> + <item name="materialColorOnSurfaceVariant">@color/system_on_surface_variant_dark</item> + <item name="materialColorOutline">@color/system_outline_dark</item> + <item name="materialColorOnPrimary">@color/system_on_primary_dark</item> + <item name="materialColorOnSurface">@color/system_on_surface_dark</item> + <item name="materialColorSurfaceContainer">@color/system_surface_container_dark</item> + <item name="materialColorSurfaceContainer">@color/system_surface_container_dark</item> + </style> <!-- DeviceDefault theme for a presentation window on a secondary display. --> @@ -805,6 +1300,51 @@ easier. <!-- Toolbar attributes --> <item name="toolbarStyle">@style/Widget.DeviceDefault.Toolbar</item> + + <item name="materialColorOnSecondaryFixedVariant">@color/system_on_secondary_fixed_variant_dark</item> + <item name="materialColorOnTertiaryFixedVariant">@color/system_on_tertiary_fixed_variant_dark</item> + <item name="materialColorSurfaceContainerLowest">@color/system_surface_container_lowest_dark</item> + <item name="materialColorOnPrimaryFixedVariant">@color/system_on_primary_fixed_variant_dark</item> + <item name="materialColorOnSecondaryContainer">@color/system_on_secondary_container_dark</item> + <item name="materialColorOnTertiaryContainer">@color/system_on_tertiary_container_dark</item> + <item name="materialColorSurfaceContainerLow">@color/system_surface_container_low_dark</item> + <item name="materialColorOnPrimaryContainer">@color/system_on_primary_container_dark</item> + <item name="materialColorSecondaryFixedDim">@color/system_secondary_fixed_dim_dark</item> + <item name="materialColorOnErrorContainer">@color/system_on_error_container_dark</item> + <item name="materialColorOnSecondaryFixed">@color/system_on_secondary_fixed_dark</item> + <item name="materialColorOnSurfaceInverse">@color/system_on_surface_dark</item> + <item name="materialColorTertiaryFixedDim">@color/system_tertiary_fixed_dim_dark</item> + <item name="materialColorOnTertiaryFixed">@color/system_on_tertiary_fixed_dark</item> + <item name="materialColorPrimaryFixedDim">@color/system_primary_fixed_dim_dark</item> + <item name="materialColorSecondaryContainer">@color/system_secondary_container_dark</item> + <item name="materialColorErrorContainer">@color/system_error_container_dark</item> + <item name="materialColorOnPrimaryFixed">@color/system_on_primary_fixed_dark</item> + <item name="materialColorPrimaryInverse">@color/system_primary_dark</item> + <item name="materialColorSecondaryFixed">@color/system_secondary_fixed_dark</item> + <item name="materialColorSurfaceInverse">@color/system_surface_dark</item> + <item name="materialColorSurfaceVariant">@color/system_surface_variant_dark</item> + <item name="materialColorTertiaryContainer">@color/system_tertiary_container_dark</item> + <item name="materialColorTertiaryFixed">@color/system_tertiary_fixed_dark</item> + <item name="materialColorPrimaryContainer">@color/system_primary_container_dark</item> + <item name="materialColorOnBackground">@color/system_on_background_dark</item> + <item name="materialColorPrimaryFixed">@color/system_primary_fixed_dark</item> + <item name="materialColorOnSecondary">@color/system_on_secondary_dark</item> + <item name="materialColorOnTertiary">@color/system_on_tertiary_dark</item> + <item name="materialColorSurfaceDim">@color/system_surface_dim_dark</item> + <item name="materialColorSurfaceBright">@color/system_surface_bright_dark</item> + <item name="materialColorSecondary">@color/system_secondary_dark</item> + <item name="materialColorOnError">@color/system_on_error_dark</item> + <item name="materialColorSurface">@color/system_surface_dark</item> + <item name="materialColorSurfaceContainerHigh">@color/system_surface_container_high_dark</item> + <item name="materialColorTertiary">@color/system_tertiary_dark</item> + <item name="materialColorSurfaceContainerHighest">@color/system_surface_container_highest_dark</item> + <item name="materialColorOnSurfaceVariant">@color/system_on_surface_variant_dark</item> + <item name="materialColorOutline">@color/system_outline_dark</item> + <item name="materialColorOnPrimary">@color/system_on_primary_dark</item> + <item name="materialColorOnSurface">@color/system_on_surface_dark</item> + <item name="materialColorSurfaceContainer">@color/system_surface_container_dark</item> + <item name="materialColorSurfaceContainer">@color/system_surface_container_dark</item> + </style> <!-- DeviceDefault theme for panel windows. This removes all extraneous window @@ -855,6 +1395,51 @@ easier. <!-- Toolbar attributes --> <item name="toolbarStyle">@style/Widget.DeviceDefault.Toolbar</item> + + <item name="materialColorOnSecondaryFixedVariant">@color/system_on_secondary_fixed_variant_dark</item> + <item name="materialColorOnTertiaryFixedVariant">@color/system_on_tertiary_fixed_variant_dark</item> + <item name="materialColorSurfaceContainerLowest">@color/system_surface_container_lowest_dark</item> + <item name="materialColorOnPrimaryFixedVariant">@color/system_on_primary_fixed_variant_dark</item> + <item name="materialColorOnSecondaryContainer">@color/system_on_secondary_container_dark</item> + <item name="materialColorOnTertiaryContainer">@color/system_on_tertiary_container_dark</item> + <item name="materialColorSurfaceContainerLow">@color/system_surface_container_low_dark</item> + <item name="materialColorOnPrimaryContainer">@color/system_on_primary_container_dark</item> + <item name="materialColorSecondaryFixedDim">@color/system_secondary_fixed_dim_dark</item> + <item name="materialColorOnErrorContainer">@color/system_on_error_container_dark</item> + <item name="materialColorOnSecondaryFixed">@color/system_on_secondary_fixed_dark</item> + <item name="materialColorOnSurfaceInverse">@color/system_on_surface_dark</item> + <item name="materialColorTertiaryFixedDim">@color/system_tertiary_fixed_dim_dark</item> + <item name="materialColorOnTertiaryFixed">@color/system_on_tertiary_fixed_dark</item> + <item name="materialColorPrimaryFixedDim">@color/system_primary_fixed_dim_dark</item> + <item name="materialColorSecondaryContainer">@color/system_secondary_container_dark</item> + <item name="materialColorErrorContainer">@color/system_error_container_dark</item> + <item name="materialColorOnPrimaryFixed">@color/system_on_primary_fixed_dark</item> + <item name="materialColorPrimaryInverse">@color/system_primary_dark</item> + <item name="materialColorSecondaryFixed">@color/system_secondary_fixed_dark</item> + <item name="materialColorSurfaceInverse">@color/system_surface_dark</item> + <item name="materialColorSurfaceVariant">@color/system_surface_variant_dark</item> + <item name="materialColorTertiaryContainer">@color/system_tertiary_container_dark</item> + <item name="materialColorTertiaryFixed">@color/system_tertiary_fixed_dark</item> + <item name="materialColorPrimaryContainer">@color/system_primary_container_dark</item> + <item name="materialColorOnBackground">@color/system_on_background_dark</item> + <item name="materialColorPrimaryFixed">@color/system_primary_fixed_dark</item> + <item name="materialColorOnSecondary">@color/system_on_secondary_dark</item> + <item name="materialColorOnTertiary">@color/system_on_tertiary_dark</item> + <item name="materialColorSurfaceDim">@color/system_surface_dim_dark</item> + <item name="materialColorSurfaceBright">@color/system_surface_bright_dark</item> + <item name="materialColorSecondary">@color/system_secondary_dark</item> + <item name="materialColorOnError">@color/system_on_error_dark</item> + <item name="materialColorSurface">@color/system_surface_dark</item> + <item name="materialColorSurfaceContainerHigh">@color/system_surface_container_high_dark</item> + <item name="materialColorTertiary">@color/system_tertiary_dark</item> + <item name="materialColorSurfaceContainerHighest">@color/system_surface_container_highest_dark</item> + <item name="materialColorOnSurfaceVariant">@color/system_on_surface_variant_dark</item> + <item name="materialColorOutline">@color/system_outline_dark</item> + <item name="materialColorOnPrimary">@color/system_on_primary_dark</item> + <item name="materialColorOnSurface">@color/system_on_surface_dark</item> + <item name="materialColorSurfaceContainer">@color/system_surface_container_dark</item> + <item name="materialColorSurfaceContainer">@color/system_surface_container_dark</item> + </style> <!-- DeviceDefault theme for windows that want to have the user's selected wallpaper appear @@ -904,6 +1489,51 @@ easier. <!-- Toolbar attributes --> <item name="toolbarStyle">@style/Widget.DeviceDefault.Toolbar</item> + + <item name="materialColorOnSecondaryFixedVariant">@color/system_on_secondary_fixed_variant_dark</item> + <item name="materialColorOnTertiaryFixedVariant">@color/system_on_tertiary_fixed_variant_dark</item> + <item name="materialColorSurfaceContainerLowest">@color/system_surface_container_lowest_dark</item> + <item name="materialColorOnPrimaryFixedVariant">@color/system_on_primary_fixed_variant_dark</item> + <item name="materialColorOnSecondaryContainer">@color/system_on_secondary_container_dark</item> + <item name="materialColorOnTertiaryContainer">@color/system_on_tertiary_container_dark</item> + <item name="materialColorSurfaceContainerLow">@color/system_surface_container_low_dark</item> + <item name="materialColorOnPrimaryContainer">@color/system_on_primary_container_dark</item> + <item name="materialColorSecondaryFixedDim">@color/system_secondary_fixed_dim_dark</item> + <item name="materialColorOnErrorContainer">@color/system_on_error_container_dark</item> + <item name="materialColorOnSecondaryFixed">@color/system_on_secondary_fixed_dark</item> + <item name="materialColorOnSurfaceInverse">@color/system_on_surface_dark</item> + <item name="materialColorTertiaryFixedDim">@color/system_tertiary_fixed_dim_dark</item> + <item name="materialColorOnTertiaryFixed">@color/system_on_tertiary_fixed_dark</item> + <item name="materialColorPrimaryFixedDim">@color/system_primary_fixed_dim_dark</item> + <item name="materialColorSecondaryContainer">@color/system_secondary_container_dark</item> + <item name="materialColorErrorContainer">@color/system_error_container_dark</item> + <item name="materialColorOnPrimaryFixed">@color/system_on_primary_fixed_dark</item> + <item name="materialColorPrimaryInverse">@color/system_primary_dark</item> + <item name="materialColorSecondaryFixed">@color/system_secondary_fixed_dark</item> + <item name="materialColorSurfaceInverse">@color/system_surface_dark</item> + <item name="materialColorSurfaceVariant">@color/system_surface_variant_dark</item> + <item name="materialColorTertiaryContainer">@color/system_tertiary_container_dark</item> + <item name="materialColorTertiaryFixed">@color/system_tertiary_fixed_dark</item> + <item name="materialColorPrimaryContainer">@color/system_primary_container_dark</item> + <item name="materialColorOnBackground">@color/system_on_background_dark</item> + <item name="materialColorPrimaryFixed">@color/system_primary_fixed_dark</item> + <item name="materialColorOnSecondary">@color/system_on_secondary_dark</item> + <item name="materialColorOnTertiary">@color/system_on_tertiary_dark</item> + <item name="materialColorSurfaceDim">@color/system_surface_dim_dark</item> + <item name="materialColorSurfaceBright">@color/system_surface_bright_dark</item> + <item name="materialColorSecondary">@color/system_secondary_dark</item> + <item name="materialColorOnError">@color/system_on_error_dark</item> + <item name="materialColorSurface">@color/system_surface_dark</item> + <item name="materialColorSurfaceContainerHigh">@color/system_surface_container_high_dark</item> + <item name="materialColorTertiary">@color/system_tertiary_dark</item> + <item name="materialColorSurfaceContainerHighest">@color/system_surface_container_highest_dark</item> + <item name="materialColorOnSurfaceVariant">@color/system_on_surface_variant_dark</item> + <item name="materialColorOutline">@color/system_outline_dark</item> + <item name="materialColorOnPrimary">@color/system_on_primary_dark</item> + <item name="materialColorOnSurface">@color/system_on_surface_dark</item> + <item name="materialColorSurfaceContainer">@color/system_surface_container_dark</item> + <item name="materialColorSurfaceContainer">@color/system_surface_container_dark</item> + </style> <!-- DeviceDefault theme for windows that want to have the user's selected wallpaper appear @@ -953,6 +1583,51 @@ easier. <!-- Toolbar attributes --> <item name="toolbarStyle">@style/Widget.DeviceDefault.Toolbar</item> + + <item name="materialColorOnSecondaryFixedVariant">@color/system_on_secondary_fixed_variant_dark</item> + <item name="materialColorOnTertiaryFixedVariant">@color/system_on_tertiary_fixed_variant_dark</item> + <item name="materialColorSurfaceContainerLowest">@color/system_surface_container_lowest_dark</item> + <item name="materialColorOnPrimaryFixedVariant">@color/system_on_primary_fixed_variant_dark</item> + <item name="materialColorOnSecondaryContainer">@color/system_on_secondary_container_dark</item> + <item name="materialColorOnTertiaryContainer">@color/system_on_tertiary_container_dark</item> + <item name="materialColorSurfaceContainerLow">@color/system_surface_container_low_dark</item> + <item name="materialColorOnPrimaryContainer">@color/system_on_primary_container_dark</item> + <item name="materialColorSecondaryFixedDim">@color/system_secondary_fixed_dim_dark</item> + <item name="materialColorOnErrorContainer">@color/system_on_error_container_dark</item> + <item name="materialColorOnSecondaryFixed">@color/system_on_secondary_fixed_dark</item> + <item name="materialColorOnSurfaceInverse">@color/system_on_surface_dark</item> + <item name="materialColorTertiaryFixedDim">@color/system_tertiary_fixed_dim_dark</item> + <item name="materialColorOnTertiaryFixed">@color/system_on_tertiary_fixed_dark</item> + <item name="materialColorPrimaryFixedDim">@color/system_primary_fixed_dim_dark</item> + <item name="materialColorSecondaryContainer">@color/system_secondary_container_dark</item> + <item name="materialColorErrorContainer">@color/system_error_container_dark</item> + <item name="materialColorOnPrimaryFixed">@color/system_on_primary_fixed_dark</item> + <item name="materialColorPrimaryInverse">@color/system_primary_dark</item> + <item name="materialColorSecondaryFixed">@color/system_secondary_fixed_dark</item> + <item name="materialColorSurfaceInverse">@color/system_surface_dark</item> + <item name="materialColorSurfaceVariant">@color/system_surface_variant_dark</item> + <item name="materialColorTertiaryContainer">@color/system_tertiary_container_dark</item> + <item name="materialColorTertiaryFixed">@color/system_tertiary_fixed_dark</item> + <item name="materialColorPrimaryContainer">@color/system_primary_container_dark</item> + <item name="materialColorOnBackground">@color/system_on_background_dark</item> + <item name="materialColorPrimaryFixed">@color/system_primary_fixed_dark</item> + <item name="materialColorOnSecondary">@color/system_on_secondary_dark</item> + <item name="materialColorOnTertiary">@color/system_on_tertiary_dark</item> + <item name="materialColorSurfaceDim">@color/system_surface_dim_dark</item> + <item name="materialColorSurfaceBright">@color/system_surface_bright_dark</item> + <item name="materialColorSecondary">@color/system_secondary_dark</item> + <item name="materialColorOnError">@color/system_on_error_dark</item> + <item name="materialColorSurface">@color/system_surface_dark</item> + <item name="materialColorSurfaceContainerHigh">@color/system_surface_container_high_dark</item> + <item name="materialColorTertiary">@color/system_tertiary_dark</item> + <item name="materialColorSurfaceContainerHighest">@color/system_surface_container_highest_dark</item> + <item name="materialColorOnSurfaceVariant">@color/system_on_surface_variant_dark</item> + <item name="materialColorOutline">@color/system_outline_dark</item> + <item name="materialColorOnPrimary">@color/system_on_primary_dark</item> + <item name="materialColorOnSurface">@color/system_on_surface_dark</item> + <item name="materialColorSurfaceContainer">@color/system_surface_container_dark</item> + <item name="materialColorSurfaceContainer">@color/system_surface_container_dark</item> + </style> <!-- DeviceDefault style for input methods, which is used by the @@ -1002,6 +1677,51 @@ easier. <!-- Toolbar attributes --> <item name="toolbarStyle">@style/Widget.DeviceDefault.Toolbar</item> + + <item name="materialColorOnSecondaryFixedVariant">@color/system_on_secondary_fixed_variant_dark</item> + <item name="materialColorOnTertiaryFixedVariant">@color/system_on_tertiary_fixed_variant_dark</item> + <item name="materialColorSurfaceContainerLowest">@color/system_surface_container_lowest_dark</item> + <item name="materialColorOnPrimaryFixedVariant">@color/system_on_primary_fixed_variant_dark</item> + <item name="materialColorOnSecondaryContainer">@color/system_on_secondary_container_dark</item> + <item name="materialColorOnTertiaryContainer">@color/system_on_tertiary_container_dark</item> + <item name="materialColorSurfaceContainerLow">@color/system_surface_container_low_dark</item> + <item name="materialColorOnPrimaryContainer">@color/system_on_primary_container_dark</item> + <item name="materialColorSecondaryFixedDim">@color/system_secondary_fixed_dim_dark</item> + <item name="materialColorOnErrorContainer">@color/system_on_error_container_dark</item> + <item name="materialColorOnSecondaryFixed">@color/system_on_secondary_fixed_dark</item> + <item name="materialColorOnSurfaceInverse">@color/system_on_surface_dark</item> + <item name="materialColorTertiaryFixedDim">@color/system_tertiary_fixed_dim_dark</item> + <item name="materialColorOnTertiaryFixed">@color/system_on_tertiary_fixed_dark</item> + <item name="materialColorPrimaryFixedDim">@color/system_primary_fixed_dim_dark</item> + <item name="materialColorSecondaryContainer">@color/system_secondary_container_dark</item> + <item name="materialColorErrorContainer">@color/system_error_container_dark</item> + <item name="materialColorOnPrimaryFixed">@color/system_on_primary_fixed_dark</item> + <item name="materialColorPrimaryInverse">@color/system_primary_dark</item> + <item name="materialColorSecondaryFixed">@color/system_secondary_fixed_dark</item> + <item name="materialColorSurfaceInverse">@color/system_surface_dark</item> + <item name="materialColorSurfaceVariant">@color/system_surface_variant_dark</item> + <item name="materialColorTertiaryContainer">@color/system_tertiary_container_dark</item> + <item name="materialColorTertiaryFixed">@color/system_tertiary_fixed_dark</item> + <item name="materialColorPrimaryContainer">@color/system_primary_container_dark</item> + <item name="materialColorOnBackground">@color/system_on_background_dark</item> + <item name="materialColorPrimaryFixed">@color/system_primary_fixed_dark</item> + <item name="materialColorOnSecondary">@color/system_on_secondary_dark</item> + <item name="materialColorOnTertiary">@color/system_on_tertiary_dark</item> + <item name="materialColorSurfaceDim">@color/system_surface_dim_dark</item> + <item name="materialColorSurfaceBright">@color/system_surface_bright_dark</item> + <item name="materialColorSecondary">@color/system_secondary_dark</item> + <item name="materialColorOnError">@color/system_on_error_dark</item> + <item name="materialColorSurface">@color/system_surface_dark</item> + <item name="materialColorSurfaceContainerHigh">@color/system_surface_container_high_dark</item> + <item name="materialColorTertiary">@color/system_tertiary_dark</item> + <item name="materialColorSurfaceContainerHighest">@color/system_surface_container_highest_dark</item> + <item name="materialColorOnSurfaceVariant">@color/system_on_surface_variant_dark</item> + <item name="materialColorOutline">@color/system_outline_dark</item> + <item name="materialColorOnPrimary">@color/system_on_primary_dark</item> + <item name="materialColorOnSurface">@color/system_on_surface_dark</item> + <item name="materialColorSurfaceContainer">@color/system_surface_container_dark</item> + <item name="materialColorSurfaceContainer">@color/system_surface_container_dark</item> + </style> <!-- DeviceDefault style for input methods, which is used by the @@ -1051,6 +1771,51 @@ easier. <!-- Toolbar attributes --> <item name="toolbarStyle">@style/Widget.DeviceDefault.Toolbar</item> + + <item name="materialColorOnSecondaryFixedVariant">@color/system_on_secondary_fixed_variant_dark</item> + <item name="materialColorOnTertiaryFixedVariant">@color/system_on_tertiary_fixed_variant_dark</item> + <item name="materialColorSurfaceContainerLowest">@color/system_surface_container_lowest_dark</item> + <item name="materialColorOnPrimaryFixedVariant">@color/system_on_primary_fixed_variant_dark</item> + <item name="materialColorOnSecondaryContainer">@color/system_on_secondary_container_dark</item> + <item name="materialColorOnTertiaryContainer">@color/system_on_tertiary_container_dark</item> + <item name="materialColorSurfaceContainerLow">@color/system_surface_container_low_dark</item> + <item name="materialColorOnPrimaryContainer">@color/system_on_primary_container_dark</item> + <item name="materialColorSecondaryFixedDim">@color/system_secondary_fixed_dim_dark</item> + <item name="materialColorOnErrorContainer">@color/system_on_error_container_dark</item> + <item name="materialColorOnSecondaryFixed">@color/system_on_secondary_fixed_dark</item> + <item name="materialColorOnSurfaceInverse">@color/system_on_surface_dark</item> + <item name="materialColorTertiaryFixedDim">@color/system_tertiary_fixed_dim_dark</item> + <item name="materialColorOnTertiaryFixed">@color/system_on_tertiary_fixed_dark</item> + <item name="materialColorPrimaryFixedDim">@color/system_primary_fixed_dim_dark</item> + <item name="materialColorSecondaryContainer">@color/system_secondary_container_dark</item> + <item name="materialColorErrorContainer">@color/system_error_container_dark</item> + <item name="materialColorOnPrimaryFixed">@color/system_on_primary_fixed_dark</item> + <item name="materialColorPrimaryInverse">@color/system_primary_dark</item> + <item name="materialColorSecondaryFixed">@color/system_secondary_fixed_dark</item> + <item name="materialColorSurfaceInverse">@color/system_surface_dark</item> + <item name="materialColorSurfaceVariant">@color/system_surface_variant_dark</item> + <item name="materialColorTertiaryContainer">@color/system_tertiary_container_dark</item> + <item name="materialColorTertiaryFixed">@color/system_tertiary_fixed_dark</item> + <item name="materialColorPrimaryContainer">@color/system_primary_container_dark</item> + <item name="materialColorOnBackground">@color/system_on_background_dark</item> + <item name="materialColorPrimaryFixed">@color/system_primary_fixed_dark</item> + <item name="materialColorOnSecondary">@color/system_on_secondary_dark</item> + <item name="materialColorOnTertiary">@color/system_on_tertiary_dark</item> + <item name="materialColorSurfaceDim">@color/system_surface_dim_dark</item> + <item name="materialColorSurfaceBright">@color/system_surface_bright_dark</item> + <item name="materialColorSecondary">@color/system_secondary_dark</item> + <item name="materialColorOnError">@color/system_on_error_dark</item> + <item name="materialColorSurface">@color/system_surface_dark</item> + <item name="materialColorSurfaceContainerHigh">@color/system_surface_container_high_dark</item> + <item name="materialColorTertiary">@color/system_tertiary_dark</item> + <item name="materialColorSurfaceContainerHighest">@color/system_surface_container_highest_dark</item> + <item name="materialColorOnSurfaceVariant">@color/system_on_surface_variant_dark</item> + <item name="materialColorOutline">@color/system_outline_dark</item> + <item name="materialColorOnPrimary">@color/system_on_primary_dark</item> + <item name="materialColorOnSurface">@color/system_on_surface_dark</item> + <item name="materialColorSurfaceContainer">@color/system_surface_container_dark</item> + <item name="materialColorSurfaceContainer">@color/system_surface_container_dark</item> + </style> <style name="Theme.DeviceDefault.Dialog.Alert" parent="Theme.Material.Dialog.Alert"> @@ -1100,6 +1865,51 @@ easier. <!-- Toolbar attributes --> <item name="toolbarStyle">@style/Widget.DeviceDefault.Toolbar</item> + + <item name="materialColorOnSecondaryFixedVariant">@color/system_on_secondary_fixed_variant_dark</item> + <item name="materialColorOnTertiaryFixedVariant">@color/system_on_tertiary_fixed_variant_dark</item> + <item name="materialColorSurfaceContainerLowest">@color/system_surface_container_lowest_dark</item> + <item name="materialColorOnPrimaryFixedVariant">@color/system_on_primary_fixed_variant_dark</item> + <item name="materialColorOnSecondaryContainer">@color/system_on_secondary_container_dark</item> + <item name="materialColorOnTertiaryContainer">@color/system_on_tertiary_container_dark</item> + <item name="materialColorSurfaceContainerLow">@color/system_surface_container_low_dark</item> + <item name="materialColorOnPrimaryContainer">@color/system_on_primary_container_dark</item> + <item name="materialColorSecondaryFixedDim">@color/system_secondary_fixed_dim_dark</item> + <item name="materialColorOnErrorContainer">@color/system_on_error_container_dark</item> + <item name="materialColorOnSecondaryFixed">@color/system_on_secondary_fixed_dark</item> + <item name="materialColorOnSurfaceInverse">@color/system_on_surface_dark</item> + <item name="materialColorTertiaryFixedDim">@color/system_tertiary_fixed_dim_dark</item> + <item name="materialColorOnTertiaryFixed">@color/system_on_tertiary_fixed_dark</item> + <item name="materialColorPrimaryFixedDim">@color/system_primary_fixed_dim_dark</item> + <item name="materialColorSecondaryContainer">@color/system_secondary_container_dark</item> + <item name="materialColorErrorContainer">@color/system_error_container_dark</item> + <item name="materialColorOnPrimaryFixed">@color/system_on_primary_fixed_dark</item> + <item name="materialColorPrimaryInverse">@color/system_primary_dark</item> + <item name="materialColorSecondaryFixed">@color/system_secondary_fixed_dark</item> + <item name="materialColorSurfaceInverse">@color/system_surface_dark</item> + <item name="materialColorSurfaceVariant">@color/system_surface_variant_dark</item> + <item name="materialColorTertiaryContainer">@color/system_tertiary_container_dark</item> + <item name="materialColorTertiaryFixed">@color/system_tertiary_fixed_dark</item> + <item name="materialColorPrimaryContainer">@color/system_primary_container_dark</item> + <item name="materialColorOnBackground">@color/system_on_background_dark</item> + <item name="materialColorPrimaryFixed">@color/system_primary_fixed_dark</item> + <item name="materialColorOnSecondary">@color/system_on_secondary_dark</item> + <item name="materialColorOnTertiary">@color/system_on_tertiary_dark</item> + <item name="materialColorSurfaceDim">@color/system_surface_dim_dark</item> + <item name="materialColorSurfaceBright">@color/system_surface_bright_dark</item> + <item name="materialColorSecondary">@color/system_secondary_dark</item> + <item name="materialColorOnError">@color/system_on_error_dark</item> + <item name="materialColorSurface">@color/system_surface_dark</item> + <item name="materialColorSurfaceContainerHigh">@color/system_surface_container_high_dark</item> + <item name="materialColorTertiary">@color/system_tertiary_dark</item> + <item name="materialColorSurfaceContainerHighest">@color/system_surface_container_highest_dark</item> + <item name="materialColorOnSurfaceVariant">@color/system_on_surface_variant_dark</item> + <item name="materialColorOutline">@color/system_outline_dark</item> + <item name="materialColorOnPrimary">@color/system_on_primary_dark</item> + <item name="materialColorOnSurface">@color/system_on_surface_dark</item> + <item name="materialColorSurfaceContainer">@color/system_surface_container_dark</item> + <item name="materialColorSurfaceContainer">@color/system_surface_container_dark</item> + </style> <!-- Theme for the dialog shown when an app crashes or ANRs. --> @@ -1154,6 +1964,51 @@ easier. <!-- Toolbar attributes --> <item name="toolbarStyle">@style/Widget.DeviceDefault.Toolbar</item> + + <item name="materialColorOnSecondaryFixedVariant">@color/system_on_secondary_fixed_variant_dark</item> + <item name="materialColorOnTertiaryFixedVariant">@color/system_on_tertiary_fixed_variant_dark</item> + <item name="materialColorSurfaceContainerLowest">@color/system_surface_container_lowest_dark</item> + <item name="materialColorOnPrimaryFixedVariant">@color/system_on_primary_fixed_variant_dark</item> + <item name="materialColorOnSecondaryContainer">@color/system_on_secondary_container_dark</item> + <item name="materialColorOnTertiaryContainer">@color/system_on_tertiary_container_dark</item> + <item name="materialColorSurfaceContainerLow">@color/system_surface_container_low_dark</item> + <item name="materialColorOnPrimaryContainer">@color/system_on_primary_container_dark</item> + <item name="materialColorSecondaryFixedDim">@color/system_secondary_fixed_dim_dark</item> + <item name="materialColorOnErrorContainer">@color/system_on_error_container_dark</item> + <item name="materialColorOnSecondaryFixed">@color/system_on_secondary_fixed_dark</item> + <item name="materialColorOnSurfaceInverse">@color/system_on_surface_dark</item> + <item name="materialColorTertiaryFixedDim">@color/system_tertiary_fixed_dim_dark</item> + <item name="materialColorOnTertiaryFixed">@color/system_on_tertiary_fixed_dark</item> + <item name="materialColorPrimaryFixedDim">@color/system_primary_fixed_dim_dark</item> + <item name="materialColorSecondaryContainer">@color/system_secondary_container_dark</item> + <item name="materialColorErrorContainer">@color/system_error_container_dark</item> + <item name="materialColorOnPrimaryFixed">@color/system_on_primary_fixed_dark</item> + <item name="materialColorPrimaryInverse">@color/system_primary_dark</item> + <item name="materialColorSecondaryFixed">@color/system_secondary_fixed_dark</item> + <item name="materialColorSurfaceInverse">@color/system_surface_dark</item> + <item name="materialColorSurfaceVariant">@color/system_surface_variant_dark</item> + <item name="materialColorTertiaryContainer">@color/system_tertiary_container_dark</item> + <item name="materialColorTertiaryFixed">@color/system_tertiary_fixed_dark</item> + <item name="materialColorPrimaryContainer">@color/system_primary_container_dark</item> + <item name="materialColorOnBackground">@color/system_on_background_dark</item> + <item name="materialColorPrimaryFixed">@color/system_primary_fixed_dark</item> + <item name="materialColorOnSecondary">@color/system_on_secondary_dark</item> + <item name="materialColorOnTertiary">@color/system_on_tertiary_dark</item> + <item name="materialColorSurfaceDim">@color/system_surface_dim_dark</item> + <item name="materialColorSurfaceBright">@color/system_surface_bright_dark</item> + <item name="materialColorSecondary">@color/system_secondary_dark</item> + <item name="materialColorOnError">@color/system_on_error_dark</item> + <item name="materialColorSurface">@color/system_surface_dark</item> + <item name="materialColorSurfaceContainerHigh">@color/system_surface_container_high_dark</item> + <item name="materialColorTertiary">@color/system_tertiary_dark</item> + <item name="materialColorSurfaceContainerHighest">@color/system_surface_container_highest_dark</item> + <item name="materialColorOnSurfaceVariant">@color/system_on_surface_variant_dark</item> + <item name="materialColorOutline">@color/system_outline_dark</item> + <item name="materialColorOnPrimary">@color/system_on_primary_dark</item> + <item name="materialColorOnSurface">@color/system_on_surface_dark</item> + <item name="materialColorSurfaceContainer">@color/system_surface_container_dark</item> + <item name="materialColorSurfaceContainer">@color/system_surface_container_dark</item> + </style> <style name="Theme.DeviceDefault.Dialog.NoFrame" parent="Theme.Material.Dialog.NoFrame"> @@ -1201,6 +2056,51 @@ easier. <!-- Toolbar attributes --> <item name="toolbarStyle">@style/Widget.DeviceDefault.Toolbar</item> + + <item name="materialColorOnSecondaryFixedVariant">@color/system_on_secondary_fixed_variant_dark</item> + <item name="materialColorOnTertiaryFixedVariant">@color/system_on_tertiary_fixed_variant_dark</item> + <item name="materialColorSurfaceContainerLowest">@color/system_surface_container_lowest_dark</item> + <item name="materialColorOnPrimaryFixedVariant">@color/system_on_primary_fixed_variant_dark</item> + <item name="materialColorOnSecondaryContainer">@color/system_on_secondary_container_dark</item> + <item name="materialColorOnTertiaryContainer">@color/system_on_tertiary_container_dark</item> + <item name="materialColorSurfaceContainerLow">@color/system_surface_container_low_dark</item> + <item name="materialColorOnPrimaryContainer">@color/system_on_primary_container_dark</item> + <item name="materialColorSecondaryFixedDim">@color/system_secondary_fixed_dim_dark</item> + <item name="materialColorOnErrorContainer">@color/system_on_error_container_dark</item> + <item name="materialColorOnSecondaryFixed">@color/system_on_secondary_fixed_dark</item> + <item name="materialColorOnSurfaceInverse">@color/system_on_surface_dark</item> + <item name="materialColorTertiaryFixedDim">@color/system_tertiary_fixed_dim_dark</item> + <item name="materialColorOnTertiaryFixed">@color/system_on_tertiary_fixed_dark</item> + <item name="materialColorPrimaryFixedDim">@color/system_primary_fixed_dim_dark</item> + <item name="materialColorSecondaryContainer">@color/system_secondary_container_dark</item> + <item name="materialColorErrorContainer">@color/system_error_container_dark</item> + <item name="materialColorOnPrimaryFixed">@color/system_on_primary_fixed_dark</item> + <item name="materialColorPrimaryInverse">@color/system_primary_dark</item> + <item name="materialColorSecondaryFixed">@color/system_secondary_fixed_dark</item> + <item name="materialColorSurfaceInverse">@color/system_surface_dark</item> + <item name="materialColorSurfaceVariant">@color/system_surface_variant_dark</item> + <item name="materialColorTertiaryContainer">@color/system_tertiary_container_dark</item> + <item name="materialColorTertiaryFixed">@color/system_tertiary_fixed_dark</item> + <item name="materialColorPrimaryContainer">@color/system_primary_container_dark</item> + <item name="materialColorOnBackground">@color/system_on_background_dark</item> + <item name="materialColorPrimaryFixed">@color/system_primary_fixed_dark</item> + <item name="materialColorOnSecondary">@color/system_on_secondary_dark</item> + <item name="materialColorOnTertiary">@color/system_on_tertiary_dark</item> + <item name="materialColorSurfaceDim">@color/system_surface_dim_dark</item> + <item name="materialColorSurfaceBright">@color/system_surface_bright_dark</item> + <item name="materialColorSecondary">@color/system_secondary_dark</item> + <item name="materialColorOnError">@color/system_on_error_dark</item> + <item name="materialColorSurface">@color/system_surface_dark</item> + <item name="materialColorSurfaceContainerHigh">@color/system_surface_container_high_dark</item> + <item name="materialColorTertiary">@color/system_tertiary_dark</item> + <item name="materialColorSurfaceContainerHighest">@color/system_surface_container_highest_dark</item> + <item name="materialColorOnSurfaceVariant">@color/system_on_surface_variant_dark</item> + <item name="materialColorOutline">@color/system_outline_dark</item> + <item name="materialColorOnPrimary">@color/system_on_primary_dark</item> + <item name="materialColorOnSurface">@color/system_on_surface_dark</item> + <item name="materialColorSurfaceContainer">@color/system_surface_container_dark</item> + <item name="materialColorSurfaceContainer">@color/system_surface_container_dark</item> + </style> <!-- Variant of {@link #Theme_DeviceDefault} with a light-colored style --> @@ -1386,6 +2286,51 @@ easier. <item name="colorForegroundInverse">@color/foreground_device_default_dark</item> <item name="colorPopupBackground">?attr/colorBackgroundFloating</item> <item name="panelColorBackground">?attr/colorBackgroundFloating</item> + + <item name="materialColorOnSecondaryFixedVariant">@color/system_on_secondary_fixed_variant_light</item> + <item name="materialColorOnTertiaryFixedVariant">@color/system_on_tertiary_fixed_variant_light</item> + <item name="materialColorSurfaceContainerLowest">@color/system_surface_container_lowest_light</item> + <item name="materialColorOnPrimaryFixedVariant">@color/system_on_primary_fixed_variant_light</item> + <item name="materialColorOnSecondaryContainer">@color/system_on_secondary_container_light</item> + <item name="materialColorOnTertiaryContainer">@color/system_on_tertiary_container_light</item> + <item name="materialColorSurfaceContainerLow">@color/system_surface_container_low_light</item> + <item name="materialColorOnPrimaryContainer">@color/system_on_primary_container_light</item> + <item name="materialColorSecondaryFixedDim">@color/system_secondary_fixed_dim_light</item> + <item name="materialColorOnErrorContainer">@color/system_on_error_container_light</item> + <item name="materialColorOnSecondaryFixed">@color/system_on_secondary_fixed_light</item> + <item name="materialColorOnSurfaceInverse">@color/system_on_surface_light</item> + <item name="materialColorTertiaryFixedDim">@color/system_tertiary_fixed_dim_light</item> + <item name="materialColorOnTertiaryFixed">@color/system_on_tertiary_fixed_light</item> + <item name="materialColorPrimaryFixedDim">@color/system_primary_fixed_dim_light</item> + <item name="materialColorSecondaryContainer">@color/system_secondary_container_light</item> + <item name="materialColorErrorContainer">@color/system_error_container_light</item> + <item name="materialColorOnPrimaryFixed">@color/system_on_primary_fixed_light</item> + <item name="materialColorPrimaryInverse">@color/system_primary_light</item> + <item name="materialColorSecondaryFixed">@color/system_secondary_fixed_light</item> + <item name="materialColorSurfaceInverse">@color/system_surface_light</item> + <item name="materialColorSurfaceVariant">@color/system_surface_variant_light</item> + <item name="materialColorTertiaryContainer">@color/system_tertiary_container_light</item> + <item name="materialColorTertiaryFixed">@color/system_tertiary_fixed_light</item> + <item name="materialColorPrimaryContainer">@color/system_primary_container_light</item> + <item name="materialColorOnBackground">@color/system_on_background_light</item> + <item name="materialColorPrimaryFixed">@color/system_primary_fixed_light</item> + <item name="materialColorOnSecondary">@color/system_on_secondary_light</item> + <item name="materialColorOnTertiary">@color/system_on_tertiary_light</item> + <item name="materialColorSurfaceDim">@color/system_surface_dim_light</item> + <item name="materialColorSurfaceBright">@color/system_surface_bright_light</item> + <item name="materialColorSecondary">@color/system_secondary_light</item> + <item name="materialColorOnError">@color/system_on_error_light</item> + <item name="materialColorSurface">@color/system_surface_light</item> + <item name="materialColorSurfaceContainerHigh">@color/system_surface_container_high_light</item> + <item name="materialColorTertiary">@color/system_tertiary_light</item> + <item name="materialColorSurfaceContainerHighest">@color/system_surface_container_highest_light</item> + <item name="materialColorOnSurfaceVariant">@color/system_on_surface_variant_light</item> + <item name="materialColorOutline">@color/system_outline_light</item> + <item name="materialColorOnPrimary">@color/system_on_primary_light</item> + <item name="materialColorOnSurface">@color/system_on_surface_light</item> + <item name="materialColorSurfaceContainer">@color/system_surface_container_light</item> + <item name="materialColorSurfaceContainer">@color/system_surface_container_light</item> + </style> <!-- Variant of the DeviceDefault (light) theme that has a solid (opaque) action bar with an @@ -1435,6 +2380,51 @@ easier. <!-- Toolbar attributes --> <item name="toolbarStyle">@style/Widget.DeviceDefault.Toolbar</item> + + <item name="materialColorOnSecondaryFixedVariant">@color/system_on_secondary_fixed_variant_light</item> + <item name="materialColorOnTertiaryFixedVariant">@color/system_on_tertiary_fixed_variant_light</item> + <item name="materialColorSurfaceContainerLowest">@color/system_surface_container_lowest_light</item> + <item name="materialColorOnPrimaryFixedVariant">@color/system_on_primary_fixed_variant_light</item> + <item name="materialColorOnSecondaryContainer">@color/system_on_secondary_container_light</item> + <item name="materialColorOnTertiaryContainer">@color/system_on_tertiary_container_light</item> + <item name="materialColorSurfaceContainerLow">@color/system_surface_container_low_light</item> + <item name="materialColorOnPrimaryContainer">@color/system_on_primary_container_light</item> + <item name="materialColorSecondaryFixedDim">@color/system_secondary_fixed_dim_light</item> + <item name="materialColorOnErrorContainer">@color/system_on_error_container_light</item> + <item name="materialColorOnSecondaryFixed">@color/system_on_secondary_fixed_light</item> + <item name="materialColorOnSurfaceInverse">@color/system_on_surface_light</item> + <item name="materialColorTertiaryFixedDim">@color/system_tertiary_fixed_dim_light</item> + <item name="materialColorOnTertiaryFixed">@color/system_on_tertiary_fixed_light</item> + <item name="materialColorPrimaryFixedDim">@color/system_primary_fixed_dim_light</item> + <item name="materialColorSecondaryContainer">@color/system_secondary_container_light</item> + <item name="materialColorErrorContainer">@color/system_error_container_light</item> + <item name="materialColorOnPrimaryFixed">@color/system_on_primary_fixed_light</item> + <item name="materialColorPrimaryInverse">@color/system_primary_light</item> + <item name="materialColorSecondaryFixed">@color/system_secondary_fixed_light</item> + <item name="materialColorSurfaceInverse">@color/system_surface_light</item> + <item name="materialColorSurfaceVariant">@color/system_surface_variant_light</item> + <item name="materialColorTertiaryContainer">@color/system_tertiary_container_light</item> + <item name="materialColorTertiaryFixed">@color/system_tertiary_fixed_light</item> + <item name="materialColorPrimaryContainer">@color/system_primary_container_light</item> + <item name="materialColorOnBackground">@color/system_on_background_light</item> + <item name="materialColorPrimaryFixed">@color/system_primary_fixed_light</item> + <item name="materialColorOnSecondary">@color/system_on_secondary_light</item> + <item name="materialColorOnTertiary">@color/system_on_tertiary_light</item> + <item name="materialColorSurfaceDim">@color/system_surface_dim_light</item> + <item name="materialColorSurfaceBright">@color/system_surface_bright_light</item> + <item name="materialColorSecondary">@color/system_secondary_light</item> + <item name="materialColorOnError">@color/system_on_error_light</item> + <item name="materialColorSurface">@color/system_surface_light</item> + <item name="materialColorSurfaceContainerHigh">@color/system_surface_container_high_light</item> + <item name="materialColorTertiary">@color/system_tertiary_light</item> + <item name="materialColorSurfaceContainerHighest">@color/system_surface_container_highest_light</item> + <item name="materialColorOnSurfaceVariant">@color/system_on_surface_variant_light</item> + <item name="materialColorOutline">@color/system_outline_light</item> + <item name="materialColorOnPrimary">@color/system_on_primary_light</item> + <item name="materialColorOnSurface">@color/system_on_surface_light</item> + <item name="materialColorSurfaceContainer">@color/system_surface_container_light</item> + <item name="materialColorSurfaceContainer">@color/system_surface_container_light</item> + </style> <!-- Variant of {@link #Theme_DeviceDefault_Light} with no action bar --> @@ -1483,6 +2473,51 @@ easier. <!-- Toolbar attributes --> <item name="toolbarStyle">@style/Widget.DeviceDefault.Toolbar</item> + + <item name="materialColorOnSecondaryFixedVariant">@color/system_on_secondary_fixed_variant_light</item> + <item name="materialColorOnTertiaryFixedVariant">@color/system_on_tertiary_fixed_variant_light</item> + <item name="materialColorSurfaceContainerLowest">@color/system_surface_container_lowest_light</item> + <item name="materialColorOnPrimaryFixedVariant">@color/system_on_primary_fixed_variant_light</item> + <item name="materialColorOnSecondaryContainer">@color/system_on_secondary_container_light</item> + <item name="materialColorOnTertiaryContainer">@color/system_on_tertiary_container_light</item> + <item name="materialColorSurfaceContainerLow">@color/system_surface_container_low_light</item> + <item name="materialColorOnPrimaryContainer">@color/system_on_primary_container_light</item> + <item name="materialColorSecondaryFixedDim">@color/system_secondary_fixed_dim_light</item> + <item name="materialColorOnErrorContainer">@color/system_on_error_container_light</item> + <item name="materialColorOnSecondaryFixed">@color/system_on_secondary_fixed_light</item> + <item name="materialColorOnSurfaceInverse">@color/system_on_surface_light</item> + <item name="materialColorTertiaryFixedDim">@color/system_tertiary_fixed_dim_light</item> + <item name="materialColorOnTertiaryFixed">@color/system_on_tertiary_fixed_light</item> + <item name="materialColorPrimaryFixedDim">@color/system_primary_fixed_dim_light</item> + <item name="materialColorSecondaryContainer">@color/system_secondary_container_light</item> + <item name="materialColorErrorContainer">@color/system_error_container_light</item> + <item name="materialColorOnPrimaryFixed">@color/system_on_primary_fixed_light</item> + <item name="materialColorPrimaryInverse">@color/system_primary_light</item> + <item name="materialColorSecondaryFixed">@color/system_secondary_fixed_light</item> + <item name="materialColorSurfaceInverse">@color/system_surface_light</item> + <item name="materialColorSurfaceVariant">@color/system_surface_variant_light</item> + <item name="materialColorTertiaryContainer">@color/system_tertiary_container_light</item> + <item name="materialColorTertiaryFixed">@color/system_tertiary_fixed_light</item> + <item name="materialColorPrimaryContainer">@color/system_primary_container_light</item> + <item name="materialColorOnBackground">@color/system_on_background_light</item> + <item name="materialColorPrimaryFixed">@color/system_primary_fixed_light</item> + <item name="materialColorOnSecondary">@color/system_on_secondary_light</item> + <item name="materialColorOnTertiary">@color/system_on_tertiary_light</item> + <item name="materialColorSurfaceDim">@color/system_surface_dim_light</item> + <item name="materialColorSurfaceBright">@color/system_surface_bright_light</item> + <item name="materialColorSecondary">@color/system_secondary_light</item> + <item name="materialColorOnError">@color/system_on_error_light</item> + <item name="materialColorSurface">@color/system_surface_light</item> + <item name="materialColorSurfaceContainerHigh">@color/system_surface_container_high_light</item> + <item name="materialColorTertiary">@color/system_tertiary_light</item> + <item name="materialColorSurfaceContainerHighest">@color/system_surface_container_highest_light</item> + <item name="materialColorOnSurfaceVariant">@color/system_on_surface_variant_light</item> + <item name="materialColorOutline">@color/system_outline_light</item> + <item name="materialColorOnPrimary">@color/system_on_primary_light</item> + <item name="materialColorOnSurface">@color/system_on_surface_light</item> + <item name="materialColorSurfaceContainer">@color/system_surface_container_light</item> + <item name="materialColorSurfaceContainer">@color/system_surface_container_light</item> + </style> <!-- Variant of {@link #Theme_DeviceDefault_Light} with no action bar and no status bar. @@ -1532,6 +2567,51 @@ easier. <!-- Toolbar attributes --> <item name="toolbarStyle">@style/Widget.DeviceDefault.Toolbar</item> + + <item name="materialColorOnSecondaryFixedVariant">@color/system_on_secondary_fixed_variant_light</item> + <item name="materialColorOnTertiaryFixedVariant">@color/system_on_tertiary_fixed_variant_light</item> + <item name="materialColorSurfaceContainerLowest">@color/system_surface_container_lowest_light</item> + <item name="materialColorOnPrimaryFixedVariant">@color/system_on_primary_fixed_variant_light</item> + <item name="materialColorOnSecondaryContainer">@color/system_on_secondary_container_light</item> + <item name="materialColorOnTertiaryContainer">@color/system_on_tertiary_container_light</item> + <item name="materialColorSurfaceContainerLow">@color/system_surface_container_low_light</item> + <item name="materialColorOnPrimaryContainer">@color/system_on_primary_container_light</item> + <item name="materialColorSecondaryFixedDim">@color/system_secondary_fixed_dim_light</item> + <item name="materialColorOnErrorContainer">@color/system_on_error_container_light</item> + <item name="materialColorOnSecondaryFixed">@color/system_on_secondary_fixed_light</item> + <item name="materialColorOnSurfaceInverse">@color/system_on_surface_light</item> + <item name="materialColorTertiaryFixedDim">@color/system_tertiary_fixed_dim_light</item> + <item name="materialColorOnTertiaryFixed">@color/system_on_tertiary_fixed_light</item> + <item name="materialColorPrimaryFixedDim">@color/system_primary_fixed_dim_light</item> + <item name="materialColorSecondaryContainer">@color/system_secondary_container_light</item> + <item name="materialColorErrorContainer">@color/system_error_container_light</item> + <item name="materialColorOnPrimaryFixed">@color/system_on_primary_fixed_light</item> + <item name="materialColorPrimaryInverse">@color/system_primary_light</item> + <item name="materialColorSecondaryFixed">@color/system_secondary_fixed_light</item> + <item name="materialColorSurfaceInverse">@color/system_surface_light</item> + <item name="materialColorSurfaceVariant">@color/system_surface_variant_light</item> + <item name="materialColorTertiaryContainer">@color/system_tertiary_container_light</item> + <item name="materialColorTertiaryFixed">@color/system_tertiary_fixed_light</item> + <item name="materialColorPrimaryContainer">@color/system_primary_container_light</item> + <item name="materialColorOnBackground">@color/system_on_background_light</item> + <item name="materialColorPrimaryFixed">@color/system_primary_fixed_light</item> + <item name="materialColorOnSecondary">@color/system_on_secondary_light</item> + <item name="materialColorOnTertiary">@color/system_on_tertiary_light</item> + <item name="materialColorSurfaceDim">@color/system_surface_dim_light</item> + <item name="materialColorSurfaceBright">@color/system_surface_bright_light</item> + <item name="materialColorSecondary">@color/system_secondary_light</item> + <item name="materialColorOnError">@color/system_on_error_light</item> + <item name="materialColorSurface">@color/system_surface_light</item> + <item name="materialColorSurfaceContainerHigh">@color/system_surface_container_high_light</item> + <item name="materialColorTertiary">@color/system_tertiary_light</item> + <item name="materialColorSurfaceContainerHighest">@color/system_surface_container_highest_light</item> + <item name="materialColorOnSurfaceVariant">@color/system_on_surface_variant_light</item> + <item name="materialColorOutline">@color/system_outline_light</item> + <item name="materialColorOnPrimary">@color/system_on_primary_light</item> + <item name="materialColorOnSurface">@color/system_on_surface_light</item> + <item name="materialColorSurfaceContainer">@color/system_surface_container_light</item> + <item name="materialColorSurfaceContainer">@color/system_surface_container_light</item> + </style> <!-- Variant of {@link #Theme_DeviceDefault_Light} with no action bar and no status bar @@ -1583,6 +2663,51 @@ easier. <!-- Toolbar attributes --> <item name="toolbarStyle">@style/Widget.DeviceDefault.Toolbar</item> + + <item name="materialColorOnSecondaryFixedVariant">@color/system_on_secondary_fixed_variant_light</item> + <item name="materialColorOnTertiaryFixedVariant">@color/system_on_tertiary_fixed_variant_light</item> + <item name="materialColorSurfaceContainerLowest">@color/system_surface_container_lowest_light</item> + <item name="materialColorOnPrimaryFixedVariant">@color/system_on_primary_fixed_variant_light</item> + <item name="materialColorOnSecondaryContainer">@color/system_on_secondary_container_light</item> + <item name="materialColorOnTertiaryContainer">@color/system_on_tertiary_container_light</item> + <item name="materialColorSurfaceContainerLow">@color/system_surface_container_low_light</item> + <item name="materialColorOnPrimaryContainer">@color/system_on_primary_container_light</item> + <item name="materialColorSecondaryFixedDim">@color/system_secondary_fixed_dim_light</item> + <item name="materialColorOnErrorContainer">@color/system_on_error_container_light</item> + <item name="materialColorOnSecondaryFixed">@color/system_on_secondary_fixed_light</item> + <item name="materialColorOnSurfaceInverse">@color/system_on_surface_light</item> + <item name="materialColorTertiaryFixedDim">@color/system_tertiary_fixed_dim_light</item> + <item name="materialColorOnTertiaryFixed">@color/system_on_tertiary_fixed_light</item> + <item name="materialColorPrimaryFixedDim">@color/system_primary_fixed_dim_light</item> + <item name="materialColorSecondaryContainer">@color/system_secondary_container_light</item> + <item name="materialColorErrorContainer">@color/system_error_container_light</item> + <item name="materialColorOnPrimaryFixed">@color/system_on_primary_fixed_light</item> + <item name="materialColorPrimaryInverse">@color/system_primary_light</item> + <item name="materialColorSecondaryFixed">@color/system_secondary_fixed_light</item> + <item name="materialColorSurfaceInverse">@color/system_surface_light</item> + <item name="materialColorSurfaceVariant">@color/system_surface_variant_light</item> + <item name="materialColorTertiaryContainer">@color/system_tertiary_container_light</item> + <item name="materialColorTertiaryFixed">@color/system_tertiary_fixed_light</item> + <item name="materialColorPrimaryContainer">@color/system_primary_container_light</item> + <item name="materialColorOnBackground">@color/system_on_background_light</item> + <item name="materialColorPrimaryFixed">@color/system_primary_fixed_light</item> + <item name="materialColorOnSecondary">@color/system_on_secondary_light</item> + <item name="materialColorOnTertiary">@color/system_on_tertiary_light</item> + <item name="materialColorSurfaceDim">@color/system_surface_dim_light</item> + <item name="materialColorSurfaceBright">@color/system_surface_bright_light</item> + <item name="materialColorSecondary">@color/system_secondary_light</item> + <item name="materialColorOnError">@color/system_on_error_light</item> + <item name="materialColorSurface">@color/system_surface_light</item> + <item name="materialColorSurfaceContainerHigh">@color/system_surface_container_high_light</item> + <item name="materialColorTertiary">@color/system_tertiary_light</item> + <item name="materialColorSurfaceContainerHighest">@color/system_surface_container_highest_light</item> + <item name="materialColorOnSurfaceVariant">@color/system_on_surface_variant_light</item> + <item name="materialColorOutline">@color/system_outline_light</item> + <item name="materialColorOnPrimary">@color/system_on_primary_light</item> + <item name="materialColorOnSurface">@color/system_on_surface_light</item> + <item name="materialColorSurfaceContainer">@color/system_surface_container_light</item> + <item name="materialColorSurfaceContainer">@color/system_surface_container_light</item> + </style> <!-- Variant of {@link #Theme_DeviceDefault_Light} that has no title bar and translucent @@ -1633,6 +2758,51 @@ easier. <!-- Toolbar attributes --> <item name="toolbarStyle">@style/Widget.DeviceDefault.Toolbar</item> + + <item name="materialColorOnSecondaryFixedVariant">@color/system_on_secondary_fixed_variant_light</item> + <item name="materialColorOnTertiaryFixedVariant">@color/system_on_tertiary_fixed_variant_light</item> + <item name="materialColorSurfaceContainerLowest">@color/system_surface_container_lowest_light</item> + <item name="materialColorOnPrimaryFixedVariant">@color/system_on_primary_fixed_variant_light</item> + <item name="materialColorOnSecondaryContainer">@color/system_on_secondary_container_light</item> + <item name="materialColorOnTertiaryContainer">@color/system_on_tertiary_container_light</item> + <item name="materialColorSurfaceContainerLow">@color/system_surface_container_low_light</item> + <item name="materialColorOnPrimaryContainer">@color/system_on_primary_container_light</item> + <item name="materialColorSecondaryFixedDim">@color/system_secondary_fixed_dim_light</item> + <item name="materialColorOnErrorContainer">@color/system_on_error_container_light</item> + <item name="materialColorOnSecondaryFixed">@color/system_on_secondary_fixed_light</item> + <item name="materialColorOnSurfaceInverse">@color/system_on_surface_light</item> + <item name="materialColorTertiaryFixedDim">@color/system_tertiary_fixed_dim_light</item> + <item name="materialColorOnTertiaryFixed">@color/system_on_tertiary_fixed_light</item> + <item name="materialColorPrimaryFixedDim">@color/system_primary_fixed_dim_light</item> + <item name="materialColorSecondaryContainer">@color/system_secondary_container_light</item> + <item name="materialColorErrorContainer">@color/system_error_container_light</item> + <item name="materialColorOnPrimaryFixed">@color/system_on_primary_fixed_light</item> + <item name="materialColorPrimaryInverse">@color/system_primary_light</item> + <item name="materialColorSecondaryFixed">@color/system_secondary_fixed_light</item> + <item name="materialColorSurfaceInverse">@color/system_surface_light</item> + <item name="materialColorSurfaceVariant">@color/system_surface_variant_light</item> + <item name="materialColorTertiaryContainer">@color/system_tertiary_container_light</item> + <item name="materialColorTertiaryFixed">@color/system_tertiary_fixed_light</item> + <item name="materialColorPrimaryContainer">@color/system_primary_container_light</item> + <item name="materialColorOnBackground">@color/system_on_background_light</item> + <item name="materialColorPrimaryFixed">@color/system_primary_fixed_light</item> + <item name="materialColorOnSecondary">@color/system_on_secondary_light</item> + <item name="materialColorOnTertiary">@color/system_on_tertiary_light</item> + <item name="materialColorSurfaceDim">@color/system_surface_dim_light</item> + <item name="materialColorSurfaceBright">@color/system_surface_bright_light</item> + <item name="materialColorSecondary">@color/system_secondary_light</item> + <item name="materialColorOnError">@color/system_on_error_light</item> + <item name="materialColorSurface">@color/system_surface_light</item> + <item name="materialColorSurfaceContainerHigh">@color/system_surface_container_high_light</item> + <item name="materialColorTertiary">@color/system_tertiary_light</item> + <item name="materialColorSurfaceContainerHighest">@color/system_surface_container_highest_light</item> + <item name="materialColorOnSurfaceVariant">@color/system_on_surface_variant_light</item> + <item name="materialColorOutline">@color/system_outline_light</item> + <item name="materialColorOnPrimary">@color/system_on_primary_light</item> + <item name="materialColorOnSurface">@color/system_on_surface_light</item> + <item name="materialColorSurfaceContainer">@color/system_surface_container_light</item> + <item name="materialColorSurfaceContainer">@color/system_surface_container_light</item> + </style> <!-- DeviceDefault light theme for dialog windows and activities. This changes the window to be @@ -1689,6 +2859,51 @@ easier. <!-- Toolbar attributes --> <item name="toolbarStyle">@style/Widget.DeviceDefault.Toolbar</item> + + <item name="materialColorOnSecondaryFixedVariant">@color/system_on_secondary_fixed_variant_light</item> + <item name="materialColorOnTertiaryFixedVariant">@color/system_on_tertiary_fixed_variant_light</item> + <item name="materialColorSurfaceContainerLowest">@color/system_surface_container_lowest_light</item> + <item name="materialColorOnPrimaryFixedVariant">@color/system_on_primary_fixed_variant_light</item> + <item name="materialColorOnSecondaryContainer">@color/system_on_secondary_container_light</item> + <item name="materialColorOnTertiaryContainer">@color/system_on_tertiary_container_light</item> + <item name="materialColorSurfaceContainerLow">@color/system_surface_container_low_light</item> + <item name="materialColorOnPrimaryContainer">@color/system_on_primary_container_light</item> + <item name="materialColorSecondaryFixedDim">@color/system_secondary_fixed_dim_light</item> + <item name="materialColorOnErrorContainer">@color/system_on_error_container_light</item> + <item name="materialColorOnSecondaryFixed">@color/system_on_secondary_fixed_light</item> + <item name="materialColorOnSurfaceInverse">@color/system_on_surface_light</item> + <item name="materialColorTertiaryFixedDim">@color/system_tertiary_fixed_dim_light</item> + <item name="materialColorOnTertiaryFixed">@color/system_on_tertiary_fixed_light</item> + <item name="materialColorPrimaryFixedDim">@color/system_primary_fixed_dim_light</item> + <item name="materialColorSecondaryContainer">@color/system_secondary_container_light</item> + <item name="materialColorErrorContainer">@color/system_error_container_light</item> + <item name="materialColorOnPrimaryFixed">@color/system_on_primary_fixed_light</item> + <item name="materialColorPrimaryInverse">@color/system_primary_light</item> + <item name="materialColorSecondaryFixed">@color/system_secondary_fixed_light</item> + <item name="materialColorSurfaceInverse">@color/system_surface_light</item> + <item name="materialColorSurfaceVariant">@color/system_surface_variant_light</item> + <item name="materialColorTertiaryContainer">@color/system_tertiary_container_light</item> + <item name="materialColorTertiaryFixed">@color/system_tertiary_fixed_light</item> + <item name="materialColorPrimaryContainer">@color/system_primary_container_light</item> + <item name="materialColorOnBackground">@color/system_on_background_light</item> + <item name="materialColorPrimaryFixed">@color/system_primary_fixed_light</item> + <item name="materialColorOnSecondary">@color/system_on_secondary_light</item> + <item name="materialColorOnTertiary">@color/system_on_tertiary_light</item> + <item name="materialColorSurfaceDim">@color/system_surface_dim_light</item> + <item name="materialColorSurfaceBright">@color/system_surface_bright_light</item> + <item name="materialColorSecondary">@color/system_secondary_light</item> + <item name="materialColorOnError">@color/system_on_error_light</item> + <item name="materialColorSurface">@color/system_surface_light</item> + <item name="materialColorSurfaceContainerHigh">@color/system_surface_container_high_light</item> + <item name="materialColorTertiary">@color/system_tertiary_light</item> + <item name="materialColorSurfaceContainerHighest">@color/system_surface_container_highest_light</item> + <item name="materialColorOnSurfaceVariant">@color/system_on_surface_variant_light</item> + <item name="materialColorOutline">@color/system_outline_light</item> + <item name="materialColorOnPrimary">@color/system_on_primary_light</item> + <item name="materialColorOnSurface">@color/system_on_surface_light</item> + <item name="materialColorSurfaceContainer">@color/system_surface_container_light</item> + <item name="materialColorSurfaceContainer">@color/system_surface_container_light</item> + </style> <!-- Variant of {@link #Theme_DeviceDefault_Light_Dialog} that has a nice minimum width for a @@ -1741,6 +2956,51 @@ easier. <!-- Toolbar attributes --> <item name="toolbarStyle">@style/Widget.DeviceDefault.Toolbar</item> + + <item name="materialColorOnSecondaryFixedVariant">@color/system_on_secondary_fixed_variant_light</item> + <item name="materialColorOnTertiaryFixedVariant">@color/system_on_tertiary_fixed_variant_light</item> + <item name="materialColorSurfaceContainerLowest">@color/system_surface_container_lowest_light</item> + <item name="materialColorOnPrimaryFixedVariant">@color/system_on_primary_fixed_variant_light</item> + <item name="materialColorOnSecondaryContainer">@color/system_on_secondary_container_light</item> + <item name="materialColorOnTertiaryContainer">@color/system_on_tertiary_container_light</item> + <item name="materialColorSurfaceContainerLow">@color/system_surface_container_low_light</item> + <item name="materialColorOnPrimaryContainer">@color/system_on_primary_container_light</item> + <item name="materialColorSecondaryFixedDim">@color/system_secondary_fixed_dim_light</item> + <item name="materialColorOnErrorContainer">@color/system_on_error_container_light</item> + <item name="materialColorOnSecondaryFixed">@color/system_on_secondary_fixed_light</item> + <item name="materialColorOnSurfaceInverse">@color/system_on_surface_light</item> + <item name="materialColorTertiaryFixedDim">@color/system_tertiary_fixed_dim_light</item> + <item name="materialColorOnTertiaryFixed">@color/system_on_tertiary_fixed_light</item> + <item name="materialColorPrimaryFixedDim">@color/system_primary_fixed_dim_light</item> + <item name="materialColorSecondaryContainer">@color/system_secondary_container_light</item> + <item name="materialColorErrorContainer">@color/system_error_container_light</item> + <item name="materialColorOnPrimaryFixed">@color/system_on_primary_fixed_light</item> + <item name="materialColorPrimaryInverse">@color/system_primary_light</item> + <item name="materialColorSecondaryFixed">@color/system_secondary_fixed_light</item> + <item name="materialColorSurfaceInverse">@color/system_surface_light</item> + <item name="materialColorSurfaceVariant">@color/system_surface_variant_light</item> + <item name="materialColorTertiaryContainer">@color/system_tertiary_container_light</item> + <item name="materialColorTertiaryFixed">@color/system_tertiary_fixed_light</item> + <item name="materialColorPrimaryContainer">@color/system_primary_container_light</item> + <item name="materialColorOnBackground">@color/system_on_background_light</item> + <item name="materialColorPrimaryFixed">@color/system_primary_fixed_light</item> + <item name="materialColorOnSecondary">@color/system_on_secondary_light</item> + <item name="materialColorOnTertiary">@color/system_on_tertiary_light</item> + <item name="materialColorSurfaceDim">@color/system_surface_dim_light</item> + <item name="materialColorSurfaceBright">@color/system_surface_bright_light</item> + <item name="materialColorSecondary">@color/system_secondary_light</item> + <item name="materialColorOnError">@color/system_on_error_light</item> + <item name="materialColorSurface">@color/system_surface_light</item> + <item name="materialColorSurfaceContainerHigh">@color/system_surface_container_high_light</item> + <item name="materialColorTertiary">@color/system_tertiary_light</item> + <item name="materialColorSurfaceContainerHighest">@color/system_surface_container_highest_light</item> + <item name="materialColorOnSurfaceVariant">@color/system_on_surface_variant_light</item> + <item name="materialColorOutline">@color/system_outline_light</item> + <item name="materialColorOnPrimary">@color/system_on_primary_light</item> + <item name="materialColorOnSurface">@color/system_on_surface_light</item> + <item name="materialColorSurfaceContainer">@color/system_surface_container_light</item> + <item name="materialColorSurfaceContainer">@color/system_surface_container_light</item> + </style> <!-- Variant of {@link #Theme_DeviceDefault_Light_Dialog} without an action bar --> @@ -1792,6 +3052,51 @@ easier. <!-- Toolbar attributes --> <item name="toolbarStyle">@style/Widget.DeviceDefault.Toolbar</item> + + <item name="materialColorOnSecondaryFixedVariant">@color/system_on_secondary_fixed_variant_light</item> + <item name="materialColorOnTertiaryFixedVariant">@color/system_on_tertiary_fixed_variant_light</item> + <item name="materialColorSurfaceContainerLowest">@color/system_surface_container_lowest_light</item> + <item name="materialColorOnPrimaryFixedVariant">@color/system_on_primary_fixed_variant_light</item> + <item name="materialColorOnSecondaryContainer">@color/system_on_secondary_container_light</item> + <item name="materialColorOnTertiaryContainer">@color/system_on_tertiary_container_light</item> + <item name="materialColorSurfaceContainerLow">@color/system_surface_container_low_light</item> + <item name="materialColorOnPrimaryContainer">@color/system_on_primary_container_light</item> + <item name="materialColorSecondaryFixedDim">@color/system_secondary_fixed_dim_light</item> + <item name="materialColorOnErrorContainer">@color/system_on_error_container_light</item> + <item name="materialColorOnSecondaryFixed">@color/system_on_secondary_fixed_light</item> + <item name="materialColorOnSurfaceInverse">@color/system_on_surface_light</item> + <item name="materialColorTertiaryFixedDim">@color/system_tertiary_fixed_dim_light</item> + <item name="materialColorOnTertiaryFixed">@color/system_on_tertiary_fixed_light</item> + <item name="materialColorPrimaryFixedDim">@color/system_primary_fixed_dim_light</item> + <item name="materialColorSecondaryContainer">@color/system_secondary_container_light</item> + <item name="materialColorErrorContainer">@color/system_error_container_light</item> + <item name="materialColorOnPrimaryFixed">@color/system_on_primary_fixed_light</item> + <item name="materialColorPrimaryInverse">@color/system_primary_light</item> + <item name="materialColorSecondaryFixed">@color/system_secondary_fixed_light</item> + <item name="materialColorSurfaceInverse">@color/system_surface_light</item> + <item name="materialColorSurfaceVariant">@color/system_surface_variant_light</item> + <item name="materialColorTertiaryContainer">@color/system_tertiary_container_light</item> + <item name="materialColorTertiaryFixed">@color/system_tertiary_fixed_light</item> + <item name="materialColorPrimaryContainer">@color/system_primary_container_light</item> + <item name="materialColorOnBackground">@color/system_on_background_light</item> + <item name="materialColorPrimaryFixed">@color/system_primary_fixed_light</item> + <item name="materialColorOnSecondary">@color/system_on_secondary_light</item> + <item name="materialColorOnTertiary">@color/system_on_tertiary_light</item> + <item name="materialColorSurfaceDim">@color/system_surface_dim_light</item> + <item name="materialColorSurfaceBright">@color/system_surface_bright_light</item> + <item name="materialColorSecondary">@color/system_secondary_light</item> + <item name="materialColorOnError">@color/system_on_error_light</item> + <item name="materialColorSurface">@color/system_surface_light</item> + <item name="materialColorSurfaceContainerHigh">@color/system_surface_container_high_light</item> + <item name="materialColorTertiary">@color/system_tertiary_light</item> + <item name="materialColorSurfaceContainerHighest">@color/system_surface_container_highest_light</item> + <item name="materialColorOnSurfaceVariant">@color/system_on_surface_variant_light</item> + <item name="materialColorOutline">@color/system_outline_light</item> + <item name="materialColorOnPrimary">@color/system_on_primary_light</item> + <item name="materialColorOnSurface">@color/system_on_surface_light</item> + <item name="materialColorSurfaceContainer">@color/system_surface_container_light</item> + <item name="materialColorSurfaceContainer">@color/system_surface_container_light</item> + </style> <!-- Variant of {@link #Theme_DeviceDefault_Light_Dialog_NoActionBar} that has a nice minimum @@ -1844,6 +3149,51 @@ easier. <!-- Toolbar attributes --> <item name="toolbarStyle">@style/Widget.DeviceDefault.Toolbar</item> + + <item name="materialColorOnSecondaryFixedVariant">@color/system_on_secondary_fixed_variant_light</item> + <item name="materialColorOnTertiaryFixedVariant">@color/system_on_tertiary_fixed_variant_light</item> + <item name="materialColorSurfaceContainerLowest">@color/system_surface_container_lowest_light</item> + <item name="materialColorOnPrimaryFixedVariant">@color/system_on_primary_fixed_variant_light</item> + <item name="materialColorOnSecondaryContainer">@color/system_on_secondary_container_light</item> + <item name="materialColorOnTertiaryContainer">@color/system_on_tertiary_container_light</item> + <item name="materialColorSurfaceContainerLow">@color/system_surface_container_low_light</item> + <item name="materialColorOnPrimaryContainer">@color/system_on_primary_container_light</item> + <item name="materialColorSecondaryFixedDim">@color/system_secondary_fixed_dim_light</item> + <item name="materialColorOnErrorContainer">@color/system_on_error_container_light</item> + <item name="materialColorOnSecondaryFixed">@color/system_on_secondary_fixed_light</item> + <item name="materialColorOnSurfaceInverse">@color/system_on_surface_light</item> + <item name="materialColorTertiaryFixedDim">@color/system_tertiary_fixed_dim_light</item> + <item name="materialColorOnTertiaryFixed">@color/system_on_tertiary_fixed_light</item> + <item name="materialColorPrimaryFixedDim">@color/system_primary_fixed_dim_light</item> + <item name="materialColorSecondaryContainer">@color/system_secondary_container_light</item> + <item name="materialColorErrorContainer">@color/system_error_container_light</item> + <item name="materialColorOnPrimaryFixed">@color/system_on_primary_fixed_light</item> + <item name="materialColorPrimaryInverse">@color/system_primary_light</item> + <item name="materialColorSecondaryFixed">@color/system_secondary_fixed_light</item> + <item name="materialColorSurfaceInverse">@color/system_surface_light</item> + <item name="materialColorSurfaceVariant">@color/system_surface_variant_light</item> + <item name="materialColorTertiaryContainer">@color/system_tertiary_container_light</item> + <item name="materialColorTertiaryFixed">@color/system_tertiary_fixed_light</item> + <item name="materialColorPrimaryContainer">@color/system_primary_container_light</item> + <item name="materialColorOnBackground">@color/system_on_background_light</item> + <item name="materialColorPrimaryFixed">@color/system_primary_fixed_light</item> + <item name="materialColorOnSecondary">@color/system_on_secondary_light</item> + <item name="materialColorOnTertiary">@color/system_on_tertiary_light</item> + <item name="materialColorSurfaceDim">@color/system_surface_dim_light</item> + <item name="materialColorSurfaceBright">@color/system_surface_bright_light</item> + <item name="materialColorSecondary">@color/system_secondary_light</item> + <item name="materialColorOnError">@color/system_on_error_light</item> + <item name="materialColorSurface">@color/system_surface_light</item> + <item name="materialColorSurfaceContainerHigh">@color/system_surface_container_high_light</item> + <item name="materialColorTertiary">@color/system_tertiary_light</item> + <item name="materialColorSurfaceContainerHighest">@color/system_surface_container_highest_light</item> + <item name="materialColorOnSurfaceVariant">@color/system_on_surface_variant_light</item> + <item name="materialColorOutline">@color/system_outline_light</item> + <item name="materialColorOnPrimary">@color/system_on_primary_light</item> + <item name="materialColorOnSurface">@color/system_on_surface_light</item> + <item name="materialColorSurfaceContainer">@color/system_surface_container_light</item> + <item name="materialColorSurfaceContainer">@color/system_surface_container_light</item> + </style> <!-- Variant of Theme.DeviceDefault.Dialog that has a fixed size. --> @@ -1877,6 +3227,51 @@ easier. <item name="textColorOnAccent">@color/text_color_on_accent_device_default</item> <item name="colorForeground">@color/foreground_device_default_light</item> <item name="colorForegroundInverse">@color/foreground_device_default_dark</item> + + <item name="materialColorOnSecondaryFixedVariant">@color/system_on_secondary_fixed_variant_light</item> + <item name="materialColorOnTertiaryFixedVariant">@color/system_on_tertiary_fixed_variant_light</item> + <item name="materialColorSurfaceContainerLowest">@color/system_surface_container_lowest_light</item> + <item name="materialColorOnPrimaryFixedVariant">@color/system_on_primary_fixed_variant_light</item> + <item name="materialColorOnSecondaryContainer">@color/system_on_secondary_container_light</item> + <item name="materialColorOnTertiaryContainer">@color/system_on_tertiary_container_light</item> + <item name="materialColorSurfaceContainerLow">@color/system_surface_container_low_light</item> + <item name="materialColorOnPrimaryContainer">@color/system_on_primary_container_light</item> + <item name="materialColorSecondaryFixedDim">@color/system_secondary_fixed_dim_light</item> + <item name="materialColorOnErrorContainer">@color/system_on_error_container_light</item> + <item name="materialColorOnSecondaryFixed">@color/system_on_secondary_fixed_light</item> + <item name="materialColorOnSurfaceInverse">@color/system_on_surface_light</item> + <item name="materialColorTertiaryFixedDim">@color/system_tertiary_fixed_dim_light</item> + <item name="materialColorOnTertiaryFixed">@color/system_on_tertiary_fixed_light</item> + <item name="materialColorPrimaryFixedDim">@color/system_primary_fixed_dim_light</item> + <item name="materialColorSecondaryContainer">@color/system_secondary_container_light</item> + <item name="materialColorErrorContainer">@color/system_error_container_light</item> + <item name="materialColorOnPrimaryFixed">@color/system_on_primary_fixed_light</item> + <item name="materialColorPrimaryInverse">@color/system_primary_light</item> + <item name="materialColorSecondaryFixed">@color/system_secondary_fixed_light</item> + <item name="materialColorSurfaceInverse">@color/system_surface_light</item> + <item name="materialColorSurfaceVariant">@color/system_surface_variant_light</item> + <item name="materialColorTertiaryContainer">@color/system_tertiary_container_light</item> + <item name="materialColorTertiaryFixed">@color/system_tertiary_fixed_light</item> + <item name="materialColorPrimaryContainer">@color/system_primary_container_light</item> + <item name="materialColorOnBackground">@color/system_on_background_light</item> + <item name="materialColorPrimaryFixed">@color/system_primary_fixed_light</item> + <item name="materialColorOnSecondary">@color/system_on_secondary_light</item> + <item name="materialColorOnTertiary">@color/system_on_tertiary_light</item> + <item name="materialColorSurfaceDim">@color/system_surface_dim_light</item> + <item name="materialColorSurfaceBright">@color/system_surface_bright_light</item> + <item name="materialColorSecondary">@color/system_secondary_light</item> + <item name="materialColorOnError">@color/system_on_error_light</item> + <item name="materialColorSurface">@color/system_surface_light</item> + <item name="materialColorSurfaceContainerHigh">@color/system_surface_container_high_light</item> + <item name="materialColorTertiary">@color/system_tertiary_light</item> + <item name="materialColorSurfaceContainerHighest">@color/system_surface_container_highest_light</item> + <item name="materialColorOnSurfaceVariant">@color/system_on_surface_variant_light</item> + <item name="materialColorOutline">@color/system_outline_light</item> + <item name="materialColorOnPrimary">@color/system_on_primary_light</item> + <item name="materialColorOnSurface">@color/system_on_surface_light</item> + <item name="materialColorSurfaceContainer">@color/system_surface_container_light</item> + <item name="materialColorSurfaceContainer">@color/system_surface_container_light</item> + </style> <!-- Variant of Theme.DeviceDefault.Dialog.NoActionBar that has a fixed size. --> @@ -1910,6 +3305,51 @@ easier. <item name="textColorOnAccent">@color/text_color_on_accent_device_default</item> <item name="colorForeground">@color/foreground_device_default_light</item> <item name="colorForegroundInverse">@color/foreground_device_default_dark</item> + + <item name="materialColorOnSecondaryFixedVariant">@color/system_on_secondary_fixed_variant_light</item> + <item name="materialColorOnTertiaryFixedVariant">@color/system_on_tertiary_fixed_variant_light</item> + <item name="materialColorSurfaceContainerLowest">@color/system_surface_container_lowest_light</item> + <item name="materialColorOnPrimaryFixedVariant">@color/system_on_primary_fixed_variant_light</item> + <item name="materialColorOnSecondaryContainer">@color/system_on_secondary_container_light</item> + <item name="materialColorOnTertiaryContainer">@color/system_on_tertiary_container_light</item> + <item name="materialColorSurfaceContainerLow">@color/system_surface_container_low_light</item> + <item name="materialColorOnPrimaryContainer">@color/system_on_primary_container_light</item> + <item name="materialColorSecondaryFixedDim">@color/system_secondary_fixed_dim_light</item> + <item name="materialColorOnErrorContainer">@color/system_on_error_container_light</item> + <item name="materialColorOnSecondaryFixed">@color/system_on_secondary_fixed_light</item> + <item name="materialColorOnSurfaceInverse">@color/system_on_surface_light</item> + <item name="materialColorTertiaryFixedDim">@color/system_tertiary_fixed_dim_light</item> + <item name="materialColorOnTertiaryFixed">@color/system_on_tertiary_fixed_light</item> + <item name="materialColorPrimaryFixedDim">@color/system_primary_fixed_dim_light</item> + <item name="materialColorSecondaryContainer">@color/system_secondary_container_light</item> + <item name="materialColorErrorContainer">@color/system_error_container_light</item> + <item name="materialColorOnPrimaryFixed">@color/system_on_primary_fixed_light</item> + <item name="materialColorPrimaryInverse">@color/system_primary_light</item> + <item name="materialColorSecondaryFixed">@color/system_secondary_fixed_light</item> + <item name="materialColorSurfaceInverse">@color/system_surface_light</item> + <item name="materialColorSurfaceVariant">@color/system_surface_variant_light</item> + <item name="materialColorTertiaryContainer">@color/system_tertiary_container_light</item> + <item name="materialColorTertiaryFixed">@color/system_tertiary_fixed_light</item> + <item name="materialColorPrimaryContainer">@color/system_primary_container_light</item> + <item name="materialColorOnBackground">@color/system_on_background_light</item> + <item name="materialColorPrimaryFixed">@color/system_primary_fixed_light</item> + <item name="materialColorOnSecondary">@color/system_on_secondary_light</item> + <item name="materialColorOnTertiary">@color/system_on_tertiary_light</item> + <item name="materialColorSurfaceDim">@color/system_surface_dim_light</item> + <item name="materialColorSurfaceBright">@color/system_surface_bright_light</item> + <item name="materialColorSecondary">@color/system_secondary_light</item> + <item name="materialColorOnError">@color/system_on_error_light</item> + <item name="materialColorSurface">@color/system_surface_light</item> + <item name="materialColorSurfaceContainerHigh">@color/system_surface_container_high_light</item> + <item name="materialColorTertiary">@color/system_tertiary_light</item> + <item name="materialColorSurfaceContainerHighest">@color/system_surface_container_highest_light</item> + <item name="materialColorOnSurfaceVariant">@color/system_on_surface_variant_light</item> + <item name="materialColorOutline">@color/system_outline_light</item> + <item name="materialColorOnPrimary">@color/system_on_primary_light</item> + <item name="materialColorOnSurface">@color/system_on_surface_light</item> + <item name="materialColorSurfaceContainer">@color/system_surface_container_light</item> + <item name="materialColorSurfaceContainer">@color/system_surface_container_light</item> + </style> <!-- DeviceDefault light theme for a window that will be displayed either full-screen on smaller @@ -1962,6 +3402,51 @@ easier. <!-- Toolbar attributes --> <item name="toolbarStyle">@style/Widget.DeviceDefault.Toolbar</item> + + <item name="materialColorOnSecondaryFixedVariant">@color/system_on_secondary_fixed_variant_light</item> + <item name="materialColorOnTertiaryFixedVariant">@color/system_on_tertiary_fixed_variant_light</item> + <item name="materialColorSurfaceContainerLowest">@color/system_surface_container_lowest_light</item> + <item name="materialColorOnPrimaryFixedVariant">@color/system_on_primary_fixed_variant_light</item> + <item name="materialColorOnSecondaryContainer">@color/system_on_secondary_container_light</item> + <item name="materialColorOnTertiaryContainer">@color/system_on_tertiary_container_light</item> + <item name="materialColorSurfaceContainerLow">@color/system_surface_container_low_light</item> + <item name="materialColorOnPrimaryContainer">@color/system_on_primary_container_light</item> + <item name="materialColorSecondaryFixedDim">@color/system_secondary_fixed_dim_light</item> + <item name="materialColorOnErrorContainer">@color/system_on_error_container_light</item> + <item name="materialColorOnSecondaryFixed">@color/system_on_secondary_fixed_light</item> + <item name="materialColorOnSurfaceInverse">@color/system_on_surface_light</item> + <item name="materialColorTertiaryFixedDim">@color/system_tertiary_fixed_dim_light</item> + <item name="materialColorOnTertiaryFixed">@color/system_on_tertiary_fixed_light</item> + <item name="materialColorPrimaryFixedDim">@color/system_primary_fixed_dim_light</item> + <item name="materialColorSecondaryContainer">@color/system_secondary_container_light</item> + <item name="materialColorErrorContainer">@color/system_error_container_light</item> + <item name="materialColorOnPrimaryFixed">@color/system_on_primary_fixed_light</item> + <item name="materialColorPrimaryInverse">@color/system_primary_light</item> + <item name="materialColorSecondaryFixed">@color/system_secondary_fixed_light</item> + <item name="materialColorSurfaceInverse">@color/system_surface_light</item> + <item name="materialColorSurfaceVariant">@color/system_surface_variant_light</item> + <item name="materialColorTertiaryContainer">@color/system_tertiary_container_light</item> + <item name="materialColorTertiaryFixed">@color/system_tertiary_fixed_light</item> + <item name="materialColorPrimaryContainer">@color/system_primary_container_light</item> + <item name="materialColorOnBackground">@color/system_on_background_light</item> + <item name="materialColorPrimaryFixed">@color/system_primary_fixed_light</item> + <item name="materialColorOnSecondary">@color/system_on_secondary_light</item> + <item name="materialColorOnTertiary">@color/system_on_tertiary_light</item> + <item name="materialColorSurfaceDim">@color/system_surface_dim_light</item> + <item name="materialColorSurfaceBright">@color/system_surface_bright_light</item> + <item name="materialColorSecondary">@color/system_secondary_light</item> + <item name="materialColorOnError">@color/system_on_error_light</item> + <item name="materialColorSurface">@color/system_surface_light</item> + <item name="materialColorSurfaceContainerHigh">@color/system_surface_container_high_light</item> + <item name="materialColorTertiary">@color/system_tertiary_light</item> + <item name="materialColorSurfaceContainerHighest">@color/system_surface_container_highest_light</item> + <item name="materialColorOnSurfaceVariant">@color/system_on_surface_variant_light</item> + <item name="materialColorOutline">@color/system_outline_light</item> + <item name="materialColorOnPrimary">@color/system_on_primary_light</item> + <item name="materialColorOnSurface">@color/system_on_surface_light</item> + <item name="materialColorSurfaceContainer">@color/system_surface_container_light</item> + <item name="materialColorSurfaceContainer">@color/system_surface_container_light</item> + </style> <!-- DeviceDefault light theme for a window without an action bar that will be displayed either @@ -2015,6 +3500,51 @@ easier. <!-- Toolbar attributes --> <item name="toolbarStyle">@style/Widget.DeviceDefault.Toolbar</item> + + <item name="materialColorOnSecondaryFixedVariant">@color/system_on_secondary_fixed_variant_light</item> + <item name="materialColorOnTertiaryFixedVariant">@color/system_on_tertiary_fixed_variant_light</item> + <item name="materialColorSurfaceContainerLowest">@color/system_surface_container_lowest_light</item> + <item name="materialColorOnPrimaryFixedVariant">@color/system_on_primary_fixed_variant_light</item> + <item name="materialColorOnSecondaryContainer">@color/system_on_secondary_container_light</item> + <item name="materialColorOnTertiaryContainer">@color/system_on_tertiary_container_light</item> + <item name="materialColorSurfaceContainerLow">@color/system_surface_container_low_light</item> + <item name="materialColorOnPrimaryContainer">@color/system_on_primary_container_light</item> + <item name="materialColorSecondaryFixedDim">@color/system_secondary_fixed_dim_light</item> + <item name="materialColorOnErrorContainer">@color/system_on_error_container_light</item> + <item name="materialColorOnSecondaryFixed">@color/system_on_secondary_fixed_light</item> + <item name="materialColorOnSurfaceInverse">@color/system_on_surface_light</item> + <item name="materialColorTertiaryFixedDim">@color/system_tertiary_fixed_dim_light</item> + <item name="materialColorOnTertiaryFixed">@color/system_on_tertiary_fixed_light</item> + <item name="materialColorPrimaryFixedDim">@color/system_primary_fixed_dim_light</item> + <item name="materialColorSecondaryContainer">@color/system_secondary_container_light</item> + <item name="materialColorErrorContainer">@color/system_error_container_light</item> + <item name="materialColorOnPrimaryFixed">@color/system_on_primary_fixed_light</item> + <item name="materialColorPrimaryInverse">@color/system_primary_light</item> + <item name="materialColorSecondaryFixed">@color/system_secondary_fixed_light</item> + <item name="materialColorSurfaceInverse">@color/system_surface_light</item> + <item name="materialColorSurfaceVariant">@color/system_surface_variant_light</item> + <item name="materialColorTertiaryContainer">@color/system_tertiary_container_light</item> + <item name="materialColorTertiaryFixed">@color/system_tertiary_fixed_light</item> + <item name="materialColorPrimaryContainer">@color/system_primary_container_light</item> + <item name="materialColorOnBackground">@color/system_on_background_light</item> + <item name="materialColorPrimaryFixed">@color/system_primary_fixed_light</item> + <item name="materialColorOnSecondary">@color/system_on_secondary_light</item> + <item name="materialColorOnTertiary">@color/system_on_tertiary_light</item> + <item name="materialColorSurfaceDim">@color/system_surface_dim_light</item> + <item name="materialColorSurfaceBright">@color/system_surface_bright_light</item> + <item name="materialColorSecondary">@color/system_secondary_light</item> + <item name="materialColorOnError">@color/system_on_error_light</item> + <item name="materialColorSurface">@color/system_surface_light</item> + <item name="materialColorSurfaceContainerHigh">@color/system_surface_container_high_light</item> + <item name="materialColorTertiary">@color/system_tertiary_light</item> + <item name="materialColorSurfaceContainerHighest">@color/system_surface_container_highest_light</item> + <item name="materialColorOnSurfaceVariant">@color/system_on_surface_variant_light</item> + <item name="materialColorOutline">@color/system_outline_light</item> + <item name="materialColorOnPrimary">@color/system_on_primary_light</item> + <item name="materialColorOnSurface">@color/system_on_surface_light</item> + <item name="materialColorSurfaceContainer">@color/system_surface_container_light</item> + <item name="materialColorSurfaceContainer">@color/system_surface_container_light</item> + </style> <!-- DeviceDefault light theme for a presentation window on a secondary display. --> @@ -2066,6 +3596,51 @@ easier. <!-- Toolbar attributes --> <item name="toolbarStyle">@style/Widget.DeviceDefault.Toolbar</item> + + <item name="materialColorOnSecondaryFixedVariant">@color/system_on_secondary_fixed_variant_light</item> + <item name="materialColorOnTertiaryFixedVariant">@color/system_on_tertiary_fixed_variant_light</item> + <item name="materialColorSurfaceContainerLowest">@color/system_surface_container_lowest_light</item> + <item name="materialColorOnPrimaryFixedVariant">@color/system_on_primary_fixed_variant_light</item> + <item name="materialColorOnSecondaryContainer">@color/system_on_secondary_container_light</item> + <item name="materialColorOnTertiaryContainer">@color/system_on_tertiary_container_light</item> + <item name="materialColorSurfaceContainerLow">@color/system_surface_container_low_light</item> + <item name="materialColorOnPrimaryContainer">@color/system_on_primary_container_light</item> + <item name="materialColorSecondaryFixedDim">@color/system_secondary_fixed_dim_light</item> + <item name="materialColorOnErrorContainer">@color/system_on_error_container_light</item> + <item name="materialColorOnSecondaryFixed">@color/system_on_secondary_fixed_light</item> + <item name="materialColorOnSurfaceInverse">@color/system_on_surface_light</item> + <item name="materialColorTertiaryFixedDim">@color/system_tertiary_fixed_dim_light</item> + <item name="materialColorOnTertiaryFixed">@color/system_on_tertiary_fixed_light</item> + <item name="materialColorPrimaryFixedDim">@color/system_primary_fixed_dim_light</item> + <item name="materialColorSecondaryContainer">@color/system_secondary_container_light</item> + <item name="materialColorErrorContainer">@color/system_error_container_light</item> + <item name="materialColorOnPrimaryFixed">@color/system_on_primary_fixed_light</item> + <item name="materialColorPrimaryInverse">@color/system_primary_light</item> + <item name="materialColorSecondaryFixed">@color/system_secondary_fixed_light</item> + <item name="materialColorSurfaceInverse">@color/system_surface_light</item> + <item name="materialColorSurfaceVariant">@color/system_surface_variant_light</item> + <item name="materialColorTertiaryContainer">@color/system_tertiary_container_light</item> + <item name="materialColorTertiaryFixed">@color/system_tertiary_fixed_light</item> + <item name="materialColorPrimaryContainer">@color/system_primary_container_light</item> + <item name="materialColorOnBackground">@color/system_on_background_light</item> + <item name="materialColorPrimaryFixed">@color/system_primary_fixed_light</item> + <item name="materialColorOnSecondary">@color/system_on_secondary_light</item> + <item name="materialColorOnTertiary">@color/system_on_tertiary_light</item> + <item name="materialColorSurfaceDim">@color/system_surface_dim_light</item> + <item name="materialColorSurfaceBright">@color/system_surface_bright_light</item> + <item name="materialColorSecondary">@color/system_secondary_light</item> + <item name="materialColorOnError">@color/system_on_error_light</item> + <item name="materialColorSurface">@color/system_surface_light</item> + <item name="materialColorSurfaceContainerHigh">@color/system_surface_container_high_light</item> + <item name="materialColorTertiary">@color/system_tertiary_light</item> + <item name="materialColorSurfaceContainerHighest">@color/system_surface_container_highest_light</item> + <item name="materialColorOnSurfaceVariant">@color/system_on_surface_variant_light</item> + <item name="materialColorOutline">@color/system_outline_light</item> + <item name="materialColorOnPrimary">@color/system_on_primary_light</item> + <item name="materialColorOnSurface">@color/system_on_surface_light</item> + <item name="materialColorSurfaceContainer">@color/system_surface_container_light</item> + <item name="materialColorSurfaceContainer">@color/system_surface_container_light</item> + </style> <!-- DeviceDefault light theme for panel windows. This removes all extraneous window @@ -2116,6 +3691,51 @@ easier. <!-- Toolbar attributes --> <item name="toolbarStyle">@style/Widget.DeviceDefault.Toolbar</item> + + <item name="materialColorOnSecondaryFixedVariant">@color/system_on_secondary_fixed_variant_light</item> + <item name="materialColorOnTertiaryFixedVariant">@color/system_on_tertiary_fixed_variant_light</item> + <item name="materialColorSurfaceContainerLowest">@color/system_surface_container_lowest_light</item> + <item name="materialColorOnPrimaryFixedVariant">@color/system_on_primary_fixed_variant_light</item> + <item name="materialColorOnSecondaryContainer">@color/system_on_secondary_container_light</item> + <item name="materialColorOnTertiaryContainer">@color/system_on_tertiary_container_light</item> + <item name="materialColorSurfaceContainerLow">@color/system_surface_container_low_light</item> + <item name="materialColorOnPrimaryContainer">@color/system_on_primary_container_light</item> + <item name="materialColorSecondaryFixedDim">@color/system_secondary_fixed_dim_light</item> + <item name="materialColorOnErrorContainer">@color/system_on_error_container_light</item> + <item name="materialColorOnSecondaryFixed">@color/system_on_secondary_fixed_light</item> + <item name="materialColorOnSurfaceInverse">@color/system_on_surface_light</item> + <item name="materialColorTertiaryFixedDim">@color/system_tertiary_fixed_dim_light</item> + <item name="materialColorOnTertiaryFixed">@color/system_on_tertiary_fixed_light</item> + <item name="materialColorPrimaryFixedDim">@color/system_primary_fixed_dim_light</item> + <item name="materialColorSecondaryContainer">@color/system_secondary_container_light</item> + <item name="materialColorErrorContainer">@color/system_error_container_light</item> + <item name="materialColorOnPrimaryFixed">@color/system_on_primary_fixed_light</item> + <item name="materialColorPrimaryInverse">@color/system_primary_light</item> + <item name="materialColorSecondaryFixed">@color/system_secondary_fixed_light</item> + <item name="materialColorSurfaceInverse">@color/system_surface_light</item> + <item name="materialColorSurfaceVariant">@color/system_surface_variant_light</item> + <item name="materialColorTertiaryContainer">@color/system_tertiary_container_light</item> + <item name="materialColorTertiaryFixed">@color/system_tertiary_fixed_light</item> + <item name="materialColorPrimaryContainer">@color/system_primary_container_light</item> + <item name="materialColorOnBackground">@color/system_on_background_light</item> + <item name="materialColorPrimaryFixed">@color/system_primary_fixed_light</item> + <item name="materialColorOnSecondary">@color/system_on_secondary_light</item> + <item name="materialColorOnTertiary">@color/system_on_tertiary_light</item> + <item name="materialColorSurfaceDim">@color/system_surface_dim_light</item> + <item name="materialColorSurfaceBright">@color/system_surface_bright_light</item> + <item name="materialColorSecondary">@color/system_secondary_light</item> + <item name="materialColorOnError">@color/system_on_error_light</item> + <item name="materialColorSurface">@color/system_surface_light</item> + <item name="materialColorSurfaceContainerHigh">@color/system_surface_container_high_light</item> + <item name="materialColorTertiary">@color/system_tertiary_light</item> + <item name="materialColorSurfaceContainerHighest">@color/system_surface_container_highest_light</item> + <item name="materialColorOnSurfaceVariant">@color/system_on_surface_variant_light</item> + <item name="materialColorOutline">@color/system_outline_light</item> + <item name="materialColorOnPrimary">@color/system_on_primary_light</item> + <item name="materialColorOnSurface">@color/system_on_surface_light</item> + <item name="materialColorSurfaceContainer">@color/system_surface_container_light</item> + <item name="materialColorSurfaceContainer">@color/system_surface_container_light</item> + </style> <style name="Theme.DeviceDefault.Light.Dialog.Alert" parent="Theme.Material.Light.Dialog.Alert"> @@ -2165,6 +3785,51 @@ easier. <!-- Toolbar attributes --> <item name="toolbarStyle">@style/Widget.DeviceDefault.Toolbar</item> + + <item name="materialColorOnSecondaryFixedVariant">@color/system_on_secondary_fixed_variant_light</item> + <item name="materialColorOnTertiaryFixedVariant">@color/system_on_tertiary_fixed_variant_light</item> + <item name="materialColorSurfaceContainerLowest">@color/system_surface_container_lowest_light</item> + <item name="materialColorOnPrimaryFixedVariant">@color/system_on_primary_fixed_variant_light</item> + <item name="materialColorOnSecondaryContainer">@color/system_on_secondary_container_light</item> + <item name="materialColorOnTertiaryContainer">@color/system_on_tertiary_container_light</item> + <item name="materialColorSurfaceContainerLow">@color/system_surface_container_low_light</item> + <item name="materialColorOnPrimaryContainer">@color/system_on_primary_container_light</item> + <item name="materialColorSecondaryFixedDim">@color/system_secondary_fixed_dim_light</item> + <item name="materialColorOnErrorContainer">@color/system_on_error_container_light</item> + <item name="materialColorOnSecondaryFixed">@color/system_on_secondary_fixed_light</item> + <item name="materialColorOnSurfaceInverse">@color/system_on_surface_light</item> + <item name="materialColorTertiaryFixedDim">@color/system_tertiary_fixed_dim_light</item> + <item name="materialColorOnTertiaryFixed">@color/system_on_tertiary_fixed_light</item> + <item name="materialColorPrimaryFixedDim">@color/system_primary_fixed_dim_light</item> + <item name="materialColorSecondaryContainer">@color/system_secondary_container_light</item> + <item name="materialColorErrorContainer">@color/system_error_container_light</item> + <item name="materialColorOnPrimaryFixed">@color/system_on_primary_fixed_light</item> + <item name="materialColorPrimaryInverse">@color/system_primary_light</item> + <item name="materialColorSecondaryFixed">@color/system_secondary_fixed_light</item> + <item name="materialColorSurfaceInverse">@color/system_surface_light</item> + <item name="materialColorSurfaceVariant">@color/system_surface_variant_light</item> + <item name="materialColorTertiaryContainer">@color/system_tertiary_container_light</item> + <item name="materialColorTertiaryFixed">@color/system_tertiary_fixed_light</item> + <item name="materialColorPrimaryContainer">@color/system_primary_container_light</item> + <item name="materialColorOnBackground">@color/system_on_background_light</item> + <item name="materialColorPrimaryFixed">@color/system_primary_fixed_light</item> + <item name="materialColorOnSecondary">@color/system_on_secondary_light</item> + <item name="materialColorOnTertiary">@color/system_on_tertiary_light</item> + <item name="materialColorSurfaceDim">@color/system_surface_dim_light</item> + <item name="materialColorSurfaceBright">@color/system_surface_bright_light</item> + <item name="materialColorSecondary">@color/system_secondary_light</item> + <item name="materialColorOnError">@color/system_on_error_light</item> + <item name="materialColorSurface">@color/system_surface_light</item> + <item name="materialColorSurfaceContainerHigh">@color/system_surface_container_high_light</item> + <item name="materialColorTertiary">@color/system_tertiary_light</item> + <item name="materialColorSurfaceContainerHighest">@color/system_surface_container_highest_light</item> + <item name="materialColorOnSurfaceVariant">@color/system_on_surface_variant_light</item> + <item name="materialColorOutline">@color/system_outline_light</item> + <item name="materialColorOnPrimary">@color/system_on_primary_light</item> + <item name="materialColorOnSurface">@color/system_on_surface_light</item> + <item name="materialColorSurfaceContainer">@color/system_surface_container_light</item> + <item name="materialColorSurfaceContainer">@color/system_surface_container_light</item> + </style> <style name="Theme.DeviceDefault.Dialog.Alert.DayNight" parent="Theme.DeviceDefault.Light.Dialog.Alert" /> @@ -2214,6 +3879,51 @@ easier. <!-- Toolbar attributes --> <item name="toolbarStyle">@style/Widget.DeviceDefault.Toolbar</item> + + <item name="materialColorOnSecondaryFixedVariant">@color/system_on_secondary_fixed_variant_light</item> + <item name="materialColorOnTertiaryFixedVariant">@color/system_on_tertiary_fixed_variant_light</item> + <item name="materialColorSurfaceContainerLowest">@color/system_surface_container_lowest_light</item> + <item name="materialColorOnPrimaryFixedVariant">@color/system_on_primary_fixed_variant_light</item> + <item name="materialColorOnSecondaryContainer">@color/system_on_secondary_container_light</item> + <item name="materialColorOnTertiaryContainer">@color/system_on_tertiary_container_light</item> + <item name="materialColorSurfaceContainerLow">@color/system_surface_container_low_light</item> + <item name="materialColorOnPrimaryContainer">@color/system_on_primary_container_light</item> + <item name="materialColorSecondaryFixedDim">@color/system_secondary_fixed_dim_light</item> + <item name="materialColorOnErrorContainer">@color/system_on_error_container_light</item> + <item name="materialColorOnSecondaryFixed">@color/system_on_secondary_fixed_light</item> + <item name="materialColorOnSurfaceInverse">@color/system_on_surface_light</item> + <item name="materialColorTertiaryFixedDim">@color/system_tertiary_fixed_dim_light</item> + <item name="materialColorOnTertiaryFixed">@color/system_on_tertiary_fixed_light</item> + <item name="materialColorPrimaryFixedDim">@color/system_primary_fixed_dim_light</item> + <item name="materialColorSecondaryContainer">@color/system_secondary_container_light</item> + <item name="materialColorErrorContainer">@color/system_error_container_light</item> + <item name="materialColorOnPrimaryFixed">@color/system_on_primary_fixed_light</item> + <item name="materialColorPrimaryInverse">@color/system_primary_light</item> + <item name="materialColorSecondaryFixed">@color/system_secondary_fixed_light</item> + <item name="materialColorSurfaceInverse">@color/system_surface_light</item> + <item name="materialColorSurfaceVariant">@color/system_surface_variant_light</item> + <item name="materialColorTertiaryContainer">@color/system_tertiary_container_light</item> + <item name="materialColorTertiaryFixed">@color/system_tertiary_fixed_light</item> + <item name="materialColorPrimaryContainer">@color/system_primary_container_light</item> + <item name="materialColorOnBackground">@color/system_on_background_light</item> + <item name="materialColorPrimaryFixed">@color/system_primary_fixed_light</item> + <item name="materialColorOnSecondary">@color/system_on_secondary_light</item> + <item name="materialColorOnTertiary">@color/system_on_tertiary_light</item> + <item name="materialColorSurfaceDim">@color/system_surface_dim_light</item> + <item name="materialColorSurfaceBright">@color/system_surface_bright_light</item> + <item name="materialColorSecondary">@color/system_secondary_light</item> + <item name="materialColorOnError">@color/system_on_error_light</item> + <item name="materialColorSurface">@color/system_surface_light</item> + <item name="materialColorSurfaceContainerHigh">@color/system_surface_container_high_light</item> + <item name="materialColorTertiary">@color/system_tertiary_light</item> + <item name="materialColorSurfaceContainerHighest">@color/system_surface_container_highest_light</item> + <item name="materialColorOnSurfaceVariant">@color/system_on_surface_variant_light</item> + <item name="materialColorOutline">@color/system_outline_light</item> + <item name="materialColorOnPrimary">@color/system_on_primary_light</item> + <item name="materialColorOnSurface">@color/system_on_surface_light</item> + <item name="materialColorSurfaceContainer">@color/system_surface_container_light</item> + <item name="materialColorSurfaceContainer">@color/system_surface_container_light</item> + </style> <style name="Theme.DeviceDefault.Light.Voice" parent="Theme.Material.Light.Voice"> @@ -2261,6 +3971,51 @@ easier. <!-- Toolbar attributes --> <item name="toolbarStyle">@style/Widget.DeviceDefault.Toolbar</item> + + <item name="materialColorOnSecondaryFixedVariant">@color/system_on_secondary_fixed_variant_light</item> + <item name="materialColorOnTertiaryFixedVariant">@color/system_on_tertiary_fixed_variant_light</item> + <item name="materialColorSurfaceContainerLowest">@color/system_surface_container_lowest_light</item> + <item name="materialColorOnPrimaryFixedVariant">@color/system_on_primary_fixed_variant_light</item> + <item name="materialColorOnSecondaryContainer">@color/system_on_secondary_container_light</item> + <item name="materialColorOnTertiaryContainer">@color/system_on_tertiary_container_light</item> + <item name="materialColorSurfaceContainerLow">@color/system_surface_container_low_light</item> + <item name="materialColorOnPrimaryContainer">@color/system_on_primary_container_light</item> + <item name="materialColorSecondaryFixedDim">@color/system_secondary_fixed_dim_light</item> + <item name="materialColorOnErrorContainer">@color/system_on_error_container_light</item> + <item name="materialColorOnSecondaryFixed">@color/system_on_secondary_fixed_light</item> + <item name="materialColorOnSurfaceInverse">@color/system_on_surface_light</item> + <item name="materialColorTertiaryFixedDim">@color/system_tertiary_fixed_dim_light</item> + <item name="materialColorOnTertiaryFixed">@color/system_on_tertiary_fixed_light</item> + <item name="materialColorPrimaryFixedDim">@color/system_primary_fixed_dim_light</item> + <item name="materialColorSecondaryContainer">@color/system_secondary_container_light</item> + <item name="materialColorErrorContainer">@color/system_error_container_light</item> + <item name="materialColorOnPrimaryFixed">@color/system_on_primary_fixed_light</item> + <item name="materialColorPrimaryInverse">@color/system_primary_light</item> + <item name="materialColorSecondaryFixed">@color/system_secondary_fixed_light</item> + <item name="materialColorSurfaceInverse">@color/system_surface_light</item> + <item name="materialColorSurfaceVariant">@color/system_surface_variant_light</item> + <item name="materialColorTertiaryContainer">@color/system_tertiary_container_light</item> + <item name="materialColorTertiaryFixed">@color/system_tertiary_fixed_light</item> + <item name="materialColorPrimaryContainer">@color/system_primary_container_light</item> + <item name="materialColorOnBackground">@color/system_on_background_light</item> + <item name="materialColorPrimaryFixed">@color/system_primary_fixed_light</item> + <item name="materialColorOnSecondary">@color/system_on_secondary_light</item> + <item name="materialColorOnTertiary">@color/system_on_tertiary_light</item> + <item name="materialColorSurfaceDim">@color/system_surface_dim_light</item> + <item name="materialColorSurfaceBright">@color/system_surface_bright_light</item> + <item name="materialColorSecondary">@color/system_secondary_light</item> + <item name="materialColorOnError">@color/system_on_error_light</item> + <item name="materialColorSurface">@color/system_surface_light</item> + <item name="materialColorSurfaceContainerHigh">@color/system_surface_container_high_light</item> + <item name="materialColorTertiary">@color/system_tertiary_light</item> + <item name="materialColorSurfaceContainerHighest">@color/system_surface_container_highest_light</item> + <item name="materialColorOnSurfaceVariant">@color/system_on_surface_variant_light</item> + <item name="materialColorOutline">@color/system_outline_light</item> + <item name="materialColorOnPrimary">@color/system_on_primary_light</item> + <item name="materialColorOnSurface">@color/system_on_surface_light</item> + <item name="materialColorSurfaceContainer">@color/system_surface_container_light</item> + <item name="materialColorSurfaceContainer">@color/system_surface_container_light</item> + </style> <!-- DeviceDefault theme for a window that should look like the Settings app. --> @@ -2315,6 +4070,51 @@ easier. <item name="colorListDivider">@color/list_divider_color_light</item> <item name="opacityListDivider">@color/list_divider_opacity_device_default_light</item> + + <item name="materialColorOnSecondaryFixedVariant">@color/system_on_secondary_fixed_variant_dark</item> + <item name="materialColorOnTertiaryFixedVariant">@color/system_on_tertiary_fixed_variant_dark</item> + <item name="materialColorSurfaceContainerLowest">@color/system_surface_container_lowest_dark</item> + <item name="materialColorOnPrimaryFixedVariant">@color/system_on_primary_fixed_variant_dark</item> + <item name="materialColorOnSecondaryContainer">@color/system_on_secondary_container_dark</item> + <item name="materialColorOnTertiaryContainer">@color/system_on_tertiary_container_dark</item> + <item name="materialColorSurfaceContainerLow">@color/system_surface_container_low_dark</item> + <item name="materialColorOnPrimaryContainer">@color/system_on_primary_container_dark</item> + <item name="materialColorSecondaryFixedDim">@color/system_secondary_fixed_dim_dark</item> + <item name="materialColorOnErrorContainer">@color/system_on_error_container_dark</item> + <item name="materialColorOnSecondaryFixed">@color/system_on_secondary_fixed_dark</item> + <item name="materialColorOnSurfaceInverse">@color/system_on_surface_dark</item> + <item name="materialColorTertiaryFixedDim">@color/system_tertiary_fixed_dim_dark</item> + <item name="materialColorOnTertiaryFixed">@color/system_on_tertiary_fixed_dark</item> + <item name="materialColorPrimaryFixedDim">@color/system_primary_fixed_dim_dark</item> + <item name="materialColorSecondaryContainer">@color/system_secondary_container_dark</item> + <item name="materialColorErrorContainer">@color/system_error_container_dark</item> + <item name="materialColorOnPrimaryFixed">@color/system_on_primary_fixed_dark</item> + <item name="materialColorPrimaryInverse">@color/system_primary_dark</item> + <item name="materialColorSecondaryFixed">@color/system_secondary_fixed_dark</item> + <item name="materialColorSurfaceInverse">@color/system_surface_dark</item> + <item name="materialColorSurfaceVariant">@color/system_surface_variant_dark</item> + <item name="materialColorTertiaryContainer">@color/system_tertiary_container_dark</item> + <item name="materialColorTertiaryFixed">@color/system_tertiary_fixed_dark</item> + <item name="materialColorPrimaryContainer">@color/system_primary_container_dark</item> + <item name="materialColorOnBackground">@color/system_on_background_dark</item> + <item name="materialColorPrimaryFixed">@color/system_primary_fixed_dark</item> + <item name="materialColorOnSecondary">@color/system_on_secondary_dark</item> + <item name="materialColorOnTertiary">@color/system_on_tertiary_dark</item> + <item name="materialColorSurfaceDim">@color/system_surface_dim_dark</item> + <item name="materialColorSurfaceBright">@color/system_surface_bright_dark</item> + <item name="materialColorSecondary">@color/system_secondary_dark</item> + <item name="materialColorOnError">@color/system_on_error_dark</item> + <item name="materialColorSurface">@color/system_surface_dark</item> + <item name="materialColorSurfaceContainerHigh">@color/system_surface_container_high_dark</item> + <item name="materialColorTertiary">@color/system_tertiary_dark</item> + <item name="materialColorSurfaceContainerHighest">@color/system_surface_container_highest_dark</item> + <item name="materialColorOnSurfaceVariant">@color/system_on_surface_variant_dark</item> + <item name="materialColorOutline">@color/system_outline_dark</item> + <item name="materialColorOnPrimary">@color/system_on_primary_dark</item> + <item name="materialColorOnSurface">@color/system_on_surface_dark</item> + <item name="materialColorSurfaceContainer">@color/system_surface_container_dark</item> + <item name="materialColorSurfaceContainer">@color/system_surface_container_dark</item> + </style> <style name="Theme.DeviceDefault.SystemUI" parent="Theme.DeviceDefault.Light"> @@ -2350,6 +4150,51 @@ easier. <!-- Toolbar attributes --> <item name="toolbarStyle">@style/Widget.DeviceDefault.Toolbar</item> + + <item name="materialColorOnSecondaryFixedVariant">@color/system_on_secondary_fixed_variant_dark</item> + <item name="materialColorOnTertiaryFixedVariant">@color/system_on_tertiary_fixed_variant_dark</item> + <item name="materialColorSurfaceContainerLowest">@color/system_surface_container_lowest_dark</item> + <item name="materialColorOnPrimaryFixedVariant">@color/system_on_primary_fixed_variant_dark</item> + <item name="materialColorOnSecondaryContainer">@color/system_on_secondary_container_dark</item> + <item name="materialColorOnTertiaryContainer">@color/system_on_tertiary_container_dark</item> + <item name="materialColorSurfaceContainerLow">@color/system_surface_container_low_dark</item> + <item name="materialColorOnPrimaryContainer">@color/system_on_primary_container_dark</item> + <item name="materialColorSecondaryFixedDim">@color/system_secondary_fixed_dim_dark</item> + <item name="materialColorOnErrorContainer">@color/system_on_error_container_dark</item> + <item name="materialColorOnSecondaryFixed">@color/system_on_secondary_fixed_dark</item> + <item name="materialColorOnSurfaceInverse">@color/system_on_surface_dark</item> + <item name="materialColorTertiaryFixedDim">@color/system_tertiary_fixed_dim_dark</item> + <item name="materialColorOnTertiaryFixed">@color/system_on_tertiary_fixed_dark</item> + <item name="materialColorPrimaryFixedDim">@color/system_primary_fixed_dim_dark</item> + <item name="materialColorSecondaryContainer">@color/system_secondary_container_dark</item> + <item name="materialColorErrorContainer">@color/system_error_container_dark</item> + <item name="materialColorOnPrimaryFixed">@color/system_on_primary_fixed_dark</item> + <item name="materialColorPrimaryInverse">@color/system_primary_dark</item> + <item name="materialColorSecondaryFixed">@color/system_secondary_fixed_dark</item> + <item name="materialColorSurfaceInverse">@color/system_surface_dark</item> + <item name="materialColorSurfaceVariant">@color/system_surface_variant_dark</item> + <item name="materialColorTertiaryContainer">@color/system_tertiary_container_dark</item> + <item name="materialColorTertiaryFixed">@color/system_tertiary_fixed_dark</item> + <item name="materialColorPrimaryContainer">@color/system_primary_container_dark</item> + <item name="materialColorOnBackground">@color/system_on_background_dark</item> + <item name="materialColorPrimaryFixed">@color/system_primary_fixed_dark</item> + <item name="materialColorOnSecondary">@color/system_on_secondary_dark</item> + <item name="materialColorOnTertiary">@color/system_on_tertiary_dark</item> + <item name="materialColorSurfaceDim">@color/system_surface_dim_dark</item> + <item name="materialColorSurfaceBright">@color/system_surface_bright_dark</item> + <item name="materialColorSecondary">@color/system_secondary_dark</item> + <item name="materialColorOnError">@color/system_on_error_dark</item> + <item name="materialColorSurface">@color/system_surface_dark</item> + <item name="materialColorSurfaceContainerHigh">@color/system_surface_container_high_dark</item> + <item name="materialColorTertiary">@color/system_tertiary_dark</item> + <item name="materialColorSurfaceContainerHighest">@color/system_surface_container_highest_dark</item> + <item name="materialColorOnSurfaceVariant">@color/system_on_surface_variant_dark</item> + <item name="materialColorOutline">@color/system_outline_dark</item> + <item name="materialColorOnPrimary">@color/system_on_primary_dark</item> + <item name="materialColorOnSurface">@color/system_on_surface_dark</item> + <item name="materialColorSurfaceContainer">@color/system_surface_container_dark</item> + <item name="materialColorSurfaceContainer">@color/system_surface_container_dark</item> + </style> <style name="Theme.DeviceDefault.SystemUI.Dialog" parent="Theme.DeviceDefault.Light.Dialog"> @@ -2377,6 +4222,51 @@ easier. <!-- Toolbar attributes --> <item name="toolbarStyle">@style/Widget.DeviceDefault.Toolbar</item> + + <item name="materialColorOnSecondaryFixedVariant">@color/system_on_secondary_fixed_variant_dark</item> + <item name="materialColorOnTertiaryFixedVariant">@color/system_on_tertiary_fixed_variant_dark</item> + <item name="materialColorSurfaceContainerLowest">@color/system_surface_container_lowest_dark</item> + <item name="materialColorOnPrimaryFixedVariant">@color/system_on_primary_fixed_variant_dark</item> + <item name="materialColorOnSecondaryContainer">@color/system_on_secondary_container_dark</item> + <item name="materialColorOnTertiaryContainer">@color/system_on_tertiary_container_dark</item> + <item name="materialColorSurfaceContainerLow">@color/system_surface_container_low_dark</item> + <item name="materialColorOnPrimaryContainer">@color/system_on_primary_container_dark</item> + <item name="materialColorSecondaryFixedDim">@color/system_secondary_fixed_dim_dark</item> + <item name="materialColorOnErrorContainer">@color/system_on_error_container_dark</item> + <item name="materialColorOnSecondaryFixed">@color/system_on_secondary_fixed_dark</item> + <item name="materialColorOnSurfaceInverse">@color/system_on_surface_dark</item> + <item name="materialColorTertiaryFixedDim">@color/system_tertiary_fixed_dim_dark</item> + <item name="materialColorOnTertiaryFixed">@color/system_on_tertiary_fixed_dark</item> + <item name="materialColorPrimaryFixedDim">@color/system_primary_fixed_dim_dark</item> + <item name="materialColorSecondaryContainer">@color/system_secondary_container_dark</item> + <item name="materialColorErrorContainer">@color/system_error_container_dark</item> + <item name="materialColorOnPrimaryFixed">@color/system_on_primary_fixed_dark</item> + <item name="materialColorPrimaryInverse">@color/system_primary_dark</item> + <item name="materialColorSecondaryFixed">@color/system_secondary_fixed_dark</item> + <item name="materialColorSurfaceInverse">@color/system_surface_dark</item> + <item name="materialColorSurfaceVariant">@color/system_surface_variant_dark</item> + <item name="materialColorTertiaryContainer">@color/system_tertiary_container_dark</item> + <item name="materialColorTertiaryFixed">@color/system_tertiary_fixed_dark</item> + <item name="materialColorPrimaryContainer">@color/system_primary_container_dark</item> + <item name="materialColorOnBackground">@color/system_on_background_dark</item> + <item name="materialColorPrimaryFixed">@color/system_primary_fixed_dark</item> + <item name="materialColorOnSecondary">@color/system_on_secondary_dark</item> + <item name="materialColorOnTertiary">@color/system_on_tertiary_dark</item> + <item name="materialColorSurfaceDim">@color/system_surface_dim_dark</item> + <item name="materialColorSurfaceBright">@color/system_surface_bright_dark</item> + <item name="materialColorSecondary">@color/system_secondary_dark</item> + <item name="materialColorOnError">@color/system_on_error_dark</item> + <item name="materialColorSurface">@color/system_surface_dark</item> + <item name="materialColorSurfaceContainerHigh">@color/system_surface_container_high_dark</item> + <item name="materialColorTertiary">@color/system_tertiary_dark</item> + <item name="materialColorSurfaceContainerHighest">@color/system_surface_container_highest_dark</item> + <item name="materialColorOnSurfaceVariant">@color/system_on_surface_variant_dark</item> + <item name="materialColorOutline">@color/system_outline_dark</item> + <item name="materialColorOnPrimary">@color/system_on_primary_dark</item> + <item name="materialColorOnSurface">@color/system_on_surface_dark</item> + <item name="materialColorSurfaceContainer">@color/system_surface_container_dark</item> + <item name="materialColorSurfaceContainer">@color/system_surface_container_dark</item> + </style> <!-- Variant of {@link #Theme_DeviceDefault_Settings_Dark} with no action bar --> @@ -2426,6 +4316,51 @@ easier. <!-- Toolbar attributes --> <item name="toolbarStyle">@style/Widget.DeviceDefault.Toolbar</item> + + <item name="materialColorOnSecondaryFixedVariant">@color/system_on_secondary_fixed_variant_dark</item> + <item name="materialColorOnTertiaryFixedVariant">@color/system_on_tertiary_fixed_variant_dark</item> + <item name="materialColorSurfaceContainerLowest">@color/system_surface_container_lowest_dark</item> + <item name="materialColorOnPrimaryFixedVariant">@color/system_on_primary_fixed_variant_dark</item> + <item name="materialColorOnSecondaryContainer">@color/system_on_secondary_container_dark</item> + <item name="materialColorOnTertiaryContainer">@color/system_on_tertiary_container_dark</item> + <item name="materialColorSurfaceContainerLow">@color/system_surface_container_low_dark</item> + <item name="materialColorOnPrimaryContainer">@color/system_on_primary_container_dark</item> + <item name="materialColorSecondaryFixedDim">@color/system_secondary_fixed_dim_dark</item> + <item name="materialColorOnErrorContainer">@color/system_on_error_container_dark</item> + <item name="materialColorOnSecondaryFixed">@color/system_on_secondary_fixed_dark</item> + <item name="materialColorOnSurfaceInverse">@color/system_on_surface_dark</item> + <item name="materialColorTertiaryFixedDim">@color/system_tertiary_fixed_dim_dark</item> + <item name="materialColorOnTertiaryFixed">@color/system_on_tertiary_fixed_dark</item> + <item name="materialColorPrimaryFixedDim">@color/system_primary_fixed_dim_dark</item> + <item name="materialColorSecondaryContainer">@color/system_secondary_container_dark</item> + <item name="materialColorErrorContainer">@color/system_error_container_dark</item> + <item name="materialColorOnPrimaryFixed">@color/system_on_primary_fixed_dark</item> + <item name="materialColorPrimaryInverse">@color/system_primary_dark</item> + <item name="materialColorSecondaryFixed">@color/system_secondary_fixed_dark</item> + <item name="materialColorSurfaceInverse">@color/system_surface_dark</item> + <item name="materialColorSurfaceVariant">@color/system_surface_variant_dark</item> + <item name="materialColorTertiaryContainer">@color/system_tertiary_container_dark</item> + <item name="materialColorTertiaryFixed">@color/system_tertiary_fixed_dark</item> + <item name="materialColorPrimaryContainer">@color/system_primary_container_dark</item> + <item name="materialColorOnBackground">@color/system_on_background_dark</item> + <item name="materialColorPrimaryFixed">@color/system_primary_fixed_dark</item> + <item name="materialColorOnSecondary">@color/system_on_secondary_dark</item> + <item name="materialColorOnTertiary">@color/system_on_tertiary_dark</item> + <item name="materialColorSurfaceDim">@color/system_surface_dim_dark</item> + <item name="materialColorSurfaceBright">@color/system_surface_bright_dark</item> + <item name="materialColorSecondary">@color/system_secondary_dark</item> + <item name="materialColorOnError">@color/system_on_error_dark</item> + <item name="materialColorSurface">@color/system_surface_dark</item> + <item name="materialColorSurfaceContainerHigh">@color/system_surface_container_high_dark</item> + <item name="materialColorTertiary">@color/system_tertiary_dark</item> + <item name="materialColorSurfaceContainerHighest">@color/system_surface_container_highest_dark</item> + <item name="materialColorOnSurfaceVariant">@color/system_on_surface_variant_dark</item> + <item name="materialColorOutline">@color/system_outline_dark</item> + <item name="materialColorOnPrimary">@color/system_on_primary_dark</item> + <item name="materialColorOnSurface">@color/system_on_surface_dark</item> + <item name="materialColorSurfaceContainer">@color/system_surface_container_dark</item> + <item name="materialColorSurfaceContainer">@color/system_surface_container_dark</item> + </style> <style name="Theme.DeviceDefault.Settings.DialogBase" parent="Theme.Material.Light.BaseDialog"> @@ -2459,6 +4394,51 @@ easier. <!-- Dialog attributes --> <item name="alertDialogTheme">@style/Theme.DeviceDefault.Light.Dialog.Alert</item> + + <item name="materialColorOnSecondaryFixedVariant">@color/system_on_secondary_fixed_variant_dark</item> + <item name="materialColorOnTertiaryFixedVariant">@color/system_on_tertiary_fixed_variant_dark</item> + <item name="materialColorSurfaceContainerLowest">@color/system_surface_container_lowest_dark</item> + <item name="materialColorOnPrimaryFixedVariant">@color/system_on_primary_fixed_variant_dark</item> + <item name="materialColorOnSecondaryContainer">@color/system_on_secondary_container_dark</item> + <item name="materialColorOnTertiaryContainer">@color/system_on_tertiary_container_dark</item> + <item name="materialColorSurfaceContainerLow">@color/system_surface_container_low_dark</item> + <item name="materialColorOnPrimaryContainer">@color/system_on_primary_container_dark</item> + <item name="materialColorSecondaryFixedDim">@color/system_secondary_fixed_dim_dark</item> + <item name="materialColorOnErrorContainer">@color/system_on_error_container_dark</item> + <item name="materialColorOnSecondaryFixed">@color/system_on_secondary_fixed_dark</item> + <item name="materialColorOnSurfaceInverse">@color/system_on_surface_dark</item> + <item name="materialColorTertiaryFixedDim">@color/system_tertiary_fixed_dim_dark</item> + <item name="materialColorOnTertiaryFixed">@color/system_on_tertiary_fixed_dark</item> + <item name="materialColorPrimaryFixedDim">@color/system_primary_fixed_dim_dark</item> + <item name="materialColorSecondaryContainer">@color/system_secondary_container_dark</item> + <item name="materialColorErrorContainer">@color/system_error_container_dark</item> + <item name="materialColorOnPrimaryFixed">@color/system_on_primary_fixed_dark</item> + <item name="materialColorPrimaryInverse">@color/system_primary_dark</item> + <item name="materialColorSecondaryFixed">@color/system_secondary_fixed_dark</item> + <item name="materialColorSurfaceInverse">@color/system_surface_dark</item> + <item name="materialColorSurfaceVariant">@color/system_surface_variant_dark</item> + <item name="materialColorTertiaryContainer">@color/system_tertiary_container_dark</item> + <item name="materialColorTertiaryFixed">@color/system_tertiary_fixed_dark</item> + <item name="materialColorPrimaryContainer">@color/system_primary_container_dark</item> + <item name="materialColorOnBackground">@color/system_on_background_dark</item> + <item name="materialColorPrimaryFixed">@color/system_primary_fixed_dark</item> + <item name="materialColorOnSecondary">@color/system_on_secondary_dark</item> + <item name="materialColorOnTertiary">@color/system_on_tertiary_dark</item> + <item name="materialColorSurfaceDim">@color/system_surface_dim_dark</item> + <item name="materialColorSurfaceBright">@color/system_surface_bright_dark</item> + <item name="materialColorSecondary">@color/system_secondary_dark</item> + <item name="materialColorOnError">@color/system_on_error_dark</item> + <item name="materialColorSurface">@color/system_surface_dark</item> + <item name="materialColorSurfaceContainerHigh">@color/system_surface_container_high_dark</item> + <item name="materialColorTertiary">@color/system_tertiary_dark</item> + <item name="materialColorSurfaceContainerHighest">@color/system_surface_container_highest_dark</item> + <item name="materialColorOnSurfaceVariant">@color/system_on_surface_variant_dark</item> + <item name="materialColorOutline">@color/system_outline_dark</item> + <item name="materialColorOnPrimary">@color/system_on_primary_dark</item> + <item name="materialColorOnSurface">@color/system_on_surface_dark</item> + <item name="materialColorSurfaceContainer">@color/system_surface_container_dark</item> + <item name="materialColorSurfaceContainer">@color/system_surface_container_dark</item> + </style> <style name="Theme.DeviceDefault.Settings.Dialog" parent="Theme.DeviceDefault.Settings.DialogBase"> @@ -2532,6 +4512,51 @@ easier. <!-- Toolbar attributes --> <item name="toolbarStyle">@style/Widget.DeviceDefault.Toolbar</item> + + <item name="materialColorOnSecondaryFixedVariant">@color/system_on_secondary_fixed_variant_dark</item> + <item name="materialColorOnTertiaryFixedVariant">@color/system_on_tertiary_fixed_variant_dark</item> + <item name="materialColorSurfaceContainerLowest">@color/system_surface_container_lowest_dark</item> + <item name="materialColorOnPrimaryFixedVariant">@color/system_on_primary_fixed_variant_dark</item> + <item name="materialColorOnSecondaryContainer">@color/system_on_secondary_container_dark</item> + <item name="materialColorOnTertiaryContainer">@color/system_on_tertiary_container_dark</item> + <item name="materialColorSurfaceContainerLow">@color/system_surface_container_low_dark</item> + <item name="materialColorOnPrimaryContainer">@color/system_on_primary_container_dark</item> + <item name="materialColorSecondaryFixedDim">@color/system_secondary_fixed_dim_dark</item> + <item name="materialColorOnErrorContainer">@color/system_on_error_container_dark</item> + <item name="materialColorOnSecondaryFixed">@color/system_on_secondary_fixed_dark</item> + <item name="materialColorOnSurfaceInverse">@color/system_on_surface_dark</item> + <item name="materialColorTertiaryFixedDim">@color/system_tertiary_fixed_dim_dark</item> + <item name="materialColorOnTertiaryFixed">@color/system_on_tertiary_fixed_dark</item> + <item name="materialColorPrimaryFixedDim">@color/system_primary_fixed_dim_dark</item> + <item name="materialColorSecondaryContainer">@color/system_secondary_container_dark</item> + <item name="materialColorErrorContainer">@color/system_error_container_dark</item> + <item name="materialColorOnPrimaryFixed">@color/system_on_primary_fixed_dark</item> + <item name="materialColorPrimaryInverse">@color/system_primary_dark</item> + <item name="materialColorSecondaryFixed">@color/system_secondary_fixed_dark</item> + <item name="materialColorSurfaceInverse">@color/system_surface_dark</item> + <item name="materialColorSurfaceVariant">@color/system_surface_variant_dark</item> + <item name="materialColorTertiaryContainer">@color/system_tertiary_container_dark</item> + <item name="materialColorTertiaryFixed">@color/system_tertiary_fixed_dark</item> + <item name="materialColorPrimaryContainer">@color/system_primary_container_dark</item> + <item name="materialColorOnBackground">@color/system_on_background_dark</item> + <item name="materialColorPrimaryFixed">@color/system_primary_fixed_dark</item> + <item name="materialColorOnSecondary">@color/system_on_secondary_dark</item> + <item name="materialColorOnTertiary">@color/system_on_tertiary_dark</item> + <item name="materialColorSurfaceDim">@color/system_surface_dim_dark</item> + <item name="materialColorSurfaceBright">@color/system_surface_bright_dark</item> + <item name="materialColorSecondary">@color/system_secondary_dark</item> + <item name="materialColorOnError">@color/system_on_error_dark</item> + <item name="materialColorSurface">@color/system_surface_dark</item> + <item name="materialColorSurfaceContainerHigh">@color/system_surface_container_high_dark</item> + <item name="materialColorTertiary">@color/system_tertiary_dark</item> + <item name="materialColorSurfaceContainerHighest">@color/system_surface_container_highest_dark</item> + <item name="materialColorOnSurfaceVariant">@color/system_on_surface_variant_dark</item> + <item name="materialColorOutline">@color/system_outline_dark</item> + <item name="materialColorOnPrimary">@color/system_on_primary_dark</item> + <item name="materialColorOnSurface">@color/system_on_surface_dark</item> + <item name="materialColorSurfaceContainer">@color/system_surface_container_dark</item> + <item name="materialColorSurfaceContainer">@color/system_surface_container_dark</item> + </style> <style name="Theme.DeviceDefault.Settings.Dialog.Alert" parent="Theme.Material.Settings.Dialog.Alert"> @@ -2583,6 +4608,51 @@ easier. <!-- Toolbar attributes --> <item name="toolbarStyle">@style/Widget.DeviceDefault.Toolbar</item> + + <item name="materialColorOnSecondaryFixedVariant">@color/system_on_secondary_fixed_variant_dark</item> + <item name="materialColorOnTertiaryFixedVariant">@color/system_on_tertiary_fixed_variant_dark</item> + <item name="materialColorSurfaceContainerLowest">@color/system_surface_container_lowest_dark</item> + <item name="materialColorOnPrimaryFixedVariant">@color/system_on_primary_fixed_variant_dark</item> + <item name="materialColorOnSecondaryContainer">@color/system_on_secondary_container_dark</item> + <item name="materialColorOnTertiaryContainer">@color/system_on_tertiary_container_dark</item> + <item name="materialColorSurfaceContainerLow">@color/system_surface_container_low_dark</item> + <item name="materialColorOnPrimaryContainer">@color/system_on_primary_container_dark</item> + <item name="materialColorSecondaryFixedDim">@color/system_secondary_fixed_dim_dark</item> + <item name="materialColorOnErrorContainer">@color/system_on_error_container_dark</item> + <item name="materialColorOnSecondaryFixed">@color/system_on_secondary_fixed_dark</item> + <item name="materialColorOnSurfaceInverse">@color/system_on_surface_dark</item> + <item name="materialColorTertiaryFixedDim">@color/system_tertiary_fixed_dim_dark</item> + <item name="materialColorOnTertiaryFixed">@color/system_on_tertiary_fixed_dark</item> + <item name="materialColorPrimaryFixedDim">@color/system_primary_fixed_dim_dark</item> + <item name="materialColorSecondaryContainer">@color/system_secondary_container_dark</item> + <item name="materialColorErrorContainer">@color/system_error_container_dark</item> + <item name="materialColorOnPrimaryFixed">@color/system_on_primary_fixed_dark</item> + <item name="materialColorPrimaryInverse">@color/system_primary_dark</item> + <item name="materialColorSecondaryFixed">@color/system_secondary_fixed_dark</item> + <item name="materialColorSurfaceInverse">@color/system_surface_dark</item> + <item name="materialColorSurfaceVariant">@color/system_surface_variant_dark</item> + <item name="materialColorTertiaryContainer">@color/system_tertiary_container_dark</item> + <item name="materialColorTertiaryFixed">@color/system_tertiary_fixed_dark</item> + <item name="materialColorPrimaryContainer">@color/system_primary_container_dark</item> + <item name="materialColorOnBackground">@color/system_on_background_dark</item> + <item name="materialColorPrimaryFixed">@color/system_primary_fixed_dark</item> + <item name="materialColorOnSecondary">@color/system_on_secondary_dark</item> + <item name="materialColorOnTertiary">@color/system_on_tertiary_dark</item> + <item name="materialColorSurfaceDim">@color/system_surface_dim_dark</item> + <item name="materialColorSurfaceBright">@color/system_surface_bright_dark</item> + <item name="materialColorSecondary">@color/system_secondary_dark</item> + <item name="materialColorOnError">@color/system_on_error_dark</item> + <item name="materialColorSurface">@color/system_surface_dark</item> + <item name="materialColorSurfaceContainerHigh">@color/system_surface_container_high_dark</item> + <item name="materialColorTertiary">@color/system_tertiary_dark</item> + <item name="materialColorSurfaceContainerHighest">@color/system_surface_container_highest_dark</item> + <item name="materialColorOnSurfaceVariant">@color/system_on_surface_variant_dark</item> + <item name="materialColorOutline">@color/system_outline_dark</item> + <item name="materialColorOnPrimary">@color/system_on_primary_dark</item> + <item name="materialColorOnSurface">@color/system_on_surface_dark</item> + <item name="materialColorSurfaceContainer">@color/system_surface_container_dark</item> + <item name="materialColorSurfaceContainer">@color/system_surface_container_dark</item> + </style> <style name="Theme.DeviceDefault.Settings.Dialog.NoActionBar" parent="Theme.DeviceDefault.Light.Dialog.NoActionBar" /> @@ -2660,6 +4730,51 @@ easier. <item name="colorAccentPrimary">@color/accent_primary_device_default</item> <item name="colorAccentSecondary">@color/accent_secondary_device_default</item> <item name="colorAccentTertiary">@color/accent_tertiary_device_default</item> + + <item name="materialColorOnSecondaryFixedVariant">@color/system_on_secondary_fixed_variant_dark</item> + <item name="materialColorOnTertiaryFixedVariant">@color/system_on_tertiary_fixed_variant_dark</item> + <item name="materialColorSurfaceContainerLowest">@color/system_surface_container_lowest_dark</item> + <item name="materialColorOnPrimaryFixedVariant">@color/system_on_primary_fixed_variant_dark</item> + <item name="materialColorOnSecondaryContainer">@color/system_on_secondary_container_dark</item> + <item name="materialColorOnTertiaryContainer">@color/system_on_tertiary_container_dark</item> + <item name="materialColorSurfaceContainerLow">@color/system_surface_container_low_dark</item> + <item name="materialColorOnPrimaryContainer">@color/system_on_primary_container_dark</item> + <item name="materialColorSecondaryFixedDim">@color/system_secondary_fixed_dim_dark</item> + <item name="materialColorOnErrorContainer">@color/system_on_error_container_dark</item> + <item name="materialColorOnSecondaryFixed">@color/system_on_secondary_fixed_dark</item> + <item name="materialColorOnSurfaceInverse">@color/system_on_surface_dark</item> + <item name="materialColorTertiaryFixedDim">@color/system_tertiary_fixed_dim_dark</item> + <item name="materialColorOnTertiaryFixed">@color/system_on_tertiary_fixed_dark</item> + <item name="materialColorPrimaryFixedDim">@color/system_primary_fixed_dim_dark</item> + <item name="materialColorSecondaryContainer">@color/system_secondary_container_dark</item> + <item name="materialColorErrorContainer">@color/system_error_container_dark</item> + <item name="materialColorOnPrimaryFixed">@color/system_on_primary_fixed_dark</item> + <item name="materialColorPrimaryInverse">@color/system_primary_dark</item> + <item name="materialColorSecondaryFixed">@color/system_secondary_fixed_dark</item> + <item name="materialColorSurfaceInverse">@color/system_surface_dark</item> + <item name="materialColorSurfaceVariant">@color/system_surface_variant_dark</item> + <item name="materialColorTertiaryContainer">@color/system_tertiary_container_dark</item> + <item name="materialColorTertiaryFixed">@color/system_tertiary_fixed_dark</item> + <item name="materialColorPrimaryContainer">@color/system_primary_container_dark</item> + <item name="materialColorOnBackground">@color/system_on_background_dark</item> + <item name="materialColorPrimaryFixed">@color/system_primary_fixed_dark</item> + <item name="materialColorOnSecondary">@color/system_on_secondary_dark</item> + <item name="materialColorOnTertiary">@color/system_on_tertiary_dark</item> + <item name="materialColorSurfaceDim">@color/system_surface_dim_dark</item> + <item name="materialColorSurfaceBright">@color/system_surface_bright_dark</item> + <item name="materialColorSecondary">@color/system_secondary_dark</item> + <item name="materialColorOnError">@color/system_on_error_dark</item> + <item name="materialColorSurface">@color/system_surface_dark</item> + <item name="materialColorSurfaceContainerHigh">@color/system_surface_container_high_dark</item> + <item name="materialColorTertiary">@color/system_tertiary_dark</item> + <item name="materialColorSurfaceContainerHighest">@color/system_surface_container_highest_dark</item> + <item name="materialColorOnSurfaceVariant">@color/system_on_surface_variant_dark</item> + <item name="materialColorOutline">@color/system_outline_dark</item> + <item name="materialColorOnPrimary">@color/system_on_primary_dark</item> + <item name="materialColorOnSurface">@color/system_on_surface_dark</item> + <item name="materialColorSurfaceContainer">@color/system_surface_container_dark</item> + <item name="materialColorSurfaceContainer">@color/system_surface_container_dark</item> + </style> <style name="ThemeOverlay.DeviceDefault.Accent.Light"> @@ -2667,6 +4782,51 @@ easier. <item name="colorAccentPrimary">@color/accent_primary_device_default</item> <item name="colorAccentSecondary">@color/accent_secondary_device_default</item> <item name="colorAccentTertiary">@color/accent_tertiary_device_default</item> + + <item name="materialColorOnSecondaryFixedVariant">@color/system_on_secondary_fixed_variant_light</item> + <item name="materialColorOnTertiaryFixedVariant">@color/system_on_tertiary_fixed_variant_light</item> + <item name="materialColorSurfaceContainerLowest">@color/system_surface_container_lowest_light</item> + <item name="materialColorOnPrimaryFixedVariant">@color/system_on_primary_fixed_variant_light</item> + <item name="materialColorOnSecondaryContainer">@color/system_on_secondary_container_light</item> + <item name="materialColorOnTertiaryContainer">@color/system_on_tertiary_container_light</item> + <item name="materialColorSurfaceContainerLow">@color/system_surface_container_low_light</item> + <item name="materialColorOnPrimaryContainer">@color/system_on_primary_container_light</item> + <item name="materialColorSecondaryFixedDim">@color/system_secondary_fixed_dim_light</item> + <item name="materialColorOnErrorContainer">@color/system_on_error_container_light</item> + <item name="materialColorOnSecondaryFixed">@color/system_on_secondary_fixed_light</item> + <item name="materialColorOnSurfaceInverse">@color/system_on_surface_light</item> + <item name="materialColorTertiaryFixedDim">@color/system_tertiary_fixed_dim_light</item> + <item name="materialColorOnTertiaryFixed">@color/system_on_tertiary_fixed_light</item> + <item name="materialColorPrimaryFixedDim">@color/system_primary_fixed_dim_light</item> + <item name="materialColorSecondaryContainer">@color/system_secondary_container_light</item> + <item name="materialColorErrorContainer">@color/system_error_container_light</item> + <item name="materialColorOnPrimaryFixed">@color/system_on_primary_fixed_light</item> + <item name="materialColorPrimaryInverse">@color/system_primary_light</item> + <item name="materialColorSecondaryFixed">@color/system_secondary_fixed_light</item> + <item name="materialColorSurfaceInverse">@color/system_surface_light</item> + <item name="materialColorSurfaceVariant">@color/system_surface_variant_light</item> + <item name="materialColorTertiaryContainer">@color/system_tertiary_container_light</item> + <item name="materialColorTertiaryFixed">@color/system_tertiary_fixed_light</item> + <item name="materialColorPrimaryContainer">@color/system_primary_container_light</item> + <item name="materialColorOnBackground">@color/system_on_background_light</item> + <item name="materialColorPrimaryFixed">@color/system_primary_fixed_light</item> + <item name="materialColorOnSecondary">@color/system_on_secondary_light</item> + <item name="materialColorOnTertiary">@color/system_on_tertiary_light</item> + <item name="materialColorSurfaceDim">@color/system_surface_dim_light</item> + <item name="materialColorSurfaceBright">@color/system_surface_bright_light</item> + <item name="materialColorSecondary">@color/system_secondary_light</item> + <item name="materialColorOnError">@color/system_on_error_light</item> + <item name="materialColorSurface">@color/system_surface_light</item> + <item name="materialColorSurfaceContainerHigh">@color/system_surface_container_high_light</item> + <item name="materialColorTertiary">@color/system_tertiary_light</item> + <item name="materialColorSurfaceContainerHighest">@color/system_surface_container_highest_light</item> + <item name="materialColorOnSurfaceVariant">@color/system_on_surface_variant_light</item> + <item name="materialColorOutline">@color/system_outline_light</item> + <item name="materialColorOnPrimary">@color/system_on_primary_light</item> + <item name="materialColorOnSurface">@color/system_on_surface_light</item> + <item name="materialColorSurfaceContainer">@color/system_surface_container_light</item> + <item name="materialColorSurfaceContainer">@color/system_surface_container_light</item> + </style> <!-- Theme overlay that replaces colorAccent with the colorAccent from {@link #Theme_DeviceDefault_DayNight}. --> @@ -2678,6 +4838,51 @@ easier. <item name="colorAccentPrimary">@color/accent_primary_device_default</item> <item name="colorAccentSecondary">@color/accent_secondary_device_default</item> <item name="colorAccentTertiary">@color/accent_tertiary_device_default</item> + + <item name="materialColorOnSecondaryFixedVariant">@color/system_on_secondary_fixed_variant_dark</item> + <item name="materialColorOnTertiaryFixedVariant">@color/system_on_tertiary_fixed_variant_dark</item> + <item name="materialColorSurfaceContainerLowest">@color/system_surface_container_lowest_dark</item> + <item name="materialColorOnPrimaryFixedVariant">@color/system_on_primary_fixed_variant_dark</item> + <item name="materialColorOnSecondaryContainer">@color/system_on_secondary_container_dark</item> + <item name="materialColorOnTertiaryContainer">@color/system_on_tertiary_container_dark</item> + <item name="materialColorSurfaceContainerLow">@color/system_surface_container_low_dark</item> + <item name="materialColorOnPrimaryContainer">@color/system_on_primary_container_dark</item> + <item name="materialColorSecondaryFixedDim">@color/system_secondary_fixed_dim_dark</item> + <item name="materialColorOnErrorContainer">@color/system_on_error_container_dark</item> + <item name="materialColorOnSecondaryFixed">@color/system_on_secondary_fixed_dark</item> + <item name="materialColorOnSurfaceInverse">@color/system_on_surface_dark</item> + <item name="materialColorTertiaryFixedDim">@color/system_tertiary_fixed_dim_dark</item> + <item name="materialColorOnTertiaryFixed">@color/system_on_tertiary_fixed_dark</item> + <item name="materialColorPrimaryFixedDim">@color/system_primary_fixed_dim_dark</item> + <item name="materialColorSecondaryContainer">@color/system_secondary_container_dark</item> + <item name="materialColorErrorContainer">@color/system_error_container_dark</item> + <item name="materialColorOnPrimaryFixed">@color/system_on_primary_fixed_dark</item> + <item name="materialColorPrimaryInverse">@color/system_primary_dark</item> + <item name="materialColorSecondaryFixed">@color/system_secondary_fixed_dark</item> + <item name="materialColorSurfaceInverse">@color/system_surface_dark</item> + <item name="materialColorSurfaceVariant">@color/system_surface_variant_dark</item> + <item name="materialColorTertiaryContainer">@color/system_tertiary_container_dark</item> + <item name="materialColorTertiaryFixed">@color/system_tertiary_fixed_dark</item> + <item name="materialColorPrimaryContainer">@color/system_primary_container_dark</item> + <item name="materialColorOnBackground">@color/system_on_background_dark</item> + <item name="materialColorPrimaryFixed">@color/system_primary_fixed_dark</item> + <item name="materialColorOnSecondary">@color/system_on_secondary_dark</item> + <item name="materialColorOnTertiary">@color/system_on_tertiary_dark</item> + <item name="materialColorSurfaceDim">@color/system_surface_dim_dark</item> + <item name="materialColorSurfaceBright">@color/system_surface_bright_dark</item> + <item name="materialColorSecondary">@color/system_secondary_dark</item> + <item name="materialColorOnError">@color/system_on_error_dark</item> + <item name="materialColorSurface">@color/system_surface_dark</item> + <item name="materialColorSurfaceContainerHigh">@color/system_surface_container_high_dark</item> + <item name="materialColorTertiary">@color/system_tertiary_dark</item> + <item name="materialColorSurfaceContainerHighest">@color/system_surface_container_highest_dark</item> + <item name="materialColorOnSurfaceVariant">@color/system_on_surface_variant_dark</item> + <item name="materialColorOutline">@color/system_outline_dark</item> + <item name="materialColorOnPrimary">@color/system_on_primary_dark</item> + <item name="materialColorOnSurface">@color/system_on_surface_dark</item> + <item name="materialColorSurfaceContainer">@color/system_surface_container_dark</item> + <item name="materialColorSurfaceContainer">@color/system_surface_container_dark</item> + </style> <style name="Theme.DeviceDefault.Light.Dialog.Alert.UserSwitchingDialog" parent="Theme.DeviceDefault.NoActionBar.Fullscreen"> @@ -2685,6 +4890,51 @@ easier. <item name="colorBackgroundFloating">@color/background_device_default_light</item> <item name="layout_gravity">center</item> <item name="windowAnimationStyle">@style/Animation.DeviceDefault.Dialog</item> + + <item name="materialColorOnSecondaryFixedVariant">@color/system_on_secondary_fixed_variant_light</item> + <item name="materialColorOnTertiaryFixedVariant">@color/system_on_tertiary_fixed_variant_light</item> + <item name="materialColorSurfaceContainerLowest">@color/system_surface_container_lowest_light</item> + <item name="materialColorOnPrimaryFixedVariant">@color/system_on_primary_fixed_variant_light</item> + <item name="materialColorOnSecondaryContainer">@color/system_on_secondary_container_light</item> + <item name="materialColorOnTertiaryContainer">@color/system_on_tertiary_container_light</item> + <item name="materialColorSurfaceContainerLow">@color/system_surface_container_low_light</item> + <item name="materialColorOnPrimaryContainer">@color/system_on_primary_container_light</item> + <item name="materialColorSecondaryFixedDim">@color/system_secondary_fixed_dim_light</item> + <item name="materialColorOnErrorContainer">@color/system_on_error_container_light</item> + <item name="materialColorOnSecondaryFixed">@color/system_on_secondary_fixed_light</item> + <item name="materialColorOnSurfaceInverse">@color/system_on_surface_light</item> + <item name="materialColorTertiaryFixedDim">@color/system_tertiary_fixed_dim_light</item> + <item name="materialColorOnTertiaryFixed">@color/system_on_tertiary_fixed_light</item> + <item name="materialColorPrimaryFixedDim">@color/system_primary_fixed_dim_light</item> + <item name="materialColorSecondaryContainer">@color/system_secondary_container_light</item> + <item name="materialColorErrorContainer">@color/system_error_container_light</item> + <item name="materialColorOnPrimaryFixed">@color/system_on_primary_fixed_light</item> + <item name="materialColorPrimaryInverse">@color/system_primary_light</item> + <item name="materialColorSecondaryFixed">@color/system_secondary_fixed_light</item> + <item name="materialColorSurfaceInverse">@color/system_surface_light</item> + <item name="materialColorSurfaceVariant">@color/system_surface_variant_light</item> + <item name="materialColorTertiaryContainer">@color/system_tertiary_container_light</item> + <item name="materialColorTertiaryFixed">@color/system_tertiary_fixed_light</item> + <item name="materialColorPrimaryContainer">@color/system_primary_container_light</item> + <item name="materialColorOnBackground">@color/system_on_background_light</item> + <item name="materialColorPrimaryFixed">@color/system_primary_fixed_light</item> + <item name="materialColorOnSecondary">@color/system_on_secondary_light</item> + <item name="materialColorOnTertiary">@color/system_on_tertiary_light</item> + <item name="materialColorSurfaceDim">@color/system_surface_dim_light</item> + <item name="materialColorSurfaceBright">@color/system_surface_bright_light</item> + <item name="materialColorSecondary">@color/system_secondary_light</item> + <item name="materialColorOnError">@color/system_on_error_light</item> + <item name="materialColorSurface">@color/system_surface_light</item> + <item name="materialColorSurfaceContainerHigh">@color/system_surface_container_high_light</item> + <item name="materialColorTertiary">@color/system_tertiary_light</item> + <item name="materialColorSurfaceContainerHighest">@color/system_surface_container_highest_light</item> + <item name="materialColorOnSurfaceVariant">@color/system_on_surface_variant_light</item> + <item name="materialColorOutline">@color/system_outline_light</item> + <item name="materialColorOnPrimary">@color/system_on_primary_light</item> + <item name="materialColorOnSurface">@color/system_on_surface_light</item> + <item name="materialColorSurfaceContainer">@color/system_surface_container_light</item> + <item name="materialColorSurfaceContainer">@color/system_surface_container_light</item> + </style> <style name="Theme.DeviceDefault.Notification" parent="@style/Theme.Material.Notification"> @@ -2703,6 +4953,51 @@ easier. <item name="colorAccentPrimary">@color/system_accent1_100</item> <item name="textColorPrimary">@color/system_neutral1_900</item> <item name="textColorSecondary">@color/system_neutral2_700</item> + + <item name="materialColorOnSecondaryFixedVariant">@color/system_on_secondary_fixed_variant_dark</item> + <item name="materialColorOnTertiaryFixedVariant">@color/system_on_tertiary_fixed_variant_dark</item> + <item name="materialColorSurfaceContainerLowest">@color/system_surface_container_lowest_dark</item> + <item name="materialColorOnPrimaryFixedVariant">@color/system_on_primary_fixed_variant_dark</item> + <item name="materialColorOnSecondaryContainer">@color/system_on_secondary_container_dark</item> + <item name="materialColorOnTertiaryContainer">@color/system_on_tertiary_container_dark</item> + <item name="materialColorSurfaceContainerLow">@color/system_surface_container_low_dark</item> + <item name="materialColorOnPrimaryContainer">@color/system_on_primary_container_dark</item> + <item name="materialColorSecondaryFixedDim">@color/system_secondary_fixed_dim_dark</item> + <item name="materialColorOnErrorContainer">@color/system_on_error_container_dark</item> + <item name="materialColorOnSecondaryFixed">@color/system_on_secondary_fixed_dark</item> + <item name="materialColorOnSurfaceInverse">@color/system_on_surface_dark</item> + <item name="materialColorTertiaryFixedDim">@color/system_tertiary_fixed_dim_dark</item> + <item name="materialColorOnTertiaryFixed">@color/system_on_tertiary_fixed_dark</item> + <item name="materialColorPrimaryFixedDim">@color/system_primary_fixed_dim_dark</item> + <item name="materialColorSecondaryContainer">@color/system_secondary_container_dark</item> + <item name="materialColorErrorContainer">@color/system_error_container_dark</item> + <item name="materialColorOnPrimaryFixed">@color/system_on_primary_fixed_dark</item> + <item name="materialColorPrimaryInverse">@color/system_primary_dark</item> + <item name="materialColorSecondaryFixed">@color/system_secondary_fixed_dark</item> + <item name="materialColorSurfaceInverse">@color/system_surface_dark</item> + <item name="materialColorSurfaceVariant">@color/system_surface_variant_dark</item> + <item name="materialColorTertiaryContainer">@color/system_tertiary_container_dark</item> + <item name="materialColorTertiaryFixed">@color/system_tertiary_fixed_dark</item> + <item name="materialColorPrimaryContainer">@color/system_primary_container_dark</item> + <item name="materialColorOnBackground">@color/system_on_background_dark</item> + <item name="materialColorPrimaryFixed">@color/system_primary_fixed_dark</item> + <item name="materialColorOnSecondary">@color/system_on_secondary_dark</item> + <item name="materialColorOnTertiary">@color/system_on_tertiary_dark</item> + <item name="materialColorSurfaceDim">@color/system_surface_dim_dark</item> + <item name="materialColorSurfaceBright">@color/system_surface_bright_dark</item> + <item name="materialColorSecondary">@color/system_secondary_dark</item> + <item name="materialColorOnError">@color/system_on_error_dark</item> + <item name="materialColorSurface">@color/system_surface_dark</item> + <item name="materialColorSurfaceContainerHigh">@color/system_surface_container_high_dark</item> + <item name="materialColorTertiary">@color/system_tertiary_dark</item> + <item name="materialColorSurfaceContainerHighest">@color/system_surface_container_highest_dark</item> + <item name="materialColorOnSurfaceVariant">@color/system_on_surface_variant_dark</item> + <item name="materialColorOutline">@color/system_outline_dark</item> + <item name="materialColorOnPrimary">@color/system_on_primary_dark</item> + <item name="materialColorOnSurface">@color/system_on_surface_dark</item> + <item name="materialColorSurfaceContainer">@color/system_surface_container_dark</item> + <item name="materialColorSurfaceContainer">@color/system_surface_container_dark</item> + </style> <style name="Theme.DeviceDefault.AutofillHalfScreenDialogList" parent="Theme.DeviceDefault.DayNight"> <item name="colorListDivider">@color/list_divider_opacity_device_default_light</item> diff --git a/data/etc/privapp-permissions-platform.xml b/data/etc/privapp-permissions-platform.xml index d726b6730f30..71050fa8b233 100644 --- a/data/etc/privapp-permissions-platform.xml +++ b/data/etc/privapp-permissions-platform.xml @@ -506,6 +506,8 @@ applications that come with the platform <permission name="android.permission.ACCESS_BROADCAST_RADIO"/> <!-- Permission required for CTS test - CtsAmbientContextServiceTestCases --> <permission name="android.permission.ACCESS_AMBIENT_CONTEXT_EVENT"/> + <!-- Permission required for CTS test - CtsTelephonyProviderTestCases --> + <permission name="android.permission.WRITE_APN_SETTINGS"/> </privapp-permissions> <privapp-permissions package="com.android.statementservice"> diff --git a/graphics/java/android/graphics/MeshSpecification.java b/graphics/java/android/graphics/MeshSpecification.java index 02015258d6a9..70311fdb2d1f 100644 --- a/graphics/java/android/graphics/MeshSpecification.java +++ b/graphics/java/android/graphics/MeshSpecification.java @@ -54,7 +54,8 @@ public class MeshSpecification { */ @IntDef( prefix = {"ALPHA_TYPE_"}, - value = {ALPHA_TYPE_UNKNOWN, ALPHA_TYPE_OPAQUE, ALPHA_TYPE_PREMUL, ALPHA_TYPE_PREMULT} + value = {ALPHA_TYPE_UNKNOWN, ALPHA_TYPE_OPAQUE, ALPHA_TYPE_PREMULTIPLIED, + ALPHA_TYPE_UNPREMULTIPLIED} ) @Retention(RetentionPolicy.SOURCE) private @interface AlphaType {} @@ -72,12 +73,12 @@ public class MeshSpecification { /** * Pixel components are premultiplied by alpha. */ - public static final int ALPHA_TYPE_PREMUL = 2; + public static final int ALPHA_TYPE_PREMULTIPLIED = 2; /** * Pixel components are independent of alpha. */ - public static final int ALPHA_TYPE_PREMULT = 3; + public static final int ALPHA_TYPE_UNPREMULTIPLIED = 3; /** * Constants for {@link Attribute} and {@link Varying} for determining the data type. @@ -220,7 +221,7 @@ public class MeshSpecification { /** * Creates a {@link MeshSpecification} object for use within {@link Mesh}. This uses a default * color space of {@link ColorSpace.Named#SRGB} and {@link AlphaType} of - * {@link #ALPHA_TYPE_PREMUL}. + * {@link #ALPHA_TYPE_PREMULTIPLIED}. * * @param attributes list of attributes represented by {@link Attribute}. Can hold a max of * 8. @@ -253,7 +254,7 @@ public class MeshSpecification { /** * Creates a {@link MeshSpecification} object. This uses a default {@link AlphaType} of - * {@link #ALPHA_TYPE_PREMUL}. + * {@link #ALPHA_TYPE_PREMULTIPLIED}. * * @param attributes list of attributes represented by {@link Attribute}. Can hold a max of * 8. @@ -306,8 +307,8 @@ public class MeshSpecification { * one of * {@link MeshSpecification#ALPHA_TYPE_UNKNOWN}, * {@link MeshSpecification#ALPHA_TYPE_OPAQUE}, - * {@link MeshSpecification#ALPHA_TYPE_PREMUL}, or - * {@link MeshSpecification#ALPHA_TYPE_PREMULT} + * {@link MeshSpecification#ALPHA_TYPE_PREMULTIPLIED}, or + * {@link MeshSpecification#ALPHA_TYPE_UNPREMULTIPLIED} * @return {@link MeshSpecification} object for use when creating {@link Mesh} */ @NonNull diff --git a/libs/WindowManager/Jetpack/src/androidx/window/extensions/embedding/SplitController.java b/libs/WindowManager/Jetpack/src/androidx/window/extensions/embedding/SplitController.java index 2c1ddf7cfcbe..9f3c19b2b545 100644 --- a/libs/WindowManager/Jetpack/src/androidx/window/extensions/embedding/SplitController.java +++ b/libs/WindowManager/Jetpack/src/androidx/window/extensions/embedding/SplitController.java @@ -308,7 +308,7 @@ public class SplitController implements JetpackTaskFragmentOrganizer.TaskFragmen synchronized (mLock) { final List<TaskFragmentContainer> containers = taskContainer.mContainers; // Clean up the TaskFragmentContainers by the z-order from the lowest. - for (int i = 0; i < containers.size() - 1; i++) { + for (int i = 0; i < containers.size(); i++) { final TaskFragmentContainer container = containers.get(i); if (pendingFinishingContainers.contains(container)) { // Don't update records here to prevent double invocation. @@ -318,7 +318,7 @@ public class SplitController implements JetpackTaskFragmentOrganizer.TaskFragmen } // Remove container records. removeContainers(taskContainer, pendingFinishingContainers); - // Update the change to the client side. + // Update the change to the server side. updateContainersInTaskIfVisible(wct, taskContainer.getTaskId()); } }); @@ -353,21 +353,25 @@ public class SplitController implements JetpackTaskFragmentOrganizer.TaskFragmen @Override public void updateSplitAttributes(@NonNull IBinder splitInfoToken, @NonNull SplitAttributes splitAttributes) { + Objects.requireNonNull(splitInfoToken); + Objects.requireNonNull(splitAttributes); synchronized (mLock) { final SplitContainer splitContainer = getSplitContainer(splitInfoToken); if (splitContainer == null) { Log.w(TAG, "Cannot find SplitContainer for token:" + splitInfoToken); return; } - WindowContainerTransaction wct = mTransactionManager.startNewTransaction() - .getTransaction(); + // Override the default split Attributes so that it will be applied + // if the SplitContainer is not visible currently. + splitContainer.updateDefaultSplitAttributes(splitAttributes); + + final TransactionRecord transactionRecord = mTransactionManager.startNewTransaction(); + final WindowContainerTransaction wct = transactionRecord.getTransaction(); if (updateSplitContainerIfNeeded(splitContainer, wct, splitAttributes)) { - splitContainer.updateDefaultSplitAttributes(splitAttributes); - mTransactionManager.getCurrentTransactionRecord() - .apply(false /* shouldApplyIndependently */); + transactionRecord.apply(false /* shouldApplyIndependently */); } else { // Abort if the SplitContainer wasn't updated. - mTransactionManager.getCurrentTransactionRecord().abort(); + transactionRecord.abort(); } } } @@ -1559,8 +1563,9 @@ public class SplitController implements JetpackTaskFragmentOrganizer.TaskFragmen * * @return {@code true} if the update succeed. Otherwise, returns {@code false}. */ + @VisibleForTesting @GuardedBy("mLock") - private boolean updateSplitContainerIfNeeded(@NonNull SplitContainer splitContainer, + boolean updateSplitContainerIfNeeded(@NonNull SplitContainer splitContainer, @NonNull WindowContainerTransaction wct, @Nullable SplitAttributes splitAttributes) { if (!isTopMostSplit(splitContainer)) { // Skip position update - it isn't the topmost split. @@ -1904,6 +1909,7 @@ public class SplitController implements JetpackTaskFragmentOrganizer.TaskFragmen return null; } + @VisibleForTesting @Nullable @GuardedBy("mLock") SplitContainer getSplitContainer(@NonNull IBinder token) { diff --git a/libs/WindowManager/Jetpack/tests/unittest/src/androidx/window/extensions/embedding/SplitControllerTest.java b/libs/WindowManager/Jetpack/tests/unittest/src/androidx/window/extensions/embedding/SplitControllerTest.java index 17909d4a0763..61cd7485ff1d 100644 --- a/libs/WindowManager/Jetpack/tests/unittest/src/androidx/window/extensions/embedding/SplitControllerTest.java +++ b/libs/WindowManager/Jetpack/tests/unittest/src/androidx/window/extensions/embedding/SplitControllerTest.java @@ -67,6 +67,7 @@ import static org.mockito.Mockito.doNothing; import static org.mockito.Mockito.doReturn; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.never; +import static org.mockito.Mockito.times; import android.annotation.NonNull; import android.app.Activity; @@ -82,6 +83,7 @@ import android.os.Bundle; import android.os.Handler; import android.os.IBinder; import android.platform.test.annotations.Presubmit; +import android.util.ArraySet; import android.view.WindowInsets; import android.view.WindowMetrics; import android.window.TaskFragmentInfo; @@ -100,12 +102,14 @@ import androidx.window.extensions.layout.WindowLayoutInfo; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; +import org.mockito.ArgumentCaptor; import org.mockito.Mock; import org.mockito.MockitoAnnotations; import java.util.ArrayList; import java.util.Collections; import java.util.List; +import java.util.Set; import java.util.function.Consumer; /** @@ -1323,6 +1327,125 @@ public class SplitControllerTest { verify(mTransaction).startActivityInTaskFragment(any(), any(), any(), any()); } + @Test + public void testFinishActivityStacks_emptySet_earlyReturn() { + mSplitController.finishActivityStacks(Collections.emptySet()); + + verify(mSplitController, never()).updateContainersInTaskIfVisible(any(), anyInt()); + } + + @Test + public void testFinishActivityStacks_invalidStacks_earlyReturn() { + mSplitController.finishActivityStacks(Collections.singleton(new Binder())); + + verify(mSplitController, never()).updateContainersInTaskIfVisible(any(), anyInt()); + } + + @Test + public void testFinishActivityStacks_finishSingleActivityStack() { + TaskFragmentContainer tf = mSplitController.newContainer(mActivity, TASK_ID); + tf.setInfo(mTransaction, createMockTaskFragmentInfo(tf, mActivity)); + + List<TaskFragmentContainer> containers = mSplitController.mTaskContainers.get(TASK_ID) + .mContainers; + + assertEquals(containers.get(0), tf); + + mSplitController.finishActivityStacks(Collections.singleton(tf.getTaskFragmentToken())); + + verify(mSplitPresenter).deleteTaskFragment(any(), eq(tf.getTaskFragmentToken())); + assertTrue(containers.isEmpty()); + } + + @Test + public void testFinishActivityStacks_finishActivityStacksInOrder() { + TaskFragmentContainer bottomTf = mSplitController.newContainer(mActivity, TASK_ID); + TaskFragmentContainer topTf = mSplitController.newContainer(mActivity, TASK_ID); + bottomTf.setInfo(mTransaction, createMockTaskFragmentInfo(bottomTf, mActivity)); + topTf.setInfo(mTransaction, createMockTaskFragmentInfo(topTf, createMockActivity())); + + List<TaskFragmentContainer> containers = mSplitController.mTaskContainers.get(TASK_ID) + .mContainers; + + assertEquals(containers.size(), 2); + + Set<IBinder> activityStackTokens = new ArraySet<>(new IBinder[]{ + topTf.getTaskFragmentToken(), bottomTf.getTaskFragmentToken()}); + + mSplitController.finishActivityStacks(activityStackTokens); + + ArgumentCaptor<IBinder> argumentCaptor = ArgumentCaptor.forClass(IBinder.class); + + verify(mSplitPresenter, times(2)).deleteTaskFragment(any(), argumentCaptor.capture()); + + List<IBinder> fragmentTokens = argumentCaptor.getAllValues(); + assertEquals("The ActivityStack must be deleted from the lowest z-order " + + "regardless of the order in ActivityStack set", + bottomTf.getTaskFragmentToken(), fragmentTokens.get(0)); + assertEquals("The ActivityStack must be deleted from the lowest z-order " + + "regardless of the order in ActivityStack set", + topTf.getTaskFragmentToken(), fragmentTokens.get(1)); + + assertTrue(containers.isEmpty()); + } + + @Test + public void testUpdateSplitAttributes_invalidSplitContainerToken_earlyReturn() { + mSplitController.updateSplitAttributes(new Binder(), SPLIT_ATTRIBUTES); + + verify(mTransactionManager, never()).startNewTransaction(); + } + + @Test + public void testUpdateSplitAttributes_nullParams_throwException() { + assertThrows(NullPointerException.class, + () -> mSplitController.updateSplitAttributes(null, SPLIT_ATTRIBUTES)); + + final SplitContainer splitContainer = mock(SplitContainer.class); + final IBinder token = new Binder(); + doReturn(token).when(splitContainer).getToken(); + doReturn(splitContainer).when(mSplitController).getSplitContainer(eq(token)); + + assertThrows(NullPointerException.class, + () -> mSplitController.updateSplitAttributes(token, null)); + } + + @Test + public void testUpdateSplitAttributes_doNotNeedToUpdateSplitContainer_doNotApplyTransaction() { + final SplitContainer splitContainer = mock(SplitContainer.class); + final IBinder token = new Binder(); + doReturn(token).when(splitContainer).getToken(); + doReturn(splitContainer).when(mSplitController).getSplitContainer(eq(token)); + doReturn(false).when(mSplitController).updateSplitContainerIfNeeded( + eq(splitContainer), any(), eq(SPLIT_ATTRIBUTES)); + TransactionManager.TransactionRecord testRecord = + mock(TransactionManager.TransactionRecord.class); + doReturn(testRecord).when(mTransactionManager).startNewTransaction(); + + mSplitController.updateSplitAttributes(token, SPLIT_ATTRIBUTES); + + verify(splitContainer).updateDefaultSplitAttributes(eq(SPLIT_ATTRIBUTES)); + verify(testRecord).abort(); + } + + @Test + public void testUpdateSplitAttributes_splitContainerUpdated_updateAttrs() { + final SplitContainer splitContainer = mock(SplitContainer.class); + final IBinder token = new Binder(); + doReturn(token).when(splitContainer).getToken(); + doReturn(splitContainer).when(mSplitController).getSplitContainer(eq(token)); + doReturn(true).when(mSplitController).updateSplitContainerIfNeeded( + eq(splitContainer), any(), eq(SPLIT_ATTRIBUTES)); + TransactionManager.TransactionRecord testRecord = + mock(TransactionManager.TransactionRecord.class); + doReturn(testRecord).when(mTransactionManager).startNewTransaction(); + + mSplitController.updateSplitAttributes(token, SPLIT_ATTRIBUTES); + + verify(splitContainer).updateDefaultSplitAttributes(eq(SPLIT_ATTRIBUTES)); + verify(testRecord).apply(eq(false)); + } + /** Creates a mock activity in the organizer process. */ private Activity createMockActivity() { return createMockActivity(TASK_ID); diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/TaskViewTaskController.java b/libs/WindowManager/Shell/src/com/android/wm/shell/TaskViewTaskController.java index 1f223a6ec5d0..080b171f4d40 100644 --- a/libs/WindowManager/Shell/src/com/android/wm/shell/TaskViewTaskController.java +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/TaskViewTaskController.java @@ -131,7 +131,7 @@ public class TaskViewTaskController implements ShellTaskOrganizer.TaskListener { mShellExecutor.execute(() -> { final WindowContainerTransaction wct = new WindowContainerTransaction(); wct.startShortcut(mContext.getPackageName(), shortcut, options.toBundle()); - mTaskViewTransitions.startTaskView(wct, this); + mTaskViewTransitions.startTaskView(wct, this, options.getLaunchCookie()); }); return; } @@ -158,7 +158,7 @@ public class TaskViewTaskController implements ShellTaskOrganizer.TaskListener { mShellExecutor.execute(() -> { WindowContainerTransaction wct = new WindowContainerTransaction(); wct.sendPendingIntent(pendingIntent, fillInIntent, options.toBundle()); - mTaskViewTransitions.startTaskView(wct, this); + mTaskViewTransitions.startTaskView(wct, this, options.getLaunchCookie()); }); return; } diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/TaskViewTransitions.java b/libs/WindowManager/Shell/src/com/android/wm/shell/TaskViewTransitions.java index aab257ebe885..04bff97bc4ce 100644 --- a/libs/WindowManager/Shell/src/com/android/wm/shell/TaskViewTransitions.java +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/TaskViewTransitions.java @@ -57,12 +57,21 @@ public class TaskViewTransitions implements Transitions.TransitionHandler { final @NonNull TaskViewTaskController mTaskView; IBinder mClaimed; + /** + * This is needed because arbitrary activity launches can still "intrude" into any + * transition since `startActivity` is a synchronous call. Once that is solved, we can + * remove this. + */ + final IBinder mLaunchCookie; + PendingTransition(@WindowManager.TransitionType int type, @Nullable WindowContainerTransaction wct, - @NonNull TaskViewTaskController taskView) { + @NonNull TaskViewTaskController taskView, + @Nullable IBinder launchCookie) { mType = type; mWct = wct; mTaskView = taskView; + mLaunchCookie = launchCookie; } } @@ -142,7 +151,7 @@ public class TaskViewTransitions implements Transitions.TransitionHandler { if (!Transitions.isClosingType(request.getType())) return null; PendingTransition pending = findPending(taskView, true /* closing */, false /* latest */); if (pending == null) { - pending = new PendingTransition(request.getType(), null, taskView); + pending = new PendingTransition(request.getType(), null, taskView, null /* cookie */); } if (pending.mClaimed != null) { throw new IllegalStateException("Task is closing in 2 collecting transitions?" @@ -162,8 +171,9 @@ public class TaskViewTransitions implements Transitions.TransitionHandler { return null; } - void startTaskView(WindowContainerTransaction wct, TaskViewTaskController taskView) { - mPending.add(new PendingTransition(TRANSIT_OPEN, wct, taskView)); + void startTaskView(@NonNull WindowContainerTransaction wct, + @NonNull TaskViewTaskController taskView, @NonNull IBinder launchCookie) { + mPending.add(new PendingTransition(TRANSIT_OPEN, wct, taskView, launchCookie)); startNextTransition(); } @@ -180,7 +190,7 @@ public class TaskViewTransitions implements Transitions.TransitionHandler { final WindowContainerTransaction wct = new WindowContainerTransaction(); wct.setHidden(taskView.getTaskInfo().token, !visible /* hidden */); pending = new PendingTransition( - visible ? TRANSIT_TO_FRONT : TRANSIT_TO_BACK, wct, taskView); + visible ? TRANSIT_TO_FRONT : TRANSIT_TO_BACK, wct, taskView, null /* cookie */); mPending.add(pending); startNextTransition(); // visibility is reported in transition. @@ -197,58 +207,92 @@ public class TaskViewTransitions implements Transitions.TransitionHandler { } @Override + public void onTransitionConsumed(@NonNull IBinder transition, boolean aborted, + @NonNull SurfaceControl.Transaction finishTransaction) { + if (!aborted) return; + final PendingTransition pending = findPending(transition); + if (pending == null) return; + mPending.remove(pending); + startNextTransition(); + } + + @Override public boolean startAnimation(@NonNull IBinder transition, @NonNull TransitionInfo info, @NonNull SurfaceControl.Transaction startTransaction, @NonNull SurfaceControl.Transaction finishTransaction, @NonNull Transitions.TransitionFinishCallback finishCallback) { PendingTransition pending = findPending(transition); - if (pending == null) return false; - mPending.remove(pending); - TaskViewTaskController taskView = pending.mTaskView; - final ArrayList<TransitionInfo.Change> tasks = new ArrayList<>(); - for (int i = 0; i < info.getChanges().size(); ++i) { - final TransitionInfo.Change chg = info.getChanges().get(i); - if (chg.getTaskInfo() == null) continue; - tasks.add(chg); + if (pending != null) { + mPending.remove(pending); } - if (tasks.isEmpty()) { - Slog.e(TAG, "Got a TaskView transition with no task."); + if (mTaskViews.isEmpty()) { + if (pending != null) { + Slog.e(TAG, "Pending taskview transition but no task-views"); + } return false; } + boolean stillNeedsMatchingLaunch = pending != null && pending.mLaunchCookie != null; + int changesHandled = 0; WindowContainerTransaction wct = null; - for (int i = 0; i < tasks.size(); ++i) { - TransitionInfo.Change chg = tasks.get(i); + for (int i = 0; i < info.getChanges().size(); ++i) { + final TransitionInfo.Change chg = info.getChanges().get(i); + if (chg.getTaskInfo() == null) continue; if (Transitions.isClosingType(chg.getMode())) { final boolean isHide = chg.getMode() == TRANSIT_TO_BACK; TaskViewTaskController tv = findTaskView(chg.getTaskInfo()); if (tv == null) { - throw new IllegalStateException("TaskView transition is closing a " - + "non-taskview task "); + if (pending != null) { + Slog.w(TAG, "Found a non-TaskView task in a TaskView Transition. This " + + "shouldn't happen, so there may be a visual artifact: " + + chg.getTaskInfo().taskId); + } + continue; } if (isHide) { tv.prepareHideAnimation(finishTransaction); } else { tv.prepareCloseAnimation(); } + changesHandled++; } else if (Transitions.isOpeningType(chg.getMode())) { final boolean taskIsNew = chg.getMode() == TRANSIT_OPEN; - if (wct == null) wct = new WindowContainerTransaction(); - TaskViewTaskController tv = taskView; - if (!taskIsNew) { + final TaskViewTaskController tv; + if (taskIsNew) { + if (pending == null + || !chg.getTaskInfo().containsLaunchCookie(pending.mLaunchCookie)) { + Slog.e(TAG, "Found a launching TaskView in the wrong transition. All " + + "TaskView launches should be initiated by shell and in their " + + "own transition: " + chg.getTaskInfo().taskId); + continue; + } + stillNeedsMatchingLaunch = false; + tv = pending.mTaskView; + } else { tv = findTaskView(chg.getTaskInfo()); if (tv == null) { - throw new IllegalStateException("TaskView transition is showing a " - + "non-taskview task "); + if (pending != null) { + Slog.w(TAG, "Found a non-TaskView task in a TaskView Transition. This " + + "shouldn't happen, so there may be a visual artifact: " + + chg.getTaskInfo().taskId); + } + continue; } } + if (wct == null) wct = new WindowContainerTransaction(); tv.prepareOpenAnimation(taskIsNew, startTransaction, finishTransaction, chg.getTaskInfo(), chg.getLeash(), wct); - } else { - throw new IllegalStateException("Claimed transition isn't an opening or closing" - + " type: " + chg.getMode()); + changesHandled++; } } + if (stillNeedsMatchingLaunch) { + throw new IllegalStateException("Expected a TaskView launch in this transition but" + + " didn't get one."); + } + if (wct == null && pending == null && changesHandled != info.getChanges().size()) { + // Just some house-keeping, let another handler animate. + return false; + } // No animation, just show it immediately. startTransaction.apply(); finishTransaction.apply(); diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/splitscreen/SplitScreenTransitions.java b/libs/WindowManager/Shell/src/com/android/wm/shell/splitscreen/SplitScreenTransitions.java index 2b21e77be9c1..520da92fad72 100644 --- a/libs/WindowManager/Shell/src/com/android/wm/shell/splitscreen/SplitScreenTransitions.java +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/splitscreen/SplitScreenTransitions.java @@ -193,6 +193,8 @@ class SplitScreenTransitions { mAnimatingTransition = transition; mFinishTransaction = finishTransaction; + startTransaction.apply(); + final SplitDecorManager topDecor = mPendingDismiss.mDismissTop == STAGE_TYPE_MAIN ? mainDecor : sideDecor; topDecor.fadeOutDecor(() -> { @@ -200,8 +202,6 @@ class SplitScreenTransitions { onFinish(null /* wct */, null /* wctCB */); }); }); - - startTransaction.apply(); } else { playAnimation(transition, info, startTransaction, finishTransaction, finishCallback, mainRoot, sideRoot, topRoot); diff --git a/media/java/android/media/tv/tuner/filter/MediaEvent.java b/media/java/android/media/tv/tuner/filter/MediaEvent.java index 8f2e7b573b09..4676dffb727f 100644 --- a/media/java/android/media/tv/tuner/filter/MediaEvent.java +++ b/media/java/android/media/tv/tuner/filter/MediaEvent.java @@ -224,6 +224,10 @@ public class MediaEvent extends FilterEvent { /** * Gets audio presentations. + * + * <p>The audio presentation order matters. As specified in ETSI EN 300 468 V1.17.1, all the + * audio programme components corresponding to the first audio preselection in the loop are + * contained in the main NGA stream. */ @NonNull public List<AudioPresentation> getAudioPresentations() { diff --git a/media/tests/MediaFrameworkTest/AndroidManifest.xml b/media/tests/MediaFrameworkTest/AndroidManifest.xml index 41ac285e49f5..e88655894156 100644 --- a/media/tests/MediaFrameworkTest/AndroidManifest.xml +++ b/media/tests/MediaFrameworkTest/AndroidManifest.xml @@ -41,7 +41,6 @@ </activity> <activity android:label="Camera2CtsActivity" android:name="Camera2SurfaceViewActivity" - android:screenOrientation="landscape" android:configChanges="keyboardHidden|orientation|screenSize" android:showWhenLocked="true" android:turnScreenOn="true" diff --git a/packages/PackageInstaller/res/values/strings.xml b/packages/PackageInstaller/res/values/strings.xml index ab680b063d6d..6669e358eb08 100644 --- a/packages/PackageInstaller/res/values/strings.xml +++ b/packages/PackageInstaller/res/values/strings.xml @@ -38,9 +38,6 @@ <!-- Message for updating an existing app [CHAR LIMIT=NONE] --> <string name="install_confirm_question_update">Do you want to update this app?</string> <!-- TODO(b/244413073) Revise the description after getting UX input and UXR on this. --> - <!-- Message for updating an existing app when updating owner changed [DO NOT TRANSLATE][CHAR LIMIT=NONE] --> - <string name="install_confirm_question_update_owner_changed">Updates to this app are currently managed by <xliff:g id="existing_update_owner">%1$s</xliff:g>.\n\nBy updating, you\'ll get future updates from <xliff:g id="new_update_owner">%2$s</xliff:g> instead.</string> - <!-- TODO(b/244413073) Revise the description after getting UX input and UXR on this. --> <!-- Message for updating an existing app with update owner reminder [DO NOT TRANSLATE][CHAR LIMIT=NONE] --> <string name="install_confirm_question_update_owner_reminder">Updates to this app are currently managed by <xliff:g id="existing_update_owner">%1$s</xliff:g>.\n\nDo you want to install this update from <xliff:g id="new_update_owner">%2$s</xliff:g>?</string> <!-- [CHAR LIMIT=100] --> diff --git a/packages/PackageInstaller/src/com/android/packageinstaller/PackageInstallerActivity.java b/packages/PackageInstaller/src/com/android/packageinstaller/PackageInstallerActivity.java index fd41f5fb08a5..d41cfbc2d4ce 100644 --- a/packages/PackageInstaller/src/com/android/packageinstaller/PackageInstallerActivity.java +++ b/packages/PackageInstaller/src/com/android/packageinstaller/PackageInstallerActivity.java @@ -144,18 +144,11 @@ public class PackageInstallerActivity extends AlertActivity { final CharSequence existingUpdateOwnerLabel = getExistingUpdateOwnerLabel(); final CharSequence requestedUpdateOwnerLabel = getApplicationLabel(mCallingPackage); - if (!TextUtils.isEmpty(existingUpdateOwnerLabel)) { - if (mPendingUserActionReason == PackageInstaller.REASON_OWNERSHIP_CHANGED) { - viewToEnable.setText( - getString(R.string.install_confirm_question_update_owner_changed, - existingUpdateOwnerLabel, requestedUpdateOwnerLabel)); - } else if (mPendingUserActionReason == PackageInstaller.REASON_REMIND_OWNERSHIP - || mPendingUserActionReason - == PackageInstaller.REASON_CONFIRM_PACKAGE_CHANGE) { - viewToEnable.setText( - getString(R.string.install_confirm_question_update_owner_reminder, - existingUpdateOwnerLabel, requestedUpdateOwnerLabel)); - } + if (!TextUtils.isEmpty(existingUpdateOwnerLabel) + && mPendingUserActionReason == PackageInstaller.REASON_REMIND_OWNERSHIP) { + viewToEnable.setText( + getString(R.string.install_confirm_question_update_owner_reminder, + existingUpdateOwnerLabel, requestedUpdateOwnerLabel)); } mOk.setText(R.string.update); diff --git a/packages/SettingsLib/ActionBarShadow/Android.bp b/packages/SettingsLib/ActionBarShadow/Android.bp index 9b0e04444d50..bf4c8587722a 100644 --- a/packages/SettingsLib/ActionBarShadow/Android.bp +++ b/packages/SettingsLib/ActionBarShadow/Android.bp @@ -22,7 +22,8 @@ android_library { min_sdk_version: "28", apex_available: [ "//apex_available:platform", - "com.android.permission", "com.android.adservices", + "com.android.extservices", + "com.android.permission", ], } diff --git a/packages/SettingsLib/CollapsingToolbarBaseActivity/Android.bp b/packages/SettingsLib/CollapsingToolbarBaseActivity/Android.bp index 6330848f6316..e9000a8e4b0f 100644 --- a/packages/SettingsLib/CollapsingToolbarBaseActivity/Android.bp +++ b/packages/SettingsLib/CollapsingToolbarBaseActivity/Android.bp @@ -27,6 +27,7 @@ android_library { "//apex_available:platform", "com.android.adservices", "com.android.cellbroadcast", + "com.android.extservices", "com.android.permission", "com.android.healthfitness", ], diff --git a/packages/SettingsLib/MainSwitchPreference/Android.bp b/packages/SettingsLib/MainSwitchPreference/Android.bp index 825e6acdf1f9..33aa985b32e8 100644 --- a/packages/SettingsLib/MainSwitchPreference/Android.bp +++ b/packages/SettingsLib/MainSwitchPreference/Android.bp @@ -25,6 +25,7 @@ android_library { "//apex_available:platform", "com.android.adservices", "com.android.cellbroadcast", + "com.android.extservices", "com.android.healthfitness", ], } diff --git a/packages/SettingsLib/SettingsTheme/Android.bp b/packages/SettingsLib/SettingsTheme/Android.bp index 09691f19e9ce..d26ad1c77f1b 100644 --- a/packages/SettingsLib/SettingsTheme/Android.bp +++ b/packages/SettingsLib/SettingsTheme/Android.bp @@ -9,18 +9,14 @@ package { android_library { name: "SettingsLibSettingsTheme", - resource_dirs: ["res"], - - static_libs: [ - "androidx.preference_preference", - ], - + static_libs: ["androidx.preference_preference"], sdk_version: "system_current", min_sdk_version: "21", apex_available: [ "//apex_available:platform", "com.android.cellbroadcast", + "com.android.extservices", "com.android.permission", "com.android.adservices", "com.android.healthfitness", diff --git a/packages/SettingsLib/SettingsTransition/Android.bp b/packages/SettingsLib/SettingsTransition/Android.bp index 7f9014cecc69..0f9f7816d1dd 100644 --- a/packages/SettingsLib/SettingsTransition/Android.bp +++ b/packages/SettingsLib/SettingsTransition/Android.bp @@ -22,6 +22,7 @@ android_library { "//apex_available:platform", "com.android.adservices", "com.android.cellbroadcast", + "com.android.extservices", "com.android.permission", "com.android.healthfitness", ], diff --git a/packages/SettingsLib/Utils/Android.bp b/packages/SettingsLib/Utils/Android.bp index 644e990bf9d9..33ba64ac2cb7 100644 --- a/packages/SettingsLib/Utils/Android.bp +++ b/packages/SettingsLib/Utils/Android.bp @@ -24,8 +24,9 @@ android_library { "//apex_available:platform", "com.android.adservices", - "com.android.permission", "com.android.cellbroadcast", + "com.android.extservices", "com.android.healthfitness", + "com.android.permission", ], } diff --git a/packages/Shell/AndroidManifest.xml b/packages/Shell/AndroidManifest.xml index 0f671249596c..82ca63d1a801 100644 --- a/packages/Shell/AndroidManifest.xml +++ b/packages/Shell/AndroidManifest.xml @@ -819,6 +819,9 @@ <!-- Permission required for CTS test - ActivityCaptureCallbackTests --> <uses-permission android:name="android.permission.DETECT_SCREEN_CAPTURE" /> + <!-- Permission required for CTS test - CtsTelephonyProviderTestCases --> + <uses-permission android:name="android.permission.WRITE_APN_SETTINGS" /> + <application android:label="@string/app_label" android:theme="@android:style/Theme.DeviceDefault.DayNight" android:defaultToDeviceProtectedStorage="true" diff --git a/packages/SystemUI/src/com/android/systemui/shade/NotificationShadeWindowView.java b/packages/SystemUI/src/com/android/systemui/shade/NotificationShadeWindowView.java index f7126291c7f0..2b6327f3eedf 100644 --- a/packages/SystemUI/src/com/android/systemui/shade/NotificationShadeWindowView.java +++ b/packages/SystemUI/src/com/android/systemui/shade/NotificationShadeWindowView.java @@ -16,7 +16,7 @@ package com.android.systemui.shade; -import static android.os.Trace.TRACE_TAG_ALWAYS; +import static android.os.Trace.TRACE_TAG_APP; import static android.view.WindowInsets.Type.systemBars; import static com.android.systemui.statusbar.phone.CentralSurfaces.DEBUG; @@ -328,7 +328,7 @@ public class NotificationShadeWindowView extends FrameLayout { @Override public void requestLayout() { - Trace.instant(TRACE_TAG_ALWAYS, "NotificationShadeWindowView#requestLayout"); + Trace.instant(TRACE_TAG_APP, "NotificationShadeWindowView#requestLayout"); super.requestLayout(); } diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/NotifCollection.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/NotifCollection.java index 32b8e09aa730..c9f31bad74c0 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/NotifCollection.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/NotifCollection.java @@ -166,6 +166,11 @@ public class NotifCollection implements Dumpable, PipelineDumpable { private Queue<NotifEvent> mEventQueue = new ArrayDeque<>(); + private final Runnable mRebuildListRunnable = () -> { + if (mBuildListener != null) { + mBuildListener.onBuildList(mReadOnlyNotificationSet, "asynchronousUpdate"); + } + }; private boolean mAttached = false; private boolean mAmDispatchingToOtherCode; @@ -462,7 +467,7 @@ public class NotifCollection implements Dumpable, PipelineDumpable { int modificationType) { Assert.isMainThread(); mEventQueue.add(new ChannelChangedEvent(pkgName, user, channel, modificationType)); - dispatchEventsAndRebuildList("onNotificationChannelModified"); + dispatchEventsAndAsynchronouslyRebuildList(); } private void onNotificationsInitialized() { @@ -621,15 +626,39 @@ public class NotifCollection implements Dumpable, PipelineDumpable { private void dispatchEventsAndRebuildList(String reason) { Trace.beginSection("NotifCollection.dispatchEventsAndRebuildList"); + if (mMainHandler.hasCallbacks(mRebuildListRunnable)) { + mMainHandler.removeCallbacks(mRebuildListRunnable); + } + + dispatchEvents(); + + if (mBuildListener != null) { + mBuildListener.onBuildList(mReadOnlyNotificationSet, reason); + } + Trace.endSection(); + } + + private void dispatchEventsAndAsynchronouslyRebuildList() { + Trace.beginSection("NotifCollection.dispatchEventsAndAsynchronouslyRebuildList"); + + dispatchEvents(); + + if (!mMainHandler.hasCallbacks(mRebuildListRunnable)) { + mMainHandler.postDelayed(mRebuildListRunnable, 1000L); + } + + Trace.endSection(); + } + + private void dispatchEvents() { + Trace.beginSection("NotifCollection.dispatchEvents"); + mAmDispatchingToOtherCode = true; while (!mEventQueue.isEmpty()) { mEventQueue.remove().dispatchTo(mNotifCollectionListeners); } mAmDispatchingToOtherCode = false; - if (mBuildListener != null) { - mBuildListener.onBuildList(mReadOnlyNotificationSet, reason); - } Trace.endSection(); } 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 1fb7eb5106e6..d2087ba6ca1c 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 @@ -16,7 +16,7 @@ package com.android.systemui.statusbar.notification.stack; -import static android.os.Trace.TRACE_TAG_ALWAYS; +import static android.os.Trace.TRACE_TAG_APP; import static com.android.internal.jank.InteractionJankMonitor.CUJ_NOTIFICATION_SHADE_SCROLL_FLING; import static com.android.internal.jank.InteractionJankMonitor.CUJ_SHADE_CLEAR_ALL; @@ -1121,7 +1121,7 @@ public class NotificationStackScrollLayout extends ViewGroup implements Dumpable @Override public void requestLayout() { - Trace.instant(TRACE_TAG_ALWAYS, "NotificationStackScrollLayout#requestLayout"); + Trace.instant(TRACE_TAG_APP, "NotificationStackScrollLayout#requestLayout"); super.requestLayout(); } diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/collection/NotifCollectionTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/collection/NotifCollectionTest.java index 005c80ab577c..540bda6ea9dc 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/collection/NotifCollectionTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/collection/NotifCollectionTest.java @@ -106,6 +106,7 @@ import org.mockito.InOrder; import org.mockito.Mock; import org.mockito.MockitoAnnotations; import org.mockito.Spy; +import org.mockito.stubbing.Answer; import java.util.Arrays; import java.util.Collection; @@ -378,6 +379,90 @@ public class NotifCollectionTest extends SysuiTestCase { } @Test + public void testScheduleBuildNotificationListWhenChannelChanged() { + // GIVEN + final NotificationEntryBuilder neb = buildNotif(TEST_PACKAGE, 48); + final NotificationChannel channel = new NotificationChannel( + "channelId", + "channelName", + NotificationManager.IMPORTANCE_DEFAULT); + neb.setChannel(channel); + + final NotifEvent notif = mNoMan.postNotif(neb); + final NotificationEntry entry = mCollectionListener.getEntry(notif.key); + + when(mMainHandler.hasCallbacks(any())).thenReturn(false); + + clearInvocations(mBuildListener); + + // WHEN + mNotifHandler.onNotificationChannelModified(TEST_PACKAGE, + entry.getSbn().getUser(), channel, NOTIFICATION_CHANNEL_OR_GROUP_UPDATED); + + // THEN + verify(mMainHandler).postDelayed(any(), eq(1000L)); + } + + @Test + public void testCancelScheduledBuildNotificationListEventWhenNotifUpdatedSynchronously() { + // GIVEN + final NotificationEntry entry1 = buildNotif(TEST_PACKAGE, 1) + .setGroup(mContext, "group_1") + .build(); + final NotificationEntry entry2 = buildNotif(TEST_PACKAGE, 2) + .setGroup(mContext, "group_1") + .setContentTitle(mContext, "New version") + .build(); + final NotificationEntry entry3 = buildNotif(TEST_PACKAGE, 3) + .setGroup(mContext, "group_1") + .build(); + + final List<CoalescedEvent> entriesToBePosted = Arrays.asList( + new CoalescedEvent(entry1.getKey(), 0, entry1.getSbn(), entry1.getRanking(), null), + new CoalescedEvent(entry2.getKey(), 1, entry2.getSbn(), entry2.getRanking(), null), + new CoalescedEvent(entry3.getKey(), 2, entry3.getSbn(), entry3.getRanking(), null) + ); + + when(mMainHandler.hasCallbacks(any())).thenReturn(true); + + // WHEN + mNotifHandler.onNotificationBatchPosted(entriesToBePosted); + + // THEN + verify(mMainHandler).removeCallbacks(any()); + } + + @Test + public void testBuildNotificationListWhenChannelChanged() { + // GIVEN + final NotificationEntryBuilder neb = buildNotif(TEST_PACKAGE, 48); + final NotificationChannel channel = new NotificationChannel( + "channelId", + "channelName", + NotificationManager.IMPORTANCE_DEFAULT); + neb.setChannel(channel); + + final NotifEvent notif = mNoMan.postNotif(neb); + final NotificationEntry entry = mCollectionListener.getEntry(notif.key); + + when(mMainHandler.hasCallbacks(any())).thenReturn(false); + when(mMainHandler.postDelayed(any(), eq(1000L))).thenAnswer((Answer) invocation -> { + final Runnable runnable = invocation.getArgument(0); + runnable.run(); + return null; + }); + + clearInvocations(mBuildListener); + + // WHEN + mNotifHandler.onNotificationChannelModified(TEST_PACKAGE, + entry.getSbn().getUser(), channel, NOTIFICATION_CHANNEL_OR_GROUP_UPDATED); + + // THEN + verifyBuiltList(List.of(entry)); + } + + @Test public void testRankingsAreUpdatedForOtherNotifs() { // GIVEN a collection with one notif NotifEvent notif1 = mNoMan.postNotif(buildNotif(TEST_PACKAGE, 3) diff --git a/services/companion/java/com/android/server/companion/RolesUtils.java b/services/companion/java/com/android/server/companion/RolesUtils.java index f674a7d20b82..163f614fb65d 100644 --- a/services/companion/java/com/android/server/companion/RolesUtils.java +++ b/services/companion/java/com/android/server/companion/RolesUtils.java @@ -27,6 +27,7 @@ import android.annotation.UserIdInt; import android.app.role.RoleManager; import android.companion.AssociationInfo; import android.content.Context; +import android.os.Binder; import android.os.UserHandle; import android.util.Log; import android.util.Slog; @@ -84,7 +85,9 @@ final class RolesUtils { Slog.i(TAG, "Removing CDM role holder, role=" + deviceProfile + ", package=u" + userId + "\\" + packageName); - roleManager.removeRoleHolderAsUser(deviceProfile, packageName, + final long identity = Binder.clearCallingIdentity(); + try { + roleManager.removeRoleHolderAsUser(deviceProfile, packageName, MANAGE_HOLDERS_FLAG_DONT_KILL_APP, userHandle, context.getMainExecutor(), success -> { if (!success) { @@ -92,6 +95,9 @@ final class RolesUtils { + " from the list of " + deviceProfile + " holders."); } }); + } finally { + Binder.restoreCallingIdentity(identity); + } } private RolesUtils() {}; diff --git a/services/core/java/com/android/server/am/ActivityManagerService.java b/services/core/java/com/android/server/am/ActivityManagerService.java index 96d5f38bd720..6aa49d276391 100644 --- a/services/core/java/com/android/server/am/ActivityManagerService.java +++ b/services/core/java/com/android/server/am/ActivityManagerService.java @@ -191,7 +191,6 @@ import android.app.ApplicationStartInfo; import android.app.ApplicationThreadConstants; import android.app.BackgroundStartPrivileges; import android.app.BroadcastOptions; -import android.app.ComponentOptions; import android.app.ContentProviderHolder; import android.app.ForegroundServiceDelegationOptions; import android.app.IActivityController; @@ -7031,6 +7030,17 @@ public class ActivityManagerService extends IActivityManager.Stub mCpHelper.getProviderMimeTypeAsync(uri, userId, resultCallback); } + /** + * Filters calls to getType based on permission. If the caller has required permission, + * then it returns the contentProvider#getType. + * Else, it returns the contentProvider#getTypeAnonymous, which does not + * reveal any internal information which should be protected by any permission. + */ + @Override + public void getMimeTypeFilterAsync(Uri uri, int userId, RemoteCallback resultCallback) { + mCpHelper.getMimeTypeFilterAsync(uri, userId, resultCallback); + } + // ========================================================= // GLOBAL MANAGEMENT // ========================================================= diff --git a/services/core/java/com/android/server/am/BroadcastProcessQueue.java b/services/core/java/com/android/server/am/BroadcastProcessQueue.java index 6e97317a5523..84c03e59c658 100644 --- a/services/core/java/com/android/server/am/BroadcastProcessQueue.java +++ b/services/core/java/com/android/server/am/BroadcastProcessQueue.java @@ -751,6 +751,22 @@ class BroadcastProcessQueue { } /** + * Quickly determine if this queue has ordered broadcasts waiting to be delivered, + * which indicates we should request an OOM adjust. + */ + public boolean isPendingOrdered() { + return mCountOrdered > 0; + } + + /** + * Quickly determine if this queue has broadcasts waiting to be delivered for which result is + * expected from the senders, which indicates we should request an OOM adjust. + */ + public boolean isPendingResultTo() { + return mCountResultTo > 0; + } + + /** * Report whether this queue is currently handling an urgent broadcast. */ public boolean isPendingUrgent() { diff --git a/services/core/java/com/android/server/am/BroadcastQueueModernImpl.java b/services/core/java/com/android/server/am/BroadcastQueueModernImpl.java index 5c7fde79821c..b942f4b96b21 100644 --- a/services/core/java/com/android/server/am/BroadcastQueueModernImpl.java +++ b/services/core/java/com/android/server/am/BroadcastQueueModernImpl.java @@ -466,7 +466,9 @@ class BroadcastQueueModernImpl extends BroadcastQueue { // Emit all trace events for this process into a consistent track queue.runningTraceTrackName = TAG + ".mRunning[" + queueIndex + "]"; - queue.runningOomAdjusted = queue.isPendingManifest(); + queue.runningOomAdjusted = queue.isPendingManifest() + || queue.isPendingOrdered() + || queue.isPendingResultTo(); // If already warm, we can make OOM adjust request immediately; // otherwise we need to wait until process becomes warm @@ -1620,6 +1622,18 @@ class BroadcastQueueModernImpl extends BroadcastQueue { */ private void notifyFinishReceiver(@Nullable BroadcastProcessQueue queue, @NonNull BroadcastRecord r, int index, @NonNull Object receiver) { + if (r.wasDeliveryAttempted(index)) { + logBroadcastDeliveryEventReported(queue, r, index, receiver); + } + + final boolean recordFinished = (r.terminalCount == r.receivers.size()); + if (recordFinished) { + notifyFinishBroadcast(r); + } + } + + private void logBroadcastDeliveryEventReported(@Nullable BroadcastProcessQueue queue, + @NonNull BroadcastRecord r, int index, @NonNull Object receiver) { // Report statistics for each individual receiver final int uid = getReceiverUid(receiver); final int senderUid = (r.callingUid == -1) ? Process.SYSTEM_UID : r.callingUid; @@ -1647,11 +1661,6 @@ class BroadcastQueueModernImpl extends BroadcastQueue { FrameworkStatsLog.write(BROADCAST_DELIVERY_EVENT_REPORTED, uid, senderUid, actionName, receiverType, type, dispatchDelay, receiveDelay, finishDelay, packageState); } - - final boolean recordFinished = (r.terminalCount == r.receivers.size()); - if (recordFinished) { - notifyFinishBroadcast(r); - } } private void notifyFinishBroadcast(@NonNull BroadcastRecord r) { diff --git a/services/core/java/com/android/server/am/BroadcastRecord.java b/services/core/java/com/android/server/am/BroadcastRecord.java index 67783be871b6..f793c5078b5e 100644 --- a/services/core/java/com/android/server/am/BroadcastRecord.java +++ b/services/core/java/com/android/server/am/BroadcastRecord.java @@ -632,6 +632,18 @@ final class BroadcastRecord extends Binder { return delivery[index]; } + boolean wasDeliveryAttempted(int index) { + final int deliveryState = getDeliveryState(index); + switch (deliveryState) { + case DELIVERY_DELIVERED: + case DELIVERY_TIMEOUT: + case DELIVERY_FAILURE: + return true; + default: + return false; + } + } + void copyEnqueueTimeFrom(@NonNull BroadcastRecord replacedBroadcast) { originalEnqueueClockTime = enqueueClockTime; enqueueTime = replacedBroadcast.enqueueTime; diff --git a/services/core/java/com/android/server/am/ContentProviderHelper.java b/services/core/java/com/android/server/am/ContentProviderHelper.java index 31301666ad53..f721d69958f5 100644 --- a/services/core/java/com/android/server/am/ContentProviderHelper.java +++ b/services/core/java/com/android/server/am/ContentProviderHelper.java @@ -15,6 +15,7 @@ */ package com.android.server.am; +import static android.Manifest.permission.GET_ANY_PROVIDER_TYPE; import static android.content.ContentProvider.isAuthorityRedirectedForCloneProfile; import static android.os.Process.PROC_CHAR; import static android.os.Process.PROC_OUT_LONG; @@ -23,8 +24,6 @@ import static android.os.Process.PROC_SPACE_TERM; import static android.os.Process.SYSTEM_UID; import static com.android.internal.util.FrameworkStatsLog.GET_TYPE_ACCESSED_WITHOUT_PERMISSION; -import static com.android.internal.util.FrameworkStatsLog.GET_TYPE_ACCESSED_WITHOUT_PERMISSION__LOCATION__AM_CHECK_URI_PERMISSION; -import static com.android.internal.util.FrameworkStatsLog.GET_TYPE_ACCESSED_WITHOUT_PERMISSION__LOCATION__AM_ERROR; import static com.android.internal.util.FrameworkStatsLog.GET_TYPE_ACCESSED_WITHOUT_PERMISSION__LOCATION__AM_FRAMEWORK_PERMISSION; import static com.android.internal.util.FrameworkStatsLog.PROVIDER_ACQUISITION_EVENT_REPORTED; import static com.android.internal.util.FrameworkStatsLog.PROVIDER_ACQUISITION_EVENT_REPORTED__PACKAGE_STOPPED_STATE__PACKAGE_STATE_NORMAL; @@ -52,7 +51,6 @@ import android.content.ContentResolver; import android.content.Context; import android.content.IContentProvider; import android.content.Intent; -import android.content.PermissionChecker; import android.content.pm.ApplicationInfo; import android.content.pm.PackageInfo; import android.content.pm.PackageManager; @@ -1019,9 +1017,6 @@ public class ContentProviderHelper { mService.mHandler.postDelayed(providerNotResponding, 1000); try { final String type = holder.provider.getType(uri); - if (type != null) { - backgroundLogging(callingUid, callingPid, userId, uri, holder, type); - } return type; } finally { mService.mHandler.removeCallbacks(providerNotResponding); @@ -1079,10 +1074,6 @@ public class ContentProviderHelper { Binder.restoreCallingIdentity(identity); } resultCallback.sendResult(result); - final String type = result.getPairValue(); - if (type != null) { - backgroundLogging(callingUid, callingPid, userId, uri, holder, type); - } })); } else { resultCallback.sendResult(Bundle.EMPTY); @@ -1093,67 +1084,84 @@ public class ContentProviderHelper { } } - private void backgroundLogging(int callingUid, int callingPid, int userId, Uri uri, - ContentProviderHolder holder, String type) { - // Push the logging code in a different handlerThread. + /** + * Filters calls to getType based on permission. If the caller has required permission, + * then it returns the contentProvider#getType. + * Else, it returns the contentProvider#getTypeAnonymous, which does not + * reveal any internal information which should be protected by any permission. + */ + void getMimeTypeFilterAsync(Uri uri, int userId, RemoteCallback resultCallback) { + mService.enforceNotIsolatedCaller("getProviderMimeTypeAsync"); + final String name = uri.getAuthority(); + final int callingUid = Binder.getCallingUid(); + final int callingPid = Binder.getCallingPid(); + final int safeUserId = mService.mUserController.unsafeConvertIncomingUser(userId); + final long ident = canClearIdentity(callingPid, callingUid, safeUserId) + ? Binder.clearCallingIdentity() : 0; + final ContentProviderHolder holder; try { - mService.mHandler.post(new Runnable() { - @Override - public void run() { - logGetTypeData(callingUid, callingPid, userId, - uri, holder, type); - } - }); - } catch (Exception e) { - // To ensure logging does not break the getType calls. + holder = getContentProviderExternalUnchecked(name, null /* token */, callingUid, + "*getmimetype*", safeUserId); + } finally { + if (ident != 0) { + Binder.restoreCallingIdentity(ident); + } } - } - // Utility function to log the getTypeData calls - private void logGetTypeData(int callingUid, int callingPid, int userId, Uri uri, - ContentProviderHolder holder, String type) { try { - boolean checkUser = true; - final String authority = uri.getAuthority(); - if (isAuthorityRedirectedForCloneProfile(authority)) { - UserManagerInternal umInternal = - LocalServices.getService(UserManagerInternal.class); - UserInfo userInfo = umInternal.getUserInfo(userId); - - if (userInfo != null && userInfo.isCloneProfile()) { - userId = umInternal.getProfileParentId(userId); - checkUser = false; + if (isHolderVisibleToCaller(holder, callingUid, safeUserId)) { + if (checkGetAnyTypePermission(callingUid, callingPid)) { + final AttributionSource attributionSource = + new AttributionSource.Builder(callingUid).build(); + holder.provider.getTypeAsync(attributionSource, + uri, new RemoteCallback(result -> { + final long identity = Binder.clearCallingIdentity(); + try { + removeContentProviderExternalUnchecked(name, null, safeUserId); + } finally { + Binder.restoreCallingIdentity(identity); + } + resultCallback.sendResult(result); + })); + } else { + holder.provider.getTypeAnonymousAsync(uri, new RemoteCallback(result -> { + final long identity = Binder.clearCallingIdentity(); + try { + removeContentProviderExternalUnchecked(name, null, safeUserId); + } finally { + Binder.restoreCallingIdentity(identity); + } + resultCallback.sendResult(result); + final String type = result.getPairValue(); + if (type != null) { + logGetTypeData(callingUid, uri, type); + } + })); } + } else { + resultCallback.sendResult(Bundle.EMPTY); } - final ProviderInfo cpi = holder.info; - final AttributionSource attributionSource = - new AttributionSource.Builder(callingUid).build(); - final String permissionCheck = - checkContentProviderPermission(cpi, callingPid, callingUid, - userId, checkUser, null); - final boolean grantCheck = mService.checkUriPermission(uri, callingPid, callingUid, - Intent.FLAG_GRANT_READ_URI_PERMISSION , userId, null) - == PackageManager.PERMISSION_GRANTED; - - if (!grantCheck && permissionCheck != null) { - FrameworkStatsLog.write(GET_TYPE_ACCESSED_WITHOUT_PERMISSION, - GET_TYPE_ACCESSED_WITHOUT_PERMISSION__LOCATION__AM_FRAMEWORK_PERMISSION, - callingUid, authority, type); - } else if (!grantCheck && cpi.forceUriPermissions - && holder.provider.checkUriPermission(attributionSource, - uri, callingUid, Intent.FLAG_GRANT_READ_URI_PERMISSION) - != PermissionChecker.PERMISSION_GRANTED) { - FrameworkStatsLog.write(GET_TYPE_ACCESSED_WITHOUT_PERMISSION, - GET_TYPE_ACCESSED_WITHOUT_PERMISSION__LOCATION__AM_CHECK_URI_PERMISSION, - callingUid, authority, type); - } - } catch (Exception e) { - FrameworkStatsLog.write(GET_TYPE_ACCESSED_WITHOUT_PERMISSION, - GET_TYPE_ACCESSED_WITHOUT_PERMISSION__LOCATION__AM_ERROR, callingUid, - uri.getAuthority(), type); + } catch (RemoteException e) { + Log.w(TAG, "Content provider dead retrieving " + uri, e); + resultCallback.sendResult(Bundle.EMPTY); } } + private boolean checkGetAnyTypePermission(int callingUid, int callingPid) { + if (mService.checkPermission(GET_ANY_PROVIDER_TYPE, callingPid, callingUid) + == PackageManager.PERMISSION_GRANTED) { + return true; + } + return false; + } + + // Utility function to log the getTypeData calls + private void logGetTypeData(int callingUid, Uri uri, String type) { + FrameworkStatsLog.write(GET_TYPE_ACCESSED_WITHOUT_PERMISSION, + GET_TYPE_ACCESSED_WITHOUT_PERMISSION__LOCATION__AM_FRAMEWORK_PERMISSION, + callingUid, uri.getAuthority(), type); + } + private boolean canClearIdentity(int callingPid, int callingUid, int userId) { if (UserHandle.getUserId(callingUid) == userId) { return true; diff --git a/services/core/java/com/android/server/audio/AudioDeviceBroker.java b/services/core/java/com/android/server/audio/AudioDeviceBroker.java index b001f3d0c892..3304fb04fa0e 100644 --- a/services/core/java/com/android/server/audio/AudioDeviceBroker.java +++ b/services/core/java/com/android/server/audio/AudioDeviceBroker.java @@ -1263,6 +1263,10 @@ import java.util.concurrent.atomic.AtomicBoolean; sendILMsg(MSG_IL_BTA2DP_TIMEOUT, SENDMSG_QUEUE, a2dpCodec, address, delayMs); } + /*package*/ void setLeAudioTimeout(String address, int device, int delayMs) { + sendILMsg(MSG_IL_BTLEAUDIO_TIMEOUT, SENDMSG_QUEUE, device, address, delayMs); + } + /*package*/ void setAvrcpAbsoluteVolumeSupported(boolean supported) { synchronized (mDeviceStateLock) { mBtHelper.setAvrcpAbsoluteVolumeSupported(supported); @@ -1467,6 +1471,13 @@ import java.util.concurrent.atomic.AtomicBoolean; mDeviceInventory.onMakeA2dpDeviceUnavailableNow((String) msg.obj, msg.arg1); } break; + case MSG_IL_BTLEAUDIO_TIMEOUT: + // msg.obj == address of LE Audio device + synchronized (mDeviceStateLock) { + mDeviceInventory.onMakeLeAudioDeviceUnavailableNow( + (String) msg.obj, msg.arg1); + } + break; case MSG_L_A2DP_DEVICE_CONFIG_CHANGE: final BluetoothDevice btDevice = (BluetoothDevice) msg.obj; synchronized (mDeviceStateLock) { @@ -1703,12 +1714,14 @@ import java.util.concurrent.atomic.AtomicBoolean; private static final int MSG_IL_SAVE_NDEF_DEVICE_FOR_STRATEGY = 47; private static final int MSG_IL_SAVE_REMOVE_NDEF_DEVICE_FOR_STRATEGY = 48; + private static final int MSG_IL_BTLEAUDIO_TIMEOUT = 49; private static boolean isMessageHandledUnderWakelock(int msgId) { switch(msgId) { case MSG_L_SET_WIRED_DEVICE_CONNECTION_STATE: case MSG_L_SET_BT_ACTIVE_DEVICE: case MSG_IL_BTA2DP_TIMEOUT: + case MSG_IL_BTLEAUDIO_TIMEOUT: case MSG_L_A2DP_DEVICE_CONFIG_CHANGE: case MSG_TOGGLE_HDMI: case MSG_L_A2DP_DEVICE_CONNECTION_CHANGE_EXT: @@ -1800,6 +1813,7 @@ import java.util.concurrent.atomic.AtomicBoolean; case MSG_L_SET_BT_ACTIVE_DEVICE: case MSG_L_SET_WIRED_DEVICE_CONNECTION_STATE: case MSG_IL_BTA2DP_TIMEOUT: + case MSG_IL_BTLEAUDIO_TIMEOUT: case MSG_L_A2DP_DEVICE_CONFIG_CHANGE: if (sLastDeviceConnectMsgTime >= time) { // add a little delay to make sure messages are ordered as expected diff --git a/services/core/java/com/android/server/audio/AudioDeviceInventory.java b/services/core/java/com/android/server/audio/AudioDeviceInventory.java index f9270c9b32bb..aae1d3884344 100644 --- a/services/core/java/com/android/server/audio/AudioDeviceInventory.java +++ b/services/core/java/com/android/server/audio/AudioDeviceInventory.java @@ -395,7 +395,7 @@ public class AudioDeviceInventory { case BluetoothProfile.LE_AUDIO: case BluetoothProfile.LE_AUDIO_BROADCAST: if (switchToUnavailable) { - makeLeAudioDeviceUnavailable(address, btInfo.mAudioSystemDevice); + makeLeAudioDeviceUnavailableNow(address, btInfo.mAudioSystemDevice); } else if (switchToAvailable) { makeLeAudioDeviceAvailable(address, BtHelper.getName(btInfo.mDevice), streamType, btInfo.mVolume == -1 ? -1 : btInfo.mVolume * 10, @@ -507,6 +507,12 @@ public class AudioDeviceInventory { } } + /*package*/ void onMakeLeAudioDeviceUnavailableNow(String address, int device) { + synchronized (mDevicesLock) { + makeLeAudioDeviceUnavailableNow(address, device); + } + } + /*package*/ void onReportNewRoutes() { int n = mRoutesObservers.beginBroadcast(); if (n > 0) { @@ -1027,10 +1033,11 @@ public class AudioDeviceInventory { new MediaMetrics.Item(mMetricsId + "disconnectLeAudio") .record(); if (toRemove.size() > 0) { - final int delay = checkSendBecomingNoisyIntentInt(device, 0, + final int delay = checkSendBecomingNoisyIntentInt(device, + AudioService.CONNECTION_STATE_DISCONNECTED, AudioSystem.DEVICE_NONE); toRemove.stream().forEach(deviceAddress -> - makeLeAudioDeviceUnavailable(deviceAddress, device) + makeLeAudioDeviceUnavailableLater(deviceAddress, device, delay) ); } } @@ -1331,9 +1338,21 @@ public class AudioDeviceInventory { */ mDeviceBroker.setBluetoothA2dpOnInt(true, false /*fromA2dp*/, eventSource); - AudioSystem.setDeviceConnectionState(new AudioDeviceAttributes(device, address, name), + final int res = AudioSystem.setDeviceConnectionState(new AudioDeviceAttributes( + device, address, name), AudioSystem.DEVICE_STATE_AVAILABLE, AudioSystem.AUDIO_FORMAT_DEFAULT); + if (res != AudioSystem.AUDIO_STATUS_OK) { + AudioService.sDeviceLogger.enqueue(new EventLogger.StringEvent( + "APM failed to make available LE Audio device addr=" + address + + " error=" + res).printLog(TAG)); + // TODO: connection failed, stop here + // TODO: return; + } else { + AudioService.sDeviceLogger.enqueue(new EventLogger.StringEvent( + "LE Audio device addr=" + address + " now available").printLog(TAG)); + } + mConnectedDevices.put(DeviceInfo.makeDeviceListKey(device, address), new DeviceInfo(device, name, address, AudioSystem.AUDIO_FORMAT_DEFAULT)); mDeviceBroker.postAccessoryPlugMediaUnmute(device); @@ -1354,11 +1373,23 @@ public class AudioDeviceInventory { } @GuardedBy("mDevicesLock") - private void makeLeAudioDeviceUnavailable(String address, int device) { + private void makeLeAudioDeviceUnavailableNow(String address, int device) { if (device != AudioSystem.DEVICE_NONE) { - AudioSystem.setDeviceConnectionState(new AudioDeviceAttributes(device, address), + final int res = AudioSystem.setDeviceConnectionState(new AudioDeviceAttributes( + device, address), AudioSystem.DEVICE_STATE_UNAVAILABLE, AudioSystem.AUDIO_FORMAT_DEFAULT); + + if (res != AudioSystem.AUDIO_STATUS_OK) { + AudioService.sDeviceLogger.enqueue(new EventLogger.StringEvent( + "APM failed to make unavailable LE Audio device addr=" + address + + " error=" + res).printLog(TAG)); + // TODO: failed to disconnect, stop here + // TODO: return; + } else { + AudioService.sDeviceLogger.enqueue(new EventLogger.StringEvent( + "LE Audio device addr=" + address + " made unavailable").printLog(TAG)); + } mConnectedDevices.remove(DeviceInfo.makeDeviceListKey(device, address)); } @@ -1366,6 +1397,14 @@ public class AudioDeviceInventory { } @GuardedBy("mDevicesLock") + private void makeLeAudioDeviceUnavailableLater(String address, int device, int delayMs) { + // the device will be made unavailable later, so consider it disconnected right away + mConnectedDevices.remove(DeviceInfo.makeDeviceListKey(device, address)); + // send the delayed message to make the device unavailable later + mDeviceBroker.setLeAudioTimeout(address, device, delayMs); + } + + @GuardedBy("mDevicesLock") private void setCurrentAudioRouteNameIfPossible(String name, boolean fromA2dp) { synchronized (mCurAudioRoutes) { if (TextUtils.equals(mCurAudioRoutes.bluetoothName, name)) { diff --git a/services/core/java/com/android/server/display/DisplayManagerService.java b/services/core/java/com/android/server/display/DisplayManagerService.java index 850f6da7e35f..81e550e3d62f 100644 --- a/services/core/java/com/android/server/display/DisplayManagerService.java +++ b/services/core/java/com/android/server/display/DisplayManagerService.java @@ -466,6 +466,8 @@ public final class DisplayManagerService extends SystemService { private boolean mIsDocked; private boolean mIsDreaming; + private boolean mBootCompleted = false; + private final BroadcastReceiver mIdleModeReceiver = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { @@ -602,6 +604,12 @@ public final class DisplayManagerService extends SystemService { } } } else if (phase == PHASE_BOOT_COMPLETED) { + synchronized (mSyncRoot) { + mBootCompleted = true; + for (int i = 0; i < mDisplayPowerControllers.size(); i++) { + mDisplayPowerControllers.valueAt(i).onBootCompleted(); + } + } mDisplayModeDirector.onBootCompleted(); mLogicalDisplayMapper.onBootCompleted(); } @@ -2998,12 +3006,12 @@ public final class DisplayManagerService extends SystemService { displayPowerController = new DisplayPowerController2( mContext, /* injector= */ null, mDisplayPowerCallbacks, mPowerHandler, mSensorManager, mDisplayBlanker, display, mBrightnessTracker, brightnessSetting, - () -> handleBrightnessChange(display), hbmMetadata); + () -> handleBrightnessChange(display), hbmMetadata, mBootCompleted); } else { displayPowerController = new DisplayPowerController( mContext, /* injector= */ null, mDisplayPowerCallbacks, mPowerHandler, mSensorManager, mDisplayBlanker, display, mBrightnessTracker, brightnessSetting, - () -> handleBrightnessChange(display), hbmMetadata); + () -> handleBrightnessChange(display), hbmMetadata, mBootCompleted); } mDisplayPowerControllers.append(display.getDisplayIdLocked(), displayPowerController); } diff --git a/services/core/java/com/android/server/display/DisplayPowerController.java b/services/core/java/com/android/server/display/DisplayPowerController.java index 82e6e308cab3..40c879a3c5e7 100644 --- a/services/core/java/com/android/server/display/DisplayPowerController.java +++ b/services/core/java/com/android/server/display/DisplayPowerController.java @@ -139,6 +139,7 @@ final class DisplayPowerController implements AutomaticBrightnessController.Call private static final int MSG_BRIGHTNESS_RAMP_DONE = 12; private static final int MSG_STATSD_HBM_BRIGHTNESS = 13; private static final int MSG_SWITCH_USER = 14; + private static final int MSG_BOOT_COMPLETED = 15; private static final int PROXIMITY_UNKNOWN = -1; private static final int PROXIMITY_NEGATIVE = 0; @@ -518,6 +519,8 @@ final class DisplayPowerController implements AutomaticBrightnessController.Call private final SparseArray<DisplayPowerControllerInterface> mDisplayBrightnessFollowers = new SparseArray<>(); + private boolean mBootCompleted; + /** * Creates the display power controller. */ @@ -525,7 +528,8 @@ final class DisplayPowerController implements AutomaticBrightnessController.Call DisplayPowerCallbacks callbacks, Handler handler, SensorManager sensorManager, DisplayBlanker blanker, LogicalDisplay logicalDisplay, BrightnessTracker brightnessTracker, BrightnessSetting brightnessSetting, - Runnable onBrightnessChangeRunnable, HighBrightnessModeMetadata hbmMetadata) { + Runnable onBrightnessChangeRunnable, HighBrightnessModeMetadata hbmMetadata, + boolean bootCompleted) { mInjector = injector != null ? injector : new Injector(); mClock = mInjector.getClock(); @@ -662,6 +666,7 @@ final class DisplayPowerController implements AutomaticBrightnessController.Call mTemporaryAutoBrightnessAdjustment = PowerManager.BRIGHTNESS_INVALID_FLOAT; mPendingAutoBrightnessAdjustment = PowerManager.BRIGHTNESS_INVALID_FLOAT; + mBootCompleted = bootCompleted; } private void applyReduceBrightColorsSplineAdjustment() { @@ -1448,7 +1453,7 @@ final class DisplayPowerController implements AutomaticBrightnessController.Call // Initialize things the first time the power state is changed. if (mustInitialize) { - initialize(state); + initialize(readyToUpdateDisplayState() ? state : Display.STATE_UNKNOWN); } // Animate the screen state change unless already animating. @@ -2154,7 +2159,8 @@ final class DisplayPowerController implements AutomaticBrightnessController.Call } } - if (!reportOnly && mPowerState.getScreenState() != state) { + if (!reportOnly && mPowerState.getScreenState() != state + && readyToUpdateDisplayState()) { Trace.traceCounter(Trace.TRACE_TAG_POWER, "ScreenState", state); // TODO(b/153319140) remove when we can get this from the above trace invocation SystemProperties.set("debug.tracing.screen_state", String.valueOf(state)); @@ -2567,6 +2573,12 @@ final class DisplayPowerController implements AutomaticBrightnessController.Call mBrightnessSetting.setBrightness(brightnessValue); } + @Override + public void onBootCompleted() { + Message msg = mHandler.obtainMessage(MSG_BOOT_COMPLETED); + mHandler.sendMessageAtTime(msg, mClock.uptimeMillis()); + } + private void updateScreenBrightnessSetting(float brightnessValue) { if (!isValidBrightnessValue(brightnessValue) || brightnessValue == mCurrentScreenBrightnessSetting) { @@ -2712,6 +2724,17 @@ final class DisplayPowerController implements AutomaticBrightnessController.Call } }; + /** + * Indicates whether the display state is ready to update. If this is the default display, we + * want to update it right away so that we can draw the boot animation on it. If it is not + * the default display, drawing the boot animation on it would look incorrect, so we need + * to wait until boot is completed. + * @return True if the display state is ready to update + */ + private boolean readyToUpdateDisplayState() { + return mDisplayId == Display.DEFAULT_DISPLAY || mBootCompleted; + } + @Override public void dump(final PrintWriter pw) { synchronized (mLock) { @@ -3235,6 +3258,11 @@ final class DisplayPowerController implements AutomaticBrightnessController.Call case MSG_SWITCH_USER: handleOnSwitchUser(msg.arg1); break; + + case MSG_BOOT_COMPLETED: + mBootCompleted = true; + updatePowerState(); + break; } } } diff --git a/services/core/java/com/android/server/display/DisplayPowerController2.java b/services/core/java/com/android/server/display/DisplayPowerController2.java index 0861a37247c4..5ea8aaa5e814 100644 --- a/services/core/java/com/android/server/display/DisplayPowerController2.java +++ b/services/core/java/com/android/server/display/DisplayPowerController2.java @@ -137,6 +137,7 @@ final class DisplayPowerController2 implements AutomaticBrightnessController.Cal private static final int MSG_BRIGHTNESS_RAMP_DONE = 10; private static final int MSG_STATSD_HBM_BRIGHTNESS = 11; private static final int MSG_SWITCH_USER = 12; + private static final int MSG_BOOT_COMPLETED = 13; private static final int BRIGHTNESS_CHANGE_STATSD_REPORT_INTERVAL_MS = 500; @@ -425,6 +426,8 @@ final class DisplayPowerController2 implements AutomaticBrightnessController.Cal private SparseArray<DisplayPowerControllerInterface> mDisplayBrightnessFollowers = new SparseArray(); + private boolean mBootCompleted; + /** * Creates the display power controller. */ @@ -432,7 +435,8 @@ final class DisplayPowerController2 implements AutomaticBrightnessController.Cal DisplayPowerCallbacks callbacks, Handler handler, SensorManager sensorManager, DisplayBlanker blanker, LogicalDisplay logicalDisplay, BrightnessTracker brightnessTracker, BrightnessSetting brightnessSetting, - Runnable onBrightnessChangeRunnable, HighBrightnessModeMetadata hbmMetadata) { + Runnable onBrightnessChangeRunnable, HighBrightnessModeMetadata hbmMetadata, + boolean bootCompleted) { mInjector = injector != null ? injector : new Injector(); mClock = mInjector.getClock(); @@ -555,6 +559,7 @@ final class DisplayPowerController2 implements AutomaticBrightnessController.Cal mTemporaryAutoBrightnessAdjustment = PowerManager.BRIGHTNESS_INVALID_FLOAT; mPendingAutoBrightnessAdjustment = PowerManager.BRIGHTNESS_INVALID_FLOAT; + mBootCompleted = bootCompleted; } private void applyReduceBrightColorsSplineAdjustment() { @@ -1190,7 +1195,7 @@ final class DisplayPowerController2 implements AutomaticBrightnessController.Cal // Initialize things the first time the power state is changed. if (mustInitialize) { - initialize(state); + initialize(readyToUpdateDisplayState() ? state : Display.STATE_UNKNOWN); } // Animate the screen state change unless already animating. @@ -1720,6 +1725,12 @@ final class DisplayPowerController2 implements AutomaticBrightnessController.Cal } } + @Override + public void onBootCompleted() { + Message msg = mHandler.obtainMessage(MSG_BOOT_COMPLETED); + mHandler.sendMessageAtTime(msg, mClock.uptimeMillis()); + } + private boolean saveBrightnessInfo(float brightness) { return saveBrightnessInfo(brightness, brightness); } @@ -1861,7 +1872,8 @@ final class DisplayPowerController2 implements AutomaticBrightnessController.Cal } } - if (!reportOnly && mPowerState.getScreenState() != state) { + if (!reportOnly && mPowerState.getScreenState() != state + && readyToUpdateDisplayState()) { Trace.traceCounter(Trace.TRACE_TAG_POWER, "ScreenState", state); // TODO(b/153319140) remove when we can get this from the above trace invocation SystemProperties.set("debug.tracing.screen_state", String.valueOf(state)); @@ -2519,6 +2531,17 @@ final class DisplayPowerController2 implements AutomaticBrightnessController.Cal } } + /** + * Indicates whether the display state is ready to update. If this is the default display, we + * want to update it right away so that we can draw the boot animation on it. If it is not + * the default display, drawing the boot animation on it would look incorrect, so we need + * to wait until boot is completed. + * @return True if the display state is ready to update + */ + private boolean readyToUpdateDisplayState() { + return mDisplayId == Display.DEFAULT_DISPLAY || mBootCompleted; + } + // Return bucket index of range_[left]_[right] where // left <= nits < right private int nitsToRangeIndex(float nits) { @@ -2738,6 +2761,11 @@ final class DisplayPowerController2 implements AutomaticBrightnessController.Cal case MSG_SWITCH_USER: handleOnSwitchUser(msg.arg1); break; + + case MSG_BOOT_COMPLETED: + mBootCompleted = true; + updatePowerState(); + break; } } } diff --git a/services/core/java/com/android/server/display/DisplayPowerControllerInterface.java b/services/core/java/com/android/server/display/DisplayPowerControllerInterface.java index 0bc8154b610c..73edb970ff95 100644 --- a/services/core/java/com/android/server/display/DisplayPowerControllerInterface.java +++ b/services/core/java/com/android/server/display/DisplayPowerControllerInterface.java @@ -206,4 +206,9 @@ public interface DisplayPowerControllerInterface { * @param follower The DPC to remove from the followers list */ void removeDisplayBrightnessFollower(DisplayPowerControllerInterface follower); + + /** + * Indicate that boot has been completed and the screen is ready to update. + */ + void onBootCompleted(); } diff --git a/services/core/java/com/android/server/notification/NotificationManagerService.java b/services/core/java/com/android/server/notification/NotificationManagerService.java index a01b2c1d9c6a..38cddc4c0127 100755 --- a/services/core/java/com/android/server/notification/NotificationManagerService.java +++ b/services/core/java/com/android/server/notification/NotificationManagerService.java @@ -17,6 +17,7 @@ package com.android.server.notification; import static android.app.ActivityManager.RunningAppProcessInfo.IMPORTANCE_FOREGROUND; +import static android.app.ActivityManagerInternal.ServiceNotificationPolicy.NOT_FOREGROUND_SERVICE; import static android.app.AppOpsManager.MODE_ALLOWED; import static android.app.Notification.BubbleMetadata.FLAG_SUPPRESS_NOTIFICATION; import static android.app.Notification.FLAG_AUTOGROUP_SUMMARY; @@ -6517,9 +6518,17 @@ public class NotificationManagerService extends SystemService { checkRestrictedCategories(notification); + // Notifications passed to setForegroundService() have FLAG_FOREGROUND_SERVICE, + // but it's also possible that the app has called notify() with an update to an + // FGS notification that hasn't yet been displayed. Make sure we check for any + // FGS-related situation up front, outside of any locks so it's safe to call into + // the Activity Manager. + final ServiceNotificationPolicy policy = mAmi.applyForegroundServiceNotification( + notification, tag, id, pkg, userId); + // Fix the notification as best we can. try { - fixNotification(notification, pkg, tag, id, userId, notificationUid); + fixNotification(notification, pkg, tag, id, userId, notificationUid, policy); } catch (Exception e) { if (notification.isForegroundService()) { throw new SecurityException("Invalid FGS notification", e); @@ -6528,13 +6537,7 @@ public class NotificationManagerService extends SystemService { return; } - // Notifications passed to setForegroundService() have FLAG_FOREGROUND_SERVICE, - // but it's also possible that the app has called notify() with an update to an - // FGS notification that hasn't yet been displayed. Make sure we check for any - // FGS-related situation up front, outside of any locks so it's safe to call into - // the Activity Manager. - final ServiceNotificationPolicy policy = mAmi.applyForegroundServiceNotification( - notification, tag, id, pkg, userId); + if (policy == ServiceNotificationPolicy.UPDATE_ONLY) { // Proceed if the notification is already showing/known, otherwise ignore // because the service lifecycle logic has retained responsibility for its @@ -6707,14 +6710,17 @@ public class NotificationManagerService extends SystemService { @VisibleForTesting protected void fixNotification(Notification notification, String pkg, String tag, int id, - @UserIdInt int userId, int notificationUid) throws NameNotFoundException, - RemoteException { - + @UserIdInt int userId, int notificationUid, ServiceNotificationPolicy fgsPolicy) + throws NameNotFoundException, RemoteException { final ApplicationInfo ai = mPackageManagerClient.getApplicationInfoAsUser( pkg, PackageManager.MATCH_DEBUG_TRIAGED_MISSING, (userId == UserHandle.USER_ALL) ? USER_SYSTEM : userId); Notification.addFieldsFromContext(ai, notification); + if (notification.isForegroundService() && fgsPolicy == NOT_FOREGROUND_SERVICE) { + notification.flags &= ~FLAG_FOREGROUND_SERVICE; + } + // Only notifications that can be non-dismissible can have the flag FLAG_NO_DISMISS if (mFlagResolver.isEnabled(ALLOW_DISMISS_ONGOING)) { if (((notification.flags & FLAG_ONGOING_EVENT) > 0) @@ -6857,11 +6863,7 @@ public class NotificationManagerService extends SystemService { * A notification should be dismissible, unless it's exempted for some reason. */ private boolean canBeNonDismissible(ApplicationInfo ai, Notification notification) { - // Check if the app is on the system partition, or an update to an app on the system - // partition. - boolean isSystemAppExempt = (ai.flags - & (ApplicationInfo.FLAG_UPDATED_SYSTEM_APP | ApplicationInfo.FLAG_SYSTEM)) > 0; - return isSystemAppExempt || notification.isMediaNotification() || isEnterpriseExempted(ai); + return notification.isMediaNotification() || isEnterpriseExempted(ai); } private boolean isEnterpriseExempted(ApplicationInfo ai) { diff --git a/services/core/java/com/android/server/pm/ComputerEngine.java b/services/core/java/com/android/server/pm/ComputerEngine.java index 58a609e3e370..5984360a534c 100644 --- a/services/core/java/com/android/server/pm/ComputerEngine.java +++ b/services/core/java/com/android/server/pm/ComputerEngine.java @@ -65,6 +65,7 @@ import android.annotation.NonNull; import android.annotation.Nullable; import android.annotation.UserIdInt; import android.app.ActivityManager; +import android.app.admin.DevicePolicyManagerInternal; import android.content.ComponentName; import android.content.Context; import android.content.Intent; @@ -2190,6 +2191,11 @@ public class ComputerEngine implements Computer { && UserHandle.getAppId(uid) == pkg.getUid(); } + private boolean isCallerFromManagedUserOrProfile(@UserIdInt int userId) { + final var dpmi = mInjector.getLocalService(DevicePolicyManagerInternal.class); + return dpmi != null && dpmi.isUserOrganizationManaged(userId); + } + public final boolean isComponentVisibleToInstantApp(@Nullable ComponentName component) { if (isComponentVisibleToInstantApp(component, TYPE_ACTIVITY)) { return true; @@ -5002,8 +5008,15 @@ public class ComputerEngine implements Computer { updateOwnerPackageName = installSource.mUpdateOwnerPackageName; if (updateOwnerPackageName != null) { final PackageStateInternal ps = mSettings.getPackage(updateOwnerPackageName); + final boolean isCallerSystemOrUpdateOwner = callingUid == Process.SYSTEM_UID + || isCallerSameApp(updateOwnerPackageName, callingUid); + // Except for package visibility filtering, we also hide update owner if the installer + // is in the managed user or profile. As we don't enforce the update ownership for the + // managed user and profile, knowing there's an update owner is meaningless in that + // user unless the installer is the owner. if (ps == null - || shouldFilterApplicationIncludingUninstalled(ps, callingUid, userId)) { + || shouldFilterApplicationIncludingUninstalled(ps, callingUid, userId) + || (!isCallerSystemOrUpdateOwner && isCallerFromManagedUserOrProfile(userId))) { updateOwnerPackageName = null; } } diff --git a/services/core/java/com/android/server/pm/InstallPackageHelper.java b/services/core/java/com/android/server/pm/InstallPackageHelper.java index 4b2be2ff500d..a868470b0042 100644 --- a/services/core/java/com/android/server/pm/InstallPackageHelper.java +++ b/services/core/java/com/android/server/pm/InstallPackageHelper.java @@ -102,6 +102,7 @@ import android.app.AppOpsManager; import android.app.ApplicationExitInfo; import android.app.ApplicationPackageManager; import android.app.BroadcastOptions; +import android.app.admin.DevicePolicyManagerInternal; import android.app.backup.IBackupManager; import android.content.ContentResolver; import android.content.Context; @@ -144,6 +145,7 @@ import android.provider.DeviceConfig; import android.stats.storage.StorageEnums; import android.system.ErrnoException; import android.system.Os; +import android.text.TextUtils; import android.util.ArrayMap; import android.util.ArraySet; import android.util.EventLog; @@ -317,10 +319,16 @@ final class InstallPackageHelper { InstallSource installSource = request.getInstallSource(); final boolean isApex = (scanFlags & SCAN_AS_APEX) != 0; + final boolean pkgAlreadyExists = oldPkgSetting != null; + final boolean isAllowUpdateOwnership = parsedPackage.isAllowUpdateOwnership(); + final String oldUpdateOwner = + pkgAlreadyExists ? oldPkgSetting.getInstallSource().mUpdateOwnerPackageName : null; final String updateOwnerFromSysconfig = isApex || !pkgSetting.isSystem() ? null : mPm.mInjector.getSystemConfig().getSystemAppUpdateOwnerPackageName( parsedPackage.getPackageName()); - // For new install (standard install), the installSource isn't null. + final boolean isUpdateOwnershipEnabled = oldUpdateOwner != null; + + // For standard install (install via session), the installSource isn't null. if (installSource != null) { // If this is part of a standard install, set the initiating package name, else rely on // previous device state. @@ -334,39 +342,68 @@ final class InstallPackageHelper { } // Handle the update ownership enforcement for APK - if (updateOwnerFromSysconfig != null) { - // For system app, we always use the update owner from sysconfig if presented. - installSource = installSource.setUpdateOwnerPackageName(updateOwnerFromSysconfig); - } else if (!parsedPackage.isAllowUpdateOwnership()) { + if (!isAllowUpdateOwnership) { // If the app wants to opt-out of the update ownership enforcement via manifest, // it overrides the installer's use of #setRequestUpdateOwnership. installSource = installSource.setUpdateOwnerPackageName(null); } else if (!isApex) { - final boolean isUpdate = oldPkgSetting != null; - final String oldUpdateOwner = - isUpdate ? oldPkgSetting.getInstallSource().mUpdateOwnerPackageName : null; - final boolean isUpdateOwnershipEnabled = oldUpdateOwner != null; + // User installer UID as "current" userId if present; otherwise, use the userId + // from InstallRequest. + final int userId = installSource.mInstallerPackageUid != Process.INVALID_UID + ? UserHandle.getUserId(installSource.mInstallerPackageUid) + : request.getUserId(); + // Whether the parsedPackage is installed on the userId + // If the oldPkgSetting doesn't exist, this package isn't installed for all users. + final boolean isUpdate = pkgAlreadyExists && (userId >= UserHandle.USER_SYSTEM + // If userID >= 0, we could check via oldPkgSetting.getInstalled(userId). + ? oldPkgSetting.getInstalled(userId) + // When userId is -1 (USER_ALL) and it's not installed for any user, + // treat it as not installed. + : oldPkgSetting.getNotInstalledUserIds().length + <= (UserManager.isHeadlessSystemUserMode() ? 1 : 0)); final boolean isRequestUpdateOwnership = (request.getInstallFlags() & PackageManager.INSTALL_REQUEST_UPDATE_OWNERSHIP) != 0; - - // Here we assign the update owner for the package, and the rules are: - // -. If the installer doesn't request update ownership on initial installation, - // keep the update owner as null. - // -. If the installer doesn't want to be the owner to provide the subsequent - // update (doesn't request to be the update owner), e.g., non-store installer - // (file manager), ADB, or DO/PO, we should not update the owner. - // -. Else, the installer requests update ownership on initial installation or - // update, we use installSource.mUpdateOwnerPackageName as the update owner. - if (!isRequestUpdateOwnership || (isUpdate && !isUpdateOwnershipEnabled)) { - installSource = installSource.setUpdateOwnerPackageName(oldUpdateOwner); + final boolean isSameUpdateOwner = + TextUtils.equals(oldUpdateOwner, installSource.mInstallerPackageName); + + // Here we handle the update owner for the package, and the rules are: + // -. Only enabling update ownership enforcement on initial installation if the + // installer has requested. + // -. Once the installer changes and users agree to proceed, clear the update + // owner (package state in other users are taken into account as well). + if (!isUpdate) { + if (!isRequestUpdateOwnership) { + installSource = installSource.setUpdateOwnerPackageName(null); + } else if ((!isUpdateOwnershipEnabled && pkgAlreadyExists) + || (isUpdateOwnershipEnabled && !isSameUpdateOwner)) { + installSource = installSource.setUpdateOwnerPackageName(null); + } + } else if (!isSameUpdateOwner || !isUpdateOwnershipEnabled) { + installSource = installSource.setUpdateOwnerPackageName(null); } } pkgSetting.setInstallSource(installSource); - // non-standard install (addForInit and install existing packages), installSource is null. - } else if (updateOwnerFromSysconfig != null) { - // For system app, we always use the update owner from sysconfig if presented. - pkgSetting.setUpdateOwnerPackage(updateOwnerFromSysconfig); + // For non-standard install (addForInit), installSource is null. + } else if (pkgSetting.isSystem()) { + // We still honor the manifest attr if the system app wants to opt-out of it. + if (!isAllowUpdateOwnership) { + pkgSetting.setUpdateOwnerPackage(null); + } else { + final boolean isSameUpdateOwner = isUpdateOwnershipEnabled + && TextUtils.equals(oldUpdateOwner, updateOwnerFromSysconfig); + + // Here we handle the update owner for the system package, and the rules are: + // -. We use the update owner from sysconfig as the initial value. + // -. Once an app becomes to system app later via OTA, only retains the update + // owner if it's consistence with sysconfig. + // -. Clear the update owner when update owner changes from sysconfig. + if (!pkgAlreadyExists || isSameUpdateOwner) { + pkgSetting.setUpdateOwnerPackage(updateOwnerFromSysconfig); + } else { + pkgSetting.setUpdateOwnerPackage(null); + } + } } if ((scanFlags & SCAN_AS_APK_IN_APEX) != 0) { @@ -641,6 +678,18 @@ final class InstallPackageHelper { } if (installed) { + final String updateOwner = pkgSetting.getInstallSource().mUpdateOwnerPackageName; + final var dpmi = mInjector.getLocalService(DevicePolicyManagerInternal.class); + final boolean isFromManagedUserOrProfile = + dpmi != null && dpmi.isUserOrganizationManaged(userId); + // Here we handle the update owner when install existing package, and the rules are: + // -. Retain the update owner when enable a system app in managed user or profile. + // -. Retain the update owner if the installer is the same. + // -. Clear the update owner when update owner changes. + if (!preLockSnapshot.isCallerSameApp(updateOwner, callingUid) + && (!pkgSetting.isSystem() || !isFromManagedUserOrProfile)) { + pkgSetting.setUpdateOwnerPackage(null); + } if (pkgSetting.getPkg() != null) { final PermissionManagerServiceInternal.PackageInstalledParams.Builder permissionParamsBuilder = diff --git a/services/core/java/com/android/server/pm/PackageInstallerService.java b/services/core/java/com/android/server/pm/PackageInstallerService.java index 77ffa165b6ad..adc0b0b6fc6a 100644 --- a/services/core/java/com/android/server/pm/PackageInstallerService.java +++ b/services/core/java/com/android/server/pm/PackageInstallerService.java @@ -926,6 +926,11 @@ public class PackageInstallerService extends IPackageInstaller.Stub implements requestedInstallerPackageName = null; } + final var dpmi = LocalServices.getService(DevicePolicyManagerInternal.class); + if (dpmi != null && dpmi.isUserOrganizationManaged(userId)) { + params.installFlags |= PackageManager.INSTALL_FROM_MANAGED_USER_OR_PROFILE; + } + if (isApex || mContext.checkCallingOrSelfPermission( Manifest.permission.ENFORCE_UPDATE_OWNERSHIP) == PackageManager.PERMISSION_DENIED) { params.installFlags &= ~PackageManager.INSTALL_REQUEST_UPDATE_OWNERSHIP; diff --git a/services/core/java/com/android/server/pm/PackageInstallerSession.java b/services/core/java/com/android/server/pm/PackageInstallerSession.java index fb6ae8b50a26..fa535c38c5d2 100644 --- a/services/core/java/com/android/server/pm/PackageInstallerSession.java +++ b/services/core/java/com/android/server/pm/PackageInstallerSession.java @@ -868,15 +868,13 @@ public class PackageInstallerSession extends IPackageInstallerSession.Stub { private static final int USER_ACTION_NOT_NEEDED = 0; private static final int USER_ACTION_REQUIRED = 1; private static final int USER_ACTION_PENDING_APK_PARSING = 2; - private static final int USER_ACTION_REQUIRED_UPDATE_OWNER_CHANGED = 3; - private static final int USER_ACTION_REQUIRED_UPDATE_OWNER_RETAINED = 4; + private static final int USER_ACTION_REQUIRED_UPDATE_OWNER_REMINDER = 3; @IntDef({ USER_ACTION_NOT_NEEDED, USER_ACTION_REQUIRED, USER_ACTION_PENDING_APK_PARSING, - USER_ACTION_REQUIRED_UPDATE_OWNER_CHANGED, - USER_ACTION_REQUIRED_UPDATE_OWNER_RETAINED + USER_ACTION_REQUIRED_UPDATE_OWNER_REMINDER, }) @interface UserActionRequirement {} @@ -937,7 +935,7 @@ public class PackageInstallerSession extends IPackageInstallerSession.Stub { : null; final boolean isInstallerOfRecord = isUpdate && Objects.equals(existingInstallerPackageName, getInstallerPackageName()); - final boolean isUpdateOwner = Objects.equals(existingUpdateOwnerPackageName, + final boolean isUpdateOwner = TextUtils.equals(existingUpdateOwnerPackageName, getInstallerPackageName()); final boolean isSelfUpdate = targetPackageUid == mInstallerUid; final boolean isPermissionGranted = isInstallPermissionGranted @@ -947,6 +945,8 @@ public class PackageInstallerSession extends IPackageInstallerSession.Stub { final boolean isInstallerRoot = (mInstallerUid == Process.ROOT_UID); final boolean isInstallerSystem = (mInstallerUid == Process.SYSTEM_UID); final boolean isInstallerShell = (mInstallerUid == Process.SHELL_UID); + final boolean isFromManagedUserOrProfile = + (params.installFlags & PackageManager.INSTALL_FROM_MANAGED_USER_OR_PROFILE) != 0; final boolean isUpdateOwnershipEnforcementEnabled = mPm.isUpdateOwnershipEnforcementAvailable() && existingUpdateOwnerPackageName != null; @@ -963,12 +963,10 @@ public class PackageInstallerSession extends IPackageInstallerSession.Stub { if (isUpdateOwnershipEnforcementEnabled && !isApexSession() && !isUpdateOwner - && !isInstallerShell) { - final boolean isRequestUpdateOwner = - (params.installFlags & PackageManager.INSTALL_REQUEST_UPDATE_OWNERSHIP) != 0; - - return isRequestUpdateOwner ? USER_ACTION_REQUIRED_UPDATE_OWNER_CHANGED - : USER_ACTION_REQUIRED_UPDATE_OWNER_RETAINED; + && !isInstallerShell + // We don't enforce the update ownership for the managed user and profile. + && !isFromManagedUserOrProfile) { + return USER_ACTION_REQUIRED_UPDATE_OWNER_REMINDER; } if (isPermissionGranted) { @@ -2361,8 +2359,7 @@ public class PackageInstallerSession extends IPackageInstallerSession.Stub { userActionRequirement = session.computeUserActionRequirement(); session.updateUserActionRequirement(userActionRequirement); if (userActionRequirement == USER_ACTION_REQUIRED - || userActionRequirement == USER_ACTION_REQUIRED_UPDATE_OWNER_CHANGED - || userActionRequirement == USER_ACTION_REQUIRED_UPDATE_OWNER_RETAINED) { + || userActionRequirement == USER_ACTION_REQUIRED_UPDATE_OWNER_REMINDER) { session.sendPendingUserActionIntent(target); return true; } @@ -2425,9 +2422,7 @@ public class PackageInstallerSession extends IPackageInstallerSession.Stub { private static @UserActionReason int userActionRequirementToReason( @UserActionRequirement int requirement) { switch (requirement) { - case USER_ACTION_REQUIRED_UPDATE_OWNER_CHANGED: - return PackageInstaller.REASON_OWNERSHIP_CHANGED; - case USER_ACTION_REQUIRED_UPDATE_OWNER_RETAINED: + case USER_ACTION_REQUIRED_UPDATE_OWNER_REMINDER: return PackageInstaller.REASON_REMIND_OWNERSHIP; default: return PackageInstaller.REASON_CONFIRM_PACKAGE_CHANGE; diff --git a/services/core/java/com/android/server/pm/RestrictionsSet.java b/services/core/java/com/android/server/pm/RestrictionsSet.java index e7ad5b92ed2e..08047695a42a 100644 --- a/services/core/java/com/android/server/pm/RestrictionsSet.java +++ b/services/core/java/com/android/server/pm/RestrictionsSet.java @@ -20,7 +20,9 @@ import android.annotation.NonNull; import android.annotation.Nullable; import android.annotation.UserIdInt; import android.os.Bundle; +import android.os.UserHandle; import android.os.UserManager; +import android.util.IntArray; import android.util.SparseArray; import com.android.internal.annotations.VisibleForTesting; @@ -37,9 +39,7 @@ import java.util.ArrayList; import java.util.List; /** - * Data structure that contains the mapping of users to user restrictions (either the user - * restrictions that apply to them, or the user restrictions that they set, depending on the - * circumstances). + * Data structure that contains the mapping of users to user restrictions. * * @hide */ @@ -88,6 +88,24 @@ public class RestrictionsSet { } /** + * Removes a particular restriction for all users. + * + * @return whether the restriction was removed or not. + */ + public boolean removeRestrictionsForAllUsers(String restriction) { + boolean removed = false; + for (int i = 0; i < mUserRestrictions.size(); i++) { + final Bundle restrictions = mUserRestrictions.valueAt(i); + + if (UserRestrictionsUtils.contains(restrictions, restriction)) { + restrictions.remove(restriction); + removed = true; + } + } + return removed; + } + + /** * Moves a particular restriction from one restriction set to another, e.g. for all users. */ public void moveRestriction(@NonNull RestrictionsSet destRestrictions, String restriction) { @@ -139,22 +157,19 @@ public class RestrictionsSet { * @return list of enforcing users that enforce a particular restriction. */ public @NonNull List<UserManager.EnforcingUser> getEnforcingUsers(String restriction, - @UserIdInt int deviceOwnerUserId) { + @UserIdInt int userId) { final List<UserManager.EnforcingUser> result = new ArrayList<>(); - for (int i = 0; i < mUserRestrictions.size(); i++) { - if (UserRestrictionsUtils.contains(mUserRestrictions.valueAt(i), restriction)) { - result.add(getEnforcingUser(mUserRestrictions.keyAt(i), deviceOwnerUserId)); - } + if (getRestrictionsNonNull(userId).containsKey(restriction)) { + result.add(new UserManager.EnforcingUser(userId, + UserManager.RESTRICTION_SOURCE_PROFILE_OWNER)); + } + + if (getRestrictionsNonNull(UserHandle.USER_ALL).containsKey(restriction)) { + result.add(new UserManager.EnforcingUser(UserHandle.USER_ALL, + UserManager.RESTRICTION_SOURCE_DEVICE_OWNER)); } - return result; - } - private UserManager.EnforcingUser getEnforcingUser(@UserIdInt int userId, - @UserIdInt int deviceOwnerUserId) { - int source = deviceOwnerUserId == userId - ? UserManager.RESTRICTION_SOURCE_DEVICE_OWNER - : UserManager.RESTRICTION_SOURCE_PROFILE_OWNER; - return new UserManager.EnforcingUser(userId, source); + return result; } /** @@ -165,6 +180,11 @@ public class RestrictionsSet { return mUserRestrictions.get(userId); } + /** @return list of user restrictions for a given user that is not null. */ + public @NonNull Bundle getRestrictionsNonNull(@UserIdInt int userId) { + return UserRestrictionsUtils.nonNull(mUserRestrictions.get(userId)); + } + /** * Removes a given user from the restrictions set, returning true if the user has non-empty * restrictions before removal. @@ -236,6 +256,15 @@ public class RestrictionsSet { } } + /** @return list of users in this restriction set. */ + public IntArray getUserIds() { + IntArray userIds = new IntArray(mUserRestrictions.size()); + for (int i = 0; i < mUserRestrictions.size(); i++) { + userIds.add(mUserRestrictions.keyAt(i)); + } + return userIds; + } + public boolean containsKey(@UserIdInt int userId) { return mUserRestrictions.contains(userId); } diff --git a/services/core/java/com/android/server/pm/UserManagerInternal.java b/services/core/java/com/android/server/pm/UserManagerInternal.java index 36efc0ddfc44..9ef1bba16351 100644 --- a/services/core/java/com/android/server/pm/UserManagerInternal.java +++ b/services/core/java/com/android/server/pm/UserManagerInternal.java @@ -141,6 +141,18 @@ public abstract class UserManagerInternal { public abstract void setDevicePolicyUserRestrictions(int originatingUserId, @Nullable Bundle global, @Nullable RestrictionsSet local, boolean isDeviceOwner); + /** + * Called by {@link com.android.server.devicepolicy.DevicePolicyManagerService} to set a + * user restriction. + * + * @param userId user id to apply the restriction to. {@link com.android.os.UserHandle.USER_ALL} + * will apply the restriction to all users globally. + * @param key The key of the restriction. + * @param value The value of the restriction. + */ + public abstract void setUserRestriction(@UserIdInt int userId, @NonNull String key, + boolean value); + /** Return a user restriction. */ public abstract boolean getUserRestriction(int userId, String key); diff --git a/services/core/java/com/android/server/pm/UserManagerService.java b/services/core/java/com/android/server/pm/UserManagerService.java index 19a0e03a9329..58ae95568e3b 100644 --- a/services/core/java/com/android/server/pm/UserManagerService.java +++ b/services/core/java/com/android/server/pm/UserManagerService.java @@ -457,30 +457,12 @@ public class UserManagerService extends IUserManager.Stub { /** * User restrictions set by {@link com.android.server.devicepolicy.DevicePolicyManagerService} - * that should be applied to all users, including guests. Only non-empty restriction bundles are - * stored. - * The key is the user id of the user whom the restriction originated from. - */ - @GuardedBy("mRestrictionsLock") - private final RestrictionsSet mDevicePolicyGlobalUserRestrictions = new RestrictionsSet(); - - /** - * Id of the user that set global restrictions. - */ - @GuardedBy("mRestrictionsLock") - private int mDeviceOwnerUserId = UserHandle.USER_NULL; - - /** - * User restrictions set by {@link com.android.server.devicepolicy.DevicePolicyManagerService} - * for each user. + * for each user. Restrictions that apply to all users (global) are represented by + * {@link com.android.os.UserHandle.USER_ALL}. * The key is the user id of the user whom the restrictions are targeting. - * The key inside the restrictionsSet is the user id of the user whom the restriction - * originated from. - * targetUserId -> originatingUserId -> restrictionBundle */ @GuardedBy("mRestrictionsLock") - private final SparseArray<RestrictionsSet> mDevicePolicyLocalUserRestrictions = - new SparseArray<>(); + private final RestrictionsSet mDevicePolicyUserRestrictions = new RestrictionsSet(); @GuardedBy("mGuestRestrictions") private final Bundle mGuestRestrictions = new Bundle(); @@ -2567,150 +2549,69 @@ public class UserManagerService extends IUserManager.Stub { } } - /** - * See {@link UserManagerInternal#setDevicePolicyUserRestrictions} - */ - private void setDevicePolicyUserRestrictionsInner(@UserIdInt int originatingUserId, - @NonNull Bundle global, @NonNull RestrictionsSet local, - boolean isDeviceOwner) { - boolean globalChanged, localChanged; - List<Integer> updatedLocalTargetUserIds; - synchronized (mRestrictionsLock) { - // Update global and local restrictions if they were changed. - globalChanged = mDevicePolicyGlobalUserRestrictions - .updateRestrictions(originatingUserId, global); - updatedLocalTargetUserIds = getUpdatedTargetUserIdsFromLocalRestrictions( - originatingUserId, local); - localChanged = updateLocalRestrictionsForTargetUsersLR(originatingUserId, local, - updatedLocalTargetUserIds); - if (isDeviceOwner) { - // Remember the global restriction owner userId to be able to make a distinction - // in getUserRestrictionSource on who set local policies. - mDeviceOwnerUserId = originatingUserId; - } else { - if (mDeviceOwnerUserId == originatingUserId) { - // When profile owner sets restrictions it passes null global bundle and we - // reset global restriction owner userId. - // This means this user used to have DO, but now the DO is gone and the user - // instead has PO. - mDeviceOwnerUserId = UserHandle.USER_NULL; - } - } - } - if (DBG) { - Slog.d(LOG_TAG, "setDevicePolicyUserRestrictions: " - + " originatingUserId=" + originatingUserId - + " global=" + global + (globalChanged ? " (changed)" : "") - + " local=" + local + (localChanged ? " (changed)" : "") - ); - } - // Don't call them within the mRestrictionsLock. - synchronized (mPackagesLock) { - if (globalChanged || localChanged) { - if (updatedLocalTargetUserIds.size() == 1 - && updatedLocalTargetUserIds.contains(originatingUserId)) { - writeUserLP(getUserDataNoChecks(originatingUserId)); - } else { - if (globalChanged) { - writeUserLP(getUserDataNoChecks(originatingUserId)); - } - if (localChanged) { - for (int targetUserId : updatedLocalTargetUserIds) { - writeAllTargetUsersLP(targetUserId); - } - } - } - } + private void setUserRestrictionInner(int userId, @NonNull String key, boolean value) { + if (!UserRestrictionsUtils.isValidRestriction(key)) { + return; } - synchronized (mRestrictionsLock) { - if (globalChanged) { - applyUserRestrictionsForAllUsersLR(); - } else if (localChanged) { - for (int targetUserId : updatedLocalTargetUserIds) { - applyUserRestrictionsLR(targetUserId); + final Bundle newRestrictions = BundleUtils.clone( + mDevicePolicyUserRestrictions.getRestrictions(userId)); + newRestrictions.putBoolean(key, value); + + if (mDevicePolicyUserRestrictions.updateRestrictions(userId, newRestrictions)) { + if (userId == UserHandle.USER_ALL) { + applyUserRestrictionsForAllUsersLR(); + } else { + applyUserRestrictionsLR(userId); } } } } /** - * @return the list of updated target user ids in device policy local restrictions for a - * given originating user id. + * See {@link UserManagerInternal#setDevicePolicyUserRestrictions} */ - private List<Integer> getUpdatedTargetUserIdsFromLocalRestrictions(int originatingUserId, - @NonNull RestrictionsSet local) { - List<Integer> targetUserIds = new ArrayList<>(); - // Update all the target user ids from the local restrictions set - for (int i = 0; i < local.size(); i++) { - targetUserIds.add(local.keyAt(i)); - } - // Update the target user id from device policy local restrictions if the local - // restrictions set does not contain the target user id. - for (int i = 0; i < mDevicePolicyLocalUserRestrictions.size(); i++) { - int targetUserId = mDevicePolicyLocalUserRestrictions.keyAt(i); - RestrictionsSet restrictionsSet = mDevicePolicyLocalUserRestrictions.valueAt(i); - if (!local.containsKey(targetUserId) - && restrictionsSet.containsKey(originatingUserId)) { - targetUserIds.add(targetUserId); - } - } - return targetUserIds; - } + private void setDevicePolicyUserRestrictionsInner(@UserIdInt int originatingUserId, + @NonNull Bundle global, @NonNull RestrictionsSet local, + boolean isDeviceOwner) { + synchronized (mRestrictionsLock) { + final IntArray updatedUserIds = mDevicePolicyUserRestrictions.getUserIds(); - /** - * Update restrictions for all target users in the restriction set. If a target user does not - * exist in device policy local restrictions, remove the restrictions bundle for that target - * user originating from the specified originating user. - */ - @GuardedBy("mRestrictionsLock") - private boolean updateLocalRestrictionsForTargetUsersLR(int originatingUserId, - RestrictionsSet local, List<Integer> updatedTargetUserIds) { - boolean changed = false; - for (int targetUserId : updatedTargetUserIds) { - Bundle restrictions = local.getRestrictions(targetUserId); - if (restrictions == null) { - restrictions = new Bundle(); - } - if (getDevicePolicyLocalRestrictionsForTargetUserLR(targetUserId) - .updateRestrictions(originatingUserId, restrictions)) { - changed = true; + mCachedEffectiveUserRestrictions.removeAllRestrictions(); + mDevicePolicyUserRestrictions.removeAllRestrictions(); + + mDevicePolicyUserRestrictions.updateRestrictions(UserHandle.USER_ALL, global); + + final IntArray localUserIds = local.getUserIds(); + for (int i = 0; i < localUserIds.size(); i++) { + final int userId = localUserIds.get(i); + mDevicePolicyUserRestrictions.updateRestrictions(userId, + local.getRestrictions(userId)); + updatedUserIds.add(userId); } - } - return changed; - } - /** - * A new restriction set is created if a restriction set does not already exist for a given - * target user. - * - * @return restrictions set for a given target user. - */ - @GuardedBy("mRestrictionsLock") - private @NonNull RestrictionsSet getDevicePolicyLocalRestrictionsForTargetUserLR( - int targetUserId) { - RestrictionsSet result = mDevicePolicyLocalUserRestrictions.get(targetUserId); - if (result == null) { - result = new RestrictionsSet(); - mDevicePolicyLocalUserRestrictions.put(targetUserId, result); + applyUserRestrictionsForAllUsersLR(); + for (int i = 0; i < updatedUserIds.size(); i++) { + applyUserRestrictionsLR(updatedUserIds.get(i)); + } } - return result; } @GuardedBy("mRestrictionsLock") private Bundle computeEffectiveUserRestrictionsLR(@UserIdInt int userId) { - final Bundle baseRestrictions = - UserRestrictionsUtils.nonNull(mBaseUserRestrictions.getRestrictions(userId)); - final Bundle global = mDevicePolicyGlobalUserRestrictions.mergeAll(); - final RestrictionsSet local = getDevicePolicyLocalRestrictionsForTargetUserLR(userId); + final Bundle baseRestrictions = mBaseUserRestrictions.getRestrictionsNonNull(userId); - if (BundleUtils.isEmpty(global) && local.isEmpty()) { + final Bundle global = mDevicePolicyUserRestrictions.getRestrictionsNonNull( + UserHandle.USER_ALL); + final Bundle local = mDevicePolicyUserRestrictions.getRestrictionsNonNull(userId); + + if (global.isEmpty() && local.isEmpty()) { // Common case first. return baseRestrictions; } final Bundle effective = BundleUtils.clone(baseRestrictions); UserRestrictionsUtils.merge(effective, global); - UserRestrictionsUtils.merge(effective, local.mergeAll()); + UserRestrictionsUtils.merge(effective, local); return effective; } @@ -2834,13 +2735,7 @@ public class UserManagerService extends IUserManager.Stub { } synchronized (mRestrictionsLock) { - // Check if it is set as a local restriction. - result.addAll(getDevicePolicyLocalRestrictionsForTargetUserLR(userId).getEnforcingUsers( - restrictionKey, mDeviceOwnerUserId)); - - // Check if it is set as a global restriction. - result.addAll(mDevicePolicyGlobalUserRestrictions.getEnforcingUsers(restrictionKey, - mDeviceOwnerUserId)); + result.addAll(mDevicePolicyUserRestrictions.getEnforcingUsers(restrictionKey, userId)); } return result; } @@ -2990,6 +2885,7 @@ public class UserManagerService extends IUserManager.Stub { @GuardedBy("mRestrictionsLock") private void applyUserRestrictionsLR(@UserIdInt int userId) { updateUserRestrictionsInternalLR(null, userId); + scheduleWriteUser(getUserDataNoChecks(userId)); } @GuardedBy("mRestrictionsLock") @@ -3666,10 +3562,6 @@ public class UserManagerService extends IUserManager.Stub { parser.getAttributeInt(null, ATTR_USER_TYPE_VERSION, mUserTypeVersion); } - // Pre-O global user restriction were stored as a single bundle (as opposed to per-user - // currently), take care of it in case of upgrade. - Bundle oldDevicePolicyGlobalUserRestrictions = null; - while ((type = parser.next()) != XmlPullParser.END_DOCUMENT) { if (type == XmlPullParser.START_TAG) { final String name = parser.getName(); @@ -3698,23 +3590,12 @@ public class UserManagerService extends IUserManager.Stub { break; } } - } else if (name.equals(TAG_DEVICE_OWNER_USER_ID) - // Legacy name, should only be encountered when upgrading from pre-O. - || name.equals(TAG_GLOBAL_RESTRICTION_OWNER_ID)) { - synchronized (mRestrictionsLock) { - mDeviceOwnerUserId = - parser.getAttributeInt(null, ATTR_ID, mDeviceOwnerUserId); - } - } else if (name.equals(TAG_DEVICE_POLICY_RESTRICTIONS)) { - // Should only happen when upgrading from pre-O (version < 7). - oldDevicePolicyGlobalUserRestrictions = - UserRestrictionsUtils.readRestrictions(parser); } } } updateUserIds(); - upgradeIfNecessaryLP(oldDevicePolicyGlobalUserRestrictions); + upgradeIfNecessaryLP(); } catch (IOException | XmlPullParserException e) { fallbackToSingleUserLP(); } finally { @@ -3724,21 +3605,19 @@ public class UserManagerService extends IUserManager.Stub { /** * Upgrade steps between versions, either for fixing bugs or changing the data format. - * @param oldGlobalUserRestrictions Pre-O global device policy restrictions. */ @GuardedBy({"mPackagesLock"}) - private void upgradeIfNecessaryLP(Bundle oldGlobalUserRestrictions) { - upgradeIfNecessaryLP(oldGlobalUserRestrictions, mUserVersion, mUserTypeVersion); + private void upgradeIfNecessaryLP() { + upgradeIfNecessaryLP(mUserVersion, mUserTypeVersion); } /** - * Version of {@link #upgradeIfNecessaryLP(Bundle)} that takes in the userVersion for testing - * purposes. For non-tests, use {@link #upgradeIfNecessaryLP(Bundle)}. + * Version of {@link #upgradeIfNecessaryLP()} that takes in the userVersion for testing + * purposes. For non-tests, use {@link #upgradeIfNecessaryLP()}. */ @GuardedBy({"mPackagesLock"}) @VisibleForTesting - void upgradeIfNecessaryLP(Bundle oldGlobalUserRestrictions, int userVersion, - int userTypeVersion) { + void upgradeIfNecessaryLP(int userVersion, int userTypeVersion) { Slog.i(LOG_TAG, "Upgrading users from userVersion " + userVersion + " to " + USER_VERSION); Set<Integer> userIdsToWrite = new ArraySet<>(); final int originalVersion = mUserVersion; @@ -3792,16 +3671,11 @@ public class UserManagerService extends IUserManager.Stub { if (userVersion < 7) { // Previously only one user could enforce global restrictions, now it is per-user. synchronized (mRestrictionsLock) { - if (!BundleUtils.isEmpty(oldGlobalUserRestrictions) - && mDeviceOwnerUserId != UserHandle.USER_NULL) { - mDevicePolicyGlobalUserRestrictions.updateRestrictions( - mDeviceOwnerUserId, oldGlobalUserRestrictions); + if (mDevicePolicyUserRestrictions.removeRestrictionsForAllUsers( + UserManager.ENSURE_VERIFY_APPS)) { + mDevicePolicyUserRestrictions.getRestrictionsNonNull(UserHandle.USER_ALL) + .putBoolean(UserManager.ENSURE_VERIFY_APPS, true); } - // ENSURE_VERIFY_APPS is now enforced globally even if put by profile owner, so move - // it from local to global bundle for all users who set it. - UserRestrictionsUtils.moveRestriction(UserManager.ENSURE_VERIFY_APPS, - mDevicePolicyLocalUserRestrictions, mDevicePolicyGlobalUserRestrictions - ); } // DISALLOW_CONFIG_WIFI was made a default guest restriction some time during version 6. final List<UserInfo> guestUsers = getGuestUsers(); @@ -4064,22 +3938,22 @@ public class UserManagerService extends IUserManager.Stub { @GuardedBy({"mPackagesLock"}) private void fallbackToSingleUserLP() { - int flags = UserInfo.FLAG_SYSTEM | UserInfo.FLAG_INITIALIZED | UserInfo.FLAG_ADMIN - | UserInfo.FLAG_PRIMARY; // Create the system user - String systemUserType = isDefaultHeadlessSystemUserMode() + final String systemUserType = isDefaultHeadlessSystemUserMode() ? UserManager.USER_TYPE_SYSTEM_HEADLESS : UserManager.USER_TYPE_FULL_SYSTEM; - flags |= mUserTypes.get(systemUserType).getDefaultUserInfoFlags(); - UserInfo system = new UserInfo(UserHandle.USER_SYSTEM, null, null, flags, systemUserType); - UserData userData = putUserInfo(system); + final int flags = mUserTypes.get(systemUserType).getDefaultUserInfoFlags() + | UserInfo.FLAG_INITIALIZED; + final UserInfo system = new UserInfo(UserHandle.USER_SYSTEM, + /* name= */ null, /* iconPath= */ null, flags, systemUserType); + final UserData userData = putUserInfo(system); userData.userProperties = new UserProperties( mUserTypes.get(userData.info.userType).getDefaultUserPropertiesReference()); mNextSerialNumber = MIN_USER_ID; mUserVersion = USER_VERSION; mUserTypeVersion = UserTypeFactory.getUserTypeVersion(); - Bundle restrictions = new Bundle(); + final Bundle restrictions = new Bundle(); try { final String[] defaultFirstUserRestrictions = mContext.getResources().getStringArray( com.android.internal.R.array.config_defaultFirstUserRestrictions); @@ -4135,17 +4009,6 @@ public class UserManagerService extends IUserManager.Stub { } @GuardedBy({"mPackagesLock"}) - private void writeAllTargetUsersLP(int originatingUserId) { - for (int i = 0; i < mDevicePolicyLocalUserRestrictions.size(); i++) { - int targetUserId = mDevicePolicyLocalUserRestrictions.keyAt(i); - RestrictionsSet restrictionsSet = mDevicePolicyLocalUserRestrictions.valueAt(i); - if (restrictionsSet.containsKey(originatingUserId)) { - writeUserLP(getUserDataNoChecks(targetUserId)); - } - } - } - - @GuardedBy({"mPackagesLock"}) private void writeUserLP(UserData userData) { if (DBG) { debug("writeUserLP " + userData); @@ -4231,11 +4094,14 @@ public class UserManagerService extends IUserManager.Stub { synchronized (mRestrictionsLock) { UserRestrictionsUtils.writeRestrictions(serializer, mBaseUserRestrictions.getRestrictions(userInfo.id), TAG_RESTRICTIONS); - getDevicePolicyLocalRestrictionsForTargetUserLR(userInfo.id).writeRestrictions( - serializer, TAG_DEVICE_POLICY_LOCAL_RESTRICTIONS); + + UserRestrictionsUtils.writeRestrictions(serializer, + mDevicePolicyUserRestrictions.getRestrictions(UserHandle.USER_ALL), + TAG_DEVICE_POLICY_RESTRICTIONS); + UserRestrictionsUtils.writeRestrictions(serializer, - mDevicePolicyGlobalUserRestrictions.getRestrictions(userInfo.id), - TAG_DEVICE_POLICY_GLOBAL_RESTRICTIONS); + mDevicePolicyUserRestrictions.getRestrictions(userInfo.id), + TAG_DEVICE_POLICY_RESTRICTIONS); } if (userData.account != null) { @@ -4303,11 +4169,6 @@ public class UserManagerService extends IUserManager.Stub { .writeRestrictions(serializer, mGuestRestrictions, TAG_RESTRICTIONS); } serializer.endTag(null, TAG_GUEST_RESTRICTIONS); - serializer.startTag(null, TAG_DEVICE_OWNER_USER_ID); - synchronized (mRestrictionsLock) { - serializer.attributeInt(null, ATTR_ID, mDeviceOwnerUserId); - } - serializer.endTag(null, TAG_DEVICE_OWNER_USER_ID); int[] userIdsToWrite; synchronized (mUsersLock) { userIdsToWrite = new int[mUsers.size()]; @@ -4379,7 +4240,7 @@ public class UserManagerService extends IUserManager.Stub { UserProperties userProperties = null; Bundle baseRestrictions = null; Bundle legacyLocalRestrictions = null; - RestrictionsSet localRestrictions = null; + Bundle localRestrictions = null; Bundle globalRestrictions = null; boolean ignorePrepareStorageErrors = true; // default is true for old users @@ -4445,8 +4306,7 @@ public class UserManagerService extends IUserManager.Stub { } else if (TAG_DEVICE_POLICY_RESTRICTIONS.equals(tag)) { legacyLocalRestrictions = UserRestrictionsUtils.readRestrictions(parser); } else if (TAG_DEVICE_POLICY_LOCAL_RESTRICTIONS.equals(tag)) { - localRestrictions = RestrictionsSet.readRestrictions(parser, - TAG_DEVICE_POLICY_LOCAL_RESTRICTIONS); + localRestrictions = UserRestrictionsUtils.readRestrictions(parser); } else if (TAG_DEVICE_POLICY_GLOBAL_RESTRICTIONS.equals(tag)) { globalRestrictions = UserRestrictionsUtils.readRestrictions(parser); } else if (TAG_ACCOUNT.equals(tag)) { @@ -4516,19 +4376,15 @@ public class UserManagerService extends IUserManager.Stub { mBaseUserRestrictions.updateRestrictions(id, baseRestrictions); } if (localRestrictions != null) { - mDevicePolicyLocalUserRestrictions.put(id, localRestrictions); + mDevicePolicyUserRestrictions.updateRestrictions(id, localRestrictions); if (legacyLocalRestrictions != null) { Slog.wtf(LOG_TAG, "Seeing both legacy and current local restrictions in xml"); } } else if (legacyLocalRestrictions != null) { - RestrictionsSet legacyLocalRestrictionsSet = - legacyLocalRestrictions.isEmpty() - ? new RestrictionsSet() - : new RestrictionsSet(id, legacyLocalRestrictions); - mDevicePolicyLocalUserRestrictions.put(id, legacyLocalRestrictionsSet); + mDevicePolicyUserRestrictions.updateRestrictions(id, legacyLocalRestrictions); } if (globalRestrictions != null) { - mDevicePolicyGlobalUserRestrictions.updateRestrictions(id, + mDevicePolicyUserRestrictions.updateRestrictions(UserHandle.USER_ALL, globalRestrictions); } } @@ -5364,18 +5220,12 @@ public class UserManagerService extends IUserManager.Stub { } } else if (atomTag == FrameworkStatsLog.MULTI_USER_INFO) { if (UserManager.getMaxSupportedUsers() > 1) { - int deviceOwnerUserId = UserHandle.USER_NULL; - - synchronized (mRestrictionsLock) { - deviceOwnerUserId = mDeviceOwnerUserId; - } - data.add(FrameworkStatsLog.buildStatsEvent(FrameworkStatsLog.MULTI_USER_INFO, UserManager.getMaxSupportedUsers(), - isUserSwitcherEnabled(deviceOwnerUserId), + isUserSwitcherEnabled(UserHandle.USER_ALL), UserManager.supportsMultipleUsers() && !hasUserRestriction(UserManager.DISALLOW_ADD_USER, - deviceOwnerUserId))); + UserHandle.USER_ALL))); } } else { Slogf.e(LOG_TAG, "Unexpected atom tag: %d", atomTag); @@ -5843,17 +5693,8 @@ public class UserManagerService extends IUserManager.Stub { mBaseUserRestrictions.remove(userId); mAppliedUserRestrictions.remove(userId); mCachedEffectiveUserRestrictions.remove(userId); - // Remove local restrictions affecting user - mDevicePolicyLocalUserRestrictions.delete(userId); - // Remove local restrictions set by user - boolean changed = false; - for (int i = 0; i < mDevicePolicyLocalUserRestrictions.size(); i++) { - int targetUserId = mDevicePolicyLocalUserRestrictions.keyAt(i); - changed |= getDevicePolicyLocalRestrictionsForTargetUserLR(targetUserId) - .remove(userId); - } - changed |= mDevicePolicyGlobalUserRestrictions.remove(userId); - if (changed) { + // Remove restrictions affecting the user + if (mDevicePolicyUserRestrictions.remove(userId)) { applyUserRestrictionsForAllUsersLR(); } } @@ -6587,10 +6428,12 @@ public class UserManagerService extends IUserManager.Stub { pw.println(); pw.println("Device properties:"); + pw.println(" Device policy global restrictions:"); synchronized (mRestrictionsLock) { - pw.println(" Device owner id:" + mDeviceOwnerUserId); + UserRestrictionsUtils.dumpRestrictions( + pw, " ", + mDevicePolicyUserRestrictions.getRestrictions(UserHandle.USER_ALL)); } - pw.println(); pw.println(" Guest restrictions:"); synchronized (mGuestRestrictions) { UserRestrictionsUtils.dumpRestrictions(pw, " ", mGuestRestrictions); @@ -6768,13 +6611,10 @@ public class UserManagerService extends IUserManager.Stub { synchronized (mRestrictionsLock) { UserRestrictionsUtils.dumpRestrictions( pw, " ", mBaseUserRestrictions.getRestrictions(userInfo.id)); - pw.println(" Device policy global restrictions:"); + pw.println(" Device policy restrictions:"); UserRestrictionsUtils.dumpRestrictions( pw, " ", - mDevicePolicyGlobalUserRestrictions.getRestrictions(userInfo.id)); - pw.println(" Device policy local restrictions:"); - getDevicePolicyLocalRestrictionsForTargetUserLR( - userInfo.id).dumpRestrictions(pw, " "); + mDevicePolicyUserRestrictions.getRestrictions(userInfo.id)); pw.println(" Effective restrictions:"); UserRestrictionsUtils.dumpRestrictions( pw, " ", @@ -6857,6 +6697,11 @@ public class UserManagerService extends IUserManager.Stub { } @Override + public void setUserRestriction(int userId, @NonNull String key, boolean value) { + UserManagerService.this.setUserRestrictionInner(userId, key, value); + } + + @Override public boolean getUserRestriction(@UserIdInt int userId, String key) { return getUserRestrictions(userId).getBoolean(key); } diff --git a/services/core/java/com/android/server/pm/UserTypeDetails.java b/services/core/java/com/android/server/pm/UserTypeDetails.java index f86ee9032ee9..6065372e1ea0 100644 --- a/services/core/java/com/android/server/pm/UserTypeDetails.java +++ b/services/core/java/com/android/server/pm/UserTypeDetails.java @@ -76,7 +76,7 @@ public final class UserTypeDetails { private final @UserInfoFlag int mBaseType; // TODO(b/143784345): Update doc/name when we clean up UserInfo. - /** The {@link UserInfo.UserInfoFlag}s that all users of this type will automatically have. */ + /** The {@link UserInfoFlag}s to apply by default to newly created users of this type. */ private final @UserInfoFlag int mDefaultUserInfoPropertyFlags; /** @@ -224,7 +224,7 @@ public final class UserTypeDetails { } // TODO(b/143784345): Update comment when UserInfo is reorganized. - /** The {@link UserInfo.UserInfoFlag}s that all users of this type will automatically have. */ + /** The {@link UserInfoFlag}s to apply by default to newly created users of this type. */ public int getDefaultUserInfoFlags() { return mDefaultUserInfoPropertyFlags | mBaseType; } @@ -526,6 +526,7 @@ public final class UserTypeDetails { Preconditions.checkArgument(hasValidPropertyFlags(), "UserTypeDetails " + mName + " has invalid flags: " + Integer.toHexString(mDefaultUserInfoPropertyFlags)); + checkSystemAndMainUserPreconditions(); if (hasBadge()) { Preconditions.checkArgument(mBadgeLabels != null && mBadgeLabels.length != 0, "UserTypeDetails " + mName + " has badge but no badgeLabels."); @@ -578,8 +579,6 @@ public final class UserTypeDetails { // TODO(b/143784345): Refactor this when we clean up UserInfo. private boolean hasValidPropertyFlags() { final int forbiddenMask = - UserInfo.FLAG_PRIMARY | - UserInfo.FLAG_ADMIN | UserInfo.FLAG_INITIALIZED | UserInfo.FLAG_QUIET_MODE | UserInfo.FLAG_FULL | @@ -587,6 +586,18 @@ public final class UserTypeDetails { UserInfo.FLAG_PROFILE; return (mDefaultUserInfoPropertyFlags & forbiddenMask) == 0; } + + private void checkSystemAndMainUserPreconditions() { + // Primary must be synonymous with System. + Preconditions.checkArgument( + ((mBaseType & UserInfo.FLAG_SYSTEM) != 0) == + ((mDefaultUserInfoPropertyFlags & UserInfo.FLAG_PRIMARY) != 0), + "UserTypeDetails " + mName + " cannot be SYSTEM xor PRIMARY."); + // At most one MainUser is ever allowed at a time. + Preconditions.checkArgument( + ((mDefaultUserInfoPropertyFlags & UserInfo.FLAG_MAIN) == 0) || mMaxAllowed == 1, + "UserTypeDetails " + mName + " must not sanction more than one MainUser."); + } } /** diff --git a/services/core/java/com/android/server/pm/UserTypeFactory.java b/services/core/java/com/android/server/pm/UserTypeFactory.java index 4cf8c0960a87..b7a2b86b1bcd 100644 --- a/services/core/java/com/android/server/pm/UserTypeFactory.java +++ b/services/core/java/com/android/server/pm/UserTypeFactory.java @@ -16,11 +16,14 @@ package com.android.server.pm; +import static android.content.pm.UserInfo.FLAG_ADMIN; import static android.content.pm.UserInfo.FLAG_DEMO; import static android.content.pm.UserInfo.FLAG_EPHEMERAL; import static android.content.pm.UserInfo.FLAG_FULL; import static android.content.pm.UserInfo.FLAG_GUEST; +import static android.content.pm.UserInfo.FLAG_MAIN; import static android.content.pm.UserInfo.FLAG_MANAGED_PROFILE; +import static android.content.pm.UserInfo.FLAG_PRIMARY; import static android.content.pm.UserInfo.FLAG_PROFILE; import static android.content.pm.UserInfo.FLAG_RESTRICTED; import static android.content.pm.UserInfo.FLAG_SYSTEM; @@ -62,7 +65,7 @@ import java.util.function.Consumer; * This class is responsible both for defining the AOSP use types, as well as reading in customized * user types from {@link com.android.internal.R.xml#config_user_types}. * - * Tests are located in UserManagerServiceUserTypeTest.java. + * Tests are located in {@link UserManagerServiceUserTypeTest}. * @hide */ public final class UserTypeFactory { @@ -277,7 +280,8 @@ public final class UserTypeFactory { return new UserTypeDetails.Builder() .setName(USER_TYPE_FULL_SYSTEM) .setBaseType(FLAG_SYSTEM | FLAG_FULL) - .setDefaultUserInfoPropertyFlags(UserInfo.FLAG_MAIN); + .setDefaultUserInfoPropertyFlags(FLAG_PRIMARY | FLAG_ADMIN | FLAG_MAIN) + .setMaxAllowed(1); } /** @@ -287,7 +291,9 @@ public final class UserTypeFactory { private static UserTypeDetails.Builder getDefaultTypeSystemHeadless() { return new UserTypeDetails.Builder() .setName(USER_TYPE_SYSTEM_HEADLESS) - .setBaseType(FLAG_SYSTEM); + .setBaseType(FLAG_SYSTEM) + .setDefaultUserInfoPropertyFlags(FLAG_PRIMARY | FLAG_ADMIN) + .setMaxAllowed(1); } private static Bundle getDefaultSecondaryUserRestrictions() { 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 78761bdbabf1..cc2c9adfcba4 100644 --- a/services/core/java/com/android/server/pm/permission/PermissionManagerServiceImpl.java +++ b/services/core/java/com/android/server/pm/permission/PermissionManagerServiceImpl.java @@ -3673,9 +3673,9 @@ public class PermissionManagerServiceImpl implements PermissionManagerServiceInt isAppOpPermission = bp.isAppOp(); } + final int flags = getPermissionFlagsInternal(pkg.getPackageName(), permission, + myUid, userId); if (shouldGrantRuntimePermission) { - final int flags = getPermissionFlagsInternal(pkg.getPackageName(), permission, - myUid, userId); if (supportsRuntimePermissions) { // Installer cannot change immutable permissions. if ((flags & immutableFlags) == 0) { @@ -3693,6 +3693,9 @@ public class PermissionManagerServiceImpl implements PermissionManagerServiceInt } else if (isAppOpPermission && PackageInstallerService.INSTALLER_CHANGEABLE_APP_OP_PERMISSIONS .contains(permission)) { + if ((flags & PackageManager.FLAG_PERMISSION_USER_SET) != 0) { + continue; + } int mode = permissionState == PERMISSION_STATE_GRANTED ? MODE_ALLOWED : MODE_ERRORED; int uid = UserHandle.getUid(userId, pkg.getUid()); diff --git a/services/core/java/com/android/server/wm/ActivityTaskManagerService.java b/services/core/java/com/android/server/wm/ActivityTaskManagerService.java index 5c20cedbee7c..8d671f768e87 100644 --- a/services/core/java/com/android/server/wm/ActivityTaskManagerService.java +++ b/services/core/java/com/android/server/wm/ActivityTaskManagerService.java @@ -4764,13 +4764,6 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub { mWindowManager.updateFocusedWindowLocked(UPDATE_FOCUS_NORMAL, true /*updateInputWindows*/); } - if (task != prevFocusTask) { - if (prevFocusTask != null) { - mTaskChangeNotificationController.notifyTaskFocusChanged( - prevFocusTask.mTaskId, false); - } - mTaskChangeNotificationController.notifyTaskFocusChanged(task.mTaskId, true); - } } if (task != prevTask) { mTaskSupervisor.mRecentTasks.add(task); diff --git a/services/core/java/com/android/server/wm/Task.java b/services/core/java/com/android/server/wm/Task.java index 10e4929ded6a..c2d78632a936 100644 --- a/services/core/java/com/android/server/wm/Task.java +++ b/services/core/java/com/android/server/wm/Task.java @@ -1290,12 +1290,12 @@ class Task extends TaskFragment { return null; } - void updateTaskMovement(boolean toTop, int position) { + void updateTaskMovement(boolean toTop, boolean toBottom, int position) { EventLogTags.writeWmTaskMoved(mTaskId, getRootTaskId(), getDisplayId(), toTop ? 1 : 0, position); final TaskDisplayArea taskDisplayArea = getDisplayArea(); if (taskDisplayArea != null && isLeafTask()) { - taskDisplayArea.onLeafTaskMoved(this, toTop); + taskDisplayArea.onLeafTaskMoved(this, toTop, toBottom); } if (isPersistable) { mLastTimeMoved = System.currentTimeMillis(); @@ -2561,7 +2561,7 @@ class Task extends TaskFragment { final Task task = child.asTask(); if (task != null) { - task.updateTaskMovement(toTop, position); + task.updateTaskMovement(toTop, position == POSITION_BOTTOM, position); } } @@ -4323,6 +4323,8 @@ class Task extends TaskFragment { dispatchTaskInfoChangedIfNeeded(false /* force */); final Task parentTask = getParent().asTask(); if (parentTask != null) parentTask.dispatchTaskInfoChangedIfNeeded(false /* force */); + + mAtmService.getTaskChangeNotificationController().notifyTaskFocusChanged(mTaskId, hasFocus); } void onPictureInPictureParamsChanged() { @@ -4655,13 +4657,9 @@ class Task extends TaskFragment { final Task lastFocusedTask = displayArea.getFocusedRootTask(); displayArea.positionChildAt(POSITION_BOTTOM, this, false /*includingParents*/); displayArea.updateLastFocusedRootTask(lastFocusedTask, reason); - mAtmService.getTaskChangeNotificationController().notifyTaskMovedToBack( - getTaskInfo()); } if (task != null && task != this) { positionChildAtBottom(task); - mAtmService.getTaskChangeNotificationController().notifyTaskMovedToBack( - task.getTaskInfo()); } return; } @@ -5923,7 +5921,7 @@ class Task extends TaskFragment { if (canBeLaunchedOnDisplay(newParent.getDisplayId())) { reparent(newParent, onTop ? POSITION_TOP : POSITION_BOTTOM); if (isLeafTask()) { - newParent.onLeafTaskMoved(this, onTop); + newParent.onLeafTaskMoved(this, onTop, !onTop); } } else { Slog.w(TAG, "Task=" + this + " can't reparent to " + newParent); diff --git a/services/core/java/com/android/server/wm/TaskDisplayArea.java b/services/core/java/com/android/server/wm/TaskDisplayArea.java index a0608db35952..8cbd553fbebd 100644 --- a/services/core/java/com/android/server/wm/TaskDisplayArea.java +++ b/services/core/java/com/android/server/wm/TaskDisplayArea.java @@ -403,7 +403,7 @@ final class TaskDisplayArea extends DisplayArea<WindowContainer> { this /* child */, true /* includingParents */); } - child.updateTaskMovement(moveToTop, targetPosition); + child.updateTaskMovement(moveToTop, moveToBottom, targetPosition); // The insert position may be adjusted to non-top when there is always-on-top root task. // Since the original position is preferred to be top, the root task should have higher @@ -433,7 +433,12 @@ final class TaskDisplayArea extends DisplayArea<WindowContainer> { } } - void onLeafTaskMoved(Task t, boolean toTop) { + void onLeafTaskMoved(Task t, boolean toTop, boolean toBottom) { + if (toBottom) { + mAtmService.getTaskChangeNotificationController().notifyTaskMovedToBack( + t.getTaskInfo()); + } + if (!toTop) { if (t.mTaskId == mLastLeafTaskToFrontId) { mLastLeafTaskToFrontId = INVALID_TASK_ID; diff --git a/services/core/java/com/android/server/wm/WindowManagerService.java b/services/core/java/com/android/server/wm/WindowManagerService.java index d5bf9f9a516c..63f8169ee726 100644 --- a/services/core/java/com/android/server/wm/WindowManagerService.java +++ b/services/core/java/com/android/server/wm/WindowManagerService.java @@ -89,6 +89,7 @@ import static android.view.WindowManager.LayoutParams.TYPE_WALLPAPER; import static android.view.WindowManager.REMOVE_CONTENT_MODE_UNDEFINED; import static android.view.WindowManager.TRANSIT_NONE; import static android.view.WindowManager.TRANSIT_RELAUNCH; +import static android.view.WindowManager.TRANSIT_TO_FRONT; import static android.view.WindowManager.fixScale; import static android.view.WindowManagerGlobal.ADD_OKAY; import static android.view.WindowManagerGlobal.RELAYOUT_RES_CANCEL_AND_REDRAW; @@ -8689,7 +8690,13 @@ public class WindowManagerService extends IWindowManager.Stub } } + // focus-transfer can re-order windows and thus potentially causes visible changes: + final Transition transition = mAtmService.getTransitionController() + .requestTransitionIfNeeded(TRANSIT_TO_FRONT, task); mAtmService.setFocusedTask(task.mTaskId, touchedActivity); + if (transition != null) { + transition.setReady(task, true /* ready */); + } } /** diff --git a/services/devicepolicy/java/com/android/server/devicepolicy/ActiveAdmin.java b/services/devicepolicy/java/com/android/server/devicepolicy/ActiveAdmin.java index e16b0f7c3f17..c42a4573d2e3 100644 --- a/services/devicepolicy/java/com/android/server/devicepolicy/ActiveAdmin.java +++ b/services/devicepolicy/java/com/android/server/devicepolicy/ActiveAdmin.java @@ -71,6 +71,10 @@ import java.util.function.Predicate; import java.util.stream.Collectors; class ActiveAdmin { + + private final int userId; + public final boolean isPermissionBased; + private static final String TAG_DISABLE_KEYGUARD_FEATURES = "disable-keyguard-features"; private static final String TAG_TEST_ONLY_ADMIN = "test-only-admin"; private static final String TAG_DISABLE_CAMERA = "disable-camera"; @@ -356,8 +360,20 @@ class ActiveAdmin { String mSmsPackage; ActiveAdmin(DeviceAdminInfo info, boolean isParent) { + this.userId = -1; this.info = info; this.isParent = isParent; + this.isPermissionBased = false; + } + + ActiveAdmin(int userId, boolean permissionBased) { + if (permissionBased == false) { + throw new IllegalArgumentException("Can only pass true for permissionBased admin"); + } + this.userId = userId; + this.isPermissionBased = permissionBased; + this.isParent = false; + this.info = null; } ActiveAdmin getParentActiveAdmin() { @@ -374,10 +390,16 @@ class ActiveAdmin { } int getUid() { + if (isPermissionBased) { + return -1; + } return info.getActivityInfo().applicationInfo.uid; } public UserHandle getUserHandle() { + if (isPermissionBased) { + return UserHandle.of(userId); + } return UserHandle.of(UserHandle.getUserId(info.getActivityInfo().applicationInfo.uid)); } diff --git a/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyData.java b/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyData.java index a5b9d4397eaf..6d51bd7c7770 100644 --- a/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyData.java +++ b/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyData.java @@ -133,9 +133,9 @@ class DevicePolicyData { // Create or get the permission-based admin. The permission-based admin will not have a // DeviceAdminInfo or ComponentName. - ActiveAdmin createOrGetPermissionBasedAdmin() { + ActiveAdmin createOrGetPermissionBasedAdmin(int userId) { if (mPermissionBasedAdmin == null) { - mPermissionBasedAdmin = new ActiveAdmin(/* info= */ null, /* parent= */ false); + mPermissionBasedAdmin = new ActiveAdmin(userId, /* permissionBased= */ true); } return mPermissionBasedAdmin; } @@ -509,7 +509,7 @@ class DevicePolicyData { Slogf.w(TAG, e, "Failed loading admin %s", name); } } else if ("permission-based-admin".equals(tag)) { - ActiveAdmin ap = new ActiveAdmin(/* info= */ null, /* parent= */ false); + ActiveAdmin ap = new ActiveAdmin(policy.mUserId, /* permissionBased= */ true); ap.readFromXml(parser, /* overwritePolicies= */ false); policy.mPermissionBasedAdmin = ap; } else if ("delegation".equals(tag)) { diff --git a/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java b/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java index 684ede3d6ed0..3c3cb2b49ba3 100644 --- a/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java +++ b/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java @@ -3616,7 +3616,7 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub { final int N = admins.size(); for (int i = 0; i < N; i++) { ActiveAdmin admin = admins.get(i); - if (admin.info.usesPolicy(DeviceAdminInfo.USES_POLICY_EXPIRE_PASSWORD) + if ((admin.isPermissionBased || admin.info.usesPolicy(DeviceAdminInfo.USES_POLICY_EXPIRE_PASSWORD)) && admin.passwordExpirationTimeout > 0L && now >= admin.passwordExpirationDate - EXPIRATION_GRACE_PERIOD_MS && admin.passwordExpirationDate > 0L) { @@ -4296,15 +4296,26 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub { } } + @GuardedBy("getLockObject()") private List<ActiveAdmin> getActiveAdminsForLockscreenPoliciesLocked(int userHandle) { if (isSeparateProfileChallengeEnabled(userHandle)) { + + if (isPermissionCheckFlagEnabled()) { + return getActiveAdminsForAffectedUserInclPermissionBasedAdminLocked(userHandle); + } // If this user has a separate challenge, only return its restrictions. return getUserDataUnchecked(userHandle).mAdminList; } // If isSeparateProfileChallengeEnabled is false and userHandle points to a managed profile // we need to query the parent user who owns the credential. - return getActiveAdminsForUserAndItsManagedProfilesLocked(getProfileParentId(userHandle), - (user) -> !mLockPatternUtils.isSeparateProfileChallengeEnabled(user.id)); + if (isPermissionCheckFlagEnabled()) { + return getActiveAdminsForUserAndItsManagedProfilesInclPermissionBasedAdminLocked(getProfileParentId(userHandle), + (user) -> !mLockPatternUtils.isSeparateProfileChallengeEnabled(user.id)); + } else { + return getActiveAdminsForUserAndItsManagedProfilesLocked(getProfileParentId(userHandle), + (user) -> !mLockPatternUtils.isSeparateProfileChallengeEnabled(user.id)); + } + } /** @@ -4340,7 +4351,14 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub { @GuardedBy("getLockObject()") private List<ActiveAdmin> getActiveAdminsForAffectedUserInclPermissionBasedAdminLocked( int userHandle) { - List<ActiveAdmin> list = getActiveAdminsForAffectedUserLocked(userHandle); + List<ActiveAdmin> list; + + if (isManagedProfile(userHandle)) { + list = getUserDataUnchecked(userHandle).mAdminList; + } + list = getActiveAdminsForUserAndItsManagedProfilesInclPermissionBasedAdminLocked(userHandle, + /* shouldIncludeProfileAdmins */ (user) -> false); + if (getUserData(userHandle).mPermissionBasedAdmin != null) { list.add(getUserData(userHandle).mPermissionBasedAdmin); } @@ -4378,6 +4396,44 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub { return admins; } + /** + * Returns the list of admins on the given user, as well as parent admins for each managed + * profile associated with the given user. Optionally also include the admin of each managed + * profile. + * <p> Should not be called on a profile user. + */ + @GuardedBy("getLockObject()") + private List<ActiveAdmin> getActiveAdminsForUserAndItsManagedProfilesInclPermissionBasedAdminLocked(int userHandle, + Predicate<UserInfo> shouldIncludeProfileAdmins) { + ArrayList<ActiveAdmin> admins = new ArrayList<>(); + mInjector.binderWithCleanCallingIdentity(() -> { + for (UserInfo userInfo : mUserManager.getProfiles(userHandle)) { + DevicePolicyData policy = getUserDataUnchecked(userInfo.id); + if (userInfo.id == userHandle) { + admins.addAll(policy.mAdminList); + if (policy.mPermissionBasedAdmin != null) { + admins.add(policy.mPermissionBasedAdmin); + } + } else if (userInfo.isManagedProfile()) { + for (int i = 0; i < policy.mAdminList.size(); i++) { + ActiveAdmin admin = policy.mAdminList.get(i); + if (admin.hasParentActiveAdmin()) { + admins.add(admin.getParentActiveAdmin()); + } + if (shouldIncludeProfileAdmins.test(userInfo)) { + admins.add(admin); + } + } + if (policy.mPermissionBasedAdmin != null + && shouldIncludeProfileAdmins.test(userInfo)) { + admins.add(policy.mPermissionBasedAdmin); + } + } + } + }); + return admins; + } + private boolean isSeparateProfileChallengeEnabled(int userHandle) { return mInjector.binderWithCleanCallingIdentity(() -> mLockPatternUtils.isSeparateProfileChallengeEnabled(userHandle)); @@ -4474,14 +4530,13 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub { Objects.requireNonNull(who, "ComponentName is null"); } - CallerIdentity caller = getCallerIdentity(who, callerPackageName); - Preconditions.checkArgumentNonnegative(timeout, "Timeout must be >= 0 ms"); int userHandle = mInjector.userHandleGetCallingUserId(); int affectedUserId = parent ? getProfileParentId(userHandle) : userHandle; synchronized (getLockObject()) { ActiveAdmin ap; if (isPermissionCheckFlagEnabled()) { + CallerIdentity caller = getCallerIdentity(who, callerPackageName); ap = enforcePermissionAndGetEnforcingAdmin( who, MANAGE_DEVICE_POLICY_LOCK_CREDENTIALS, caller.getPackageName(), affectedUserId) @@ -4505,7 +4560,7 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub { setExpirationAlarmCheckLocked(mContext, userHandle, parent); } if (SecurityLog.isLoggingEnabled()) { - SecurityLog.writeEvent(SecurityLog.TAG_PASSWORD_EXPIRATION_SET, caller.getPackageName(), + SecurityLog.writeEvent(SecurityLog.TAG_PASSWORD_EXPIRATION_SET, callerPackageName, userHandle, affectedUserId, timeout); } } @@ -4698,6 +4753,7 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub { * Return a single admin's expiration date/time, or the min (soonest) for all admins. * Returns 0 if not configured. */ + @GuardedBy("getLockObject()") private long getPasswordExpirationLocked(ComponentName who, int userHandle, boolean parent) { long timeout = 0L; @@ -5011,7 +5067,8 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub { } @Override - public boolean isActivePasswordSufficient(int userHandle, boolean parent) { + public boolean isActivePasswordSufficient( + String callerPackageName, int userHandle, boolean parent) { if (!mHasFeature) { return true; } @@ -5025,7 +5082,7 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub { if (isPermissionCheckFlagEnabled()) { int affectedUser = parent ? getProfileParentId(userHandle) : userHandle; enforcePermission(MANAGE_DEVICE_POLICY_LOCK_CREDENTIALS, - /*callerPackageName=*/ null, affectedUser); + callerPackageName, affectedUser); } else { // This API can only be called by an active device admin, // so try to retrieve it to check that the caller is one. @@ -5213,8 +5270,11 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub { Preconditions.checkArgument(allowedModes.contains(passwordComplexity), "Provided complexity is not one of the allowed values."); - final CallerIdentity caller = getCallerIdentity(callerPackageName); - if (!isPermissionCheckFlagEnabled()) { + CallerIdentity caller; + if (isPermissionCheckFlagEnabled()) { + caller = getCallerIdentity(callerPackageName); + } else { + caller = getCallerIdentity(); Preconditions.checkCallAuthorization( isDefaultDeviceOwner(caller) || isProfileOwner(caller)); Preconditions.checkArgument(!calledOnParent || isProfileOwner(caller)); @@ -5280,11 +5340,12 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub { adminPackageName, userId, affectedUserId, complexity); } } - + @GuardedBy("getLockObject()") private int getAggregatedPasswordComplexityLocked(@UserIdInt int userHandle) { return getAggregatedPasswordComplexityLocked(userHandle, false); } + @GuardedBy("getLockObject()") private int getAggregatedPasswordComplexityLocked(@UserIdInt int userHandle, boolean deviceWideOnly) { ensureLocked(); @@ -5303,7 +5364,7 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub { } @Override - public int getRequiredPasswordComplexity(boolean calledOnParent) { + public int getRequiredPasswordComplexity(String callerPackageName, boolean calledOnParent) { if (!mHasFeature) { return PASSWORD_COMPLEXITY_NONE; } @@ -5314,7 +5375,7 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub { int affectedUser = calledOnParent ? getProfileParentId(caller.getUserId()) : caller.getUserId(); enforcePermission(MANAGE_DEVICE_POLICY_LOCK_CREDENTIALS, - /*callerPackageName=*/ null, affectedUser); + callerPackageName, affectedUser); } else { Preconditions.checkCallAuthorization( isDefaultDeviceOwner(caller) || isProfileOwner(caller)); @@ -5345,7 +5406,8 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub { @Override - public int getCurrentFailedPasswordAttempts(int userHandle, boolean parent) { + public int getCurrentFailedPasswordAttempts( + String callerPackageName, int userHandle, boolean parent) { if (!mLockPatternUtils.hasSecureLockScreen()) { return 0; } @@ -5361,7 +5423,7 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub { if (isPermissionCheckFlagEnabled()) { int affectedUser = parent ? getProfileParentId(userHandle) : userHandle; enforcePermission(MANAGE_DEVICE_POLICY_LOCK_CREDENTIALS, - /*callerPackageName=*/ null, affectedUser); + callerPackageName, affectedUser); } else { getActiveAdminForCallerLocked( null, DeviceAdminInfo.USES_POLICY_WATCH_LOGIN, parent); @@ -5386,7 +5448,6 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub { Objects.requireNonNull(who, "ComponentName is null"); } - CallerIdentity caller = getCallerIdentity(who, callerPackageName); int userId = mInjector.userHandleGetCallingUserId(); int affectedUserId = parent ? getProfileParentId(userId) : userId; @@ -5394,6 +5455,7 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub { synchronized (getLockObject()) { ActiveAdmin ap; if (isPermissionCheckFlagEnabled()) { + CallerIdentity caller = getCallerIdentity(who, callerPackageName); ap = enforcePermissionAndGetEnforcingAdmin( who, MANAGE_DEVICE_POLICY_WIPE_DATA, caller.getPackageName(), affectedUserId).getActiveAdmin(); @@ -5467,6 +5529,7 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub { * profile. * Returns {@code null} if no participating admin has that policy set. */ + @GuardedBy("getLockObject()") private ActiveAdmin getAdminWithMinimumFailedPasswordsForWipeLocked( int userHandle, boolean parent) { int count = 0; @@ -5664,7 +5727,6 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub { @Override public void setMaximumTimeToLock(ComponentName who, String callerPackageName, long timeMs, boolean parent) { - CallerIdentity caller = getCallerIdentity(who, callerPackageName); if (!mHasFeature) { return; } @@ -5676,6 +5738,7 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub { synchronized (getLockObject()) { ActiveAdmin ap; if (isPermissionCheckFlagEnabled()) { + CallerIdentity caller = getCallerIdentity(who, callerPackageName); // TODO: Allow use of USES_POLICY_FORCE_LOCK ap = enforcePermissionAndGetEnforcingAdmin( who, MANAGE_DEVICE_POLICY_LOCK, caller.getPackageName(), @@ -5693,10 +5756,11 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub { } if (SecurityLog.isLoggingEnabled()) { SecurityLog.writeEvent(SecurityLog.TAG_MAX_SCREEN_LOCK_TIMEOUT_SET, - caller.getPackageName(), userHandle, affectedUserId, timeMs); + callerPackageName, userHandle, affectedUserId, timeMs); } } + @GuardedBy("getLockObject()") private void updateMaximumTimeToLockLocked(@UserIdInt int userId) { // Update the profile's timeout if (isManagedProfile(userId)) { @@ -5725,6 +5789,7 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub { }); } + @GuardedBy("getLockObject()") private void updateProfileLockTimeoutLocked(@UserIdInt int userId) { final long timeMs; if (isSeparateProfileChallengeEnabled(userId)) { @@ -5788,12 +5853,13 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub { if (!mHasFeature || !mLockPatternUtils.hasSecureLockScreen()) { return; } - if (!isPermissionCheckFlagEnabled()) { - Objects.requireNonNull(who, "ComponentName is null"); - } Preconditions.checkArgument(timeoutMs >= 0, "Timeout must not be a negative number."); - final CallerIdentity caller = getCallerIdentity(who, callerPackageName); - if (!isPermissionCheckFlagEnabled()) { + CallerIdentity caller; + if (isPermissionCheckFlagEnabled()) { + caller = getCallerIdentity(who, callerPackageName); + } else { + caller = getCallerIdentity(who); + Objects.requireNonNull(who, "ComponentName is null"); Preconditions.checkCallAuthorization( isDefaultDeviceOwner(caller) || isProfileOwner(caller)); } @@ -7456,9 +7522,15 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub { final String adminName; final ComponentName adminComp; if (admin != null) { - adminComp = admin.info.getComponent(); - adminName = adminComp.flattenToShortString(); - event.setAdmin(adminComp); + if (admin.isPermissionBased) { + adminComp = null; + adminName = caller.getPackageName(); + event.setAdmin(adminName); + } else { + adminComp = admin.info.getComponent(); + adminName = adminComp.flattenToShortString(); + event.setAdmin(adminComp); + } } else { adminComp = null; adminName = mInjector.getPackageManager().getPackagesForUid(caller.getUid())[0]; @@ -7747,13 +7819,7 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub { || hasCallingPermission(permission.MASTER_CLEAR) || hasCallingPermission(MANAGE_DEVICE_POLICY_FACTORY_RESET), "Must be called by the FRP management agent on device"); - // TODO(b/261999445): Remove - if (isHeadlessFlagEnabled()) { - admin = getDeviceOwnerOrProfileOwnerOfOrganizationOwnedDeviceLocked(); - } else { - admin = getDeviceOwnerOrProfileOwnerOfOrganizationOwnedDeviceLocked( - UserHandle.getUserId(frpManagementAgentUid)); - } + admin = getDeviceOwnerOrProfileOwnerOfOrganizationOwnedDeviceOrSystemPermissionBasedAdminLocked(); } else { Preconditions.checkCallAuthorization( isDefaultDeviceOwner(caller) @@ -7924,12 +7990,13 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub { * * @return the set of user IDs that have been affected */ + @GuardedBy("getLockObject()") private Set<Integer> updatePasswordExpirationsLocked(int userHandle) { final ArraySet<Integer> affectedUserIds = new ArraySet<>(); List<ActiveAdmin> admins = getActiveAdminsForLockscreenPoliciesLocked(userHandle); for (int i = 0; i < admins.size(); i++) { ActiveAdmin admin = admins.get(i); - if (admin.info.usesPolicy(DeviceAdminInfo.USES_POLICY_EXPIRE_PASSWORD)) { + if (admin.isPermissionBased || admin.info.usesPolicy(DeviceAdminInfo.USES_POLICY_EXPIRE_PASSWORD)) { affectedUserIds.add(admin.getUserHandle().getIdentifier()); long timeout = admin.passwordExpirationTimeout; admin.passwordExpirationDate = @@ -8023,6 +8090,9 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub { */ private int getUserIdToWipeForFailedPasswords(ActiveAdmin admin) { final int userId = admin.getUserHandle().getIdentifier(); + if (admin.isPermissionBased) { + return userId; + } final ComponentName component = admin.info.getComponent(); return isProfileOwnerOfOrganizationOwnedDevice(component, userId) ? getProfileParentId(userId) : userId; @@ -8407,9 +8477,12 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub { return; } - CallerIdentity caller = getCallerIdentity(who, callerPackage); - if (!isPermissionCheckFlagEnabled()) { + CallerIdentity caller; + if (isPermissionCheckFlagEnabled()) { + caller = getCallerIdentity(who, callerPackage); + } else { Objects.requireNonNull(who, "ComponentName is null"); + caller = getCallerIdentity(who); if (parent) { Preconditions.checkCallAuthorization( isProfileOwnerOfOrganizationOwnedDevice(caller)); @@ -8711,7 +8784,7 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub { } if (isPermissionCheckFlagEnabled()) { - enforceCanQuery(caller.getPackageName(), SET_TIME, UserHandle.USER_ALL); + enforceCanQuery(SET_TIME, caller.getPackageName(), UserHandle.USER_ALL); } else { Objects.requireNonNull(who, "ComponentName is null"); Preconditions.checkCallAuthorization(isProfileOwnerOnUser0(caller) @@ -8787,7 +8860,7 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub { if (isPermissionCheckFlagEnabled()) { // The effect of this policy is device-wide. - enforceCanQuery(caller.getPackageName(), SET_TIME_ZONE, UserHandle.USER_ALL); + enforceCanQuery(SET_TIME_ZONE, caller.getPackageName(), UserHandle.USER_ALL); } else { Objects.requireNonNull(who, "ComponentName is null"); Preconditions.checkCallAuthorization(isProfileOwnerOnUser0(caller) @@ -8951,8 +9024,14 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub { return; } - final CallerIdentity caller = getCallerIdentity(who, callerPackageName); + CallerIdentity caller; + if (isPermissionCheckFlagEnabled()) { + caller = getCallerIdentity(who, callerPackageName); + } else { + caller = getCallerIdentity(who); + } final int userId = caller.getUserId(); + checkCanExecuteOrThrowUnsafe(DevicePolicyManager.OPERATION_SET_CAMERA_DISABLED); ActiveAdmin admin; @@ -9065,11 +9144,15 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub { if (!mHasFeature) { return; } - if (!isPermissionCheckFlagEnabled()) { + + CallerIdentity caller; + if (isPermissionCheckFlagEnabled()) { + caller = getCallerIdentity(who, callerPackageName); + } else { + caller = getCallerIdentity(who); Objects.requireNonNull(who, "ComponentName is null"); } - final CallerIdentity caller = getCallerIdentity(who, callerPackageName); final int userHandle = caller.getUserId(); int affectedUserId = parent ? getProfileParentId(userHandle) : userHandle; @@ -9637,6 +9720,15 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub { return admin; } + ActiveAdmin getDeviceOwnerOrProfileOwnerOfOrganizationOwnedDeviceOrSystemPermissionBasedAdminLocked() { + ensureLocked(); + ActiveAdmin doOrPo = getDeviceOwnerOrProfileOwnerOfOrganizationOwnedDeviceLocked(); + if (isPermissionCheckFlagEnabled() && doOrPo == null) { + return getUserData(0).mPermissionBasedAdmin; + } + return doOrPo; + } + ActiveAdmin getDeviceOwnerOrProfileOwnerOfOrganizationOwnedDeviceParentLocked(int userId) { ensureLocked(); ActiveAdmin admin = getDeviceOwnerAdminLocked(); @@ -10643,9 +10735,12 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub { return false; } - final ComponentName profileOwner = getProfileOwnerAsUser(userId); - if (profileOwner == null) { - return false; + if (!isPermissionCheckFlagEnabled()) { + // TODO: Figure out if something like this needs to be restored for policy engine + final ComponentName profileOwner = getProfileOwnerAsUser(userId); + if (profileOwner == null) { + return false; + } } // Managed profiles are not allowed to use lock task @@ -10670,7 +10765,7 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub { CallerIdentity caller = getCallerIdentity(who, callerPackageName); final int userId = caller.getUserId(); - enforceCanQuery(caller.getPackageName(), MANAGE_DEVICE_POLICY_LOCK_TASK, userId); + enforceCanQuery(MANAGE_DEVICE_POLICY_LOCK_TASK, caller.getPackageName(), userId); if (!canUserUseLockTaskLocked(userId)) { throw new SecurityException("User " + userId + " is not allowed to use lock task"); } @@ -11289,16 +11384,17 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub { if (!mHasFeature || !mLockPatternUtils.hasSecureLockScreen()) { return; } + if (!isPermissionCheckFlagEnabled()) { Objects.requireNonNull(admin, "admin is null"); } - CallerIdentity caller = getCallerIdentity(admin, callerPackageName); Objects.requireNonNull(agent, "agent is null"); int userHandle = UserHandle.getCallingUserId(); synchronized (getLockObject()) { ActiveAdmin ap; if (isPermissionCheckFlagEnabled()) { + CallerIdentity caller = getCallerIdentity(admin, callerPackageName); int affectedUserId = parent ? getProfileParentId(userHandle) : userHandle; // TODO: Support USES_POLICY_DISABLE_KEYGUARD_FEATURES ap = enforcePermissionAndGetEnforcingAdmin( @@ -11733,11 +11829,15 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub { if (!mHasFeature) { return false; } - if (!isPermissionCheckFlagEnabled()) { + + CallerIdentity caller; + if (isPermissionCheckFlagEnabled()) { + caller = getCallerIdentity(who, callerPackageName); + } else { + caller = getCallerIdentity(who); Objects.requireNonNull(who, "ComponentName is null"); } - CallerIdentity caller = getCallerIdentity(who, callerPackageName); int userId = getProfileParentUserIfRequested( caller.getUserId(), calledOnParentInstance); if (calledOnParentInstance) { @@ -11810,11 +11910,15 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub { if (!mHasFeature) { return null; } - if (!isPermissionCheckFlagEnabled()) { + + CallerIdentity caller; + if (isPermissionCheckFlagEnabled()) { + caller = getCallerIdentity(who, callerPackageName); + } else { + caller = getCallerIdentity(who); Objects.requireNonNull(who, "ComponentName is null"); } - final CallerIdentity caller = getCallerIdentity(who, callerPackageName); if (!isPermissionCheckFlagEnabled()) { if (calledOnParentInstance) { Preconditions.checkCallAuthorization( @@ -11859,7 +11963,7 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub { synchronized (getLockObject()) { List<String> result = null; // Only device or profile owners can have permitted lists set. - List<ActiveAdmin> admins = getActiveAdminsForAffectedUserLocked(userId); + List<ActiveAdmin> admins = getActiveAdminsForAffectedUserInclPermissionBasedAdminLocked(userId); for (ActiveAdmin admin: admins) { List<String> fromAdmin = admin.permittedInputMethods; if (fromAdmin != null) { @@ -12572,7 +12676,6 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub { } return policies.get(enforcingAdmin).getValue(); } else { - Objects.requireNonNull(who, "ComponentName is null"); Preconditions.checkCallAuthorization((caller.hasAdminComponent() && (isProfileOwner(caller) || isDefaultDeviceOwner(caller))) || (caller.hasPackage() && isCallerDelegate(caller, @@ -12798,11 +12901,12 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub { checkCanExecuteOrThrowUnsafe(DevicePolicyManager.OPERATION_SET_USER_RESTRICTION); if (useDevicePolicyEngine(caller, /* delegateScope= */ null)) { + int affectedUserId = parent ? getProfileParentId(userId) : userId; EnforcingAdmin admin = enforcePermissionForUserRestriction( who, key, caller.getPackageName(), - userId); + affectedUserId); PolicyDefinition<Boolean> policyDefinition = PolicyDefinition.getPolicyDefinitionForUserRestriction(key); if (enabledFromThisOwner) { @@ -12810,7 +12914,7 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub { policyDefinition, admin, new BooleanPolicyValue(true), - parent ? getProfileParentId(userId) : userId); + affectedUserId); } else { // Remove any local and global policy that was set by the admin if (!policyDefinition.isLocalOnlyPolicy()) { @@ -13232,7 +13336,7 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub { public boolean setApplicationHidden(ComponentName who, String callerPackage, String packageName, boolean hidden, boolean parent) { CallerIdentity caller = getCallerIdentity(who, callerPackage); - int userId = parent ? getProfileParentId(caller.getUserId()) : caller.getUserId(); + final int userId = parent ? getProfileParentId(caller.getUserId()) : caller.getUserId(); if (isPermissionCheckFlagEnabled()) { // TODO: We need to ensure the delegate with DELEGATION_PACKAGE_ACCESS can do this enforcePermission(MANAGE_DEVICE_POLICY_PACKAGE_STATE, caller.getPackageName(), userId); @@ -13598,7 +13702,6 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub { new BooleanPolicyValue(uninstallBlocked), caller.getUserId()); } else { - Objects.requireNonNull(who, "ComponentName is null"); Preconditions.checkCallAuthorization((caller.hasAdminComponent() && (isProfileOwner(caller) || isDefaultDeviceOwner(caller) || isFinancedDeviceOwner(caller))) @@ -14173,7 +14276,7 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub { mDevicePolicyEngine.setLocalPolicy( PolicyDefinition.LOCK_TASK, - EnforcingAdmin.createEnterpriseEnforcingAdmin(who, caller.getUserId()), + enforcingAdmin, policy, caller.getUserId()); } @@ -14240,7 +14343,7 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub { final int userId = mInjector.userHandleGetCallingUserId(); // Is it ok to just check that no active policies exist currently? - if (mDevicePolicyEngine.hasActivePolicies()) { + if (isDevicePolicyEngineFlagEnabled() && mDevicePolicyEngine.hasActivePolicies()) { LockTaskPolicy policy = mDevicePolicyEngine.getResolvedPolicy( PolicyDefinition.LOCK_TASK, userId); if (policy == null) { @@ -14492,12 +14595,14 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub { if (!mHasFeature) { return; } - CallerIdentity caller = getCallerIdentity(who, callerPackageName); + CallerIdentity caller; if (isPermissionCheckFlagEnabled()) { + caller = getCallerIdentity(who, callerPackageName); enforcePermission(MANAGE_DEVICE_POLICY_WIFI, caller.getPackageName(), UserHandle.USER_ALL); } else { + caller = getCallerIdentity(who); Preconditions.checkNotNull(who, "ComponentName is null"); Preconditions.checkCallAuthorization( isDefaultDeviceOwner(caller) @@ -14522,7 +14627,7 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub { } CallerIdentity caller = getCallerIdentity(who); if (isPermissionCheckFlagEnabled()) { - enforcePermission(MANAGE_DEVICE_POLICY_WIFI, /*callerPackageName=*/ null, + enforcePermission(MANAGE_DEVICE_POLICY_WIFI, who.getPackageName(), UserHandle.USER_ALL); } else { Preconditions.checkNotNull(who, "ComponentName is null"); @@ -15787,7 +15892,7 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub { if (admin.mPasswordPolicy.quality < minPasswordQuality) { return false; } - return admin.info.usesPolicy(DeviceAdminInfo.USES_POLICY_LIMIT_PASSWORD); + return admin.isPermissionBased || admin.info.usesPolicy(DeviceAdminInfo.USES_POLICY_LIMIT_PASSWORD); } @Override @@ -15843,13 +15948,15 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub { policy.validateAgainstPreviousFreezePeriod(record.first, record.second, LocalDate.now()); } - final CallerIdentity caller = getCallerIdentity(who, callerPackageName); + CallerIdentity caller; synchronized (getLockObject()) { if (isPermissionCheckFlagEnabled()) { + caller = getCallerIdentity(who, callerPackageName); enforcePermission(MANAGE_DEVICE_POLICY_SYSTEM_UPDATES, caller.getPackageName(), UserHandle.USER_ALL); } else { + caller = getCallerIdentity(who); Preconditions.checkCallAuthorization( isProfileOwnerOfOrganizationOwnedDevice(caller) || isDefaultDeviceOwner(caller)); @@ -18504,9 +18611,9 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub { public StringParceledListSlice getOwnerInstalledCaCerts(@NonNull UserHandle user) { final int userId = user.getIdentifier(); final CallerIdentity caller = getCallerIdentity(); - Preconditions.checkCallAuthorization((userId == caller.getUserId()) - || isProfileOwner(caller) || isDefaultDeviceOwner(caller) - || hasFullCrossUsersPermission(caller, userId)); + Preconditions.checkCallAuthorization( + (isProfileOwner(caller) || isDefaultDeviceOwner(caller) || canQueryAdminPolicy( + caller)) && hasFullCrossUsersPermission(caller, userId)); synchronized (getLockObject()) { return new StringParceledListSlice( @@ -19151,11 +19258,13 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub { Objects.requireNonNull(admin, "ComponentName is null"); } - final CallerIdentity caller = getCallerIdentity(admin, callerPackageName); + CallerIdentity caller; if (isPermissionCheckFlagEnabled()) { + caller = getCallerIdentity(admin, callerPackageName); enforcePermission(MANAGE_DEVICE_POLICY_SYSTEM_UPDATES, caller.getPackageName(), UserHandle.USER_ALL); } else { + caller = getCallerIdentity(admin); Preconditions.checkCallAuthorization( isDefaultDeviceOwner(caller) || isProfileOwnerOfOrganizationOwnedDevice(caller)); @@ -19719,8 +19828,8 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub { if (useDevicePolicyEngine(caller, /* delegateScope= */ null)) { enforceCanQuery( - caller.getPackageName(), MANAGE_DEVICE_POLICY_APPS_CONTROL, + caller.getPackageName(), caller.getUserId()); // This retrieves the policy for the calling user only, DOs for example can't know // what's enforced globally or on another user. @@ -21357,8 +21466,11 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub { @Override public void setMinimumRequiredWifiSecurityLevel(String callerPackageName, int level) { - final CallerIdentity caller = getCallerIdentity(); - if (!isPermissionCheckFlagEnabled()) { + CallerIdentity caller; + if (isPermissionCheckFlagEnabled()) { + caller = getCallerIdentity(callerPackageName); + } else { + caller = getCallerIdentity(); Preconditions.checkCallAuthorization( isDefaultDeviceOwner(caller) || isProfileOwnerOfOrganizationOwnedDevice(caller), "Wi-Fi minimum security level can only be controlled by a device owner or " @@ -21401,10 +21513,10 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub { } @Override - public WifiSsidPolicy getWifiSsidPolicy() { + public WifiSsidPolicy getWifiSsidPolicy(String callerPackageName) { final CallerIdentity caller = getCallerIdentity(); if (isPermissionCheckFlagEnabled()) { - enforcePermission(MANAGE_DEVICE_POLICY_WIFI, /*callerPackageName=*/ null, + enforcePermission(MANAGE_DEVICE_POLICY_WIFI, callerPackageName, caller.getUserId()); } else { Preconditions.checkCallAuthorization( @@ -21417,22 +21529,19 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub { } synchronized (getLockObject()) { ActiveAdmin admin; - // TODO(b/261999445): remove - if (isHeadlessFlagEnabled()) { - admin = getDeviceOwnerOrProfileOwnerOfOrganizationOwnedDeviceLocked(); - } else { - admin = getDeviceOwnerOrProfileOwnerOfOrganizationOwnedDeviceLocked( - UserHandle.USER_SYSTEM); - } + admin = getDeviceOwnerOrProfileOwnerOfOrganizationOwnedDeviceOrSystemPermissionBasedAdminLocked(); return admin != null ? admin.mWifiSsidPolicy : null; } } @Override public void setWifiSsidPolicy(String callerPackageName, WifiSsidPolicy policy) { - final CallerIdentity caller = getCallerIdentity(callerPackageName); + CallerIdentity caller; - if (!isPermissionCheckFlagEnabled()) { + if (isPermissionCheckFlagEnabled()) { + caller = getCallerIdentity(callerPackageName); + } else { + caller = getCallerIdentity(); Preconditions.checkCallAuthorization( isDefaultDeviceOwner(caller) || isProfileOwnerOfOrganizationOwnedDevice(caller), "SSID denylist can only be controlled by a device owner or " @@ -22417,7 +22526,7 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub { return EnforcingAdmin.createDeviceAdminEnforcingAdmin(who, userId, admin); } if (admin == null) { - admin = getUserData(userId).createOrGetPermissionBasedAdmin(); + admin = getUserData(userId).createOrGetPermissionBasedAdmin(userId); } return EnforcingAdmin.createEnforcingAdmin(caller.getPackageName(), userId, admin); } @@ -22977,26 +23086,12 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub { return admins; } - // TODO: This can actually accept an EnforcingAdmin that gets created in the permission check - // method. private boolean useDevicePolicyEngine(CallerIdentity caller, @Nullable String delegateScope) { - if (!isCallerActiveAdminOrDelegate(caller, delegateScope)) { - if (!isDevicePolicyEngineFlagEnabled()) { - throw new IllegalStateException("Non DPC caller can't set device policies."); - } - if (hasDPCsNotSupportingCoexistence()) { - throw new IllegalStateException("Non DPC caller can't set device policies with " - + "existing legacy admins on the device."); - } - return true; - } else { - return isDevicePolicyEngineEnabled(); - } + return isDevicePolicyEngineEnabled(); } private boolean isDevicePolicyEngineEnabled() { - return isDevicePolicyEngineFlagEnabled() && !hasDPCsNotSupportingCoexistence() - && isPermissionCheckFlagEnabled(); + return isDevicePolicyEngineFlagEnabled() && isPermissionCheckFlagEnabled(); } private boolean isDevicePolicyEngineFlagEnabled() { diff --git a/services/devicepolicy/java/com/android/server/devicepolicy/PolicyEnforcerCallbacks.java b/services/devicepolicy/java/com/android/server/devicepolicy/PolicyEnforcerCallbacks.java index daa8a26e00d1..fd91249fac62 100644 --- a/services/devicepolicy/java/com/android/server/devicepolicy/PolicyEnforcerCallbacks.java +++ b/services/devicepolicy/java/com/android/server/devicepolicy/PolicyEnforcerCallbacks.java @@ -215,10 +215,9 @@ final class PolicyEnforcerCallbacks { } UserRestrictionPolicyKey parsedKey = (UserRestrictionPolicyKey) policyKey; - // TODO: call into new UserManager API when merged UserManagerInternal userManager = LocalServices.getService(UserManagerInternal.class); -// userManager.setUserRestriction( -// userId, parsedKey.getRestriction(), enabled != null && enabled); + userManager.setUserRestriction( + userId, parsedKey.getRestriction(), enabled != null && enabled); return true; })); } diff --git a/services/tests/PackageManagerServiceTests/server/src/com/android/server/pm/RestrictionsSetTest.java b/services/tests/PackageManagerServiceTests/server/src/com/android/server/pm/RestrictionsSetTest.java index e7adf7b757f1..8345a43979af 100644 --- a/services/tests/PackageManagerServiceTests/server/src/com/android/server/pm/RestrictionsSetTest.java +++ b/services/tests/PackageManagerServiceTests/server/src/com/android/server/pm/RestrictionsSetTest.java @@ -32,6 +32,7 @@ import android.platform.test.annotations.Presubmit; import androidx.test.runner.AndroidJUnit4; +import org.junit.Ignore; import org.junit.Test; import org.junit.runner.RunWith; @@ -138,6 +139,7 @@ public class RestrictionsSetTest { } @Test + @Ignore("b/268334580") public void testGetEnforcingUsers_hasEnforcingUser() { mRestrictionsSet.updateRestrictions(originatingUserId, newRestrictions(UserManager.ENSURE_VERIFY_APPS)); @@ -154,6 +156,7 @@ public class RestrictionsSetTest { } @Test + @Ignore("b/268334580") public void testGetEnforcingUsers_hasMultipleEnforcingUsers() { int originatingUserId2 = 10; mRestrictionsSet.updateRestrictions(originatingUserId, diff --git a/services/tests/mockingservicestests/src/com/android/server/am/BroadcastQueueModernImplTest.java b/services/tests/mockingservicestests/src/com/android/server/am/BroadcastQueueModernImplTest.java index 68cfe4591c51..dcdee37059a9 100644 --- a/services/tests/mockingservicestests/src/com/android/server/am/BroadcastQueueModernImplTest.java +++ b/services/tests/mockingservicestests/src/com/android/server/am/BroadcastQueueModernImplTest.java @@ -16,6 +16,10 @@ package com.android.server.am; +import static com.android.dx.mockito.inline.extended.ExtendedMockito.verify; +import static com.android.internal.util.FrameworkStatsLog.BROADCAST_DELIVERY_EVENT_REPORTED; +import static com.android.internal.util.FrameworkStatsLog.BROADCAST_DELIVERY_EVENT_REPORTED__PROC_START_TYPE__PROCESS_START_TYPE_COLD; +import static com.android.internal.util.FrameworkStatsLog.BROADCAST_DELIVERY_EVENT_REPORTED__RECEIVER_TYPE__MANIFEST; import static com.android.server.am.BroadcastProcessQueue.REASON_CONTAINS_ALARM; import static com.android.server.am.BroadcastProcessQueue.REASON_CONTAINS_FOREGROUND; import static com.android.server.am.BroadcastProcessQueue.REASON_CONTAINS_INTERACTIVE; @@ -44,8 +48,12 @@ import static org.junit.Assert.assertNotEquals; import static org.junit.Assert.assertNull; import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; +import static org.mockito.ArgumentMatchers.anyInt; +import static org.mockito.ArgumentMatchers.anyLong; +import static org.mockito.ArgumentMatchers.eq; import static org.mockito.Mockito.doReturn; import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.times; import android.annotation.NonNull; import android.app.Activity; @@ -70,6 +78,11 @@ import android.util.Pair; import androidx.test.filters.SmallTest; +import com.android.dx.mockito.inline.extended.StaticMockitoSessionBuilder; +import com.android.internal.util.FrameworkStatsLog; +import com.android.server.ExtendedMockitoTestCase; +import com.android.server.am.BroadcastQueueTest.SyncBarrier; + import org.junit.After; import org.junit.Before; import org.junit.Test; @@ -86,7 +99,7 @@ import java.util.List; @SmallTest @RunWith(MockitoJUnitRunner.class) -public class BroadcastQueueModernImplTest { +public class BroadcastQueueModernImplTest extends ExtendedMockitoTestCase { private static final int TEST_UID = android.os.Process.FIRST_APPLICATION_UID; private static final int TEST_UID2 = android.os.Process.FIRST_APPLICATION_UID + 1; @@ -105,6 +118,11 @@ public class BroadcastQueueModernImplTest { BroadcastProcessQueue mHead; + @Override + protected void initializeSession(StaticMockitoSessionBuilder builder) { + builder.spyStatic(FrameworkStatsLog.class); + } + @Before public void setUp() throws Exception { MockitoAnnotations.initMocks(this); @@ -1081,6 +1099,28 @@ public class BroadcastQueueModernImplTest { } } + @Test + public void testBroadcastDeliveryEventReported() throws Exception { + final Intent timeTick = new Intent(Intent.ACTION_TIME_TICK); + final BroadcastOptions optionsTimeTick = BroadcastOptions.makeBasic(); + optionsTimeTick.setDeliveryGroupPolicy(BroadcastOptions.DELIVERY_GROUP_POLICY_MOST_RECENT); + + // Halt all processing so that we get a consistent view + try (SyncBarrier b = new SyncBarrier(mHandlerThread)) { + mImpl.enqueueBroadcastLocked(makeBroadcastRecord(timeTick, optionsTimeTick)); + mImpl.enqueueBroadcastLocked(makeBroadcastRecord(timeTick, optionsTimeTick)); + } + mImpl.waitForIdle(null); + + // Verify that there is only one delivery event reported since one of the broadcasts + // should have been skipped. + verify(() -> FrameworkStatsLog.write(eq(BROADCAST_DELIVERY_EVENT_REPORTED), + eq(getUidForPackage(PACKAGE_GREEN)), anyInt(), eq(Intent.ACTION_TIME_TICK), + eq(BROADCAST_DELIVERY_EVENT_REPORTED__RECEIVER_TYPE__MANIFEST), + eq(BROADCAST_DELIVERY_EVENT_REPORTED__PROC_START_TYPE__PROCESS_START_TYPE_COLD), + anyLong(), anyLong(), anyLong(), anyInt()), times(1)); + } + private Intent createPackageChangedIntent(int uid, List<String> componentNameList) { final Intent packageChangedIntent = new Intent(Intent.ACTION_PACKAGE_CHANGED); packageChangedIntent.putExtra(Intent.EXTRA_UID, uid); diff --git a/services/tests/mockingservicestests/src/com/android/server/am/BroadcastQueueTest.java b/services/tests/mockingservicestests/src/com/android/server/am/BroadcastQueueTest.java index e7b3dd985053..cf8460bca1a6 100644 --- a/services/tests/mockingservicestests/src/com/android/server/am/BroadcastQueueTest.java +++ b/services/tests/mockingservicestests/src/com/android/server/am/BroadcastQueueTest.java @@ -346,16 +346,18 @@ public class BroadcastQueueTest { * Helper that leverages try-with-resources to pause dispatch of * {@link #mHandlerThread} until released. */ - private class SyncBarrier implements AutoCloseable { + static class SyncBarrier implements AutoCloseable { private final int mToken; + private HandlerThread mThread; - public SyncBarrier() { - mToken = mHandlerThread.getLooper().getQueue().postSyncBarrier(); + SyncBarrier(HandlerThread thread) { + mThread = thread; + mToken = mThread.getLooper().getQueue().postSyncBarrier(); } @Override public void close() throws Exception { - mHandlerThread.getLooper().getQueue().removeSyncBarrier(mToken); + mThread.getLooper().getQueue().removeSyncBarrier(mToken); } } @@ -1120,7 +1122,7 @@ public class BroadcastQueueTest { final ProcessRecord receiverApp = makeActiveProcessRecord(PACKAGE_GREEN); final Intent airplane = new Intent(Intent.ACTION_AIRPLANE_MODE_CHANGED); - try (SyncBarrier b = new SyncBarrier()) { + try (SyncBarrier b = new SyncBarrier(mHandlerThread)) { enqueueBroadcast(makeBroadcastRecord(airplane, callerApp, new ArrayList<>( List.of(makeRegisteredReceiver(receiverApp), makeManifestReceiver(PACKAGE_GREEN, CLASS_RED), @@ -1164,7 +1166,7 @@ public class BroadcastQueueTest { final Intent airplane = new Intent(Intent.ACTION_AIRPLANE_MODE_CHANGED); final Intent timeZone = new Intent(Intent.ACTION_TIMEZONE_CHANGED); - try (SyncBarrier b = new SyncBarrier()) { + try (SyncBarrier b = new SyncBarrier(mHandlerThread)) { enqueueBroadcast(makeBroadcastRecord(airplane, callerApp, USER_GUEST, new ArrayList<>( List.of(makeRegisteredReceiver(callerApp), makeManifestReceiver(PACKAGE_GREEN, CLASS_RED, USER_GUEST), @@ -1204,7 +1206,7 @@ public class BroadcastQueueTest { final ProcessRecord oldApp = makeActiveProcessRecord(PACKAGE_GREEN); final Intent airplane = new Intent(Intent.ACTION_AIRPLANE_MODE_CHANGED); - try (SyncBarrier b = new SyncBarrier()) { + try (SyncBarrier b = new SyncBarrier(mHandlerThread)) { enqueueBroadcast(makeBroadcastRecord(airplane, callerApp, new ArrayList<>( List.of(makeRegisteredReceiver(oldApp), makeManifestReceiver(PACKAGE_GREEN, CLASS_GREEN))))); @@ -1585,7 +1587,7 @@ public class BroadcastQueueTest { final Intent timezone = new Intent(Intent.ACTION_TIMEZONE_CHANGED); final Intent airplane = new Intent(Intent.ACTION_AIRPLANE_MODE_CHANGED); airplane.addFlags(Intent.FLAG_RECEIVER_FOREGROUND); - try (SyncBarrier b = new SyncBarrier()) { + try (SyncBarrier b = new SyncBarrier(mHandlerThread)) { enqueueBroadcast(makeBroadcastRecord(timezone, callerApp, List.of(makeRegisteredReceiver(receiverBlueApp, 10), makeRegisteredReceiver(receiverGreenApp, 10), @@ -1638,7 +1640,7 @@ public class BroadcastQueueTest { final IIntentReceiver resultToFirst = mock(IIntentReceiver.class); final IIntentReceiver resultToSecond = mock(IIntentReceiver.class); - try (SyncBarrier b = new SyncBarrier()) { + try (SyncBarrier b = new SyncBarrier(mHandlerThread)) { enqueueBroadcast(makeOrderedBroadcastRecord(timezoneFirst, callerApp, List.of(makeManifestReceiver(PACKAGE_BLUE, CLASS_BLUE), makeManifestReceiver(PACKAGE_BLUE, CLASS_GREEN)), @@ -1729,7 +1731,7 @@ public class BroadcastQueueTest { timeTickFirst.putExtra(Intent.EXTRA_INDEX, "third"); timeTickThird.addFlags(Intent.FLAG_RECEIVER_REPLACE_PENDING); - try (SyncBarrier b = new SyncBarrier()) { + try (SyncBarrier b = new SyncBarrier(mHandlerThread)) { enqueueBroadcast(makeBroadcastRecord(timeTickFirst, callerApp, List.of(makeManifestReceiver(PACKAGE_BLUE, CLASS_BLUE)))); enqueueBroadcast(makeBroadcastRecord(timeTickSecond, callerApp, @@ -1771,7 +1773,7 @@ public class BroadcastQueueTest { assertTrue(mQueue.isIdleLocked()); assertTrue(mQueue.isBeyondBarrierLocked(beforeFirst)); - try (SyncBarrier b = new SyncBarrier()) { + try (SyncBarrier b = new SyncBarrier(mHandlerThread)) { final Intent timezone = new Intent(Intent.ACTION_TIMEZONE_CHANGED); enqueueBroadcast(makeBroadcastRecord(timezone, callerApp, List.of(makeRegisteredReceiver(receiverApp)))); @@ -1820,6 +1822,42 @@ public class BroadcastQueueTest { } /** + * Verify that we OOM adjust for ordered broadcast receivers. + */ + @Test + public void testOomAdjust_Ordered() throws Exception { + final ProcessRecord callerApp = makeActiveProcessRecord(PACKAGE_RED); + + final IIntentReceiver orderedResultTo = mock(IIntentReceiver.class); + final Intent airplane = new Intent(Intent.ACTION_AIRPLANE_MODE_CHANGED); + enqueueBroadcast(makeOrderedBroadcastRecord(airplane, callerApp, + List.of(makeManifestReceiver(PACKAGE_GREEN, CLASS_GREEN), + makeManifestReceiver(PACKAGE_GREEN, CLASS_BLUE), + makeManifestReceiver(PACKAGE_GREEN, CLASS_RED)), orderedResultTo, null)); + + waitForIdle(); + verify(mAms, atLeastOnce()).enqueueOomAdjTargetLocked(any()); + } + + /** + * Verify that we OOM adjust for resultTo broadcast receivers. + */ + @Test + public void testOomAdjust_ResultTo() throws Exception { + final ProcessRecord callerApp = makeActiveProcessRecord(PACKAGE_RED); + + final IIntentReceiver resultTo = mock(IIntentReceiver.class); + final Intent airplane = new Intent(Intent.ACTION_AIRPLANE_MODE_CHANGED); + enqueueBroadcast(makeBroadcastRecord(airplane, callerApp, + List.of(makeManifestReceiver(PACKAGE_GREEN, CLASS_GREEN), + makeManifestReceiver(PACKAGE_GREEN, CLASS_BLUE), + makeManifestReceiver(PACKAGE_GREEN, CLASS_RED)), resultTo)); + + waitForIdle(); + verify(mAms, atLeastOnce()).enqueueOomAdjTargetLocked(any()); + } + + /** * Verify that we never OOM adjust for registered receivers. */ @Test @@ -1865,7 +1903,7 @@ public class BroadcastQueueTest { final ProcessRecord receiverBlueApp = makeActiveProcessRecord(PACKAGE_BLUE); final Intent airplane = new Intent(Intent.ACTION_AIRPLANE_MODE_CHANGED); - try (SyncBarrier b = new SyncBarrier()) { + try (SyncBarrier b = new SyncBarrier(mHandlerThread)) { final Object greenReceiver = makeRegisteredReceiver(receiverGreenApp); final Object blueReceiver = makeRegisteredReceiver(receiverBlueApp); final Object yellowReceiver = makeManifestReceiver(PACKAGE_YELLOW, CLASS_YELLOW); diff --git a/services/tests/mockingservicestests/src/com/android/server/display/DisplayPowerController2Test.java b/services/tests/mockingservicestests/src/com/android/server/display/DisplayPowerController2Test.java index 6e63315d2830..b9f2059c0799 100644 --- a/services/tests/mockingservicestests/src/com/android/server/display/DisplayPowerController2Test.java +++ b/services/tests/mockingservicestests/src/com/android/server/display/DisplayPowerController2Test.java @@ -460,6 +460,25 @@ public final class DisplayPowerController2Test { verify(secondFollowerDpc.animator).animateTo(eq(brightness), anyFloat(), anyFloat()); } + @Test + public void testDoesNotSetScreenStateForNonDefaultDisplayUntilBootCompleted() { + // We should still set screen state for the default display + DisplayPowerRequest dpr = new DisplayPowerRequest(); + mHolder.dpc.requestPowerState(dpr, /* waitForNegativeProximity= */ false); + advanceTime(1); + verify(mHolder.displayPowerState).setScreenState(anyInt()); + + mHolder = createDisplayPowerController(42, UNIQUE_ID); + + mHolder.dpc.requestPowerState(dpr, /* waitForNegativeProximity= */ false); + advanceTime(1); + verify(mHolder.displayPowerState, never()).setScreenState(anyInt()); + + mHolder.dpc.onBootCompleted(); + advanceTime(1); + verify(mHolder.displayPowerState).setScreenState(anyInt()); + } + private DisplayPowerControllerHolder createDisplayPowerController(int displayId, String uniqueId) { final DisplayPowerState displayPowerState = mock(DisplayPowerState.class); @@ -487,7 +506,7 @@ public final class DisplayPowerController2Test { mContextSpy, injector, mDisplayPowerCallbacksMock, mHandler, mSensorManagerMock, mDisplayBlankerMock, display, mBrightnessTrackerMock, brightnessSetting, () -> {}, - hbmMetadata); + hbmMetadata, /* bootCompleted= */ false); return new DisplayPowerControllerHolder(dpc, displayPowerState, brightnessSetting, animator, automaticBrightnessController, wakelockController); diff --git a/services/tests/mockingservicestests/src/com/android/server/display/DisplayPowerControllerTest.java b/services/tests/mockingservicestests/src/com/android/server/display/DisplayPowerControllerTest.java index a8c3e4e9dc7e..1e9041c48e44 100644 --- a/services/tests/mockingservicestests/src/com/android/server/display/DisplayPowerControllerTest.java +++ b/services/tests/mockingservicestests/src/com/android/server/display/DisplayPowerControllerTest.java @@ -464,6 +464,25 @@ public final class DisplayPowerControllerTest { verify(secondFollowerHolder.animator).animateTo(eq(brightness), anyFloat(), anyFloat()); } + @Test + public void testDoesNotSetScreenStateForNonDefaultDisplayUntilBootCompleted() { + // We should still set screen state for the default display + DisplayPowerRequest dpr = new DisplayPowerRequest(); + mHolder.dpc.requestPowerState(dpr, /* waitForNegativeProximity= */ false); + advanceTime(1); + verify(mHolder.displayPowerState).setScreenState(anyInt()); + + mHolder = createDisplayPowerController(42, UNIQUE_ID); + + mHolder.dpc.requestPowerState(dpr, /* waitForNegativeProximity= */ false); + advanceTime(1); + verify(mHolder.displayPowerState, never()).setScreenState(anyInt()); + + mHolder.dpc.onBootCompleted(); + advanceTime(1); + verify(mHolder.displayPowerState).setScreenState(anyInt()); + } + private DisplayPowerControllerHolder createDisplayPowerController(int displayId, String uniqueId) { final DisplayPowerState displayPowerState = mock(DisplayPowerState.class); @@ -489,7 +508,7 @@ public final class DisplayPowerControllerTest { mContextSpy, injector, mDisplayPowerCallbacksMock, mHandler, mSensorManagerMock, mDisplayBlankerMock, display, mBrightnessTrackerMock, brightnessSetting, () -> {}, - hbmMetadata); + hbmMetadata, /* bootCompleted= */ false); return new DisplayPowerControllerHolder(dpc, displayPowerState, brightnessSetting, animator, automaticBrightnessController); diff --git a/services/tests/mockingservicestests/src/com/android/server/job/JobSchedulerServiceTest.java b/services/tests/mockingservicestests/src/com/android/server/job/JobSchedulerServiceTest.java index 63a5ff17fedc..991d5667206b 100644 --- a/services/tests/mockingservicestests/src/com/android/server/job/JobSchedulerServiceTest.java +++ b/services/tests/mockingservicestests/src/com/android/server/job/JobSchedulerServiceTest.java @@ -276,11 +276,11 @@ public class JobSchedulerServiceTest { mService.getMinJobExecutionGuaranteeMs(ejMax)); assertEquals(mService.mConstants.RUNTIME_MIN_EJ_GUARANTEE_MS, mService.getMinJobExecutionGuaranteeMs(ejHigh)); - assertEquals(mService.mConstants.RUNTIME_MIN_HIGH_PRIORITY_GUARANTEE_MS, + assertEquals(mService.mConstants.RUNTIME_MIN_GUARANTEE_MS, mService.getMinJobExecutionGuaranteeMs(ejMaxDowngraded)); - assertEquals(mService.mConstants.RUNTIME_MIN_HIGH_PRIORITY_GUARANTEE_MS, + assertEquals(mService.mConstants.RUNTIME_MIN_GUARANTEE_MS, mService.getMinJobExecutionGuaranteeMs(ejHighDowngraded)); - assertEquals(mService.mConstants.RUNTIME_MIN_HIGH_PRIORITY_GUARANTEE_MS, + assertEquals(mService.mConstants.RUNTIME_MIN_GUARANTEE_MS, mService.getMinJobExecutionGuaranteeMs(jobHigh)); assertEquals(mService.mConstants.RUNTIME_MIN_GUARANTEE_MS, mService.getMinJobExecutionGuaranteeMs(jobDef)); diff --git a/services/tests/servicestests/src/com/android/server/devicepolicy/DevicePolicyManagerTest.java b/services/tests/servicestests/src/com/android/server/devicepolicy/DevicePolicyManagerTest.java index 48025ed3ce1e..1f25da7a3cef 100644 --- a/services/tests/servicestests/src/com/android/server/devicepolicy/DevicePolicyManagerTest.java +++ b/services/tests/servicestests/src/com/android/server/devicepolicy/DevicePolicyManagerTest.java @@ -162,6 +162,7 @@ import com.android.server.pm.UserRestrictionsUtils; import org.hamcrest.BaseMatcher; import org.hamcrest.Description; import org.hamcrest.Matcher; +import org.junit.Ignore; import org.junit.After; import org.junit.Before; import org.junit.Test; @@ -1800,6 +1801,7 @@ public class DevicePolicyManagerTest extends DpmTestBase { * privileges can acually be exercised by a delegate are not covered here. */ @Test + @Ignore // temp dsiabled - broken with flags public void testDelegation() throws Exception { setAsProfileOwner(admin1); @@ -1874,6 +1876,7 @@ public class DevicePolicyManagerTest extends DpmTestBase { } @Test + @Ignore // Temp disabled - broken with flags public void testApplicationRestrictionsManagingApp() throws Exception { setAsProfileOwner(admin1); @@ -7344,6 +7347,7 @@ public class DevicePolicyManagerTest extends DpmTestBase { * warned with a notification and then the apps get suspended. */ @Test + @Ignore // Temp disabled - broken with flags public void testMaximumProfileTimeOff_profileOffTimeExceeded() throws Exception { prepareMocksForSetMaximumProfileTimeOff(); diff --git a/services/tests/servicestests/src/com/android/server/pm/UserManagerServiceUserInfoTest.java b/services/tests/servicestests/src/com/android/server/pm/UserManagerServiceUserInfoTest.java index d999aa315940..2273fcd22b38 100644 --- a/services/tests/servicestests/src/com/android/server/pm/UserManagerServiceUserInfoTest.java +++ b/services/tests/servicestests/src/com/android/server/pm/UserManagerServiceUserInfoTest.java @@ -230,7 +230,7 @@ public class UserManagerServiceUserInfoTest { mUserManagerService.putUserInfo(createUser(105, FLAG_SYSTEM | FLAG_FULL, null)); mUserManagerService.putUserInfo(createUser(106, FLAG_DEMO | FLAG_FULL, null)); - mUserManagerService.upgradeIfNecessaryLP(null, versionToTest - 1, userTypeVersion); + mUserManagerService.upgradeIfNecessaryLP(versionToTest - 1, userTypeVersion); assertTrue(mUserManagerService.isUserOfType(100, USER_TYPE_PROFILE_MANAGED)); assertTrue((mUserManagerService.getUserInfo(100).flags & FLAG_PROFILE) != 0); diff --git a/services/tests/servicestests/src/com/android/server/power/LowPowerStandbyControllerTest.java b/services/tests/servicestests/src/com/android/server/power/LowPowerStandbyControllerTest.java index 8a29f75994bd..d3c0e354838b 100644 --- a/services/tests/servicestests/src/com/android/server/power/LowPowerStandbyControllerTest.java +++ b/services/tests/servicestests/src/com/android/server/power/LowPowerStandbyControllerTest.java @@ -16,10 +16,10 @@ package com.android.server.power; +import static android.os.PowerManager.FEATURE_WAKE_ON_LAN_IN_LOW_POWER_STANDBY; import static android.os.PowerManager.LOW_POWER_STANDBY_ALLOWED_REASON_ONGOING_CALL; import static android.os.PowerManager.LOW_POWER_STANDBY_ALLOWED_REASON_TEMP_POWER_SAVE_ALLOWLIST; import static android.os.PowerManager.LOW_POWER_STANDBY_ALLOWED_REASON_VOICE_INTERACTION; -import static android.os.PowerManager.LOW_POWER_STANDBY_FEATURE_WAKE_ON_LAN; import static android.os.PowerManager.LowPowerStandbyPortDescription.MATCH_PORT_LOCAL; import static android.os.PowerManager.LowPowerStandbyPortDescription.PROTOCOL_TCP; import static android.os.PowerManager.LowPowerStandbyPortDescription.PROTOCOL_UDP; @@ -571,17 +571,17 @@ public class LowPowerStandbyControllerTest { mController.setEnabled(false); mTestLooper.dispatchAll(); - assertTrue(mController.isAllowed(LOW_POWER_STANDBY_FEATURE_WAKE_ON_LAN)); + assertTrue(mController.isAllowed(FEATURE_WAKE_ON_LAN_IN_LOW_POWER_STANDBY)); } @Test public void testSetAllowedFeatures_isAllowedWhenEnabled() throws Exception { mController.systemReady(); mController.setEnabled(true); - mController.setPolicy(policyWithAllowedFeatures(LOW_POWER_STANDBY_FEATURE_WAKE_ON_LAN)); + mController.setPolicy(policyWithAllowedFeatures(FEATURE_WAKE_ON_LAN_IN_LOW_POWER_STANDBY)); mTestLooper.dispatchAll(); - assertTrue(mController.isAllowed(LOW_POWER_STANDBY_FEATURE_WAKE_ON_LAN)); + assertTrue(mController.isAllowed(FEATURE_WAKE_ON_LAN_IN_LOW_POWER_STANDBY)); } @Test @@ -590,7 +590,7 @@ public class LowPowerStandbyControllerTest { mController.setEnabled(true); mTestLooper.dispatchAll(); - assertFalse(mController.isAllowed(LOW_POWER_STANDBY_FEATURE_WAKE_ON_LAN)); + assertFalse(mController.isAllowed(FEATURE_WAKE_ON_LAN_IN_LOW_POWER_STANDBY)); } @Test 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 96ec2b83a496..ef3b007171b2 100755 --- a/services/tests/uiservicestests/src/com/android/server/notification/NotificationManagerServiceTest.java +++ b/services/tests/uiservicestests/src/com/android/server/notification/NotificationManagerServiceTest.java @@ -18,6 +18,8 @@ package com.android.server.notification; import static android.app.ActivityManager.RunningAppProcessInfo.IMPORTANCE_FOREGROUND; import static android.app.ActivityManager.RunningAppProcessInfo.IMPORTANCE_VISIBLE; +import static android.app.ActivityManagerInternal.ServiceNotificationPolicy.NOT_FOREGROUND_SERVICE; +import static android.app.ActivityManagerInternal.ServiceNotificationPolicy.SHOW_IMMEDIATELY; import static android.app.ActivityTaskManager.INVALID_TASK_ID; import static android.app.Notification.EXTRA_ALLOW_DURING_SETUP; import static android.app.Notification.FLAG_AUTO_CANCEL; @@ -441,6 +443,8 @@ public class NotificationManagerServiceTest extends UiServiceTestCase { doNothing().when(mContext).sendBroadcastAsUser(any(), any(), any()); + setDpmAppOppsExemptFromDismissal(false); + mService = new TestableNotificationManagerService(mContext, mNotificationRecordLogger, mNotificationInstanceIdSequence); @@ -1183,6 +1187,8 @@ public class NotificationManagerServiceTest extends UiServiceTestCase { public void testEnqueuedBlockedNotifications_appBlockedChannelForegroundService() throws Exception { when(mPackageManager.isPackageSuspendedForUser(anyString(), anyInt())).thenReturn(false); + when(mAmi.applyForegroundServiceNotification( + any(), anyString(), anyInt(), anyString(), anyInt())).thenReturn(SHOW_IMMEDIATELY); NotificationChannel channel = new NotificationChannel("blocked", "name", NotificationManager.IMPORTANCE_NONE); @@ -1205,6 +1211,8 @@ public class NotificationManagerServiceTest extends UiServiceTestCase { public void testEnqueuedBlockedNotifications_userBlockedChannelForegroundService() throws Exception { when(mPackageManager.isPackageSuspendedForUser(anyString(), anyInt())).thenReturn(false); + when(mAmi.applyForegroundServiceNotification( + any(), anyString(), anyInt(), anyString(), anyInt())).thenReturn(SHOW_IMMEDIATELY); NotificationChannel channel = new NotificationChannel("blockedbyuser", "name", IMPORTANCE_HIGH); @@ -1284,6 +1292,8 @@ public class NotificationManagerServiceTest extends UiServiceTestCase { public void testEnqueuedBlockedNotifications_blockedAppForegroundService() throws Exception { when(mPackageManager.isPackageSuspendedForUser(anyString(), anyInt())).thenReturn(false); when(mPermissionHelper.hasPermission(mUid)).thenReturn(false); + when(mAmi.applyForegroundServiceNotification( + any(), anyString(), anyInt(), anyString(), anyInt())).thenReturn(SHOW_IMMEDIATELY); final StatusBarNotification sbn = generateNotificationRecord(null).getSbn(); sbn.getNotification().flags |= FLAG_FOREGROUND_SERVICE; @@ -1613,6 +1623,8 @@ public class NotificationManagerServiceTest extends UiServiceTestCase { @Test public void testEnqueueNotificationWithTag_FgsAddsFlags_dismissalAllowed() throws Exception { + when(mAmi.applyForegroundServiceNotification( + any(), anyString(), anyInt(), anyString(), anyInt())).thenReturn(SHOW_IMMEDIATELY); mContext.getTestablePermissions().setPermission( android.Manifest.permission.USE_COLORIZED_NOTIFICATIONS, PERMISSION_GRANTED); DeviceConfig.setProperty( @@ -1643,6 +1655,8 @@ public class NotificationManagerServiceTest extends UiServiceTestCase { @Test public void testEnqueueNotificationWithTag_FGSaddsFlags_dismissalNotAllowed() throws Exception { + when(mAmi.applyForegroundServiceNotification( + any(), anyString(), anyInt(), anyString(), anyInt())).thenReturn(SHOW_IMMEDIATELY); mContext.getTestablePermissions().setPermission( android.Manifest.permission.USE_COLORIZED_NOTIFICATIONS, PERMISSION_GRANTED); DeviceConfig.setProperty( @@ -1931,6 +1945,8 @@ public class NotificationManagerServiceTest extends UiServiceTestCase { @Test public void testCancelAllNotifications_IgnoreForegroundService() throws Exception { + when(mAmi.applyForegroundServiceNotification( + any(), anyString(), anyInt(), anyString(), anyInt())).thenReturn(SHOW_IMMEDIATELY); final StatusBarNotification sbn = generateNotificationRecord(null).getSbn(); sbn.getNotification().flags |= FLAG_FOREGROUND_SERVICE; mBinderService.enqueueNotificationWithTag(PKG, PKG, @@ -1945,7 +1961,27 @@ public class NotificationManagerServiceTest extends UiServiceTestCase { } @Test + public void testCancelAllNotifications_FgsFlag_NoFgs_Allowed() throws Exception { + when(mAmi.applyForegroundServiceNotification( + any(), anyString(), anyInt(), anyString(), anyInt())) + .thenReturn(NOT_FOREGROUND_SERVICE); + final StatusBarNotification sbn = generateNotificationRecord(null).getSbn(); + sbn.getNotification().flags |= FLAG_FOREGROUND_SERVICE; + mBinderService.enqueueNotificationWithTag(PKG, PKG, + "testCancelAllNotifications_IgnoreForegroundService", + sbn.getId(), sbn.getNotification(), sbn.getUserId()); + mBinderService.cancelAllNotifications(PKG, sbn.getUserId()); + waitForIdle(); + StatusBarNotification[] notifs = + mBinderService.getActiveNotifications(sbn.getPackageName()); + assertEquals(0, notifs.length); + } + + @Test public void testCancelAllNotifications_IgnoreOtherPackages() throws Exception { + when(mAmi.applyForegroundServiceNotification( + any(), anyString(), anyInt(), anyString(), anyInt())) + .thenReturn(SHOW_IMMEDIATELY); final StatusBarNotification sbn = generateNotificationRecord(null).getSbn(); sbn.getNotification().flags |= FLAG_FOREGROUND_SERVICE; mBinderService.enqueueNotificationWithTag(PKG, PKG, @@ -2033,6 +2069,9 @@ public class NotificationManagerServiceTest extends UiServiceTestCase { @Test public void testRemoveForegroundServiceFlag_ImmediatelyAfterEnqueue() throws Exception { + when(mAmi.applyForegroundServiceNotification( + any(), anyString(), anyInt(), anyString(), anyInt())) + .thenReturn(SHOW_IMMEDIATELY); Notification n = new Notification.Builder(mContext, mTestNotificationChannel.getId()) .setSmallIcon(android.R.drawable.sym_def_app_icon) @@ -2070,6 +2109,9 @@ public class NotificationManagerServiceTest extends UiServiceTestCase { @Test public void testCancelNotificationWithTag_fromApp_cannotCancelFgsChild() throws Exception { + when(mAmi.applyForegroundServiceNotification( + any(), anyString(), anyInt(), anyString(), anyInt())) + .thenReturn(SHOW_IMMEDIATELY); mService.isSystemUid = false; final NotificationRecord parent = generateNotificationRecord( mTestNotificationChannel, 1, "group", true); @@ -2093,6 +2135,9 @@ public class NotificationManagerServiceTest extends UiServiceTestCase { @Test public void testCancelNotificationWithTag_fromApp_cannotCancelFgsParent() throws Exception { + when(mAmi.applyForegroundServiceNotification( + any(), anyString(), anyInt(), anyString(), anyInt())) + .thenReturn(SHOW_IMMEDIATELY); mService.isSystemUid = false; final NotificationRecord parent = generateNotificationRecord( mTestNotificationChannel, 1, "group", true); @@ -2162,6 +2207,9 @@ public class NotificationManagerServiceTest extends UiServiceTestCase { @Test public void testCancelAllNotificationsFromApp_cannotCancelFgsChild() throws Exception { + when(mAmi.applyForegroundServiceNotification( + any(), anyString(), anyInt(), anyString(), anyInt())) + .thenReturn(SHOW_IMMEDIATELY); mService.isSystemUid = false; final NotificationRecord parent = generateNotificationRecord( mTestNotificationChannel, 1, "group", true); @@ -2187,6 +2235,9 @@ public class NotificationManagerServiceTest extends UiServiceTestCase { @Test public void testCancelAllNotifications_fromApp_cannotCancelFgsParent() throws Exception { + when(mAmi.applyForegroundServiceNotification( + any(), anyString(), anyInt(), anyString(), anyInt())) + .thenReturn(SHOW_IMMEDIATELY); mService.isSystemUid = false; final NotificationRecord parent = generateNotificationRecord( mTestNotificationChannel, 1, "group", true); @@ -2308,6 +2359,9 @@ public class NotificationManagerServiceTest extends UiServiceTestCase { @Test public void testCancelNotificationsFromListener_clearAll_GroupWithFgsParent() throws Exception { + when(mAmi.applyForegroundServiceNotification( + any(), anyString(), anyInt(), anyString(), anyInt())) + .thenReturn(SHOW_IMMEDIATELY); final NotificationRecord parent = generateNotificationRecord( mTestNotificationChannel, 1, "group", true); parent.getNotification().flags |= FLAG_FOREGROUND_SERVICE; @@ -2331,6 +2385,9 @@ public class NotificationManagerServiceTest extends UiServiceTestCase { @Test public void testCancelNotificationsFromListener_clearAll_GroupWithFgsChild() throws Exception { + when(mAmi.applyForegroundServiceNotification( + any(), anyString(), anyInt(), anyString(), anyInt())) + .thenReturn(SHOW_IMMEDIATELY); final NotificationRecord parent = generateNotificationRecord( mTestNotificationChannel, 1, "group", true); final NotificationRecord child = generateNotificationRecord( @@ -2429,6 +2486,9 @@ public class NotificationManagerServiceTest extends UiServiceTestCase { @Test public void testCancelNotificationsFromListener_clearAll_Fgs() throws Exception { + when(mAmi.applyForegroundServiceNotification( + any(), anyString(), anyInt(), anyString(), anyInt())) + .thenReturn(SHOW_IMMEDIATELY); final NotificationRecord child2 = generateNotificationRecord( mTestNotificationChannel, 3, null, false); child2.getNotification().flags |= FLAG_FOREGROUND_SERVICE; @@ -2493,6 +2553,9 @@ public class NotificationManagerServiceTest extends UiServiceTestCase { @Test public void testCancelNotificationsFromListener_byKey_GroupWithFgsParent() throws Exception { + when(mAmi.applyForegroundServiceNotification( + any(), anyString(), anyInt(), anyString(), anyInt())) + .thenReturn(SHOW_IMMEDIATELY); final NotificationRecord parent = generateNotificationRecord( mTestNotificationChannel, 1, "group", true); parent.getNotification().flags |= FLAG_FOREGROUND_SERVICE; @@ -2518,6 +2581,9 @@ public class NotificationManagerServiceTest extends UiServiceTestCase { @Test public void testCancelNotificationsFromListener_byKey_GroupWithFgsChild() throws Exception { + when(mAmi.applyForegroundServiceNotification( + any(), anyString(), anyInt(), anyString(), anyInt())) + .thenReturn(SHOW_IMMEDIATELY); final NotificationRecord parent = generateNotificationRecord( mTestNotificationChannel, 1, "group", true); final NotificationRecord child = generateNotificationRecord( @@ -2623,6 +2689,9 @@ public class NotificationManagerServiceTest extends UiServiceTestCase { @Test public void testCancelNotificationsFromListener_byKey_Fgs() throws Exception { + when(mAmi.applyForegroundServiceNotification( + any(), anyString(), anyInt(), anyString(), anyInt())) + .thenReturn(SHOW_IMMEDIATELY); final NotificationRecord child2 = generateNotificationRecord( mTestNotificationChannel, 3, null, false); child2.getNotification().flags |= FLAG_FOREGROUND_SERVICE; @@ -2789,6 +2858,9 @@ public class NotificationManagerServiceTest extends UiServiceTestCase { @Test public void testUserInitiatedCancelAllWithGroup_ForegroundServiceFlag() throws Exception { + when(mAmi.applyForegroundServiceNotification( + any(), anyString(), anyInt(), anyString(), anyInt())) + .thenReturn(SHOW_IMMEDIATELY); final NotificationRecord parent = generateNotificationRecord( mTestNotificationChannel, 1, "group", true); final NotificationRecord child = generateNotificationRecord( @@ -6249,6 +6321,9 @@ public class NotificationManagerServiceTest extends UiServiceTestCase { @Test public void testRemoveForegroundServiceFlagFromNotification_enqueued() { + when(mAmi.applyForegroundServiceNotification( + any(), anyString(), anyInt(), anyString(), anyInt())) + .thenReturn(SHOW_IMMEDIATELY); Notification n = new Notification.Builder(mContext, "").build(); n.flags |= FLAG_FOREGROUND_SERVICE; @@ -6268,6 +6343,9 @@ public class NotificationManagerServiceTest extends UiServiceTestCase { @Test public void testRemoveForegroundServiceFlagFromNotification_posted() { + when(mAmi.applyForegroundServiceNotification( + any(), anyString(), anyInt(), anyString(), anyInt())) + .thenReturn(SHOW_IMMEDIATELY); Notification n = new Notification.Builder(mContext, "").build(); n.flags |= FLAG_FOREGROUND_SERVICE; @@ -6291,6 +6369,9 @@ public class NotificationManagerServiceTest extends UiServiceTestCase { @Test public void testCannotRemoveForegroundFlagWhenOverLimit_enqueued() { + when(mAmi.applyForegroundServiceNotification( + any(), anyString(), anyInt(), anyString(), anyInt())) + .thenReturn(SHOW_IMMEDIATELY); for (int i = 0; i < NotificationManagerService.MAX_PACKAGE_NOTIFICATIONS; i++) { Notification n = new Notification.Builder(mContext, "").build(); StatusBarNotification sbn = new StatusBarNotification(PKG, PKG, i, null, mUid, 0, @@ -6319,6 +6400,9 @@ public class NotificationManagerServiceTest extends UiServiceTestCase { @Test public void testCannotRemoveForegroundFlagWhenOverLimit_posted() { + when(mAmi.applyForegroundServiceNotification( + any(), anyString(), anyInt(), anyString(), anyInt())) + .thenReturn(SHOW_IMMEDIATELY); for (int i = 0; i < NotificationManagerService.MAX_PACKAGE_NOTIFICATIONS; i++) { Notification n = new Notification.Builder(mContext, "").build(); StatusBarNotification sbn = new StatusBarNotification(PKG, PKG, i, null, mUid, 0, @@ -8327,7 +8411,7 @@ public class NotificationManagerServiceTest extends UiServiceTestCase { assertNotNull(n.publicVersion.bigContentView); assertNotNull(n.publicVersion.headsUpContentView); - mService.fixNotification(n, PKG, "tag", 9, 0, mUid); + mService.fixNotification(n, PKG, "tag", 9, 0, mUid, NOT_FOREGROUND_SERVICE); assertNull(n.contentView); assertNull(n.bigContentView); @@ -9018,6 +9102,9 @@ public class NotificationManagerServiceTest extends UiServiceTestCase { @Test public void testCanPostFgsWhenOverLimit() throws RemoteException { + when(mAmi.applyForegroundServiceNotification( + any(), anyString(), anyInt(), anyString(), anyInt())) + .thenReturn(SHOW_IMMEDIATELY); for (int i = 0; i < NotificationManagerService.MAX_PACKAGE_NOTIFICATIONS; i++) { StatusBarNotification sbn = generateNotificationRecord(mTestNotificationChannel, i, null, false).getSbn(); @@ -9043,6 +9130,9 @@ public class NotificationManagerServiceTest extends UiServiceTestCase { @Test public void testCannotPostNonFgsWhenOverLimit() throws RemoteException { + when(mAmi.applyForegroundServiceNotification( + any(), anyString(), anyInt(), anyString(), anyInt())) + .thenReturn(SHOW_IMMEDIATELY); for (int i = 0; i < NotificationManagerService.MAX_PACKAGE_NOTIFICATIONS; i++) { StatusBarNotification sbn = generateNotificationRecord(mTestNotificationChannel, i, null, false).getSbn(); @@ -9065,6 +9155,17 @@ public class NotificationManagerServiceTest extends UiServiceTestCase { "testCanPostFgsWhenOverLimit - non fgs over limit!", sbn2.getId(), sbn2.getNotification(), sbn2.getUserId()); + + when(mAmi.applyForegroundServiceNotification( + any(), anyString(), anyInt(), anyString(), anyInt())) + .thenReturn(NOT_FOREGROUND_SERVICE); + final StatusBarNotification sbn3 = generateNotificationRecord(mTestNotificationChannel, + 101, null, false).getSbn(); + sbn3.getNotification().flags |= FLAG_FOREGROUND_SERVICE; + mBinderService.enqueueNotificationWithTag(PKG, PKG, + "testCanPostFgsWhenOverLimit - fake fgs over limit!", + sbn3.getId(), sbn3.getNotification(), sbn3.getUserId()); + waitForIdle(); StatusBarNotification[] notifs = @@ -10137,7 +10238,7 @@ public class NotificationManagerServiceTest extends UiServiceTestCase { .setFullScreenIntent(mock(PendingIntent.class), true) .build(); - mService.fixNotification(n, PKG, "tag", 9, 0, mUid); + mService.fixNotification(n, PKG, "tag", 9, 0, mUid, NOT_FOREGROUND_SERVICE); final int stickyFlag = n.flags & Notification.FLAG_FSI_REQUESTED_BUT_DENIED; @@ -10203,8 +10304,35 @@ public class NotificationManagerServiceTest extends UiServiceTestCase { } @Test - public void fixSystemNotification_withOnGoingFlag_shouldBeNonDismissible() + public void fixNotification_withFgsFlag_butIsNotFgs() throws Exception { + final ApplicationInfo applicationInfo = new ApplicationInfo(); + when(mPackageManagerClient.getApplicationInfoAsUser(anyString(), anyInt(), anyInt())) + .thenReturn(applicationInfo); + + Notification n = new Notification.Builder(mContext, "test") + .setFlag(FLAG_FOREGROUND_SERVICE, true) + .setFlag(FLAG_CAN_COLORIZE, true) + .build(); + + mService.fixNotification(n, PKG, "tag", 9, 0, mUid, NOT_FOREGROUND_SERVICE); + + assertFalse(n.isForegroundService()); + assertFalse(n.hasColorizedPermission()); + } + + @Test + public void fixSystemNotification_withOnGoingFlag_shouldBeDismissible() throws Exception { + final ApplicationInfo ai = new ApplicationInfo(); + ai.packageName = "pkg"; + ai.uid = mUid; + ai.flags |= ApplicationInfo.FLAG_SYSTEM; + + when(mPackageManagerClient.getApplicationInfoAsUser(anyString(), anyInt(), anyInt())) + .thenReturn(ai); + when(mAppOpsManager.checkOpNoThrow( + AppOpsManager.OP_SYSTEM_EXEMPT_FROM_DISMISSIBLE_NOTIFICATIONS, ai.uid, + ai.packageName)).thenReturn(AppOpsManager.MODE_IGNORED); // Given: a notification from an app on the system partition has the flag // FLAG_ONGOING_EVENT set // feature flag: ALLOW_DISMISS_ONGOING is on @@ -10213,16 +10341,11 @@ public class NotificationManagerServiceTest extends UiServiceTestCase { .setOngoing(true) .build(); - final ApplicationInfo systemAppInfo = new ApplicationInfo(); - systemAppInfo.flags |= ApplicationInfo.FLAG_SYSTEM; - when(mPackageManagerClient.getApplicationInfoAsUser(anyString(), anyInt(), anyInt())) - .thenReturn(systemAppInfo); - // When: fix the notification with NotificationManagerService - mService.fixNotification(n, PKG, "tag", 9, 0, mUid); + mService.fixNotification(n, PKG, "tag", 9, 0, mUid, NOT_FOREGROUND_SERVICE); - // Then: the notification's flag FLAG_NO_DISMISS should be set - assertNotSame(0, n.flags & Notification.FLAG_NO_DISMISS); + // Then: the notification's flag FLAG_NO_DISMISS should not be set + assertSame(0, n.flags & Notification.FLAG_NO_DISMISS); } @Test @@ -10238,7 +10361,7 @@ public class NotificationManagerServiceTest extends UiServiceTestCase { .build(); // When: fix the notification with NotificationManagerService - mService.fixNotification(n, PKG, "tag", 9, 0, mUid); + mService.fixNotification(n, PKG, "tag", 9, 0, mUid, NOT_FOREGROUND_SERVICE); // Then: the notification's flag FLAG_NO_DISMISS should be set assertNotSame(0, n.flags & Notification.FLAG_NO_DISMISS); @@ -10254,7 +10377,7 @@ public class NotificationManagerServiceTest extends UiServiceTestCase { .build(); // When: fix the notification with NotificationManagerService - mService.fixNotification(n, PKG, "tag", 9, 0, mUid); + mService.fixNotification(n, PKG, "tag", 9, 0, mUid, NOT_FOREGROUND_SERVICE); // Then: the notification's flag FLAG_NO_DISMISS should not be set assertEquals(0, n.flags & Notification.FLAG_NO_DISMISS); @@ -10272,53 +10395,7 @@ public class NotificationManagerServiceTest extends UiServiceTestCase { n.flags |= Notification.FLAG_NO_DISMISS; // When: fix the notification with NotificationManagerService - mService.fixNotification(n, PKG, "tag", 9, 0, mUid); - - // Then: the notification's flag FLAG_NO_DISMISS should be cleared - assertEquals(0, n.flags & Notification.FLAG_NO_DISMISS); - } - - @Test - public void fixSystemNotification_withoutOnGoingFlag_shouldBeDismissible() throws Exception { - // Given: a notification from an app on the system partition doesn't have the flag - // FLAG_ONGOING_EVENT set - // feature flag: ALLOW_DISMISS_ONGOING is on - mTestFlagResolver.setFlagOverride(ALLOW_DISMISS_ONGOING, true); - Notification n = new Notification.Builder(mContext, "test") - .setOngoing(false) - .build(); - - final ApplicationInfo systemAppInfo = new ApplicationInfo(); - systemAppInfo.flags |= ApplicationInfo.FLAG_SYSTEM; - when(mPackageManagerClient.getApplicationInfoAsUser(anyString(), anyInt(), anyInt())) - .thenReturn(systemAppInfo); - - // When: fix the notification with NotificationManagerService - mService.fixNotification(n, PKG, "tag", 9, 0, mUid); - - // Then: the notification's flag FLAG_NO_DISMISS should not be set - assertEquals(0, n.flags & Notification.FLAG_NO_DISMISS); - } - - @Test - public void fixSystemNotification_withoutOnGoingFlag_withNoDismissFlag_shouldBeDismissible() - throws Exception { - // Given: a notification from an app on the system partition doesn't have the flag - // FLAG_ONGOING_EVENT set, but has the flag FLAG_NO_DISMISS set - // feature flag: ALLOW_DISMISS_ONGOING is on - mTestFlagResolver.setFlagOverride(ALLOW_DISMISS_ONGOING, true); - Notification n = new Notification.Builder(mContext, "test") - .setOngoing(false) - .build(); - n.flags |= Notification.FLAG_NO_DISMISS; - - final ApplicationInfo systemAppInfo = new ApplicationInfo(); - systemAppInfo.flags |= ApplicationInfo.FLAG_SYSTEM; - when(mPackageManagerClient.getApplicationInfoAsUser(anyString(), anyInt(), anyInt())) - .thenReturn(systemAppInfo); - - // When: fix the notification with NotificationManagerService - mService.fixNotification(n, PKG, "tag", 9, 0, mUid); + mService.fixNotification(n, PKG, "tag", 9, 0, mUid, NOT_FOREGROUND_SERVICE); // Then: the notification's flag FLAG_NO_DISMISS should be cleared assertEquals(0, n.flags & Notification.FLAG_NO_DISMISS); @@ -10336,7 +10413,7 @@ public class NotificationManagerServiceTest extends UiServiceTestCase { .build(); // When: fix the notification with NotificationManagerService - mService.fixNotification(n, PKG, "tag", 9, 0, mUid); + mService.fixNotification(n, PKG, "tag", 9, 0, mUid, NOT_FOREGROUND_SERVICE); // Then: the notification's flag FLAG_NO_DISMISS should not be set assertEquals(0, n.flags & Notification.FLAG_NO_DISMISS); @@ -10357,7 +10434,7 @@ public class NotificationManagerServiceTest extends UiServiceTestCase { n.flags |= Notification.FLAG_NO_DISMISS; // When: fix the notification with NotificationManagerService - mService.fixNotification(n, PKG, "tag", 9, 0, mUid); + mService.fixNotification(n, PKG, "tag", 9, 0, mUid, NOT_FOREGROUND_SERVICE); // Then: the notification's flag FLAG_NO_DISMISS should be cleared assertEquals(0, n.flags & Notification.FLAG_NO_DISMISS); @@ -10374,7 +10451,7 @@ public class NotificationManagerServiceTest extends UiServiceTestCase { .build(); // When: fix the notification with NotificationManagerService - mService.fixNotification(n, PKG, "tag", 9, 0, mUid); + mService.fixNotification(n, PKG, "tag", 9, 0, mUid, NOT_FOREGROUND_SERVICE); // Then: the notification's flag FLAG_NO_DISMISS should not be set assertEquals(0, n.flags & Notification.FLAG_NO_DISMISS); @@ -10387,43 +10464,48 @@ public class NotificationManagerServiceTest extends UiServiceTestCase { // Given: a notification has the flag FLAG_ONGOING_EVENT set // feature flag: ALLOW_DISMISS_ONGOING is on mTestFlagResolver.setFlagOverride(ALLOW_DISMISS_ONGOING, true); - setSystemExemptFromDismissal(false); + setDpmAppOppsExemptFromDismissal(false); Notification n = new Notification.Builder(mContext, "test") .setOngoing(true) .build(); // When: fix the notification with NotificationManagerService - mService.fixNotification(n, PKG, "tag", 9, 0, mUid); + mService.fixNotification(n, PKG, "tag", 9, 0, mUid, NOT_FOREGROUND_SERVICE); // Then: the notification's flag FLAG_NO_DISMISS should be set assertNotSame(0, n.flags & Notification.FLAG_NO_DISMISS); } @Test - public void fixSystemExemptAppOpNotification_withFlag_shouldBeNonDismissible() + public void fixExemptAppOpNotification_withFlag_shouldBeNonDismissible() throws Exception { + final ApplicationInfo ai = new ApplicationInfo(); + ai.packageName = PKG; + ai.uid = mUid; + ai.flags |= ApplicationInfo.FLAG_SYSTEM; + + when(mPackageManagerClient.getApplicationInfoAsUser(anyString(), anyInt(), anyInt())) + .thenReturn(ai); when(mAppOpsManager.checkOpNoThrow( AppOpsManager.OP_SYSTEM_EXEMPT_FROM_DISMISSIBLE_NOTIFICATIONS, mUid, PKG)).thenReturn(AppOpsManager.MODE_ALLOWED); // Given: a notification has the flag FLAG_ONGOING_EVENT set // feature flag: ALLOW_DISMISS_ONGOING is on mTestFlagResolver.setFlagOverride(ALLOW_DISMISS_ONGOING, true); - setSystemExemptFromDismissal(true); + setDpmAppOppsExemptFromDismissal(true); Notification n = new Notification.Builder(mContext, "test") .setOngoing(true) .build(); // When: fix the notification with NotificationManagerService - mService.fixNotification(n, PKG, "tag", 9, 0, mUid); + mService.fixNotification(n, PKG, "tag", 9, 0, mUid, NOT_FOREGROUND_SERVICE); - // Then: the notification's flag FLAG_NO_DISMISS should be set - assertNotSame(0, n.flags & Notification.FLAG_NO_DISMISS); - - setSystemExemptFromDismissal(false); + // Then: the notification's flag FLAG_NO_DISMISS should be cleared + assertEquals(0, n.flags & Notification.FLAG_NO_DISMISS); } @Test - public void fixSystemExemptAppOpNotification_withoutFlag_shouldBeNonDismissible() + public void fixExemptAppOpNotification_withoutAppOpsFlag_shouldBeDismissible() throws Exception { when(mAppOpsManager.checkOpNoThrow( AppOpsManager.OP_SYSTEM_EXEMPT_FROM_DISMISSIBLE_NOTIFICATIONS, mUid, @@ -10431,19 +10513,19 @@ public class NotificationManagerServiceTest extends UiServiceTestCase { // Given: a notification has the flag FLAG_ONGOING_EVENT set // feature flag: ALLOW_DISMISS_ONGOING is on mTestFlagResolver.setFlagOverride(ALLOW_DISMISS_ONGOING, true); - setSystemExemptFromDismissal(false); + setDpmAppOppsExemptFromDismissal(false); Notification n = new Notification.Builder(mContext, "test") .setOngoing(true) .build(); // When: fix the notification with NotificationManagerService - mService.fixNotification(n, PKG, "tag", 9, 0, mUid); + mService.fixNotification(n, PKG, "tag", 9, 0, mUid, NOT_FOREGROUND_SERVICE); // Then: the notification's flag FLAG_NO_DISMISS should not be set - assertEquals(0, n.flags & Notification.FLAG_NO_DISMISS); + assertSame(0, n.flags & Notification.FLAG_NO_DISMISS); } - private void setSystemExemptFromDismissal(boolean isOn) { + private void setDpmAppOppsExemptFromDismissal(boolean isOn) { DeviceConfig.setProperty( DeviceConfig.NAMESPACE_DEVICE_POLICY_MANAGER, /* name= */ "application_exemptions", diff --git a/services/tests/wmtests/src/com/android/server/policy/ModifierShortcutTests.java b/services/tests/wmtests/src/com/android/server/policy/ModifierShortcutTests.java index ad47773747d4..369e8f14ff74 100644 --- a/services/tests/wmtests/src/com/android/server/policy/ModifierShortcutTests.java +++ b/services/tests/wmtests/src/com/android/server/policy/ModifierShortcutTests.java @@ -16,13 +16,12 @@ package com.android.server.policy; -import static android.view.KeyEvent.KEYCODE_A; import static android.view.KeyEvent.KEYCODE_ALT_LEFT; import static android.view.KeyEvent.KEYCODE_B; import static android.view.KeyEvent.KEYCODE_C; import static android.view.KeyEvent.KEYCODE_CTRL_LEFT; import static android.view.KeyEvent.KEYCODE_E; -import static android.view.KeyEvent.KEYCODE_L; +import static android.view.KeyEvent.KEYCODE_K; import static android.view.KeyEvent.KEYCODE_M; import static android.view.KeyEvent.KEYCODE_META_LEFT; import static android.view.KeyEvent.KEYCODE_N; @@ -31,6 +30,7 @@ import static android.view.KeyEvent.KEYCODE_S; import static android.view.KeyEvent.KEYCODE_SLASH; import static android.view.KeyEvent.KEYCODE_SPACE; import static android.view.KeyEvent.KEYCODE_TAB; +import static android.view.KeyEvent.KEYCODE_U; import static android.view.KeyEvent.KEYCODE_Z; import android.content.Intent; @@ -42,11 +42,11 @@ import org.junit.Test; public class ModifierShortcutTests extends ShortcutKeyTestBase { private static final SparseArray<String> META_SHORTCUTS = new SparseArray<>(); static { - META_SHORTCUTS.append(KEYCODE_A, Intent.CATEGORY_APP_CALCULATOR); + META_SHORTCUTS.append(KEYCODE_U, Intent.CATEGORY_APP_CALCULATOR); META_SHORTCUTS.append(KEYCODE_B, Intent.CATEGORY_APP_BROWSER); META_SHORTCUTS.append(KEYCODE_C, Intent.CATEGORY_APP_CONTACTS); META_SHORTCUTS.append(KEYCODE_E, Intent.CATEGORY_APP_EMAIL); - META_SHORTCUTS.append(KEYCODE_L, Intent.CATEGORY_APP_CALENDAR); + META_SHORTCUTS.append(KEYCODE_K, Intent.CATEGORY_APP_CALENDAR); META_SHORTCUTS.append(KEYCODE_M, Intent.CATEGORY_APP_MAPS); META_SHORTCUTS.append(KEYCODE_P, Intent.CATEGORY_APP_MUSIC); META_SHORTCUTS.append(KEYCODE_S, Intent.CATEGORY_APP_MESSAGING); diff --git a/services/tests/wmtests/src/com/android/server/policy/TestPhoneWindowManager.java b/services/tests/wmtests/src/com/android/server/policy/TestPhoneWindowManager.java index a76b82babe08..6e7e005fc0a3 100644 --- a/services/tests/wmtests/src/com/android/server/policy/TestPhoneWindowManager.java +++ b/services/tests/wmtests/src/com/android/server/policy/TestPhoneWindowManager.java @@ -237,6 +237,7 @@ class TestPhoneWindowManager { overrideLaunchAccessibility(); doReturn(false).when(mPhoneWindowManager).keyguardOn(); doNothing().when(mContext).startActivityAsUser(any(), any()); + Mockito.reset(mContext); } void tearDown() { @@ -399,8 +400,12 @@ class TestPhoneWindowManager { void assertLaunchCategory(String category) { waitForIdle(); ArgumentCaptor<Intent> intentCaptor = ArgumentCaptor.forClass(Intent.class); - verify(mContext).startActivityAsUser(intentCaptor.capture(), any()); - Assert.assertTrue(intentCaptor.getValue().getSelector().hasCategory(category)); + try { + verify(mContext).startActivityAsUser(intentCaptor.capture(), any()); + Assert.assertTrue(intentCaptor.getValue().getSelector().hasCategory(category)); + } catch (Throwable t) { + throw new AssertionError("failed to assert " + category, t); + } // Reset verifier for next call. Mockito.reset(mContext); } diff --git a/services/voiceinteraction/java/com/android/server/soundtrigger/SoundTriggerService.java b/services/voiceinteraction/java/com/android/server/soundtrigger/SoundTriggerService.java index 495a43370163..140088666536 100644 --- a/services/voiceinteraction/java/com/android/server/soundtrigger/SoundTriggerService.java +++ b/services/voiceinteraction/java/com/android/server/soundtrigger/SoundTriggerService.java @@ -1647,11 +1647,13 @@ public class SoundTriggerService extends SystemService { @Override public List<ModuleProperties> listModuleProperties(Identity originatorIdentity) { - Identity middlemanIdentity = new Identity(); - middlemanIdentity.packageName = ActivityThread.currentOpPackageName(); + Identity identity = new Identity(); + identity.packageName = ActivityThread.currentOpPackageName(); ArrayList<ModuleProperties> moduleList = new ArrayList<>(); - SoundTrigger.listModulesAsMiddleman(moduleList, middlemanIdentity, - originatorIdentity); + // Overwrite with our own identity to fix permission issues. + // VIMService always does its own validation, so this is fine. + // TODO(b/269765333) + SoundTrigger.listModulesAsOriginator(moduleList, identity); return moduleList; } diff --git a/services/voiceinteraction/java/com/android/server/voiceinteraction/DetectorSession.java b/services/voiceinteraction/java/com/android/server/voiceinteraction/DetectorSession.java index afee94000edc..ec9bd2fbfa6d 100644 --- a/services/voiceinteraction/java/com/android/server/voiceinteraction/DetectorSession.java +++ b/services/voiceinteraction/java/com/android/server/voiceinteraction/DetectorSession.java @@ -70,6 +70,7 @@ import android.os.RemoteException; import android.os.SharedMemory; import android.service.voice.HotwordDetectedResult; import android.service.voice.HotwordDetectionService; +import android.service.voice.HotwordDetectionServiceFailure; import android.service.voice.HotwordDetector; import android.service.voice.HotwordRejectedResult; import android.service.voice.IDspHotwordDetectionCallback; @@ -122,10 +123,16 @@ abstract class DetectorSession { "Providing hotword detection result to VoiceInteractionService"; // The error codes are used for onError callback - static final int HOTWORD_DETECTION_SERVICE_DIED = -1; - static final int CALLBACK_ONDETECTED_GOT_SECURITY_EXCEPTION = -2; - static final int CALLBACK_DETECT_TIMEOUT = -3; - static final int CALLBACK_ONDETECTED_STREAM_COPY_ERROR = -4; + static final int HOTWORD_DETECTION_SERVICE_DIED = + HotwordDetectionServiceFailure.ERROR_CODE_BINDING_DIED; + static final int CALLBACK_ONDETECTED_GOT_SECURITY_EXCEPTION = + HotwordDetectionServiceFailure.ERROR_CODE_ON_DETECTED_SECURITY_EXCEPTION; + static final int CALLBACK_DETECT_TIMEOUT = + HotwordDetectionServiceFailure.ERROR_CODE_DETECT_TIMEOUT; + static final int CALLBACK_ONDETECTED_STREAM_COPY_ERROR = + HotwordDetectionServiceFailure.ERROR_CODE_ON_DETECTED_STREAM_COPY_FAILURE; + static final int CALLBACK_COPY_AUDIO_DATA_FAILURE = + HotwordDetectionServiceFailure.ERROR_CODE_COPY_AUDIO_DATA_FAILURE; // TODO: These constants need to be refined. private static final long MAX_UPDATE_TIMEOUT_MILLIS = 30000; @@ -426,7 +433,9 @@ abstract class DetectorSession { Slog.w(TAG, "Failed supplying audio data to validator", e); try { - callback.onError(); + callback.onError( + new HotwordDetectionServiceFailure(CALLBACK_COPY_AUDIO_DATA_FAILURE, + "Copy audio data failure for external source detection.")); } catch (RemoteException ex) { Slog.w(TAG, "Failed to report onError status: " + ex); if (getDetectorType() != HotwordDetector.DETECTOR_TYPE_VISUAL_QUERY_DETECTOR) { @@ -505,7 +514,10 @@ abstract class DetectorSession { getDetectorType(), EXTERNAL_SOURCE_DETECT_SECURITY_EXCEPTION, mVoiceInteractionServiceUid); - callback.onError(); + callback.onError(new HotwordDetectionServiceFailure( + CALLBACK_ONDETECTED_GOT_SECURITY_EXCEPTION, + "Security exception occurs in #onDetected" + + " method.")); return; } HotwordDetectedResult newResult; @@ -514,7 +526,9 @@ abstract class DetectorSession { .startCopyingAudioStreams(triggerResult); } catch (IOException e) { // TODO: Write event - callback.onError(); + callback.onError(new HotwordDetectionServiceFailure( + CALLBACK_ONDETECTED_STREAM_COPY_ERROR, + "Copy audio stream failure.")); return; } callback.onDetected(newResult, /* audioFormat= */ null, @@ -569,9 +583,11 @@ abstract class DetectorSession { mRemoteDetectionService = remoteDetectionService; } - void reportErrorLocked(int status) { + void reportErrorLocked(int errorCode, @NonNull String errorMessage) { try { - mCallback.onError(status); + // TODO: Use instanceof(this) to get different detector to set the right error source. + mCallback.onDetectionFailure( + new HotwordDetectionServiceFailure(errorCode, errorMessage)); } catch (RemoteException e) { Slog.w(TAG, "Failed to report onError status: " + e); if (getDetectorType() != HotwordDetector.DETECTOR_TYPE_VISUAL_QUERY_DETECTOR) { diff --git a/services/voiceinteraction/java/com/android/server/voiceinteraction/DspTrustedHotwordDetectorSession.java b/services/voiceinteraction/java/com/android/server/voiceinteraction/DspTrustedHotwordDetectorSession.java index cb5b9300c197..63e0f466bb10 100644 --- a/services/voiceinteraction/java/com/android/server/voiceinteraction/DspTrustedHotwordDetectorSession.java +++ b/services/voiceinteraction/java/com/android/server/voiceinteraction/DspTrustedHotwordDetectorSession.java @@ -34,6 +34,7 @@ import android.os.RemoteException; import android.os.SharedMemory; import android.service.voice.HotwordDetectedResult; import android.service.voice.HotwordDetectionService; +import android.service.voice.HotwordDetectionServiceFailure; import android.service.voice.HotwordDetector; import android.service.voice.HotwordRejectedResult; import android.service.voice.IDspHotwordDetectionCallback; @@ -130,7 +131,9 @@ final class DspTrustedHotwordDetectorSession extends DetectorSession { HotwordDetector.DETECTOR_TYPE_TRUSTED_HOTWORD_DSP, METRICS_KEYPHRASE_TRIGGERED_DETECT_SECURITY_EXCEPTION, mVoiceInteractionServiceUid); - externalCallback.onError(CALLBACK_ONDETECTED_GOT_SECURITY_EXCEPTION); + externalCallback.onDetectionFailure(new HotwordDetectionServiceFailure( + CALLBACK_ONDETECTED_GOT_SECURITY_EXCEPTION, + "Security exception occurs in #onDetected method.")); return; } saveProximityValueToBundle(result); @@ -138,7 +141,9 @@ final class DspTrustedHotwordDetectorSession extends DetectorSession { try { newResult = mHotwordAudioStreamCopier.startCopyingAudioStreams(result); } catch (IOException e) { - externalCallback.onError(CALLBACK_ONDETECTED_STREAM_COPY_ERROR); + externalCallback.onDetectionFailure(new HotwordDetectionServiceFailure( + CALLBACK_ONDETECTED_STREAM_COPY_ERROR, + "Copy audio stream failure.")); return; } externalCallback.onKeyphraseDetected(recognitionEvent, newResult); @@ -201,7 +206,9 @@ final class DspTrustedHotwordDetectorSession extends DetectorSession { HOTWORD_DETECTOR_KEYPHRASE_TRIGGERED__RESULT__DETECT_TIMEOUT, mVoiceInteractionServiceUid); try { - externalCallback.onError(CALLBACK_DETECT_TIMEOUT); + externalCallback.onDetectionFailure( + new HotwordDetectionServiceFailure(CALLBACK_DETECT_TIMEOUT, + "Timeout to response to the detection result.")); } catch (RemoteException e) { Slog.w(TAG, "Failed to report onError status: ", e); HotwordMetricsLogger.writeDetectorEvent( diff --git a/services/voiceinteraction/java/com/android/server/voiceinteraction/HotwordDetectionConnection.java b/services/voiceinteraction/java/com/android/server/voiceinteraction/HotwordDetectionConnection.java index b672b00fa8c3..1ba397529bbd 100644 --- a/services/voiceinteraction/java/com/android/server/voiceinteraction/HotwordDetectionConnection.java +++ b/services/voiceinteraction/java/com/android/server/voiceinteraction/HotwordDetectionConnection.java @@ -690,8 +690,8 @@ final class HotwordDetectionConnection { //TODO(b265535257): report error to either service only. synchronized (HotwordDetectionConnection.this.mLock) { runForEachDetectorSessionLocked((session) -> { - session.reportErrorLocked( - DetectorSession.HOTWORD_DETECTION_SERVICE_DIED); + session.reportErrorLocked(DetectorSession.HOTWORD_DETECTION_SERVICE_DIED, + "Detection service is dead."); }); } // Can improve to log exit reason if needed diff --git a/services/voiceinteraction/java/com/android/server/voiceinteraction/SoftwareTrustedHotwordDetectorSession.java b/services/voiceinteraction/java/com/android/server/voiceinteraction/SoftwareTrustedHotwordDetectorSession.java index 3ad963d21943..522d832c41bc 100644 --- a/services/voiceinteraction/java/com/android/server/voiceinteraction/SoftwareTrustedHotwordDetectorSession.java +++ b/services/voiceinteraction/java/com/android/server/voiceinteraction/SoftwareTrustedHotwordDetectorSession.java @@ -33,6 +33,7 @@ import android.os.RemoteException; import android.os.SharedMemory; import android.service.voice.HotwordDetectedResult; import android.service.voice.HotwordDetectionService; +import android.service.voice.HotwordDetectionServiceFailure; import android.service.voice.HotwordDetector; import android.service.voice.HotwordRejectedResult; import android.service.voice.IDspHotwordDetectionCallback; @@ -121,7 +122,9 @@ final class SoftwareTrustedHotwordDetectorSession extends DetectorSession { HotwordDetector.DETECTOR_TYPE_TRUSTED_HOTWORD_SOFTWARE, METRICS_KEYPHRASE_TRIGGERED_DETECT_SECURITY_EXCEPTION, mVoiceInteractionServiceUid); - mSoftwareCallback.onError(); + mSoftwareCallback.onError(new HotwordDetectionServiceFailure( + CALLBACK_ONDETECTED_GOT_SECURITY_EXCEPTION, + "Security exception occurs in #onDetected method.")); return; } saveProximityValueToBundle(result); @@ -130,7 +133,9 @@ final class SoftwareTrustedHotwordDetectorSession extends DetectorSession { newResult = mHotwordAudioStreamCopier.startCopyingAudioStreams(result); } catch (IOException e) { // TODO: Write event - mSoftwareCallback.onError(); + mSoftwareCallback.onError(new HotwordDetectionServiceFailure( + CALLBACK_ONDETECTED_STREAM_COPY_ERROR, + "Copy audio stream failure.")); return; } mSoftwareCallback.onDetected(newResult, null, null); diff --git a/services/voiceinteraction/java/com/android/server/voiceinteraction/VisualQueryDetectorSession.java b/services/voiceinteraction/java/com/android/server/voiceinteraction/VisualQueryDetectorSession.java index 33150d8789eb..c397812b4158 100644 --- a/services/voiceinteraction/java/com/android/server/voiceinteraction/VisualQueryDetectorSession.java +++ b/services/voiceinteraction/java/com/android/server/voiceinteraction/VisualQueryDetectorSession.java @@ -16,6 +16,9 @@ package com.android.server.voiceinteraction; +import static android.service.voice.VisualQueryDetectionServiceFailure.ERROR_CODE_ILLEGAL_ATTENTION_STATE; +import static android.service.voice.VisualQueryDetectionServiceFailure.ERROR_CODE_ILLEGAL_STREAMING_STATE; + import android.annotation.NonNull; import android.annotation.Nullable; import android.content.Context; @@ -30,6 +33,7 @@ import android.service.voice.IDetectorSessionVisualQueryDetectionCallback; import android.service.voice.IMicrophoneHotwordDetectionVoiceInteractionCallback; import android.service.voice.ISandboxedDetectionService; import android.service.voice.IVisualQueryDetectionVoiceInteractionCallback; +import android.service.voice.VisualQueryDetectionServiceFailure; import android.util.Slog; import com.android.internal.app.IHotwordRecognitionStatusCallback; @@ -102,6 +106,13 @@ final class VisualQueryDetectorSession extends DetectorSession { mAttentionListener.onAttentionGained(); } catch (RemoteException e) { Slog.e(TAG, "Error delivering attention gained event.", e); + try { + callback.onDetectionFailure(new VisualQueryDetectionServiceFailure( + ERROR_CODE_ILLEGAL_ATTENTION_STATE, + "Attention listener failed to switch to GAINED state.")); + } catch (RemoteException ex) { + Slog.v(TAG, "Fail to call onDetectionFailure"); + } return; } } @@ -117,6 +128,13 @@ final class VisualQueryDetectorSession extends DetectorSession { mAttentionListener.onAttentionLost(); } catch (RemoteException e) { Slog.e(TAG, "Error delivering attention lost event.", e); + try { + callback.onDetectionFailure(new VisualQueryDetectionServiceFailure( + ERROR_CODE_ILLEGAL_ATTENTION_STATE, + "Attention listener failed to switch to LOST state.")); + } catch (RemoteException ex) { + Slog.v(TAG, "Fail to call onDetectionFailure"); + } return; } } @@ -127,6 +145,9 @@ final class VisualQueryDetectorSession extends DetectorSession { Slog.v(TAG, "BinderCallback#onQueryDetected"); if (!mEgressingData) { Slog.v(TAG, "Query should not be egressed within the unattention state."); + callback.onDetectionFailure(new VisualQueryDetectionServiceFailure( + ERROR_CODE_ILLEGAL_STREAMING_STATE, + "Cannot stream queries without attention signals.")); return; } mQueryStreaming = true; @@ -140,6 +161,9 @@ final class VisualQueryDetectorSession extends DetectorSession { if (!mQueryStreaming) { Slog.v(TAG, "Query streaming state signal FINISHED is block since there is" + " no active query being streamed."); + callback.onDetectionFailure(new VisualQueryDetectionServiceFailure( + ERROR_CODE_ILLEGAL_STREAMING_STATE, + "Cannot send FINISHED signal with no query streamed.")); return; } callback.onQueryFinished(); @@ -152,6 +176,9 @@ final class VisualQueryDetectorSession extends DetectorSession { if (!mQueryStreaming) { Slog.v(TAG, "Query streaming state signal REJECTED is block since there is" + " no active query being streamed."); + callback.onDetectionFailure(new VisualQueryDetectionServiceFailure( + ERROR_CODE_ILLEGAL_STREAMING_STATE, + "Cannot send REJECTED signal with no query streamed.")); return; } callback.onQueryRejected(); diff --git a/services/voiceinteraction/java/com/android/server/voiceinteraction/VoiceInteractionManagerService.java b/services/voiceinteraction/java/com/android/server/voiceinteraction/VoiceInteractionManagerService.java index d4374a9c2654..fd542939373b 100644 --- a/services/voiceinteraction/java/com/android/server/voiceinteraction/VoiceInteractionManagerService.java +++ b/services/voiceinteraction/java/com/android/server/voiceinteraction/VoiceInteractionManagerService.java @@ -1049,7 +1049,8 @@ public class VoiceInteractionManagerService extends SystemService { @Override public int startAssistantActivity(@NonNull IBinder token, @NonNull Intent intent, - @Nullable String resolvedType, @Nullable String attributionTag) { + @Nullable String resolvedType, @NonNull String attributionTag, + @NonNull Bundle bundle) { synchronized (this) { if (mImpl == null) { Slog.w(TAG, "startAssistantActivity without running voice interaction service"); @@ -1060,7 +1061,7 @@ public class VoiceInteractionManagerService extends SystemService { final long caller = Binder.clearCallingIdentity(); try { return mImpl.startAssistantActivityLocked(attributionTag, callingPid, - callingUid, token, intent, resolvedType); + callingUid, token, intent, resolvedType, bundle); } finally { Binder.restoreCallingIdentity(caller); } diff --git a/services/voiceinteraction/java/com/android/server/voiceinteraction/VoiceInteractionManagerServiceImpl.java b/services/voiceinteraction/java/com/android/server/voiceinteraction/VoiceInteractionManagerServiceImpl.java index ad0e9217c50b..96b69f8c4130 100644 --- a/services/voiceinteraction/java/com/android/server/voiceinteraction/VoiceInteractionManagerServiceImpl.java +++ b/services/voiceinteraction/java/com/android/server/voiceinteraction/VoiceInteractionManagerServiceImpl.java @@ -29,7 +29,6 @@ import android.Manifest; import android.annotation.NonNull; import android.annotation.Nullable; import android.app.ActivityManager; -import android.app.ActivityOptions; import android.app.ActivityTaskManager; import android.app.AppGlobals; import android.app.ApplicationExitInfo; @@ -376,7 +375,8 @@ class VoiceInteractionManagerServiceImpl implements VoiceInteractionSessionConne @GuardedBy("this") public int startAssistantActivityLocked(@Nullable String callingFeatureId, int callingPid, - int callingUid, IBinder token, Intent intent, String resolvedType) { + int callingUid, IBinder token, Intent intent, String resolvedType, + @NonNull Bundle bundle) { try { if (mActiveSession == null || token != mActiveSession.mToken) { Slog.w(TAG, "startAssistantActivity does not match active session"); @@ -388,10 +388,10 @@ class VoiceInteractionManagerServiceImpl implements VoiceInteractionSessionConne } intent = new Intent(intent); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); - final ActivityOptions options = ActivityOptions.makeBasic(); - options.setLaunchActivityType(ACTIVITY_TYPE_ASSISTANT); + // TODO: make the key public hidden + bundle.putInt("android.activity.activityType", ACTIVITY_TYPE_ASSISTANT); return mAtm.startAssistantActivity(mComponent.getPackageName(), callingFeatureId, - callingPid, callingUid, intent, resolvedType, options.toBundle(), mUser); + callingPid, callingUid, intent, resolvedType, bundle, mUser); } catch (RemoteException e) { throw new IllegalStateException("Unexpected remote error", e); } diff --git a/telephony/java/android/telephony/satellite/ISatelliteDatagramCallback.aidl b/telephony/java/android/telephony/satellite/ISatelliteDatagramCallback.aidl index d6f8012201ab..abf2b55de76a 100644 --- a/telephony/java/android/telephony/satellite/ISatelliteDatagramCallback.aidl +++ b/telephony/java/android/telephony/satellite/ISatelliteDatagramCallback.aidl @@ -16,6 +16,7 @@ package android.telephony.satellite; +import android.telephony.satellite.ISatelliteDatagramReceiverAck; import android.telephony.satellite.SatelliteDatagram; /** @@ -24,8 +25,15 @@ import android.telephony.satellite.SatelliteDatagram; */ oneway interface ISatelliteDatagramCallback { /** - * Called when there are incoming datagrams to be received. - * @param datagrams Array of datagrams to be received over satellite. + * Called when datagrams are received from satellite. + * + * @param datagramId An id that uniquely identifies incoming datagram. + * @param datagram datagram received from satellite. + * @param pendingCount Number of datagrams yet to be received from satellite. + * @param callback This callback will be used by datagram receiver app to send ack back to + * Telephony. If the callback is not received within five minutes, + * Telephony will resend the datagrams. */ - void onSatelliteDatagrams(in SatelliteDatagram[] datagrams); + void onSatelliteDatagramReceived(long datagramId, in SatelliteDatagram datagram, + int pendingCount, ISatelliteDatagramReceiverAck callback); } diff --git a/telephony/java/android/telephony/satellite/ISatelliteDatagramReceiverAck.aidl b/telephony/java/android/telephony/satellite/ISatelliteDatagramReceiverAck.aidl new file mode 100644 index 000000000000..eeb0ac56d6bf --- /dev/null +++ b/telephony/java/android/telephony/satellite/ISatelliteDatagramReceiverAck.aidl @@ -0,0 +1,41 @@ +/* + * Copyright 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.telephony.satellite; + +import android.telephony.satellite.PointingInfo; +import android.telephony.satellite.SatelliteDatagram; + +/** + * Interface for satellite datagram receiver acknowledgement. + * @hide + */ +oneway interface ISatelliteDatagramReceiverAck { + /** + * This callback will be used by datagram receiver app to send ack back to + * Telephony. If the callback is not received within five minutes, + * then Telephony will resend the datagram again. + * + * @param datagramId An id that uniquely identifies datagram + * received by satellite datagram receiver app. + * This should match with datagramId passed in + * {@link SatelliteDatagramCallback#onSatelliteDatagramReceived( + * long, SatelliteDatagram, int, ISatelliteDatagramReceiverAck)}. + * Upon receiving the ack, Telephony will remove the datagram from + * the persistent memory. + */ + void acknowledgeSatelliteDatagramReceived(in long datagramId); +} diff --git a/telephony/java/android/telephony/satellite/SatelliteDatagramCallback.java b/telephony/java/android/telephony/satellite/SatelliteDatagramCallback.java index 484b783e35e8..2c3884c81bfc 100644 --- a/telephony/java/android/telephony/satellite/SatelliteDatagramCallback.java +++ b/telephony/java/android/telephony/satellite/SatelliteDatagramCallback.java @@ -38,10 +38,12 @@ public class SatelliteDatagramCallback { } @Override - public void onSatelliteDatagrams(SatelliteDatagram[] datagrams) { + public void onSatelliteDatagramReceived(long datagramId, SatelliteDatagram datagram, + int pendingCount, ISatelliteDatagramReceiverAck callback) { final long callingIdentity = Binder.clearCallingIdentity(); try { - mExecutor.execute(() -> mLocalCallback.onSatelliteDatagrams(datagrams)); + mExecutor.execute(() -> mLocalCallback.onSatelliteDatagramReceived(datagramId, + datagram, pendingCount, callback)); } finally { restoreCallingIdentity(callingIdentity); } @@ -54,9 +56,14 @@ public class SatelliteDatagramCallback { /** * Called when there are incoming datagrams to be received. - * @param datagrams Datagrams to be received over satellite. + * @param datagramId An id that uniquely identifies incoming datagram. + * @param datagram datagram to be received over satellite. + * @param pendingCount Number of datagrams yet to be received by the app. + * @param callback This callback will be used by datagram receiver app to send ack back to + * Telephony. */ - public void onSatelliteDatagrams(SatelliteDatagram[] datagrams) { + public void onSatelliteDatagramReceived(long datagramId, SatelliteDatagram datagram, + int pendingCount, ISatelliteDatagramReceiverAck callback) { // Base Implementation } diff --git a/telephony/java/android/telephony/satellite/SatelliteManager.java b/telephony/java/android/telephony/satellite/SatelliteManager.java index 8fbf64070534..dbc0ed9c5a24 100644 --- a/telephony/java/android/telephony/satellite/SatelliteManager.java +++ b/telephony/java/android/telephony/satellite/SatelliteManager.java @@ -130,7 +130,7 @@ public class SatelliteManager { /** * Bundle key to get the response from - * {@link #requestMaxCharactersPerSatelliteTextMessage(Executor, OutcomeReceiver)}. + * {@link #requestMaxSizePerSendingDatagram(Executor, OutcomeReceiver)} . * @hide */ public static final String KEY_MAX_CHARACTERS_PER_SATELLITE_TEXT = @@ -159,6 +159,13 @@ public class SatelliteManager { public static final String KEY_SATELLITE_NEXT_VISIBILITY = "satellite_next_visibility"; /** + * Bundle key to get the respoonse from + * {@link #sendSatelliteDatagram(long, int, SatelliteDatagram, Executor, OutcomeReceiver)}. + * @hide + */ + public static final String KEY_SEND_SATELLITE_DATAGRAM = "send_satellite_datagram"; + + /** * The request was successfully processed. */ public static final int SATELLITE_ERROR_NONE = 0; @@ -541,8 +548,8 @@ public class SatelliteManager { @Retention(RetentionPolicy.SOURCE) public @interface SatelliteModemState {} - /** Datagram type indicating that the datagram to be sent or received is of type SOS SMS. */ - public static final int DATAGRAM_TYPE_SOS_SMS = 0; + /** Datagram type indicating that the datagram to be sent or received is of type SOS message. */ + public static final int DATAGRAM_TYPE_SOS_MESSAGE = 0; /** Datagram type indicating that the datagram to be sent or received is of type * location sharing. */ @@ -551,7 +558,7 @@ public class SatelliteManager { @IntDef( prefix = "DATAGRAM_TYPE_", value = { - DATAGRAM_TYPE_SOS_SMS, + DATAGRAM_TYPE_SOS_MESSAGE, DATAGRAM_TYPE_LOCATION_SHARING, }) @Retention(RetentionPolicy.SOURCE) @@ -651,19 +658,20 @@ public class SatelliteManager { } /** - * Request to get the maximum number of characters per text message on satellite. + * Request to get the maximum number of bytes per datagram that can be sent to satellite. * * @param executor The executor on which the callback will be called. * @param callback The callback object to which the result will be delivered. * If the request is successful, {@link OutcomeReceiver#onResult(Object)} - * will return the maximum number of characters per text message on satellite. + * will return the maximum number of bytes per datagram that can be sent to + * satellite. * If the request is not successful, {@link OutcomeReceiver#onError(Throwable)} * * @throws SecurityException if the caller doesn't have required permission. * @throws IllegalStateException if the Telephony process is not currently available. */ @RequiresPermission(Manifest.permission.SATELLITE_COMMUNICATION) - public void requestMaxCharactersPerSatelliteTextMessage( + public void requestMaxSizePerSendingDatagram( @NonNull @CallbackExecutor Executor executor, @NonNull OutcomeReceiver<Integer, SatelliteException> callback) { Objects.requireNonNull(executor); @@ -693,7 +701,7 @@ public class SatelliteManager { } } }; - telephony.requestMaxCharactersPerSatelliteTextMessage(mSubId, receiver); + telephony.requestMaxSizePerSendingDatagram(mSubId, receiver); } else { throw new IllegalStateException("telephony service is null."); } @@ -1039,7 +1047,8 @@ public class SatelliteManager { * * This method requests modem to check if there are any pending datagrams to be received over * satellite. If there are any incoming datagrams, they will be received via - * {@link SatelliteDatagramCallback#onSatelliteDatagrams(SatelliteDatagram[])})}. + * {@link SatelliteDatagramCallback#onSatelliteDatagramReceived(long, SatelliteDatagram, int, + * ISatelliteDatagramReceiverAck)} * * @param executor The executor on which the result listener will be called. * @param resultListener Listener for the {@link SatelliteError} result of the operation. @@ -1076,39 +1085,60 @@ public class SatelliteManager { /** * Send datagram over satellite. * - * Gateway encodes SOS SMS or location sharing message into a datagram and passes it as input to - * this method. Datagram received here will be passed down to modem without any encoding or - * encryption. + * Gateway encodes SOS message or location sharing message into a datagram and passes it as + * input to this method. Datagram received here will be passed down to modem without any + * encoding or encryption. * + * @param datagramId An id that uniquely identifies datagram requested to be sent. * @param datagramType datagram type indicating whether the datagram is of type * SOS_SMS or LOCATION_SHARING. * @param datagram encoded gateway datagram which is encrypted by the caller. * Datagram will be passed down to modem without any encoding or encryption. * @param executor The executor on which the result listener will be called. - * @param resultListener Listener for the {@link SatelliteError} result of the operation. + * @param callback The callback object to which the result will be returned. + * If datagram is sent successfully, then + * {@link OutcomeReceiver#onResult(Object)} will return datagramId. + * If the request is not successful, {@link OutcomeReceiver#onError(Throwable)} + * will return a {@link SatelliteException} with the {@link SatelliteError}. * * @throws SecurityException if the caller doesn't have required permission. * @throws IllegalStateException if the Telephony process is not currently available. */ @RequiresPermission(Manifest.permission.SATELLITE_COMMUNICATION) - public void sendSatelliteDatagram(@DatagramType int datagramType, + public void sendSatelliteDatagram(long datagramId, @DatagramType int datagramType, @NonNull SatelliteDatagram datagram, @NonNull @CallbackExecutor Executor executor, - @SatelliteError @NonNull Consumer<Integer> resultListener) { + @NonNull OutcomeReceiver<Long, SatelliteException> callback) { Objects.requireNonNull(datagram); Objects.requireNonNull(executor); - Objects.requireNonNull(resultListener); + Objects.requireNonNull(callback); try { ITelephony telephony = getITelephony(); if (telephony != null) { - IIntegerConsumer internalCallback = new IIntegerConsumer.Stub() { + ResultReceiver receiver = new ResultReceiver(null) { @Override - public void accept(int result) { - executor.execute(() -> Binder.withCleanCallingIdentity( - () -> resultListener.accept(result))); + protected void onReceiveResult(int resultCode, Bundle resultData) { + if (resultCode == SATELLITE_ERROR_NONE) { + if (resultData.containsKey(KEY_SEND_SATELLITE_DATAGRAM)) { + long resultDatagramId = resultData + .getLong(KEY_SEND_SATELLITE_DATAGRAM); + executor.execute(() -> Binder.withCleanCallingIdentity(() -> + callback.onResult(resultDatagramId))); + } else { + loge("KEY_SEND_SATELLITE_DATAGRAM does not exist."); + executor.execute(() -> Binder.withCleanCallingIdentity(() -> + callback.onError( + new SatelliteException(SATELLITE_REQUEST_FAILED)))); + } + + } else { + executor.execute(() -> Binder.withCleanCallingIdentity(() -> + callback.onError(new SatelliteException(resultCode)))); + } } }; - telephony.sendSatelliteDatagram(mSubId, datagramType, datagram, internalCallback); + telephony.sendSatelliteDatagram(mSubId, datagramId, datagramType, datagram, + receiver); } else { throw new IllegalStateException("telephony service is null."); } diff --git a/telephony/java/com/android/internal/telephony/ITelephony.aidl b/telephony/java/com/android/internal/telephony/ITelephony.aidl index 62e087f3ca34..5bf55ef72bd0 100644 --- a/telephony/java/com/android/internal/telephony/ITelephony.aidl +++ b/telephony/java/com/android/internal/telephony/ITelephony.aidl @@ -2772,15 +2772,15 @@ interface ITelephony { in ISatellitePositionUpdateCallback callback); /** - * Request to get the maximum number of characters per text message on satellite. + * Request to get the maximum number of bytes per datagram that can be sent to satellite. * * @param subId The subId of the subscription to get the maximum number of characters for. * @param receiver Result receiver to get the error code of the request and the requested - * maximum number of characters per text message on satellite. + * maximum number of bytes per datagram that can be sent to satellite. */ @JavaPassthrough(annotation="@android.annotation.RequiresPermission(" + "android.Manifest.permission.SATELLITE_COMMUNICATION)") - void requestMaxCharactersPerSatelliteTextMessage(int subId, in ResultReceiver receiver); + void requestMaxSizePerSendingDatagram(int subId, in ResultReceiver receiver); /** * Register the subscription with a satellite provider. @@ -2912,14 +2912,16 @@ interface ITelephony { * Send datagram over satellite. * * @param subId The subId of the subscription to send satellite datagrams for. + * @param datagramId An id that uniquely identifies datagram requested to be sent. * @param datagramType Type of datagram. * @param datagram Datagram to send over satellite. - * @param callback The callback to get the error code of the request. + * @param receiver Result receiver to get the datagramId if datagram is sent successfully else + * error code of the request. */ @JavaPassthrough(annotation="@android.annotation.RequiresPermission(" + "android.Manifest.permission.SATELLITE_COMMUNICATION)") - void sendSatelliteDatagram(int subId, int datagramType, in SatelliteDatagram datagram, - IIntegerConsumer callback); + void sendSatelliteDatagram(int subId, long datagramId, int datagramType, + in SatelliteDatagram datagram, in ResultReceiver receiver); /** * Request to get whether satellite communication is allowed for the current location. diff --git a/telephony/java/com/android/internal/telephony/PhoneConstants.java b/telephony/java/com/android/internal/telephony/PhoneConstants.java index a9ebd5c2d7cd..07f2916838e8 100644 --- a/telephony/java/com/android/internal/telephony/PhoneConstants.java +++ b/telephony/java/com/android/internal/telephony/PhoneConstants.java @@ -250,6 +250,9 @@ public class PhoneConstants { */ public static final int DOMAIN_NON_3GPP_PS = 4; + /** Key to enable comparison of domain selection results from legacy and new code. */ + public static final String EXTRA_COMPARE_DOMAIN = "compare_domain"; + /** The key to specify the emergency service category */ public static final String EXTRA_EMERGENCY_SERVICE_CATEGORY = "emergency_service_category"; } diff --git a/test-mock/src/android/test/mock/MockContentProvider.java b/test-mock/src/android/test/mock/MockContentProvider.java index 7be42f4f36f5..7f084f896e3f 100644 --- a/test-mock/src/android/test/mock/MockContentProvider.java +++ b/test-mock/src/android/test/mock/MockContentProvider.java @@ -80,16 +80,22 @@ public class MockContentProvider extends ContentProvider { } @Override - public String getType(Uri url) throws RemoteException { + public String getType(@NonNull AttributionSource attributionSource, + Uri url) throws RemoteException { return MockContentProvider.this.getType(url); } @Override - public void getTypeAsync(Uri uri, RemoteCallback callback) throws RemoteException { + public void getTypeAsync(@NonNull AttributionSource attributionSource, + Uri uri, RemoteCallback callback) throws RemoteException { MockContentProvider.this.getTypeAsync(uri, callback); } @Override + public void getTypeAnonymousAsync(Uri uri, RemoteCallback callback) throws RemoteException { + MockContentProvider.this.getTypeAnonymousAsync(uri, callback); + } + @Override public Uri insert(@NonNull AttributionSource attributionSource, Uri url, ContentValues initialValues, Bundle extras) throws RemoteException { return MockContentProvider.this.insert(url, initialValues, extras); @@ -247,6 +253,23 @@ public class MockContentProvider extends ContentProvider { } @Override + public String getTypeAnonymous(Uri uri) { + throw new UnsupportedOperationException("unimplemented mock method"); + } + + /** + * @hide + */ + @SuppressWarnings("deprecation") + public void getTypeAnonymousAsync(Uri uri, RemoteCallback remoteCallback) { + AsyncTask.SERIAL_EXECUTOR.execute(() -> { + final Bundle bundle = new Bundle(); + bundle.putString(ContentResolver.REMOTE_CALLBACK_RESULT, getTypeAnonymous(uri)); + remoteCallback.sendResult(bundle); + }); + } + + @Override public Uri insert(Uri uri, ContentValues values) { throw new UnsupportedOperationException("unimplemented mock method"); } diff --git a/test-mock/src/android/test/mock/MockIContentProvider.java b/test-mock/src/android/test/mock/MockIContentProvider.java index b81c70704d79..bb2996a2cb40 100644 --- a/test-mock/src/android/test/mock/MockIContentProvider.java +++ b/test-mock/src/android/test/mock/MockIContentProvider.java @@ -61,16 +61,30 @@ public class MockIContentProvider implements IContentProvider { } @Override - public String getType(Uri url) { + public String getType(@NonNull AttributionSource attributionSource, Uri url) { throw new UnsupportedOperationException("unimplemented mock method"); } @Override @SuppressWarnings("deprecation") - public void getTypeAsync(Uri uri, RemoteCallback remoteCallback) { + public void getTypeAsync(@NonNull AttributionSource attributionSource, + Uri uri, RemoteCallback remoteCallback) { AsyncTask.SERIAL_EXECUTOR.execute(() -> { final Bundle bundle = new Bundle(); - bundle.putString(ContentResolver.REMOTE_CALLBACK_RESULT, getType(uri)); + bundle.putString(ContentResolver.REMOTE_CALLBACK_RESULT, getType(attributionSource, + uri)); + remoteCallback.sendResult(bundle); + }); + } + public String getTypeAnonymous(Uri url) { + throw new UnsupportedOperationException("unimplemented mock method"); + } + @Override + @SuppressWarnings("deprecation") + public void getTypeAnonymousAsync(Uri uri, RemoteCallback remoteCallback) { + AsyncTask.SERIAL_EXECUTOR.execute(() -> { + final Bundle bundle = new Bundle(); + bundle.putString(ContentResolver.REMOTE_CALLBACK_RESULT, getTypeAnonymous(uri)); remoteCallback.sendResult(bundle); }); } diff --git a/tools/processors/immutability/TEST_MAPPING b/tools/processors/immutability/TEST_MAPPING deleted file mode 100644 index 4e8e2386ad8d..000000000000 --- a/tools/processors/immutability/TEST_MAPPING +++ /dev/null @@ -1,7 +0,0 @@ -{ - "presubmit": [ - { - "name": "ImmutabilityAnnotationProcessorUnitTests" - } - ] -} diff --git a/wifi/java/src/android/net/wifi/sharedconnectivity/service/SharedConnectivityService.java b/wifi/java/src/android/net/wifi/sharedconnectivity/service/SharedConnectivityService.java index 13084f47efe6..f3af06247576 100644 --- a/wifi/java/src/android/net/wifi/sharedconnectivity/service/SharedConnectivityService.java +++ b/wifi/java/src/android/net/wifi/sharedconnectivity/service/SharedConnectivityService.java @@ -59,7 +59,7 @@ public abstract class SharedConnectivityService extends Service { private static final String TAG = SharedConnectivityService.class.getSimpleName(); private static final boolean DEBUG = true; - private final Handler mHandler; + private Handler mHandler; private final List<ISharedConnectivityCallback> mCallbacks = new ArrayList<>(); // Used to find DeathRecipient when unregistering a callback to call unlinkToDeath. private final Map<ISharedConnectivityCallback, DeathRecipient> mDeathRecipientMap = @@ -71,14 +71,6 @@ public abstract class SharedConnectivityService extends Service { private TetherNetworkConnectionStatus mTetherNetworkConnectionStatus; private KnownNetworkConnectionStatus mKnownNetworkConnectionStatus; - public SharedConnectivityService() { - mHandler = new Handler(getMainLooper()); - } - - public SharedConnectivityService(@NonNull Handler handler) { - mHandler = handler; - } - private final class DeathRecipient implements IBinder.DeathRecipient { ISharedConnectivityCallback mCallback; @@ -97,6 +89,7 @@ public abstract class SharedConnectivityService extends Service { @Nullable public final IBinder onBind(@NonNull Intent intent) { if (DEBUG) Log.i(TAG, "onBind intent=" + intent); + mHandler = new Handler(getMainLooper()); return new ISharedConnectivityService.Stub() { @Override public void registerCallback(ISharedConnectivityCallback callback) { diff --git a/wifi/tests/src/android/net/wifi/sharedconnectivity/service/SharedConnectivityServiceTest.java b/wifi/tests/src/android/net/wifi/sharedconnectivity/service/SharedConnectivityServiceTest.java index fb8d7bf95ea0..d7f7fea4df3e 100644 --- a/wifi/tests/src/android/net/wifi/sharedconnectivity/service/SharedConnectivityServiceTest.java +++ b/wifi/tests/src/android/net/wifi/sharedconnectivity/service/SharedConnectivityServiceTest.java @@ -17,16 +17,21 @@ package android.net.wifi.sharedconnectivity.service; import static org.junit.Assert.assertNotNull; +import static org.mockito.Mockito.when; +import android.content.Context; import android.content.Intent; import android.net.wifi.sharedconnectivity.app.KnownNetwork; import android.net.wifi.sharedconnectivity.app.TetherNetwork; -import android.os.Handler; -import android.os.test.TestLooper; +import android.os.Looper; +import androidx.annotation.NonNull; import androidx.test.filters.SmallTest; +import org.junit.Before; import org.junit.Test; +import org.mockito.Mock; +import org.mockito.MockitoAnnotations; /** * Unit tests for {@link android.net.wifi.sharedconnectivity.service.SharedConnectivityService}. @@ -34,6 +39,33 @@ import org.junit.Test; @SmallTest public class SharedConnectivityServiceTest { + @Mock + Context mContext; + + static class FakeSharedConnectivityService extends SharedConnectivityService { + public void attachBaseContext(Context context) { + super.attachBaseContext(context); + } + + @Override + public void onConnectTetherNetwork(@NonNull TetherNetwork network) {} + + @Override + public void onDisconnectTetherNetwork(@NonNull TetherNetwork network) {} + + @Override + public void onConnectKnownNetwork(@NonNull KnownNetwork network) {} + + @Override + public void onForgetKnownNetwork(@NonNull KnownNetwork network) {} + } + + @Before + public void setUp() { + MockitoAnnotations.initMocks(this); + when(mContext.getMainLooper()).thenReturn(Looper.getMainLooper()); + } + /** * Verifies service returns */ @@ -51,18 +83,8 @@ public class SharedConnectivityServiceTest { } private SharedConnectivityService createService() { - return new SharedConnectivityService(new Handler(new TestLooper().getLooper())) { - @Override - public void onConnectTetherNetwork(TetherNetwork network) {} - - @Override - public void onDisconnectTetherNetwork(TetherNetwork network) {} - - @Override - public void onConnectKnownNetwork(KnownNetwork network) {} - - @Override - public void onForgetKnownNetwork(KnownNetwork network) {} - }; + FakeSharedConnectivityService service = new FakeSharedConnectivityService(); + service.attachBaseContext(mContext); + return service; } } |