diff options
163 files changed, 1126 insertions, 683 deletions
diff --git a/api/current.txt b/api/current.txt index 2156867ceb43..21c29999faa6 100644 --- a/api/current.txt +++ b/api/current.txt @@ -16797,6 +16797,7 @@ package android.hardware.camera2 { public abstract static class CameraManager.AvailabilityCallback { ctor public CameraManager.AvailabilityCallback(); + method public void onCameraAccessPrioritiesChanged(); method public void onCameraAvailable(@NonNull String); method public void onCameraUnavailable(@NonNull String); } @@ -23696,12 +23697,12 @@ package android.media { } public class CallbackDataSourceDesc extends android.media.DataSourceDesc { - method public android.media.DataSourceCallback getDataSourceCallback(); + method @NonNull public android.media.DataSourceCallback getDataSourceCallback(); } public static class CallbackDataSourceDesc.Builder extends android.media.DataSourceDesc.BuilderBase<android.media.CallbackDataSourceDesc.Builder> { ctor public CallbackDataSourceDesc.Builder(); - ctor public CallbackDataSourceDesc.Builder(android.media.CallbackDataSourceDesc); + ctor public CallbackDataSourceDesc.Builder(@Nullable android.media.CallbackDataSourceDesc); method @NonNull public android.media.CallbackDataSourceDesc build(); method @NonNull public android.media.CallbackDataSourceDesc.Builder setDataSource(@NonNull android.media.DataSourceCallback); } @@ -23761,12 +23762,12 @@ package android.media { public abstract class DataSourceCallback implements java.io.Closeable { ctor public DataSourceCallback(); method public abstract long getSize() throws java.io.IOException; - method public abstract int readAt(long, byte[], int, int) throws java.io.IOException; + method public abstract int readAt(long, @NonNull byte[], int, int) throws java.io.IOException; } public class DataSourceDesc { method public long getEndPosition(); - method public String getMediaId(); + method @Nullable public String getMediaId(); method public long getStartPosition(); field public static final long LONG_MAX_TIME_MS = 576460752303423L; // 0x20c49ba5e353fL field public static final long POSITION_UNKNOWN = 576460752303423L; // 0x20c49ba5e353fL @@ -23774,7 +23775,7 @@ package android.media { protected static class DataSourceDesc.BuilderBase<T extends android.media.DataSourceDesc.BuilderBase> { method @NonNull public T setEndPosition(long); - method @NonNull public T setMediaId(String); + method @NonNull public T setMediaId(@Nullable String); method @NonNull public T setStartPosition(long); } @@ -23983,13 +23984,13 @@ package android.media { public class FileDataSourceDesc extends android.media.DataSourceDesc { method public long getLength(); method public long getOffset(); - method public android.os.ParcelFileDescriptor getParcelFileDescriptor(); + method @NonNull public android.os.ParcelFileDescriptor getParcelFileDescriptor(); field public static final long FD_LENGTH_UNKNOWN = 576460752303423487L; // 0x7ffffffffffffffL } public static class FileDataSourceDesc.Builder extends android.media.DataSourceDesc.BuilderBase<android.media.FileDataSourceDesc.Builder> { ctor public FileDataSourceDesc.Builder(); - ctor public FileDataSourceDesc.Builder(android.media.FileDataSourceDesc); + ctor public FileDataSourceDesc.Builder(@Nullable android.media.FileDataSourceDesc); method @NonNull public android.media.FileDataSourceDesc build(); method @NonNull public android.media.FileDataSourceDesc.Builder setDataSource(@NonNull android.os.ParcelFileDescriptor); method @NonNull public android.media.FileDataSourceDesc.Builder setDataSource(@NonNull android.os.ParcelFileDescriptor, long, long); @@ -25541,16 +25542,16 @@ package android.media { } public class MediaPlayer2 implements android.media.AudioRouting java.lang.AutoCloseable { - ctor public MediaPlayer2(android.content.Context); - method public void addOnRoutingChangedListener(android.media.AudioRouting.OnRoutingChangedListener, android.os.Handler); - method public Object attachAuxEffect(int); + ctor public MediaPlayer2(@NonNull android.content.Context); + method public void addOnRoutingChangedListener(@NonNull android.media.AudioRouting.OnRoutingChangedListener, @Nullable android.os.Handler); + method @NonNull public Object attachAuxEffect(int); method public boolean cancelCommand(@NonNull Object); method public void clearDrmEventCallback(); - method public Object clearNextDataSources(); + method @NonNull public Object clearNextDataSources(); method public void clearPendingCommands(); method public void close(); - method public Object deselectTrack(int); - method public Object deselectTrack(@NonNull android.media.DataSourceDesc, int); + method @NonNull public Object deselectTrack(int); + method @NonNull public Object deselectTrack(@NonNull android.media.DataSourceDesc, int); method @NonNull public android.media.AudioAttributes getAudioAttributes(); method public int getAudioSessionId(); method public long getBufferedPosition(); @@ -25560,11 +25561,11 @@ package android.media { method public long getDuration(); method public long getDuration(@NonNull android.media.DataSourceDesc); method public float getMaxPlayerVolume(); - method public android.os.PersistableBundle getMetrics(); + method @Nullable public android.os.PersistableBundle getMetrics(); method @NonNull public android.media.PlaybackParams getPlaybackParams(); method public float getPlayerVolume(); - method public android.media.AudioDeviceInfo getPreferredDevice(); - method public android.media.AudioDeviceInfo getRoutedDevice(); + method @Nullable public android.media.AudioDeviceInfo getPreferredDevice(); + method @Nullable public android.media.AudioDeviceInfo getRoutedDevice(); method public int getSelectedTrack(int); method public int getSelectedTrack(@NonNull android.media.DataSourceDesc, int); method public int getState(); @@ -25572,37 +25573,37 @@ package android.media { method @Nullable public android.media.MediaTimestamp getTimestamp(); method @NonNull public java.util.List<android.media.MediaPlayer2.TrackInfo> getTrackInfo(); method @NonNull public java.util.List<android.media.MediaPlayer2.TrackInfo> getTrackInfo(@NonNull android.media.DataSourceDesc); - method public android.util.Size getVideoSize(); + method @NonNull public android.util.Size getVideoSize(); method public boolean isLooping(); - method public Object loopCurrent(boolean); - method public Object notifyWhenCommandLabelReached(@NonNull Object); - method public Object pause(); - method public Object play(); - method public Object prepare(); + method @NonNull public Object loopCurrent(boolean); + method @NonNull public Object notifyWhenCommandLabelReached(@NonNull Object); + method @NonNull public Object pause(); + method @NonNull public Object play(); + method @NonNull public Object prepare(); method public void registerEventCallback(@NonNull java.util.concurrent.Executor, @NonNull android.media.MediaPlayer2.EventCallback); - method public void removeOnRoutingChangedListener(android.media.AudioRouting.OnRoutingChangedListener); + method public void removeOnRoutingChangedListener(@NonNull android.media.AudioRouting.OnRoutingChangedListener); method public void reset(); - method public Object seekTo(long); - method public Object seekTo(long, int); - method public Object selectTrack(int); - method public Object selectTrack(@NonNull android.media.DataSourceDesc, int); - method public Object setAudioAttributes(@NonNull android.media.AudioAttributes); - method public Object setAudioSessionId(int); - method public Object setAuxEffectSendLevel(float); - method public Object setDataSource(@NonNull android.media.DataSourceDesc); - method public Object setDisplay(android.view.SurfaceHolder); + method @NonNull public Object seekTo(long); + method @NonNull public Object seekTo(long, int); + method @NonNull public Object selectTrack(int); + method @NonNull public Object selectTrack(@NonNull android.media.DataSourceDesc, int); + method @NonNull public Object setAudioAttributes(@NonNull android.media.AudioAttributes); + method @NonNull public Object setAudioSessionId(int); + method @NonNull public Object setAuxEffectSendLevel(float); + method @NonNull public Object setDataSource(@NonNull android.media.DataSourceDesc); + method @NonNull public Object setDisplay(@Nullable android.view.SurfaceHolder); method public void setDrmEventCallback(@NonNull java.util.concurrent.Executor, @NonNull android.media.MediaPlayer2.DrmEventCallback); - method public Object setNextDataSource(@NonNull android.media.DataSourceDesc); - method public Object setNextDataSources(@NonNull java.util.List<android.media.DataSourceDesc>); - method public Object setPlaybackParams(@NonNull android.media.PlaybackParams); - method public Object setPlayerVolume(float); - method public boolean setPreferredDevice(android.media.AudioDeviceInfo); - method public Object setScreenOnWhilePlaying(boolean); - method public Object setSurface(android.view.Surface); - method public Object setSyncParams(@NonNull android.media.SyncParams); - method public Object setWakeLock(@NonNull android.os.PowerManager.WakeLock); - method public Object skipToNext(); - method public void unregisterEventCallback(android.media.MediaPlayer2.EventCallback); + method @NonNull public Object setNextDataSource(@NonNull android.media.DataSourceDesc); + method @NonNull public Object setNextDataSources(@NonNull java.util.List<android.media.DataSourceDesc>); + method @NonNull public Object setPlaybackParams(@NonNull android.media.PlaybackParams); + method @NonNull public Object setPlayerVolume(float); + method public boolean setPreferredDevice(@Nullable android.media.AudioDeviceInfo); + method @NonNull public Object setScreenOnWhilePlaying(boolean); + method @NonNull public Object setSurface(@Nullable android.view.Surface); + method @NonNull public Object setSyncParams(@NonNull android.media.SyncParams); + method @NonNull public Object setWakeLock(@NonNull android.os.PowerManager.WakeLock); + method @NonNull public Object skipToNext(); + method public void unregisterEventCallback(@NonNull android.media.MediaPlayer2.EventCallback); field public static final int CALL_COMPLETED_ATTACH_AUX_EFFECT = 1; // 0x1 field public static final int CALL_COMPLETED_CLEAR_NEXT_DATA_SOURCES = 30; // 0x1e field public static final int CALL_COMPLETED_DESELECT_TRACK = 2; // 0x2 @@ -25737,8 +25738,8 @@ package android.media { } public static class MediaPlayer2.TrackInfo { - method public android.media.MediaFormat getFormat(); - method public String getLanguage(); + method @Nullable public android.media.MediaFormat getFormat(); + method @Nullable public String getLanguage(); method public int getTrackType(); field public static final int MEDIA_TRACK_TYPE_AUDIO = 2; // 0x2 field public static final int MEDIA_TRACK_TYPE_METADATA = 5; // 0x5 @@ -26618,15 +26619,15 @@ package android.media { } public class UriDataSourceDesc extends android.media.DataSourceDesc { - method public android.content.Context getContext(); - method public java.util.List<java.net.HttpCookie> getCookies(); - method public java.util.Map<java.lang.String,java.lang.String> getHeaders(); - method public android.net.Uri getUri(); + method @NonNull public android.content.Context getContext(); + method @Nullable public java.util.List<java.net.HttpCookie> getCookies(); + method @Nullable public java.util.Map<java.lang.String,java.lang.String> getHeaders(); + method @NonNull public android.net.Uri getUri(); } public static class UriDataSourceDesc.Builder extends android.media.DataSourceDesc.BuilderBase<android.media.UriDataSourceDesc.Builder> { ctor public UriDataSourceDesc.Builder(); - ctor public UriDataSourceDesc.Builder(android.media.UriDataSourceDesc); + ctor public UriDataSourceDesc.Builder(@Nullable android.media.UriDataSourceDesc); method @NonNull public android.media.UriDataSourceDesc build(); method @NonNull public android.media.UriDataSourceDesc.Builder setDataSource(@NonNull android.content.Context, @NonNull android.net.Uri); method @NonNull public android.media.UriDataSourceDesc.Builder setDataSource(@NonNull android.content.Context, @NonNull android.net.Uri, @Nullable java.util.Map<java.lang.String,java.lang.String>, @Nullable java.util.List<java.net.HttpCookie>); @@ -28981,6 +28982,7 @@ package android.net { field public static final int NET_CAPABILITY_IA = 7; // 0x7 field public static final int NET_CAPABILITY_IMS = 4; // 0x4 field public static final int NET_CAPABILITY_INTERNET = 12; // 0xc + field public static final int NET_CAPABILITY_MCX = 23; // 0x17 field public static final int NET_CAPABILITY_MMS = 0; // 0x0 field public static final int NET_CAPABILITY_NOT_CONGESTED = 20; // 0x14 field public static final int NET_CAPABILITY_NOT_METERED = 11; // 0xb @@ -45471,6 +45473,7 @@ package android.telephony.data { field public static final int TYPE_HIPRI = 16; // 0x10 field public static final int TYPE_IA = 256; // 0x100 field public static final int TYPE_IMS = 64; // 0x40 + field public static final int TYPE_MCX = 1024; // 0x400 field public static final int TYPE_MMS = 2; // 0x2 field public static final int TYPE_SUPL = 4; // 0x4 } @@ -45560,7 +45563,7 @@ package android.telephony.euicc { } public class EuiccManager { - method public android.telephony.euicc.EuiccManager createForCardId(int); + method @NonNull public android.telephony.euicc.EuiccManager createForCardId(int); method @RequiresPermission("android.permission.WRITE_EMBEDDED_SUBSCRIPTIONS") public void deleteSubscription(int, android.app.PendingIntent); method @RequiresPermission("android.permission.WRITE_EMBEDDED_SUBSCRIPTIONS") public void downloadSubscription(android.telephony.euicc.DownloadableSubscription, boolean, android.app.PendingIntent); method @Nullable public String getEid(); diff --git a/api/system-current.txt b/api/system-current.txt index 95f2a9ae6b57..99a17808dd61 100644 --- a/api/system-current.txt +++ b/api/system-current.txt @@ -951,7 +951,7 @@ package android.app.contentsuggestions { public final class ClassificationsRequest implements android.os.Parcelable { method public int describeContents(); - method @Nullable public android.os.Bundle getExtras(); + method @NonNull public android.os.Bundle getExtras(); method @NonNull public java.util.List<android.app.contentsuggestions.ContentSelection> getSelections(); method public void writeToParcel(android.os.Parcel, int); field @NonNull public static final android.os.Parcelable.Creator<android.app.contentsuggestions.ClassificationsRequest> CREATOR; @@ -959,8 +959,8 @@ package android.app.contentsuggestions { public static final class ClassificationsRequest.Builder { ctor public ClassificationsRequest.Builder(@NonNull java.util.List<android.app.contentsuggestions.ContentSelection>); - method public android.app.contentsuggestions.ClassificationsRequest build(); - method public android.app.contentsuggestions.ClassificationsRequest.Builder setExtras(@NonNull android.os.Bundle); + method @NonNull public android.app.contentsuggestions.ClassificationsRequest build(); + method @NonNull public android.app.contentsuggestions.ClassificationsRequest.Builder setExtras(@NonNull android.os.Bundle); } public final class ContentClassification implements android.os.Parcelable { @@ -998,7 +998,7 @@ package android.app.contentsuggestions { public final class SelectionsRequest implements android.os.Parcelable { method public int describeContents(); - method @Nullable public android.os.Bundle getExtras(); + method @NonNull public android.os.Bundle getExtras(); method @Nullable public android.graphics.Point getInterestPoint(); method public int getTaskId(); method public void writeToParcel(android.os.Parcel, int); @@ -1007,9 +1007,9 @@ package android.app.contentsuggestions { public static final class SelectionsRequest.Builder { ctor public SelectionsRequest.Builder(int); - method public android.app.contentsuggestions.SelectionsRequest build(); - method public android.app.contentsuggestions.SelectionsRequest.Builder setExtras(@NonNull android.os.Bundle); - method public android.app.contentsuggestions.SelectionsRequest.Builder setInterestPoint(@NonNull android.graphics.Point); + method @NonNull public android.app.contentsuggestions.SelectionsRequest build(); + method @NonNull public android.app.contentsuggestions.SelectionsRequest.Builder setExtras(@NonNull android.os.Bundle); + method @NonNull public android.app.contentsuggestions.SelectionsRequest.Builder setInterestPoint(@NonNull android.graphics.Point); } } @@ -3540,7 +3540,7 @@ package android.media { method public void stop(); } - public static class HwAudioSource.Builder { + public static final class HwAudioSource.Builder { ctor public HwAudioSource.Builder(); method @NonNull public android.media.HwAudioSource build(); method @NonNull public android.media.HwAudioSource.Builder setAudioAttributes(@NonNull android.media.AudioAttributes); @@ -3553,7 +3553,7 @@ package android.media { field public static final int RADIO_TUNER = 1998; // 0x7ce } - public static class MediaTimestamp.Builder { + public static final class MediaTimestamp.Builder { ctor public MediaTimestamp.Builder(); ctor public MediaTimestamp.Builder(@NonNull android.media.MediaTimestamp); method @NonNull public android.media.MediaTimestamp build(); @@ -3569,14 +3569,14 @@ package android.media { method public void stop(); } - public static class SubtitleData.Builder { + public static final class SubtitleData.Builder { ctor public SubtitleData.Builder(); ctor public SubtitleData.Builder(@NonNull android.media.SubtitleData); method @NonNull public android.media.SubtitleData build(); method @NonNull public android.media.SubtitleData.Builder setSubtitleData(int, long, long, @NonNull byte[]); } - public static class TimedMetaData.Builder { + public static final class TimedMetaData.Builder { ctor public TimedMetaData.Builder(); ctor public TimedMetaData.Builder(@NonNull android.media.TimedMetaData); method @NonNull public android.media.TimedMetaData build(); @@ -3695,7 +3695,7 @@ package android.media.audiopolicy { public final class AudioVolumeGroup implements android.os.Parcelable { method public int describeContents(); - method public java.util.List<android.media.AudioAttributes> getAudioAttributes(); + method @NonNull public java.util.List<android.media.AudioAttributes> getAudioAttributes(); method public int getId(); method @NonNull public int[] getLegacyStreamTypes(); method @NonNull public String name(); @@ -3707,7 +3707,7 @@ package android.media.audiopolicy { ctor public AudioVolumeGroups(); method public int describeContents(); method @Nullable public android.media.audiopolicy.AudioVolumeGroup getById(int); - method public java.util.Iterator<android.media.audiopolicy.AudioVolumeGroup> iterator(); + method @NonNull public java.util.Iterator<android.media.audiopolicy.AudioVolumeGroup> iterator(); method public int size(); method public void writeToParcel(@NonNull android.os.Parcel, int); field public static final android.os.Parcelable.Creator<android.media.audiopolicy.AudioVolumeGroups> CREATOR; @@ -5707,7 +5707,7 @@ package android.permission { } public final class RuntimePermissionPresentationInfo implements android.os.Parcelable { - ctor public RuntimePermissionPresentationInfo(CharSequence, boolean, boolean); + ctor public RuntimePermissionPresentationInfo(@NonNull CharSequence, boolean, boolean); method public int describeContents(); method @NonNull public CharSequence getLabel(); method public boolean isGranted(); @@ -5851,19 +5851,17 @@ package android.provider { method @RequiresPermission(android.Manifest.permission.WRITE_DEVICE_CONFIG) public static void resetToDefaults(int, @Nullable String); method @RequiresPermission(android.Manifest.permission.WRITE_DEVICE_CONFIG) public static boolean setProperty(String, String, String, boolean); field public static final String NAMESPACE_ACTIVITY_MANAGER = "activity_manager"; + field public static final String NAMESPACE_ACTIVITY_MANAGER_NATIVE_BOOT = "activity_manager_native_boot"; field public static final String NAMESPACE_AUTOFILL = "autofill"; field public static final String NAMESPACE_CONTENT_CAPTURE = "content_capture"; field public static final String NAMESPACE_GAME_DRIVER = "game_driver"; field public static final String NAMESPACE_INPUT_NATIVE_BOOT = "input_native_boot"; + field public static final String NAMESPACE_MEDIA_NATIVE = "media_native"; field public static final String NAMESPACE_NETD_NATIVE = "netd_native"; + field public static final String NAMESPACE_RUNTIME_NATIVE_BOOT = "runtime_native_boot"; field public static final String NAMESPACE_SYSTEMUI = "systemui"; } - public static interface DeviceConfig.ActivityManagerNativeBoot { - field public static final String NAMESPACE = "activity_manager_native_boot"; - field public static final String OFFLOAD_QUEUE_ENABLED = "offload_queue_enabled"; - } - public static interface DeviceConfig.AttentionManagerService { field public static final String COMPONENT_NAME = "component_name"; field public static final String NAMESPACE = "attention_manager_service"; @@ -5882,10 +5880,6 @@ package android.provider { field public static final String NAMESPACE = "intelligence_attention"; } - public static interface DeviceConfig.MediaNative { - field public static final String NAMESPACE = "media_native"; - } - public static interface DeviceConfig.OnPropertyChangedListener { method public void onPropertyChanged(String, String, String); } @@ -5912,10 +5906,6 @@ package android.provider { field public static final String NAMESPACE = "runtime_native"; } - public static interface DeviceConfig.RuntimeNativeBoot { - field public static final String NAMESPACE = "runtime_native_boot"; - } - public static interface DeviceConfig.Scheduler { field public static final String ENABLE_FAST_METRICS_COLLECTION = "enable_fast_metrics_collection"; field public static final String NAMESPACE = "scheduler"; @@ -6433,8 +6423,8 @@ package android.service.carrier { public abstract class ApnService extends android.app.Service { ctor public ApnService(); - method public android.os.IBinder onBind(android.content.Intent); - method @WorkerThread public abstract java.util.List<android.content.ContentValues> onRestoreApns(int); + method @NonNull public android.os.IBinder onBind(@Nullable android.content.Intent); + method @WorkerThread @NonNull public abstract java.util.List<android.content.ContentValues> onRestoreApns(int); } } @@ -7106,12 +7096,12 @@ package android.telephony { field public static final int WWAN = 1; // 0x1 } - public class CallAttributes implements android.os.Parcelable { - ctor public CallAttributes(android.telephony.PreciseCallState, int, android.telephony.CallQuality); + public final class CallAttributes implements android.os.Parcelable { + ctor public CallAttributes(@NonNull android.telephony.PreciseCallState, int, @NonNull android.telephony.CallQuality); method public int describeContents(); - method public android.telephony.CallQuality getCallQuality(); + method @NonNull public android.telephony.CallQuality getCallQuality(); method public int getNetworkType(); - method public android.telephony.PreciseCallState getPreciseCallState(); + method @NonNull public android.telephony.PreciseCallState getPreciseCallState(); method public void writeToParcel(android.os.Parcel, int); field @NonNull public static final android.os.Parcelable.Creator<android.telephony.CallAttributes> CREATOR; } @@ -7148,13 +7138,13 @@ package android.telephony { } public final class CarrierRestrictionRules implements android.os.Parcelable { + method @NonNull public java.util.List<java.lang.Boolean> areCarrierIdentifiersAllowed(@NonNull java.util.List<android.service.carrier.CarrierIdentifier>); method public int describeContents(); method @NonNull public java.util.List<android.service.carrier.CarrierIdentifier> getAllowedCarriers(); method public int getDefaultCarrierRestriction(); method @NonNull public java.util.List<android.service.carrier.CarrierIdentifier> getExcludedCarriers(); method public int getMultiSimPolicy(); method public boolean isAllCarriersAllowed(); - method public java.util.List<java.lang.Boolean> isCarrierIdentifiersAllowed(@NonNull java.util.List<android.service.carrier.CarrierIdentifier>); method public void writeToParcel(android.os.Parcel, int); field public static final int CARRIER_RESTRICTION_DEFAULT_ALLOWED = 1; // 0x1 field public static final int CARRIER_RESTRICTION_DEFAULT_NOT_ALLOWED = 0; // 0x0 @@ -7163,13 +7153,13 @@ package android.telephony { field public static final int MULTISIM_POLICY_ONE_VALID_SIM_MUST_BE_PRESENT = 1; // 0x1 } - public static class CarrierRestrictionRules.Builder { - method public android.telephony.CarrierRestrictionRules build(); - method public android.telephony.CarrierRestrictionRules.Builder setAllCarriersAllowed(); - method public android.telephony.CarrierRestrictionRules.Builder setAllowedCarriers(java.util.List<android.service.carrier.CarrierIdentifier>); - method public android.telephony.CarrierRestrictionRules.Builder setDefaultCarrierRestriction(int); - method public android.telephony.CarrierRestrictionRules.Builder setExcludedCarriers(java.util.List<android.service.carrier.CarrierIdentifier>); - method public android.telephony.CarrierRestrictionRules.Builder setMultiSimPolicy(int); + public static final class CarrierRestrictionRules.Builder { + method @NonNull public android.telephony.CarrierRestrictionRules build(); + method @NonNull public android.telephony.CarrierRestrictionRules.Builder setAllCarriersAllowed(); + method @NonNull public android.telephony.CarrierRestrictionRules.Builder setAllowedCarriers(@NonNull java.util.List<android.service.carrier.CarrierIdentifier>); + method @NonNull public android.telephony.CarrierRestrictionRules.Builder setDefaultCarrierRestriction(int); + method @NonNull public android.telephony.CarrierRestrictionRules.Builder setExcludedCarriers(@NonNull java.util.List<android.service.carrier.CarrierIdentifier>); + method @NonNull public android.telephony.CarrierRestrictionRules.Builder setMultiSimPolicy(int); } public final class DataFailCause { @@ -8435,7 +8425,7 @@ package android.telephony.ims { } public class ImsCallSessionListener { - method public void callQualityChanged(android.telephony.CallQuality); + method public void callQualityChanged(@NonNull android.telephony.CallQuality); method public void callSessionConferenceExtendFailed(android.telephony.ims.ImsReasonInfo); method public void callSessionConferenceExtendReceived(android.telephony.ims.stub.ImsCallSessionImplBase, android.telephony.ims.ImsCallProfile); method public void callSessionConferenceExtended(android.telephony.ims.stub.ImsCallSessionImplBase, android.telephony.ims.ImsCallProfile); diff --git a/api/test-current.txt b/api/test-current.txt index a3b61552cc0e..684524e8987b 100644 --- a/api/test-current.txt +++ b/api/test-current.txt @@ -1011,7 +1011,7 @@ package android.media { method public android.media.MediaPlayer2.DrmInfo getDrmInfo(@NonNull android.media.DataSourceDesc); method public android.media.MediaDrm.KeyRequest getDrmKeyRequest(@NonNull android.media.DataSourceDesc, @Nullable byte[], @Nullable byte[], @Nullable String, int, @Nullable java.util.Map<java.lang.String,java.lang.String>) throws android.media.MediaPlayer2.NoDrmSchemeException; method public String getDrmPropertyString(@NonNull android.media.DataSourceDesc, @NonNull String) throws android.media.MediaPlayer2.NoDrmSchemeException; - method public Object prepareDrm(@NonNull android.media.DataSourceDesc, @NonNull java.util.UUID); + method @NonNull public Object prepareDrm(@NonNull android.media.DataSourceDesc, @NonNull java.util.UUID); method public byte[] provideDrmKeyResponse(@NonNull android.media.DataSourceDesc, @Nullable byte[], @NonNull byte[]) throws android.media.DeniedByServerException, android.media.MediaPlayer2.NoDrmSchemeException; method public void releaseDrm(@NonNull android.media.DataSourceDesc) throws android.media.MediaPlayer2.NoDrmSchemeException; method public void restoreDrmKeys(@NonNull android.media.DataSourceDesc, @NonNull byte[]) throws android.media.MediaPlayer2.NoDrmSchemeException; @@ -3033,7 +3033,7 @@ package android.view.inspector { method public abstract String value(); } - @java.lang.annotation.Retention(java.lang.annotation.RetentionPolicy.SOURCE) @java.lang.annotation.Target({java.lang.annotation.ElementType.METHOD}) public @interface InspectableProperty { + @java.lang.annotation.Retention(java.lang.annotation.RetentionPolicy.SOURCE) @java.lang.annotation.Target({java.lang.annotation.ElementType.METHOD, java.lang.annotation.ElementType.FIELD}) public @interface InspectableProperty { method public abstract int attributeId() default android.content.res.Resources.ID_NULL; method public abstract android.view.inspector.InspectableProperty.EnumMap[] enumMapping() default {}; method public abstract android.view.inspector.InspectableProperty.FlagMap[] flagMapping() default {}; diff --git a/core/java/android/app/admin/DevicePolicyManager.java b/core/java/android/app/admin/DevicePolicyManager.java index d593ad1fd0cd..efbd09844977 100644 --- a/core/java/android/app/admin/DevicePolicyManager.java +++ b/core/java/android/app/admin/DevicePolicyManager.java @@ -3153,7 +3153,7 @@ public class DevicePolicyManager { * {@link #PASSWORD_QUALITY_ALPHANUMERIC} with {@link #setPasswordQuality}. * <p> * On devices not supporting {@link PackageManager#FEATURE_SECURE_LOCK_SCREEN} feature, the - * password is always treated as empty. + * password history length is always 0. * <p> * The calling device admin must have requested * {@link DeviceAdminInfo#USES_POLICY_LIMIT_PASSWORD} to be able to call this method; if it has @@ -3191,6 +3191,9 @@ public class DevicePolicyManager { * <p> * To disable password expiration, a value of 0 may be used for timeout. * <p> + * On devices not supporting {@link PackageManager#FEATURE_SECURE_LOCK_SCREEN} feature, the + * password expiration is always disabled. + * <p> * The calling device admin must have requested * {@link DeviceAdminInfo#USES_POLICY_EXPIRE_PASSWORD} to be able to call this method; if it has * not, a security exception will be thrown. @@ -3230,6 +3233,9 @@ public class DevicePolicyManager { * returned by {@link #getParentProfileInstance(ComponentName)} in order to retrieve * restrictions on the parent profile. * + * <p>On devices not supporting {@link PackageManager#FEATURE_SECURE_LOCK_SCREEN} feature, the + * password expiration is always disabled and this method always returns 0. + * * @param admin The name of the admin component to check, or {@code null} to aggregate all admins. * @return The timeout for the given admin or the minimum of all timeouts */ @@ -3255,6 +3261,9 @@ public class DevicePolicyManager { * returned by {@link #getParentProfileInstance(ComponentName)} in order to retrieve * the password expiration for the parent profile. * + * <p>On devices not supporting {@link PackageManager#FEATURE_SECURE_LOCK_SCREEN} feature, the + * password expiration is always disabled and this method always returns 0. + * * @param admin The name of the admin component to check, or {@code null} to aggregate all admins. * @return The password expiration time, in milliseconds since epoch. */ @@ -3279,6 +3288,9 @@ public class DevicePolicyManager { * returned by {@link #getParentProfileInstance(ComponentName)} in order to retrieve * restrictions on the parent profile. * + * <p>On devices not supporting {@link PackageManager#FEATURE_SECURE_LOCK_SCREEN} feature, the + * password history length is always 0. + * * @param admin The name of the admin component to check, or {@code null} to aggregate * all admins. * @return The length of the password history @@ -3306,7 +3318,7 @@ public class DevicePolicyManager { * Return the maximum password length that the device supports for a * particular password quality. * <p>On devices not supporting {@link PackageManager#FEATURE_SECURE_LOCK_SCREEN} feature, the - * password is always empty. + * password is always empty and this method always returns 0. * @param quality The quality being interrogated. * @return Returns the maximum length that the user can enter. */ @@ -3362,7 +3374,7 @@ public class DevicePolicyManager { * #getParentProfileInstance}. * * <p>On devices not supporting {@link PackageManager#FEATURE_SECURE_LOCK_SCREEN} feature, the - * password is always treated as empty. + * password is always empty and this method returns {@link #PASSWORD_COMPLEXITY_NONE}. * * @throws IllegalStateException if the user is not unlocked. * @throws SecurityException if the calling application does not have the permission @@ -3437,6 +3449,8 @@ public class DevicePolicyManager { * <p> * The calling device admin must have requested {@link DeviceAdminInfo#USES_POLICY_WATCH_LOGIN} * to be able to call this method; if it has not, a security exception will be thrown. + * <p>On devices not supporting {@link PackageManager#FEATURE_SECURE_LOCK_SCREEN} feature, the + * password is always empty and this method always returns 0. * * @return The number of times user has entered an incorrect password since the last correct * password entry. @@ -3503,6 +3517,8 @@ public class DevicePolicyManager { * This method can be called on the {@link DevicePolicyManager} instance returned by * {@link #getParentProfileInstance(ComponentName)} in order to set a value on the parent * profile. + * <p>On devices not supporting {@link PackageManager#FEATURE_SECURE_LOCK_SCREEN} feature, the + * password is always empty and this method has no effect - i.e. the policy is not set. * * @param admin Which {@link DeviceAdminReceiver} this request is associated with. * @param num The number of failed password attempts at which point the device or profile will @@ -3532,6 +3548,10 @@ public class DevicePolicyManager { * returned by {@link #getParentProfileInstance(ComponentName)} in order to retrieve * the value for the parent profile. * + * <p>On devices not supporting {@link PackageManager#FEATURE_SECURE_LOCK_SCREEN} feature, the + * password is always empty and this method returns a default value (0) indicating that the + * policy is not set. + * * @param admin The name of the admin component to check, or {@code null} to aggregate * all admins. */ @@ -3619,6 +3639,8 @@ public class DevicePolicyManager { * {@link android.os.Build.VERSION_CODES#N} and later for managed profiles, or for device admins * that are not device owner or profile owner. Once set, the password cannot be changed to null * or empty except by these admins.</em> + * <p>On devices not supporting {@link PackageManager#FEATURE_SECURE_LOCK_SCREEN} feature, this + * methods does nothing. * <p> * The calling device admin must have requested * {@link DeviceAdminInfo#USES_POLICY_RESET_PASSWORD} to be able to call this method; if it has @@ -3669,6 +3691,8 @@ public class DevicePolicyManager { * will be stored on your server and who will need access to them. Tokens may be the subject of * legal access requests. * </em> + * <p>On devices not supporting {@link PackageManager#FEATURE_SECURE_LOCK_SCREEN} feature, the + * reset token is not set and this method returns false. * * @param admin Which {@link DeviceAdminReceiver} this request is associated with. * @param token a secure token a least 32-byte long, which must be generated by a @@ -3693,6 +3717,10 @@ public class DevicePolicyManager { /** * Called by a profile or device owner to revoke the current password reset token. * + * <p>On devices not supporting {@link PackageManager#FEATURE_SECURE_LOCK_SCREEN} feature, this + * method has no effect - the reset token should not have been set in the first place - and + * false is returned. + * * @param admin Which {@link DeviceAdminReceiver} this request is associated with. * @return true if the operation is successful, false otherwise. * @throws SecurityException if admin is not a device or profile owner. @@ -3713,6 +3741,9 @@ public class DevicePolicyManager { /** * Called by a profile or device owner to check if the current reset password token is active. * + * <p>On devices not supporting {@link PackageManager#FEATURE_SECURE_LOCK_SCREEN} feature, + * false is always returned. + * * @param admin Which {@link DeviceAdminReceiver} this request is associated with. * @return true if the token is active, false otherwise. * @throws SecurityException if admin is not a device or profile owner. @@ -3748,6 +3779,8 @@ public class DevicePolicyManager { * <p> * Calling with a {@code null} or empty password will clear any existing PIN, pattern or * password if the current password constraints allow it. + * <p>On devices not supporting {@link PackageManager#FEATURE_SECURE_LOCK_SCREEN} feature, + * calling this methods has no effect - the password is always empty - and false is returned. * * @param admin Which {@link DeviceAdminReceiver} this request is associated with. * @param password The new password for the user. {@code null} or empty clears the password. @@ -3855,6 +3888,9 @@ public class DevicePolicyManager { * {@link #getParentProfileInstance(ComponentName)} in order to set restrictions on the parent * profile. * + * <p>On devices not supporting {@link PackageManager#FEATURE_SECURE_LOCK_SCREEN} feature, + * calling this methods has no effect - i.e. the timeout is not set. + * * @param admin Which {@link DeviceAdminReceiver} this request is associated with. * @param timeoutMs The new timeout in milliseconds, after which the user will have to unlock * with strong authentication method. A value of 0 means the admin is not participating @@ -3887,6 +3923,9 @@ public class DevicePolicyManager { * returned by {@link #getParentProfileInstance(ComponentName)} in order to retrieve * restrictions on the parent profile. * + * <p>On devices not supporting {@link PackageManager#FEATURE_SECURE_LOCK_SCREEN} feature, + * 0 is returned to indicate that no timeout is configured. + * * @param admin The name of the admin component to check, or {@code null} to aggregate * across all participating admins. * @return The timeout in milliseconds or 0 if not configured for the provided admin. @@ -6617,6 +6656,9 @@ public class DevicePolicyManager { * This method can be called on the {@link DevicePolicyManager} instance returned by * {@link #getParentProfileInstance(ComponentName)} in order to set the configuration for * the parent profile. + * <p> + * On devices not supporting {@link PackageManager#FEATURE_SECURE_LOCK_SCREEN} feature, calling + * this method has no effect - no trust agent configuration will be set. * * @param admin Which {@link DeviceAdminReceiver} this request is associated with. * @param target Component name of the agent to be configured. @@ -6646,6 +6688,9 @@ public class DevicePolicyManager { * This method can be called on the {@link DevicePolicyManager} instance returned by * {@link #getParentProfileInstance(ComponentName)} in order to retrieve the configuration set * on the parent profile. + * <p> + * On devices not supporting {@link PackageManager#FEATURE_SECURE_LOCK_SCREEN} feature, null is + * always returned. * * @param admin Which {@link DeviceAdminReceiver} this request is associated with. If null, * this function returns a list of configurations for all admins that declare diff --git a/core/java/android/app/contentsuggestions/ClassificationsRequest.java b/core/java/android/app/contentsuggestions/ClassificationsRequest.java index 1b50015ffc71..2051a55e1c2f 100644 --- a/core/java/android/app/contentsuggestions/ClassificationsRequest.java +++ b/core/java/android/app/contentsuggestions/ClassificationsRequest.java @@ -54,10 +54,10 @@ public final class ClassificationsRequest implements Parcelable { } /** - * Return the request extras or {@code null} if there are none. + * Return the request extras, can be an empty bundle. */ - public @Nullable Bundle getExtras() { - return mExtras; + public @NonNull Bundle getExtras() { + return mExtras == null ? new Bundle() : mExtras; } @Override @@ -103,7 +103,7 @@ public final class ClassificationsRequest implements Parcelable { /** * Sets the request extras. */ - public Builder setExtras(@NonNull Bundle extras) { + public @NonNull Builder setExtras(@NonNull Bundle extras) { mExtras = extras; return this; } @@ -111,7 +111,7 @@ public final class ClassificationsRequest implements Parcelable { /** * Builds a new request instance. */ - public ClassificationsRequest build() { + public @NonNull ClassificationsRequest build() { return new ClassificationsRequest(mSelections, mExtras); } } diff --git a/core/java/android/app/contentsuggestions/SelectionsRequest.java b/core/java/android/app/contentsuggestions/SelectionsRequest.java index 257f98d5d7d6..84f33b552893 100644 --- a/core/java/android/app/contentsuggestions/SelectionsRequest.java +++ b/core/java/android/app/contentsuggestions/SelectionsRequest.java @@ -63,10 +63,10 @@ public final class SelectionsRequest implements Parcelable { } /** - * Return the request extras or {@code null} if there aren't any. + * Return the request extras, may be an empty bundle if there aren't any. */ - public @Nullable Bundle getExtras() { - return mExtras; + public @NonNull Bundle getExtras() { + return mExtras == null ? new Bundle() : mExtras; } @Override @@ -118,7 +118,7 @@ public final class SelectionsRequest implements Parcelable { /** * Sets the request extras. */ - public Builder setExtras(@NonNull Bundle extras) { + public @NonNull Builder setExtras(@NonNull Bundle extras) { mExtras = extras; return this; } @@ -126,7 +126,7 @@ public final class SelectionsRequest implements Parcelable { /** * Sets the request interest point. */ - public Builder setInterestPoint(@NonNull Point interestPoint) { + public @NonNull Builder setInterestPoint(@NonNull Point interestPoint) { mInterestPoint = interestPoint; return this; } @@ -134,7 +134,7 @@ public final class SelectionsRequest implements Parcelable { /** * Builds a new request instance. */ - public SelectionsRequest build() { + public @NonNull SelectionsRequest build() { return new SelectionsRequest(mTaskId, mInterestPoint, mExtras); } } diff --git a/core/java/android/hardware/camera2/CameraManager.java b/core/java/android/hardware/camera2/CameraManager.java index 536c2e13389b..234014327150 100644 --- a/core/java/android/hardware/camera2/CameraManager.java +++ b/core/java/android/hardware/camera2/CameraManager.java @@ -678,6 +678,31 @@ public final class CameraManager { public void onCameraUnavailable(@NonNull String cameraId) { // default empty implementation } + + /** + * Notify registered clients about a change in the camera access priorities. + * + * <p>Notification that camera access priorities have changed and the camera may + * now be openable. An application that was previously denied camera access due to + * a higher-priority user already using the camera, or that was disconnected from an + * active camera session due to a higher-priority user trying to open the camera, + * should try to open the camera again if it still wants to use it. Note that + * multiple applications may receive this callback at the same time, and only one of + * them will succeed in opening the camera in practice, depending on exact access + * priority levels and timing. This method is useful in cases where multiple + * applications may be in the resumed state at the same time, and the user switches + * focus between them, or if the current camera-using application moves between + * full-screen and Picture-in-Picture (PiP) states. In such cases, the camera + * available/unavailable callbacks will not be invoked, but another application may + * now have higher priority for camera access than the current camera-using + * application.</p> + * + * <p>The default implementation of this method does nothing.</p> + * + */ + public void onCameraAccessPrioritiesChanged() { + // default empty implementation + } } /** @@ -1098,6 +1123,22 @@ public final class CameraManager { } } + private void postSingleAccessPriorityChangeUpdate(final AvailabilityCallback callback, + final Executor executor) { + final long ident = Binder.clearCallingIdentity(); + try { + executor.execute( + new Runnable() { + @Override + public void run() { + callback.onCameraAccessPrioritiesChanged(); + } + }); + } finally { + Binder.restoreCallingIdentity(ident); + } + } + private void postSingleUpdate(final AvailabilityCallback callback, final Executor executor, final String id, final int status) { if (isAvailable(status)) { @@ -1347,6 +1388,19 @@ public final class CameraManager { } } + @Override + public void onCameraAccessPrioritiesChanged() { + synchronized (mLock) { + final int callbackCount = mCallbackMap.size(); + for (int i = 0; i < callbackCount; i++) { + Executor executor = mCallbackMap.valueAt(i); + final AvailabilityCallback callback = mCallbackMap.keyAt(i); + + postSingleAccessPriorityChangeUpdate(callback, executor); + } + } + } + /** * Try to connect to camera service after some delay if any client registered camera * availability callback or torch status callback. diff --git a/core/java/android/net/NetworkCapabilities.java b/core/java/android/net/NetworkCapabilities.java index a17ebcbedd1a..eb0fe33df03a 100644 --- a/core/java/android/net/NetworkCapabilities.java +++ b/core/java/android/net/NetworkCapabilities.java @@ -143,6 +143,7 @@ public final class NetworkCapabilities implements Parcelable { NET_CAPABILITY_NOT_CONGESTED, NET_CAPABILITY_NOT_SUSPENDED, NET_CAPABILITY_OEM_PAID, + NET_CAPABILITY_MCX }) public @interface NetCapability { } @@ -297,8 +298,14 @@ public final class NetworkCapabilities implements Parcelable { @SystemApi public static final int NET_CAPABILITY_OEM_PAID = 22; + /** + * Indicates this is a network that has the ability to reach a carrier's Mission Critical + * servers. + */ + public static final int NET_CAPABILITY_MCX = 23; + private static final int MIN_NET_CAPABILITY = NET_CAPABILITY_MMS; - private static final int MAX_NET_CAPABILITY = NET_CAPABILITY_OEM_PAID; + private static final int MAX_NET_CAPABILITY = NET_CAPABILITY_MCX; /** * Network capabilities that are expected to be mutable, i.e., can change while a particular @@ -346,7 +353,8 @@ public final class NetworkCapabilities implements Parcelable { (1 << NET_CAPABILITY_IA) | (1 << NET_CAPABILITY_IMS) | (1 << NET_CAPABILITY_RCS) | - (1 << NET_CAPABILITY_XCAP); + (1 << NET_CAPABILITY_XCAP) | + (1 << NET_CAPABILITY_MCX); /** * Capabilities that force network to be restricted. @@ -1614,6 +1622,7 @@ public final class NetworkCapabilities implements Parcelable { case NET_CAPABILITY_NOT_CONGESTED: return "NOT_CONGESTED"; case NET_CAPABILITY_NOT_SUSPENDED: return "NOT_SUSPENDED"; case NET_CAPABILITY_OEM_PAID: return "OEM_PAID"; + case NET_CAPABILITY_MCX: return "MCX"; default: return Integer.toString(capability); } } diff --git a/core/java/android/permission/RuntimePermissionPresentationInfo.java b/core/java/android/permission/RuntimePermissionPresentationInfo.java index d66789fa1ac2..4fce14cef3f0 100644 --- a/core/java/android/permission/RuntimePermissionPresentationInfo.java +++ b/core/java/android/permission/RuntimePermissionPresentationInfo.java @@ -21,6 +21,8 @@ import android.annotation.SystemApi; import android.os.Parcel; import android.os.Parcelable; +import com.android.internal.util.Preconditions; + /** * This class contains information about how a runtime permission * is to be presented in the UI. A single runtime permission @@ -35,7 +37,7 @@ public final class RuntimePermissionPresentationInfo implements Parcelable { private static final int FLAG_GRANTED = 1 << 0; private static final int FLAG_STANDARD = 1 << 1; - private final CharSequence mLabel; + private final @NonNull CharSequence mLabel; private final int mFlags; /** @@ -45,8 +47,10 @@ public final class RuntimePermissionPresentationInfo implements Parcelable { * @param granted Whether the permission is granted. * @param standard Whether this is a platform-defined permission. */ - public RuntimePermissionPresentationInfo(CharSequence label, + public RuntimePermissionPresentationInfo(@NonNull CharSequence label, boolean granted, boolean standard) { + Preconditions.checkNotNull(label); + mLabel = label; int flags = 0; if (granted) { @@ -58,11 +62,6 @@ public final class RuntimePermissionPresentationInfo implements Parcelable { mFlags = flags; } - private RuntimePermissionPresentationInfo(Parcel parcel) { - mLabel = parcel.readCharSequence(); - mFlags = parcel.readInt(); - } - /** * @return Whether the permission is granted. */ @@ -97,10 +96,14 @@ public final class RuntimePermissionPresentationInfo implements Parcelable { parcel.writeInt(mFlags); } - public static final @android.annotation.NonNull Creator<RuntimePermissionPresentationInfo> CREATOR = + public static final @NonNull Creator<RuntimePermissionPresentationInfo> CREATOR = new Creator<RuntimePermissionPresentationInfo>() { public RuntimePermissionPresentationInfo createFromParcel(Parcel source) { - return new RuntimePermissionPresentationInfo(source); + CharSequence label = source.readCharSequence(); + int flags = source.readInt(); + + return new RuntimePermissionPresentationInfo(label, (flags & FLAG_GRANTED) != 0, + (flags & FLAG_STANDARD) != 0); } public RuntimePermissionPresentationInfo[] newArray(int size) { diff --git a/core/java/android/provider/DeviceConfig.java b/core/java/android/provider/DeviceConfig.java index 2cd3c48b0eb8..5d4539cb62af 100644 --- a/core/java/android/provider/DeviceConfig.java +++ b/core/java/android/provider/DeviceConfig.java @@ -64,12 +64,14 @@ public final class DeviceConfig { public static final String NAMESPACE_ACTIVITY_MANAGER = "activity_manager"; /** - * Namespace for all Game Driver features. + * Namespace for all activity manager related features that are used at the native level. + * These features are applied at reboot. * * @hide */ @SystemApi - public static final String NAMESPACE_GAME_DRIVER = "game_driver"; + public static final String NAMESPACE_ACTIVITY_MANAGER_NATIVE_BOOT = + "activity_manager_native_boot"; /** * Namespace for autofill feature that provides suggestions across all apps when @@ -92,6 +94,14 @@ public final class DeviceConfig { public static final String NAMESPACE_CONTENT_CAPTURE = "content_capture"; /** + * Namespace for all Game Driver features. + * + * @hide + */ + @SystemApi + public static final String NAMESPACE_GAME_DRIVER = "game_driver"; + + /** * Namespace for all input-related features that are used at the native level. * These features are applied at reboot. * @@ -101,6 +111,14 @@ public final class DeviceConfig { public static final String NAMESPACE_INPUT_NATIVE_BOOT = "input_native_boot"; /** + * Namespace for all media native related features. + * + * @hide + */ + @SystemApi + public static final String NAMESPACE_MEDIA_NATIVE = "media_native"; + + /** * Namespace for all netd related features. * * @hide @@ -109,6 +127,15 @@ public final class DeviceConfig { public static final String NAMESPACE_NETD_NATIVE = "netd_native"; /** + * Namespace for all runtime native boot related features. Boot in this case refers to the + * fact that the properties only take affect after rebooting the device. + * + * @hide + */ + @SystemApi + public static final String NAMESPACE_RUNTIME_NATIVE_BOOT = "runtime_native_boot"; + + /** * Namespace for System UI related features. * * @hide @@ -174,40 +201,6 @@ public final class DeviceConfig { } /** - * Namespace for all runtime native boot related features. Boot in this case refers to the - * fact that the properties only take affect after rebooting the device. - * - * @hide - */ - @SystemApi - public interface RuntimeNativeBoot { - String NAMESPACE = "runtime_native_boot"; - } - - /** - * Namespace for all media native related features. - * - * @hide - */ - @SystemApi - public interface MediaNative { - /** The flag namespace for media native features. */ - String NAMESPACE = "media_native"; - } - - /** - * Namespace for all activity manager related features that are used at the native level. - * These features are applied at reboot. - * - * @hide - */ - @SystemApi - public interface ActivityManagerNativeBoot { - String NAMESPACE = "activity_manager_native_boot"; - String OFFLOAD_QUEUE_ENABLED = "offload_queue_enabled"; - } - - /** * Namespace for attention-based features provided by on-device machine intelligence. * * @hide diff --git a/core/java/android/service/carrier/ApnService.java b/core/java/android/service/carrier/ApnService.java index d53eb37ca786..57e4b1b40748 100644 --- a/core/java/android/service/carrier/ApnService.java +++ b/core/java/android/service/carrier/ApnService.java @@ -16,6 +16,8 @@ package android.service.carrier; +import android.annotation.NonNull; +import android.annotation.Nullable; import android.annotation.SystemApi; import android.annotation.WorkerThread; import android.app.Service; @@ -60,7 +62,8 @@ public abstract class ApnService extends Service { }; @Override - public IBinder onBind(Intent intent) { + @NonNull + public IBinder onBind(@Nullable Intent intent) { return mBinder; } @@ -73,5 +76,6 @@ public abstract class ApnService extends Service { * subId. */ @WorkerThread + @NonNull public abstract List<ContentValues> onRestoreApns(int subId); } diff --git a/core/java/android/view/View.java b/core/java/android/view/View.java index 877b3044f7c3..874be814ed9a 100644 --- a/core/java/android/view/View.java +++ b/core/java/android/view/View.java @@ -18589,7 +18589,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback, @FlagMap(target = FADING_EDGE_VERTICAL, name = "vertical"), @FlagMap(target = FADING_EDGE_HORIZONTAL, name = "horizontal") }) - int getFadingEdge() { + public int getFadingEdge() { return mViewFlags & FADING_EDGE_MASK; } @@ -18600,7 +18600,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback, * @hide */ @InspectableProperty - int getFadingEdgeLength() { + public int getFadingEdgeLength() { if (mScrollCache != null && (mViewFlags & FADING_EDGE_MASK) != FADING_EDGE_NONE) { return mScrollCache.fadingEdgeLength; } diff --git a/core/java/android/view/inspector/InspectableProperty.java b/core/java/android/view/inspector/InspectableProperty.java index f85952108f07..30938c152eca 100644 --- a/core/java/android/view/inspector/InspectableProperty.java +++ b/core/java/android/view/inspector/InspectableProperty.java @@ -16,6 +16,7 @@ package android.view.inspector; +import static java.lang.annotation.ElementType.FIELD; import static java.lang.annotation.ElementType.METHOD; import static java.lang.annotation.ElementType.TYPE; import static java.lang.annotation.RetentionPolicy.SOURCE; @@ -39,7 +40,7 @@ import java.lang.annotation.Target; * @see InspectionCompanion#readProperties(Object, PropertyReader) * @hide */ -@Target({METHOD}) +@Target({METHOD, FIELD}) @Retention(SOURCE) @TestApi public @interface InspectableProperty { diff --git a/core/proto/android/app/settings_enums.proto b/core/proto/android/app/settings_enums.proto index f3bc2c7fa513..5064d23453a7 100644 --- a/core/proto/android/app/settings_enums.proto +++ b/core/proto/android/app/settings_enums.proto @@ -2287,4 +2287,7 @@ enum PageId { // OPEN: Accessibility detail settings (android.settings.ACCESSIBILITY_DETAILS_SETTINGS intent) ACCESSIBILITY_DETAILS_SETTINGS = 1682; + + // Open: Settings will show the conditional when Grayscale mode is on + SETTINGS_CONDITION_GRAYSCALE_MODE = 1683; } diff --git a/core/res/res/layout/immersive_mode_cling.xml b/core/res/res/layout/immersive_mode_cling.xml index b08b0f4d59c0..9fd615dc96b7 100644 --- a/core/res/res/layout/immersive_mode_cling.xml +++ b/core/res/res/layout/immersive_mode_cling.xml @@ -59,7 +59,7 @@ android:paddingStart="48dp" android:paddingTop="40dp" android:text="@string/immersive_cling_title" - android:textColor="@color/primary_text_default_material_light" + android:textColor="@android:color/white" android:textSize="24sp" /> <TextView @@ -71,7 +71,7 @@ android:paddingStart="48dp" android:paddingTop="12.6dp" android:text="@string/immersive_cling_description" - android:textColor="@color/primary_text_default_material_light" + android:textColor="@android:color/white" android:textSize="16sp" /> <Button @@ -89,4 +89,4 @@ android:textColor="@android:color/white" android:textSize="14sp" /> -</RelativeLayout>
\ No newline at end of file +</RelativeLayout> diff --git a/core/tests/BroadcastRadioTests/Android.mk b/core/tests/BroadcastRadioTests/Android.mk index 6b0484ec366d..faffc4b28a58 100644 --- a/core/tests/BroadcastRadioTests/Android.mk +++ b/core/tests/BroadcastRadioTests/Android.mk @@ -25,7 +25,7 @@ LOCAL_MODULE_TAGS := tests # LOCAL_SDK_VERSION := current LOCAL_PRIVATE_PLATFORM_APIS := true -LOCAL_STATIC_JAVA_LIBRARIES := compatibility-device-util androidx.test.rules testng +LOCAL_STATIC_JAVA_LIBRARIES := compatibility-device-util-axt androidx.test.rules testng LOCAL_JAVA_LIBRARIES := android.test.base diff --git a/keystore/tests/Android.mk b/keystore/tests/Android.mk index 596e5f530970..99d3197f8bf3 100644 --- a/keystore/tests/Android.mk +++ b/keystore/tests/Android.mk @@ -21,7 +21,7 @@ LOCAL_MODULE_TAGS := tests LOCAL_SRC_FILES := $(call all-java-files-under, src) LOCAL_STATIC_JAVA_LIBRARIES := \ - android-support-test + androidx.test.rules hamcrest-library LOCAL_PACKAGE_NAME := KeystoreTests LOCAL_PRIVATE_PLATFORM_APIS := true diff --git a/keystore/tests/AndroidManifest.xml b/keystore/tests/AndroidManifest.xml index 9bf2d0c761e6..6833cd1e35b9 100644 --- a/keystore/tests/AndroidManifest.xml +++ b/keystore/tests/AndroidManifest.xml @@ -20,7 +20,7 @@ <uses-library android:name="android.test.runner" /> </application> - <instrumentation android:name="android.support.test.runner.AndroidJUnitRunner" + <instrumentation android:name="androidx.test.runner.AndroidJUnitRunner" android:targetPackage="android.security.tests" android:label="Tests for Keystore"> </instrumentation> diff --git a/keystore/tests/src/android/security/ParcelableKeyGenParameterSpecTest.java b/keystore/tests/src/android/security/ParcelableKeyGenParameterSpecTest.java index 32f8ec44d11f..fca2775a34bb 100644 --- a/keystore/tests/src/android/security/ParcelableKeyGenParameterSpecTest.java +++ b/keystore/tests/src/android/security/ParcelableKeyGenParameterSpecTest.java @@ -22,16 +22,20 @@ import static org.junit.Assert.assertThat; import android.os.Parcel; import android.security.keystore.KeyGenParameterSpec; -import android.security.keystore.ParcelableKeyGenParameterSpec; import android.security.keystore.KeyProperties; -import android.support.test.runner.AndroidJUnit4; +import android.security.keystore.ParcelableKeyGenParameterSpec; + +import androidx.test.runner.AndroidJUnit4; + +import org.junit.Test; +import org.junit.runner.RunWith; + import java.math.BigInteger; import java.security.spec.ECGenParameterSpec; import java.security.spec.RSAKeyGenParameterSpec; import java.util.Date; + import javax.security.auth.x500.X500Principal; -import org.junit.Test; -import org.junit.runner.RunWith; /** Unit tests for {@link ParcelableKeyGenParameterSpec}. */ @RunWith(AndroidJUnit4.class) diff --git a/keystore/tests/src/android/security/keystore/KeyGenParameterSpecTest.java b/keystore/tests/src/android/security/keystore/KeyGenParameterSpecTest.java index 865cad472eb5..b2edfd05d13f 100644 --- a/keystore/tests/src/android/security/keystore/KeyGenParameterSpecTest.java +++ b/keystore/tests/src/android/security/keystore/KeyGenParameterSpecTest.java @@ -20,10 +20,12 @@ import static org.hamcrest.Matchers.is; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertThat; +import android.security.ParcelableKeyGenParameterSpecTest; import android.security.keystore.KeyGenParameterSpec; import android.security.keystore.KeyProperties; -import android.security.ParcelableKeyGenParameterSpecTest; -import android.support.test.runner.AndroidJUnit4; + +import androidx.test.runner.AndroidJUnit4; + import org.junit.Test; import org.junit.runner.RunWith; diff --git a/media/apex/java/android/media/CallbackDataSourceDesc.java b/media/apex/java/android/media/CallbackDataSourceDesc.java index cd364145e8a4..9209ca94897f 100644 --- a/media/apex/java/android/media/CallbackDataSourceDesc.java +++ b/media/apex/java/android/media/CallbackDataSourceDesc.java @@ -17,6 +17,7 @@ package android.media; import android.annotation.NonNull; +import android.annotation.Nullable; /** * Structure of data source descriptor for sources using callback. @@ -37,7 +38,7 @@ public class CallbackDataSourceDesc extends DataSourceDesc { * Return the DataSourceCallback of this data source. * @return the DataSourceCallback of this data source */ - public DataSourceCallback getDataSourceCallback() { + public @NonNull DataSourceCallback getDataSourceCallback() { return mDataSourceCallback; } @@ -70,7 +71,7 @@ public class CallbackDataSourceDesc extends DataSourceDesc { * @param dsd the {@link CallbackDataSourceDesc} object whose data will be reused * in the new Builder. */ - public Builder(CallbackDataSourceDesc dsd) { + public Builder(@Nullable CallbackDataSourceDesc dsd) { super(dsd); if (dsd == null) { return; // use default @@ -86,6 +87,11 @@ public class CallbackDataSourceDesc extends DataSourceDesc { * @return a new {@link CallbackDataSourceDesc} object */ public @NonNull CallbackDataSourceDesc build() { + if (mDataSourceCallback == null) { + throw new IllegalStateException( + "DataSourceCallback should not be null"); + } + CallbackDataSourceDesc dsd = new CallbackDataSourceDesc(); super.build(dsd); dsd.mDataSourceCallback = mDataSourceCallback; diff --git a/media/apex/java/android/media/DataSourceCallback.java b/media/apex/java/android/media/DataSourceCallback.java index 1afcd2075ba4..6515bd6a2c09 100644 --- a/media/apex/java/android/media/DataSourceCallback.java +++ b/media/apex/java/android/media/DataSourceCallback.java @@ -17,6 +17,8 @@ package android.media; +import android.annotation.NonNull; + import java.io.Closeable; import java.io.IOException; @@ -49,7 +51,7 @@ public abstract class DataSourceCallback implements Closeable { * @throws IOException on fatal errors. * @return the number of bytes read, or -1 if end of stream is reached. */ - public abstract int readAt(long position, byte[] buffer, int offset, int size) + public abstract int readAt(long position, @NonNull byte[] buffer, int offset, int size) throws IOException; /** diff --git a/media/apex/java/android/media/DataSourceDesc.java b/media/apex/java/android/media/DataSourceDesc.java index 7fc6f794cff8..e6fd120b6d5b 100644 --- a/media/apex/java/android/media/DataSourceDesc.java +++ b/media/apex/java/android/media/DataSourceDesc.java @@ -17,6 +17,7 @@ package android.media; import android.annotation.NonNull; +import android.annotation.Nullable; /** * Base class of data source descriptor. @@ -64,7 +65,7 @@ public class DataSourceDesc { * Return the media Id of data source. * @return the media Id of data source */ - public String getMediaId() { + public @Nullable String getMediaId() { return mMediaId; } @@ -149,7 +150,7 @@ public class DataSourceDesc { * @param mediaId the media Id of this data source * @return the same Builder instance. */ - public @NonNull T setMediaId(String mediaId) { + public @NonNull T setMediaId(@Nullable String mediaId) { mMediaId = mediaId; return (T) this; } diff --git a/media/apex/java/android/media/FileDataSourceDesc.java b/media/apex/java/android/media/FileDataSourceDesc.java index e29bd006c00a..4b703670abf1 100644 --- a/media/apex/java/android/media/FileDataSourceDesc.java +++ b/media/apex/java/android/media/FileDataSourceDesc.java @@ -17,6 +17,7 @@ package android.media; import android.annotation.NonNull; +import android.annotation.Nullable; import android.os.ParcelFileDescriptor; import android.util.Log; @@ -106,7 +107,7 @@ public class FileDataSourceDesc extends DataSourceDesc { * Return the ParcelFileDescriptor of this data source. * @return the ParcelFileDescriptor of this data source */ - public ParcelFileDescriptor getParcelFileDescriptor() { + public @NonNull ParcelFileDescriptor getParcelFileDescriptor() { return mPFD; } @@ -159,7 +160,7 @@ public class FileDataSourceDesc extends DataSourceDesc { * @param dsd the {@link FileDataSourceDesc} object whose data will be reused * in the new Builder. */ - public Builder(FileDataSourceDesc dsd) { + public Builder(@Nullable FileDataSourceDesc dsd) { super(dsd); if (dsd == null) { return; // use default diff --git a/media/apex/java/android/media/MediaPlayer2.java b/media/apex/java/android/media/MediaPlayer2.java index ef30172213bb..f6b2031bc456 100644 --- a/media/apex/java/android/media/MediaPlayer2.java +++ b/media/apex/java/android/media/MediaPlayer2.java @@ -344,7 +344,7 @@ public class MediaPlayer2 implements AutoCloseable * to free the resources. If not released, too many MediaPlayer2 instances may * result in an exception.</p> */ - public MediaPlayer2(Context context) { + public MediaPlayer2(@NonNull Context context) { mGuard.open("close"); mContext = context; @@ -488,7 +488,7 @@ public class MediaPlayer2 implements AutoCloseable * @return a token which can be used to cancel the operation later with {@link #cancelCommand}. */ // This is an asynchronous call. - public Object play() { + public @NonNull Object play() { return addTask(new Task(CALL_COMPLETED_PLAY, false) { @Override void process() { @@ -508,7 +508,7 @@ public class MediaPlayer2 implements AutoCloseable * @return a token which can be used to cancel the operation later with {@link #cancelCommand}. */ // This is an asynchronous call. - public Object prepare() { + public @NonNull Object prepare() { return addTask(new Task(CALL_COMPLETED_PREPARE, true) { @Override void process() { @@ -524,7 +524,7 @@ public class MediaPlayer2 implements AutoCloseable * @return a token which can be used to cancel the operation later with {@link #cancelCommand}. */ // This is an asynchronous call. - public Object pause() { + public @NonNull Object pause() { return addTask(new Task(CALL_COMPLETED_PAUSE, false) { @Override void process() { @@ -542,7 +542,7 @@ public class MediaPlayer2 implements AutoCloseable * @return a token which can be used to cancel the operation later with {@link #cancelCommand}. */ // This is an asynchronous call. - public Object skipToNext() { + public @NonNull Object skipToNext() { return addTask(new Task(CALL_COMPLETED_SKIP_TO_NEXT, false) { @Override void process() { @@ -700,7 +700,7 @@ public class MediaPlayer2 implements AutoCloseable * @return a token which can be used to cancel the operation later with {@link #cancelCommand}. */ // This is an asynchronous call. - public Object setAudioAttributes(@NonNull AudioAttributes attributes) { + public @NonNull Object setAudioAttributes(@NonNull AudioAttributes attributes) { return addTask(new Task(CALL_COMPLETED_SET_AUDIO_ATTRIBUTES, false) { @Override void process() { @@ -735,7 +735,7 @@ public class MediaPlayer2 implements AutoCloseable * @return a token which can be used to cancel the operation later with {@link #cancelCommand}. */ // This is an asynchronous call. - public Object setDataSource(@NonNull DataSourceDesc dsd) { + public @NonNull Object setDataSource(@NonNull DataSourceDesc dsd) { return addTask(new Task(CALL_COMPLETED_SET_DATA_SOURCE, false) { @Override void process() throws IOException { @@ -768,7 +768,7 @@ public class MediaPlayer2 implements AutoCloseable * @return a token which can be used to cancel the operation later with {@link #cancelCommand}. */ // This is an asynchronous call. - public Object setNextDataSource(@NonNull DataSourceDesc dsd) { + public @NonNull Object setNextDataSource(@NonNull DataSourceDesc dsd) { return addTask(new Task(CALL_COMPLETED_SET_NEXT_DATA_SOURCE, false) { @Override void process() { @@ -791,7 +791,7 @@ public class MediaPlayer2 implements AutoCloseable * @return a token which can be used to cancel the operation later with {@link #cancelCommand}. */ // This is an asynchronous call. - public Object setNextDataSources(@NonNull List<DataSourceDesc> dsds) { + public @NonNull Object setNextDataSources(@NonNull List<DataSourceDesc> dsds) { return addTask(new Task(CALL_COMPLETED_SET_NEXT_DATA_SOURCES, false) { @Override void process() { @@ -853,7 +853,7 @@ public class MediaPlayer2 implements AutoCloseable * @return a token which can be used to cancel the operation later with {@link #cancelCommand}. */ // This is an asynchronous call. - public Object clearNextDataSources() { + public @NonNull Object clearNextDataSources() { return addTask(new Task(CALL_COMPLETED_CLEAR_NEXT_DATA_SOURCES, false) { @Override void process() { @@ -1194,7 +1194,7 @@ public class MediaPlayer2 implements AutoCloseable * @return a token which can be used to cancel the operation later with {@link #cancelCommand}. */ // This is an asynchronous call. - public Object loopCurrent(boolean loop) { + public @NonNull Object loopCurrent(boolean loop) { return addTask(new Task(CALL_COMPLETED_LOOP_CURRENT, false) { @Override void process() { @@ -1216,7 +1216,7 @@ public class MediaPlayer2 implements AutoCloseable * @return a token which can be used to cancel the operation later with {@link #cancelCommand}. */ // This is an asynchronous call. - public Object setPlayerVolume(float volume) { + public @NonNull Object setPlayerVolume(float volume) { return addTask(new Task(CALL_COMPLETED_SET_PLAYER_VOLUME, false) { @Override void process() { @@ -1257,7 +1257,7 @@ public class MediaPlayer2 implements AutoCloseable * @return a token which can be used to cancel the operation later with {@link #cancelCommand}. */ // This is an asynchronous call. - public Object notifyWhenCommandLabelReached(@NonNull Object label) { + public @NonNull Object notifyWhenCommandLabelReached(@NonNull Object label) { return addTask(new Task(CALL_COMPLETED_NOTIFY_WHEN_COMMAND_LABEL_REACHED, false) { @Override void process() { @@ -1285,7 +1285,7 @@ public class MediaPlayer2 implements AutoCloseable * @param sh the SurfaceHolder to use for video display * @return a token which can be used to cancel the operation later with {@link #cancelCommand}. */ - public Object setDisplay(SurfaceHolder sh) { + public @NonNull Object setDisplay(@Nullable SurfaceHolder sh) { return addTask(new Task(CALL_COMPLETED_SET_DISPLAY, false) { @Override void process() { @@ -1321,7 +1321,7 @@ public class MediaPlayer2 implements AutoCloseable * @return a token which can be used to cancel the operation later with {@link #cancelCommand}. */ // This is an asynchronous call. - public Object setSurface(Surface surface) { + public @NonNull Object setSurface(@Nullable Surface surface) { return addTask(new Task(CALL_COMPLETED_SET_SURFACE, false) { @Override void process() { @@ -1355,7 +1355,7 @@ public class MediaPlayer2 implements AutoCloseable * @see android.os.PowerManager */ // This is an asynchronous call. - public Object setWakeLock(@NonNull PowerManager.WakeLock wakeLock) { + public @NonNull Object setWakeLock(@NonNull PowerManager.WakeLock wakeLock) { return addTask(new Task(CALL_COMPLETED_SET_WAKE_LOCK, false) { @Override void process() { @@ -1390,7 +1390,7 @@ public class MediaPlayer2 implements AutoCloseable * @return a token which can be used to cancel the operation later with {@link #cancelCommand}. */ // This is an asynchronous call. - public Object setScreenOnWhilePlaying(boolean screenOn) { + public @NonNull Object setScreenOnWhilePlaying(boolean screenOn) { return addTask(new Task(CALL_COMPLETED_SET_SCREEN_ON_WHILE_PLAYING, false) { @Override void process() { @@ -1466,7 +1466,7 @@ public class MediaPlayer2 implements AutoCloseable */ // This is a synchronous call. @Override - public boolean setPreferredDevice(AudioDeviceInfo deviceInfo) { + public boolean setPreferredDevice(@Nullable AudioDeviceInfo deviceInfo) { boolean status = native_setPreferredDevice(deviceInfo); if (status) { synchronized (this) { @@ -1483,7 +1483,7 @@ public class MediaPlayer2 implements AutoCloseable * is not guaranteed to correspond to the actual device being used for playback. */ @Override - public AudioDeviceInfo getPreferredDevice() { + public @Nullable AudioDeviceInfo getPreferredDevice() { synchronized (this) { return mPreferredDevice; } @@ -1496,7 +1496,7 @@ public class MediaPlayer2 implements AutoCloseable * selected device when the player was last active. */ @Override - public native AudioDeviceInfo getRoutedDevice(); + public @Nullable native AudioDeviceInfo getRoutedDevice(); /** * Adds an {@link AudioRouting.OnRoutingChangedListener} to receive notifications of routing @@ -1508,8 +1508,8 @@ public class MediaPlayer2 implements AutoCloseable */ // This is a synchronous call. @Override - public void addOnRoutingChangedListener(AudioRouting.OnRoutingChangedListener listener, - Handler handler) { + public void addOnRoutingChangedListener(@NonNull AudioRouting.OnRoutingChangedListener listener, + @Nullable Handler handler) { if (listener == null) { throw new IllegalArgumentException("addOnRoutingChangedListener: listener is NULL"); } @@ -1527,7 +1527,8 @@ public class MediaPlayer2 implements AutoCloseable */ // This is a synchronous call. @Override - public void removeOnRoutingChangedListener(AudioRouting.OnRoutingChangedListener listener) { + public void removeOnRoutingChangedListener( + @NonNull AudioRouting.OnRoutingChangedListener listener) { if (listener == null) { throw new IllegalArgumentException("removeOnRoutingChangedListener: listener is NULL"); } @@ -1547,7 +1548,7 @@ public class MediaPlayer2 implements AutoCloseable * notification {@code EventCallback.onVideoSizeChanged} when the size * is available. */ - public Size getVideoSize() { + public @NonNull Size getVideoSize() { return mVideoSize; } @@ -1560,7 +1561,7 @@ public class MediaPlayer2 implements AutoCloseable * * Additional vendor-specific fields may also be present in the return value. */ - public PersistableBundle getMetrics() { + public @Nullable PersistableBundle getMetrics() { PersistableBundle bundle = native_getMetrics(); return bundle; } @@ -1592,7 +1593,7 @@ public class MediaPlayer2 implements AutoCloseable */ // TODO: make it public when ready // This is an asynchronous call. - Object setBufferingParams(@NonNull BufferingParams params) { + @NonNull Object setBufferingParams(@NonNull BufferingParams params) { return addTask(new Task(CALL_COMPLETED_SET_BUFFERING_PARAMS, false) { @Override void process() { @@ -1614,7 +1615,7 @@ public class MediaPlayer2 implements AutoCloseable * @return a token which can be used to cancel the operation later with {@link #cancelCommand}. */ // This is an asynchronous call. - public Object setPlaybackParams(@NonNull PlaybackParams params) { + public @NonNull Object setPlaybackParams(@NonNull PlaybackParams params) { return addTask(new Task(CALL_COMPLETED_SET_PLAYBACK_PARAMS, false) { @Override void process() { @@ -1642,7 +1643,7 @@ public class MediaPlayer2 implements AutoCloseable * @return a token which can be used to cancel the operation later with {@link #cancelCommand}. */ // This is an asynchronous call. - public Object setSyncParams(@NonNull SyncParams params) { + public @NonNull Object setSyncParams(@NonNull SyncParams params) { return addTask(new Task(CALL_COMPLETED_SET_SYNC_PARAMS, false) { @Override void process() { @@ -1671,7 +1672,7 @@ public class MediaPlayer2 implements AutoCloseable * @return a token which can be used to cancel the operation later with {@link #cancelCommand}. */ // This is an asynchronous call. - public Object seekTo(long msec) { + public @NonNull Object seekTo(long msec) { return seekTo(msec, SEEK_PREVIOUS_SYNC /* mode */); } @@ -1745,7 +1746,7 @@ public class MediaPlayer2 implements AutoCloseable * @return a token which can be used to cancel the operation later with {@link #cancelCommand}. */ // This is an asynchronous call. - public Object seekTo(long msec, @SeekMode int mode) { + public @NonNull Object seekTo(long msec, @SeekMode int mode) { return addTask(new Task(CALL_COMPLETED_SEEK_TO, true) { @Override void process() { @@ -1846,7 +1847,7 @@ public class MediaPlayer2 implements AutoCloseable * @return a token which can be used to cancel the operation later with {@link #cancelCommand}. */ // This is an asynchronous call. - public Object setAudioSessionId(int sessionId) { + public @NonNull Object setAudioSessionId(int sessionId) { final AudioTrack dummyAudioTrack = new AudioTrack(AudioManager.STREAM_MUSIC, 44100, AudioFormat.CHANNEL_OUT_MONO, AudioFormat.ENCODING_PCM_16BIT, 2, AudioTrack.MODE_STATIC, sessionId); @@ -1887,7 +1888,7 @@ public class MediaPlayer2 implements AutoCloseable * @return a token which can be used to cancel the operation later with {@link #cancelCommand}. */ // This is an asynchronous call. - public Object attachAuxEffect(int effectId) { + public @NonNull Object attachAuxEffect(int effectId) { return addTask(new Task(CALL_COMPLETED_ATTACH_AUX_EFFECT, false) { @Override void process() { @@ -1912,7 +1913,7 @@ public class MediaPlayer2 implements AutoCloseable * @return a token which can be used to cancel the operation later with {@link #cancelCommand}. */ // This is an asynchronous call. - public Object setAuxEffectSendLevel(float level) { + public @NonNull Object setAuxEffectSendLevel(float level) { return addTask(new Task(CALL_COMPLETED_SET_AUX_EFFECT_SEND_LEVEL, false) { @Override void process() { @@ -1984,7 +1985,7 @@ public class MediaPlayer2 implements AutoCloseable * When the language is unknown or could not be determined, * ISO-639-2 language code, "und", is returned. */ - public String getLanguage() { + public @Nullable String getLanguage() { String language = mFormat.getString(MediaFormat.KEY_LANGUAGE); return language == null ? "und" : language; } @@ -1993,7 +1994,7 @@ public class MediaPlayer2 implements AutoCloseable * Gets the {@link MediaFormat} of the track. If the format is * unknown or could not be determined, null is returned. */ - public MediaFormat getFormat() { + public @Nullable MediaFormat getFormat() { if (mTrackType == MEDIA_TRACK_TYPE_TIMEDTEXT || mTrackType == MEDIA_TRACK_TYPE_SUBTITLE) { return mFormat; @@ -2201,7 +2202,7 @@ public class MediaPlayer2 implements AutoCloseable * @see MediaPlayer2#getTrackInfo() */ // This is an asynchronous call. - public Object selectTrack(int index) { + public @NonNull Object selectTrack(int index) { return selectTrack(getCurrentDataSource(), index); } @@ -2235,7 +2236,7 @@ public class MediaPlayer2 implements AutoCloseable * @see MediaPlayer2#getTrackInfo(DataSourceDesc) */ // This is an asynchronous call. - public Object selectTrack(@NonNull DataSourceDesc dsd, int index) { + public @NonNull Object selectTrack(@NonNull DataSourceDesc dsd, int index) { return addTask(new Task(CALL_COMPLETED_SELECT_TRACK, false) { @Override void process() { @@ -2257,7 +2258,7 @@ public class MediaPlayer2 implements AutoCloseable * @see MediaPlayer2#getTrackInfo() */ // This is an asynchronous call. - public Object deselectTrack(int index) { + public @NonNull Object deselectTrack(int index) { return deselectTrack(getCurrentDataSource(), index); } @@ -2277,7 +2278,7 @@ public class MediaPlayer2 implements AutoCloseable * @see MediaPlayer2#getTrackInfo(DataSourceDesc) */ // This is an asynchronous call. - public Object deselectTrack(@NonNull DataSourceDesc dsd, int index) { + public @NonNull Object deselectTrack(@NonNull DataSourceDesc dsd, int index) { return addTask(new Task(CALL_COMPLETED_DESELECT_TRACK, false) { @Override void process() { @@ -2928,7 +2929,7 @@ public class MediaPlayer2 implements AutoCloseable * @param eventCallback the callback to be unregistered */ // This is a synchronous call. - public void unregisterEventCallback(EventCallback eventCallback) { + public void unregisterEventCallback(@NonNull EventCallback eventCallback) { synchronized (mEventCbLock) { for (Pair<Executor, EventCallback> cb : mEventCallbackRecords) { if (cb.second == eventCallback) { @@ -3850,7 +3851,7 @@ public class MediaPlayer2 implements AutoCloseable */ // This is an asynchronous call. @TestApi - public Object prepareDrm(@NonNull DataSourceDesc dsd, @NonNull UUID uuid) { + public @NonNull Object prepareDrm(@NonNull DataSourceDesc dsd, @NonNull UUID uuid) { return addTask(newPrepareDrmTask(dsd, uuid)); } diff --git a/media/apex/java/android/media/UriDataSourceDesc.java b/media/apex/java/android/media/UriDataSourceDesc.java index 4eb9e8d3376f..c0b3c825323c 100644 --- a/media/apex/java/android/media/UriDataSourceDesc.java +++ b/media/apex/java/android/media/UriDataSourceDesc.java @@ -51,7 +51,7 @@ public class UriDataSourceDesc extends DataSourceDesc { * Return the Uri of this data source. * @return the Uri of this data source */ - public Uri getUri() { + public @NonNull Uri getUri() { return mUri; } @@ -59,7 +59,7 @@ public class UriDataSourceDesc extends DataSourceDesc { * Return the Uri headers of this data source. * @return the Uri headers of this data source */ - public Map<String, String> getHeaders() { + public @Nullable Map<String, String> getHeaders() { if (mHeader == null) { return null; } @@ -70,7 +70,7 @@ public class UriDataSourceDesc extends DataSourceDesc { * Return the Uri cookies of this data source. * @return the Uri cookies of this data source */ - public List<HttpCookie> getCookies() { + public @Nullable List<HttpCookie> getCookies() { if (mCookies == null) { return null; } @@ -81,7 +81,7 @@ public class UriDataSourceDesc extends DataSourceDesc { * Return the Context used for resolving the Uri of this data source. * @return the Context used for resolving the Uri of this data source */ - public Context getContext() { + public @NonNull Context getContext() { return mContext; } @@ -117,7 +117,7 @@ public class UriDataSourceDesc extends DataSourceDesc { * @param dsd the {@link UriDataSourceDesc} object whose data will be reused * in the new Builder. */ - public Builder(UriDataSourceDesc dsd) { + public Builder(@Nullable UriDataSourceDesc dsd) { super(dsd); if (dsd == null) { return; // use default @@ -136,6 +136,11 @@ public class UriDataSourceDesc extends DataSourceDesc { * @return a new {@link UriDataSourceDesc} object */ public @NonNull UriDataSourceDesc build() { + if (mUri == null || mContext == null) { + throw new IllegalStateException( + "Uri and Context should not be null"); + } + UriDataSourceDesc dsd = new UriDataSourceDesc(); super.build(dsd); dsd.mUri = mUri; diff --git a/media/java/android/media/AudioManager.java b/media/java/android/media/AudioManager.java index 15f9b47ede09..669baeadad65 100644 --- a/media/java/android/media/AudioManager.java +++ b/media/java/android/media/AudioManager.java @@ -4068,6 +4068,10 @@ public class AudioManager { /** * Indicate Hearing Aid connection state change and eventually suppress * the {@link AudioManager.ACTION_AUDIO_BECOMING_NOISY} intent. + * This operation is asynchronous but its execution will still be sequentially scheduled + * relative to calls to {@link #setBluetoothA2dpDeviceConnectionStateSuppressNoisyIntent( + * * BluetoothDevice, int, int, boolean, int)} and + * and {@link #handleBluetoothA2dpDeviceConfigChange(BluetoothDevice)}. * @param device Bluetooth device connected/disconnected * @param state new connection state (BluetoothProfile.STATE_xxx) * @param musicDevice Default get system volume for the connecting device. @@ -4075,27 +4079,27 @@ public class AudioManager { * {@link android.bluetooth.BluetoothProfile.HEARING_AID}) * @param suppressNoisyIntent if true the * {@link AudioManager.ACTION_AUDIO_BECOMING_NOISY} intent will not be sent. - * @return a delay in ms that the caller should wait before broadcasting - * BluetoothHearingAid.ACTION_CONNECTION_STATE_CHANGED intent. * {@hide} */ - public int setBluetoothHearingAidDeviceConnectionState( + public void setBluetoothHearingAidDeviceConnectionState( BluetoothDevice device, int state, boolean suppressNoisyIntent, int musicDevice) { final IAudioService service = getService(); - int delay = 0; try { - delay = service.setBluetoothHearingAidDeviceConnectionState(device, + service.setBluetoothHearingAidDeviceConnectionState(device, state, suppressNoisyIntent, musicDevice); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } - return delay; } /** * Indicate A2DP source or sink connection state change and eventually suppress * the {@link AudioManager.ACTION_AUDIO_BECOMING_NOISY} intent. + * This operation is asynchronous but its execution will still be sequentially scheduled + * relative to calls to {@link #setBluetoothHearingAidDeviceConnectionState(BluetoothDevice, + * int, boolean, int)} and + * {@link #handleBluetoothA2dpDeviceConfigChange(BluetoothDevice)}. * @param device Bluetooth device connected/disconnected * @param state new connection state, {@link BluetoothProfile#STATE_CONNECTED} * or {@link BluetoothProfile#STATE_DISCONNECTED} @@ -4105,26 +4109,27 @@ public class AudioManager { * {@link android.bluetooth.BluetoothProfile.A2DP_SINK}) * @param suppressNoisyIntent if true the * {@link AudioManager.ACTION_AUDIO_BECOMING_NOISY} intent will not be sent. - * @return a delay in ms that the caller should wait before broadcasting - * BluetoothA2dp.ACTION_CONNECTION_STATE_CHANGED intent. * {@hide} */ - public int setBluetoothA2dpDeviceConnectionStateSuppressNoisyIntent( + public void setBluetoothA2dpDeviceConnectionStateSuppressNoisyIntent( BluetoothDevice device, int state, int profile, boolean suppressNoisyIntent, int a2dpVolume) { final IAudioService service = getService(); - int delay = 0; try { - delay = service.setBluetoothA2dpDeviceConnectionStateSuppressNoisyIntent(device, + service.setBluetoothA2dpDeviceConnectionStateSuppressNoisyIntent(device, state, profile, suppressNoisyIntent, a2dpVolume); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } - return delay; } /** * Indicate A2DP device configuration has changed. + * This operation is asynchronous but its execution will still be sequentially scheduled + * relative to calls to + * {@link #setBluetoothA2dpDeviceConnectionStateSuppressNoisyIntent(BluetoothDevice, int, int, + * boolean, int)} and + * {@link #setBluetoothHearingAidDeviceConnectionState(BluetoothDevice, int, boolean, int)} * @param device Bluetooth device whose configuration has changed. * {@hide} */ diff --git a/media/java/android/media/HwAudioSource.java b/media/java/android/media/HwAudioSource.java index 8bdb8a63f470..d9be0a593e4b 100644 --- a/media/java/android/media/HwAudioSource.java +++ b/media/java/android/media/HwAudioSource.java @@ -165,7 +165,7 @@ public class HwAudioSource extends PlayerBase { * If the audio attributes are not set with {@link #setAudioAttributes(AudioAttributes)}, * attributes comprising {@link AudioAttributes#USAGE_MEDIA} will be used. */ - public static class Builder { + public static final class Builder { private AudioAttributes mAudioAttributes; private AudioDeviceInfo mAudioDeviceInfo; diff --git a/media/java/android/media/IAudioService.aidl b/media/java/android/media/IAudioService.aidl index 1b82fcc48bf8..02856678879e 100644 --- a/media/java/android/media/IAudioService.aidl +++ b/media/java/android/media/IAudioService.aidl @@ -228,10 +228,10 @@ interface IAudioService { oneway void playerHasOpPlayAudio(in int piid, in boolean hasOpPlayAudio); - int setBluetoothHearingAidDeviceConnectionState(in BluetoothDevice device, + void setBluetoothHearingAidDeviceConnectionState(in BluetoothDevice device, int state, boolean suppressNoisyIntent, int musicDevice); - int setBluetoothA2dpDeviceConnectionStateSuppressNoisyIntent(in BluetoothDevice device, + void setBluetoothA2dpDeviceConnectionStateSuppressNoisyIntent(in BluetoothDevice device, int state, int profile, boolean suppressNoisyIntent, int a2dpVolume); oneway void setFocusRequestResultFromExtPolicy(in AudioFocusInfo afi, int requestResult, diff --git a/media/java/android/media/MediaTimestamp.java b/media/java/android/media/MediaTimestamp.java index 03e454c1e962..da3362a019b9 100644 --- a/media/java/android/media/MediaTimestamp.java +++ b/media/java/android/media/MediaTimestamp.java @@ -134,7 +134,7 @@ public final class MediaTimestamp * @hide */ @SystemApi - public static class Builder { + public static final class Builder { long mMediaTimeUs; long mNanoTime; float mClockRate = 1.0f; diff --git a/media/java/android/media/SubtitleData.java b/media/java/android/media/SubtitleData.java index 852babe1ecea..31622a9d467c 100644 --- a/media/java/android/media/SubtitleData.java +++ b/media/java/android/media/SubtitleData.java @@ -155,7 +155,7 @@ public final class SubtitleData * @hide */ @SystemApi - public static class Builder { + public static final class Builder { private int mTrackIndex; private long mStartTimeUs; private long mDurationUs; diff --git a/media/java/android/media/TimedMetaData.java b/media/java/android/media/TimedMetaData.java index 2a8988855168..990760cf32ae 100644 --- a/media/java/android/media/TimedMetaData.java +++ b/media/java/android/media/TimedMetaData.java @@ -104,7 +104,7 @@ public final class TimedMetaData { * @hide */ @SystemApi - public static class Builder { + public static final class Builder { private long mTimestampUs; private byte[] mMetaData = new byte[0]; diff --git a/media/java/android/media/audiopolicy/AudioVolumeGroup.java b/media/java/android/media/audiopolicy/AudioVolumeGroup.java index 0b4ba937ad29..b60947f13c1f 100644 --- a/media/java/android/media/audiopolicy/AudioVolumeGroup.java +++ b/media/java/android/media/audiopolicy/AudioVolumeGroup.java @@ -77,7 +77,7 @@ public final class AudioVolumeGroup implements Parcelable { /** * @return List of {@link AudioAttributes} involved in this {@link AudioVolumeGroup}. */ - public List<AudioAttributes> getAudioAttributes() { + public @NonNull List<AudioAttributes> getAudioAttributes() { return Arrays.asList(mAudioAttributes); } diff --git a/media/java/android/media/audiopolicy/AudioVolumeGroups.java b/media/java/android/media/audiopolicy/AudioVolumeGroups.java index 301bec7a10c4..2e56f846e574 100644 --- a/media/java/android/media/audiopolicy/AudioVolumeGroups.java +++ b/media/java/android/media/audiopolicy/AudioVolumeGroups.java @@ -70,7 +70,7 @@ public final class AudioVolumeGroups implements Iterable<AudioVolumeGroup>, Parc * Returns an {@link Iterator} */ @Override - public Iterator<AudioVolumeGroup> iterator() { + public @NonNull Iterator<AudioVolumeGroup> iterator() { return mAudioVolumeGroupList.iterator(); } diff --git a/media/tests/MediaFrameworkTest/Android.mk b/media/tests/MediaFrameworkTest/Android.mk index fb473f0581c9..167d255af74c 100644 --- a/media/tests/MediaFrameworkTest/Android.mk +++ b/media/tests/MediaFrameworkTest/Android.mk @@ -9,7 +9,7 @@ LOCAL_JAVA_LIBRARIES := android.test.runner android.test.base LOCAL_STATIC_JAVA_LIBRARIES := \ mockito-target-minus-junit4 \ - android-support-test \ + androidx.test.rules \ android-ex-camera2 LOCAL_PACKAGE_NAME := mediaframeworktest diff --git a/media/tests/MediaFrameworkTest/AndroidManifest.xml b/media/tests/MediaFrameworkTest/AndroidManifest.xml index e50a3757d14f..fb2d630faaf6 100644 --- a/media/tests/MediaFrameworkTest/AndroidManifest.xml +++ b/media/tests/MediaFrameworkTest/AndroidManifest.xml @@ -86,7 +86,7 @@ android:label="MediaFramework integration tests InstrumentationRunner"> </instrumentation> - <instrumentation android:name="android.support.test.runner.AndroidJUnitRunner" + <instrumentation android:name="androidx.test.runner.AndroidJUnitRunner" android:targetPackage="com.android.mediaframeworktest" android:label="media framework tests"> </instrumentation> diff --git a/media/tests/MediaFrameworkTest/AndroidTest.xml b/media/tests/MediaFrameworkTest/AndroidTest.xml index 204959ff2749..132028ce98dc 100644 --- a/media/tests/MediaFrameworkTest/AndroidTest.xml +++ b/media/tests/MediaFrameworkTest/AndroidTest.xml @@ -21,7 +21,7 @@ <option name="test-tag" value="MediaFrameworkTest" /> <test class="com.android.tradefed.testtype.AndroidJUnitTest" > <option name="package" value="com.android.mediaframeworktest" /> - <option name="runner" value="android.support.test.runner.AndroidJUnitRunner" /> + <option name="runner" value="androidx.test.runner.AndroidJUnitRunner" /> <option name="hidden-api-checks" value="false"/> </test> </configuration> diff --git a/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/integration/CameraBinderTest.java b/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/integration/CameraBinderTest.java index d8c975f44c6a..87a59df19e8e 100644 --- a/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/integration/CameraBinderTest.java +++ b/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/integration/CameraBinderTest.java @@ -309,6 +309,10 @@ public class CameraBinderTest extends AndroidTestCase { Log.v(TAG, String.format("Camera %s has torch status changed to 0x%x", cameraId, status)); } + @Override + public void onCameraAccessPrioritiesChanged() { + Log.v(TAG, "Camera access permission change"); + } } /** diff --git a/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/unit/MediaFileTest.java b/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/unit/MediaFileTest.java index feac63d40710..701454c32e4b 100644 --- a/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/unit/MediaFileTest.java +++ b/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/unit/MediaFileTest.java @@ -28,7 +28,8 @@ import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; import android.mtp.MtpConstants; -import android.support.test.runner.AndroidJUnit4; + +import androidx.test.runner.AndroidJUnit4; import libcore.net.MimeUtils; diff --git a/packages/SystemUI/res/layout/screen_pinning_request_text_area.xml b/packages/SystemUI/res/layout/screen_pinning_request_text_area.xml index cdad94bd1b22..8dcddc28c3b7 100644 --- a/packages/SystemUI/res/layout/screen_pinning_request_text_area.xml +++ b/packages/SystemUI/res/layout/screen_pinning_request_text_area.xml @@ -31,7 +31,7 @@ android:paddingStart="48dp" android:paddingTop="43dp" android:text="@string/screen_pinning_title" - android:textColor="@color/screen_pinning_primary_text" + android:textColor="@android:color/white" android:textSize="24sp" /> <TextView @@ -43,7 +43,7 @@ android:paddingStart="48dp" android:paddingTop="12.6dp" android:text="@string/screen_pinning_description" - android:textColor="@color/screen_pinning_primary_text" + android:textColor="@android:color/white" android:textSize="16sp" /> <Button diff --git a/packages/SystemUI/res/values/internal.xml b/packages/SystemUI/res/values/internal.xml index e0d3cd23565f..930cfce65b61 100644 --- a/packages/SystemUI/res/values/internal.xml +++ b/packages/SystemUI/res/values/internal.xml @@ -18,6 +18,5 @@ <dimen name="status_bar_height">@*android:dimen/status_bar_height</dimen> <dimen name="navigation_bar_height">@*android:dimen/navigation_bar_height</dimen> <dimen name="navigation_bar_height_car_mode">@*android:dimen/navigation_bar_height_car_mode</dimen> - <color name="screen_pinning_primary_text">@*android:color/primary_text_default_material_light</color> </resources> diff --git a/proto/src/metrics_constants/metrics_constants.proto b/proto/src/metrics_constants/metrics_constants.proto index ab8ad0f45f9f..0a6e92371d6a 100644 --- a/proto/src/metrics_constants/metrics_constants.proto +++ b/proto/src/metrics_constants/metrics_constants.proto @@ -7075,6 +7075,9 @@ message MetricsEvent { // OPEN: Accessibility detail settings (android.settings.ACCESSIBILITY_DETAILS_SETTINGS intent) ACCESSIBILITY_DETAILS_SETTINGS = 1682; + // Open: Settings will show the conditional when Grayscale mode is on + SETTINGS_CONDITION_GRAYSCALE_MODE = 1683; + // ---- End Q Constants, all Q constants go above this line ---- // Add new aosp constants above this line. // END OF AOSP CONSTANTS diff --git a/services/core/java/com/android/server/am/SettingsToPropertiesMapper.java b/services/core/java/com/android/server/am/SettingsToPropertiesMapper.java index 894a704c5bba..5da1ce610079 100644 --- a/services/core/java/com/android/server/am/SettingsToPropertiesMapper.java +++ b/services/core/java/com/android/server/am/SettingsToPropertiesMapper.java @@ -78,11 +78,11 @@ public class SettingsToPropertiesMapper { // permission in the corresponding .te file your feature belongs to. @VisibleForTesting static final String[] sDeviceConfigScopes = new String[] { - DeviceConfig.ActivityManagerNativeBoot.NAMESPACE, - DeviceConfig.MediaNative.NAMESPACE, + DeviceConfig.NAMESPACE_ACTIVITY_MANAGER_NATIVE_BOOT, DeviceConfig.NAMESPACE_INPUT_NATIVE_BOOT, + DeviceConfig.NAMESPACE_MEDIA_NATIVE, DeviceConfig.NAMESPACE_NETD_NATIVE, - DeviceConfig.RuntimeNativeBoot.NAMESPACE, + DeviceConfig.NAMESPACE_RUNTIME_NATIVE_BOOT, DeviceConfig.RuntimeNative.NAMESPACE, }; diff --git a/services/core/java/com/android/server/audio/AudioDeviceBroker.java b/services/core/java/com/android/server/audio/AudioDeviceBroker.java index 9af57daa259b..451fd66d4327 100644 --- a/services/core/java/com/android/server/audio/AudioDeviceBroker.java +++ b/services/core/java/com/android/server/audio/AudioDeviceBroker.java @@ -201,51 +201,72 @@ import java.util.ArrayList; } } - /*package*/ int setBluetoothA2dpDeviceConnectionStateSuppressNoisyIntent( + private static final class BtDeviceConnectionInfo { + final @NonNull BluetoothDevice mDevice; + final @AudioService.BtProfileConnectionState int mState; + final int mProfile; + final boolean mSupprNoisy; + final int mVolume; + + BtDeviceConnectionInfo(@NonNull BluetoothDevice device, + @AudioService.BtProfileConnectionState int state, + int profile, boolean suppressNoisyIntent, int vol) { + mDevice = device; + mState = state; + mProfile = profile; + mSupprNoisy = suppressNoisyIntent; + mVolume = vol; + } + } + + /*package*/ void postBluetoothA2dpDeviceConnectionStateSuppressNoisyIntent( @NonNull BluetoothDevice device, @AudioService.BtProfileConnectionState int state, int profile, boolean suppressNoisyIntent, int a2dpVolume) { - AudioService.sDeviceLogger.log((new AudioEventLogger.StringEvent( - "setBluetoothA2dpDeviceConnectionStateSuppressNoisyIntent state=" + state - // only querying address as this is the only readily available field - // on the device - + " addr=" + device.getAddress() - + " prof=" + profile + " supprNoisy=" + suppressNoisyIntent - + " vol=" + a2dpVolume)).printLog(TAG)); - synchronized (mDeviceStateLock) { - if (mBrokerHandler.hasMessages(MSG_IL_SET_A2DP_SINK_CONNECTION_STATE, - new BtHelper.BluetoothA2dpDeviceInfo(device))) { - AudioService.sDeviceLogger.log(new AudioEventLogger.StringEvent( - "A2DP connection state ignored")); - return 0; - } - return mDeviceInventory.setBluetoothA2dpDeviceConnectionState( - device, state, profile, suppressNoisyIntent, - AudioSystem.DEVICE_NONE, a2dpVolume); - } + final BtDeviceConnectionInfo info = new BtDeviceConnectionInfo(device, state, profile, + suppressNoisyIntent, a2dpVolume); + + // TODO add a check to try to remove unprocessed messages for the same device (the old + // check didn't work), and make sure it doesn't conflict with config change message + sendLMsgNoDelay(MSG_L_A2DP_DEVICE_CONNECTION_CHANGE_EXT, SENDMSG_QUEUE, info); } /*package*/ int handleBluetoothA2dpActiveDeviceChange( @NonNull BluetoothDevice device, @AudioService.BtProfileConnectionState int state, int profile, boolean suppressNoisyIntent, int a2dpVolume) { + // FIXME method was added by @a8439e2 but never used, and now conflicts with async behavior + // of handleBluetoothA2dpDeviceConfigChange and + // setBluetoothA2dpDeviceConnectionStateSuppressNoisyIntent synchronized (mDeviceStateLock) { return mDeviceInventory.handleBluetoothA2dpActiveDeviceChange(device, state, profile, suppressNoisyIntent, a2dpVolume); } } - /*package*/ int setBluetoothHearingAidDeviceConnectionState( + private static final class HearingAidDeviceConnectionInfo { + final @NonNull BluetoothDevice mDevice; + final @AudioService.BtProfileConnectionState int mState; + final boolean mSupprNoisy; + final int mMusicDevice; + final @NonNull String mEventSource; + + HearingAidDeviceConnectionInfo(@NonNull BluetoothDevice device, + @AudioService.BtProfileConnectionState int state, + boolean suppressNoisyIntent, int musicDevice, @NonNull String eventSource) { + mDevice = device; + mState = state; + mSupprNoisy = suppressNoisyIntent; + mMusicDevice = musicDevice; + mEventSource = eventSource; + } + } + + /*package*/ void postBluetoothHearingAidDeviceConnectionState( @NonNull BluetoothDevice device, @AudioService.BtProfileConnectionState int state, boolean suppressNoisyIntent, int musicDevice, @NonNull String eventSource) { - AudioService.sDeviceLogger.log((new AudioEventLogger.StringEvent( - "setHearingAidDeviceConnectionState state=" + state - + " addr=" + device.getAddress() - + " supprNoisy=" + suppressNoisyIntent - + " src=" + eventSource)).printLog(TAG)); - synchronized (mDeviceStateLock) { - return mDeviceInventory.setBluetoothHearingAidDeviceConnectionState( - device, state, suppressNoisyIntent, musicDevice); - } + final HearingAidDeviceConnectionInfo info = new HearingAidDeviceConnectionInfo( + device, state, suppressNoisyIntent, musicDevice, eventSource); + sendLMsgNoDelay(MSG_L_HEARING_AID_DEVICE_CONNECTION_CHANGE_EXT, SENDMSG_QUEUE, info); } // never called by system components @@ -766,6 +787,35 @@ import java.util.ArrayList; mBtHelper.onHeadsetProfileConnected((BluetoothHeadset) msg.obj); } break; + case MSG_L_A2DP_DEVICE_CONNECTION_CHANGE_EXT: { + final BtDeviceConnectionInfo info = (BtDeviceConnectionInfo) msg.obj; + AudioService.sDeviceLogger.log((new AudioEventLogger.StringEvent( + "setBluetoothA2dpDeviceConnectionStateSuppressNoisyIntent " + + " state=" + info.mState + // only querying address as this is the only readily available + // field on the device + + " addr=" + info.mDevice.getAddress() + + " prof=" + info.mProfile + " supprNoisy=" + info.mSupprNoisy + + " vol=" + info.mVolume)).printLog(TAG)); + synchronized (mDeviceStateLock) { + mDeviceInventory.setBluetoothA2dpDeviceConnectionState( + info.mDevice, info.mState, info.mProfile, info.mSupprNoisy, + AudioSystem.DEVICE_NONE, info.mVolume); + } + } break; + case MSG_L_HEARING_AID_DEVICE_CONNECTION_CHANGE_EXT: { + final HearingAidDeviceConnectionInfo info = + (HearingAidDeviceConnectionInfo) msg.obj; + AudioService.sDeviceLogger.log((new AudioEventLogger.StringEvent( + "setHearingAidDeviceConnectionState state=" + info.mState + + " addr=" + info.mDevice.getAddress() + + " supprNoisy=" + info.mSupprNoisy + + " src=" + info.mEventSource)).printLog(TAG)); + synchronized (mDeviceStateLock) { + mDeviceInventory.setBluetoothHearingAidDeviceConnectionState( + info.mDevice, info.mState, info.mSupprNoisy, info.mMusicDevice); + } + } break; default: Log.wtf(TAG, "Invalid message " + msg.what); } @@ -809,6 +859,10 @@ import java.util.ArrayList; private static final int MSG_L_BT_SERVICE_CONNECTED_PROFILE_A2DP_SINK = 24; private static final int MSG_L_BT_SERVICE_CONNECTED_PROFILE_HEARING_AID = 25; private static final int MSG_L_BT_SERVICE_CONNECTED_PROFILE_HEADSET = 26; + // process external command to (dis)connect an A2DP device + private static final int MSG_L_A2DP_DEVICE_CONNECTION_CHANGE_EXT = 27; + // process external command to (dis)connect a hearing aid device + private static final int MSG_L_HEARING_AID_DEVICE_CONNECTION_CHANGE_EXT = 28; private static boolean isMessageHandledUnderWakelock(int msgId) { @@ -821,6 +875,8 @@ import java.util.ArrayList; case MSG_L_A2DP_DEVICE_CONFIG_CHANGE: case MSG_TOGGLE_HDMI: case MSG_L_A2DP_ACTIVE_DEVICE_CHANGE: + case MSG_L_A2DP_DEVICE_CONNECTION_CHANGE_EXT: + case MSG_L_HEARING_AID_DEVICE_CONNECTION_CHANGE_EXT: return true; default: return false; diff --git a/services/core/java/com/android/server/audio/AudioDeviceInventory.java b/services/core/java/com/android/server/audio/AudioDeviceInventory.java index 37f0496c0db3..41a3c9859f23 100644 --- a/services/core/java/com/android/server/audio/AudioDeviceInventory.java +++ b/services/core/java/com/android/server/audio/AudioDeviceInventory.java @@ -578,7 +578,7 @@ public final class AudioDeviceInventory { return mCurAudioRoutes; } - /*package*/ int setBluetoothA2dpDeviceConnectionState( + /*package*/ void setBluetoothA2dpDeviceConnectionState( @NonNull BluetoothDevice device, @AudioService.BtProfileConnectionState int state, int profile, boolean suppressNoisyIntent, int musicDevice, int a2dpVolume) { int delay; @@ -614,46 +614,50 @@ public final class AudioDeviceInventory { delay); } } - return delay; } /*package*/ int handleBluetoothA2dpActiveDeviceChange( @NonNull BluetoothDevice device, @AudioService.BtProfileConnectionState int state, int profile, boolean suppressNoisyIntent, int a2dpVolume) { - if (state == BluetoothProfile.STATE_DISCONNECTED) { - return setBluetoothA2dpDeviceConnectionState(device, state, profile, - suppressNoisyIntent, AudioSystem.DEVICE_NONE, a2dpVolume); - } - // state == BluetoothProfile.STATE_CONNECTED - synchronized (mConnectedDevices) { - for (int i = 0; i < mConnectedDevices.size(); i++) { - final DeviceInfo deviceInfo = mConnectedDevices.valueAt(i); - if (deviceInfo.mDeviceType != AudioSystem.DEVICE_OUT_BLUETOOTH_A2DP) { - continue; - } - // If A2DP device exists, this is either an active device change or - // device config change - final String existingDevicekey = mConnectedDevices.keyAt(i); - final String deviceName = device.getName(); - final String address = device.getAddress(); - final String newDeviceKey = DeviceInfo.makeDeviceListKey( - AudioSystem.DEVICE_OUT_BLUETOOTH_A2DP, address); - int a2dpCodec = mDeviceBroker.getA2dpCodec(device); - // Device not equal to existing device, active device change - if (!TextUtils.equals(existingDevicekey, newDeviceKey)) { - mConnectedDevices.remove(existingDevicekey); - mConnectedDevices.put(newDeviceKey, new DeviceInfo( - AudioSystem.DEVICE_OUT_BLUETOOTH_A2DP, deviceName, - address, a2dpCodec)); - mDeviceBroker.postA2dpActiveDeviceChange( - new BtHelper.BluetoothA2dpDeviceInfo( - device, a2dpVolume, a2dpCodec)); - return 0; - } else { - // Device config change for existing device - mDeviceBroker.postBluetoothA2dpDeviceConfigChange(device); - return 0; + // method was added by QC but never used, and now conflicts with async behavior of + // handleBluetoothA2dpDeviceConfigChange and + // setBluetoothA2dpDeviceConnectionStateSuppressNoisyIntent + if (false) { + if (state == BluetoothProfile.STATE_DISCONNECTED) { + setBluetoothA2dpDeviceConnectionState(device, state, profile, + suppressNoisyIntent, AudioSystem.DEVICE_NONE, a2dpVolume); + } + // state == BluetoothProfile.STATE_CONNECTED + synchronized (mConnectedDevices) { + for (int i = 0; i < mConnectedDevices.size(); i++) { + final DeviceInfo deviceInfo = mConnectedDevices.valueAt(i); + if (deviceInfo.mDeviceType != AudioSystem.DEVICE_OUT_BLUETOOTH_A2DP) { + continue; + } + // If A2DP device exists, this is either an active device change or + // device config change + final String existingDevicekey = mConnectedDevices.keyAt(i); + final String deviceName = device.getName(); + final String address = device.getAddress(); + final String newDeviceKey = DeviceInfo.makeDeviceListKey( + AudioSystem.DEVICE_OUT_BLUETOOTH_A2DP, address); + int a2dpCodec = mDeviceBroker.getA2dpCodec(device); + // Device not equal to existing device, active device change + if (!TextUtils.equals(existingDevicekey, newDeviceKey)) { + mConnectedDevices.remove(existingDevicekey); + mConnectedDevices.put(newDeviceKey, new DeviceInfo( + AudioSystem.DEVICE_OUT_BLUETOOTH_A2DP, deviceName, + address, a2dpCodec)); + mDeviceBroker.postA2dpActiveDeviceChange( + new BtHelper.BluetoothA2dpDeviceInfo( + device, a2dpVolume, a2dpCodec)); + return 0; + } else { + // Device config change for existing device + mDeviceBroker.postBluetoothA2dpDeviceConfigChange(device); + return 0; + } } } } diff --git a/services/core/java/com/android/server/audio/AudioService.java b/services/core/java/com/android/server/audio/AudioService.java index 6bd412bcd536..91d19def1766 100644 --- a/services/core/java/com/android/server/audio/AudioService.java +++ b/services/core/java/com/android/server/audio/AudioService.java @@ -4041,7 +4041,10 @@ public class AudioService extends IAudioService.Stub @Retention(RetentionPolicy.SOURCE) public @interface BtProfileConnectionState {} - public int setBluetoothHearingAidDeviceConnectionState( + /** + * See AudioManager.setBluetoothHearingAidDeviceConnectionState() + */ + public void setBluetoothHearingAidDeviceConnectionState( @NonNull BluetoothDevice device, @BtProfileConnectionState int state, boolean suppressNoisyIntent, int musicDevice) { @@ -4053,14 +4056,14 @@ public class AudioService extends IAudioService.Stub throw new IllegalArgumentException("Illegal BluetoothProfile state for device " + " (dis)connection, got " + state); } - return mDeviceBroker.setBluetoothHearingAidDeviceConnectionState( + mDeviceBroker.postBluetoothHearingAidDeviceConnectionState( device, state, suppressNoisyIntent, musicDevice, "AudioService"); } /** * See AudioManager.setBluetoothA2dpDeviceConnectionStateSuppressNoisyIntent() */ - public int setBluetoothA2dpDeviceConnectionStateSuppressNoisyIntent( + public void setBluetoothA2dpDeviceConnectionStateSuppressNoisyIntent( @NonNull BluetoothDevice device, @AudioService.BtProfileConnectionState int state, int profile, boolean suppressNoisyIntent, int a2dpVolume) { if (device == null) { @@ -4071,7 +4074,7 @@ public class AudioService extends IAudioService.Stub throw new IllegalArgumentException("Illegal BluetoothProfile state for device " + " (dis)connection, got " + state); } - return mDeviceBroker.setBluetoothA2dpDeviceConnectionStateSuppressNoisyIntent(device, state, + mDeviceBroker.postBluetoothA2dpDeviceConnectionStateSuppressNoisyIntent(device, state, profile, suppressNoisyIntent, a2dpVolume); } @@ -4094,6 +4097,9 @@ public class AudioService extends IAudioService.Stub public int handleBluetoothA2dpActiveDeviceChange( BluetoothDevice device, int state, int profile, boolean suppressNoisyIntent, int a2dpVolume) { + // FIXME method was added by @a8439e2 but never used, and now conflicts with async behavior + // of handleBluetoothA2dpDeviceConfigChange and + // setBluetoothA2dpDeviceConnectionStateSuppressNoisyIntent if (device == null) { throw new IllegalArgumentException("Illegal null device"); } diff --git a/services/core/java/com/android/server/audio/BtHelper.java b/services/core/java/com/android/server/audio/BtHelper.java index 58c1882abf6f..04073cb5f45c 100644 --- a/services/core/java/com/android/server/audio/BtHelper.java +++ b/services/core/java/com/android/server/audio/BtHelper.java @@ -426,7 +426,7 @@ public class BtHelper { final BluetoothDevice btDevice = deviceList.get(0); final @BluetoothProfile.BtProfileState int state = mHearingAid.getConnectionState(btDevice); - mDeviceBroker.setBluetoothHearingAidDeviceConnectionState( + mDeviceBroker.postBluetoothHearingAidDeviceConnectionState( btDevice, state, /*suppressNoisyIntent*/ false, /*musicDevice*/ android.media.AudioSystem.DEVICE_NONE, diff --git a/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java b/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java index f496e817bc6c..36251f52d985 100644 --- a/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java +++ b/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java @@ -172,7 +172,6 @@ import android.os.Handler; import android.os.IBinder; import android.os.Looper; import android.os.ParcelFileDescriptor; -import android.os.ParcelableException; import android.os.PersistableBundle; import android.os.PowerManager; import android.os.PowerManagerInternal; @@ -5338,9 +5337,14 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager { */ @Override public long getRequiredStrongAuthTimeout(ComponentName who, int userId, boolean parent) { - if (!mHasFeature || !mLockPatternUtils.hasSecureLockScreen()) { + if (!mHasFeature) { return DevicePolicyManager.DEFAULT_STRONG_AUTH_TIMEOUT_MS; } + if (!mLockPatternUtils.hasSecureLockScreen()) { + // No strong auth timeout on devices not supporting the + // {@link PackageManager#FEATURE_SECURE_LOCK_SCREEN} feature + return 0; + } enforceFullCrossUsersPermission(userId); synchronized (getLockObject()) { if (who != null) { diff --git a/services/tests/runtests.py b/services/tests/runtests.py index f19cc5d567ec..4c8b4bad8019 100755 --- a/services/tests/runtests.py +++ b/services/tests/runtests.py @@ -19,7 +19,7 @@ import subprocess import sys INSTRUMENTED_PACKAGE_RUNNER = ('com.android.frameworks.servicestests/' - 'android.support.test.runner.AndroidJUnitRunner') + 'androidx.test.runner.AndroidJUnitRunner') PACKAGE_WHITELIST = ( "com.android.server", diff --git a/startop/iorap/tests/Android.bp b/startop/iorap/tests/Android.bp index 5ac4a46b81f1..4359978f5814 100644 --- a/startop/iorap/tests/Android.bp +++ b/startop/iorap/tests/Android.bp @@ -29,7 +29,7 @@ java_library { // test android dependencies "platform-test-annotations", - "android-support-test", + "androidx.test.rules", // test framework dependencies "mockito-target-inline-minus-junit4", // "mockito-target-minus-junit4", diff --git a/startop/iorap/tests/AndroidManifest.xml b/startop/iorap/tests/AndroidManifest.xml index 99f4add6579f..b967e7207a3f 100644 --- a/startop/iorap/tests/AndroidManifest.xml +++ b/startop/iorap/tests/AndroidManifest.xml @@ -22,7 +22,7 @@ <!--suppress AndroidDomInspection --> <instrumentation - android:name="android.support.test.runner.AndroidJUnitRunner" + android:name="androidx.test.runner.AndroidJUnitRunner" android:targetPackage="com.google.android.startop.iorap.tests" /> <!-- diff --git a/startop/iorap/tests/AndroidTest.xml b/startop/iorap/tests/AndroidTest.xml index 919154d3e48a..bcd11033bed3 100644 --- a/startop/iorap/tests/AndroidTest.xml +++ b/startop/iorap/tests/AndroidTest.xml @@ -44,7 +44,7 @@ <test class="com.android.tradefed.testtype.AndroidJUnitTest" > <option name="package" value="com.google.android.startop.iorap.tests" /> - <option name="runner" value="android.support.test.runner.AndroidJUnitRunner" /> + <option name="runner" value="androidx.test.runner.AndroidJUnitRunner" /> </test> </configuration> diff --git a/startop/iorap/tests/src/com/google/android/startop/iorap/IIorapIntegrationTest.kt b/startop/iorap/tests/src/com/google/android/startop/iorap/IIorapIntegrationTest.kt index 16dcbe20f46a..b1e6194e0c92 100644 --- a/startop/iorap/tests/src/com/google/android/startop/iorap/IIorapIntegrationTest.kt +++ b/startop/iorap/tests/src/com/google/android/startop/iorap/IIorapIntegrationTest.kt @@ -14,12 +14,14 @@ package com.google.android.startop.iorap -import android.net.Uri import android.os.ServiceManager -import android.support.test.filters.MediumTest +import androidx.test.filters.MediumTest import org.junit.Test -import org.junit.Ignore -import org.mockito.Mockito.* +import org.mockito.Mockito.argThat +import org.mockito.Mockito.eq +import org.mockito.Mockito.inOrder +import org.mockito.Mockito.spy +import org.mockito.Mockito.timeout // @Ignore("Test is disabled until iorapd is added to init and there's selinux policies for it") @MediumTest @@ -27,7 +29,7 @@ class IIorapIntegrationTest { /** * @throws ServiceManager.ServiceNotFoundException if iorapd service could not be found */ - private val iorapService : IIorap by lazy { + private val iorapService: IIorap by lazy { // TODO: connect to 'iorapd.stub' which doesn't actually do any work other than reply. IIorap.Stub.asInterface(ServiceManager.getServiceOrThrow("iorapd")) @@ -39,7 +41,7 @@ class IIorapIntegrationTest { // A dummy binder stub implementation is required to use with mockito#spy. // Mockito overrides the methods at runtime and tracks how methods were invoked. - open class DummyTaskListener : ITaskListener.Stub() { + open class DummyTaskListener : ITaskListener.Stub() { // Note: make parameters nullable to avoid the kotlin IllegalStateExceptions // from using the mockito matchers (eq, argThat, etc). override fun onProgress(requestId: RequestId?, result: TaskResult?) { @@ -49,7 +51,7 @@ class IIorapIntegrationTest { } } - private fun testAnyMethod(func : (RequestId) -> Unit) { + private fun testAnyMethod(func: (RequestId) -> Unit) { val taskListener = spy(DummyTaskListener())!! try { @@ -68,14 +70,13 @@ class IIorapIntegrationTest { // The "stub" behavior of iorapd is that every request immediately gets a response of // BEGAN,ONGOING,COMPLETED - inOrder.verify(taskListener, timeout(100)). - onProgress(eq(requestId), argThat { it!!.state == TaskResult.STATE_BEGAN }) - inOrder.verify(taskListener, timeout(100)). - onProgress(eq(requestId), argThat { it!!.state == TaskResult.STATE_ONGOING }) - inOrder.verify(taskListener, timeout(100)). - onComplete(eq(requestId), argThat { it!!.state == TaskResult.STATE_COMPLETED }) + inOrder.verify(taskListener, timeout(100)) + .onProgress(eq(requestId), argThat { it!!.state == TaskResult.STATE_BEGAN }) + inOrder.verify(taskListener, timeout(100)) + .onProgress(eq(requestId), argThat { it!!.state == TaskResult.STATE_ONGOING }) + inOrder.verify(taskListener, timeout(100)) + .onComplete(eq(requestId), argThat { it!!.state == TaskResult.STATE_COMPLETED }) inOrder.verifyNoMoreInteractions() - } finally { // iorapService.setTaskListener(null) // FIXME: null is broken, C++ side sees a non-null object. @@ -96,7 +97,7 @@ class IIorapIntegrationTest { @Test fun testOnAppIntentEvent() { - testAnyMethod { requestId : RequestId -> + testAnyMethod { requestId: RequestId -> iorapService.onAppIntentEvent(requestId, AppIntentEvent.createDefaultIntentChanged( ActivityInfo("dont care", "dont care"), ActivityInfo("dont care 2", "dont care 2"))) @@ -105,7 +106,7 @@ class IIorapIntegrationTest { @Test fun testOnSystemServiceEvent() { - testAnyMethod { requestId : RequestId -> + testAnyMethod { requestId: RequestId -> iorapService.onSystemServiceEvent(requestId, SystemServiceEvent(SystemServiceEvent.TYPE_START)) } @@ -113,9 +114,9 @@ class IIorapIntegrationTest { @Test fun testOnSystemServiceUserEvent() { - testAnyMethod { requestId : RequestId -> + testAnyMethod { requestId: RequestId -> iorapService.onSystemServiceUserEvent(requestId, - SystemServiceUserEvent(SystemServiceUserEvent.TYPE_START_USER,0)) + SystemServiceUserEvent(SystemServiceUserEvent.TYPE_START_USER, 0)) } } } diff --git a/startop/iorap/tests/src/com/google/android/startop/iorap/ParcelablesTest.kt b/startop/iorap/tests/src/com/google/android/startop/iorap/ParcelablesTest.kt index 4abbb3e9f162..8fa0cde0f9cc 100644 --- a/startop/iorap/tests/src/com/google/android/startop/iorap/ParcelablesTest.kt +++ b/startop/iorap/tests/src/com/google/android/startop/iorap/ParcelablesTest.kt @@ -17,7 +17,7 @@ package com.google.android.startop.iorap import android.net.Uri import android.os.Parcel import android.os.Parcelable -import android.support.test.filters.SmallTest +import androidx.test.filters.SmallTest import org.junit.Test import org.junit.runner.RunWith import com.google.common.truth.Truth.assertThat @@ -29,7 +29,7 @@ import org.junit.runners.Parameterized */ @SmallTest @RunWith(Parameterized::class) -class ParcelablesTest<T : Parcelable>(private val inputData : InputData<T>) { +class ParcelablesTest<T : Parcelable>(private val inputData: InputData<T>) { companion object { private val initialRequestId = RequestId.nextValueForSequence()!! @@ -73,19 +73,19 @@ class ParcelablesTest<T : Parcelable>(private val inputData : InputData<T>) { TaskResult(TaskResult.STATE_ONGOING)) ) - private fun newActivityInfo() : ActivityInfo { + private fun newActivityInfo(): ActivityInfo { return ActivityInfo("some package", "some activity") } - private fun newActivityInfoOther() : ActivityInfo { + private fun newActivityInfoOther(): ActivityInfo { return ActivityInfo("some package 2", "some activity 2") } - private fun newUri() : Uri { + private fun newUri(): Uri { return Uri.parse("https://www.google.com") } - private fun cloneRequestId(requestId: RequestId) : RequestId { + private fun cloneRequestId(requestId: RequestId): RequestId { val constructor = requestId::class.java.declaredConstructors[0] constructor.isAccessible = true return constructor.newInstance(requestId.requestId) as RequestId @@ -108,7 +108,7 @@ class ParcelablesTest<T : Parcelable>(private val inputData : InputData<T>) { @Test fun testParcelRoundTrip() { // calling writeToParcel and then T::CREATOR.createFromParcel would return the same data. - val assertParcels = { it : T, data : InputData<T> -> + val assertParcels = { it: T, data: InputData<T> -> val parcel = Parcel.obtain() it.writeToParcel(parcel, 0) parcel.setDataPosition(0) // future reads will see all previous writes. @@ -121,7 +121,7 @@ class ParcelablesTest<T : Parcelable>(private val inputData : InputData<T>) { assertParcels(inputData.validOther, inputData) } - data class InputData<T : Parcelable>(val valid : T, val validCopy : T, val validOther : T) { + data class InputData<T : Parcelable>(val valid: T, val validCopy: T, val validOther: T) { val kls = valid.javaClass init { assertThat(valid).isNotSameAs(validCopy) @@ -130,8 +130,8 @@ class ParcelablesTest<T : Parcelable>(private val inputData : InputData<T>) { assertThat(validOther.javaClass).isEqualTo(valid.javaClass) } - fun createFromParcel(parcel : Parcel) : T { - val field = kls.getDeclaredField("CREATOR") + fun createFromParcel(parcel: Parcel): T { + val field = kls.getDeclaredField("CREATOR") val creator = field.get(null) as Parcelable.Creator<T> return creator.createFromParcel(parcel) diff --git a/startop/view_compiler/dex_builder_test/Android.bp b/startop/view_compiler/dex_builder_test/Android.bp index ac60e966fe43..22a3cfafbc44 100644 --- a/startop/view_compiler/dex_builder_test/Android.bp +++ b/startop/view_compiler/dex_builder_test/Android.bp @@ -43,7 +43,7 @@ android_test { sdk_version: "current", data: [":generate_dex_testcases", ":generate_compiled_layout1", ":generate_compiled_layout2"], static_libs: [ - "android-support-test", + "androidx.test.rules", "guava", ], manifest: "AndroidManifest.xml", diff --git a/startop/view_compiler/dex_builder_test/AndroidManifest.xml b/startop/view_compiler/dex_builder_test/AndroidManifest.xml index 6ac5fc5db345..b33566363286 100644 --- a/startop/view_compiler/dex_builder_test/AndroidManifest.xml +++ b/startop/view_compiler/dex_builder_test/AndroidManifest.xml @@ -22,7 +22,7 @@ <uses-library android:name="android.test.runner" /> </application> - <instrumentation android:name="android.support.test.runner.AndroidJUnitRunner" + <instrumentation android:name="androidx.test.runner.AndroidJUnitRunner" android:targetPackage="android.startop.test" android:label="DexBuilder Tests"/> diff --git a/startop/view_compiler/dex_builder_test/AndroidTest.xml b/startop/view_compiler/dex_builder_test/AndroidTest.xml index 92e2a718bcce..82509b960f24 100644 --- a/startop/view_compiler/dex_builder_test/AndroidTest.xml +++ b/startop/view_compiler/dex_builder_test/AndroidTest.xml @@ -31,6 +31,6 @@ <test class="com.android.tradefed.testtype.AndroidJUnitTest" > <option name="package" value="android.startop.test" /> - <option name="runner" value="android.support.test.runner.AndroidJUnitRunner" /> + <option name="runner" value="androidx.test.runner.AndroidJUnitRunner" /> </test> </configuration> diff --git a/startop/view_compiler/dex_builder_test/src/android/startop/test/DexBuilderTest.java b/startop/view_compiler/dex_builder_test/src/android/startop/test/DexBuilderTest.java index 42d4161ee81e..f7b1674894f5 100644 --- a/startop/view_compiler/dex_builder_test/src/android/startop/test/DexBuilderTest.java +++ b/startop/view_compiler/dex_builder_test/src/android/startop/test/DexBuilderTest.java @@ -14,18 +14,14 @@ package android.startop.test; -import android.content.Context; -import android.support.test.InstrumentationRegistry; -import com.google.common.io.ByteStreams; -import dalvik.system.InMemoryDexClassLoader; import dalvik.system.PathClassLoader; -import java.io.InputStream; -import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Method; -import java.nio.ByteBuffer; + import org.junit.Assert; import org.junit.Test; +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; + // Adding tests here requires changes in several other places. See README.md in // the view_compiler directory for more information. public class DexBuilderTest { diff --git a/startop/view_compiler/dex_builder_test/src/android/startop/test/LayoutCompilerTest.java b/startop/view_compiler/dex_builder_test/src/android/startop/test/LayoutCompilerTest.java index a3b1b6c11ac3..3dfb20c2e524 100644 --- a/startop/view_compiler/dex_builder_test/src/android/startop/test/LayoutCompilerTest.java +++ b/startop/view_compiler/dex_builder_test/src/android/startop/test/LayoutCompilerTest.java @@ -15,18 +15,15 @@ package android.startop.test; import android.content.Context; -import android.support.test.InstrumentationRegistry; -import android.view.View; -import com.google.common.io.ByteStreams; -import dalvik.system.InMemoryDexClassLoader; + +import androidx.test.InstrumentationRegistry; + import dalvik.system.PathClassLoader; -import java.io.InputStream; -import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Method; -import java.nio.ByteBuffer; -import org.junit.Assert; + import org.junit.Test; +import java.lang.reflect.Method; + // Adding tests here requires changes in several other places. See README.md in // the view_compiler directory for more information. public class LayoutCompilerTest { diff --git a/telephony/java/android/telephony/CallAttributes.java b/telephony/java/android/telephony/CallAttributes.java index 368f0c67e2b0..3a340053ace3 100644 --- a/telephony/java/android/telephony/CallAttributes.java +++ b/telephony/java/android/telephony/CallAttributes.java @@ -16,6 +16,7 @@ package android.telephony; +import android.annotation.NonNull; import android.annotation.SystemApi; import android.os.Parcel; import android.os.Parcelable; @@ -29,15 +30,15 @@ import java.util.Objects; * @hide */ @SystemApi -public class CallAttributes implements Parcelable { +public final class CallAttributes implements Parcelable { private PreciseCallState mPreciseCallState; @NetworkType private int mNetworkType; // TelephonyManager.NETWORK_TYPE_* ints private CallQuality mCallQuality; - public CallAttributes(PreciseCallState state, @NetworkType int networkType, - CallQuality callQuality) { + public CallAttributes(@NonNull PreciseCallState state, @NetworkType int networkType, + @NonNull CallQuality callQuality) { this.mPreciseCallState = state; this.mNetworkType = networkType; this.mCallQuality = callQuality; @@ -59,6 +60,7 @@ public class CallAttributes implements Parcelable { /** * Returns the {@link PreciseCallState} of the call. */ + @NonNull public PreciseCallState getPreciseCallState() { return mPreciseCallState; } @@ -96,6 +98,7 @@ public class CallAttributes implements Parcelable { /** * Returns the {#link CallQuality} of the call. */ + @NonNull public CallQuality getCallQuality() { return mCallQuality; } diff --git a/telephony/java/android/telephony/CarrierRestrictionRules.java b/telephony/java/android/telephony/CarrierRestrictionRules.java index 47ce632f98c5..78623e74277a 100644 --- a/telephony/java/android/telephony/CarrierRestrictionRules.java +++ b/telephony/java/android/telephony/CarrierRestrictionRules.java @@ -177,7 +177,8 @@ public final class CarrierRestrictionRules implements Parcelable { * @return a list of boolean with the same size as input, indicating if each * {@link CarrierIdentifier} is allowed or not. */ - public List<Boolean> isCarrierIdentifiersAllowed(@NonNull List<CarrierIdentifier> carrierIds) { + public @NonNull List<Boolean> areCarrierIdentifiersAllowed( + @NonNull List<CarrierIdentifier> carrierIds) { ArrayList<Boolean> result = new ArrayList<>(carrierIds.size()); // First calculate the result for each slot independently @@ -332,7 +333,7 @@ public final class CarrierRestrictionRules implements Parcelable { /** * Builder for a {@link CarrierRestrictionRules}. */ - public static class Builder { + public static final class Builder { private final CarrierRestrictionRules mRules; /** {@hide} */ @@ -341,14 +342,14 @@ public final class CarrierRestrictionRules implements Parcelable { } /** build command */ - public CarrierRestrictionRules build() { + public @NonNull CarrierRestrictionRules build() { return mRules; } /** * Indicate that all carriers are allowed. */ - public Builder setAllCarriersAllowed() { + public @NonNull Builder setAllCarriersAllowed() { mRules.mAllowedCarriers.clear(); mRules.mExcludedCarriers.clear(); mRules.mCarrierRestrictionDefault = CARRIER_RESTRICTION_DEFAULT_ALLOWED; @@ -360,7 +361,8 @@ public final class CarrierRestrictionRules implements Parcelable { * * @param allowedCarriers list of allowed carriers */ - public Builder setAllowedCarriers(List<CarrierIdentifier> allowedCarriers) { + public @NonNull Builder setAllowedCarriers( + @NonNull List<CarrierIdentifier> allowedCarriers) { mRules.mAllowedCarriers = new ArrayList<CarrierIdentifier>(allowedCarriers); return this; } @@ -370,7 +372,8 @@ public final class CarrierRestrictionRules implements Parcelable { * * @param excludedCarriers list of excluded carriers */ - public Builder setExcludedCarriers(List<CarrierIdentifier> excludedCarriers) { + public @NonNull Builder setExcludedCarriers( + @NonNull List<CarrierIdentifier> excludedCarriers) { mRules.mExcludedCarriers = new ArrayList<CarrierIdentifier>(excludedCarriers); return this; } @@ -380,7 +383,7 @@ public final class CarrierRestrictionRules implements Parcelable { * * @param carrierRestrictionDefault prioritized carrier list */ - public Builder setDefaultCarrierRestriction( + public @NonNull Builder setDefaultCarrierRestriction( @CarrierRestrictionDefault int carrierRestrictionDefault) { mRules.mCarrierRestrictionDefault = carrierRestrictionDefault; return this; @@ -391,7 +394,7 @@ public final class CarrierRestrictionRules implements Parcelable { * * @param multiSimPolicy multi SIM policy */ - public Builder setMultiSimPolicy(@MultiSimPolicy int multiSimPolicy) { + public @NonNull Builder setMultiSimPolicy(@MultiSimPolicy int multiSimPolicy) { mRules.mMultiSimPolicy = multiSimPolicy; return this; } diff --git a/telephony/java/android/telephony/data/ApnSetting.java b/telephony/java/android/telephony/data/ApnSetting.java index a4ed7750d417..9d072f008bed 100644 --- a/telephony/java/android/telephony/data/ApnSetting.java +++ b/telephony/java/android/telephony/data/ApnSetting.java @@ -19,7 +19,7 @@ import android.annotation.IntDef; import android.annotation.NonNull; import android.content.ContentValues; import android.database.Cursor; -import android.hardware.radio.V1_0.ApnTypes; +import android.hardware.radio.V1_4.ApnTypes; import android.net.Uri; import android.os.Parcel; import android.os.Parcelable; @@ -79,7 +79,7 @@ public class ApnSetting implements Parcelable { * APN type for all APNs. * @hide */ - public static final int TYPE_ALL = ApnTypes.ALL; + public static final int TYPE_ALL = ApnTypes.ALL | ApnTypes.MCX; /** APN type for default data traffic. */ public static final int TYPE_DEFAULT = ApnTypes.DEFAULT | ApnTypes.HIPRI; /** APN type for MMS traffic. */ @@ -103,6 +103,8 @@ public class ApnSetting implements Parcelable { * for access to carrier services in an emergency call situation. */ public static final int TYPE_EMERGENCY = ApnTypes.EMERGENCY; + /** APN type for MCX (Mission Critical Service) where X can be PTT/Video/Data */ + public static final int TYPE_MCX = ApnTypes.MCX; /** @hide */ @IntDef(flag = true, prefix = { "TYPE_" }, value = { @@ -115,7 +117,8 @@ public class ApnSetting implements Parcelable { TYPE_IMS, TYPE_CBS, TYPE_IA, - TYPE_EMERGENCY + TYPE_EMERGENCY, + TYPE_MCX }) @Retention(RetentionPolicy.SOURCE) public @interface ApnType {} @@ -206,6 +209,7 @@ public class ApnSetting implements Parcelable { APN_TYPE_STRING_MAP.put("cbs", TYPE_CBS); APN_TYPE_STRING_MAP.put("ia", TYPE_IA); APN_TYPE_STRING_MAP.put("emergency", TYPE_EMERGENCY); + APN_TYPE_STRING_MAP.put("mcx", TYPE_MCX); APN_TYPE_INT_MAP = new ArrayMap<Integer, String>(); APN_TYPE_INT_MAP.put(TYPE_DEFAULT, "default"); APN_TYPE_INT_MAP.put(TYPE_MMS, "mms"); @@ -217,6 +221,7 @@ public class ApnSetting implements Parcelable { APN_TYPE_INT_MAP.put(TYPE_CBS, "cbs"); APN_TYPE_INT_MAP.put(TYPE_IA, "ia"); APN_TYPE_INT_MAP.put(TYPE_EMERGENCY, "emergency"); + APN_TYPE_INT_MAP.put(TYPE_MCX, "mcx"); PROTOCOL_STRING_MAP = new ArrayMap<String, Integer>(); PROTOCOL_STRING_MAP.put("IP", PROTOCOL_IP); @@ -1833,7 +1838,7 @@ public class ApnSetting implements Parcelable { * {@link ApnSetting} built from this builder otherwise. */ public ApnSetting build() { - if ((mApnTypeBitmask & ApnTypes.ALL) == 0 || TextUtils.isEmpty(mApnName) + if ((mApnTypeBitmask & TYPE_ALL) == 0 || TextUtils.isEmpty(mApnName) || TextUtils.isEmpty(mEntryName)) { return null; } diff --git a/telephony/java/android/telephony/euicc/EuiccManager.java b/telephony/java/android/telephony/euicc/EuiccManager.java index ad343498f9e1..afbf46d8b7b1 100644 --- a/telephony/java/android/telephony/euicc/EuiccManager.java +++ b/telephony/java/android/telephony/euicc/EuiccManager.java @@ -17,6 +17,7 @@ package android.telephony.euicc; import android.Manifest; import android.annotation.IntDef; +import android.annotation.NonNull; import android.annotation.Nullable; import android.annotation.RequiresPermission; import android.annotation.SdkConstant; @@ -429,6 +430,7 @@ public class EuiccManager { * * @return an EuiccManager that uses the given card ID for all calls. */ + @NonNull public EuiccManager createForCardId(int cardId) { return new EuiccManager(mContext, cardId); } diff --git a/telephony/java/android/telephony/ims/ImsCallSessionListener.java b/telephony/java/android/telephony/ims/ImsCallSessionListener.java index 337375ac51c3..4519a575923c 100644 --- a/telephony/java/android/telephony/ims/ImsCallSessionListener.java +++ b/telephony/java/android/telephony/ims/ImsCallSessionListener.java @@ -16,6 +16,7 @@ package android.telephony.ims; +import android.annotation.NonNull; import android.annotation.SystemApi; import android.os.RemoteException; import android.telephony.CallQuality; @@ -619,7 +620,7 @@ public class ImsCallSessionListener { * * @param callQuality The new call quality */ - public void callQualityChanged(CallQuality callQuality) { + public void callQualityChanged(@NonNull CallQuality callQuality) { try { mListener.callQualityChanged(callQuality); } catch (RemoteException e) { diff --git a/telephony/java/com/android/internal/telephony/PhoneConstants.java b/telephony/java/com/android/internal/telephony/PhoneConstants.java index e87d28c6f9e9..d5061a32ba6d 100644 --- a/telephony/java/com/android/internal/telephony/PhoneConstants.java +++ b/telephony/java/com/android/internal/telephony/PhoneConstants.java @@ -141,6 +141,8 @@ public class PhoneConstants { /** APN type for Emergency PDN. This is not an IA apn, but is used * for access to carrier services in an emergency call situation. */ public static final String APN_TYPE_EMERGENCY = "emergency"; + /** APN type for Mission Critical Services */ + public static final String APN_TYPE_MCX = "mcx"; /** Array of all APN types */ public static final String[] APN_TYPES = {APN_TYPE_DEFAULT, APN_TYPE_MMS, @@ -151,7 +153,8 @@ public class PhoneConstants { APN_TYPE_IMS, APN_TYPE_CBS, APN_TYPE_IA, - APN_TYPE_EMERGENCY + APN_TYPE_EMERGENCY, + APN_TYPE_MCX }; public static final int RIL_CARD_MAX_APPS = 8; diff --git a/tests/ActivityManagerPerfTests/tests/Android.mk b/tests/ActivityManagerPerfTests/tests/Android.mk index f23a665dc5b2..e1f56b8ba55f 100644 --- a/tests/ActivityManagerPerfTests/tests/Android.mk +++ b/tests/ActivityManagerPerfTests/tests/Android.mk @@ -21,7 +21,7 @@ LOCAL_SRC_FILES := \ $(call all-java-files-under, src) LOCAL_STATIC_JAVA_LIBRARIES := \ - android-support-test \ + androidx.test.rules \ apct-perftests-utils \ ActivityManagerPerfTestsUtils diff --git a/tests/ActivityManagerPerfTests/tests/AndroidManifest.xml b/tests/ActivityManagerPerfTests/tests/AndroidManifest.xml index a1ab33a96248..04aef47419d0 100644 --- a/tests/ActivityManagerPerfTests/tests/AndroidManifest.xml +++ b/tests/ActivityManagerPerfTests/tests/AndroidManifest.xml @@ -25,6 +25,6 @@ <uses-library android:name="android.test.runner" /> </application> - <instrumentation android:name="android.support.test.runner.AndroidJUnitRunner" + <instrumentation android:name="androidx.test.runner.AndroidJUnitRunner" android:targetPackage="com.android.frameworks.perftests.amtests"/> </manifest> diff --git a/tests/ActivityManagerPerfTests/tests/AndroidTest.xml b/tests/ActivityManagerPerfTests/tests/AndroidTest.xml index ffb5404d7d94..76c40b2e3dc6 100644 --- a/tests/ActivityManagerPerfTests/tests/AndroidTest.xml +++ b/tests/ActivityManagerPerfTests/tests/AndroidTest.xml @@ -24,6 +24,6 @@ <option name="test-tag" value="ActivityManagerPerfTests"/> <test class="com.android.tradefed.testtype.AndroidJUnitTest"> <option name="package" value="com.android.frameworks.perftests.amtests"/> - <option name="runner" value="android.support.test.runner.AndroidJUnitRunner"/> + <option name="runner" value="androidx.test.runner.AndroidJUnitRunner"/> </test> </configuration>
\ No newline at end of file diff --git a/tests/ActivityManagerPerfTests/tests/src/com/android/frameworks/perftests/am/tests/BasePerfTest.java b/tests/ActivityManagerPerfTests/tests/src/com/android/frameworks/perftests/am/tests/BasePerfTest.java index 58fb136ae9b3..daff76f4f522 100644 --- a/tests/ActivityManagerPerfTests/tests/src/com/android/frameworks/perftests/am/tests/BasePerfTest.java +++ b/tests/ActivityManagerPerfTests/tests/src/com/android/frameworks/perftests/am/tests/BasePerfTest.java @@ -21,7 +21,8 @@ import android.content.Intent; import android.content.ServiceConnection; import android.perftests.utils.ManualBenchmarkState; import android.perftests.utils.PerfManualStatusReporter; -import android.support.test.InstrumentationRegistry; + +import androidx.test.InstrumentationRegistry; import com.android.frameworks.perftests.am.util.TargetPackageUtils; import com.android.frameworks.perftests.am.util.TimeReceiver; diff --git a/tests/ActivityManagerPerfTests/tests/src/com/android/frameworks/perftests/am/tests/BroadcastPerfTest.java b/tests/ActivityManagerPerfTests/tests/src/com/android/frameworks/perftests/am/tests/BroadcastPerfTest.java index f7dab03f10ee..bc528d4d4fb7 100644 --- a/tests/ActivityManagerPerfTests/tests/src/com/android/frameworks/perftests/am/tests/BroadcastPerfTest.java +++ b/tests/ActivityManagerPerfTests/tests/src/com/android/frameworks/perftests/am/tests/BroadcastPerfTest.java @@ -17,8 +17,9 @@ package com.android.frameworks.perftests.am.tests; import android.content.Intent; -import android.support.test.filters.LargeTest; -import android.support.test.runner.AndroidJUnit4; + +import androidx.test.filters.LargeTest; +import androidx.test.runner.AndroidJUnit4; import com.android.frameworks.perftests.am.util.Constants; diff --git a/tests/ActivityManagerPerfTests/tests/src/com/android/frameworks/perftests/am/tests/ContentProviderPerfTest.java b/tests/ActivityManagerPerfTests/tests/src/com/android/frameworks/perftests/am/tests/ContentProviderPerfTest.java index 3bf56ce8b085..8e8221954ad6 100644 --- a/tests/ActivityManagerPerfTests/tests/src/com/android/frameworks/perftests/am/tests/ContentProviderPerfTest.java +++ b/tests/ActivityManagerPerfTests/tests/src/com/android/frameworks/perftests/am/tests/ContentProviderPerfTest.java @@ -17,8 +17,9 @@ package com.android.frameworks.perftests.am.tests; import android.content.ContentProviderClient; -import android.support.test.filters.LargeTest; -import android.support.test.runner.AndroidJUnit4; + +import androidx.test.filters.LargeTest; +import androidx.test.runner.AndroidJUnit4; import com.android.frameworks.perftests.am.util.TargetPackageUtils; diff --git a/tests/ActivityManagerPerfTests/tests/src/com/android/frameworks/perftests/am/tests/ServiceBindPerfTest.java b/tests/ActivityManagerPerfTests/tests/src/com/android/frameworks/perftests/am/tests/ServiceBindPerfTest.java index e1263db61b8b..996c5a5c5584 100644 --- a/tests/ActivityManagerPerfTests/tests/src/com/android/frameworks/perftests/am/tests/ServiceBindPerfTest.java +++ b/tests/ActivityManagerPerfTests/tests/src/com/android/frameworks/perftests/am/tests/ServiceBindPerfTest.java @@ -21,8 +21,9 @@ import android.content.Context; import android.content.Intent; import android.content.ServiceConnection; import android.os.IBinder; -import android.support.test.filters.LargeTest; -import android.support.test.runner.AndroidJUnit4; + +import androidx.test.filters.LargeTest; +import androidx.test.runner.AndroidJUnit4; import com.android.frameworks.perftests.am.util.Constants; import com.android.frameworks.perftests.am.util.TargetPackageUtils; diff --git a/tests/ActivityManagerPerfTests/tests/src/com/android/frameworks/perftests/am/tests/ServiceStartPerfTest.java b/tests/ActivityManagerPerfTests/tests/src/com/android/frameworks/perftests/am/tests/ServiceStartPerfTest.java index f05f32382e53..ba2064005937 100644 --- a/tests/ActivityManagerPerfTests/tests/src/com/android/frameworks/perftests/am/tests/ServiceStartPerfTest.java +++ b/tests/ActivityManagerPerfTests/tests/src/com/android/frameworks/perftests/am/tests/ServiceStartPerfTest.java @@ -19,8 +19,9 @@ package com.android.frameworks.perftests.am.tests; import android.content.ComponentName; import android.content.Intent; import android.content.ServiceConnection; -import android.support.test.filters.LargeTest; -import android.support.test.runner.AndroidJUnit4; + +import androidx.test.filters.LargeTest; +import androidx.test.runner.AndroidJUnit4; import com.android.frameworks.perftests.am.util.Constants; import com.android.frameworks.perftests.am.util.TargetPackageUtils; diff --git a/tests/ActivityManagerPerfTests/utils/Android.mk b/tests/ActivityManagerPerfTests/utils/Android.mk index 60c94239d85f..7a7471dd6cd8 100644 --- a/tests/ActivityManagerPerfTests/utils/Android.mk +++ b/tests/ActivityManagerPerfTests/utils/Android.mk @@ -23,7 +23,7 @@ LOCAL_SRC_FILES := \ src/com/android/frameworks/perftests/am/util/ITimeReceiverCallback.aidl LOCAL_STATIC_JAVA_LIBRARIES := \ - android-support-test \ + androidx.test.rules \ junit \ ub-uiautomator diff --git a/tests/ActivityManagerPerfTests/utils/src/com/android/frameworks/perftests/am/util/Utils.java b/tests/ActivityManagerPerfTests/utils/src/com/android/frameworks/perftests/am/util/Utils.java index 67071d204eff..fc787bafa93a 100644 --- a/tests/ActivityManagerPerfTests/utils/src/com/android/frameworks/perftests/am/util/Utils.java +++ b/tests/ActivityManagerPerfTests/utils/src/com/android/frameworks/perftests/am/util/Utils.java @@ -19,10 +19,11 @@ package com.android.frameworks.perftests.am.util; import android.content.Intent; import android.os.RemoteException; import android.os.ResultReceiver; -import android.support.test.InstrumentationRegistry; import android.support.test.uiautomator.UiDevice; import android.util.Log; +import androidx.test.InstrumentationRegistry; + import java.io.IOException; public class Utils { diff --git a/tests/AppLaunch/Android.mk b/tests/AppLaunch/Android.mk index 1fb548b0edde..f50bca560f83 100644 --- a/tests/AppLaunch/Android.mk +++ b/tests/AppLaunch/Android.mk @@ -12,7 +12,7 @@ LOCAL_PRIVATE_PLATFORM_APIS := true LOCAL_CERTIFICATE := platform LOCAL_JAVA_LIBRARIES := android.test.base android.test.runner -LOCAL_STATIC_JAVA_LIBRARIES := android-support-test +LOCAL_STATIC_JAVA_LIBRARIES := androidx.test.rules LOCAL_COMPATIBILITY_SUITE := device-tests diff --git a/tests/AppLaunch/src/com/android/tests/applaunch/AppLaunch.java b/tests/AppLaunch/src/com/android/tests/applaunch/AppLaunch.java index 5ea8ff1c4861..9d7319f7d337 100644 --- a/tests/AppLaunch/src/com/android/tests/applaunch/AppLaunch.java +++ b/tests/AppLaunch/src/com/android/tests/applaunch/AppLaunch.java @@ -30,11 +30,12 @@ import android.os.Bundle; import android.os.ParcelFileDescriptor; import android.os.RemoteException; import android.os.UserHandle; -import android.support.test.rule.logging.AtraceLogger; import android.test.InstrumentationTestCase; import android.test.InstrumentationTestRunner; import android.util.Log; +import androidx.test.rule.logging.AtraceLogger; + import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.File; @@ -51,6 +52,7 @@ import java.util.LinkedHashMap; import java.util.List; import java.util.Map; import java.util.Set; + /** * This test is intended to measure the time it takes for the apps to start. * Names of the applications are passed in command line, and the diff --git a/tests/AppLaunchWear/Android.mk b/tests/AppLaunchWear/Android.mk index 6d083661324d..332b6808ace8 100644 --- a/tests/AppLaunchWear/Android.mk +++ b/tests/AppLaunchWear/Android.mk @@ -12,7 +12,7 @@ LOCAL_PRIVATE_PLATFORM_APIS := true LOCAL_CERTIFICATE := platform LOCAL_JAVA_LIBRARIES := android.test.base android.test.runner -LOCAL_STATIC_JAVA_LIBRARIES := android-support-test +LOCAL_STATIC_JAVA_LIBRARIES := androidx.test.rules LOCAL_COMPATIBILITY_SUITE := device-tests diff --git a/tests/AppLaunchWear/src/com/android/tests/applaunch/AppLaunch.java b/tests/AppLaunchWear/src/com/android/tests/applaunch/AppLaunch.java index d36d84e8f51d..97701c61011e 100644 --- a/tests/AppLaunchWear/src/com/android/tests/applaunch/AppLaunch.java +++ b/tests/AppLaunchWear/src/com/android/tests/applaunch/AppLaunch.java @@ -30,16 +30,16 @@ import android.os.Bundle; import android.os.ParcelFileDescriptor; import android.os.RemoteException; import android.os.UserHandle; -import android.support.test.rule.logging.AtraceLogger; import android.test.InstrumentationTestCase; import android.test.InstrumentationTestRunner; import android.util.Log; +import androidx.test.rule.logging.AtraceLogger; + import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.File; import java.io.FileInputStream; -import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; @@ -52,6 +52,7 @@ import java.util.LinkedHashMap; import java.util.List; import java.util.Map; import java.util.Set; + /** * This test is intended to measure the time it takes for the apps to start. * Names of the applications are passed in command line, and the diff --git a/tests/BackgroundDexOptServiceIntegrationTests/Android.mk b/tests/BackgroundDexOptServiceIntegrationTests/Android.mk index b10305d96fce..f47cf96446ba 100644 --- a/tests/BackgroundDexOptServiceIntegrationTests/Android.mk +++ b/tests/BackgroundDexOptServiceIntegrationTests/Android.mk @@ -24,7 +24,7 @@ LOCAL_MODULE_TAGS := tests LOCAL_SRC_FILES := $(call all-java-files-under, src) LOCAL_STATIC_JAVA_LIBRARIES := \ - android-support-test \ + androidx.test.rules \ LOCAL_PACKAGE_NAME := BackgroundDexOptServiceIntegrationTests LOCAL_PRIVATE_PLATFORM_APIS := true diff --git a/tests/BackgroundDexOptServiceIntegrationTests/AndroidManifest.xml b/tests/BackgroundDexOptServiceIntegrationTests/AndroidManifest.xml index afae155f88fe..aec9f77cf922 100644 --- a/tests/BackgroundDexOptServiceIntegrationTests/AndroidManifest.xml +++ b/tests/BackgroundDexOptServiceIntegrationTests/AndroidManifest.xml @@ -34,7 +34,7 @@ </application> <instrumentation - android:name="android.support.test.runner.AndroidJUnitRunner" + android:name="androidx.test.runner.AndroidJUnitRunner" android:targetPackage="com.android.frameworks.bgdexopttest" android:label="Integration test for BackgroundDexOptService" /> </manifest> diff --git a/tests/BackgroundDexOptServiceIntegrationTests/AndroidTest.xml b/tests/BackgroundDexOptServiceIntegrationTests/AndroidTest.xml index 9bb1e280b861..a532422a38d3 100644 --- a/tests/BackgroundDexOptServiceIntegrationTests/AndroidTest.xml +++ b/tests/BackgroundDexOptServiceIntegrationTests/AndroidTest.xml @@ -50,6 +50,6 @@ <option name="test-tag" value="BackgroundDexOptServiceIntegrationTests"/> <test class="com.android.tradefed.testtype.AndroidJUnitTest"> <option name="package" value="com.android.frameworks.bgdexopttest"/> - <option name="runner" value="android.support.test.runner.AndroidJUnitRunner"/> + <option name="runner" value="androidx.test.runner.AndroidJUnitRunner"/> </test> </configuration> diff --git a/tests/BackgroundDexOptServiceIntegrationTests/src/com/android/server/pm/BackgroundDexOptServiceIntegrationTests.java b/tests/BackgroundDexOptServiceIntegrationTests/src/com/android/server/pm/BackgroundDexOptServiceIntegrationTests.java index fd20f4a1fa77..7d826f7172da 100644 --- a/tests/BackgroundDexOptServiceIntegrationTests/src/com/android/server/pm/BackgroundDexOptServiceIntegrationTests.java +++ b/tests/BackgroundDexOptServiceIntegrationTests/src/com/android/server/pm/BackgroundDexOptServiceIntegrationTests.java @@ -17,17 +17,16 @@ package com.android.server.pm; import android.app.AlarmManager; -import android.app.UiAutomation; import android.content.Context; import android.os.Environment; import android.os.ParcelFileDescriptor; import android.os.SystemProperties; import android.os.storage.StorageManager; -import android.support.test.InstrumentationRegistry; import android.util.Log; +import androidx.test.InstrumentationRegistry; + import org.junit.After; -import org.junit.AfterClass; import org.junit.Assert; import org.junit.Before; import org.junit.BeforeClass; diff --git a/tests/Camera2Tests/CameraToo/tests/Android.mk b/tests/Camera2Tests/CameraToo/tests/Android.mk index eb8f6c306862..fe4dc42aa7d9 100644 --- a/tests/Camera2Tests/CameraToo/tests/Android.mk +++ b/tests/Camera2Tests/CameraToo/tests/Android.mk @@ -20,6 +20,6 @@ LOCAL_PACKAGE_NAME := CameraTooTests LOCAL_INSTRUMENTATION_FOR := CameraToo LOCAL_SDK_VERSION := current LOCAL_SRC_FILES := $(call all-java-files-under,src) -LOCAL_STATIC_JAVA_LIBRARIES := android-support-test mockito-target-minus-junit4 +LOCAL_STATIC_JAVA_LIBRARIES := androidx.test.rules mockito-target-minus-junit4 include $(BUILD_PACKAGE) diff --git a/tests/Camera2Tests/CameraToo/tests/AndroidManifest.xml b/tests/Camera2Tests/CameraToo/tests/AndroidManifest.xml index 30210bae5cd1..8d3574929ca8 100644 --- a/tests/Camera2Tests/CameraToo/tests/AndroidManifest.xml +++ b/tests/Camera2Tests/CameraToo/tests/AndroidManifest.xml @@ -23,7 +23,7 @@ <application android:label="CameraToo"> <uses-library android:name="android.test.runner" /> </application> - <instrumentation android:name="android.support.test.runner.AndroidJUnitRunner" + <instrumentation android:name="androidx.test.runner.AndroidJUnitRunner" android:targetPackage="com.example.android.camera2.cameratoo" android:label="CameraToo tests" /> </manifest> diff --git a/tests/Compatibility/Android.mk b/tests/Compatibility/Android.mk index 9c47a2610223..643f9ebd5f15 100644 --- a/tests/Compatibility/Android.mk +++ b/tests/Compatibility/Android.mk @@ -17,7 +17,7 @@ include $(CLEAR_VARS) # We only want this apk build for tests. LOCAL_MODULE_TAGS := tests -LOCAL_STATIC_JAVA_LIBRARIES := android-support-test +LOCAL_STATIC_JAVA_LIBRARIES := androidx.test.rules # Include all test java files. LOCAL_SRC_FILES := \ $(call all-java-files-under, src) diff --git a/tests/Compatibility/src/com/android/compatibilitytest/AppCompatibility.java b/tests/Compatibility/src/com/android/compatibilitytest/AppCompatibility.java index 95eb5c9e7770..d683ec746a61 100644 --- a/tests/Compatibility/src/com/android/compatibilitytest/AppCompatibility.java +++ b/tests/Compatibility/src/com/android/compatibilitytest/AppCompatibility.java @@ -33,10 +33,11 @@ import android.os.Bundle; import android.os.DropBoxManager; import android.os.RemoteException; import android.os.ServiceManager; -import android.support.test.InstrumentationRegistry; -import android.support.test.runner.AndroidJUnit4; import android.util.Log; +import androidx.test.InstrumentationRegistry; +import androidx.test.runner.AndroidJUnit4; + import org.junit.After; import org.junit.Assert; import org.junit.Before; diff --git a/tests/Compatibility/src/com/android/compatibilitytest/AppCompatibilityRunner.java b/tests/Compatibility/src/com/android/compatibilitytest/AppCompatibilityRunner.java index b61ec346f041..960ea4966958 100644 --- a/tests/Compatibility/src/com/android/compatibilitytest/AppCompatibilityRunner.java +++ b/tests/Compatibility/src/com/android/compatibilitytest/AppCompatibilityRunner.java @@ -16,7 +16,7 @@ package com.android.compatibilitytest; -import android.support.test.runner.AndroidJUnitRunner; +import androidx.test.runner.AndroidJUnitRunner; // empty subclass to maintain backwards compatibility on host-side harness public class AppCompatibilityRunner extends AndroidJUnitRunner {} diff --git a/tests/DynamicCodeLoggerIntegrationTests/Android.mk b/tests/DynamicCodeLoggerIntegrationTests/Android.mk index f324eb10a7b0..62c1ba89653c 100644 --- a/tests/DynamicCodeLoggerIntegrationTests/Android.mk +++ b/tests/DynamicCodeLoggerIntegrationTests/Android.mk @@ -67,7 +67,7 @@ LOCAL_CERTIFICATE := shared LOCAL_SRC_FILES := $(call all-java-files-under, src/com/android/server/pm) LOCAL_STATIC_JAVA_LIBRARIES := \ - android-support-test \ + androidx.test.rules \ truth-prebuilt \ # Include both versions of the .so if we have 2 arch diff --git a/tests/DynamicCodeLoggerIntegrationTests/AndroidManifest.xml b/tests/DynamicCodeLoggerIntegrationTests/AndroidManifest.xml index 4327da2db3dd..08fac300512b 100644 --- a/tests/DynamicCodeLoggerIntegrationTests/AndroidManifest.xml +++ b/tests/DynamicCodeLoggerIntegrationTests/AndroidManifest.xml @@ -29,7 +29,7 @@ </application> <instrumentation - android:name="android.support.test.runner.AndroidJUnitRunner" + android:name="androidx.test.runner.AndroidJUnitRunner" android:targetPackage="com.android.frameworks.dynamiccodeloggertest" android:label="Integration test for DynamicCodeLogger" /> </manifest> diff --git a/tests/DynamicCodeLoggerIntegrationTests/AndroidTest.xml b/tests/DynamicCodeLoggerIntegrationTests/AndroidTest.xml index f70b9c8cb357..f8a1ec90a78a 100644 --- a/tests/DynamicCodeLoggerIntegrationTests/AndroidTest.xml +++ b/tests/DynamicCodeLoggerIntegrationTests/AndroidTest.xml @@ -24,7 +24,7 @@ <test class="com.android.tradefed.testtype.AndroidJUnitTest"> <option name="package" value="com.android.frameworks.dynamiccodeloggertest"/> - <option name="runner" value="android.support.test.runner.AndroidJUnitRunner"/> + <option name="runner" value="androidx.test.runner.AndroidJUnitRunner"/> <option name="hidden-api-checks" value="false"/> </test> </configuration> diff --git a/tests/DynamicCodeLoggerIntegrationTests/src/com/android/server/pm/dex/DynamicCodeLoggerIntegrationTests.java b/tests/DynamicCodeLoggerIntegrationTests/src/com/android/server/pm/dex/DynamicCodeLoggerIntegrationTests.java index 4f9aeea5bdb4..db2f659c655b 100644 --- a/tests/DynamicCodeLoggerIntegrationTests/src/com/android/server/pm/dex/DynamicCodeLoggerIntegrationTests.java +++ b/tests/DynamicCodeLoggerIntegrationTests/src/com/android/server/pm/dex/DynamicCodeLoggerIntegrationTests.java @@ -24,11 +24,12 @@ import android.content.Context; import android.os.Build; import android.os.ParcelFileDescriptor; import android.os.SystemClock; -import android.support.test.InstrumentationRegistry; -import android.support.test.filters.LargeTest; import android.util.EventLog; import android.util.EventLog.Event; +import androidx.test.InstrumentationRegistry; +import androidx.test.filters.LargeTest; + import dalvik.system.DexClassLoader; import org.junit.Before; diff --git a/tests/FlickerTests/AndroidManifest.xml b/tests/FlickerTests/AndroidManifest.xml index ba6394008642..5b1a36b84cc4 100644 --- a/tests/FlickerTests/AndroidManifest.xml +++ b/tests/FlickerTests/AndroidManifest.xml @@ -29,7 +29,7 @@ <uses-library android:name="android.test.runner"/> </application> - <instrumentation android:name="android.support.test.runner.AndroidJUnitRunner" + <instrumentation android:name="androidx.test.runner.AndroidJUnitRunner" android:targetPackage="com.android.server.wm.flicker" android:label="WindowManager Flicker Tests"> </instrumentation> diff --git a/tests/FlickerTests/lib/Android.mk b/tests/FlickerTests/lib/Android.mk index 6a8dfe8b5d0a..e438822a6f32 100644 --- a/tests/FlickerTests/lib/Android.mk +++ b/tests/FlickerTests/lib/Android.mk @@ -24,7 +24,7 @@ LOCAL_CERTIFICATE := platform LOCAL_PRIVATE_PLATFORM_APIS := true LOCAL_SRC_FILES := $(call all-java-files-under, src) LOCAL_STATIC_JAVA_LIBRARIES := \ - ub-janktesthelper \ + androidx.test.janktesthelper \ cts-amwm-util \ platformprotosnano \ layersprotosnano \ @@ -41,7 +41,7 @@ LOCAL_SRC_FILES := src/com/android/server/wm/flicker/AutomationUtils.java \ src/com/android/server/wm/flicker/WindowUtils.java LOCAL_STATIC_JAVA_LIBRARIES := sysui-helper \ launcher-helper-lib \ - compatibility-device-util + compatibility-device-util-axt include $(BUILD_STATIC_JAVA_LIBRARY) diff --git a/tests/FlickerTests/lib/src/com/android/server/wm/flicker/AutomationUtils.java b/tests/FlickerTests/lib/src/com/android/server/wm/flicker/AutomationUtils.java index 6306f0e16375..e00a2474556c 100644 --- a/tests/FlickerTests/lib/src/com/android/server/wm/flicker/AutomationUtils.java +++ b/tests/FlickerTests/lib/src/com/android/server/wm/flicker/AutomationUtils.java @@ -30,7 +30,6 @@ import android.content.pm.PackageManager; import android.graphics.Point; import android.graphics.Rect; import android.os.RemoteException; -import android.support.test.InstrumentationRegistry; import android.support.test.launcherhelper.LauncherStrategyFactory; import android.support.test.uiautomator.By; import android.support.test.uiautomator.BySelector; @@ -43,6 +42,8 @@ import android.util.Rational; import android.view.View; import android.view.ViewConfiguration; +import androidx.test.InstrumentationRegistry; + /** * Collection of UI Automation helper functions. */ diff --git a/tests/FlickerTests/lib/src/com/android/server/wm/flicker/TransitionRunner.java b/tests/FlickerTests/lib/src/com/android/server/wm/flicker/TransitionRunner.java index f6e8192ee4c0..0a3fe3c00de2 100644 --- a/tests/FlickerTests/lib/src/com/android/server/wm/flicker/TransitionRunner.java +++ b/tests/FlickerTests/lib/src/com/android/server/wm/flicker/TransitionRunner.java @@ -18,9 +18,10 @@ package com.android.server.wm.flicker; import android.annotation.Nullable; import android.support.annotation.VisibleForTesting; -import android.support.test.InstrumentationRegistry; import android.util.Log; +import androidx.test.InstrumentationRegistry; + import com.android.server.wm.flicker.monitor.ITransitionMonitor; import com.android.server.wm.flicker.monitor.LayersTraceMonitor; import com.android.server.wm.flicker.monitor.ScreenRecorder; diff --git a/tests/FlickerTests/lib/src/com/android/server/wm/flicker/WindowUtils.java b/tests/FlickerTests/lib/src/com/android/server/wm/flicker/WindowUtils.java index 0da876173995..c54396f895e4 100644 --- a/tests/FlickerTests/lib/src/com/android/server/wm/flicker/WindowUtils.java +++ b/tests/FlickerTests/lib/src/com/android/server/wm/flicker/WindowUtils.java @@ -20,10 +20,11 @@ import android.content.Context; import android.content.res.Resources; import android.graphics.Point; import android.graphics.Rect; -import android.support.test.InstrumentationRegistry; import android.view.Surface; import android.view.WindowManager; +import androidx.test.InstrumentationRegistry; + /** * Helper functions to retrieve system window sizes and positions. */ diff --git a/tests/FlickerTests/lib/src/com/android/server/wm/flicker/monitor/WindowAnimationFrameStatsMonitor.java b/tests/FlickerTests/lib/src/com/android/server/wm/flicker/monitor/WindowAnimationFrameStatsMonitor.java index 717d187e1d4a..3f86f0d001d7 100644 --- a/tests/FlickerTests/lib/src/com/android/server/wm/flicker/monitor/WindowAnimationFrameStatsMonitor.java +++ b/tests/FlickerTests/lib/src/com/android/server/wm/flicker/monitor/WindowAnimationFrameStatsMonitor.java @@ -25,7 +25,7 @@ import android.view.FrameStats; /** * Monitors {@link android.view.WindowAnimationFrameStats} to detect janky frames. * - * Adapted from {@link android.support.test.jank.internal.WindowAnimationFrameStatsMonitorImpl} + * Adapted from {@link androidx.test.jank.internal.WindowAnimationFrameStatsMonitorImpl} * using the same threshold to determine jank. */ public class WindowAnimationFrameStatsMonitor implements ITransitionMonitor { diff --git a/tests/FlickerTests/lib/test/Android.mk b/tests/FlickerTests/lib/test/Android.mk index 0e3f58d8a8c9..5be89ba624e6 100644 --- a/tests/FlickerTests/lib/test/Android.mk +++ b/tests/FlickerTests/lib/test/Android.mk @@ -25,7 +25,7 @@ LOCAL_COMPATIBILITY_SUITE := tests LOCAL_SRC_FILES := $(call all-java-files-under, src) LOCAL_JAVA_LIBRARIES := android.test.runner LOCAL_STATIC_JAVA_LIBRARIES := \ - android-support-test \ + androidx.test.rules \ platform-test-annotations \ truth-prebuilt \ platformprotosnano \ diff --git a/tests/FlickerTests/lib/test/AndroidManifest.xml b/tests/FlickerTests/lib/test/AndroidManifest.xml index d30172d56c2c..6451a5710821 100644 --- a/tests/FlickerTests/lib/test/AndroidManifest.xml +++ b/tests/FlickerTests/lib/test/AndroidManifest.xml @@ -18,7 +18,7 @@ <uses-library android:name="android.test.runner"/> </application> - <instrumentation android:name="android.support.test.runner.AndroidJUnitRunner" + <instrumentation android:name="androidx.test.runner.AndroidJUnitRunner" android:targetPackage="com.android.server.wm.flicker" android:label="WindowManager Flicker Lib Test"> </instrumentation> diff --git a/tests/FlickerTests/lib/test/src/com/android/server/wm/flicker/LayersTraceTest.java b/tests/FlickerTests/lib/test/src/com/android/server/wm/flicker/LayersTraceTest.java index 42b2acace8c9..7d77126fd7d4 100644 --- a/tests/FlickerTests/lib/test/src/com/android/server/wm/flicker/LayersTraceTest.java +++ b/tests/FlickerTests/lib/test/src/com/android/server/wm/flicker/LayersTraceTest.java @@ -26,9 +26,10 @@ import static org.junit.Assert.fail; import android.content.Context; import android.graphics.Point; import android.graphics.Rect; -import android.support.test.InstrumentationRegistry; import android.view.WindowManager; +import androidx.test.InstrumentationRegistry; + import org.junit.Test; import java.util.List; diff --git a/tests/FlickerTests/lib/test/src/com/android/server/wm/flicker/TestFileUtils.java b/tests/FlickerTests/lib/test/src/com/android/server/wm/flicker/TestFileUtils.java index 5a24e6d91595..c46175c1a977 100644 --- a/tests/FlickerTests/lib/test/src/com/android/server/wm/flicker/TestFileUtils.java +++ b/tests/FlickerTests/lib/test/src/com/android/server/wm/flicker/TestFileUtils.java @@ -17,7 +17,8 @@ package com.android.server.wm.flicker; import android.content.Context; -import android.support.test.InstrumentationRegistry; + +import androidx.test.InstrumentationRegistry; import com.google.common.io.ByteStreams; diff --git a/tests/FlickerTests/lib/test/src/com/android/server/wm/flicker/monitor/WindowAnimationFrameStatsMonitorTest.java b/tests/FlickerTests/lib/test/src/com/android/server/wm/flicker/monitor/WindowAnimationFrameStatsMonitorTest.java index f7fa0d572de6..dd6fed04d3e6 100644 --- a/tests/FlickerTests/lib/test/src/com/android/server/wm/flicker/monitor/WindowAnimationFrameStatsMonitorTest.java +++ b/tests/FlickerTests/lib/test/src/com/android/server/wm/flicker/monitor/WindowAnimationFrameStatsMonitorTest.java @@ -18,9 +18,7 @@ package com.android.server.wm.flicker.monitor; import static com.android.server.wm.flicker.AutomationUtils.wakeUpAndGoToHomeScreen; -import static com.google.common.truth.Truth.assertThat; - -import android.support.test.InstrumentationRegistry; +import androidx.test.InstrumentationRegistry; import org.junit.Before; import org.junit.Ignore; diff --git a/tests/FlickerTests/src/com/android/server/wm/flicker/ChangeAppRotationTest.java b/tests/FlickerTests/src/com/android/server/wm/flicker/ChangeAppRotationTest.java index 34f4ebb89543..b6860cbd8d96 100644 --- a/tests/FlickerTests/src/com/android/server/wm/flicker/ChangeAppRotationTest.java +++ b/tests/FlickerTests/src/com/android/server/wm/flicker/ChangeAppRotationTest.java @@ -25,11 +25,12 @@ import static com.android.server.wm.flicker.WindowUtils.getStatusBarPosition; import static com.android.server.wm.flicker.WmTraceSubject.assertThat; import android.graphics.Rect; -import android.support.test.InstrumentationRegistry; -import android.support.test.filters.LargeTest; import android.util.Log; import android.view.Surface; +import androidx.test.InstrumentationRegistry; +import androidx.test.filters.LargeTest; + import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; diff --git a/tests/FlickerTests/src/com/android/server/wm/flicker/CloseImeWindowToAppTest.java b/tests/FlickerTests/src/com/android/server/wm/flicker/CloseImeWindowToAppTest.java index 2b62fcf196fb..6590b86f1499 100644 --- a/tests/FlickerTests/src/com/android/server/wm/flicker/CloseImeWindowToAppTest.java +++ b/tests/FlickerTests/src/com/android/server/wm/flicker/CloseImeWindowToAppTest.java @@ -20,9 +20,10 @@ import static com.android.server.wm.flicker.CommonTransitions.editTextLoseFocusT import static com.android.server.wm.flicker.WindowUtils.getDisplayBounds; import android.platform.helpers.IAppHelper; -import android.support.test.InstrumentationRegistry; -import android.support.test.filters.LargeTest; -import android.support.test.runner.AndroidJUnit4; + +import androidx.test.InstrumentationRegistry; +import androidx.test.filters.LargeTest; +import androidx.test.runner.AndroidJUnit4; import org.junit.Before; import org.junit.Test; diff --git a/tests/FlickerTests/src/com/android/server/wm/flicker/CloseImeWindowToHomeTest.java b/tests/FlickerTests/src/com/android/server/wm/flicker/CloseImeWindowToHomeTest.java index 42b161f8a604..4771b02000c0 100644 --- a/tests/FlickerTests/src/com/android/server/wm/flicker/CloseImeWindowToHomeTest.java +++ b/tests/FlickerTests/src/com/android/server/wm/flicker/CloseImeWindowToHomeTest.java @@ -20,9 +20,10 @@ import static com.android.server.wm.flicker.CommonTransitions.editTextLoseFocusT import static com.android.server.wm.flicker.WindowUtils.getDisplayBounds; import android.platform.helpers.IAppHelper; -import android.support.test.InstrumentationRegistry; -import android.support.test.filters.LargeTest; -import android.support.test.runner.AndroidJUnit4; + +import androidx.test.InstrumentationRegistry; +import androidx.test.filters.LargeTest; +import androidx.test.runner.AndroidJUnit4; import org.junit.Before; import org.junit.Test; diff --git a/tests/FlickerTests/src/com/android/server/wm/flicker/CommonTransitions.java b/tests/FlickerTests/src/com/android/server/wm/flicker/CommonTransitions.java index 92bb1ea0b58f..65888acc184b 100644 --- a/tests/FlickerTests/src/com/android/server/wm/flicker/CommonTransitions.java +++ b/tests/FlickerTests/src/com/android/server/wm/flicker/CommonTransitions.java @@ -30,7 +30,6 @@ import android.content.Context; import android.content.Intent; import android.os.RemoteException; import android.platform.helpers.IAppHelper; -import android.support.test.InstrumentationRegistry; import android.support.test.uiautomator.By; import android.support.test.uiautomator.UiDevice; import android.support.test.uiautomator.UiObject2; @@ -38,6 +37,8 @@ import android.support.test.uiautomator.Until; import android.util.Rational; import android.view.Surface; +import androidx.test.InstrumentationRegistry; + import com.android.server.wm.flicker.TransitionRunner.TransitionBuilder; /** diff --git a/tests/FlickerTests/src/com/android/server/wm/flicker/DebugTest.java b/tests/FlickerTests/src/com/android/server/wm/flicker/DebugTest.java index fec248c13818..61cca0d6b53f 100644 --- a/tests/FlickerTests/src/com/android/server/wm/flicker/DebugTest.java +++ b/tests/FlickerTests/src/com/android/server/wm/flicker/DebugTest.java @@ -17,12 +17,13 @@ package com.android.server.wm.flicker; import android.platform.helpers.IAppHelper; -import android.support.test.InstrumentationRegistry; -import android.support.test.runner.AndroidJUnit4; import android.support.test.uiautomator.UiDevice; import android.util.Rational; import android.view.Surface; +import androidx.test.InstrumentationRegistry; +import androidx.test.runner.AndroidJUnit4; + import org.junit.Ignore; import org.junit.Test; import org.junit.runner.RunWith; diff --git a/tests/FlickerTests/src/com/android/server/wm/flicker/FlickerTestBase.java b/tests/FlickerTests/src/com/android/server/wm/flicker/FlickerTestBase.java index 7061b23c069d..00e11c0cef41 100644 --- a/tests/FlickerTests/src/com/android/server/wm/flicker/FlickerTestBase.java +++ b/tests/FlickerTests/src/com/android/server/wm/flicker/FlickerTestBase.java @@ -21,10 +21,11 @@ import static com.android.server.wm.flicker.AutomationUtils.setDefaultWait; import static com.google.common.truth.Truth.assertWithMessage; import android.platform.helpers.IAppHelper; -import android.support.test.InstrumentationRegistry; import android.support.test.uiautomator.UiDevice; import android.util.Log; +import androidx.test.InstrumentationRegistry; + import com.android.server.wm.flicker.TransitionRunner.TransitionResult; import org.junit.After; diff --git a/tests/FlickerTests/src/com/android/server/wm/flicker/OpenAppColdTest.java b/tests/FlickerTests/src/com/android/server/wm/flicker/OpenAppColdTest.java index 7e713699c72e..7818c4e4ba50 100644 --- a/tests/FlickerTests/src/com/android/server/wm/flicker/OpenAppColdTest.java +++ b/tests/FlickerTests/src/com/android/server/wm/flicker/OpenAppColdTest.java @@ -20,9 +20,9 @@ import static com.android.server.wm.flicker.CommonTransitions.getOpenAppCold; import static com.android.server.wm.flicker.WindowUtils.getDisplayBounds; import static com.android.server.wm.flicker.WmTraceSubject.assertThat; -import android.support.test.InstrumentationRegistry; -import android.support.test.filters.LargeTest; -import android.support.test.runner.AndroidJUnit4; +import androidx.test.InstrumentationRegistry; +import androidx.test.filters.LargeTest; +import androidx.test.runner.AndroidJUnit4; import org.junit.Before; import org.junit.Test; diff --git a/tests/FlickerTests/src/com/android/server/wm/flicker/OpenAppToSplitScreenTest.java b/tests/FlickerTests/src/com/android/server/wm/flicker/OpenAppToSplitScreenTest.java index 745569aac7ab..63018ec1d9e7 100644 --- a/tests/FlickerTests/src/com/android/server/wm/flicker/OpenAppToSplitScreenTest.java +++ b/tests/FlickerTests/src/com/android/server/wm/flicker/OpenAppToSplitScreenTest.java @@ -19,9 +19,9 @@ package com.android.server.wm.flicker; import static com.android.server.wm.flicker.CommonTransitions.appToSplitScreen; import static com.android.server.wm.flicker.WindowUtils.getDisplayBounds; -import android.support.test.InstrumentationRegistry; -import android.support.test.filters.LargeTest; -import android.support.test.runner.AndroidJUnit4; +import androidx.test.InstrumentationRegistry; +import androidx.test.filters.LargeTest; +import androidx.test.runner.AndroidJUnit4; import org.junit.Before; import org.junit.Test; diff --git a/tests/FlickerTests/src/com/android/server/wm/flicker/OpenAppWarmTest.java b/tests/FlickerTests/src/com/android/server/wm/flicker/OpenAppWarmTest.java index de7639d43d3c..1aba93056c89 100644 --- a/tests/FlickerTests/src/com/android/server/wm/flicker/OpenAppWarmTest.java +++ b/tests/FlickerTests/src/com/android/server/wm/flicker/OpenAppWarmTest.java @@ -20,9 +20,9 @@ import static com.android.server.wm.flicker.CommonTransitions.openAppWarm; import static com.android.server.wm.flicker.WindowUtils.getDisplayBounds; import static com.android.server.wm.flicker.WmTraceSubject.assertThat; -import android.support.test.InstrumentationRegistry; -import android.support.test.filters.LargeTest; -import android.support.test.runner.AndroidJUnit4; +import androidx.test.InstrumentationRegistry; +import androidx.test.filters.LargeTest; +import androidx.test.runner.AndroidJUnit4; import org.junit.Before; import org.junit.Test; diff --git a/tests/FlickerTests/src/com/android/server/wm/flicker/OpenImeWindowTest.java b/tests/FlickerTests/src/com/android/server/wm/flicker/OpenImeWindowTest.java index 1bd519c8334e..a81fa8e6d123 100644 --- a/tests/FlickerTests/src/com/android/server/wm/flicker/OpenImeWindowTest.java +++ b/tests/FlickerTests/src/com/android/server/wm/flicker/OpenImeWindowTest.java @@ -19,8 +19,8 @@ package com.android.server.wm.flicker; import static com.android.server.wm.flicker.CommonTransitions.editTextSetFocus; import static com.android.server.wm.flicker.WindowUtils.getDisplayBounds; -import android.support.test.filters.LargeTest; -import android.support.test.runner.AndroidJUnit4; +import androidx.test.filters.LargeTest; +import androidx.test.runner.AndroidJUnit4; import org.junit.Before; import org.junit.Test; diff --git a/tests/FlickerTests/src/com/android/server/wm/flicker/ResizeSplitScreenTest.java b/tests/FlickerTests/src/com/android/server/wm/flicker/ResizeSplitScreenTest.java index 8a15cbdb7709..50dba81e53b7 100644 --- a/tests/FlickerTests/src/com/android/server/wm/flicker/ResizeSplitScreenTest.java +++ b/tests/FlickerTests/src/com/android/server/wm/flicker/ResizeSplitScreenTest.java @@ -25,11 +25,12 @@ import static com.google.common.truth.Truth.assertThat; import android.graphics.Rect; import android.platform.helpers.IAppHelper; -import android.support.test.InstrumentationRegistry; -import android.support.test.filters.LargeTest; -import android.support.test.runner.AndroidJUnit4; import android.util.Rational; +import androidx.test.InstrumentationRegistry; +import androidx.test.filters.LargeTest; +import androidx.test.runner.AndroidJUnit4; + import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; diff --git a/tests/FlickerTests/src/com/android/server/wm/flicker/SeamlessAppRotationTest.java b/tests/FlickerTests/src/com/android/server/wm/flicker/SeamlessAppRotationTest.java index 3eab68d1272f..117ac5a8fadf 100644 --- a/tests/FlickerTests/src/com/android/server/wm/flicker/SeamlessAppRotationTest.java +++ b/tests/FlickerTests/src/com/android/server/wm/flicker/SeamlessAppRotationTest.java @@ -27,10 +27,11 @@ import static com.android.server.wm.flicker.testapp.ActivityOptions.SEAMLESS_ACT import android.content.Intent; import android.graphics.Rect; -import android.support.test.InstrumentationRegistry; -import android.support.test.filters.LargeTest; import android.view.Surface; +import androidx.test.InstrumentationRegistry; +import androidx.test.filters.LargeTest; + import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; diff --git a/tests/FlickerTests/src/com/android/server/wm/flicker/SplitScreenToLauncherTest.java b/tests/FlickerTests/src/com/android/server/wm/flicker/SplitScreenToLauncherTest.java index 40bd4e962153..1d30df9750b2 100644 --- a/tests/FlickerTests/src/com/android/server/wm/flicker/SplitScreenToLauncherTest.java +++ b/tests/FlickerTests/src/com/android/server/wm/flicker/SplitScreenToLauncherTest.java @@ -19,10 +19,10 @@ package com.android.server.wm.flicker; import static com.android.server.wm.flicker.CommonTransitions.splitScreenToLauncher; import static com.android.server.wm.flicker.WindowUtils.getDisplayBounds; -import android.support.test.InstrumentationRegistry; -import android.support.test.filters.FlakyTest; -import android.support.test.filters.LargeTest; -import android.support.test.runner.AndroidJUnit4; +import androidx.test.InstrumentationRegistry; +import androidx.test.filters.FlakyTest; +import androidx.test.filters.LargeTest; +import androidx.test.runner.AndroidJUnit4; import org.junit.Before; import org.junit.Test; diff --git a/tests/Internal/Android.mk b/tests/Internal/Android.mk index da566967fbeb..2e26ef103794 100644 --- a/tests/Internal/Android.mk +++ b/tests/Internal/Android.mk @@ -11,7 +11,7 @@ LOCAL_SRC_FILES := $(call all-java-files-under, src) LOCAL_JAVA_LIBRARIES := android.test.runner LOCAL_STATIC_JAVA_LIBRARIES := junit \ - android-support-test \ + androidx.test.rules \ mockito-target-minus-junit4 LOCAL_JAVA_RESOURCE_DIRS := res diff --git a/tests/Internal/AndroidManifest.xml b/tests/Internal/AndroidManifest.xml index e5a56949fe4e..c85c3b12504a 100644 --- a/tests/Internal/AndroidManifest.xml +++ b/tests/Internal/AndroidManifest.xml @@ -38,7 +38,7 @@ </service> </application> - <instrumentation android:name="android.support.test.runner.AndroidJUnitRunner" + <instrumentation android:name="androidx.test.runner.AndroidJUnitRunner" android:targetPackage="com.android.internal.tests" android:label="Internal Tests" /> </manifest> diff --git a/tests/Internal/AndroidTest.xml b/tests/Internal/AndroidTest.xml index 6531c9355e3d..7b67e9ebcced 100644 --- a/tests/Internal/AndroidTest.xml +++ b/tests/Internal/AndroidTest.xml @@ -24,6 +24,6 @@ <option name="test-tag" value="InternalTests" /> <test class="com.android.tradefed.testtype.AndroidJUnitTest" > <option name="package" value="com.android.internal.tests" /> - <option name="runner" value="android.support.test.runner.AndroidJUnitRunner" /> + <option name="runner" value="androidx.test.runner.AndroidJUnitRunner" /> </test> </configuration>
\ No newline at end of file diff --git a/tests/Internal/src/android/app/WallpaperColorsTest.java b/tests/Internal/src/android/app/WallpaperColorsTest.java index 881f6284413f..65ff6eb1ba04 100644 --- a/tests/Internal/src/android/app/WallpaperColorsTest.java +++ b/tests/Internal/src/android/app/WallpaperColorsTest.java @@ -20,8 +20,9 @@ import android.graphics.Bitmap; import android.graphics.Canvas; import android.graphics.Color; import android.graphics.Paint; -import android.support.test.filters.SmallTest; -import android.support.test.runner.AndroidJUnit4; + +import androidx.test.filters.SmallTest; +import androidx.test.runner.AndroidJUnit4; import org.junit.Assert; import org.junit.Test; diff --git a/tests/Internal/src/android/app/WallpaperInfoTest.java b/tests/Internal/src/android/app/WallpaperInfoTest.java index 7f06f2cb7aeb..476b99155672 100644 --- a/tests/Internal/src/android/app/WallpaperInfoTest.java +++ b/tests/Internal/src/android/app/WallpaperInfoTest.java @@ -26,9 +26,10 @@ import android.content.pm.ResolveInfo; import android.net.Uri; import android.os.Parcel; import android.service.wallpaper.WallpaperService; -import android.support.test.InstrumentationRegistry; -import android.support.test.filters.SmallTest; -import android.support.test.runner.AndroidJUnit4; + +import androidx.test.InstrumentationRegistry; +import androidx.test.filters.SmallTest; +import androidx.test.runner.AndroidJUnit4; import org.junit.Test; import org.junit.runner.RunWith; diff --git a/tests/Internal/src/android/service/wallpaper/WallpaperServiceTest.java b/tests/Internal/src/android/service/wallpaper/WallpaperServiceTest.java index b9e282ebdfef..592aa3ac4a6b 100644 --- a/tests/Internal/src/android/service/wallpaper/WallpaperServiceTest.java +++ b/tests/Internal/src/android/service/wallpaper/WallpaperServiceTest.java @@ -20,7 +20,7 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; -import android.support.test.filters.SmallTest; +import androidx.test.filters.SmallTest; import org.junit.Test; import org.junit.runner.RunWith; diff --git a/tests/Internal/src/com/android/internal/colorextraction/ColorExtractorTest.java b/tests/Internal/src/com/android/internal/colorextraction/ColorExtractorTest.java index 39608a40b416..17fa93135c7d 100644 --- a/tests/Internal/src/com/android/internal/colorextraction/ColorExtractorTest.java +++ b/tests/Internal/src/com/android/internal/colorextraction/ColorExtractorTest.java @@ -27,9 +27,10 @@ import android.app.WallpaperColors; import android.app.WallpaperManager; import android.content.Context; import android.graphics.Color; -import android.support.test.InstrumentationRegistry; -import android.support.test.filters.SmallTest; -import android.support.test.runner.AndroidJUnit4; + +import androidx.test.InstrumentationRegistry; +import androidx.test.filters.SmallTest; +import androidx.test.runner.AndroidJUnit4; import com.android.internal.colorextraction.ColorExtractor.GradientColors; import com.android.internal.colorextraction.types.ExtractionType; diff --git a/tests/Internal/src/com/android/internal/colorextraction/types/TonalTest.java b/tests/Internal/src/com/android/internal/colorextraction/types/TonalTest.java index a7d5ae8f69a3..d92cfce0379b 100644 --- a/tests/Internal/src/com/android/internal/colorextraction/types/TonalTest.java +++ b/tests/Internal/src/com/android/internal/colorextraction/types/TonalTest.java @@ -20,11 +20,12 @@ import static org.junit.Assert.assertTrue; import android.app.WallpaperColors; import android.graphics.Color; -import android.support.test.InstrumentationRegistry; -import android.support.test.filters.SmallTest; -import android.support.test.runner.AndroidJUnit4; import android.util.Range; +import androidx.test.InstrumentationRegistry; +import androidx.test.filters.SmallTest; +import androidx.test.runner.AndroidJUnit4; + import com.android.internal.colorextraction.ColorExtractor.GradientColors; import com.android.internal.graphics.ColorUtils; diff --git a/tests/Internal/src/com/android/internal/graphics/ColorUtilsTest.java b/tests/Internal/src/com/android/internal/graphics/ColorUtilsTest.java index 73df9a09ea75..d0bb8e3745bc 100644 --- a/tests/Internal/src/com/android/internal/graphics/ColorUtilsTest.java +++ b/tests/Internal/src/com/android/internal/graphics/ColorUtilsTest.java @@ -16,12 +16,13 @@ package com.android.internal.graphics; +import static org.junit.Assert.assertTrue; + import android.graphics.Color; -import android.support.test.filters.SmallTest; -import org.junit.Test; +import androidx.test.filters.SmallTest; -import static org.junit.Assert.assertTrue; +import org.junit.Test; @SmallTest public class ColorUtilsTest { diff --git a/tests/Internal/src/com/android/internal/ml/clustering/KMeansTest.java b/tests/Internal/src/com/android/internal/ml/clustering/KMeansTest.java index a64f8a60d485..540a1ec2bd5a 100644 --- a/tests/Internal/src/com/android/internal/ml/clustering/KMeansTest.java +++ b/tests/Internal/src/com/android/internal/ml/clustering/KMeansTest.java @@ -20,8 +20,9 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; import android.annotation.SuppressLint; -import android.support.test.filters.SmallTest; -import android.support.test.runner.AndroidJUnit4; + +import androidx.test.filters.SmallTest; +import androidx.test.runner.AndroidJUnit4; import org.junit.Assert; import org.junit.Before; diff --git a/tests/PackageWatchdog/Android.mk b/tests/PackageWatchdog/Android.mk index 1c1c2a426d15..1e4aacce1613 100644 --- a/tests/PackageWatchdog/Android.mk +++ b/tests/PackageWatchdog/Android.mk @@ -22,7 +22,7 @@ LOCAL_MODULE_TAGS := tests LOCAL_STATIC_JAVA_LIBRARIES := \ junit \ frameworks-base-testutils \ - android-support-test \ + androidx.test.rules \ services.core LOCAL_JAVA_LIBRARIES := \ diff --git a/tests/PackageWatchdog/AndroidManifest.xml b/tests/PackageWatchdog/AndroidManifest.xml index fa89528403c3..540edb41f66f 100644 --- a/tests/PackageWatchdog/AndroidManifest.xml +++ b/tests/PackageWatchdog/AndroidManifest.xml @@ -22,7 +22,7 @@ </application> - <instrumentation android:name="android.support.test.runner.AndroidJUnitRunner" + <instrumentation android:name="androidx.test.runner.AndroidJUnitRunner" android:targetPackage="com.android.tests.packagewatchdog" android:label="PackageWatchdog Test"/> </manifest> diff --git a/tests/PackageWatchdog/src/com/android/server/PackageWatchdogTest.java b/tests/PackageWatchdog/src/com/android/server/PackageWatchdogTest.java index 77cd62e4cbd3..598f60ad7c8d 100644 --- a/tests/PackageWatchdog/src/com/android/server/PackageWatchdogTest.java +++ b/tests/PackageWatchdog/src/com/android/server/PackageWatchdogTest.java @@ -24,7 +24,8 @@ import static org.junit.Assert.assertTrue; import android.content.pm.VersionedPackage; import android.os.test.TestLooper; -import android.support.test.InstrumentationRegistry; + +import androidx.test.InstrumentationRegistry; import com.android.server.PackageWatchdog.PackageHealthObserver; import com.android.server.PackageWatchdog.PackageHealthObserverImpact; diff --git a/tests/RcsTests/Android.mk b/tests/RcsTests/Android.mk index 7b348d73747a..a276584530f4 100644 --- a/tests/RcsTests/Android.mk +++ b/tests/RcsTests/Android.mk @@ -11,7 +11,7 @@ LOCAL_PRIVATE_PLATFORM_APIS := true LOCAL_CERTIFICATE := platform LOCAL_JAVA_LIBRARIES := android.test.runner android.test.base -LOCAL_STATIC_JAVA_LIBRARIES := junit android-support-test mockito-target-minus-junit4 truth-prebuilt +LOCAL_STATIC_JAVA_LIBRARIES := junit androidx.test.rules mockito-target-minus-junit4 truth-prebuilt include $(BUILD_PACKAGE) diff --git a/tests/RcsTests/AndroidManifest.xml b/tests/RcsTests/AndroidManifest.xml index a7e7d479a4d9..b1706a0a3629 100644 --- a/tests/RcsTests/AndroidManifest.xml +++ b/tests/RcsTests/AndroidManifest.xml @@ -6,6 +6,6 @@ <uses-library android:name="android.test.runner" /> </application> - <instrumentation android:name="android.support.test.runner.AndroidJUnitRunner" + <instrumentation android:name="androidx.test.runner.AndroidJUnitRunner" android:targetPackage="com.android.tests.rcs"/> </manifest> diff --git a/tests/RcsTests/src/com/android/tests/ims/RcsGroupThreadIconChangedEventTest.java b/tests/RcsTests/src/com/android/tests/ims/RcsGroupThreadIconChangedEventTest.java index 89d32ab5a925..e8989424de6d 100644 --- a/tests/RcsTests/src/com/android/tests/ims/RcsGroupThreadIconChangedEventTest.java +++ b/tests/RcsTests/src/com/android/tests/ims/RcsGroupThreadIconChangedEventTest.java @@ -19,10 +19,11 @@ import static com.google.common.truth.Truth.assertThat; import android.net.Uri; import android.os.Parcel; -import android.support.test.runner.AndroidJUnit4; import android.telephony.ims.RcsGroupThreadIconChangedEvent; import android.telephony.ims.RcsGroupThreadIconChangedEventDescriptor; +import androidx.test.runner.AndroidJUnit4; + import org.junit.Test; import org.junit.runner.RunWith; diff --git a/tests/RcsTests/src/com/android/tests/ims/RcsGroupThreadNameChangedEventTest.java b/tests/RcsTests/src/com/android/tests/ims/RcsGroupThreadNameChangedEventTest.java index 726b9cd6641f..356688d4db81 100644 --- a/tests/RcsTests/src/com/android/tests/ims/RcsGroupThreadNameChangedEventTest.java +++ b/tests/RcsTests/src/com/android/tests/ims/RcsGroupThreadNameChangedEventTest.java @@ -18,10 +18,11 @@ package com.android.tests.ims; import static com.google.common.truth.Truth.assertThat; import android.os.Parcel; -import android.support.test.runner.AndroidJUnit4; import android.telephony.ims.RcsGroupThreadNameChangedEvent; import android.telephony.ims.RcsGroupThreadNameChangedEventDescriptor; +import androidx.test.runner.AndroidJUnit4; + import org.junit.Test; import org.junit.runner.RunWith; diff --git a/tests/RcsTests/src/com/android/tests/ims/RcsGroupThreadParticipantJoinedEventTest.java b/tests/RcsTests/src/com/android/tests/ims/RcsGroupThreadParticipantJoinedEventTest.java index a109310076d2..572fcb8ffd5e 100644 --- a/tests/RcsTests/src/com/android/tests/ims/RcsGroupThreadParticipantJoinedEventTest.java +++ b/tests/RcsTests/src/com/android/tests/ims/RcsGroupThreadParticipantJoinedEventTest.java @@ -18,10 +18,11 @@ package com.android.tests.ims; import static com.google.common.truth.Truth.assertThat; import android.os.Parcel; -import android.support.test.runner.AndroidJUnit4; import android.telephony.ims.RcsGroupThreadParticipantJoinedEvent; import android.telephony.ims.RcsGroupThreadParticipantJoinedEventDescriptor; +import androidx.test.runner.AndroidJUnit4; + import org.junit.Test; import org.junit.runner.RunWith; diff --git a/tests/RcsTests/src/com/android/tests/ims/RcsGroupThreadParticipantLeftEventTest.java b/tests/RcsTests/src/com/android/tests/ims/RcsGroupThreadParticipantLeftEventTest.java index de2688c5b8c8..038b2e8e60e3 100644 --- a/tests/RcsTests/src/com/android/tests/ims/RcsGroupThreadParticipantLeftEventTest.java +++ b/tests/RcsTests/src/com/android/tests/ims/RcsGroupThreadParticipantLeftEventTest.java @@ -18,10 +18,11 @@ package com.android.tests.ims; import static com.google.common.truth.Truth.assertThat; import android.os.Parcel; -import android.support.test.runner.AndroidJUnit4; import android.telephony.ims.RcsGroupThreadParticipantLeftEvent; import android.telephony.ims.RcsGroupThreadParticipantLeftEventDescriptor; +import androidx.test.runner.AndroidJUnit4; + import org.junit.Test; import org.junit.runner.RunWith; diff --git a/tests/RcsTests/src/com/android/tests/ims/RcsParticipantAliasChangedEventTest.java b/tests/RcsTests/src/com/android/tests/ims/RcsParticipantAliasChangedEventTest.java index 57240545e5d8..283c71b38eef 100644 --- a/tests/RcsTests/src/com/android/tests/ims/RcsParticipantAliasChangedEventTest.java +++ b/tests/RcsTests/src/com/android/tests/ims/RcsParticipantAliasChangedEventTest.java @@ -18,10 +18,11 @@ package com.android.tests.ims; import static com.google.common.truth.Truth.assertThat; import android.os.Parcel; -import android.support.test.runner.AndroidJUnit4; import android.telephony.ims.RcsParticipantAliasChangedEvent; import android.telephony.ims.RcsParticipantAliasChangedEventDescriptor; +import androidx.test.runner.AndroidJUnit4; + import org.junit.Test; import org.junit.runner.RunWith; diff --git a/tests/RcsTests/src/com/android/tests/ims/RcsParticipantQueryParamsTest.java b/tests/RcsTests/src/com/android/tests/ims/RcsParticipantQueryParamsTest.java index 6361a393187e..2d95513be069 100644 --- a/tests/RcsTests/src/com/android/tests/ims/RcsParticipantQueryParamsTest.java +++ b/tests/RcsTests/src/com/android/tests/ims/RcsParticipantQueryParamsTest.java @@ -18,9 +18,10 @@ package com.android.tests.ims; import static com.google.common.truth.Truth.assertThat; import android.os.Parcel; -import android.support.test.runner.AndroidJUnit4; import android.telephony.ims.RcsParticipantQueryParams; +import androidx.test.runner.AndroidJUnit4; + import org.junit.Test; import org.junit.runner.RunWith; diff --git a/tests/RcsTests/src/com/android/tests/ims/RcsThreadQueryParamsTest.java b/tests/RcsTests/src/com/android/tests/ims/RcsThreadQueryParamsTest.java index beb4f8ad28e2..fb51bdaa88a5 100644 --- a/tests/RcsTests/src/com/android/tests/ims/RcsThreadQueryParamsTest.java +++ b/tests/RcsTests/src/com/android/tests/ims/RcsThreadQueryParamsTest.java @@ -21,10 +21,11 @@ import static android.telephony.ims.RcsThreadQueryParams.THREAD_TYPE_GROUP; import static com.google.common.truth.Truth.assertThat; import android.os.Parcel; -import android.support.test.runner.AndroidJUnit4; import android.telephony.ims.RcsParticipant; import android.telephony.ims.RcsThreadQueryParams; +import androidx.test.runner.AndroidJUnit4; + import org.junit.Test; import org.junit.runner.RunWith; diff --git a/tests/RollbackTest/Android.mk b/tests/RollbackTest/Android.mk index db9376b844f9..206f8671d497 100644 --- a/tests/RollbackTest/Android.mk +++ b/tests/RollbackTest/Android.mk @@ -107,7 +107,7 @@ include $(CLEAR_VARS) LOCAL_SRC_FILES := $(call all-java-files-under, RollbackTest/src) LOCAL_PACKAGE_NAME := RollbackTest LOCAL_MODULE_TAGS := tests -LOCAL_STATIC_JAVA_LIBRARIES := android-support-test +LOCAL_STATIC_JAVA_LIBRARIES := androidx.test.rules LOCAL_COMPATIBILITY_SUITE := general-tests LOCAL_JAVA_RESOURCE_FILES := \ $(ROLLBACK_TEST_APP_AV1) \ diff --git a/tests/RollbackTest/RollbackTest.xml b/tests/RollbackTest/RollbackTest.xml index ac39f853656a..70cd86783d6d 100644 --- a/tests/RollbackTest/RollbackTest.xml +++ b/tests/RollbackTest/RollbackTest.xml @@ -20,7 +20,7 @@ </target_preparer> <test class="com.android.tradefed.testtype.AndroidJUnitTest" > <option name="package" value="com.android.tests.rollback" /> - <option name="runner" value="android.support.test.runner.AndroidJUnitRunner" /> + <option name="runner" value="androidx.test.runner.AndroidJUnitRunner" /> <!-- Exclude the StagedRollbackTest tests, which needs to be specially driven from the StagedRollbackTest host test --> diff --git a/tests/RollbackTest/RollbackTest/AndroidManifest.xml b/tests/RollbackTest/RollbackTest/AndroidManifest.xml index e57a768ad1b5..5380dc9fc8cd 100644 --- a/tests/RollbackTest/RollbackTest/AndroidManifest.xml +++ b/tests/RollbackTest/RollbackTest/AndroidManifest.xml @@ -24,7 +24,7 @@ </application> - <instrumentation android:name="android.support.test.runner.AndroidJUnitRunner" + <instrumentation android:name="androidx.test.runner.AndroidJUnitRunner" android:targetPackage="com.android.tests.rollback" android:label="Rollback Test"/> diff --git a/tests/RollbackTest/RollbackTest/src/com/android/tests/rollback/LocalIntentSender.java b/tests/RollbackTest/RollbackTest/src/com/android/tests/rollback/LocalIntentSender.java index ddcf1dabcafc..267ef7377b36 100644 --- a/tests/RollbackTest/RollbackTest/src/com/android/tests/rollback/LocalIntentSender.java +++ b/tests/RollbackTest/RollbackTest/src/com/android/tests/rollback/LocalIntentSender.java @@ -21,7 +21,8 @@ import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; import android.content.IntentSender; -import android.support.test.InstrumentationRegistry; + +import androidx.test.InstrumentationRegistry; import java.util.concurrent.BlockingQueue; import java.util.concurrent.LinkedBlockingQueue; diff --git a/tests/RollbackTest/RollbackTest/src/com/android/tests/rollback/RollbackBroadcastReceiver.java b/tests/RollbackTest/RollbackTest/src/com/android/tests/rollback/RollbackBroadcastReceiver.java index e10f866c899f..8a925b9bad38 100644 --- a/tests/RollbackTest/RollbackTest/src/com/android/tests/rollback/RollbackBroadcastReceiver.java +++ b/tests/RollbackTest/RollbackTest/src/com/android/tests/rollback/RollbackBroadcastReceiver.java @@ -20,9 +20,10 @@ import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; import android.content.IntentFilter; -import android.support.test.InstrumentationRegistry; import android.util.Log; +import androidx.test.InstrumentationRegistry; + import java.util.concurrent.BlockingQueue; import java.util.concurrent.LinkedBlockingQueue; import java.util.concurrent.TimeUnit; diff --git a/tests/RollbackTest/RollbackTest/src/com/android/tests/rollback/RollbackTest.java b/tests/RollbackTest/RollbackTest/src/com/android/tests/rollback/RollbackTest.java index a6054e8f41d0..4780f30d5f7f 100644 --- a/tests/RollbackTest/RollbackTest/src/com/android/tests/rollback/RollbackTest.java +++ b/tests/RollbackTest/RollbackTest/src/com/android/tests/rollback/RollbackTest.java @@ -21,6 +21,11 @@ import static com.android.tests.rollback.RollbackTestUtils.assertRollbackInfoEqu import static com.android.tests.rollback.RollbackTestUtils.getUniqueRollbackInfoForPackage; import static com.android.tests.rollback.RollbackTestUtils.processUserData; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.fail; + import android.Manifest; import android.app.ActivityManager; import android.content.BroadcastReceiver; @@ -31,13 +36,9 @@ import android.content.pm.VersionedPackage; import android.content.rollback.RollbackInfo; import android.content.rollback.RollbackManager; import android.provider.DeviceConfig; -import android.support.test.InstrumentationRegistry; import android.util.Log; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.fail; +import androidx.test.InstrumentationRegistry; import org.junit.Test; import org.junit.runner.RunWith; diff --git a/tests/RollbackTest/RollbackTest/src/com/android/tests/rollback/RollbackTestUtils.java b/tests/RollbackTest/RollbackTest/src/com/android/tests/rollback/RollbackTestUtils.java index 2f989f316ea6..e8cbd60ae649 100644 --- a/tests/RollbackTest/RollbackTest/src/com/android/tests/rollback/RollbackTestUtils.java +++ b/tests/RollbackTest/RollbackTest/src/com/android/tests/rollback/RollbackTestUtils.java @@ -16,6 +16,11 @@ package com.android.tests.rollback; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.fail; + import android.content.BroadcastReceiver; import android.content.ComponentName; import android.content.Context; @@ -30,13 +35,9 @@ import android.content.rollback.RollbackInfo; import android.content.rollback.RollbackManager; import android.os.Handler; import android.os.HandlerThread; -import android.support.test.InstrumentationRegistry; import android.util.Log; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.fail; +import androidx.test.InstrumentationRegistry; import java.io.IOException; import java.io.InputStream; diff --git a/tests/ServiceCrashTest/Android.mk b/tests/ServiceCrashTest/Android.mk index d1f6450e84a6..617ee7caf139 100644 --- a/tests/ServiceCrashTest/Android.mk +++ b/tests/ServiceCrashTest/Android.mk @@ -12,7 +12,7 @@ LOCAL_PRIVATE_PLATFORM_APIS := true LOCAL_CERTIFICATE := platform LOCAL_JAVA_LIBRARIES := android.test.base -LOCAL_STATIC_JAVA_LIBRARIES := compatibility-device-util android-support-test +LOCAL_STATIC_JAVA_LIBRARIES := compatibility-device-util-axt androidx.test.rules include $(BUILD_PACKAGE) diff --git a/tests/UsageStatsPerfTests/Android.mk b/tests/UsageStatsPerfTests/Android.mk index cd29b51e5a24..4304fb0d8e9e 100644 --- a/tests/UsageStatsPerfTests/Android.mk +++ b/tests/UsageStatsPerfTests/Android.mk @@ -21,7 +21,7 @@ LOCAL_SRC_FILES := \ $(call all-java-files-under, src) LOCAL_STATIC_JAVA_LIBRARIES := \ - android-support-test \ + androidx.test.rules \ apct-perftests-utils \ services.usage diff --git a/tests/UsageStatsPerfTests/AndroidManifest.xml b/tests/UsageStatsPerfTests/AndroidManifest.xml index 596a79cd8948..98915485c7bd 100644 --- a/tests/UsageStatsPerfTests/AndroidManifest.xml +++ b/tests/UsageStatsPerfTests/AndroidManifest.xml @@ -24,6 +24,6 @@ <uses-library android:name="android.test.runner" /> </application> - <instrumentation android:name="android.support.test.runner.AndroidJUnitRunner" + <instrumentation android:name="androidx.test.runner.AndroidJUnitRunner" android:targetPackage="com.android.frameworks.perftests.usage"/> </manifest> diff --git a/tests/UsageStatsPerfTests/AndroidTest.xml b/tests/UsageStatsPerfTests/AndroidTest.xml index c9b51dc5ba07..b8892ebc2ff7 100644 --- a/tests/UsageStatsPerfTests/AndroidTest.xml +++ b/tests/UsageStatsPerfTests/AndroidTest.xml @@ -23,6 +23,6 @@ <option name="test-tag" value="UsageStatsPerfTests"/> <test class="com.android.tradefed.testtype.AndroidJUnitTest"> <option name="package" value="com.android.frameworks.perftests.usage"/> - <option name="runner" value="android.support.test.runner.AndroidJUnitRunner"/> + <option name="runner" value="androidx.test.runner.AndroidJUnitRunner"/> </test> </configuration>
\ No newline at end of file diff --git a/tests/UsageStatsPerfTests/src/com/android/frameworks/perftests/usage/tests/UsageStatsDatabasePerfTest.java b/tests/UsageStatsPerfTests/src/com/android/frameworks/perftests/usage/tests/UsageStatsDatabasePerfTest.java index e2a4c26606bf..7d9d0d52b002 100644 --- a/tests/UsageStatsPerfTests/src/com/android/frameworks/perftests/usage/tests/UsageStatsDatabasePerfTest.java +++ b/tests/UsageStatsPerfTests/src/com/android/frameworks/perftests/usage/tests/UsageStatsDatabasePerfTest.java @@ -24,9 +24,10 @@ import android.content.Context; import android.os.SystemClock; import android.perftests.utils.ManualBenchmarkState; import android.perftests.utils.PerfManualStatusReporter; -import android.support.test.InstrumentationRegistry; -import android.support.test.filters.LargeTest; -import android.support.test.runner.AndroidJUnit4; + +import androidx.test.InstrumentationRegistry; +import androidx.test.filters.LargeTest; +import androidx.test.runner.AndroidJUnit4; import com.android.server.usage.IntervalStats; import com.android.server.usage.UsageStatsDatabase; diff --git a/tests/UsbTests/Android.mk b/tests/UsbTests/Android.mk index 4e215cc5996f..aef993b9d348 100644 --- a/tests/UsbTests/Android.mk +++ b/tests/UsbTests/Android.mk @@ -24,7 +24,7 @@ LOCAL_SRC_FILES := $(call all-subdir-java-files) LOCAL_STATIC_JAVA_LIBRARIES := \ frameworks-base-testutils \ - android-support-test \ + androidx.test.rules \ mockito-target-inline-minus-junit4 \ platform-test-annotations \ services.core \ diff --git a/tests/UsbTests/AndroidManifest.xml b/tests/UsbTests/AndroidManifest.xml index 5d606951bb5e..03d1a3ee25e2 100644 --- a/tests/UsbTests/AndroidManifest.xml +++ b/tests/UsbTests/AndroidManifest.xml @@ -24,7 +24,7 @@ <uses-library android:name="android.test.runner" /> </application> - <instrumentation android:name="android.support.test.runner.AndroidJUnitRunner" + <instrumentation android:name="androidx.test.runner.AndroidJUnitRunner" android:targetPackage="com.android.server.usb" android:label="UsbTests"/> </manifest> diff --git a/tests/UsbTests/AndroidTest.xml b/tests/UsbTests/AndroidTest.xml index 4affad39b4eb..e55bc98ecdc1 100644 --- a/tests/UsbTests/AndroidTest.xml +++ b/tests/UsbTests/AndroidTest.xml @@ -24,7 +24,7 @@ <test class="com.android.tradefed.testtype.AndroidJUnitTest"> <option name="package" value="com.android.server.usb"/> - <option name="runner" value="android.support.test.runner.AndroidJUnitRunner"/> + <option name="runner" value="androidx.test.runner.AndroidJUnitRunner"/> <option name="hidden-api-checks" value="false"/> </test> </configuration> diff --git a/tests/UsbTests/src/com/android/server/usb/UsbDescriptorParserTests.java b/tests/UsbTests/src/com/android/server/usb/UsbDescriptorParserTests.java index ea027d7ae049..89dc79c08261 100644 --- a/tests/UsbTests/src/com/android/server/usb/UsbDescriptorParserTests.java +++ b/tests/UsbTests/src/com/android/server/usb/UsbDescriptorParserTests.java @@ -16,29 +16,29 @@ package com.android.server.usb; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; import android.content.Context; import android.content.res.Resources; import android.content.res.Resources.NotFoundException; -import android.support.test.InstrumentationRegistry; -import android.support.test.filters.SmallTest; -import android.support.test.runner.AndroidJUnit4; + +import androidx.test.InstrumentationRegistry; +import androidx.test.filters.SmallTest; +import androidx.test.runner.AndroidJUnit4; import com.android.server.usb.descriptors.UsbDescriptorParser; -import com.android.server.usb.descriptors.UsbDeviceDescriptor; -import com.google.common.io.ByteStreams; -import java.io.InputStream; -import java.io.IOException; -import java.lang.Exception; +import com.google.common.io.ByteStreams; import org.junit.Test; import org.junit.runner.RunWith; +import java.io.IOException; +import java.io.InputStream; + /** * Tests for {@link com.android.server.usb.descriptors.UsbDescriptorParser} */ diff --git a/tests/UsbTests/src/com/android/server/usb/UsbHandlerTest.java b/tests/UsbTests/src/com/android/server/usb/UsbHandlerTest.java index 4b93ca3dcaa9..ca1eb705e457 100644 --- a/tests/UsbTests/src/com/android/server/usb/UsbHandlerTest.java +++ b/tests/UsbTests/src/com/android/server/usb/UsbHandlerTest.java @@ -31,11 +31,11 @@ import android.hardware.usb.UsbManager; import android.os.Handler; import android.os.Looper; import android.os.Message; -import android.os.UserHandle; import android.provider.Settings; -import android.support.test.InstrumentationRegistry; -import android.support.test.filters.SmallTest; -import android.support.test.runner.AndroidJUnit4; + +import androidx.test.InstrumentationRegistry; +import androidx.test.filters.SmallTest; +import androidx.test.runner.AndroidJUnit4; import com.android.server.FgThread; diff --git a/tests/WindowAnimationJank/Android.mk b/tests/WindowAnimationJank/Android.mk index 7800a8078d2a..1c2d16787e88 100644 --- a/tests/WindowAnimationJank/Android.mk +++ b/tests/WindowAnimationJank/Android.mk @@ -26,7 +26,7 @@ LOCAL_PACKAGE_NAME := WindowAnimationJank LOCAL_STATIC_JAVA_LIBRARIES := \ ub-uiautomator \ - ub-janktesthelper \ + androidx.test.janktesthelper \ junit LOCAL_JAVA_LIBRARIES := android.test.base.stubs diff --git a/tests/WindowAnimationJank/src/android/windowanimationjank/FullscreenRotationTest.java b/tests/WindowAnimationJank/src/android/windowanimationjank/FullscreenRotationTest.java index 1fb502a09874..6792a8b486af 100644 --- a/tests/WindowAnimationJank/src/android/windowanimationjank/FullscreenRotationTest.java +++ b/tests/WindowAnimationJank/src/android/windowanimationjank/FullscreenRotationTest.java @@ -17,8 +17,9 @@ package android.windowanimationjank; import android.os.Bundle; -import android.support.test.jank.JankTest; -import android.support.test.jank.GfxMonitor; + +import androidx.test.jank.GfxMonitor; +import androidx.test.jank.JankTest; /** * Detect janks during screen rotation for full-screen activity. Periodically change diff --git a/tests/WindowAnimationJank/src/android/windowanimationjank/WindowAnimationJankTestBase.java b/tests/WindowAnimationJank/src/android/windowanimationjank/WindowAnimationJankTestBase.java index bf739fa8da07..a8ace162c4d0 100644 --- a/tests/WindowAnimationJank/src/android/windowanimationjank/WindowAnimationJankTestBase.java +++ b/tests/WindowAnimationJank/src/android/windowanimationjank/WindowAnimationJankTestBase.java @@ -16,12 +16,10 @@ package android.windowanimationjank; -import java.io.IOException; -import java.util.StringTokenizer; - -import android.support.test.jank.JankTestBase; import android.support.test.uiautomator.UiDevice; +import androidx.test.jank.JankTestBase; + /** * This adds additional system level jank monitor and its result is merged with primary monitor * used in test. diff --git a/tools/processors/view_inspector/src/java/android/processor/view/inspector/InspectableClassModel.java b/tools/processors/view_inspector/src/java/android/processor/view/inspector/InspectableClassModel.java index 6f588935c44c..ee976287b467 100644 --- a/tools/processors/view_inspector/src/java/android/processor/view/inspector/InspectableClassModel.java +++ b/tools/processors/view_inspector/src/java/android/processor/view/inspector/InspectableClassModel.java @@ -23,6 +23,7 @@ import java.util.Collections; import java.util.HashMap; import java.util.List; import java.util.Map; +import java.util.NoSuchElementException; import java.util.Objects; import java.util.Optional; @@ -86,20 +87,98 @@ public final class InspectableClassModel { } /** + * Represents a way to access a property, either a getter or a field. + */ + public static final class Accessor { + private final String mName; + private final Type mType; + + /** + * Construct an accessor for a field. + * + * @param name The name of the field + * @return The new accessor + * @see Type#FIELD + */ + static Accessor ofField(String name) { + return new Accessor(name, Type.FIELD); + } + + /** + * Construct an accessor for a getter. + * + * @param name The name of the getter + * @return The new accessor + * @see Type#GETTER + */ + static Accessor ofGetter(String name) { + return new Accessor(name, Type.GETTER); + } + + public Accessor(String name, Type type) { + mName = Objects.requireNonNull(name, "Accessor name must not be null"); + mType = Objects.requireNonNull(type, "Accessor type must not be null"); + } + + public String getName() { + return mName; + } + + public Type getType() { + return mType; + } + + /** + * Get the invocation of this accessor. + * + * Example: {@code "getValue()"} for a getter or {@code "valueField"} for a field. + * + * @return A string representing the invocation of this accessor + */ + public String invocation() { + switch (mType) { + case FIELD: + return mName; + case GETTER: + return String.format("%s()", mName); + default: + throw new NoSuchElementException( + String.format("No such accessor type %s", mType)); + } + } + + public enum Type { + /** + * A property accessed by a public field. + * + * @see #ofField(String) + */ + FIELD, + + /** + * A property accessed by a public getter method. + * + * @see #ofGetter(String) + */ + GETTER + } + } + + /** * Model an inspectable property */ public static final class Property { private final String mName; - private final String mGetter; + private final Accessor mAccessor; private final Type mType; private boolean mAttributeIdInferrableFromR = true; private int mAttributeId = 0; private List<IntEnumEntry> mIntEnumEntries; private List<IntFlagEntry> mIntFlagEntries; - public Property(String name, String getter, Type type) { + public Property(String name, Accessor accessor, Type type) { mName = Objects.requireNonNull(name, "Name must not be null"); - mGetter = Objects.requireNonNull(getter, "Getter must not be null"); + mAccessor = Objects.requireNonNull(accessor, "Accessor must not be null"); mType = Objects.requireNonNull(type, "Type must not be null"); } @@ -129,8 +208,8 @@ public final class InspectableClassModel { return mName; } - public String getGetter() { - return mGetter; + public Accessor getAccessor() { + return mAccessor; } public Type getType() { diff --git a/tools/processors/view_inspector/src/java/android/processor/view/inspector/InspectablePropertyProcessor.java b/tools/processors/view_inspector/src/java/android/processor/view/inspector/InspectablePropertyProcessor.java index 50c79da25eba..6305228cfa36 100644 --- a/tools/processors/view_inspector/src/java/android/processor/view/inspector/InspectablePropertyProcessor.java +++ b/tools/processors/view_inspector/src/java/android/processor/view/inspector/InspectablePropertyProcessor.java @@ -16,6 +16,7 @@ package android.processor.view.inspector; +import android.processor.view.inspector.InspectableClassModel.Accessor; import android.processor.view.inspector.InspectableClassModel.IntEnumEntry; import android.processor.view.inspector.InspectableClassModel.IntFlagEntry; import android.processor.view.inspector.InspectableClassModel.Property; @@ -93,16 +94,15 @@ public final class InspectablePropertyProcessor implements ModelProcessor { try { final AnnotationMirror annotation = mAnnotationUtils.exactlyOneMirror(mQualifiedName, element); - final ExecutableElement getter = ensureGetter(element); - final Property property = buildProperty(getter, annotation); + final Property property = buildProperty(element, annotation); model.getProperty(property.getName()).ifPresent(p -> { throw new ProcessingException( String.format( - "Property \"%s\" is already defined on #%s().", + "Property \"%s\" is already defined on #%s.", p.getName(), - p.getGetter()), - getter, + p.getAccessor().invocation()), + element, annotation); }); @@ -112,26 +112,79 @@ public final class InspectablePropertyProcessor implements ModelProcessor { } } + /** - * Check that an element is shaped like a getter. + * Build a {@link Property} from a getter and an inspectable property annotation. * - * @param element An element that hopefully represents a getter - * @return An {@link ExecutableElement} that represents a getter method. - * @throws ProcessingException if the element isn't a getter + * @param accessor An element representing the getter or public field to build from + * @param annotation A mirror of an inspectable property-shaped annotation + * @return A property for the getter and annotation + * @throws ProcessingException If the supplied data is invalid and a property cannot be modeled */ - private ExecutableElement ensureGetter(Element element) { - if (element.getKind() != ElementKind.METHOD) { - throw new ProcessingException( - String.format("Expected a method, got a %s", element.getKind()), - element); + private Property buildProperty(Element accessor, AnnotationMirror annotation) { + final Property property; + final Optional<String> nameFromAnnotation = mAnnotationUtils + .typedValueByName("name", String.class, accessor, annotation); + + validateModifiers(accessor); + + switch (accessor.getKind()) { + case FIELD: + property = new Property( + nameFromAnnotation.orElseGet(() -> accessor.getSimpleName().toString()), + Accessor.ofField(accessor.getSimpleName().toString()), + determinePropertyType(accessor, annotation)); + break; + case METHOD: + final ExecutableElement getter = ensureGetter(accessor); + + property = new Property( + nameFromAnnotation.orElseGet(() -> inferPropertyNameFromGetter(getter)), + Accessor.ofGetter(getter.getSimpleName().toString()), + determinePropertyType(getter, annotation)); + break; + default: + throw new ProcessingException( + String.format( + "Property must either be a getter method or a field, got %s.", + accessor.getKind() + ), + accessor, + annotation); } - final ExecutableElement method = (ExecutableElement) element; - final Set<Modifier> modifiers = method.getModifiers(); + mAnnotationUtils + .typedValueByName("hasAttributeId", Boolean.class, accessor, annotation) + .ifPresent(property::setAttributeIdInferrableFromR); - if (modifiers.contains(Modifier.PRIVATE)) { + mAnnotationUtils + .typedValueByName("attributeId", Integer.class, accessor, annotation) + .ifPresent(property::setAttributeId); + + switch (property.getType()) { + case INT_ENUM: + property.setIntEnumEntries(processEnumMapping(accessor, annotation)); + break; + case INT_FLAG: + property.setIntFlagEntries(processFlagMapping(accessor, annotation)); + break; + } + + return property; + } + + /** + * Validates that an element is public, concrete, and non-static. + * + * @param element The element to check + * @throws ProcessingException If the element's modifiers are invalid + */ + private void validateModifiers(Element element) { + final Set<Modifier> modifiers = element.getModifiers(); + + if (!modifiers.contains(Modifier.PUBLIC)) { throw new ProcessingException( - "Property getter methods must not be private.", + "Property getter methods and fields must be public.", element); } @@ -143,10 +196,28 @@ public final class InspectablePropertyProcessor implements ModelProcessor { if (modifiers.contains(Modifier.STATIC)) { throw new ProcessingException( - "Property getter methods must not be static.", + "Property getter methods and fields must not be static.", + element); + } + } + + /** + * Check that an element is shaped like a getter. + * + * @param element An element that hopefully represents a getter + * @return An {@link ExecutableElement} that represents a getter method. + * @throws ProcessingException if the element isn't a getter + */ + private ExecutableElement ensureGetter(Element element) { + if (element.getKind() != ElementKind.METHOD) { + throw new ProcessingException( + String.format("Expected a method, got a %s", element.getKind()), element); } + final ExecutableElement method = (ExecutableElement) element; + + if (!method.getParameters().isEmpty()) { throw new ProcessingException( String.format( @@ -171,77 +242,41 @@ public final class InspectablePropertyProcessor implements ModelProcessor { return method; } - /** - * Build a {@link Property} from a getter and an inspectable property annotation. - * - * @param getter An element representing the getter to build from - * @param annotation A mirror of an inspectable property-shaped annotation - * @return A property for the getter and annotation - * @throws ProcessingException If the supplied data is invalid and a property cannot be modeled - */ - private Property buildProperty(ExecutableElement getter, AnnotationMirror annotation) { - final String name = mAnnotationUtils - .typedValueByName("name", String.class, getter, annotation) - .orElseGet(() -> inferPropertyNameFromGetter(getter)); - - final Property property = new Property( - name, - getter.getSimpleName().toString(), - determinePropertyType(getter, annotation)); - - mAnnotationUtils - .typedValueByName("hasAttributeId", Boolean.class, getter, annotation) - .ifPresent(property::setAttributeIdInferrableFromR); - - mAnnotationUtils - .typedValueByName("attributeId", Integer.class, getter, annotation) - .ifPresent(property::setAttributeId); - - switch (property.getType()) { - case INT_ENUM: - property.setIntEnumEntries(processEnumMapping(getter, annotation)); - break; - case INT_FLAG: - property.setIntFlagEntries(processFlagMapping(getter, annotation)); - break; - } - - return property; - } /** * Determine the property type from the annotation, return type, or context clues. * - * @param getter An element representing the getter to build from + * @param accessor An element representing the getter or field to determine the type of * @param annotation A mirror of an inspectable property-shaped annotation * @return The resolved property type * @throws ProcessingException If the property type cannot be resolved or is invalid * @see android.view.inspector.InspectableProperty#valueType() */ private Property.Type determinePropertyType( - ExecutableElement getter, + Element accessor, AnnotationMirror annotation) { final String valueType = mAnnotationUtils - .untypedValueByName("valueType", getter, annotation) + .untypedValueByName("valueType", accessor, annotation) .map(Object::toString) .orElse("INFERRED"); - final Property.Type returnType = convertReturnTypeToPropertyType(getter); + final Property.Type accessorType = + convertTypeMirrorToPropertyType(extractReturnOrFieldType(accessor), accessor); - final boolean hasColor = hasColorAnnotation(getter); + final boolean hasColor = hasColorAnnotation(accessor); final Optional<AnnotationValue> enumMapping = mAnnotationUtils.valueByName("enumMapping", annotation); final Optional<AnnotationValue> flagMapping = mAnnotationUtils.valueByName("flagMapping", annotation); - if (returnType != Property.Type.INT) { + if (accessorType != Property.Type.INT) { enumMapping.ifPresent(value -> { throw new ProcessingException( String.format( "Can only use enumMapping on int types, got %s.", - returnType.toString().toLowerCase()), - getter, + accessorType.toString().toLowerCase()), + accessor, annotation, value); }); @@ -249,8 +284,8 @@ public final class InspectablePropertyProcessor implements ModelProcessor { throw new ProcessingException( String.format( "Can only use flagMapping on int types, got %s.", - returnType.toString().toLowerCase()), - getter, + accessorType.toString().toLowerCase()), + accessor, annotation, value); }); @@ -262,14 +297,14 @@ public final class InspectablePropertyProcessor implements ModelProcessor { enumMapping.ifPresent(value -> { throw new ProcessingException( "Cannot use enumMapping on a color type.", - getter, + accessor, annotation, value); }); flagMapping.ifPresent(value -> { throw new ProcessingException( "Cannot use flagMapping on a color type.", - getter, + accessor, annotation, value); }); @@ -278,7 +313,7 @@ public final class InspectablePropertyProcessor implements ModelProcessor { flagMapping.ifPresent(value -> { throw new ProcessingException( "Cannot use flagMapping and enumMapping simultaneously.", - getter, + accessor, annotation, value); }); @@ -286,12 +321,12 @@ public final class InspectablePropertyProcessor implements ModelProcessor { } else if (flagMapping.isPresent()) { return Property.Type.INT_FLAG; } else { - return returnType; + return accessorType; } case "NONE": - return returnType; + return accessorType; case "COLOR": - switch (returnType) { + switch (accessorType) { case COLOR: case INT: case LONG: @@ -299,37 +334,58 @@ public final class InspectablePropertyProcessor implements ModelProcessor { default: throw new ProcessingException( "Color must be a long, integer, or android.graphics.Color", - getter, + accessor, annotation); } case "GRAVITY": - requirePackedIntToReturnInt("Gravity", returnType, getter, annotation); + requirePackedIntToBeInt("Gravity", accessorType, accessor, annotation); return Property.Type.GRAVITY; case "INT_ENUM": - requirePackedIntToReturnInt("IntEnum", returnType, getter, annotation); + requirePackedIntToBeInt("IntEnum", accessorType, accessor, annotation); return Property.Type.INT_ENUM; case "INT_FLAG": - requirePackedIntToReturnInt("IntFlag", returnType, getter, annotation); + requirePackedIntToBeInt("IntFlag", accessorType, accessor, annotation); return Property.Type.INT_FLAG; default: throw new ProcessingException( String.format("Unknown value type enumeration value: %s", valueType), - getter, + accessor, annotation); } } /** - * Get a property type from the return type of a getter. + * Get the type of a field or the return type of a method. * - * @param getter The getter to extract the return type of + * @param element The element to extract a {@link TypeMirror} from + * @return The return or field type of the element + * @throws ProcessingException If the element is not a field or a method + */ + private TypeMirror extractReturnOrFieldType(Element element) { + switch (element.getKind()) { + case FIELD: + return element.asType(); + case METHOD: + return ((ExecutableElement) element).getReturnType(); + default: + throw new ProcessingException( + String.format( + "Unable to determine the type of a %s.", + element.getKind()), + element); + } + } + + /** + * Get a property type from a type mirror + * + * @param typeMirror The type mirror to convert to a property type + * @param element The element to be used for exceptions * @return The property type returned by the getter * @throws ProcessingException If the return type is not a primitive or an object */ - private Property.Type convertReturnTypeToPropertyType(ExecutableElement getter) { - final TypeMirror returnType = getter.getReturnType(); - - switch (unboxType(returnType)) { + private Property.Type convertTypeMirrorToPropertyType(TypeMirror typeMirror, Element element) { + switch (unboxType(typeMirror)) { case BOOLEAN: return Property.Type.BOOLEAN; case BYTE: @@ -347,7 +403,7 @@ public final class InspectablePropertyProcessor implements ModelProcessor { case SHORT: return Property.Type.SHORT; case DECLARED: - if (isColorType(returnType)) { + if (isColorType(typeMirror)) { return Property.Type.COLOR; } else { return Property.Type.OBJECT; @@ -356,24 +412,24 @@ public final class InspectablePropertyProcessor implements ModelProcessor { return Property.Type.OBJECT; default: throw new ProcessingException( - String.format("Unsupported return type %s.", returnType), - getter); + String.format("Unsupported property type %s.", typeMirror), + element); } } /** * Require that a value type packed into an integer be on a getter that returns an int. * - * @param typeName The name of the type to use in the exception + * @param typeName The name of the type to use in the exception * @param returnType The return type of the getter to check - * @param getter The getter, to use in the exception + * @param accessor The getter, to use in the exception * @param annotation The annotation, to use in the exception * @throws ProcessingException If the return type is not an int */ - private static void requirePackedIntToReturnInt( + private static void requirePackedIntToBeInt( String typeName, Property.Type returnType, - ExecutableElement getter, + Element accessor, AnnotationMirror annotation) { if (returnType != Property.Type.INT) { throw new ProcessingException( @@ -381,7 +437,7 @@ public final class InspectablePropertyProcessor implements ModelProcessor { "%s can only be defined on a method that returns int, got %s.", typeName, returnType.toString().toLowerCase()), - getter, + accessor, annotation); } } @@ -393,21 +449,21 @@ public final class InspectablePropertyProcessor implements ModelProcessor { * not considered to be annotated, nor is a {@code long} annotated with * {@link android.annotation.ColorInt}. * - * @param getter The getter to query + * @param accessor The getter or field to query * @return True if the getter has a color annotation, false otherwise */ - private boolean hasColorAnnotation(ExecutableElement getter) { - switch (unboxType(getter.getReturnType())) { + private boolean hasColorAnnotation(Element accessor) { + switch (unboxType(extractReturnOrFieldType(accessor))) { case INT: for (String name : COLOR_INT_ANNOTATION_NAMES) { - if (mAnnotationUtils.hasAnnotation(getter, name)) { + if (mAnnotationUtils.hasAnnotation(accessor, name)) { return true; } } return false; case LONG: for (String name : COLOR_LONG_ANNOTATION_NAMES) { - if (mAnnotationUtils.hasAnnotation(getter, name)) { + if (mAnnotationUtils.hasAnnotation(accessor, name)) { return true; } } @@ -452,40 +508,40 @@ public final class InspectablePropertyProcessor implements ModelProcessor { * * @see android.view.inspector.IntEnumMapping * @see android.view.inspector.InspectableProperty#enumMapping() - * @param getter The getter of the property, used for exceptions + * @param accessor The accessor of the property, used for exceptions * @param annotation The {@link android.view.inspector.InspectableProperty} annotation to * extract enum mapping values from. * @return A list of int enum entries, in the order specified in source * @throws ProcessingException if mapping doesn't exist or is invalid */ private List<IntEnumEntry> processEnumMapping( - ExecutableElement getter, + Element accessor, AnnotationMirror annotation) { List<AnnotationMirror> enumAnnotations = mAnnotationUtils.typedArrayValuesByName( - "enumMapping", AnnotationMirror.class, getter, annotation); + "enumMapping", AnnotationMirror.class, accessor, annotation); List<IntEnumEntry> enumEntries = new ArrayList<>(enumAnnotations.size()); if (enumAnnotations.isEmpty()) { throw new ProcessingException( - "Encountered an empty array for enumMapping", getter, annotation); + "Encountered an empty array for enumMapping", accessor, annotation); } for (AnnotationMirror enumAnnotation : enumAnnotations) { final String name = mAnnotationUtils.typedValueByName( - "name", String.class, getter, enumAnnotation) + "name", String.class, accessor, enumAnnotation) .orElseThrow(() -> { throw new ProcessingException( "Name is required for @EnumMap", - getter, + accessor, enumAnnotation); }); final int value = mAnnotationUtils.typedValueByName( - "value", Integer.class, getter, enumAnnotation) + "value", Integer.class, accessor, enumAnnotation) .orElseThrow(() -> { throw new ProcessingException( "Value is required for @EnumMap", - getter, + accessor, enumAnnotation); }); @@ -504,45 +560,45 @@ public final class InspectablePropertyProcessor implements ModelProcessor { * * @see android.view.inspector.IntFlagMapping * @see android.view.inspector.InspectableProperty#flagMapping() - * @param getter The getter of the property, used for exceptions + * @param accessor The accessor of the property, used for exceptions * @param annotation The {@link android.view.inspector.InspectableProperty} annotation to * extract flag mapping values from. * @return A list of int flags entries, in the order specified in source * @throws ProcessingException if mapping doesn't exist or is invalid */ private List<IntFlagEntry> processFlagMapping( - ExecutableElement getter, + Element accessor, AnnotationMirror annotation) { List<AnnotationMirror> flagAnnotations = mAnnotationUtils.typedArrayValuesByName( - "flagMapping", AnnotationMirror.class, getter, annotation); + "flagMapping", AnnotationMirror.class, accessor, annotation); List<IntFlagEntry> flagEntries = new ArrayList<>(flagAnnotations.size()); if (flagAnnotations.isEmpty()) { throw new ProcessingException( - "Encountered an empty array for flagMapping", getter, annotation); + "Encountered an empty array for flagMapping", accessor, annotation); } for (AnnotationMirror flagAnnotation : flagAnnotations) { final String name = mAnnotationUtils.typedValueByName( - "name", String.class, getter, flagAnnotation) + "name", String.class, accessor, flagAnnotation) .orElseThrow(() -> { throw new ProcessingException( "Name is required for @FlagMap", - getter, + accessor, flagAnnotation); }); final int target = mAnnotationUtils.typedValueByName( - "target", Integer.class, getter, flagAnnotation) + "target", Integer.class, accessor, flagAnnotation) .orElseThrow(() -> { throw new ProcessingException( "Target is required for @FlagMap", - getter, + accessor, flagAnnotation); }); final Optional<Integer> mask = mAnnotationUtils.typedValueByName( - "mask", Integer.class, getter, flagAnnotation); + "mask", Integer.class, accessor, flagAnnotation); if (mask.isPresent()) { flagEntries.add(new IntFlagEntry(name, target, mask.get())); diff --git a/tools/processors/view_inspector/src/java/android/processor/view/inspector/InspectionCompanionGenerator.java b/tools/processors/view_inspector/src/java/android/processor/view/inspector/InspectionCompanionGenerator.java index 7b04645e9f44..1ab9914d3aed 100644 --- a/tools/processors/view_inspector/src/java/android/processor/view/inspector/InspectionCompanionGenerator.java +++ b/tools/processors/view_inspector/src/java/android/processor/view/inspector/InspectionCompanionGenerator.java @@ -16,6 +16,7 @@ package android.processor.view.inspector; + import android.processor.view.inspector.InspectableClassModel.IntEnumEntry; import android.processor.view.inspector.InspectableClassModel.IntFlagEntry; import android.processor.view.inspector.InspectableClassModel.Property; @@ -268,10 +269,10 @@ public final class InspectionCompanionGenerator { for (PropertyIdField propertyIdField : propertyIdFields) { builder.addStatement( - "propertyReader.read$L($N, node.$L())", + "propertyReader.read$L($N, node.$L)", methodSuffixForPropertyType(propertyIdField.mProperty.getType()), propertyIdField.mFieldSpec, - propertyIdField.mProperty.getGetter()); + propertyIdField.mProperty.getAccessor().invocation()); } return builder.build(); diff --git a/tools/processors/view_inspector/test/java/android/processor/view/inspector/InspectionCompanionGeneratorTest.java b/tools/processors/view_inspector/test/java/android/processor/view/inspector/InspectionCompanionGeneratorTest.java index f6d8bb0939db..35f0fcf9bcae 100644 --- a/tools/processors/view_inspector/test/java/android/processor/view/inspector/InspectionCompanionGeneratorTest.java +++ b/tools/processors/view_inspector/test/java/android/processor/view/inspector/InspectionCompanionGeneratorTest.java @@ -20,6 +20,8 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.fail; + +import android.processor.view.inspector.InspectableClassModel.Accessor; import android.processor.view.inspector.InspectableClassModel.IntEnumEntry; import android.processor.view.inspector.InspectableClassModel.IntFlagEntry; import android.processor.view.inspector.InspectableClassModel.Property; @@ -86,7 +88,7 @@ public class InspectionCompanionGeneratorTest { @Test public void testNoAttributeId() { - final Property property = new Property( + final Property property = addProperty( "noAttributeProperty", "getNoAttributeProperty", Property.Type.INT); @@ -98,19 +100,18 @@ public class InspectionCompanionGeneratorTest { @Test public void testSuppliedAttributeId() { - final Property property = new Property( + final Property property = addProperty( "suppliedAttributeProperty", "getSuppliedAttributeProperty", Property.Type.INT); property.setAttributeId(0xdecafbad); - mModel.putProperty(property); assertGeneratedFileEquals("SuppliedAttributeId"); } @Test public void testIntEnum() { - final Property property = new Property( + final Property property = addProperty( "intEnumProperty", "getIntEnumProperty", Property.Type.INT_ENUM); @@ -127,7 +128,7 @@ public class InspectionCompanionGeneratorTest { @Test public void testIntFlag() { - final Property property = new Property( + final Property property = addProperty( "intFlag", "getIntFlag", Property.Type.INT_FLAG); @@ -139,13 +140,21 @@ public class InspectionCompanionGeneratorTest { new IntFlagEntry("WARP", 0x4) )); - mModel.putProperty(property); - assertGeneratedFileEquals("IntFlag"); } + @Test + public void testFieldProperty() { + mModel.putProperty(new Property( + "fieldProperty", + Accessor.ofField("fieldProperty"), + Property.Type.INT)); + + assertGeneratedFileEquals("FieldProperty"); + } + private Property addProperty(String name, String getter, Property.Type type) { - final Property property = new Property(name, getter, type); + final Property property = new Property(name, Accessor.ofGetter(getter), type); mModel.putProperty(property); return property; } diff --git a/tools/processors/view_inspector/test/resources/android/processor/view/inspector/InspectionCompanionGeneratorTest/FieldProperty.java.txt b/tools/processors/view_inspector/test/resources/android/processor/view/inspector/InspectionCompanionGeneratorTest/FieldProperty.java.txt new file mode 100644 index 000000000000..a44c43ec0b21 --- /dev/null +++ b/tools/processors/view_inspector/test/resources/android/processor/view/inspector/InspectionCompanionGeneratorTest/FieldProperty.java.txt @@ -0,0 +1,39 @@ +package com.android.node; + +import android.R; +import android.view.inspector.InspectionCompanion; +import android.view.inspector.PropertyMapper; +import android.view.inspector.PropertyReader; +import java.lang.Override; + +/** + * Inspection companion for {@link TestNode}. + * + * Generated by {@link android.processor.view.inspector.InspectionCompanionGenerator} + * on behalf of {@link android.processor.view.inspector.InspectionCompanionGeneratorTest}. + */ +public final class TestNode$$InspectionCompanion implements InspectionCompanion<TestNode> { + /** + * Set by {@link #mapProperties(PropertyMapper)} once properties have been mapped. + */ + private boolean mPropertiesMapped = false; + + /** + * Property ID of {@code fieldProperty}. + */ + private int mFieldPropertyId; + + @Override + public void mapProperties(PropertyMapper propertyMapper) { + mFieldPropertyId = propertyMapper.mapInt("fieldProperty", R.attr.fieldProperty); + mPropertiesMapped = true; + } + + @Override + public void readProperties(TestNode node, PropertyReader propertyReader) { + if (!mPropertiesMapped) { + throw new InspectionCompanion.UninitializedPropertyMapException(); + } + propertyReader.readInt(mFieldPropertyId, node.fieldProperty); + } +} |