Merge "Fix error message on Flicker's launchSplitActivity test"
diff --git a/Android.bp b/Android.bp
index e19ca84..c6cf75d 100644
--- a/Android.bp
+++ b/Android.bp
@@ -49,8 +49,6 @@
"rs/java/**/*.java",
":framework-javastream-protos",
- // TODO: Resolve circular library dependency and remove media1-srcs
- ":media1-srcs",
"core/java/android/accessibilityservice/IAccessibilityServiceConnection.aidl",
"core/java/android/accessibilityservice/IAccessibilityServiceClient.aidl",
@@ -249,6 +247,7 @@
"core/java/android/os/ICancellationSignal.aidl",
"core/java/android/os/IDeviceIdentifiersPolicyService.aidl",
"core/java/android/os/IDeviceIdleController.aidl",
+ "core/java/android/os/IDynamicAndroidService.aidl",
"core/java/android/os/IHardwarePropertiesManager.aidl",
":libincident_aidl",
"core/java/android/os/IMaintenanceActivityListener.aidl",
@@ -505,7 +504,11 @@
"media/java/android/media/session/ICallback.aidl",
"media/java/android/media/session/IOnMediaKeyListener.aidl",
"media/java/android/media/session/IOnVolumeKeyLongPressListener.aidl",
+ "media/java/android/media/session/ISession.aidl",
"media/java/android/media/session/ISession2TokensListener.aidl",
+ "media/java/android/media/session/ISessionCallback.aidl",
+ "media/java/android/media/session/ISessionController.aidl",
+ "media/java/android/media/session/ISessionControllerCallback.aidl",
"media/java/android/media/session/ISessionManager.aidl",
"media/java/android/media/soundtrigger/ISoundTriggerDetectionService.aidl",
"media/java/android/media/soundtrigger/ISoundTriggerDetectionServiceClient.aidl",
@@ -520,6 +523,8 @@
"media/java/android/media/tv/ITvInputSessionCallback.aidl",
"media/java/android/media/tv/ITvRemoteProvider.aidl",
"media/java/android/media/tv/ITvRemoteServiceInput.aidl",
+ "media/java/android/service/media/IMediaBrowserService.aidl",
+ "media/java/android/service/media/IMediaBrowserServiceCallbacks.aidl",
"telecomm/java/com/android/internal/telecom/ICallRedirectionAdapter.aidl",
"telecomm/java/com/android/internal/telecom/ICallRedirectionService.aidl",
"telecomm/java/com/android/internal/telecom/ICallScreeningAdapter.aidl",
@@ -654,6 +659,7 @@
":storaged_aidl",
":vold_aidl",
+ ":gsiservice_aidl",
":installd_aidl",
":dumpstate_aidl",
":incidentcompanion_aidl",
@@ -713,6 +719,7 @@
"frameworks/native/aidl/gui",
"system/core/storaged/binder",
"system/vold/binder",
+ "system/gsid/aidl",
"system/bt/binder",
"system/security/keystore/binder",
],
diff --git a/api/current.txt b/api/current.txt
index 3b6cfe3..83de0b1 100644
--- a/api/current.txt
+++ b/api/current.txt
@@ -1622,6 +1622,7 @@
field @Deprecated public static final int yearListSelectorColor = 16843930; // 0x101049a
field public static final int yesNoPreferenceStyle = 16842896; // 0x1010090
field public static final int zAdjustment = 16843201; // 0x10101c1
+ field public static final int zygotePreloadName = 16844195; // 0x10105a3
}
public static final class R.bool {
@@ -6483,6 +6484,10 @@
method public void onColorsChanged(android.app.WallpaperColors, int);
}
+ public interface ZygotePreload {
+ method public void doPreload(android.content.pm.ApplicationInfo);
+ }
+
}
package android.app.admin {
@@ -11233,6 +11238,7 @@
public class LauncherApps {
method public java.util.List<android.content.pm.LauncherActivityInfo> getActivityList(String, android.os.UserHandle);
+ method @NonNull public java.util.List<android.content.pm.PackageInstaller.SessionInfo> getAllPackageInstallerSessions();
method @Nullable public android.content.pm.LauncherApps.AppUsageLimit getAppUsageLimit(String, android.os.UserHandle);
method public android.content.pm.ApplicationInfo getApplicationInfo(@NonNull String, int, @NonNull android.os.UserHandle) throws android.content.pm.PackageManager.NameNotFoundException;
method public android.content.pm.LauncherApps.PinItemRequest getPinItemRequest(android.content.Intent);
@@ -11249,13 +11255,16 @@
method public void pinShortcuts(@NonNull String, @NonNull java.util.List<java.lang.String>, @NonNull android.os.UserHandle);
method public void registerCallback(android.content.pm.LauncherApps.Callback);
method public void registerCallback(android.content.pm.LauncherApps.Callback, android.os.Handler);
+ method public void registerPackageInstallerSessionCallback(@NonNull java.util.concurrent.Executor, @NonNull android.content.pm.PackageInstaller.SessionCallback);
method public android.content.pm.LauncherActivityInfo resolveActivity(android.content.Intent, android.os.UserHandle);
method public boolean shouldHideFromSuggestions(@NonNull String, @NonNull android.os.UserHandle);
method public void startAppDetailsActivity(android.content.ComponentName, android.os.UserHandle, android.graphics.Rect, android.os.Bundle);
method public void startMainActivity(android.content.ComponentName, android.os.UserHandle, android.graphics.Rect, android.os.Bundle);
+ method public void startPackageInstallerSessionDetailsActivity(android.content.pm.PackageInstaller.SessionInfo, android.graphics.Rect, android.os.Bundle);
method public void startShortcut(@NonNull String, @NonNull String, @Nullable android.graphics.Rect, @Nullable android.os.Bundle, @NonNull android.os.UserHandle);
method public void startShortcut(@NonNull android.content.pm.ShortcutInfo, @Nullable android.graphics.Rect, @Nullable android.os.Bundle);
method public void unregisterCallback(android.content.pm.LauncherApps.Callback);
+ method public void unregisterPackageInstallerSessionCallback(android.content.pm.PackageInstaller.SessionCallback);
field public static final String ACTION_CONFIRM_PIN_APPWIDGET = "android.content.pm.action.CONFIRM_PIN_APPWIDGET";
field public static final String ACTION_CONFIRM_PIN_SHORTCUT = "android.content.pm.action.CONFIRM_PIN_SHORTCUT";
field public static final String EXTRA_PIN_ITEM_REQUEST = "android.content.pm.extra.PIN_ITEM_REQUEST";
@@ -11445,6 +11454,7 @@
method public long getSize();
method public int getStagedSessionErrorCode();
method public String getStagedSessionErrorMessage();
+ method public android.os.UserHandle getUser();
method public boolean isActive();
method public boolean isMultiPackage();
method public boolean isSealed();
@@ -13552,10 +13562,12 @@
method public static android.graphics.Bitmap createScaledBitmap(@NonNull android.graphics.Bitmap, int, int, boolean);
method public int describeContents();
method public void eraseColor(@ColorInt int);
+ method public void eraseColor(@ColorLong long);
method @CheckResult public android.graphics.Bitmap extractAlpha();
method @CheckResult public android.graphics.Bitmap extractAlpha(android.graphics.Paint, int[]);
method public int getAllocationByteCount();
method public int getByteCount();
+ method public android.graphics.Color getColor(int, int);
method @Nullable public android.graphics.ColorSpace getColorSpace();
method public android.graphics.Bitmap.Config getConfig();
method public int getDensity();
@@ -13581,6 +13593,7 @@
method public void reconfigure(int, int, android.graphics.Bitmap.Config);
method public void recycle();
method public boolean sameAs(android.graphics.Bitmap);
+ method public void setColorSpace(@NonNull android.graphics.ColorSpace);
method public void setConfig(android.graphics.Bitmap.Config);
method public void setDensity(int);
method public void setHasAlpha(boolean);
@@ -14241,7 +14254,9 @@
public class LinearGradient extends android.graphics.Shader {
ctor public LinearGradient(float, float, float, float, @NonNull @ColorInt int[], @Nullable float[], @NonNull android.graphics.Shader.TileMode);
+ ctor public LinearGradient(float, float, float, float, @NonNull @ColorLong long[], @Nullable float[], @NonNull android.graphics.Shader.TileMode);
ctor public LinearGradient(float, float, float, float, @ColorInt int, @ColorInt int, @NonNull android.graphics.Shader.TileMode);
+ ctor public LinearGradient(float, float, float, float, @ColorLong long, @ColorLong long, @NonNull android.graphics.Shader.TileMode);
}
public class MaskFilter {
@@ -14382,6 +14397,7 @@
method @Nullable public android.graphics.BlendMode getBlendMode();
method @ColorInt public int getColor();
method public android.graphics.ColorFilter getColorFilter();
+ method @ColorLong public long getColorLong();
method public boolean getFillPath(android.graphics.Path, android.graphics.Path);
method public int getFlags();
method public String getFontFeatureSettings();
@@ -14402,6 +14418,7 @@
method public float getRunAdvance(CharSequence, int, int, int, int, boolean, int);
method public android.graphics.Shader getShader();
method @ColorInt public int getShadowLayerColor();
+ method @ColorLong public long getShadowLayerColorLong();
method public float getShadowLayerDx();
method public float getShadowLayerDy();
method public float getShadowLayerRadius();
@@ -14456,6 +14473,7 @@
method public void setAntiAlias(boolean);
method public void setBlendMode(@Nullable android.graphics.BlendMode);
method public void setColor(@ColorInt int);
+ method public void setColor(@ColorLong long);
method public android.graphics.ColorFilter setColorFilter(android.graphics.ColorFilter);
method public void setDither(boolean);
method public void setElegantTextHeight(boolean);
@@ -14472,6 +14490,7 @@
method public android.graphics.PathEffect setPathEffect(android.graphics.PathEffect);
method public android.graphics.Shader setShader(android.graphics.Shader);
method public void setShadowLayer(float, float, float, @ColorInt int);
+ method public void setShadowLayer(float, float, float, @ColorLong long);
method public void setStrikeThruText(boolean);
method public void setStrokeCap(android.graphics.Paint.Cap);
method public void setStrokeJoin(android.graphics.Paint.Join);
@@ -14766,7 +14785,9 @@
public class RadialGradient extends android.graphics.Shader {
ctor public RadialGradient(float, float, float, @NonNull @ColorInt int[], @Nullable float[], @NonNull android.graphics.Shader.TileMode);
+ ctor public RadialGradient(float, float, float, @NonNull @ColorLong long[], @Nullable float[], @NonNull android.graphics.Shader.TileMode);
ctor public RadialGradient(float, float, float, @ColorInt int, @ColorInt int, @NonNull android.graphics.Shader.TileMode);
+ ctor public RadialGradient(float, float, float, @ColorLong long, @ColorLong long, @NonNull android.graphics.Shader.TileMode);
}
public final class RecordingCanvas extends android.graphics.Canvas {
@@ -15026,7 +15047,9 @@
public class SweepGradient extends android.graphics.Shader {
ctor public SweepGradient(float, float, @NonNull @ColorInt int[], @Nullable float[]);
+ ctor public SweepGradient(float, float, @NonNull @ColorLong long[], @Nullable float[]);
ctor public SweepGradient(float, float, @ColorInt int, @ColorInt int);
+ ctor public SweepGradient(float, float, @ColorLong long, @ColorLong long);
}
public class Typeface {
@@ -25575,6 +25598,14 @@
field public static final int PLAYER_STATE_PAUSED = 1003; // 0x3eb
field public static final int PLAYER_STATE_PLAYING = 1004; // 0x3ec
field public static final int PLAYER_STATE_PREPARED = 1002; // 0x3ea
+ field public static final int PREPARE_DRM_STATUS_KEY_EXCHANGE_ERROR = 7; // 0x7
+ field public static final int PREPARE_DRM_STATUS_PREPARATION_ERROR = 3; // 0x3
+ field public static final int PREPARE_DRM_STATUS_PROVISIONING_NETWORK_ERROR = 1; // 0x1
+ field public static final int PREPARE_DRM_STATUS_PROVISIONING_SERVER_ERROR = 2; // 0x2
+ field public static final int PREPARE_DRM_STATUS_RESOURCE_BUSY = 5; // 0x5
+ field public static final int PREPARE_DRM_STATUS_RESTORE_ERROR = 6; // 0x6
+ field public static final int PREPARE_DRM_STATUS_SUCCESS = 0; // 0x0
+ field public static final int PREPARE_DRM_STATUS_UNSUPPORTED_SCHEME = 4; // 0x4
field public static final int SEEK_CLOSEST = 3; // 0x3
field public static final int SEEK_CLOSEST_SYNC = 2; // 0x2
field public static final int SEEK_NEXT_SYNC = 1; // 0x1
@@ -27366,7 +27397,6 @@
method public int getRatingType();
method @Nullable public android.app.PendingIntent getSessionActivity();
method @NonNull public android.media.session.MediaSession.Token getSessionToken();
- method public String getTag();
method @NonNull public android.media.session.MediaController.TransportControls getTransportControls();
method public void registerCallback(@NonNull android.media.session.MediaController.Callback);
method public void registerCallback(@NonNull android.media.session.MediaController.Callback, @Nullable android.os.Handler);
@@ -29261,6 +29291,7 @@
method public android.net.VpnService.Builder setBlocking(boolean);
method public android.net.VpnService.Builder setConfigureIntent(android.app.PendingIntent);
method public android.net.VpnService.Builder setHttpProxy(android.net.ProxyInfo);
+ method public android.net.VpnService.Builder setMetered(boolean);
method public android.net.VpnService.Builder setMtu(int);
method public android.net.VpnService.Builder setSession(String);
method public android.net.VpnService.Builder setUnderlyingNetworks(android.net.Network[]);
@@ -38490,13 +38521,13 @@
field public static final String BUCKET_ID = "bucket_id";
field public static final String DATE_TAKEN = "datetaken";
field public static final String DESCRIPTION = "description";
+ field public static final String GROUP_ID = "group_id";
field public static final String IS_PRIVATE = "isprivate";
field @Deprecated public static final String LATITUDE = "latitude";
field @Deprecated public static final String LONGITUDE = "longitude";
field @Deprecated public static final String MINI_THUMB_MAGIC = "mini_thumb_magic";
field public static final String ORIENTATION = "orientation";
field @Deprecated public static final String PICASA_ID = "picasa_id";
- field public static final String SECONDARY_BUCKET_ID = "secondary_bucket_id";
}
public static final class MediaStore.Images.Media implements android.provider.MediaStore.Images.ImageColumns {
@@ -38550,6 +38581,8 @@
field public static final String IS_TRASHED = "is_trashed";
field public static final String MIME_TYPE = "mime_type";
field public static final String OWNER_PACKAGE_NAME = "owner_package_name";
+ field public static final String PRIMARY_DIRECTORY = "primary_directory";
+ field public static final String SECONDARY_DIRECTORY = "secondary_directory";
field public static final String SIZE = "_size";
field public static final String TITLE = "title";
field public static final String WIDTH = "width";
@@ -38617,13 +38650,13 @@
field public static final String DATE_TAKEN = "datetaken";
field public static final String DESCRIPTION = "description";
field public static final String DURATION = "duration";
+ field public static final String GROUP_ID = "group_id";
field public static final String IS_PRIVATE = "isprivate";
field public static final String LANGUAGE = "language";
field @Deprecated public static final String LATITUDE = "latitude";
field @Deprecated public static final String LONGITUDE = "longitude";
field @Deprecated public static final String MINI_THUMB_MAGIC = "mini_thumb_magic";
field public static final String RESOLUTION = "resolution";
- field public static final String SECONDARY_BUCKET_ID = "secondary_bucket_id";
field public static final String TAGS = "tags";
}
@@ -38847,6 +38880,7 @@
field @Deprecated public static final int LOCATION_MODE_BATTERY_SAVING = 2; // 0x2
field @Deprecated public static final int LOCATION_MODE_HIGH_ACCURACY = 3; // 0x3
field @Deprecated public static final int LOCATION_MODE_OFF = 0; // 0x0
+ field @Deprecated public static final int LOCATION_MODE_ON = 3; // 0x3
field @Deprecated public static final int LOCATION_MODE_SENSORS_ONLY = 1; // 0x1
field @Deprecated public static final String LOCATION_PROVIDERS_ALLOWED = "location_providers_allowed";
field @Deprecated public static final String LOCK_PATTERN_ENABLED = "lock_pattern_autolock";
@@ -41871,10 +41905,6 @@
method public void showSession(android.os.Bundle, int);
field public static final String SERVICE_INTERFACE = "android.service.voice.VoiceInteractionService";
field public static final String SERVICE_META_DATA = "android.voice_interaction";
- field public static final int VOICE_STATE_CONDITIONAL_LISTENING = 1; // 0x1
- field public static final int VOICE_STATE_FULFILLING = 3; // 0x3
- field public static final int VOICE_STATE_LISTENING = 2; // 0x2
- field public static final int VOICE_STATE_NONE = 0; // 0x0
}
public class VoiceInteractionSession implements android.content.ComponentCallbacks2 android.view.KeyEvent.Callback {
diff --git a/api/system-current.txt b/api/system-current.txt
index 1fd8495..43d055b 100644
--- a/api/system-current.txt
+++ b/api/system-current.txt
@@ -122,6 +122,7 @@
field public static final String OBSERVE_ROLE_HOLDERS = "android.permission.OBSERVE_ROLE_HOLDERS";
field public static final String OVERRIDE_WIFI_CONFIG = "android.permission.OVERRIDE_WIFI_CONFIG";
field public static final String PACKAGE_VERIFICATION_AGENT = "android.permission.PACKAGE_VERIFICATION_AGENT";
+ field public static final String PACKET_KEEPALIVE_OFFLOAD = "android.permission.PACKET_KEEPALIVE_OFFLOAD";
field public static final String PEERS_MAC_ADDRESS = "android.permission.PEERS_MAC_ADDRESS";
field public static final String PERFORM_CDMA_PROVISIONING = "android.permission.PERFORM_CDMA_PROVISIONING";
field public static final String PERFORM_SIM_ACTIVATION = "android.permission.PERFORM_SIM_ACTIVATION";
@@ -990,6 +991,7 @@
}
public static final class AppPredictionContext.Builder {
+ ctor public AppPredictionContext.Builder(@NonNull android.content.Context);
method public android.app.prediction.AppPredictionContext build();
method public android.app.prediction.AppPredictionContext.Builder setExtras(@Nullable android.os.Bundle);
method public android.app.prediction.AppPredictionContext.Builder setPredictedTargetCount(int);
@@ -1021,6 +1023,8 @@
}
public final class AppTarget implements android.os.Parcelable {
+ ctor public AppTarget(@NonNull android.app.prediction.AppTargetId, @NonNull String, @Nullable String, @NonNull android.os.UserHandle);
+ ctor public AppTarget(@NonNull android.app.prediction.AppTargetId, @NonNull android.content.pm.ShortcutInfo, @Nullable String);
method public int describeContents();
method @Nullable public String getClassName();
method @NonNull public android.app.prediction.AppTargetId getId();
@@ -1051,6 +1055,7 @@
}
public final class AppTargetId implements android.os.Parcelable {
+ ctor public AppTargetId(@NonNull String);
method public int describeContents();
method public void writeToParcel(android.os.Parcel, int);
field public static final android.os.Parcelable.Creator<android.app.prediction.AppTargetId> CREATOR;
@@ -1286,6 +1291,7 @@
field public static final String BACKUP_SERVICE = "backup";
field public static final String CONTENT_SUGGESTIONS_SERVICE = "content_suggestions";
field public static final String CONTEXTHUB_SERVICE = "contexthub";
+ field public static final String DYNAMIC_ANDROID_SERVICE = "dynamic_android";
field public static final String EUICC_CARD_SERVICE = "euicc_card";
field public static final String HDMI_CONTROL_SERVICE = "hdmi_control";
field public static final String NETD_SERVICE = "netd";
@@ -3478,15 +3484,6 @@
method @NonNull public android.media.TimedMetaData.Builder setTimedMetaData(long, @NonNull byte[]);
}
- public abstract class VolumeProvider {
- method public void setCallback(android.media.VolumeProvider.Callback);
- }
-
- public abstract static class VolumeProvider.Callback {
- ctor public VolumeProvider.Callback();
- method public abstract void onVolumeChanged(android.media.VolumeProvider);
- }
-
}
package android.media.audiopolicy {
@@ -3575,167 +3572,10 @@
package android.media.session {
- public final class ControllerCallbackLink implements android.os.Parcelable {
- ctor public ControllerCallbackLink(@NonNull android.content.Context, @NonNull android.media.session.ControllerCallbackLink.CallbackStub);
- ctor public ControllerCallbackLink(android.os.IBinder);
- method public int describeContents();
- method @NonNull public android.os.IBinder getBinder();
- method @RequiresPermission(android.Manifest.permission.MEDIA_CONTENT_CONTROL) public void notifyEvent(@NonNull String, @Nullable android.os.Bundle);
- method @RequiresPermission(android.Manifest.permission.MEDIA_CONTENT_CONTROL) public void notifyExtrasChanged(@Nullable android.os.Bundle);
- method @RequiresPermission(android.Manifest.permission.MEDIA_CONTENT_CONTROL) public void notifyMetadataChanged(@Nullable android.media.MediaMetadata);
- method @RequiresPermission(android.Manifest.permission.MEDIA_CONTENT_CONTROL) public void notifyPlaybackStateChanged(@Nullable android.media.session.PlaybackState);
- method @RequiresPermission(android.Manifest.permission.MEDIA_CONTENT_CONTROL) public void notifyQueueChanged(@Nullable java.util.List<android.media.session.MediaSession.QueueItem>);
- method @RequiresPermission(android.Manifest.permission.MEDIA_CONTENT_CONTROL) public void notifyQueueTitleChanged(@Nullable CharSequence);
- method @RequiresPermission(android.Manifest.permission.MEDIA_CONTENT_CONTROL) public void notifySessionDestroyed();
- method @RequiresPermission(android.Manifest.permission.MEDIA_CONTENT_CONTROL) public void notifyVolumeInfoChanged(@NonNull android.media.session.MediaController.PlaybackInfo);
- method public void writeToParcel(android.os.Parcel, int);
- field public static final android.os.Parcelable.Creator<android.media.session.ControllerCallbackLink> CREATOR;
- }
-
- public abstract static class ControllerCallbackLink.CallbackStub {
- ctor public ControllerCallbackLink.CallbackStub();
- method public void onEvent(@NonNull String, @Nullable android.os.Bundle);
- method public void onExtrasChanged(@Nullable android.os.Bundle);
- method public void onMetadataChanged(@Nullable android.media.MediaMetadata);
- method public void onPlaybackStateChanged(@Nullable android.media.session.PlaybackState);
- method public void onQueueChanged(@Nullable java.util.List<android.media.session.MediaSession.QueueItem>);
- method public void onQueueTitleChanged(@Nullable CharSequence);
- method public void onSessionDestroyed();
- method public void onVolumeInfoChanged(@NonNull android.media.session.MediaController.PlaybackInfo);
- }
-
- public final class ControllerLink implements android.os.Parcelable {
- ctor public ControllerLink(@NonNull android.media.session.ControllerLink.ControllerStub);
- ctor public ControllerLink(android.os.IBinder);
- method public int describeContents();
- method @NonNull public android.os.IBinder getBinder();
- method @Nullable public android.os.Bundle getExtras();
- method @Nullable public android.media.MediaMetadata getMetadata();
- method @Nullable public android.media.session.PlaybackState getPlaybackState();
- method @Nullable public java.util.List<android.media.session.MediaSession.QueueItem> getQueue();
- method @Nullable public CharSequence getQueueTitle();
- method public int getRatingType();
- method public void writeToParcel(android.os.Parcel, int);
- field public static final android.os.Parcelable.Creator<android.media.session.ControllerLink> CREATOR;
- }
-
- public abstract static class ControllerLink.ControllerStub {
- ctor public ControllerLink.ControllerStub();
- method public void adjustVolume(@NonNull String, @NonNull String, @NonNull android.media.session.ControllerCallbackLink, int, int);
- method public void fastForward(@NonNull String, @NonNull android.media.session.ControllerCallbackLink);
- method @Nullable public android.os.Bundle getExtras();
- method public long getFlags();
- method @Nullable public android.app.PendingIntent getLaunchPendingIntent();
- method @Nullable public android.media.MediaMetadata getMetadata();
- method @NonNull public String getPackageName();
- method @Nullable public android.media.session.PlaybackState getPlaybackState();
- method @Nullable public java.util.List<android.media.session.MediaSession.QueueItem> getQueue();
- method @Nullable public CharSequence getQueueTitle();
- method public int getRatingType();
- method @NonNull public String getTag();
- method @NonNull public android.media.session.MediaController.PlaybackInfo getVolumeAttributes();
- method public void next(@NonNull String, @NonNull android.media.session.ControllerCallbackLink);
- method public void pause(@NonNull String, @NonNull android.media.session.ControllerCallbackLink);
- method public void play(@NonNull String, @NonNull android.media.session.ControllerCallbackLink);
- method public void playFromMediaId(@NonNull String, @NonNull android.media.session.ControllerCallbackLink, @NonNull String, @Nullable android.os.Bundle);
- method public void playFromSearch(@NonNull String, @NonNull android.media.session.ControllerCallbackLink, @NonNull String, @Nullable android.os.Bundle);
- method public void playFromUri(@NonNull String, @NonNull android.media.session.ControllerCallbackLink, @NonNull android.net.Uri, @Nullable android.os.Bundle);
- method public void prepare(@NonNull String, @NonNull android.media.session.ControllerCallbackLink);
- method public void prepareFromMediaId(@NonNull String, @NonNull android.media.session.ControllerCallbackLink, @NonNull String, @Nullable android.os.Bundle);
- method public void prepareFromSearch(@NonNull String, @NonNull android.media.session.ControllerCallbackLink, @NonNull String, @Nullable android.os.Bundle);
- method public void prepareFromUri(@NonNull String, @NonNull android.media.session.ControllerCallbackLink, @NonNull android.net.Uri, @Nullable android.os.Bundle);
- method public void previous(@NonNull String, @NonNull android.media.session.ControllerCallbackLink);
- method public void rate(@NonNull String, @NonNull android.media.session.ControllerCallbackLink, @NonNull android.media.Rating);
- method public void registerCallback(@NonNull String, @NonNull android.media.session.ControllerCallbackLink);
- method public void rewind(@NonNull String, @NonNull android.media.session.ControllerCallbackLink);
- method public void seekTo(@NonNull String, @NonNull android.media.session.ControllerCallbackLink, long);
- method public void sendCommand(@NonNull String, @NonNull android.media.session.ControllerCallbackLink, @NonNull String, @Nullable android.os.Bundle, @Nullable android.os.ResultReceiver);
- method public void sendCustomAction(@NonNull String, @NonNull android.media.session.ControllerCallbackLink, @NonNull String, @Nullable android.os.Bundle);
- method public boolean sendMediaButton(@NonNull String, @NonNull android.media.session.ControllerCallbackLink, @NonNull android.view.KeyEvent);
- method public void setVolumeTo(@NonNull String, @NonNull String, @NonNull android.media.session.ControllerCallbackLink, int, int);
- method public void skipToQueueItem(@NonNull String, @NonNull android.media.session.ControllerCallbackLink, long);
- method public void stop(@NonNull String, @NonNull android.media.session.ControllerCallbackLink);
- method public void unregisterCallback(@NonNull android.media.session.ControllerCallbackLink);
- }
-
public static final class MediaController.PlaybackInfo implements android.os.Parcelable {
ctor public MediaController.PlaybackInfo(int, int, int, int, android.media.AudioAttributes);
}
- public abstract static class MediaSession.Callback {
- method public void onSetMediaButtonEventDelegate(@NonNull android.media.session.MediaSessionEngine.MediaButtonEventDelegate);
- }
-
- public static final class MediaSession.Token implements android.os.Parcelable {
- method public android.media.session.ControllerLink getControllerLink();
- }
-
- public final class MediaSessionEngine implements java.lang.AutoCloseable {
- ctor public MediaSessionEngine(@NonNull android.content.Context, @NonNull android.media.session.SessionLink, @NonNull android.media.session.SessionCallbackLink, @NonNull android.media.session.MediaSessionEngine.CallbackStub);
- method public void close();
- method public String getCallingPackage();
- method @NonNull public android.media.session.MediaController getController();
- method @NonNull public android.media.session.MediaSessionManager.RemoteUserInfo getCurrentControllerInfo();
- method @NonNull public android.media.session.MediaSession.Token getSessionToken();
- method public boolean isActive();
- method public static boolean isActiveState(int);
- method public void sendSessionEvent(@NonNull String, @Nullable android.os.Bundle);
- method public void setActive(boolean);
- method public void setCallback(@Nullable android.media.session.MediaSession.Callback);
- method public void setCallback(@Nullable android.media.session.MediaSession.Callback, @NonNull android.os.Handler);
- method public void setExtras(@Nullable android.os.Bundle);
- method public void setFlags(int);
- method public void setMediaButtonReceiver(@Nullable android.app.PendingIntent);
- method public void setMetadata(@Nullable android.media.MediaMetadata);
- method public void setPlaybackState(@Nullable android.media.session.PlaybackState);
- method public void setPlaybackToLocal(android.media.AudioAttributes);
- method public void setPlaybackToRemote(@NonNull android.media.VolumeProvider);
- method public void setQueue(@Nullable java.util.List<android.media.session.MediaSession.QueueItem>);
- method public void setQueueTitle(@Nullable CharSequence);
- method public void setRatingType(int);
- method public void setSessionActivity(@Nullable android.app.PendingIntent);
- }
-
- public static final class MediaSessionEngine.CallbackStub {
- ctor public MediaSessionEngine.CallbackStub();
- method public void onAdjustVolume(String, int, int, android.media.session.ControllerCallbackLink, int);
- method public void onCommand(String, int, int, android.media.session.ControllerCallbackLink, String, android.os.Bundle, android.os.ResultReceiver);
- method public void onCustomAction(String, int, int, android.media.session.ControllerCallbackLink, String, android.os.Bundle);
- method public void onFastForward(String, int, int, android.media.session.ControllerCallbackLink);
- method public void onMediaButton(String, int, int, android.content.Intent, int, android.os.ResultReceiver);
- method public void onMediaButtonFromController(String, int, int, android.media.session.ControllerCallbackLink, android.content.Intent);
- method public void onNext(String, int, int, android.media.session.ControllerCallbackLink);
- method public void onPause(String, int, int, android.media.session.ControllerCallbackLink);
- method public void onPlay(String, int, int, android.media.session.ControllerCallbackLink);
- method public void onPlayFromMediaId(String, int, int, android.media.session.ControllerCallbackLink, String, android.os.Bundle);
- method public void onPlayFromSearch(String, int, int, android.media.session.ControllerCallbackLink, String, android.os.Bundle);
- method public void onPlayFromUri(String, int, int, android.media.session.ControllerCallbackLink, android.net.Uri, android.os.Bundle);
- method public void onPrepare(String, int, int, android.media.session.ControllerCallbackLink);
- method public void onPrepareFromMediaId(String, int, int, android.media.session.ControllerCallbackLink, String, android.os.Bundle);
- method public void onPrepareFromSearch(String, int, int, android.media.session.ControllerCallbackLink, String, android.os.Bundle);
- method public void onPrepareFromUri(String, int, int, android.media.session.ControllerCallbackLink, android.net.Uri, android.os.Bundle);
- method public void onPrevious(String, int, int, android.media.session.ControllerCallbackLink);
- method public void onRate(String, int, int, android.media.session.ControllerCallbackLink, android.media.Rating);
- method public void onRewind(String, int, int, android.media.session.ControllerCallbackLink);
- method public void onSeekTo(String, int, int, android.media.session.ControllerCallbackLink, long);
- method public void onSetVolumeTo(String, int, int, android.media.session.ControllerCallbackLink, int);
- method public void onSkipToTrack(String, int, int, android.media.session.ControllerCallbackLink, long);
- method public void onStop(String, int, int, android.media.session.ControllerCallbackLink);
- }
-
- public static interface MediaSessionEngine.MediaButtonEventDelegate {
- method public boolean onMediaButtonIntent(android.content.Intent);
- }
-
- public static final class MediaSessionEngine.QueueItem {
- ctor public MediaSessionEngine.QueueItem(android.media.MediaDescription, long);
- ctor public MediaSessionEngine.QueueItem(android.os.Parcel);
- method public android.media.MediaDescription getDescription();
- method public long getQueueId();
- method public void writeToParcel(android.os.Parcel, int);
- field public static final int UNKNOWN_ID = -1; // 0xffffffff
- }
-
public final class MediaSessionManager {
method @RequiresPermission(android.Manifest.permission.SET_MEDIA_KEY_LISTENER) public void setOnMediaKeyListener(android.media.session.MediaSessionManager.OnMediaKeyListener, @Nullable android.os.Handler);
method @RequiresPermission(android.Manifest.permission.SET_VOLUME_KEY_LONG_PRESS_LISTENER) public void setOnVolumeKeyLongPressListener(android.media.session.MediaSessionManager.OnVolumeKeyLongPressListener, @Nullable android.os.Handler);
@@ -3749,66 +3589,6 @@
method public void onVolumeKeyLongPress(android.view.KeyEvent);
}
- public final class SessionCallbackLink implements android.os.Parcelable {
- ctor public SessionCallbackLink(android.os.IBinder);
- method public int describeContents();
- method @NonNull public android.os.IBinder getBinder();
- method @RequiresPermission(android.Manifest.permission.MEDIA_CONTENT_CONTROL) public void notifyAdjustVolume(@NonNull String, int, int, @NonNull android.media.session.ControllerCallbackLink, int);
- method @RequiresPermission(android.Manifest.permission.MEDIA_CONTENT_CONTROL) public void notifyCommand(@NonNull String, int, int, @NonNull android.media.session.ControllerCallbackLink, @NonNull String, @Nullable android.os.Bundle, @Nullable android.os.ResultReceiver);
- method @RequiresPermission(android.Manifest.permission.MEDIA_CONTENT_CONTROL) public void notifyCustomAction(@NonNull String, int, int, @NonNull android.media.session.ControllerCallbackLink, @NonNull String, @Nullable android.os.Bundle);
- method @RequiresPermission(android.Manifest.permission.MEDIA_CONTENT_CONTROL) public void notifyFastForward(@NonNull String, int, int, @NonNull android.media.session.ControllerCallbackLink);
- method @RequiresPermission(android.Manifest.permission.MEDIA_CONTENT_CONTROL) public void notifyMediaButton(@NonNull String, int, int, @NonNull android.content.Intent, int, @Nullable android.os.ResultReceiver);
- method @RequiresPermission(android.Manifest.permission.MEDIA_CONTENT_CONTROL) public void notifyMediaButtonFromController(@NonNull String, int, int, @NonNull android.media.session.ControllerCallbackLink, @NonNull android.content.Intent);
- method @RequiresPermission(android.Manifest.permission.MEDIA_CONTENT_CONTROL) public void notifyNext(@NonNull String, int, int, @NonNull android.media.session.ControllerCallbackLink);
- method @RequiresPermission(android.Manifest.permission.MEDIA_CONTENT_CONTROL) public void notifyPause(@NonNull String, int, int, @NonNull android.media.session.ControllerCallbackLink);
- method @RequiresPermission(android.Manifest.permission.MEDIA_CONTENT_CONTROL) public void notifyPlay(@NonNull String, int, int, @NonNull android.media.session.ControllerCallbackLink);
- method @RequiresPermission(android.Manifest.permission.MEDIA_CONTENT_CONTROL) public void notifyPlayFromMediaId(@NonNull String, int, int, @NonNull android.media.session.ControllerCallbackLink, @NonNull String, @Nullable android.os.Bundle);
- method @RequiresPermission(android.Manifest.permission.MEDIA_CONTENT_CONTROL) public void notifyPlayFromSearch(@NonNull String, int, int, @NonNull android.media.session.ControllerCallbackLink, @NonNull String, @Nullable android.os.Bundle);
- method @RequiresPermission(android.Manifest.permission.MEDIA_CONTENT_CONTROL) public void notifyPlayFromUri(@NonNull String, int, int, @NonNull android.media.session.ControllerCallbackLink, @NonNull android.net.Uri, @Nullable android.os.Bundle);
- method @RequiresPermission(android.Manifest.permission.MEDIA_CONTENT_CONTROL) public void notifyPrepare(@NonNull String, int, int, @NonNull android.media.session.ControllerCallbackLink);
- method @RequiresPermission(android.Manifest.permission.MEDIA_CONTENT_CONTROL) public void notifyPrepareFromMediaId(@NonNull String, int, int, @NonNull android.media.session.ControllerCallbackLink, @NonNull String, @Nullable android.os.Bundle);
- method @RequiresPermission(android.Manifest.permission.MEDIA_CONTENT_CONTROL) public void notifyPrepareFromSearch(@NonNull String, int, int, @NonNull android.media.session.ControllerCallbackLink, @NonNull String, @Nullable android.os.Bundle);
- method @RequiresPermission(android.Manifest.permission.MEDIA_CONTENT_CONTROL) public void notifyPrepareFromUri(@NonNull String, int, int, @NonNull android.media.session.ControllerCallbackLink, @NonNull android.net.Uri, @Nullable android.os.Bundle);
- method @RequiresPermission(android.Manifest.permission.MEDIA_CONTENT_CONTROL) public void notifyPrevious(@NonNull String, int, int, @NonNull android.media.session.ControllerCallbackLink);
- method @RequiresPermission(android.Manifest.permission.MEDIA_CONTENT_CONTROL) public void notifyRate(@NonNull String, int, int, @NonNull android.media.session.ControllerCallbackLink, @NonNull android.media.Rating);
- method @RequiresPermission(android.Manifest.permission.MEDIA_CONTENT_CONTROL) public void notifyRewind(@NonNull String, int, int, @NonNull android.media.session.ControllerCallbackLink);
- method @RequiresPermission(android.Manifest.permission.MEDIA_CONTENT_CONTROL) public void notifySeekTo(@NonNull String, int, int, @NonNull android.media.session.ControllerCallbackLink, long);
- method @RequiresPermission(android.Manifest.permission.MEDIA_CONTENT_CONTROL) public void notifySetVolumeTo(@NonNull String, int, int, @NonNull android.media.session.ControllerCallbackLink, int);
- method @RequiresPermission(android.Manifest.permission.MEDIA_CONTENT_CONTROL) public void notifySkipToTrack(@NonNull String, int, int, @NonNull android.media.session.ControllerCallbackLink, long);
- method @RequiresPermission(android.Manifest.permission.MEDIA_CONTENT_CONTROL) public void notifyStop(@NonNull String, int, int, @NonNull android.media.session.ControllerCallbackLink);
- method public void writeToParcel(android.os.Parcel, int);
- field public static final android.os.Parcelable.Creator<android.media.session.SessionCallbackLink> CREATOR;
- }
-
- public final class SessionLink implements android.os.Parcelable {
- ctor public SessionLink(@NonNull android.media.session.SessionLink.SessionStub);
- ctor public SessionLink(android.os.IBinder);
- method public int describeContents();
- method @NonNull public android.os.IBinder getBinder();
- method public void writeToParcel(android.os.Parcel, int);
- field public static final android.os.Parcelable.Creator<android.media.session.SessionLink> CREATOR;
- }
-
- public abstract static class SessionLink.SessionStub {
- ctor public SessionLink.SessionStub();
- method public void destroySession();
- method @NonNull public android.media.session.ControllerLink getController();
- method public void sendEvent(@NonNull String, @Nullable android.os.Bundle);
- method public void setActive(boolean);
- method public void setCurrentVolume(int);
- method public void setExtras(@Nullable android.os.Bundle);
- method public void setFlags(int);
- method public void setLaunchPendingIntent(@Nullable android.app.PendingIntent);
- method public void setMediaButtonReceiver(@Nullable android.app.PendingIntent);
- method public void setMetadata(@Nullable android.media.MediaMetadata, long, @Nullable String);
- method public void setPlaybackState(@Nullable android.media.session.PlaybackState);
- method public void setPlaybackToLocal(@NonNull android.media.AudioAttributes);
- method public void setPlaybackToRemote(int, int);
- method public void setQueue(@Nullable java.util.List<android.media.session.MediaSession.QueueItem>);
- method public void setQueueTitle(@Nullable CharSequence);
- method public void setRatingType(int);
- }
-
}
package android.media.soundtrigger {
@@ -4110,9 +3890,10 @@
}
public class ConnectivityManager {
- method @RequiresPermission("android.permission.PACKET_KEEPALIVE_OFFLOAD") public android.net.SocketKeepalive createNattKeepalive(@NonNull android.net.Network, @NonNull java.io.FileDescriptor, @NonNull java.net.InetAddress, @NonNull java.net.InetAddress, @NonNull java.util.concurrent.Executor, @NonNull android.net.SocketKeepalive.Callback);
+ method @RequiresPermission(android.Manifest.permission.PACKET_KEEPALIVE_OFFLOAD) public android.net.SocketKeepalive createNattKeepalive(@NonNull android.net.Network, @NonNull java.io.FileDescriptor, @NonNull java.net.InetAddress, @NonNull java.net.InetAddress, @NonNull java.util.concurrent.Executor, @NonNull android.net.SocketKeepalive.Callback);
method public boolean getAvoidBadWifi();
method @RequiresPermission(android.Manifest.permission.LOCAL_MAC_ADDRESS) public String getCaptivePortalServerUrl();
+ method @RequiresPermission(android.Manifest.permission.TETHER_PRIVILEGED) public void getLatestTetheringEntitlementValue(int, boolean, @NonNull android.net.ConnectivityManager.TetheringEntitlementValueListener, @Nullable android.os.Handler);
method @RequiresPermission(anyOf={android.Manifest.permission.TETHER_PRIVILEGED, android.Manifest.permission.WRITE_SETTINGS}) public boolean isTetheringSupported();
method @RequiresPermission(anyOf={"android.permission.NETWORK_SETTINGS", android.Manifest.permission.NETWORK_SETUP_WIZARD, "android.permission.NETWORK_STACK"}) public void setAirplaneMode(boolean);
method @RequiresPermission(android.Manifest.permission.TETHER_PRIVILEGED) public void startTethering(int, boolean, android.net.ConnectivityManager.OnStartTetheringCallback);
@@ -4123,6 +3904,9 @@
field public static final int TETHERING_BLUETOOTH = 2; // 0x2
field public static final int TETHERING_USB = 1; // 0x1
field public static final int TETHERING_WIFI = 0; // 0x0
+ field public static final int TETHER_ERROR_ENTITLEMENT_UNKONWN = 13; // 0xd
+ field public static final int TETHER_ERROR_NO_ERROR = 0; // 0x0
+ field public static final int TETHER_ERROR_PROVISION_FAILED = 11; // 0xb
}
public abstract static class ConnectivityManager.OnStartTetheringCallback {
@@ -4131,6 +3915,11 @@
method public void onTetheringStarted();
}
+ public abstract static class ConnectivityManager.TetheringEntitlementValueListener {
+ ctor public ConnectivityManager.TetheringEntitlementValueListener();
+ method public void onEntitlementResult(int);
+ }
+
public final class IpPrefix implements android.os.Parcelable {
ctor public IpPrefix(java.net.InetAddress, int);
ctor public IpPrefix(String);
@@ -4246,6 +4035,10 @@
field public static final String EXTRA_PACKAGE_NAME = "packageName";
}
+ public class NetworkStack {
+ field public static final String PERMISSION_MAINLINE_NETWORK_STACK = "android.permission.MAINLINE_NETWORK_STACK";
+ }
+
public final class RouteInfo implements android.os.Parcelable {
ctor public RouteInfo(android.net.IpPrefix, java.net.InetAddress, String, int);
method public int getType();
@@ -5165,6 +4958,53 @@
field public static final String EXTRA_EVENT_TIMESTAMP = "android.os.extra.EVENT_TIMESTAMP";
}
+ public final class BatterySaverPolicyConfig implements android.os.Parcelable {
+ method public int describeContents();
+ method public float getAdjustBrightnessFactor();
+ method public boolean getAdvertiseIsEnabled();
+ method public boolean getDeferFullBackup();
+ method public boolean getDeferKeyValueBackup();
+ method @NonNull public java.util.Map<java.lang.String,java.lang.String> getDeviceSpecificSettings();
+ method public boolean getDisableAnimation();
+ method public boolean getDisableAod();
+ method public boolean getDisableLaunchBoost();
+ method public boolean getDisableOptionalSensors();
+ method public boolean getDisableSoundTrigger();
+ method public boolean getDisableVibration();
+ method public boolean getEnableAdjustBrightness();
+ method public boolean getEnableDataSaver();
+ method public boolean getEnableFirewall();
+ method public boolean getEnableQuickDoze();
+ method public boolean getForceAllAppsStandby();
+ method public boolean getForceBackgroundCheck();
+ method public int getGpsMode();
+ method public void writeToParcel(android.os.Parcel, int);
+ field public static final android.os.Parcelable.Creator<android.os.BatterySaverPolicyConfig> CREATOR;
+ }
+
+ public static final class BatterySaverPolicyConfig.Builder {
+ ctor public BatterySaverPolicyConfig.Builder();
+ method @NonNull public android.os.BatterySaverPolicyConfig.Builder addDeviceSpecificSetting(@NonNull String, @NonNull String);
+ method @NonNull public android.os.BatterySaverPolicyConfig build();
+ method @NonNull public android.os.BatterySaverPolicyConfig.Builder setAdjustBrightnessFactor(float);
+ method @NonNull public android.os.BatterySaverPolicyConfig.Builder setAdvertiseIsEnabled(boolean);
+ method @NonNull public android.os.BatterySaverPolicyConfig.Builder setDeferFullBackup(boolean);
+ method @NonNull public android.os.BatterySaverPolicyConfig.Builder setDeferKeyValueBackup(boolean);
+ method @NonNull public android.os.BatterySaverPolicyConfig.Builder setDisableAnimation(boolean);
+ method @NonNull public android.os.BatterySaverPolicyConfig.Builder setDisableAod(boolean);
+ method @NonNull public android.os.BatterySaverPolicyConfig.Builder setDisableLaunchBoost(boolean);
+ method @NonNull public android.os.BatterySaverPolicyConfig.Builder setDisableOptionalSensors(boolean);
+ method @NonNull public android.os.BatterySaverPolicyConfig.Builder setDisableSoundTrigger(boolean);
+ method @NonNull public android.os.BatterySaverPolicyConfig.Builder setDisableVibration(boolean);
+ method @NonNull public android.os.BatterySaverPolicyConfig.Builder setEnableAdjustBrightness(boolean);
+ method @NonNull public android.os.BatterySaverPolicyConfig.Builder setEnableDataSaver(boolean);
+ method @NonNull public android.os.BatterySaverPolicyConfig.Builder setEnableFirewall(boolean);
+ method @NonNull public android.os.BatterySaverPolicyConfig.Builder setEnableQuickDoze(boolean);
+ method @NonNull public android.os.BatterySaverPolicyConfig.Builder setForceAllAppsStandby(boolean);
+ method @NonNull public android.os.BatterySaverPolicyConfig.Builder setForceBackgroundCheck(boolean);
+ method @NonNull public android.os.BatterySaverPolicyConfig.Builder setGpsMode(int);
+ }
+
public class Binder implements android.os.IBinder {
method public static final long clearCallingWorkSource();
method public static final int getCallingWorkSourceUid();
@@ -5440,6 +5280,8 @@
public final class PowerManager {
method @RequiresPermission(allOf={android.Manifest.permission.READ_DREAM_STATE, android.Manifest.permission.WRITE_DREAM_STATE}) public void dream(long);
method @RequiresPermission(android.Manifest.permission.POWER_SAVER) public int getPowerSaveMode();
+ method @RequiresPermission(anyOf={android.Manifest.permission.DEVICE_POWER, android.Manifest.permission.POWER_SAVER}) public boolean setAdaptivePowerSaveEnabled(boolean);
+ method @RequiresPermission(anyOf={android.Manifest.permission.DEVICE_POWER, android.Manifest.permission.POWER_SAVER}) public boolean setAdaptivePowerSavePolicy(@NonNull android.os.BatterySaverPolicyConfig);
method @RequiresPermission(android.Manifest.permission.POWER_SAVER) public boolean setDynamicPowerSavings(boolean, int);
method @RequiresPermission(anyOf={android.Manifest.permission.DEVICE_POWER, android.Manifest.permission.POWER_SAVER}) public boolean setPowerSaveMode(boolean);
method @RequiresPermission(anyOf={android.Manifest.permission.DEVICE_POWER, android.Manifest.permission.USER_ACTIVITY}) public void userActivity(long, int, int);
@@ -5578,6 +5420,7 @@
}
public final class UserHandle implements android.os.Parcelable {
+ method public static int getAppId(int);
method public int getIdentifier();
method @Deprecated public boolean isOwner();
method public boolean isSystem();
@@ -5840,6 +5683,7 @@
public static interface DeviceConfig.ActivityManager {
field public static final String KEY_COMPACT_ACTION_1 = "compact_action_1";
field public static final String KEY_COMPACT_ACTION_2 = "compact_action_2";
+ field public static final String KEY_COMPACT_STATSD_SAMPLE_RATE = "compact_statsd_sample_rate";
field public static final String KEY_COMPACT_THROTTLE_1 = "compact_throttle_1";
field public static final String KEY_COMPACT_THROTTLE_2 = "compact_throttle_2";
field public static final String KEY_COMPACT_THROTTLE_3 = "compact_throttle_3";
@@ -5855,9 +5699,9 @@
}
public static interface DeviceConfig.AttentionManagerService {
+ field public static final String COMPONENT_NAME = "component_name";
field public static final String NAMESPACE = "attention_manager_service";
- field public static final String PROPERTY_COMPONENT_NAME = "component_name";
- field public static final String PROPERTY_SERVICE_ENABLED = "service_enabled";
+ field public static final String SERVICE_ENABLED = "service_enabled";
}
public static interface DeviceConfig.ContentCapture {
@@ -5871,9 +5715,9 @@
}
public static interface DeviceConfig.IntelligenceAttention {
+ field public static final String ATTENTION_ENABLED = "attention_enabled";
+ field public static final String ATTENTION_SETTINGS = "attention_settings";
field public static final String NAMESPACE = "intelligence_attention";
- field public static final String PROPERTY_ATTENTION_ENABLED = "attention_enabled";
- field public static final String PROPERTY_ATTENTION_SETTINGS = "attention_settings";
}
public static interface DeviceConfig.NotificationAssistant {
@@ -5888,8 +5732,8 @@
public static interface DeviceConfig.Privacy {
field public static final String NAMESPACE = "privacy";
- field public static final String PROPERTY_LOCATION_ACCESS_CHECK_ENABLED = "enable_location_access_check";
- field public static final String PROPERTY_PERMISSIONS_HUB_ENABLED = "enable_permissions_hub";
+ field public static final String PROPERTY_LOCATION_ACCESS_CHECK_ENABLED = "location_access_check_enabled";
+ field public static final String PROPERTY_PERMISSIONS_HUB_ENABLED = "permissions_hub_enabled";
}
public static interface DeviceConfig.RuntimeNative {
@@ -5903,8 +5747,9 @@
public static interface DeviceConfig.Telephony {
field public static final String NAMESPACE = "telephony";
- field public static final String PROPERTY_ENABLE_RAMPING_RINGER = "enable_ramping_ringer";
- field public static final String PROPERTY_RAMPING_RINGER_DURATION = "ramping_duration";
+ field public static final String RAMPING_RINGER_DURATION = "ramping_ringer_duration";
+ field public static final String RAMPING_RINGER_ENABLED = "ramping_ringer_enabled";
+ field public static final String RAMPING_RINGER_VIBRATION_DURATION = "ramping_ringer_vibration_duration";
}
public final class DocumentsContract {
@@ -7927,6 +7772,7 @@
method @RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE) public boolean getEmergencyCallbackMode();
method @RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE) public String getIsimDomain();
method @RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE) public String getIsimIst();
+ method @NonNull @RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE) public java.util.List<android.util.Pair<java.lang.Integer,java.lang.Integer>> getLogicalToPhysicalSlotMapping();
method @RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE) public long getPreferredNetworkTypeBitmap();
method @RequiresPermission(anyOf={android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE, android.Manifest.permission.READ_PHONE_STATE}) public int getRadioPowerState();
method public int getSimApplicationState();
diff --git a/api/test-current.txt b/api/test-current.txt
index 91d0019..9023a85 100644
--- a/api/test-current.txt
+++ b/api/test-current.txt
@@ -242,6 +242,7 @@
public class NotificationManager {
method public android.content.ComponentName getEffectsSuppressor();
+ method public boolean matchesCallFilter(android.os.Bundle);
}
public final class PictureInPictureParams implements android.os.Parcelable {
@@ -332,6 +333,91 @@
}
+package android.app.prediction {
+
+ public final class AppPredictionContext implements android.os.Parcelable {
+ method public int describeContents();
+ method @Nullable public android.os.Bundle getExtras();
+ method @NonNull public String getPackageName();
+ method public int getPredictedTargetCount();
+ method public String getUiSurface();
+ method public void writeToParcel(android.os.Parcel, int);
+ field public static final android.os.Parcelable.Creator<android.app.prediction.AppPredictionContext> CREATOR;
+ }
+
+ public static final class AppPredictionContext.Builder {
+ ctor public AppPredictionContext.Builder(@NonNull android.content.Context);
+ method public android.app.prediction.AppPredictionContext build();
+ method public android.app.prediction.AppPredictionContext.Builder setExtras(@Nullable android.os.Bundle);
+ method public android.app.prediction.AppPredictionContext.Builder setPredictedTargetCount(int);
+ method public android.app.prediction.AppPredictionContext.Builder setUiSurface(@Nullable String);
+ }
+
+ public final class AppPredictionManager {
+ method public android.app.prediction.AppPredictor createAppPredictionSession(@NonNull android.app.prediction.AppPredictionContext);
+ }
+
+ public final class AppPredictionSessionId implements android.os.Parcelable {
+ method public int describeContents();
+ method public void writeToParcel(android.os.Parcel, int);
+ field public static final android.os.Parcelable.Creator<android.app.prediction.AppPredictionSessionId> CREATOR;
+ }
+
+ public final class AppPredictor {
+ method public void destroy();
+ method public android.app.prediction.AppPredictionSessionId getSessionId();
+ method public void notifyAppTargetEvent(@NonNull android.app.prediction.AppTargetEvent);
+ method public void notifyLocationShown(@NonNull String, @NonNull java.util.List<android.app.prediction.AppTargetId>);
+ method public void registerPredictionUpdates(@NonNull java.util.concurrent.Executor, @NonNull android.app.prediction.AppPredictor.Callback);
+ method public void requestPredictionUpdate();
+ method @Nullable public void sortTargets(@NonNull java.util.List<android.app.prediction.AppTarget>, @NonNull java.util.concurrent.Executor, @NonNull java.util.function.Consumer<java.util.List<android.app.prediction.AppTarget>>);
+ method public void unregisterPredictionUpdates(@NonNull android.app.prediction.AppPredictor.Callback);
+ }
+
+ public static interface AppPredictor.Callback {
+ method public void onTargetsAvailable(@NonNull java.util.List<android.app.prediction.AppTarget>);
+ }
+
+ public final class AppTarget implements android.os.Parcelable {
+ ctor public AppTarget(@NonNull android.app.prediction.AppTargetId, @NonNull String, @Nullable String, @NonNull android.os.UserHandle);
+ method public int describeContents();
+ method @Nullable public String getClassName();
+ method @NonNull public android.app.prediction.AppTargetId getId();
+ method @NonNull public String getPackageName();
+ method public int getRank();
+ method @Nullable public android.content.pm.ShortcutInfo getShortcutInfo();
+ method @NonNull public android.os.UserHandle getUser();
+ method public void writeToParcel(android.os.Parcel, int);
+ field public static final android.os.Parcelable.Creator<android.app.prediction.AppTarget> CREATOR;
+ }
+
+ public final class AppTargetEvent implements android.os.Parcelable {
+ method public int describeContents();
+ method @NonNull public int getAction();
+ method @NonNull public String getLaunchLocation();
+ method @Nullable public android.app.prediction.AppTarget getTarget();
+ method public void writeToParcel(android.os.Parcel, int);
+ field public static final int ACTION_DISMISS = 2; // 0x2
+ field public static final int ACTION_LAUNCH = 1; // 0x1
+ field public static final int ACTION_PIN = 3; // 0x3
+ field public static final android.os.Parcelable.Creator<android.app.prediction.AppTargetEvent> CREATOR;
+ }
+
+ public static final class AppTargetEvent.Builder {
+ ctor public AppTargetEvent.Builder(@Nullable android.app.prediction.AppTarget, int);
+ method public android.app.prediction.AppTargetEvent build();
+ method public android.app.prediction.AppTargetEvent.Builder setLaunchLocation(String);
+ }
+
+ public final class AppTargetId implements android.os.Parcelable {
+ ctor public AppTargetId(@NonNull String);
+ method public int describeContents();
+ method public void writeToParcel(android.os.Parcel, int);
+ field public static final android.os.Parcelable.Creator<android.app.prediction.AppTargetId> CREATOR;
+ }
+
+}
+
package android.app.role {
public final class RoleManager {
@@ -518,23 +604,10 @@
package android.graphics {
- public final class Bitmap implements android.os.Parcelable {
- method public void eraseColor(@ColorLong long);
- method public android.graphics.Color getColor(int, int);
- method public void setColorSpace(@NonNull android.graphics.ColorSpace);
- }
-
public final class ImageDecoder implements java.lang.AutoCloseable {
method @AnyThread @NonNull public static android.graphics.ImageDecoder.Source createSource(android.content.res.Resources, java.io.InputStream, int);
}
- public class Paint {
- method @ColorLong public long getColorLong();
- method @ColorLong public long getShadowLayerColorLong();
- method public void setColor(@ColorLong long);
- method public void setShadowLayer(float, float, float, @ColorLong long);
- }
-
}
package android.graphics.drawable {
@@ -754,6 +827,17 @@
method public android.media.BufferingParams.Builder setResumePlaybackMarkMs(int);
}
+ public class MediaPlayer2 implements android.media.AudioRouting java.lang.AutoCloseable {
+ 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 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;
+ method public void setDrmPropertyString(@NonNull android.media.DataSourceDesc, @NonNull String, @NonNull String) throws android.media.MediaPlayer2.NoDrmSchemeException;
+ }
+
public final class PlaybackParams implements android.os.Parcelable {
method public int getAudioStretchMode();
method public android.media.PlaybackParams setAudioStretchMode(int);
@@ -873,6 +957,10 @@
method public boolean satisfiedByNetworkCapabilities(android.net.NetworkCapabilities);
}
+ public class NetworkStack {
+ field public static final String PERMISSION_MAINLINE_NETWORK_STACK = "android.permission.MAINLINE_NETWORK_STACK";
+ }
+
public final class RouteInfo implements android.os.Parcelable {
ctor public RouteInfo(android.net.IpPrefix, java.net.InetAddress, String, int);
method public int getType();
@@ -1660,7 +1748,7 @@
public static interface DeviceConfig.Privacy {
field public static final String NAMESPACE = "privacy";
- field public static final String PROPERTY_LOCATION_ACCESS_CHECK_ENABLED = "enable_location_access_check";
+ field public static final String PROPERTY_LOCATION_ACCESS_CHECK_ENABLED = "location_access_check_enabled";
}
public final class MediaStore {
@@ -1774,6 +1862,24 @@
}
+package android.service.appprediction {
+
+ public abstract class AppPredictionService extends android.app.Service {
+ ctor public AppPredictionService();
+ method @MainThread public abstract void onAppTargetEvent(@NonNull android.app.prediction.AppPredictionSessionId, @NonNull android.app.prediction.AppTargetEvent);
+ method public final android.os.IBinder onBind(android.content.Intent);
+ method public void onCreatePredictionSession(@NonNull android.app.prediction.AppPredictionContext, @NonNull android.app.prediction.AppPredictionSessionId);
+ method @MainThread public void onDestroyPredictionSession(@NonNull android.app.prediction.AppPredictionSessionId);
+ method @MainThread public abstract void onLocationShown(@NonNull android.app.prediction.AppPredictionSessionId, @NonNull String, @NonNull java.util.List<android.app.prediction.AppTargetId>);
+ method @MainThread public abstract void onRequestPredictionUpdate(@NonNull android.app.prediction.AppPredictionSessionId);
+ method @MainThread public abstract void onSortAppTargets(@NonNull android.app.prediction.AppPredictionSessionId, @NonNull java.util.List<android.app.prediction.AppTarget>, @NonNull android.os.CancellationSignal, @NonNull java.util.function.Consumer<java.util.List<android.app.prediction.AppTarget>>);
+ method @MainThread public void onStartPredictionUpdates();
+ method @MainThread public void onStopPredictionUpdates();
+ method public final void updatePredictions(@NonNull android.app.prediction.AppPredictionSessionId, @NonNull java.util.List<android.app.prediction.AppTarget>);
+ }
+
+}
+
package android.service.autofill {
public abstract class AutofillFieldClassificationService extends android.app.Service {
diff --git a/cmds/statsd/src/atoms.proto b/cmds/statsd/src/atoms.proto
index 30df850..427662a 100644
--- a/cmds/statsd/src/atoms.proto
+++ b/cmds/statsd/src/atoms.proto
@@ -234,6 +234,7 @@
BluetoothBondStateChanged bluetooth_bond_state_changed = 165;
BluetoothClassicPairingEventReported bluetooth_classic_pairing_event_reported = 166;
BluetoothSmpPairingEventReported bluetooth_smp_pairing_event_reported = 167;
+ ScreenTimeoutExtensionReported screen_timeout_extension_reported = 168;
}
// Pulled events will start at field 10000.
@@ -288,6 +289,7 @@
DebugElapsedClock debug_elapsed_clock = 10046;
DebugFailingElapsedClock debug_failing_elapsed_clock = 10047;
NumBiometricsEnrolled num_faces_enrolled = 10048;
+ RoleHolder role_holder = 10049;
}
// DO NOT USE field numbers above 100,000 in AOSP.
@@ -3973,6 +3975,20 @@
optional int32 num_enrolled = 2;
}
+/**
+ * A mapping of role holder -> role
+ */
+message RoleHolder {
+ // uid of the role holder
+ optional int32 uid = 1 [(is_uid) = true];
+
+ // package name of the role holder
+ optional string package_name = 2;
+
+ // the role held
+ optional string role = 3;
+}
+
message AggStats {
optional int64 min = 1;
@@ -4968,17 +4984,17 @@
* packages/apps/Nfc/src/com/android/nfc/cardemulation/AidRoutingManager.java
*/
message NfcErrorOccurred {
- enum Type {
- UNKNOWN = 0;
- CMD_TIMEOUT = 1;
- ERROR_NOTIFICATION = 2;
- AID_OVERFLOW = 3;
- }
- optional Type type = 1;
- // If it's nci cmd timeout, log the timeout command.
- optional uint32 nci_cmd = 2;
+ enum Type {
+ UNKNOWN = 0;
+ CMD_TIMEOUT = 1;
+ ERROR_NOTIFICATION = 2;
+ AID_OVERFLOW = 3;
+ }
+ optional Type type = 1;
+ // If it's nci cmd timeout, log the timeout command.
+ optional uint32 nci_cmd = 2;
- optional uint32 error_ntf_status_code = 3;
+ optional uint32 error_ntf_status_code = 3;
}
/**
@@ -4987,14 +5003,14 @@
* packages/apps/Nfc/src/com/android/nfc/NfcService.java
*/
message NfcStateChanged {
- enum State {
- UNKNOWN = 0;
- OFF = 1;
- ON = 2;
- ON_LOCKED = 3; // Secure Nfc enabled.
- CRASH_RESTART = 4; // NfcService watchdog timeout restart.
- }
- optional State state = 1;
+ enum State {
+ UNKNOWN = 0;
+ OFF = 1;
+ ON = 2;
+ ON_LOCKED = 3; // Secure Nfc enabled.
+ CRASH_RESTART = 4; // NfcService watchdog timeout restart.
+ }
+ optional State state = 1;
}
/**
@@ -5003,12 +5019,12 @@
* packages/apps/Nfc/src/com/android/nfc/P2pLinkManager.java
*/
message NfcBeamOccurred {
- enum Operation {
- UNKNOWN = 0;
- SEND = 1;
- RECEIVE = 2;
- }
- optional Operation operation = 1;
+ enum Operation {
+ UNKNOWN = 0;
+ SEND = 1;
+ RECEIVE = 2;
+ }
+ optional Operation operation = 1;
}
/**
@@ -5018,16 +5034,16 @@
* packages/apps/Nfc/src/com/android/nfc/cardemulation/HostNfcFEmulationManager.java
*/
message NfcCardemulationOccurred {
- enum Category {
- UNKNOWN = 0;
- HCE_PAYMENT = 1;
- HCE_OTHER = 2;
- OFFHOST = 3;
- }
- // Transaction belongs to HCE payment or HCE other category, or offhost.
- optional Category category = 1;
- // SeName from transaction: SIMx, eSEx, HCE, HCEF.
- optional string se_name = 2;
+ enum Category {
+ UNKNOWN = 0;
+ HCE_PAYMENT = 1;
+ HCE_OTHER = 2;
+ OFFHOST = 3;
+ }
+ // Transaction belongs to HCE payment or HCE other category, or offhost.
+ optional Category category = 1;
+ // SeName from transaction: SIMx, eSEx, HCE, HCEF.
+ optional string se_name = 2;
}
/**
@@ -5036,16 +5052,16 @@
* packages/apps/Nfc/src/com/android/nfc/NfcDispatcher.java
*/
message NfcTagOccurred {
- enum Type {
- UNKNOWN = 0;
- URL = 1;
- BT_PAIRING = 2;
- PROVISION = 3;
- WIFI_CONNECT = 4;
- APP_LAUNCH = 5;
- OTHERS = 6;
- }
- optional Type type = 1;
+ enum Type {
+ UNKNOWN = 0;
+ URL = 1;
+ BT_PAIRING = 2;
+ PROVISION = 3;
+ WIFI_CONNECT = 4;
+ APP_LAUNCH = 5;
+ OTHERS = 6;
+ }
+ optional Type type = 1;
}
/**
@@ -5065,18 +5081,18 @@
* packages/apps/SecureElement/src/com/android/se/Terminal.java
*/
message SeStateChanged {
- enum State {
- UNKNOWN = 0;
- INITIALIZED = 1;
- DISCONNECTED = 2;
- CONNECTED = 3;
- HALCRASH = 4;
- }
- optional State state = 1;
+ enum State {
+ UNKNOWN = 0;
+ INITIALIZED = 1;
+ DISCONNECTED = 2;
+ CONNECTED = 3;
+ HALCRASH = 4;
+ }
+ optional State state = 1;
- optional string state_change_reason = 2;
- // SIMx or eSEx.
- optional string terminal = 3;
+ optional string state_change_reason = 2;
+ // SIMx or eSEx.
+ optional string terminal = 3;
}
/**
@@ -5085,15 +5101,15 @@
* packages/apps/SecureElement/src/com/android/se/Terminal.java
*/
message SeOmapiReported {
- enum Operation {
- UNKNOWN = 0;
- OPEN_CHANNEL = 1;
- }
- optional Operation operation = 1;
- // SIMx or eSEx.
- optional string terminal = 2;
+ enum Operation {
+ UNKNOWN = 0;
+ OPEN_CHANNEL = 1;
+ }
+ optional Operation operation = 1;
+ // SIMx or eSEx.
+ optional string terminal = 2;
- optional string package_name = 3;
+ optional string package_name = 3;
}
/**
@@ -5275,3 +5291,15 @@
}
optional State state = 4;
}
+
+/**
+ * Logs PowerManagerService screen timeout resets (extensions) that happen when an attention check
+ * returns true.
+ *
+ * Logged from:
+ * frameworks/base/services/core/java/com/android/server/power/PowerManagerService.java
+ */
+message ScreenTimeoutExtensionReported {
+ // Describes how many times in a row did the power manager reset the screen off timeout.
+ optional uint32 consecutive_timeout_extended_count = 1;
+}
diff --git a/cmds/statsd/src/external/StatsPullerManager.cpp b/cmds/statsd/src/external/StatsPullerManager.cpp
index a6ba2ca..6f3eeaa7 100644
--- a/cmds/statsd/src/external/StatsPullerManager.cpp
+++ b/cmds/statsd/src/external/StatsPullerManager.cpp
@@ -220,6 +220,9 @@
// BuildInformation.
{android::util::BUILD_INFORMATION,
{.puller = new StatsCompanionServicePuller(android::util::BUILD_INFORMATION)}},
+ // RoleHolder.
+ {android::util::ROLE_HOLDER,
+ {.puller = new StatsCompanionServicePuller(android::util::ROLE_HOLDER)}},
};
StatsPullerManager::StatsPullerManager() : mNextPullTimeNs(NO_ALARM_UPDATE) {
diff --git a/core/java/android/app/ActivityThread.java b/core/java/android/app/ActivityThread.java
index 03a09ee..22dcce5 100644
--- a/core/java/android/app/ActivityThread.java
+++ b/core/java/android/app/ActivityThread.java
@@ -177,7 +177,6 @@
import java.io.IOException;
import java.io.PrintWriter;
import java.lang.ref.WeakReference;
-import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.net.InetAddress;
import java.text.DateFormat;
@@ -5936,18 +5935,6 @@
StrictMode.initThreadDefaults(data.appInfo);
StrictMode.initVmDefaults(data.appInfo);
- // We deprecated Build.SERIAL and only apps that target pre NMR1
- // SDK can see it. Since access to the serial is now behind a
- // permission we push down the value and here we fix it up
- // before any app code has been loaded.
- try {
- Field field = Build.class.getDeclaredField("SERIAL");
- field.setAccessible(true);
- field.set(Build.class, data.buildSerial);
- } catch (NoSuchFieldException | IllegalAccessException e) {
- /* ignore */
- }
-
if (data.debugMode != ApplicationThreadConstants.DEBUG_OFF) {
// XXX should have option to change the port.
Debug.changeDebugPort(8100);
@@ -6083,7 +6070,12 @@
instrApp.initForUser(UserHandle.myUserId());
final LoadedApk pi = getPackageInfo(instrApp, data.compatInfo,
appContext.getClassLoader(), false, true, false);
- final ContextImpl instrContext = ContextImpl.createAppContext(this, pi);
+
+ // The test context's op package name == the target app's op package name, because
+ // the app ops manager checks the op package name against the real calling UID,
+ // which is what the target package name is associated with.
+ final ContextImpl instrContext = ContextImpl.createAppContext(this, pi,
+ appContext.getOpPackageName());
try {
final ClassLoader cl = instrContext.getClassLoader();
diff --git a/core/java/android/app/ContextImpl.java b/core/java/android/app/ContextImpl.java
index 92cdb20..1a728c1 100644
--- a/core/java/android/app/ContextImpl.java
+++ b/core/java/android/app/ContextImpl.java
@@ -2128,7 +2128,7 @@
flags | CONTEXT_REGISTER_PACKAGE);
if (pi != null) {
ContextImpl c = new ContextImpl(this, mMainThread, pi, null, mActivityToken,
- new UserHandle(UserHandle.getUserId(application.uid)), flags, null);
+ new UserHandle(UserHandle.getUserId(application.uid)), flags, null, null);
final int displayId = getDisplayId();
@@ -2156,14 +2156,14 @@
// The system resources are loaded in every application, so we can safely copy
// the context without reloading Resources.
return new ContextImpl(this, mMainThread, mPackageInfo, null, mActivityToken, user,
- flags, null);
+ flags, null, null);
}
LoadedApk pi = mMainThread.getPackageInfo(packageName, mResources.getCompatibilityInfo(),
flags | CONTEXT_REGISTER_PACKAGE, user.getIdentifier());
if (pi != null) {
ContextImpl c = new ContextImpl(this, mMainThread, pi, null, mActivityToken, user,
- flags, null);
+ flags, null, null);
final int displayId = getDisplayId();
@@ -2190,7 +2190,7 @@
final String[] paths = mPackageInfo.getSplitPaths(splitName);
final ContextImpl context = new ContextImpl(this, mMainThread, mPackageInfo, splitName,
- mActivityToken, mUser, mFlags, classLoader);
+ mActivityToken, mUser, mFlags, classLoader, null);
final int displayId = getDisplayId();
@@ -2214,7 +2214,7 @@
}
ContextImpl context = new ContextImpl(this, mMainThread, mPackageInfo, mSplitName,
- mActivityToken, mUser, mFlags, mClassLoader);
+ mActivityToken, mUser, mFlags, mClassLoader, null);
final int displayId = getDisplayId();
context.setResources(createResources(mActivityToken, mPackageInfo, mSplitName, displayId,
@@ -2229,7 +2229,7 @@
}
ContextImpl context = new ContextImpl(this, mMainThread, mPackageInfo, mSplitName,
- mActivityToken, mUser, mFlags, mClassLoader);
+ mActivityToken, mUser, mFlags, mClassLoader, null);
final int displayId = display.getDisplayId();
context.setResources(createResources(mActivityToken, mPackageInfo, mSplitName, displayId,
@@ -2243,7 +2243,7 @@
final int flags = (mFlags & ~Context.CONTEXT_CREDENTIAL_PROTECTED_STORAGE)
| Context.CONTEXT_DEVICE_PROTECTED_STORAGE;
return new ContextImpl(this, mMainThread, mPackageInfo, mSplitName, mActivityToken, mUser,
- flags, mClassLoader);
+ flags, mClassLoader, null);
}
@Override
@@ -2251,7 +2251,7 @@
final int flags = (mFlags & ~Context.CONTEXT_DEVICE_PROTECTED_STORAGE)
| Context.CONTEXT_CREDENTIAL_PROTECTED_STORAGE;
return new ContextImpl(this, mMainThread, mPackageInfo, mSplitName, mActivityToken, mUser,
- flags, mClassLoader);
+ flags, mClassLoader, null);
}
@Override
@@ -2397,7 +2397,7 @@
static ContextImpl createSystemContext(ActivityThread mainThread) {
LoadedApk packageInfo = new LoadedApk(mainThread);
ContextImpl context = new ContextImpl(null, mainThread, packageInfo, null, null, null, 0,
- null);
+ null, null);
context.setResources(packageInfo.getResources());
context.mResources.updateConfiguration(context.mResourcesManager.getConfiguration(),
context.mResourcesManager.getDisplayMetrics());
@@ -2414,7 +2414,7 @@
static ContextImpl createSystemUiContext(ContextImpl systemContext, int displayId) {
final LoadedApk packageInfo = systemContext.mPackageInfo;
ContextImpl context = new ContextImpl(null, systemContext.mMainThread, packageInfo, null,
- null, null, 0, null);
+ null, null, 0, null, null);
context.setResources(createResources(null, packageInfo, null, displayId, null,
packageInfo.getCompatibilityInfo()));
context.updateDisplay(displayId);
@@ -2431,9 +2431,14 @@
@UnsupportedAppUsage
static ContextImpl createAppContext(ActivityThread mainThread, LoadedApk packageInfo) {
+ return createAppContext(mainThread, packageInfo, null);
+ }
+
+ static ContextImpl createAppContext(ActivityThread mainThread, LoadedApk packageInfo,
+ String opPackageName) {
if (packageInfo == null) throw new IllegalArgumentException("packageInfo");
ContextImpl context = new ContextImpl(null, mainThread, packageInfo, null, null, null, 0,
- null);
+ null, opPackageName);
context.setResources(packageInfo.getResources());
return context;
}
@@ -2461,7 +2466,7 @@
}
ContextImpl context = new ContextImpl(null, mainThread, packageInfo, activityInfo.splitName,
- activityToken, null, 0, classLoader);
+ activityToken, null, 0, classLoader, null);
// Clamp display ID to DEFAULT_DISPLAY if it is INVALID_DISPLAY.
displayId = (displayId != Display.INVALID_DISPLAY) ? displayId : Display.DEFAULT_DISPLAY;
@@ -2491,7 +2496,7 @@
private ContextImpl(@Nullable ContextImpl container, @NonNull ActivityThread mainThread,
@NonNull LoadedApk packageInfo, @Nullable String splitName,
@Nullable IBinder activityToken, @Nullable UserHandle user, int flags,
- @Nullable ClassLoader classLoader) {
+ @Nullable ClassLoader classLoader, @Nullable String overrideOpPackageName) {
mOuterContext = this;
// If creator didn't specify which storage to use, use the default
@@ -2520,9 +2525,11 @@
mClassLoader = classLoader;
mResourcesManager = ResourcesManager.getInstance();
+ String opPackageName;
+
if (container != null) {
mBasePackageName = container.mBasePackageName;
- mOpPackageName = container.mOpPackageName;
+ opPackageName = container.mOpPackageName;
setResources(container.mResources);
mDisplay = container.mDisplay;
} else {
@@ -2533,12 +2540,14 @@
// processes. For purposes of app ops, we must then consider the context as
// belonging to the package of this process, not the system itself, otherwise
// the package+uid verifications in app ops will fail.
- mOpPackageName = ActivityThread.currentPackageName();
+ opPackageName = ActivityThread.currentPackageName();
} else {
- mOpPackageName = mBasePackageName;
+ opPackageName = mBasePackageName;
}
}
+ mOpPackageName = overrideOpPackageName != null ? overrideOpPackageName : opPackageName;
+
mContentResolver = new ApplicationContentResolver(this, mainThread);
}
diff --git a/core/java/android/app/DownloadManager.java b/core/java/android/app/DownloadManager.java
index acc7094..fde1d29e 100644
--- a/core/java/android/app/DownloadManager.java
+++ b/core/java/android/app/DownloadManager.java
@@ -26,7 +26,6 @@
import android.content.ContentUris;
import android.content.ContentValues;
import android.content.Context;
-import android.content.Intent;
import android.database.Cursor;
import android.database.CursorWrapper;
import android.net.ConnectivityManager;
@@ -37,7 +36,6 @@
import android.os.FileUtils;
import android.os.ParcelFileDescriptor;
import android.provider.Downloads;
-import android.provider.MediaStore.Images;
import android.provider.Settings;
import android.provider.Settings.SettingNotFoundException;
import android.text.TextUtils;
@@ -399,14 +397,14 @@
/** if a file is designated as a MediaScanner scannable file, the following value is
* stored in the database column {@link Downloads.Impl#COLUMN_MEDIA_SCANNED}.
*/
- private static final int SCANNABLE_VALUE_YES = 0;
+ private static final int SCANNABLE_VALUE_YES = Downloads.Impl.MEDIA_NOT_SCANNED;
// value of 1 is stored in the above column by DownloadProvider after it is scanned by
// MediaScanner
/** if a file is designated as a file that should not be scanned by MediaScanner,
* the following value is stored in the database column
* {@link Downloads.Impl#COLUMN_MEDIA_SCANNED}.
*/
- private static final int SCANNABLE_VALUE_NO = 2;
+ private static final int SCANNABLE_VALUE_NO = Downloads.Impl.MEDIA_NOT_SCANNABLE;
/**
* This download is visible but only shows in the notifications
@@ -1264,19 +1262,6 @@
throw new IllegalStateException("Failed to rename to " + after);
}
- // Update MediaProvider if necessary
- if (mimeType.startsWith("image/")) {
- context.getContentResolver().delete(Images.Media.EXTERNAL_CONTENT_URI,
- Images.Media.DATA + "=?",
- new String[] {
- before.getAbsolutePath()
- });
-
- Intent intent = new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE);
- intent.setData(Uri.fromFile(after));
- context.sendBroadcast(intent);
- }
-
ContentValues values = new ContentValues();
values.put(Downloads.Impl.COLUMN_TITLE, displayName);
values.put(Downloads.Impl._DATA, after.toString());
@@ -1329,8 +1314,7 @@
* @param description the description that would appear for this file in Downloads App.
* @param isMediaScannerScannable true if the file is to be scanned by MediaScanner. Files
* scanned by MediaScanner appear in the applications used to view media (for example,
- * Gallery app). Starting from {@link android.os.Build.VERSION_CODES#Q}, this argument is
- * ignored and the file is always scanned by MediaScanner.
+ * Gallery app).
* @param mimeType mimetype of the file.
* @param path absolute pathname to the file. The file should be world-readable, so that it can
* be managed by the Downloads App and any other app that is used to read it (for example,
@@ -1359,8 +1343,7 @@
* @param description the description that would appear for this file in Downloads App.
* @param isMediaScannerScannable true if the file is to be scanned by MediaScanner. Files
* scanned by MediaScanner appear in the applications used to view media (for example,
- * Gallery app). Starting from {@link android.os.Build.VERSION_CODES#Q}, this argument is
- * ignored and the file is always scanned by MediaScanner.
+ * Gallery app).
* @param mimeType mimetype of the file.
* @param path absolute pathname to the file. The file should be world-readable, so that it can
* be managed by the Downloads App and any other app that is used to read it (for example,
diff --git a/core/java/android/app/Notification.java b/core/java/android/app/Notification.java
index 7c550d4..028e3ef 100644
--- a/core/java/android/app/Notification.java
+++ b/core/java/android/app/Notification.java
@@ -8122,6 +8122,10 @@
big.setViewVisibility(MEDIA_BUTTON_IDS[i], View.GONE);
}
}
+ bindMediaActionButton(big, R.id.media_seamless, new Action(R.drawable.ic_media_seamless,
+ mBuilder.mContext.getString(
+ com.android.internal.R.string.ext_media_seamless_action), null), p);
+ big.setViewVisibility(R.id.media_seamless, View.GONE);
handleImage(big);
return big;
}
diff --git a/core/java/android/app/NotificationManager.java b/core/java/android/app/NotificationManager.java
index 6a1ff29..8207e0a 100644
--- a/core/java/android/app/NotificationManager.java
+++ b/core/java/android/app/NotificationManager.java
@@ -828,6 +828,7 @@
/**
* @hide
*/
+ @TestApi
public boolean matchesCallFilter(Bundle extras) {
INotificationManager service = getService();
try {
diff --git a/core/java/android/app/SystemServiceRegistry.java b/core/java/android/app/SystemServiceRegistry.java
index ee13164..31a3def 100644
--- a/core/java/android/app/SystemServiceRegistry.java
+++ b/core/java/android/app/SystemServiceRegistry.java
@@ -132,11 +132,13 @@
import android.os.Build;
import android.os.DeviceIdleManager;
import android.os.DropBoxManager;
+import android.os.DynamicAndroidManager;
import android.os.HardwarePropertiesManager;
import android.os.IBatteryPropertiesRegistrar;
import android.os.IBinder;
import android.os.IDeviceIdleController;
import android.os.IDumpstate;
+import android.os.IDynamicAndroidService;
import android.os.IHardwarePropertiesManager;
import android.os.IPowerManager;
import android.os.IRecoverySystem;
@@ -1260,6 +1262,17 @@
return new RollbackManager(ctx.getOuterContext(),
IRollbackManager.Stub.asInterface(b));
}});
+
+ registerService(Context.DYNAMIC_ANDROID_SERVICE, DynamicAndroidManager.class,
+ new CachedServiceFetcher<DynamicAndroidManager>() {
+ @Override
+ public DynamicAndroidManager createService(ContextImpl ctx)
+ throws ServiceNotFoundException {
+ IBinder b = ServiceManager.getServiceOrThrow(
+ Context.DYNAMIC_ANDROID_SERVICE);
+ return new DynamicAndroidManager(
+ IDynamicAndroidService.Stub.asInterface(b));
+ }});
//CHECKSTYLE:ON IndentationCheck
}
diff --git a/core/java/android/app/ZygotePreload.java b/core/java/android/app/ZygotePreload.java
new file mode 100644
index 0000000..a295af3
--- /dev/null
+++ b/core/java/android/app/ZygotePreload.java
@@ -0,0 +1,42 @@
+/*
+ * Copyright (C) 2019 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package android.app;
+
+import android.content.pm.ApplicationInfo;
+
+/**
+ * This is the interface to be implemented for the class that is specified by the
+ * {@link android.R.styleable#AndroidManifestApplication_zygotePreloadName
+ * android:zygotePreloadName} of the <application> tag.
+ *
+ * It is responsible for preloading application code and data, that will be shared by all
+ * isolated services that have the
+ * {@link android.R.styleable#AndroidManifestService_useAppZygote android:useAppZygote} attribute
+ * of the <service> tag set to <code>true</code>.
+ *
+ * Note that this implementations of this class must provide a default constructor with no
+ * arguments.
+ */
+public interface ZygotePreload {
+ /**
+ * This method is called once every time the Application Zygote is started. It is normally
+ * started the first time an isolated service that uses it is started. The Application Zygote
+ * will be stopped when all isolated services that use it are stopped.
+ *
+ * @param appInfo The ApplicationInfo object belonging to the application
+ */
+ void doPreload(ApplicationInfo appInfo);
+}
diff --git a/core/java/android/app/admin/DevicePolicyManager.java b/core/java/android/app/admin/DevicePolicyManager.java
index f0d0aad..24d3b98 100644
--- a/core/java/android/app/admin/DevicePolicyManager.java
+++ b/core/java/android/app/admin/DevicePolicyManager.java
@@ -3149,6 +3149,7 @@
* @throws SecurityException if {@code admin} is not an active administrator or {@code admin}
* does not use {@link DeviceAdminInfo#USES_POLICY_LIMIT_PASSWORD}
*/
+ @RequiresFeature(PackageManager.FEATURE_SECURE_LOCK_SCREEN)
public void setPasswordHistoryLength(@NonNull ComponentName admin, int length) {
if (mService != null) {
try {
diff --git a/core/java/android/app/prediction/AppPredictionContext.java b/core/java/android/app/prediction/AppPredictionContext.java
index 87ccb66..2fbe6e36 100644
--- a/core/java/android/app/prediction/AppPredictionContext.java
+++ b/core/java/android/app/prediction/AppPredictionContext.java
@@ -18,6 +18,7 @@
import android.annotation.NonNull;
import android.annotation.Nullable;
import android.annotation.SystemApi;
+import android.annotation.TestApi;
import android.content.Context;
import android.os.Bundle;
import android.os.Parcel;
@@ -29,6 +30,7 @@
* @hide
*/
@SystemApi
+@TestApi
public final class AppPredictionContext implements Parcelable {
private final int mPredictedTargetCount;
@@ -73,6 +75,17 @@
}
@Override
+ public boolean equals(Object o) {
+ if (o == this) return true;
+ if (!getClass().equals(o != null ? o.getClass() : null)) return false;
+
+ AppPredictionContext other = (AppPredictionContext) o;
+ return mPredictedTargetCount == other.mPredictedTargetCount
+ && mUiSurface.equals(other.mUiSurface)
+ && mPackageName.equals(other.mPackageName);
+ }
+
+ @Override
public int describeContents() {
return 0;
}
@@ -104,6 +117,7 @@
* @hide
*/
@SystemApi
+ @TestApi
public static final class Builder {
@NonNull
@@ -116,8 +130,12 @@
private Bundle mExtras;
/**
+ * TODO(b/123591863): Add java docs
+ *
* @hide
*/
+ @SystemApi
+ @TestApi
public Builder(@NonNull Context context) {
mPackageName = context.getPackageName();
}
diff --git a/core/java/android/app/prediction/AppPredictionManager.java b/core/java/android/app/prediction/AppPredictionManager.java
index f8578d4..99f78f1 100644
--- a/core/java/android/app/prediction/AppPredictionManager.java
+++ b/core/java/android/app/prediction/AppPredictionManager.java
@@ -17,6 +17,7 @@
import android.annotation.NonNull;
import android.annotation.SystemApi;
+import android.annotation.TestApi;
import android.content.Context;
import com.android.internal.util.Preconditions;
@@ -26,6 +27,7 @@
* @hide
*/
@SystemApi
+@TestApi
public final class AppPredictionManager {
private final Context mContext;
diff --git a/core/java/android/app/prediction/AppPredictionSessionId.java b/core/java/android/app/prediction/AppPredictionSessionId.java
index 1d7308e..1e76c24 100644
--- a/core/java/android/app/prediction/AppPredictionSessionId.java
+++ b/core/java/android/app/prediction/AppPredictionSessionId.java
@@ -17,6 +17,7 @@
import android.annotation.NonNull;
import android.annotation.SystemApi;
+import android.annotation.TestApi;
import android.os.Parcel;
import android.os.Parcelable;
@@ -26,6 +27,7 @@
* @hide
*/
@SystemApi
+@TestApi
public final class AppPredictionSessionId implements Parcelable {
private final String mId;
diff --git a/core/java/android/app/prediction/AppPredictor.java b/core/java/android/app/prediction/AppPredictor.java
index 2ddbd08c..12d6ce3 100644
--- a/core/java/android/app/prediction/AppPredictor.java
+++ b/core/java/android/app/prediction/AppPredictor.java
@@ -19,6 +19,7 @@
import android.annotation.NonNull;
import android.annotation.Nullable;
import android.annotation.SystemApi;
+import android.annotation.TestApi;
import android.app.prediction.IPredictionCallback.Stub;
import android.content.Context;
import android.content.pm.ParceledListSlice;
@@ -63,6 +64,7 @@
* @hide
*/
@SystemApi
+@TestApi
public final class AppPredictor {
private static final String TAG = AppPredictor.class.getSimpleName();
@@ -102,6 +104,10 @@
* Notifies the prediction service of an app target event.
*/
public void notifyAppTargetEvent(@NonNull AppTargetEvent event) {
+ if (mIsClosed.get()) {
+ throw new IllegalStateException("This client has already been destroyed.");
+ }
+
try {
mPredictionManager.notifyAppTargetEvent(mSessionId, event);
} catch (RemoteException e) {
@@ -114,6 +120,10 @@
*/
public void notifyLocationShown(@NonNull String launchLocation,
@NonNull List<AppTargetId> targetIds) {
+ if (mIsClosed.get()) {
+ throw new IllegalStateException("This client has already been destroyed.");
+ }
+
try {
mPredictionManager.notifyLocationShown(mSessionId, launchLocation,
new ParceledListSlice<>(targetIds));
@@ -130,6 +140,10 @@
*/
public void registerPredictionUpdates(@NonNull @CallbackExecutor Executor callbackExecutor,
@NonNull AppPredictor.Callback callback) {
+ if (mIsClosed.get()) {
+ throw new IllegalStateException("This client has already been destroyed.");
+ }
+
if (mRegisteredCallbacks.containsKey(callback)) {
// Skip if this callback is already registered
return;
@@ -149,6 +163,10 @@
* callback until the callback is re-registered.
*/
public void unregisterPredictionUpdates(@NonNull AppPredictor.Callback callback) {
+ if (mIsClosed.get()) {
+ throw new IllegalStateException("This client has already been destroyed.");
+ }
+
if (!mRegisteredCallbacks.containsKey(callback)) {
// Skip if this callback was never registered
return;
@@ -168,6 +186,10 @@
* @see Callback#onTargetsAvailable(List)
*/
public void requestPredictionUpdate() {
+ if (mIsClosed.get()) {
+ throw new IllegalStateException("This client has already been destroyed.");
+ }
+
try {
mPredictionManager.requestPredictionUpdate(mSessionId);
} catch (RemoteException e) {
@@ -182,6 +204,10 @@
@Nullable
public void sortTargets(@NonNull List<AppTarget> targets,
@NonNull Executor callbackExecutor, @NonNull Consumer<List<AppTarget>> callback) {
+ if (mIsClosed.get()) {
+ throw new IllegalStateException("This client has already been destroyed.");
+ }
+
try {
mPredictionManager.sortAppTargets(mSessionId, new ParceledListSlice(targets),
new CallbackWrapper(callbackExecutor, callback));
@@ -206,6 +232,8 @@
} catch (RemoteException e) {
Log.e(TAG, "Failed to notify app target event", e);
}
+ } else {
+ throw new IllegalStateException("This client has already been destroyed.");
}
}
@@ -222,6 +250,16 @@
}
/**
+ * TODO(b/123591863): Add java docs
+ *
+ * @hide
+ */
+ @TestApi
+ public AppPredictionSessionId getSessionId() {
+ return mSessionId;
+ }
+
+ /**
* Callback for receiving prediction updates.
*/
public interface Callback {
diff --git a/core/java/android/app/prediction/AppTarget.java b/core/java/android/app/prediction/AppTarget.java
index 99c1c44..b924cec 100644
--- a/core/java/android/app/prediction/AppTarget.java
+++ b/core/java/android/app/prediction/AppTarget.java
@@ -18,6 +18,7 @@
import android.annotation.NonNull;
import android.annotation.Nullable;
import android.annotation.SystemApi;
+import android.annotation.TestApi;
import android.content.pm.ShortcutInfo;
import android.os.Parcel;
import android.os.Parcelable;
@@ -30,6 +31,7 @@
* @hide
*/
@SystemApi
+@TestApi
public final class AppTarget implements Parcelable {
private final AppTargetId mId;
@@ -42,8 +44,12 @@
private int mRank;
/**
+ * TODO(b/123591863): Add java docs
+ *
* @hide
*/
+ @SystemApi
+ @TestApi
public AppTarget(@NonNull AppTargetId id, @NonNull String packageName,
@Nullable String className, @NonNull UserHandle user) {
mId = id;
@@ -55,15 +61,19 @@
}
/**
+ * TODO(b/123591863): Add java docs
+ *
* @hide
*/
- public AppTarget(@NonNull AppTargetId id, @NonNull ShortcutInfo shortcutInfo) {
+ @SystemApi
+ public AppTarget(@NonNull AppTargetId id, @NonNull ShortcutInfo shortcutInfo,
+ @Nullable String className) {
mId = id;
mShortcutInfo = Preconditions.checkNotNull(shortcutInfo);
mPackageName = mShortcutInfo.getPackage();
mUser = mShortcutInfo.getUserHandle();
- mClassName = null;
+ mClassName = className;
}
private AppTarget(Parcel parcel) {
@@ -71,13 +81,12 @@
mShortcutInfo = parcel.readTypedObject(ShortcutInfo.CREATOR);
if (mShortcutInfo == null) {
mPackageName = parcel.readString();
- mClassName = parcel.readString();
mUser = UserHandle.of(parcel.readInt());
} else {
mPackageName = mShortcutInfo.getPackage();
mUser = mShortcutInfo.getUserHandle();
- mClassName = null;
}
+ mClassName = parcel.readString();
mRank = parcel.readInt();
}
@@ -129,11 +138,32 @@
mRank = rank;
}
+ /**
+ * Returns the rank for the target.
+ */
public int getRank() {
return mRank;
}
@Override
+ public boolean equals(Object o) {
+ if (!getClass().equals(o != null ? o.getClass() : null)) return false;
+
+ AppTarget other = (AppTarget) o;
+ boolean sameClassName = (mClassName == null && other.mClassName == null)
+ || (mClassName != null && mClassName.equals(other.mClassName));
+ boolean sameShortcutInfo = (mShortcutInfo == null && other.mShortcutInfo == null)
+ || (mShortcutInfo != null && other.mShortcutInfo != null
+ && mShortcutInfo.getId() == other.mShortcutInfo.getId());
+ return mId.equals(other.mId)
+ && mPackageName.equals(other.mPackageName)
+ && sameClassName
+ && mUser.equals(other.mUser)
+ && sameShortcutInfo
+ && mRank == other.mRank;
+ }
+
+ @Override
public int describeContents() {
return 0;
}
@@ -144,9 +174,9 @@
dest.writeTypedObject(mShortcutInfo, flags);
if (mShortcutInfo == null) {
dest.writeString(mPackageName);
- dest.writeString(mClassName);
dest.writeInt(mUser.getIdentifier());
}
+ dest.writeString(mClassName);
dest.writeInt(mRank);
}
diff --git a/core/java/android/app/prediction/AppTargetEvent.java b/core/java/android/app/prediction/AppTargetEvent.java
index 18317e1..37e41de 100644
--- a/core/java/android/app/prediction/AppTargetEvent.java
+++ b/core/java/android/app/prediction/AppTargetEvent.java
@@ -19,6 +19,7 @@
import android.annotation.NonNull;
import android.annotation.Nullable;
import android.annotation.SystemApi;
+import android.annotation.TestApi;
import android.os.Parcel;
import android.os.Parcelable;
@@ -30,6 +31,7 @@
* @hide
*/
@SystemApi
+@TestApi
public final class AppTargetEvent implements Parcelable {
/**
@@ -96,6 +98,16 @@
}
@Override
+ public boolean equals(Object o) {
+ if (!getClass().equals(o != null ? o.getClass() : null)) return false;
+
+ AppTargetEvent other = (AppTargetEvent) o;
+ return mTarget.equals(other.mTarget)
+ && mLocation.equals(other.mLocation)
+ && mAction == other.mAction;
+ }
+
+ @Override
public int describeContents() {
return 0;
}
@@ -126,6 +138,7 @@
* @hide
*/
@SystemApi
+ @TestApi
public static final class Builder {
private AppTarget mTarget;
private String mLocation;
diff --git a/core/java/android/app/prediction/AppTargetId.java b/core/java/android/app/prediction/AppTargetId.java
index 0b8fb47..639ba78 100644
--- a/core/java/android/app/prediction/AppTargetId.java
+++ b/core/java/android/app/prediction/AppTargetId.java
@@ -17,6 +17,7 @@
import android.annotation.NonNull;
import android.annotation.SystemApi;
+import android.annotation.TestApi;
import android.os.Parcel;
import android.os.Parcelable;
@@ -25,14 +26,19 @@
* @hide
*/
@SystemApi
+@TestApi
public final class AppTargetId implements Parcelable {
@NonNull
private final String mId;
/**
+ * TODO(b/123591863): Add java docs
+ *
* @hide
*/
+ @SystemApi
+ @TestApi
public AppTargetId(@NonNull String id) {
mId = id;
}
diff --git a/core/java/android/content/Context.java b/core/java/android/content/Context.java
index adc1bf2..97323ca 100644
--- a/core/java/android/content/Context.java
+++ b/core/java/android/content/Context.java
@@ -4585,6 +4585,14 @@
*/
public static final String TELEPHONY_RCS_SERVICE = "ircs";
+ /**
+ * Use with {@link #getSystemService(String)} to retrieve an
+ * {@link android.os.DynamicAndroidManager}.
+ * @hide
+ */
+ @SystemApi
+ public static final String DYNAMIC_ANDROID_SERVICE = "dynamic_android";
+
/**
* Determine whether the given permission is allowed for a particular
* process and user ID running in the system.
diff --git a/core/java/android/content/pm/ApplicationInfo.java b/core/java/android/content/pm/ApplicationInfo.java
index 5d6d144..1358bc2 100644
--- a/core/java/android/content/pm/ApplicationInfo.java
+++ b/core/java/android/content/pm/ApplicationInfo.java
@@ -1192,6 +1192,9 @@
/** @hide */
public boolean hiddenUntilInstalled;
+ /** @hide */
+ public String zygotePreloadName;
+
/**
* Represents the default policy. The actual policy used will depend on other properties of
* the application, e.g. the target SDK version.
@@ -1533,6 +1536,7 @@
compileSdkVersionCodename = orig.compileSdkVersionCodename;
mHiddenApiPolicy = orig.mHiddenApiPolicy;
hiddenUntilInstalled = orig.hiddenUntilInstalled;
+ zygotePreloadName = orig.zygotePreloadName;
}
public String toString() {
@@ -1609,6 +1613,7 @@
dest.writeString(appComponentFactory);
dest.writeInt(mHiddenApiPolicy);
dest.writeInt(hiddenUntilInstalled ? 1 : 0);
+ dest.writeString(zygotePreloadName);
}
public static final Parcelable.Creator<ApplicationInfo> CREATOR
@@ -1682,6 +1687,7 @@
appComponentFactory = source.readString();
mHiddenApiPolicy = source.readInt();
hiddenUntilInstalled = source.readInt() != 0;
+ zygotePreloadName = source.readString();
}
/**
diff --git a/core/java/android/content/pm/ILauncherApps.aidl b/core/java/android/content/pm/ILauncherApps.aidl
index d1bc377..50bb3c7 100644
--- a/core/java/android/content/pm/ILauncherApps.aidl
+++ b/core/java/android/content/pm/ILauncherApps.aidl
@@ -24,6 +24,8 @@
import android.content.pm.ApplicationInfo;
import android.content.pm.IOnAppsChangedListener;
import android.content.pm.LauncherApps;
+import android.content.pm.IPackageInstallerCallback;
+import android.content.pm.PackageInstaller;
import android.content.pm.ParceledListSlice;
import android.content.pm.ResolveInfo;
import android.content.pm.ShortcutInfo;
@@ -44,6 +46,9 @@
String callingPackage, String packageName, in UserHandle user);
ActivityInfo resolveActivity(
String callingPackage, in ComponentName component, in UserHandle user);
+ void startSessionDetailsActivityAsUser(in IApplicationThread caller, String callingPackage,
+ in PackageInstaller.SessionInfo sessionInfo, in Rect sourceBounds, in Bundle opts,
+ in UserHandle user);
void startActivityAsUser(in IApplicationThread caller, String callingPackage,
in ComponentName component, in Rect sourceBounds,
in Bundle opts, in UserHandle user);
@@ -79,4 +84,9 @@
String callingPackage, String packageName, in UserHandle user);
IntentSender getShortcutConfigActivityIntent(String callingPackage, in ComponentName component,
in UserHandle user);
+
+ // Unregister is performed using package installer
+ void registerPackageInstallerCallback(String callingPackage,
+ in IPackageInstallerCallback callback);
+ ParceledListSlice getAllSessions(String callingPackage);
}
diff --git a/core/java/android/content/pm/LauncherApps.java b/core/java/android/content/pm/LauncherApps.java
index 98dd9b3..b0d16cd 100644
--- a/core/java/android/content/pm/LauncherApps.java
+++ b/core/java/android/content/pm/LauncherApps.java
@@ -16,6 +16,7 @@
package android.content.pm;
+import android.annotation.CallbackExecutor;
import android.annotation.IntDef;
import android.annotation.NonNull;
import android.annotation.Nullable;
@@ -32,6 +33,9 @@
import android.content.Context;
import android.content.Intent;
import android.content.IntentSender;
+import android.content.pm.PackageInstaller.SessionCallback;
+import android.content.pm.PackageInstaller.SessionCallbackDelegate;
+import android.content.pm.PackageInstaller.SessionInfo;
import android.content.pm.PackageManager.ApplicationInfoFlags;
import android.content.pm.PackageManager.NameNotFoundException;
import android.content.res.Resources;
@@ -65,7 +69,9 @@
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
+import java.util.Iterator;
import java.util.List;
+import java.util.concurrent.Executor;
/**
* Class for retrieving a list of launchable activities for the current user and any associated
@@ -154,8 +160,8 @@
private final PackageManager mPm;
private final UserManager mUserManager;
- private List<CallbackMessageHandler> mCallbacks
- = new ArrayList<CallbackMessageHandler>();
+ private final List<CallbackMessageHandler> mCallbacks = new ArrayList<>();
+ private final List<SessionCallbackDelegate> mDelegates = new ArrayList<>();
/**
* Callbacks for package changes to this and related managed profiles.
@@ -572,6 +578,24 @@
}
/**
+ * Starts an activity to show the details of the specified session.
+ *
+ * @param sessionInfo The SessionInfo of the session
+ * @param sourceBounds The Rect containing the source bounds of the clicked icon
+ * @param opts Options to pass to startActivity
+ */
+ public void startPackageInstallerSessionDetailsActivity(SessionInfo sessionInfo,
+ Rect sourceBounds, Bundle opts) {
+ try {
+ mService.startSessionDetailsActivityAsUser(mContext.getIApplicationThread(),
+ mContext.getPackageName(), sessionInfo, sourceBounds, opts,
+ sessionInfo.getUser());
+ } catch (RemoteException re) {
+ throw re.rethrowFromSystemServer();
+ }
+ }
+
+ /**
* Starts the settings activity to show the application details for a
* package in the specified profile.
*
@@ -1131,7 +1155,7 @@
}
/**
- * Registers a callback for changes to packages in current and managed profiles.
+ * Registers a callback for changes to packages in this user and managed profiles.
*
* @param callback The callback to register.
*/
@@ -1140,7 +1164,7 @@
}
/**
- * Registers a callback for changes to packages in current and managed profiles.
+ * Registers a callback for changes to packages in this user and managed profiles.
*
* @param callback The callback to register.
* @param handler that should be used to post callbacks on, may be null.
@@ -1446,6 +1470,64 @@
}
/**
+ * Register a callback to watch for session lifecycle events in this user and managed profiles.
+ * @param callback The callback to register.
+ * @param executor {@link Executor} to handle the callbacks, cannot be null.
+ *
+ * @see PackageInstaller#registerSessionCallback(SessionCallback)
+ */
+ public void registerPackageInstallerSessionCallback(
+ @NonNull @CallbackExecutor Executor executor, @NonNull SessionCallback callback) {
+ if (executor == null) {
+ throw new NullPointerException("Executor must not be null");
+ }
+
+ synchronized (mDelegates) {
+ final SessionCallbackDelegate delegate = new SessionCallbackDelegate(callback,
+ executor);
+ try {
+ mService.registerPackageInstallerCallback(mContext.getPackageName(),
+ delegate);
+ } catch (RemoteException e) {
+ throw e.rethrowFromSystemServer();
+ }
+ mDelegates.add(delegate);
+ }
+ }
+
+ /**
+ * Unregisters a callback that was previously registered.
+ *
+ * @param callback The callback to unregister.
+ * @see #registerPackageInstallerSessionCallback(Executor, SessionCallback)
+ */
+ public void unregisterPackageInstallerSessionCallback(SessionCallback callback) {
+ synchronized (mDelegates) {
+ for (Iterator<SessionCallbackDelegate> i = mDelegates.iterator(); i.hasNext();) {
+ final SessionCallbackDelegate delegate = i.next();
+ if (delegate.mCallback == callback) {
+ mPm.getPackageInstaller().unregisterSessionCallback(delegate.mCallback);
+ i.remove();
+ }
+ }
+ }
+ }
+
+ /**
+ * Return list of all known install sessions in this user and managed profiles, regardless
+ * of the installer.
+ *
+ * @see PackageInstaller#getAllSessions()
+ */
+ public @NonNull List<SessionInfo> getAllPackageInstallerSessions() {
+ try {
+ return mService.getAllSessions(mContext.getPackageName()).getList();
+ } catch (RemoteException e) {
+ throw e.rethrowFromSystemServer();
+ }
+ }
+
+ /**
* A helper method to extract a {@link PinItemRequest} set to
* the {@link #EXTRA_PIN_ITEM_REQUEST} extra.
*/
diff --git a/core/java/android/content/pm/PackageInstaller.java b/core/java/android/content/pm/PackageInstaller.java
index 2dc014c..4f674bd 100644
--- a/core/java/android/content/pm/PackageInstaller.java
+++ b/core/java/android/content/pm/PackageInstaller.java
@@ -36,20 +36,21 @@
import android.os.Build;
import android.os.FileBridge;
import android.os.Handler;
-import android.os.Looper;
-import android.os.Message;
+import android.os.HandlerExecutor;
import android.os.Parcel;
import android.os.ParcelFileDescriptor;
import android.os.Parcelable;
import android.os.ParcelableException;
import android.os.RemoteException;
import android.os.SystemProperties;
+import android.os.UserHandle;
import android.system.ErrnoException;
import android.system.Os;
import android.util.ExceptionUtils;
import com.android.internal.util.IndentingPrintWriter;
import com.android.internal.util.Preconditions;
+import com.android.internal.util.function.pooled.PooledLambda;
import java.io.Closeable;
import java.io.IOException;
@@ -61,6 +62,7 @@
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
+import java.util.concurrent.Executor;
/**
* Offers the ability to install, upgrade, and remove applications on the
@@ -659,8 +661,7 @@
}
/** {@hide} */
- private static class SessionCallbackDelegate extends IPackageInstallerCallback.Stub implements
- Handler.Callback {
+ static class SessionCallbackDelegate extends IPackageInstallerCallback.Stub {
private static final int MSG_SESSION_CREATED = 1;
private static final int MSG_SESSION_BADGING_CHANGED = 2;
private static final int MSG_SESSION_ACTIVE_CHANGED = 3;
@@ -668,63 +669,41 @@
private static final int MSG_SESSION_FINISHED = 5;
final SessionCallback mCallback;
- final Handler mHandler;
+ final Executor mExecutor;
- public SessionCallbackDelegate(SessionCallback callback, Looper looper) {
+ SessionCallbackDelegate(SessionCallback callback, Executor executor) {
mCallback = callback;
- mHandler = new Handler(looper, this);
- }
-
- @Override
- public boolean handleMessage(Message msg) {
- final int sessionId = msg.arg1;
- switch (msg.what) {
- case MSG_SESSION_CREATED:
- mCallback.onCreated(sessionId);
- return true;
- case MSG_SESSION_BADGING_CHANGED:
- mCallback.onBadgingChanged(sessionId);
- return true;
- case MSG_SESSION_ACTIVE_CHANGED:
- final boolean active = msg.arg2 != 0;
- mCallback.onActiveChanged(sessionId, active);
- return true;
- case MSG_SESSION_PROGRESS_CHANGED:
- mCallback.onProgressChanged(sessionId, (float) msg.obj);
- return true;
- case MSG_SESSION_FINISHED:
- mCallback.onFinished(sessionId, msg.arg2 != 0);
- return true;
- }
- return false;
+ mExecutor = executor;
}
@Override
public void onSessionCreated(int sessionId) {
- mHandler.obtainMessage(MSG_SESSION_CREATED, sessionId, 0).sendToTarget();
+ mExecutor.execute(PooledLambda.obtainRunnable(SessionCallback::onCreated, mCallback,
+ sessionId).recycleOnUse());
}
@Override
public void onSessionBadgingChanged(int sessionId) {
- mHandler.obtainMessage(MSG_SESSION_BADGING_CHANGED, sessionId, 0).sendToTarget();
+ mExecutor.execute(PooledLambda.obtainRunnable(SessionCallback::onBadgingChanged,
+ mCallback, sessionId).recycleOnUse());
}
@Override
public void onSessionActiveChanged(int sessionId, boolean active) {
- mHandler.obtainMessage(MSG_SESSION_ACTIVE_CHANGED, sessionId, active ? 1 : 0)
- .sendToTarget();
+ mExecutor.execute(PooledLambda.obtainRunnable(SessionCallback::onActiveChanged,
+ mCallback, sessionId, active).recycleOnUse());
}
@Override
public void onSessionProgressChanged(int sessionId, float progress) {
- mHandler.obtainMessage(MSG_SESSION_PROGRESS_CHANGED, sessionId, 0, progress)
- .sendToTarget();
+ mExecutor.execute(PooledLambda.obtainRunnable(SessionCallback::onProgressChanged,
+ mCallback, sessionId, progress).recycleOnUse());
}
@Override
public void onSessionFinished(int sessionId, boolean success) {
- mHandler.obtainMessage(MSG_SESSION_FINISHED, sessionId, success ? 1 : 0)
- .sendToTarget();
+ mExecutor.execute(PooledLambda.obtainRunnable(SessionCallback::onFinished,
+ mCallback, sessionId, success).recycleOnUse());
}
}
@@ -758,7 +737,7 @@
public void registerSessionCallback(@NonNull SessionCallback callback, @NonNull Handler handler) {
synchronized (mDelegates) {
final SessionCallbackDelegate delegate = new SessionCallbackDelegate(callback,
- handler.getLooper());
+ new HandlerExecutor(handler));
try {
mInstaller.registerCallback(delegate, mUserId);
} catch (RemoteException e) {
@@ -1649,6 +1628,8 @@
@UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P, trackingBug = 115609023)
public int sessionId;
/** {@hide} */
+ public int userId;
+ /** {@hide} */
@UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P, trackingBug = 115609023)
public String installerPackageName;
/** {@hide} */
@@ -1720,6 +1701,7 @@
/** {@hide} */
public SessionInfo(Parcel source) {
sessionId = source.readInt();
+ userId = source.readInt();
installerPackageName = source.readString();
resolvedBaseCodePath = source.readString();
progress = source.readFloat();
@@ -1761,6 +1743,13 @@
}
/**
+ * Return the user associated with this session.
+ */
+ public UserHandle getUser() {
+ return new UserHandle(userId);
+ }
+
+ /**
* Return the package name of the app that owns this session.
*/
public @Nullable String getInstallerPackageName() {
@@ -2091,6 +2080,7 @@
@Override
public void writeToParcel(Parcel dest, int flags) {
dest.writeInt(sessionId);
+ dest.writeInt(userId);
dest.writeString(installerPackageName);
dest.writeString(resolvedBaseCodePath);
dest.writeFloat(progress);
diff --git a/core/java/android/content/pm/PackageParser.java b/core/java/android/content/pm/PackageParser.java
index eb59cfc..1fab443 100644
--- a/core/java/android/content/pm/PackageParser.java
+++ b/core/java/android/content/pm/PackageParser.java
@@ -3907,6 +3907,9 @@
outError[0] = "Invalid class loader name: " + ai.classLoaderName;
}
+ ai.zygotePreloadName = sa.getString(
+ com.android.internal.R.styleable.AndroidManifestApplication_zygotePreloadName);
+
sa.recycle();
if (outError[0] != null) {
diff --git a/core/java/android/content/rollback/IRollbackManager.aidl b/core/java/android/content/rollback/IRollbackManager.aidl
index 32e2198..104661f 100644
--- a/core/java/android/content/rollback/IRollbackManager.aidl
+++ b/core/java/android/content/rollback/IRollbackManager.aidl
@@ -32,7 +32,7 @@
// Exposed for use from the system server only. Callback from the package
// manager during the install flow when user data can be restored for a given
// package.
- void restoreUserData(String packageName, int userId, int appId, long ceDataInode,
+ void restoreUserData(String packageName, in int[] userIds, int appId, long ceDataInode,
String seInfo, int token);
// Exposed for test purposes only.
diff --git a/core/java/android/net/ConnectivityManager.java b/core/java/android/net/ConnectivityManager.java
index ef8ca9e..1656c6f 100644
--- a/core/java/android/net/ConnectivityManager.java
+++ b/core/java/android/net/ConnectivityManager.java
@@ -1033,34 +1033,6 @@
}
}
- /**
- * Configures an always-on VPN connection through a specific application.
- * This connection is automatically granted and persisted after a reboot.
- *
- * <p>The designated package should declare a {@link VpnService} in its
- * manifest guarded by {@link android.Manifest.permission.BIND_VPN_SERVICE},
- * otherwise the call will fail.
- *
- * @param userId The identifier of the user to set an always-on VPN for.
- * @param vpnPackage The package name for an installed VPN app on the device, or {@code null}
- * to remove an existing always-on VPN configuration.
- * @param lockdownEnabled {@code true} to disallow networking when the VPN is not connected or
- * {@code false} otherwise.
- * @return {@code true} if the package is set as always-on VPN controller;
- * {@code false} otherwise.
- * @hide
- */
- @RequiresPermission(android.Manifest.permission.CONTROL_ALWAYS_ON_VPN)
- public boolean setAlwaysOnVpnPackageForUser(int userId, @Nullable String vpnPackage,
- boolean lockdownEnabled) {
- try {
- return mService.setAlwaysOnVpnPackage(
- userId, vpnPackage, lockdownEnabled, /* whitelist */ null);
- } catch (RemoteException e) {
- throw e.rethrowFromSystemServer();
- }
- }
-
/**
* Returns the package name of the currently set always-on VPN application.
* If there is no always-on VPN set, or the VPN is provided by the system instead
@@ -2609,6 +2581,7 @@
}
/** {@hide} */
+ @SystemApi
public static final int TETHER_ERROR_NO_ERROR = 0;
/** {@hide} */
public static final int TETHER_ERROR_UNKNOWN_IFACE = 1;
@@ -2631,9 +2604,13 @@
/** {@hide} */
public static final int TETHER_ERROR_IFACE_CFG_ERROR = 10;
/** {@hide} */
+ @SystemApi
public static final int TETHER_ERROR_PROVISION_FAILED = 11;
/** {@hide} */
public static final int TETHER_ERROR_DHCPSERVER_ERROR = 12;
+ /** {@hide} */
+ @SystemApi
+ public static final int TETHER_ERROR_ENTITLEMENT_UNKONWN = 13;
/**
* Get a more detailed error code after a Tethering or Untethering
@@ -2656,6 +2633,65 @@
}
/**
+ * Callback for use with {@link #getLatestTetheringEntitlementValue} to find out whether
+ * entitlement succeeded.
+ * @hide
+ */
+ @SystemApi
+ public abstract static class TetheringEntitlementValueListener {
+ /**
+ * Called to notify entitlement result.
+ *
+ * @param resultCode a int value of entitlement result. It may be one of
+ * {@link #TETHER_ERROR_NO_ERROR},
+ * {@link #TETHER_ERROR_PROVISION_FAILED}, or
+ * {@link #TETHER_ERROR_ENTITLEMENT_UNKONWN}.
+ */
+ public void onEntitlementResult(int resultCode) {}
+ }
+
+ /**
+ * Get the last value of the entitlement check on this downstream. If the cached value is
+ * {@link #TETHER_ERROR_NO_ERROR} or showEntitlementUi argument is false, it just return the
+ * cached value. Otherwise, a UI-based entitlement check would be performed. It is not
+ * guaranteed that the UI-based entitlement check will complete in any specific time period
+ * and may in fact never complete. Any successful entitlement check the platform performs for
+ * any reason will update the cached value.
+ *
+ * @param type the downstream type of tethering. Must be one of
+ * {@link #TETHERING_WIFI},
+ * {@link #TETHERING_USB}, or
+ * {@link #TETHERING_BLUETOOTH}.
+ * @param showEntitlementUi a boolean indicating whether to run UI-based entitlement check.
+ * @param listener an {@link TetheringEntitlementValueListener} which will be called to notify
+ * the caller of the result of entitlement check. The listener may be called zero or
+ * one time.
+ * @param handler {@link Handler} to specify the thread upon which the listener will be invoked.
+ * {@hide}
+ */
+ @SystemApi
+ @RequiresPermission(android.Manifest.permission.TETHER_PRIVILEGED)
+ public void getLatestTetheringEntitlementValue(int type, boolean showEntitlementUi,
+ @NonNull final TetheringEntitlementValueListener listener, @Nullable Handler handler) {
+ Preconditions.checkNotNull(listener, "TetheringEntitlementValueListener cannot be null.");
+ ResultReceiver wrappedListener = new ResultReceiver(handler) {
+ @Override
+ protected void onReceiveResult(int resultCode, Bundle resultData) {
+ listener.onEntitlementResult(resultCode);
+ }
+ };
+
+ try {
+ String pkgName = mContext.getOpPackageName();
+ Log.i(TAG, "getLatestTetheringEntitlementValue:" + pkgName);
+ mService.getLatestTetheringEntitlementValue(type, wrappedListener,
+ showEntitlementUi, pkgName);
+ } catch (RemoteException e) {
+ throw e.rethrowFromSystemServer();
+ }
+ }
+
+ /**
* Report network connectivity status. This is currently used only
* to alter status bar UI.
* <p>This method requires the caller to hold the permission
@@ -3986,10 +4022,17 @@
@Deprecated
public static boolean setProcessDefaultNetwork(@Nullable Network network) {
int netId = (network == null) ? NETID_UNSET : network.netId;
- if (netId == NetworkUtils.getBoundNetworkForProcess()) {
- return true;
+ boolean isSameNetId = (netId == NetworkUtils.getBoundNetworkForProcess());
+
+ if (netId != NETID_UNSET) {
+ netId = network.getNetIdForResolv();
}
- if (NetworkUtils.bindProcessToNetwork(netId)) {
+
+ if (!NetworkUtils.bindProcessToNetwork(netId)) {
+ return false;
+ }
+
+ if (!isSameNetId) {
// Set HTTP proxy system properties to match network.
// TODO: Deprecate this static method and replace it with a non-static version.
try {
@@ -4003,10 +4046,9 @@
// Must flush socket pool as idle sockets will be bound to previous network and may
// cause subsequent fetches to be performed on old network.
NetworkEventDispatcher.getInstance().onNetworkConfigurationChanged();
- return true;
- } else {
- return false;
}
+
+ return true;
}
/**
diff --git a/core/java/android/net/IConnectivityManager.aidl b/core/java/android/net/IConnectivityManager.aidl
index f88adc2..1148ac1 100644
--- a/core/java/android/net/IConnectivityManager.aidl
+++ b/core/java/android/net/IConnectivityManager.aidl
@@ -197,4 +197,7 @@
int getConnectionOwnerUid(in ConnectionInfo connectionInfo);
boolean isCallerCurrentAlwaysOnVpnApp();
boolean isCallerCurrentAlwaysOnVpnLockdownApp();
+
+ void getLatestTetheringEntitlementValue(int type, in ResultReceiver receiver,
+ boolean showEntitlementUi, String callerPkg);
}
diff --git a/core/java/android/net/NetworkStack.java b/core/java/android/net/NetworkStack.java
index ac6bff0..b6cd635 100644
--- a/core/java/android/net/NetworkStack.java
+++ b/core/java/android/net/NetworkStack.java
@@ -20,7 +20,9 @@
import android.annotation.NonNull;
import android.annotation.Nullable;
+import android.annotation.SystemApi;
import android.annotation.SystemService;
+import android.annotation.TestApi;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
@@ -46,9 +48,22 @@
* @hide
*/
@SystemService(Context.NETWORK_STACK_SERVICE)
+@SystemApi
+@TestApi
public class NetworkStack {
private static final String TAG = NetworkStack.class.getSimpleName();
+ /**
+ * Permission granted only to the NetworkStack APK, defined in NetworkStackStub with signature
+ * protection level.
+ * @hide
+ */
+ @SystemApi
+ @TestApi
+ public static final String PERMISSION_MAINLINE_NETWORK_STACK =
+ "android.permission.MAINLINE_NETWORK_STACK";
+
+ /** @hide */
public static final String NETWORKSTACK_PACKAGE_NAME = "com.android.mainline.networkstack";
private static final int NETWORKSTACK_TIMEOUT_MS = 10_000;
@@ -66,12 +81,14 @@
void onNetworkStackConnected(INetworkStackConnector connector);
}
+ /** @hide */
public NetworkStack() { }
/**
* Create a DHCP server according to the specified parameters.
*
* <p>The server will be returned asynchronously through the provided callbacks.
+ * @hide
*/
public void makeDhcpServer(final String ifName, final DhcpServingParamsParcel params,
final IDhcpServerCallbacks cb) {
@@ -88,6 +105,7 @@
* Create an IpClient on the specified interface.
*
* <p>The IpClient will be returned asynchronously through the provided callbacks.
+ * @hide
*/
public void makeIpClient(String ifName, IIpClientCallbacks cb) {
requestConnector(connector -> {
@@ -103,6 +121,7 @@
* Create a NetworkMonitor.
*
* <p>The INetworkMonitor will be returned asynchronously through the provided callbacks.
+ * @hide
*/
public void makeNetworkMonitor(
NetworkParcelable network, String name, INetworkMonitorCallbacks cb) {
@@ -153,6 +172,7 @@
* the system server on devices that do not support the network stack module. The network stack
* connector will then be delivered asynchronously to clients that requested it before it was
* started.
+ * @hide
*/
public void start(Context context) {
mNetworkStackStartRequested = true;
@@ -223,7 +243,7 @@
private void requestConnector(@NonNull NetworkStackCallback request) {
// TODO: PID check.
final int caller = Binder.getCallingUid();
- if (caller != Process.SYSTEM_UID && caller != Process.BLUETOOTH_UID) {
+ if (caller != Process.SYSTEM_UID && !UserHandle.isSameApp(caller, Process.BLUETOOTH_UID)) {
// Don't even attempt to obtain the connector and give a nice error message
throw new SecurityException(
"Only the system server should try to bind to the network stack.");
diff --git a/core/java/android/net/VpnService.java b/core/java/android/net/VpnService.java
index dc099a4..784f233 100644
--- a/core/java/android/net/VpnService.java
+++ b/core/java/android/net/VpnService.java
@@ -791,6 +791,27 @@
}
/**
+ * Marks the VPN network as metered. A VPN network is classified as metered when the user is
+ * sensitive to heavy data usage due to monetary costs and/or data limitations. In such
+ * cases, you should set this to {@code true} so that apps on the system can avoid doing
+ * large data transfers. Otherwise, set this to {@code false}. Doing so would cause VPN
+ * network to inherit its meteredness from its underlying networks.
+ *
+ * <p>VPN apps targeting {@link android.os.Build.VERSION_CODES#Q} or above will be
+ * considered metered by default.
+ *
+ * @param isMetered {@code true} if VPN network should be treated as metered regardless of
+ * underlying network meteredness
+ * @return this {@link Builder} object to facilitate chaining method calls
+ * @see #setUnderlyingNetworks(Networks[])
+ * @see ConnectivityManager#isActiveNetworkMetered()
+ */
+ public Builder setMetered(boolean isMetered) {
+ mConfig.isMetered = isMetered;
+ return this;
+ }
+
+ /**
* Create a VPN interface using the parameters supplied to this
* builder. The interface works on IP packets, and a file descriptor
* is returned for the application to access them. Each read
diff --git a/packages/overlays/FontRubikRubikOverlay/res/values/strings.xml b/core/java/android/os/BatterySaverPolicyConfig.aidl
similarity index 60%
rename from packages/overlays/FontRubikRubikOverlay/res/values/strings.xml
rename to core/java/android/os/BatterySaverPolicyConfig.aidl
index 4bac7da..37c66d0 100644
--- a/packages/overlays/FontRubikRubikOverlay/res/values/strings.xml
+++ b/core/java/android/os/BatterySaverPolicyConfig.aidl
@@ -1,12 +1,11 @@
-<!--
-/**
- * Copyright (c) 2018, The Android Open Source Project
+/*
+ * Copyright (C) 2019 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
@@ -14,8 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
--->
-<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
- <!-- Headline / Body font Rubik overlay -->
- <string name="font_rubik_rubik_overlay" translatable="false">Rubik / Rubik</string>
-</resources>
+
+package android.os;
+
+parcelable BatterySaverPolicyConfig;
diff --git a/core/java/android/os/BatterySaverPolicyConfig.java b/core/java/android/os/BatterySaverPolicyConfig.java
new file mode 100644
index 0000000..b6e2b69
--- /dev/null
+++ b/core/java/android/os/BatterySaverPolicyConfig.java
@@ -0,0 +1,468 @@
+/*
+ * Copyright (C) 2019 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.os;
+
+import android.annotation.NonNull;
+import android.annotation.SystemApi;
+import android.text.TextUtils;
+import android.util.ArrayMap;
+
+import java.util.Collections;
+import java.util.Map;
+import java.util.Set;
+
+/**
+ * Config to set Battery Saver policy flags.
+ *
+ * @hide
+ */
+@SystemApi
+public final class BatterySaverPolicyConfig implements Parcelable {
+ private final float mAdjustBrightnessFactor;
+ private final boolean mAdvertiseIsEnabled;
+ private final boolean mDeferFullBackup;
+ private final boolean mDeferKeyValueBackup;
+ @NonNull
+ private final Map<String, String> mDeviceSpecificSettings;
+ private final boolean mDisableAnimation;
+ private final boolean mDisableAod;
+ private final boolean mDisableLaunchBoost;
+ private final boolean mDisableOptionalSensors;
+ private final boolean mDisableSoundTrigger;
+ private final boolean mDisableVibration;
+ private final boolean mEnableAdjustBrightness;
+ private final boolean mEnableDataSaver;
+ private final boolean mEnableFirewall;
+ private final boolean mEnableQuickDoze;
+ private final boolean mForceAllAppsStandby;
+ private final boolean mForceBackgroundCheck;
+ private final int mGpsMode;
+
+ private BatterySaverPolicyConfig(Builder in) {
+ mAdjustBrightnessFactor = Math.max(0, Math.min(in.mAdjustBrightnessFactor, 1f));
+ mAdvertiseIsEnabled = in.mAdvertiseIsEnabled;
+ mDeferFullBackup = in.mDeferFullBackup;
+ mDeferKeyValueBackup = in.mDeferKeyValueBackup;
+ mDeviceSpecificSettings = Collections.unmodifiableMap(in.mDeviceSpecificSettings);
+ mDisableAnimation = in.mDisableAnimation;
+ mDisableAod = in.mDisableAod;
+ mDisableLaunchBoost = in.mDisableLaunchBoost;
+ mDisableOptionalSensors = in.mDisableOptionalSensors;
+ mDisableSoundTrigger = in.mDisableSoundTrigger;
+ mDisableVibration = in.mDisableVibration;
+ mEnableAdjustBrightness = in.mEnableAdjustBrightness;
+ mEnableDataSaver = in.mEnableDataSaver;
+ mEnableFirewall = in.mEnableFirewall;
+ mEnableQuickDoze = in.mEnableQuickDoze;
+ mForceAllAppsStandby = in.mForceAllAppsStandby;
+ mForceBackgroundCheck = in.mForceBackgroundCheck;
+ mGpsMode = Math.max(PowerManager.MIN_LOCATION_MODE,
+ Math.min(in.mGpsMode, PowerManager.MAX_LOCATION_MODE));
+ }
+
+ private BatterySaverPolicyConfig(Parcel in) {
+ mAdjustBrightnessFactor = Math.max(0, Math.min(in.readFloat(), 1f));
+ mAdvertiseIsEnabled = in.readBoolean();
+ mDeferFullBackup = in.readBoolean();
+ mDeferKeyValueBackup = in.readBoolean();
+
+ final int size = in.readInt();
+ Map<String, String> deviceSpecificSettings = new ArrayMap<>(size);
+ for (int i = 0; i < size; ++i) {
+ String key = TextUtils.emptyIfNull(in.readString());
+ String val = TextUtils.emptyIfNull(in.readString());
+ if (key.trim().isEmpty()) {
+ continue;
+ }
+ deviceSpecificSettings.put(key, val);
+ }
+ mDeviceSpecificSettings = Collections.unmodifiableMap(deviceSpecificSettings);
+
+ mDisableAnimation = in.readBoolean();
+ mDisableAod = in.readBoolean();
+ mDisableLaunchBoost = in.readBoolean();
+ mDisableOptionalSensors = in.readBoolean();
+ mDisableSoundTrigger = in.readBoolean();
+ mDisableVibration = in.readBoolean();
+ mEnableAdjustBrightness = in.readBoolean();
+ mEnableDataSaver = in.readBoolean();
+ mEnableFirewall = in.readBoolean();
+ mEnableQuickDoze = in.readBoolean();
+ mForceAllAppsStandby = in.readBoolean();
+ mForceBackgroundCheck = in.readBoolean();
+ mGpsMode = Math.max(PowerManager.MIN_LOCATION_MODE,
+ Math.min(in.readInt(), PowerManager.MAX_LOCATION_MODE));
+ }
+
+ public static final Creator<BatterySaverPolicyConfig> CREATOR =
+ new Creator<BatterySaverPolicyConfig>() {
+ @Override
+ public BatterySaverPolicyConfig createFromParcel(Parcel in) {
+ return new BatterySaverPolicyConfig(in);
+ }
+
+ @Override
+ public BatterySaverPolicyConfig[] newArray(int size) {
+ return new BatterySaverPolicyConfig[size];
+ }
+ };
+
+ @Override
+ public int describeContents() {
+ return 0;
+ }
+
+ @Override
+ public void writeToParcel(Parcel dest, int flags) {
+ dest.writeFloat(mAdjustBrightnessFactor);
+ dest.writeBoolean(mAdvertiseIsEnabled);
+ dest.writeBoolean(mDeferFullBackup);
+ dest.writeBoolean(mDeferKeyValueBackup);
+
+ final Set<Map.Entry<String, String>> entries = mDeviceSpecificSettings.entrySet();
+ final int size = entries.size();
+ dest.writeInt(size);
+ for (Map.Entry<String, String> entry : entries) {
+ dest.writeString(entry.getKey());
+ dest.writeString(entry.getValue());
+ }
+
+ dest.writeBoolean(mDisableAnimation);
+ dest.writeBoolean(mDisableAod);
+ dest.writeBoolean(mDisableLaunchBoost);
+ dest.writeBoolean(mDisableOptionalSensors);
+ dest.writeBoolean(mDisableSoundTrigger);
+ dest.writeBoolean(mDisableVibration);
+ dest.writeBoolean(mEnableAdjustBrightness);
+ dest.writeBoolean(mEnableDataSaver);
+ dest.writeBoolean(mEnableFirewall);
+ dest.writeBoolean(mEnableQuickDoze);
+ dest.writeBoolean(mForceAllAppsStandby);
+ dest.writeBoolean(mForceBackgroundCheck);
+ dest.writeInt(mGpsMode);
+ }
+
+ @Override
+ public String toString() {
+ StringBuilder sb = new StringBuilder();
+ for (Map.Entry<String, String> entry : mDeviceSpecificSettings.entrySet()) {
+ sb.append(entry.getKey()).append("=").append(entry.getValue()).append(",");
+ }
+ return "adjust_brightness_disabled=" + !mEnableAdjustBrightness + ","
+ + "adjust_brightness_factor=" + mAdjustBrightnessFactor + ","
+ + "advertise_is_enabled=" + mAdvertiseIsEnabled + ","
+ + "animation_disabled=" + mDisableAnimation + ","
+ + "aod_disabled=" + mDisableAod + ","
+ + "datasaver_disabled=" + !mEnableDataSaver + ","
+ + "firewall_disabled=" + !mEnableFirewall + ","
+ + "force_all_apps_standby=" + mForceAllAppsStandby + ","
+ + "force_background_check=" + mForceBackgroundCheck + ","
+ + "fullbackup_deferred=" + mDeferFullBackup + ","
+ + "gps_mode=" + mGpsMode + ","
+ + "keyvaluebackup_deferred=" + mDeferKeyValueBackup + ","
+ + "launch_boost_disabled=" + mDisableLaunchBoost + ","
+ + "optional_sensors_disabled=" + mDisableOptionalSensors + ","
+ + "quick_doze_enabled=" + mEnableQuickDoze + ","
+ + "soundtrigger_disabled=" + mDisableSoundTrigger + ","
+ + "vibration_disabled=" + mDisableVibration + ","
+ + sb.toString();
+ }
+
+ /**
+ * How much to adjust the screen brightness while in Battery Saver. This will have no effect
+ * if {@link #getEnableAdjustBrightness()} is {@code false}.
+ */
+ public float getAdjustBrightnessFactor() {
+ return mAdjustBrightnessFactor;
+ }
+
+ /**
+ * Whether or not to tell the system (and other apps) that Battery Saver is currently enabled.
+ */
+ public boolean getAdvertiseIsEnabled() {
+ return mAdvertiseIsEnabled;
+ }
+
+ /** Whether or not to defer full backup while in Battery Saver. */
+ public boolean getDeferFullBackup() {
+ return mDeferFullBackup;
+ }
+
+ /** Whether or not to defer key-value backup while in Battery Saver. */
+ public boolean getDeferKeyValueBackup() {
+ return mDeferKeyValueBackup;
+ }
+
+ /**
+ * Returns the device-specific battery saver constants.
+ */
+ @NonNull
+ public Map<String, String> getDeviceSpecificSettings() {
+ return mDeviceSpecificSettings;
+ }
+
+ /** Whether or not to disable animation while in Battery Saver. */
+ public boolean getDisableAnimation() {
+ return mDisableAnimation;
+ }
+
+ /** Whether or not to disable Always On Display while in Battery Saver. */
+ public boolean getDisableAod() {
+ return mDisableAod;
+ }
+
+ /** Whether or not to disable launch boost while in Battery Saver. */
+ public boolean getDisableLaunchBoost() {
+ return mDisableLaunchBoost;
+ }
+
+ /** Whether or not to disable optional sensors while in Battery Saver. */
+ public boolean getDisableOptionalSensors() {
+ return mDisableOptionalSensors;
+ }
+
+ /** Whether or not to disable sound trigger while in Battery Saver. */
+ public boolean getDisableSoundTrigger() {
+ return mDisableSoundTrigger;
+ }
+
+ /** Whether or not to disable vibration while in Battery Saver. */
+ public boolean getDisableVibration() {
+ return mDisableVibration;
+ }
+
+ /** Whether or not to enable brightness adjustment while in Battery Saver. */
+ public boolean getEnableAdjustBrightness() {
+ return mEnableAdjustBrightness;
+ }
+
+ /** Whether or not to enable Data Saver while in Battery Saver. */
+ public boolean getEnableDataSaver() {
+ return mEnableDataSaver;
+ }
+
+ /** Whether or not to enable the network firewall while in Battery Saver. */
+ public boolean getEnableFirewall() {
+ return mEnableFirewall;
+ }
+
+ /** Whether or not to enable Quick Doze while in Battery Saver. */
+ public boolean getEnableQuickDoze() {
+ return mEnableQuickDoze;
+ }
+
+ /** Whether or not to force all apps to standby mode while in Battery Saver. */
+ public boolean getForceAllAppsStandby() {
+ return mForceAllAppsStandby;
+ }
+
+ /** Whether or not to force background check while in Battery Saver. */
+ public boolean getForceBackgroundCheck() {
+ return mForceBackgroundCheck;
+ }
+
+ /** The GPS mode while in Battery Saver. */
+ public int getGpsMode() {
+ return mGpsMode;
+ }
+
+ /** Builder class for constructing {@link BatterySaverPolicyConfig} objects. */
+ public static final class Builder {
+ private float mAdjustBrightnessFactor = 1f;
+ private boolean mAdvertiseIsEnabled = false;
+ private boolean mDeferFullBackup = false;
+ private boolean mDeferKeyValueBackup = false;
+ @NonNull
+ private final ArrayMap<String, String> mDeviceSpecificSettings = new ArrayMap<>();
+ private boolean mDisableAnimation = false;
+ private boolean mDisableAod = false;
+ private boolean mDisableLaunchBoost = false;
+ private boolean mDisableOptionalSensors = false;
+ private boolean mDisableSoundTrigger = false;
+ private boolean mDisableVibration = false;
+ private boolean mEnableAdjustBrightness = false;
+ private boolean mEnableDataSaver = false;
+ private boolean mEnableFirewall = false;
+ private boolean mEnableQuickDoze = false;
+ private boolean mForceAllAppsStandby = false;
+ private boolean mForceBackgroundCheck = false;
+ private int mGpsMode = PowerManager.LOCATION_MODE_NO_CHANGE;
+
+ public Builder() {
+ }
+
+ /**
+ * Set how much to adjust the screen brightness while in Battery Saver. The value should
+ * be in the [0, 1] range, where 1 will not change the brightness. This will have no
+ * effect if {@link #setEnableAdjustBrightness(boolean)} is not called with {@code true}.
+ */
+ @NonNull
+ public Builder setAdjustBrightnessFactor(float adjustBrightnessFactor) {
+ mAdjustBrightnessFactor = adjustBrightnessFactor;
+ return this;
+ }
+
+ /**
+ * Set whether or not to tell the system (and other apps) that Battery Saver is
+ * currently enabled.
+ */
+ @NonNull
+ public Builder setAdvertiseIsEnabled(boolean advertiseIsEnabled) {
+ mAdvertiseIsEnabled = advertiseIsEnabled;
+ return this;
+ }
+
+ /** Set whether or not to defer full backup while in Battery Saver. */
+ @NonNull
+ public Builder setDeferFullBackup(boolean deferFullBackup) {
+ mDeferFullBackup = deferFullBackup;
+ return this;
+ }
+
+ /** Set whether or not to defer key-value backup while in Battery Saver. */
+ @NonNull
+ public Builder setDeferKeyValueBackup(boolean deferKeyValueBackup) {
+ mDeferKeyValueBackup = deferKeyValueBackup;
+ return this;
+ }
+
+ /**
+ * Adds a key-value pair for device-specific battery saver constants. The supported keys
+ * and values are the same as those in
+ * {@link android.provider.Settings.Global#BATTERY_SAVER_DEVICE_SPECIFIC_CONSTANTS}.
+ *
+ * @throws IllegalArgumentException if the provided key is invalid (empty, null, or all
+ * whitespace)
+ */
+ @NonNull
+ public Builder addDeviceSpecificSetting(@NonNull String key, @NonNull String value) {
+ if (key == null) {
+ throw new IllegalArgumentException("Key cannot be null");
+ }
+ key = key.trim();
+ if (TextUtils.isEmpty(key)) {
+ throw new IllegalArgumentException("Key cannot be empty");
+ }
+ mDeviceSpecificSettings.put(key, TextUtils.emptyIfNull(value));
+ return this;
+ }
+
+ /** Set whether or not to disable animation while in Battery Saver. */
+ @NonNull
+ public Builder setDisableAnimation(boolean disableAnimation) {
+ mDisableAnimation = disableAnimation;
+ return this;
+ }
+
+ /** Set whether or not to disable Always On Display while in Battery Saver. */
+ @NonNull
+ public Builder setDisableAod(boolean disableAod) {
+ mDisableAod = disableAod;
+ return this;
+ }
+
+ /** Set whether or not to disable launch boost while in Battery Saver. */
+ @NonNull
+ public Builder setDisableLaunchBoost(boolean disableLaunchBoost) {
+ mDisableLaunchBoost = disableLaunchBoost;
+ return this;
+ }
+
+ /** Set whether or not to disable optional sensors while in Battery Saver. */
+ @NonNull
+ public Builder setDisableOptionalSensors(boolean disableOptionalSensors) {
+ mDisableOptionalSensors = disableOptionalSensors;
+ return this;
+ }
+
+ /** Set whether or not to disable sound trigger while in Battery Saver. */
+ @NonNull
+ public Builder setDisableSoundTrigger(boolean disableSoundTrigger) {
+ mDisableSoundTrigger = disableSoundTrigger;
+ return this;
+ }
+
+ /** Set whether or not to disable vibration while in Battery Saver. */
+ @NonNull
+ public Builder setDisableVibration(boolean disableVibration) {
+ mDisableVibration = disableVibration;
+ return this;
+ }
+
+ /** Set whether or not to enable brightness adjustment while in Battery Saver. */
+ @NonNull
+ public Builder setEnableAdjustBrightness(boolean enableAdjustBrightness) {
+ mEnableAdjustBrightness = enableAdjustBrightness;
+ return this;
+ }
+
+ /** Set whether or not to enable Data Saver while in Battery Saver. */
+ @NonNull
+ public Builder setEnableDataSaver(boolean enableDataSaver) {
+ mEnableDataSaver = enableDataSaver;
+ return this;
+ }
+
+ /** Set whether or not to enable the network firewall while in Battery Saver. */
+ @NonNull
+ public Builder setEnableFirewall(boolean enableFirewall) {
+ mEnableFirewall = enableFirewall;
+ return this;
+ }
+
+ /** Set whether or not to enable Quick Doze while in Battery Saver. */
+ @NonNull
+ public Builder setEnableQuickDoze(boolean enableQuickDoze) {
+ mEnableQuickDoze = enableQuickDoze;
+ return this;
+ }
+
+ /** Set whether or not to force all apps to standby mode while in Battery Saver. */
+ @NonNull
+ public Builder setForceAllAppsStandby(boolean forceAllAppsStandby) {
+ mForceAllAppsStandby = forceAllAppsStandby;
+ return this;
+ }
+
+ /** Set whether or not to force background check while in Battery Saver. */
+ @NonNull
+ public Builder setForceBackgroundCheck(boolean forceBackgroundCheck) {
+ mForceBackgroundCheck = forceBackgroundCheck;
+ return this;
+ }
+
+ /** Set the GPS mode while in Battery Saver. */
+ @NonNull
+ public Builder setGpsMode(@PowerManager.LocationPowerSaveMode int gpsMode) {
+ mGpsMode = gpsMode;
+ return this;
+ }
+
+ /**
+ * Build a {@link BatterySaverPolicyConfig} object using the set parameters. This object
+ * is immutable.
+ */
+ @NonNull
+ public BatterySaverPolicyConfig build() {
+ if (!mEnableAdjustBrightness && Float.compare(1f, mAdjustBrightnessFactor) != 0) {
+ throw new IllegalArgumentException("Brightness adjustment factor changed without "
+ + "enabling brightness adjustment");
+ }
+ return new BatterySaverPolicyConfig(this);
+ }
+ }
+}
diff --git a/core/java/android/os/DynamicAndroidManager.java b/core/java/android/os/DynamicAndroidManager.java
new file mode 100644
index 0000000..5238896
--- /dev/null
+++ b/core/java/android/os/DynamicAndroidManager.java
@@ -0,0 +1,188 @@
+/*
+ * Copyright (C) 2019 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.os;
+
+import android.annotation.RequiresPermission;
+import android.annotation.SystemService;
+import android.content.Context;
+import android.gsi.GsiProgress;
+
+/**
+ * The DynamicAndroidManager offers a mechanism to use a new Android image temporarily. After the
+ * installation, the device can reboot into this image with a new created /data. This image will
+ * last until the next reboot and then the device will go back to the original image. However the
+ * installed image and the new created /data are not deleted but disabled. Thus the application can
+ * either re-enable the installed image by calling {@link #toggle} or use the {@link #remove} to
+ * delete it completely. In other words, there are three device states: no installation, installed
+ * and running. The procedure to install a DynamicAndroid starts with a {@link #startInstallation},
+ * followed by a series of {@link #write} and ends with a {@link commit}. Once the installation is
+ * complete, the device state changes from no installation to the installed state and a followed
+ * reboot will change its state to running. Note one instance of dynamic android can exist on a
+ * given device thus the {@link #startInstallation} will fail if the device is currently running a
+ * DynamicAndroid.
+ *
+ * @hide
+ */
+@SystemService(Context.DYNAMIC_ANDROID_SERVICE)
+public class DynamicAndroidManager {
+ private static final String TAG = "DynamicAndroidManager";
+
+ private final IDynamicAndroidService mService;
+
+ /** {@hide} */
+ public DynamicAndroidManager(IDynamicAndroidService service) {
+ mService = service;
+ }
+
+ /** The DynamicAndroidManager.Session represents a started session for the installation. */
+ public class Session {
+ private Session() {}
+ /**
+ * Write a chunk of the DynamicAndroid system image
+ *
+ * @return {@code true} if the call succeeds. {@code false} if there is any native runtime
+ * error.
+ */
+ @RequiresPermission(android.Manifest.permission.MANAGE_DYNAMIC_ANDROID)
+ public boolean write(byte[] buf) {
+ try {
+ return mService.write(buf);
+ } catch (RemoteException e) {
+ throw new RuntimeException(e.toString());
+ }
+ }
+
+ /**
+ * Finish write and make device to boot into the it after reboot.
+ *
+ * @return {@code true} if the call succeeds. {@code false} if there is any native runtime
+ * error.
+ */
+ @RequiresPermission(android.Manifest.permission.MANAGE_DYNAMIC_ANDROID)
+ public boolean commit() {
+ try {
+ return mService.commit();
+ } catch (RemoteException e) {
+ throw new RuntimeException(e.toString());
+ }
+ }
+ }
+ /**
+ * Start DynamicAndroid installation. This call may take an unbounded amount of time. The caller
+ * may use another thread to call the getStartProgress() to get the progress.
+ *
+ * @param systemSize system size in bytes
+ * @param userdataSize userdata size in bytes
+ * @return {@code true} if the call succeeds. {@code false} either the device does not contain
+ * enough space or a DynamicAndroid is currently in use where the {@link #isInUse} would be
+ * true.
+ */
+ @RequiresPermission(android.Manifest.permission.MANAGE_DYNAMIC_ANDROID)
+ public Session startInstallation(long systemSize, long userdataSize) {
+ try {
+ if (mService.startInstallation(systemSize, userdataSize)) {
+ return new Session();
+ } else {
+ return null;
+ }
+ } catch (RemoteException e) {
+ throw new RuntimeException(e.toString());
+ }
+ }
+
+ /**
+ * Query the progress of the current installation operation. This can be called while the
+ * installation is in progress.
+ *
+ * @return GsiProgress GsiProgress { int status; long bytes_processed; long total_bytes; } The
+ * status field can be IGsiService.STATUS_NO_OPERATION, IGsiService.STATUS_WORKING or
+ * IGsiService.STATUS_COMPLETE.
+ */
+ @RequiresPermission(android.Manifest.permission.MANAGE_DYNAMIC_ANDROID)
+ public GsiProgress getInstallationProgress() {
+ try {
+ return mService.getInstallationProgress();
+ } catch (RemoteException e) {
+ throw new RuntimeException(e.toString());
+ }
+ }
+
+ /**
+ * Abort the installation process. Note this method must be called in a thread other than the
+ * one calling the startInstallation method as the startInstallation method will not return
+ * until it is finished.
+ *
+ * @return {@code true} if the call succeeds. {@code false} if there is no installation
+ * currently.
+ */
+ @RequiresPermission(android.Manifest.permission.MANAGE_DYNAMIC_ANDROID)
+ public boolean abort() {
+ try {
+ return mService.abort();
+ } catch (RemoteException e) {
+ throw new RuntimeException(e.toString());
+ }
+ }
+
+ /** @return {@code true} if the device is running a dynamic android */
+ @RequiresPermission(android.Manifest.permission.MANAGE_DYNAMIC_ANDROID)
+ public boolean isInUse() {
+ try {
+ return mService.isInUse();
+ } catch (RemoteException e) {
+ throw new RuntimeException(e.toString());
+ }
+ }
+
+ /** @return {@code true} if the device has a dynamic android installed */
+ @RequiresPermission(android.Manifest.permission.MANAGE_DYNAMIC_ANDROID)
+ public boolean isInstalled() {
+ try {
+ return mService.isInstalled();
+ } catch (RemoteException e) {
+ throw new RuntimeException(e.toString());
+ }
+ }
+
+ /**
+ * Remove DynamicAndroid installation if present
+ *
+ * @return {@code true} if the call succeeds. {@code false} if there is no installed image.
+ */
+ @RequiresPermission(android.Manifest.permission.MANAGE_DYNAMIC_ANDROID)
+ public boolean remove() {
+ try {
+ return mService.remove();
+ } catch (RemoteException e) {
+ throw new RuntimeException(e.toString());
+ }
+ }
+
+ /**
+ * Enable DynamicAndroid when it's not enabled, otherwise, disable it.
+ *
+ * @return {@code true} if the call succeeds. {@code false} if there is no installed image.
+ */
+ @RequiresPermission(android.Manifest.permission.MANAGE_DYNAMIC_ANDROID)
+ public boolean toggle() {
+ try {
+ return mService.toggle();
+ } catch (RemoteException e) {
+ throw new RuntimeException(e.toString());
+ }
+ }
+}
diff --git a/core/java/android/os/IDynamicAndroidService.aidl b/core/java/android/os/IDynamicAndroidService.aidl
new file mode 100644
index 0000000..0b28799
--- /dev/null
+++ b/core/java/android/os/IDynamicAndroidService.aidl
@@ -0,0 +1,87 @@
+/*
+ * Copyright (C) 2019 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package android.os;
+
+import android.gsi.GsiProgress;
+
+/** {@hide} */
+interface IDynamicAndroidService
+{
+ /**
+ * Start DynamicAndroid installation. This call may take 60~90 seconds. The caller
+ * may use another thread to call the getStartProgress() to get the progress.
+ *
+ * @param systemSize system size in bytes
+ * @param userdataSize userdata size in bytes
+ * @return true if the call succeeds
+ */
+ boolean startInstallation(long systemSize, long userdataSize);
+
+ /**
+ * Query the progress of the current installation operation. This can be called while
+ * the installation is in progress.
+ *
+ * @return GsiProgress
+ */
+ GsiProgress getInstallationProgress();
+
+ /**
+ * Abort the installation process. Note this method must be called in a thread other
+ * than the one calling the startInstallation method as the startInstallation
+ * method will not return until it is finished.
+ *
+ * @return true if the call succeeds
+ */
+ boolean abort();
+
+ /**
+ * @return true if the device is running an DynamicAnroid image
+ */
+ boolean isInUse();
+
+ /**
+ * @return true if the device has an DynamicAndroid image installed
+ */
+ boolean isInstalled();
+
+ /**
+ * Remove DynamicAndroid installation if present
+ *
+ * @return true if the call succeeds
+ */
+ boolean remove();
+
+ /**
+ * Enable DynamicAndroid when it's not enabled, otherwise, disable it.
+ *
+ * @return true if the call succeeds
+ */
+ boolean toggle();
+
+ /**
+ * Write a chunk of the DynamicAndroid system image
+ *
+ * @return true if the call succeeds
+ */
+ boolean write(in byte[] buf);
+
+ /**
+ * Finish write and make device to boot into the it after reboot.
+ *
+ * @return true if the call succeeds
+ */
+ boolean commit();
+}
diff --git a/core/java/android/os/IPowerManager.aidl b/core/java/android/os/IPowerManager.aidl
index ca5b233..093897a 100644
--- a/core/java/android/os/IPowerManager.aidl
+++ b/core/java/android/os/IPowerManager.aidl
@@ -17,8 +17,9 @@
package android.os;
-import android.os.WorkSource;
+import android.os.BatterySaverPolicyConfig;
import android.os.PowerSaveState;
+import android.os.WorkSource;
/** @hide */
@@ -49,6 +50,8 @@
PowerSaveState getPowerSaveState(int serviceType);
boolean setPowerSaveMode(boolean mode);
boolean setDynamicPowerSavings(boolean dynamicPowerSavingsEnabled, int disableThreshold);
+ boolean setAdaptivePowerSavePolicy(in BatterySaverPolicyConfig config);
+ boolean setAdaptivePowerSaveEnabled(boolean enabled);
int getPowerSaveMode();
boolean isDeviceIdleMode();
boolean isLightDeviceIdleMode();
diff --git a/core/java/android/os/OWNERS b/core/java/android/os/OWNERS
new file mode 100644
index 0000000..b568f15
--- /dev/null
+++ b/core/java/android/os/OWNERS
@@ -0,0 +1,2 @@
+# Zygote
+per-file ZygoteProcess.java = chriswailes@google.com, ngeoffray@google.com, sehr@google.com, narayan@google.com, maco@google.com
diff --git a/core/java/android/os/PowerManager.java b/core/java/android/os/PowerManager.java
index 7f4254e..0441ba2 100644
--- a/core/java/android/os/PowerManager.java
+++ b/core/java/android/os/PowerManager.java
@@ -640,6 +640,9 @@
*/
public static final int LOCATION_MODE_FOREGROUND_ONLY = 3;
+ static final int MIN_LOCATION_MODE = LOCATION_MODE_NO_CHANGE;
+ static final int MAX_LOCATION_MODE = LOCATION_MODE_FOREGROUND_ONLY;
+
/**
* @hide
*/
@@ -1272,6 +1275,48 @@
}
/**
+ * Sets the policy for adaptive power save.
+ *
+ * @return true if there was an effectual change. If full battery saver is enabled or the
+ * adaptive policy is not enabled, then this will return false.
+ *
+ * @hide
+ */
+ @SystemApi
+ @RequiresPermission(anyOf = {
+ android.Manifest.permission.DEVICE_POWER,
+ android.Manifest.permission.POWER_SAVER
+ })
+ public boolean setAdaptivePowerSavePolicy(@NonNull BatterySaverPolicyConfig config) {
+ try {
+ return mService.setAdaptivePowerSavePolicy(config);
+ } catch (RemoteException e) {
+ throw e.rethrowFromSystemServer();
+ }
+ }
+
+ /**
+ * Enables or disables adaptive power save.
+ *
+ * @return true if there was an effectual change. If full battery saver is enabled, then this
+ * will return false.
+ *
+ * @hide
+ */
+ @SystemApi
+ @RequiresPermission(anyOf = {
+ android.Manifest.permission.DEVICE_POWER,
+ android.Manifest.permission.POWER_SAVER
+ })
+ public boolean setAdaptivePowerSaveEnabled(boolean enabled) {
+ try {
+ return mService.setAdaptivePowerSaveEnabled(enabled);
+ } catch (RemoteException e) {
+ throw e.rethrowFromSystemServer();
+ }
+ }
+
+ /**
* Indicates automatic battery saver toggling by the system will be based on percentage.
*
* @see PowerManager#getPowerSaveMode()
diff --git a/core/java/android/os/UserHandle.java b/core/java/android/os/UserHandle.java
index ad8a4d5..40c48a0 100644
--- a/core/java/android/os/UserHandle.java
+++ b/core/java/android/os/UserHandle.java
@@ -226,6 +226,7 @@
* @hide
*/
@TestApi
+ @SystemApi
public static @AppIdInt int getAppId(int uid) {
return uid % PER_USER_RANGE;
}
diff --git a/core/java/android/provider/DeviceConfig.java b/core/java/android/provider/DeviceConfig.java
index 30c0731..92650e1 100644
--- a/core/java/android/provider/DeviceConfig.java
+++ b/core/java/android/provider/DeviceConfig.java
@@ -181,10 +181,10 @@
String NAMESPACE = "intelligence_attention";
/** If {@code true}, enables the attention features. */
- String PROPERTY_ATTENTION_ENABLED = "attention_enabled";
+ String ATTENTION_ENABLED = "attention_enabled";
/** Settings for the attention features. */
- String PROPERTY_ATTENTION_SETTINGS = "attention_settings";
+ String ATTENTION_SETTINGS = "attention_settings";
}
/**
@@ -203,12 +203,12 @@
* @hide
*/
@SystemApi
- String PROPERTY_PERMISSIONS_HUB_ENABLED = "enable_permissions_hub";
+ String PROPERTY_PERMISSIONS_HUB_ENABLED = "permissions_hub_enabled";
/**
* Whether to show location access check notifications.
*/
- String PROPERTY_LOCATION_ACCESS_CHECK_ENABLED = "enable_location_access_check";
+ String PROPERTY_LOCATION_ACCESS_CHECK_ENABLED = "location_access_check_enabled";
}
/**
@@ -220,13 +220,17 @@
public interface Telephony {
String NAMESPACE = "telephony";
/**
- * Whether to apply ramping ringer on incoming phone calls.
- */
- String PROPERTY_ENABLE_RAMPING_RINGER = "enable_ramping_ringer";
- /**
* Ringer ramping time in milliseconds.
*/
- String PROPERTY_RAMPING_RINGER_DURATION = "ramping_duration";
+ String RAMPING_RINGER_DURATION = "ramping_ringer_duration";
+ /**
+ * Whether to apply ramping ringer on incoming phone calls.
+ */
+ String RAMPING_RINGER_ENABLED = "ramping_ringer_enabled";
+ /**
+ * Vibration time in milliseconds before ramping ringer starts.
+ */
+ String RAMPING_RINGER_VIBRATION_DURATION = "ramping_ringer_vibration_duration";
}
/**
@@ -261,6 +265,7 @@
String KEY_COMPACT_THROTTLE_2 = "compact_throttle_2";
String KEY_COMPACT_THROTTLE_3 = "compact_throttle_3";
String KEY_COMPACT_THROTTLE_4 = "compact_throttle_4";
+ String KEY_COMPACT_STATSD_SAMPLE_RATE = "compact_statsd_sample_rate";
/**
* Maximum number of cached processes. See
@@ -279,10 +284,10 @@
String NAMESPACE = "attention_manager_service";
/** If {@code true}, enables {@link AttentionManagerService} features. */
- String PROPERTY_SERVICE_ENABLED = "service_enabled";
+ String SERVICE_ENABLED = "service_enabled";
/** Allows a CTS to inject a fake implementation. */
- String PROPERTY_COMPONENT_NAME = "component_name";
+ String COMPONENT_NAME = "component_name";
}
/**
diff --git a/core/java/android/provider/Downloads.java b/core/java/android/provider/Downloads.java
index 63bbb9c..89d1c44 100644
--- a/core/java/android/provider/Downloads.java
+++ b/core/java/android/provider/Downloads.java
@@ -419,12 +419,20 @@
/**
* The column that is used to remember whether the media scanner was invoked.
- * It can take the values: null or 0(not scanned), 1(scanned), 2 (not scannable).
+ * It can take the values: {@link #MEDIA_NOT_SCANNED}, {@link #MEDIA_SCANNED} or
+ * {@link #MEDIA_NOT_SCANNABLE} or {@code null}. If it's value is {@code null}, it will be
+ * treated as {@link #MEDIA_NOT_SCANNED}.
+ *
* <P>Type: TEXT</P>
*/
@UnsupportedAppUsage
public static final String COLUMN_MEDIA_SCANNED = "scanned";
+ /** Possible values for column {@link #COLUMN_MEDIA_SCANNED} */
+ public static final int MEDIA_NOT_SCANNED = 0;
+ public static final int MEDIA_SCANNED = 1;
+ public static final int MEDIA_NOT_SCANNABLE = 2;
+
/**
* The column with errorMsg for a failed downloaded.
* Used only for debugging purposes.
diff --git a/core/java/android/provider/MediaStore.java b/core/java/android/provider/MediaStore.java
index 124c50a..0743c23 100644
--- a/core/java/android/provider/MediaStore.java
+++ b/core/java/android/provider/MediaStore.java
@@ -641,6 +641,8 @@
* location. For example, when this value is left undefined, pending
* {@link MediaStore.Audio.Media} items are stored under
* {@link Environment#DIRECTORY_MUSIC}.
+ *
+ * @see MediaColumns#PRIMARY_DIRECTORY
*/
public void setPrimaryDirectory(@Nullable String primaryDirectory) {
this.primaryDirectory = primaryDirectory;
@@ -652,6 +654,8 @@
* <p>
* You may leave this value undefined to store the media as a direct
* descendant of the {@link #setPrimaryDirectory(String)} location.
+ *
+ * @see MediaColumns#SECONDARY_DIRECTORY
*/
public void setSecondaryDirectory(@Nullable String secondaryDirectory) {
this.secondaryDirectory = secondaryDirectory;
@@ -980,6 +984,26 @@
* Type: TEXT
*/
public static final String OWNER_PACKAGE_NAME = "owner_package_name";
+
+ /**
+ * The primary directory name this media exists under. The value may be
+ * {@code NULL} if the media doesn't have a primary directory name.
+ * <p>
+ * Type: TEXT
+ *
+ * @see PendingParams#setPrimaryDirectory(String)
+ */
+ public static final String PRIMARY_DIRECTORY = "primary_directory";
+
+ /**
+ * The secondary directory name this media exists under. The value may
+ * be {@code NULL} if the media doesn't have a secondary directory name.
+ * <p>
+ * Type: TEXT
+ *
+ * @see PendingParams#setSecondaryDirectory(String)
+ */
+ public static final String SECONDARY_DIRECTORY = "secondary_directory";
}
/**
@@ -1428,13 +1452,20 @@
public static final String BUCKET_DISPLAY_NAME = "bucket_display_name";
/**
- * The secondary bucket ID of this media item. This can be useful to
- * present the user a second-level clustering of related media
- * items. This is a read-only column that is automatically computed.
+ * The group ID of this media item. This can be useful to present
+ * the user a grouping of related media items, such a burst of
+ * images, or a {@code JPG} and {@code DNG} version of the same
+ * image.
+ * <p>
+ * This is a read-only column that is automatically computed based
+ * on the first portion of the filename. For example,
+ * {@code IMG1024.BURST001.JPG} and {@code IMG1024.BURST002.JPG}
+ * will have the same {@link #GROUP_ID} because the first portion of
+ * their filenames is identical.
* <p>
* Type: INTEGER
*/
- public static final String SECONDARY_BUCKET_ID = "secondary_bucket_id";
+ public static final String GROUP_ID = "group_id";
}
public static final class Media implements ImageColumns {
@@ -2697,13 +2728,20 @@
public static final String BUCKET_DISPLAY_NAME = "bucket_display_name";
/**
- * The secondary bucket ID of this media item. This can be useful to
- * present the user a second-level clustering of related media
- * items. This is a read-only column that is automatically computed.
+ * The group ID of this media item. This can be useful to present
+ * the user a grouping of related media items, such a burst of
+ * images, or a {@code JPG} and {@code DNG} version of the same
+ * image.
+ * <p>
+ * This is a read-only column that is automatically computed based
+ * on the first portion of the filename. For example,
+ * {@code IMG1024.BURST001.JPG} and {@code IMG1024.BURST002.JPG}
+ * will have the same {@link #GROUP_ID} because the first portion of
+ * their filenames is identical.
* <p>
* Type: INTEGER
*/
- public static final String SECONDARY_BUCKET_ID = "secondary_bucket_id";
+ public static final String GROUP_ID = "group_id";
/**
* The bookmark for the video. Time in ms. Represents the location in the video that the
diff --git a/core/java/android/provider/Settings.java b/core/java/android/provider/Settings.java
index 5151e29..ffa47a9 100644
--- a/core/java/android/provider/Settings.java
+++ b/core/java/android/provider/Settings.java
@@ -5874,30 +5874,24 @@
"unknown_sources_default_reversed";
/**
- * Comma-separated list of location providers that activities may access. Do not rely on
- * this value being present in settings.db or on ContentObserver notifications on the
+ * Comma-separated list of location providers that are accessible. Do not rely on
+ * this value being present or correct, or on ContentObserver notifications on the
* corresponding Uri.
*
- * @deprecated Providers should not be controlled individually. See {@link #LOCATION_MODE}
- * documentation for information on reading/writing location information.
+ * @deprecated The preferred methods for checking provider status and listening for changes
+ * are via {@link LocationManager#isProviderEnabled(String)} and
+ * {@link LocationManager#PROVIDERS_CHANGED_ACTION}.
*/
@Deprecated
public static final String LOCATION_PROVIDERS_ALLOWED = "location_providers_allowed";
/**
- * The degree of location access enabled by the user.
- * <p>
- * When used with {@link #putInt(ContentResolver, String, int)}, must be one of {@link
- * #LOCATION_MODE_HIGH_ACCURACY}, {@link #LOCATION_MODE_SENSORS_ONLY}, {@link
- * #LOCATION_MODE_BATTERY_SAVING}, or {@link #LOCATION_MODE_OFF}. When used with {@link
- * #getInt(ContentResolver, String)}, the caller must gracefully handle additional location
- * modes that might be added in the future.
- * <p>
- * Note: do not rely on this value being present in settings.db or on ContentObserver
- * notifications for the corresponding Uri. Use {@link LocationManager#MODE_CHANGED_ACTION}
- * to receive changes in this value.
+ * The current location mode of the device. Do not rely on this value being present or on
+ * ContentObserver notifications on the corresponding Uri.
*
- * @deprecated To check location mode, use {@link LocationManager#isLocationEnabled()}.
+ * @deprecated The preferred methods for checking location mode and listening for changes
+ * are via {@link LocationManager#isLocationEnabled()} and
+ * {@link LocationManager#MODE_CHANGED_ACTION}.
*/
@Deprecated
public static final String LOCATION_MODE = "location_mode";
@@ -5924,7 +5918,7 @@
public static final int LOCATION_CHANGER_QUICK_SETTINGS = 2;
/**
- * Location access disabled.
+ * Location mode is off.
*
* @deprecated See {@link #LOCATION_MODE}.
*/
@@ -5932,32 +5926,39 @@
public static final int LOCATION_MODE_OFF = 0;
/**
- * Network Location Provider disabled, but GPS and other sensors enabled.
+ * This mode no longer has any distinct meaning, but is interpreted as the location mode is
+ * on.
*
- * @deprecated To check location status, use {@link LocationManager#isLocationEnabled()}. To
- * get the status of a location provider, use
- * {@link LocationManager#isProviderEnabled(String)}.
+ * @deprecated See {@link #LOCATION_MODE_ON}.
*/
@Deprecated
public static final int LOCATION_MODE_SENSORS_ONLY = 1;
/**
- * Reduced power usage, such as limiting the number of GPS updates per hour. Requests
- * with {@link android.location.Criteria#POWER_HIGH} may be downgraded to
- * {@link android.location.Criteria#POWER_MEDIUM}.
+ * This mode no longer has any distinct meaning, but is interpreted as the location mode is
+ * on.
*
- * @deprecated See {@link #LOCATION_MODE}.
+ * @deprecated See {@link #LOCATION_MODE_ON}.
*/
@Deprecated
public static final int LOCATION_MODE_BATTERY_SAVING = 2;
/**
- * Best-effort location computation allowed.
+ * This mode no longer has any distinct meaning, but is interpreted as the location mode is
+ * on.
+ *
+ * @deprecated See {@link #LOCATION_MODE_ON}.
+ */
+ @Deprecated
+ public static final int LOCATION_MODE_HIGH_ACCURACY = 3;
+
+ /**
+ * Location mode is on.
*
* @deprecated See {@link #LOCATION_MODE}.
*/
@Deprecated
- public static final int LOCATION_MODE_HIGH_ACCURACY = 3;
+ public static final int LOCATION_MODE_ON = LOCATION_MODE_HIGH_ACCURACY;
/**
* A flag containing settings used for biometric weak
@@ -7466,14 +7467,6 @@
private static final Validator DOZE_TAP_SCREEN_GESTURE_VALIDATOR = BOOLEAN_VALIDATOR;
/**
- * Gesture that wakes up the lock screen.
- * @hide
- */
- public static final String DOZE_WAKE_LOCK_SCREEN_GESTURE = "doze_wake_lock_screen_gesture";
-
- private static final Validator DOZE_WAKE_LOCK_SCREEN_GESTURE_VALIDATOR = BOOLEAN_VALIDATOR;
-
- /**
* Gesture that wakes up the display, showing the ambient version of the status bar.
* @hide
*/
@@ -8588,7 +8581,6 @@
DOZE_PICK_UP_GESTURE,
DOZE_DOUBLE_TAP_GESTURE,
DOZE_TAP_SCREEN_GESTURE,
- DOZE_WAKE_LOCK_SCREEN_GESTURE,
DOZE_WAKE_SCREEN_GESTURE,
NFC_PAYMENT_DEFAULT_COMPONENT,
AUTOMATIC_STORAGE_MANAGER_DAYS_TO_RETAIN,
@@ -8748,7 +8740,6 @@
VALIDATORS.put(DOZE_PICK_UP_GESTURE, DOZE_PICK_UP_GESTURE_VALIDATOR);
VALIDATORS.put(DOZE_DOUBLE_TAP_GESTURE, DOZE_DOUBLE_TAP_GESTURE_VALIDATOR);
VALIDATORS.put(DOZE_TAP_SCREEN_GESTURE, DOZE_TAP_SCREEN_GESTURE_VALIDATOR);
- VALIDATORS.put(DOZE_WAKE_LOCK_SCREEN_GESTURE, DOZE_WAKE_LOCK_SCREEN_GESTURE_VALIDATOR);
VALIDATORS.put(DOZE_WAKE_SCREEN_GESTURE, DOZE_WAKE_SCREEN_GESTURE_VALIDATOR);
VALIDATORS.put(NFC_PAYMENT_DEFAULT_COMPONENT, NFC_PAYMENT_DEFAULT_COMPONENT_VALIDATOR);
VALIDATORS.put(AUTOMATIC_STORAGE_MANAGER_DAYS_TO_RETAIN,
@@ -10600,6 +10591,18 @@
private static final Validator WIFI_PNO_RECENCY_SORTING_ENABLED_VALIDATOR =
BOOLEAN_VALIDATOR;
+ /**
+ * Setting to enable the Wi-Fi link probing.
+ * Disabled by default, and setting it to 1 will enable it.
+ * The value is boolean (0 or 1).
+ * @hide
+ */
+ public static final String WIFI_LINK_PROBING_ENABLED =
+ "wifi_link_probing_enabled";
+
+ private static final Validator WIFI_LINK_PROBING_ENABLED_VALIDATOR =
+ BOOLEAN_VALIDATOR;
+
/**
* The maximum number of times we will retry a connection to an access
* point for which we have failed in acquiring an IP address from DHCP.
@@ -11425,6 +11428,9 @@
* The following keys are supported:
*
* <pre>
+ * advertise_is_enabled (boolean)
+ * datasaver_disabled (boolean)
+ * launch_boost_disabled (boolean)
* vibration_disabled (boolean)
* animation_disabled (boolean)
* soundtrigger_disabled (boolean)
@@ -11448,6 +11454,14 @@
/**
* Battery Saver device specific settings
* This is encoded as a key=value list, separated by commas.
+ *
+ * The following keys are supported:
+ *
+ * <pre>
+ * cpufreq-i (list of "core-number:frequency" pairs concatenated with /)
+ * cpufreq-n (list of "core-number:frequency" pairs concatenated with /)
+ * </pre>
+ *
* See {@link com.android.server.power.batterysaver.BatterySaverPolicy} for the details.
*
* @hide
@@ -11456,6 +11470,24 @@
"battery_saver_device_specific_constants";
/**
+ * Settings for adaptive Battery Saver mode. Uses the same flags as
+ * {@link #BATTERY_SAVER_CONSTANTS}.
+ *
+ * @hide
+ */
+ public static final String BATTERY_SAVER_ADAPTIVE_CONSTANTS =
+ "battery_saver_adaptive_constants";
+
+ /**
+ * Device specific settings for adaptive Battery Saver mode. Uses the same flags as
+ * {@link #BATTERY_SAVER_DEVICE_SPECIFIC_CONSTANTS}.
+ *
+ * @hide
+ */
+ public static final String BATTERY_SAVER_ADAPTIVE_DEVICE_SPECIFIC_CONSTANTS =
+ "battery_saver_adaptive_device_specific_constants";
+
+ /**
* Battery tip specific settings
* This is encoded as a key=value list, separated by commas. Ex:
*
@@ -13393,6 +13425,7 @@
WIFI_PNO_FREQUENCY_CULLING_ENABLED_VALIDATOR);
VALIDATORS.put(WIFI_PNO_RECENCY_SORTING_ENABLED,
WIFI_PNO_RECENCY_SORTING_ENABLED_VALIDATOR);
+ VALIDATORS.put(WIFI_LINK_PROBING_ENABLED, WIFI_LINK_PROBING_ENABLED_VALIDATOR);
}
/**
diff --git a/core/java/android/service/appprediction/AppPredictionService.java b/core/java/android/service/appprediction/AppPredictionService.java
index b77405a..d012851 100644
--- a/core/java/android/service/appprediction/AppPredictionService.java
+++ b/core/java/android/service/appprediction/AppPredictionService.java
@@ -21,6 +21,7 @@
import android.annotation.MainThread;
import android.annotation.NonNull;
import android.annotation.SystemApi;
+import android.annotation.TestApi;
import android.app.Service;
import android.app.prediction.AppPredictionContext;
import android.app.prediction.AppPredictionSessionId;
@@ -49,6 +50,7 @@
* @hide
*/
@SystemApi
+@TestApi
public abstract class AppPredictionService extends Service {
private static final String TAG = "AppPredictionService";
@@ -140,6 +142,7 @@
@Override
public final IBinder onBind(Intent intent) {
+ // TODO(b/111701043): Verify that the action is valid
return mInterface.asBinder();
}
@@ -228,6 +231,7 @@
public void onStopPredictionUpdates() {}
private void doRequestPredictionUpdate(@NonNull AppPredictionSessionId sessionId) {
+ // Just an optimization, if there are no callbacks, then don't bother notifying the service
final ArrayList<CallbackWrapper> callbacks = mSessionCallbacks.get(sessionId);
if (callbacks != null && !callbacks.isEmpty()) {
onRequestPredictionUpdate(sessionId);
diff --git a/core/java/android/service/attention/AttentionService.java b/core/java/android/service/attention/AttentionService.java
index f6e448dc..24d74ff 100644
--- a/core/java/android/service/attention/AttentionService.java
+++ b/core/java/android/service/attention/AttentionService.java
@@ -64,10 +64,10 @@
/** Attention is present. */
public static final int ATTENTION_SUCCESS_PRESENT = 1;
- /** Preempted by other camera user. */
+ /** Preempted by other client. */
public static final int ATTENTION_FAILURE_PREEMPTED = 2;
- /** Preempted by other camera user. */
+ /** Request timed out. */
public static final int ATTENTION_FAILURE_TIMED_OUT = 3;
/** Unknown reasons for failing to determine the attention. */
diff --git a/core/java/android/service/dreams/OWNERS b/core/java/android/service/dreams/OWNERS
index 3c9bbf8..426f002 100644
--- a/core/java/android/service/dreams/OWNERS
+++ b/core/java/android/service/dreams/OWNERS
@@ -1,3 +1,3 @@
-dsandler@google.com
+dsandler@android.com
michaelwr@google.com
roosa@google.com
diff --git a/core/java/android/service/voice/VoiceInteractionService.java b/core/java/android/service/voice/VoiceInteractionService.java
index 2789651..e76e096 100644
--- a/core/java/android/service/voice/VoiceInteractionService.java
+++ b/core/java/android/service/voice/VoiceInteractionService.java
@@ -16,7 +16,6 @@
package android.service.voice;
-import android.annotation.IntDef;
import android.annotation.NonNull;
import android.annotation.Nullable;
import android.annotation.SdkConstant;
@@ -41,8 +40,6 @@
import java.io.FileDescriptor;
import java.io.PrintWriter;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
import java.util.ArrayList;
import java.util.List;
import java.util.Locale;
@@ -80,33 +77,6 @@
*/
public static final String SERVICE_META_DATA = "android.voice_interaction";
- /** @hide */
- @Retention(RetentionPolicy.SOURCE)
- @IntDef(prefix = {"VOICE_STATE_"}, value = {
- VOICE_STATE_NONE,
- VOICE_STATE_CONDITIONAL_LISTENING,
- VOICE_STATE_LISTENING,
- VOICE_STATE_FULFILLING})
- public @interface VoiceState {
- }
-
- /**
- * Voice assistant inactive.
- */
- public static final int VOICE_STATE_NONE = 0;
- /**
- * Voice assistant listening, but will only trigger if it hears a request it can fulfill.
- */
- public static final int VOICE_STATE_CONDITIONAL_LISTENING = 1;
- /**
- * Voice assistant is listening to user speech.
- */
- public static final int VOICE_STATE_LISTENING = 2;
- /**
- * Voice assistant is fulfilling an action requested by the user.
- */
- public static final int VOICE_STATE_FULFILLING = 3;
-
IVoiceInteractionService mInterface = new IVoiceInteractionService.Stub() {
@Override
public void ready() {
@@ -376,7 +346,7 @@
*
* @param state value indicating whether the assistant is listening, fulfilling, etc.
*/
- public final void setVoiceState(@VoiceState int state) {
+ public final void setVoiceState(int state) {
try {
mSystemService.setVoiceState(state);
} catch (RemoteException e) {
diff --git a/core/java/android/util/FeatureFlagUtils.java b/core/java/android/util/FeatureFlagUtils.java
index db9351b..1ca6398 100644
--- a/core/java/android/util/FeatureFlagUtils.java
+++ b/core/java/android/util/FeatureFlagUtils.java
@@ -36,6 +36,7 @@
public static final String FFLAG_PREFIX = "sys.fflag.";
public static final String FFLAG_OVERRIDE_PREFIX = FFLAG_PREFIX + "override.";
public static final String PERSIST_PREFIX = "persist." + FFLAG_OVERRIDE_PREFIX;
+ public static final String SEAMLESS_TRANSFER = "settings_seamless_transfer";
public static final String HEARING_AID_SETTINGS = "settings_bluetooth_hearing_aid";
public static final String SAFETY_HUB = "settings_safety_hub";
public static final String SCREENRECORD_LONG_PRESS = "settings_screenrecord_long_press";
@@ -51,12 +52,13 @@
DEFAULT_FLAGS.put("settings_dynamic_homepage", "true");
DEFAULT_FLAGS.put("settings_mobile_network_v2", "true");
DEFAULT_FLAGS.put("settings_network_and_internet_v2", "false");
- DEFAULT_FLAGS.put("settings_seamless_transfer", "false");
DEFAULT_FLAGS.put("settings_slice_injection", "true");
DEFAULT_FLAGS.put("settings_systemui_theme", "true");
DEFAULT_FLAGS.put("settings_wifi_dpp", "true");
DEFAULT_FLAGS.put("settings_wifi_mac_randomization", "true");
DEFAULT_FLAGS.put("settings_wifi_sharing", "true");
+ DEFAULT_FLAGS.put("settings_mainline_module", "false");
+ DEFAULT_FLAGS.put(SEAMLESS_TRANSFER, "false");
DEFAULT_FLAGS.put(HEARING_AID_SETTINGS, "false");
DEFAULT_FLAGS.put(SAFETY_HUB, "false");
DEFAULT_FLAGS.put(SCREENRECORD_LONG_PRESS, "false");
diff --git a/core/java/android/view/textclassifier/ExtrasUtils.java b/core/java/android/view/textclassifier/ExtrasUtils.java
new file mode 100644
index 0000000..602455c
--- /dev/null
+++ b/core/java/android/view/textclassifier/ExtrasUtils.java
@@ -0,0 +1,127 @@
+/*
+ * Copyright (C) 2019 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.view.textclassifier;
+
+import android.annotation.Nullable;
+import android.app.RemoteAction;
+import android.content.Intent;
+import android.os.Bundle;
+
+import java.util.ArrayList;
+
+/**
+ * Utility class for inserting and retrieving data in TextClassifier request/response extras.
+ * @hide
+ */
+public final class ExtrasUtils {
+
+ private static final String ACTIONS_INTENTS = "actions-intents";
+ private static final String FOREIGN_LANGUAGE = "foreign-language";
+ private static final String ENTITY_TYPE = "entity-type";
+ private static final String SCORE = "score";
+ private static final String MODEL_VERSION = "model-version";
+ private static final String MODEL_NAME = "model-name";
+
+ private ExtrasUtils() {}
+
+ /**
+ * Bundles and returns foreign language detection information for TextClassifier responses.
+ */
+ static Bundle createForeignLanguageExtra(
+ String language, float score, int modelVersion) {
+ final Bundle bundle = new Bundle();
+ bundle.putString(ENTITY_TYPE, language);
+ bundle.putFloat(SCORE, score);
+ bundle.putInt(MODEL_VERSION, modelVersion);
+ bundle.putString(MODEL_NAME, "langId_v" + modelVersion);
+ return bundle;
+ }
+
+ /**
+ * Stores {@code extra} as foreign language information in TextClassifier response object's
+ * extras {@code container}.
+ */
+ static void putForeignLanguageExtra(Bundle container, Bundle extra) {
+ container.putParcelable(FOREIGN_LANGUAGE, extra);
+ }
+
+ /**
+ * Returns foreign language detection information contained in the TextClassification object.
+ * responses.
+ */
+ @Nullable
+ public static Bundle getForeignLanguageExtra(TextClassification classification) {
+ return classification.getExtras().getBundle(FOREIGN_LANGUAGE);
+ }
+
+ /**
+ * Stores {@code actionIntents} information in TextClassifier response object's extras
+ * {@code container}.
+ */
+ static void putActionsIntents(Bundle container, ArrayList<Intent> actionsIntents) {
+ container.putParcelableArrayList(ACTIONS_INTENTS, actionsIntents);
+ }
+
+ /**
+ * Returns {@code actionIntents} information contained in the TextClassification object.
+ */
+ @Nullable
+ public static ArrayList<Intent> getActionsIntents(TextClassification classification) {
+ return classification.getExtras().getParcelableArrayList(ACTIONS_INTENTS);
+ }
+
+ /**
+ * Returns the first "translate" action found in the {@code classification} object.
+ */
+ @Nullable
+ public static RemoteAction findTranslateAction(TextClassification classification) {
+ final ArrayList<Intent> actionIntents = getActionsIntents(classification);
+ if (actionIntents != null) {
+ final int size = actionIntents.size();
+ for (int i = 0; i < size; i++) {
+ if (Intent.ACTION_TRANSLATE.equals(actionIntents.get(i).getAction())) {
+ return classification.getActions().get(i);
+ }
+ }
+ }
+ return null;
+ }
+
+ /**
+ * Returns the entity type contained in the {@code extra}.
+ */
+ @Nullable
+ public static String getEntityType(Bundle extra) {
+ return extra.getString(ENTITY_TYPE);
+ }
+
+ /**
+ * Returns the score contained in the {@code extra}.
+ */
+ @Nullable
+ public static float getScore(Bundle extra) {
+ return extra.getFloat(SCORE, -1);
+ }
+
+ /**
+ * Returns the model name contained in the {@code extra}.
+ */
+ @Nullable
+ public static String getModelName(Bundle extra) {
+ return extra.getString(MODEL_NAME);
+ }
+}
diff --git a/core/java/android/view/textclassifier/TextClassification.java b/core/java/android/view/textclassifier/TextClassification.java
index d9f7965..a059209 100644
--- a/core/java/android/view/textclassifier/TextClassification.java
+++ b/core/java/android/view/textclassifier/TextClassification.java
@@ -378,6 +378,8 @@
@Nullable private OnClickListener mLegacyOnClickListener;
@Nullable private String mId;
@Nullable private Bundle mExtras;
+ @NonNull private final ArrayList<Intent> mActionIntents = new ArrayList<>();
+ @Nullable private Bundle mForeignLanguageExtra;
/**
* Sets the classified text.
@@ -412,8 +414,19 @@
*/
@NonNull
public Builder addAction(@NonNull RemoteAction action) {
+ return addAction(action, null);
+ }
+
+ /**
+ * @param intent the intent in the remote action.
+ * @see #addAction(RemoteAction)
+ * @hide
+ */
+ @VisibleForTesting(visibility = VisibleForTesting.Visibility.PACKAGE)
+ public Builder addAction(RemoteAction action, @Nullable Intent intent) {
Preconditions.checkArgument(action != null);
mActions.add(action);
+ mActionIntents.add(intent);
return this;
}
@@ -499,13 +512,33 @@
}
/**
+ * @see #setExtras(Bundle)
+ * @hide
+ */
+ @VisibleForTesting(visibility = VisibleForTesting.Visibility.PACKAGE)
+ public Builder setForeignLanguageExtra(@Nullable Bundle extra) {
+ mForeignLanguageExtra = extra;
+ return this;
+ }
+
+ /**
* Builds and returns a {@link TextClassification} object.
*/
@NonNull
public TextClassification build() {
return new TextClassification(mText, mLegacyIcon, mLegacyLabel, mLegacyIntent,
- mLegacyOnClickListener, mActions, mEntityConfidence, mId,
- mExtras == null ? Bundle.EMPTY : mExtras.deepCopy());
+ mLegacyOnClickListener, mActions, mEntityConfidence, mId, buildExtras());
+ }
+
+ private Bundle buildExtras() {
+ final Bundle extras = mExtras == null ? new Bundle() : mExtras.deepCopy();
+ if (!mActionIntents.isEmpty()) {
+ ExtrasUtils.putActionsIntents(extras, mActionIntents);
+ }
+ if (mForeignLanguageExtra != null) {
+ ExtrasUtils.putForeignLanguageExtra(extras, mForeignLanguageExtra);
+ }
+ return extras.isEmpty() ? Bundle.EMPTY : extras;
}
}
diff --git a/core/java/android/view/textclassifier/TextClassificationSession.java b/core/java/android/view/textclassifier/TextClassificationSession.java
index 45668c0..ba1287f 100644
--- a/core/java/android/view/textclassifier/TextClassificationSession.java
+++ b/core/java/android/view/textclassifier/TextClassificationSession.java
@@ -71,10 +71,23 @@
@Override
public void onSelectionEvent(SelectionEvent event) {
- checkDestroyed();
- Preconditions.checkNotNull(event);
- if (mEventHelper.sanitizeEvent(event)) {
- mDelegate.onSelectionEvent(event);
+ try {
+ if (mEventHelper.sanitizeEvent(event)) {
+ mDelegate.onSelectionEvent(event);
+ }
+ } catch (Exception e) {
+ // Avoid crashing for event reporting.
+ Log.e(LOG_TAG, "Error reporting text classifier selection event", e);
+ }
+ }
+
+ @Override
+ public void onTextClassifierEvent(TextClassifierEvent event) {
+ try {
+ mDelegate.onTextClassifierEvent(event);
+ } catch (Exception e) {
+ // Avoid crashing for event reporting.
+ Log.e(LOG_TAG, "Error reporting text classifier event", e);
}
}
diff --git a/core/java/android/view/textclassifier/TextClassifier.java b/core/java/android/view/textclassifier/TextClassifier.java
index 8a688d8..e010155 100644
--- a/core/java/android/view/textclassifier/TextClassifier.java
+++ b/core/java/android/view/textclassifier/TextClassifier.java
@@ -161,7 +161,12 @@
* No-op TextClassifier.
* This may be used to turn off TextClassifier features.
*/
- TextClassifier NO_OP = new TextClassifier() {};
+ TextClassifier NO_OP = new TextClassifier() {
+ @Override
+ public String toString() {
+ return "TextClassifier.NO_OP";
+ }
+ };
/**
* Extra that is included on activity intents coming from a TextClassifier when
diff --git a/core/java/android/view/textclassifier/TextClassifierEvent.java b/core/java/android/view/textclassifier/TextClassifierEvent.java
index cd13cc0..0d4338b 100644
--- a/core/java/android/view/textclassifier/TextClassifierEvent.java
+++ b/core/java/android/view/textclassifier/TextClassifierEvent.java
@@ -141,6 +141,8 @@
@Nullable private final String mLanguage;
private final float mScore;
+ @Nullable private final String mModelName;
+
private TextClassifierEvent(
int eventCategory,
int eventType,
@@ -156,7 +158,8 @@
int relativeSuggestedWordEndIndex,
int[] actionIndex,
String language,
- float score) {
+ float score,
+ String modelVersion) {
mEventCategory = eventCategory;
mEventType = eventType;
mEntityTypes = entityTypes;
@@ -172,6 +175,7 @@
mActionIndices = actionIndex;
mLanguage = language;
mScore = score;
+ mModelName = modelVersion;
}
@Override
@@ -196,6 +200,7 @@
dest.writeIntArray(mActionIndices);
dest.writeString(mLanguage);
dest.writeFloat(mScore);
+ dest.writeString(mModelName);
}
private static TextClassifierEvent readFromParcel(Parcel in) {
@@ -214,7 +219,8 @@
/* relativeSuggestedWordEndIndex= */ in.readInt(),
/* actionIndices= */ in.createIntArray(),
/* language= */ in.readString(),
- /* score= */ in.readFloat());
+ /* score= */ in.readFloat(),
+ /* modelVersion= */ in.readString());
}
/**
@@ -264,6 +270,7 @@
return mEventIndex;
}
+ // TODO: Remove this API.
/**
* Returns the time this event occurred. This is the number of milliseconds since
* January 1, 1970, 00:00:00 GMT. 0 indicates not set.
@@ -339,6 +346,15 @@
}
/**
+ * Returns the model name.
+ * @hide
+ */
+ @Nullable
+ public String getModelName() {
+ return mModelName;
+ }
+
+ /**
* Builder to build a text classifier event.
*/
public static final class Builder {
@@ -359,6 +375,8 @@
@Nullable private String mLanguage;
private float mScore;
+ private String mModelName;
+
/**
* Creates a builder for building {@link TextClassifierEvent}s.
*
@@ -407,6 +425,7 @@
return this;
}
+ // TODO: Remove this API.
/**
* Sets the time this event occurred. This is the number of milliseconds since
* January 1, 1970, 00:00:00 GMT. 0 indicates not set.
@@ -501,6 +520,15 @@
}
/**
+ * Sets the model name string.
+ * @hide
+ */
+ public Builder setModelName(@Nullable String modelVersion) {
+ mModelName = modelVersion;
+ return this;
+ }
+
+ /**
* Builds and returns a text classifier event.
*/
@NonNull
@@ -521,7 +549,8 @@
mRelativeSuggestedWordEndIndex,
mActionIndices,
mLanguage,
- mScore);
+ mScore,
+ mModelName);
}
// TODO: Add build(boolean validate).
}
@@ -544,6 +573,7 @@
out.append(", mActionIndices=").append(Arrays.toString(mActionIndices));
out.append(", mLanguage=").append(mLanguage);
out.append(", mScore=").append(mScore);
+ out.append(", mModelName=").append(mModelName);
out.append("}");
return out.toString();
}
diff --git a/core/java/android/view/textclassifier/TextClassifierEventTronLogger.java b/core/java/android/view/textclassifier/TextClassifierEventTronLogger.java
index 5563dfc..6a12250 100644
--- a/core/java/android/view/textclassifier/TextClassifierEventTronLogger.java
+++ b/core/java/android/view/textclassifier/TextClassifierEventTronLogger.java
@@ -16,7 +16,6 @@
package android.view.textclassifier;
import static com.android.internal.logging.nano.MetricsProto.MetricsEvent.FIELD_TEXTCLASSIFIER_MODEL;
-import static com.android.internal.logging.nano.MetricsProto.MetricsEvent.FIELD_TEXT_CLASSIFIER_EVENT_TIME;
import static com.android.internal.logging.nano.MetricsProto.MetricsEvent.FIELD_TEXT_CLASSIFIER_FIRST_ENTITY_TYPE;
import static com.android.internal.logging.nano.MetricsProto.MetricsEvent.FIELD_TEXT_CLASSIFIER_SCORE;
import static com.android.internal.logging.nano.MetricsProto.MetricsEvent.FIELD_TEXT_CLASSIFIER_SECOND_ENTITY_TYPE;
@@ -46,7 +45,7 @@
private final MetricsLogger mMetricsLogger;
public TextClassifierEventTronLogger() {
- mMetricsLogger = new MetricsLogger();
+ this(new MetricsLogger());
}
@VisibleForTesting
@@ -57,6 +56,7 @@
/** Emits a text classifier event to the logs. */
public void writeEvent(TextClassifierEvent event) {
Preconditions.checkNotNull(event);
+
int category = getCategory(event);
if (category == -1) {
Log.w(TAG, "Unknown category: " + event.getEventCategory());
@@ -65,14 +65,12 @@
final LogMaker log = new LogMaker(category)
.setSubtype(getLogType(event))
.addTaggedData(FIELD_TEXT_CLASSIFIER_SESSION_ID, event.getResultId())
- .addTaggedData(FIELD_TEXT_CLASSIFIER_EVENT_TIME, event.getEventTime())
- .addTaggedData(FIELD_TEXTCLASSIFIER_MODEL,
- SelectionSessionLogger.SignatureParser.getModelName(event.getResultId()))
+ .addTaggedData(FIELD_TEXTCLASSIFIER_MODEL, getModelName(event))
.addTaggedData(FIELD_TEXT_CLASSIFIER_SCORE, event.getScore());
String[] entityTypes = event.getEntityTypes();
- // TRON does not support a field of list type, and thus workaround by store them
- // in three separate fields. This is no longer an issue once we have moved to Westworld.
+ // The old logger does not support a field of list type, and thus workaround by store them
+ // in three separate fields. This is not an issue with the new logger.
if (entityTypes.length >= 1) {
log.addTaggedData(FIELD_TEXT_CLASSIFIER_FIRST_ENTITY_TYPE, entityTypes[0]);
}
@@ -93,6 +91,13 @@
debugLog(log);
}
+ private static String getModelName(TextClassifierEvent event) {
+ if (event.getModelName() != null) {
+ return event.getModelName();
+ }
+ return SelectionSessionLogger.SignatureParser.getModelName(event.getResultId());
+ }
+
private static int getCategory(TextClassifierEvent event) {
switch (event.getEventCategory()) {
case TextClassifierEvent.CATEGORY_CONVERSATION_ACTIONS:
diff --git a/core/java/android/view/textclassifier/TextClassifierImpl.java b/core/java/android/view/textclassifier/TextClassifierImpl.java
index c297928..14afa33 100644
--- a/core/java/android/view/textclassifier/TextClassifierImpl.java
+++ b/core/java/android/view/textclassifier/TextClassifierImpl.java
@@ -65,9 +65,6 @@
*/
public final class TextClassifierImpl implements TextClassifier {
- /** @hide */
- public static final String ACTIONS_INTENTS = "actions-intents";
-
private static final String LOG_TAG = DEFAULT_LOG_TAG;
private static final boolean DEBUG = false;
@@ -343,7 +340,11 @@
if (DEBUG) {
Log.d(DEFAULT_LOG_TAG, "onTextClassifierEvent() called with: event = [" + event + "]");
}
- mTextClassifierEventTronLogger.writeEvent(event);
+ try {
+ mTextClassifierEventTronLogger.writeEvent(event);
+ } catch (Exception e) {
+ Log.e(LOG_TAG, "Error writing event", e);
+ }
}
/** @inheritDoc */
@@ -566,12 +567,16 @@
final float foreignTextThreshold = mSettings.getLangIdThresholdOverride() >= 0
? mSettings.getLangIdThresholdOverride()
: 0.5f /* TODO: Load this from the langId model. */;
+ final Bundle foreignLanguageBundle =
+ detectForeignLanguage(classifiedText, foreignTextThreshold);
+ builder.setForeignLanguageExtra(foreignLanguageBundle);
+
boolean isPrimaryAction = true;
final ArrayList<Intent> sourceIntents = new ArrayList<>();
List<LabeledIntent> labeledIntents = mIntentFactory.create(
mContext,
classifiedText,
- isForeignText(classifiedText, foreignTextThreshold),
+ foreignLanguageBundle != null,
referenceTime,
highestScoringResult);
for (LabeledIntent labeledIntent : labeledIntents) {
@@ -590,28 +595,28 @@
labeledIntent.getIntent(), labeledIntent.getRequestCode())));
isPrimaryAction = false;
}
- builder.addAction(action);
- sourceIntents.add(labeledIntent.getIntent());
+ builder.addAction(action, labeledIntent.getIntent());
}
- final Bundle extras = new Bundle();
- extras.putParcelableArrayList(ACTIONS_INTENTS, sourceIntents);
-
- return builder.setId(createId(text, start, end))
- .setExtras(extras)
- .build();
+ return builder.setId(createId(text, start, end)).build();
}
- private boolean isForeignText(String text, float threshold) {
+ /**
+ * Returns a bundle with the language and confidence score if it finds the text to be
+ * in a foreign language. Otherwise returns null.
+ */
+ @Nullable
+ private Bundle detectForeignLanguage(String text, float threshold) {
if (threshold > 1) {
- return false;
+ return null;
}
// TODO: Revisit this algorithm.
try {
- final LangIdModel.LanguageResult[] langResults = getLangIdImpl().detectLanguages(text);
+ final LangIdModel langId = getLangIdImpl();
+ final LangIdModel.LanguageResult[] langResults = langId.detectLanguages(text);
if (langResults.length <= 0) {
- return false;
+ return null;
}
LangIdModel.LanguageResult highestScoringResult = langResults[0];
@@ -621,7 +626,7 @@
}
}
if (highestScoringResult.getScore() < threshold) {
- return false;
+ return null;
}
// TODO: Remove
Log.d(LOG_TAG, String.format("Language detected: <%s:%s>",
@@ -632,14 +637,15 @@
final int size = deviceLocales.size();
for (int i = 0; i < size; i++) {
if (deviceLocales.get(i).getLanguage().equals(detected.getLanguage())) {
- return false;
+ return null;
}
}
- return true;
+ return ExtrasUtils.createForeignLanguageExtra(
+ detected.getLanguage(), highestScoringResult.getScore(), langId.getVersion());
} catch (Throwable t) {
Log.e(LOG_TAG, "Error detecting foreign text. Ignored.", t);
}
- return false;
+ return null;
}
@Override
@@ -773,3 +779,4 @@
}
}
}
+
diff --git a/core/java/android/widget/Editor.java b/core/java/android/widget/Editor.java
index 4a60b6a..c38566b 100644
--- a/core/java/android/widget/Editor.java
+++ b/core/java/android/widget/Editor.java
@@ -4112,9 +4112,9 @@
}
}
- private MenuItem addAssistMenuItem(Menu menu, RemoteAction action, int intemId, int order,
+ private MenuItem addAssistMenuItem(Menu menu, RemoteAction action, int itemId, int order,
int showAsAction) {
- final MenuItem item = menu.add(TextView.ID_ASSIST, intemId, order, action.getTitle())
+ final MenuItem item = menu.add(TextView.ID_ASSIST, itemId, order, action.getTitle())
.setContentDescription(action.getContentDescription());
if (action.shouldShowIcon()) {
item.setIcon(action.getIcon().loadDrawable(mTextView.getContext()));
@@ -4188,7 +4188,8 @@
@Override
public boolean onActionItemClicked(ActionMode mode, MenuItem item) {
- getSelectionActionModeHelper().onSelectionAction(item.getItemId());
+ getSelectionActionModeHelper()
+ .onSelectionAction(item.getItemId(), item.getTitle().toString());
if (mProcessTextIntentActionsHandler.performMenuItemAction(item)) {
return true;
diff --git a/core/java/android/widget/SelectionActionModeHelper.java b/core/java/android/widget/SelectionActionModeHelper.java
index 4caf288..564cfdd 100644
--- a/core/java/android/widget/SelectionActionModeHelper.java
+++ b/core/java/android/widget/SelectionActionModeHelper.java
@@ -20,12 +20,14 @@
import android.annotation.Nullable;
import android.annotation.UiThread;
import android.annotation.WorkerThread;
+import android.app.RemoteAction;
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.PointF;
import android.graphics.RectF;
import android.os.AsyncTask;
import android.os.Build;
+import android.os.Bundle;
import android.os.LocaleList;
import android.text.Layout;
import android.text.Selection;
@@ -34,13 +36,16 @@
import android.text.util.Linkify;
import android.util.Log;
import android.view.ActionMode;
+import android.view.textclassifier.ExtrasUtils;
import android.view.textclassifier.SelectionEvent;
import android.view.textclassifier.SelectionEvent.InvocationMethod;
import android.view.textclassifier.SelectionSessionLogger;
import android.view.textclassifier.TextClassification;
import android.view.textclassifier.TextClassificationConstants;
+import android.view.textclassifier.TextClassificationContext;
import android.view.textclassifier.TextClassificationManager;
import android.view.textclassifier.TextClassifier;
+import android.view.textclassifier.TextClassifierEvent;
import android.view.textclassifier.TextSelection;
import android.widget.Editor.SelectionModifierCursorController;
@@ -166,16 +171,17 @@
}
}
- public void onSelectionAction(int menuItemId) {
+ /** Reports a selection action event. */
+ public void onSelectionAction(int menuItemId, @Nullable String actionLabel) {
mSelectionTracker.onSelectionAction(
mTextView.getSelectionStart(), mTextView.getSelectionEnd(),
- getActionType(menuItemId), mTextClassification);
+ getActionType(menuItemId), actionLabel, mTextClassification);
}
public void onSelectionDrag() {
mSelectionTracker.onSelectionAction(
mTextView.getSelectionStart(), mTextView.getSelectionEnd(),
- SelectionEvent.ACTION_DRAG, mTextClassification);
+ SelectionEvent.ACTION_DRAG, /* actionLabel= */ null, mTextClassification);
}
public void onTextChanged(int start, int end) {
@@ -511,8 +517,11 @@
mOriginalEnd = mSelectionEnd = selectionEnd;
mAllowReset = false;
maybeInvalidateLogger();
- mLogger.logSelectionStarted(mTextView.getTextClassificationSession(),
- text, selectionStart,
+ mLogger.logSelectionStarted(
+ mTextView.getTextClassificationSession(),
+ mTextView.getTextClassificationContext(),
+ text,
+ selectionStart,
isLink ? SelectionEvent.INVOCATION_LINK : SelectionEvent.INVOCATION_MANUAL);
}
@@ -570,10 +579,12 @@
public void onSelectionAction(
int selectionStart, int selectionEnd,
@SelectionEvent.ActionType int action,
+ @Nullable String actionLabel,
@Nullable TextClassification classification) {
if (isSelectionStarted()) {
mAllowReset = false;
- mLogger.logSelectionAction(selectionStart, selectionEnd, action, classification);
+ mLogger.logSelectionAction(
+ selectionStart, selectionEnd, action, actionLabel, classification);
}
}
@@ -596,7 +607,8 @@
mSelectionEnd = editor.getTextView().getSelectionEnd();
mLogger.logSelectionAction(
textView.getSelectionStart(), textView.getSelectionEnd(),
- SelectionEvent.ACTION_RESET, null /* classification */);
+ SelectionEvent.ACTION_RESET,
+ /* actionLabel= */ null, /* classification= */ null);
}
return selected;
}
@@ -605,7 +617,9 @@
public void onTextChanged(int start, int end, TextClassification classification) {
if (isSelectionStarted() && start == mSelectionStart && end == mSelectionEnd) {
- onSelectionAction(start, end, SelectionEvent.ACTION_OVERTYPE, classification);
+ onSelectionAction(
+ start, end, SelectionEvent.ACTION_OVERTYPE,
+ /* actionLabel= */ null, classification);
}
}
@@ -644,7 +658,8 @@
if (mIsPending) {
mLogger.logSelectionAction(
mSelectionStart, mSelectionEnd,
- SelectionEvent.ACTION_ABANDON, null /* classification */);
+ SelectionEvent.ACTION_ABANDON,
+ /* actionLabel= */ null, /* classification= */ null);
mSelectionStart = mSelectionEnd = -1;
mLogger.endTextClassificationSession();
mIsPending = false;
@@ -679,6 +694,11 @@
private final BreakIterator mTokenIterator;
@Nullable private TextClassifier mClassificationSession;
+ @Nullable private TextClassificationContext mClassificationContext;
+
+ @Nullable private TextClassifierEvent mTranslateViewEvent;
+ @Nullable private TextClassifierEvent mTranslateClickEvent;
+
private int mStartIndex;
private String mText;
@@ -690,6 +710,7 @@
public void logSelectionStarted(
TextClassifier classificationSession,
+ TextClassificationContext classificationContext,
CharSequence text, int index,
@InvocationMethod int invocationMethod) {
try {
@@ -701,6 +722,7 @@
mTokenIterator.setText(mText);
mStartIndex = index;
mClassificationSession = classificationSession;
+ mClassificationContext = classificationContext;
if (hasActiveClassificationSession()) {
mClassificationSession.onSelectionEvent(
SelectionEvent.createSelectionStartedEvent(invocationMethod, 0));
@@ -731,6 +753,7 @@
SelectionEvent.createSelectionModifiedEvent(
wordIndices[0], wordIndices[1]));
}
+ maybeGenerateTranslateViewEvent(classification);
}
} catch (Exception e) {
// Avoid crashes due to logging.
@@ -741,6 +764,7 @@
public void logSelectionAction(
int start, int end,
@SelectionEvent.ActionType int action,
+ @Nullable String actionLabel,
@Nullable TextClassification classification) {
try {
if (hasActiveClassificationSession()) {
@@ -757,6 +781,9 @@
SelectionEvent.createSelectionActionEvent(
wordIndices[0], wordIndices[1], action));
}
+
+ maybeGenerateTranslateClickEvent(classification, actionLabel);
+
if (SelectionEvent.isTerminal(action)) {
endTextClassificationSession();
}
@@ -773,6 +800,7 @@
public void endTextClassificationSession() {
if (hasActiveClassificationSession()) {
+ maybeReportTranslateEvents();
mClassificationSession.destroy();
}
}
@@ -843,6 +871,78 @@
private boolean isWhitespace(int start, int end) {
return PATTERN_WHITESPACE.matcher(mText.substring(start, end)).matches();
}
+
+ private void maybeGenerateTranslateViewEvent(@Nullable TextClassification classification) {
+ if (classification != null) {
+ final TextClassifierEvent event = generateTranslateEvent(
+ TextClassifierEvent.TYPE_ACTIONS_SHOWN,
+ classification, mClassificationContext, /* actionLabel= */null);
+ mTranslateViewEvent = (event != null) ? event : mTranslateViewEvent;
+ }
+ }
+
+ private void maybeGenerateTranslateClickEvent(
+ @Nullable TextClassification classification, String actionLabel) {
+ if (classification != null) {
+ mTranslateClickEvent = generateTranslateEvent(
+ TextClassifierEvent.TYPE_SMART_ACTION,
+ classification, mClassificationContext, actionLabel);
+ }
+ }
+
+ private void maybeReportTranslateEvents() {
+ // Translate view and click events should only be logged once per selection session.
+ if (mTranslateViewEvent != null) {
+ mClassificationSession.onTextClassifierEvent(mTranslateViewEvent);
+ mTranslateViewEvent = null;
+ }
+ if (mTranslateClickEvent != null) {
+ mClassificationSession.onTextClassifierEvent(mTranslateClickEvent);
+ mTranslateClickEvent = null;
+ }
+ }
+
+ @Nullable
+ private static TextClassifierEvent generateTranslateEvent(
+ int eventType, TextClassification classification,
+ TextClassificationContext classificationContext, @Nullable String actionLabel) {
+
+ // The platform attempts to log "views" and "clicks" of the "Translate" action.
+ // Views are logged if a user is presented with the translate action during a selection
+ // session.
+ // Clicks are logged if the user clicks on the translate action.
+ // The index of the translate action is also logged to indicate whether it might have
+ // been in the main panel or overflow panel of the selection toolbar.
+ // NOTE that the "views" metric may be flawed if a TextView removes the translate menu
+ // item via a custom action mode callback or does not show a selection menu item.
+
+ final RemoteAction translateAction = ExtrasUtils.findTranslateAction(classification);
+ if (translateAction == null) {
+ // No translate action present. Nothing to log. Exit.
+ return null;
+ }
+
+ if (eventType == TextClassifierEvent.TYPE_SMART_ACTION
+ && !translateAction.getTitle().toString().equals(actionLabel)) {
+ // Clicked action is not a translate action. Nothing to log. Exit.
+ // Note that we don't expect an actionLabel for "view" events.
+ return null;
+ }
+
+ final Bundle foreignLanguageExtra = ExtrasUtils.getForeignLanguageExtra(classification);
+ final String language = ExtrasUtils.getEntityType(foreignLanguageExtra);
+ final float score = ExtrasUtils.getScore(foreignLanguageExtra);
+ final String model = ExtrasUtils.getModelName(foreignLanguageExtra);
+ return new TextClassifierEvent.Builder(
+ TextClassifierEvent.CATEGORY_LANGUAGE_DETECTION, eventType)
+ .setEventContext(classificationContext)
+ .setResultId(classification.getId())
+ .setEntityTypes(language)
+ .setScore(score)
+ .setActionIndices(classification.getActions().indexOf(translateAction))
+ .setModelName(model)
+ .build();
+ }
}
/**
diff --git a/core/java/android/widget/TextView.java b/core/java/android/widget/TextView.java
index 2b45c06..8029cf0 100644
--- a/core/java/android/widget/TextView.java
+++ b/core/java/android/widget/TextView.java
@@ -456,6 +456,7 @@
private TextClassifier mTextClassifier;
private TextClassifier mTextClassificationSession;
+ private TextClassificationContext mTextClassificationContext;
// A flag to prevent repeated movements from escaping the enclosing text view. The idea here is
// that if a user is holding down a movement key to traverse text, we shouldn't also traverse
@@ -12068,16 +12069,15 @@
} else {
widgetType = TextClassifier.WIDGET_TYPE_UNSELECTABLE_TEXTVIEW;
}
- final TextClassificationContext textClassificationContext =
- new TextClassificationContext.Builder(
- mContext.getPackageName(), widgetType)
- .build();
+ mTextClassificationContext = new TextClassificationContext.Builder(
+ mContext.getPackageName(), widgetType)
+ .build();
if (mTextClassifier != null) {
mTextClassificationSession = tcm.createTextClassificationSession(
- textClassificationContext, mTextClassifier);
+ mTextClassificationContext, mTextClassifier);
} else {
mTextClassificationSession = tcm.createTextClassificationSession(
- textClassificationContext);
+ mTextClassificationContext);
}
} else {
mTextClassificationSession = TextClassifier.NO_OP;
@@ -12087,6 +12087,15 @@
}
/**
+ * Returns the {@link TextClassificationContext} for the current TextClassifier session.
+ * @see #getTextClassificationSession()
+ */
+ @Nullable
+ TextClassificationContext getTextClassificationContext() {
+ return mTextClassificationContext;
+ }
+
+ /**
* Returns true if this TextView uses a no-op TextClassifier.
*/
boolean usesNoOpTextClassifier() {
diff --git a/core/java/com/android/internal/hardware/AmbientDisplayConfiguration.java b/core/java/com/android/internal/hardware/AmbientDisplayConfiguration.java
index 7a00a51..e19a32e 100644
--- a/core/java/com/android/internal/hardware/AmbientDisplayConfiguration.java
+++ b/core/java/com/android/internal/hardware/AmbientDisplayConfiguration.java
@@ -38,7 +38,7 @@
return pulseOnNotificationEnabled(user)
|| pulseOnLongPressEnabled(user)
|| alwaysOnEnabled(user)
- || wakeLockScreenGestureEnabled(user);
+ || wakeScreenGestureEnabled(user);
}
public boolean pulseOnNotificationEnabled(int user) {
@@ -76,11 +76,6 @@
return !TextUtils.isEmpty(doubleTapSensorType());
}
- public boolean wakeLockScreenGestureEnabled(int user) {
- return boolSettingDefaultOn(Settings.Secure.DOZE_WAKE_LOCK_SCREEN_GESTURE, user)
- && wakeScreenGestureAvailable();
- }
-
public boolean wakeScreenGestureAvailable() {
return mContext.getResources()
.getBoolean(R.bool.config_dozeWakeLockScreenSensorAvailable);
diff --git a/core/java/com/android/internal/net/VpnConfig.java b/core/java/com/android/internal/net/VpnConfig.java
index da8605e..65b974b 100644
--- a/core/java/com/android/internal/net/VpnConfig.java
+++ b/core/java/com/android/internal/net/VpnConfig.java
@@ -104,6 +104,7 @@
public boolean allowBypass;
public boolean allowIPv4;
public boolean allowIPv6;
+ public boolean isMetered = true;
public Network[] underlyingNetworks;
public ProxyInfo proxyInfo;
@@ -165,6 +166,7 @@
out.writeInt(allowBypass ? 1 : 0);
out.writeInt(allowIPv4 ? 1 : 0);
out.writeInt(allowIPv6 ? 1 : 0);
+ out.writeInt(isMetered ? 1 : 0);
out.writeTypedArray(underlyingNetworks, flags);
out.writeParcelable(proxyInfo, flags);
}
@@ -191,6 +193,7 @@
config.allowBypass = in.readInt() != 0;
config.allowIPv4 = in.readInt() != 0;
config.allowIPv6 = in.readInt() != 0;
+ config.isMetered = in.readInt() != 0;
config.underlyingNetworks = in.createTypedArray(Network.CREATOR);
config.proxyInfo = in.readParcelable(null);
return config;
diff --git a/core/java/com/android/internal/os/AppZygoteInit.java b/core/java/com/android/internal/os/AppZygoteInit.java
index 6ba584d..0e83e41 100644
--- a/core/java/com/android/internal/os/AppZygoteInit.java
+++ b/core/java/com/android/internal/os/AppZygoteInit.java
@@ -17,13 +17,15 @@
package com.android.internal.os;
import android.app.LoadedApk;
+import android.app.ZygotePreload;
+import android.content.ComponentName;
import android.content.pm.ApplicationInfo;
import android.net.LocalSocket;
import android.util.Log;
import java.io.DataOutputStream;
import java.io.IOException;
-import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Constructor;
import java.lang.reflect.Method;
/**
@@ -76,20 +78,29 @@
Zygote.allowAppFilesAcrossFork(appInfo);
- Class<?> cl;
- Method m;
- try {
- cl = Class.forName(appInfo.packageName + ".ZygotePreload", true, loader);
- m = cl.getMethod("doPreload");
- m.setAccessible(true);
- m.invoke(null);
- } catch (ClassNotFoundException e) {
- // Don't treat this as an error since an app may not want to do any preloads
- Log.w(TAG, "No ZygotePreload class found for " + appInfo.packageName);
- } catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException e) {
- Log.e(TAG, "AppZygote application preload failed for "
- + appInfo.packageName, e);
+ if (appInfo.zygotePreloadName != null) {
+ Class<?> cl;
+ Method m;
+ try {
+ ComponentName preloadName = ComponentName.createRelative(appInfo.packageName,
+ appInfo.zygotePreloadName);
+ cl = Class.forName(preloadName.getClassName(), true, loader);
+ if (!ZygotePreload.class.isAssignableFrom(cl)) {
+ Log.e(TAG, preloadName.getClassName() + " does not implement "
+ + ZygotePreload.class.getName());
+ } else {
+ Constructor<?> ctor = cl.getConstructor();
+ ZygotePreload preloadObject = (ZygotePreload) ctor.newInstance();
+ preloadObject.doPreload(appInfo);
+ }
+ } catch (ReflectiveOperationException e) {
+ Log.e(TAG, "AppZygote application preload failed for "
+ + appInfo.zygotePreloadName, e);
+ }
+ } else {
+ Log.i(TAG, "No zygotePreloadName attribute specified.");
}
+
try {
DataOutputStream socketOut = getSocketOutputStream();
socketOut.writeInt(loader != null ? 1 : 0);
diff --git a/core/java/com/android/internal/os/OWNERS b/core/java/com/android/internal/os/OWNERS
new file mode 100644
index 0000000..9283105
--- /dev/null
+++ b/core/java/com/android/internal/os/OWNERS
@@ -0,0 +1 @@
+per-file ZygoteArguments.java,ZygoteConnection.java,ZygoteInit.java,Zygote.java,ZygoteServer.java = chriswailes@google.com, ngeoffray@google.com, sehr@google.com, narayan@google.com, maco@google.com
diff --git a/core/jni/OWNERS b/core/jni/OWNERS
index a365a56..86342c4 100644
--- a/core/jni/OWNERS
+++ b/core/jni/OWNERS
@@ -4,3 +4,6 @@
# Connectivity
per-file android_net_* = ek@google.com, lorenzo@google.com, satk@google.com
+
+# Zygote
+per-file com_android_inernal_os_Zygote.*,fd_utils.* = chriswailes@google.com, ngeoffray@google.com, sehr@google.com, narayan@google.com, maco@google.com
diff --git a/core/jni/android/graphics/Shader.cpp b/core/jni/android/graphics/Shader.cpp
index ed6a84b..e741979 100644
--- a/core/jni/android/graphics/Shader.cpp
+++ b/core/jni/android/graphics/Shader.cpp
@@ -8,6 +8,8 @@
#include <jni.h>
+#include <vector>
+
using namespace android::uirenderer;
/**
@@ -18,11 +20,11 @@
*/
static const uint32_t sGradientShaderFlags = SkGradientShader::kInterpolateColorsInPremul_Flag;
-static void ThrowIAE_IfNull(JNIEnv* env, void* ptr) {
- if (NULL == ptr) {
- doThrowIAE(env);
+#define ThrowIAE_IfNull(env, ptr) \
+ if (nullptr == ptr) { \
+ doThrowIAE(env); \
+ return 0; \
}
-}
static void Color_RGBToHSV(JNIEnv* env, jobject, jint red, jint green, jint blue, jfloatArray hsvArray)
{
@@ -76,186 +78,115 @@
}
sk_sp<SkShader> shader = image->makeShader(
(SkShader::TileMode)tileModeX, (SkShader::TileMode)tileModeY);
+ ThrowIAE_IfNull(env, shader.get());
if (matrix) {
shader = shader->makeWithLocalMatrix(*matrix);
}
- ThrowIAE_IfNull(env, shader.get());
return reinterpret_cast<jlong>(shader.release());
}
///////////////////////////////////////////////////////////////////////////////////////////////
-static jlong LinearGradient_create1(JNIEnv* env, jobject o, jlong matrixPtr,
- jfloat x0, jfloat y0, jfloat x1, jfloat y1,
- jintArray colorArray, jfloatArray posArray, jint tileMode) {
- const SkMatrix* matrix = reinterpret_cast<const SkMatrix*>(matrixPtr);
- SkPoint pts[2];
- pts[0].set(x0, y0);
- pts[1].set(x1, y1);
+static std::vector<SkColor4f> convertColorLongs(JNIEnv* env, jlongArray colorArray) {
+ const size_t count = env->GetArrayLength(colorArray);
+ const jlong* colorValues = env->GetLongArrayElements(colorArray, nullptr);
- size_t count = env->GetArrayLength(colorArray);
- const jint* colorValues = env->GetIntArrayElements(colorArray, NULL);
-
- AutoJavaFloatArray autoPos(env, posArray, count);
-#ifdef SK_SCALAR_IS_FLOAT
- SkScalar* pos = autoPos.ptr();
-#else
- #error Need to convert float array to SkScalar array before calling the following function.
-#endif
-
- sk_sp<SkShader> baseShader(SkGradientShader::MakeLinear(pts,
- reinterpret_cast<const SkColor*>(colorValues), pos, count,
- static_cast<SkShader::TileMode>(tileMode), sGradientShaderFlags, NULL));
-
- SkShader* shader;
- if (matrix) {
- shader = baseShader->makeWithLocalMatrix(*matrix).release();
- } else {
- shader = baseShader.release();
+ std::vector<SkColor4f> colors(count);
+ for (size_t i = 0; i < count; ++i) {
+ colors[i] = GraphicsJNI::convertColorLong(colorValues[i]);
}
- env->ReleaseIntArrayElements(colorArray, const_cast<jint*>(colorValues), JNI_ABORT);
- ThrowIAE_IfNull(env, shader);
- return reinterpret_cast<jlong>(shader);
-}
-
-static jlong LinearGradient_create2(JNIEnv* env, jobject o, jlong matrixPtr,
- jfloat x0, jfloat y0, jfloat x1, jfloat y1, jint color0, jint color1, jint tileMode) {
- const SkMatrix* matrix = reinterpret_cast<const SkMatrix*>(matrixPtr);
-
- SkPoint pts[2];
- pts[0].set(x0, y0);
- pts[1].set(x1, y1);
-
- SkColor colors[2];
- colors[0] = color0;
- colors[1] = color1;
-
- sk_sp<SkShader> baseShader(SkGradientShader::MakeLinear(pts, colors, NULL, 2,
- static_cast<SkShader::TileMode>(tileMode), sGradientShaderFlags, NULL));
-
- SkShader* s;
- if (matrix) {
- s = baseShader->makeWithLocalMatrix(*matrix).release();
- } else {
- s = baseShader.release();
- }
-
- ThrowIAE_IfNull(env, s);
- return reinterpret_cast<jlong>(s);
+ env->ReleaseLongArrayElements(colorArray, const_cast<jlong*>(colorValues), JNI_ABORT);
+ return colors;
}
///////////////////////////////////////////////////////////////////////////////////////////////
-static jlong RadialGradient_create1(JNIEnv* env, jobject, jlong matrixPtr, jfloat x, jfloat y,
- jfloat radius, jintArray colorArray, jfloatArray posArray, jint tileMode) {
- const SkMatrix* matrix = reinterpret_cast<const SkMatrix*>(matrixPtr);
- SkPoint center;
- center.set(x, y);
+static jlong LinearGradient_create(JNIEnv* env, jobject, jlong matrixPtr,
+ jfloat x0, jfloat y0, jfloat x1, jfloat y1, jlongArray colorArray,
+ jfloatArray posArray, jint tileMode, long colorSpaceHandle) {
+ SkPoint pts[2];
+ pts[0].set(x0, y0);
+ pts[1].set(x1, y1);
- size_t count = env->GetArrayLength(colorArray);
- const jint* colorValues = env->GetIntArrayElements(colorArray, NULL);
+ std::vector<SkColor4f> colors = convertColorLongs(env, colorArray);
- AutoJavaFloatArray autoPos(env, posArray, count);
+ AutoJavaFloatArray autoPos(env, posArray, colors.size());
#ifdef SK_SCALAR_IS_FLOAT
SkScalar* pos = autoPos.ptr();
#else
#error Need to convert float array to SkScalar array before calling the following function.
#endif
- sk_sp<SkShader> baseShader = SkGradientShader::MakeRadial(center, radius,
- reinterpret_cast<const SkColor*>(colorValues), pos, count,
- static_cast<SkShader::TileMode>(tileMode), sGradientShaderFlags, NULL);
+ sk_sp<SkShader> shader(SkGradientShader::MakeLinear(pts, &colors[0],
+ GraphicsJNI::getNativeColorSpace(colorSpaceHandle), pos, colors.size(),
+ static_cast<SkShader::TileMode>(tileMode), sGradientShaderFlags, nullptr));
+ ThrowIAE_IfNull(env, shader);
- SkShader* shader;
+ const SkMatrix* matrix = reinterpret_cast<const SkMatrix*>(matrixPtr);
if (matrix) {
- shader = baseShader->makeWithLocalMatrix(*matrix).release();
- } else {
- shader = baseShader.release();
+ shader = shader->makeWithLocalMatrix(*matrix);
}
- env->ReleaseIntArrayElements(colorArray, const_cast<jint*>(colorValues),
- JNI_ABORT);
-
- ThrowIAE_IfNull(env, shader);
- return reinterpret_cast<jlong>(shader);
+ return reinterpret_cast<jlong>(shader.release());
}
-static jlong RadialGradient_create2(JNIEnv* env, jobject, jlong matrixPtr, jfloat x, jfloat y, jfloat radius,
- jint color0, jint color1, jint tileMode) {
- const SkMatrix* matrix = reinterpret_cast<const SkMatrix*>(matrixPtr);
+///////////////////////////////////////////////////////////////////////////////////////////////
+
+static jlong RadialGradient_create(JNIEnv* env, jobject, jlong matrixPtr, jfloat x, jfloat y,
+ jfloat radius, jlongArray colorArray, jfloatArray posArray, jint tileMode,
+ jlong colorSpaceHandle) {
SkPoint center;
center.set(x, y);
- SkColor colors[2];
- colors[0] = color0;
- colors[1] = color1;
+ std::vector<SkColor4f> colors = convertColorLongs(env, colorArray);
- sk_sp<SkShader> baseShader = SkGradientShader::MakeRadial(center, radius, colors, NULL, 2,
- static_cast<SkShader::TileMode>(tileMode), sGradientShaderFlags, NULL);
+ AutoJavaFloatArray autoPos(env, posArray, colors.size());
+#ifdef SK_SCALAR_IS_FLOAT
+ SkScalar* pos = autoPos.ptr();
+#else
+ #error Need to convert float array to SkScalar array before calling the following function.
+#endif
- SkShader* shader;
- if (matrix) {
- shader = baseShader->makeWithLocalMatrix(*matrix).release();
- } else {
- shader = baseShader.release();
- }
+ sk_sp<SkShader> shader = SkGradientShader::MakeRadial(center, radius, &colors[0],
+ GraphicsJNI::getNativeColorSpace(colorSpaceHandle), pos, colors.size(),
+ static_cast<SkShader::TileMode>(tileMode), sGradientShaderFlags, nullptr);
ThrowIAE_IfNull(env, shader);
- return reinterpret_cast<jlong>(shader);
+
+ const SkMatrix* matrix = reinterpret_cast<const SkMatrix*>(matrixPtr);
+ if (matrix) {
+ shader = shader->makeWithLocalMatrix(*matrix);
+ }
+
+ return reinterpret_cast<jlong>(shader.release());
}
///////////////////////////////////////////////////////////////////////////////
-static jlong SweepGradient_create1(JNIEnv* env, jobject, jlong matrixPtr, jfloat x, jfloat y,
- jintArray jcolors, jfloatArray jpositions) {
- const SkMatrix* matrix = reinterpret_cast<const SkMatrix*>(matrixPtr);
- size_t count = env->GetArrayLength(jcolors);
- const jint* colors = env->GetIntArrayElements(jcolors, NULL);
+static jlong SweepGradient_create(JNIEnv* env, jobject, jlong matrixPtr, jfloat x, jfloat y,
+ jlongArray colorArray, jfloatArray jpositions, jlong colorSpaceHandle) {
+ std::vector<SkColor4f> colors = convertColorLongs(env, colorArray);
- AutoJavaFloatArray autoPos(env, jpositions, count);
+ AutoJavaFloatArray autoPos(env, jpositions, colors.size());
#ifdef SK_SCALAR_IS_FLOAT
SkScalar* pos = autoPos.ptr();
#else
#error Need to convert float array to SkScalar array before calling the following function.
#endif
- sk_sp<SkShader> baseShader = SkGradientShader::MakeSweep(x, y,
- reinterpret_cast<const SkColor*>(colors), pos, count,
- sGradientShaderFlags, NULL);
-
- SkShader* shader;
- if (matrix) {
- shader = baseShader->makeWithLocalMatrix(*matrix).release();
- } else {
- shader = baseShader.release();
- }
-
- env->ReleaseIntArrayElements(jcolors, const_cast<jint*>(colors),
- JNI_ABORT);
+ sk_sp<SkShader> shader = SkGradientShader::MakeSweep(x, y, &colors[0],
+ GraphicsJNI::getNativeColorSpace(colorSpaceHandle), pos, colors.size(),
+ sGradientShaderFlags, nullptr);
ThrowIAE_IfNull(env, shader);
- return reinterpret_cast<jlong>(shader);
-}
-static jlong SweepGradient_create2(JNIEnv* env, jobject, jlong matrixPtr, jfloat x, jfloat y,
- int color0, int color1) {
const SkMatrix* matrix = reinterpret_cast<const SkMatrix*>(matrixPtr);
- SkColor colors[2];
- colors[0] = color0;
- colors[1] = color1;
-
- sk_sp<SkShader> baseShader = SkGradientShader::MakeSweep(x, y, colors,
- NULL, 2, sGradientShaderFlags, NULL);
-
- SkShader* shader;
if (matrix) {
- shader = baseShader->makeWithLocalMatrix(*matrix).release();
- } else {
- shader = baseShader.release();
+ shader = shader->makeWithLocalMatrix(*matrix);
}
- ThrowIAE_IfNull(env, shader);
- return reinterpret_cast<jlong>(shader);
+
+ return reinterpret_cast<jlong>(shader.release());
}
///////////////////////////////////////////////////////////////////////////////////////////////
@@ -295,18 +226,15 @@
};
static const JNINativeMethod gLinearGradientMethods[] = {
- { "nativeCreate1", "(JFFFF[I[FI)J", (void*)LinearGradient_create1 },
- { "nativeCreate2", "(JFFFFIII)J", (void*)LinearGradient_create2 },
+ { "nativeCreate", "(JFFFF[J[FIJ)J", (void*)LinearGradient_create },
};
static const JNINativeMethod gRadialGradientMethods[] = {
- { "nativeCreate1", "(JFFF[I[FI)J", (void*)RadialGradient_create1 },
- { "nativeCreate2", "(JFFFIII)J", (void*)RadialGradient_create2 },
+ { "nativeCreate", "(JFFF[J[FIJ)J", (void*)RadialGradient_create },
};
static const JNINativeMethod gSweepGradientMethods[] = {
- { "nativeCreate1", "(JFF[I[F)J", (void*)SweepGradient_create1 },
- { "nativeCreate2", "(JFFII)J", (void*)SweepGradient_create2 },
+ { "nativeCreate", "(JFF[J[FJ)J", (void*)SweepGradient_create },
};
static const JNINativeMethod gComposeShaderMethods[] = {
diff --git a/core/jni/android_media_AudioAttributes.cpp b/core/jni/android_media_AudioAttributes.cpp
index 4be4def..b87a34d 100644
--- a/core/jni/android_media_AudioAttributes.cpp
+++ b/core/jni/android_media_AudioAttributes.cpp
@@ -135,7 +135,7 @@
{
audio_attributes_t *aa = new (calloc(1, sizeof(audio_attributes_t)))
audio_attributes_t{AUDIO_ATTRIBUTES_INITIALIZER};
- return UniqueAaPtr{aa, free};
+ return UniqueAaPtr{aa};
}
jint JNIAudioAttributeHelper::nativeFromJava(JNIEnv* env, jobject jAudioAttributes,
diff --git a/core/jni/android_media_AudioAttributes.h b/core/jni/android_media_AudioAttributes.h
index c558352..628f7e3 100644
--- a/core/jni/android_media_AudioAttributes.h
+++ b/core/jni/android_media_AudioAttributes.h
@@ -27,7 +27,11 @@
class JNIAudioAttributeHelper
{
public:
- using UniqueAaPtr = std::unique_ptr<audio_attributes_t, decltype(free)*>;
+ struct FreeDeleter {
+ void operator()(void *p) const { ::free(p); }
+ };
+
+ using UniqueAaPtr = std::unique_ptr<audio_attributes_t, FreeDeleter>;
/**
* @brief makeUnique helper to prevent leak
diff --git a/core/jni/android_os_VintfObject.cpp b/core/jni/android_os_VintfObject.cpp
index e64d2af..ee11b61 100644
--- a/core/jni/android_os_VintfObject.cpp
+++ b/core/jni/android_os_VintfObject.cpp
@@ -96,7 +96,7 @@
return toJavaStringArray(env, cStrings);
}
-static jint verify(JNIEnv* env, jobjectArray packageInfo, android::vintf::CheckFlags::Type checks) {
+static jint android_os_VintfObject_verify(JNIEnv* env, jclass, jobjectArray packageInfo) {
std::vector<std::string> cPackageInfo;
if (packageInfo) {
size_t count = env->GetArrayLength(packageInfo);
@@ -109,18 +109,19 @@
}
}
std::string error;
- int32_t status = VintfObject::CheckCompatibility(cPackageInfo, &error, checks);
+ int32_t status = VintfObject::CheckCompatibility(cPackageInfo, &error);
if (status)
LOG(WARNING) << "VintfObject.verify() returns " << status << ": " << error;
return status;
}
-static jint android_os_VintfObject_verify(JNIEnv* env, jclass, jobjectArray packageInfo) {
- return verify(env, packageInfo, ::android::vintf::CheckFlags::ENABLE_ALL_CHECKS);
-}
-
static jint android_os_VintfObject_verifyWithoutAvb(JNIEnv* env, jclass) {
- return verify(env, nullptr, ::android::vintf::CheckFlags::DISABLE_AVB_CHECK);
+ std::string error;
+ int32_t status = VintfObject::CheckCompatibility({}, &error,
+ ::android::vintf::CheckFlags::DISABLE_AVB_CHECK);
+ if (status)
+ LOG(WARNING) << "VintfObject.verifyWithoutAvb() returns " << status << ": " << error;
+ return status;
}
static jobjectArray android_os_VintfObject_getHalNamesAndVersions(JNIEnv* env, jclass) {
diff --git a/core/proto/android/app/settings_enums.proto b/core/proto/android/app/settings_enums.proto
index 94a6734..f2f7304 100644
--- a/core/proto/android/app/settings_enums.proto
+++ b/core/proto/android/app/settings_enums.proto
@@ -2189,4 +2189,9 @@
// OPEN: Settings > System > Aware > Disable > Dialog
DIALOG_AWARE_DISABLE = 1633;
+
+ // OPEN: Settings > Settings > Network & internet > Click Mobile network to land on page with
+ // details for a SIM/eSIM mobile network > Click edit icon to bring up a rename dialog.
+ // OS: Q
+ MOBILE_NETWORK_RENAME_DIALOG = 1642;
}
diff --git a/core/proto/android/server/powermanagerservice.proto b/core/proto/android/server/powermanagerservice.proto
index af0a942..8fce94e 100644
--- a/core/proto/android/server/powermanagerservice.proto
+++ b/core/proto/android/server/powermanagerservice.proto
@@ -318,6 +318,16 @@
// Whether battery saver is enabled.
optional bool enabled = 1;
+ // Whether full battery saver is enabled.
+ optional bool is_full_enabled = 14;
+
+ // Whether adaptive battery saver is enabled.
+ optional bool is_adaptive_enabled = 15;
+
+ // Whether the battery saver policy indicates that is_enabled should be
+ // advertised.
+ optional bool should_advertise_is_enabled = 16;
+
// Whether system has booted.
optional bool boot_completed = 2;
@@ -358,4 +368,10 @@
// The value of Global.LOW_POWER_MODE_STICKY_AUTO_DISABLE_LEVEL. This is a cached value, so it
// could be slightly different from what's in GlobalSettingsProto.LowPowerMode.
optional int32 setting_battery_saver_sticky_auto_disable_threshold = 13;
+
+ // The last time adaptive battery saver was changed by an external service,
+ // using elapsed realtime as the timebase.
+ optional int64 last_adaptive_battery_saver_changed_externally_elapsed = 17;
+
+ // Next tag: 18
}
diff --git a/core/res/AndroidManifest.xml b/core/res/AndroidManifest.xml
index 7a261a9..bc9dc57 100644
--- a/core/res/AndroidManifest.xml
+++ b/core/res/AndroidManifest.xml
@@ -1730,7 +1730,7 @@
<permission android:name="android.permission.CONNECTIVITY_USE_RESTRICTED_NETWORKS"
android:protectionLevel="signature|privileged" />
- <!-- Allows a system application to access hardware packet offload capabilities.
+ <!-- @SystemApi Allows a system application to access hardware packet offload capabilities.
@hide -->
<permission android:name="android.permission.PACKET_KEEPALIVE_OFFLOAD"
android:protectionLevel="signature|privileged" />
@@ -1868,6 +1868,10 @@
<permission android:name="android.permission.HARDWARE_TEST"
android:protectionLevel="signature" />
+ <!-- @hide Allows an application to manage DynamicAndroid image -->
+ <permission android:name="android.permission.MANAGE_DYNAMIC_ANDROID"
+ android:protectionLevel="signature" />
+
<!-- @SystemApi Allows access to Broadcast Radio
@hide This is not a third-party API (intended for system apps).-->
<permission android:name="android.permission.ACCESS_BROADCAST_RADIO"
diff --git a/core/res/res/drawable/ic_media_seamless.xml b/core/res/res/drawable/ic_media_seamless.xml
new file mode 100644
index 0000000..122e9c5
--- /dev/null
+++ b/core/res/res/drawable/ic_media_seamless.xml
@@ -0,0 +1,25 @@
+<!--
+ Copyright (C) 2017 The Android Open Source Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
+ android:width="24dp"
+ android:height="24dp"
+ android:viewportWidth="24.0"
+ android:viewportHeight="24.0"
+ android:tint="?android:attr/colorControlNormal">
+ <path
+ android:fillColor="#FF000000"
+ android:pathData="M12,3l0.01,10.55c-0.59,-0.34 -1.27,-0.55 -2,-0.55C7.79,13 6,14.79 6,17c0,2.21 1.79,4 4.01,4S14,19.21 14,17V7h4V3H12zM10.01,19c-1.1,0 -2,-0.9 -2,-2c0,-1.1 0.9,-2 2,-2s2,0.9 2,2C12.01,18.1 11.11,19 10.01,19z"/>
+</vector>
diff --git a/core/res/res/layout/notification_template_material_big_media.xml b/core/res/res/layout/notification_template_material_big_media.xml
index 5cb93eb..56f7a59 100644
--- a/core/res/res/layout/notification_template_material_big_media.xml
+++ b/core/res/res/layout/notification_template_material_big_media.xml
@@ -79,6 +79,10 @@
layout="@layout/notification_material_media_action"
android:id="@+id/action4"
/>
+ <include
+ layout="@layout/notification_material_media_action"
+ android:id="@+id/media_seamless"
+ />
</LinearLayout>
</LinearLayout>
</com.android.internal.widget.MediaNotificationView>
diff --git a/core/res/res/values/attrs_manifest.xml b/core/res/res/values/attrs_manifest.xml
index 0abe456..1eece03 100644
--- a/core/res/res/values/attrs_manifest.xml
+++ b/core/res/res/values/attrs_manifest.xml
@@ -1116,6 +1116,15 @@
-->
<attr name="classLoader" format="string" />
+ <!-- Name of the class that gets invoked for preloading application code, when starting an
+ {@link android.R.attr#isolatedProcess} service that has
+ {@link android.R.attr#useAppZygote} set to <code>true</code>. This is a fully
+ qualified class name (for example, com.mycompany.myapp.MyZygotePreload); as a
+ short-hand if the first character of the class is a period then it is appended
+ to your package name. The class must implement the {@link android.app.ZygotePreload}
+ interface. -->
+ <attr name="zygotePreloadName" format="string"/>
+
<!-- If set to <code>true</code>, indicates to the platform that this APK is
a 'feature' split and that it implicitly depends on the base APK. This distinguishes
this split APK from a 'configuration' split, which provides resource overrides
@@ -1644,6 +1653,7 @@
<!-- If {@code true} the user is prompted to keep the app's data on uninstall -->
<attr name="hasFragileUserData" />
+ <attr name="zygotePreloadName" />
</declare-styleable>
<!-- The <code>permission</code> tag declares a security permission that can be
used to control access from other packages to specific components or
@@ -2300,17 +2310,18 @@
<!-- If true, and this is an {@link android.R.attr#isolatedProcess} service, the service
will be spawned from an Application Zygote, instead of the regular Zygote.
<p>
- The Application Zygote will pre-initialize the application's class loader,
- and call a static callback into the application to allow it to perform
+ The Application Zygote will first pre-initialize the application's class loader. Then,
+ if the application has defined the {@link android.R.attr#zygotePreloadName} attribute,
+ the Application Zygote will call into that class to allow it to perform
application-specific preloads (such as loading a shared library). Therefore,
spawning from the Application Zygote will typically reduce the service
launch time and reduce its memory usage. The downside of using this flag
is that you will have an additional process (the app zygote itself) that
is taking up memory. Whether actual memory usage is improved therefore strongly
depends on the number of isolated services that an application starts,
- and how much memory those services save by preloading. Therefore, it is
- recommended to measure memory usage under typical workloads to determine
- whether it makes sense to use this flag. -->
+ and how much memory those services save by preloading and sharing memory with
+ the app zygote. Therefore, it is recommended to measure memory usage under
+ typical workloads to determine whether it makes sense to use this flag. -->
<attr name="useAppZygote" format="boolean" />
<!-- If this is a foreground service, specify its category. -->
<attr name="foregroundServiceType" />
diff --git a/core/res/res/values/config.xml b/core/res/res/values/config.xml
index 67b0652..eb214ba 100644
--- a/core/res/res/values/config.xml
+++ b/core/res/res/values/config.xml
@@ -712,6 +712,9 @@
<!-- Indicates that connected MAC randomization is supported on this device -->
<bool translatable="false" name="config_wifi_connected_mac_randomization_supported">false</bool>
+ <!-- Indicates that wifi link probing is supported on this device -->
+ <bool translatable="false" name="config_wifi_link_probing_supported">false</bool>
+
<!-- Flag indicating whether we should enable the automatic brightness.
Software implementation will be used if config_hardware_auto_brightness_available is not set -->
<bool name="config_automatic_brightness_available">false</bool>
diff --git a/core/res/res/values/dimens.xml b/core/res/res/values/dimens.xml
index ef3834c..baf7587 100644
--- a/core/res/res/values/dimens.xml
+++ b/core/res/res/values/dimens.xml
@@ -240,7 +240,7 @@
<dimen name="notification_header_icon_size">18dp</dimen>
<!-- size (width and height) of the icon in the notification header -->
- <dimen name="notification_header_icon_size_ambient">20dp</dimen>
+ <dimen name="notification_header_icon_size_ambient">18dp</dimen>
<!-- The margin before the start of the app name in the header. -->
<dimen name="notification_header_app_name_margin_start">3dp</dimen>
diff --git a/core/res/res/values/public.xml b/core/res/res/values/public.xml
index ec1bac1..b5266e2 100644
--- a/core/res/res/values/public.xml
+++ b/core/res/res/values/public.xml
@@ -2936,6 +2936,7 @@
<public name="minAspectRatio" />
<!-- @hide @SystemApi -->
<public name="inheritShowWhenLocked" />
+ <public name="zygotePreloadName" />
</public-group>
<public-group type="drawable" first-id="0x010800b4">
diff --git a/core/res/res/values/strings.xml b/core/res/res/values/strings.xml
index 6adb4a7..04df97c 100644
--- a/core/res/res/values/strings.xml
+++ b/core/res/res/values/strings.xml
@@ -3692,6 +3692,9 @@
<!-- Notification action to browse external media [CHAR LIMIT=20] -->
<string name="ext_media_browse_action">Explore</string>
+ <!-- Notification action to transfer media [CHAR LIMIT=40] -->
+ <string name="ext_media_seamless_action">Seamless transfer</string>
+
<!-- Notification title when external media is missing [CHAR LIMIT=30] -->
<string name="ext_media_missing_title"><xliff:g id="name" example="SD card">%s</xliff:g> missing</string>
<!-- Notification body when external media is missing [CHAR LIMIT=30] -->
diff --git a/core/res/res/values/styles_device_defaults.xml b/core/res/res/values/styles_device_defaults.xml
index 79afe69..0dc54e0 100644
--- a/core/res/res/values/styles_device_defaults.xml
+++ b/core/res/res/values/styles_device_defaults.xml
@@ -374,7 +374,9 @@
<style name="TextAppearance.DeviceDefault.Caption" parent="TextAppearance.Material.Caption">
<item name="fontFamily">@string/config_bodyFontFamily</item>
</style>
- <style name="TextAppearance.DeviceDefault.ListItem" parent="TextAppearance.DeviceDefault.Subhead"/>
+ <style name="TextAppearance.DeviceDefault.ListItem" parent="TextAppearance.DeviceDefault.Subhead">
+ <item name="fontFamily">@string/config_headlineFontFamily</item>
+ </style>
<style name="TextAppearance.DeviceDefault.ListItemSecondary" parent="TextAppearance.DeviceDefault.Body1"/>
<!-- Preference Styles -->
diff --git a/core/res/res/values/symbols.xml b/core/res/res/values/symbols.xml
index 54a3243..52400de 100644
--- a/core/res/res/values/symbols.xml
+++ b/core/res/res/values/symbols.xml
@@ -191,6 +191,7 @@
<java-symbol type="id" name="action2" />
<java-symbol type="id" name="action3" />
<java-symbol type="id" name="action4" />
+ <java-symbol type="id" name="media_seamless" />
<java-symbol type="id" name="big_picture" />
<java-symbol type="id" name="big_text" />
<java-symbol type="id" name="chronometer" />
@@ -1910,6 +1911,7 @@
<java-symbol type="bool" name="config_wifi_convert_apband_5ghz_to_any" />
<java-symbol type="bool" name="config_wifi_local_only_hotspot_5ghz" />
<java-symbol type="bool" name="config_wifi_connected_mac_randomization_supported" />
+ <java-symbol type="bool" name="config_wifi_link_probing_supported" />
<java-symbol type="bool" name="config_wifi_fast_bss_transition_enabled" />
<java-symbol type="bool" name="config_wimaxEnabled" />
<java-symbol type="bool" name="show_ongoing_ime_switcher" />
@@ -2236,6 +2238,7 @@
<java-symbol type="string" name="ext_media_init_action" />
<java-symbol type="string" name="ext_media_unmount_action" />
<java-symbol type="string" name="ext_media_browse_action" />
+ <java-symbol type="string" name="ext_media_seamless_action" />
<java-symbol type="string" name="ext_media_missing_title" />
<java-symbol type="string" name="ext_media_missing_message" />
<java-symbol type="string" name="ext_media_move_specific_title" />
@@ -3097,6 +3100,7 @@
<java-symbol type="drawable" name="ic_restart" />
<java-symbol type="drawable" name="ic_screenshot" />
<java-symbol type="drawable" name="ic_faster_emergency" />
+ <java-symbol type="drawable" name="ic_media_seamless" />
<java-symbol type="drawable" name="emergency_icon" />
<java-symbol type="array" name="config_convert_to_emergency_number_map" />
diff --git a/core/tests/coretests/src/android/provider/SettingsBackupTest.java b/core/tests/coretests/src/android/provider/SettingsBackupTest.java
index e32b412..f420033 100644
--- a/core/tests/coretests/src/android/provider/SettingsBackupTest.java
+++ b/core/tests/coretests/src/android/provider/SettingsBackupTest.java
@@ -137,6 +137,7 @@
Settings.Global.BROADCAST_OFFLOAD_CONSTANTS,
Settings.Global.BATTERY_DISCHARGE_DURATION_THRESHOLD,
Settings.Global.BATTERY_DISCHARGE_THRESHOLD,
+ Settings.Global.BATTERY_SAVER_ADAPTIVE_DEVICE_SPECIFIC_CONSTANTS,
Settings.Global.BATTERY_SAVER_DEVICE_SPECIFIC_CONSTANTS,
Settings.Global.BATTERY_STATS_CONSTANTS,
Settings.Global.BINDER_CALLS_STATS,
@@ -222,6 +223,7 @@
Settings.Global.DEVELOPMENT_SETTINGS_ENABLED,
Settings.Global.DEVICE_DEMO_MODE,
Settings.Global.DEVICE_IDLE_CONSTANTS,
+ Settings.Global.BATTERY_SAVER_ADAPTIVE_CONSTANTS,
Settings.Global.BATTERY_SAVER_CONSTANTS,
Settings.Global.BATTERY_TIP_CONSTANTS,
Settings.Global.DEFAULT_SM_DP_PLUS,
@@ -525,6 +527,7 @@
Settings.Global.WIFI_LINK_SPEED_METRICS_ENABLED,
Settings.Global.WIFI_PNO_FREQUENCY_CULLING_ENABLED,
Settings.Global.WIFI_PNO_RECENCY_SORTING_ENABLED,
+ Settings.Global.WIFI_LINK_PROBING_ENABLED,
Settings.Global.WIFI_MAX_DHCP_RETRY_COUNT,
Settings.Global.WIFI_MOBILE_DATA_TRANSITION_WAKELOCK_TIMEOUT_MS,
Settings.Global.WIFI_NETWORK_SHOW_RSSI,
diff --git a/core/tests/coretests/src/android/view/textclassifier/TextClassifierTest.java b/core/tests/coretests/src/android/view/textclassifier/TextClassifierTest.java
index 5e58f82..582be9d 100644
--- a/core/tests/coretests/src/android/view/textclassifier/TextClassifierTest.java
+++ b/core/tests/coretests/src/android/view/textclassifier/TextClassifierTest.java
@@ -21,8 +21,10 @@
import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
+import android.app.RemoteAction;
import android.content.Context;
import android.content.Intent;
+import android.os.Bundle;
import android.os.LocaleList;
import android.text.Spannable;
import android.text.SpannableString;
@@ -246,25 +248,31 @@
public void testClassifyText_foreignText() {
LocaleList originalLocales = LocaleList.getDefault();
LocaleList.setDefault(LocaleList.forLanguageTags("en"));
- String foreignText = "これは日本語のテキストです";
+ String japaneseText = "これは日本語のテキストです";
Context context = new FakeContextBuilder()
.setIntentComponent(Intent.ACTION_TRANSLATE, FakeContextBuilder.DEFAULT_COMPONENT)
.build();
TextClassifier classifier = new TextClassifierImpl(context, TC_CONSTANTS);
TextClassification.Request request = new TextClassification.Request.Builder(
- foreignText, 0, foreignText.length())
+ japaneseText, 0, japaneseText.length())
.setDefaultLocales(LOCALES)
.build();
TextClassification classification = classifier.classifyText(request);
+ RemoteAction translateAction = classification.getActions().get(0);
assertEquals(1, classification.getActions().size());
assertEquals(
context.getString(com.android.internal.R.string.translate),
- classification.getActions().get(0).getTitle());
- Intent intent = (Intent) classification.getExtras()
- .getParcelableArrayList(TextClassifierImpl.ACTIONS_INTENTS).get(0);
+ translateAction.getTitle());
+
+ assertEquals(translateAction, ExtrasUtils.findTranslateAction(classification));
+ Intent intent = ExtrasUtils.getActionsIntents(classification).get(0);
assertEquals(Intent.ACTION_TRANSLATE, intent.getAction());
+ Bundle foreignLanguageInfo = ExtrasUtils.getForeignLanguageExtra(classification);
+ assertEquals("ja", ExtrasUtils.getEntityType(foreignLanguageInfo));
+ assertTrue(ExtrasUtils.getScore(foreignLanguageInfo) >= 0);
+ assertTrue(ExtrasUtils.getScore(foreignLanguageInfo) <= 1);
LocaleList.setDefault(originalLocales);
}
diff --git a/data/etc/privapp-permissions-platform.xml b/data/etc/privapp-permissions-platform.xml
index a47ab87..bcac5fd 100644
--- a/data/etc/privapp-permissions-platform.xml
+++ b/data/etc/privapp-permissions-platform.xml
@@ -329,6 +329,7 @@
<permission name="android.permission.USE_RESERVED_DISK"/>
<permission name="android.permission.WRITE_MEDIA_STORAGE"/>
<permission name="android.permission.WRITE_SECURE_SETTINGS"/>
+ <permission name="android.permission.STATUS_BAR_SERVICE"/>
<permission name="android.permission.REQUEST_INCIDENT_REPORT_APPROVAL"/>
</privapp-permissions>
diff --git a/graphics/java/android/graphics/Bitmap.java b/graphics/java/android/graphics/Bitmap.java
index 97cb2ec..f9e7dd1 100644
--- a/graphics/java/android/graphics/Bitmap.java
+++ b/graphics/java/android/graphics/Bitmap.java
@@ -21,7 +21,6 @@
import android.annotation.ColorLong;
import android.annotation.NonNull;
import android.annotation.Nullable;
-import android.annotation.TestApi;
import android.annotation.UnsupportedAppUsage;
import android.annotation.WorkerThread;
import android.content.res.ResourcesImpl;
@@ -1762,9 +1761,7 @@
* previously assigned color space.
*
* @param colorSpace to assign to the bitmap
- * @hide
*/
- @TestApi
public void setColorSpace(@NonNull ColorSpace colorSpace) {
checkRecycled("setColorSpace called on a recycled bitmap");
if (colorSpace == null) {
@@ -1815,9 +1812,7 @@
* @throws IllegalArgumentException if the color space encoded in the long
* is invalid or unknown.
*
- * @hide pending API approval
*/
- @TestApi
public void eraseColor(@ColorLong long c) {
checkRecycled("Can't erase a recycled bitmap");
if (!isMutable()) {
@@ -1864,9 +1859,7 @@
* @throws IllegalArgumentException if x, y exceed the bitmap's bounds
* @throws IllegalStateException if the bitmap's config is {@link Config#HARDWARE}
*
- * @hide pending API approval
*/
- @TestApi
public Color getColor(int x, int y) {
checkRecycled("Can't call getColor() on a recycled bitmap");
checkHardware("unable to getColor(), "
diff --git a/graphics/java/android/graphics/LinearGradient.java b/graphics/java/android/graphics/LinearGradient.java
index 7e6fc35..ad33f79 100644
--- a/graphics/java/android/graphics/LinearGradient.java
+++ b/graphics/java/android/graphics/LinearGradient.java
@@ -17,21 +17,13 @@
package android.graphics;
import android.annotation.ColorInt;
+import android.annotation.ColorLong;
import android.annotation.NonNull;
import android.annotation.Nullable;
import android.annotation.UnsupportedAppUsage;
+
public class LinearGradient extends Shader {
-
- private static final int TYPE_COLORS_AND_POSITIONS = 1;
- private static final int TYPE_COLOR_START_AND_COLOR_END = 2;
-
- /**
- * Type of the LinearGradient: can be either TYPE_COLORS_AND_POSITIONS or
- * TYPE_COLOR_START_AND_COLOR_END.
- */
- private int mType;
-
@UnsupportedAppUsage
private float mX0;
@UnsupportedAppUsage
@@ -41,16 +33,43 @@
@UnsupportedAppUsage
private float mY1;
@UnsupportedAppUsage
- private int[] mColors;
- @UnsupportedAppUsage
private float[] mPositions;
@UnsupportedAppUsage
+ private TileMode mTileMode;
+
+ // @ColorInts are replaced by @ColorLongs, but these remain due to @UnsupportedAppUsage.
+ @UnsupportedAppUsage
+ @ColorInt
+ private int[] mColors;
+ @UnsupportedAppUsage
+ @ColorInt
private int mColor0;
@UnsupportedAppUsage
+ @ColorInt
private int mColor1;
- @UnsupportedAppUsage
- private TileMode mTileMode;
+ @ColorLong
+ private final long[] mColorLongs;
+
+
+ /**
+ * Create a shader that draws a linear gradient along a line.
+ *
+ * @param x0 The x-coordinate for the start of the gradient line
+ * @param y0 The y-coordinate for the start of the gradient line
+ * @param x1 The x-coordinate for the end of the gradient line
+ * @param y1 The y-coordinate for the end of the gradient line
+ * @param colors The sRGB colors to be distributed along the gradient line
+ * @param positions May be null. The relative positions [0..1] of
+ * each corresponding color in the colors array. If this is null,
+ * the the colors are distributed evenly along the gradient line.
+ * @param tile The Shader tiling mode
+ */
+ public LinearGradient(float x0, float y0, float x1, float y1, @NonNull @ColorInt int[] colors,
+ @Nullable float[] positions, @NonNull TileMode tile) {
+ this(x0, y0, x1, y1, convertColors(colors), positions, tile,
+ ColorSpace.get(ColorSpace.Named.SRGB));
+ }
/**
* Create a shader that draws a linear gradient along a line.
@@ -64,21 +83,33 @@
* each corresponding color in the colors array. If this is null,
* the the colors are distributed evenly along the gradient line.
* @param tile The Shader tiling mode
- */
- public LinearGradient(float x0, float y0, float x1, float y1, @NonNull @ColorInt int colors[],
- @Nullable float positions[], @NonNull TileMode tile) {
- if (colors.length < 2) {
- throw new IllegalArgumentException("needs >= 2 number of colors");
- }
+ *
+ * @throws IllegalArgumentException if there are less than two colors, the colors do
+ * not share the same {@link ColorSpace} or do not use a valid one, or {@code positions}
+ * is not {@code null} and has a different length from {@code colors}.
+ */
+ public LinearGradient(float x0, float y0, float x1, float y1, @NonNull @ColorLong long[] colors,
+ @Nullable float[] positions, @NonNull TileMode tile) {
+ this(x0, y0, x1, y1, colors.clone(), positions, tile, detectColorSpace(colors));
+ }
+
+ /**
+ * Base constructor. Assumes @param colors is a copy that this object can hold onto,
+ * and all colors share @param colorSpace.
+ */
+ private LinearGradient(float x0, float y0, float x1, float y1,
+ @NonNull @ColorLong long[] colors, @Nullable float[] positions, @NonNull TileMode tile,
+ @NonNull ColorSpace colorSpace) {
+ super(colorSpace);
+
if (positions != null && colors.length != positions.length) {
throw new IllegalArgumentException("color and position arrays must be of equal length");
}
- mType = TYPE_COLORS_AND_POSITIONS;
mX0 = x0;
mY0 = y0;
mX1 = x1;
mY1 = y1;
- mColors = colors.clone();
+ mColorLongs = colors;
mPositions = positions != null ? positions.clone() : null;
mTileMode = tile;
}
@@ -90,34 +121,41 @@
* @param y0 The y-coordinate for the start of the gradient line
* @param x1 The x-coordinate for the end of the gradient line
* @param y1 The y-coordinate for the end of the gradient line
+ * @param color0 The sRGB color at the start of the gradient line.
+ * @param color1 The sRGB color at the end of the gradient line.
+ * @param tile The Shader tiling mode
+ */
+ public LinearGradient(float x0, float y0, float x1, float y1,
+ @ColorInt int color0, @ColorInt int color1,
+ @NonNull TileMode tile) {
+ this(x0, y0, x1, y1, Color.pack(color0), Color.pack(color1), tile);
+ }
+
+ /**
+ * Create a shader that draws a linear gradient along a line.
+ *
+ * @param x0 The x-coordinate for the start of the gradient line
+ * @param y0 The y-coordinate for the start of the gradient line
+ * @param x1 The x-coordinate for the end of the gradient line
+ * @param y1 The y-coordinate for the end of the gradient line
* @param color0 The color at the start of the gradient line.
* @param color1 The color at the end of the gradient line.
* @param tile The Shader tiling mode
- */
+ *
+ * @throws IllegalArgumentException if the colors do
+ * not share the same {@link ColorSpace} or do not use a valid one.
+ */
public LinearGradient(float x0, float y0, float x1, float y1,
- @ColorInt int color0, @ColorInt int color1,
+ @ColorLong long color0, @ColorLong long color1,
@NonNull TileMode tile) {
- mType = TYPE_COLOR_START_AND_COLOR_END;
- mX0 = x0;
- mY0 = y0;
- mX1 = x1;
- mY1 = y1;
- mColor0 = color0;
- mColor1 = color1;
- mColors = null;
- mPositions = null;
- mTileMode = tile;
+ this(x0, y0, x1, y1, new long[] {color0, color1}, null, tile);
}
@Override
long createNativeInstance(long nativeMatrix) {
- if (mType == TYPE_COLORS_AND_POSITIONS) {
- return nativeCreate1(nativeMatrix, mX0, mY0, mX1, mY1,
- mColors, mPositions, mTileMode.nativeInt);
- } else { // TYPE_COLOR_START_AND_COLOR_END
- return nativeCreate2(nativeMatrix, mX0, mY0, mX1, mY1,
- mColor0, mColor1, mTileMode.nativeInt);
- }
+ return nativeCreate(nativeMatrix, mX0, mY0, mX1, mY1,
+ mColorLongs, mPositions, mTileMode.nativeInt,
+ colorSpace().getNativeInstance());
}
/**
@@ -125,19 +163,12 @@
*/
@Override
protected Shader copy() {
- final LinearGradient copy;
- if (mType == TYPE_COLORS_AND_POSITIONS) {
- copy = new LinearGradient(mX0, mY0, mX1, mY1, mColors.clone(),
- mPositions != null ? mPositions.clone() : null, mTileMode);
- } else { // TYPE_COLOR_START_AND_COLOR_END
- copy = new LinearGradient(mX0, mY0, mX1, mY1, mColor0, mColor1, mTileMode);
- }
+ final LinearGradient copy = new LinearGradient(mX0, mY0, mX1, mY1, mColorLongs,
+ mPositions, mTileMode, colorSpace());
copyLocalMatrix(copy);
return copy;
}
- private native long nativeCreate1(long matrix, float x0, float y0, float x1, float y1,
- int colors[], float positions[], int tileMode);
- private native long nativeCreate2(long matrix, float x0, float y0, float x1, float y1,
- int color0, int color1, int tileMode);
+ private native long nativeCreate(long matrix, float x0, float y0, float x1, float y1,
+ long[] colors, float[] positions, int tileMode, long colorSpaceHandle);
}
diff --git a/graphics/java/android/graphics/Paint.java b/graphics/java/android/graphics/Paint.java
index 7eee6f4..73442db 100644
--- a/graphics/java/android/graphics/Paint.java
+++ b/graphics/java/android/graphics/Paint.java
@@ -24,7 +24,6 @@
import android.annotation.Nullable;
import android.annotation.Px;
import android.annotation.Size;
-import android.annotation.TestApi;
import android.annotation.UnsupportedAppUsage;
import android.graphics.fonts.FontVariationAxis;
import android.os.Build;
@@ -974,10 +973,7 @@
* @see Color for APIs that help manipulate a color long.
*
* @return the paint's color (and alpha).
- *
- * @hide pending API approval
*/
- @TestApi
@ColorLong
public long getColorLong() {
return mColor;
@@ -1006,10 +1002,7 @@
* to set in the paint.
* @throws IllegalArgumentException if the color space encoded in the long
* is invalid or unknown.
- *
- * @hide pending API approval
*/
- @TestApi
public void setColor(@ColorLong long color) {
ColorSpace cs = Color.colorSpace(color);
float r = Color.red(color);
@@ -1445,10 +1438,7 @@
*
* @throws IllegalArgumentException if the color space encoded in the long
* is invalid or unknown.
- *
- * @hide pending API approval
*/
- @TestApi
public void setShadowLayer(float radius, float dx, float dy, @ColorLong long shadowColor) {
ColorSpace cs = Color.colorSpace(shadowColor);
float r = Color.red(shadowColor);
@@ -1517,9 +1507,7 @@
* Returns the color of the shadow layer.
* @see #setShadowLayer(float,float,float,int)
* @see #setShadowLayer(float,float,float,long)
- * @hide pending API approval
*/
- @TestApi
public @ColorLong long getShadowLayerColorLong() {
return mShadowLayerColor;
}
diff --git a/graphics/java/android/graphics/RadialGradient.java b/graphics/java/android/graphics/RadialGradient.java
index 41d2628..5e16180 100644
--- a/graphics/java/android/graphics/RadialGradient.java
+++ b/graphics/java/android/graphics/RadialGradient.java
@@ -16,22 +16,13 @@
package android.graphics;
+import android.annotation.ColorInt;
+import android.annotation.ColorLong;
import android.annotation.NonNull;
import android.annotation.Nullable;
-import android.annotation.ColorInt;
import android.annotation.UnsupportedAppUsage;
public class RadialGradient extends Shader {
-
- private static final int TYPE_COLORS_AND_POSITIONS = 1;
- private static final int TYPE_COLOR_CENTER_AND_COLOR_EDGE = 2;
-
- /**
- * Type of the RadialGradient: can be either TYPE_COLORS_AND_POSITIONS or
- * TYPE_COLOR_CENTER_AND_COLOR_EDGE.
- */
- private int mType;
-
@UnsupportedAppUsage
private float mX;
@UnsupportedAppUsage
@@ -39,16 +30,43 @@
@UnsupportedAppUsage
private float mRadius;
@UnsupportedAppUsage
- private int[] mColors;
- @UnsupportedAppUsage
private float[] mPositions;
@UnsupportedAppUsage
+ private TileMode mTileMode;
+
+ // @ColorInts are replaced by @ColorLongs, but these remain due to @UnsupportedAppUsage.
+ @UnsupportedAppUsage
+ @ColorInt
+ private int[] mColors;
+ @UnsupportedAppUsage
+ @ColorInt
private int mCenterColor;
@UnsupportedAppUsage
+ @ColorInt
private int mEdgeColor;
- @UnsupportedAppUsage
- private TileMode mTileMode;
+ @ColorLong
+ private final long[] mColorLongs;
+
+ /**
+ * Create a shader that draws a radial gradient given the center and radius.
+ *
+ * @param centerX The x-coordinate of the center of the radius
+ * @param centerY The y-coordinate of the center of the radius
+ * @param radius Must be positive. The radius of the circle for this gradient.
+ * @param colors The sRGB colors to be distributed between the center and edge of the circle
+ * @param stops May be <code>null</code>. Valid values are between <code>0.0f</code> and
+ * <code>1.0f</code>. The relative position of each corresponding color in
+ * the colors array. If <code>null</code>, colors are distributed evenly
+ * between the center and edge of the circle.
+ * @param tileMode The Shader tiling mode
+ */
+ public RadialGradient(float centerX, float centerY, float radius,
+ @NonNull @ColorInt int[] colors, @Nullable float[] stops,
+ @NonNull TileMode tileMode) {
+ this(centerX, centerY, radius, convertColors(colors), stops, tileMode,
+ ColorSpace.get(ColorSpace.Named.SRGB));
+ }
/**
* Create a shader that draws a radial gradient given the center and radius.
@@ -62,24 +80,36 @@
* the colors array. If <code>null</code>, colors are distributed evenly
* between the center and edge of the circle.
* @param tileMode The Shader tiling mode
+ *
+ * @throws IllegalArgumentException if there are less than two colors, the colors do
+ * not share the same {@link ColorSpace} or do not use a valid one, or {@code stops}
+ * is not {@code null} and has a different length from {@code colors}.
*/
public RadialGradient(float centerX, float centerY, float radius,
- @NonNull @ColorInt int colors[], @Nullable float stops[],
+ @NonNull @ColorLong long[] colors, @Nullable float[] stops,
@NonNull TileMode tileMode) {
+ this(centerX, centerY, radius, colors.clone(), stops, tileMode, detectColorSpace(colors));
+ }
+
+ /**
+ * Base constructor. Assumes @param colors is a copy that this object can hold onto,
+ * and all colors share @param colorSpace.
+ */
+ private RadialGradient(float centerX, float centerY, float radius,
+ @NonNull @ColorLong long[] colors, @Nullable float[] stops,
+ @NonNull TileMode tileMode, ColorSpace colorSpace) {
+ super(colorSpace);
+
if (radius <= 0) {
throw new IllegalArgumentException("radius must be > 0");
}
- if (colors.length < 2) {
- throw new IllegalArgumentException("needs >= 2 number of colors");
- }
if (stops != null && colors.length != stops.length) {
throw new IllegalArgumentException("color and position arrays must be of equal length");
}
- mType = TYPE_COLORS_AND_POSITIONS;
mX = centerX;
mY = centerY;
mRadius = radius;
- mColors = colors.clone();
+ mColorLongs = colors;
mPositions = stops != null ? stops.clone() : null;
mTileMode = tileMode;
}
@@ -90,33 +120,38 @@
* @param centerX The x-coordinate of the center of the radius
* @param centerY The y-coordinate of the center of the radius
* @param radius Must be positive. The radius of the circle for this gradient
+ * @param centerColor The sRGB color at the center of the circle.
+ * @param edgeColor The sRGB color at the edge of the circle.
+ * @param tileMode The Shader tiling mode
+ */
+ public RadialGradient(float centerX, float centerY, float radius,
+ @ColorInt int centerColor, @ColorInt int edgeColor, @NonNull TileMode tileMode) {
+ this(centerX, centerY, radius, Color.pack(centerColor), Color.pack(edgeColor), tileMode);
+ }
+
+ /**
+ * Create a shader that draws a radial gradient given the center and radius.
+ *
+ * @param centerX The x-coordinate of the center of the radius
+ * @param centerY The y-coordinate of the center of the radius
+ * @param radius Must be positive. The radius of the circle for this gradient
* @param centerColor The color at the center of the circle.
* @param edgeColor The color at the edge of the circle.
* @param tileMode The Shader tiling mode
+ *
+ * @throws IllegalArgumentException if the colors do
+ * not share the same {@link ColorSpace} or do not use a valid one.
*/
public RadialGradient(float centerX, float centerY, float radius,
- @ColorInt int centerColor, @ColorInt int edgeColor, @NonNull TileMode tileMode) {
- if (radius <= 0) {
- throw new IllegalArgumentException("radius must be > 0");
- }
- mType = TYPE_COLOR_CENTER_AND_COLOR_EDGE;
- mX = centerX;
- mY = centerY;
- mRadius = radius;
- mCenterColor = centerColor;
- mEdgeColor = edgeColor;
- mTileMode = tileMode;
+ @ColorLong long centerColor, @ColorLong long edgeColor, @NonNull TileMode tileMode) {
+ this(centerX, centerY, radius, new long[] {centerColor, edgeColor}, null, tileMode);
}
@Override
long createNativeInstance(long nativeMatrix) {
- if (mType == TYPE_COLORS_AND_POSITIONS) {
- return nativeCreate1(nativeMatrix, mX, mY, mRadius,
- mColors, mPositions, mTileMode.nativeInt);
- } else { // TYPE_COLOR_CENTER_AND_COLOR_EDGE
- return nativeCreate2(nativeMatrix, mX, mY, mRadius,
- mCenterColor, mEdgeColor, mTileMode.nativeInt);
- }
+ return nativeCreate(nativeMatrix, mX, mY, mRadius,
+ mColorLongs, mPositions, mTileMode.nativeInt,
+ colorSpace().getNativeInstance());
}
/**
@@ -124,20 +159,13 @@
*/
@Override
protected Shader copy() {
- final RadialGradient copy;
- if (mType == TYPE_COLORS_AND_POSITIONS) {
- copy = new RadialGradient(mX, mY, mRadius, mColors.clone(),
- mPositions != null ? mPositions.clone() : null, mTileMode);
- } else { // TYPE_COLOR_CENTER_AND_COLOR_EDGE
- copy = new RadialGradient(mX, mY, mRadius, mCenterColor, mEdgeColor, mTileMode);
- }
+ final RadialGradient copy = new RadialGradient(mX, mY, mRadius, mColorLongs,
+ mPositions, mTileMode, colorSpace());
copyLocalMatrix(copy);
return copy;
}
- private static native long nativeCreate1(long matrix, float x, float y, float radius,
- int colors[], float positions[], int tileMode);
- private static native long nativeCreate2(long matrix, float x, float y, float radius,
- int color0, int color1, int tileMode);
+ private static native long nativeCreate(long matrix, float x, float y, float radius,
+ @ColorLong long[] colors, float[] positions, int tileMode, long colorSpaceHandle);
}
diff --git a/graphics/java/android/graphics/Shader.java b/graphics/java/android/graphics/Shader.java
index 40bcc9e..7f09786 100644
--- a/graphics/java/android/graphics/Shader.java
+++ b/graphics/java/android/graphics/Shader.java
@@ -16,6 +16,8 @@
package android.graphics;
+import android.annotation.ColorInt;
+import android.annotation.ColorLong;
import android.annotation.NonNull;
import android.annotation.Nullable;
import android.annotation.UnsupportedAppUsage;
@@ -39,7 +41,32 @@
* @deprecated Use subclass constructors directly instead.
*/
@Deprecated
- public Shader() {}
+ public Shader() {
+ mColorSpace = null;
+ }
+
+ /**
+ * @hide
+ */
+ public Shader(ColorSpace colorSpace) {
+ mColorSpace = colorSpace;
+ if (colorSpace == null) {
+ throw new IllegalArgumentException(
+ "Use Shader() to create a Shader with no ColorSpace");
+ }
+
+ // This just ensures that if the ColorSpace is invalid, the Exception will be thrown now.
+ mColorSpace.getNativeInstance();
+ }
+
+ private final ColorSpace mColorSpace;
+
+ /**
+ * @hide
+ */
+ protected ColorSpace colorSpace() {
+ return mColorSpace;
+ }
/**
* Current native shader instance. Created and updated lazily when {@link #getNativeInstance()}
@@ -169,6 +196,43 @@
return mNativeInstance;
}
+ /**
+ * @hide
+ */
+ public static @ColorLong long[] convertColors(@NonNull @ColorInt int[] colors) {
+ if (colors.length < 2) {
+ throw new IllegalArgumentException("needs >= 2 number of colors");
+ }
+
+ long[] colorLongs = new long[colors.length];
+ for (int i = 0; i < colors.length; ++i) {
+ colorLongs[i] = Color.pack(colors[i]);
+ }
+
+ return colorLongs;
+ }
+
+ /**
+ * Detect the ColorSpace that the {@code colors} share.
+ *
+ * @throws IllegalArgumentException if the colors do not all share the same,
+ * valid ColorSpace, or if there are less than 2 colors.
+ *
+ * @hide
+ */
+ public static ColorSpace detectColorSpace(@NonNull @ColorLong long[] colors) {
+ if (colors.length < 2) {
+ throw new IllegalArgumentException("needs >= 2 number of colors");
+ }
+ final ColorSpace colorSpace = Color.colorSpace(colors[0]);
+ for (int i = 1; i < colors.length; ++i) {
+ if (Color.colorSpace(colors[i]) != colorSpace) {
+ throw new IllegalArgumentException("All colors must be in the same ColorSpace!");
+ }
+ }
+ return colorSpace;
+ }
+
private static native long nativeGetFinalizer();
}
diff --git a/graphics/java/android/graphics/SweepGradient.java b/graphics/java/android/graphics/SweepGradient.java
index f944d85..fc386d7 100644
--- a/graphics/java/android/graphics/SweepGradient.java
+++ b/graphics/java/android/graphics/SweepGradient.java
@@ -17,34 +17,52 @@
package android.graphics;
import android.annotation.ColorInt;
+import android.annotation.ColorLong;
import android.annotation.NonNull;
import android.annotation.Nullable;
import android.annotation.UnsupportedAppUsage;
public class SweepGradient extends Shader {
-
- private static final int TYPE_COLORS_AND_POSITIONS = 1;
- private static final int TYPE_COLOR_START_AND_COLOR_END = 2;
-
- /**
- * Type of the LinearGradient: can be either TYPE_COLORS_AND_POSITIONS or
- * TYPE_COLOR_START_AND_COLOR_END.
- */
- private int mType;
-
@UnsupportedAppUsage
private float mCx;
@UnsupportedAppUsage
private float mCy;
@UnsupportedAppUsage
+ private float[] mPositions;
+
+ // @ColorInts are replaced by @ColorLongs, but these remain due to @UnsupportedAppUsage.
+ @UnsupportedAppUsage
+ @ColorInt
private int[] mColors;
@UnsupportedAppUsage
- private float[] mPositions;
- @UnsupportedAppUsage
+ @ColorInt
private int mColor0;
@UnsupportedAppUsage
+ @ColorInt
private int mColor1;
+ @ColorLong
+ private final long[] mColorLongs;
+
+ /**
+ * A Shader that draws a sweep gradient around a center point.
+ *
+ * @param cx The x-coordinate of the center
+ * @param cy The y-coordinate of the center
+ * @param colors The sRGB colors to be distributed between around the center.
+ * There must be at least 2 colors in the array.
+ * @param positions May be NULL. The relative position of
+ * each corresponding color in the colors array, beginning
+ * with 0 and ending with 1.0. If the values are not
+ * monotonic, the drawing may produce unexpected results.
+ * If positions is NULL, then the colors are automatically
+ * spaced evenly.
+ */
+ public SweepGradient(float cx, float cy, @NonNull @ColorInt int[] colors,
+ @Nullable float[] positions) {
+ this(cx, cy, convertColors(colors), positions, ColorSpace.get(ColorSpace.Named.SRGB));
+ }
+
/**
* A Shader that draws a sweep gradient around a center point.
*
@@ -58,20 +76,30 @@
* monotonic, the drawing may produce unexpected results.
* If positions is NULL, then the colors are automatically
* spaced evenly.
+ * @throws IllegalArgumentException if there are less than two colors, the colors do
+ * not share the same {@link ColorSpace} or do not use a valid one, or {@code positions}
+ * is not {@code null} and has a different length from {@code colors}.
*/
- public SweepGradient(float cx, float cy,
- @NonNull @ColorInt int colors[], @Nullable float positions[]) {
- if (colors.length < 2) {
- throw new IllegalArgumentException("needs >= 2 number of colors");
- }
+ public SweepGradient(float cx, float cy, @NonNull @ColorLong long[] colors,
+ @Nullable float[] positions) {
+ this(cx, cy, colors.clone(), positions, detectColorSpace(colors));
+ }
+
+ /**
+ * Base constructor. Assumes @param colors is a copy that this object can hold onto,
+ * and all colors share @param colorSpace.
+ */
+ private SweepGradient(float cx, float cy, @NonNull @ColorLong long[] colors,
+ @Nullable float[] positions, ColorSpace colorSpace) {
+ super(colorSpace);
+
if (positions != null && colors.length != positions.length) {
throw new IllegalArgumentException(
"color and position arrays must be of equal length");
}
- mType = TYPE_COLORS_AND_POSITIONS;
mCx = cx;
mCy = cy;
- mColors = colors.clone();
+ mColorLongs = colors;
mPositions = positions != null ? positions.clone() : null;
}
@@ -80,26 +108,32 @@
*
* @param cx The x-coordinate of the center
* @param cy The y-coordinate of the center
+ * @param color0 The sRGB color to use at the start of the sweep
+ * @param color1 The sRGB color to use at the end of the sweep
+ */
+ public SweepGradient(float cx, float cy, @ColorInt int color0, @ColorInt int color1) {
+ this(cx, cy, Color.pack(color0), Color.pack(color1));
+ }
+
+ /**
+ * A Shader that draws a sweep gradient around a center point.
+ *
+ * @param cx The x-coordinate of the center
+ * @param cy The y-coordinate of the center
* @param color0 The color to use at the start of the sweep
* @param color1 The color to use at the end of the sweep
+ *
+ * @throws IllegalArgumentException if the colors do
+ * not share the same {@link ColorSpace} or do not use a valid one.
*/
- public SweepGradient(float cx, float cy, @ColorInt int color0, @ColorInt int color1) {
- mType = TYPE_COLOR_START_AND_COLOR_END;
- mCx = cx;
- mCy = cy;
- mColor0 = color0;
- mColor1 = color1;
- mColors = null;
- mPositions = null;
+ public SweepGradient(float cx, float cy, @ColorLong long color0, @ColorLong long color1) {
+ this(cx, cy, new long[] {color0, color1}, null);
}
@Override
long createNativeInstance(long nativeMatrix) {
- if (mType == TYPE_COLORS_AND_POSITIONS) {
- return nativeCreate1(nativeMatrix, mCx, mCy, mColors, mPositions);
- } else { // TYPE_COLOR_START_AND_COLOR_END
- return nativeCreate2(nativeMatrix, mCx, mCy, mColor0, mColor1);
- }
+ return nativeCreate(nativeMatrix, mCx, mCy, mColorLongs, mPositions,
+ colorSpace().getNativeInstance());
}
/**
@@ -107,20 +141,13 @@
*/
@Override
protected Shader copy() {
- final SweepGradient copy;
- if (mType == TYPE_COLORS_AND_POSITIONS) {
- copy = new SweepGradient(mCx, mCy, mColors.clone(),
- mPositions != null ? mPositions.clone() : null);
- } else { // TYPE_COLOR_START_AND_COLOR_END
- copy = new SweepGradient(mCx, mCy, mColor0, mColor1);
- }
+ final SweepGradient copy = new SweepGradient(mCx, mCy, mColorLongs,
+ mPositions, colorSpace());
copyLocalMatrix(copy);
return copy;
}
- private static native long nativeCreate1(long matrix, float x, float y,
- int colors[], float positions[]);
- private static native long nativeCreate2(long matrix, float x, float y,
- int color0, int color1);
+ private static native long nativeCreate(long matrix, float x, float y,
+ long[] colors, float[] positions, long colorSpaceHandle);
}
diff --git a/libs/hwui/RecordingCanvas.cpp b/libs/hwui/RecordingCanvas.cpp
index 6dc9d34..8594766 100644
--- a/libs/hwui/RecordingCanvas.cpp
+++ b/libs/hwui/RecordingCanvas.cpp
@@ -759,6 +759,8 @@
void RecordingCanvas::reset(DisplayListData* dl, const SkIRect& bounds) {
this->resetCanvas(bounds.right(), bounds.bottom());
fDL = dl;
+ mClipMayBeComplex = false;
+ mSaveCount = mComplexSaveCount = 0;
}
sk_sp<SkSurface> RecordingCanvas::onNewSurface(const SkImageInfo&, const SkSurfaceProps&) {
@@ -770,6 +772,7 @@
}
void RecordingCanvas::willSave() {
+ mSaveCount++;
fDL->save();
}
SkCanvas::SaveLayerStrategy RecordingCanvas::getSaveLayerStrategy(const SaveLayerRec& rec) {
@@ -778,6 +781,11 @@
return SkCanvas::kNoLayer_SaveLayerStrategy;
}
void RecordingCanvas::willRestore() {
+ mSaveCount--;
+ if (mSaveCount < mComplexSaveCount) {
+ mClipMayBeComplex = false;
+ mComplexSaveCount = 0;
+ }
fDL->restore();
}
@@ -798,17 +806,27 @@
void RecordingCanvas::onClipRect(const SkRect& rect, SkClipOp op, ClipEdgeStyle style) {
fDL->clipRect(rect, op, style == kSoft_ClipEdgeStyle);
+ if (!getTotalMatrix().isScaleTranslate()) {
+ setClipMayBeComplex();
+ }
this->INHERITED::onClipRect(rect, op, style);
}
void RecordingCanvas::onClipRRect(const SkRRect& rrect, SkClipOp op, ClipEdgeStyle style) {
+ if (rrect.getType() > SkRRect::kRect_Type || !getTotalMatrix().isScaleTranslate()) {
+ setClipMayBeComplex();
+ }
fDL->clipRRect(rrect, op, style == kSoft_ClipEdgeStyle);
this->INHERITED::onClipRRect(rrect, op, style);
}
void RecordingCanvas::onClipPath(const SkPath& path, SkClipOp op, ClipEdgeStyle style) {
+ setClipMayBeComplex();
fDL->clipPath(path, op, style == kSoft_ClipEdgeStyle);
this->INHERITED::onClipPath(path, op, style);
}
void RecordingCanvas::onClipRegion(const SkRegion& region, SkClipOp op) {
+ if (region.isComplex() || !getTotalMatrix().isScaleTranslate()) {
+ setClipMayBeComplex();
+ }
fDL->clipRegion(region, op);
this->INHERITED::onClipRegion(region, op);
}
diff --git a/libs/hwui/RecordingCanvas.h b/libs/hwui/RecordingCanvas.h
index caaef67..3a76ca1 100644
--- a/libs/hwui/RecordingCanvas.h
+++ b/libs/hwui/RecordingCanvas.h
@@ -203,10 +203,41 @@
void drawVectorDrawable(VectorDrawableRoot* tree);
+ /**
+ * If "isClipMayBeComplex" returns false, it is guaranteed the current clip is a rectangle.
+ * If the return value is true, then clip may or may not be complex (there is no guarantee).
+ */
+ inline bool isClipMayBeComplex() { return mClipMayBeComplex; }
+
private:
typedef SkCanvasVirtualEnforcer<SkNoDrawCanvas> INHERITED;
+ inline void setClipMayBeComplex() {
+ if (!mClipMayBeComplex) {
+ mComplexSaveCount = mSaveCount;
+ mClipMayBeComplex = true;
+ }
+ }
+
DisplayListData* fDL;
+
+ /**
+ * mClipMayBeComplex tracks if the current clip is a rectangle. This flag is used to promote
+ * FunctorDrawable to a layer, if it is clipped by a non-rect.
+ */
+ bool mClipMayBeComplex = false;
+
+ /**
+ * mSaveCount is the current level of our save tree.
+ */
+ int mSaveCount = 0;
+
+ /**
+ * mComplexSaveCount is the first save level, which has a complex clip. Every level below
+ * mComplexSaveCount is assumed to have a complex clip and every level above mComplexSaveCount
+ * is guaranteed to not be complex.
+ */
+ int mComplexSaveCount = 0;
};
} // namespace uirenderer
diff --git a/libs/hwui/RenderProperties.h b/libs/hwui/RenderProperties.h
index ddb7e4e..e6710cc 100644
--- a/libs/hwui/RenderProperties.h
+++ b/libs/hwui/RenderProperties.h
@@ -151,6 +151,7 @@
// parent may have already dictated that a descendant layer is needed
bool functorsNeedLayer =
ancestorDictatesFunctorsNeedLayer
+ || CC_UNLIKELY(isClipMayBeComplex())
// Round rect clipping forces layer for functors
|| CC_UNLIKELY(getOutline().willRoundRectClip()) ||
@@ -193,6 +194,12 @@
bool isProjectionReceiver() const { return mPrimitiveFields.mProjectionReceiver; }
+ bool setClipMayBeComplex(bool isClipMayBeComplex) {
+ return RP_SET(mPrimitiveFields.mClipMayBeComplex, isClipMayBeComplex);
+ }
+
+ bool isClipMayBeComplex() const { return mPrimitiveFields.mClipMayBeComplex; }
+
bool setStaticMatrix(const SkMatrix* matrix) {
delete mStaticMatrix;
if (matrix) {
@@ -563,6 +570,7 @@
bool mProjectBackwards = false;
bool mProjectionReceiver = false;
bool mAllowForceDark = true;
+ bool mClipMayBeComplex = false;
Rect mClipBounds;
Outline mOutline;
RevealClip mRevealClip;
diff --git a/libs/hwui/pipeline/skia/SkiaDisplayList.cpp b/libs/hwui/pipeline/skia/SkiaDisplayList.cpp
index 230065c..29d5ef2 100644
--- a/libs/hwui/pipeline/skia/SkiaDisplayList.cpp
+++ b/libs/hwui/pipeline/skia/SkiaDisplayList.cpp
@@ -73,7 +73,6 @@
RenderNode* childNode = child.getRenderNode();
Matrix4 mat4(child.getRecordedMatrix());
info.damageAccumulator->pushTransform(&mat4);
- // TODO: a layer is needed if the canvas is rotated or has a non-rect clip
info.hasBackwardProjectedNodes = false;
childFn(childNode, observer, info, functorsNeedLayer);
hasBackwardProjectedNodesSubtree |= info.hasBackwardProjectedNodes;
diff --git a/libs/hwui/pipeline/skia/SkiaRecordingCanvas.cpp b/libs/hwui/pipeline/skia/SkiaRecordingCanvas.cpp
index d54275f..d945635 100644
--- a/libs/hwui/pipeline/skia/SkiaRecordingCanvas.cpp
+++ b/libs/hwui/pipeline/skia/SkiaRecordingCanvas.cpp
@@ -113,6 +113,10 @@
// Record the child node. Drawable dtor will be invoked when mChildNodes deque is cleared.
mDisplayList->mChildNodes.emplace_back(renderNode, asSkCanvas(), true, mCurrentBarrier);
auto& renderNodeDrawable = mDisplayList->mChildNodes.back();
+ if (Properties::getRenderPipelineType() == RenderPipelineType::SkiaVulkan) {
+ // Put Vulkan WebViews with non-rectangular clips in a HW layer
+ renderNode->mutateStagingProperties().setClipMayBeComplex(mRecorder.isClipMayBeComplex());
+ }
drawDrawable(&renderNodeDrawable);
// use staging property, since recording on UI thread
@@ -138,10 +142,8 @@
void SkiaRecordingCanvas::drawWebViewFunctor(int functor) {
FunctorDrawable* functorDrawable;
if (Properties::getRenderPipelineType() == RenderPipelineType::SkiaVulkan) {
- // TODO(cblume) use VkFunctorDrawable instead of VkInteropFunctorDrawable here when the
- // interop is disabled.
functorDrawable =
- mDisplayList->allocateDrawable<VkInteropFunctorDrawable>(functor, asSkCanvas());
+ mDisplayList->allocateDrawable<VkFunctorDrawable>(functor, asSkCanvas());
} else {
functorDrawable = mDisplayList->allocateDrawable<GLFunctorDrawable>(functor, asSkCanvas());
}
diff --git a/location/java/android/location/LocationManager.java b/location/java/android/location/LocationManager.java
index 59c6a0a..63b57d1 100644
--- a/location/java/android/location/LocationManager.java
+++ b/location/java/android/location/LocationManager.java
@@ -181,22 +181,14 @@
"android.location.GPS_ENABLED_CHANGE";
/**
- * Broadcast intent action when the configured location providers
- * change. For use with {@link #isProviderEnabled(String)}. If you're interacting with the
- * {@link android.provider.Settings.Secure#LOCATION_MODE} API, use {@link #MODE_CHANGED_ACTION}
- * instead.
+ * Broadcast intent action when the set of enabled location providers changes. To check the
+ * status of a provider, use {@link #isProviderEnabled(String)}.
*/
- public static final String PROVIDERS_CHANGED_ACTION =
- "android.location.PROVIDERS_CHANGED";
+ public static final String PROVIDERS_CHANGED_ACTION = "android.location.PROVIDERS_CHANGED";
/**
- * Broadcast intent action when {@link android.provider.Settings.Secure#LOCATION_MODE} changes.
- * For use with the {@link android.provider.Settings.Secure#LOCATION_MODE} API.
- * If you're interacting with {@link #isProviderEnabled(String)}, use
- * {@link #PROVIDERS_CHANGED_ACTION} instead.
- *
- * In the future, there may be mode changes that do not result in
- * {@link #PROVIDERS_CHANGED_ACTION} broadcasts.
+ * Broadcast intent action when the device location mode changes. To check the location mode,
+ * use {@link #isLocationEnabled()}.
*/
public static final String MODE_CHANGED_ACTION = "android.location.MODE_CHANGED";
@@ -207,8 +199,10 @@
* If you're interacting with {@link #isProviderEnabled(String)}, use
* {@link #PROVIDERS_CHANGED_ACTION} instead.
*
+ * @deprecated Do not use.
* @hide
*/
+ @Deprecated
public static final String MODE_CHANGING_ACTION = "com.android.settings.location.MODE_CHANGING";
/**
@@ -299,7 +293,7 @@
"com.android.settings.location.FOOTER_STRING";
// Map from LocationListeners to their associated ListenerTransport objects
- private HashMap<LocationListener,ListenerTransport> mListeners =
+ private final HashMap<LocationListener, ListenerTransport> mListeners =
new HashMap<LocationListener,ListenerTransport>();
private class ListenerTransport extends ILocationListener.Stub {
@@ -1264,39 +1258,20 @@
}
/**
- * Returns the current enabled/disabled status of location
+ * Returns the current enabled/disabled state of location. To listen for changes, see
+ * {@link #MODE_CHANGED_ACTION}.
*
- * @return true if location is enabled. false if location is disabled.
+ * @return true if location is enabled and false if location is disabled.
*/
public boolean isLocationEnabled() {
return isLocationEnabledForUser(Process.myUserHandle());
}
/**
- * Method for enabling or disabling location.
- *
- * @param enabled true to enable location. false to disable location
- * @param userHandle the user to set
- *
- * @hide
- */
- @SystemApi
- @RequiresPermission(WRITE_SECURE_SETTINGS)
- public void setLocationEnabledForUser(boolean enabled, UserHandle userHandle) {
- Settings.Secure.putIntForUser(
- mContext.getContentResolver(),
- Settings.Secure.LOCATION_MODE,
- enabled
- ? Settings.Secure.LOCATION_MODE_HIGH_ACCURACY
- : Settings.Secure.LOCATION_MODE_OFF,
- userHandle.getIdentifier());
- }
-
- /**
- * Returns the current enabled/disabled status of location
+ * Returns the current enabled/disabled state of location.
*
* @param userHandle the user to query
- * @return true location is enabled. false if location is disabled.
+ * @return true if location is enabled and false if location is disabled.
*
* @hide
*/
@@ -1310,19 +1285,32 @@
}
/**
- * Returns the current enabled/disabled status of the given provider.
+ * Enables or disables the location setting.
*
- * <p>If the user has enabled this provider in the Settings menu, true
- * is returned otherwise false is returned
+ * @param enabled true to enable location and false to disable location.
+ * @param userHandle the user to set
*
- * <p>Callers should instead use {@link #isLocationEnabled()}
- * unless they depend on provider-specific APIs such as
- * {@link #requestLocationUpdates(String, long, float, LocationListener)}.
+ * @hide
+ */
+ @SystemApi
+ @RequiresPermission(WRITE_SECURE_SETTINGS)
+ public void setLocationEnabledForUser(boolean enabled, UserHandle userHandle) {
+ Settings.Secure.putIntForUser(
+ mContext.getContentResolver(),
+ Settings.Secure.LOCATION_MODE,
+ enabled
+ ? Settings.Secure.LOCATION_MODE_ON
+ : Settings.Secure.LOCATION_MODE_OFF,
+ userHandle.getIdentifier());
+ }
+
+ /**
+ * Returns the current enabled/disabled status of the given provider. To listen for changes, see
+ * {@link #PROVIDERS_CHANGED_ACTION}.
*
- * <p>
- * Before API version {@link android.os.Build.VERSION_CODES#LOLLIPOP}, this
- * method would throw {@link SecurityException} if the location permissions
- * were not sufficient to use the specified provider.
+ * Before API version {@link android.os.Build.VERSION_CODES#LOLLIPOP}, this method would throw
+ * {@link SecurityException} if the location permissions were not sufficient to use the
+ * specified provider.
*
* @param provider the name of the provider
* @return true if the provider exists and is enabled
@@ -1334,19 +1322,13 @@
}
/**
- * Returns the current enabled/disabled status of the given provider and user.
+ * Returns the current enabled/disabled status of the given provider and user. Callers should
+ * prefer {@link #isLocationEnabledForUser(UserHandle)} unless they depend on provider-specific
+ * APIs.
*
- * <p>If the user has enabled this provider in the Settings menu, true
- * is returned otherwise false is returned
- *
- * <p>Callers should instead use {@link #isLocationEnabled()}
- * unless they depend on provider-specific APIs such as
- * {@link #requestLocationUpdates(String, long, float, LocationListener)}.
- *
- * <p>
- * Before API version {@link android.os.Build.VERSION_CODES#LOLLIPOP}, this
- * method would throw {@link SecurityException} if the location permissions
- * were not sufficient to use the specified provider.
+ * Before API version {@link android.os.Build.VERSION_CODES#LOLLIPOP}, this method would throw
+ * {@link SecurityException} if the location permissions were not sufficient to use the
+ * specified provider.
*
* @param provider the name of the provider
* @param userHandle the user to query
@@ -1367,12 +1349,14 @@
}
/**
- * Method for enabling or disabling a single location provider.
+ * Method for enabling or disabling a single location provider. This method is deprecated and
+ * functions as a best effort. It should not be relied on in any meaningful sense as providers
+ * may no longer be enabled or disabled by clients.
*
* @param provider the name of the provider
* @param enabled true to enable the provider. false to disable the provider
* @param userHandle the user to set
- * @return true if the value was set, false on database errors
+ * @return true if the value was set, false otherwise
*
* @throws IllegalArgumentException if provider is null
* @deprecated Do not manipulate providers individually, use
diff --git a/location/java/android/location/LocationRequest.java b/location/java/android/location/LocationRequest.java
index 3d0afb09..0480eab 100644
--- a/location/java/android/location/LocationRequest.java
+++ b/location/java/android/location/LocationRequest.java
@@ -683,6 +683,7 @@
request.setSmallestDisplacement(in.readFloat());
request.setHideFromAppOps(in.readInt() != 0);
request.setLowPowerMode(in.readInt() != 0);
+ request.setLocationSettingsIgnored(in.readInt() != 0);
String provider = in.readString();
if (provider != null) request.setProvider(provider);
WorkSource workSource = in.readParcelable(null);
@@ -711,6 +712,7 @@
parcel.writeFloat(mSmallestDisplacement);
parcel.writeInt(mHideFromAppOps ? 1 : 0);
parcel.writeInt(mLowPowerMode ? 1 : 0);
+ parcel.writeInt(mLocationSettingsIgnored ? 1 : 0);
parcel.writeString(mProvider);
parcel.writeParcelable(mWorkSource, 0);
}
@@ -755,6 +757,9 @@
s.append(" num=").append(mNumUpdates);
}
s.append(" lowPowerMode=").append(mLowPowerMode);
+ if (mLocationSettingsIgnored) {
+ s.append(" ignoreSettings");
+ }
s.append(']');
return s.toString();
}
diff --git a/media/Android.bp b/media/Android.bp
index e7d5faf..d7b8dd2 100644
--- a/media/Android.bp
+++ b/media/Android.bp
@@ -1,30 +1,4 @@
java_library {
- name: "updatable-media1",
-
- srcs: [
- ":media1-srcs",
- ":framework-media-annotation-srcs",
- ],
-
- aidl: {
- export_include_dirs: [
- "apex/java",
- ],
-
- // TODO: find out a way to include only the necessary aidl files instead of dirs.
- include_dirs: [
- "frameworks/base/core/java",
- "frameworks/base/media/java",
- ],
- },
-
- installable: true,
-
- // Make sure that the implementaion only relies on SDK or system APIs.
- sdk_version: "system_current",
-}
-
-java_library {
name: "updatable-media",
srcs: [
@@ -57,55 +31,12 @@
filegroup {
name: "media-srcs-without-aidls",
srcs : [
- ":media1-srcs-without-aidls",
":mediasession2-srcs-without-aidls",
":mediaplayer2-srcs",
],
}
filegroup {
- name: "media1-srcs",
- srcs: [
- "apex/java/android/media/MediaDescription.java",
- "apex/java/android/media/MediaParceledListSlice.java",
- "apex/java/android/media/Rating.java",
- "apex/java/android/media/VolumeProvider.java",
- "apex/java/android/media/browse/MediaBrowser.java",
- "apex/java/android/media/browse/MediaBrowserUtils.java",
- "apex/java/android/media/session/ControllerCallbackLink.java",
- "apex/java/android/media/session/ControllerLink.java",
- "apex/java/android/media/session/ISession.aidl",
- "apex/java/android/media/session/ISessionCallback.aidl",
- "apex/java/android/media/session/ISessionController.aidl",
- "apex/java/android/media/session/ISessionControllerCallback.aidl",
- "apex/java/android/media/session/MediaController.java",
- "apex/java/android/media/session/MediaSessionEngine.java",
- "apex/java/android/media/session/MediaSessionProviderService.java",
- "apex/java/android/media/session/PlaybackState.java",
- "apex/java/android/media/session/SessionCallbackLink.java",
- "apex/java/android/media/session/SessionLink.java",
- "apex/java/android/service/media/IMediaBrowserService.aidl",
- "apex/java/android/service/media/IMediaBrowserServiceCallbacks.aidl",
- "apex/java/android/service/media/MediaBrowserService.java",
- ],
-}
-
-filegroup {
- name: "media1-srcs-without-aidls",
- srcs: [
- ":media1-srcs",
- ],
- exclude_srcs: [
- "apex/java/android/media/session/ISession.aidl",
- "apex/java/android/media/session/ISessionCallback.aidl",
- "apex/java/android/media/session/ISessionController.aidl",
- "apex/java/android/media/session/ISessionControllerCallback.aidl",
- "apex/java/android/service/media/IMediaBrowserService.aidl",
- "apex/java/android/service/media/IMediaBrowserServiceCallbacks.aidl",
- ],
-}
-
-filegroup {
name: "mediasession2-srcs",
srcs: [
"apex/java/android/media/Controller2Link.java",
diff --git a/media/apex/java/android/media/MediaPlayer2.java b/media/apex/java/android/media/MediaPlayer2.java
index 1a1f6fb..0fd496b 100644
--- a/media/apex/java/android/media/MediaPlayer2.java
+++ b/media/apex/java/android/media/MediaPlayer2.java
@@ -21,6 +21,7 @@
import android.annotation.NonNull;
import android.annotation.Nullable;
import android.annotation.StringDef;
+import android.annotation.TestApi;
import android.content.ContentResolver;
import android.content.Context;
import android.content.res.AssetFileDescriptor;
@@ -3667,53 +3668,66 @@
}
/**
- * The status codes for {@link DrmEventCallback#onDrmPrepared} listener.
+ * A status code for {@link DrmEventCallback#onDrmPrepared} listener.
* <p>
*
* DRM preparation has succeeded.
- * @hide
*/
public static final int PREPARE_DRM_STATUS_SUCCESS = 0;
/**
+ * A status code for {@link DrmEventCallback#onDrmPrepared} listener.
+ * <p>
+ *
* The device required DRM provisioning but couldn't reach the provisioning server.
- * @hide
*/
public static final int PREPARE_DRM_STATUS_PROVISIONING_NETWORK_ERROR = 1;
/**
+ * A status code for {@link DrmEventCallback#onDrmPrepared} listener.
+ * <p>
+ *
* The device required DRM provisioning but the provisioning server denied the request.
- * @hide
*/
public static final int PREPARE_DRM_STATUS_PROVISIONING_SERVER_ERROR = 2;
/**
+ * A status code for {@link DrmEventCallback#onDrmPrepared} listener.
+ * <p>
+ *
* The DRM preparation has failed .
- * @hide
*/
public static final int PREPARE_DRM_STATUS_PREPARATION_ERROR = 3;
/**
+ * A status code for {@link DrmEventCallback#onDrmPrepared} listener.
+ * <p>
+ *
* The crypto scheme UUID is not supported by the device.
- * @hide
*/
public static final int PREPARE_DRM_STATUS_UNSUPPORTED_SCHEME = 4;
/**
+ * A status code for {@link DrmEventCallback#onDrmPrepared} listener.
+ * <p>
+ *
* The hardware resources are not available, due to being in use.
- * @hide
*/
public static final int PREPARE_DRM_STATUS_RESOURCE_BUSY = 5;
/**
+ * A status code for {@link DrmEventCallback#onDrmPrepared} listener.
+ * <p>
+ *
* Restoring persisted offline keys failed.
- * @hide
*/
public static final int PREPARE_DRM_STATUS_RESTORE_ERROR = 6;
/**
+ * A status code for {@link DrmEventCallback#onDrmPrepared} listener.
+ * <p>
+ *
* Error during key request/response exchange with license server.
- * @hide
*/
public static final int PREPARE_DRM_STATUS_KEY_EXCHANGE_ERROR = 7;
@@ -3758,6 +3772,7 @@
* @throws IllegalStateException if called before being prepared
* @hide
*/
+ @TestApi
public DrmInfo getDrmInfo(@NonNull DataSourceDesc dsd) {
final SourceInfo sourceInfo = getSourceInfo(dsd);
if (sourceInfo != null) {
@@ -3814,6 +3829,7 @@
* @hide
*/
// This is an asynchronous call.
+ @TestApi
public Object prepareDrm(@NonNull DataSourceDesc dsd, @NonNull UUID uuid) {
return addTask(newPrepareDrmTask(dsd, uuid));
}
@@ -3905,6 +3921,7 @@
* @hide
*/
// This is a synchronous call.
+ @TestApi
public void releaseDrm(@NonNull DataSourceDesc dsd)
throws NoDrmSchemeException {
final SourceInfo sourceInfo = getSourceInfo(dsd);
@@ -3955,6 +3972,7 @@
* @throws NoDrmSchemeException if there is no active DRM session
* @hide
*/
+ @TestApi
public MediaDrm.KeyRequest getDrmKeyRequest(
@NonNull DataSourceDesc dsd,
@Nullable byte[] keySetId, @Nullable byte[] initData,
@@ -3997,6 +4015,7 @@
* @hide
*/
// This is a synchronous call.
+ @TestApi
public byte[] provideDrmKeyResponse(
@NonNull DataSourceDesc dsd,
@Nullable byte[] keySetId, @NonNull byte[] response)
@@ -4023,6 +4042,7 @@
* @hide
*/
// This is a synchronous call.
+ @TestApi
public void restoreDrmKeys(
@NonNull DataSourceDesc dsd,
@NonNull byte[] keySetId)
@@ -4050,6 +4070,7 @@
* @throws NoDrmSchemeException if there is no active DRM session
* @hide
*/
+ @TestApi
public String getDrmPropertyString(
@NonNull DataSourceDesc dsd,
@NonNull @MediaDrmStringProperty String propertyName)
@@ -4078,6 +4099,7 @@
* @hide
*/
// This is a synchronous call.
+ @TestApi
public void setDrmPropertyString(
@NonNull DataSourceDesc dsd,
@NonNull @MediaDrmStringProperty String propertyName, @NonNull String value)
diff --git a/media/java/android/media/MediaCodec.java b/media/java/android/media/MediaCodec.java
index f756658..0c3d625 100644
--- a/media/java/android/media/MediaCodec.java
+++ b/media/java/android/media/MediaCodec.java
@@ -3314,7 +3314,7 @@
*/
public void setAudioPresentation(@NonNull AudioPresentation presentation) {
if (presentation == null) {
- throw new IllegalArgumentException("audio presentation is null");
+ throw new NullPointerException("audio presentation is null");
}
native_setAudioPresentation(presentation.getPresentationId(), presentation.getProgramId());
}
diff --git a/media/apex/java/android/media/MediaDescription.aidl b/media/java/android/media/MediaDescription.aidl
similarity index 100%
rename from media/apex/java/android/media/MediaDescription.aidl
rename to media/java/android/media/MediaDescription.aidl
diff --git a/media/apex/java/android/media/MediaDescription.java b/media/java/android/media/MediaDescription.java
similarity index 100%
rename from media/apex/java/android/media/MediaDescription.java
rename to media/java/android/media/MediaDescription.java
diff --git a/media/apex/java/android/media/MediaParceledListSlice.aidl b/media/java/android/media/MediaParceledListSlice.aidl
similarity index 100%
rename from media/apex/java/android/media/MediaParceledListSlice.aidl
rename to media/java/android/media/MediaParceledListSlice.aidl
diff --git a/media/apex/java/android/media/MediaParceledListSlice.java b/media/java/android/media/MediaParceledListSlice.java
similarity index 100%
rename from media/apex/java/android/media/MediaParceledListSlice.java
rename to media/java/android/media/MediaParceledListSlice.java
diff --git a/media/apex/java/android/media/Rating.aidl b/media/java/android/media/Rating.aidl
similarity index 100%
rename from media/apex/java/android/media/Rating.aidl
rename to media/java/android/media/Rating.aidl
diff --git a/media/apex/java/android/media/Rating.java b/media/java/android/media/Rating.java
similarity index 100%
rename from media/apex/java/android/media/Rating.java
rename to media/java/android/media/Rating.java
diff --git a/media/apex/java/android/media/VolumeProvider.java b/media/java/android/media/VolumeProvider.java
similarity index 98%
rename from media/apex/java/android/media/VolumeProvider.java
rename to media/java/android/media/VolumeProvider.java
index 49202ee..8f68cbd 100644
--- a/media/apex/java/android/media/VolumeProvider.java
+++ b/media/java/android/media/VolumeProvider.java
@@ -16,7 +16,6 @@
package android.media;
import android.annotation.IntDef;
-import android.annotation.SystemApi;
import android.media.session.MediaSession;
import java.lang.annotation.Retention;
@@ -148,7 +147,6 @@
* Sets a callback to receive volume changes.
* @hide
*/
- @SystemApi
public void setCallback(Callback callback) {
mCallback = callback;
}
@@ -157,7 +155,6 @@
* Listens for changes to the volume.
* @hide
*/
- @SystemApi
public abstract static class Callback {
/**
* Called when volume changed.
diff --git a/media/apex/java/android/media/browse/MediaBrowser.aidl b/media/java/android/media/browse/MediaBrowser.aidl
similarity index 100%
rename from media/apex/java/android/media/browse/MediaBrowser.aidl
rename to media/java/android/media/browse/MediaBrowser.aidl
diff --git a/media/apex/java/android/media/browse/MediaBrowser.java b/media/java/android/media/browse/MediaBrowser.java
similarity index 100%
rename from media/apex/java/android/media/browse/MediaBrowser.java
rename to media/java/android/media/browse/MediaBrowser.java
diff --git a/media/apex/java/android/media/browse/MediaBrowserUtils.java b/media/java/android/media/browse/MediaBrowserUtils.java
similarity index 100%
rename from media/apex/java/android/media/browse/MediaBrowserUtils.java
rename to media/java/android/media/browse/MediaBrowserUtils.java
diff --git a/media/apex/java/android/media/session/ControllerCallbackLink.aidl b/media/java/android/media/session/ControllerCallbackLink.aidl
similarity index 100%
rename from media/apex/java/android/media/session/ControllerCallbackLink.aidl
rename to media/java/android/media/session/ControllerCallbackLink.aidl
diff --git a/media/apex/java/android/media/session/ControllerCallbackLink.java b/media/java/android/media/session/ControllerCallbackLink.java
similarity index 99%
rename from media/apex/java/android/media/session/ControllerCallbackLink.java
rename to media/java/android/media/session/ControllerCallbackLink.java
index adc14a5..428be0d 100644
--- a/media/apex/java/android/media/session/ControllerCallbackLink.java
+++ b/media/java/android/media/session/ControllerCallbackLink.java
@@ -20,7 +20,6 @@
import android.annotation.NonNull;
import android.annotation.Nullable;
import android.annotation.RequiresPermission;
-import android.annotation.SystemApi;
import android.content.Context;
import android.content.pm.PackageManager;
import android.media.MediaMetadata;
@@ -41,7 +40,6 @@
* Handles incoming commands to {@link MediaController.Callback}.
* @hide
*/
-@SystemApi
public final class ControllerCallbackLink implements Parcelable {
final Context mContext;
final CallbackStub mCallbackStub;
diff --git a/media/apex/java/android/media/session/ControllerLink.aidl b/media/java/android/media/session/ControllerLink.aidl
similarity index 100%
rename from media/apex/java/android/media/session/ControllerLink.aidl
rename to media/java/android/media/session/ControllerLink.aidl
diff --git a/media/apex/java/android/media/session/ControllerLink.java b/media/java/android/media/session/ControllerLink.java
similarity index 99%
rename from media/apex/java/android/media/session/ControllerLink.java
rename to media/java/android/media/session/ControllerLink.java
index f60ec00..64d283f 100644
--- a/media/apex/java/android/media/session/ControllerLink.java
+++ b/media/java/android/media/session/ControllerLink.java
@@ -18,7 +18,6 @@
import android.annotation.NonNull;
import android.annotation.Nullable;
-import android.annotation.SystemApi;
import android.app.PendingIntent;
import android.media.MediaMetadata;
import android.media.MediaParceledListSlice;
@@ -40,7 +39,6 @@
* Handles incoming commands from {@link MediaController}.
* @hide
*/
-@SystemApi
public final class ControllerLink implements Parcelable {
public static final Parcelable.Creator<ControllerLink> CREATOR =
new Parcelable.Creator<ControllerLink>() {
diff --git a/media/apex/java/android/media/session/ISession.aidl b/media/java/android/media/session/ISession.aidl
similarity index 100%
rename from media/apex/java/android/media/session/ISession.aidl
rename to media/java/android/media/session/ISession.aidl
diff --git a/media/apex/java/android/media/session/ISessionCallback.aidl b/media/java/android/media/session/ISessionCallback.aidl
similarity index 100%
rename from media/apex/java/android/media/session/ISessionCallback.aidl
rename to media/java/android/media/session/ISessionCallback.aidl
diff --git a/media/apex/java/android/media/session/ISessionController.aidl b/media/java/android/media/session/ISessionController.aidl
similarity index 100%
rename from media/apex/java/android/media/session/ISessionController.aidl
rename to media/java/android/media/session/ISessionController.aidl
diff --git a/media/apex/java/android/media/session/ISessionControllerCallback.aidl b/media/java/android/media/session/ISessionControllerCallback.aidl
similarity index 100%
rename from media/apex/java/android/media/session/ISessionControllerCallback.aidl
rename to media/java/android/media/session/ISessionControllerCallback.aidl
diff --git a/media/apex/java/android/media/session/MediaController.aidl b/media/java/android/media/session/MediaController.aidl
similarity index 100%
rename from media/apex/java/android/media/session/MediaController.aidl
rename to media/java/android/media/session/MediaController.aidl
diff --git a/media/apex/java/android/media/session/MediaController.java b/media/java/android/media/session/MediaController.java
similarity index 99%
rename from media/apex/java/android/media/session/MediaController.java
rename to media/java/android/media/session/MediaController.java
index 1333ab0..6e2c8c5 100644
--- a/media/apex/java/android/media/session/MediaController.java
+++ b/media/java/android/media/session/MediaController.java
@@ -413,6 +413,7 @@
* Get the session's tag for debugging purposes.
*
* @return The session's tag.
+ * @hide
*/
public String getTag() {
if (mTag == null) {
diff --git a/media/java/android/media/session/MediaSession.java b/media/java/android/media/session/MediaSession.java
index ca3346c..1b9ebda 100644
--- a/media/java/android/media/session/MediaSession.java
+++ b/media/java/android/media/session/MediaSession.java
@@ -19,7 +19,6 @@
import android.annotation.IntDef;
import android.annotation.NonNull;
import android.annotation.Nullable;
-import android.annotation.SystemApi;
import android.annotation.UnsupportedAppUsage;
import android.app.Activity;
import android.app.PendingIntent;
@@ -142,10 +141,9 @@
MediaSessionManager manager = (MediaSessionManager) context
.getSystemService(Context.MEDIA_SESSION_SERVICE);
try {
- MediaSessionEngine.CallbackStub cbStub = new MediaSessionEngine.CallbackStub();
- SessionCallbackLink cbLink = new SessionCallbackLink(context, cbStub);
+ SessionCallbackLink cbLink = new SessionCallbackLink(context);
SessionLink sessionLink = manager.createSession(cbLink, tag);
- mImpl = new MediaSessionEngine(context, sessionLink, cbLink, cbStub);
+ mImpl = new MediaSessionEngine(context, sessionLink, cbLink);
mMaxBitmapSize = context.getResources().getDimensionPixelSize(
android.R.dimen.config_mediaMetadataBitmapMaxSize);
} catch (RuntimeException e) {
@@ -488,7 +486,6 @@
* Gets the controller link in this token.
* @hide
*/
- @SystemApi
public ControllerLink getControllerLink() {
return mControllerLink;
}
@@ -697,7 +694,6 @@
/**
* @hide
*/
- @SystemApi
public void onSetMediaButtonEventDelegate(
@NonNull MediaSessionEngine.MediaButtonEventDelegate delegate) {
mMediaButtonEventDelegate = delegate;
diff --git a/media/apex/java/android/media/session/MediaSessionEngine.java b/media/java/android/media/session/MediaSessionEngine.java
similarity index 78%
rename from media/apex/java/android/media/session/MediaSessionEngine.java
rename to media/java/android/media/session/MediaSessionEngine.java
index 31714e1..e19bdbc 100644
--- a/media/apex/java/android/media/session/MediaSessionEngine.java
+++ b/media/java/android/media/session/MediaSessionEngine.java
@@ -18,8 +18,6 @@
import android.annotation.NonNull;
import android.annotation.Nullable;
-import android.annotation.SystemApi;
-import android.annotation.UnsupportedAppUsage;
import android.app.Activity;
import android.app.PendingIntent;
import android.content.Context;
@@ -44,14 +42,12 @@
import android.view.KeyEvent;
import android.view.ViewConfiguration;
-import java.lang.ref.WeakReference;
import java.util.List;
import java.util.Objects;
/**
* @hide
*/
-@SystemApi
public final class MediaSessionEngine implements AutoCloseable {
private static final String TAG = "MediaSession";
@@ -60,10 +56,7 @@
private final MediaSession.Token mSessionToken;
private final MediaController mController;
private final SessionLink mSessionLink;
- private final SessionCallbackLink mCbLink;
- // Do not change the name of mCallbackWrapper. Support lib accesses this by using reflection.
- @UnsupportedAppUsage
private CallbackMessageHandler mCallbackHandler;
private VolumeProvider mVolumeProvider;
private PlaybackState mPlaybackState;
@@ -78,14 +71,12 @@
*
* @param context The context to use to create the session.
* @param sessionLink A session link for the binder of MediaSessionRecord
- * @param cbStub A callback link that handles incoming command to {@link MediaSession.Callback}.
*/
public MediaSessionEngine(@NonNull Context context, @NonNull SessionLink sessionLink,
- @NonNull SessionCallbackLink cbLink, @NonNull CallbackStub cbStub) {
+ @NonNull SessionCallbackLink cbLink) {
mSessionLink = sessionLink;
- mCbLink = cbLink;
- cbStub.setSessionImpl(this);
+ cbLink.setSessionEngine(this);
mSessionToken = new MediaSession.Token(mSessionLink.getController());
mController = new MediaController(context, mSessionToken);
}
@@ -479,97 +470,97 @@
}
}
- private void dispatchPrepare(RemoteUserInfo caller) {
+ void dispatchPrepare(RemoteUserInfo caller) {
postToCallback(caller, CallbackMessageHandler.MSG_PREPARE, null, null);
}
- private void dispatchPrepareFromMediaId(RemoteUserInfo caller, String mediaId, Bundle extras) {
+ void dispatchPrepareFromMediaId(RemoteUserInfo caller, String mediaId, Bundle extras) {
postToCallback(caller, CallbackMessageHandler.MSG_PREPARE_MEDIA_ID, mediaId, extras);
}
- private void dispatchPrepareFromSearch(RemoteUserInfo caller, String query, Bundle extras) {
+ void dispatchPrepareFromSearch(RemoteUserInfo caller, String query, Bundle extras) {
postToCallback(caller, CallbackMessageHandler.MSG_PREPARE_SEARCH, query, extras);
}
- private void dispatchPrepareFromUri(RemoteUserInfo caller, Uri uri, Bundle extras) {
+ void dispatchPrepareFromUri(RemoteUserInfo caller, Uri uri, Bundle extras) {
postToCallback(caller, CallbackMessageHandler.MSG_PREPARE_URI, uri, extras);
}
- private void dispatchPlay(RemoteUserInfo caller) {
+ void dispatchPlay(RemoteUserInfo caller) {
postToCallback(caller, CallbackMessageHandler.MSG_PLAY, null, null);
}
- private void dispatchPlayFromMediaId(RemoteUserInfo caller, String mediaId, Bundle extras) {
+ void dispatchPlayFromMediaId(RemoteUserInfo caller, String mediaId, Bundle extras) {
postToCallback(caller, CallbackMessageHandler.MSG_PLAY_MEDIA_ID, mediaId, extras);
}
- private void dispatchPlayFromSearch(RemoteUserInfo caller, String query, Bundle extras) {
+ void dispatchPlayFromSearch(RemoteUserInfo caller, String query, Bundle extras) {
postToCallback(caller, CallbackMessageHandler.MSG_PLAY_SEARCH, query, extras);
}
- private void dispatchPlayFromUri(RemoteUserInfo caller, Uri uri, Bundle extras) {
+ void dispatchPlayFromUri(RemoteUserInfo caller, Uri uri, Bundle extras) {
postToCallback(caller, CallbackMessageHandler.MSG_PLAY_URI, uri, extras);
}
- private void dispatchSkipToItem(RemoteUserInfo caller, long id) {
+ void dispatchSkipToItem(RemoteUserInfo caller, long id) {
postToCallback(caller, CallbackMessageHandler.MSG_SKIP_TO_ITEM, id, null);
}
- private void dispatchPause(RemoteUserInfo caller) {
+ void dispatchPause(RemoteUserInfo caller) {
postToCallback(caller, CallbackMessageHandler.MSG_PAUSE, null, null);
}
- private void dispatchStop(RemoteUserInfo caller) {
+ void dispatchStop(RemoteUserInfo caller) {
postToCallback(caller, CallbackMessageHandler.MSG_STOP, null, null);
}
- private void dispatchNext(RemoteUserInfo caller) {
+ void dispatchNext(RemoteUserInfo caller) {
postToCallback(caller, CallbackMessageHandler.MSG_NEXT, null, null);
}
- private void dispatchPrevious(RemoteUserInfo caller) {
+ void dispatchPrevious(RemoteUserInfo caller) {
postToCallback(caller, CallbackMessageHandler.MSG_PREVIOUS, null, null);
}
- private void dispatchFastForward(RemoteUserInfo caller) {
+ void dispatchFastForward(RemoteUserInfo caller) {
postToCallback(caller, CallbackMessageHandler.MSG_FAST_FORWARD, null, null);
}
- private void dispatchRewind(RemoteUserInfo caller) {
+ void dispatchRewind(RemoteUserInfo caller) {
postToCallback(caller, CallbackMessageHandler.MSG_REWIND, null, null);
}
- private void dispatchSeekTo(RemoteUserInfo caller, long pos) {
+ void dispatchSeekTo(RemoteUserInfo caller, long pos) {
postToCallback(caller, CallbackMessageHandler.MSG_SEEK_TO, pos, null);
}
- private void dispatchRate(RemoteUserInfo caller, Rating rating) {
+ void dispatchRate(RemoteUserInfo caller, Rating rating) {
postToCallback(caller, CallbackMessageHandler.MSG_RATE, rating, null);
}
- private void dispatchCustomAction(RemoteUserInfo caller, String action, Bundle args) {
+ void dispatchCustomAction(RemoteUserInfo caller, String action, Bundle args) {
postToCallback(caller, CallbackMessageHandler.MSG_CUSTOM_ACTION, action, args);
}
- private void dispatchMediaButton(RemoteUserInfo caller, Intent mediaButtonIntent) {
+ void dispatchMediaButton(RemoteUserInfo caller, Intent mediaButtonIntent) {
postToCallback(caller, CallbackMessageHandler.MSG_MEDIA_BUTTON, mediaButtonIntent, null);
}
- private void dispatchMediaButtonDelayed(RemoteUserInfo info, Intent mediaButtonIntent,
+ void dispatchMediaButtonDelayed(RemoteUserInfo info, Intent mediaButtonIntent,
long delay) {
postToCallbackDelayed(info, CallbackMessageHandler.MSG_PLAY_PAUSE_KEY_DOUBLE_TAP_TIMEOUT,
mediaButtonIntent, null, delay);
}
- private void dispatchAdjustVolume(RemoteUserInfo caller, int direction) {
+ void dispatchAdjustVolume(RemoteUserInfo caller, int direction) {
postToCallback(caller, CallbackMessageHandler.MSG_ADJUST_VOLUME, direction, null);
}
- private void dispatchSetVolumeTo(RemoteUserInfo caller, int volume) {
+ void dispatchSetVolumeTo(RemoteUserInfo caller, int volume) {
postToCallback(caller, CallbackMessageHandler.MSG_SET_VOLUME, volume, null);
}
- private void dispatchCommand(RemoteUserInfo caller, String command, Bundle args,
+ void dispatchCommand(RemoteUserInfo caller, String command, Bundle args,
ResultReceiver resultCb) {
Command cmd = new Command(command, args, resultCb);
postToCallback(caller, CallbackMessageHandler.MSG_COMMAND, cmd, null);
@@ -979,259 +970,7 @@
}
}
- /**
- * @hide
- */
- @SystemApi
- public static final class CallbackStub extends SessionCallbackLink.CallbackStub {
- private WeakReference<MediaSessionEngine> mSessionImpl;
-
- private static RemoteUserInfo createRemoteUserInfo(String packageName, int pid, int uid) {
- return new RemoteUserInfo(packageName, pid, uid);
- }
-
- public CallbackStub() {
- }
-
- @Override
- public void onCommand(String packageName, int pid, int uid,
- ControllerCallbackLink caller, String command, Bundle args, ResultReceiver cb) {
- MediaSessionEngine sessionImpl = mSessionImpl.get();
- if (sessionImpl != null) {
- sessionImpl.dispatchCommand(createRemoteUserInfo(packageName, pid, uid),
- command, args, cb);
- }
- }
-
- @Override
- public void onMediaButton(String packageName, int pid, int uid, Intent mediaButtonIntent,
- int sequenceNumber, ResultReceiver cb) {
- MediaSessionEngine sessionImpl = mSessionImpl.get();
- try {
- if (sessionImpl != null) {
- sessionImpl.dispatchMediaButton(
- createRemoteUserInfo(packageName, pid, uid), mediaButtonIntent);
- }
- } finally {
- if (cb != null) {
- cb.send(sequenceNumber, null);
- }
- }
- }
-
- @Override
- public void onMediaButtonFromController(String packageName, int pid, int uid,
- ControllerCallbackLink caller, Intent mediaButtonIntent) {
- MediaSessionEngine sessionImpl = mSessionImpl.get();
- if (sessionImpl != null) {
- sessionImpl.dispatchMediaButton(createRemoteUserInfo(packageName, pid, uid),
- mediaButtonIntent);
- }
- }
-
- @Override
- public void onPrepare(String packageName, int pid, int uid,
- ControllerCallbackLink caller) {
- MediaSessionEngine sessionImpl = mSessionImpl.get();
- if (sessionImpl != null) {
- sessionImpl.dispatchPrepare(createRemoteUserInfo(packageName, pid, uid));
- }
- }
-
- @Override
- public void onPrepareFromMediaId(String packageName, int pid, int uid,
- ControllerCallbackLink caller, String mediaId,
- Bundle extras) {
- MediaSessionEngine sessionImpl = mSessionImpl.get();
- if (sessionImpl != null) {
- sessionImpl.dispatchPrepareFromMediaId(
- createRemoteUserInfo(packageName, pid, uid), mediaId, extras);
- }
- }
-
- @Override
- public void onPrepareFromSearch(String packageName, int pid, int uid,
- ControllerCallbackLink caller, String query,
- Bundle extras) {
- MediaSessionEngine sessionImpl = mSessionImpl.get();
- if (sessionImpl != null) {
- sessionImpl.dispatchPrepareFromSearch(
- createRemoteUserInfo(packageName, pid, uid), query, extras);
- }
- }
-
- @Override
- public void onPrepareFromUri(String packageName, int pid, int uid,
- ControllerCallbackLink caller, Uri uri, Bundle extras) {
- MediaSessionEngine sessionImpl = mSessionImpl.get();
- if (sessionImpl != null) {
- sessionImpl.dispatchPrepareFromUri(
- createRemoteUserInfo(packageName, pid, uid), uri, extras);
- }
- }
-
- @Override
- public void onPlay(String packageName, int pid, int uid,
- ControllerCallbackLink caller) {
- MediaSessionEngine sessionImpl = mSessionImpl.get();
- if (sessionImpl != null) {
- sessionImpl.dispatchPlay(createRemoteUserInfo(packageName, pid, uid));
- }
- }
-
- @Override
- public void onPlayFromMediaId(String packageName, int pid, int uid,
- ControllerCallbackLink caller, String mediaId,
- Bundle extras) {
- MediaSessionEngine sessionImpl = mSessionImpl.get();
- if (sessionImpl != null) {
- sessionImpl.dispatchPlayFromMediaId(
- createRemoteUserInfo(packageName, pid, uid), mediaId, extras);
- }
- }
-
- @Override
- public void onPlayFromSearch(String packageName, int pid, int uid,
- ControllerCallbackLink caller, String query,
- Bundle extras) {
- MediaSessionEngine sessionImpl = mSessionImpl.get();
- if (sessionImpl != null) {
- sessionImpl.dispatchPlayFromSearch(
- createRemoteUserInfo(packageName, pid, uid), query, extras);
- }
- }
-
- @Override
- public void onPlayFromUri(String packageName, int pid, int uid,
- ControllerCallbackLink caller, Uri uri, Bundle extras) {
- MediaSessionEngine sessionImpl = mSessionImpl.get();
- if (sessionImpl != null) {
- sessionImpl.dispatchPlayFromUri(
- createRemoteUserInfo(packageName, pid, uid), uri, extras);
- }
- }
-
- @Override
- public void onSkipToTrack(String packageName, int pid, int uid,
- ControllerCallbackLink caller, long id) {
- MediaSessionEngine sessionImpl = mSessionImpl.get();
- if (sessionImpl != null) {
- sessionImpl.dispatchSkipToItem(
- createRemoteUserInfo(packageName, pid, uid), id);
- }
- }
-
- @Override
- public void onPause(String packageName, int pid, int uid,
- ControllerCallbackLink caller) {
- MediaSessionEngine sessionImpl = mSessionImpl.get();
- if (sessionImpl != null) {
- sessionImpl.dispatchPause(createRemoteUserInfo(packageName, pid, uid));
- }
- }
-
- @Override
- public void onStop(String packageName, int pid, int uid,
- ControllerCallbackLink caller) {
- MediaSessionEngine sessionImpl = mSessionImpl.get();
- if (sessionImpl != null) {
- sessionImpl.dispatchStop(createRemoteUserInfo(packageName, pid, uid));
- }
- }
-
- @Override
- public void onNext(String packageName, int pid, int uid,
- ControllerCallbackLink caller) {
- MediaSessionEngine sessionImpl = mSessionImpl.get();
- if (sessionImpl != null) {
- sessionImpl.dispatchNext(createRemoteUserInfo(packageName, pid, uid));
- }
- }
-
- @Override
- public void onPrevious(String packageName, int pid, int uid,
- ControllerCallbackLink caller) {
- MediaSessionEngine sessionImpl = mSessionImpl.get();
- if (sessionImpl != null) {
- sessionImpl.dispatchPrevious(createRemoteUserInfo(packageName, pid, uid));
- }
- }
-
- @Override
- public void onFastForward(String packageName, int pid, int uid,
- ControllerCallbackLink caller) {
- MediaSessionEngine sessionImpl = mSessionImpl.get();
- if (sessionImpl != null) {
- sessionImpl.dispatchFastForward(
- createRemoteUserInfo(packageName, pid, uid));
- }
- }
-
- @Override
- public void onRewind(String packageName, int pid, int uid,
- ControllerCallbackLink caller) {
- MediaSessionEngine sessionImpl = mSessionImpl.get();
- if (sessionImpl != null) {
- sessionImpl.dispatchRewind(createRemoteUserInfo(packageName, pid, uid));
- }
- }
-
- @Override
- public void onSeekTo(String packageName, int pid, int uid,
- ControllerCallbackLink caller, long pos) {
- MediaSessionEngine sessionImpl = mSessionImpl.get();
- if (sessionImpl != null) {
- sessionImpl.dispatchSeekTo(
- createRemoteUserInfo(packageName, pid, uid), pos);
- }
- }
-
- @Override
- public void onRate(String packageName, int pid, int uid, ControllerCallbackLink caller,
- Rating rating) {
- MediaSessionEngine sessionImpl = mSessionImpl.get();
- if (sessionImpl != null) {
- sessionImpl.dispatchRate(
- createRemoteUserInfo(packageName, pid, uid), rating);
- }
- }
-
- @Override
- public void onCustomAction(String packageName, int pid, int uid,
- ControllerCallbackLink caller, String action, Bundle args) {
- MediaSessionEngine sessionImpl = mSessionImpl.get();
- if (sessionImpl != null) {
- sessionImpl.dispatchCustomAction(
- createRemoteUserInfo(packageName, pid, uid), action, args);
- }
- }
-
- @Override
- public void onAdjustVolume(String packageName, int pid, int uid,
- ControllerCallbackLink caller, int direction) {
- MediaSessionEngine sessionImpl = mSessionImpl.get();
- if (sessionImpl != null) {
- sessionImpl.dispatchAdjustVolume(
- createRemoteUserInfo(packageName, pid, uid), direction);
- }
- }
-
- @Override
- public void onSetVolumeTo(String packageName, int pid, int uid,
- ControllerCallbackLink caller, int value) {
- MediaSessionEngine sessionImpl = mSessionImpl.get();
- if (sessionImpl != null) {
- sessionImpl.dispatchSetVolumeTo(
- createRemoteUserInfo(packageName, pid, uid), value);
- }
- }
-
- void setSessionImpl(MediaSessionEngine sessionImpl) {
- mSessionImpl = new WeakReference<>(sessionImpl);
- }
- }
-
- /**
+ /**
* A single item that is part of the play queue. It contains a description
* of the item and its id in the queue.
*/
diff --git a/media/apex/java/android/media/session/MediaSessionProviderService.java b/media/java/android/media/session/MediaSessionProviderService.java
similarity index 100%
rename from media/apex/java/android/media/session/MediaSessionProviderService.java
rename to media/java/android/media/session/MediaSessionProviderService.java
diff --git a/media/apex/java/android/media/session/PlaybackState.aidl b/media/java/android/media/session/PlaybackState.aidl
similarity index 100%
rename from media/apex/java/android/media/session/PlaybackState.aidl
rename to media/java/android/media/session/PlaybackState.aidl
diff --git a/media/apex/java/android/media/session/PlaybackState.java b/media/java/android/media/session/PlaybackState.java
similarity index 100%
rename from media/apex/java/android/media/session/PlaybackState.java
rename to media/java/android/media/session/PlaybackState.java
diff --git a/media/apex/java/android/media/session/SessionCallbackLink.aidl b/media/java/android/media/session/SessionCallbackLink.aidl
similarity index 100%
rename from media/apex/java/android/media/session/SessionCallbackLink.aidl
rename to media/java/android/media/session/SessionCallbackLink.aidl
diff --git a/media/apex/java/android/media/session/SessionCallbackLink.java b/media/java/android/media/session/SessionCallbackLink.java
similarity index 79%
rename from media/apex/java/android/media/session/SessionCallbackLink.java
rename to media/java/android/media/session/SessionCallbackLink.java
index 3bcb65c..f59a69d 100644
--- a/media/apex/java/android/media/session/SessionCallbackLink.java
+++ b/media/java/android/media/session/SessionCallbackLink.java
@@ -20,11 +20,11 @@
import android.annotation.NonNull;
import android.annotation.Nullable;
import android.annotation.RequiresPermission;
-import android.annotation.SystemApi;
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.media.Rating;
+import android.media.session.MediaSessionManager.RemoteUserInfo;
import android.net.Uri;
import android.os.Binder;
import android.os.Bundle;
@@ -35,23 +35,23 @@
import android.os.RemoteException;
import android.os.ResultReceiver;
+import java.lang.ref.WeakReference;
+
/**
* Handles incoming commands to {@link MediaSession.Callback}.
* @hide
*/
-@SystemApi
public final class SessionCallbackLink implements Parcelable {
final Context mContext;
- final CallbackStub mCallbackStub;
final ISessionCallback mISessionCallback;
/**
* Constructor for stub (Callee)
+ * @hide
*/
- SessionCallbackLink(@NonNull Context context, @NonNull CallbackStub callbackStub) {
+ public SessionCallbackLink(@NonNull Context context) {
mContext = context;
- mCallbackStub = callbackStub;
- mISessionCallback = new CallbackStubProxy();
+ mISessionCallback = new CallbackStub();
}
/**
@@ -59,11 +59,19 @@
*/
public SessionCallbackLink(IBinder binder) {
mContext = null;
- mCallbackStub = null;
mISessionCallback = ISessionCallback.Stub.asInterface(binder);
}
/**
+ * Set {@link MediaSessionEngine} which will be used by {@link CallbackStub}.
+ */
+ void setSessionEngine(@Nullable MediaSessionEngine sessionImpl) {
+ if (mISessionCallback instanceof CallbackStub) {
+ ((CallbackStub) mISessionCallback).mSessionImpl = new WeakReference<>(sessionImpl);
+ }
+ }
+
+ /**
* Notify session that a controller sends a command.
*
* @param packageName the package name of the controller
@@ -540,139 +548,24 @@
}
};
- /**
- * Class for Stub implementation
- */
- abstract static class CallbackStub {
- /** Stub method for ISessionCallback.notifyCommand */
- public void onCommand(@NonNull String packageName, int pid, int uid,
- @NonNull ControllerCallbackLink caller, @NonNull String command,
- @Nullable Bundle args, @Nullable ResultReceiver cb) {
+ private class CallbackStub extends ISessionCallback.Stub {
+ private WeakReference<MediaSessionEngine> mSessionImpl;
+
+ private RemoteUserInfo createRemoteUserInfo(String packageName, int pid, int uid) {
+ return new RemoteUserInfo(packageName, pid, uid);
}
- /** Stub method for ISessionCallback.notifyMediaButton */
- public void onMediaButton(@NonNull String packageName, int pid, int uid,
- @NonNull Intent mediaButtonIntent, int sequenceNumber,
- @Nullable ResultReceiver cb) {
- }
-
- /** Stub method for ISessionCallback.notifyMediaButtonFromController */
- public void onMediaButtonFromController(@NonNull String packageName, int pid, int uid,
- @NonNull ControllerCallbackLink caller, @NonNull Intent mediaButtonIntent) {
- }
-
- /** Stub method for ISessionCallback.notifyPrepare */
- public void onPrepare(@NonNull String packageName, int pid, int uid,
- @NonNull ControllerCallbackLink caller) {
- }
-
- /** Stub method for ISessionCallback.notifyPrepareFromMediaId */
- public void onPrepareFromMediaId(@NonNull String packageName, int pid, int uid,
- @NonNull ControllerCallbackLink caller, @NonNull String mediaId,
- @Nullable Bundle extras) {
- }
-
- /** Stub method for ISessionCallback.notifyPrepareFromSearch */
- public void onPrepareFromSearch(@NonNull String packageName, int pid, int uid,
- @NonNull ControllerCallbackLink caller, String query, @Nullable Bundle extras) {
- }
-
- /** Stub method for ISessionCallback.notifyPrepareFromUri */
- public void onPrepareFromUri(@NonNull String packageName, int pid, int uid,
- @NonNull ControllerCallbackLink caller, @NonNull Uri uri, @Nullable Bundle extras) {
- }
-
- /** Stub method for ISessionCallback.notifyPlay */
- public void onPlay(@NonNull String packageName, int pid, int uid,
- @NonNull ControllerCallbackLink caller) {
- }
-
- /** Stub method for ISessionCallback.notifyPlayFromMediaId */
- public void onPlayFromMediaId(@NonNull String packageName, int pid, int uid,
- @NonNull ControllerCallbackLink caller, @NonNull String mediaId,
- @Nullable Bundle extras) {
- }
-
- /** Stub method for ISessionCallback.notifyPlayFromSearch */
- public void onPlayFromSearch(@NonNull String packageName, int pid, int uid,
- @NonNull ControllerCallbackLink caller, String query, @Nullable Bundle extras) {
- }
-
- /** Stub method for ISessionCallback.notifyPlayFromUri */
- public void onPlayFromUri(@NonNull String packageName, int pid, int uid,
- @NonNull ControllerCallbackLink caller, @NonNull Uri uri, @Nullable Bundle extras) {
- }
-
- /** Stub method for ISessionCallback.notifySkipToTrack */
- public void onSkipToTrack(@NonNull String packageName, int pid, int uid,
- @NonNull ControllerCallbackLink caller, long id) {
- }
-
- /** Stub method for ISessionCallback.notifyPause */
- public void onPause(@NonNull String packageName, int pid, int uid,
- @NonNull ControllerCallbackLink caller) {
- }
-
- /** Stub method for ISessionCallback.notifyStop */
- public void onStop(@NonNull String packageName, int pid, int uid,
- @NonNull ControllerCallbackLink caller) {
- }
-
- /** Stub method for ISessionCallback.notifyNext */
- public void onNext(@NonNull String packageName, int pid, int uid,
- @NonNull ControllerCallbackLink caller) {
- }
-
- /** Stub method for ISessionCallback.notifyPrevious */
- public void onPrevious(@NonNull String packageName, int pid, int uid,
- @NonNull ControllerCallbackLink caller) {
- }
-
- /** Stub method for ISessionCallback.notifyFastForward */
- public void onFastForward(@NonNull String packageName, int pid, int uid,
- @NonNull ControllerCallbackLink caller) {
- }
-
- /** Stub method for ISessionCallback.notifyRewind */
- public void onRewind(@NonNull String packageName, int pid, int uid,
- @NonNull ControllerCallbackLink caller) {
- }
-
- /** Stub method for ISessionCallback.notifySeekTo */
- public void onSeekTo(@NonNull String packageName, int pid, int uid,
- @NonNull ControllerCallbackLink caller, long pos) {
- }
-
- /** Stub method for ISessionCallback.notifyRate */
- public void onRate(@NonNull String packageName, int pid, int uid,
- @NonNull ControllerCallbackLink caller, @NonNull Rating rating) {
- }
-
- /** Stub method for ISessionCallback.notifyCustomAction */
- public void onCustomAction(@NonNull String packageName, int pid, int uid,
- @NonNull ControllerCallbackLink caller, @NonNull String action,
- @Nullable Bundle args) {
- }
-
- /** Stub method for ISessionCallback.notifyAdjustVolume */
- public void onAdjustVolume(@NonNull String packageName, int pid, int uid,
- @NonNull ControllerCallbackLink caller, int direction) {
- }
-
- /** Stub method for ISessionCallback.notifySetVolumeTo */
- public void onSetVolumeTo(@NonNull String packageName, int pid, int uid,
- @NonNull ControllerCallbackLink caller, int value) {
- }
- }
-
- private class CallbackStubProxy extends ISessionCallback.Stub {
@Override
public void notifyCommand(String packageName, int pid, int uid,
ControllerCallbackLink caller, String command, Bundle args, ResultReceiver cb) {
ensureMediaControlPermission();
final long token = Binder.clearCallingIdentity();
try {
- mCallbackStub.onCommand(packageName, pid, uid, caller, command, args, cb);
+ MediaSessionEngine sessionImpl = mSessionImpl.get();
+ if (sessionImpl != null) {
+ sessionImpl.dispatchCommand(createRemoteUserInfo(packageName, pid, uid),
+ command, args, cb);
+ }
} finally {
Binder.restoreCallingIdentity(token);
}
@@ -684,9 +577,15 @@
ensureMediaControlPermission();
final long token = Binder.clearCallingIdentity();
try {
- mCallbackStub.onMediaButton(packageName, pid, uid, mediaButtonIntent,
- sequenceNumber, cb);
+ MediaSessionEngine sessionImpl = mSessionImpl.get();
+ if (sessionImpl != null) {
+ sessionImpl.dispatchMediaButton(
+ createRemoteUserInfo(packageName, pid, uid), mediaButtonIntent);
+ }
} finally {
+ if (cb != null) {
+ cb.send(sequenceNumber, null);
+ }
Binder.restoreCallingIdentity(token);
}
}
@@ -697,8 +596,11 @@
ensureMediaControlPermission();
final long token = Binder.clearCallingIdentity();
try {
- mCallbackStub.onMediaButtonFromController(packageName, pid, uid, caller,
- mediaButtonIntent);
+ MediaSessionEngine sessionImpl = mSessionImpl.get();
+ if (sessionImpl != null) {
+ sessionImpl.dispatchMediaButton(createRemoteUserInfo(packageName, pid, uid),
+ mediaButtonIntent);
+ }
} finally {
Binder.restoreCallingIdentity(token);
}
@@ -710,7 +612,10 @@
ensureMediaControlPermission();
final long token = Binder.clearCallingIdentity();
try {
- mCallbackStub.onPrepare(packageName, pid, uid, caller);
+ MediaSessionEngine sessionImpl = mSessionImpl.get();
+ if (sessionImpl != null) {
+ sessionImpl.dispatchPrepare(createRemoteUserInfo(packageName, pid, uid));
+ }
} finally {
Binder.restoreCallingIdentity(token);
}
@@ -722,7 +627,11 @@
ensureMediaControlPermission();
final long token = Binder.clearCallingIdentity();
try {
- mCallbackStub.onPrepareFromMediaId(packageName, pid, uid, caller, mediaId, extras);
+ MediaSessionEngine sessionImpl = mSessionImpl.get();
+ if (sessionImpl != null) {
+ sessionImpl.dispatchPrepareFromMediaId(
+ createRemoteUserInfo(packageName, pid, uid), mediaId, extras);
+ }
} finally {
Binder.restoreCallingIdentity(token);
}
@@ -734,7 +643,11 @@
ensureMediaControlPermission();
final long token = Binder.clearCallingIdentity();
try {
- mCallbackStub.onPrepareFromSearch(packageName, pid, uid, caller, query, extras);
+ MediaSessionEngine sessionImpl = mSessionImpl.get();
+ if (sessionImpl != null) {
+ sessionImpl.dispatchPrepareFromSearch(
+ createRemoteUserInfo(packageName, pid, uid), query, extras);
+ }
} finally {
Binder.restoreCallingIdentity(token);
}
@@ -746,7 +659,11 @@
ensureMediaControlPermission();
final long token = Binder.clearCallingIdentity();
try {
- mCallbackStub.onPrepareFromUri(packageName, pid, uid, caller, uri, extras);
+ MediaSessionEngine sessionImpl = mSessionImpl.get();
+ if (sessionImpl != null) {
+ sessionImpl.dispatchPrepareFromUri(
+ createRemoteUserInfo(packageName, pid, uid), uri, extras);
+ }
} finally {
Binder.restoreCallingIdentity(token);
}
@@ -758,7 +675,10 @@
ensureMediaControlPermission();
final long token = Binder.clearCallingIdentity();
try {
- mCallbackStub.onPlay(packageName, pid, uid, caller);
+ MediaSessionEngine sessionImpl = mSessionImpl.get();
+ if (sessionImpl != null) {
+ sessionImpl.dispatchPlay(createRemoteUserInfo(packageName, pid, uid));
+ }
} finally {
Binder.restoreCallingIdentity(token);
}
@@ -770,7 +690,11 @@
ensureMediaControlPermission();
final long token = Binder.clearCallingIdentity();
try {
- mCallbackStub.onPlayFromMediaId(packageName, pid, uid, caller, mediaId, extras);
+ MediaSessionEngine sessionImpl = mSessionImpl.get();
+ if (sessionImpl != null) {
+ sessionImpl.dispatchPlayFromMediaId(
+ createRemoteUserInfo(packageName, pid, uid), mediaId, extras);
+ }
} finally {
Binder.restoreCallingIdentity(token);
}
@@ -782,7 +706,11 @@
ensureMediaControlPermission();
final long token = Binder.clearCallingIdentity();
try {
- mCallbackStub.onPlayFromSearch(packageName, pid, uid, caller, query, extras);
+ MediaSessionEngine sessionImpl = mSessionImpl.get();
+ if (sessionImpl != null) {
+ sessionImpl.dispatchPlayFromSearch(
+ createRemoteUserInfo(packageName, pid, uid), query, extras);
+ }
} finally {
Binder.restoreCallingIdentity(token);
}
@@ -794,7 +722,11 @@
ensureMediaControlPermission();
final long token = Binder.clearCallingIdentity();
try {
- mCallbackStub.onPlayFromUri(packageName, pid, uid, caller, uri, extras);
+ MediaSessionEngine sessionImpl = mSessionImpl.get();
+ if (sessionImpl != null) {
+ sessionImpl.dispatchPlayFromUri(
+ createRemoteUserInfo(packageName, pid, uid), uri, extras);
+ }
} finally {
Binder.restoreCallingIdentity(token);
}
@@ -806,7 +738,11 @@
ensureMediaControlPermission();
final long token = Binder.clearCallingIdentity();
try {
- mCallbackStub.onSkipToTrack(packageName, pid, uid, caller, id);
+ MediaSessionEngine sessionImpl = mSessionImpl.get();
+ if (sessionImpl != null) {
+ sessionImpl.dispatchSkipToItem(
+ createRemoteUserInfo(packageName, pid, uid), id);
+ }
} finally {
Binder.restoreCallingIdentity(token);
}
@@ -818,7 +754,10 @@
ensureMediaControlPermission();
final long token = Binder.clearCallingIdentity();
try {
- mCallbackStub.onPause(packageName, pid, uid, caller);
+ MediaSessionEngine sessionImpl = mSessionImpl.get();
+ if (sessionImpl != null) {
+ sessionImpl.dispatchPause(createRemoteUserInfo(packageName, pid, uid));
+ }
} finally {
Binder.restoreCallingIdentity(token);
}
@@ -830,7 +769,10 @@
ensureMediaControlPermission();
final long token = Binder.clearCallingIdentity();
try {
- mCallbackStub.onStop(packageName, pid, uid, caller);
+ MediaSessionEngine sessionImpl = mSessionImpl.get();
+ if (sessionImpl != null) {
+ sessionImpl.dispatchStop(createRemoteUserInfo(packageName, pid, uid));
+ }
} finally {
Binder.restoreCallingIdentity(token);
}
@@ -842,7 +784,10 @@
ensureMediaControlPermission();
final long token = Binder.clearCallingIdentity();
try {
- mCallbackStub.onNext(packageName, pid, uid, caller);
+ MediaSessionEngine sessionImpl = mSessionImpl.get();
+ if (sessionImpl != null) {
+ sessionImpl.dispatchNext(createRemoteUserInfo(packageName, pid, uid));
+ }
} finally {
Binder.restoreCallingIdentity(token);
}
@@ -854,7 +799,10 @@
ensureMediaControlPermission();
final long token = Binder.clearCallingIdentity();
try {
- mCallbackStub.onPrevious(packageName, pid, uid, caller);
+ MediaSessionEngine sessionImpl = mSessionImpl.get();
+ if (sessionImpl != null) {
+ sessionImpl.dispatchPrevious(createRemoteUserInfo(packageName, pid, uid));
+ }
} finally {
Binder.restoreCallingIdentity(token);
}
@@ -866,7 +814,11 @@
ensureMediaControlPermission();
final long token = Binder.clearCallingIdentity();
try {
- mCallbackStub.onFastForward(packageName, pid, uid, caller);
+ MediaSessionEngine sessionImpl = mSessionImpl.get();
+ if (sessionImpl != null) {
+ sessionImpl.dispatchFastForward(
+ createRemoteUserInfo(packageName, pid, uid));
+ }
} finally {
Binder.restoreCallingIdentity(token);
}
@@ -878,7 +830,10 @@
ensureMediaControlPermission();
final long token = Binder.clearCallingIdentity();
try {
- mCallbackStub.onRewind(packageName, pid, uid, caller);
+ MediaSessionEngine sessionImpl = mSessionImpl.get();
+ if (sessionImpl != null) {
+ sessionImpl.dispatchRewind(createRemoteUserInfo(packageName, pid, uid));
+ }
} finally {
Binder.restoreCallingIdentity(token);
}
@@ -890,7 +845,11 @@
ensureMediaControlPermission();
final long token = Binder.clearCallingIdentity();
try {
- mCallbackStub.onSeekTo(packageName, pid, uid, caller, pos);
+ MediaSessionEngine sessionImpl = mSessionImpl.get();
+ if (sessionImpl != null) {
+ sessionImpl.dispatchSeekTo(
+ createRemoteUserInfo(packageName, pid, uid), pos);
+ }
} finally {
Binder.restoreCallingIdentity(token);
}
@@ -902,7 +861,11 @@
ensureMediaControlPermission();
final long token = Binder.clearCallingIdentity();
try {
- mCallbackStub.onRate(packageName, pid, uid, caller, rating);
+ MediaSessionEngine sessionImpl = mSessionImpl.get();
+ if (sessionImpl != null) {
+ sessionImpl.dispatchRate(
+ createRemoteUserInfo(packageName, pid, uid), rating);
+ }
} finally {
Binder.restoreCallingIdentity(token);
}
@@ -913,7 +876,11 @@
ensureMediaControlPermission();
final long token = Binder.clearCallingIdentity();
try {
- mCallbackStub.onCustomAction(packageName, pid, uid, caller, action, args);
+ MediaSessionEngine sessionImpl = mSessionImpl.get();
+ if (sessionImpl != null) {
+ sessionImpl.dispatchCustomAction(
+ createRemoteUserInfo(packageName, pid, uid), action, args);
+ }
} finally {
Binder.restoreCallingIdentity(token);
}
@@ -925,7 +892,11 @@
ensureMediaControlPermission();
final long token = Binder.clearCallingIdentity();
try {
- mCallbackStub.onAdjustVolume(packageName, pid, uid, caller, direction);
+ MediaSessionEngine sessionImpl = mSessionImpl.get();
+ if (sessionImpl != null) {
+ sessionImpl.dispatchAdjustVolume(
+ createRemoteUserInfo(packageName, pid, uid), direction);
+ }
} finally {
Binder.restoreCallingIdentity(token);
}
@@ -937,7 +908,11 @@
ensureMediaControlPermission();
final long token = Binder.clearCallingIdentity();
try {
- mCallbackStub.onSetVolumeTo(packageName, pid, uid, caller, value);
+ MediaSessionEngine sessionImpl = mSessionImpl.get();
+ if (sessionImpl != null) {
+ sessionImpl.dispatchSetVolumeTo(
+ createRemoteUserInfo(packageName, pid, uid), value);
+ }
} finally {
Binder.restoreCallingIdentity(token);
}
diff --git a/media/apex/java/android/media/session/SessionLink.aidl b/media/java/android/media/session/SessionLink.aidl
similarity index 100%
rename from media/apex/java/android/media/session/SessionLink.aidl
rename to media/java/android/media/session/SessionLink.aidl
diff --git a/media/apex/java/android/media/session/SessionLink.java b/media/java/android/media/session/SessionLink.java
similarity index 99%
rename from media/apex/java/android/media/session/SessionLink.java
rename to media/java/android/media/session/SessionLink.java
index 4ea7623..2331a4a 100644
--- a/media/apex/java/android/media/session/SessionLink.java
+++ b/media/java/android/media/session/SessionLink.java
@@ -18,7 +18,6 @@
import android.annotation.NonNull;
import android.annotation.Nullable;
-import android.annotation.SystemApi;
import android.app.PendingIntent;
import android.media.AudioAttributes;
import android.media.MediaMetadata;
@@ -36,7 +35,6 @@
* Handles incoming commands from {@link MediaSession}.
* @hide
*/
-@SystemApi
public final class SessionLink implements Parcelable {
public static final Parcelable.Creator<SessionLink> CREATOR =
new Parcelable.Creator<SessionLink>() {
diff --git a/media/apex/java/android/service/media/IMediaBrowserService.aidl b/media/java/android/service/media/IMediaBrowserService.aidl
similarity index 100%
rename from media/apex/java/android/service/media/IMediaBrowserService.aidl
rename to media/java/android/service/media/IMediaBrowserService.aidl
diff --git a/media/apex/java/android/service/media/IMediaBrowserServiceCallbacks.aidl b/media/java/android/service/media/IMediaBrowserServiceCallbacks.aidl
similarity index 100%
rename from media/apex/java/android/service/media/IMediaBrowserServiceCallbacks.aidl
rename to media/java/android/service/media/IMediaBrowserServiceCallbacks.aidl
diff --git a/media/apex/java/android/service/media/MediaBrowserService.java b/media/java/android/service/media/MediaBrowserService.java
similarity index 100%
rename from media/apex/java/android/service/media/MediaBrowserService.java
rename to media/java/android/service/media/MediaBrowserService.java
diff --git a/native/webview/plat_support/draw_functor.cpp b/native/webview/plat_support/draw_functor.cpp
index 6deb47f..e43a60c 100644
--- a/native/webview/plat_support/draw_functor.cpp
+++ b/native/webview/plat_support/draw_functor.cpp
@@ -177,9 +177,6 @@
webview_functor_callbacks.vk.initialize = &initializeVk;
webview_functor_callbacks.vk.draw = &drawVk;
webview_functor_callbacks.vk.postDraw = &postDrawVk;
- // TODO(boliu): Remove this once SkiaRecordingCanvas::drawWebViewFunctor
- // no longer uses GL interop.
- webview_functor_callbacks.gles.draw = &draw_gl;
break;
}
callbacks_initialized = true;
diff --git a/packages/CaptivePortalLogin/Android.bp b/packages/CaptivePortalLogin/Android.bp
new file mode 100644
index 0000000..b3e4e83
--- /dev/null
+++ b/packages/CaptivePortalLogin/Android.bp
@@ -0,0 +1,27 @@
+//
+// Copyright (C) 2019 The Android Open Source Project
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+android_app {
+ name: "CaptivePortalLogin",
+ srcs: ["src/**/*.java"],
+ platform_apis: true,
+ certificate: "platform",
+ static_libs: [
+ "androidx.legacy_legacy-support-v4",
+ "metrics-constants-protos",
+ ],
+ manifest: "AndroidManifest.xml",
+}
diff --git a/packages/CaptivePortalLogin/Android.mk b/packages/CaptivePortalLogin/Android.mk
deleted file mode 100644
index 8c63f45..0000000
--- a/packages/CaptivePortalLogin/Android.mk
+++ /dev/null
@@ -1,14 +0,0 @@
-LOCAL_PATH:= $(call my-dir)
-include $(CLEAR_VARS)
-
-LOCAL_MODULE_TAGS := optional
-LOCAL_USE_AAPT2 := true
-LOCAL_STATIC_ANDROID_LIBRARIES := androidx.legacy_legacy-support-v4
-
-LOCAL_SRC_FILES := $(call all-java-files-under, src)
-
-LOCAL_PACKAGE_NAME := CaptivePortalLogin
-LOCAL_PRIVATE_PLATFORM_APIS := true
-LOCAL_CERTIFICATE := platform
-
-include $(BUILD_PACKAGE)
diff --git a/packages/CaptivePortalLogin/AndroidManifest.xml b/packages/CaptivePortalLogin/AndroidManifest.xml
index 5ab6632..e15dca0 100644
--- a/packages/CaptivePortalLogin/AndroidManifest.xml
+++ b/packages/CaptivePortalLogin/AndroidManifest.xml
@@ -21,9 +21,10 @@
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
- <uses-permission android:name="android.permission.CONNECTIVITY_INTERNAL" />
- <uses-permission android:name="android.permission.NETWORK_BYPASS_PRIVATE_DNS" />
+ <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
+ <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.NETWORK_SETTINGS" />
+ <uses-permission android:name="android.permission.NETWORK_BYPASS_PRIVATE_DNS" />
<application android:label="@string/app_name"
android:usesCleartextTraffic="true"
diff --git a/packages/CaptivePortalLogin/res/layout/ssl_error_msg.xml b/packages/CaptivePortalLogin/res/layout/ssl_error_msg.xml
deleted file mode 100644
index d460041..0000000
--- a/packages/CaptivePortalLogin/res/layout/ssl_error_msg.xml
+++ /dev/null
@@ -1,28 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2018 The Android Open Source Project
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-
-<TextView
- xmlns:android="http://schemas.android.com/apk/res/android"
- android:id="@+id/ssl_error_msg"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:textAppearance="?android:attr/textAppearanceSmall"
- android:layout_marginStart="20dip"
- android:layout_marginEnd="20dip"
- android:gravity="center_vertical"
- android:layout_marginBottom="4dip"
- android:layout_marginTop="4dip" />
-
diff --git a/packages/CaptivePortalLogin/res/layout/ssl_warning.xml b/packages/CaptivePortalLogin/res/layout/ssl_warning.xml
index ffd57a4..ce05e78 100644
--- a/packages/CaptivePortalLogin/res/layout/ssl_warning.xml
+++ b/packages/CaptivePortalLogin/res/layout/ssl_warning.xml
@@ -78,7 +78,18 @@
android:id="@+id/certificate_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
+ android:orientation="vertical"
android:layout_marginBottom="16dip" >
+ <TextView
+ android:id="@+id/ssl_error_msg"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:textAppearance="?android:attr/textAppearanceSmall"
+ android:layout_marginStart="20dip"
+ android:layout_marginEnd="20dip"
+ android:gravity="center_vertical"
+ android:layout_marginBottom="4dip"
+ android:layout_marginTop="16dip" />
</LinearLayout>
</ScrollView>
diff --git a/packages/CaptivePortalLogin/src/com/android/captiveportallogin/CaptivePortalLoginActivity.java b/packages/CaptivePortalLogin/src/com/android/captiveportallogin/CaptivePortalLoginActivity.java
index 0a571c5..ce627ce 100644
--- a/packages/CaptivePortalLogin/src/com/android/captiveportallogin/CaptivePortalLoginActivity.java
+++ b/packages/CaptivePortalLogin/src/com/android/captiveportallogin/CaptivePortalLoginActivity.java
@@ -20,7 +20,7 @@
import android.app.Activity;
import android.app.AlertDialog;
-import android.app.LoadedApk;
+import android.app.Application;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
@@ -37,8 +37,9 @@
import android.net.http.SslCertificate;
import android.net.http.SslError;
import android.net.wifi.WifiInfo;
-import android.os.Build;
+import android.net.wifi.WifiManager;
import android.os.Bundle;
+import android.os.SystemProperties;
import android.text.TextUtils;
import android.util.ArrayMap;
import android.util.Log;
@@ -96,6 +97,7 @@
private CaptivePortal mCaptivePortal;
private NetworkCallback mNetworkCallback;
private ConnectivityManager mCm;
+ private WifiManager mWifiManager;
private boolean mLaunchBrowser = false;
private MyWebViewClient mWebViewClient;
private SwipeRefreshLayout mSwipeRefreshLayout;
@@ -109,7 +111,8 @@
mCaptivePortal = getIntent().getParcelableExtra(ConnectivityManager.EXTRA_CAPTIVE_PORTAL);
logMetricsEvent(MetricsEvent.ACTION_CAPTIVE_PORTAL_LOGIN_ACTIVITY);
- mCm = ConnectivityManager.from(this);
+ mCm = getSystemService(ConnectivityManager.class);
+ mWifiManager = getSystemService(WifiManager.class);
mNetwork = getIntent().getParcelableExtra(ConnectivityManager.EXTRA_NETWORK);
mUserAgent =
getIntent().getStringExtra(ConnectivityManager.EXTRA_CAPTIVE_PORTAL_USER_AGENT);
@@ -151,7 +154,6 @@
// Also initializes proxy system properties.
mNetwork = mNetwork.getPrivateDnsBypassingCopy();
mCm.bindProcessToNetwork(mNetwork);
- mCm.setProcessDefaultNetworkForHostResolution(mNetwork);
// Proxy system properties must be initialized before setContentView is called because
// setContentView initializes the WebView logic which in turn reads the system properties.
@@ -190,9 +192,12 @@
// Find WebView's proxy BroadcastReceiver and prompt it to read proxy system properties.
private void setWebViewProxy() {
- LoadedApk loadedApk = getApplication().mLoadedApk;
+ // TODO: migrate to androidx WebView proxy setting API as soon as it is finalized
try {
- Field receiversField = LoadedApk.class.getDeclaredField("mReceivers");
+ final Field loadedApkField = Application.class.getDeclaredField("mLoadedApk");
+ final Class<?> loadedApkClass = loadedApkField.getType();
+ final Object loadedApk = loadedApkField.get(getApplication());
+ Field receiversField = loadedApkClass.getDeclaredField("mReceivers");
receiversField.setAccessible(true);
ArrayMap receivers = (ArrayMap) receiversField.get(loadedApk);
for (Object receiverMap : receivers.values()) {
@@ -333,7 +338,11 @@
private static String sanitizeURL(URL url) {
// In non-Debug build, only show host to avoid leaking private info.
- return Build.IS_DEBUGGABLE ? Objects.toString(url) : host(url);
+ return isDebuggable() ? Objects.toString(url) : host(url);
+ }
+
+ private static boolean isDebuggable() {
+ return SystemProperties.getInt("ro.debuggable", 0) == 1;
}
private void testForCaptivePortal() {
@@ -586,19 +595,18 @@
}
private void setViewSecurityCertificate(LinearLayout certificateLayout, SslError error) {
+ ((TextView) certificateLayout.findViewById(R.id.ssl_error_msg))
+ .setText(sslErrorMessage(error));
SslCertificate cert = error.getCertificate();
-
- View certificateView = cert.inflateCertificateView(CaptivePortalLoginActivity.this);
- final LinearLayout placeholder = (LinearLayout) certificateView
- .findViewById(com.android.internal.R.id.placeholder);
- LayoutInflater factory = LayoutInflater.from(CaptivePortalLoginActivity.this);
-
- TextView textView = (TextView) factory.inflate(
- R.layout.ssl_error_msg, placeholder, false);
- textView.setText(sslErrorMessage(error));
- placeholder.addView(textView);
-
- certificateLayout.addView(certificateView);
+ // TODO: call the method directly once inflateCertificateView is @SystemApi
+ try {
+ final View certificateView = (View) SslCertificate.class.getMethod(
+ "inflateCertificateView", Context.class)
+ .invoke(cert, CaptivePortalLoginActivity.this);
+ certificateLayout.addView(certificateView);
+ } catch (ReflectiveOperationException | SecurityException e) {
+ Log.e(TAG, "Could not create certificate view", e);
+ }
}
}
@@ -619,11 +627,30 @@
private String getHeaderTitle() {
NetworkCapabilities nc = mCm.getNetworkCapabilities(mNetwork);
- if (nc == null || TextUtils.isEmpty(nc.getSSID())
- || !nc.hasTransport(NetworkCapabilities.TRANSPORT_WIFI)) {
+ final String ssid = getSsid();
+ if (TextUtils.isEmpty(ssid)
+ || nc == null || !nc.hasTransport(NetworkCapabilities.TRANSPORT_WIFI)) {
return getString(R.string.action_bar_label);
}
- return getString(R.string.action_bar_title, WifiInfo.removeDoubleQuotes(nc.getSSID()));
+ return getString(R.string.action_bar_title, ssid);
+ }
+
+ // TODO: remove once SSID is obtained from NetworkCapabilities
+ private String getSsid() {
+ if (mWifiManager == null) {
+ return null;
+ }
+ final WifiInfo wifiInfo = mWifiManager.getConnectionInfo();
+ return removeDoubleQuotes(wifiInfo.getSSID());
+ }
+
+ private static String removeDoubleQuotes(String string) {
+ if (string == null) return null;
+ final int length = string.length();
+ if ((length > 1) && (string.charAt(0) == '"') && (string.charAt(length - 1) == '"')) {
+ return string.substring(1, length - 1);
+ }
+ return string;
}
private String getHeaderSubtitle(URL url) {
diff --git a/packages/CarSystemUI/res/values/integers_car.xml b/packages/CarSystemUI/res/values/integers_car.xml
index 777283d..be2cb0d8 100644
--- a/packages/CarSystemUI/res/values/integers_car.xml
+++ b/packages/CarSystemUI/res/values/integers_car.xml
@@ -23,7 +23,7 @@
<!-- Number of milliseconds user can spend driving with the keyguard up. After that, we switch to Guest. -->
<!-- If the number is negative, the feature is disabled.
If it's zero, we switch to guest immediately as we start driving. -->
- <integer name="driving_on_keyguard_timeout_ms">30000</integer>
+ <integer name="driving_on_keyguard_timeout_ms">-1</integer>
<!--Percentage of the screen height, from the bottom, that a notification panel being
partially closed at will result in it remaining open if released-->
diff --git a/packages/ExtServices/Android.bp b/packages/ExtServices/Android.bp
new file mode 100644
index 0000000..77972fe
--- /dev/null
+++ b/packages/ExtServices/Android.bp
@@ -0,0 +1,11 @@
+android_library {
+ name: "ExtServices-core",
+ srcs: [
+ "src/**/*.java",
+ ],
+ resource_dirs: [
+ "res",
+ ],
+
+ manifest: "AndroidManifest.xml",
+}
\ No newline at end of file
diff --git a/packages/ExtServices/tests/Android.bp b/packages/ExtServices/tests/Android.bp
new file mode 100644
index 0000000..5de4548
--- /dev/null
+++ b/packages/ExtServices/tests/Android.bp
@@ -0,0 +1,26 @@
+android_test {
+ name: "ExtServicesUnitTests",
+
+ // Include all test java files.
+ srcs: ["src/**/*.java"],
+
+ // We only want this apk build for tests.
+ certificate: "platform",
+
+ libs: [
+ "android.test.runner",
+ "android.test.base",
+ ],
+
+ static_libs: [
+ "ExtServices-core",
+ "android-support-test",
+ "mockito-target-minus-junit4",
+ "espresso-core",
+ "truth-prebuilt",
+ "testables",
+ "testng",
+ ],
+
+ platform_apis: true,
+}
\ No newline at end of file
diff --git a/packages/ExtServices/tests/Android.mk b/packages/ExtServices/tests/Android.mk
deleted file mode 100644
index a57fa94..0000000
--- a/packages/ExtServices/tests/Android.mk
+++ /dev/null
@@ -1,26 +0,0 @@
-LOCAL_PATH:= $(call my-dir)
-include $(CLEAR_VARS)
-
-# We only want this apk build for tests.
-LOCAL_MODULE_TAGS := tests
-LOCAL_CERTIFICATE := platform
-
-LOCAL_JAVA_LIBRARIES := android.test.runner android.test.base
-
-LOCAL_STATIC_JAVA_LIBRARIES := \
- android-support-test \
- mockito-target-minus-junit4 \
- espresso-core \
- truth-prebuilt \
- testables \
- testng
-
-# Include all test java files.
-LOCAL_SRC_FILES := $(call all-java-files-under, src)
-
-LOCAL_PACKAGE_NAME := ExtServicesUnitTests
-LOCAL_PRIVATE_PLATFORM_APIS := true
-
-LOCAL_INSTRUMENTATION_FOR := ExtServices
-
-include $(BUILD_PACKAGE)
diff --git a/packages/ExtServices/tests/AndroidManifest.xml b/packages/ExtServices/tests/AndroidManifest.xml
index ddf725b..3cf1527 100644
--- a/packages/ExtServices/tests/AndroidManifest.xml
+++ b/packages/ExtServices/tests/AndroidManifest.xml
@@ -24,7 +24,7 @@
</application>
<instrumentation android:name="android.support.test.runner.AndroidJUnitRunner"
- android:targetPackage="android.ext.services"
+ android:targetPackage="android.ext.services.tests.unit"
android:label="ExtServices Test Cases">
</instrumentation>
diff --git a/packages/ExtServices/tests/src/android/ext/services/notification/NotificationCategorizerTest.java b/packages/ExtServices/tests/src/android/ext/services/notification/NotificationCategorizerTest.java
index 12908e6..c59885e 100644
--- a/packages/ExtServices/tests/src/android/ext/services/notification/NotificationCategorizerTest.java
+++ b/packages/ExtServices/tests/src/android/ext/services/notification/NotificationCategorizerTest.java
@@ -180,7 +180,7 @@
assertFalse(nc.shouldSilence(NotificationCategorizer.CATEGORY_SYSTEM));
when(mSbn.getUid()).thenReturn(FIRST_APPLICATION_UID);
- assertEquals(NotificationCategorizer.CATEGORY_EVERYTHING_ELSE, nc.getCategory(mEntry));
+ assertEquals(NotificationCategorizer.CATEGORY_HIGH, nc.getCategory(mEntry));
}
@Test
diff --git a/packages/NetworkStack/Android.bp b/packages/NetworkStack/Android.bp
index b0522f2..d656593 100644
--- a/packages/NetworkStack/Android.bp
+++ b/packages/NetworkStack/Android.bp
@@ -41,4 +41,5 @@
"NetworkStackLib"
],
manifest: "AndroidManifest.xml",
+ required: ["NetworkStackPermissionStub"],
}
\ No newline at end of file
diff --git a/packages/NetworkStack/AndroidManifest.xml b/packages/NetworkStack/AndroidManifest.xml
index 5ab833b..ac55bfa 100644
--- a/packages/NetworkStack/AndroidManifest.xml
+++ b/packages/NetworkStack/AndroidManifest.xml
@@ -25,6 +25,8 @@
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.CONNECTIVITY_INTERNAL" />
<uses-permission android:name="android.permission.NETWORK_SETTINGS" />
+ <!-- Signature permission defined in NetworkStackStub -->
+ <uses-permission android:name="android.permission.MAINLINE_NETWORK_STACK" />
<!-- Launch captive portal app as specific user -->
<uses-permission android:name="android.permission.INTERACT_ACROSS_USERS_FULL" />
<uses-permission android:name="android.permission.NETWORK_STACK" />
diff --git a/packages/NetworkStack/src/com/android/server/connectivity/NetworkMonitor.java b/packages/NetworkStack/src/com/android/server/connectivity/NetworkMonitor.java
index b34efc4..dbffa6d 100644
--- a/packages/NetworkStack/src/com/android/server/connectivity/NetworkMonitor.java
+++ b/packages/NetworkStack/src/com/android/server/connectivity/NetworkMonitor.java
@@ -109,6 +109,8 @@
private static final boolean DBG = true;
private static final boolean VDBG = false;
private static final boolean VDBG_STALL = Log.isLoggable(TAG, Log.DEBUG);
+ // TODO: use another permission for CaptivePortalLoginActivity once it has its own certificate
+ private static final String PERMISSION_NETWORK_SETTINGS = "android.permission.NETWORK_SETTINGS";
// Default configuration values for captive portal detection probes.
// TODO: append a random length parameter to the default HTTPS url.
// TODO: randomize browser version ids in the default User-Agent String.
@@ -682,7 +684,7 @@
public void appResponse(int response) {
if (response == APP_RETURN_WANTED_AS_IS) {
mContext.enforceCallingPermission(
- android.Manifest.permission.CONNECTIVITY_INTERNAL,
+ PERMISSION_NETWORK_SETTINGS,
"CaptivePortal");
}
sendMessage(CMD_CAPTIVE_PORTAL_APP_FINISHED, response);
@@ -692,7 +694,7 @@
public void logEvent(int eventId, String packageName)
throws RemoteException {
mContext.enforceCallingPermission(
- android.Manifest.permission.CONNECTIVITY_INTERNAL,
+ PERMISSION_NETWORK_SETTINGS,
"CaptivePortal");
mCallback.logCaptivePortalLoginEvent(eventId, packageName);
}
diff --git a/packages/NetworkStack/src/com/android/server/util/PermissionUtil.java b/packages/NetworkStack/src/com/android/server/util/PermissionUtil.java
index 82bf038..f6eb900 100644
--- a/packages/NetworkStack/src/com/android/server/util/PermissionUtil.java
+++ b/packages/NetworkStack/src/com/android/server/util/PermissionUtil.java
@@ -19,6 +19,7 @@
import static android.os.Binder.getCallingUid;
import android.os.Process;
+import android.os.UserHandle;
/**
* Utility class to check calling permissions on the network stack.
@@ -32,7 +33,7 @@
public static void checkNetworkStackCallingPermission() {
// TODO: check that the calling PID is the system server.
final int caller = getCallingUid();
- if (caller != Process.SYSTEM_UID && caller != Process.BLUETOOTH_UID) {
+ if (caller != Process.SYSTEM_UID && UserHandle.getAppId(caller) != Process.BLUETOOTH_UID) {
throw new SecurityException("Invalid caller: " + caller);
}
}
diff --git a/packages/NetworkStackPermissionStub/Android.bp b/packages/NetworkStackPermissionStub/Android.bp
new file mode 100644
index 0000000..94870c9
--- /dev/null
+++ b/packages/NetworkStackPermissionStub/Android.bp
@@ -0,0 +1,27 @@
+//
+// Copyright (C) 2019 The Android Open Source Project
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+// Stub APK to define permissions for NetworkStack
+android_app {
+ name: "NetworkStackPermissionStub",
+ // TODO: mark app as hasCode=false in manifest once soong stops complaining about apps without
+ // a classes.dex.
+ srcs: ["src/**/*.java"],
+ platform_apis: true,
+ certificate: "platform",
+ privileged: true,
+ manifest: "AndroidManifest.xml",
+}
diff --git a/packages/NetworkStackPermissionStub/AndroidManifest.xml b/packages/NetworkStackPermissionStub/AndroidManifest.xml
new file mode 100644
index 0000000..2ccf5ff
--- /dev/null
+++ b/packages/NetworkStackPermissionStub/AndroidManifest.xml
@@ -0,0 +1,36 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+/*
+ * Copyright (C) 2019 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+-->
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
+ package="com.android.mainline.networkstack.permissionstub">
+ <!--
+ This package only exists to define the below permissions, and enforce that they are only
+ granted to apps sharing the same signature.
+ Permissions defined here are intended to be used only by the NetworkStack: both
+ NetworkStack and this stub APK are to be signed with a dedicated certificate to ensure
+ that, with the below permissions being signature permissions.
+
+ This APK *must* be installed, even if the NetworkStack app is not installed, because otherwise,
+ any application will be able to define this permission and the system will give that application
+ full access to the network stack.
+ -->
+ <permission android:name="android.permission.MAINLINE_NETWORK_STACK"
+ android:protectionLevel="signature"/>
+
+ <application android:name="com.android.server.NetworkStackPermissionStub"/>
+</manifest>
\ No newline at end of file
diff --git a/packages/NetworkStackPermissionStub/src/com/android/server/NetworkStackPermissionStub.java b/packages/NetworkStackPermissionStub/src/com/android/server/NetworkStackPermissionStub.java
new file mode 100644
index 0000000..01e59d2
--- /dev/null
+++ b/packages/NetworkStackPermissionStub/src/com/android/server/NetworkStackPermissionStub.java
@@ -0,0 +1,26 @@
+/*
+ * Copyright (C) 2019 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.server;
+
+import android.app.Application;
+
+/**
+ * Empty application for NetworkStackStub that only exists because soong builds complain if APKs
+ * have no source file.
+ */
+public class NetworkStackPermissionStub extends Application {
+}
diff --git a/packages/SettingsLib/OWNERS b/packages/SettingsLib/OWNERS
index d188c65..d879087 100644
--- a/packages/SettingsLib/OWNERS
+++ b/packages/SettingsLib/OWNERS
@@ -4,7 +4,7 @@
dehboxturtle@google.com
dhnishi@google.com
dling@google.com
-dsandler@google.com
+dsandler@android.com
evanlaird@google.com
jackqdyulei@google.com
jmonk@google.com
diff --git a/packages/SettingsLib/res/values/strings.xml b/packages/SettingsLib/res/values/strings.xml
index ec70f8c..191bd8f 100644
--- a/packages/SettingsLib/res/values/strings.xml
+++ b/packages/SettingsLib/res/values/strings.xml
@@ -106,7 +106,7 @@
<!-- Status message of Wi-Fi when network has matching passpoint credentials. [CHAR LIMIT=NONE] -->
<string name="available_via_passpoint">Available via %1$s</string>
<!-- Status message of OSU Provider network when not connected. [CHAR LIMIT=NONE] -->
- <string name="tap_to_set_up">Tap to set up</string>
+ <string name="tap_to_sign_up">Tap to sign up</string>
<!-- Package name for Settings app-->
<string name="settings_package" translatable="false">com.android.settings</string>
<!-- Package name for Certinstaller app-->
@@ -129,78 +129,16 @@
<!-- Status message of Wi-Fi when an available network is a carrier network. [CHAR LIMIT=NONE] -->
<string name="available_via_carrier">Available via %1$s</string>
- <!-- Status message of OSU Provider on receiving OSU_FAILURE_AP_CONNECTION. [CHAR LIMIT=NONE] -->
- <string name="osu_failure_ap_connection">Connection failed</string>
- <!-- Status message of OSU Provider on receiving OSU_FAILURE_SERVER_URL_INVALID. [CHAR LIMIT=NONE] -->
- <string name="osu_failure_server_url_invalid">Invalid OSU server URL</string>
- <!-- Status message of OSU Provider on receiving OSU_FAILURE_SERVER_CONNECTION. [CHAR LIMIT=NONE] -->
- <string name="osu_failure_server_connection">OSU server connection failed</string>
- <!-- Status message of OSU Provider on receiving OSU_FAILURE_SERVER_VALIDATION. [CHAR LIMIT=NONE] -->
- <string name="osu_failure_server_validation">OSU server validation failed</string>
- <!-- Status message of OSU Provider on receiving OSU_FAILURE_SERVICE_PROVIDER_VERIFICATION. [CHAR LIMIT=NONE] -->
- <string name="osu_failure_service_provider_verification">Invalid OSU server certificate</string>
- <!-- Status message of OSU Provider on receiving OSU_FAILURE_PROVISIONING_ABORTED. [CHAR LIMIT=NONE] -->
- <string name="osu_failure_provisioning_aborted">Provisioning aborted</string>
- <!-- Status message of OSU Provider on receiving OSU_FAILURE_PROVISIONING_NOT_AVAILABLE. [CHAR LIMIT=NONE] -->
- <string name="osu_failure_provisioning_not_available">Provisioning not available</string>
- <!-- Status message of OSU Provider on receiving OSU_FAILURE_INVALID_SERVER_URL. [CHAR LIMIT=NONE] -->
- <string name="osu_failure_invalid_server_url">Invalid OSU server URL</string>
- <!-- Status message of OSU Provider on receiving OSU_FAILURE_UNEXPECTED_COMMAND_TYPE. [CHAR LIMIT=NONE] -->
- <string name="osu_failure_unexpected_command_type">Unexpected command type</string>
- <!-- Status message of OSU Provider on receiving OSU_FAILURE_UNEXPECTED_SOAP_MESSAGE_TYPE. [CHAR LIMIT=NONE] -->
- <string name="osu_failure_unexpected_soap_message_type">Unexpected SOAP message type</string>
- <!-- Status message of OSU Provider on receiving OSU_FAILURE_SOAP_MESSAGE_EXCHANGE. [CHAR LIMIT=NONE] -->
- <string name="osu_failure_soap_message_exchange">SOAP message exchange failed</string>
- <!-- Status message of OSU Provider on receiving OSU_FAILURE_START_REDIRECT_LISTENER. [CHAR LIMIT=NONE] -->
- <string name="osu_failure_start_redirect_listener">Redirect listener failed to start</string>
- <!-- Status message of OSU Provider on receiving OSU_FAILURE_TIMED_OUT_REDIRECT_LISTENER. [CHAR LIMIT=NONE] -->
- <string name="osu_failure_timed_out_redirect_listener">Timed out waiting for redirect</string>
- <!-- Status message of OSU Provider on receiving OSU_FAILURE_NO_OSU_ACTIVITY_FOUND. [CHAR LIMIT=NONE] -->
- <string name="osu_failure_no_osu_activity_found">No OSU activity found</string>
- <!-- Status message of OSU Provider on receiving OSU_FAILURE_UNEXPECTED_SOAP_MESSAGE_STATUS. [CHAR LIMIT=NONE] -->
- <string name="osu_failure_unexpected_soap_message_status">Unexpected SOAP message status</string>
- <!-- Status message of OSU Provider on receiving OSU_FAILURE_NO_PPS_MO. [CHAR LIMIT=NONE] -->
- <string name="osu_failure_no_pps_mo">Failed to find PPS-MO</string>
- <!-- Status message of OSU Provider on receiving OSU_FAILURE_NO_AAA_SERVER_TRUST_ROOT_NODE. [CHAR LIMIT=NONE] -->
- <string name="osu_failure_no_aaa_server_trust_root_node">Failed to find trust root node for AAA server</string>
- <!-- Status message of OSU Provider on receiving OSU_FAILURE_NO_REMEDIATION_SERVER_TRUST_ROOT_NODE. [CHAR LIMIT=NONE] -->
- <string name="osu_failure_no_remediation_server_trust_root_node">Failed to find trust root node for remediation server</string>
- <!-- Status message of OSU Provider on receiving OSU_FAILURE_NO_POLICY_SERVER_TRUST_ROOT_NODE. [CHAR LIMIT=NONE] -->
- <string name="osu_failure_no_policy_server_trust_root_node">Failed to find trust root node for policy server</string>
- <!-- Status message of OSU Provider on receiving OSU_FAILURE_RETRIEVE_TRUST_ROOT_CERTIFICATES. [CHAR LIMIT=NONE] -->
- <string name="osu_failure_retrieve_trust_root_certificates">Failed to retrieve trust root certificates</string>
- <!-- Status message of OSU Provider on receiving OSU_FAILURE_NO_AAA_TRUST_ROOT_CERTIFICATE. [CHAR LIMIT=NONE] -->
- <string name="osu_failure_no_aaa_trust_root_certificate">Failed to find trust root certificate for AAA server</string>
- <!-- Status message of OSU Provider on receiving OSU_FAILURE_ADD_PASSPOINT_CONFIGURATION. [CHAR LIMIT=NONE] -->
- <string name="osu_failure_add_passpoint_configuration">Failed to add PassPoint configuration</string>
- <!-- Status message of OSU Provider on receiving OSU_FAILURE_OSU_PROVIDER_NOT_FOUND. [CHAR LIMIT=NONE] -->
- <string name="osu_failure_osu_provider_not_found">Failed to find an OSU provider</string>
-
- <!-- Status message of OSU Provider on receiving OSU_STATUS_AP_CONNECTING. [CHAR LIMIT=NONE] -->
- <string name="osu_status_ap_connecting">Connecting</string>
- <!-- Status message of OSU Provider on receiving OSU_STATUS_AP_CONNECTED. [CHAR LIMIT=NONE] -->
- <string name="osu_status_ap_connected">Connected</string>
- <!-- Status message of OSU Provider on receiving OSU_STATUS_SERVER_CONNECTING. [CHAR LIMIT=NONE] -->
- <string name="osu_status_server_connecting">Connecting to OSU server</string>
- <!-- Status message of OSU Provider on receiving OSU_STATUS_SERVER_VALIDATED. [CHAR LIMIT=NONE] -->
- <string name="osu_status_server_validated">OSU server validated</string>
- <!-- Status message of OSU Provider on receiving OSU_STATUS_SERVER_CONNECTED. [CHAR LIMIT=NONE] -->
- <string name="osu_status_server_connected">Connected to OSU server</string>
- <!-- Status message of OSU Provider on receiving OSU_STATUS_INIT_SOAP_EXCHANGE. [CHAR LIMIT=NONE] -->
- <string name="osu_status_init_soap_exchange">Initial SOAP exchange</string>
- <!-- Status message of OSU Provider on receiving OSU_STATUS_WAITING_FOR_REDIRECT_RESPONSE. [CHAR LIMIT=NONE] -->
- <string name="osu_status_waiting_for_redirect_response">Waiting for redirect response</string>
- <!-- Status message of OSU Provider on receiving OSU_STATUS_REDIRECT_RESPONSE_RECEIVED. [CHAR LIMIT=NONE] -->
- <string name="osu_status_redirect_response_received">Received redirect response</string>
- <!-- Status message of OSU Provider on receiving OSU_STATUS_SECOND_SOAP_EXCHANGE. [CHAR LIMIT=NONE] -->
- <string name="osu_status_second_soap_exchange">Second SOAP exchange</string>
- <!-- Status message of OSU Provider on receiving OSU_STATUS_THIRD_SOAP_EXCHANGE. [CHAR LIMIT=NONE] -->
- <string name="osu_status_third_soap_exchange">Third SOAP exchange</string>
- <!-- Status message of OSU Provider on receiving OSU_STATUS_RETRIEVING_TRUST_ROOT_CERTS. [CHAR LIMIT=NONE] -->
- <string name="osu_status_retrieving_trust_root_certs">Retrieving trust root certificates</string>
-
+ <!-- Status message of OSU Provider upon initiating provisioning flow [CHAR LIMIT=NONE] -->
+ <string name="osu_opening_provider">Opening <xliff:g id="passpointProvider" example="Passpoint Provider">%1$s</xliff:g></string>
+ <!-- Status message of OSU Provider when connection fails [CHAR LIMIT=NONE] -->
+ <string name="osu_connect_failed">Couldn\u2019t connect</string>
+ <!-- Status message of OSU Provider after user completes provisioning flow [CHAR LIMIT=NONE] -->
+ <string name="osu_completing_sign_up">Completing sign-up\u2026</string>
+ <!-- Status message of OSU Provider when sign up could not be completed [CHAR LIMIT=NONE] -->
+ <string name="osu_sign_up_failed">Couldn\u2019t complete sign-up. Tap to try again.</string>
<!-- Status message of OSU Provider on completing provisioning. [CHAR LIMIT=NONE] -->
- <string name="osu_provisioning_complete">Provisioning complete</string>
+ <string name="osu_sign_up_complete">Sign-up complete. Connecting\u2026</string>
<!-- Speed label for very slow network speed -->
<string name="speed_label_very_slow">Very Slow</string>
diff --git a/packages/SettingsLib/src/com/android/settingslib/wifi/AccessPoint.java b/packages/SettingsLib/src/com/android/settingslib/wifi/AccessPoint.java
index c74d9ff..ed8b487 100644
--- a/packages/SettingsLib/src/com/android/settingslib/wifi/AccessPoint.java
+++ b/packages/SettingsLib/src/com/android/settingslib/wifi/AccessPoint.java
@@ -888,13 +888,13 @@
if (isOsuProvider()) {
if (mOsuProvisioningComplete) {
- summary.append(mContext.getString(R.string.osu_provisioning_complete));
+ summary.append(mContext.getString(R.string.osu_sign_up_complete));
} else if (mOsuFailure != null) {
summary.append(mOsuFailure);
} else if (mOsuStatus != null) {
summary.append(mOsuStatus);
} else {
- summary.append(mContext.getString(R.string.tap_to_set_up));
+ summary.append(mContext.getString(R.string.tap_to_sign_up));
}
} else if (isActive()) {
if (isPasspoint()) {
@@ -1554,91 +1554,12 @@
* All methods are invoked on the Main Thread
*/
private class AccessPointProvisioningCallback extends ProvisioningCallback {
- // TODO: Remove logs and implement summary changing logic for these provisioning callbacks.
@Override
@MainThread public void onProvisioningFailure(int status) {
- switch (status) {
- case OSU_FAILURE_AP_CONNECTION:
- mOsuFailure = mContext.getString(R.string.osu_failure_ap_connection);
- break;
- case OSU_FAILURE_SERVER_URL_INVALID:
- mOsuFailure = mContext.getString(R.string.osu_failure_server_url_invalid);
- break;
- case OSU_FAILURE_SERVER_CONNECTION:
- mOsuFailure = mContext.getString(R.string.osu_failure_server_connection);
- break;
- case OSU_FAILURE_SERVER_VALIDATION:
- mOsuFailure = mContext.getString(R.string.osu_failure_server_validation);
- break;
- case OSU_FAILURE_SERVICE_PROVIDER_VERIFICATION:
- mOsuFailure = mContext.getString(
- R.string.osu_failure_service_provider_verification);
- break;
- case OSU_FAILURE_PROVISIONING_ABORTED:
- mOsuFailure = mContext.getString(R.string.osu_failure_provisioning_aborted);
- break;
- case OSU_FAILURE_PROVISIONING_NOT_AVAILABLE:
- mOsuFailure = mContext.getString(
- R.string.osu_failure_provisioning_not_available);
- break;
- case OSU_FAILURE_INVALID_URL_FORMAT_FOR_OSU:
- mOsuFailure = mContext.getString(R.string.osu_failure_invalid_server_url);
- break;
- case OSU_FAILURE_UNEXPECTED_COMMAND_TYPE:
- mOsuFailure = mContext.getString(R.string.osu_failure_unexpected_command_type);
- break;
- case OSU_FAILURE_UNEXPECTED_SOAP_MESSAGE_TYPE:
- mOsuFailure = mContext.getString(
- R.string.osu_failure_unexpected_soap_message_type);
- break;
- case OSU_FAILURE_SOAP_MESSAGE_EXCHANGE:
- mOsuFailure = mContext.getString(R.string.osu_failure_soap_message_exchange);
- break;
- case OSU_FAILURE_START_REDIRECT_LISTENER:
- mOsuFailure = mContext.getString(R.string.osu_failure_start_redirect_listener);
- break;
- case OSU_FAILURE_TIMED_OUT_REDIRECT_LISTENER:
- mOsuFailure = mContext.getString(
- R.string.osu_failure_timed_out_redirect_listener);
- break;
- case OSU_FAILURE_NO_OSU_ACTIVITY_FOUND:
- mOsuFailure = mContext.getString(R.string.osu_failure_no_osu_activity_found);
- break;
- case OSU_FAILURE_UNEXPECTED_SOAP_MESSAGE_STATUS:
- mOsuFailure = mContext.getString(
- R.string.osu_failure_unexpected_soap_message_status);
- break;
- case OSU_FAILURE_NO_PPS_MO:
- mOsuFailure = mContext.getString(
- R.string.osu_failure_no_pps_mo);
- break;
- case OSU_FAILURE_NO_AAA_SERVER_TRUST_ROOT_NODE:
- mOsuFailure = mContext.getString(
- R.string.osu_failure_no_aaa_server_trust_root_node);
- break;
- case OSU_FAILURE_NO_REMEDIATION_SERVER_TRUST_ROOT_NODE:
- mOsuFailure = mContext.getString(
- R.string.osu_failure_no_remediation_server_trust_root_node);
- break;
- case OSU_FAILURE_NO_POLICY_SERVER_TRUST_ROOT_NODE:
- mOsuFailure = mContext.getString(
- R.string.osu_failure_no_policy_server_trust_root_node);
- break;
- case OSU_FAILURE_RETRIEVE_TRUST_ROOT_CERTIFICATES:
- mOsuFailure = mContext.getString(
- R.string.osu_failure_retrieve_trust_root_certificates);
- break;
- case OSU_FAILURE_NO_AAA_TRUST_ROOT_CERTIFICATE:
- mOsuFailure = mContext.getString(
- R.string.osu_failure_no_aaa_trust_root_certificate);
- break;
- case OSU_FAILURE_ADD_PASSPOINT_CONFIGURATION:
- mOsuFailure = mContext.getString(
- R.string.osu_failure_add_passpoint_configuration);
- break;
- case OSU_FAILURE_OSU_PROVIDER_NOT_FOUND:
- mOsuFailure = mContext.getString(R.string.osu_failure_osu_provider_not_found);
- break;
+ if (TextUtils.equals(mOsuStatus, mContext.getString(R.string.osu_completing_sign_up))) {
+ mOsuFailure = mContext.getString(R.string.osu_sign_up_failed);
+ } else {
+ mOsuFailure = mContext.getString(R.string.osu_connect_failed);
}
mOsuStatus = null;
mOsuProvisioningComplete = false;
@@ -1651,50 +1572,37 @@
@Override
@MainThread public void onProvisioningStatus(int status) {
+ String newStatus = null;
switch (status) {
case OSU_STATUS_AP_CONNECTING:
- mOsuStatus = mContext.getString(R.string.osu_status_ap_connecting);
- break;
case OSU_STATUS_AP_CONNECTED:
- mOsuStatus = mContext.getString(R.string.osu_status_ap_connected);
- break;
case OSU_STATUS_SERVER_CONNECTING:
- mOsuStatus = mContext.getString(R.string.osu_status_server_connecting);
- break;
case OSU_STATUS_SERVER_VALIDATED:
- mOsuStatus = mContext.getString(R.string.osu_status_server_validated);
- break;
case OSU_STATUS_SERVER_CONNECTED:
- mOsuStatus = mContext.getString(R.string.osu_status_server_connected);
- break;
case OSU_STATUS_INIT_SOAP_EXCHANGE:
- mOsuStatus = mContext.getString(R.string.osu_status_init_soap_exchange);
- break;
case OSU_STATUS_WAITING_FOR_REDIRECT_RESPONSE:
- mOsuStatus = mContext.getString(
- R.string.osu_status_waiting_for_redirect_response);
+ newStatus = String.format(mContext.getString(R.string.osu_opening_provider),
+ mOsuProvider.getFriendlyName());
break;
case OSU_STATUS_REDIRECT_RESPONSE_RECEIVED:
- mOsuStatus = mContext.getString(R.string.osu_status_redirect_response_received);
- break;
case OSU_STATUS_SECOND_SOAP_EXCHANGE:
- mOsuStatus = mContext.getString(R.string.osu_status_second_soap_exchange);
- break;
case OSU_STATUS_THIRD_SOAP_EXCHANGE:
- mOsuStatus = mContext.getString(R.string.osu_status_third_soap_exchange);
- break;
case OSU_STATUS_RETRIEVING_TRUST_ROOT_CERTS:
- mOsuStatus = mContext.getString(
- R.string.osu_status_retrieving_trust_root_certs);
+ newStatus = mContext.getString(
+ R.string.osu_completing_sign_up);
break;
}
+ boolean updated = !TextUtils.equals(mOsuStatus, newStatus);
+ mOsuStatus = newStatus;
mOsuFailure = null;
mOsuProvisioningComplete = false;
- ThreadUtils.postOnMainThread(() -> {
- if (mAccessPointListener != null) {
- mAccessPointListener.onAccessPointChanged(AccessPoint.this);
- }
- });
+ if (updated) {
+ ThreadUtils.postOnMainThread(() -> {
+ if (mAccessPointListener != null) {
+ mAccessPointListener.onAccessPointChanged(AccessPoint.this);
+ }
+ });
+ }
}
@Override
diff --git a/packages/SettingsProvider/src/com/android/providers/settings/SettingsProvider.java b/packages/SettingsProvider/src/com/android/providers/settings/SettingsProvider.java
index 4453121..23e5f0e 100644
--- a/packages/SettingsProvider/src/com/android/providers/settings/SettingsProvider.java
+++ b/packages/SettingsProvider/src/com/android/providers/settings/SettingsProvider.java
@@ -4231,7 +4231,7 @@
String defLocationMode = Integer.toString(
!TextUtils.isEmpty(locationProvidersAllowed.getValue())
- ? Secure.LOCATION_MODE_HIGH_ACCURACY
+ ? Secure.LOCATION_MODE_ON
: Secure.LOCATION_MODE_OFF);
secureSettings.insertSettingLocked(
Secure.LOCATION_MODE, defLocationMode,
diff --git a/packages/Shell/AndroidManifest.xml b/packages/Shell/AndroidManifest.xml
index c3c3f25..c032683 100644
--- a/packages/Shell/AndroidManifest.xml
+++ b/packages/Shell/AndroidManifest.xml
@@ -145,6 +145,7 @@
<uses-permission android:name="android.permission.SET_TIME_ZONE" />
<uses-permission android:name="android.permission.DISABLE_HIDDEN_API_CHECKS" />
<uses-permission android:name="android.permission.MANAGE_ROLE_HOLDERS" />
+ <uses-permission android:name="android.permission.STATUS_BAR_SERVICE" />
<!-- Permission needed to rename bugreport notifications (so they're not shown as Shell) -->
<uses-permission android:name="android.permission.SUBSTITUTE_NOTIFICATION_APP_NAME" />
<!-- Permission needed to hold a wakelock in dumpstate.cpp (drop_root_user()) -->
diff --git a/packages/SystemUI/AndroidManifest.xml b/packages/SystemUI/AndroidManifest.xml
index a18eb76..815ae9a 100644
--- a/packages/SystemUI/AndroidManifest.xml
+++ b/packages/SystemUI/AndroidManifest.xml
@@ -22,6 +22,11 @@
android:sharedUserId="android.uid.systemui"
coreApp="true">
+ <!-- Using OpenGL ES 2.0 -->
+ <uses-feature
+ android:glEsVersion="0x00020000"
+ android:required="true" />
+
<!-- SysUI must be the one to define this permission; its name is
referenced by the core OS. -->
<permission android:name="android.permission.systemui.IDENTITY"
diff --git a/packages/SystemUI/OWNERS b/packages/SystemUI/OWNERS
index 2f6e32b..e7e2c1a 100644
--- a/packages/SystemUI/OWNERS
+++ b/packages/SystemUI/OWNERS
@@ -1,6 +1,6 @@
set noparent
-dsandler@google.com
+dsandler@android.com
adamcohen@google.com
asc@google.com
diff --git a/packages/SystemUI/plugin/src/com/android/systemui/plugins/ActivityStarter.java b/packages/SystemUI/plugin/src/com/android/systemui/plugins/ActivityStarter.java
index 5317a6d..66d5d11 100644
--- a/packages/SystemUI/plugin/src/com/android/systemui/plugins/ActivityStarter.java
+++ b/packages/SystemUI/plugin/src/com/android/systemui/plugins/ActivityStarter.java
@@ -27,7 +27,7 @@
*/
@ProvidesInterface(version = ActivityStarter.VERSION)
public interface ActivityStarter {
- int VERSION = 1;
+ int VERSION = 2;
void startPendingIntentDismissingKeyguard(PendingIntent intent);
@@ -37,6 +37,11 @@
*/
void startPendingIntentDismissingKeyguard(PendingIntent intent,
Runnable intentSentUiThreadCallback);
+
+ /**
+ * The intent flag can be specified in startActivity().
+ */
+ void startActivity(Intent intent, boolean onlyProvisioned, boolean dismissShade, int flags);
void startActivity(Intent intent, boolean dismissShade);
void startActivity(Intent intent, boolean onlyProvisioned, boolean dismissShade);
void startActivity(Intent intent, boolean dismissShade, Callback callback);
diff --git a/packages/SystemUI/res-keyguard/values/strings.xml b/packages/SystemUI/res-keyguard/values/strings.xml
index 7432f9c..41acf82 100644
--- a/packages/SystemUI/res-keyguard/values/strings.xml
+++ b/packages/SystemUI/res-keyguard/values/strings.xml
@@ -405,7 +405,7 @@
<!-- Header for typographic clock face. [CHAR LIMIT=8] -->
<string name="type_clock_header">It\u2019s</string>
- <!-- Hour displayed in words on the typographic clock face. [CHAR LIMIT=8] -->
+ <!-- Hour displayed in words on the typographic clock face. [CHAR LIMIT=12] -->
<string-array name="type_clock_hours">
<item>Twelve</item>
<item>One</item>
@@ -421,7 +421,7 @@
<item>Eleven</item>
</string-array>
- <!-- Minutes displayed in words on the typographic clock face. [CHAR LIMIT=16] -->
+ <!-- Minutes displayed in words on the typographic clock face. [CHAR LIMIT=20] -->
<string-array name="type_clock_minutes">
<item>O\u2019Clock</item>
<item>O\u2019One</item>
diff --git a/packages/SystemUI/res/raw/image_wallpaper_fragment_shader.glsl b/packages/SystemUI/res/raw/image_wallpaper_fragment_shader.glsl
new file mode 100644
index 0000000..11d73a9
--- /dev/null
+++ b/packages/SystemUI/res/raw/image_wallpaper_fragment_shader.glsl
@@ -0,0 +1,33 @@
+precision mediump float;
+
+uniform sampler2D uTexture;
+uniform float uCenterReveal;
+uniform float uReveal;
+uniform float uAod2Opacity;
+uniform int uAodMode;
+varying vec2 vTextureCoordinates;
+
+vec3 luminosity(vec3 color) {
+ float lum = 0.2126 * color.r + 0.7152 * color.g + 0.0722 * color.b;
+ return vec3(lum);
+}
+
+vec4 transform(vec3 diffuse) {
+ // TODO: Add well comments here, tracking on b/123615467.
+ vec3 lum = luminosity(diffuse);
+ diffuse = mix(diffuse, lum, smoothstep(0., uCenterReveal, uReveal));
+ float val = mix(uReveal, uCenterReveal, step(uCenterReveal, uReveal));
+ diffuse = smoothstep(val, 1.0, diffuse);
+ diffuse *= uAod2Opacity * (1. - smoothstep(uCenterReveal, 1., uReveal));
+ return vec4(diffuse.r, diffuse.g, diffuse.b, 1.);
+}
+
+void main() {
+ vec4 fragColor = texture2D(uTexture, vTextureCoordinates);
+ // TODO: Remove the branch logic here, tracking on b/123615467.
+ if (uAodMode != 0) {
+ gl_FragColor = transform(fragColor.rgb);
+ } else {
+ gl_FragColor = fragColor;
+ }
+}
\ No newline at end of file
diff --git a/packages/SystemUI/res/raw/image_wallpaper_vertex_shader.glsl b/packages/SystemUI/res/raw/image_wallpaper_vertex_shader.glsl
new file mode 100644
index 0000000..4393e2b
--- /dev/null
+++ b/packages/SystemUI/res/raw/image_wallpaper_vertex_shader.glsl
@@ -0,0 +1,8 @@
+attribute vec4 aPosition;
+attribute vec2 aTextureCoordinates;
+varying vec2 vTextureCoordinates;
+
+void main() {
+ vTextureCoordinates = aTextureCoordinates;
+ gl_Position = aPosition;
+}
\ No newline at end of file
diff --git a/packages/SystemUI/src/com/android/systemui/ActivityStarterDelegate.java b/packages/SystemUI/src/com/android/systemui/ActivityStarterDelegate.java
index b461f69..04f887b 100644
--- a/packages/SystemUI/src/com/android/systemui/ActivityStarterDelegate.java
+++ b/packages/SystemUI/src/com/android/systemui/ActivityStarterDelegate.java
@@ -53,6 +53,15 @@
}
@Override
+ public void startActivity(Intent intent, boolean onlyProvisioned, boolean dismissShade,
+ int flags) {
+ if (mActualStarter == null) {
+ return;
+ }
+ mActualStarter.startActivity(intent, onlyProvisioned, dismissShade, flags);
+ }
+
+ @Override
public void startActivity(Intent intent, boolean dismissShade) {
if (mActualStarter == null) {
return;
diff --git a/packages/SystemUI/src/com/android/systemui/ImageWallpaper.java b/packages/SystemUI/src/com/android/systemui/ImageWallpaper.java
index 2aecc24..5040942 100644
--- a/packages/SystemUI/src/com/android/systemui/ImageWallpaper.java
+++ b/packages/SystemUI/src/com/android/systemui/ImageWallpaper.java
@@ -19,8 +19,11 @@
import static android.view.Display.DEFAULT_DISPLAY;
import android.app.WallpaperManager;
+import android.content.BroadcastReceiver;
import android.content.ComponentCallbacks2;
import android.content.Context;
+import android.content.Intent;
+import android.content.IntentFilter;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.RecordingCanvas;
@@ -28,7 +31,9 @@
import android.graphics.RectF;
import android.graphics.Region.Op;
import android.hardware.display.DisplayManager;
+import android.opengl.GLSurfaceView;
import android.os.AsyncTask;
+import android.os.Build;
import android.os.Handler;
import android.os.Trace;
import android.service.wallpaper.WallpaperService;
@@ -39,6 +44,7 @@
import android.view.SurfaceHolder;
import com.android.internal.annotations.VisibleForTesting;
+import com.android.systemui.glwallpaper.ImageWallpaperRenderer;
import java.io.FileDescriptor;
import java.io.IOException;
@@ -51,12 +57,17 @@
public class ImageWallpaper extends WallpaperService {
private static final String TAG = "ImageWallpaper";
private static final String GL_LOG_TAG = "ImageWallpaperGL";
+ // TODO: Testing purpose, need to remove later, b/123616712.
+ private static final String SENSOR_EVENT_AWAKE = "systemui.test.event.awake";
+ // TODO: Testing purpose, need to remove later, b/123616712.
+ private static final String SENSOR_EVENT_SLEEP = "systemui.test.event.sleep";
private static final boolean DEBUG = false;
private static final String PROPERTY_KERNEL_QEMU = "ro.kernel.qemu";
private static final long DELAY_FORGET_WALLPAPER = 5000;
private WallpaperManager mWallpaperManager;
private DrawableEngine mEngine;
+ private GLEngine mGlEngine;
@Override
public void onCreate() {
@@ -73,10 +84,112 @@
@Override
public Engine onCreateEngine() {
- mEngine = new DrawableEngine();
- return mEngine;
+ mGlEngine = new GLEngine(this);
+ return mGlEngine;
}
+ class GLEngine extends Engine {
+ private GLWallpaperSurfaceView mWallpaperSurfaceView;
+
+ GLEngine(Context context) {
+ mWallpaperSurfaceView = new GLWallpaperSurfaceView(context);
+ mWallpaperSurfaceView.setRenderer(
+ new ImageWallpaperRenderer(context, mWallpaperSurfaceView));
+ mWallpaperSurfaceView.setRenderMode(GLSurfaceView.RENDERMODE_WHEN_DIRTY);
+ setOffsetNotificationsEnabled(true);
+ }
+
+ @Override
+ public void onAmbientModeChanged(boolean inAmbientMode, long animationDuration) {
+ if (mWallpaperSurfaceView != null) {
+ mWallpaperSurfaceView.notifyAmbientModeChanged(inAmbientMode);
+ }
+ }
+
+ @Override
+ public void onOffsetsChanged(float xOffset, float yOffset, float xOffsetStep,
+ float yOffsetStep, int xPixelOffset, int yPixelOffset) {
+ if (mWallpaperSurfaceView != null) {
+ mWallpaperSurfaceView.notifyOffsetsChanged(xOffset, yOffset);
+ }
+ }
+
+ private class GLWallpaperSurfaceView extends GLSurfaceView implements ImageGLView {
+ private SensorEventListener mEventListener;
+ private WallpaperStatusListener mWallpaperChangedListener;
+
+ // TODO: Testing purpose, need to remove later, b/123616712.
+ /**
+ * For testing only: adb shell am broadcast -a <INTENT>
+ */
+ private final BroadcastReceiver mReceiver = new BroadcastReceiver() {
+ @Override
+ public void onReceive(Context context, Intent intent) {
+ if (intent == null) {
+ return;
+ }
+ switch (intent.getAction()) {
+ case SENSOR_EVENT_AWAKE:
+ notifySensorEvents(true);
+ break;
+ case SENSOR_EVENT_SLEEP:
+ notifySensorEvents(false);
+ break;
+ }
+ }
+ };
+
+ GLWallpaperSurfaceView(Context context) {
+ super(context);
+ setEGLContextClientVersion(2);
+ // TODO: Testing purpose, need to remove later, b/123616712.
+ if (Build.IS_DEBUGGABLE) {
+ IntentFilter filter = new IntentFilter();
+ filter.addAction(SENSOR_EVENT_AWAKE);
+ filter.addAction(SENSOR_EVENT_SLEEP);
+ registerReceiver(mReceiver, filter);
+ }
+ }
+
+ @Override
+ public SurfaceHolder getHolder() {
+ return getSurfaceHolder();
+ }
+
+ @Override
+ public void setRenderer(Renderer renderer) {
+ super.setRenderer(renderer);
+ mEventListener = (SensorEventListener) renderer;
+ mWallpaperChangedListener = (WallpaperStatusListener) renderer;
+ }
+
+ private void notifySensorEvents(boolean reach) {
+ if (mEventListener != null) {
+ mEventListener.onSensorEvent(reach);
+ }
+ }
+
+ private void notifyAmbientModeChanged(boolean inAmbient) {
+ if (mWallpaperChangedListener != null) {
+ mWallpaperChangedListener.onAmbientModeChanged(inAmbient);
+ }
+ }
+
+ private void notifyOffsetsChanged(float xOffset, float yOffset) {
+ if (mWallpaperChangedListener != null) {
+ mWallpaperChangedListener.onOffsetsChanged(
+ xOffset, yOffset, getHolder().getSurfaceFrame());
+ }
+ }
+
+ @Override
+ public void render() {
+ requestRender();
+ }
+ }
+ }
+
+ // TODO: Remove this engine, tracking on b/123617158.
class DrawableEngine extends Engine {
private final Runnable mUnloadWallpaperCallback = () -> {
unloadWallpaper(false /* forgetSize */);
@@ -564,4 +677,46 @@
}
}
}
+
+ /**
+ * A listener to trace sensor event.
+ */
+ public interface SensorEventListener {
+
+ /**
+ * Called back while sensor event comes.
+ * @param reach The status of sensor.
+ */
+ void onSensorEvent(boolean reach);
+ }
+
+ /**
+ * A listener to trace status of image wallpaper.
+ */
+ public interface WallpaperStatusListener {
+
+ /**
+ * Called back while ambient mode changes.
+ * @param inAmbientMode true if is in ambient mode, false otherwise.
+ */
+ void onAmbientModeChanged(boolean inAmbientMode);
+
+ /**
+ * Called back while wallpaper offsets.
+ * @param xOffset The offset portion along x.
+ * @param yOffset The offset portion along y.
+ */
+ void onOffsetsChanged(float xOffset, float yOffset, Rect frame);
+ }
+
+ /**
+ * An abstraction for view of GLRenderer.
+ */
+ public interface ImageGLView {
+
+ /**
+ * Ask the view to render.
+ */
+ void render();
+ }
}
diff --git a/packages/SystemUI/src/com/android/systemui/bubbles/BubbleExpandedViewContainer.java b/packages/SystemUI/src/com/android/systemui/bubbles/BubbleExpandedViewContainer.java
index 71ae1f8..231e725 100644
--- a/packages/SystemUI/src/com/android/systemui/bubbles/BubbleExpandedViewContainer.java
+++ b/packages/SystemUI/src/com/android/systemui/bubbles/BubbleExpandedViewContainer.java
@@ -19,6 +19,7 @@
import android.annotation.Nullable;
import android.content.Context;
import android.content.res.Resources;
+import android.content.res.TypedArray;
import android.graphics.Color;
import android.graphics.drawable.ShapeDrawable;
import android.text.TextUtils;
@@ -68,9 +69,15 @@
mPointerView = findViewById(R.id.pointer_view);
int width = res.getDimensionPixelSize(R.dimen.bubble_pointer_width);
int height = res.getDimensionPixelSize(R.dimen.bubble_pointer_height);
+
+ TypedArray ta = getContext().obtainStyledAttributes(
+ new int[] {android.R.attr.colorBackgroundFloating});
+ int bgColor = ta.getColor(0, Color.WHITE);
+ ta.recycle();
+
ShapeDrawable triangleDrawable = new ShapeDrawable(
TriangleShape.create(width, height, true /* pointUp */));
- triangleDrawable.setTint(Color.WHITE); // TODO: dark mode
+ triangleDrawable.setTint(bgColor);
mPointerView.setBackground(triangleDrawable);
mHeaderView = findViewById(R.id.bubble_content_header);
}
diff --git a/packages/SystemUI/src/com/android/systemui/bubbles/BubbleStackView.java b/packages/SystemUI/src/com/android/systemui/bubbles/BubbleStackView.java
index 8731bd5..cbca2fc 100644
--- a/packages/SystemUI/src/com/android/systemui/bubbles/BubbleStackView.java
+++ b/packages/SystemUI/src/com/android/systemui/bubbles/BubbleStackView.java
@@ -237,6 +237,10 @@
* Sets the bubble that should be expanded and expands if needed.
*/
public void setExpandedBubble(BubbleView bubbleToExpand) {
+ if (mIsExpanded && !bubbleToExpand.equals(mExpandedBubble)) {
+ // Previously expanded, notify that this bubble is no longer expanded
+ notifyExpansionChanged(mExpandedBubble, false /* expanded */);
+ }
mExpandedBubble = bubbleToExpand;
if (!mIsExpanded) {
// If we weren't previously expanded we should animate open.
@@ -291,12 +295,12 @@
int nextIndex = bubbleCount > removedIndex ? removedIndex : bubbleCount - 1;
BubbleView expandedBubble = (BubbleView) mBubbleContainer.getChildAt(nextIndex);
setExpandedBubble(expandedBubble);
+ requestUpdate();
}
mIsExpanded = wasExpanded && mBubbleContainer.getChildCount() > 0;
if (wasExpanded != mIsExpanded) {
notifyExpansionChanged(mExpandedBubble, mIsExpanded);
}
- requestUpdate();
}
/**
@@ -373,9 +377,7 @@
public void expandStack() {
if (!mIsExpanded) {
mExpandedBubble = getTopBubble();
- mExpandedBubble.getEntry().setShowInShadeWhenBubble(false);
- animateExpansion(true /* shouldExpand */);
- notifyExpansionChanged(mExpandedBubble, true /* expanded */);
+ setExpandedBubble(mExpandedBubble);
}
}
diff --git a/packages/SystemUI/src/com/android/systemui/doze/DozeSensors.java b/packages/SystemUI/src/com/android/systemui/doze/DozeSensors.java
index 562edd6..675948e 100644
--- a/packages/SystemUI/src/com/android/systemui/doze/DozeSensors.java
+++ b/packages/SystemUI/src/com/android/systemui/doze/DozeSensors.java
@@ -130,7 +130,7 @@
false /* touchscreen */),
new PluginSensor(
new SensorManagerPlugin.Sensor(TYPE_WAKE_LOCK_SCREEN),
- Settings.Secure.DOZE_WAKE_LOCK_SCREEN_GESTURE,
+ Settings.Secure.DOZE_WAKE_SCREEN_GESTURE,
mConfig.wakeScreenGestureAvailable(),
DozeLog.PULSE_REASON_SENSOR_WAKE_LOCK_SCREEN,
false /* reports touch coordinates */,
diff --git a/packages/SystemUI/src/com/android/systemui/glwallpaper/ImageGLProgram.java b/packages/SystemUI/src/com/android/systemui/glwallpaper/ImageGLProgram.java
new file mode 100644
index 0000000..d03b00b
--- /dev/null
+++ b/packages/SystemUI/src/com/android/systemui/glwallpaper/ImageGLProgram.java
@@ -0,0 +1,115 @@
+/*
+ * Copyright (C) 2019 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.systemui.glwallpaper;
+
+import static android.opengl.GLES20.GL_FRAGMENT_SHADER;
+import static android.opengl.GLES20.GL_VERTEX_SHADER;
+import static android.opengl.GLES20.glAttachShader;
+import static android.opengl.GLES20.glCompileShader;
+import static android.opengl.GLES20.glCreateProgram;
+import static android.opengl.GLES20.glCreateShader;
+import static android.opengl.GLES20.glGetAttribLocation;
+import static android.opengl.GLES20.glGetUniformLocation;
+import static android.opengl.GLES20.glLinkProgram;
+import static android.opengl.GLES20.glShaderSource;
+import static android.opengl.GLES20.glUseProgram;
+
+import android.content.Context;
+import android.content.res.Resources;
+import android.util.Log;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStreamReader;
+
+/**
+ * This class takes charge of linking shader codes and then return a handle for OpenGL ES program.
+ */
+class ImageGLProgram {
+ private static final String TAG = ImageGLProgram.class.getSimpleName();
+
+ private Context mContext;
+ private int mProgramHandle;
+
+ ImageGLProgram(Context context) {
+ mContext = context.getApplicationContext();
+ }
+
+ private int loadShaderProgram(int vertexId, int fragmentId) {
+ final String vertexSrc = getShaderResource(vertexId);
+ final String fragmentSrc = getShaderResource(fragmentId);
+ final int vertexHandle = getShaderHandle(GL_VERTEX_SHADER, vertexSrc);
+ final int fragmentHandle = getShaderHandle(GL_FRAGMENT_SHADER, fragmentSrc);
+ return getProgramHandle(vertexHandle, fragmentHandle);
+ }
+
+ private String getShaderResource(int shaderId) {
+ Resources res = mContext.getResources();
+ StringBuilder code = new StringBuilder();
+
+ try (BufferedReader reader = new BufferedReader(
+ new InputStreamReader(res.openRawResource(shaderId)))) {
+ String nextLine;
+ while ((nextLine = reader.readLine()) != null) {
+ code.append(nextLine).append("\n");
+ }
+ } catch (IOException | Resources.NotFoundException ex) {
+ Log.d(TAG, "Can not read the shader source", ex);
+ code = null;
+ }
+
+ return code == null ? "" : code.toString();
+ }
+
+ private int getShaderHandle(int type, String src) {
+ final int shader = glCreateShader(type);
+ if (shader == 0) {
+ Log.d(TAG, "Create shader failed, type=" + type);
+ return 0;
+ }
+ glShaderSource(shader, src);
+ glCompileShader(shader);
+ return shader;
+ }
+
+ private int getProgramHandle(int vertexHandle, int fragmentHandle) {
+ final int program = glCreateProgram();
+ if (program == 0) {
+ Log.d(TAG, "Can not create OpenGL ES program");
+ return 0;
+ }
+
+ glAttachShader(program, vertexHandle);
+ glAttachShader(program, fragmentHandle);
+ glLinkProgram(program);
+ return program;
+ }
+
+ boolean useGLProgram(int vertexResId, int fragmentResId) {
+ mProgramHandle = loadShaderProgram(vertexResId, fragmentResId);
+ glUseProgram(mProgramHandle);
+ return true;
+ }
+
+ int getAttributeHandle(String name) {
+ return glGetAttribLocation(mProgramHandle, name);
+ }
+
+ int getUniformHandle(String name) {
+ return glGetUniformLocation(mProgramHandle, name);
+ }
+}
diff --git a/packages/SystemUI/src/com/android/systemui/glwallpaper/ImageGLWallpaper.java b/packages/SystemUI/src/com/android/systemui/glwallpaper/ImageGLWallpaper.java
new file mode 100644
index 0000000..4e07872
--- /dev/null
+++ b/packages/SystemUI/src/com/android/systemui/glwallpaper/ImageGLWallpaper.java
@@ -0,0 +1,245 @@
+/*
+ * Copyright (C) 2019 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.systemui.glwallpaper;
+
+import static android.opengl.GLES20.GL_FLOAT;
+import static android.opengl.GLES20.GL_LINEAR;
+import static android.opengl.GLES20.GL_TEXTURE0;
+import static android.opengl.GLES20.GL_TEXTURE_2D;
+import static android.opengl.GLES20.GL_TEXTURE_MAG_FILTER;
+import static android.opengl.GLES20.GL_TEXTURE_MIN_FILTER;
+import static android.opengl.GLES20.GL_TRIANGLES;
+import static android.opengl.GLES20.glActiveTexture;
+import static android.opengl.GLES20.glBindTexture;
+import static android.opengl.GLES20.glDrawArrays;
+import static android.opengl.GLES20.glEnableVertexAttribArray;
+import static android.opengl.GLES20.glGenTextures;
+import static android.opengl.GLES20.glTexParameteri;
+import static android.opengl.GLES20.glUniform1i;
+import static android.opengl.GLES20.glVertexAttribPointer;
+
+import android.graphics.Bitmap;
+import android.opengl.GLUtils;
+import android.util.Log;
+
+import java.nio.ByteBuffer;
+import java.nio.ByteOrder;
+import java.nio.FloatBuffer;
+
+/**
+ * This class takes charge of the geometry data like vertices and texture coordinates.
+ * It delivers these data to opengl runtime and triggers draw calls if necessary.
+ */
+class ImageGLWallpaper {
+ private static final String TAG = ImageGLWallpaper.class.getSimpleName();
+
+ static final String A_POSITION = "aPosition";
+ static final String A_TEXTURE_COORDINATES = "aTextureCoordinates";
+ static final String U_CENTER_REVEAL = "uCenterReveal";
+ static final String U_REVEAL = "uReveal";
+ static final String U_AOD2OPACITY = "uAod2Opacity";
+ static final String U_TEXTURE = "uTexture";
+ static final String U_AOD_MODE = "uAodMode";
+
+ private static final int HANDLE_UNDEFINED = -1;
+ private static final int POSITION_COMPONENT_COUNT = 2;
+ private static final int TEXTURE_COMPONENT_COUNT = 2;
+ private static final int BYTES_PER_FLOAT = 4;
+
+ // Vertices to define the square with 2 triangles.
+ private static final float[] VERTICES = {
+ -1.0f, -1.0f,
+ +1.0f, -1.0f,
+ +1.0f, +1.0f,
+ +1.0f, +1.0f,
+ -1.0f, +1.0f,
+ -1.0f, -1.0f
+ };
+
+ // Texture coordinates that maps to vertices.
+ private static final float[] TEXTURES = {
+ 0f, 1f,
+ 1f, 1f,
+ 1f, 0f,
+ 1f, 0f,
+ 0f, 0f,
+ 0f, 1f
+ };
+
+ private final FloatBuffer mVertexBuffer;
+ private final FloatBuffer mTextureBuffer;
+ private final ImageGLProgram mProgram;
+
+ private int mAttrPosition;
+ private int mAttrTextureCoordinates;
+ private int mUniAod2Opacity;
+ private int mUniAodMode;
+ private int mUniCenterReveal;
+ private int mUniReveal;
+ private int mUniTexture;
+ private int mTextureId;
+
+ ImageGLWallpaper(ImageGLProgram program) {
+ mProgram = program;
+
+ // Create an float array in opengles runtime (native) and put vertex data.
+ mVertexBuffer = ByteBuffer.allocateDirect(VERTICES.length * BYTES_PER_FLOAT)
+ .order(ByteOrder.nativeOrder())
+ .asFloatBuffer();
+ mVertexBuffer.put(VERTICES);
+ mVertexBuffer.position(0);
+
+ // Create an float array in opengles runtime (native) and put texture data.
+ mTextureBuffer = ByteBuffer.allocateDirect(TEXTURES.length * BYTES_PER_FLOAT)
+ .order(ByteOrder.nativeOrder())
+ .asFloatBuffer();
+ mTextureBuffer.put(TEXTURES);
+ mTextureBuffer.position(0);
+ }
+
+ void setup() {
+ setupAttributes();
+ setupUniforms();
+ }
+
+ private void setupAttributes() {
+ mAttrPosition = mProgram.getAttributeHandle(A_POSITION);
+ mVertexBuffer.position(0);
+ glVertexAttribPointer(mAttrPosition, POSITION_COMPONENT_COUNT, GL_FLOAT,
+ false, 0, mVertexBuffer);
+ glEnableVertexAttribArray(mAttrPosition);
+
+ mAttrTextureCoordinates = mProgram.getAttributeHandle(A_TEXTURE_COORDINATES);
+ mTextureBuffer.position(0);
+ glVertexAttribPointer(mAttrTextureCoordinates, TEXTURE_COMPONENT_COUNT, GL_FLOAT,
+ false, 0, mTextureBuffer);
+ glEnableVertexAttribArray(mAttrTextureCoordinates);
+ }
+
+ private void setupUniforms() {
+ mUniAod2Opacity = mProgram.getUniformHandle(U_AOD2OPACITY);
+ mUniAodMode = mProgram.getUniformHandle(U_AOD_MODE);
+ mUniCenterReveal = mProgram.getUniformHandle(U_CENTER_REVEAL);
+ mUniReveal = mProgram.getUniformHandle(U_REVEAL);
+ mUniTexture = mProgram.getUniformHandle(U_TEXTURE);
+ }
+
+ int getHandle(String name) {
+ switch (name) {
+ case A_POSITION:
+ return mAttrPosition;
+ case A_TEXTURE_COORDINATES:
+ return mAttrTextureCoordinates;
+ case U_AOD2OPACITY:
+ return mUniAod2Opacity;
+ case U_AOD_MODE:
+ return mUniAodMode;
+ case U_CENTER_REVEAL:
+ return mUniCenterReveal;
+ case U_REVEAL:
+ return mUniReveal;
+ case U_TEXTURE:
+ return mUniTexture;
+ default:
+ return HANDLE_UNDEFINED;
+ }
+ }
+
+ void draw() {
+ glDrawArrays(GL_TRIANGLES, 0, VERTICES.length / 2);
+ }
+
+ void setupTexture(Bitmap bitmap) {
+ final int[] tids = new int[1];
+
+ if (bitmap == null) {
+ Log.w(TAG, "setupTexture: invalid bitmap");
+ return;
+ }
+
+ // Generate one texture object and store the id in tids[0].
+ glGenTextures(1, tids, 0);
+ if (tids[0] == 0) {
+ Log.w(TAG, "setupTexture: glGenTextures() failed");
+ return;
+ }
+
+ // Bind a named texture to a texturing target.
+ glBindTexture(GL_TEXTURE_2D, tids[0]);
+ // Load the bitmap data and copy it over into the texture object that is currently bound.
+ GLUtils.texImage2D(GL_TEXTURE_2D, 0, bitmap, 0);
+ // Use bilinear texture filtering when minification.
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
+ // Use bilinear texture filtering when magnification.
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
+
+ mTextureId = tids[0];
+ }
+
+ void useTexture() {
+ // Set the active texture unit to texture unit 0.
+ glActiveTexture(GL_TEXTURE0);
+ // Bind the texture to this unit.
+ glBindTexture(GL_TEXTURE_2D, mTextureId);
+ // Let the texture sampler in fragment shader to read form this texture unit.
+ glUniform1i(mUniTexture, 0);
+ }
+
+ void adjustTextureCoordinates(Bitmap bitmap, int surfaceWidth, int surfaceHeight,
+ float xOffset, float yOffset) {
+ if (bitmap == null) {
+ Log.d(TAG, "adjustTextureCoordinates: invalid bitmap");
+ return;
+ }
+
+ float ratioW = 1f;
+ float ratioH = 1f;
+ int bitmapWidth = bitmap.getWidth();
+ int bitmapHeight = bitmap.getHeight();
+
+ boolean adjustWidth = bitmapWidth > surfaceWidth;
+ if (adjustWidth) {
+ ratioW = (float) surfaceWidth / bitmapWidth;
+ float referenceX = xOffset + ratioW > 1f ? 1f - ratioW : xOffset;
+ for (int i = 0; i < TEXTURES.length; i += 2) {
+ if (i == 2 || i == 4 || i == 6) {
+ TEXTURES[i] = Math.min(1f, referenceX + ratioW);
+ } else {
+ TEXTURES[i] = referenceX;
+ }
+ }
+ }
+
+ boolean adjustHeight = bitmapHeight > surfaceHeight;
+ if (adjustHeight) {
+ ratioH = (float) surfaceHeight / bitmapHeight;
+ float referenceY = yOffset + ratioH > 1f ? 1f - ratioH : yOffset;
+ for (int i = 1; i < TEXTURES.length; i += 2) {
+ if (i == 1 || i == 3 || i == 11) {
+ TEXTURES[i] = Math.min(1f, referenceY + ratioH);
+ } else {
+ TEXTURES[i] = referenceY;
+ }
+ }
+ }
+
+ if (adjustWidth || adjustHeight) {
+ mTextureBuffer.put(TEXTURES);
+ mTextureBuffer.position(0);
+ }
+ }
+}
diff --git a/packages/SystemUI/src/com/android/systemui/glwallpaper/ImageProcessHelper.java b/packages/SystemUI/src/com/android/systemui/glwallpaper/ImageProcessHelper.java
new file mode 100644
index 0000000..477e7d7e
--- /dev/null
+++ b/packages/SystemUI/src/com/android/systemui/glwallpaper/ImageProcessHelper.java
@@ -0,0 +1,144 @@
+/*
+ * Copyright (C) 2019 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.systemui.glwallpaper;
+
+import android.graphics.Bitmap;
+import android.graphics.Canvas;
+import android.graphics.Color;
+import android.graphics.ColorMatrix;
+import android.graphics.ColorMatrixColorFilter;
+import android.graphics.Matrix;
+import android.graphics.Paint;
+import android.os.AsyncTask;
+import android.os.Handler;
+import android.os.Handler.Callback;
+import android.os.Message;
+import android.util.Log;
+
+/**
+ * A helper class that computes histogram and percentile 85 from a bitmap.
+ * Percentile 85 will be computed each time the user picks a new image wallpaper.
+ */
+class ImageProcessHelper {
+ private static final String TAG = ImageProcessHelper.class.getSimpleName();
+ private static final float DEFAULT_PER85 = 0.8f;
+ private static final int MSG_UPDATE_PER85 = 1;
+
+ /**
+ * This color matrix will be applied to each pixel to get luminance from rgb by below formula:
+ * Luminance = .2126f * r + .7152f * g + .0722f * b.
+ */
+ private static final float[] LUMINOSITY_MATRIX = new float[] {
+ .2126f, .0000f, .0000f, .0000f, .0000f,
+ .0000f, .7152f, .0000f, .0000f, .0000f,
+ .0000f, .0000f, .0722f, .0000f, .0000f,
+ .0000f, .0000f, .0000f, 1.000f, .0000f
+ };
+
+ private final Handler mHandler = new Handler(new Callback() {
+ @Override
+ public boolean handleMessage(Message msg) {
+ switch (msg.what) {
+ case MSG_UPDATE_PER85:
+ mPer85 = (float) msg.obj;
+ return true;
+ default:
+ return false;
+ }
+ }
+ });
+
+ private float mPer85 = DEFAULT_PER85;
+
+ void startComputingPercentile85(Bitmap bitmap) {
+ new Per85ComputeTask(mHandler).execute(bitmap);
+ }
+
+ float getPercentile85() {
+ return mPer85;
+ }
+
+ private static class Per85ComputeTask extends AsyncTask<Bitmap, Void, Float> {
+ private Handler mUpdateHandler;
+
+ Per85ComputeTask(Handler handler) {
+ super(handler);
+ mUpdateHandler = handler;
+ }
+
+ @Override
+ protected Float doInBackground(Bitmap... bitmaps) {
+ Bitmap bitmap = bitmaps[0];
+ if (bitmap != null) {
+ int[] histogram = processHistogram(bitmap);
+ return computePercentile85(bitmap, histogram);
+ }
+ Log.e(TAG, "Per85ComputeTask: Can't get bitmap");
+ return DEFAULT_PER85;
+ }
+
+ @Override
+ protected void onPostExecute(Float result) {
+ Message msg = mUpdateHandler.obtainMessage(MSG_UPDATE_PER85, result);
+ mUpdateHandler.sendMessage(msg);
+ }
+
+ private int[] processHistogram(Bitmap bitmap) {
+ int width = bitmap.getWidth();
+ int height = bitmap.getHeight();
+
+ Bitmap target = Bitmap.createBitmap(width, height, bitmap.getConfig());
+ Canvas canvas = new Canvas(target);
+ ColorMatrix cm = new ColorMatrix(LUMINOSITY_MATRIX);
+ Paint paint = new Paint();
+ paint.setColorFilter(new ColorMatrixColorFilter(cm));
+ canvas.drawBitmap(bitmap, new Matrix(), paint);
+
+ // TODO: Fine tune the performance here, tracking on b/123615079.
+ int[] histogram = new int[256];
+ for (int row = 0; row < height; row++) {
+ for (int col = 0; col < width; col++) {
+ int pixel = target.getPixel(col, row);
+ int y = Color.red(pixel) + Color.green(pixel) + Color.blue(pixel);
+ histogram[y]++;
+ }
+ }
+
+ return histogram;
+ }
+
+ private float computePercentile85(Bitmap bitmap, int[] histogram) {
+ float per85 = DEFAULT_PER85;
+ int pixelCount = bitmap.getWidth() * bitmap.getHeight();
+ float[] acc = new float[256];
+ for (int i = 0; i < acc.length; i++) {
+ acc[i] = (float) histogram[i] / pixelCount;
+ float prev = i == 0 ? 0f : acc[i - 1];
+ float next = acc[i];
+ float idx = (float) (i + 1) / 255;
+ float sum = prev + next;
+ if (prev < 0.85f && sum >= 0.85f) {
+ per85 = idx;
+ }
+ if (i > 0) {
+ acc[i] += acc[i - 1];
+ }
+ }
+ return per85;
+ }
+ }
+}
diff --git a/packages/SystemUI/src/com/android/systemui/glwallpaper/ImageRevealHelper.java b/packages/SystemUI/src/com/android/systemui/glwallpaper/ImageRevealHelper.java
new file mode 100644
index 0000000..787972c
--- /dev/null
+++ b/packages/SystemUI/src/com/android/systemui/glwallpaper/ImageRevealHelper.java
@@ -0,0 +1,103 @@
+/*
+ * Copyright (C) 2019 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.systemui.glwallpaper;
+
+import android.animation.Animator;
+import android.animation.AnimatorListenerAdapter;
+import android.animation.ValueAnimator;
+
+import com.android.systemui.Interpolators;
+
+/**
+ * Use ValueAnimator and appropriate interpolator to control the progress of reveal transition.
+ * The transition will happen while getting awake and quit events.
+ */
+class ImageRevealHelper {
+ private static final String TAG = ImageRevealHelper.class.getSimpleName();
+ private static final float MAX_REVEAL = 0f;
+ private static final float MIN_REVEAL = 1f;
+ private static final int REVEAL_DURATION = 1000;
+
+ private final ValueAnimator mAnimator;
+ private final RevealStateListener mRevealListener;
+ private float mReveal = MIN_REVEAL;
+ private boolean mAwake = false;
+
+ ImageRevealHelper(RevealStateListener listener) {
+ mRevealListener = listener;
+ mAnimator = ValueAnimator.ofFloat();
+ mAnimator.setDuration(REVEAL_DURATION);
+ mAnimator.setInterpolator(Interpolators.FAST_OUT_SLOW_IN);
+ mAnimator.addUpdateListener(animator -> {
+ mReveal = (float) animator.getAnimatedValue();
+ if (mRevealListener != null) {
+ mRevealListener.onRevealStateChanged();
+ }
+ });
+ mAnimator.addListener(new AnimatorListenerAdapter() {
+ private boolean mIsCanceled;
+
+ @Override
+ public void onAnimationCancel(Animator animation) {
+ mIsCanceled = true;
+ }
+
+ @Override
+ public void onAnimationEnd(Animator animation) {
+ if (!mIsCanceled) {
+ mAwake = !mAwake;
+ }
+ mIsCanceled = false;
+ }
+ });
+ }
+
+ private void animate() {
+ mAnimator.cancel();
+ mAnimator.setFloatValues(mReveal, !mAwake ? MIN_REVEAL : MAX_REVEAL);
+ mAnimator.start();
+ }
+
+ public float getReveal() {
+ return mReveal;
+ }
+
+ public boolean isAwake() {
+ return mAwake;
+ }
+
+ void updateAwake(boolean awake) {
+ mAwake = awake;
+ animate();
+ }
+
+ void sleep() {
+ mReveal = MIN_REVEAL;
+ mAwake = false;
+ }
+
+ /**
+ * A listener to trace value changes of reveal.
+ */
+ public interface RevealStateListener {
+
+ /**
+ * Called back while reveal status changes.
+ */
+ void onRevealStateChanged();
+ }
+}
diff --git a/packages/SystemUI/src/com/android/systemui/glwallpaper/ImageWallpaperRenderer.java b/packages/SystemUI/src/com/android/systemui/glwallpaper/ImageWallpaperRenderer.java
new file mode 100644
index 0000000..8916b28
--- /dev/null
+++ b/packages/SystemUI/src/com/android/systemui/glwallpaper/ImageWallpaperRenderer.java
@@ -0,0 +1,153 @@
+/*
+ * Copyright (C) 2019 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.systemui.glwallpaper;
+
+import static android.opengl.GLES20.GL_COLOR_BUFFER_BIT;
+import static android.opengl.GLES20.glClear;
+import static android.opengl.GLES20.glClearColor;
+import static android.opengl.GLES20.glUniform1f;
+import static android.opengl.GLES20.glUniform1i;
+import static android.opengl.GLES20.glViewport;
+
+import android.app.WallpaperManager;
+import android.content.Context;
+import android.graphics.Bitmap;
+import android.graphics.Rect;
+import android.opengl.GLSurfaceView;
+import android.util.Log;
+
+import com.android.systemui.ImageWallpaper;
+import com.android.systemui.ImageWallpaper.ImageGLView;
+import com.android.systemui.R;
+
+import javax.microedition.khronos.egl.EGLConfig;
+import javax.microedition.khronos.opengles.GL10;
+
+/**
+ * A GL renderer for image wallpaper.
+ */
+public class ImageWallpaperRenderer implements GLSurfaceView.Renderer,
+ ImageWallpaper.SensorEventListener, ImageWallpaper.WallpaperStatusListener,
+ ImageRevealHelper.RevealStateListener {
+ private static final String TAG = ImageWallpaperRenderer.class.getSimpleName();
+
+ private final WallpaperManager mWallpaperManager;
+ private final ImageGLProgram mProgram;
+ private final ImageGLWallpaper mWallpaper;
+ private final ImageProcessHelper mImageProcessHelper;
+ private final ImageRevealHelper mImageRevealHelper;
+ private final ImageGLView mGLView;
+ private boolean mIsInAmbientMode;
+ private float mXOffset = 0f;
+ private float mYOffset = 0f;
+
+ public ImageWallpaperRenderer(Context context, ImageGLView glView) {
+ mWallpaperManager = context.getSystemService(WallpaperManager.class);
+ if (mWallpaperManager == null) {
+ Log.w(TAG, "WallpaperManager not available");
+ }
+
+ mProgram = new ImageGLProgram(context);
+ mWallpaper = new ImageGLWallpaper(mProgram);
+ mImageProcessHelper = new ImageProcessHelper();
+ mImageRevealHelper = new ImageRevealHelper(this);
+ mGLView = glView;
+
+ if (mWallpaperManager != null) {
+ // Compute per85 as transition threshold, this is an async work.
+ mImageProcessHelper.startComputingPercentile85(mWallpaperManager.getBitmap());
+ }
+ }
+
+ @Override
+ public void onSurfaceCreated(GL10 gl, EGLConfig config) {
+ glClearColor(0f, 0f, 0f, 1.0f);
+ mProgram.useGLProgram(
+ R.raw.image_wallpaper_vertex_shader, R.raw.image_wallpaper_fragment_shader);
+ mWallpaper.setup();
+ mWallpaper.setupTexture(mWallpaperManager.getBitmap());
+ }
+
+ @Override
+ public void onSurfaceChanged(GL10 gl, int width, int height) {
+ glViewport(0, 0, width, height);
+ mWallpaper.adjustTextureCoordinates(mWallpaperManager.getBitmap(),
+ width, height, mXOffset, mYOffset);
+ }
+
+ @Override
+ public void onDrawFrame(GL10 gl) {
+ float threshold = mImageProcessHelper.getPercentile85();
+ float reveal = mImageRevealHelper.getReveal();
+
+ glClear(GL_COLOR_BUFFER_BIT);
+
+ glUniform1f(mWallpaper.getHandle(ImageGLWallpaper.U_AOD2OPACITY), .25f);
+ glUniform1f(mWallpaper.getHandle(ImageGLWallpaper.U_CENTER_REVEAL), threshold);
+ glUniform1f(mWallpaper.getHandle(ImageGLWallpaper.U_REVEAL), reveal);
+ glUniform1i(mWallpaper.getHandle(ImageGLWallpaper.U_AOD_MODE), mIsInAmbientMode ? 1 : 0);
+
+ mWallpaper.useTexture();
+ mWallpaper.draw();
+ }
+
+ @Override
+ public void onSensorEvent(boolean awake) {
+ mImageRevealHelper.updateAwake(awake);
+ }
+
+ @Override
+ public void onAmbientModeChanged(boolean inAmbientMode) {
+ mIsInAmbientMode = inAmbientMode;
+ if (inAmbientMode) {
+ mImageRevealHelper.sleep();
+ }
+ requestRender();
+ }
+
+ @Override
+ public void onOffsetsChanged(float xOffset, float yOffset, Rect frame) {
+ if (frame == null || mWallpaperManager == null
+ || (xOffset == mXOffset && yOffset == mYOffset)) {
+ return;
+ }
+
+ Bitmap bitmap = mWallpaperManager.getBitmap();
+ if (bitmap == null) {
+ return;
+ }
+
+ int width = frame.width();
+ int height = frame.height();
+ mXOffset = xOffset;
+ mYOffset = yOffset;
+
+ mWallpaper.adjustTextureCoordinates(bitmap, width, height, mXOffset, mYOffset);
+ requestRender();
+ }
+
+ @Override
+ public void onRevealStateChanged() {
+ requestRender();
+ }
+
+ private void requestRender() {
+ if (mGLView != null) {
+ mGLView.render();
+ }
+ }
+}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/MediaTransferManager.java b/packages/SystemUI/src/com/android/systemui/statusbar/MediaTransferManager.java
new file mode 100644
index 0000000..752b6a8
--- /dev/null
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/MediaTransferManager.java
@@ -0,0 +1,99 @@
+/*
+ * Copyright (C) 2019 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.systemui.statusbar;
+
+import android.content.Context;
+import android.content.Intent;
+import android.service.notification.StatusBarNotification;
+import android.util.FeatureFlagUtils;
+import android.view.View;
+import android.view.ViewGroup;
+import android.view.ViewParent;
+
+import com.android.settingslib.media.MediaOutputSliceConstants;
+import com.android.systemui.Dependency;
+import com.android.systemui.plugins.ActivityStarter;
+import com.android.systemui.statusbar.notification.collection.NotificationEntry;
+import com.android.systemui.statusbar.notification.row.ExpandableNotificationRow;
+
+/**
+ * Class for handling MediaTransfer state over a set of notifications.
+ */
+public class MediaTransferManager {
+ private final Context mContext;
+ private final ActivityStarter mActivityStarter;
+
+ private final View.OnClickListener mOnClickHandler = new View.OnClickListener() {
+ @Override
+ public void onClick(View view) {
+ if (handleMediaTransfer(view)) {
+ return;
+ }
+ }
+
+ private boolean handleMediaTransfer(View view) {
+ if (view.findViewById(com.android.internal.R.id.media_seamless) == null) {
+ return false;
+ }
+
+ ViewParent parent = view.getParent();
+ StatusBarNotification statusBarNotification = getNotificationForParent(parent);
+ final Intent intent = new Intent()
+ .setAction(MediaOutputSliceConstants.ACTION_MEDIA_OUTPUT)
+ .putExtra(MediaOutputSliceConstants.EXTRA_PACKAGE_NAME,
+ statusBarNotification.getPackageName());
+ mActivityStarter.startActivity(intent, false, true /* dismissShade */,
+ Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
+ return true;
+ }
+
+ private StatusBarNotification getNotificationForParent(ViewParent parent) {
+ while (parent != null) {
+ if (parent instanceof ExpandableNotificationRow) {
+ return ((ExpandableNotificationRow) parent).getStatusBarNotification();
+ }
+ parent = parent.getParent();
+ }
+ return null;
+ }
+ };
+
+ public MediaTransferManager(Context context) {
+ mContext = context;
+ mActivityStarter = Dependency.get(ActivityStarter.class);
+ }
+
+ /**
+ * apply the action button for MediaTransfer
+ *
+ * @param root The parent container of the view.
+ * @param entry The entry of MediaTransfer action button.
+ */
+ public void applyMediaTransferView(ViewGroup root, NotificationEntry entry) {
+ if (!FeatureFlagUtils.isEnabled(mContext, FeatureFlagUtils.SEAMLESS_TRANSFER)) {
+ return;
+ }
+
+ View view = root.findViewById(com.android.internal.R.id.media_seamless);
+ if (view == null) {
+ return;
+ }
+
+ view.setVisibility(View.VISIBLE);
+ view.setOnClickListener(mOnClickHandler);
+ }
+}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/NotificationListener.java b/packages/SystemUI/src/com/android/systemui/statusbar/NotificationListener.java
index 0583843..be63bad 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/NotificationListener.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/NotificationListener.java
@@ -55,8 +55,6 @@
private final ArrayList<NotificationSettingsListener> mSettingsListeners = new ArrayList<>();
private final Context mContext;
- protected NotificationPresenter mPresenter;
-
public NotificationListener(Context context) {
mContext = context;
}
@@ -152,9 +150,7 @@
}
}
- public void setUpWithPresenter(NotificationPresenter presenter) {
- mPresenter = presenter;
-
+ public void registerAsSystemService() {
try {
registerAsSystemService(mContext,
new ComponentName(mContext.getPackageName(), getClass().getCanonicalName()),
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/NotificationContentView.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/NotificationContentView.java
index c161da3..0a04f4d 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/NotificationContentView.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/NotificationContentView.java
@@ -43,6 +43,7 @@
import com.android.internal.util.ContrastColorUtil;
import com.android.systemui.Dependency;
import com.android.systemui.R;
+import com.android.systemui.statusbar.MediaTransferManager;
import com.android.systemui.statusbar.RemoteInputController;
import com.android.systemui.statusbar.SmartReplyController;
import com.android.systemui.statusbar.TransformableView;
@@ -163,11 +164,13 @@
private boolean mIsContentExpandable;
private boolean mRemoteInputVisible;
private int mUnrestrictedContentHeight;
+ private MediaTransferManager mMediaTransferManager;
public NotificationContentView(Context context, AttributeSet attrs) {
super(context, attrs);
mHybridGroupManager = new HybridGroupManager(getContext(), this);
+ mMediaTransferManager = new MediaTransferManager(getContext());
mSmartReplyConstants = Dependency.get(SmartReplyConstants.class);
mSmartReplyController = Dependency.get(SmartReplyController.class);
initView();
@@ -1250,6 +1253,7 @@
mAmbientWrapper.onContentUpdated(row);
}
applyRemoteInputAndSmartReply(entry);
+ applyMediaTransfer(entry);
updateLegacy();
mForceSelectNextLayout = true;
setDark(mDark, false /* animate */, 0 /* delay */);
@@ -1292,6 +1296,22 @@
}
}
+ private void applyMediaTransfer(final NotificationEntry entry) {
+ View bigContentView = mExpandedChild;
+ if (bigContentView == null || !entry.isMediaNotification()) {
+ return;
+ }
+
+ View mediaActionContainer = bigContentView.findViewById(
+ com.android.internal.R.id.media_actions);
+ if (!(mediaActionContainer instanceof LinearLayout)) {
+ return;
+ }
+
+ mMediaTransferManager.applyMediaTransferView((ViewGroup) mediaActionContainer,
+ entry);
+ }
+
private void applyRemoteInputAndSmartReply(final NotificationEntry entry) {
if (mRemoteInputController == null) {
return;
@@ -1314,16 +1334,21 @@
static SmartRepliesAndActions chooseSmartRepliesAndActions(
SmartReplyConstants smartReplyConstants,
final NotificationEntry entry) {
- boolean enableAppGeneratedSmartReplies = (smartReplyConstants.isEnabled()
- && (!smartReplyConstants.requiresTargetingP()
- || entry.targetSdk >= Build.VERSION_CODES.P));
-
Notification notification = entry.notification.getNotification();
Pair<RemoteInput, Notification.Action> remoteInputActionPair =
notification.findRemoteInputActionPair(false /* freeform */);
Pair<RemoteInput, Notification.Action> freeformRemoteInputActionPair =
notification.findRemoteInputActionPair(true /* freeform */);
+ if (!smartReplyConstants.isEnabled()) {
+ return new SmartRepliesAndActions(null, null, freeformRemoteInputActionPair != null);
+ }
+ // Only use smart replies from the app if they target P or above. We have this check because
+ // the smart reply API has been used for other things (Wearables) in the past. The API to
+ // add smart actions is new in Q so it doesn't require a target-sdk check.
+ boolean enableAppGeneratedSmartReplies = (!smartReplyConstants.requiresTargetingP()
+ || entry.targetSdk >= Build.VERSION_CODES.P);
+
boolean appGeneratedSmartRepliesExist =
enableAppGeneratedSmartReplies
&& remoteInputActionPair != null
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/NotificationGutsManager.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/NotificationGutsManager.java
index cb1384c..aa221993 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/NotificationGutsManager.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/NotificationGutsManager.java
@@ -25,7 +25,6 @@
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageManager;
-import android.metrics.LogMaker;
import android.net.Uri;
import android.os.ServiceManager;
import android.os.UserHandle;
@@ -392,12 +391,6 @@
return false;
}
- LogMaker logMaker = (row.getStatusBarNotification() == null)
- ? new LogMaker(MetricsProto.MetricsEvent.ACTION_NOTE_CONTROLS)
- : row.getStatusBarNotification().getLogMaker();
- mMetricsLogger.write(logMaker.setCategory(MetricsProto.MetricsEvent.ACTION_NOTE_CONTROLS)
- .setType(MetricsProto.MetricsEvent.TYPE_ACTION));
-
// ensure that it's laid but not visible until actually laid out
guts.setVisibility(View.INVISIBLE);
// Post to ensure the the guts are properly laid out.
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/NotificationInfo.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/NotificationInfo.java
index 359bc6e..b6948fc 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/NotificationInfo.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/NotificationInfo.java
@@ -126,18 +126,23 @@
private OnClickListener mOnKeepShowing = v -> {
mExitReason = NotificationCounters.BLOCKING_HELPER_KEEP_SHOWING;
closeControls(v);
- mMetricsLogger.write(getLogMaker().setCategory(MetricsEvent.NOTIFICATION_BLOCKING_HELPER)
- .setType(MetricsEvent.TYPE_ACTION)
- .setSubtype(MetricsEvent.BLOCKING_HELPER_CLICK_STAY_SILENT));
+ if (mIsForBlockingHelper) {
+ mMetricsLogger.write(getLogMaker().setCategory(
+ MetricsEvent.NOTIFICATION_BLOCKING_HELPER)
+ .setType(MetricsEvent.TYPE_ACTION)
+ .setSubtype(MetricsEvent.BLOCKING_HELPER_CLICK_STAY_SILENT));
+ }
};
private OnClickListener mOnToggleSilent = v -> {
Runnable saveImportance = () -> {
swapContent(ACTION_TOGGLE_SILENT, true /* animate */);
- mMetricsLogger.write(getLogMaker()
- .setCategory(MetricsEvent.NOTIFICATION_BLOCKING_HELPER)
- .setType(MetricsEvent.TYPE_ACTION)
- .setSubtype(MetricsEvent.BLOCKING_HELPER_CLICK_ALERT_ME));
+ if (mIsForBlockingHelper) {
+ mMetricsLogger.write(getLogMaker()
+ .setCategory(MetricsEvent.NOTIFICATION_BLOCKING_HELPER)
+ .setType(MetricsEvent.TYPE_ACTION)
+ .setSubtype(MetricsEvent.BLOCKING_HELPER_CLICK_ALERT_ME));
+ }
};
if (mCheckSaveListener != null) {
mCheckSaveListener.checkSave(saveImportance, mSbn);
@@ -149,10 +154,12 @@
private OnClickListener mOnStopOrMinimizeNotifications = v -> {
Runnable saveImportance = () -> {
swapContent(ACTION_BLOCK, true /* animate */);
- mMetricsLogger.write(getLogMaker()
- .setCategory(MetricsEvent.NOTIFICATION_BLOCKING_HELPER)
- .setType(MetricsEvent.TYPE_ACTION)
- .setSubtype(MetricsEvent.BLOCKING_HELPER_CLICK_BLOCKED));
+ if (mIsForBlockingHelper) {
+ mMetricsLogger.write(getLogMaker()
+ .setCategory(MetricsEvent.NOTIFICATION_BLOCKING_HELPER)
+ .setType(MetricsEvent.TYPE_ACTION)
+ .setSubtype(MetricsEvent.BLOCKING_HELPER_CLICK_BLOCKED));
+ }
};
if (mCheckSaveListener != null) {
mCheckSaveListener.checkSave(saveImportance, mSbn);
@@ -164,12 +171,16 @@
private OnClickListener mOnUndo = v -> {
// Reset exit counter that we'll log and record an undo event separately (not an exit event)
mExitReason = NotificationCounters.BLOCKING_HELPER_DISMISSED;
- logBlockingHelperCounter(NotificationCounters.BLOCKING_HELPER_UNDO);
- mMetricsLogger.write(importanceChangeLogMaker().setType(MetricsEvent.TYPE_DISMISS));
+ if (mIsForBlockingHelper) {
+ logBlockingHelperCounter(NotificationCounters.BLOCKING_HELPER_UNDO);
+ mMetricsLogger.write(getLogMaker().setCategory(
+ MetricsEvent.NOTIFICATION_BLOCKING_HELPER)
+ .setType(MetricsEvent.TYPE_DISMISS)
+ .setSubtype(MetricsEvent.BLOCKING_HELPER_CLICK_UNDO));
+ } else {
+ mMetricsLogger.write(importanceChangeLogMaker().setType(MetricsEvent.TYPE_DISMISS));
+ }
swapContent(ACTION_UNDO, true /* animate */);
- mMetricsLogger.write(getLogMaker().setCategory(MetricsEvent.NOTIFICATION_BLOCKING_HELPER)
- .setType(MetricsEvent.TYPE_DISMISS)
- .setSubtype(MetricsEvent.BLOCKING_HELPER_CLICK_UNDO));
};
public NotificationInfo(Context context, AttributeSet attrs) {
@@ -269,11 +280,11 @@
bindPrompt();
bindButtons();
- mMetricsLogger.write(getLogMaker().setCategory(MetricsEvent.NOTIFICATION_BLOCKING_HELPER)
- .setType(MetricsEvent.TYPE_OPEN)
- .setSubtype(MetricsEvent.BLOCKING_HELPER_DISPLAY));
+ mMetricsLogger.write(notificationControlsLogMaker());
}
+
+
private void bindHeader() throws RemoteException {
// Package name
Drawable pkgicon = null;
@@ -404,19 +415,6 @@
}
}
- /**
- * Returns an initialized LogMaker for logging importance changes.
- * The caller may override the type (to DISMISS) before passing it to mMetricsLogger.
- * @return new LogMaker
- */
- private LogMaker importanceChangeLogMaker() {
- Integer chosenImportance =
- mChosenImportance != null ? mChosenImportance : mStartingChannelImportance;
- return new LogMaker(MetricsEvent.ACTION_SAVE_IMPORTANCE)
- .setType(MetricsEvent.TYPE_ACTION)
- .setSubtype(chosenImportance - mStartingChannelImportance);
- }
-
private boolean hasImportanceChanged() {
return mSingleNotificationChannel != null
&& mChosenImportance != null
@@ -616,8 +614,8 @@
confirmation.setAlpha(1f);
header.setVisibility(VISIBLE);
header.setAlpha(1f);
- mMetricsLogger.write(getLogMaker().setCategory(MetricsEvent.NOTIFICATION_BLOCKING_HELPER)
- .setType(MetricsEvent.TYPE_CLOSE));
+
+ mMetricsLogger.write(notificationControlsLogMaker().setType(MetricsEvent.TYPE_CLOSE));
}
@Override
@@ -764,7 +762,39 @@
}
}
+ /**
+ * Returns a LogMaker with all available notification information.
+ * Caller should set category, type, and maybe subtype, before passing it to mMetricsLogger.
+ * @return LogMaker
+ */
private LogMaker getLogMaker() {
- return mSbn.getLogMaker();
+ // The constructor requires a category, so also do it in the other branch for consistency.
+ return mSbn == null ? new LogMaker(MetricsEvent.NOTIFICATION_BLOCKING_HELPER)
+ : mSbn.getLogMaker().setCategory(MetricsEvent.NOTIFICATION_BLOCKING_HELPER);
+ }
+
+ /**
+ * Returns an initialized LogMaker for logging importance changes.
+ * The caller may override the type before passing it to mMetricsLogger.
+ * @return LogMaker
+ */
+ private LogMaker importanceChangeLogMaker() {
+ Integer chosenImportance =
+ mChosenImportance != null ? mChosenImportance : mStartingChannelImportance;
+ return getLogMaker().setCategory(MetricsEvent.ACTION_SAVE_IMPORTANCE)
+ .setType(MetricsEvent.TYPE_ACTION)
+ .setSubtype(chosenImportance - mStartingChannelImportance);
+ }
+
+ /**
+ * Returns an initialized LogMaker for logging open/close of the info display.
+ * The caller may override the type before passing it to mMetricsLogger.
+ * @return LogMaker
+ */
+ private LogMaker notificationControlsLogMaker() {
+ return getLogMaker().setCategory(MetricsEvent.ACTION_NOTE_CONTROLS)
+ .setType(MetricsEvent.TYPE_OPEN)
+ .setSubtype(mIsForBlockingHelper ? MetricsEvent.BLOCKING_HELPER_DISPLAY
+ : MetricsEvent.BLOCKING_HELPER_UNKNOWN);
}
}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java
index ceadd1e..8796e0a 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java
@@ -480,8 +480,7 @@
updateAodMaskVisibility(deviceSupportsAodWallpaper && aodImageWallpaperEnabled);
// If WallpaperInfo is null, it must be ImageWallpaper.
final boolean supportsAmbientMode = deviceSupportsAodWallpaper
- && (info == null && aodImageWallpaperEnabled
- || info != null && info.supportsAmbientMode());
+ && (info == null || info.supportsAmbientMode());
mStatusBarWindowController.setWallpaperSupportsAmbientMode(supportsAmbientMode);
mScrimController.setWallpaperSupportsAmbientMode(supportsAmbientMode);
@@ -613,6 +612,7 @@
mNotificationLogger = Dependency.get(NotificationLogger.class);
mRemoteInputManager = Dependency.get(NotificationRemoteInputManager.class);
mNotificationListener = Dependency.get(NotificationListener.class);
+ mNotificationListener.registerAsSystemService();
mNetworkController = Dependency.get(NetworkController.class);
mUserSwitcherController = Dependency.get(UserSwitcherController.class);
mScreenLifecycle = Dependency.get(ScreenLifecycle.class);
@@ -1055,7 +1055,6 @@
mDeviceProvisionedController);
mAppOpsController.addCallback(APP_OPS, this);
- mNotificationListener.setUpWithPresenter(mPresenter);
mNotificationShelf.setOnActivatedListener(mPresenter);
mRemoteInputManager.getController().addCallback(mStatusBarWindowController);
@@ -1445,6 +1444,7 @@
return new StatusBar.H();
}
+ @Override
public void startActivity(Intent intent, boolean onlyProvisioned, boolean dismissShade,
int flags) {
startActivityDismissingKeyguard(intent, onlyProvisioned, dismissShade, flags);
diff --git a/packages/SystemUI/src/com/android/systemui/wallpaper/AodMaskView.java b/packages/SystemUI/src/com/android/systemui/wallpaper/AodMaskView.java
index 52cabe2..dd1d0ca 100644
--- a/packages/SystemUI/src/com/android/systemui/wallpaper/AodMaskView.java
+++ b/packages/SystemUI/src/com/android/systemui/wallpaper/AodMaskView.java
@@ -156,6 +156,8 @@
private boolean checkIfNeedMask() {
// We need mask for ImageWallpaper / LockScreen Wallpaper (Music album art).
+ // Because of conflicting with another wallpaper feature,
+ // we only support LockScreen wallpaper currently.
return mWallpaperManager.getWallpaperInfo() == null || ScrimState.AOD.hasBackdrop();
}
diff --git a/packages/SystemUI/tests/src/com/android/systemui/bubbles/BubbleControllerTest.java b/packages/SystemUI/tests/src/com/android/systemui/bubbles/BubbleControllerTest.java
index 6a3bd73..5be8826 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/bubbles/BubbleControllerTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/bubbles/BubbleControllerTest.java
@@ -77,6 +77,10 @@
@Mock
private NotificationData mNotificationData;
+ @Mock
+ private BubbleController.BubbleStateChangeListener mBubbleStateChangeListener;
+ @Mock
+ private BubbleController.BubbleExpandListener mBubbleExpandListener;
@Before
public void setUp() throws Exception {
@@ -101,6 +105,8 @@
when(mNotificationData.getChannel(mNoChannelRow.getEntry().key)).thenReturn(null);
mBubbleController = new TestableBubbleController(mContext, mStatusBarWindowController);
+ mBubbleController.setBubbleStateChangeListener(mBubbleStateChangeListener);
+ mBubbleController.setExpandListener(mBubbleExpandListener);
// Get a reference to the BubbleController's entry listener
verify(mNotificationEntryManager, atLeastOnce())
@@ -112,6 +118,8 @@
public void testAddBubble() {
mBubbleController.updateBubble(mRow.getEntry(), true /* updatePosition */);
assertTrue(mBubbleController.hasBubbles());
+
+ verify(mBubbleStateChangeListener).onHasBubblesChanged(true);
}
@Test
@@ -126,10 +134,14 @@
mBubbleController.updateBubble(mRow.getEntry(), true /* updatePosition */);
assertTrue(mBubbleController.hasBubbles());
+ verify(mBubbleStateChangeListener).onHasBubblesChanged(true);
+
mBubbleController.removeBubble(mRow.getEntry().key);
assertFalse(mStatusBarWindowController.getBubblesShowing());
assertTrue(mRow.getEntry().isBubbleDismissed());
verify(mNotificationEntryManager).updateNotifications();
+
+ verify(mBubbleStateChangeListener).onHasBubblesChanged(false);
}
@Test
@@ -141,41 +153,133 @@
mBubbleController.dismissStack();
assertFalse(mStatusBarWindowController.getBubblesShowing());
verify(mNotificationEntryManager).updateNotifications();
+ assertTrue(mRow.getEntry().isBubbleDismissed());
+ assertTrue(mRow2.getEntry().isBubbleDismissed());
}
@Test
- public void testIsStackExpanded() {
+ public void testExpandCollapseStack() {
assertFalse(mBubbleController.isStackExpanded());
+
+ // Mark it as a bubble and add it explicitly
+ mEntryListener.onPendingEntryAdded(mRow.getEntry());
mBubbleController.updateBubble(mRow.getEntry(), true /* updatePosition */);
+ // We should have bubbles & their notifs should show in the shade
+ assertTrue(mBubbleController.hasBubbles());
+ assertTrue(mRow.getEntry().showInShadeWhenBubble());
+
+ // Expand the stack
BubbleStackView stackView = mBubbleController.getStackView();
stackView.expandStack();
assertTrue(mBubbleController.isStackExpanded());
+ verify(mBubbleExpandListener).onBubbleExpandChanged(true, mRow.getEntry().key);
+ // Make sure it's no longer in the shade
+ assertFalse(mRow.getEntry().showInShadeWhenBubble());
+
+ // Collapse
stackView.collapseStack();
+ verify(mBubbleExpandListener).onBubbleExpandChanged(false, mRow.getEntry().key);
assertFalse(mBubbleController.isStackExpanded());
}
@Test
- public void testCollapseStack() {
+ public void testCollapseAfterChangingExpandedBubble() {
+ // Mark it as a bubble and add it explicitly
+ mEntryListener.onPendingEntryAdded(mRow.getEntry());
+ mEntryListener.onPendingEntryAdded(mRow2.getEntry());
mBubbleController.updateBubble(mRow.getEntry(), true /* updatePosition */);
mBubbleController.updateBubble(mRow2.getEntry(), true /* updatePosition */);
+ // We should have bubbles & their notifs should show in the shade
+ assertTrue(mBubbleController.hasBubbles());
+ assertTrue(mRow.getEntry().showInShadeWhenBubble());
+ assertTrue(mRow2.getEntry().showInShadeWhenBubble());
+
+ // Expand
BubbleStackView stackView = mBubbleController.getStackView();
stackView.expandStack();
assertTrue(mBubbleController.isStackExpanded());
+ verify(mBubbleExpandListener).onBubbleExpandChanged(true, mRow2.getEntry().key);
+ // Last added is the one that is expanded
+ assertEquals(mRow2.getEntry(), stackView.getExpandedBubble().getEntry());
+ assertFalse(mRow2.getEntry().showInShadeWhenBubble());
+
+ // Switch which bubble is expanded
stackView.setExpandedBubble(mRow.getEntry());
- assertEquals(stackView.getExpandedBubble().getEntry(), mRow.getEntry());
+ assertEquals(mRow.getEntry(), stackView.getExpandedBubble().getEntry());
+ assertFalse(mRow.getEntry().showInShadeWhenBubble());
- stackView.setExpandedBubble(mRow2.getEntry());
- assertEquals(stackView.getExpandedBubble().getEntry(), mRow2.getEntry());
+ // collapse for previous bubble
+ verify(mBubbleExpandListener).onBubbleExpandChanged(false, mRow2.getEntry().key);
+ // expand for selected bubble
+ verify(mBubbleExpandListener).onBubbleExpandChanged(true, mRow.getEntry().key);
+ // Collapse
mBubbleController.collapseStack();
assertFalse(mBubbleController.isStackExpanded());
}
@Test
+ public void testExpansionRemovesShowInShade() {
+ // Mark it as a bubble and add it explicitly
+ mEntryListener.onPendingEntryAdded(mRow.getEntry());
+ mBubbleController.updateBubble(mRow.getEntry(), true /* updatePosition */);
+
+ // We should have bubbles & their notifs should show in the shade
+ assertTrue(mBubbleController.hasBubbles());
+ assertTrue(mRow.getEntry().showInShadeWhenBubble());
+
+ // Expand
+ BubbleStackView stackView = mBubbleController.getStackView();
+ stackView.expandStack();
+ assertTrue(mBubbleController.isStackExpanded());
+ verify(mBubbleExpandListener).onBubbleExpandChanged(true, mRow.getEntry().key);
+
+ // No longer show shade in notif after expansion
+ assertFalse(mRow.getEntry().showInShadeWhenBubble());
+ }
+
+ @Test
+ public void testRemoveLastExpandedCollapses() {
+ // Mark it as a bubble and add it explicitly
+ mEntryListener.onPendingEntryAdded(mRow.getEntry());
+ mEntryListener.onPendingEntryAdded(mRow2.getEntry());
+ mBubbleController.updateBubble(mRow.getEntry(), true /* updatePosition */);
+ mBubbleController.updateBubble(mRow2.getEntry(), true /* updatePosition */);
+ verify(mBubbleStateChangeListener).onHasBubblesChanged(true);
+
+ // Expand
+ BubbleStackView stackView = mBubbleController.getStackView();
+ stackView.expandStack();
+
+ assertTrue(mBubbleController.isStackExpanded());
+ verify(mBubbleExpandListener).onBubbleExpandChanged(true, mRow2.getEntry().key);
+
+ // Last added is the one that is expanded
+ assertEquals(mRow2.getEntry(), stackView.getExpandedBubble().getEntry());
+ assertFalse(mRow2.getEntry().showInShadeWhenBubble());
+
+ // Dismiss currently expanded
+ mBubbleController.removeBubble(stackView.getExpandedBubble().getKey());
+ verify(mBubbleExpandListener).onBubbleExpandChanged(false, mRow2.getEntry().key);
+
+ // Make sure next bubble is selected
+ assertEquals(mRow.getEntry(), stackView.getExpandedBubble().getEntry());
+ verify(mBubbleExpandListener).onBubbleExpandChanged(true, mRow.getEntry().key);
+
+ // Dismiss that one
+ mBubbleController.removeBubble(stackView.getExpandedBubble().getKey());
+
+ // Make sure state changes and collapse happens
+ verify(mBubbleExpandListener).onBubbleExpandChanged(false, mRow.getEntry().key);
+ verify(mBubbleStateChangeListener).onHasBubblesChanged(false);
+ assertFalse(mBubbleController.hasBubbles());
+ }
+
+ @Test
public void testMarkNewNotificationAsBubble() {
mEntryListener.onPendingEntryAdded(mRow.getEntry());
assertTrue(mRow.getEntry().isBubble());
diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/NonPhoneDependencyTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/NonPhoneDependencyTest.java
index 425ca58..8e926848 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/NonPhoneDependencyTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/NonPhoneDependencyTest.java
@@ -97,7 +97,6 @@
mDelegate);
lockscreenUserManager.setUpWithPresenter(mPresenter);
viewHierarchyManager.setUpWithPresenter(mPresenter, mListContainer);
- notificationListener.setUpWithPresenter(mPresenter);
TestableLooper.get(this).processAllMessages();
assertFalse(mDependency.hasInstantiatedDependency(StatusBarWindowController.class));
diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/NotificationListenerTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/NotificationListenerTest.java
index bcf5964..cffa9c7 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/NotificationListenerTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/NotificationListenerTest.java
@@ -77,8 +77,6 @@
mListener = new NotificationListener(mContext);
mSbn = new StatusBarNotification(TEST_PACKAGE_NAME, TEST_PACKAGE_NAME, 0, null, TEST_UID, 0,
new Notification(), UserHandle.CURRENT, null, 0);
-
- mListener.setUpWithPresenter(mPresenter);
}
@Test
diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/row/NotificationContentViewTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/row/NotificationContentViewTest.java
index d94bf84..c36fec2 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/row/NotificationContentViewTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/row/NotificationContentViewTest.java
@@ -193,14 +193,32 @@
}
@Test
- public void chooseSmartRepliesAndActions_smartRepliesOff_noAppGeneratedSmartReplies() {
- setupAppGeneratedReplies(new String[] {"Reply1", "Reply2"});
+ public void chooseSmartRepliesAndActions_smartRepliesOff_noAppGeneratedSmartSuggestions() {
+ CharSequence[] smartReplies = new String[] {"Reply1", "Reply2"};
+ List<Notification.Action> smartActions =
+ createActions(new String[] {"Test Action 1", "Test Action 2"});
+ setupAppGeneratedSuggestions(smartReplies, smartActions);
when(mSmartReplyConstants.isEnabled()).thenReturn(false);
NotificationContentView.SmartRepliesAndActions repliesAndActions =
NotificationContentView.chooseSmartRepliesAndActions(mSmartReplyConstants, mEntry);
assertThat(repliesAndActions.smartReplies).isNull();
+ assertThat(repliesAndActions.smartActions).isNull();
+ }
+
+ @Test
+ public void chooseSmartRepliesAndActions_smartRepliesOff_noSystemGeneratedSmartSuggestions() {
+ mEntry.smartReplies = new String[] {"Sys Smart Reply 1", "Sys Smart Reply 2"};
+ mEntry.systemGeneratedSmartActions =
+ createActions(new String[] {"Sys Smart Action 1", "Sys Smart Action 2"});
+ when(mSmartReplyConstants.isEnabled()).thenReturn(false);
+
+ NotificationContentView.SmartRepliesAndActions repliesAndActions =
+ NotificationContentView.chooseSmartRepliesAndActions(mSmartReplyConstants, mEntry);
+
+ assertThat(repliesAndActions.smartReplies).isNull();
+ assertThat(repliesAndActions.smartActions).isNull();
}
@Test
diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/row/NotificationGutsManagerTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/row/NotificationGutsManagerTest.java
index fdc9e0c..727e9af 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/row/NotificationGutsManagerTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/row/NotificationGutsManagerTest.java
@@ -45,7 +45,6 @@
import android.app.NotificationChannel;
import android.content.Intent;
import android.content.pm.PackageManager;
-import android.metrics.LogMaker;
import android.os.Binder;
import android.os.Handler;
import android.provider.Settings;
@@ -57,7 +56,6 @@
import android.view.View;
import com.android.internal.logging.MetricsLogger;
-import com.android.internal.logging.nano.MetricsProto;
import com.android.systemui.SysuiTestCase;
import com.android.systemui.plugins.statusbar.NotificationMenuRowPlugin;
import com.android.systemui.statusbar.NotificationPresenter;
@@ -220,34 +218,6 @@
}
@Test
- public void testOpenGutsLogging() {
- NotificationGutsManager gutsManager = spy(mGutsManager);
- doReturn(true).when(gutsManager).bindGuts(any(), any());
-
- NotificationGuts guts = spy(new NotificationGuts(mContext));
- doReturn(true).when(guts).post(any());
-
- ExpandableNotificationRow realRow = createTestNotificationRow();
- NotificationMenuRowPlugin.MenuItem menuItem = createTestMenuItem(realRow);
-
- ExpandableNotificationRow row = spy(realRow);
- when(row.getWindowToken()).thenReturn(new Binder());
- when(row.getGuts()).thenReturn(guts);
- StatusBarNotification notification = spy(realRow.getStatusBarNotification());
- when(row.getStatusBarNotification()).thenReturn(notification);
-
- assertTrue(gutsManager.openGuts(row, 0, 0, menuItem));
-
- ArgumentCaptor<LogMaker> logMakerCaptor = ArgumentCaptor.forClass(LogMaker.class);
- verify(notification).getLogMaker();
- verify(mMetricsLogger).write(logMakerCaptor.capture());
- assertEquals(MetricsProto.MetricsEvent.ACTION_NOTE_CONTROLS,
- logMakerCaptor.getValue().getCategory());
- assertEquals(MetricsProto.MetricsEvent.TYPE_ACTION,
- logMakerCaptor.getValue().getType());
- }
-
- @Test
public void testAppOpsSettingsIntent_camera() {
ArraySet<Integer> ops = new ArraySet<>();
ops.add(OP_CAMERA);
diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/row/NotificationInfoTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/row/NotificationInfoTest.java
index 554baaf..2a64445 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/row/NotificationInfoTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/row/NotificationInfoTest.java
@@ -83,7 +83,6 @@
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.ArgumentCaptor;
-import org.mockito.ArgumentMatcher;
import org.mockito.Mock;
import org.mockito.junit.MockitoJUnit;
import org.mockito.junit.MockitoRule;
@@ -107,11 +106,16 @@
private NotificationChannel mDefaultNotificationChannel;
private StatusBarNotification mSbn;
- @Rule public MockitoRule mockito = MockitoJUnit.rule();
- @Mock private MetricsLogger mMetricsLogger;
- @Mock private INotificationManager mMockINotificationManager;
- @Mock private PackageManager mMockPackageManager;
- @Mock private NotificationBlockingHelperManager mBlockingHelperManager;
+ @Rule
+ public MockitoRule mockito = MockitoJUnit.rule();
+ @Mock
+ private MetricsLogger mMetricsLogger;
+ @Mock
+ private INotificationManager mMockINotificationManager;
+ @Mock
+ private PackageManager mMockPackageManager;
+ @Mock
+ private NotificationBlockingHelperManager mBlockingHelperManager;
@Before
public void setUp() throws Exception {
@@ -172,44 +176,25 @@
PollingCheck.waitFor(1000,
() -> VISIBLE == mNotificationInfo.findViewById(R.id.confirmation).getVisibility());
}
+
private void ensureNoUndoButton() {
PollingCheck.waitFor(1000,
() -> GONE == mNotificationInfo.findViewById(R.id.confirmation).getVisibility()
&& !mNotificationInfo.isAnimating());
}
+
private void waitForStopButton() {
PollingCheck.waitFor(1000,
() -> VISIBLE == mNotificationInfo.findViewById(R.id.prompt).getVisibility());
}
- class ImportanceChangeLogMaker implements ArgumentMatcher<LogMaker> {
- private static final int CATEGORY = MetricsProto.MetricsEvent.ACTION_SAVE_IMPORTANCE;
- private int mType, mSubtype;
-
- ImportanceChangeLogMaker(int type, int subtype) {
- mType = type;
- mSubtype = subtype;
- }
- public boolean matches(LogMaker l) {
- return (l.getCategory() == CATEGORY)
- && (l.getType() == mType)
- && (l.getSubtype() == mSubtype);
- }
-
- public String toString() {
- return String.format("LogMaker(%d, %d, %d)", CATEGORY, mType, mSubtype);
- }
- }
-
- private LogMaker importanceChangeLog(int type, int subtype) {
- return argThat(new ImportanceChangeLogMaker(type, subtype));
- }
-
@Test
public void testBindNotification_SetsTextApplicationName() throws Exception {
when(mMockPackageManager.getApplicationLabel(any())).thenReturn("App Name");
mNotificationInfo.bindNotification(mMockPackageManager, mMockINotificationManager,
- TEST_PACKAGE_NAME, mNotificationChannel, 1, mSbn, null, null, null, true, false,
+ TEST_PACKAGE_NAME, mNotificationChannel, 1, mSbn,
+ null, null, null,
+ true, false,
IMPORTANCE_DEFAULT, true);
final TextView textView = mNotificationInfo.findViewById(R.id.pkgname);
assertTrue(textView.getText().toString().contains("App Name"));
@@ -330,9 +315,9 @@
@Test
public void testBindNotification_BlockButton() throws Exception {
- mNotificationInfo.bindNotification(mMockPackageManager, mMockINotificationManager,
- TEST_PACKAGE_NAME, mNotificationChannel, 1, mSbn, null, null, null, true, false,
- IMPORTANCE_DEFAULT, true);
+ mNotificationInfo.bindNotification(mMockPackageManager, mMockINotificationManager,
+ TEST_PACKAGE_NAME, mNotificationChannel, 1, mSbn, null, null, null, true, false,
+ IMPORTANCE_DEFAULT, true);
final View block = mNotificationInfo.findViewById(R.id.int_block);
final View minimize = mNotificationInfo.findViewById(R.id.block_or_minimize);
assertEquals(VISIBLE, block.getVisibility());
@@ -340,7 +325,7 @@
}
@Test
- public void testBindNotification_BlockButton_BlockHelper() throws Exception {
+ public void testBindNotification_BlockButton_BlockingHelper() throws Exception {
mNotificationInfo.bindNotification(mMockPackageManager, mMockINotificationManager,
TEST_PACKAGE_NAME, mNotificationChannel, 1, mSbn, null, null, null, true, false,
true /* isBlockingHelper */, false, IMPORTANCE_DEFAULT, true);
@@ -498,13 +483,29 @@
}
@Test
- public void testLogBlockingHelperCounter_logGutsViewDisplayed() throws Exception {
+ public void testBindNotificationLogging_notBlockingHelper() throws Exception {
mNotificationInfo.bindNotification(mMockPackageManager, mMockINotificationManager,
- TEST_PACKAGE_NAME, mNotificationChannel, 1, mSbn, null, null, null, true, false,
+ TEST_PACKAGE_NAME, mNotificationChannel, 1, mSbn,
+ null, null, null,
+ true, false,
IMPORTANCE_DEFAULT, true);
- mNotificationInfo.logBlockingHelperCounter("HowCanNotifsBeRealIfAppsArent");
verify(mMetricsLogger).write(argThat(logMaker ->
- logMaker.getCategory() == MetricsEvent.NOTIFICATION_BLOCKING_HELPER
+ logMaker.getCategory() == MetricsEvent.ACTION_NOTE_CONTROLS
+ && logMaker.getType() == MetricsEvent.TYPE_OPEN
+ && logMaker.getSubtype() == MetricsEvent.BLOCKING_HELPER_UNKNOWN
+ ));
+ }
+
+ @Test
+ public void testBindNotificationLogging_BlockingHelper() throws Exception {
+ mNotificationInfo.bindNotification(mMockPackageManager, mMockINotificationManager,
+ TEST_PACKAGE_NAME, mNotificationChannel, 1, mSbn,
+ null, null, null,
+ false, true,
+ true, true,
+ IMPORTANCE_DEFAULT, true);
+ verify(mMetricsLogger).write(argThat(logMaker ->
+ logMaker.getCategory() == MetricsEvent.ACTION_NOTE_CONTROLS
&& logMaker.getType() == MetricsEvent.TYPE_OPEN
&& logMaker.getSubtype() == MetricsEvent.BLOCKING_HELPER_DISPLAY
));
@@ -513,8 +514,11 @@
@Test
public void testLogBlockingHelperCounter_logsForBlockingHelper() throws Exception {
mNotificationInfo.bindNotification(mMockPackageManager, mMockINotificationManager,
- TEST_PACKAGE_NAME, mNotificationChannel, 1, mSbn, null, null, null, false, true,
- true, true, IMPORTANCE_DEFAULT, true);
+ TEST_PACKAGE_NAME, mNotificationChannel, 1, mSbn,
+ null, null, null,
+ false, true,
+ true, true,
+ IMPORTANCE_DEFAULT, true);
mNotificationInfo.logBlockingHelperCounter("HowCanNotifsBeRealIfAppsArent");
verify(mMetricsLogger).count(eq("HowCanNotifsBeRealIfAppsArent"), eq(1));
}
@@ -680,7 +684,7 @@
mNotificationInfo.bindNotification(mMockPackageManager, mMockINotificationManager,
TEST_PACKAGE_NAME, mNotificationChannel /* notificationChannel */,
10 /* numUniqueChannelsInRow */, mSbn, null /* checkSaveListener */,
- null /* onSettingsClick */, null /* onAppSettingsClick */ ,
+ null /* onSettingsClick */, null /* onAppSettingsClick */,
true, false /* isNonblockable */, IMPORTANCE_DEFAULT, false
);
@@ -722,7 +726,7 @@
mNotificationInfo.bindNotification(mMockPackageManager, mMockINotificationManager,
TEST_PACKAGE_NAME, mNotificationChannel /* notificationChannel */,
10 /* numUniqueChannelsInRow */, mSbn, null /* checkSaveListener */,
- null /* onSettingsClick */, null /* onAppSettingsClick */ ,
+ null /* onSettingsClick */, null /* onAppSettingsClick */,
true /* provisioned */,
false /* isNonblockable */, true /* isForBlockingHelper */,
true /* isUserSentimentNegative */, IMPORTANCE_DEFAULT, true);
@@ -744,14 +748,14 @@
}
@Test
- public void testCloseControls_nonNullCheckSaveListenerDoesntDelayKeepShowing()
+ public void testCloseControls_nonNullCheckSaveListenerDoesntDelayKeepShowing_BlockingHelper()
throws Exception {
NotificationInfo.CheckSaveListener listener =
mock(NotificationInfo.CheckSaveListener.class);
mNotificationInfo.bindNotification(mMockPackageManager, mMockINotificationManager,
TEST_PACKAGE_NAME, mNotificationChannel /* notificationChannel */,
10 /* numUniqueChannelsInRow */, mSbn, listener /* checkSaveListener */,
- null /* onSettingsClick */, null /* onAppSettingsClick */ , true /* provisioned */,
+ null /* onSettingsClick */, null /* onAppSettingsClick */, true /* provisioned */,
false /* isNonblockable */, true /* isForBlockingHelper */,
true /* isUserSentimentNegative */, IMPORTANCE_DEFAULT, true);
@@ -772,14 +776,14 @@
}
@Test
- public void testCloseControls_nonNullCheckSaveListenerDoesntDelayDismiss()
+ public void testCloseControls_nonNullCheckSaveListenerDoesntDelayDismiss_BlockingHelper()
throws Exception {
NotificationInfo.CheckSaveListener listener =
mock(NotificationInfo.CheckSaveListener.class);
mNotificationInfo.bindNotification(mMockPackageManager, mMockINotificationManager,
TEST_PACKAGE_NAME, mNotificationChannel /* notificationChannel */,
10 /* numUniqueChannelsInRow */, mSbn, listener /* checkSaveListener */,
- null /* onSettingsClick */, null /* onAppSettingsClick */ ,
+ null /* onSettingsClick */, null /* onAppSettingsClick */,
false /* isNonblockable */, true /* isForBlockingHelper */,
true, true /* isUserSentimentNegative */, /* isNoisy */
IMPORTANCE_DEFAULT, true);
@@ -791,7 +795,7 @@
}
@Test
- public void testCloseControls_checkSaveListenerDelaysStopNotifications()
+ public void testCloseControls_checkSaveListenerDelaysStopNotifications_BlockingHelper()
throws Exception {
NotificationInfo.CheckSaveListener listener =
mock(NotificationInfo.CheckSaveListener.class);
@@ -849,18 +853,25 @@
}
@Test
- public void testBlockChangedCallsUpdateNotificationChannel() throws Exception {
+ public void testBlockChangedCallsUpdateNotificationChannel_notBlockingHelper()
+ throws Exception {
mNotificationChannel.setImportance(IMPORTANCE_LOW);
mNotificationInfo.bindNotification(mMockPackageManager, mMockINotificationManager,
- TEST_PACKAGE_NAME, mNotificationChannel, 1, mSbn, null, null, null, true, false,
+ TEST_PACKAGE_NAME, mNotificationChannel, 1, mSbn,
+ null, null, null,
+ true, false,
IMPORTANCE_DEFAULT, false);
mNotificationInfo.findViewById(R.id.int_block).performClick();
waitForUndoButton();
mNotificationInfo.handleCloseControls(true, false);
- verify(mMetricsLogger).write(importanceChangeLog(
- MetricsProto.MetricsEvent.TYPE_ACTION, IMPORTANCE_NONE - IMPORTANCE_LOW));
+ ArgumentCaptor<LogMaker> logMakerCaptor = ArgumentCaptor.forClass(LogMaker.class);
+ verify(mMetricsLogger, times(2)).write(logMakerCaptor.capture());
+ assertEquals(MetricsProto.MetricsEvent.TYPE_ACTION,
+ logMakerCaptor.getValue().getType());
+ assertEquals(IMPORTANCE_NONE - IMPORTANCE_LOW,
+ logMakerCaptor.getValue().getSubtype());
mTestableLooper.processAllMessages();
ArgumentCaptor<NotificationChannel> updated =
@@ -896,8 +907,12 @@
waitForUndoButton();
mNotificationInfo.handleCloseControls(true, false);
- verify(mMetricsLogger).write(importanceChangeLog(
- MetricsProto.MetricsEvent.TYPE_ACTION, IMPORTANCE_NONE - IMPORTANCE_LOW));
+ ArgumentCaptor<LogMaker> logMakerCaptor = ArgumentCaptor.forClass(LogMaker.class);
+ verify(mMetricsLogger, times(3)).write(logMakerCaptor.capture());
+ assertEquals(MetricsProto.MetricsEvent.TYPE_ACTION,
+ logMakerCaptor.getValue().getType());
+ assertEquals(IMPORTANCE_NONE - IMPORTANCE_LOW,
+ logMakerCaptor.getValue().getSubtype());
mTestableLooper.processAllMessages();
ArgumentCaptor<NotificationChannel> updated =
@@ -965,10 +980,12 @@
}
@Test
- public void testBlockUndoDoesNotBlockNotificationChannel() throws Exception {
+ public void testBlockUndoDoesNotBlockNotificationChannel_notBlockingHelper() throws Exception {
mNotificationChannel.setImportance(IMPORTANCE_LOW);
mNotificationInfo.bindNotification(mMockPackageManager, mMockINotificationManager,
- TEST_PACKAGE_NAME, mNotificationChannel, 1, mSbn, null, null, null, true, false,
+ TEST_PACKAGE_NAME, mNotificationChannel, 1, mSbn,
+ null, null, null,
+ true, false,
IMPORTANCE_DEFAULT, false);
mNotificationInfo.findViewById(R.id.int_block).performClick();
@@ -977,8 +994,15 @@
waitForStopButton();
// mNotificationInfo.handleCloseControls doesn't get called by this interaction.
- verify(mMetricsLogger).write(importanceChangeLog(
- MetricsProto.MetricsEvent.TYPE_DISMISS, IMPORTANCE_NONE - IMPORTANCE_LOW));
+ ArgumentCaptor<LogMaker> logMakerCaptor = ArgumentCaptor.forClass(LogMaker.class);
+ verify(mMetricsLogger, times(2)).write(logMakerCaptor.capture());
+ assertEquals(MetricsEvent.ACTION_SAVE_IMPORTANCE,
+ logMakerCaptor.getValue().getCategory());
+ assertEquals(MetricsEvent.TYPE_DISMISS,
+ logMakerCaptor.getValue().getType());
+ assertEquals(IMPORTANCE_NONE - IMPORTANCE_LOW,
+ logMakerCaptor.getValue().getSubtype());
+
mTestableLooper.processAllMessages();
verify(mMockINotificationManager, never()).updateNotificationChannelForPackage(
@@ -986,11 +1010,12 @@
}
@Test
- public void testMinUndoDoesNotMinNotificationChannel() throws Exception {
+ public void testMinUndoDoesNotMinNotificationChannel_notBlockingHelper() throws Exception {
mNotificationChannel.setImportance(IMPORTANCE_LOW);
mNotificationInfo.bindNotification(mMockPackageManager, mMockINotificationManager,
- TEST_PACKAGE_NAME, mNotificationChannel, 1, mSbn, null, null, null, true, true,
- IMPORTANCE_DEFAULT, false);
+ TEST_PACKAGE_NAME, mNotificationChannel, 1, mSbn,
+ null, null, null, true,
+ true, IMPORTANCE_DEFAULT, false);
mNotificationInfo.findViewById(R.id.minimize).performClick();
waitForUndoButton();
diff --git a/packages/VpnDialogs/AndroidManifest.xml b/packages/VpnDialogs/AndroidManifest.xml
index 8172e71..1d0b9b6 100644
--- a/packages/VpnDialogs/AndroidManifest.xml
+++ b/packages/VpnDialogs/AndroidManifest.xml
@@ -20,6 +20,7 @@
package="com.android.vpndialogs">
<uses-permission android:name="android.permission.CONTROL_VPN" />
+ <uses-permission android:name="android.permission.CONTROL_ALWAYS_ON_VPN" />
<uses-permission android:name="android.permission.CONNECTIVITY_INTERNAL" />
<application android:label="VpnDialogs"
diff --git a/packages/overlays/FontArbutusSourceOverlay/Android.mk b/packages/overlays/FontArbutusSourceOverlay/Android.mk
deleted file mode 100644
index 23aee55..0000000
--- a/packages/overlays/FontArbutusSourceOverlay/Android.mk
+++ /dev/null
@@ -1,31 +0,0 @@
-#
-# Copyright 2018, The Android Open Source Project
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-LOCAL_PATH:= $(call my-dir)
-include $(CLEAR_VARS)
-
-LOCAL_RRO_THEME := FontArbutusSource
-LOCAL_CERTIFICATE := platform
-LOCAL_PRODUCT_MODULE := true
-
-LOCAL_SRC_FILES := $(call all-subdir-java-files)
-
-LOCAL_RESOURCE_DIR := $(LOCAL_PATH)/res
-
-LOCAL_PACKAGE_NAME := FontArbutusSourceOverlay
-LOCAL_SDK_VERSION := current
-
-include $(BUILD_RRO_PACKAGE)
diff --git a/packages/overlays/FontArbutusSourceOverlay/AndroidManifest.xml b/packages/overlays/FontArbutusSourceOverlay/AndroidManifest.xml
deleted file mode 100644
index 46c06b9..0000000
--- a/packages/overlays/FontArbutusSourceOverlay/AndroidManifest.xml
+++ /dev/null
@@ -1,31 +0,0 @@
-<!--
-/**
- * Copyright (c) 2018, The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
--->
-<manifest xmlns:android="http://schemas.android.com/apk/res/android"
- package="com.android.theme.font.arbutussource"
- android:versionCode="1"
- android:versionName="1.0">
- <overlay android:targetPackage="android"
- android:category="android.theme.customization.font"
- android:priority="1"/>
-
- <application android:label="@string/font_arbutus_source_overlay" android:hasCode="false">
- <meta-data
- android:name="android.theme.customization.REQUIRED_SYSTEM_FONTS"
- android:value="arbutus-slab,source-sans-pro,source-sans-pro-medium" />
- </application>
-</manifest>
diff --git a/packages/overlays/FontArbutusSourceOverlay/res/values/config.xml b/packages/overlays/FontArbutusSourceOverlay/res/values/config.xml
deleted file mode 100644
index a6aa64c..0000000
--- a/packages/overlays/FontArbutusSourceOverlay/res/values/config.xml
+++ /dev/null
@@ -1,28 +0,0 @@
-<!--
-/**
- * Copyright (c) 2018, The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
--->
-<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
- <!-- Name of a font family to use for body text. -->
- <string name="config_bodyFontFamily" translatable="false">source-sans-pro</string>
- <!-- Name of a font family to use for medium body text. -->
- <string name="config_bodyFontFamilyMedium" translatable="false">source-sans-pro-semi-bold</string>
- <!-- Name of a font family to use for headlines. If empty, falls back to platform default -->
- <string name="config_headlineFontFamily" translatable="false">arbutus-slab</string>
- <!-- Name of the font family used for system surfaces where the font should use medium weight -->
- <string name="config_headlineFontFamilyMedium" translatable="false">arbutus-slab</string>
-</resources>
-
diff --git a/packages/overlays/FontArbutusSourceOverlay/res/values/strings.xml b/packages/overlays/FontArbutusSourceOverlay/res/values/strings.xml
deleted file mode 100644
index d80eb20..0000000
--- a/packages/overlays/FontArbutusSourceOverlay/res/values/strings.xml
+++ /dev/null
@@ -1,21 +0,0 @@
-<!--
-/**
- * Copyright (c) 2018, The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
--->
-<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
- <!-- Headline / Body font Arbutus Slab / Source Sans Pro overlay -->
- <string name="font_arbutus_source_overlay" translatable="false">Arbutus Slab / Source Sans Pro</string>
-</resources>
diff --git a/packages/overlays/FontArvoLatoOverlay/Android.mk b/packages/overlays/FontArvoLatoOverlay/Android.mk
deleted file mode 100644
index 3433ecf..0000000
--- a/packages/overlays/FontArvoLatoOverlay/Android.mk
+++ /dev/null
@@ -1,31 +0,0 @@
-#
-# Copyright 2018, The Android Open Source Project
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-LOCAL_PATH:= $(call my-dir)
-include $(CLEAR_VARS)
-
-LOCAL_RRO_THEME := FontArvoLato
-LOCAL_CERTIFICATE := platform
-LOCAL_PRODUCT_MODULE := true
-
-LOCAL_SRC_FILES := $(call all-subdir-java-files)
-
-LOCAL_RESOURCE_DIR := $(LOCAL_PATH)/res
-
-LOCAL_PACKAGE_NAME := FontArvoLatoOverlay
-LOCAL_SDK_VERSION := current
-
-include $(BUILD_RRO_PACKAGE)
diff --git a/packages/overlays/FontArvoLatoOverlay/AndroidManifest.xml b/packages/overlays/FontArvoLatoOverlay/AndroidManifest.xml
deleted file mode 100644
index 3f2e5de..0000000
--- a/packages/overlays/FontArvoLatoOverlay/AndroidManifest.xml
+++ /dev/null
@@ -1,31 +0,0 @@
-<!--
-/**
- * Copyright (c) 2018, The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
--->
-<manifest xmlns:android="http://schemas.android.com/apk/res/android"
- package="com.android.theme.font.arvolato"
- android:versionCode="1"
- android:versionName="1.0">
- <overlay android:targetPackage="android"
- android:category="android.theme.customization.font"
- android:priority="1"/>
-
- <application android:label="@string/font_arvo_lato_overlay" android:hasCode="false">
- <meta-data
- android:name="android.theme.customization.REQUIRED_SYSTEM_FONTS"
- android:value="arvo,arvo-medium,lato,lato-medium" />
- </application>
-</manifest>
diff --git a/packages/overlays/FontArvoLatoOverlay/res/values/config.xml b/packages/overlays/FontArvoLatoOverlay/res/values/config.xml
deleted file mode 100644
index 4e70d72..0000000
--- a/packages/overlays/FontArvoLatoOverlay/res/values/config.xml
+++ /dev/null
@@ -1,28 +0,0 @@
-<!--
-/**
- * Copyright (c) 2018, The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
--->
-<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
- <!-- Name of a font family to use for body text. -->
- <string name="config_bodyFontFamily" translatable="false">lato</string>
- <!-- Name of a font family to use for medium body text. -->
- <string name="config_bodyFontFamilyMedium" translatable="false">lato-bold</string>
- <!-- Name of a font family to use for headlines. If empty, falls back to platform default -->
- <string name="config_headlineFontFamily" translatable="false">arvo</string>
- <!-- Name of the font family used for system surfaces where the font should use medium weight -->
- <string name="config_headlineFontFamilyMedium" translatable="false">arvo-bold</string>
-</resources>
-
diff --git a/packages/overlays/FontArvoLatoOverlay/res/values/strings.xml b/packages/overlays/FontArvoLatoOverlay/res/values/strings.xml
deleted file mode 100644
index 9ea097f..0000000
--- a/packages/overlays/FontArvoLatoOverlay/res/values/strings.xml
+++ /dev/null
@@ -1,21 +0,0 @@
-<!--
-/**
- * Copyright (c) 2018, The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
--->
-<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
- <!-- Headline / Body font Arvo / Lato overlay -->
- <string name="font_arvo_lato_overlay" translatable="false">Arvo / Lato</string>
-</resources>
diff --git a/packages/overlays/FontRubikRubikOverlay/Android.mk b/packages/overlays/FontRubikRubikOverlay/Android.mk
deleted file mode 100644
index 21d617e..0000000
--- a/packages/overlays/FontRubikRubikOverlay/Android.mk
+++ /dev/null
@@ -1,31 +0,0 @@
-#
-# Copyright 2018, The Android Open Source Project
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-LOCAL_PATH:= $(call my-dir)
-include $(CLEAR_VARS)
-
-LOCAL_RRO_THEME := FontRubikRubik
-LOCAL_CERTIFICATE := platform
-LOCAL_PRODUCT_MODULE := true
-
-LOCAL_SRC_FILES := $(call all-subdir-java-files)
-
-LOCAL_RESOURCE_DIR := $(LOCAL_PATH)/res
-
-LOCAL_PACKAGE_NAME := FontRubikRubikOverlay
-LOCAL_SDK_VERSION := current
-
-include $(BUILD_RRO_PACKAGE)
diff --git a/packages/overlays/FontRubikRubikOverlay/AndroidManifest.xml b/packages/overlays/FontRubikRubikOverlay/AndroidManifest.xml
deleted file mode 100644
index 1f28d46..0000000
--- a/packages/overlays/FontRubikRubikOverlay/AndroidManifest.xml
+++ /dev/null
@@ -1,31 +0,0 @@
-<!--
-/**
- * Copyright (c) 2018, The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
--->
-<manifest xmlns:android="http://schemas.android.com/apk/res/android"
- package="com.android.theme.font.rubikrubik"
- android:versionCode="1"
- android:versionName="1.0">
- <overlay android:targetPackage="android"
- android:category="android.theme.customization.font"
- android:priority="1"/>
-
- <application android:label="@string/font_rubik_rubik_overlay" android:hasCode="false">
- <meta-data
- android:name="android.theme.customization.REQUIRED_SYSTEM_FONTS"
- android:value="rubik,rubik-medium" />
- </application>
-</manifest>
diff --git a/packages/overlays/FontRubikRubikOverlay/res/values/config.xml b/packages/overlays/FontRubikRubikOverlay/res/values/config.xml
deleted file mode 100644
index 4f90e29..0000000
--- a/packages/overlays/FontRubikRubikOverlay/res/values/config.xml
+++ /dev/null
@@ -1,28 +0,0 @@
-<!--
-/**
- * Copyright (c) 2018, The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
--->
-<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
- <!-- Name of a font family to use for body text. -->
- <string name="config_bodyFontFamily" translatable="false">rubik</string>
- <!-- Name of a font family to use for medium body text. -->
- <string name="config_bodyFontFamilyMedium" translatable="false">rubik-medium</string>
- <!-- Name of a font family to use for headlines. If empty, falls back to platform default -->
- <string name="config_headlineFontFamily" translatable="false">rubik</string>
- <!-- Name of the font family used for system surfaces where the font should use medium weight -->
- <string name="config_headlineFontFamilyMedium" translatable="false">rubik-medium</string>
-</resources>
-
diff --git a/proto/Android.bp b/proto/Android.bp
index f3811bd..817a54d 100644
--- a/proto/Android.bp
+++ b/proto/Android.bp
@@ -17,3 +17,24 @@
},
},
}
+
+java_library_static {
+ name: "metrics-constants-protos",
+ host_supported: true,
+ proto: {
+ type: "nano",
+ },
+ srcs: ["src/metrics_constants/metrics_constants.proto"],
+ no_framework_libs: true,
+ sdk_version: "system_current",
+ // Pin java_version until jarjar is certified to support later versions. http://b/72703434
+ java_version: "1.8",
+ target: {
+ android: {
+ jarjar_rules: "jarjar-rules.txt",
+ },
+ host: {
+ static_libs: ["libprotobuf-java-nano"],
+ },
+ },
+}
diff --git a/proto/src/metrics_constants/metrics_constants.proto b/proto/src/metrics_constants/metrics_constants.proto
index 385931d..aeb4261 100644
--- a/proto/src/metrics_constants/metrics_constants.proto
+++ b/proto/src/metrics_constants/metrics_constants.proto
@@ -6910,6 +6910,11 @@
// CATEGORY: NOTIFICATION
FIELD_NOTIFICATION_CATEGORY = 1641;
+ // OPEN: Settings > Settings > Network & internet > Click Mobile network to land on page with
+ // details for a SIM/eSIM mobile network > Click edit icon to bring up a rename dialog.
+ // OS: Q
+ MOBILE_NETWORK_RENAME_DIALOG = 1642;
+
// ---- 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/accessibility/java/com/android/server/accessibility/AbstractAccessibilityServiceConnection.java b/services/accessibility/java/com/android/server/accessibility/AbstractAccessibilityServiceConnection.java
index f4ac130..fc43882 100644
--- a/services/accessibility/java/com/android/server/accessibility/AbstractAccessibilityServiceConnection.java
+++ b/services/accessibility/java/com/android/server/accessibility/AbstractAccessibilityServiceConnection.java
@@ -348,8 +348,8 @@
}
int getRelevantEventTypes() {
- return (mUsesAccessibilityCache ? AccessibilityCache.CACHE_CRITICAL_EVENTS_MASK : 0)
- | mEventTypes;
+ return (mUsesAccessibilityCache ? AccessibilityCache.CACHE_CRITICAL_EVENTS_MASK
+ : AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED) | mEventTypes;
}
@Override
diff --git a/services/backup/java/com/android/server/backup/Trampoline.java b/services/backup/java/com/android/server/backup/Trampoline.java
index 303734a..87872e8 100644
--- a/services/backup/java/com/android/server/backup/Trampoline.java
+++ b/services/backup/java/com/android/server/backup/Trampoline.java
@@ -332,7 +332,14 @@
// If the user is unlocked, we can start the backup service for it. Otherwise we
// will start the service when the user is unlocked as part of its unlock callback.
if (getUserManager().isUserUnlocked(userId)) {
- startServiceForUser(userId);
+ // Clear calling identity as initialization enforces the system identity but we
+ // can be coming from shell.
+ long oldId = Binder.clearCallingIdentity();
+ try {
+ startServiceForUser(userId);
+ } finally {
+ Binder.restoreCallingIdentity(oldId);
+ }
}
} else {
try {
diff --git a/services/core/Android.bp b/services/core/Android.bp
index 4408db8..bf08f3e 100644
--- a/services/core/Android.bp
+++ b/services/core/Android.bp
@@ -8,6 +8,7 @@
"frameworks/native/cmds/dumpstate/binder",
"system/core/storaged/binder",
"system/vold/binder",
+ "system/gsid/aidl",
],
},
srcs: [
@@ -17,6 +18,7 @@
":installd_aidl",
":storaged_aidl",
":vold_aidl",
+ ":gsiservice_aidl",
":mediaupdateservice_aidl",
"java/com/android/server/EventLogTags.logtags",
"java/com/android/server/am/EventLogTags.logtags",
diff --git a/services/core/java/com/android/server/ConnectivityService.java b/services/core/java/com/android/server/ConnectivityService.java
index 58263fc..f807543 100644
--- a/services/core/java/com/android/server/ConnectivityService.java
+++ b/services/core/java/com/android/server/ConnectivityService.java
@@ -3653,6 +3653,20 @@
mTethering.stopTethering(type);
}
+ /**
+ * Get the latest value of the tethering entitlement check.
+ *
+ * Note: Allow privileged apps who have TETHER_PRIVILEGED permission to access. If it turns
+ * out some such apps are observed to abuse this API, change to per-UID limits on this API
+ * if it's really needed.
+ */
+ @Override
+ public void getLatestTetheringEntitlementValue(int type, ResultReceiver receiver,
+ boolean showEntitlementUi, String callerPkg) {
+ ConnectivityManager.enforceTetherChangePermission(mContext, callerPkg);
+ mTethering.getLatestTetheringEntitlementValue(type, receiver, showEntitlementUi);
+ }
+
// Called when we lose the default network and have no replacement yet.
// This will automatically be cleared after X seconds or a new default network
// becomes CONNECTED, whichever happens first. The timer is started by the
diff --git a/services/core/java/com/android/server/DynamicAndroidService.java b/services/core/java/com/android/server/DynamicAndroidService.java
new file mode 100644
index 0000000..12a3f02
--- /dev/null
+++ b/services/core/java/com/android/server/DynamicAndroidService.java
@@ -0,0 +1,134 @@
+/*
+ * Copyright (C) 2019 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.server;
+
+import android.content.Context;
+import android.content.pm.PackageManager;
+import android.gsi.GsiProgress;
+import android.gsi.IGsiService;
+import android.os.IBinder;
+import android.os.IBinder.DeathRecipient;
+import android.os.IDynamicAndroidService;
+import android.os.RemoteException;
+import android.os.ServiceManager;
+import android.util.Slog;
+
+/**
+ * DynamicAndroidService implements IDynamicAndroidService. It provides permission check before
+ * passing requests to gsid
+ */
+public class DynamicAndroidService extends IDynamicAndroidService.Stub implements DeathRecipient {
+ private static final String TAG = "DynamicAndroidService";
+ private static final String NO_SERVICE_ERROR = "no gsiservice";
+
+ private Context mContext;
+ private volatile IGsiService mGsiService;
+
+ DynamicAndroidService(Context context) {
+ mContext = context;
+ }
+
+ private static IGsiService connect(DeathRecipient recipient) throws RemoteException {
+ IBinder binder = ServiceManager.getService("gsiservice");
+ if (binder == null) {
+ throw new RemoteException(NO_SERVICE_ERROR);
+ }
+ /**
+ * The init will restart gsiservice if it crashed and the proxy object will need to be
+ * re-initialized in this case.
+ */
+ binder.linkToDeath(recipient, 0);
+ return IGsiService.Stub.asInterface(binder);
+ }
+
+ /** implements DeathRecipient */
+ @Override
+ public void binderDied() {
+ Slog.w(TAG, "gsiservice died; reconnecting");
+ synchronized (this) {
+ mGsiService = null;
+ }
+ }
+
+ private IGsiService getGsiService() throws RemoteException {
+ checkPermission();
+ synchronized (this) {
+ if (mGsiService == null) {
+ mGsiService = connect(this);
+ }
+ return mGsiService;
+ }
+ }
+
+ private void checkPermission() {
+ if (mContext.checkCallingOrSelfPermission(
+ android.Manifest.permission.MANAGE_DYNAMIC_ANDROID)
+ != PackageManager.PERMISSION_GRANTED) {
+ throw new SecurityException("Requires MANAGE_DYNAMIC_ANDROID permission");
+ }
+ }
+
+ @Override
+ public boolean startInstallation(long systemSize, long userdataSize) throws RemoteException {
+ return getGsiService().startGsiInstall(systemSize, userdataSize, true) == 0;
+ }
+
+ @Override
+ public GsiProgress getInstallationProgress() throws RemoteException {
+ return getGsiService().getInstallProgress();
+ }
+
+ @Override
+ public boolean abort() throws RemoteException {
+ return getGsiService().cancelGsiInstall();
+ }
+
+ @Override
+ public boolean isInUse() throws RemoteException {
+ return getGsiService().isGsiRunning();
+ }
+
+ @Override
+ public boolean isInstalled() throws RemoteException {
+ return getGsiService().isGsiInstalled();
+ }
+
+ @Override
+ public boolean remove() throws RemoteException {
+ return getGsiService().removeGsiInstall();
+ }
+
+ @Override
+ public boolean toggle() throws RemoteException {
+ IGsiService gsiService = getGsiService();
+ if (gsiService.isGsiRunning()) {
+ return gsiService.disableGsiInstall();
+ } else {
+ return gsiService.setGsiBootable() == 0;
+ }
+ }
+
+ @Override
+ public boolean write(byte[] buf) throws RemoteException {
+ return getGsiService().commitGsiChunkFromMemory(buf);
+ }
+
+ @Override
+ public boolean commit() throws RemoteException {
+ return getGsiService().setGsiBootable() == 0;
+ }
+}
diff --git a/services/core/java/com/android/server/EventLogTags.logtags b/services/core/java/com/android/server/EventLogTags.logtags
index d869734..0ed5beb 100644
--- a/services/core/java/com/android/server/EventLogTags.logtags
+++ b/services/core/java/com/android/server/EventLogTags.logtags
@@ -33,7 +33,7 @@
# It logs the time remaining before the device would've normally gone to sleep without the request.
2731 power_soft_sleep_requested (savedwaketimems|2)
# Power save state has changed. See BatterySaverController.java for the details.
-2739 battery_saver_mode (prevOffOrOn|1|5),(nowOffOrOn|1|5),(interactive|1|5),(features|3|5),(reason|1|5)
+2739 battery_saver_mode (fullPrevOffOrOn|1|5),(adaptivePrevOffOrOn|1|5),(fullNowOffOrOn|1|5),(adaptiveNowOffOrOn|1|5),(interactive|1|5),(features|3|5),(reason|1|5)
27390 battery_saving_stats (batterySaver|1|5),(interactive|1|5),(doze|1|5),(delta_duration|2|3),(delta_battery_drain|1|1),(delta_battery_drain_percent|1|6),(total_duration|2|3),(total_battery_drain|1|1),(total_battery_drain_percent|1|6)
# Note when the user activity timeout has been overriden by ActivityManagerService
27391 user_activity_timeout_override (override|2|3)
diff --git a/services/core/java/com/android/server/LocationManagerService.java b/services/core/java/com/android/server/LocationManagerService.java
index d2c6354..33c6dd2 100644
--- a/services/core/java/com/android/server/LocationManagerService.java
+++ b/services/core/java/com/android/server/LocationManagerService.java
@@ -405,6 +405,7 @@
// initialize in-memory settings values
onBackgroundThrottleWhitelistChangedLocked();
+ onIgnoreSettingsWhitelistChangedLocked();
}
@GuardedBy("mLock")
@@ -547,17 +548,16 @@
@GuardedBy("mLock")
private void onBackgroundThrottleWhitelistChangedLocked() {
- String setting = Settings.Global.getString(
- mContext.getContentResolver(),
- Settings.Global.LOCATION_BACKGROUND_THROTTLE_PACKAGE_WHITELIST);
- if (setting == null) {
- setting = "";
- }
-
mBackgroundThrottlePackageWhitelist.clear();
mBackgroundThrottlePackageWhitelist.addAll(
SystemConfig.getInstance().getAllowUnthrottledLocation());
- mBackgroundThrottlePackageWhitelist.addAll(Arrays.asList(setting.split(",")));
+
+ String setting = Settings.Global.getString(
+ mContext.getContentResolver(),
+ Settings.Global.LOCATION_BACKGROUND_THROTTLE_PACKAGE_WHITELIST);
+ if (!TextUtils.isEmpty(setting)) {
+ mBackgroundThrottlePackageWhitelist.addAll(Arrays.asList(setting.split(",")));
+ }
for (LocationProvider p : mProviders) {
applyRequirementsLocked(p);
@@ -566,17 +566,16 @@
@GuardedBy("lock")
private void onIgnoreSettingsWhitelistChangedLocked() {
- String setting = Settings.Global.getString(
- mContext.getContentResolver(),
- Settings.Global.LOCATION_IGNORE_SETTINGS_PACKAGE_WHITELIST);
- if (setting == null) {
- setting = "";
- }
-
mIgnoreSettingsPackageWhitelist.clear();
mIgnoreSettingsPackageWhitelist.addAll(
SystemConfig.getInstance().getAllowIgnoreLocationSettings());
- mIgnoreSettingsPackageWhitelist.addAll(Arrays.asList(setting.split(",")));
+
+ String setting = Settings.Global.getString(
+ mContext.getContentResolver(),
+ Settings.Global.LOCATION_IGNORE_SETTINGS_PACKAGE_WHITELIST);
+ if (!TextUtils.isEmpty(setting)) {
+ mIgnoreSettingsPackageWhitelist.addAll(Arrays.asList(setting.split(",")));
+ }
for (LocationProvider p : mProviders) {
applyRequirementsLocked(p);
@@ -2200,7 +2199,7 @@
return false;
}
- if (mBackgroundThrottlePackageWhitelist.contains(record.mReceiver.mIdentity.mPackageName)) {
+ if (mIgnoreSettingsPackageWhitelist.contains(record.mReceiver.mIdentity.mPackageName)) {
return true;
}
diff --git a/services/core/java/com/android/server/StorageManagerService.java b/services/core/java/com/android/server/StorageManagerService.java
index cecd55a3..f2329d3 100644
--- a/services/core/java/com/android/server/StorageManagerService.java
+++ b/services/core/java/com/android/server/StorageManagerService.java
@@ -1541,10 +1541,6 @@
mCallbacks = new Callbacks(FgThread.get().getLooper());
mLockPatternUtils = new LockPatternUtils(mContext);
- mPmInternal = LocalServices.getService(PackageManagerInternal.class);
- mUmInternal = LocalServices.getService(UserManagerInternal.class);
- mAmInternal = LocalServices.getService(ActivityManagerInternal.class);
-
HandlerThread hthread = new HandlerThread(TAG);
hthread.start();
mHandler = new StorageManagerServiceHandler(hthread.getLooper());
@@ -1662,6 +1658,19 @@
}
private void servicesReady() {
+ mPmInternal = LocalServices.getService(PackageManagerInternal.class);
+ mUmInternal = LocalServices.getService(UserManagerInternal.class);
+ mAmInternal = LocalServices.getService(ActivityManagerInternal.class);
+
+ mIPackageManager = IPackageManager.Stub.asInterface(
+ ServiceManager.getService("package"));
+ mIAppOpsService = IAppOpsService.Stub.asInterface(
+ ServiceManager.getService(Context.APP_OPS_SERVICE));
+ try {
+ mIAppOpsService.startWatchingMode(OP_REQUEST_INSTALL_PACKAGES, null, mAppOpsCallback);
+ } catch (RemoteException e) {
+ }
+
synchronized (mLock) {
final boolean thisIsolatedStorage = StorageManager.hasIsolatedStorage();
if (mLastIsolatedStorage == thisIsolatedStorage) {
@@ -1734,14 +1743,6 @@
.registerScreenObserver(this);
mSystemReady = true;
- mIPackageManager = IPackageManager.Stub.asInterface(
- ServiceManager.getService("package"));
- mIAppOpsService = IAppOpsService.Stub.asInterface(
- ServiceManager.getService(Context.APP_OPS_SERVICE));
- try {
- mIAppOpsService.startWatchingMode(OP_REQUEST_INSTALL_PACKAGES, null, mAppOpsCallback);
- } catch (RemoteException e) {
- }
mHandler.obtainMessage(H_SYSTEM_READY).sendToTarget();
}
diff --git a/services/core/java/com/android/server/ThreadPriorityBooster.java b/services/core/java/com/android/server/ThreadPriorityBooster.java
index 53e8ce4..f74a4385 100644
--- a/services/core/java/com/android/server/ThreadPriorityBooster.java
+++ b/services/core/java/com/android/server/ThreadPriorityBooster.java
@@ -43,9 +43,9 @@
public void boost() {
final int tid = myTid();
- final int prevPriority = getThreadPriority(tid);
final PriorityState state = mThreadState.get();
if (state.regionCounter == 0) {
+ final int prevPriority = getThreadPriority(tid);
state.prevPriority = prevPriority;
if (prevPriority > mBoostToPriority) {
setThreadPriority(tid, mBoostToPriority);
@@ -60,9 +60,11 @@
public void reset() {
final PriorityState state = mThreadState.get();
state.regionCounter--;
- final int currentPriority = getThreadPriority(myTid());
- if (state.regionCounter == 0 && state.prevPriority != currentPriority) {
- setThreadPriority(myTid(), state.prevPriority);
+ if (state.regionCounter == 0) {
+ final int currentPriority = getThreadPriority(myTid());
+ if (state.prevPriority != currentPriority) {
+ setThreadPriority(myTid(), state.prevPriority);
+ }
}
}
@@ -77,9 +79,11 @@
mBoostToPriority = priority;
final PriorityState state = mThreadState.get();
final int tid = myTid();
- final int prevPriority = getThreadPriority(tid);
- if (state.regionCounter != 0 && prevPriority != priority) {
- setThreadPriority(tid, priority);
+ if (state.regionCounter != 0) {
+ final int prevPriority = getThreadPriority(tid);
+ if (prevPriority != priority) {
+ setThreadPriority(tid, priority);
+ }
}
}
diff --git a/services/core/java/com/android/server/VibratorService.java b/services/core/java/com/android/server/VibratorService.java
index f6e698f..9b9911a 100644
--- a/services/core/java/com/android/server/VibratorService.java
+++ b/services/core/java/com/android/server/VibratorService.java
@@ -593,7 +593,7 @@
Vibration vib = new Vibration(token, effect, usageHint, uid, opPkg, reason);
if (mProcStatesCache.get(uid, ActivityManager.PROCESS_STATE_IMPORTANT_FOREGROUND)
> ActivityManager.PROCESS_STATE_IMPORTANT_FOREGROUND
- && vib.isHapticFeedback()) {
+ && !vib.isNotification() && !vib.isRingtone()) {
Slog.e(TAG, "Ignoring incoming vibration as process with uid = "
+ uid + " is background");
return;
diff --git a/services/core/java/com/android/server/am/ActiveInstrumentation.java b/services/core/java/com/android/server/am/ActiveInstrumentation.java
index 15de3de..9510f59 100644
--- a/services/core/java/com/android/server/am/ActiveInstrumentation.java
+++ b/services/core/java/com/android/server/am/ActiveInstrumentation.java
@@ -49,6 +49,9 @@
// Connection to use the UI introspection APIs.
IUiAutomationConnection mUiAutomationConnection;
+ // Whether the caller holds START_ACTIVITIES_FROM_BACKGROUND permission
+ boolean mHasBackgroundActivityStartsPermission;
+
// As given to us
Bundle mArguments;
@@ -117,6 +120,8 @@
pw.print(prefix); pw.print("mUiAutomationConnection=");
pw.println(mUiAutomationConnection);
}
+ pw.print("mHasBackgroundActivityStartsPermission=");
+ pw.println(mHasBackgroundActivityStartsPermission);
pw.print(prefix); pw.print("mArguments=");
pw.println(mArguments);
}
diff --git a/services/core/java/com/android/server/am/ActivityManagerService.java b/services/core/java/com/android/server/am/ActivityManagerService.java
index bec7386..66e9eb3a 100644
--- a/services/core/java/com/android/server/am/ActivityManagerService.java
+++ b/services/core/java/com/android/server/am/ActivityManagerService.java
@@ -22,6 +22,7 @@
import static android.Manifest.permission.INTERACT_ACROSS_USERS;
import static android.Manifest.permission.INTERACT_ACROSS_USERS_FULL;
import static android.Manifest.permission.REMOVE_TASKS;
+import static android.Manifest.permission.START_ACTIVITIES_FROM_BACKGROUND;
import static android.app.ActivityManager.INSTR_FLAG_DISABLE_HIDDEN_API_CHECKS;
import static android.app.ActivityManager.INSTR_FLAG_MOUNT_EXTERNAL_STORAGE_FULL;
import static android.app.ActivityManager.PROCESS_STATE_LAST_ACTIVITY;
@@ -2217,7 +2218,7 @@
mConstants = hasHandlerThread ? new ActivityManagerConstants(this, mHandler) : null;
final ActiveUids activeUids = new ActiveUids(this, false /* postChangesToAtm */);
mProcessList.init(this, activeUids);
- mOomAdjuster = new OomAdjuster(this, mProcessList, activeUids);
+ mOomAdjuster = new OomAdjuster(this, mProcessList, activeUids, new Object());
mIntentFirewall = hasHandlerThread
? new IntentFirewall(new IntentFirewallInterface(), mHandler) : null;
@@ -2265,7 +2266,7 @@
mConstants = new ActivityManagerConstants(this, mHandler);
final ActiveUids activeUids = new ActiveUids(this, true /* postChangesToAtm */);
mProcessList.init(this, activeUids);
- mOomAdjuster = new OomAdjuster(this, mProcessList, activeUids);
+ mOomAdjuster = new OomAdjuster(this, mProcessList, activeUids, atm.getGlobalLock());
// Broadcast policy parameters
final BroadcastConstants foreConstants = new BroadcastConstants(
@@ -3091,7 +3092,7 @@
} else {
UidRecord validateUid = mValidateUids.get(item.uid);
if (validateUid == null) {
- validateUid = new UidRecord(item.uid, mAtmInternal);
+ validateUid = new UidRecord(item.uid);
mValidateUids.put(item.uid, validateUid);
}
if ((item.change & UidRecord.CHANGE_IDLE) != 0) {
@@ -15195,7 +15196,9 @@
IInstrumentationWatcher watcher, IUiAutomationConnection uiAutomationConnection,
int userId, String abiOverride) {
enforceNotIsolatedCaller("startInstrumentation");
- userId = mUserController.handleIncomingUser(Binder.getCallingPid(), Binder.getCallingUid(),
+ final int callingUid = Binder.getCallingUid();
+ final int callingPid = Binder.getCallingPid();
+ userId = mUserController.handleIncomingUser(callingPid, callingUid,
userId, false, ALLOW_FULL_ONLY, "startInstrumentation", null);
// Refuse possible leaked file descriptors
if (arguments != null && arguments.hasFileDescriptors()) {
@@ -15260,6 +15263,9 @@
activeInstr.mWatcher = watcher;
activeInstr.mUiAutomationConnection = uiAutomationConnection;
activeInstr.mResultClass = className;
+ activeInstr.mHasBackgroundActivityStartsPermission = checkPermission(
+ START_ACTIVITIES_FROM_BACKGROUND, callingPid, callingUid)
+ == PackageManager.PERMISSION_GRANTED;
boolean disableHiddenApiChecks = ai.usesNonSdkApi()
|| (flags & INSTR_FLAG_DISABLE_HIDDEN_API_CHECKS) != 0;
diff --git a/services/core/java/com/android/server/am/AppCompactor.java b/services/core/java/com/android/server/am/AppCompactor.java
index bb55ec31..1118014 100644
--- a/services/core/java/com/android/server/am/AppCompactor.java
+++ b/services/core/java/com/android/server/am/AppCompactor.java
@@ -19,6 +19,7 @@
import static android.os.Process.THREAD_PRIORITY_FOREGROUND;
import static android.provider.DeviceConfig.ActivityManager.KEY_COMPACT_ACTION_1;
import static android.provider.DeviceConfig.ActivityManager.KEY_COMPACT_ACTION_2;
+import static android.provider.DeviceConfig.ActivityManager.KEY_COMPACT_STATSD_SAMPLE_RATE;
import static android.provider.DeviceConfig.ActivityManager.KEY_COMPACT_THROTTLE_1;
import static android.provider.DeviceConfig.ActivityManager.KEY_COMPACT_THROTTLE_2;
import static android.provider.DeviceConfig.ActivityManager.KEY_COMPACT_THROTTLE_3;
@@ -45,6 +46,7 @@
import java.io.FileOutputStream;
import java.io.PrintWriter;
import java.util.ArrayList;
+import java.util.Random;
public final class AppCompactor {
@@ -65,6 +67,8 @@
@VisibleForTesting static final long DEFAULT_COMPACT_THROTTLE_2 = 10_000;
@VisibleForTesting static final long DEFAULT_COMPACT_THROTTLE_3 = 500;
@VisibleForTesting static final long DEFAULT_COMPACT_THROTTLE_4 = 10_000;
+ // The sampling rate to push app compaction events into statsd for upload.
+ @VisibleForTesting static final float DEFAULT_STATSD_SAMPLE_RATE = 0.1f;
@VisibleForTesting
interface PropertyChangedCallbackForTest {
@@ -104,6 +108,8 @@
|| KEY_COMPACT_THROTTLE_3.equals(name)
|| KEY_COMPACT_THROTTLE_4.equals(name)) {
updateCompactionThrottles();
+ } else if (KEY_COMPACT_STATSD_SAMPLE_RATE.equals(name)) {
+ updateStatsdSampleRate();
}
}
if (mTestCallback != null) {
@@ -116,21 +122,25 @@
// Configured by phenotype. Updates from the server take effect immediately.
@GuardedBy("mPhenotypeFlagLock")
- @VisibleForTesting String mCompactActionSome =
+ @VisibleForTesting volatile String mCompactActionSome =
compactActionIntToString(DEFAULT_COMPACT_ACTION_1);
@GuardedBy("mPhenotypeFlagLock")
- @VisibleForTesting String mCompactActionFull =
+ @VisibleForTesting volatile String mCompactActionFull =
compactActionIntToString(DEFAULT_COMPACT_ACTION_2);
@GuardedBy("mPhenotypeFlagLock")
- @VisibleForTesting long mCompactThrottleSomeSome = DEFAULT_COMPACT_THROTTLE_1;
+ @VisibleForTesting volatile long mCompactThrottleSomeSome = DEFAULT_COMPACT_THROTTLE_1;
@GuardedBy("mPhenotypeFlagLock")
- @VisibleForTesting long mCompactThrottleSomeFull = DEFAULT_COMPACT_THROTTLE_2;
+ @VisibleForTesting volatile long mCompactThrottleSomeFull = DEFAULT_COMPACT_THROTTLE_2;
@GuardedBy("mPhenotypeFlagLock")
- @VisibleForTesting long mCompactThrottleFullSome = DEFAULT_COMPACT_THROTTLE_3;
+ @VisibleForTesting volatile long mCompactThrottleFullSome = DEFAULT_COMPACT_THROTTLE_3;
@GuardedBy("mPhenotypeFlagLock")
- @VisibleForTesting long mCompactThrottleFullFull = DEFAULT_COMPACT_THROTTLE_4;
+ @VisibleForTesting volatile long mCompactThrottleFullFull = DEFAULT_COMPACT_THROTTLE_4;
@GuardedBy("mPhenotypeFlagLock")
- private boolean mUseCompaction = DEFAULT_USE_COMPACTION;
+ private volatile boolean mUseCompaction = DEFAULT_USE_COMPACTION;
+
+ private final Random mRandom = new Random();
+ @GuardedBy("mPhenotypeFlagLock")
+ @VisibleForTesting volatile float mStatsdSampleRate = DEFAULT_STATSD_SAMPLE_RATE;
// Handler on which compaction runs.
private Handler mCompactionHandler;
@@ -158,6 +168,7 @@
updateUseCompaction();
updateCompactionActions();
updateCompactionThrottles();
+ updateStatsdSampleRate();
}
}
@@ -181,6 +192,7 @@
pw.println(" " + KEY_COMPACT_THROTTLE_2 + "=" + mCompactThrottleSomeFull);
pw.println(" " + KEY_COMPACT_THROTTLE_3 + "=" + mCompactThrottleFullSome);
pw.println(" " + KEY_COMPACT_THROTTLE_4 + "=" + mCompactThrottleFullFull);
+ pw.println(" " + KEY_COMPACT_STATSD_SAMPLE_RATE + "=" + mStatsdSampleRate);
}
}
@@ -289,6 +301,19 @@
}
}
+ @GuardedBy("mPhenotypeFlagLock")
+ private void updateStatsdSampleRate() {
+ String sampleRateFlag = DeviceConfig.getProperty(DeviceConfig.ActivityManager.NAMESPACE,
+ KEY_COMPACT_STATSD_SAMPLE_RATE);
+ try {
+ mStatsdSampleRate = TextUtils.isEmpty(sampleRateFlag)
+ ? DEFAULT_STATSD_SAMPLE_RATE : Float.parseFloat(sampleRateFlag);
+ } catch (NumberFormatException e) {
+ mStatsdSampleRate = DEFAULT_STATSD_SAMPLE_RATE;
+ }
+ mStatsdSampleRate = Math.min(1.0f, Math.max(0.0f, mStatsdSampleRate));
+ }
+
@VisibleForTesting
static String compactActionIntToString(int action) {
switch(action) {
@@ -385,11 +410,16 @@
rssBefore[0], rssBefore[1], rssBefore[2], rssBefore[3],
rssAfter[0], rssAfter[1], rssAfter[2], rssAfter[3], time,
lastCompactAction, lastCompactTime, msg.arg1, msg.arg2);
- StatsLog.write(StatsLog.APP_COMPACTED, pid, name, pendingAction,
- rssBefore[0], rssBefore[1], rssBefore[2], rssBefore[3],
- rssAfter[0], rssAfter[1], rssAfter[2], rssAfter[3], time,
- lastCompactAction, lastCompactTime, msg.arg1,
- ActivityManager.processStateAmToProto(msg.arg2));
+ // Note that as above not taking mPhenoTypeFlagLock here to avoid locking
+ // on every single compaction for a flag that will seldom change and the
+ // impact of reading the wrong value here is low.
+ if (mRandom.nextFloat() < mStatsdSampleRate) {
+ StatsLog.write(StatsLog.APP_COMPACTED, pid, name, pendingAction,
+ rssBefore[0], rssBefore[1], rssBefore[2], rssBefore[3],
+ rssAfter[0], rssAfter[1], rssAfter[2], rssAfter[3], time,
+ lastCompactAction, lastCompactTime, msg.arg1,
+ ActivityManager.processStateAmToProto(msg.arg2));
+ }
synchronized (mAm) {
proc.lastCompactTime = end;
proc.lastCompactAction = pendingAction;
diff --git a/services/core/java/com/android/server/am/BroadcastQueue.java b/services/core/java/com/android/server/am/BroadcastQueue.java
index 64a36ef..1fb11ba 100644
--- a/services/core/java/com/android/server/am/BroadcastQueue.java
+++ b/services/core/java/com/android/server/am/BroadcastQueue.java
@@ -450,7 +450,7 @@
if (state == BroadcastRecord.IDLE) {
Slog.w(TAG, "finishReceiver [" + mQueueName + "] called but state is IDLE");
}
- if (r.allowBackgroundActivityStarts) {
+ if (r.allowBackgroundActivityStarts && r.curApp != null) {
r.curApp.removeAllowBackgroundActivityStartsToken(r);
}
// If we're abandoning this broadcast before any receivers were actually spun up,
diff --git a/services/core/java/com/android/server/am/OomAdjuster.java b/services/core/java/com/android/server/am/OomAdjuster.java
index 6e8646e..4985c52 100644
--- a/services/core/java/com/android/server/am/OomAdjuster.java
+++ b/services/core/java/com/android/server/am/OomAdjuster.java
@@ -127,8 +127,18 @@
private final ActivityManagerService mService;
private final ProcessList mProcessList;
- OomAdjuster(ActivityManagerService service, ProcessList processList, ActiveUids activeUids) {
+ /**
+ * Used to lock {@link #updateOomAdjImpl} for state consistency. It also reduces frequency lock
+ * and unlock when getting and setting value to {@link ProcessRecord#mWindowProcessController}.
+ * Note it is declared as Object type so the locked-region-code-injection won't wrap the
+ * unnecessary priority booster.
+ */
+ private final Object mAtmGlobalLock;
+
+ OomAdjuster(ActivityManagerService service, ProcessList processList, ActiveUids activeUids,
+ Object atmGlobalLock) {
mService = service;
+ mAtmGlobalLock = atmGlobalLock;
mProcessList = processList;
mActiveUids = activeUids;
@@ -186,6 +196,13 @@
@GuardedBy("mService")
final void updateOomAdjLocked() {
+ synchronized (mAtmGlobalLock) {
+ updateOomAdjImpl();
+ }
+ }
+
+ @GuardedBy({"mService", "mAtmGlobalLock"})
+ private void updateOomAdjImpl() {
Trace.traceBegin(Trace.TRACE_TAG_ACTIVITY_MANAGER, "updateOomAdj");
mService.mOomAdjProfiler.oomAdjStarted();
final ProcessRecord TOP_APP = mService.getTopAppLocked();
@@ -534,6 +551,7 @@
uidRec.setProcState = uidRec.getCurProcState();
uidRec.setWhitelist = uidRec.curWhitelist;
uidRec.setIdle = uidRec.idle;
+ mService.mAtmInternal.onUidProcStateChanged(uidRec.uid, uidRec.setProcState);
mService.enqueueUidChangeLocked(uidRec, -1, uidChange);
mService.noteUidProcessState(uidRec.uid, uidRec.getCurProcState());
if (uidRec.foregroundServices) {
diff --git a/services/core/java/com/android/server/am/ProcessList.java b/services/core/java/com/android/server/am/ProcessList.java
index 4aa71f9..49c4bc4 100644
--- a/services/core/java/com/android/server/am/ProcessList.java
+++ b/services/core/java/com/android/server/am/ProcessList.java
@@ -2197,7 +2197,7 @@
}
UidRecord uidRec = mActiveUids.get(proc.uid);
if (uidRec == null) {
- uidRec = new UidRecord(proc.uid, mService.mAtmInternal);
+ uidRec = new UidRecord(proc.uid);
// This is the first appearance of the uid, report it now!
if (DEBUG_UID_OBSERVERS) Slog.i(TAG_UID_OBSERVERS,
"Creating new process uid: " + uidRec);
diff --git a/services/core/java/com/android/server/am/ProcessRecord.java b/services/core/java/com/android/server/am/ProcessRecord.java
index 7ae77d5..6161f7d 100644
--- a/services/core/java/com/android/server/am/ProcessRecord.java
+++ b/services/core/java/com/android/server/am/ProcessRecord.java
@@ -655,10 +655,6 @@
return mWindowProcessController.hasActivities();
}
- void clearActivities() {
- mWindowProcessController.clearActivities();
- }
-
boolean hasActivitiesOrRecentTasks() {
return mWindowProcessController.hasActivitiesOrRecentTasks();
}
@@ -667,10 +663,6 @@
return mWindowProcessController.hasRecentTasks();
}
- void clearRecentTasks() {
- mWindowProcessController.clearRecentTasks();
- }
-
/**
* This method returns true if any of the activities within the process record are interesting
* to the user. See HistoryRecord.isInterestingToUserLocked()
@@ -1181,6 +1173,8 @@
void setActiveInstrumentation(ActiveInstrumentation instr) {
mInstr = instr;
mWindowProcessController.setInstrumenting(instr != null);
+ mWindowProcessController.setInstrumentingWithBackgroundActivityStartPrivileges(instr != null
+ && instr.mHasBackgroundActivityStartsPermission);
}
ActiveInstrumentation getActiveInstrumentation() {
diff --git a/services/core/java/com/android/server/am/UidRecord.java b/services/core/java/com/android/server/am/UidRecord.java
index 6cb1097..22a7de7 100644
--- a/services/core/java/com/android/server/am/UidRecord.java
+++ b/services/core/java/com/android/server/am/UidRecord.java
@@ -26,7 +26,6 @@
import android.util.proto.ProtoUtils;
import com.android.internal.annotations.GuardedBy;
-import com.android.server.wm.ActivityTaskManagerInternal;
/**
* Overall information about a uid that has actively running processes.
@@ -43,7 +42,6 @@
boolean idle;
boolean setIdle;
int numProcs;
- final ActivityTaskManagerInternal mAtmInternal;
/**
* Sequence number associated with the {@link #mCurProcState}. This is incremented using
@@ -117,10 +115,9 @@
ChangeItem pendingChange;
int lastReportedChange;
- public UidRecord(int _uid, ActivityTaskManagerInternal atmInternal) {
+ public UidRecord(int _uid) {
uid = _uid;
idle = true;
- mAtmInternal = atmInternal;
reset();
}
@@ -130,9 +127,6 @@
public void setCurProcState(int curProcState) {
mCurProcState = curProcState;
- if (mAtmInternal != null) {
- mAtmInternal.onUidProcStateChanged(uid, curProcState);
- }
}
public void reset() {
diff --git a/services/core/java/com/android/server/attention/AttentionManagerService.java b/services/core/java/com/android/server/attention/AttentionManagerService.java
index 5b469fe..2061b26 100644
--- a/services/core/java/com/android/server/attention/AttentionManagerService.java
+++ b/services/core/java/com/android/server/attention/AttentionManagerService.java
@@ -16,9 +16,9 @@
package com.android.server.attention;
+import static android.provider.DeviceConfig.AttentionManagerService.COMPONENT_NAME;
import static android.provider.DeviceConfig.AttentionManagerService.NAMESPACE;
-import static android.provider.DeviceConfig.AttentionManagerService.PROPERTY_COMPONENT_NAME;
-import static android.provider.DeviceConfig.AttentionManagerService.PROPERTY_SERVICE_ENABLED;
+import static android.provider.DeviceConfig.AttentionManagerService.SERVICE_ENABLED;
import android.Manifest;
import android.annotation.Nullable;
@@ -129,7 +129,7 @@
}
private boolean isServiceEnabled() {
- final String enabled = DeviceConfig.getProperty(NAMESPACE, PROPERTY_SERVICE_ENABLED);
+ final String enabled = DeviceConfig.getProperty(NAMESPACE, SERVICE_ENABLED);
return enabled == null ? DEFAULT_SERVICE_ENABLED : "true".equals(enabled);
}
@@ -279,7 +279,7 @@
* system.
*/
private static ComponentName resolveAttentionService(Context context) {
- final String flag = DeviceConfig.getProperty(NAMESPACE, PROPERTY_COMPONENT_NAME);
+ final String flag = DeviceConfig.getProperty(NAMESPACE, COMPONENT_NAME);
final String componentNameString = flag != null ? flag : context.getString(
R.string.config_defaultAttentionService);
diff --git a/services/core/java/com/android/server/audio/AudioDeviceBroker.java b/services/core/java/com/android/server/audio/AudioDeviceBroker.java
index d652f93..deaa931 100644
--- a/services/core/java/com/android/server/audio/AudioDeviceBroker.java
+++ b/services/core/java/com/android/server/audio/AudioDeviceBroker.java
@@ -600,7 +600,7 @@
break;
case MSG_IL_SET_A2DP_SINK_CONNECTION_STATE:
mDeviceInventory.onSetA2dpSinkConnectionState(
- (BtHelper.BluetoothA2dpDeviceInfo) msg.obj, msg.arg1, msg.arg2);
+ (BtHelper.BluetoothA2dpDeviceInfo) msg.obj, msg.arg1);
break;
case MSG_IL_SET_A2DP_SOURCE_CONNECTION_STATE:
mDeviceInventory.onSetA2dpSourceConnectionState(
diff --git a/services/core/java/com/android/server/audio/AudioDeviceInventory.java b/services/core/java/com/android/server/audio/AudioDeviceInventory.java
index eb76e6e0..97649a7 100644
--- a/services/core/java/com/android/server/audio/AudioDeviceInventory.java
+++ b/services/core/java/com/android/server/audio/AudioDeviceInventory.java
@@ -147,18 +147,20 @@
}
/*package*/ void onSetA2dpSinkConnectionState(@NonNull BtHelper.BluetoothA2dpDeviceInfo btInfo,
- @AudioService.BtProfileConnectionState int state, int a2dpVolume) {
+ @AudioService.BtProfileConnectionState int state) {
final BluetoothDevice btDevice = btInfo.getBtDevice();
+ int a2dpVolume = btInfo.getVolume();
if (AudioService.DEBUG_DEVICES) {
Log.d(TAG, "onSetA2dpSinkConnectionState btDevice=" + btDevice + " state="
- + state + " is dock=" + btDevice.isBluetoothDock());
+ + state + " is dock=" + btDevice.isBluetoothDock() + " vol=" + a2dpVolume);
}
String address = btDevice.getAddress();
if (!BluetoothAdapter.checkBluetoothAddress(address)) {
address = "";
}
AudioService.sDeviceLogger.log(new AudioEventLogger.StringEvent(
- "A2DP sink connected: device addr=" + address + " state=" + state));
+ "A2DP sink connected: device addr=" + address + " state=" + state
+ + " vol=" + a2dpVolume));
final int a2dpCodec;
synchronized (mDeviceBroker.mA2dpAvrcpLock) {
diff --git a/services/core/java/com/android/server/audio/AudioService.java b/services/core/java/com/android/server/audio/AudioService.java
index df33bf2..1723163 100644
--- a/services/core/java/com/android/server/audio/AudioService.java
+++ b/services/core/java/com/android/server/audio/AudioService.java
@@ -392,12 +392,14 @@
* e.g. user on homescreen, no app playing anything, presses hardware volume buttons, this
* stream type is controlled.
*/
- protected static final int DEFAULT_VOL_STREAM_NO_PLAYBACK = AudioSystem.STREAM_MUSIC;
+ protected static final int DEFAULT_VOL_STREAM_NO_PLAYBACK = AudioSystem.STREAM_MUSIC;
private final AudioSystem.ErrorCallback mAudioSystemCallback = new AudioSystem.ErrorCallback() {
public void onError(int error) {
switch (error) {
case AudioSystem.AUDIO_STATUS_SERVER_DIED:
+ mRecordMonitor.clear();
+
sendMsg(mAudioHandler, MSG_AUDIO_SERVER_DIED,
SENDMSG_NOOP, 0, 0, null, 0);
sendMsg(mAudioHandler, MSG_DISPATCH_AUDIO_SERVER_STATE,
diff --git a/services/core/java/com/android/server/audio/RecordingActivityMonitor.java b/services/core/java/com/android/server/audio/RecordingActivityMonitor.java
index 9d6628c..b2c7ff3 100644
--- a/services/core/java/com/android/server/audio/RecordingActivityMonitor.java
+++ b/services/core/java/com/android/server/audio/RecordingActivityMonitor.java
@@ -78,24 +78,27 @@
updateSnapshot(event, uid, session, source, recordingInfo,
portId, silenced, activeSource, clientEffects, effects);
if (configsSystem != null){
- synchronized (mClients) {
- // list of recording configurations for "public consumption". It is only computed if
- // there are non-system recording activity listeners.
- final List<AudioRecordingConfiguration> configsPublic = mHasPublicClients ?
- anonymizeForPublicConsumption(configsSystem) :
- new ArrayList<AudioRecordingConfiguration>();
- final Iterator<RecMonitorClient> clientIterator = mClients.iterator();
- while (clientIterator.hasNext()) {
- final RecMonitorClient rmc = clientIterator.next();
- try {
- if (rmc.mIsPrivileged) {
- rmc.mDispatcherCb.dispatchRecordingConfigChange(configsSystem);
- } else {
- rmc.mDispatcherCb.dispatchRecordingConfigChange(configsPublic);
- }
- } catch (RemoteException e) {
- Log.w(TAG, "Could not call dispatchRecordingConfigChange() on client", e);
+ dispatchCallbacks(configsSystem);
+ }
+ }
+ private void dispatchCallbacks(List<AudioRecordingConfiguration> configs) {
+ synchronized (mClients) {
+ // list of recording configurations for "public consumption". It is only computed if
+ // there are non-system recording activity listeners.
+ final List<AudioRecordingConfiguration> configsPublic = mHasPublicClients
+ ? anonymizeForPublicConsumption(configs) :
+ new ArrayList<AudioRecordingConfiguration>();
+ final Iterator<RecMonitorClient> clientIterator = mClients.iterator();
+ while (clientIterator.hasNext()) {
+ final RecMonitorClient rmc = clientIterator.next();
+ try {
+ if (rmc.mIsPrivileged) {
+ rmc.mDispatcherCb.dispatchRecordingConfigChange(configs);
+ } else {
+ rmc.mDispatcherCb.dispatchRecordingConfigChange(configsPublic);
}
+ } catch (RemoteException e) {
+ Log.w(TAG, "Could not call dispatchRecordingConfigChange() on client", e);
}
}
}
@@ -130,6 +133,13 @@
AudioSystem.setRecordingCallback(this);
}
+ void clear() {
+ synchronized (mRecordConfigs) {
+ mRecordConfigs.clear();
+ }
+ dispatchCallbacks(new ArrayList<AudioRecordingConfiguration>());
+ }
+
void registerRecordingCallback(IRecordingConfigDispatcher rcdb, boolean isPrivileged) {
if (rcdb == null) {
return;
diff --git a/services/core/java/com/android/server/connectivity/Tethering.java b/services/core/java/com/android/server/connectivity/Tethering.java
index eb5be77..a14fd17 100644
--- a/services/core/java/com/android/server/connectivity/Tethering.java
+++ b/services/core/java/com/android/server/connectivity/Tethering.java
@@ -121,7 +121,6 @@
import java.util.HashSet;
import java.util.Set;
-
/**
* @hide
*
@@ -223,7 +222,8 @@
IntentFilter filter = new IntentFilter();
filter.addAction(ACTION_CARRIER_CONFIG_CHANGED);
- mEntitlementMgr = mDeps.getEntitlementManager(mContext, mLog, systemProperties);
+ mEntitlementMgr = mDeps.getEntitlementManager(mContext, mTetherMasterSM,
+ mLog, systemProperties);
mCarrierConfigChange = new VersionedBroadcastListener(
"CarrierConfigChangeListener", mContext, smHandler, filter,
(Intent ignored) -> {
@@ -470,6 +470,7 @@
} else {
sendTetherResult(receiver, resultCode);
}
+ mEntitlementMgr.updateEntitlementCacheValue(type, resultCode);
}
};
@@ -1662,6 +1663,14 @@
mUpstreamNetworkMonitor.startTrackDefaultNetwork(mDeps.getDefaultNetworkRequest());
}
+ /** Get the latest value of the tethering entitlement check. */
+ public void getLatestTetheringEntitlementValue(int type, ResultReceiver receiver,
+ boolean showEntitlementUi) {
+ if (receiver != null) {
+ mEntitlementMgr.getLatestTetheringEntitlementValue(type, receiver, showEntitlementUi);
+ }
+ }
+
@Override
public void dump(FileDescriptor fd, PrintWriter writer, String[] args) {
// Binder.java closes the resource for us.
diff --git a/services/core/java/com/android/server/connectivity/Vpn.java b/services/core/java/com/android/server/connectivity/Vpn.java
index 7e95f10..e1af81b 100644
--- a/services/core/java/com/android/server/connectivity/Vpn.java
+++ b/services/core/java/com/android/server/connectivity/Vpn.java
@@ -166,6 +166,7 @@
private final NetworkInfo mNetworkInfo;
private String mPackage;
private int mOwnerUID;
+ private boolean mIsPackageTargetingAtLeastQ;
private String mInterface;
private Connection mConnection;
private LegacyVpnRunner mLegacyVpnRunner;
@@ -227,6 +228,7 @@
mPackage = VpnConfig.LEGACY_VPN;
mOwnerUID = getAppUid(mPackage, mUserHandle);
+ mIsPackageTargetingAtLeastQ = doesPackageTargetAtLeastQ(mPackage);
try {
netService.registerObserver(mObserver);
@@ -268,8 +270,11 @@
public void updateCapabilities() {
final Network[] underlyingNetworks = (mConfig != null) ? mConfig.underlyingNetworks : null;
+ // Only apps targeting Q and above can explicitly declare themselves as metered.
+ final boolean isAlwaysMetered =
+ mIsPackageTargetingAtLeastQ && (mConfig == null || mConfig.isMetered);
updateCapabilities(mContext.getSystemService(ConnectivityManager.class), underlyingNetworks,
- mNetworkCapabilities);
+ mNetworkCapabilities, isAlwaysMetered);
if (mNetworkAgent != null) {
mNetworkAgent.sendNetworkCapabilities(mNetworkCapabilities);
@@ -278,11 +283,13 @@
@VisibleForTesting
public static void updateCapabilities(ConnectivityManager cm, Network[] underlyingNetworks,
- NetworkCapabilities caps) {
+ NetworkCapabilities caps, boolean isAlwaysMetered) {
int[] transportTypes = new int[] { NetworkCapabilities.TRANSPORT_VPN };
int downKbps = NetworkCapabilities.LINK_BANDWIDTH_UNSPECIFIED;
int upKbps = NetworkCapabilities.LINK_BANDWIDTH_UNSPECIFIED;
- boolean metered = false;
+ // VPN's meteredness is OR'd with isAlwaysMetered and meteredness of its underlying
+ // networks.
+ boolean metered = isAlwaysMetered;
boolean roaming = false;
boolean congested = false;
@@ -725,6 +732,7 @@
Log.i(TAG, "Switched from " + mPackage + " to " + newPackage);
mPackage = newPackage;
mOwnerUID = getAppUid(newPackage, mUserHandle);
+ mIsPackageTargetingAtLeastQ = doesPackageTargetAtLeastQ(newPackage);
try {
mNetd.allowProtect(mOwnerUID);
} catch (Exception e) {
@@ -790,6 +798,21 @@
return result;
}
+ private boolean doesPackageTargetAtLeastQ(String packageName) {
+ if (VpnConfig.LEGACY_VPN.equals(packageName)) {
+ return true;
+ }
+ PackageManager pm = mContext.getPackageManager();
+ try {
+ ApplicationInfo appInfo =
+ pm.getApplicationInfoAsUser(packageName, 0 /*flags*/, mUserHandle);
+ return appInfo.targetSdkVersion >= VERSION_CODES.Q;
+ } catch (NameNotFoundException unused) {
+ Log.w(TAG, "Can't find \"" + packageName + "\"");
+ return false;
+ }
+ }
+
public NetworkInfo getNetworkInfo() {
return mNetworkInfo;
}
@@ -1078,6 +1101,8 @@
// as rules are deleted. This prevents data leakage as the rules are moved over.
agentDisconnect(oldNetworkAgent);
}
+ // Set up VPN's capabilities such as meteredness.
+ updateCapabilities();
if (oldConnection != null) {
mContext.unbindService(oldConnection);
@@ -1778,6 +1803,7 @@
config.user = profile.key;
config.interfaze = iface;
config.session = profile.name;
+ config.isMetered = false;
config.addLegacyRoutes(profile.routes);
if (!profile.dnsServers.isEmpty()) {
diff --git a/services/core/java/com/android/server/connectivity/tethering/EntitlementManager.java b/services/core/java/com/android/server/connectivity/tethering/EntitlementManager.java
index a4e3e1d..75aac10 100644
--- a/services/core/java/com/android/server/connectivity/tethering/EntitlementManager.java
+++ b/services/core/java/com/android/server/connectivity/tethering/EntitlementManager.java
@@ -21,6 +21,9 @@
import static android.net.ConnectivityManager.EXTRA_REM_TETHER_TYPE;
import static android.net.ConnectivityManager.EXTRA_RUN_PROVISION;
import static android.net.ConnectivityManager.EXTRA_SET_ALARM;
+import static android.net.ConnectivityManager.TETHER_ERROR_ENTITLEMENT_UNKONWN;
+import static android.net.ConnectivityManager.TETHER_ERROR_NO_ERROR;
+import static android.net.ConnectivityManager.TETHER_ERROR_PROVISION_FAILED;
import static com.android.internal.R.string.config_wifi_tether_enable;
@@ -31,15 +34,21 @@
import android.content.res.Resources;
import android.net.util.SharedLog;
import android.os.Binder;
+import android.os.Bundle;
+import android.os.Handler;
+import android.os.Parcel;
import android.os.PersistableBundle;
import android.os.ResultReceiver;
import android.os.UserHandle;
import android.provider.Settings;
import android.telephony.CarrierConfigManager;
import android.util.ArraySet;
+import android.util.Log;
+import android.util.SparseIntArray;
import com.android.internal.annotations.GuardedBy;
import com.android.internal.annotations.VisibleForTesting;
+import com.android.internal.util.StateMachine;
import com.android.server.connectivity.MockableSystemProperties;
/**
@@ -50,6 +59,7 @@
*/
public class EntitlementManager {
private static final String TAG = EntitlementManager.class.getSimpleName();
+ private static final boolean DBG = false;
// {@link ComponentName} of the Service used to run tether provisioning.
private static final ComponentName TETHER_SERVICE = ComponentName.unflattenFromString(
@@ -65,15 +75,19 @@
private final Context mContext;
private final MockableSystemProperties mSystemProperties;
private final SharedLog mLog;
+ private final Handler mMasterHandler;
+ private final SparseIntArray mEntitlementCacheValue;
@Nullable
private TetheringConfiguration mConfig;
- public EntitlementManager(Context ctx, SharedLog log,
+ public EntitlementManager(Context ctx, StateMachine tetherMasterSM, SharedLog log,
MockableSystemProperties systemProperties) {
mContext = ctx;
- mLog = log;
+ mLog = log.forSubComponent(TAG);
mCurrentTethers = new ArraySet<Integer>();
mSystemProperties = systemProperties;
+ mEntitlementCacheValue = new SparseIntArray();
+ mMasterHandler = tetherMasterSM.getHandler();
}
/**
@@ -128,6 +142,10 @@
* Reference ConnectivityManager.TETHERING_{@code *} for each tether type.
*/
public void reevaluateSimCardProvisioning() {
+ synchronized (mEntitlementCacheValue) {
+ mEntitlementCacheValue.clear();
+ }
+
if (!mConfig.hasMobileHotspotProvisionApp()) return;
if (carrierConfigAffirmsEntitlementCheckNotRequired()) return;
@@ -175,6 +193,11 @@
}
public void runUiTetherProvisioningAndEnable(int type, ResultReceiver receiver) {
+ runUiTetherProvisioning(type, receiver);
+ }
+
+ @VisibleForTesting
+ protected void runUiTetherProvisioning(int type, ResultReceiver receiver) {
Intent intent = new Intent(Settings.ACTION_TETHER_PROVISIONING);
intent.putExtra(EXTRA_ADD_TETHER_TYPE, type);
intent.putExtra(EXTRA_PROVISION_CALLBACK, receiver);
@@ -221,4 +244,70 @@
Binder.restoreCallingIdentity(ident);
}
}
+
+ private ResultReceiver buildProxyReceiver(int type, final ResultReceiver receiver) {
+ ResultReceiver rr = new ResultReceiver(mMasterHandler) {
+ @Override
+ protected void onReceiveResult(int resultCode, Bundle resultData) {
+ int updatedCacheValue = updateEntitlementCacheValue(type, resultCode);
+ receiver.send(updatedCacheValue, null);
+ }
+ };
+
+ return writeToParcel(rr);
+ }
+
+ private ResultReceiver writeToParcel(final ResultReceiver receiver) {
+ // This is necessary to avoid unmarshalling issues when sending the receiver
+ // across processes.
+ Parcel parcel = Parcel.obtain();
+ receiver.writeToParcel(parcel, 0);
+ parcel.setDataPosition(0);
+ ResultReceiver receiverForSending = ResultReceiver.CREATOR.createFromParcel(parcel);
+ parcel.recycle();
+ return receiverForSending;
+ }
+
+ /**
+ * Update the last entitlement value to internal cache
+ *
+ * @param type tethering type from ConnectivityManager.TETHERING_{@code *}
+ * @param resultCode last entitlement value
+ * @return the last updated entitlement value
+ */
+ public int updateEntitlementCacheValue(int type, int resultCode) {
+ if (DBG) {
+ Log.d(TAG, "updateEntitlementCacheValue: " + type + ", result: " + resultCode);
+ }
+ synchronized (mEntitlementCacheValue) {
+ if (resultCode == TETHER_ERROR_NO_ERROR) {
+ mEntitlementCacheValue.put(type, resultCode);
+ return resultCode;
+ } else {
+ mEntitlementCacheValue.put(type, TETHER_ERROR_PROVISION_FAILED);
+ return TETHER_ERROR_PROVISION_FAILED;
+ }
+ }
+ }
+
+ /** Get the last value of the tethering entitlement check. */
+ public void getLatestTetheringEntitlementValue(int downstream, ResultReceiver receiver,
+ boolean showEntitlementUi) {
+ if (!isTetherProvisioningRequired()) {
+ receiver.send(TETHER_ERROR_NO_ERROR, null);
+ return;
+ }
+
+ final int cacheValue;
+ synchronized (mEntitlementCacheValue) {
+ cacheValue = mEntitlementCacheValue.get(
+ downstream, TETHER_ERROR_ENTITLEMENT_UNKONWN);
+ }
+ if (cacheValue == TETHER_ERROR_NO_ERROR || !showEntitlementUi) {
+ receiver.send(cacheValue, null);
+ } else {
+ ResultReceiver proxy = buildProxyReceiver(downstream, receiver);
+ runUiTetherProvisioning(downstream, proxy);
+ }
+ }
}
diff --git a/services/core/java/com/android/server/connectivity/tethering/TetheringDependencies.java b/services/core/java/com/android/server/connectivity/tethering/TetheringDependencies.java
index a42efe9..6d6f81e 100644
--- a/services/core/java/com/android/server/connectivity/tethering/TetheringDependencies.java
+++ b/services/core/java/com/android/server/connectivity/tethering/TetheringDependencies.java
@@ -81,8 +81,8 @@
/**
* Get a reference to the EntitlementManager to be used by tethering.
*/
- public EntitlementManager getEntitlementManager(Context ctx, SharedLog log,
- MockableSystemProperties systemProperties) {
- return new EntitlementManager(ctx, log, systemProperties);
+ public EntitlementManager getEntitlementManager(Context ctx, StateMachine target,
+ SharedLog log, MockableSystemProperties systemProperties) {
+ return new EntitlementManager(ctx, target, log, systemProperties);
}
}
diff --git a/services/core/java/com/android/server/display/DisplayPowerController.java b/services/core/java/com/android/server/display/DisplayPowerController.java
index db3928e..2a8462b 100644
--- a/services/core/java/com/android/server/display/DisplayPowerController.java
+++ b/services/core/java/com/android/server/display/DisplayPowerController.java
@@ -592,6 +592,9 @@
}
public BrightnessConfiguration getDefaultBrightnessConfiguration() {
+ if (mAutomaticBrightnessController == null) {
+ return null;
+ }
return mAutomaticBrightnessController.getDefaultConfig();
}
diff --git a/services/core/java/com/android/server/dreams/OWNERS b/services/core/java/com/android/server/dreams/OWNERS
index 3c9bbf8..426f002 100644
--- a/services/core/java/com/android/server/dreams/OWNERS
+++ b/services/core/java/com/android/server/dreams/OWNERS
@@ -1,3 +1,3 @@
-dsandler@google.com
+dsandler@android.com
michaelwr@google.com
roosa@google.com
diff --git a/services/core/java/com/android/server/incident/IncidentCompanionService.java b/services/core/java/com/android/server/incident/IncidentCompanionService.java
index 3ebba00..6f2bfc3 100644
--- a/services/core/java/com/android/server/incident/IncidentCompanionService.java
+++ b/services/core/java/com/android/server/incident/IncidentCompanionService.java
@@ -16,38 +16,18 @@
package com.android.server.incident;
-import android.app.ActivityManager;
-import android.app.AppOpsManager;
-import android.content.ComponentName;
import android.content.Context;
-import android.content.Intent;
-import android.content.pm.PackageManager;
-import android.content.pm.ResolveInfo;
-import android.content.pm.UserInfo;
-import android.net.Uri;
import android.os.Binder;
-import android.os.Handler;
import android.os.IIncidentAuthListener;
import android.os.IIncidentCompanion;
-import android.os.IncidentManager;
-import android.os.RemoteException;
-import android.os.SystemClock;
-import android.os.UserHandle;
-import android.os.UserManager;
-import android.util.Log;
import com.android.internal.util.DumpUtils;
import com.android.server.SystemService;
import java.io.FileDescriptor;
import java.io.PrintWriter;
-import java.text.SimpleDateFormat;
-import java.util.ArrayList;
-import java.util.Date;
import java.util.List;
-// TODO: User changes should deny everything that's pending.
-
/**
* Helper service for incidentd and dumpstated to provide user feedback
* and authorization for bug and inicdent reports to be taken.
@@ -55,83 +35,26 @@
public class IncidentCompanionService extends SystemService {
static final String TAG = "IncidentCompanionService";
- private final Handler mHandler = new Handler();
- private final RequestQueue mRequestQueue = new RequestQueue(mHandler);
- private final PackageManager mPackageManager;
- private final AppOpsManager mAppOpsManager;
-
- //
- // All fields below must be protected by mLock
- //
- private final Object mLock = new Object();
- private final ArrayList<PendingReportRec> mPending = new ArrayList();
-
/**
- * The next ID we'll use when we make a PendingReportRec.
+ * Tracker for reports pending approval.
*/
- private int mNextPendingId = 1;
-
- /**
- * One for each authorization that's pending.
- */
- private final class PendingReportRec {
- public int id;
- public String callingPackage;
- public int flags;
- public IIncidentAuthListener listener;
- public long addedRealtime;
- public long addedWalltime;
-
- /**
- * Construct a PendingReportRec, with an auto-incremented id.
- */
- PendingReportRec(String callingPackage, int flags, IIncidentAuthListener listener) {
- this.id = mNextPendingId++;
- this.callingPackage = callingPackage;
- this.flags = flags;
- this.listener = listener;
- this.addedRealtime = SystemClock.elapsedRealtime();
- this.addedWalltime = System.currentTimeMillis();
- }
-
- /**
- * Get the Uri that contains the flattened data.
- */
- Uri getUri() {
- return (new Uri.Builder())
- .scheme(IncidentManager.URI_SCHEME)
- .authority(IncidentManager.URI_AUTHORITY)
- .path(IncidentManager.URI_PATH)
- .appendQueryParameter(IncidentManager.URI_PARAM_ID, Integer.toString(id))
- .appendQueryParameter(IncidentManager.URI_PARAM_CALLING_PACKAGE, callingPackage)
- .appendQueryParameter(IncidentManager.URI_PARAM_FLAGS, Integer.toString(flags))
- .appendQueryParameter(IncidentManager.URI_PARAM_TIMESTAMP,
- Long.toString(addedWalltime))
- .build();
- }
- }
+ private PendingReports mPendingReports;
/**
* Implementation of the IIncidentCompanion binder interface.
*/
private final class BinderService extends IIncidentCompanion.Stub {
/**
- * ONEWAY binder call to initiate authorizing the report. The actual logic is posted
- * to mRequestQueue, and may happen later. The security checks need to happen here.
+ * ONEWAY binder call to initiate authorizing the report.
*/
@Override
- public void authorizeReport(int callingUid, final String callingPackage, final int flags,
+ public void authorizeReport(int callingUid, final String callingPackage, int flags,
final IIncidentAuthListener listener) {
enforceRequestAuthorizationPermission();
final long ident = Binder.clearCallingIdentity();
try {
- // Starting the system server is complicated, and rather than try to
- // have a complicated lifecycle that we share with dumpstated and incidentd,
- // we will accept the request, and then display it whenever it becomes possible to.
- mRequestQueue.enqueue(listener.asBinder(), true, () -> {
- authorizeReportImpl(callingUid, callingPackage, flags, listener);
- });
+ mPendingReports.authorizeReport(callingUid, callingPackage, flags, listener);
} finally {
Binder.restoreCallingIdentity(ident);
}
@@ -152,9 +75,7 @@
// authorize/cancel pairs.
final long ident = Binder.clearCallingIdentity();
try {
- mRequestQueue.enqueue(listener.asBinder(), false, () -> {
- cancelReportImpl(listener);
- });
+ mPendingReports.cancelAuthorization(listener);
} finally {
Binder.restoreCallingIdentity(ident);
}
@@ -167,19 +88,11 @@
@Override
public List<String> getPendingReports() {
enforceAuthorizePermission();
-
- synchronized (mLock) {
- final int size = mPending.size();
- final ArrayList<String> result = new ArrayList(size);
- for (int i = 0; i < size; i++) {
- result.add(mPending.get(i).getUri().toString());
- }
- return result;
- }
+ return mPendingReports.getPendingReports();
}
/**
- * ONEWAY binder call to mark a report as approved.
+ * SYNCHRONOUS binder call to mark a report as approved.
*/
@Override
public void approveReport(String uri) {
@@ -187,32 +100,14 @@
final long ident = Binder.clearCallingIdentity();
try {
- final PendingReportRec rec;
- synchronized (mLock) {
- rec = findAndRemovePendingReportRecLocked(uri);
- if (rec == null) {
- Log.e(TAG, "confirmApproved: Couldn't find record for uri: " + uri);
- return;
- }
- }
-
- // Re-do the broadcast, so whoever is listening knows the list changed,
- // in case another one was added in the meantime.
- sendBroadcast();
-
- Log.i(TAG, "Approved report: " + uri);
- try {
- rec.listener.onReportApproved();
- } catch (RemoteException ex) {
- Log.w(TAG, "Failed calling back for approval for: " + uri, ex);
- }
+ mPendingReports.approveReport(uri);
} finally {
Binder.restoreCallingIdentity(ident);
}
}
/**
- * ONEWAY binder call to mark a report as NOT approved.
+ * SYNCHRONOUS binder call to mark a report as NOT approved.
*/
@Override
public void denyReport(String uri) {
@@ -220,25 +115,7 @@
final long ident = Binder.clearCallingIdentity();
try {
- final PendingReportRec rec;
- synchronized (mLock) {
- rec = findAndRemovePendingReportRecLocked(uri);
- if (rec == null) {
- Log.e(TAG, "confirmDenied: Couldn't find record for uri: " + uri);
- return;
- }
- }
-
- // Re-do the broadcast, so whoever is listening knows the list changed,
- // in case another one was added in the meantime.
- sendBroadcast();
-
- Log.i(TAG, "Denied report: " + uri);
- try {
- rec.listener.onReportDenied();
- } catch (RemoteException ex) {
- Log.w(TAG, "Failed calling back for denial for: " + uri, ex);
- }
+ mPendingReports.denyReport(uri);
} finally {
Binder.restoreCallingIdentity(ident);
}
@@ -252,27 +129,22 @@
if (!DumpUtils.checkDumpPermission(getContext(), TAG, writer)) {
return;
}
- if (args.length == 0) {
- // Standard text dumpsys
- final SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS");
- synchronized (mLock) {
- final int size = mPending.size();
- writer.println("mPending: (" + size + ")");
- for (int i = 0; i < size; i++) {
- final PendingReportRec entry = mPending.get(i);
- writer.println(String.format(" %11d %s: %s", entry.addedRealtime,
- df.format(new Date(entry.addedWalltime)),
- entry.getUri().toString()));
- }
- }
- }
+ mPendingReports.dump(fd, writer, args);
}
+ /**
+ * Inside the binder interface class because we want to do all of the authorization
+ * here, before calling out to the helper objects.
+ */
private void enforceRequestAuthorizationPermission() {
getContext().enforceCallingOrSelfPermission(
android.Manifest.permission.REQUEST_INCIDENT_REPORT_APPROVAL, null);
}
+ /**
+ * Inside the binder interface class because we want to do all of the authorization
+ * here, before calling out to the helper objects.
+ */
private void enforceAuthorizePermission() {
getContext().enforceCallingOrSelfPermission(
android.Manifest.permission.APPROVE_INCIDENT_REPORTS, null);
@@ -285,8 +157,7 @@
*/
public IncidentCompanionService(Context context) {
super(context);
- mPackageManager = context.getPackageManager();
- mAppOpsManager = context.getSystemService(AppOpsManager.class);
+ mPendingReports = new PendingReports(context);
}
/**
@@ -307,239 +178,9 @@
super.onBootPhase(phase);
switch (phase) {
case SystemService.PHASE_BOOT_COMPLETED:
- // Release the enqueued work.
- mRequestQueue.start();
+ mPendingReports.onBootCompleted();
break;
}
}
-
- /**
- * Start the confirmation process.
- */
- private void authorizeReportImpl(int callingUid, final String callingPackage, int flags,
- final IIncidentAuthListener listener) {
- // Enforce that the calling package pertains to the callingUid.
- if (!isPackageInUid(callingUid, callingPackage)) {
- Log.w(TAG, "Calling uid " + callingUid + " doesn't match package "
- + callingPackage);
- denyReportBeforeAddingRec(listener, callingPackage);
- return;
- }
-
- // Find the primary user of this device.
- final int primaryUser = getAndValidateUser();
- if (primaryUser == UserHandle.USER_NULL) {
- denyReportBeforeAddingRec(listener, callingPackage);
- return;
- }
-
- // Find the approver app (hint: it's PermissionController).
- final ComponentName receiver = getApproverComponent(primaryUser);
- if (receiver == null) {
- // We couldn't find an approver... so deny the request here and now, before we
- // do anything else.
- denyReportBeforeAddingRec(listener, callingPackage);
- return;
- }
-
- // Save the record for when the PermissionController comes back to authorize it.
- PendingReportRec rec = null;
- synchronized (mLock) {
- rec = new PendingReportRec(callingPackage, flags, listener);
- mPending.add(rec);
- }
-
- try {
- listener.asBinder().linkToDeath(() -> {
- Log.i(TAG, "Got death notification listener=" + listener);
- cancelReportImpl(listener, receiver, primaryUser);
- }, 0);
- } catch (RemoteException ex) {
- Log.e(TAG, "Remote died while trying to register death listener: " + rec.getUri());
- // First, remove from our list.
- cancelReportImpl(listener, receiver, primaryUser);
- }
-
- // Go tell Permission controller to start asking the user.
- sendBroadcast(receiver, primaryUser);
- }
-
- /**
- * Cancel a pending report request (because of an explicit call to cancel)
- */
- private void cancelReportImpl(IIncidentAuthListener listener) {
- final int primaryUser = getAndValidateUser();
- final ComponentName receiver = getApproverComponent(primaryUser);
- if (primaryUser != UserHandle.USER_NULL && receiver != null) {
- cancelReportImpl(listener, receiver, primaryUser);
- }
- }
-
- /**
- * Cancel a pending report request (either because of an explicit call to cancel
- * by the calling app, or because of a binder death).
- */
- private void cancelReportImpl(IIncidentAuthListener listener, ComponentName receiver,
- int primaryUser) {
- // First, remove from our list.
- synchronized (mLock) {
- removePendingReportRecLocked(listener);
- }
- // Second, call back to PermissionController to say it's canceled.
- sendBroadcast(receiver, primaryUser);
- }
-
- /**
- * Send an extra copy of the broadcast, to tell them that the list has changed
- * because of an addition or removal. This function is less aggressive than
- * authorizeReportImpl in logging about failures, because this is for use in
- * cleanup cases to keep the apps' list in sync with ours.
- */
- private void sendBroadcast() {
- final int primaryUser = getAndValidateUser();
- if (primaryUser == UserHandle.USER_NULL) {
- return;
- }
- final ComponentName receiver = getApproverComponent(primaryUser);
- if (receiver == null) {
- return;
- }
- sendBroadcast(receiver, primaryUser);
- }
-
- /**
- * Send the confirmation broadcast.
- */
- private void sendBroadcast(ComponentName receiver, int primaryUser) {
- final Intent intent = new Intent(Intent.ACTION_PENDING_INCIDENT_REPORTS_CHANGED);
- intent.setComponent(receiver);
-
- // Send it to the primary user.
- getContext().sendBroadcastAsUser(intent, UserHandle.getUserHandleForUid(primaryUser),
- android.Manifest.permission.APPROVE_INCIDENT_REPORTS);
- }
-
- /**
- * Remove a PendingReportRec keyed by uri, and return it.
- */
- private PendingReportRec findAndRemovePendingReportRecLocked(String uriString) {
- final Uri uri = Uri.parse(uriString);
- final int id;
- try {
- final String idStr = uri.getQueryParameter(IncidentManager.URI_PARAM_ID);
- id = Integer.parseInt(idStr);
- } catch (NumberFormatException ex) {
- Log.w(TAG, "Can't parse id from: " + uriString);
- return null;
- }
- final int size = mPending.size();
- for (int i = 0; i < size; i++) {
- final PendingReportRec rec = mPending.get(i);
- if (rec.id == id) {
- mPending.remove(i);
- return rec;
- }
- }
- return null;
- }
-
- /**
- * Remove a PendingReportRec keyed by listener.
- */
- private void removePendingReportRecLocked(IIncidentAuthListener listener) {
- final int size = mPending.size();
- for (int i = 0; i < size; i++) {
- final PendingReportRec rec = mPending.get(i);
- if (rec.listener.asBinder() == listener.asBinder()) {
- Log.i(TAG, " ...Removed PendingReportRec index=" + i + ": " + rec.getUri());
- mPending.remove(i);
- }
- }
- }
-
- /**
- * Just call listener.deny() (wrapping the RemoteException), without try to
- * add it to the list.
- */
- private void denyReportBeforeAddingRec(IIncidentAuthListener listener, String pkg) {
- try {
- listener.onReportDenied();
- } catch (RemoteException ex) {
- Log.w(TAG, "Failed calling back for denial for " + pkg, ex);
- }
- }
-
- /**
- * Check whether the current user is the primary user, and return the user id if they are.
- * Returns UserHandle.USER_NULL if not valid.
- */
- private int getAndValidateUser() {
- // Current user
- UserInfo currentUser;
- try {
- currentUser = ActivityManager.getService().getCurrentUser();
- } catch (RemoteException ex) {
- // We're already inside the system process.
- throw new RuntimeException(ex);
- }
-
- // Primary user
- final UserManager um = UserManager.get(getContext());
- final UserInfo primaryUser = um.getPrimaryUser();
-
- // Check that we're using the right user.
- if (currentUser == null) {
- Log.w(TAG, "No current user. Nobody to approve the report."
- + " The report will be denied.");
- return UserHandle.USER_NULL;
- }
- if (primaryUser == null) {
- Log.w(TAG, "No primary user. Nobody to approve the report."
- + " The report will be denied.");
- return UserHandle.USER_NULL;
- }
- if (primaryUser.id != currentUser.id) {
- Log.w(TAG, "Only the primary user can approve bugreports, but they are not"
- + " the current user. The report will be denied.");
- return UserHandle.USER_NULL;
- }
-
- return primaryUser.id;
- }
-
- /**
- * Return the ComponentName of the BroadcastReceiver that will approve reports.
- * The system must have zero or one of these installed. We only look on the
- * system partition. When the broadcast happens, the component will also need
- * have the APPROVE_INCIDENT_REPORTS permission.
- */
- private ComponentName getApproverComponent(int userId) {
- // Find the one true BroadcastReceiver
- final Intent intent = new Intent(Intent.ACTION_PENDING_INCIDENT_REPORTS_CHANGED);
- final List<ResolveInfo> matches = mPackageManager.queryBroadcastReceiversAsUser(intent,
- PackageManager.MATCH_SYSTEM_ONLY | PackageManager.MATCH_DIRECT_BOOT_AWARE
- | PackageManager.MATCH_DIRECT_BOOT_UNAWARE, userId);
- if (matches.size() == 1) {
- return matches.get(0).getComponentInfo().getComponentName();
- } else {
- Log.w(TAG, "Didn't find exactly one BroadcastReceiver to handle "
- + Intent.ACTION_PENDING_INCIDENT_REPORTS_CHANGED
- + ". The report will be denied. size="
- + matches.size() + ": matches=" + matches);
- return null;
- }
- }
-
- /**
- * Return whether the package is one of the packages installed for the uid.
- */
- private boolean isPackageInUid(int uid, String packageName) {
- try {
- mAppOpsManager.checkPackage(uid, packageName);
- return true;
- } catch (SecurityException ex) {
- return false;
- }
- }
}
diff --git a/services/core/java/com/android/server/incident/PendingReports.java b/services/core/java/com/android/server/incident/PendingReports.java
new file mode 100644
index 0000000..519ed41
--- /dev/null
+++ b/services/core/java/com/android/server/incident/PendingReports.java
@@ -0,0 +1,477 @@
+/*
+ * Copyright (C) 2019 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.server.incident;
+
+import android.app.ActivityManager;
+import android.app.AppOpsManager;
+import android.content.ComponentName;
+import android.content.Context;
+import android.content.Intent;
+import android.content.pm.PackageManager;
+import android.content.pm.ResolveInfo;
+import android.content.pm.UserInfo;
+import android.net.Uri;
+import android.os.Handler;
+import android.os.IIncidentAuthListener;
+import android.os.IncidentManager;
+import android.os.RemoteException;
+import android.os.SystemClock;
+import android.os.UserHandle;
+import android.os.UserManager;
+import android.util.Log;
+
+import java.io.FileDescriptor;
+import java.io.PrintWriter;
+import java.text.SimpleDateFormat;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+
+// TODO: User changes should deny everything that's pending.
+
+/**
+ * Tracker for reports pending approval.
+ */
+class PendingReports {
+ static final String TAG = IncidentCompanionService.TAG;
+
+ private final Handler mHandler = new Handler();
+ private final RequestQueue mRequestQueue = new RequestQueue(mHandler);
+ private final Context mContext;
+ private final PackageManager mPackageManager;
+ private final AppOpsManager mAppOpsManager;
+
+ //
+ // All fields below must be protected by mLock
+ //
+ private final Object mLock = new Object();
+ private final ArrayList<PendingReportRec> mPending = new ArrayList();
+
+ /**
+ * The next ID we'll use when we make a PendingReportRec.
+ */
+ private int mNextPendingId = 1;
+
+ /**
+ * One for each authorization that's pending.
+ */
+ private final class PendingReportRec {
+ public int id;
+ public String callingPackage;
+ public int flags;
+ public IIncidentAuthListener listener;
+ public long addedRealtime;
+ public long addedWalltime;
+
+ /**
+ * Construct a PendingReportRec, with an auto-incremented id.
+ */
+ PendingReportRec(String callingPackage, int flags, IIncidentAuthListener listener) {
+ this.id = mNextPendingId++;
+ this.callingPackage = callingPackage;
+ this.flags = flags;
+ this.listener = listener;
+ this.addedRealtime = SystemClock.elapsedRealtime();
+ this.addedWalltime = System.currentTimeMillis();
+ }
+
+ /**
+ * Get the Uri that contains the flattened data.
+ */
+ Uri getUri() {
+ return (new Uri.Builder())
+ .scheme(IncidentManager.URI_SCHEME)
+ .authority(IncidentManager.URI_AUTHORITY)
+ .path(IncidentManager.URI_PATH)
+ .appendQueryParameter(IncidentManager.URI_PARAM_ID, Integer.toString(id))
+ .appendQueryParameter(IncidentManager.URI_PARAM_CALLING_PACKAGE, callingPackage)
+ .appendQueryParameter(IncidentManager.URI_PARAM_FLAGS, Integer.toString(flags))
+ .appendQueryParameter(IncidentManager.URI_PARAM_TIMESTAMP,
+ Long.toString(addedWalltime))
+ .build();
+ }
+ }
+
+ /**
+ * Construct new PendingReports with the context.
+ */
+ PendingReports(Context context) {
+ mContext = context;
+ mPackageManager = context.getPackageManager();
+ mAppOpsManager = context.getSystemService(AppOpsManager.class);
+ }
+
+ /**
+ * ONEWAY binder call to initiate authorizing the report. The actual logic is posted
+ * to mRequestQueue, and may happen later.
+ * <p>
+ * The security checks are handled by IncidentCompanionService.
+ */
+ public void authorizeReport(int callingUid, final String callingPackage, final int flags,
+ final IIncidentAuthListener listener) {
+ // Starting the system server is complicated, and rather than try to
+ // have a complicated lifecycle that we share with dumpstated and incidentd,
+ // we will accept the request, and then display it whenever it becomes possible to.
+ mRequestQueue.enqueue(listener.asBinder(), true, () -> {
+ authorizeReportImpl(callingUid, callingPackage, flags, listener);
+ });
+ }
+
+ /**
+ * ONEWAY binder call to cancel the inbound authorization request.
+ * <p>
+ * This is a oneway call, and so is authorizeReport, so the
+ * caller's ordering is preserved. The other calls on this object are synchronous, so
+ * their ordering is not guaranteed with respect to these calls. So the implementation
+ * sends out extra broadcasts to allow for eventual consistency.
+ * <p>
+ * The security checks are handled by IncidentCompanionService.
+ */
+ public void cancelAuthorization(final IIncidentAuthListener listener) {
+ mRequestQueue.enqueue(listener.asBinder(), false, () -> {
+ cancelReportImpl(listener);
+ });
+ }
+
+ /**
+ * SYNCHRONOUS binder call to get the list of reports that are pending confirmation
+ * by the user.
+ * <p>
+ * The security checks are handled by IncidentCompanionService.
+ */
+ public List<String> getPendingReports() {
+ synchronized (mLock) {
+ final int size = mPending.size();
+ final ArrayList<String> result = new ArrayList(size);
+ for (int i = 0; i < size; i++) {
+ result.add(mPending.get(i).getUri().toString());
+ }
+ return result;
+ }
+ }
+
+ /**
+ * SYNCHRONOUS binder call to mark a report as approved.
+ * <p>
+ * The security checks are handled by IncidentCompanionService.
+ */
+ public void approveReport(String uri) {
+ final PendingReportRec rec;
+ synchronized (mLock) {
+ rec = findAndRemovePendingReportRecLocked(uri);
+ if (rec == null) {
+ Log.e(TAG, "confirmApproved: Couldn't find record for uri: " + uri);
+ return;
+ }
+ }
+
+ // Re-do the broadcast, so whoever is listening knows the list changed,
+ // in case another one was added in the meantime.
+ sendBroadcast();
+
+ Log.i(TAG, "Approved report: " + uri);
+ try {
+ rec.listener.onReportApproved();
+ } catch (RemoteException ex) {
+ Log.w(TAG, "Failed calling back for approval for: " + uri, ex);
+ }
+ }
+
+ /**
+ * SYNCHRONOUS binder call to mark a report as NOT approved.
+ */
+ public void denyReport(String uri) {
+ final PendingReportRec rec;
+ synchronized (mLock) {
+ rec = findAndRemovePendingReportRecLocked(uri);
+ if (rec == null) {
+ Log.e(TAG, "confirmDenied: Couldn't find record for uri: " + uri);
+ return;
+ }
+ }
+
+ // Re-do the broadcast, so whoever is listening knows the list changed,
+ // in case another one was added in the meantime.
+ sendBroadcast();
+
+ Log.i(TAG, "Denied report: " + uri);
+ try {
+ rec.listener.onReportDenied();
+ } catch (RemoteException ex) {
+ Log.w(TAG, "Failed calling back for denial for: " + uri, ex);
+ }
+ }
+
+ /**
+ * Implementation of adb shell dumpsys debugreportcompanion.
+ */
+ protected void dump(FileDescriptor fd, final PrintWriter writer, String[] args) {
+ if (args.length == 0) {
+ // Standard text dumpsys
+ final SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS");
+ synchronized (mLock) {
+ final int size = mPending.size();
+ writer.println("mPending: (" + size + ")");
+ for (int i = 0; i < size; i++) {
+ final PendingReportRec entry = mPending.get(i);
+ writer.println(String.format(" %11d %s: %s", entry.addedRealtime,
+ df.format(new Date(entry.addedWalltime)),
+ entry.getUri().toString()));
+ }
+ }
+ }
+ }
+
+ /**
+ * Handle the boot process... Starts everything running once the system is
+ * up enough for us to do UI.
+ */
+ public void onBootCompleted() {
+ // Release the enqueued work.
+ mRequestQueue.start();
+ }
+
+ /**
+ * Start the confirmation process.
+ */
+ private void authorizeReportImpl(int callingUid, final String callingPackage, int flags,
+ final IIncidentAuthListener listener) {
+ // Enforce that the calling package pertains to the callingUid.
+ if (!isPackageInUid(callingUid, callingPackage)) {
+ Log.w(TAG, "Calling uid " + callingUid + " doesn't match package "
+ + callingPackage);
+ denyReportBeforeAddingRec(listener, callingPackage);
+ return;
+ }
+
+ // Find the primary user of this device.
+ final int primaryUser = getAndValidateUser();
+ if (primaryUser == UserHandle.USER_NULL) {
+ denyReportBeforeAddingRec(listener, callingPackage);
+ return;
+ }
+
+ // Find the approver app (hint: it's PermissionController).
+ final ComponentName receiver = getApproverComponent(primaryUser);
+ if (receiver == null) {
+ // We couldn't find an approver... so deny the request here and now, before we
+ // do anything else.
+ denyReportBeforeAddingRec(listener, callingPackage);
+ return;
+ }
+
+ // Save the record for when the PermissionController comes back to authorize it.
+ PendingReportRec rec = null;
+ synchronized (mLock) {
+ rec = new PendingReportRec(callingPackage, flags, listener);
+ mPending.add(rec);
+ }
+
+ try {
+ listener.asBinder().linkToDeath(() -> {
+ Log.i(TAG, "Got death notification listener=" + listener);
+ cancelReportImpl(listener, receiver, primaryUser);
+ }, 0);
+ } catch (RemoteException ex) {
+ Log.e(TAG, "Remote died while trying to register death listener: " + rec.getUri());
+ // First, remove from our list.
+ cancelReportImpl(listener, receiver, primaryUser);
+ }
+
+ // Go tell Permission controller to start asking the user.
+ sendBroadcast(receiver, primaryUser);
+ }
+
+ /**
+ * Cancel a pending report request (because of an explicit call to cancel)
+ */
+ private void cancelReportImpl(IIncidentAuthListener listener) {
+ final int primaryUser = getAndValidateUser();
+ final ComponentName receiver = getApproverComponent(primaryUser);
+ if (primaryUser != UserHandle.USER_NULL && receiver != null) {
+ cancelReportImpl(listener, receiver, primaryUser);
+ }
+ }
+
+ /**
+ * Cancel a pending report request (either because of an explicit call to cancel
+ * by the calling app, or because of a binder death).
+ */
+ private void cancelReportImpl(IIncidentAuthListener listener, ComponentName receiver,
+ int primaryUser) {
+ // First, remove from our list.
+ synchronized (mLock) {
+ removePendingReportRecLocked(listener);
+ }
+ // Second, call back to PermissionController to say it's canceled.
+ sendBroadcast(receiver, primaryUser);
+ }
+
+ /**
+ * Send an extra copy of the broadcast, to tell them that the list has changed
+ * because of an addition or removal. This function is less aggressive than
+ * authorizeReportImpl in logging about failures, because this is for use in
+ * cleanup cases to keep the apps' list in sync with ours.
+ */
+ private void sendBroadcast() {
+ final int primaryUser = getAndValidateUser();
+ if (primaryUser == UserHandle.USER_NULL) {
+ return;
+ }
+ final ComponentName receiver = getApproverComponent(primaryUser);
+ if (receiver == null) {
+ return;
+ }
+ sendBroadcast(receiver, primaryUser);
+ }
+
+ /**
+ * Send the confirmation broadcast.
+ */
+ private void sendBroadcast(ComponentName receiver, int primaryUser) {
+ final Intent intent = new Intent(Intent.ACTION_PENDING_INCIDENT_REPORTS_CHANGED);
+ intent.setComponent(receiver);
+
+ // Send it to the primary user.
+ mContext.sendBroadcastAsUser(intent, UserHandle.getUserHandleForUid(primaryUser),
+ android.Manifest.permission.APPROVE_INCIDENT_REPORTS);
+ }
+
+ /**
+ * Remove a PendingReportRec keyed by uri, and return it.
+ */
+ private PendingReportRec findAndRemovePendingReportRecLocked(String uriString) {
+ final Uri uri = Uri.parse(uriString);
+ final int id;
+ try {
+ final String idStr = uri.getQueryParameter(IncidentManager.URI_PARAM_ID);
+ id = Integer.parseInt(idStr);
+ } catch (NumberFormatException ex) {
+ Log.w(TAG, "Can't parse id from: " + uriString);
+ return null;
+ }
+ final int size = mPending.size();
+ for (int i = 0; i < size; i++) {
+ final PendingReportRec rec = mPending.get(i);
+ if (rec.id == id) {
+ mPending.remove(i);
+ return rec;
+ }
+ }
+ return null;
+ }
+
+ /**
+ * Remove a PendingReportRec keyed by listener.
+ */
+ private void removePendingReportRecLocked(IIncidentAuthListener listener) {
+ final int size = mPending.size();
+ for (int i = 0; i < size; i++) {
+ final PendingReportRec rec = mPending.get(i);
+ if (rec.listener.asBinder() == listener.asBinder()) {
+ Log.i(TAG, " ...Removed PendingReportRec index=" + i + ": " + rec.getUri());
+ mPending.remove(i);
+ }
+ }
+ }
+
+ /**
+ * Just call listener.deny() (wrapping the RemoteException), without try to
+ * add it to the list.
+ */
+ private void denyReportBeforeAddingRec(IIncidentAuthListener listener, String pkg) {
+ try {
+ listener.onReportDenied();
+ } catch (RemoteException ex) {
+ Log.w(TAG, "Failed calling back for denial for " + pkg, ex);
+ }
+ }
+
+ /**
+ * Check whether the current user is the primary user, and return the user id if they are.
+ * Returns UserHandle.USER_NULL if not valid.
+ */
+ private int getAndValidateUser() {
+ // Current user
+ UserInfo currentUser;
+ try {
+ currentUser = ActivityManager.getService().getCurrentUser();
+ } catch (RemoteException ex) {
+ // We're already inside the system process.
+ throw new RuntimeException(ex);
+ }
+
+ // Primary user
+ final UserManager um = UserManager.get(mContext);
+ final UserInfo primaryUser = um.getPrimaryUser();
+
+ // Check that we're using the right user.
+ if (currentUser == null) {
+ Log.w(TAG, "No current user. Nobody to approve the report."
+ + " The report will be denied.");
+ return UserHandle.USER_NULL;
+ }
+ if (primaryUser == null) {
+ Log.w(TAG, "No primary user. Nobody to approve the report."
+ + " The report will be denied.");
+ return UserHandle.USER_NULL;
+ }
+ if (primaryUser.id != currentUser.id) {
+ Log.w(TAG, "Only the primary user can approve bugreports, but they are not"
+ + " the current user. The report will be denied.");
+ return UserHandle.USER_NULL;
+ }
+
+ return primaryUser.id;
+ }
+
+ /**
+ * Return the ComponentName of the BroadcastReceiver that will approve reports.
+ * The system must have zero or one of these installed. We only look on the
+ * system partition. When the broadcast happens, the component will also need
+ * have the APPROVE_INCIDENT_REPORTS permission.
+ */
+ private ComponentName getApproverComponent(int userId) {
+ // Find the one true BroadcastReceiver
+ final Intent intent = new Intent(Intent.ACTION_PENDING_INCIDENT_REPORTS_CHANGED);
+ final List<ResolveInfo> matches = mPackageManager.queryBroadcastReceiversAsUser(intent,
+ PackageManager.MATCH_SYSTEM_ONLY | PackageManager.MATCH_DIRECT_BOOT_AWARE
+ | PackageManager.MATCH_DIRECT_BOOT_UNAWARE, userId);
+ if (matches.size() == 1) {
+ return matches.get(0).getComponentInfo().getComponentName();
+ } else {
+ Log.w(TAG, "Didn't find exactly one BroadcastReceiver to handle "
+ + Intent.ACTION_PENDING_INCIDENT_REPORTS_CHANGED
+ + ". The report will be denied. size="
+ + matches.size() + ": matches=" + matches);
+ return null;
+ }
+ }
+
+ /**
+ * Return whether the package is one of the packages installed for the uid.
+ */
+ private boolean isPackageInUid(int uid, String packageName) {
+ try {
+ mAppOpsManager.checkPackage(uid, packageName);
+ return true;
+ } catch (SecurityException ex) {
+ return false;
+ }
+ }
+}
+
diff --git a/services/core/java/com/android/server/location/ActivityRecognitionProxy.java b/services/core/java/com/android/server/location/ActivityRecognitionProxy.java
index 22fabb2..80ab790 100644
--- a/services/core/java/com/android/server/location/ActivityRecognitionProxy.java
+++ b/services/core/java/com/android/server/location/ActivityRecognitionProxy.java
@@ -24,7 +24,7 @@
import android.os.RemoteException;
import android.util.Log;
-import com.android.internal.os.BackgroundThread;
+import com.android.server.FgThread;
import com.android.server.ServiceWatcher;
/**
@@ -84,7 +84,7 @@
overlaySwitchResId,
defaultServicePackageNameResId,
initialPackageNameResId,
- BackgroundThread.getHandler()) {
+ FgThread.getHandler()) {
@Override
protected void onBind() {
runOnBinder(ActivityRecognitionProxy.this::initializeService);
diff --git a/services/core/java/com/android/server/location/GeocoderProxy.java b/services/core/java/com/android/server/location/GeocoderProxy.java
index e6f0ed9..d9602b8 100644
--- a/services/core/java/com/android/server/location/GeocoderProxy.java
+++ b/services/core/java/com/android/server/location/GeocoderProxy.java
@@ -21,7 +21,7 @@
import android.location.GeocoderParams;
import android.location.IGeocodeProvider;
-import com.android.internal.os.BackgroundThread;
+import com.android.server.FgThread;
import com.android.server.ServiceWatcher;
import java.util.List;
@@ -53,7 +53,7 @@
int initialPackageNamesResId) {
mServiceWatcher = new ServiceWatcher(context, TAG, SERVICE_ACTION, overlaySwitchResId,
defaultServicePackageNameResId, initialPackageNamesResId,
- BackgroundThread.getHandler());
+ FgThread.getHandler());
}
private boolean bind() {
diff --git a/services/core/java/com/android/server/location/GeofenceProxy.java b/services/core/java/com/android/server/location/GeofenceProxy.java
index 38c7d49..ce93661 100644
--- a/services/core/java/com/android/server/location/GeofenceProxy.java
+++ b/services/core/java/com/android/server/location/GeofenceProxy.java
@@ -30,7 +30,7 @@
import android.os.UserHandle;
import android.util.Log;
-import com.android.internal.os.BackgroundThread;
+import com.android.server.FgThread;
import com.android.server.ServiceWatcher;
/**
@@ -82,7 +82,7 @@
mContext = context;
mServiceWatcher = new ServiceWatcher(context, TAG, SERVICE_ACTION, overlaySwitchResId,
defaultServicePackageNameResId, initialPackageNamesResId,
- BackgroundThread.getHandler()) {
+ FgThread.getHandler()) {
@Override
protected void onBind() {
runOnBinder(mUpdateGeofenceHardware);
diff --git a/services/core/java/com/android/server/location/LocationProviderProxy.java b/services/core/java/com/android/server/location/LocationProviderProxy.java
index 6b5b1be..776beb5 100644
--- a/services/core/java/com/android/server/location/LocationProviderProxy.java
+++ b/services/core/java/com/android/server/location/LocationProviderProxy.java
@@ -31,8 +31,8 @@
import com.android.internal.location.ILocationProviderManager;
import com.android.internal.location.ProviderProperties;
import com.android.internal.location.ProviderRequest;
-import com.android.internal.os.BackgroundThread;
import com.android.internal.os.TransferPipe;
+import com.android.server.FgThread;
import com.android.server.LocationManagerService;
import com.android.server.ServiceWatcher;
@@ -105,7 +105,7 @@
mServiceWatcher = new ServiceWatcher(context, TAG, action, overlaySwitchResId,
defaultServicePackageNameResId, initialPackageNamesResId,
- BackgroundThread.getHandler()) {
+ FgThread.getHandler()) {
@Override
protected void onBind() {
diff --git a/services/core/java/com/android/server/pm/LauncherAppsService.java b/services/core/java/com/android/server/pm/LauncherAppsService.java
index c2ac27a..62c4815 100644
--- a/services/core/java/com/android/server/pm/LauncherAppsService.java
+++ b/services/core/java/com/android/server/pm/LauncherAppsService.java
@@ -34,9 +34,11 @@
import android.content.pm.ApplicationInfo;
import android.content.pm.ILauncherApps;
import android.content.pm.IOnAppsChangedListener;
+import android.content.pm.IPackageInstallerCallback;
import android.content.pm.LauncherApps;
import android.content.pm.LauncherApps.ShortcutQuery;
import android.content.pm.PackageInfo;
+import android.content.pm.PackageInstaller.SessionInfo;
import android.content.pm.PackageManager;
import android.content.pm.PackageManagerInternal;
import android.content.pm.ParceledListSlice;
@@ -56,6 +58,7 @@
import android.os.ParcelFileDescriptor;
import android.os.RemoteCallbackList;
import android.os.RemoteException;
+import android.os.ServiceManager;
import android.os.UserHandle;
import android.os.UserManager;
import android.os.UserManagerInternal;
@@ -153,6 +156,8 @@
private final Object mVouchedSignaturesLocked = new Object();
+ private PackageInstallerService mPackageInstallerService;
+
public LauncherAppsImpl(Context context) {
mContext = context;
mUm = (UserManager) mContext.getSystemService(Context.USER_SERVICE);
@@ -204,8 +209,7 @@
}
/*
- * @see android.content.pm.ILauncherApps#addOnAppsChangedListener(
- * android.content.pm.IOnAppsChangedListener)
+ * @see android.content.pm.ILauncherApps#addOnAppsChangedListener
*/
@Override
public void addOnAppsChangedListener(String callingPackage, IOnAppsChangedListener listener)
@@ -228,8 +232,7 @@
}
/*
- * @see android.content.pm.ILauncherApps#removeOnAppsChangedListener(
- * android.content.pm.IOnAppsChangedListener)
+ * @see android.content.pm.ILauncherApps#removeOnAppsChangedListener
*/
@Override
public void removeOnAppsChangedListener(IOnAppsChangedListener listener)
@@ -246,6 +249,44 @@
}
/**
+ * @see android.content.pm.ILauncherApps#registerPackageInstallerCallback
+ */
+ @Override
+ public void registerPackageInstallerCallback(String callingPackage,
+ IPackageInstallerCallback callback) {
+ verifyCallingPackage(callingPackage);
+ UserHandle callingIdUserHandle = new UserHandle(getCallingUserId());
+ getPackageInstallerService().registerCallback(callback, eventUserId ->
+ isEnabledProfileOf(callingIdUserHandle,
+ new UserHandle(eventUserId), "shouldReceiveEvent"));
+ }
+
+ @Override
+ public ParceledListSlice<SessionInfo> getAllSessions(String callingPackage) {
+ verifyCallingPackage(callingPackage);
+ List<SessionInfo> sessionInfos = new ArrayList<>();
+ int[] userIds = mUm.getEnabledProfileIds(getCallingUserId());
+ long token = Binder.clearCallingIdentity();
+ try {
+ for (int userId : userIds) {
+ sessionInfos.addAll(getPackageInstallerService().getAllSessions(userId)
+ .getList());
+ }
+ } finally {
+ Binder.restoreCallingIdentity(token);
+ }
+ return new ParceledListSlice<>(sessionInfos);
+ }
+
+ private PackageInstallerService getPackageInstallerService() {
+ if (mPackageInstallerService == null) {
+ mPackageInstallerService = ((PackageInstallerService) ((PackageManagerService)
+ ServiceManager.getService("package")).getPackageInstaller());
+ }
+ return mPackageInstallerService;
+ }
+
+ /**
* Register a receiver to watch for package broadcasts
*/
private void startWatchingPackageBroadcasts() {
@@ -430,6 +471,9 @@
if (!mVouchedSignaturesByUser.containsKey(user)) {
initVouchedSignatures(user);
}
+ if (isManagedProfileAdmin(user, appInfo.packageName)) {
+ return false;
+ }
if (mVouchProviders.contains(appInfo.packageName)) {
// If it's a vouching packages then we must show hidden app
return true;
@@ -453,6 +497,24 @@
return true;
}
+ private boolean isManagedProfileAdmin(UserHandle user, String packageName) {
+ final List<UserInfo> userInfoList = mUm.getProfiles(user.getIdentifier());
+ for (int i = 0; i < userInfoList.size(); i++) {
+ UserInfo userInfo = userInfoList.get(i);
+ if (!userInfo.isManagedProfile()) {
+ continue;
+ }
+ ComponentName componentName = mDpm.getProfileOwnerAsUser(userInfo.getUserHandle());
+ if (componentName == null) {
+ continue;
+ }
+ if (componentName.getPackageName().equals(packageName)) {
+ return true;
+ }
+ }
+ return false;
+ }
+
@VisibleForTesting
static String computePackageCertDigest(Signature signature) {
MessageDigest messageDigest;
@@ -848,6 +910,29 @@
}
@Override
+ public void startSessionDetailsActivityAsUser(IApplicationThread caller,
+ String callingPackage, SessionInfo sessionInfo, Rect sourceBounds,
+ Bundle opts, UserHandle userHandle) throws RemoteException {
+ int userId = userHandle.getIdentifier();
+ if (!canAccessProfile(userId, "Cannot start details activity")) {
+ return;
+ }
+
+ Intent i = new Intent(Intent.ACTION_VIEW)
+ .setData(new Uri.Builder()
+ .scheme("market")
+ .authority("details")
+ .appendQueryParameter("id", sessionInfo.appPackageName)
+ .build())
+ .putExtra(Intent.EXTRA_REFERRER, new Uri.Builder().scheme("android-app")
+ .authority(callingPackage).build());
+ i.setSourceBounds(sourceBounds);
+
+ mActivityTaskManagerInternal.startActivityAsUser(caller, callingPackage, i, opts,
+ userId);
+ }
+
+ @Override
public void startActivityAsUser(IApplicationThread caller, String callingPackage,
ComponentName component, Rect sourceBounds,
Bundle opts, UserHandle user) throws RemoteException {
diff --git a/services/core/java/com/android/server/pm/OWNERS b/services/core/java/com/android/server/pm/OWNERS
index 60d7925..33b8641 100644
--- a/services/core/java/com/android/server/pm/OWNERS
+++ b/services/core/java/com/android/server/pm/OWNERS
@@ -51,6 +51,8 @@
per-file UserManagerService.java = yamasani@google.com
per-file UserRestrictionsUtils.java = omakoto@google.com
per-file UserRestrictionsUtils.java = yamasani@google.com
+per-file UserRestrictionsUtils.java = rubinxu@google.com
+per-file UserRestrictionsUtils.java = sandness@google.com
# security
per-file KeySetHandle.java = cbrubaker@google.com
diff --git a/services/core/java/com/android/server/pm/PackageInstallerService.java b/services/core/java/com/android/server/pm/PackageInstallerService.java
index 146a2f3..a3e0d8d 100644
--- a/services/core/java/com/android/server/pm/PackageInstallerService.java
+++ b/services/core/java/com/android/server/pm/PackageInstallerService.java
@@ -59,7 +59,6 @@
import android.os.RemoteCallbackList;
import android.os.RemoteException;
import android.os.SELinux;
-import android.os.UserHandle;
import android.os.UserManager;
import android.os.storage.StorageManager;
import android.system.ErrnoException;
@@ -107,6 +106,7 @@
import java.util.List;
import java.util.Objects;
import java.util.Random;
+import java.util.function.IntPredicate;
/** The service responsible for installing packages. */
public class PackageInstallerService extends IPackageInstaller.Stub implements
@@ -804,7 +804,14 @@
public void registerCallback(IPackageInstallerCallback callback, int userId) {
mPermissionManager.enforceCrossUserPermission(
Binder.getCallingUid(), userId, true, false, "registerCallback");
- mCallbacks.register(callback, userId);
+ registerCallback(callback, eventUserId -> userId == eventUserId);
+ }
+
+ /**
+ * Assume permissions already checked and caller's identity cleared
+ */
+ public void registerCallback(IPackageInstallerCallback callback, IntPredicate userCheck) {
+ mCallbacks.register(callback, userCheck);
}
@Override
@@ -1026,8 +1033,8 @@
super(looper);
}
- public void register(IPackageInstallerCallback callback, int userId) {
- mCallbacks.register(callback, new UserHandle(userId));
+ public void register(IPackageInstallerCallback callback, IntPredicate userCheck) {
+ mCallbacks.register(callback, userCheck);
}
public void unregister(IPackageInstallerCallback callback) {
@@ -1040,9 +1047,8 @@
final int n = mCallbacks.beginBroadcast();
for (int i = 0; i < n; i++) {
final IPackageInstallerCallback callback = mCallbacks.getBroadcastItem(i);
- final UserHandle user = (UserHandle) mCallbacks.getBroadcastCookie(i);
- // TODO: dispatch notifications for slave profiles
- if (userId == user.getIdentifier()) {
+ final IntPredicate userCheck = (IntPredicate) mCallbacks.getBroadcastCookie(i);
+ if (userCheck.test(userId)) {
try {
invokeCallback(callback, msg);
} catch (RemoteException ignored) {
diff --git a/services/core/java/com/android/server/pm/PackageInstallerSession.java b/services/core/java/com/android/server/pm/PackageInstallerSession.java
index 494ec3f..de0849f 100644
--- a/services/core/java/com/android/server/pm/PackageInstallerSession.java
+++ b/services/core/java/com/android/server/pm/PackageInstallerSession.java
@@ -473,6 +473,7 @@
final SessionInfo info = new SessionInfo();
synchronized (mLock) {
info.sessionId = sessionId;
+ info.userId = userId;
info.installerPackageName = mInstallerPackageName;
info.resolvedBaseCodePath = (mResolvedBaseFile != null) ?
mResolvedBaseFile.getAbsolutePath() : null;
diff --git a/services/core/java/com/android/server/pm/PackageManagerService.java b/services/core/java/com/android/server/pm/PackageManagerService.java
index d2547d9..6f9a290 100644
--- a/services/core/java/com/android/server/pm/PackageManagerService.java
+++ b/services/core/java/com/android/server/pm/PackageManagerService.java
@@ -13883,6 +13883,9 @@
final String packageName = res.pkg.applicationInfo.packageName;
final String seInfo = res.pkg.applicationInfo.seInfo;
+ final int[] allUsers = sUserManager.getUserIds();
+ final int[] installedUsers;
+
final PackageSetting ps;
int appId = -1;
long ceDataInode = -1;
@@ -13892,11 +13895,16 @@
appId = ps.appId;
ceDataInode = ps.getCeDataInode(userId);
}
+
+ // NOTE: We ignore the user specified in the InstallParam because we know this is
+ // an update, and hence need to restore data for all installed users.
+ installedUsers = ps.queryInstalledUsers(allUsers, true);
}
if (ps != null) {
try {
- rm.restoreUserData(packageName, userId, appId, ceDataInode, seInfo, token);
+ rm.restoreUserData(packageName, installedUsers, appId, ceDataInode,
+ seInfo, token);
} catch (RemoteException re) {
// Cannot happen, the RollbackManager is hosted in the same process.
}
@@ -14593,6 +14601,17 @@
TRACE_TAG_PACKAGE_MANAGER, "enable_rollback", enableRollbackToken);
mPendingEnableRollback.append(enableRollbackToken, this);
+ final int[] installedUsers;
+ synchronized (mPackages) {
+ PackageSetting ps = mSettings.getPackageLPr(pkgLite.packageName);
+ if (ps != null) {
+ installedUsers = ps.queryInstalledUsers(sUserManager.getUserIds(),
+ true);
+ } else {
+ installedUsers = new int[0];
+ }
+ }
+
// TODO(ruhler) b/112431924: What user? Test for multi-user.
Intent enableRollbackIntent = new Intent(Intent.ACTION_PACKAGE_ENABLE_ROLLBACK);
enableRollbackIntent.putExtra(
@@ -14603,7 +14622,7 @@
installFlags);
enableRollbackIntent.putExtra(
PackageManagerInternal.EXTRA_ENABLE_ROLLBACK_INSTALLED_USERS,
- resolveUserIds(args.user.getIdentifier()));
+ installedUsers);
enableRollbackIntent.setDataAndType(Uri.fromFile(new File(origin.resolvedPath)),
PACKAGE_MIME_TYPE);
enableRollbackIntent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
diff --git a/services/core/java/com/android/server/pm/UserManagerService.java b/services/core/java/com/android/server/pm/UserManagerService.java
index 4f20590..d0f192d 100644
--- a/services/core/java/com/android/server/pm/UserManagerService.java
+++ b/services/core/java/com/android/server/pm/UserManagerService.java
@@ -1109,14 +1109,7 @@
@Override
public int getManagedProfileBadge(@UserIdInt int userId) {
- int callingUserId = UserHandle.getCallingUserId();
- if (callingUserId != userId && !hasManageUsersPermission()) {
- if (!isSameProfileGroupNoChecks(callingUserId, userId)) {
- throw new SecurityException(
- "You need MANAGE_USERS permission to: check if specified user a " +
- "managed profile outside your profile group");
- }
- }
+ checkManageOrInteractPermIfCallerInOtherProfileGroup(userId, "getManagedProfileBadge");
synchronized (mUsersLock) {
UserInfo userInfo = getUserInfoLU(userId);
return userInfo != null ? userInfo.profileBadge : 0;
@@ -1125,14 +1118,7 @@
@Override
public boolean isManagedProfile(int userId) {
- int callingUserId = UserHandle.getCallingUserId();
- if (callingUserId != userId && !hasManageUsersPermission()) {
- if (!isSameProfileGroupNoChecks(callingUserId, userId)) {
- throw new SecurityException(
- "You need MANAGE_USERS permission to: check if specified user a " +
- "managed profile outside your profile group");
- }
- }
+ checkManageOrInteractPermIfCallerInOtherProfileGroup(userId, "isManagedProfile");
synchronized (mUsersLock) {
UserInfo userInfo = getUserInfoLU(userId);
return userInfo != null && userInfo.isManagedProfile();
diff --git a/services/core/java/com/android/server/power/AttentionDetector.java b/services/core/java/com/android/server/power/AttentionDetector.java
index a2c8dac..4186154 100644
--- a/services/core/java/com/android/server/power/AttentionDetector.java
+++ b/services/core/java/com/android/server/power/AttentionDetector.java
@@ -24,11 +24,13 @@
import android.os.SystemClock;
import android.service.attention.AttentionService;
import android.util.Slog;
+import android.util.StatsLog;
import com.android.internal.annotations.VisibleForTesting;
import com.android.server.LocalServices;
import java.io.PrintWriter;
+import java.util.concurrent.atomic.AtomicLong;
/**
* Class responsible for checking if the user is currently paying attention to the phone and
@@ -79,6 +81,11 @@
*/
private int mWakefulness;
+ /**
+ * Describes how many times in a row was the timeout extended.
+ */
+ private AtomicLong mConsecutiveTimeoutExtendedCount = new AtomicLong(0);
+
@VisibleForTesting
final AttentionCallbackInternal mCallback = new AttentionCallbackInternal() {
@@ -95,6 +102,8 @@
}
if (result == AttentionService.ATTENTION_SUCCESS_PRESENT) {
mOnUserAttention.run();
+ } else {
+ resetConsecutiveExtensionCount();
}
}
}
@@ -176,6 +185,7 @@
public int onUserActivity(long eventTime, int event) {
switch (event) {
case PowerManager.USER_ACTIVITY_EVENT_ATTENTION:
+ mConsecutiveTimeoutExtendedCount.incrementAndGet();
return 0;
case PowerManager.USER_ACTIVITY_EVENT_OTHER:
case PowerManager.USER_ACTIVITY_EVENT_BUTTON:
@@ -183,6 +193,7 @@
case PowerManager.USER_ACTIVITY_EVENT_ACCESSIBILITY:
cancelCurrentRequestIfAny();
mLastUserActivityTime = eventTime;
+ resetConsecutiveExtensionCount();
return 1;
default:
if (DEBUG) {
@@ -196,6 +207,7 @@
mWakefulness = wakefulness;
if (wakefulness != PowerManagerInternal.WAKEFULNESS_AWAKE) {
cancelCurrentRequestIfAny();
+ resetConsecutiveExtensionCount();
}
}
@@ -206,6 +218,13 @@
}
}
+ private void resetConsecutiveExtensionCount() {
+ final long previousCount = mConsecutiveTimeoutExtendedCount.getAndSet(0);
+ if (previousCount > 0) {
+ StatsLog.write(StatsLog.SCREEN_TIMEOUT_EXTENSION_REPORTED, previousCount);
+ }
+ }
+
@VisibleForTesting
int getRequestCode() {
return (int) (mLastUserActivityTime % Integer.MAX_VALUE);
diff --git a/services/core/java/com/android/server/power/PowerManagerService.java b/services/core/java/com/android/server/power/PowerManagerService.java
index 3be6480..3ccd234 100644
--- a/services/core/java/com/android/server/power/PowerManagerService.java
+++ b/services/core/java/com/android/server/power/PowerManagerService.java
@@ -22,6 +22,7 @@
import static android.os.PowerManagerInternal.WAKEFULNESS_DREAMING;
import android.annotation.IntDef;
+import android.annotation.NonNull;
import android.annotation.UserIdInt;
import android.app.ActivityManager;
import android.app.SynchronousUserSwitchObserver;
@@ -42,6 +43,7 @@
import android.net.Uri;
import android.os.BatteryManager;
import android.os.BatteryManagerInternal;
+import android.os.BatterySaverPolicyConfig;
import android.os.Binder;
import android.os.Handler;
import android.os.IBinder;
@@ -2875,8 +2877,7 @@
@VisibleForTesting
void updatePowerRequestFromBatterySaverPolicy(DisplayPowerRequest displayPowerRequest) {
PowerSaveState state = mBatterySaverPolicy.
- getBatterySaverPolicy(ServiceType.SCREEN_BRIGHTNESS,
- mBatterySaverController.isEnabled());
+ getBatterySaverPolicy(ServiceType.SCREEN_BRIGHTNESS);
displayPowerRequest.lowPowerMode = state.batterySaverEnabled;
displayPowerRequest.screenLowPowerBrightnessFactor = state.brightnessFactor;
}
@@ -4451,8 +4452,7 @@
public PowerSaveState getPowerSaveState(@ServiceType int serviceType) {
final long ident = Binder.clearCallingIdentity();
try {
- return mBatterySaverPolicy.getBatterySaverPolicy(
- serviceType, mBatterySaverController.isEnabled());
+ return mBatterySaverPolicy.getBatterySaverPolicy(serviceType);
} finally {
Binder.restoreCallingIdentity(ident);
}
@@ -4497,6 +4497,36 @@
}
@Override // Binder call
+ public boolean setAdaptivePowerSavePolicy(@NonNull BatterySaverPolicyConfig config) {
+ if (mContext.checkCallingOrSelfPermission(android.Manifest.permission.POWER_SAVER)
+ != PackageManager.PERMISSION_GRANTED) {
+ mContext.enforceCallingOrSelfPermission(
+ android.Manifest.permission.DEVICE_POWER, "setAdaptivePowerSavePolicy");
+ }
+ final long ident = Binder.clearCallingIdentity();
+ try {
+ return mBatterySaverStateMachine.setAdaptiveBatterySaverPolicy(config);
+ } finally {
+ Binder.restoreCallingIdentity(ident);
+ }
+ }
+
+ @Override // Binder call
+ public boolean setAdaptivePowerSaveEnabled(boolean enabled) {
+ if (mContext.checkCallingOrSelfPermission(android.Manifest.permission.POWER_SAVER)
+ != PackageManager.PERMISSION_GRANTED) {
+ mContext.enforceCallingOrSelfPermission(
+ android.Manifest.permission.DEVICE_POWER, "setAdaptivePowerSaveEnabled");
+ }
+ final long ident = Binder.clearCallingIdentity();
+ try {
+ return mBatterySaverStateMachine.setAdaptiveBatterySaverEnabled(enabled);
+ } finally {
+ Binder.restoreCallingIdentity(ident);
+ }
+ }
+
+ @Override // Binder call
public int getPowerSaveMode() {
mContext.enforceCallingOrSelfPermission(android.Manifest.permission.POWER_SAVER, null);
final long ident = Binder.clearCallingIdentity();
@@ -4846,8 +4876,7 @@
@Override
public PowerSaveState getLowPowerState(@ServiceType int serviceType) {
- return mBatterySaverPolicy.getBatterySaverPolicy(serviceType,
- mBatterySaverController.isEnabled());
+ return mBatterySaverPolicy.getBatterySaverPolicy(serviceType);
}
@Override
diff --git a/services/core/java/com/android/server/power/PowerManagerShellCommand.java b/services/core/java/com/android/server/power/PowerManagerShellCommand.java
index 46115d8..18b8f0e 100644
--- a/services/core/java/com/android/server/power/PowerManagerShellCommand.java
+++ b/services/core/java/com/android/server/power/PowerManagerShellCommand.java
@@ -41,6 +41,8 @@
final PrintWriter pw = getOutPrintWriter();
try {
switch(cmd) {
+ case "set-adaptive-power-saver-enabled":
+ return runSetAdaptiveEnabled();
case "set-mode":
return runSetMode();
default:
@@ -52,6 +54,11 @@
return -1;
}
+ private int runSetAdaptiveEnabled() throws RemoteException {
+ mInterface.setAdaptivePowerSaveEnabled(Boolean.parseBoolean(getNextArgRequired()));
+ return 0;
+ }
+
private int runSetMode() throws RemoteException {
final PrintWriter pw = getOutPrintWriter();
int mode = -1;
@@ -72,6 +79,8 @@
pw.println(" help");
pw.println(" Print this help text.");
pw.println("");
+ pw.println(" set-adaptive-power-saver-enabled [true|false]");
+ pw.println(" enables or disables adaptive power saver.");
pw.println(" set-mode MODE");
pw.println(" sets the power mode of the device to MODE.");
pw.println(" 1 turns low power mode on and 0 turns low power mode off.");
diff --git a/services/core/java/com/android/server/power/batterysaver/BatterySaverController.java b/services/core/java/com/android/server/power/batterysaver/BatterySaverController.java
index ab2807a..94bb3ea 100644
--- a/services/core/java/com/android/server/power/batterysaver/BatterySaverController.java
+++ b/services/core/java/com/android/server/power/batterysaver/BatterySaverController.java
@@ -23,6 +23,7 @@
import android.content.IntentFilter;
import android.hardware.power.V1_0.PowerHint;
import android.os.BatteryManager;
+import android.os.BatterySaverPolicyConfig;
import android.os.Handler;
import android.os.Looper;
import android.os.Message;
@@ -42,6 +43,7 @@
import com.android.server.LocalServices;
import com.android.server.power.PowerManagerService;
import com.android.server.power.batterysaver.BatterySaverPolicy.BatterySaverPolicyListener;
+import com.android.server.power.batterysaver.BatterySaverPolicy.Policy;
import com.android.server.power.batterysaver.BatterySavingStats.BatterySaverState;
import com.android.server.power.batterysaver.BatterySavingStats.DozeState;
import com.android.server.power.batterysaver.BatterySavingStats.InteractiveState;
@@ -74,16 +76,25 @@
private final ArrayList<LowPowerModeListener> mListeners = new ArrayList<>();
@GuardedBy("mLock")
- private boolean mEnabled;
+ private boolean mFullEnabled;
+
+ @GuardedBy("mLock")
+ private boolean mAdaptiveEnabled;
@GuardedBy("mLock")
private boolean mIsPluggedIn;
/**
- * Previously enabled or not; only for the event logging. Only use it from
+ * Whether full was previously enabled or not; only for the event logging. Only use it from
* {@link #handleBatterySaverStateChanged}.
*/
- private boolean mPreviouslyEnabled;
+ private boolean mFullPreviouslyEnabled;
+
+ /**
+ * Whether adaptive was previously enabled or not; only for the event logging. Only use it from
+ * {@link #handleBatterySaverStateChanged}.
+ */
+ private boolean mAdaptivePreviouslyEnabled;
@GuardedBy("mLock")
private boolean mIsInteractive;
@@ -104,7 +115,9 @@
public static final int REASON_SETTING_CHANGED = 8;
public static final int REASON_DYNAMIC_POWER_SAVINGS_AUTOMATIC_ON = 9;
public static final int REASON_DYNAMIC_POWER_SAVINGS_AUTOMATIC_OFF = 10;
- public static final int REASON_STICKY_RESTORE_OFF = 13;
+ public static final int REASON_STICKY_RESTORE_OFF = 11;
+ public static final int REASON_ADAPTIVE_DYNAMIC_POWER_SAVINGS_CHANGED = 12;
+ public static final int REASON_TIMEOUT = 13;
/**
* Plugin interface. All methods are guaranteed to be called on the same (handler) thread.
@@ -124,7 +137,7 @@
switch (intent.getAction()) {
case Intent.ACTION_SCREEN_ON:
case Intent.ACTION_SCREEN_OFF:
- if (!isEnabled()) {
+ if (!isPolicyEnabled()) {
updateBatterySavingStats();
return; // No need to send it if not enabled.
}
@@ -199,7 +212,7 @@
@Override
public void onBatterySaverPolicyChanged(BatterySaverPolicy policy) {
- if (!isEnabled()) {
+ if (!isPolicyEnabled()) {
return; // No need to send it if not enabled.
}
mHandler.postStateChanged(/*sendBroadcast=*/ true, REASON_POLICY_CHANGED);
@@ -248,22 +261,98 @@
@VisibleForTesting
public void enableBatterySaver(boolean enable, int reason) {
synchronized (mLock) {
- if (mEnabled == enable) {
+ if (mFullEnabled == enable) {
return;
}
- mEnabled = enable;
+ mFullEnabled = enable;
- mHandler.postStateChanged(/*sendBroadcast=*/ true, reason);
+ if (updatePolicyLevelLocked()) {
+ mHandler.postStateChanged(/*sendBroadcast=*/ true, reason);
+ }
}
}
- /** @return whether battery saver is enabled or not. */
+ private boolean updatePolicyLevelLocked() {
+ if (mFullEnabled) {
+ return mBatterySaverPolicy.setPolicyLevel(BatterySaverPolicy.POLICY_LEVEL_FULL);
+ } else if (mAdaptiveEnabled) {
+ return mBatterySaverPolicy.setPolicyLevel(BatterySaverPolicy.POLICY_LEVEL_ADAPTIVE);
+ } else {
+ return mBatterySaverPolicy.setPolicyLevel(BatterySaverPolicy.POLICY_LEVEL_OFF);
+ }
+ }
+
+ /**
+ * @return whether battery saver is enabled or not. This takes into
+ * account whether a policy says to advertise isEnabled so this can be propagated externally.
+ */
public boolean isEnabled() {
synchronized (mLock) {
- return mEnabled;
+ return mFullEnabled
+ || (mAdaptiveEnabled && mBatterySaverPolicy.shouldAdvertiseIsEnabled());
}
}
+ /**
+ * @return whether battery saver policy is enabled or not. This does not take into account
+ * whether a policy says to advertise isEnabled, so this shouldn't be propagated externally.
+ */
+ private boolean isPolicyEnabled() {
+ synchronized (mLock) {
+ return mFullEnabled || mAdaptiveEnabled;
+ }
+ }
+
+ boolean isFullEnabled() {
+ synchronized (mLock) {
+ return mFullEnabled;
+ }
+ }
+
+ boolean isAdaptiveEnabled() {
+ synchronized (mLock) {
+ return mAdaptiveEnabled;
+ }
+ }
+
+ boolean setAdaptivePolicyLocked(String settings, String deviceSpecificSettings, int reason) {
+ return setAdaptivePolicyLocked(
+ BatterySaverPolicy.Policy.fromSettings(settings, deviceSpecificSettings),
+ reason);
+ }
+
+ boolean setAdaptivePolicyLocked(BatterySaverPolicyConfig config, int reason) {
+ return setAdaptivePolicyLocked(BatterySaverPolicy.Policy.fromConfig(config), reason);
+ }
+
+ boolean setAdaptivePolicyLocked(Policy policy, int reason) {
+ if (mBatterySaverPolicy.setAdaptivePolicyLocked(policy)) {
+ mHandler.postStateChanged(/*sendBroadcast=*/ true, reason);
+ return true;
+ }
+ return false;
+ }
+
+ boolean resetAdaptivePolicyLocked(int reason) {
+ if (mBatterySaverPolicy.resetAdaptivePolicyLocked()) {
+ mHandler.postStateChanged(/*sendBroadcast=*/ true, reason);
+ return true;
+ }
+ return false;
+ }
+
+ boolean setAdaptivePolicyEnabledLocked(boolean enabled, int reason) {
+ if (mAdaptiveEnabled == enabled) {
+ return false;
+ }
+ mAdaptiveEnabled = enabled;
+ if (updatePolicyLevelLocked()) {
+ mHandler.postStateChanged(/*sendBroadcast=*/ true, reason);
+ return true;
+ }
+ return false;
+ }
+
/** @return whether device is in interactive state. */
public boolean isInteractive() {
synchronized (mLock) {
@@ -280,7 +369,7 @@
* @return true if launch boost should currently be disabled.
*/
public boolean isLaunchBoostDisabled() {
- return isEnabled() && mBatterySaverPolicy.isLaunchBoostDisabled();
+ return isPolicyEnabled() && mBatterySaverPolicy.isLaunchBoostDisabled();
}
/**
@@ -293,6 +382,9 @@
* - When battery saver becomes deactivated.
* - When battery saver is on and the interactive state changes.
* - When battery saver is on and the battery saver policy changes.
+ * - When adaptive battery saver becomes activated.
+ * - When adaptive battery saver becomes deactivated.
+ * - When adaptive battery saver policy changes.
*/
void handleBatterySaverStateChanged(boolean sendBroadcast, int reason) {
final LowPowerModeListener[] listeners;
@@ -302,17 +394,22 @@
final ArrayMap<String, String> fileValues;
synchronized (mLock) {
+ enabled = mFullEnabled || mAdaptiveEnabled;
+
EventLogTags.writeBatterySaverMode(
- mPreviouslyEnabled ? 1 : 0, // Previously off or on.
- mEnabled ? 1 : 0, // Now off or on.
+ mFullPreviouslyEnabled ? 1 : 0, // Previously off or on.
+ mAdaptivePreviouslyEnabled ? 1 : 0, // Previously off or on.
+ mFullEnabled ? 1 : 0, // Now off or on.
+ mAdaptiveEnabled ? 1 : 0, // Now off or on.
isInteractive ? 1 : 0, // Device interactive state.
- mEnabled ? mBatterySaverPolicy.toEventLogString() : "",
+ enabled ? mBatterySaverPolicy.toEventLogString() : "",
reason);
- mPreviouslyEnabled = mEnabled;
+
+ mFullPreviouslyEnabled = mFullEnabled;
+ mAdaptivePreviouslyEnabled = mAdaptiveEnabled;
listeners = mListeners.toArray(new LowPowerModeListener[0]);
- enabled = mEnabled;
mIsInteractive = isInteractive;
if (enabled) {
@@ -324,7 +421,7 @@
final PowerManagerInternal pmi = LocalServices.getService(PowerManagerInternal.class);
if (pmi != null) {
- pmi.powerHint(PowerHint.LOW_POWER, enabled ? 1 : 0);
+ pmi.powerHint(PowerHint.LOW_POWER, isEnabled() ? 1 : 0);
}
updateBatterySavingStats();
@@ -342,13 +439,13 @@
if (sendBroadcast) {
if (DEBUG) {
- Slog.i(TAG, "Sending broadcasts for mode: " + enabled);
+ Slog.i(TAG, "Sending broadcasts for mode: " + isEnabled());
}
// Send the broadcasts and notify the listeners. We only do this when the battery saver
// mode changes, but not when only the screen state changes.
Intent intent = new Intent(PowerManager.ACTION_POWER_SAVE_MODE_CHANGING)
- .putExtra(PowerManager.EXTRA_POWER_SAVE_MODE, enabled)
+ .putExtra(PowerManager.EXTRA_POWER_SAVE_MODE, isEnabled())
.addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY);
mContext.sendBroadcastAsUser(intent, UserHandle.ALL);
@@ -364,8 +461,7 @@
for (LowPowerModeListener listener : listeners) {
final PowerSaveState result =
- mBatterySaverPolicy.getBatterySaverPolicy(
- listener.getServiceType(), enabled);
+ mBatterySaverPolicy.getBatterySaverPolicy(listener.getServiceType());
listener.onLowPowerModeChanged(result);
}
}
@@ -389,7 +485,8 @@
return;
}
mBatterySavingStats.transitionState(
- mEnabled ? BatterySaverState.ON : BatterySaverState.OFF,
+ mFullEnabled ? BatterySaverState.ON :
+ (mAdaptiveEnabled ? BatterySaverState.ADAPTIVE : BatterySaverState.OFF),
isInteractive ? InteractiveState.INTERACTIVE : InteractiveState.NON_INTERACTIVE,
dozeMode);
}
diff --git a/services/core/java/com/android/server/power/batterysaver/BatterySaverLocationPlugin.java b/services/core/java/com/android/server/power/batterysaver/BatterySaverLocationPlugin.java
index bd8baeb..a77d133 100644
--- a/services/core/java/com/android/server/power/batterysaver/BatterySaverLocationPlugin.java
+++ b/services/core/java/com/android/server/power/batterysaver/BatterySaverLocationPlugin.java
@@ -53,8 +53,8 @@
private void updateLocationState(BatterySaverController caller) {
final boolean kill =
(caller.getBatterySaverPolicy().getGpsMode()
- == PowerManager.LOCATION_MODE_ALL_DISABLED_WHEN_SCREEN_OFF) &&
- caller.isEnabled() && !caller.isInteractive();
+ == PowerManager.LOCATION_MODE_ALL_DISABLED_WHEN_SCREEN_OFF)
+ && !caller.isInteractive();
if (DEBUG) {
Slog.d(TAG, "Battery saver " + (kill ? "stopping" : "restoring") + " location.");
diff --git a/services/core/java/com/android/server/power/batterysaver/BatterySaverPolicy.java b/services/core/java/com/android/server/power/batterysaver/BatterySaverPolicy.java
index 48a041e..8550bc3 100644
--- a/services/core/java/com/android/server/power/batterysaver/BatterySaverPolicy.java
+++ b/services/core/java/com/android/server/power/batterysaver/BatterySaverPolicy.java
@@ -15,16 +15,17 @@
*/
package com.android.server.power.batterysaver;
+import android.annotation.IntDef;
import android.content.ContentResolver;
import android.content.Context;
import android.database.ContentObserver;
import android.net.Uri;
+import android.os.BatterySaverPolicyConfig;
import android.os.Handler;
import android.os.PowerManager;
import android.os.PowerManager.ServiceType;
import android.os.PowerSaveState;
import android.provider.Settings;
-import android.provider.Settings.Global;
import android.text.TextUtils;
import android.util.ArrayMap;
import android.util.KeyValueListParser;
@@ -39,8 +40,12 @@
import com.android.server.power.PowerManagerService;
import java.io.PrintWriter;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
import java.util.ArrayList;
import java.util.List;
+import java.util.Map;
+import java.util.Objects;
/**
* Class to decide whether to turn on battery saver mode for specific services.
@@ -48,12 +53,12 @@
* IMPORTANT: This class shares the power manager lock, which is very low in the lock hierarchy.
* Do not call out with the lock held, such as AccessibilityManager. (Settings provider is okay.)
*
- * Test: atest com.android.server.power.batterysaver.BatterySaverPolicyTest.java
+ * Test: atest com.android.server.power.batterysaver.BatterySaverPolicyTest
*/
public class BatterySaverPolicy extends ContentObserver {
private static final String TAG = "BatterySaverPolicy";
- public static final boolean DEBUG = false; // DO NOT SUBMIT WITH TRUE.
+ static final boolean DEBUG = false; // DO NOT SUBMIT WITH TRUE.
private static final String KEY_GPS_MODE = "gps_mode";
private static final String KEY_VIBRATION_DISABLED = "vibration_disabled";
@@ -81,6 +86,14 @@
* If set to true, Data Saver WILL NOT be turned on when Battery Saver is turned on.
*/
private static final String KEY_ACTIVATE_DATASAVER_DISABLED = "datasaver_disabled";
+
+ /**
+ * {@code true} if the Policy should advertise to the rest of the system that battery saver
+ * is enabled. This advertising could cause other system components to change their
+ * behavior. This will not affect other policy flags and what they change.
+ */
+ private static final String KEY_ADVERTISE_IS_ENABLED = "advertise_is_enabled";
+
private static final String KEY_LAUNCH_BOOST_DISABLED = "launch_boost_disabled";
private static final String KEY_ADJUST_BRIGHTNESS_FACTOR = "adjust_brightness_factor";
private static final String KEY_FULLBACKUP_DEFERRED = "fullbackup_deferred";
@@ -96,8 +109,35 @@
private static final String KEY_CPU_FREQ_INTERACTIVE = "cpufreq-i";
private static final String KEY_CPU_FREQ_NONINTERACTIVE = "cpufreq-n";
- private static final Policy sDefaultPolicy = new Policy(
+ @VisibleForTesting
+ static final Policy OFF_POLICY = new Policy(
+ 1f, /* adjustBrightnessFactor */
+ false, /* advertiseIsEnabled */
+ false, /* deferFullBackup */
+ false, /* deferKeyValueBackup */
+ false, /* disableAnimation */
+ false, /* disableAod */
+ false, /* disableLaunchBoost */
+ false, /* disableOptionalSensors */
+ false, /* disableSoundTrigger */
+ false, /* disableVibration */
+ false, /* enableAdjustBrightness */
+ false, /* enableDataSaver */
+ false, /* enableFireWall */
+ false, /* enableQuickDoze */
+ new ArrayMap<>(), /* filesForInteractive */
+ new ArrayMap<>(), /* filesForNoninteractive */
+ false, /* forceAllAppsStandby */
+ false, /* forceBackgroundCheck */
+ PowerManager.LOCATION_MODE_NO_CHANGE, /* gpsMode */
+ false /* sendTronLog */
+ );
+
+ private static final Policy DEFAULT_ADAPTIVE_POLICY = OFF_POLICY;
+
+ private static final Policy DEFAULT_FULL_POLICY = new Policy(
0.5f, /* adjustBrightnessFactor */
+ true, /* advertiseIsEnabled */
true, /* deferFullBackup */
true, /* deferKeyValueBackup */
false, /* disableAnimation */
@@ -130,6 +170,12 @@
@GuardedBy("mLock")
private String mDeviceSpecificSettingsSource; // For dump() only.
+ @GuardedBy("mLock")
+ private String mAdaptiveSettings;
+
+ @GuardedBy("mLock")
+ private String mAdaptiveDeviceSpecificSettings;
+
/**
* A short string describing which battery saver is now enabled, which we dump in the eventlog.
*/
@@ -149,8 +195,32 @@
@GuardedBy("mLock")
private boolean mAccessibilityEnabled;
+ /** The current default adaptive policy. */
@GuardedBy("mLock")
- private Policy mCurrPolicy = sDefaultPolicy;
+ private Policy mDefaultAdaptivePolicy = DEFAULT_ADAPTIVE_POLICY;
+
+ /** The policy that will be used for adaptive battery saver. */
+ @GuardedBy("mLock")
+ private Policy mAdaptivePolicy = DEFAULT_ADAPTIVE_POLICY;
+
+ /** The policy to be used for full battery saver. */
+ @GuardedBy("mLock")
+ private Policy mFullPolicy = DEFAULT_FULL_POLICY;
+
+ @IntDef(prefix = {"POLICY_LEVEL_"}, value = {
+ POLICY_LEVEL_OFF,
+ POLICY_LEVEL_ADAPTIVE,
+ POLICY_LEVEL_FULL,
+ })
+ @Retention(RetentionPolicy.SOURCE)
+ @interface PolicyLevel {}
+
+ static final int POLICY_LEVEL_OFF = 0;
+ static final int POLICY_LEVEL_ADAPTIVE = 1;
+ static final int POLICY_LEVEL_FULL = 2;
+
+ @GuardedBy("mLock")
+ private int mPolicyLevel = POLICY_LEVEL_OFF;
private final Context mContext;
private final ContentResolver mContentResolver;
@@ -181,7 +251,11 @@
mContentResolver.registerContentObserver(Settings.Global.getUriFor(
Settings.Global.BATTERY_SAVER_CONSTANTS), false, this);
mContentResolver.registerContentObserver(Settings.Global.getUriFor(
- Global.BATTERY_SAVER_DEVICE_SPECIFIC_CONSTANTS), false, this);
+ Settings.Global.BATTERY_SAVER_DEVICE_SPECIFIC_CONSTANTS), false, this);
+ mContentResolver.registerContentObserver(Settings.Global.getUriFor(
+ Settings.Global.BATTERY_SAVER_ADAPTIVE_CONSTANTS), false, this);
+ mContentResolver.registerContentObserver(Settings.Global.getUriFor(
+ Settings.Global.BATTERY_SAVER_ADAPTIVE_DEVICE_SPECIFIC_CONSTANTS), false, this);
final AccessibilityManager acm = mContext.getSystemService(AccessibilityManager.class);
@@ -241,8 +315,16 @@
mDeviceSpecificSettingsSource = "(overlay)";
}
- // Update.
- updateConstantsLocked(setting, deviceSpecificSetting);
+ final String adaptiveSetting =
+ getGlobalSetting(Settings.Global.BATTERY_SAVER_ADAPTIVE_CONSTANTS);
+ final String adaptiveDeviceSpecificSetting = getGlobalSetting(
+ Settings.Global.BATTERY_SAVER_ADAPTIVE_DEVICE_SPECIFIC_CONSTANTS);
+
+ if (!updateConstantsLocked(setting, deviceSpecificSetting,
+ adaptiveSetting, adaptiveDeviceSpecificSetting)) {
+ // Nothing of note changed.
+ return;
+ }
listeners = mListeners.toArray(new BatterySaverPolicyListener[0]);
}
@@ -258,123 +340,94 @@
@GuardedBy("mLock")
@VisibleForTesting
void updateConstantsLocked(final String setting, final String deviceSpecificSetting) {
+ updateConstantsLocked(setting, deviceSpecificSetting, "", "");
+ }
+
+ /** @return true if the currently active policy changed. */
+ private boolean updateConstantsLocked(String setting, String deviceSpecificSetting,
+ String adaptiveSetting, String adaptiveDeviceSpecificSetting) {
+ setting = TextUtils.emptyIfNull(setting);
+ deviceSpecificSetting = TextUtils.emptyIfNull(deviceSpecificSetting);
+ adaptiveSetting = TextUtils.emptyIfNull(adaptiveSetting);
+ adaptiveDeviceSpecificSetting = TextUtils.emptyIfNull(adaptiveDeviceSpecificSetting);
+
+ if (setting.equals(mSettings)
+ && deviceSpecificSetting.equals(mDeviceSpecificSettings)
+ && adaptiveSetting.equals(mAdaptiveSettings)
+ && adaptiveDeviceSpecificSetting.equals(mAdaptiveDeviceSpecificSettings)) {
+ return false;
+ }
+
mSettings = setting;
mDeviceSpecificSettings = deviceSpecificSetting;
+ mAdaptiveSettings = adaptiveSetting;
+ mAdaptiveDeviceSpecificSettings = adaptiveDeviceSpecificSetting;
if (DEBUG) {
Slog.i(TAG, "mSettings=" + mSettings);
Slog.i(TAG, "mDeviceSpecificSettings=" + mDeviceSpecificSettings);
+ Slog.i(TAG, "mAdaptiveSettings=" + mAdaptiveSettings);
+ Slog.i(TAG, "mAdaptiveDeviceSpecificSettings=" + mAdaptiveDeviceSpecificSettings);
}
- final KeyValueListParser parser = new KeyValueListParser(',');
-
- // Device-specific parameters.
- try {
- parser.setString(deviceSpecificSetting);
- } catch (IllegalArgumentException e) {
- Slog.wtf(TAG, "Bad device specific battery saver constants: "
- + deviceSpecificSetting);
+ boolean changed = false;
+ Policy newFullPolicy = Policy.fromSettings(setting, deviceSpecificSetting,
+ DEFAULT_FULL_POLICY);
+ if (mPolicyLevel == POLICY_LEVEL_FULL && !mFullPolicy.equals(newFullPolicy)) {
+ changed = true;
}
+ mFullPolicy = newFullPolicy;
- final String cpuFreqInteractive = parser.getString(KEY_CPU_FREQ_INTERACTIVE, "");
- final String cpuFreqNoninteractive = parser.getString(KEY_CPU_FREQ_NONINTERACTIVE, "");
-
- // Non-device-specific parameters.
- try {
- parser.setString(setting);
- } catch (IllegalArgumentException e) {
- Slog.wtf(TAG, "Bad battery saver constants: " + setting);
+ mDefaultAdaptivePolicy = Policy.fromSettings(adaptiveSetting, adaptiveDeviceSpecificSetting,
+ DEFAULT_ADAPTIVE_POLICY);
+ if (mPolicyLevel == POLICY_LEVEL_ADAPTIVE
+ && !mAdaptivePolicy.equals(mDefaultAdaptivePolicy)) {
+ changed = true;
}
+ // This will override any config set by an external source. This should be fine for now.
+ // TODO: make sure it doesn't override what's set externally
+ mAdaptivePolicy = mDefaultAdaptivePolicy;
- float adjustBrightnessFactor = parser.getFloat(KEY_ADJUST_BRIGHTNESS_FACTOR,
- sDefaultPolicy.adjustBrightnessFactor);
- boolean deferFullBackup = parser.getBoolean(KEY_FULLBACKUP_DEFERRED,
- sDefaultPolicy.deferFullBackup);
- boolean deferKeyValueBackup = parser.getBoolean(KEY_KEYVALUE_DEFERRED,
- sDefaultPolicy.deferKeyValueBackup);
- boolean disableAnimation = parser.getBoolean(KEY_ANIMATION_DISABLED,
- sDefaultPolicy.disableAnimation);
- boolean disableAod = parser.getBoolean(KEY_AOD_DISABLED, sDefaultPolicy.disableAod);
- boolean disableLaunchBoost = parser.getBoolean(KEY_LAUNCH_BOOST_DISABLED,
- sDefaultPolicy.disableLaunchBoost);
- boolean disableOptionalSensors = parser.getBoolean(KEY_OPTIONAL_SENSORS_DISABLED,
- sDefaultPolicy.disableOptionalSensors);
- boolean disableSoundTrigger = parser.getBoolean(KEY_SOUNDTRIGGER_DISABLED,
- sDefaultPolicy.disableSoundTrigger);
- boolean disableVibrationConfig = parser.getBoolean(KEY_VIBRATION_DISABLED,
- sDefaultPolicy.disableVibration);
- boolean enableAdjustBrightness = !parser.getBoolean(KEY_ADJUST_BRIGHTNESS_DISABLED,
- !sDefaultPolicy.enableAdjustBrightness);
- boolean enableDataSaver = !parser.getBoolean(KEY_ACTIVATE_DATASAVER_DISABLED,
- !sDefaultPolicy.enableDataSaver);
- boolean enableFirewall = !parser.getBoolean(KEY_ACTIVATE_FIREWALL_DISABLED,
- !sDefaultPolicy.enableFirewall);
- boolean enableQuickDoze = parser.getBoolean(KEY_QUICK_DOZE_ENABLED,
- sDefaultPolicy.enableQuickDoze);
- boolean forceAllAppsStandby = parser.getBoolean(KEY_FORCE_ALL_APPS_STANDBY,
- sDefaultPolicy.forceAllAppsStandby);
- boolean forceBackgroundCheck = parser.getBoolean(KEY_FORCE_BACKGROUND_CHECK,
- sDefaultPolicy.forceBackgroundCheck);
- int gpsMode = parser.getInt(KEY_GPS_MODE, sDefaultPolicy.gpsMode);
- boolean sendTronLog = parser.getBoolean(KEY_SEND_TRON_LOG, sDefaultPolicy.sendTronLog);
+ updatePolicyDependenciesLocked();
- mCurrPolicy = new Policy(
- adjustBrightnessFactor,
- deferFullBackup,
- deferKeyValueBackup,
- disableAnimation,
- disableAod,
- disableLaunchBoost,
- disableOptionalSensors,
- disableSoundTrigger,
- /* disableVibration */
- disableVibrationConfig,
- enableAdjustBrightness,
- enableDataSaver,
- enableFirewall,
- enableQuickDoze,
- /* filesForInteractive */
- (new CpuFrequencies()).parseString(cpuFreqInteractive).toSysFileMap(),
- /* filesForNoninteractive */
- (new CpuFrequencies()).parseString(cpuFreqNoninteractive).toSysFileMap(),
- forceAllAppsStandby,
- forceBackgroundCheck,
- gpsMode,
- sendTronLog
- );
+ return changed;
+ }
- // Update the effective policy.
- mDisableVibrationEffective = mCurrPolicy.disableVibration
+ @GuardedBy("mLock")
+ private void updatePolicyDependenciesLocked() {
+ final Policy currPolicy = getCurrentPolicyLocked();
+ // Update the effective vibration policy.
+ mDisableVibrationEffective = currPolicy.disableVibration
&& !mAccessibilityEnabled; // Don't disable vibration when accessibility is on.
final StringBuilder sb = new StringBuilder();
- if (mCurrPolicy.forceAllAppsStandby) sb.append("A");
- if (mCurrPolicy.forceBackgroundCheck) sb.append("B");
+ if (currPolicy.forceAllAppsStandby) sb.append("A");
+ if (currPolicy.forceBackgroundCheck) sb.append("B");
if (mDisableVibrationEffective) sb.append("v");
- if (mCurrPolicy.disableAnimation) sb.append("a");
- if (mCurrPolicy.disableSoundTrigger) sb.append("s");
- if (mCurrPolicy.deferFullBackup) sb.append("F");
- if (mCurrPolicy.deferKeyValueBackup) sb.append("K");
- if (mCurrPolicy.enableFirewall) sb.append("f");
- if (mCurrPolicy.enableDataSaver) sb.append("d");
- if (mCurrPolicy.enableAdjustBrightness) sb.append("b");
+ if (currPolicy.disableAnimation) sb.append("a");
+ if (currPolicy.disableSoundTrigger) sb.append("s");
+ if (currPolicy.deferFullBackup) sb.append("F");
+ if (currPolicy.deferKeyValueBackup) sb.append("K");
+ if (currPolicy.enableFirewall) sb.append("f");
+ if (currPolicy.enableDataSaver) sb.append("d");
+ if (currPolicy.enableAdjustBrightness) sb.append("b");
- if (mCurrPolicy.disableLaunchBoost) sb.append("l");
- if (mCurrPolicy.disableOptionalSensors) sb.append("S");
- if (mCurrPolicy.disableAod) sb.append("o");
- if (mCurrPolicy.enableQuickDoze) sb.append("q");
- if (mCurrPolicy.sendTronLog) sb.append("t");
+ if (currPolicy.disableLaunchBoost) sb.append("l");
+ if (currPolicy.disableOptionalSensors) sb.append("S");
+ if (currPolicy.disableAod) sb.append("o");
+ if (currPolicy.enableQuickDoze) sb.append("q");
+ if (currPolicy.sendTronLog) sb.append("t");
- sb.append(mCurrPolicy.gpsMode);
+ sb.append(currPolicy.gpsMode);
mEventLogKeys = sb.toString();
- mBatterySavingStats.setSendTronLog(mCurrPolicy.sendTronLog);
+ mBatterySavingStats.setSendTronLog(currPolicy.sendTronLog);
}
- private static class Policy {
+ static class Policy {
/**
* This is the flag to decide the how much to adjust the screen brightness. This is
* the float value from 0 to 1 where 1 means don't change brightness.
@@ -385,6 +438,16 @@
public final float adjustBrightnessFactor;
/**
+ * {@code true} if the Policy should advertise to the rest of the system that battery saver
+ * is enabled. This advertising could cause other system components to change their
+ * behavior. This will not affect other policy flags and what they change.
+ *
+ * @see Settings.Global#BATTERY_SAVER_CONSTANTS
+ * @see #KEY_ADVERTISE_IS_ENABLED
+ */
+ public final boolean advertiseIsEnabled;
+
+ /**
* {@code true} if full backup is deferred in battery saver mode.
*
* @see Settings.Global#BATTERY_SAVER_CONSTANTS
@@ -509,8 +572,11 @@
*/
public final boolean sendTronLog;
+ private final int mHashCode;
+
Policy(
float adjustBrightnessFactor,
+ boolean advertiseIsEnabled,
boolean deferFullBackup,
boolean deferKeyValueBackup,
boolean disableAnimation,
@@ -531,6 +597,7 @@
boolean sendTronLog) {
this.adjustBrightnessFactor = adjustBrightnessFactor;
+ this.advertiseIsEnabled = advertiseIsEnabled;
this.deferFullBackup = deferFullBackup;
this.deferKeyValueBackup = deferKeyValueBackup;
this.disableAnimation = disableAnimation;
@@ -549,94 +616,338 @@
this.forceBackgroundCheck = forceBackgroundCheck;
this.gpsMode = gpsMode;
this.sendTronLog = sendTronLog;
+
+ mHashCode = Objects.hash(
+ adjustBrightnessFactor,
+ advertiseIsEnabled,
+ deferFullBackup,
+ deferKeyValueBackup,
+ disableAnimation,
+ disableAod,
+ disableLaunchBoost,
+ disableOptionalSensors,
+ disableSoundTrigger,
+ disableVibration,
+ enableAdjustBrightness,
+ enableDataSaver,
+ enableFirewall,
+ enableQuickDoze,
+ filesForInteractive,
+ filesForNoninteractive,
+ forceAllAppsStandby,
+ forceBackgroundCheck,
+ gpsMode,
+ sendTronLog);
+ }
+
+ static Policy fromConfig(BatterySaverPolicyConfig config) {
+ if (config == null) {
+ Slog.e(TAG, "Null config passed down to BatterySaverPolicy");
+ return OFF_POLICY;
+ }
+
+ // Device-specific parameters.
+ Map<String, String> deviceSpecificSettings = config.getDeviceSpecificSettings();
+ final String cpuFreqInteractive =
+ deviceSpecificSettings.getOrDefault(KEY_CPU_FREQ_INTERACTIVE, "");
+ final String cpuFreqNoninteractive =
+ deviceSpecificSettings.getOrDefault(KEY_CPU_FREQ_NONINTERACTIVE, "");
+
+ return new Policy(
+ config.getAdjustBrightnessFactor(),
+ config.getAdvertiseIsEnabled(),
+ config.getDeferFullBackup(),
+ config.getDeferKeyValueBackup(),
+ config.getDisableAnimation(),
+ config.getDisableAod(),
+ config.getDisableLaunchBoost(),
+ config.getDisableOptionalSensors(),
+ config.getDisableSoundTrigger(),
+ config.getDisableVibration(),
+ config.getEnableAdjustBrightness(),
+ config.getEnableDataSaver(),
+ config.getEnableFirewall(),
+ config.getEnableQuickDoze(),
+ /* filesForInteractive */
+ (new CpuFrequencies()).parseString(cpuFreqInteractive).toSysFileMap(),
+ /* filesForNoninteractive */
+ (new CpuFrequencies()).parseString(cpuFreqNoninteractive).toSysFileMap(),
+ config.getForceAllAppsStandby(),
+ config.getForceBackgroundCheck(),
+ config.getGpsMode(),
+ OFF_POLICY.sendTronLog
+ );
+ }
+
+ static Policy fromSettings(String settings, String deviceSpecificSettings) {
+ return fromSettings(settings, deviceSpecificSettings, OFF_POLICY);
+ }
+
+ static Policy fromSettings(String settings, String deviceSpecificSettings,
+ Policy defaultPolicy) {
+ final KeyValueListParser parser = new KeyValueListParser(',');
+
+ // Device-specific parameters.
+ try {
+ parser.setString(deviceSpecificSettings == null ? "" : deviceSpecificSettings);
+ } catch (IllegalArgumentException e) {
+ Slog.wtf(TAG, "Bad device specific battery saver constants: "
+ + deviceSpecificSettings);
+ }
+
+ final String cpuFreqInteractive = parser.getString(KEY_CPU_FREQ_INTERACTIVE, "");
+ final String cpuFreqNoninteractive = parser.getString(KEY_CPU_FREQ_NONINTERACTIVE, "");
+
+ // Non-device-specific parameters.
+ try {
+ parser.setString(settings == null ? "" : settings);
+ } catch (IllegalArgumentException e) {
+ Slog.wtf(TAG, "Bad battery saver constants: " + settings);
+ }
+
+ float adjustBrightnessFactor = parser.getFloat(KEY_ADJUST_BRIGHTNESS_FACTOR,
+ defaultPolicy.adjustBrightnessFactor);
+ boolean advertiseIsEnabled = parser.getBoolean(KEY_ADVERTISE_IS_ENABLED,
+ defaultPolicy.advertiseIsEnabled);
+ boolean deferFullBackup = parser.getBoolean(KEY_FULLBACKUP_DEFERRED,
+ defaultPolicy.deferFullBackup);
+ boolean deferKeyValueBackup = parser.getBoolean(KEY_KEYVALUE_DEFERRED,
+ defaultPolicy.deferKeyValueBackup);
+ boolean disableAnimation = parser.getBoolean(KEY_ANIMATION_DISABLED,
+ defaultPolicy.disableAnimation);
+ boolean disableAod = parser.getBoolean(KEY_AOD_DISABLED, defaultPolicy.disableAod);
+ boolean disableLaunchBoost = parser.getBoolean(KEY_LAUNCH_BOOST_DISABLED,
+ defaultPolicy.disableLaunchBoost);
+ boolean disableOptionalSensors = parser.getBoolean(KEY_OPTIONAL_SENSORS_DISABLED,
+ defaultPolicy.disableOptionalSensors);
+ boolean disableSoundTrigger = parser.getBoolean(KEY_SOUNDTRIGGER_DISABLED,
+ defaultPolicy.disableSoundTrigger);
+ boolean disableVibrationConfig = parser.getBoolean(KEY_VIBRATION_DISABLED,
+ defaultPolicy.disableVibration);
+ boolean enableAdjustBrightness = !parser.getBoolean(KEY_ADJUST_BRIGHTNESS_DISABLED,
+ !defaultPolicy.enableAdjustBrightness);
+ boolean enableDataSaver = !parser.getBoolean(KEY_ACTIVATE_DATASAVER_DISABLED,
+ !defaultPolicy.enableDataSaver);
+ boolean enableFirewall = !parser.getBoolean(KEY_ACTIVATE_FIREWALL_DISABLED,
+ !defaultPolicy.enableFirewall);
+ boolean enableQuickDoze = parser.getBoolean(KEY_QUICK_DOZE_ENABLED,
+ defaultPolicy.enableQuickDoze);
+ boolean forceAllAppsStandby = parser.getBoolean(KEY_FORCE_ALL_APPS_STANDBY,
+ defaultPolicy.forceAllAppsStandby);
+ boolean forceBackgroundCheck = parser.getBoolean(KEY_FORCE_BACKGROUND_CHECK,
+ defaultPolicy.forceBackgroundCheck);
+ int gpsMode = parser.getInt(KEY_GPS_MODE, defaultPolicy.gpsMode);
+ boolean sendTronLog = parser.getBoolean(KEY_SEND_TRON_LOG, defaultPolicy.sendTronLog);
+
+ return new Policy(
+ adjustBrightnessFactor,
+ advertiseIsEnabled,
+ deferFullBackup,
+ deferKeyValueBackup,
+ disableAnimation,
+ disableAod,
+ disableLaunchBoost,
+ disableOptionalSensors,
+ disableSoundTrigger,
+ /* disableVibration */
+ disableVibrationConfig,
+ enableAdjustBrightness,
+ enableDataSaver,
+ enableFirewall,
+ enableQuickDoze,
+ /* filesForInteractive */
+ (new CpuFrequencies()).parseString(cpuFreqInteractive).toSysFileMap(),
+ /* filesForNoninteractive */
+ (new CpuFrequencies()).parseString(cpuFreqNoninteractive).toSysFileMap(),
+ forceAllAppsStandby,
+ forceBackgroundCheck,
+ gpsMode,
+ sendTronLog
+ );
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) return true;
+ if (!(obj instanceof Policy)) return false;
+ Policy other = (Policy) obj;
+ return Float.compare(other.adjustBrightnessFactor, adjustBrightnessFactor) == 0
+ && advertiseIsEnabled == other.advertiseIsEnabled
+ && deferFullBackup == other.deferFullBackup
+ && deferKeyValueBackup == other.deferKeyValueBackup
+ && disableAnimation == other.disableAnimation
+ && disableAod == other.disableAod
+ && disableLaunchBoost == other.disableLaunchBoost
+ && disableOptionalSensors == other.disableOptionalSensors
+ && disableSoundTrigger == other.disableSoundTrigger
+ && disableVibration == other.disableVibration
+ && enableAdjustBrightness == other.enableAdjustBrightness
+ && enableDataSaver == other.enableDataSaver
+ && enableFirewall == other.enableFirewall
+ && enableQuickDoze == other.enableQuickDoze
+ && forceAllAppsStandby == other.forceAllAppsStandby
+ && forceBackgroundCheck == other.forceBackgroundCheck
+ && gpsMode == other.gpsMode
+ && sendTronLog == other.sendTronLog
+ && filesForInteractive.equals(other.filesForInteractive)
+ && filesForNoninteractive.equals(other.filesForNoninteractive);
+ }
+
+ @Override
+ public int hashCode() {
+ return mHashCode;
}
}
/**
- * Get the {@link PowerSaveState} based on {@paramref type} and {@paramref realMode}.
+ * Get the {@link PowerSaveState} based on the current policy level.
* The result will have {@link PowerSaveState#batterySaverEnabled} and some other
* parameters when necessary.
*
- * @param type type of the service, one of {@link ServiceType}
- * @param realMode whether the battery saver is on by default
+ * @param type type of the service, one of {@link ServiceType}
* @return State data that contains battery saver data
*/
- public PowerSaveState getBatterySaverPolicy(@ServiceType int type, boolean realMode) {
+ public PowerSaveState getBatterySaverPolicy(@ServiceType int type) {
synchronized (mLock) {
+ final Policy currPolicy = getCurrentPolicyLocked();
final PowerSaveState.Builder builder = new PowerSaveState.Builder()
- .setGlobalBatterySaverEnabled(realMode);
- if (!realMode) {
- return builder.setBatterySaverEnabled(realMode)
- .build();
- }
+ .setGlobalBatterySaverEnabled(currPolicy.advertiseIsEnabled);
switch (type) {
case ServiceType.GPS:
- return builder.setBatterySaverEnabled(realMode)
- .setGpsMode(mCurrPolicy.gpsMode)
+ boolean isEnabled = currPolicy.advertiseIsEnabled
+ || currPolicy.gpsMode != PowerManager.LOCATION_MODE_NO_CHANGE;
+ return builder.setBatterySaverEnabled(isEnabled)
+ .setGpsMode(currPolicy.gpsMode)
.build();
case ServiceType.ANIMATION:
- return builder.setBatterySaverEnabled(mCurrPolicy.disableAnimation)
+ return builder.setBatterySaverEnabled(currPolicy.disableAnimation)
.build();
case ServiceType.FULL_BACKUP:
- return builder.setBatterySaverEnabled(mCurrPolicy.deferFullBackup)
+ return builder.setBatterySaverEnabled(currPolicy.deferFullBackup)
.build();
case ServiceType.KEYVALUE_BACKUP:
- return builder.setBatterySaverEnabled(mCurrPolicy.deferKeyValueBackup)
+ return builder.setBatterySaverEnabled(currPolicy.deferKeyValueBackup)
.build();
case ServiceType.NETWORK_FIREWALL:
- return builder.setBatterySaverEnabled(mCurrPolicy.enableFirewall)
+ return builder.setBatterySaverEnabled(currPolicy.enableFirewall)
.build();
case ServiceType.SCREEN_BRIGHTNESS:
- return builder.setBatterySaverEnabled(mCurrPolicy.enableAdjustBrightness)
- .setBrightnessFactor(mCurrPolicy.adjustBrightnessFactor)
+ return builder.setBatterySaverEnabled(currPolicy.enableAdjustBrightness)
+ .setBrightnessFactor(currPolicy.adjustBrightnessFactor)
.build();
case ServiceType.DATA_SAVER:
- return builder.setBatterySaverEnabled(mCurrPolicy.enableDataSaver)
+ return builder.setBatterySaverEnabled(currPolicy.enableDataSaver)
.build();
case ServiceType.SOUND:
- return builder.setBatterySaverEnabled(mCurrPolicy.disableSoundTrigger)
+ return builder.setBatterySaverEnabled(currPolicy.disableSoundTrigger)
.build();
case ServiceType.VIBRATION:
return builder.setBatterySaverEnabled(mDisableVibrationEffective)
.build();
case ServiceType.FORCE_ALL_APPS_STANDBY:
- return builder.setBatterySaverEnabled(mCurrPolicy.forceAllAppsStandby)
+ return builder.setBatterySaverEnabled(currPolicy.forceAllAppsStandby)
.build();
case ServiceType.FORCE_BACKGROUND_CHECK:
- return builder.setBatterySaverEnabled(mCurrPolicy.forceBackgroundCheck)
+ return builder.setBatterySaverEnabled(currPolicy.forceBackgroundCheck)
.build();
case ServiceType.OPTIONAL_SENSORS:
- return builder.setBatterySaverEnabled(mCurrPolicy.disableOptionalSensors)
+ return builder.setBatterySaverEnabled(currPolicy.disableOptionalSensors)
.build();
case ServiceType.AOD:
- return builder.setBatterySaverEnabled(mCurrPolicy.disableAod)
+ return builder.setBatterySaverEnabled(currPolicy.disableAod)
.build();
case ServiceType.QUICK_DOZE:
- return builder.setBatterySaverEnabled(mCurrPolicy.enableQuickDoze)
+ return builder.setBatterySaverEnabled(currPolicy.enableQuickDoze)
.build();
default:
- return builder.setBatterySaverEnabled(realMode)
+ return builder.setBatterySaverEnabled(currPolicy.advertiseIsEnabled)
.build();
}
}
}
+ /**
+ * Sets the current policy.
+ *
+ * @return true if the policy level was changed.
+ */
+ boolean setPolicyLevel(@PolicyLevel int level) {
+ synchronized (mLock) {
+ if (mPolicyLevel == level) {
+ return false;
+ }
+ switch (level) {
+ case POLICY_LEVEL_FULL:
+ case POLICY_LEVEL_ADAPTIVE:
+ case POLICY_LEVEL_OFF:
+ mPolicyLevel = level;
+ break;
+ default:
+ Slog.wtf(TAG, "setPolicyLevel invalid level given: " + level);
+ return false;
+ }
+ updatePolicyDependenciesLocked();
+ return true;
+ }
+ }
+
+ /** @return true if the current policy changed and the policy level is ADAPTIVE. */
+ boolean setAdaptivePolicyLocked(Policy p) {
+ if (p == null) {
+ Slog.wtf(TAG, "setAdaptivePolicy given null policy");
+ return false;
+ }
+ if (mAdaptivePolicy.equals(p)) {
+ return false;
+ }
+
+ mAdaptivePolicy = p;
+ if (mPolicyLevel == POLICY_LEVEL_ADAPTIVE) {
+ updatePolicyDependenciesLocked();
+ return true;
+ }
+ return false;
+ }
+
+ /** @return true if the current policy changed and the policy level is ADAPTIVE. */
+ boolean resetAdaptivePolicyLocked() {
+ return setAdaptivePolicyLocked(mDefaultAdaptivePolicy);
+ }
+
+ private Policy getCurrentPolicyLocked() {
+ switch (mPolicyLevel) {
+ case POLICY_LEVEL_FULL:
+ return mFullPolicy;
+ case POLICY_LEVEL_ADAPTIVE:
+ return mAdaptivePolicy;
+ case POLICY_LEVEL_OFF:
+ default:
+ return OFF_POLICY;
+ }
+ }
+
public int getGpsMode() {
synchronized (mLock) {
- return mCurrPolicy.gpsMode;
+ return getCurrentPolicyLocked().gpsMode;
}
}
public ArrayMap<String, String> getFileValues(boolean interactive) {
synchronized (mLock) {
- return interactive ? mCurrPolicy.filesForInteractive
- : mCurrPolicy.filesForNoninteractive;
+ return interactive ? getCurrentPolicyLocked().filesForInteractive
+ : getCurrentPolicyLocked().filesForNoninteractive;
}
}
public boolean isLaunchBoostDisabled() {
synchronized (mLock) {
- return mCurrPolicy.disableLaunchBoost;
+ return getCurrentPolicyLocked().disableLaunchBoost;
+ }
+ }
+
+ boolean shouldAdvertiseIsEnabled() {
+ synchronized (mLock) {
+ return getCurrentPolicyLocked().advertiseIsEnabled;
}
}
@@ -658,40 +969,75 @@
pw.println(" Settings: " + mDeviceSpecificSettingsSource);
pw.println(" value: " + mDeviceSpecificSettings);
- pw.println();
+ pw.println(" Adaptive Settings: " + Settings.Global.BATTERY_SAVER_ADAPTIVE_CONSTANTS);
+ pw.println(" value: " + mAdaptiveSettings);
+ pw.println(" Adaptive Device Specific Settings: "
+ + Settings.Global.BATTERY_SAVER_ADAPTIVE_DEVICE_SPECIFIC_CONSTANTS);
+ pw.println(" value: " + mAdaptiveDeviceSpecificSettings);
+
pw.println(" mAccessibilityEnabled=" + mAccessibilityEnabled);
- pw.println(" " + KEY_VIBRATION_DISABLED + ":config=" + mCurrPolicy.disableVibration);
- pw.println(" " + KEY_VIBRATION_DISABLED + ":effective=" + mDisableVibrationEffective);
- pw.println(" " + KEY_ANIMATION_DISABLED + "=" + mCurrPolicy.disableAnimation);
- pw.println(" " + KEY_FULLBACKUP_DEFERRED + "=" + mCurrPolicy.deferFullBackup);
- pw.println(" " + KEY_KEYVALUE_DEFERRED + "=" + mCurrPolicy.deferKeyValueBackup);
- pw.println(" " + KEY_ACTIVATE_FIREWALL_DISABLED + "=" + !mCurrPolicy.enableFirewall);
- pw.println(" " + KEY_ACTIVATE_DATASAVER_DISABLED + "=" + !mCurrPolicy.enableDataSaver);
- pw.println(" " + KEY_LAUNCH_BOOST_DISABLED + "=" + mCurrPolicy.disableLaunchBoost);
- pw.println(" " + KEY_ADJUST_BRIGHTNESS_DISABLED + "="
- + !mCurrPolicy.enableAdjustBrightness);
- pw.println(
- " " + KEY_ADJUST_BRIGHTNESS_FACTOR + "=" + mCurrPolicy.adjustBrightnessFactor);
- pw.println(" " + KEY_GPS_MODE + "=" + mCurrPolicy.gpsMode);
- pw.println(" " + KEY_FORCE_ALL_APPS_STANDBY + "=" + mCurrPolicy.forceAllAppsStandby);
- pw.println(" " + KEY_FORCE_BACKGROUND_CHECK + "=" + mCurrPolicy.forceBackgroundCheck);
- pw.println(" " + KEY_OPTIONAL_SENSORS_DISABLED + "="
- + mCurrPolicy.disableOptionalSensors);
- pw.println(" " + KEY_AOD_DISABLED + "=" + mCurrPolicy.disableAod);
- pw.println(" " + KEY_SOUNDTRIGGER_DISABLED + "=" + mCurrPolicy.disableSoundTrigger);
- pw.println(" " + KEY_QUICK_DOZE_ENABLED + "=" + mCurrPolicy.enableQuickDoze);
- pw.println(" " + KEY_SEND_TRON_LOG + "=" + mCurrPolicy.sendTronLog);
- pw.println();
+ pw.println(" mPolicyLevel=" + mPolicyLevel);
- pw.print(" Interactive File values:\n");
- dumpMap(pw, " ", mCurrPolicy.filesForInteractive);
- pw.println();
-
- pw.print(" Noninteractive File values:\n");
- dumpMap(pw, " ", mCurrPolicy.filesForNoninteractive);
+ dumpPolicyLocked(pw, " ", "full", mFullPolicy);
+ dumpPolicyLocked(pw, " ", "default adaptive", mDefaultAdaptivePolicy);
+ dumpPolicyLocked(pw, " ", "current adaptive", mAdaptivePolicy);
}
}
+ private void dumpPolicyLocked(PrintWriter pw, String indent, String label, Policy p) {
+ pw.println();
+ pw.print(indent);
+ pw.println("Policy '" + label + "'");
+ pw.print(indent);
+ pw.println(" " + KEY_ADVERTISE_IS_ENABLED + "=" + p.advertiseIsEnabled);
+ pw.print(indent);
+ pw.println(" " + KEY_VIBRATION_DISABLED + ":config=" + p.disableVibration);
+ // mDisableVibrationEffective is based on the currently selected policy
+ pw.print(indent);
+ pw.println(" " + KEY_VIBRATION_DISABLED + ":effective=" + (p.disableVibration
+ && !mAccessibilityEnabled));
+ pw.print(indent);
+ pw.println(" " + KEY_ANIMATION_DISABLED + "=" + p.disableAnimation);
+ pw.print(indent);
+ pw.println(" " + KEY_FULLBACKUP_DEFERRED + "=" + p.deferFullBackup);
+ pw.print(indent);
+ pw.println(" " + KEY_KEYVALUE_DEFERRED + "=" + p.deferKeyValueBackup);
+ pw.print(indent);
+ pw.println(" " + KEY_ACTIVATE_FIREWALL_DISABLED + "=" + !p.enableFirewall);
+ pw.print(indent);
+ pw.println(" " + KEY_ACTIVATE_DATASAVER_DISABLED + "=" + !p.enableDataSaver);
+ pw.print(indent);
+ pw.println(" " + KEY_LAUNCH_BOOST_DISABLED + "=" + p.disableLaunchBoost);
+ pw.println(
+ " " + KEY_ADJUST_BRIGHTNESS_DISABLED + "=" + !p.enableAdjustBrightness);
+ pw.print(indent);
+ pw.println(" " + KEY_ADJUST_BRIGHTNESS_FACTOR + "=" + p.adjustBrightnessFactor);
+ pw.print(indent);
+ pw.println(" " + KEY_GPS_MODE + "=" + p.gpsMode);
+ pw.print(indent);
+ pw.println(" " + KEY_FORCE_ALL_APPS_STANDBY + "=" + p.forceAllAppsStandby);
+ pw.print(indent);
+ pw.println(" " + KEY_FORCE_BACKGROUND_CHECK + "=" + p.forceBackgroundCheck);
+ pw.println(
+ " " + KEY_OPTIONAL_SENSORS_DISABLED + "=" + p.disableOptionalSensors);
+ pw.print(indent);
+ pw.println(" " + KEY_AOD_DISABLED + "=" + p.disableAod);
+ pw.print(indent);
+ pw.println(" " + KEY_SOUNDTRIGGER_DISABLED + "=" + p.disableSoundTrigger);
+ pw.print(indent);
+ pw.println(" " + KEY_QUICK_DOZE_ENABLED + "=" + p.enableQuickDoze);
+ pw.print(indent);
+ pw.println(" " + KEY_SEND_TRON_LOG + "=" + p.sendTronLog);
+ pw.println();
+
+ pw.print(" Interactive File values:\n");
+ dumpMap(pw, " ", p.filesForInteractive);
+ pw.println();
+
+ pw.print(" Noninteractive File values:\n");
+ dumpMap(pw, " ", p.filesForNoninteractive);
+ }
+
private void dumpMap(PrintWriter pw, String prefix, ArrayMap<String, String> map) {
if (map == null) {
return;
@@ -710,6 +1056,7 @@
public void setAccessibilityEnabledForTest(boolean enabled) {
synchronized (mLock) {
mAccessibilityEnabled = enabled;
+ updatePolicyDependenciesLocked();
}
}
}
diff --git a/services/core/java/com/android/server/power/batterysaver/BatterySaverStateMachine.java b/services/core/java/com/android/server/power/batterysaver/BatterySaverStateMachine.java
index 404e450..e6fa500 100644
--- a/services/core/java/com/android/server/power/batterysaver/BatterySaverStateMachine.java
+++ b/services/core/java/com/android/server/power/batterysaver/BatterySaverStateMachine.java
@@ -24,8 +24,10 @@
import android.content.Intent;
import android.content.res.Resources;
import android.database.ContentObserver;
+import android.os.BatterySaverPolicyConfig;
import android.os.Handler;
import android.os.PowerManager;
+import android.os.SystemClock;
import android.os.UserHandle;
import android.provider.Settings;
import android.util.Slog;
@@ -46,8 +48,7 @@
* IMPORTANT: This class shares the power manager lock, which is very low in the lock hierarchy.
* Do not call out with the lock held. (Settings provider is okay.)
*
- * Test:
- atest $ANDROID_BUILD_TOP/frameworks/base/services/tests/servicestests/src/com/android/server/power/batterysaver/BatterySaverStateMachineTest.java
+ * Test: atest com.android.server.power.batterysaver.BatterySaverStateMachineTest
*/
public class BatterySaverStateMachine {
private static final String TAG = "BatterySaverStateMachine";
@@ -57,6 +58,8 @@
private static final boolean DEBUG = BatterySaverPolicy.DEBUG;
+ private static final long ADAPTIVE_CHANGE_TIMEOUT_MS = 24 * 60 * 60 * 1000L;
+
private final Context mContext;
private final BatterySaverController mBatterySaverController;
@@ -157,6 +160,13 @@
@GuardedBy("mLock")
private String mLastChangedStrReason;
+ /**
+ * The last time adaptive battery saver was changed by an external service, using elapsed
+ * realtime as the timebase.
+ */
+ @GuardedBy("mLock")
+ private long mLastAdaptiveBatterySaverChangedExternallyElapsed;
+
private final ContentObserver mSettingsObserver = new ContentObserver(null) {
@Override
public void onChange(boolean selfChange) {
@@ -178,10 +188,6 @@
com.android.internal.R.integer.config_dynamicPowerSavingsDefaultDisableThreshold);
}
- private boolean isBatterySaverEnabled() {
- return mBatterySaverController.isEnabled();
- }
-
private boolean isAutoBatterySaverConfiguredLocked() {
return mSettingBatterySaverTriggerThreshold > 0;
}
@@ -392,6 +398,36 @@
}
}
+ /**
+ * Enable or disable the current adaptive battery saver policy. This may not change what's in
+ * effect if full battery saver is also enabled.
+ */
+ public boolean setAdaptiveBatterySaverEnabled(boolean enabled) {
+ if (DEBUG) {
+ Slog.d(TAG, "setAdaptiveBatterySaverEnabled: enabled=" + enabled);
+ }
+ synchronized (mLock) {
+ mLastAdaptiveBatterySaverChangedExternallyElapsed = SystemClock.elapsedRealtime();
+ return mBatterySaverController.setAdaptivePolicyEnabledLocked(
+ enabled, BatterySaverController.REASON_ADAPTIVE_DYNAMIC_POWER_SAVINGS_CHANGED);
+ }
+ }
+
+ /**
+ * Change the adaptive battery saver policy.
+ */
+ public boolean setAdaptiveBatterySaverPolicy(BatterySaverPolicyConfig config) {
+ if (DEBUG) {
+ Slog.d(TAG, "setAdaptiveBatterySaverPolicy: config=" + config);
+ }
+
+ synchronized (mLock) {
+ mLastAdaptiveBatterySaverChangedExternallyElapsed = SystemClock.elapsedRealtime();
+ return mBatterySaverController.setAdaptivePolicyLocked(config,
+ BatterySaverController.REASON_ADAPTIVE_DYNAMIC_POWER_SAVINGS_CHANGED);
+ }
+ }
+
@GuardedBy("mLock")
private boolean isBatteryLowLocked() {
final boolean percentageLow =
@@ -427,12 +463,26 @@
if (!isBatteryLowLocked()) {
updateSnoozingLocked(false, "Battery not low");
}
+
+ if (SystemClock.elapsedRealtime() - mLastAdaptiveBatterySaverChangedExternallyElapsed
+ > ADAPTIVE_CHANGE_TIMEOUT_MS) {
+ mBatterySaverController.setAdaptivePolicyEnabledLocked(
+ false, BatterySaverController.REASON_TIMEOUT);
+ mBatterySaverController.resetAdaptivePolicyLocked(
+ BatterySaverController.REASON_TIMEOUT);
+ }
+
if (mIsPowered) {
updateSnoozingLocked(false, "Plugged in");
enableBatterySaverLocked(/*enable=*/ false, /*manual=*/ false,
BatterySaverController.REASON_PLUGGED_IN,
"Plugged in");
+ if (mBatteryLevel >= 80 /* Arbitrary level */) {
+ mBatterySaverController.setAdaptivePolicyEnabledLocked(
+ false, BatterySaverController.REASON_PLUGGED_IN);
+ }
+
} else if (mSettingBatterySaverEnabledSticky && !mBatterySaverStickyBehaviourDisabled) {
if (mSettingBatterySaverStickyAutoDisableEnabled
&& mBatteryLevel >= mSettingBatterySaverStickyAutoDisableThreshold) {
@@ -472,7 +522,7 @@
// do nothing if automatic battery saver mode = PERCENTAGE and low warning threshold = 0%
}
- /**
+ /**
* {@link com.android.server.power.PowerManagerService} calls it when
* {@link android.os.PowerManager#setPowerSaveMode} is called.
*
@@ -501,7 +551,7 @@
Slog.d(TAG, "enableBatterySaver: enable=" + enable + " manual=" + manual
+ " reason=" + strReason + "(" + intReason + ")");
}
- final boolean wasEnabled = mBatterySaverController.isEnabled();
+ final boolean wasEnabled = mBatterySaverController.isFullEnabled();
if (wasEnabled == enable) {
if (DEBUG) {
@@ -523,9 +573,10 @@
// When battery saver is disabled manually (while battery saver is enabled)
// when the battery level is low, we "snooze" BS -- i.e. disable auto battery saver.
// We resume auto-BS once the battery level is not low, or the device is plugged in.
- if (isBatterySaverEnabled() && isBatteryLowLocked()) {
+ if (mBatterySaverController.isFullEnabled() && isBatteryLowLocked()) {
updateSnoozingLocked(true, "Manual snooze");
}
+ // TODO: maybe turn off adaptive if it's on and advertiseIsEnabled is true
}
}
@@ -622,6 +673,17 @@
pw.print(" Enabled=");
pw.println(mBatterySaverController.isEnabled());
+ pw.print(" full=");
+ pw.println(mBatterySaverController.isFullEnabled());
+ pw.print(" adaptive=");
+ pw.print(mBatterySaverController.isAdaptiveEnabled());
+ if (mBatterySaverController.isAdaptiveEnabled()) {
+ pw.print(" (advertise=");
+ pw.print(
+ mBatterySaverController.getBatterySaverPolicy().shouldAdvertiseIsEnabled());
+ pw.print(")");
+ }
+ pw.println();
pw.print(" mLastChangedIntReason=");
pw.println(mLastChangedIntReason);
@@ -657,6 +719,9 @@
pw.println(mSettingBatterySaverTriggerThreshold);
pw.print(" mBatterySaverStickyBehaviourDisabled=");
pw.println(mBatterySaverStickyBehaviourDisabled);
+
+ pw.print(" mLastAdaptiveBatterySaverChangedExternallyElapsed=");
+ pw.println(mLastAdaptiveBatterySaverChangedExternallyElapsed);
}
}
@@ -666,6 +731,12 @@
proto.write(BatterySaverStateMachineProto.ENABLED,
mBatterySaverController.isEnabled());
+ proto.write(BatterySaverStateMachineProto.IS_FULL_ENABLED,
+ mBatterySaverController.isFullEnabled());
+ proto.write(BatterySaverStateMachineProto.IS_ADAPTIVE_ENABLED,
+ mBatterySaverController.isAdaptiveEnabled());
+ proto.write(BatterySaverStateMachineProto.SHOULD_ADVERTISE_IS_ENABLED,
+ mBatterySaverController.getBatterySaverPolicy().shouldAdvertiseIsEnabled());
proto.write(BatterySaverStateMachineProto.BOOT_COMPLETED, mBootCompleted);
proto.write(BatterySaverStateMachineProto.SETTINGS_LOADED, mSettingsLoaded);
@@ -692,6 +763,11 @@
.SETTING_BATTERY_SAVER_STICKY_AUTO_DISABLE_THRESHOLD,
mSettingBatterySaverStickyAutoDisableThreshold);
+ proto.write(
+ BatterySaverStateMachineProto
+ .LAST_ADAPTIVE_BATTERY_SAVER_CHANGED_EXTERNALLY_ELAPSED,
+ mLastAdaptiveBatterySaverChangedExternallyElapsed);
+
proto.end(token);
}
}
diff --git a/services/core/java/com/android/server/power/batterysaver/BatterySavingStats.java b/services/core/java/com/android/server/power/batterysaver/BatterySavingStats.java
index 79b44eb..1d30a03 100644
--- a/services/core/java/com/android/server/power/batterysaver/BatterySavingStats.java
+++ b/services/core/java/com/android/server/power/batterysaver/BatterySavingStats.java
@@ -57,9 +57,10 @@
interface BatterySaverState {
int OFF = 0;
int ON = 1;
+ int ADAPTIVE = 2;
int SHIFT = 0;
- int BITS = 1;
+ int BITS = 2;
int MASK = (1 << BITS) - 1;
static int fromIndex(int index) {
diff --git a/services/core/java/com/android/server/role/RoleManagerService.java b/services/core/java/com/android/server/role/RoleManagerService.java
index 03ec57b..d72270e 100644
--- a/services/core/java/com/android/server/role/RoleManagerService.java
+++ b/services/core/java/com/android/server/role/RoleManagerService.java
@@ -52,6 +52,7 @@
import android.service.sms.FinancialSmsService;
import android.telephony.IFinancialSmsCallback;
import android.text.TextUtils;
+import android.util.ArrayMap;
import android.util.ArraySet;
import android.util.PackageUtils;
import android.util.Slog;
@@ -145,6 +146,9 @@
mUserManagerInternal = LocalServices.getService(UserManagerInternal.class);
mAppOpsManager = context.getSystemService(AppOpsManager.class);
+ LocalServices.addService(RoleManagerServiceInternal.class,
+ new RoleManagerServiceInternalImpl());
+
registerUserRemovedReceiver();
}
@@ -382,6 +386,19 @@
}
}
+ /**
+ * Get all roles and packages hold them.
+ *
+ * @param user The user to query to roles for
+ *
+ * @return The roles and their holders
+ */
+ @NonNull
+ private ArrayMap<String, ArraySet<String>> getRoleHoldersAsUser(@NonNull UserHandle user) {
+ RoleUserState userState = getOrCreateUserState(user.getIdentifier());
+ return userState.getRoleHolders();
+ }
+
private class Stub extends IRoleManager.Stub {
@Override
@@ -676,4 +693,16 @@
}
}
}
+
+ /**
+ * Entry point for internal calls into role manager
+ */
+ private final class RoleManagerServiceInternalImpl extends RoleManagerServiceInternal {
+
+ @NonNull
+ @Override
+ public ArrayMap<String, ArraySet<String>> getRoleHoldersAsUser(@NonNull UserHandle user) {
+ return RoleManagerService.this.getRoleHoldersAsUser(user);
+ }
+ }
}
diff --git a/services/core/java/com/android/server/role/RoleManagerServiceInternal.java b/services/core/java/com/android/server/role/RoleManagerServiceInternal.java
new file mode 100644
index 0000000..3afc3f7
--- /dev/null
+++ b/services/core/java/com/android/server/role/RoleManagerServiceInternal.java
@@ -0,0 +1,38 @@
+/*
+ * Copyright (C) 2019 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.server.role;
+
+import android.annotation.NonNull;
+import android.os.UserHandle;
+import android.util.ArrayMap;
+import android.util.ArraySet;
+
+/**
+ * Internal calls into {@link RoleManagerService}
+ */
+public abstract class RoleManagerServiceInternal {
+ /**
+ * Get all roles and packages hold them.
+ *
+ * @param user The user to query to roles for
+ *
+ * @return The roles and their holders
+ */
+ @NonNull
+ public abstract ArrayMap<String, ArraySet<String>> getRoleHoldersAsUser(
+ @NonNull UserHandle user);
+}
diff --git a/services/core/java/com/android/server/role/RoleUserState.java b/services/core/java/com/android/server/role/RoleUserState.java
index 02dcc49..bc68dde 100644
--- a/services/core/java/com/android/server/role/RoleUserState.java
+++ b/services/core/java/com/android/server/role/RoleUserState.java
@@ -376,7 +376,7 @@
version = mVersion;
packagesHash = mPackagesHash;
- roles = snapshotRolesLocked();
+ roles = getRoleHolders();
}
AtomicFile atomicFile = new AtomicFile(getFile(mUserId), "roles-" + mUserId);
@@ -541,7 +541,7 @@
version = mVersion;
packagesHash = mPackagesHash;
- roles = snapshotRolesLocked();
+ roles = getRoleHolders();
}
long fieldToken = dumpOutputStream.start(fieldName, fieldId);
@@ -570,17 +570,24 @@
dumpOutputStream.end(fieldToken);
}
- @GuardedBy("mLock")
- private ArrayMap<String, ArraySet<String>> snapshotRolesLocked() {
- ArrayMap<String, ArraySet<String>> roles = new ArrayMap<>();
- for (int i = 0, size = CollectionUtils.size(mRoles); i < size; ++i) {
- String roleName = mRoles.keyAt(i);
- ArraySet<String> roleHolders = mRoles.valueAt(i);
+ /**
+ * Get the roles and their holders.
+ *
+ * @return A copy of the roles and their holders
+ */
+ @NonNull
+ public ArrayMap<String, ArraySet<String>> getRoleHolders() {
+ synchronized (mLock) {
+ ArrayMap<String, ArraySet<String>> roles = new ArrayMap<>();
+ for (int i = 0, size = CollectionUtils.size(mRoles); i < size; ++i) {
+ String roleName = mRoles.keyAt(i);
+ ArraySet<String> roleHolders = mRoles.valueAt(i);
- roleHolders = new ArraySet<>(roleHolders);
- roles.put(roleName, roleHolders);
+ roleHolders = new ArraySet<>(roleHolders);
+ roles.put(roleName, roleHolders);
+ }
+ return roles;
}
- return roles;
}
/**
diff --git a/services/core/java/com/android/server/rollback/RollbackManagerServiceImpl.java b/services/core/java/com/android/server/rollback/RollbackManagerServiceImpl.java
index 5eb137b..4613400 100644
--- a/services/core/java/com/android/server/rollback/RollbackManagerServiceImpl.java
+++ b/services/core/java/com/android/server/rollback/RollbackManagerServiceImpl.java
@@ -783,7 +783,7 @@
}
@Override
- public void restoreUserData(String packageName, int userId, int appId, long ceDataInode,
+ public void restoreUserData(String packageName, int[] userIds, int appId, long ceDataInode,
String seInfo, int token) {
if (Binder.getCallingUid() != Process.SYSTEM_UID) {
throw new SecurityException("restoureUserData may only be called by the system.");
@@ -791,23 +791,26 @@
getHandler().post(() -> {
final RollbackData rollbackData = getRollbackForPackage(packageName);
- final boolean changedRollbackData = mUserdataHelper.restoreAppData(packageName,
- rollbackData, userId, appId, ceDataInode, seInfo);
+ for (int userId : userIds) {
+ final boolean changedRollbackData = mUserdataHelper.restoreAppData(packageName,
+ rollbackData, userId, appId, ceDataInode, seInfo);
+
+ // We've updated metadata about this rollback, so save it to flash.
+ if (changedRollbackData) {
+ try {
+ mRollbackStore.saveAvailableRollback(rollbackData);
+ } catch (IOException ioe) {
+ // TODO(narayan): What is the right thing to do here ? This isn't a fatal
+ // error, since it will only result in us trying to restore data again,
+ // which will be a no-op if there's no data available.
+ Log.e(TAG, "Unable to save available rollback: " + packageName, ioe);
+ }
+ }
+ }
+
final PackageManagerInternal pmi = LocalServices.getService(
PackageManagerInternal.class);
pmi.finishPackageInstall(token, false);
-
- // We've updated metadata about this rollback, so save it to flash.
- if (changedRollbackData) {
- try {
- mRollbackStore.saveAvailableRollback(rollbackData);
- } catch (IOException ioe) {
- // TODO(narayan): What is the right thing to do here ? This isn't a fatal error,
- // since it will only result in us trying to restore data again, which will be
- // a no-op if there's no data available.
- Log.e(TAG, "Unable to save available rollback: " + packageName, ioe);
- }
- }
});
}
diff --git a/services/core/java/com/android/server/stats/StatsCompanionService.java b/services/core/java/com/android/server/stats/StatsCompanionService.java
index c6d2870..2be78fe3 100644
--- a/services/core/java/com/android/server/stats/StatsCompanionService.java
+++ b/services/core/java/com/android/server/stats/StatsCompanionService.java
@@ -23,6 +23,7 @@
import static com.android.server.am.MemoryStatUtil.readMemoryStatFromProcfs;
import static com.android.server.am.MemoryStatUtil.readRssHighWaterMarkFromProcfs;
+import android.annotation.NonNull;
import android.annotation.Nullable;
import android.app.ActivityManagerInternal;
import android.app.AlarmManager;
@@ -83,6 +84,7 @@
import android.telephony.ModemActivityInfo;
import android.telephony.TelephonyManager;
import android.util.ArrayMap;
+import android.util.ArraySet;
import android.util.Log;
import android.util.Slog;
import android.util.StatsLog;
@@ -112,6 +114,7 @@
import com.android.server.SystemService;
import com.android.server.SystemServiceManager;
import com.android.server.am.MemoryStatUtil.MemoryStat;
+import com.android.server.role.RoleManagerServiceInternal;
import com.android.server.storage.DiskStatsFileLogger;
import com.android.server.storage.DiskStatsLoggingService;
@@ -1781,6 +1784,60 @@
}
/**
+ * Add a RoleHolder atom for each package that holds a role.
+ *
+ * @param elapsedNanos the time since boot
+ * @param wallClockNanos the time on the clock
+ * @param pulledData the data sink to write to
+ */
+ private void pullRoleHolders(long elapsedNanos, final long wallClockNanos,
+ @NonNull List<StatsLogEventWrapper> pulledData) {
+ long callingToken = Binder.clearCallingIdentity();
+ try {
+ PackageManager pm = mContext.getPackageManager();
+ RoleManagerServiceInternal rm =
+ LocalServices.getService(RoleManagerServiceInternal.class);
+
+ List<UserInfo> users = mContext.getSystemService(UserManager.class).getUsers();
+
+ int numUsers = users.size();
+ for (int userNum = 0; userNum < numUsers; userNum++) {
+ UserHandle user = users.get(userNum).getUserHandle();
+
+ ArrayMap<String, ArraySet<String>> roles = rm.getRoleHoldersAsUser(user);
+
+ int numRoles = roles.size();
+ for (int roleNum = 0; roleNum < numRoles; roleNum++) {
+ String roleName = roles.keyAt(roleNum);
+ ArraySet<String> holders = roles.valueAt(roleNum);
+
+ int numHolders = holders.size();
+ for (int holderNum = 0; holderNum < numHolders; holderNum++) {
+ String holderName = holders.valueAt(holderNum);
+
+ PackageInfo pkg;
+ try {
+ pkg = pm.getPackageInfoAsUser(holderName, 0, user.getIdentifier());
+ } catch (PackageManager.NameNotFoundException e) {
+ Log.w(TAG, "Role holder " + holderName + " not found");
+ return;
+ }
+
+ StatsLogEventWrapper e = new StatsLogEventWrapper(StatsLog.ROLE_HOLDER,
+ elapsedNanos, wallClockNanos);
+ e.writeInt(pkg.applicationInfo.uid);
+ e.writeString(holderName);
+ e.writeString(roleName);
+ pulledData.add(e);
+ }
+ }
+ }
+ } finally {
+ Binder.restoreCallingIdentity(callingToken);
+ }
+ }
+
+ /**
* Pulls various data.
*/
@Override // Binder call
@@ -1954,6 +2011,10 @@
pullDebugFailingElapsedClock(tagId, elapsedNanos, wallClockNanos, ret);
break;
}
+ case StatsLog.ROLE_HOLDER: {
+ pullRoleHolders(elapsedNanos, wallClockNanos, ret);
+ break;
+ }
default:
Slog.w(TAG, "No such tagId data as " + tagId);
return null;
diff --git a/services/core/java/com/android/server/wallpaper/WallpaperManagerService.java b/services/core/java/com/android/server/wallpaper/WallpaperManagerService.java
index b0ef8a0..071dde7 100644
--- a/services/core/java/com/android/server/wallpaper/WallpaperManagerService.java
+++ b/services/core/java/com/android/server/wallpaper/WallpaperManagerService.java
@@ -2243,12 +2243,9 @@
synchronized (mLock) {
mInAmbientMode = inAmbientMode;
final WallpaperData data = mWallpaperMap.get(mCurrentUserId);
- final boolean hasConnection = data != null && data.connection != null;
- final WallpaperInfo info = hasConnection ? data.connection.mInfo : null;
-
// The wallpaper info is null for image wallpaper, also use the engine in this case.
- if (hasConnection && (info == null && isAodImageWallpaperEnabled()
- || info != null && info.supportsAmbientMode())) {
+ if (data != null && data.connection != null && (data.connection.mInfo == null
+ || data.connection.mInfo.supportsAmbientMode())) {
// TODO(multi-display) Extends this method with specific display.
engine = data.connection.getDisplayConnectorOrCreate(DEFAULT_DISPLAY).mEngine;
} else {
diff --git a/services/core/java/com/android/server/wm/ActivityStarter.java b/services/core/java/com/android/server/wm/ActivityStarter.java
index 95a6f71..d1cd1db 100644
--- a/services/core/java/com/android/server/wm/ActivityStarter.java
+++ b/services/core/java/com/android/server/wm/ActivityStarter.java
@@ -926,6 +926,10 @@
if (callerApp != null && callerApp.hasForegroundActivities()) {
return false;
}
+ // don't abort if the callerApp is instrumenting with background activity starts privileges
+ if (callerApp != null && callerApp.isInstrumentingWithBackgroundActivityStartPrivileges()) {
+ return false;
+ }
// don't abort if the callingUid is in the foreground or is a persistent system process
final int callingUidProcState = mService.getUidStateLocked(callingUid);
final boolean callingUidHasAnyVisibleWindow =
diff --git a/services/core/java/com/android/server/wm/ActivityTaskManagerService.java b/services/core/java/com/android/server/wm/ActivityTaskManagerService.java
index 5fabde4..09ef4b9 100644
--- a/services/core/java/com/android/server/wm/ActivityTaskManagerService.java
+++ b/services/core/java/com/android/server/wm/ActivityTaskManagerService.java
@@ -349,6 +349,14 @@
/* Global service lock used by the package the owns this service. */
final WindowManagerGlobalLock mGlobalLock = new WindowManagerGlobalLock();
+ /**
+ * It is the same instance as {@link mGlobalLock}, just declared as a type that the
+ * locked-region-code-injection does't recognize it. It is used to skip wrapping priority
+ * booster for places that are already in the scope of another booster (e.g. computing oom-adj).
+ *
+ * @see WindowManagerThreadPriorityBooster
+ */
+ final Object mGlobalLockWithoutBoost = mGlobalLock;
ActivityStackSupervisor mStackSupervisor;
RootActivityContainer mRootActivityContainer;
WindowManagerService mWindowManager;
@@ -6837,7 +6845,7 @@
@Override
public WindowProcessController getTopApp() {
- synchronized (mGlobalLock) {
+ synchronized (mGlobalLockWithoutBoost) {
final ActivityRecord top = mRootActivityContainer.getTopResumedActivity();
return top != null ? top.app : null;
}
@@ -6845,7 +6853,7 @@
@Override
public void rankTaskLayersIfNeeded() {
- synchronized (mGlobalLock) {
+ synchronized (mGlobalLockWithoutBoost) {
if (mRootActivityContainer != null) {
mRootActivityContainer.rankTaskLayersIfNeeded();
}
@@ -6889,28 +6897,28 @@
@Override
public void onUidActive(int uid, int procState) {
- synchronized (mGlobalLock) {
+ synchronized (mGlobalLockWithoutBoost) {
mActiveUids.put(uid, procState);
}
}
@Override
public void onUidInactive(int uid) {
- synchronized (mGlobalLock) {
+ synchronized (mGlobalLockWithoutBoost) {
mActiveUids.remove(uid);
}
}
@Override
public void onActiveUidsCleared() {
- synchronized (mGlobalLock) {
+ synchronized (mGlobalLockWithoutBoost) {
mActiveUids.clear();
}
}
@Override
public void onUidProcStateChanged(int uid, int procState) {
- synchronized (mGlobalLock) {
+ synchronized (mGlobalLockWithoutBoost) {
if (mActiveUids.get(uid) != null) {
mActiveUids.put(uid, procState);
}
@@ -6919,14 +6927,14 @@
@Override
public void onUidAddedToPendingTempWhitelist(int uid, String tag) {
- synchronized (mGlobalLock) {
+ synchronized (mGlobalLockWithoutBoost) {
mPendingTempWhitelist.put(uid, tag);
}
}
@Override
public void onUidRemovedFromPendingTempWhitelist(int uid) {
- synchronized (mGlobalLock) {
+ synchronized (mGlobalLockWithoutBoost) {
mPendingTempWhitelist.remove(uid);
}
}
diff --git a/services/core/java/com/android/server/wm/WindowProcessController.java b/services/core/java/com/android/server/wm/WindowProcessController.java
index 030cc05..8da39b6 100644
--- a/services/core/java/com/android/server/wm/WindowProcessController.java
+++ b/services/core/java/com/android/server/wm/WindowProcessController.java
@@ -138,6 +138,8 @@
private volatile boolean mDebugging;
// Active instrumentation running in process?
private volatile boolean mInstrumenting;
+ // Active instrumentation with background activity starts privilege running in process?
+ private volatile boolean mInstrumentingWithBackgroundActivityStartPrivileges;
// This process it perceptible by the user.
private volatile boolean mPerceptible;
// Set to true when process was launched with a wrapper attached
@@ -370,6 +372,23 @@
return mInstrumenting;
}
+ /**
+ * {@see isInstrumentingWithBackgroundActivityStartPrivileges}
+ */
+ public void setInstrumentingWithBackgroundActivityStartPrivileges(
+ boolean instrumentingWithBackgroundActivityStartPrivileges) {
+ mInstrumentingWithBackgroundActivityStartPrivileges =
+ instrumentingWithBackgroundActivityStartPrivileges;
+ }
+
+ /**
+ * @return true if the instrumentation was started by a holder of
+ * START_ACTIVITIES_FROM_BACKGROUND permission
+ */
+ boolean isInstrumentingWithBackgroundActivityStartPrivileges() {
+ return mInstrumentingWithBackgroundActivityStartPrivileges;
+ }
+
public void setPerceptible(boolean perceptible) {
mPerceptible = perceptible;
}
@@ -394,13 +413,13 @@
}
public void addPackage(String packageName) {
- synchronized (mAtm.mGlobalLock) {
+ synchronized (mAtm.mGlobalLockWithoutBoost) {
mPkgList.add(packageName);
}
}
public void clearPackageList() {
- synchronized (mAtm.mGlobalLock) {
+ synchronized (mAtm.mGlobalLockWithoutBoost) {
mPkgList.clear();
}
}
@@ -422,20 +441,18 @@
}
}
- public void clearActivities() {
- synchronized (mAtm.mGlobalLock) {
- mActivities.clear();
- }
+ void clearActivities() {
+ mActivities.clear();
}
public boolean hasActivities() {
- synchronized (mAtm.mGlobalLock) {
+ synchronized (mAtm.mGlobalLockWithoutBoost) {
return !mActivities.isEmpty();
}
}
public boolean hasVisibleActivities() {
- synchronized (mAtm.mGlobalLock) {
+ synchronized (mAtm.mGlobalLockWithoutBoost) {
for (int i = mActivities.size() - 1; i >= 0; --i) {
final ActivityRecord r = mActivities.get(i);
if (r.visible) {
@@ -447,7 +464,7 @@
}
public boolean hasActivitiesOrRecentTasks() {
- synchronized (mAtm.mGlobalLock) {
+ synchronized (mAtm.mGlobalLockWithoutBoost) {
return !mActivities.isEmpty() || !mRecentTasks.isEmpty();
}
}
@@ -462,15 +479,13 @@
}
}
- public void finishActivities() {
- synchronized (mAtm.mGlobalLock) {
- ArrayList<ActivityRecord> activities = new ArrayList<>(mActivities);
- for (int i = 0; i < activities.size(); i++) {
- final ActivityRecord r = activities.get(i);
- if (!r.finishing && r.isInStackLocked()) {
- r.getActivityStack().finishActivityLocked(r, Activity.RESULT_CANCELED,
- null, "finish-heavy", true);
- }
+ void finishActivities() {
+ ArrayList<ActivityRecord> activities = new ArrayList<>(mActivities);
+ for (int i = 0; i < activities.size(); i++) {
+ final ActivityRecord r = activities.get(i);
+ if (!r.finishing && r.isInStackLocked()) {
+ r.getActivityStack().finishActivityLocked(r, Activity.RESULT_CANCELED,
+ null, "finish-heavy", true);
}
}
}
@@ -531,15 +546,13 @@
}
- public void updateIntentForHeavyWeightActivity(Intent intent) {
- synchronized (mAtm.mGlobalLock) {
- if (mActivities.isEmpty()) {
- return;
- }
- ActivityRecord hist = mActivities.get(0);
- intent.putExtra(HeavyWeightSwitcherActivity.KEY_CUR_APP, hist.packageName);
- intent.putExtra(HeavyWeightSwitcherActivity.KEY_CUR_TASK, hist.getTaskRecord().taskId);
+ void updateIntentForHeavyWeightActivity(Intent intent) {
+ if (mActivities.isEmpty()) {
+ return;
}
+ ActivityRecord hist = mActivities.get(0);
+ intent.putExtra(HeavyWeightSwitcherActivity.KEY_CUR_APP, hist.packageName);
+ intent.putExtra(HeavyWeightSwitcherActivity.KEY_CUR_TASK, hist.getTaskRecord().taskId);
}
boolean shouldKillProcessForRemovedTask(TaskRecord tr) {
@@ -609,7 +622,7 @@
}
public int computeOomAdjFromActivities(int minTaskLayer, ComputeOomAdjCallback callback) {
- synchronized (mAtm.mGlobalLock) {
+ synchronized (mAtm.mGlobalLockWithoutBoost) {
final int activitiesSize = mActivities.size();
for (int j = 0; j < activitiesSize; j++) {
final ActivityRecord r = mActivities.get(j);
@@ -842,18 +855,16 @@
}
public boolean hasRecentTasks() {
- synchronized (mAtm.mGlobalLock) {
+ synchronized (mAtm.mGlobalLockWithoutBoost) {
return !mRecentTasks.isEmpty();
}
}
- public void clearRecentTasks() {
- synchronized (mAtm.mGlobalLock) {
- for (int i = mRecentTasks.size() - 1; i >= 0; i--) {
- mRecentTasks.get(i).clearRootProcess();
- }
- mRecentTasks.clear();
+ void clearRecentTasks() {
+ for (int i = mRecentTasks.size() - 1; i >= 0; i--) {
+ mRecentTasks.get(i).clearRootProcess();
}
+ mRecentTasks.clear();
}
public void appEarlyNotResponding(String annotation, Runnable killAppCallback) {
@@ -907,19 +918,19 @@
}
public void onTopProcChanged() {
- synchronized (mAtm.mGlobalLock) {
+ synchronized (mAtm.mGlobalLockWithoutBoost) {
mAtm.mVrController.onTopProcChangedLocked(this);
}
}
public boolean isHomeProcess() {
- synchronized (mAtm.mGlobalLock) {
+ synchronized (mAtm.mGlobalLockWithoutBoost) {
return this == mAtm.mHomeProcess;
}
}
public boolean isPreviousProcess() {
- synchronized (mAtm.mGlobalLock) {
+ synchronized (mAtm.mGlobalLockWithoutBoost) {
return this == mAtm.mPreviousProcess;
}
}
diff --git a/services/core/jni/com_android_server_security_VerityUtils.cpp b/services/core/jni/com_android_server_security_VerityUtils.cpp
index 0d888dc..988d75c 100644
--- a/services/core/jni/com_android_server_security_VerityUtils.cpp
+++ b/services/core/jni/com_android_server_security_VerityUtils.cpp
@@ -32,9 +32,67 @@
// TODO(112037636): Always include once fsverity.h is upstreamed.
#if __has_include(<linux/fsverity.h>)
#include <linux/fsverity.h>
-const int kSha256Bytes = 32;
+#else
+
+// Before fs-verity is upstreamed, use the current snapshot for development.
+// https://git.kernel.org/pub/scm/linux/kernel/git/ebiggers/linux.git/tree/include/uapi/linux/fsverity.h?h=fsverity
+
+#include <linux/limits.h>
+#include <linux/ioctl.h>
+#include <linux/types.h>
+
+struct fsverity_digest {
+ __u16 digest_algorithm;
+ __u16 digest_size; /* input/output */
+ __u8 digest[];
+};
+
+#define FS_IOC_ENABLE_VERITY _IO('f', 133)
+#define FS_IOC_MEASURE_VERITY _IOWR('f', 134, struct fsverity_digest)
+
+#define FS_VERITY_MAGIC "FSVerity"
+
+#define FS_VERITY_ALG_SHA256 1
+
+struct fsverity_descriptor {
+ __u8 magic[8]; /* must be FS_VERITY_MAGIC */
+ __u8 major_version; /* must be 1 */
+ __u8 minor_version; /* must be 0 */
+ __u8 log_data_blocksize;/* log2(data-bytes-per-hash), e.g. 12 for 4KB */
+ __u8 log_tree_blocksize;/* log2(tree-bytes-per-hash), e.g. 12 for 4KB */
+ __le16 data_algorithm; /* hash algorithm for data blocks */
+ __le16 tree_algorithm; /* hash algorithm for tree blocks */
+ __le32 flags; /* flags */
+ __le32 __reserved1; /* must be 0 */
+ __le64 orig_file_size; /* size of the original file data */
+ __le16 auth_ext_count; /* number of authenticated extensions */
+ __u8 __reserved2[30]; /* must be 0 */
+};
+
+#define FS_VERITY_EXT_ROOT_HASH 1
+#define FS_VERITY_EXT_PKCS7_SIGNATURE 3
+
+struct fsverity_extension {
+ __le32 length;
+ __le16 type; /* Type of this extension (see codes above) */
+ __le16 __reserved; /* Reserved, must be 0 */
+};
+
+struct fsverity_digest_disk {
+ __le16 digest_algorithm;
+ __le16 digest_size;
+ __u8 digest[];
+};
+
+struct fsverity_footer {
+ __le32 desc_reverse_offset; /* distance to fsverity_descriptor */
+ __u8 magic[8]; /* FS_VERITY_MAGIC */
+} __packed;
+
#endif
+const int kSha256Bytes = 32;
+
namespace android {
namespace {
@@ -73,7 +131,6 @@
};
int enableFsverity(JNIEnv* env, jobject /* clazz */, jstring filePath) {
-#if __has_include(<linux/fsverity.h>)
const char* path = env->GetStringUTFChars(filePath, nullptr);
::android::base::unique_fd rfd(open(path, O_RDONLY | O_CLOEXEC));
if (rfd.get() < 0) {
@@ -83,14 +140,9 @@
return errno;
}
return 0;
-#else
- LOG_ALWAYS_FATAL("fs-verity is used while not enabled");
- return ENOSYS;
-#endif
}
int measureFsverity(JNIEnv* env, jobject /* clazz */, jstring filePath) {
-#if __has_include(<linux/fsverity.h>)
auto raii = JavaByteArrayHolder::newArray(env, sizeof(fsverity_digest) + kSha256Bytes);
fsverity_digest* data = reinterpret_cast<fsverity_digest*>(raii->getRaw());
data->digest_size = kSha256Bytes; // the only input/output parameter
@@ -104,14 +156,9 @@
return errno;
}
return 0;
-#else
- LOG_ALWAYS_FATAL("fs-verity is used while not enabled");
- return ENOSYS;
-#endif
}
jbyteArray constructFsveritySignedData(JNIEnv* env, jobject /* clazz */, jbyteArray digest) {
-#if __has_include(<linux/fsverity.h>)
auto raii = JavaByteArrayHolder::newArray(env, sizeof(fsverity_digest_disk) + kSha256Bytes);
fsverity_digest_disk* data = reinterpret_cast<fsverity_digest_disk*>(raii->getRaw());
@@ -126,15 +173,10 @@
memcpy(data->digest, src, kSha256Bytes);
return raii->release();
-#else
- LOG_ALWAYS_FATAL("fs-verity is used while not enabled");
- return 0;
-#endif
}
jbyteArray constructFsverityDescriptor(JNIEnv* env, jobject /* clazz */, jlong fileSize) {
-#if __has_include(<linux/fsverity.h>)
auto raii = JavaByteArrayHolder::newArray(env, sizeof(fsverity_descriptor));
fsverity_descriptor* desc = reinterpret_cast<fsverity_descriptor*>(raii->getRaw());
@@ -150,15 +192,10 @@
desc->auth_ext_count = 1;
return raii->release();
-#else
- LOG_ALWAYS_FATAL("fs-verity is used while not enabled");
- return 0;
-#endif
}
jbyteArray constructFsverityExtension(JNIEnv* env, jobject /* clazz */, jshort extensionId,
jint extensionDataSize) {
-#if __has_include(<linux/fsverity.h>)
auto raii = JavaByteArrayHolder::newArray(env, sizeof(fsverity_extension));
fsverity_extension* ext = reinterpret_cast<fsverity_extension*>(raii->getRaw());
@@ -166,15 +203,10 @@
ext->type = extensionId;
return raii->release();
-#else
- LOG_ALWAYS_FATAL("fs-verity is used while not enabled");
- return 0;
-#endif
}
jbyteArray constructFsverityFooter(JNIEnv* env, jobject /* clazz */,
jint offsetToDescriptorHead) {
-#if __has_include(<linux/fsverity.h>)
auto raii = JavaByteArrayHolder::newArray(env, sizeof(fsverity_footer));
fsverity_footer* footer = reinterpret_cast<fsverity_footer*>(raii->getRaw());
@@ -182,10 +214,6 @@
memcpy(footer->magic, FS_VERITY_MAGIC, sizeof(footer->magic));
return raii->release();
-#else
- LOG_ALWAYS_FATAL("fs-verity is used while not enabled");
- return 0;
-#endif
}
const JNINativeMethod sMethods[] = {
diff --git a/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java b/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java
index a01a026..f176bc4 100644
--- a/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java
+++ b/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java
@@ -8364,16 +8364,22 @@
!= PackageManager.PERMISSION_GRANTED) {
return false;
}
- // Allow access to the device owner.
+
+ // Allow access to the device owner or delegate cert installer.
ComponentName deviceOwner = getDeviceOwnerComponent(true);
- if (deviceOwner != null && deviceOwner.getPackageName().equals(packageName)) {
+ if (deviceOwner != null && (deviceOwner.getPackageName().equals(packageName)
+ || isCallerDelegate(packageName, uid, DELEGATION_CERT_INSTALL))) {
return true;
}
- // Allow access to the profile owner for the specified user.
+ // Allow access to the profile owner for the specified user, or delegate cert installer
ComponentName profileOwner = getProfileOwnerAsUser(userHandle);
- if (profileOwner != null && profileOwner.getPackageName().equals(packageName)) {
+ if (profileOwner != null && (profileOwner.getPackageName().equals(packageName)
+ || isCallerDelegate(packageName, uid, DELEGATION_CERT_INSTALL))) {
return true;
}
+
+ Log.w(LOG_TAG, String.format("Package if %s (uid=%d, pid=%d) cannot access Device IDs",
+ packageName, uid, pid));
return false;
}
diff --git a/services/java/com/android/server/SystemServer.java b/services/java/com/android/server/SystemServer.java
index d030fa5..6733440 100644
--- a/services/java/com/android/server/SystemServer.java
+++ b/services/java/com/android/server/SystemServer.java
@@ -827,6 +827,7 @@
private void startOtherServices() {
final Context context = mSystemContext;
VibratorService vibrator = null;
+ DynamicAndroidService dynamicAndroid = null;
IStorageManager storageManager = null;
NetworkManagementService networkManagement = null;
IpSecService ipSecService = null;
@@ -945,6 +946,11 @@
ServiceManager.addService("vibrator", vibrator);
traceEnd();
+ traceBeginAndSlog("StartDynamicAndroidService");
+ dynamicAndroid = new DynamicAndroidService(context);
+ ServiceManager.addService("dynamic_android", dynamicAndroid);
+ traceEnd();
+
if (!isWatch) {
traceBeginAndSlog("StartConsumerIrService");
consumerIr = new ConsumerIrService(context);
diff --git a/services/tests/mockingservicestests/src/com/android/server/power/batterysaver/BatterySaverStateMachineTest.java b/services/tests/mockingservicestests/src/com/android/server/power/batterysaver/BatterySaverStateMachineTest.java
index 5009d64..86e8598 100644
--- a/services/tests/mockingservicestests/src/com/android/server/power/batterysaver/BatterySaverStateMachineTest.java
+++ b/services/tests/mockingservicestests/src/com/android/server/power/batterysaver/BatterySaverStateMachineTest.java
@@ -16,6 +16,7 @@
package com.android.server.power.batterysaver;
import static org.junit.Assert.assertEquals;
+import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyBoolean;
import static org.mockito.ArgumentMatchers.anyInt;
import static org.mockito.Mockito.doAnswer;
@@ -178,8 +179,12 @@
.getSystemService(NotificationManager.class);
doAnswer((inv) -> mDevice.batterySaverEnabled = inv.getArgument(0))
.when(mMockBatterySaverController).enableBatterySaver(anyBoolean(), anyInt());
+ doReturn(true).when(mMockBatterySaverController)
+ .setAdaptivePolicyLocked(any(BatterySaverPolicy.Policy.class), anyInt());
when(mMockBatterySaverController.isEnabled())
.thenAnswer((inv) -> mDevice.batterySaverEnabled);
+ when(mMockBatterySaverController.isFullEnabled())
+ .thenAnswer((inv) -> mDevice.batterySaverEnabled);
when(mMockResources.getBoolean(
com.android.internal.R.bool.config_batterySaverStickyBehaviourDisabled))
.thenReturn(false);
diff --git a/services/tests/servicestests/src/com/android/server/DynamicAndroidServiceTest.java b/services/tests/servicestests/src/com/android/server/DynamicAndroidServiceTest.java
new file mode 100644
index 0000000..1494284
--- /dev/null
+++ b/services/tests/servicestests/src/com/android/server/DynamicAndroidServiceTest.java
@@ -0,0 +1,47 @@
+/*
+ * Copyright (C) 2019 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.server;
+
+import android.os.IDynamicAndroidService;
+import android.os.ServiceManager;
+import android.test.AndroidTestCase;
+import android.test.suitebuilder.annotation.LargeTest;
+
+public class DynamicAndroidServiceTest extends AndroidTestCase {
+ private static final String TAG = "DynamicAndroidServiceTests";
+ private IDynamicAndroidService mService;
+
+ @Override
+ protected void setUp() throws Exception {
+ mService =
+ IDynamicAndroidService.Stub.asInterface(
+ ServiceManager.getService("dynamic_android"));
+ }
+
+ @LargeTest
+ public void test1() {
+ assertTrue("dynamic_android service available", mService != null);
+ try {
+ mService.startInstallation(1 << 20, 8 << 30);
+ fail("DynamicAndroidService did not throw SecurityException as expected");
+ } catch (SecurityException e) {
+ // expected
+ } catch (Exception e) {
+ fail(e.toString());
+ }
+ }
+}
diff --git a/services/tests/servicestests/src/com/android/server/am/ActivityManagerInternalTest.java b/services/tests/servicestests/src/com/android/server/am/ActivityManagerInternalTest.java
index 00a60b9..5dafe07 100644
--- a/services/tests/servicestests/src/com/android/server/am/ActivityManagerInternalTest.java
+++ b/services/tests/servicestests/src/com/android/server/am/ActivityManagerInternalTest.java
@@ -122,7 +122,7 @@
private UidRecord addActiveUidRecord(int uid, long curProcStateSeq,
long lastNetworkUpdatedProcStateSeq) {
- final UidRecord record = new UidRecord(uid, null /* atmInternal */);
+ final UidRecord record = new UidRecord(uid);
record.lastNetworkUpdatedProcStateSeq = lastNetworkUpdatedProcStateSeq;
record.curProcStateSeq = curProcStateSeq;
record.waitingForNetwork = true;
diff --git a/services/tests/servicestests/src/com/android/server/am/ActivityManagerServiceTest.java b/services/tests/servicestests/src/com/android/server/am/ActivityManagerServiceTest.java
index 419c736..4e21fd0c 100644
--- a/services/tests/servicestests/src/com/android/server/am/ActivityManagerServiceTest.java
+++ b/services/tests/servicestests/src/com/android/server/am/ActivityManagerServiceTest.java
@@ -250,7 +250,7 @@
}
private UidRecord addUidRecord(int uid) {
- final UidRecord uidRec = new UidRecord(uid, null /* atmInternal */);
+ final UidRecord uidRec = new UidRecord(uid);
uidRec.waitingForNetwork = true;
uidRec.hasInternetPermission = true;
mAms.mProcessList.mActiveUids.put(uid, uidRec);
@@ -405,7 +405,7 @@
@Test
public void testBlockStateForUid() {
- final UidRecord uidRec = new UidRecord(TEST_UID, null /* atmInternal */);
+ final UidRecord uidRec = new UidRecord(TEST_UID);
int expectedBlockState;
final String errorTemplate = "Block state should be %s, prevState: %s, curState: %s";
@@ -732,7 +732,7 @@
@Test
public void testEnqueueUidChangeLocked_procStateSeqUpdated() {
- final UidRecord uidRecord = new UidRecord(TEST_UID, null /* atmInternal */);
+ final UidRecord uidRecord = new UidRecord(TEST_UID);
uidRecord.curProcStateSeq = TEST_PROC_STATE_SEQ1;
// Verify with no pending changes for TEST_UID.
@@ -778,7 +778,7 @@
@MediumTest
@Test
public void testEnqueueUidChangeLocked_dispatchUidsChanged() {
- final UidRecord uidRecord = new UidRecord(TEST_UID, null /* atmInternal */);
+ final UidRecord uidRecord = new UidRecord(TEST_UID);
final int expectedProcState = PROCESS_STATE_SERVICE;
uidRecord.setProcState = expectedProcState;
uidRecord.curProcStateSeq = TEST_PROC_STATE_SEQ1;
@@ -850,7 +850,7 @@
private void verifyWaitingForNetworkStateUpdate(long curProcStateSeq,
long lastDispatchedProcStateSeq, long lastNetworkUpdatedProcStateSeq,
final long procStateSeqToWait, boolean expectWait) throws Exception {
- final UidRecord record = new UidRecord(Process.myUid(), null /* atmInternal */);
+ final UidRecord record = new UidRecord(Process.myUid());
record.curProcStateSeq = curProcStateSeq;
record.lastDispatchedProcStateSeq = lastDispatchedProcStateSeq;
record.lastNetworkUpdatedProcStateSeq = lastNetworkUpdatedProcStateSeq;
diff --git a/services/tests/servicestests/src/com/android/server/am/AppCompactorTest.java b/services/tests/servicestests/src/com/android/server/am/AppCompactorTest.java
index 1a231cf..2f8e545 100644
--- a/services/tests/servicestests/src/com/android/server/am/AppCompactorTest.java
+++ b/services/tests/servicestests/src/com/android/server/am/AppCompactorTest.java
@@ -18,6 +18,7 @@
import static android.provider.DeviceConfig.ActivityManager.KEY_COMPACT_ACTION_1;
import static android.provider.DeviceConfig.ActivityManager.KEY_COMPACT_ACTION_2;
+import static android.provider.DeviceConfig.ActivityManager.KEY_COMPACT_STATSD_SAMPLE_RATE;
import static android.provider.DeviceConfig.ActivityManager.KEY_COMPACT_THROTTLE_1;
import static android.provider.DeviceConfig.ActivityManager.KEY_COMPACT_THROTTLE_2;
import static android.provider.DeviceConfig.ActivityManager.KEY_COMPACT_THROTTLE_3;
@@ -61,6 +62,9 @@
@RunWith(AndroidJUnit4.class)
public final class AppCompactorTest {
+ private static final String CLEAR_DEVICE_CONFIG_KEY_CMD =
+ "device_config delete activity_manager";
+
@Mock private AppOpsService mAppOpsService;
private AppCompactor mCompactorUnderTest;
private HandlerThread mHandlerThread;
@@ -70,19 +74,21 @@
private static void clearDeviceConfig() throws IOException {
UiDevice uiDevice = UiDevice.getInstance(InstrumentationRegistry.getInstrumentation());
uiDevice.executeShellCommand(
- "device_config delete activity_manager " + KEY_USE_COMPACTION);
+ CLEAR_DEVICE_CONFIG_KEY_CMD + " " + KEY_USE_COMPACTION);
uiDevice.executeShellCommand(
- "device_config delete activity_manager " + KEY_COMPACT_ACTION_1);
+ CLEAR_DEVICE_CONFIG_KEY_CMD + " " + KEY_COMPACT_ACTION_1);
uiDevice.executeShellCommand(
- "device_config delete activity_manager " + KEY_COMPACT_ACTION_2);
+ CLEAR_DEVICE_CONFIG_KEY_CMD + " " + KEY_COMPACT_ACTION_2);
uiDevice.executeShellCommand(
- "device_config delete activity_manager " + KEY_COMPACT_THROTTLE_1);
+ CLEAR_DEVICE_CONFIG_KEY_CMD + " " + KEY_COMPACT_THROTTLE_1);
uiDevice.executeShellCommand(
- "device_config delete activity_manager " + KEY_COMPACT_THROTTLE_2);
+ CLEAR_DEVICE_CONFIG_KEY_CMD + " " + KEY_COMPACT_THROTTLE_2);
uiDevice.executeShellCommand(
- "device_config delete activity_manager " + KEY_COMPACT_THROTTLE_3);
+ CLEAR_DEVICE_CONFIG_KEY_CMD + " " + KEY_COMPACT_THROTTLE_3);
uiDevice.executeShellCommand(
- "device_config delete activity_manager " + KEY_COMPACT_THROTTLE_4);
+ CLEAR_DEVICE_CONFIG_KEY_CMD + " " + KEY_COMPACT_THROTTLE_4);
+ uiDevice.executeShellCommand(
+ CLEAR_DEVICE_CONFIG_KEY_CMD + " " + KEY_COMPACT_STATSD_SAMPLE_RATE);
}
@Before
@@ -128,6 +134,8 @@
is(AppCompactor.DEFAULT_COMPACT_THROTTLE_3));
assertThat(mCompactorUnderTest.mCompactThrottleFullFull,
is(AppCompactor.DEFAULT_COMPACT_THROTTLE_4));
+ assertThat(mCompactorUnderTest.mStatsdSampleRate,
+ is(AppCompactor.DEFAULT_STATSD_SAMPLE_RATE));
}
@Test
@@ -155,6 +163,9 @@
DeviceConfig.setProperty(DeviceConfig.ActivityManager.NAMESPACE,
KEY_COMPACT_THROTTLE_4,
Long.toString(AppCompactor.DEFAULT_COMPACT_THROTTLE_4 + 1), false);
+ DeviceConfig.setProperty(DeviceConfig.ActivityManager.NAMESPACE,
+ KEY_COMPACT_STATSD_SAMPLE_RATE,
+ Float.toString(AppCompactor.DEFAULT_STATSD_SAMPLE_RATE + 0.1f), false);
// Then calling init will read and set that flag.
mCompactorUnderTest.init();
@@ -173,6 +184,8 @@
is(AppCompactor.DEFAULT_COMPACT_THROTTLE_3 + 1));
assertThat(mCompactorUnderTest.mCompactThrottleFullFull,
is(AppCompactor.DEFAULT_COMPACT_THROTTLE_4 + 1));
+ assertThat(mCompactorUnderTest.mStatsdSampleRate,
+ is(AppCompactor.DEFAULT_STATSD_SAMPLE_RATE + 0.1f));
}
@Test
@@ -365,6 +378,63 @@
is(AppCompactor.DEFAULT_COMPACT_THROTTLE_4));
}
+ @Test
+ public void statsdSampleRate_listensToDeviceConfigChanges() throws InterruptedException {
+ mCompactorUnderTest.init();
+
+ // When we override mStatsdSampleRate with a reasonable values ...
+ mCountDown = new CountDownLatch(1);
+ DeviceConfig.setProperty(DeviceConfig.ActivityManager.NAMESPACE,
+ KEY_COMPACT_STATSD_SAMPLE_RATE,
+ Float.toString(AppCompactor.DEFAULT_STATSD_SAMPLE_RATE + 0.1f), false);
+ assertThat(mCountDown.await(5, TimeUnit.SECONDS), is(true));
+
+ // Then that override is reflected in the compactor.
+ assertThat(mCompactorUnderTest.mStatsdSampleRate,
+ is(AppCompactor.DEFAULT_STATSD_SAMPLE_RATE + 0.1f));
+ }
+
+ @Test
+ public void statsdSanokeRate_listensToDeviceConfigChangesBadValues()
+ throws InterruptedException {
+ mCompactorUnderTest.init();
+
+ // When we override mStatsdSampleRate with a reasonable values ...
+ mCountDown = new CountDownLatch(1);
+ DeviceConfig.setProperty(DeviceConfig.ActivityManager.NAMESPACE,
+ KEY_COMPACT_STATSD_SAMPLE_RATE, "foo", false);
+ assertThat(mCountDown.await(5, TimeUnit.SECONDS), is(true));
+
+ // Then that override is reflected in the compactor.
+ assertThat(mCompactorUnderTest.mStatsdSampleRate,
+ is(AppCompactor.DEFAULT_STATSD_SAMPLE_RATE));
+ }
+
+ @Test
+ public void statsdSanokeRate_listensToDeviceConfigChangesOutOfRangeValues()
+ throws InterruptedException {
+ mCompactorUnderTest.init();
+
+ // When we override mStatsdSampleRate with an value outside of [0..1]...
+ mCountDown = new CountDownLatch(1);
+ DeviceConfig.setProperty(DeviceConfig.ActivityManager.NAMESPACE,
+ KEY_COMPACT_STATSD_SAMPLE_RATE,
+ Float.toString(-1.0f), false);
+ assertThat(mCountDown.await(5, TimeUnit.SECONDS), is(true));
+
+ // Then the values is capped in the range.
+ assertThat(mCompactorUnderTest.mStatsdSampleRate, is(0.0f));
+
+ mCountDown = new CountDownLatch(1);
+ DeviceConfig.setProperty(DeviceConfig.ActivityManager.NAMESPACE,
+ KEY_COMPACT_STATSD_SAMPLE_RATE,
+ Float.toString(1.01f), false);
+ assertThat(mCountDown.await(5, TimeUnit.SECONDS), is(true));
+
+ // Then the values is capped in the range.
+ assertThat(mCompactorUnderTest.mStatsdSampleRate, is(1.0f));
+ }
+
private class TestInjector extends Injector {
@Override
public AppOpsService getAppOpsService(File file, Handler handler) {
diff --git a/services/tests/servicestests/src/com/android/server/power/PowerManagerServiceTest.java b/services/tests/servicestests/src/com/android/server/power/PowerManagerServiceTest.java
index 0dff03f..bfa0b74 100644
--- a/services/tests/servicestests/src/com/android/server/power/PowerManagerServiceTest.java
+++ b/services/tests/servicestests/src/com/android/server/power/PowerManagerServiceTest.java
@@ -21,7 +21,6 @@
import static com.google.common.truth.Truth.assertThat;
-import static org.mockito.ArgumentMatchers.anyBoolean;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
@@ -86,7 +85,7 @@
.setBrightnessFactor(BRIGHTNESS_FACTOR)
.build();
when(mBatterySaverPolicyMock.getBatterySaverPolicy(
- eq(PowerManager.ServiceType.SCREEN_BRIGHTNESS), anyBoolean()))
+ eq(PowerManager.ServiceType.SCREEN_BRIGHTNESS)))
.thenReturn(mPowerSaveState);
mDisplayPowerRequest = new DisplayPowerRequest();
diff --git a/services/tests/servicestests/src/com/android/server/power/batterysaver/BatterySaverPolicyTest.java b/services/tests/servicestests/src/com/android/server/power/batterysaver/BatterySaverPolicyTest.java
index 73eefcf..9cc2b10 100644
--- a/services/tests/servicestests/src/com/android/server/power/batterysaver/BatterySaverPolicyTest.java
+++ b/services/tests/servicestests/src/com/android/server/power/batterysaver/BatterySaverPolicyTest.java
@@ -15,6 +15,10 @@
*/
package com.android.server.power.batterysaver;
+import static com.android.server.power.batterysaver.BatterySaverPolicy.POLICY_LEVEL_ADAPTIVE;
+import static com.android.server.power.batterysaver.BatterySaverPolicy.POLICY_LEVEL_FULL;
+import static com.android.server.power.batterysaver.BatterySaverPolicy.POLICY_LEVEL_OFF;
+
import static com.google.common.truth.Truth.assertThat;
import static org.mockito.Mockito.mock;
@@ -31,6 +35,7 @@
import com.android.frameworks.servicestests.R;
import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.logging.MetricsLogger;
+import com.android.server.power.batterysaver.BatterySaverPolicy.Policy;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
@@ -39,15 +44,15 @@
* Tests for {@link com.android.server.power.batterysaver.BatterySaverPolicy}
*/
public class BatterySaverPolicyTest extends AndroidTestCase {
- private static final boolean BATTERY_SAVER_ON = true;
- private static final boolean BATTERY_SAVER_OFF = false;
+ private static final int MAX_SERVICE_TYPE = 15;
private static final float BRIGHTNESS_FACTOR = 0.7f;
private static final float DEFAULT_BRIGHTNESS_FACTOR = 0.5f;
private static final float PRECISION = 0.001f;
- private static final int GPS_MODE = 0;
+ private static final int GPS_MODE = 0; // LOCATION_MODE_NO_CHANGE
private static final int DEFAULT_GPS_MODE =
PowerManager.LOCATION_MODE_ALL_DISABLED_WHEN_SCREEN_OFF;
private static final String BATTERY_SAVER_CONSTANTS = "vibration_disabled=true,"
+ + "advertise_is_enabled=true,"
+ "animation_disabled=false,"
+ "soundtrigger_disabled=true,"
+ "firewall_disabled=false,"
@@ -56,7 +61,7 @@
+ "adjust_brightness_factor=0.7,"
+ "fullbackup_deferred=true,"
+ "keyvaluebackup_deferred=false,"
- + "gps_mode=0,"
+ + "gps_mode=0," // LOCATION_MODE_NO_CHANGE
+ "quick_doze_enabled=true";
private static final String BATTERY_SAVER_INCORRECT_CONSTANTS = "vi*,!=,,true";
@@ -97,6 +102,8 @@
mBatterySaverPolicy = new BatterySaverPolicyForTest(lock, getContext(),
new BatterySavingStats(lock, mMetricsLogger));
mBatterySaverPolicy.systemReady();
+
+ mBatterySaverPolicy.setPolicyLevel(POLICY_LEVEL_FULL);
}
@SmallTest
@@ -148,12 +155,14 @@
@SmallTest
public void testGetBatterySaverPolicy_PolicyDataSaver_DefaultValueCorrect() {
mBatterySaverPolicy.updateConstantsLocked("", "");
+ mBatterySaverPolicy.setPolicyLevel(POLICY_LEVEL_FULL);
final PowerSaveState batterySaverStateOn =
- mBatterySaverPolicy.getBatterySaverPolicy(ServiceType.DATA_SAVER, BATTERY_SAVER_ON);
+ mBatterySaverPolicy.getBatterySaverPolicy(ServiceType.DATA_SAVER);
assertThat(batterySaverStateOn.batterySaverEnabled).isFalse();
+ mBatterySaverPolicy.setPolicyLevel(POLICY_LEVEL_OFF);
final PowerSaveState batterySaverStateOff = mBatterySaverPolicy.getBatterySaverPolicy(
- ServiceType.DATA_SAVER, BATTERY_SAVER_OFF);
+ ServiceType.DATA_SAVER);
assertThat(batterySaverStateOff.batterySaverEnabled).isFalse();
}
@@ -166,8 +175,9 @@
public void testGetBatterySaverPolicy_PolicyGps_DefaultValueCorrect() {
testServiceDefaultValue_On(ServiceType.GPS);
+ mBatterySaverPolicy.setPolicyLevel(POLICY_LEVEL_FULL);
PowerSaveState stateOn =
- mBatterySaverPolicy.getBatterySaverPolicy(ServiceType.GPS, true);
+ mBatterySaverPolicy.getBatterySaverPolicy(ServiceType.GPS);
assertThat(stateOn.gpsMode).isEqualTo(DEFAULT_GPS_MODE);
}
@@ -180,47 +190,51 @@
public void testUpdateConstants_getCorrectData() {
mBatterySaverPolicy.updateConstantsLocked(BATTERY_SAVER_CONSTANTS, "");
+ mBatterySaverPolicy.setPolicyLevel(POLICY_LEVEL_FULL);
+ verifyBatterySaverConstantsUpdated();
+ }
+
+ private void verifyBatterySaverConstantsUpdated() {
final PowerSaveState vibrationState =
- mBatterySaverPolicy.getBatterySaverPolicy(ServiceType.VIBRATION, BATTERY_SAVER_ON);
+ mBatterySaverPolicy.getBatterySaverPolicy(ServiceType.VIBRATION);
assertThat(vibrationState.batterySaverEnabled).isTrue();
final PowerSaveState animationState =
- mBatterySaverPolicy.getBatterySaverPolicy(ServiceType.ANIMATION, BATTERY_SAVER_ON);
+ mBatterySaverPolicy.getBatterySaverPolicy(ServiceType.ANIMATION);
assertThat(animationState.batterySaverEnabled).isFalse();
final PowerSaveState soundState =
- mBatterySaverPolicy.getBatterySaverPolicy(ServiceType.SOUND, BATTERY_SAVER_ON);
+ mBatterySaverPolicy.getBatterySaverPolicy(ServiceType.SOUND);
assertThat(soundState.batterySaverEnabled).isTrue();
final PowerSaveState networkState = mBatterySaverPolicy.getBatterySaverPolicy(
- ServiceType.NETWORK_FIREWALL, BATTERY_SAVER_ON);
+ ServiceType.NETWORK_FIREWALL);
assertThat(networkState.batterySaverEnabled).isTrue();
final PowerSaveState screenState =
- mBatterySaverPolicy.getBatterySaverPolicy(ServiceType.SCREEN_BRIGHTNESS,
- BATTERY_SAVER_ON);
+ mBatterySaverPolicy.getBatterySaverPolicy(ServiceType.SCREEN_BRIGHTNESS);
assertThat(screenState.batterySaverEnabled).isFalse();
assertThat(screenState.brightnessFactor).isWithin(PRECISION).of(BRIGHTNESS_FACTOR);
final PowerSaveState fullBackupState = mBatterySaverPolicy.getBatterySaverPolicy(
- ServiceType.FULL_BACKUP, BATTERY_SAVER_ON);
+ ServiceType.FULL_BACKUP);
assertThat(fullBackupState.batterySaverEnabled).isTrue();
final PowerSaveState keyValueBackupState = mBatterySaverPolicy.getBatterySaverPolicy(
- ServiceType.KEYVALUE_BACKUP, BATTERY_SAVER_ON);
+ ServiceType.KEYVALUE_BACKUP);
assertThat(keyValueBackupState.batterySaverEnabled).isFalse();
final PowerSaveState dataSaverState = mBatterySaverPolicy.getBatterySaverPolicy(
- ServiceType.DATA_SAVER, BATTERY_SAVER_ON);
+ ServiceType.DATA_SAVER);
assertThat(dataSaverState.batterySaverEnabled).isTrue();
final PowerSaveState gpsState =
- mBatterySaverPolicy.getBatterySaverPolicy(ServiceType.GPS, BATTERY_SAVER_ON);
+ mBatterySaverPolicy.getBatterySaverPolicy(ServiceType.GPS);
assertThat(gpsState.batterySaverEnabled).isTrue();
assertThat(gpsState.gpsMode).isEqualTo(GPS_MODE);
final PowerSaveState quickDozeState = mBatterySaverPolicy.getBatterySaverPolicy(
- ServiceType.QUICK_DOZE, BATTERY_SAVER_ON);
+ ServiceType.QUICK_DOZE);
assertThat(quickDozeState.batterySaverEnabled).isTrue();
}
@@ -233,23 +247,27 @@
private void testServiceDefaultValue_On(@ServiceType int type) {
mBatterySaverPolicy.updateConstantsLocked("", "");
+ mBatterySaverPolicy.setPolicyLevel(POLICY_LEVEL_FULL);
final PowerSaveState batterySaverStateOn =
- mBatterySaverPolicy.getBatterySaverPolicy(type, BATTERY_SAVER_ON);
+ mBatterySaverPolicy.getBatterySaverPolicy(type);
assertThat(batterySaverStateOn.batterySaverEnabled).isTrue();
+ mBatterySaverPolicy.setPolicyLevel(POLICY_LEVEL_OFF);
final PowerSaveState batterySaverStateOff =
- mBatterySaverPolicy.getBatterySaverPolicy(type, BATTERY_SAVER_OFF);
+ mBatterySaverPolicy.getBatterySaverPolicy(type);
assertThat(batterySaverStateOff.batterySaverEnabled).isFalse();
}
private void testServiceDefaultValue_Off(@ServiceType int type) {
mBatterySaverPolicy.updateConstantsLocked("", "");
+ mBatterySaverPolicy.setPolicyLevel(POLICY_LEVEL_FULL);
final PowerSaveState batterySaverStateOn =
- mBatterySaverPolicy.getBatterySaverPolicy(type, BATTERY_SAVER_ON);
+ mBatterySaverPolicy.getBatterySaverPolicy(type);
assertThat(batterySaverStateOn.batterySaverEnabled).isFalse();
+ mBatterySaverPolicy.setPolicyLevel(POLICY_LEVEL_OFF);
final PowerSaveState batterySaverStateOff =
- mBatterySaverPolicy.getBatterySaverPolicy(type, BATTERY_SAVER_OFF);
+ mBatterySaverPolicy.getBatterySaverPolicy(type);
assertThat(batterySaverStateOff.batterySaverEnabled).isFalse();
}
@@ -291,4 +309,26 @@
+ "/sys/devices/system/cpu/cpu5/cpufreq/scaling_max_freq=15}");
assertThat(mBatterySaverPolicy.getFileValues(false).toString()).isEqualTo("{}");
}
+
+ public void testSetPolicyLevel_Off() {
+ mBatterySaverPolicy.setPolicyLevel(POLICY_LEVEL_OFF);
+
+ // +1 to make sure the default value is off as well.
+ for (int i = 0; i < MAX_SERVICE_TYPE + 1; ++i) {
+ assertThat(mBatterySaverPolicy.getBatterySaverPolicy(i).batterySaverEnabled).isFalse();
+ }
+ }
+
+ public void testSetPolicyLevel_Adaptive() {
+ mBatterySaverPolicy.setPolicyLevel(POLICY_LEVEL_ADAPTIVE);
+
+ mBatterySaverPolicy.setAdaptivePolicyLocked(BatterySaverPolicy.OFF_POLICY);
+ for (int i = 0; i < MAX_SERVICE_TYPE + 1; ++i) {
+ assertThat(mBatterySaverPolicy.getBatterySaverPolicy(i).batterySaverEnabled).isFalse();
+ }
+
+ mBatterySaverPolicy.setAdaptivePolicyLocked(
+ Policy.fromSettings(BATTERY_SAVER_CONSTANTS, ""));
+ verifyBatterySaverConstantsUpdated();
+ }
}
diff --git a/services/tests/wmtests/src/com/android/server/wm/ActivityStarterTests.java b/services/tests/wmtests/src/com/android/server/wm/ActivityStarterTests.java
index ace965b..62ec838 100644
--- a/services/tests/wmtests/src/com/android/server/wm/ActivityStarterTests.java
+++ b/services/tests/wmtests/src/com/android/server/wm/ActivityStarterTests.java
@@ -561,7 +561,7 @@
runAndVerifyBackgroundActivityStartsSubtest("allowed_noStartsAborted", false,
UNIMPORTANT_UID, false, PROCESS_STATE_TOP + 1,
UNIMPORTANT_UID2, false, PROCESS_STATE_TOP + 1,
- false, false, false);
+ false, false, false, false);
}
/**
@@ -576,7 +576,7 @@
"disallowed_unsupportedUsecase_aborted", true,
UNIMPORTANT_UID, false, PROCESS_STATE_TOP + 1,
UNIMPORTANT_UID2, false, PROCESS_STATE_TOP + 1,
- false, false, false);
+ false, false, false, false);
}
/**
@@ -591,57 +591,64 @@
runAndVerifyBackgroundActivityStartsSubtest("disallowed_rootUid_notAborted", false,
Process.ROOT_UID, false, PROCESS_STATE_TOP + 1,
UNIMPORTANT_UID2, false, PROCESS_STATE_TOP + 1,
- false, false, false);
+ false, false, false, false);
runAndVerifyBackgroundActivityStartsSubtest("disallowed_systemUid_notAborted", false,
Process.SYSTEM_UID, false, PROCESS_STATE_TOP + 1,
UNIMPORTANT_UID2, false, PROCESS_STATE_TOP + 1,
- false, false, false);
+ false, false, false, false);
runAndVerifyBackgroundActivityStartsSubtest("disallowed_nfcUid_notAborted", false,
Process.NFC_UID, false, PROCESS_STATE_TOP + 1,
UNIMPORTANT_UID2, false, PROCESS_STATE_TOP + 1,
- false, false, false);
+ false, false, false, false);
runAndVerifyBackgroundActivityStartsSubtest(
"disallowed_callingUidHasVisibleWindow_notAborted", false,
UNIMPORTANT_UID, true, PROCESS_STATE_TOP + 1,
UNIMPORTANT_UID2, false, PROCESS_STATE_TOP + 1,
- false, false, false);
+ false, false, false, false);
runAndVerifyBackgroundActivityStartsSubtest(
"disallowed_callingUidProcessStateTop_notAborted", false,
UNIMPORTANT_UID, false, PROCESS_STATE_TOP,
UNIMPORTANT_UID2, false, PROCESS_STATE_TOP + 1,
- false, false, false);
+ false, false, false, false);
runAndVerifyBackgroundActivityStartsSubtest(
"disallowed_realCallingUidHasVisibleWindow_notAborted", false,
UNIMPORTANT_UID, false, PROCESS_STATE_TOP + 1,
UNIMPORTANT_UID2, true, PROCESS_STATE_TOP + 1,
- false, false, false);
+ false, false, false, false);
runAndVerifyBackgroundActivityStartsSubtest(
"disallowed_realCallingUidProcessStateTop_notAborted", false,
UNIMPORTANT_UID, false, PROCESS_STATE_TOP + 1,
UNIMPORTANT_UID2, false, PROCESS_STATE_TOP,
- false, false, false);
+ false, false, false, false);
runAndVerifyBackgroundActivityStartsSubtest(
"disallowed_hasForegroundActivities_notAborted", false,
UNIMPORTANT_UID, false, PROCESS_STATE_TOP + 1,
UNIMPORTANT_UID2, false, PROCESS_STATE_TOP + 1,
- true, false, false);
+ true, false, false, false);
runAndVerifyBackgroundActivityStartsSubtest(
"disallowed_callerIsRecents_notAborted", false,
UNIMPORTANT_UID, false, PROCESS_STATE_TOP + 1,
UNIMPORTANT_UID2, false, PROCESS_STATE_TOP + 1,
- false, true, false);
+ false, true, false, false);
runAndVerifyBackgroundActivityStartsSubtest(
"disallowed_callerIsWhitelisted_notAborted", false,
UNIMPORTANT_UID, false, PROCESS_STATE_TOP + 1,
UNIMPORTANT_UID2, false, PROCESS_STATE_TOP + 1,
- false, false, true);
+ false, false, true, false);
+ runAndVerifyBackgroundActivityStartsSubtest(
+ "disallowed_callerIsInstrumentingWithBackgroundActivityStartPrivileges_notAborted",
+ false,
+ UNIMPORTANT_UID, false, PROCESS_STATE_TOP + 1,
+ UNIMPORTANT_UID2, false, PROCESS_STATE_TOP + 1,
+ false, false, false, true);
}
private void runAndVerifyBackgroundActivityStartsSubtest(String name, boolean shouldHaveAborted,
int callingUid, boolean callingUidHasVisibleWindow, int callingUidProcState,
int realCallingUid, boolean realCallingUidHasVisibleWindow, int realCallingUidProcState,
boolean hasForegroundActivities, boolean callerIsRecents,
- boolean callerIsTempWhitelisted) {
+ boolean callerIsTempWhitelisted,
+ boolean callerIsInstrumentingWithBackgroundActivityStartPrivileges) {
// window visibility
doReturn(callingUidHasVisibleWindow).when(mService.mWindowManager.mRoot)
.isAnyNonToastWindowVisibleForUid(callingUid);
@@ -664,6 +671,9 @@
doReturn(callerIsRecents).when(recentTasks).isCallerRecents(callingUid);
// caller is temp whitelisted
callerApp.setAllowBackgroundActivityStarts(callerIsTempWhitelisted);
+ // caller is instrumenting with background activity starts privileges
+ callerApp.setInstrumentingWithBackgroundActivityStartPrivileges(
+ callerIsInstrumentingWithBackgroundActivityStartPrivileges);
final ActivityOptions options = spy(ActivityOptions.makeBasic());
ActivityStarter starter = prepareStarter(FLAG_ACTIVITY_NEW_TASK)
diff --git a/startop/iorap/src/com/google/android/startop/iorap/IorapForwardingService.java b/startop/iorap/src/com/google/android/startop/iorap/IorapForwardingService.java
index 9a30b35..22fc159 100644
--- a/startop/iorap/src/com/google/android/startop/iorap/IorapForwardingService.java
+++ b/startop/iorap/src/com/google/android/startop/iorap/IorapForwardingService.java
@@ -50,8 +50,8 @@
public static final String TAG = "IorapForwardingService";
/** $> adb shell 'setprop log.tag.IorapdForwardingService VERBOSE' */
public static final boolean DEBUG = Log.isLoggable(TAG, Log.DEBUG);
- /** $> adb shell 'setprop iorapd.enable true' */
- private static boolean IS_ENABLED = SystemProperties.getBoolean("iorapd.enable", true);
+ /** $> adb shell 'setprop ro.iorapd.enable true' */
+ private static boolean IS_ENABLED = SystemProperties.getBoolean("ro.iorapd.enable", true);
/** $> adb shell 'setprop iorapd.forwarding_service.wtf_crash true' */
private static boolean WTF_CRASH = SystemProperties.getBoolean(
"iorapd.forwarding_service.wtf_crash", false);
diff --git a/telephony/java/android/telephony/NetworkService.java b/telephony/java/android/telephony/NetworkService.java
index 4bca404..6c45cc4 100644
--- a/telephony/java/android/telephony/NetworkService.java
+++ b/telephony/java/android/telephony/NetworkService.java
@@ -16,6 +16,7 @@
package android.telephony;
+import android.annotation.NonNull;
import android.annotation.SystemApi;
import android.app.Service;
import android.content.Intent;
@@ -112,13 +113,13 @@
mSlotId, 0, null).sendToTarget();
}
- private void registerForStateChanged(INetworkServiceCallback callback) {
+ private void registerForStateChanged(@NonNull INetworkServiceCallback callback) {
synchronized (mNetworkRegistrationStateChangedCallbacks) {
mNetworkRegistrationStateChangedCallbacks.add(callback);
}
}
- private void unregisterForStateChanged(INetworkServiceCallback callback) {
+ private void unregisterForStateChanged(@NonNull INetworkServiceCallback callback) {
synchronized (mNetworkRegistrationStateChangedCallbacks) {
mNetworkRegistrationStateChangedCallbacks.remove(callback);
}
diff --git a/telephony/java/android/telephony/SubscriptionManager.java b/telephony/java/android/telephony/SubscriptionManager.java
index 869cf1c..dfe36ef 100644
--- a/telephony/java/android/telephony/SubscriptionManager.java
+++ b/telephony/java/android/telephony/SubscriptionManager.java
@@ -2577,8 +2577,14 @@
@RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE)
public void setPreferredDataSubscriptionId(int subId) {
if (VDBG) logd("[setPreferredDataSubscriptionId]+ subId:" + subId);
- setSubscriptionPropertyHelper(DEFAULT_SUBSCRIPTION_ID, "setPreferredDataSubscriptionId",
- (iSub)-> iSub.setPreferredDataSubscriptionId(subId));
+ try {
+ ISub iSub = ISub.Stub.asInterface(ServiceManager.getService("isub"));
+ if (iSub != null) {
+ iSub.setPreferredDataSubscriptionId(subId);
+ }
+ } catch (RemoteException ex) {
+ // ignore it
+ }
}
/**
diff --git a/telephony/java/android/telephony/TelephonyManager.java b/telephony/java/android/telephony/TelephonyManager.java
index dfdec4d..a1fb090 100644
--- a/telephony/java/android/telephony/TelephonyManager.java
+++ b/telephony/java/android/telephony/TelephonyManager.java
@@ -72,6 +72,7 @@
import android.telephony.ims.stub.ImsRegistrationImplBase;
import android.text.TextUtils;
import android.util.Log;
+import android.util.Pair;
import com.android.ims.internal.IImsServiceFeatureCallback;
import com.android.internal.annotations.VisibleForTesting;
@@ -3264,6 +3265,35 @@
}
}
+ /**
+ * Get the mapping from logical slots to physical slots. The mapping represent by a pair list.
+ * The key of the piar is the logical slot id and the value of the pair is the physical
+ * slots id mapped to this logical slot id.
+ *
+ * @return an pair list indicates the mapping from logical slots to physical slots. The size of
+ * the list should be {@link #getPhoneCount()} if success, otherwise return an empty list.
+ *
+ * @hide
+ */
+ @SystemApi
+ @RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE)
+ @NonNull
+ public List<Pair<Integer, Integer>> getLogicalToPhysicalSlotMapping() {
+ List<Pair<Integer, Integer>> slotMapping = new ArrayList<>();
+ try {
+ ITelephony telephony = getITelephony();
+ if (telephony != null) {
+ int[] slotMappingArray = telephony.getSlotsMapping();
+ for (int i = 0; i < slotMappingArray.length; i++) {
+ slotMapping.add(new Pair(i, slotMappingArray[i]));
+ }
+ }
+ } catch (RemoteException e) {
+ Log.e(TAG, "getSlotsMapping RemoteException", e);
+ }
+ return slotMapping;
+ }
+
//
//
// Subscriber Info
@@ -10239,4 +10269,24 @@
Rlog.e(TAG, "switchMultiSimConfig RemoteException", ex);
}
}
+
+ /**
+ * Get whether reboot is required or not after making changes to modem configurations.
+ * @Return {@code True} if reboot is required after making changes to modem configurations,
+ * otherwise return {@code False}.
+ *
+ * @hide
+ */
+ @RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE)
+ public boolean isRebootRequiredForModemConfigChange() {
+ try {
+ ITelephony service = getITelephony();
+ if (service != null) {
+ return service.isRebootRequiredForModemConfigChange();
+ }
+ } catch (RemoteException e) {
+ Log.e(TAG, "isRebootRequiredForModemConfigChange RemoteException", e);
+ }
+ return false;
+ }
}
diff --git a/telephony/java/android/telephony/data/DataService.java b/telephony/java/android/telephony/data/DataService.java
index 74d1e83..79572b9 100644
--- a/telephony/java/android/telephony/data/DataService.java
+++ b/telephony/java/android/telephony/data/DataService.java
@@ -157,7 +157,10 @@
@Nullable LinkProperties linkProperties,
@Nullable DataServiceCallback callback) {
// The default implementation is to return unsupported.
- callback.onSetupDataCallComplete(DataServiceCallback.RESULT_ERROR_UNSUPPORTED, null);
+ if (callback != null) {
+ callback.onSetupDataCallComplete(DataServiceCallback.RESULT_ERROR_UNSUPPORTED,
+ null);
+ }
}
/**
@@ -176,7 +179,9 @@
public void deactivateDataCall(int cid, @DeactivateDataReason int reason,
@Nullable DataServiceCallback callback) {
// The default implementation is to return unsupported.
- callback.onDeactivateDataCallComplete(DataServiceCallback.RESULT_ERROR_UNSUPPORTED);
+ if (callback != null) {
+ callback.onDeactivateDataCallComplete(DataServiceCallback.RESULT_ERROR_UNSUPPORTED);
+ }
}
/**
@@ -190,7 +195,10 @@
public void setInitialAttachApn(DataProfile dataProfile, boolean isRoaming,
@Nullable DataServiceCallback callback) {
// The default implementation is to return unsupported.
- callback.onSetInitialAttachApnComplete(DataServiceCallback.RESULT_ERROR_UNSUPPORTED);
+ if (callback != null) {
+ callback.onSetInitialAttachApnComplete(
+ DataServiceCallback.RESULT_ERROR_UNSUPPORTED);
+ }
}
/**
@@ -206,7 +214,9 @@
public void setDataProfile(List<DataProfile> dps, boolean isRoaming,
@Nullable DataServiceCallback callback) {
// The default implementation is to return unsupported.
- callback.onSetDataProfileComplete(DataServiceCallback.RESULT_ERROR_UNSUPPORTED);
+ if (callback != null) {
+ callback.onSetDataProfileComplete(DataServiceCallback.RESULT_ERROR_UNSUPPORTED);
+ }
}
/**
diff --git a/telephony/java/android/telephony/euicc/EuiccManager.java b/telephony/java/android/telephony/euicc/EuiccManager.java
index bca088e..b2f5802 100644
--- a/telephony/java/android/telephony/euicc/EuiccManager.java
+++ b/telephony/java/android/telephony/euicc/EuiccManager.java
@@ -464,7 +464,7 @@
return null;
}
try {
- return getIEuiccController().getEid(mCardId);
+ return getIEuiccController().getEid(mCardId, mContext.getOpPackageName());
} catch (RemoteException e) {
throw e.rethrowFromSystemServer();
}
@@ -502,6 +502,15 @@
* Without the former, an {@link #EMBEDDED_SUBSCRIPTION_RESULT_RESOLVABLE_ERROR} will be
* returned in the callback intent to prompt the user to accept the download.
*
+ * <p>On a multi-active SIM device, requires the
+ * {@code android.Manifest.permission#WRITE_EMBEDDED_SUBSCRIPTIONS} permission, or a calling app
+ * only if the targeted eUICC does not currently have an active subscription or the calling app
+ * is authorized to manage the active subscription on the target eUICC, and the calling app is
+ * authorized to manage any active subscription on any SIM. Without it, an
+ * {@link #EMBEDDED_SUBSCRIPTION_RESULT_RESOLVABLE_ERROR} will be returned in the callback
+ * intent to prompt the user to accept the download. The caller should also be authorized to
+ * manage the subscription to be downloaded.
+ *
* @param subscription the subscription to download.
* @param switchAfterDownload if true, the profile will be activated upon successful download.
* @param callbackIntent a PendingIntent to launch when the operation completes.
@@ -704,9 +713,21 @@
* an {@link #EMBEDDED_SUBSCRIPTION_RESULT_RESOLVABLE_ERROR} will be returned in the callback
* intent to prompt the user to accept the download.
*
+ * <p>On a multi-active SIM device, requires the
+ * {@code android.Manifest.permission#WRITE_EMBEDDED_SUBSCRIPTIONS} permission, or a calling app
+ * only if the targeted eUICC does not currently have an active subscription or the calling app
+ * is authorized to manage the active subscription on the target eUICC, and the calling app is
+ * authorized to manage any active subscription on any SIM. Without it, an
+ * {@link #EMBEDDED_SUBSCRIPTION_RESULT_RESOLVABLE_ERROR} will be returned in the callback
+ * intent to prompt the user to accept the download. The caller should also be authorized to
+ * manage the subscription to be enabled.
+ *
* @param subscriptionId the ID of the subscription to enable. May be
* {@link android.telephony.SubscriptionManager#INVALID_SUBSCRIPTION_ID} to deactivate the
- * current profile without activating another profile to replace it.
+ * current profile without activating another profile to replace it. If it's a disable
+ * operation, requires the {@code android.Manifest.permission#WRITE_EMBEDDED_SUBSCRIPTIONS}
+ * permission, or the calling app must be authorized to manage the active subscription on
+ * the target eUICC.
* @param callbackIntent a PendingIntent to launch when the operation completes.
*/
@RequiresPermission(Manifest.permission.WRITE_EMBEDDED_SUBSCRIPTIONS)
diff --git a/telephony/java/com/android/internal/telephony/ISub.aidl b/telephony/java/com/android/internal/telephony/ISub.aidl
index a49d2d9..6ce9de4 100755
--- a/telephony/java/com/android/internal/telephony/ISub.aidl
+++ b/telephony/java/com/android/internal/telephony/ISub.aidl
@@ -220,7 +220,7 @@
* @hide
*
*/
- int setPreferredDataSubscriptionId(int subId);
+ void setPreferredDataSubscriptionId(int subId);
/**
* Get which subscription is preferred for cellular data.
diff --git a/telephony/java/com/android/internal/telephony/ITelephony.aidl b/telephony/java/com/android/internal/telephony/ITelephony.aidl
index 927c676..762d886 100644
--- a/telephony/java/com/android/internal/telephony/ITelephony.aidl
+++ b/telephony/java/com/android/internal/telephony/ITelephony.aidl
@@ -1848,4 +1848,14 @@
* @hide
*/
int getNumOfActiveSims();
+
+ /**
+ * Get if reboot is required upon altering modems configurations
+ */
+ boolean isRebootRequiredForModemConfigChange();
+
+ /**
+ * Get the mapping from logical slots to physical slots.
+ */
+ int[] getSlotsMapping();
}
diff --git a/telephony/java/com/android/internal/telephony/TelephonyProperties.java b/telephony/java/com/android/internal/telephony/TelephonyProperties.java
index 6567ea7..603c4c2 100644
--- a/telephony/java/com/android/internal/telephony/TelephonyProperties.java
+++ b/telephony/java/com/android/internal/telephony/TelephonyProperties.java
@@ -194,6 +194,13 @@
*/
static final String PROPERTY_MULTI_SIM_CONFIG = "persist.radio.multisim.config";
+ /**
+ * Property to indicate if reboot is required when changing modems configurations
+ * Type: String(true, false) default is false; most devices don't need reboot
+ */
+ String PROPERTY_REBOOT_REQUIRED_ON_MODEM_CHANGE =
+ "persist.radio.reboot_on_modem_change";
+
/**
* Property to store default subscription.
*/
diff --git a/telephony/java/com/android/internal/telephony/euicc/IEuiccController.aidl b/telephony/java/com/android/internal/telephony/euicc/IEuiccController.aidl
index 14a36c8..2016915 100644
--- a/telephony/java/com/android/internal/telephony/euicc/IEuiccController.aidl
+++ b/telephony/java/com/android/internal/telephony/euicc/IEuiccController.aidl
@@ -31,7 +31,7 @@
String callingPackage, in PendingIntent callbackIntent);
oneway void getDefaultDownloadableSubscriptionList(int cardId,
String callingPackage, in PendingIntent callbackIntent);
- String getEid(int cardId);
+ String getEid(int cardId, String callingPackage);
int getOtaStatus(int cardId);
oneway void downloadSubscription(int cardId, in DownloadableSubscription subscription,
boolean switchAfterDownload, String callingPackage, in Bundle resolvedBundle,
diff --git a/tests/RollbackTest/Android.bp b/tests/RollbackTest/Android.bp
new file mode 100644
index 0000000..3d57d56
--- /dev/null
+++ b/tests/RollbackTest/Android.bp
@@ -0,0 +1,64 @@
+// Copyright (C) 2018 The Android Open Source Project
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+android_app {
+ name: "RollbackTestAppAv1",
+ manifest: "TestApp/Av1.xml",
+ sdk_version: "current",
+ srcs: ["TestApp/src/**/*.java"],
+}
+
+android_app {
+ name: "RollbackTestAppAv2",
+ manifest: "TestApp/Av2.xml",
+ sdk_version: "current",
+ srcs: ["TestApp/src/**/*.java"],
+}
+
+android_app {
+ name: "RollbackTestAppACrashingV2",
+ manifest: "TestApp/ACrashingV2.xml",
+ sdk_version: "current",
+ srcs: ["TestApp/src/**/*.java"],
+}
+
+android_app {
+ name: "RollbackTestAppBv1",
+ manifest: "TestApp/Bv1.xml",
+ sdk_version: "current",
+ srcs: ["TestApp/src/**/*.java"],
+}
+
+android_app {
+ name: "RollbackTestAppBv2",
+ manifest: "TestApp/Bv2.xml",
+ sdk_version: "current",
+ srcs: ["TestApp/src/**/*.java"],
+}
+
+android_test {
+ name: "RollbackTest",
+ srcs: ["src/**/*.java"],
+ static_libs: ["android-support-test"],
+ test_suites: ["general-tests"],
+ java_resources: [
+ ":RollbackTestAppAv1",
+ ":RollbackTestAppAv2",
+ ":RollbackTestAppACrashingV2",
+ ":RollbackTestAppBv1",
+ ":RollbackTestAppBv2",
+ ],
+ test_config: "RollbackTest.xml",
+ sdk_version: "system_current",
+}
diff --git a/tests/RollbackTest/Android.mk b/tests/RollbackTest/Android.mk
deleted file mode 100644
index 780bb24..0000000
--- a/tests/RollbackTest/Android.mk
+++ /dev/null
@@ -1,94 +0,0 @@
-# Copyright (C) 2018 The Android Open Source Project
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-LOCAL_PATH:= $(call my-dir)
-
-# RollbackTestAppAv1.apk
-include $(CLEAR_VARS)
-LOCAL_MODULE_TAGS := optional
-LOCAL_MODULE_PATH := $(TARGET_OUT_DATA_APPS)
-LOCAL_SDK_VERSION := current
-LOCAL_SRC_FILES := $(call all-java-files-under, TestApp/src)
-LOCAL_MANIFEST_FILE := TestApp/Av1.xml
-LOCAL_PACKAGE_NAME := RollbackTestAppAv1
-include $(BUILD_PACKAGE)
-ROLLBACK_TEST_APP_AV1 := $(LOCAL_INSTALLED_MODULE)
-
-# RollbackTestAppAv2.apk
-include $(CLEAR_VARS)
-LOCAL_MODULE_TAGS := optional
-LOCAL_MODULE_PATH := $(TARGET_OUT_DATA_APPS)
-LOCAL_SDK_VERSION := current
-LOCAL_SRC_FILES := $(call all-java-files-under, TestApp/src)
-LOCAL_MANIFEST_FILE := TestApp/Av2.xml
-LOCAL_PACKAGE_NAME := RollbackTestAppAv2
-include $(BUILD_PACKAGE)
-ROLLBACK_TEST_APP_AV2 := $(LOCAL_INSTALLED_MODULE)
-
-# RollbackTestAppACrashingV2.apk
-include $(CLEAR_VARS)
-LOCAL_MODULE_TAGS := optional
-LOCAL_MODULE_PATH := $(TARGET_OUT_DATA_APPS)
-LOCAL_SDK_VERSION := current
-LOCAL_SRC_FILES := $(call all-java-files-under, TestApp/src)
-LOCAL_MANIFEST_FILE := TestApp/ACrashingV2.xml
-LOCAL_PACKAGE_NAME := RollbackTestAppACrashingV2
-include $(BUILD_PACKAGE)
-ROLLBACK_TEST_APP_A_CRASHING_V2 := $(LOCAL_INSTALLED_MODULE)
-
-# RollbackTestAppBv1.apk
-include $(CLEAR_VARS)
-LOCAL_MODULE_TAGS := optional
-LOCAL_MODULE_PATH := $(TARGET_OUT_DATA_APPS)
-LOCAL_SDK_VERSION := current
-LOCAL_SRC_FILES := $(call all-java-files-under, TestApp/src)
-LOCAL_MANIFEST_FILE := TestApp/Bv1.xml
-LOCAL_PACKAGE_NAME := RollbackTestAppBv1
-include $(BUILD_PACKAGE)
-ROLLBACK_TEST_APP_BV1 := $(LOCAL_INSTALLED_MODULE)
-
-# RollbackTestAppBv2.apk
-include $(CLEAR_VARS)
-LOCAL_MODULE_TAGS := optional
-LOCAL_MODULE_PATH := $(TARGET_OUT_DATA_APPS)
-LOCAL_SDK_VERSION := current
-LOCAL_SRC_FILES := $(call all-java-files-under, TestApp/src)
-LOCAL_MANIFEST_FILE := TestApp/Bv2.xml
-LOCAL_PACKAGE_NAME := RollbackTestAppBv2
-include $(BUILD_PACKAGE)
-ROLLBACK_TEST_APP_BV2 := $(LOCAL_INSTALLED_MODULE)
-
-# RollbackTest
-include $(CLEAR_VARS)
-LOCAL_SRC_FILES := $(call all-java-files-under, src)
-LOCAL_PACKAGE_NAME := RollbackTest
-LOCAL_MODULE_TAGS := tests
-LOCAL_STATIC_JAVA_LIBRARIES := android-support-test
-LOCAL_COMPATIBILITY_SUITE := general-tests
-LOCAL_JAVA_RESOURCE_FILES := \
- $(ROLLBACK_TEST_APP_AV1) \
- $(ROLLBACK_TEST_APP_AV2) \
- $(ROLLBACK_TEST_APP_A_CRASHING_V2) \
- $(ROLLBACK_TEST_APP_BV1) \
- $(ROLLBACK_TEST_APP_BV2)
-LOCAL_SDK_VERSION := system_current
-LOCAL_TEST_CONFIG := RollbackTest.xml
-include $(BUILD_PACKAGE)
-
-# Clean up local variables
-ROLLBACK_TEST_APP_AV1 :=
-ROLLBACK_TEST_APP_AV2 :=
-ROLLBACK_TEST_APP_A_CRASHING_V2 :=
-ROLLBACK_TEST_APP_BV1 :=
-ROLLBACK_TEST_APP_BV2 :=
diff --git a/tests/net/java/com/android/server/ConnectivityServiceTest.java b/tests/net/java/com/android/server/ConnectivityServiceTest.java
index 3127d74..50468cb 100644
--- a/tests/net/java/com/android/server/ConnectivityServiceTest.java
+++ b/tests/net/java/com/android/server/ConnectivityServiceTest.java
@@ -922,6 +922,7 @@
mNetworkCapabilities.set(mMockNetworkAgent.getNetworkCapabilities());
mConnected = true;
mConfig = new VpnConfig();
+ mConfig.isMetered = false;
}
@Override
diff --git a/tests/net/java/com/android/server/connectivity/VpnTest.java b/tests/net/java/com/android/server/connectivity/VpnTest.java
index 5b17224..46de3d0 100644
--- a/tests/net/java/com/android/server/connectivity/VpnTest.java
+++ b/tests/net/java/com/android/server/connectivity/VpnTest.java
@@ -168,6 +168,8 @@
ApplicationInfo applicationInfo = new ApplicationInfo();
applicationInfo.targetSdkVersion = VERSION_CODES.CUR_DEVELOPMENT;
when(mContext.getApplicationInfo()).thenReturn(applicationInfo);
+ when(mPackageManager.getApplicationInfoAsUser(anyString(), anyInt(), anyInt()))
+ .thenReturn(applicationInfo);
doNothing().when(mNetService).registerObserver(any());
}
@@ -544,23 +546,28 @@
final Network wifi = new Network(2);
final Map<Network, NetworkCapabilities> networks = new HashMap<>();
- networks.put(mobile, new NetworkCapabilities()
- .addTransportType(TRANSPORT_CELLULAR)
- .addCapability(NET_CAPABILITY_INTERNET)
- .addCapability(NET_CAPABILITY_NOT_METERED)
- .addCapability(NET_CAPABILITY_NOT_CONGESTED)
- .setLinkDownstreamBandwidthKbps(10));
- networks.put(wifi, new NetworkCapabilities()
- .addTransportType(TRANSPORT_WIFI)
- .addCapability(NET_CAPABILITY_INTERNET)
- .addCapability(NET_CAPABILITY_NOT_ROAMING)
- .addCapability(NET_CAPABILITY_NOT_CONGESTED)
- .setLinkUpstreamBandwidthKbps(20));
+ networks.put(
+ mobile,
+ new NetworkCapabilities()
+ .addTransportType(TRANSPORT_CELLULAR)
+ .addCapability(NET_CAPABILITY_INTERNET)
+ .addCapability(NET_CAPABILITY_NOT_CONGESTED)
+ .setLinkDownstreamBandwidthKbps(10));
+ networks.put(
+ wifi,
+ new NetworkCapabilities()
+ .addTransportType(TRANSPORT_WIFI)
+ .addCapability(NET_CAPABILITY_INTERNET)
+ .addCapability(NET_CAPABILITY_NOT_METERED)
+ .addCapability(NET_CAPABILITY_NOT_ROAMING)
+ .addCapability(NET_CAPABILITY_NOT_CONGESTED)
+ .setLinkUpstreamBandwidthKbps(20));
setMockedNetworks(networks);
final NetworkCapabilities caps = new NetworkCapabilities();
- Vpn.updateCapabilities(mConnectivityManager, new Network[] { }, caps);
+ Vpn.updateCapabilities(
+ mConnectivityManager, new Network[] {}, caps, false /* isAlwaysMetered */);
assertTrue(caps.hasTransport(TRANSPORT_VPN));
assertFalse(caps.hasTransport(TRANSPORT_CELLULAR));
assertFalse(caps.hasTransport(TRANSPORT_WIFI));
@@ -570,17 +577,33 @@
assertTrue(caps.hasCapability(NET_CAPABILITY_NOT_ROAMING));
assertTrue(caps.hasCapability(NET_CAPABILITY_NOT_CONGESTED));
- Vpn.updateCapabilities(mConnectivityManager, new Network[] { mobile }, caps);
+ Vpn.updateCapabilities(
+ mConnectivityManager,
+ new Network[] {mobile},
+ caps,
+ false /* isAlwaysMetered */);
assertTrue(caps.hasTransport(TRANSPORT_VPN));
assertTrue(caps.hasTransport(TRANSPORT_CELLULAR));
assertFalse(caps.hasTransport(TRANSPORT_WIFI));
assertEquals(10, caps.getLinkDownstreamBandwidthKbps());
assertEquals(LINK_BANDWIDTH_UNSPECIFIED, caps.getLinkUpstreamBandwidthKbps());
- assertTrue(caps.hasCapability(NET_CAPABILITY_NOT_METERED));
+ assertFalse(caps.hasCapability(NET_CAPABILITY_NOT_METERED));
assertFalse(caps.hasCapability(NET_CAPABILITY_NOT_ROAMING));
assertTrue(caps.hasCapability(NET_CAPABILITY_NOT_CONGESTED));
- Vpn.updateCapabilities(mConnectivityManager, new Network[] { wifi }, caps);
+ Vpn.updateCapabilities(
+ mConnectivityManager, new Network[] {wifi}, caps, false /* isAlwaysMetered */);
+ assertTrue(caps.hasTransport(TRANSPORT_VPN));
+ assertFalse(caps.hasTransport(TRANSPORT_CELLULAR));
+ assertTrue(caps.hasTransport(TRANSPORT_WIFI));
+ assertEquals(LINK_BANDWIDTH_UNSPECIFIED, caps.getLinkDownstreamBandwidthKbps());
+ assertEquals(20, caps.getLinkUpstreamBandwidthKbps());
+ assertTrue(caps.hasCapability(NET_CAPABILITY_NOT_METERED));
+ assertTrue(caps.hasCapability(NET_CAPABILITY_NOT_ROAMING));
+ assertTrue(caps.hasCapability(NET_CAPABILITY_NOT_CONGESTED));
+
+ Vpn.updateCapabilities(
+ mConnectivityManager, new Network[] {wifi}, caps, true /* isAlwaysMetered */);
assertTrue(caps.hasTransport(TRANSPORT_VPN));
assertFalse(caps.hasTransport(TRANSPORT_CELLULAR));
assertTrue(caps.hasTransport(TRANSPORT_WIFI));
@@ -590,7 +613,11 @@
assertTrue(caps.hasCapability(NET_CAPABILITY_NOT_ROAMING));
assertTrue(caps.hasCapability(NET_CAPABILITY_NOT_CONGESTED));
- Vpn.updateCapabilities(mConnectivityManager, new Network[] { mobile, wifi }, caps);
+ Vpn.updateCapabilities(
+ mConnectivityManager,
+ new Network[] {mobile, wifi},
+ caps,
+ false /* isAlwaysMetered */);
assertTrue(caps.hasTransport(TRANSPORT_VPN));
assertTrue(caps.hasTransport(TRANSPORT_CELLULAR));
assertTrue(caps.hasTransport(TRANSPORT_WIFI));
diff --git a/tests/net/java/com/android/server/connectivity/tethering/EntitlementManagerTest.java b/tests/net/java/com/android/server/connectivity/tethering/EntitlementManagerTest.java
index 0f72229..ec286759 100644
--- a/tests/net/java/com/android/server/connectivity/tethering/EntitlementManagerTest.java
+++ b/tests/net/java/com/android/server/connectivity/tethering/EntitlementManagerTest.java
@@ -16,8 +16,16 @@
package com.android.server.connectivity.tethering;
+import static android.net.ConnectivityManager.TETHERING_USB;
+import static android.net.ConnectivityManager.TETHERING_WIFI;
+import static android.net.ConnectivityManager.TETHER_ERROR_ENTITLEMENT_UNKONWN;
+import static android.net.ConnectivityManager.TETHER_ERROR_NO_ERROR;
+import static android.net.ConnectivityManager.TETHER_ERROR_PROVISION_FAILED;
+
+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 static org.mockito.Matchers.anyBoolean;
import static org.mockito.Matchers.anyString;
import static org.mockito.Matchers.eq;
@@ -27,12 +35,22 @@
import android.content.Context;
import android.content.res.Resources;
import android.net.util.SharedLog;
+import android.os.Bundle;
+import android.os.Message;
import android.os.PersistableBundle;
+import android.os.ResultReceiver;
+import android.os.test.TestLooper;
+import android.provider.Settings;
import android.support.test.filters.SmallTest;
import android.support.test.runner.AndroidJUnit4;
import android.telephony.CarrierConfigManager;
+import android.test.mock.MockContentResolver;
import com.android.internal.R;
+import com.android.internal.util.State;
+import com.android.internal.util.StateMachine;
+import com.android.internal.util.test.BroadcastInterceptingContext;
+import com.android.internal.util.test.FakeSettingsProvider;
import com.android.server.connectivity.MockableSystemProperties;
import org.junit.After;
@@ -42,6 +60,10 @@
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
+import java.util.ArrayList;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.TimeUnit;
+
@RunWith(AndroidJUnit4.class)
@SmallTest
public final class EntitlementManagerTest {
@@ -51,7 +73,6 @@
@Mock private CarrierConfigManager mCarrierConfigManager;
@Mock private Context mContext;
- @Mock private ContentResolver mContent;
@Mock private MockableSystemProperties mSystemProperties;
@Mock private Resources mResources;
@Mock private SharedLog mLog;
@@ -59,15 +80,49 @@
// Like so many Android system APIs, these cannot be mocked because it is marked final.
// We have to use the real versions.
private final PersistableBundle mCarrierConfig = new PersistableBundle();
+ private final TestLooper mLooper = new TestLooper();
+ private Context mMockContext;
+ private MockContentResolver mContentResolver;
- private EntitlementManager mEnMgr;
+ private TestStateMachine mSM;
+ private WrappedEntitlementManager mEnMgr;
+
+ private class MockContext extends BroadcastInterceptingContext {
+ MockContext(Context base) {
+ super(base);
+ }
+
+ @Override
+ public Resources getResources() {
+ return mResources;
+ }
+
+ @Override
+ public ContentResolver getContentResolver() {
+ return mContentResolver;
+ }
+ }
+
+ public class WrappedEntitlementManager extends EntitlementManager {
+ public int fakeEntitlementResult = TETHER_ERROR_ENTITLEMENT_UNKONWN;
+ public boolean everRunUiEntitlement = false;
+
+ public WrappedEntitlementManager(Context ctx, StateMachine target,
+ SharedLog log, MockableSystemProperties systemProperties) {
+ super(ctx, target, log, systemProperties);
+ }
+
+ @Override
+ protected void runUiTetherProvisioning(int type, ResultReceiver receiver) {
+ everRunUiEntitlement = true;
+ receiver.send(fakeEntitlementResult, null);
+ }
+ }
@Before
public void setUp() {
MockitoAnnotations.initMocks(this);
- when(mContext.getResources()).thenReturn(mResources);
- when(mContext.getContentResolver()).thenReturn(mContent);
when(mResources.getStringArray(R.array.config_tether_dhcp_range))
.thenReturn(new String[0]);
when(mResources.getStringArray(R.array.config_tether_usb_regexs))
@@ -80,12 +135,21 @@
.thenReturn(new int[0]);
when(mLog.forSubComponent(anyString())).thenReturn(mLog);
- mEnMgr = new EntitlementManager(mContext, mLog, mSystemProperties);
- mEnMgr.updateConfiguration(new TetheringConfiguration(mContext, mLog));
+ mContentResolver = new MockContentResolver();
+ mContentResolver.addProvider(Settings.AUTHORITY, new FakeSettingsProvider());
+ mMockContext = new MockContext(mContext);
+ mSM = new TestStateMachine();
+ mEnMgr = new WrappedEntitlementManager(mMockContext, mSM, mLog, mSystemProperties);
+ mEnMgr.updateConfiguration(new TetheringConfiguration(mMockContext, mLog));
}
@After
- public void tearDown() throws Exception {}
+ public void tearDown() throws Exception {
+ if (mSM != null) {
+ mSM.quit();
+ mSM = null;
+ }
+ }
private void setupForRequiredProvisioning() {
// Produce some acceptable looking provision app setting if requested.
@@ -104,7 +168,7 @@
@Test
public void canRequireProvisioning() {
setupForRequiredProvisioning();
- mEnMgr.updateConfiguration(new TetheringConfiguration(mContext, mLog));
+ mEnMgr.updateConfiguration(new TetheringConfiguration(mMockContext, mLog));
assertTrue(mEnMgr.isTetherProvisioningRequired());
}
@@ -113,7 +177,7 @@
setupForRequiredProvisioning();
when(mContext.getSystemService(Context.CARRIER_CONFIG_SERVICE))
.thenReturn(null);
- mEnMgr.updateConfiguration(new TetheringConfiguration(mContext, mLog));
+ mEnMgr.updateConfiguration(new TetheringConfiguration(mMockContext, mLog));
// Couldn't get the CarrierConfigManager, but still had a declared provisioning app.
// Therefore provisioning still be required.
assertTrue(mEnMgr.isTetherProvisioningRequired());
@@ -123,7 +187,7 @@
public void toleratesCarrierConfigMissing() {
setupForRequiredProvisioning();
when(mCarrierConfigManager.getConfig()).thenReturn(null);
- mEnMgr.updateConfiguration(new TetheringConfiguration(mContext, mLog));
+ mEnMgr.updateConfiguration(new TetheringConfiguration(mMockContext, mLog));
// We still have a provisioning app configured, so still require provisioning.
assertTrue(mEnMgr.isTetherProvisioningRequired());
}
@@ -133,12 +197,143 @@
setupForRequiredProvisioning();
when(mResources.getStringArray(R.array.config_mobile_hotspot_provision_app))
.thenReturn(null);
- mEnMgr.updateConfiguration(new TetheringConfiguration(mContext, mLog));
+ mEnMgr.updateConfiguration(new TetheringConfiguration(mMockContext, mLog));
assertFalse(mEnMgr.isTetherProvisioningRequired());
when(mResources.getStringArray(R.array.config_mobile_hotspot_provision_app))
.thenReturn(new String[] {"malformedApp"});
- mEnMgr.updateConfiguration(new TetheringConfiguration(mContext, mLog));
+ mEnMgr.updateConfiguration(new TetheringConfiguration(mMockContext, mLog));
assertFalse(mEnMgr.isTetherProvisioningRequired());
}
+ @Test
+ public void testGetLastEntitlementCacheValue() throws Exception {
+ final CountDownLatch mCallbacklatch = new CountDownLatch(1);
+ // 1. Entitlement check is not required.
+ mEnMgr.fakeEntitlementResult = TETHER_ERROR_NO_ERROR;
+ mEnMgr.everRunUiEntitlement = false;
+ ResultReceiver receiver = new ResultReceiver(null) {
+ @Override
+ protected void onReceiveResult(int resultCode, Bundle resultData) {
+ assertEquals(TETHER_ERROR_NO_ERROR, resultCode);
+ mCallbacklatch.countDown();
+ }
+ };
+ mEnMgr.getLatestTetheringEntitlementValue(TETHERING_WIFI, receiver, true);
+ callbackTimeoutHelper(mCallbacklatch);
+ assertFalse(mEnMgr.everRunUiEntitlement);
+
+ setupForRequiredProvisioning();
+ mEnMgr.updateConfiguration(new TetheringConfiguration(mMockContext, mLog));
+ // 2. No cache value and don't need to run entitlement check.
+ mEnMgr.everRunUiEntitlement = false;
+ receiver = new ResultReceiver(null) {
+ @Override
+ protected void onReceiveResult(int resultCode, Bundle resultData) {
+ assertEquals(TETHER_ERROR_ENTITLEMENT_UNKONWN, resultCode);
+ mCallbacklatch.countDown();
+ }
+ };
+ mEnMgr.getLatestTetheringEntitlementValue(TETHERING_WIFI, receiver, false);
+ callbackTimeoutHelper(mCallbacklatch);
+ assertFalse(mEnMgr.everRunUiEntitlement);
+ // 3. No cache value and ui entitlement check is needed.
+ mEnMgr.fakeEntitlementResult = TETHER_ERROR_PROVISION_FAILED;
+ mEnMgr.everRunUiEntitlement = false;
+ receiver = new ResultReceiver(null) {
+ @Override
+ protected void onReceiveResult(int resultCode, Bundle resultData) {
+ assertEquals(TETHER_ERROR_PROVISION_FAILED, resultCode);
+ mCallbacklatch.countDown();
+ }
+ };
+ mEnMgr.getLatestTetheringEntitlementValue(TETHERING_WIFI, receiver, true);
+ mLooper.dispatchAll();
+ callbackTimeoutHelper(mCallbacklatch);
+ assertTrue(mEnMgr.everRunUiEntitlement);
+ // 4. Cache value is TETHER_ERROR_PROVISION_FAILED and don't need to run entitlement check.
+ mEnMgr.fakeEntitlementResult = TETHER_ERROR_NO_ERROR;
+ mEnMgr.everRunUiEntitlement = false;
+ receiver = new ResultReceiver(null) {
+ @Override
+ protected void onReceiveResult(int resultCode, Bundle resultData) {
+ assertEquals(TETHER_ERROR_PROVISION_FAILED, resultCode);
+ mCallbacklatch.countDown();
+ }
+ };
+ mEnMgr.getLatestTetheringEntitlementValue(TETHERING_WIFI, receiver, false);
+ callbackTimeoutHelper(mCallbacklatch);
+ assertFalse(mEnMgr.everRunUiEntitlement);
+ // 5. Cache value is TETHER_ERROR_PROVISION_FAILED and ui entitlement check is needed.
+ mEnMgr.fakeEntitlementResult = TETHER_ERROR_NO_ERROR;
+ mEnMgr.everRunUiEntitlement = false;
+ receiver = new ResultReceiver(null) {
+ @Override
+ protected void onReceiveResult(int resultCode, Bundle resultData) {
+ assertEquals(TETHER_ERROR_NO_ERROR, resultCode);
+ mCallbacklatch.countDown();
+ }
+ };
+ mEnMgr.getLatestTetheringEntitlementValue(TETHERING_WIFI, receiver, true);
+ mLooper.dispatchAll();
+ callbackTimeoutHelper(mCallbacklatch);
+ assertTrue(mEnMgr.everRunUiEntitlement);
+ // 6. Cache value is TETHER_ERROR_NO_ERROR.
+ mEnMgr.fakeEntitlementResult = TETHER_ERROR_NO_ERROR;
+ mEnMgr.everRunUiEntitlement = false;
+ receiver = new ResultReceiver(null) {
+ @Override
+ protected void onReceiveResult(int resultCode, Bundle resultData) {
+ assertEquals(TETHER_ERROR_NO_ERROR, resultCode);
+ mCallbacklatch.countDown();
+ }
+ };
+ mEnMgr.getLatestTetheringEntitlementValue(TETHERING_WIFI, receiver, true);
+ callbackTimeoutHelper(mCallbacklatch);
+ assertFalse(mEnMgr.everRunUiEntitlement);
+ // 7. Test get value for other downstream type.
+ mEnMgr.everRunUiEntitlement = false;
+ receiver = new ResultReceiver(null) {
+ @Override
+ protected void onReceiveResult(int resultCode, Bundle resultData) {
+ assertEquals(TETHER_ERROR_ENTITLEMENT_UNKONWN, resultCode);
+ mCallbacklatch.countDown();
+ }
+ };
+ mEnMgr.getLatestTetheringEntitlementValue(TETHERING_USB, receiver, false);
+ callbackTimeoutHelper(mCallbacklatch);
+ assertFalse(mEnMgr.everRunUiEntitlement);
+ }
+
+ void callbackTimeoutHelper(final CountDownLatch latch) throws Exception {
+ if (!latch.await(1, TimeUnit.SECONDS)) {
+ fail("Timout, fail to recieve callback");
+ }
+ }
+ public class TestStateMachine extends StateMachine {
+ public final ArrayList<Message> messages = new ArrayList<>();
+ private final State mLoggingState =
+ new EntitlementManagerTest.TestStateMachine.LoggingState();
+
+ class LoggingState extends State {
+ @Override public void enter() {
+ messages.clear();
+ }
+
+ @Override public void exit() {
+ messages.clear();
+ }
+
+ @Override public boolean processMessage(Message msg) {
+ messages.add(msg);
+ return false;
+ }
+ }
+
+ public TestStateMachine() {
+ super("EntitlementManagerTest.TestStateMachine", mLooper.getLooper());
+ addState(mLoggingState);
+ setInitialState(mLoggingState);
+ super.start();
+ }
+ }
}
diff --git a/tools/aapt/AaptAssets.cpp b/tools/aapt/AaptAssets.cpp
index 3c3edda..672731c 100644
--- a/tools/aapt/AaptAssets.cpp
+++ b/tools/aapt/AaptAssets.cpp
@@ -301,6 +301,7 @@
break;
}
// This is not alphabetical, so we fall through to variant
+ [[fallthrough]];
case 5:
case 6:
case 7: